From f5a0721ec0d2ab40f6c5c2f35fb3bed5b814455c Mon Sep 17 00:00:00 2001 From: Phillip Stephens Date: Thu, 12 Jan 2023 14:46:08 -0800 Subject: [PATCH] Add RstlExtras Former-commit-id: b2a9c6a8f36a7a675f579e67c928b31a4dacacac --- asm/GuiSys/CGuiTextSupport.s | 12 +-- asm/Kyoto/Text/CImageInstruction.s | 2 +- asm/Kyoto/Text/CTextExecuteBuffer.s | 2 +- asm/Kyoto/Text/CTextParser.s | 6 +- asm/Kyoto/Text/CTextRenderBuffer.s | 2 +- asm/Kyoto/rstl/RstlExtras.s | 34 +++--- asm/Kyoto/rstl/rstl_strings.s | 9 +- asm/MetroidPrime/CAutoMapper.s | 6 +- asm/MetroidPrime/CFrontEndUI.s | 2 +- asm/MetroidPrime/CLogBookScreen.s | 2 +- asm/MetroidPrime/CPauseScreen.s | 4 +- asm/MetroidPrime/CSlideShow.s | 2 +- asm/MetroidPrime/CSplashScreen.s | 6 +- configure.py | 2 +- include/Kyoto/Animation/CSegId.hpp | 2 +- include/Kyoto/Basics/CCast.hpp | 4 + include/Kyoto/rstl/StringExtras.hpp | 12 --- include/rstl/StringExtras.hpp | 19 ++++ include/rstl/rc_ptr.hpp | 1 + include/rstl/string.hpp | 7 +- src/Kyoto/Animation/DolphinCVirtualBone.cpp | 2 +- src/Kyoto/rstl/RstlExtras.cpp | 112 ++++++++++++++++++++ 22 files changed, 187 insertions(+), 63 deletions(-) delete mode 100644 include/Kyoto/rstl/StringExtras.hpp create mode 100644 include/rstl/StringExtras.hpp create mode 100644 src/Kyoto/rstl/RstlExtras.cpp diff --git a/asm/GuiSys/CGuiTextSupport.s b/asm/GuiSys/CGuiTextSupport.s index dbcfce5f..738aa3a0 100644 --- a/asm/GuiSys/CGuiTextSupport.s +++ b/asm/GuiSys/CGuiTextSupport.s @@ -66,7 +66,7 @@ sub_802c7d4c: /* 802C7D50 002C4CB0 7C 08 02 A6 */ mflr r0 /* 802C7D54 002C4CB4 38 80 FF FF */ li r4, -1 /* 802C7D58 002C4CB8 90 01 00 14 */ stw r0, 0x14(r1) -/* 802C7D5C 002C4CBC 4B D6 0E A1 */ bl sub_80028bfc +/* 802C7D5C 002C4CBC 4B D6 0E A1 */ bl __dt__13CFontImageDefFv /* 802C7D60 002C4CC0 80 01 00 14 */ lwz r0, 0x14(r1) /* 802C7D64 002C4CC4 7C 08 03 A6 */ mtlr r0 /* 802C7D68 002C4CC8 38 21 00 10 */ addi r1, r1, 0x10 @@ -997,15 +997,15 @@ sub_802c89bc: /* 802C89C4 002C5924 28 03 00 00 */ cmplwi r3, 0 /* 802C89C8 002C5928 90 01 00 14 */ stw r0, 0x14(r1) /* 802C89CC 002C592C 41 82 00 08 */ beq lbl_802C89D4 -/* 802C89D0 002C5930 48 00 00 15 */ bl sub_802c89e4 +/* 802C89D0 002C5930 48 00 00 15 */ bl __ct__13CFontImageDefFRC13CFontImageDef lbl_802C89D4: /* 802C89D4 002C5934 80 01 00 14 */ lwz r0, 0x14(r1) /* 802C89D8 002C5938 7C 08 03 A6 */ mtlr r0 /* 802C89DC 002C593C 38 21 00 10 */ addi r1, r1, 0x10 /* 802C89E0 002C5940 4E 80 00 20 */ blr -.global sub_802c89e4 -sub_802c89e4: +.global __ct__13CFontImageDefFRC13CFontImageDef +__ct__13CFontImageDefFRC13CFontImageDef: /* 802C89E4 002C5944 94 21 FF E0 */ stwu r1, -0x20(r1) /* 802C89E8 002C5948 7C 08 02 A6 */ mflr r0 /* 802C89EC 002C594C 90 01 00 24 */ stw r0, 0x24(r1) @@ -1793,7 +1793,7 @@ CheckAndRebuildTextBuffer__15CGuiTextSupportFv: /* 802C9470 002C63D0 48 03 A0 55 */ bl AddColor__18CTextExecuteBufferF10EColorTypeRC10CTextColor /* 802C9474 002C63D4 80 9F 00 5C */ lwz r4, 0x5c(r31) /* 802C9478 002C63D8 38 60 00 00 */ li r3, 0 -/* 802C947C 002C63DC 38 AD A9 1A */ addi r5, r13, lbl_805A94DA@sda21 +/* 802C947C 002C63DC 38 AD A9 1A */ addi r5, r13, "mNull__Q24rstl66basic_string,Q24rstl17rmemory_allocator>"@sda21 /* 802C9480 002C63E0 90 61 00 50 */ stw r3, 0x50(r1) /* 802C9484 002C63E4 3C 04 00 01 */ addis r0, r4, 1 /* 802C9488 002C63E8 28 00 FF FF */ cmplwi r0, 0xffff @@ -2533,7 +2533,7 @@ __ct__15CGuiTextSupportFv: /* 802C9E44 002C6DA4 39 60 00 00 */ li r11, 0 /* 802C9E48 002C6DA8 C0 42 C3 E0 */ lfs f2, lbl_805AE100@sda21(r2) /* 802C9E4C 002C6DAC 90 01 00 44 */ stw r0, 0x44(r1) -/* 802C9E50 002C6DB0 38 0D A9 1A */ addi r0, r13, lbl_805A94DA@sda21 +/* 802C9E50 002C6DB0 38 0D A9 1A */ addi r0, r13, "mNull__Q24rstl66basic_string,Q24rstl17rmemory_allocator>"@sda21 /* 802C9E54 002C6DB4 C0 22 C4 08 */ lfs f1, lbl_805AE128@sda21(r2) /* 802C9E58 002C6DB8 93 E1 00 3C */ stw r31, 0x3c(r1) /* 802C9E5C 002C6DBC C0 02 C4 0C */ lfs f0, lbl_805AE12C@sda21(r2) diff --git a/asm/Kyoto/Text/CImageInstruction.s b/asm/Kyoto/Text/CImageInstruction.s index 13a71f6d..696b3df6 100644 --- a/asm/Kyoto/Text/CImageInstruction.s +++ b/asm/Kyoto/Text/CImageInstruction.s @@ -32,7 +32,7 @@ __dt__17CImageInstructionFv: /* 80359740 003566A0 38 04 F7 98 */ addi r0, r4, lbl_803EF798@l /* 80359744 003566A4 38 80 FF FF */ li r4, -1 /* 80359748 003566A8 90 1E 00 00 */ stw r0, 0(r30) -/* 8035974C 003566AC 4B CC F4 B1 */ bl sub_80028bfc +/* 8035974C 003566AC 4B CC F4 B1 */ bl __dt__13CFontImageDefFv /* 80359750 003566B0 28 1E 00 00 */ cmplwi r30, 0 /* 80359754 003566B4 41 82 00 10 */ beq lbl_80359764 /* 80359758 003566B8 3C 60 80 3E */ lis r3, __vt__12CInstruction@ha diff --git a/asm/Kyoto/Text/CTextExecuteBuffer.s b/asm/Kyoto/Text/CTextExecuteBuffer.s index 45a61b8b..a94d27e4 100644 --- a/asm/Kyoto/Text/CTextExecuteBuffer.s +++ b/asm/Kyoto/Text/CTextExecuteBuffer.s @@ -2137,7 +2137,7 @@ __ct__17CImageInstructionFRC13CFontImageDef: /* 8030392C 0030088C 38 03 F7 98 */ addi r0, r3, lbl_803EF798@l /* 80303930 00300890 38 7F 00 04 */ addi r3, r31, 4 /* 80303934 00300894 90 1F 00 00 */ stw r0, 0(r31) -/* 80303938 00300898 4B FC 50 AD */ bl sub_802c89e4 +/* 80303938 00300898 4B FC 50 AD */ bl __ct__13CFontImageDefFRC13CFontImageDef /* 8030393C 0030089C 80 01 00 14 */ lwz r0, 0x14(r1) /* 80303940 003008A0 7F E3 FB 78 */ mr r3, r31 /* 80303944 003008A4 83 E1 00 0C */ lwz r31, 0xc(r1) diff --git a/asm/Kyoto/Text/CTextParser.s b/asm/Kyoto/Text/CTextParser.s index dbe4789e..2c8d8b0c 100644 --- a/asm/Kyoto/Text/CTextParser.s +++ b/asm/Kyoto/Text/CTextParser.s @@ -305,16 +305,16 @@ lbl_80304658: /* 8030468C 003015EC 48 00 06 21 */ bl GetImage__11CTextParserFPCwi /* 80304690 003015F0 38 61 00 48 */ addi r3, r1, 0x48 /* 80304694 003015F4 38 81 00 2C */ addi r4, r1, 0x2c -/* 80304698 003015F8 4B FC 43 4D */ bl sub_802c89e4 +/* 80304698 003015F8 4B FC 43 4D */ bl __ct__13CFontImageDefFRC13CFontImageDef /* 8030469C 003015FC 38 61 00 2C */ addi r3, r1, 0x2c /* 803046A0 00301600 38 80 FF FF */ li r4, -1 -/* 803046A4 00301604 4B D2 45 59 */ bl sub_80028bfc +/* 803046A4 00301604 4B D2 45 59 */ bl __dt__13CFontImageDefFv /* 803046A8 00301608 7F A3 EB 78 */ mr r3, r29 /* 803046AC 0030160C 38 81 00 48 */ addi r4, r1, 0x48 /* 803046B0 00301610 4B FF EE FD */ bl AddImage__18CTextExecuteBufferFRC13CFontImageDef /* 803046B4 00301614 38 61 00 48 */ addi r3, r1, 0x48 /* 803046B8 00301618 38 80 FF FF */ li r4, -1 -/* 803046BC 0030161C 4B D2 45 41 */ bl sub_80028bfc +/* 803046BC 0030161C 4B D2 45 41 */ bl __dt__13CFontImageDefFv /* 803046C0 00301620 48 00 05 D0 */ b lbl_80304C90 lbl_803046C4: /* 803046C4 00301624 3C 80 80 3F */ lis r4, lbl_803ED718@ha diff --git a/asm/Kyoto/Text/CTextRenderBuffer.s b/asm/Kyoto/Text/CTextRenderBuffer.s index fd0e897e..497f60e2 100644 --- a/asm/Kyoto/Text/CTextRenderBuffer.s +++ b/asm/Kyoto/Text/CTextRenderBuffer.s @@ -1360,7 +1360,7 @@ sub_8035ae58: /* 8035AE60 00357DC0 28 03 00 00 */ cmplwi r3, 0 /* 8035AE64 00357DC4 90 01 00 14 */ stw r0, 0x14(r1) /* 8035AE68 00357DC8 41 82 00 08 */ beq lbl_8035AE70 -/* 8035AE6C 00357DCC 4B F6 DB 79 */ bl sub_802c89e4 +/* 8035AE6C 00357DCC 4B F6 DB 79 */ bl __ct__13CFontImageDefFRC13CFontImageDef lbl_8035AE70: /* 8035AE70 00357DD0 80 01 00 14 */ lwz r0, 0x14(r1) /* 8035AE74 00357DD4 7C 08 03 A6 */ mtlr r0 diff --git a/asm/Kyoto/rstl/RstlExtras.s b/asm/Kyoto/rstl/RstlExtras.s index f79c45ac..02d949fe 100644 --- a/asm/Kyoto/rstl/RstlExtras.s +++ b/asm/Kyoto/rstl/RstlExtras.s @@ -127,9 +127,9 @@ lbl_8033E58C: /* 8033E59C 0033B4FC 90 1D 00 0C */ stw r0, 0xc(r29) /* 8033E5A0 0033B500 48 00 00 18 */ b lbl_8033E5B8 lbl_8033E5A4: -/* 8033E5A4 0033B504 3C 80 80 3D */ lis r4, lbl_803D7A50@ha +/* 8033E5A4 0033B504 3C 80 80 3D */ lis r4, "@stringBase0"@ha /* 8033E5A8 0033B508 38 A0 00 00 */ li r5, 0 -/* 8033E5AC 0033B50C 38 84 7A 50 */ addi r4, r4, lbl_803D7A50@l +/* 8033E5AC 0033B50C 38 84 7A 50 */ addi r4, r4, "@stringBase0"@l /* 8033E5B0 0033B510 4B FD 72 69 */ bl __nwa__FUlPCcPCc /* 8033E5B4 0033B514 90 7D 00 0C */ stw r3, 0xc(r29) lbl_8033E5B8: @@ -242,7 +242,7 @@ lbl_8033E6E4: "ConvertToUNICODE__13CStringExtrasFRCQ24rstl66basic_string,Q24rstl17rmemory_allocator>": /* 8033E720 0033B680 94 21 FF D0 */ stwu r1, -0x30(r1) /* 8033E724 0033B684 7C 08 02 A6 */ mflr r0 -/* 8033E728 0033B688 38 AD A9 1A */ addi r5, r13, lbl_805A94DA@sda21 +/* 8033E728 0033B688 38 AD A9 1A */ addi r5, r13, "mNull__Q24rstl66basic_string,Q24rstl17rmemory_allocator>"@sda21 /* 8033E72C 0033B68C 90 01 00 34 */ stw r0, 0x34(r1) /* 8033E730 0033B690 38 00 00 00 */ li r0, 0 /* 8033E734 0033B694 93 E1 00 2C */ stw r31, 0x2c(r1) @@ -357,8 +357,8 @@ CreateFromInteger__13CStringExtrasFi: /* 8033E8C0 0033B820 93 A1 00 34 */ stw r29, 0x34(r1) /* 8033E8C4 0033B824 93 81 00 30 */ stw r28, 0x30(r1) /* 8033E8C8 0033B828 40 82 00 18 */ bne lbl_8033E8E0 -/* 8033E8CC 0033B82C 3C 80 80 3D */ lis r4, lbl_803D7A50@ha -/* 8033E8D0 0033B830 38 84 7A 50 */ addi r4, r4, lbl_803D7A50@l +/* 8033E8CC 0033B82C 3C 80 80 3D */ lis r4, "@stringBase0"@ha +/* 8033E8D0 0033B830 38 84 7A 50 */ addi r4, r4, "@stringBase0"@l /* 8033E8D4 0033B834 38 84 00 0E */ addi r4, r4, 0xe /* 8033E8D8 0033B838 4B CC 63 E1 */ bl string_l__4rstlFPCc /* 8033E8DC 0033B83C 48 00 00 CC */ b lbl_8033E9A8 @@ -391,9 +391,9 @@ lbl_8033E924: /* 8033E93C 0033B89C 90 01 00 0C */ stw r0, 0xc(r1) /* 8033E940 0033B8A0 90 01 00 10 */ stw r0, 0x10(r1) /* 8033E944 0033B8A4 40 80 00 1C */ bge lbl_8033E960 -/* 8033E948 0033B8A8 3C 80 80 3D */ lis r4, lbl_803D7A50@ha +/* 8033E948 0033B8A8 3C 80 80 3D */ lis r4, "@stringBase0"@ha /* 8033E94C 0033B8AC 38 61 00 08 */ addi r3, r1, 8 -/* 8033E950 0033B8B0 38 84 7A 50 */ addi r4, r4, lbl_803D7A50@l +/* 8033E950 0033B8B0 38 84 7A 50 */ addi r4, r4, "@stringBase0"@l /* 8033E954 0033B8B4 38 A0 FF FF */ li r5, -1 /* 8033E958 0033B8B8 38 84 00 10 */ addi r4, r4, 0x10 /* 8033E95C 0033B8BC 4B FF F5 89 */ bl "append__Q24rstl66basic_string,Q24rstl17rmemory_allocator>FPCci" @@ -575,7 +575,7 @@ lbl_8033EB8C: __sinit_RstlExtras_cpp: /* 8033EBA0 0033BB00 94 21 FF F0 */ stwu r1, -0x10(r1) /* 8033EBA4 0033BB04 7C 08 02 A6 */ mflr r0 -/* 8033EBA8 0033BB08 3C 80 80 34 */ lis r4, __ct__Q24rstl8CRefDataFPCPvi@ha +/* 8033EBA8 0033BB08 3C 80 80 34 */ lis r4, __dt__Q24rstl8CRefDataFv@ha /* 8033EBAC 0033BB0C 3C A0 01 00 */ lis r5, 0x00FFFFFF@ha /* 8033EBB0 0033BB10 90 01 00 14 */ stw r0, 0x14(r1) /* 8033EBB4 0033BB14 38 E0 00 00 */ li r7, 0 @@ -584,7 +584,7 @@ __sinit_RstlExtras_cpp: /* 8033EBC0 0033BB20 3C 60 80 4C */ lis r3, lbl_804BFF30@ha /* 8033EBC4 0033BB24 90 ED A9 28 */ stw r7, sNull__Q24rstl8CRefData@sda21(r13) /* 8033EBC8 0033BB28 38 A3 FF 30 */ addi r5, r3, lbl_804BFF30@l -/* 8033EBCC 0033BB2C 38 84 EB EC */ addi r4, r4, __ct__Q24rstl8CRefDataFPCPvi@l +/* 8033EBCC 0033BB2C 38 84 EB EC */ addi r4, r4, __dt__Q24rstl8CRefDataFv@l /* 8033EBD0 0033BB30 90 06 00 04 */ stw r0, 4(r6) /* 8033EBD4 0033BB34 38 6D A9 28 */ addi r3, r13, sNull__Q24rstl8CRefData@sda21 /* 8033EBD8 0033BB38 48 04 AA B5 */ bl __register_global_object @@ -593,8 +593,8 @@ __sinit_RstlExtras_cpp: /* 8033EBE4 0033BB44 38 21 00 10 */ addi r1, r1, 0x10 /* 8033EBE8 0033BB48 4E 80 00 20 */ blr -.global __ct__Q24rstl8CRefDataFPCPvi -__ct__Q24rstl8CRefDataFPCPvi: +.global __dt__Q24rstl8CRefDataFv +__dt__Q24rstl8CRefDataFv: /* 8033EBEC 0033BB4C 94 21 FF F0 */ stwu r1, -0x10(r1) /* 8033EBF0 0033BB50 7C 08 02 A6 */ mflr r0 /* 8033EBF4 0033BB54 90 01 00 14 */ stw r0, 0x14(r1) @@ -615,13 +615,9 @@ lbl_8033EC10: .section .rodata .balign 8 -.global lbl_803D7A50 -lbl_803D7A50: +"@stringBase0": # ROM: 0x3D4A50 .asciz "??(??)" - .byte 0x25 - .asciz "%.%df" - .byte 0x30, 0x00 - .4byte 0x2D000000 - .4byte 0 - + .asciz "%%.%df" + .asciz "0" + .asciz "-" diff --git a/asm/Kyoto/rstl/rstl_strings.s b/asm/Kyoto/rstl/rstl_strings.s index 46c91904..0f41723f 100644 --- a/asm/Kyoto/rstl/rstl_strings.s +++ b/asm/Kyoto/rstl/rstl_strings.s @@ -10,8 +10,8 @@ lbl_ctor: .global "mNull__Q24rstl66basic_string,Q24rstl17rmemory_allocator>" "mNull__Q24rstl66basic_string,Q24rstl17rmemory_allocator>": .skip 0x2 -.global lbl_805A94DA -lbl_805A94DA: +.global "mNull__Q24rstl66basic_string,Q24rstl17rmemory_allocator>" +"mNull__Q24rstl66basic_string,Q24rstl17rmemory_allocator>": .skip 0x2 .global lbl_805A94DC lbl_805A94DC: @@ -848,7 +848,7 @@ lbl_8033D748: /* 8033D7E4 0033A744 A0 1F 00 00 */ lhz r0, 0(r31) /* 8033D7E8 0033A748 28 00 00 00 */ cmplwi r0, 0 /* 8033D7EC 0033A74C 40 82 00 1C */ bne lbl_8033D808 -/* 8033D7F0 0033A750 38 8D A9 1A */ addi r4, r13, lbl_805A94DA@sda21 +/* 8033D7F0 0033A750 38 8D A9 1A */ addi r4, r13, "mNull__Q24rstl66basic_string,Q24rstl17rmemory_allocator>"@sda21 /* 8033D7F4 0033A754 38 00 00 00 */ li r0, 0 /* 8033D7F8 0033A758 90 9E 00 00 */ stw r4, 0(r30) /* 8033D7FC 0033A75C 90 1E 00 08 */ stw r0, 8(r30) @@ -1727,7 +1727,7 @@ lbl_8033E3D8: /* 8033E3E0 0033B340 40 82 00 14 */ bne lbl_8033E3F4 /* 8033E3E4 0033B344 38 60 00 00 */ li r3, 0 /* 8033E3E8 0033B348 38 00 00 01 */ li r0, 1 -/* 8033E3EC 0033B34C B0 6D A9 1A */ sth r3, lbl_805A94DA@sda21(r13) +/* 8033E3EC 0033B34C B0 6D A9 1A */ sth r3, "mNull__Q24rstl66basic_string,Q24rstl17rmemory_allocator>"@sda21(r13) /* 8033E3F0 0033B350 98 0D A9 21 */ stb r0, lbl_805A94E1@sda21(r13) lbl_8033E3F4: /* 8033E3F4 0033B354 88 0D A9 22 */ lbz r0, lbl_805A94E2@sda21(r13) @@ -1754,4 +1754,3 @@ lbl_803D7A48: # ROM: 0x3D4A48 .asciz "??(??)" .balign 4 - diff --git a/asm/MetroidPrime/CAutoMapper.s b/asm/MetroidPrime/CAutoMapper.s index 347c6025..2b13cdd2 100644 --- a/asm/MetroidPrime/CAutoMapper.s +++ b/asm/MetroidPrime/CAutoMapper.s @@ -3227,7 +3227,7 @@ lbl_80097F74: /* 80097F94 00094EF4 38 84 00 EB */ addi r4, r4, 0xeb /* 80097F98 00094EF8 48 22 A1 BD */ bl FindWidget__9CGuiFrameCFPCc /* 80097F9C 00094EFC 38 00 00 00 */ li r0, 0 -/* 80097FA0 00094F00 38 8D A9 1A */ addi r4, r13, lbl_805A94DA@sda21 +/* 80097FA0 00094F00 38 8D A9 1A */ addi r4, r13, "mNull__Q24rstl66basic_string,Q24rstl17rmemory_allocator>"@sda21 /* 80097FA4 00094F04 90 81 01 CC */ stw r4, 0x1cc(r1) /* 80097FA8 00094F08 3C 80 80 3D */ lis r4, lbl_803CD7FC@ha /* 80097FAC 00094F0C 38 E4 D7 FC */ addi r7, r4, lbl_803CD7FC@l @@ -3315,7 +3315,7 @@ lbl_800980C4: /* 800980E8 00095048 38 84 01 01 */ addi r4, r4, 0x101 /* 800980EC 0009504C 48 22 A0 69 */ bl FindWidget__9CGuiFrameCFPCc /* 800980F0 00095050 38 00 00 00 */ li r0, 0 -/* 800980F4 00095054 38 8D A9 1A */ addi r4, r13, lbl_805A94DA@sda21 +/* 800980F4 00095054 38 8D A9 1A */ addi r4, r13, "mNull__Q24rstl66basic_string,Q24rstl17rmemory_allocator>"@sda21 /* 800980F8 00095058 90 81 01 BC */ stw r4, 0x1bc(r1) /* 800980FC 0009505C 7C 7E 1B 78 */ mr r30, r3 /* 80098100 00095060 90 01 01 C0 */ stw r0, 0x1c0(r1) @@ -6908,7 +6908,7 @@ lbl_8009B46C: /* 8009B49C 000983FC 38 A3 D7 EC */ addi r5, r3, lbl_803CD7EC@l /* 8009B4A0 00098400 80 E2 8B 64 */ lwz r7, lbl_805AA884@sda21(r2) /* 8009B4A4 00098404 81 65 00 00 */ lwz r11, 0(r5) -/* 8009B4A8 00098408 38 CD A9 1A */ addi r6, r13, lbl_805A94DA@sda21 +/* 8009B4A8 00098408 38 CD A9 1A */ addi r6, r13, "mNull__Q24rstl66basic_string,Q24rstl17rmemory_allocator>"@sda21 /* 8009B4AC 0009840C 81 45 00 04 */ lwz r10, 4(r5) /* 8009B4B0 00098410 38 61 01 70 */ addi r3, r1, 0x170 /* 8009B4B4 00098414 81 25 00 08 */ lwz r9, 8(r5) diff --git a/asm/MetroidPrime/CFrontEndUI.s b/asm/MetroidPrime/CFrontEndUI.s index 8ae082f2..a0f7b435 100644 --- a/asm/MetroidPrime/CFrontEndUI.s +++ b/asm/MetroidPrime/CFrontEndUI.s @@ -5233,7 +5233,7 @@ lbl_8001FCC4: /* 8001FCE0 0001CC40 7F C4 F3 78 */ mr r4, r30 /* 8001FCE4 0001CC44 48 22 FA 19 */ bl GetGameData__15CSaveGameScreenFi /* 8001FCE8 0001CC48 80 BF 00 28 */ lwz r5, 0x28(r31) -/* 8001FCEC 0001CC4C 38 8D A9 1A */ addi r4, r13, lbl_805A94DA@sda21 +/* 8001FCEC 0001CC4C 38 8D A9 1A */ addi r4, r13, "mNull__Q24rstl66basic_string,Q24rstl17rmemory_allocator>"@sda21 /* 8001FCF0 0001CC50 38 00 00 00 */ li r0, 0 /* 8001FCF4 0001CC54 7C 7A 1B 78 */ mr r26, r3 /* 8001FCF8 0001CC58 54 A3 18 38 */ slwi r3, r5, 3 diff --git a/asm/MetroidPrime/CLogBookScreen.s b/asm/MetroidPrime/CLogBookScreen.s index df7d5326..8eb476b8 100644 --- a/asm/MetroidPrime/CLogBookScreen.s +++ b/asm/MetroidPrime/CLogBookScreen.s @@ -193,7 +193,7 @@ UpdateRightTitles__14CLogBookScreenFv: lbl_80245B8C: /* 80245B8C 00242AEC 80 9C 00 18 */ lwz r4, 0x18(r28) /* 80245B90 00242AF0 38 00 00 00 */ li r0, 0 -/* 80245B94 00242AF4 38 6D A9 1A */ addi r3, r13, lbl_805A94DA@sda21 +/* 80245B94 00242AF4 38 6D A9 1A */ addi r3, r13, "mNull__Q24rstl66basic_string,Q24rstl17rmemory_allocator>"@sda21 /* 80245B98 00242AF8 90 61 00 4C */ stw r3, 0x4c(r1) /* 80245B9C 00242AFC 7C 84 EA 14 */ add r4, r4, r29 /* 80245BA0 00242B00 90 01 00 50 */ stw r0, 0x50(r1) diff --git a/asm/MetroidPrime/CPauseScreen.s b/asm/MetroidPrime/CPauseScreen.s index d8b89de3..6ae7632e 100644 --- a/asm/MetroidPrime/CPauseScreen.s +++ b/asm/MetroidPrime/CPauseScreen.s @@ -1419,7 +1419,7 @@ InitializeFrameGlue__16CPauseScreenBaseFv: /* 80071B94 0006EAF4 38 A3 D2 C8 */ addi r5, r3, lbl_803CD2C8@l /* 80071B98 0006EAF8 38 00 00 00 */ li r0, 0 /* 80071B9C 0006EAFC 81 65 00 00 */ lwz r11, 0(r5) -/* 80071BA0 0006EB00 38 CD A9 1A */ addi r6, r13, lbl_805A94DA@sda21 +/* 80071BA0 0006EB00 38 CD A9 1A */ addi r6, r13, "mNull__Q24rstl66basic_string,Q24rstl17rmemory_allocator>"@sda21 /* 80071BA4 0006EB04 81 45 00 04 */ lwz r10, 4(r5) /* 80071BA8 0006EB08 38 61 01 0C */ addi r3, r1, 0x10c /* 80071BAC 0006EB0C 81 25 00 08 */ lwz r9, 8(r5) @@ -2720,7 +2720,7 @@ lbl_80072E24: /* 80072E54 0006FDB4 81 25 00 08 */ lwz r9, 8(r5) /* 80072E58 0006FDB8 7D 4B 00 D0 */ neg r10, r11 /* 80072E5C 0006FDBC 81 05 00 0C */ lwz r8, 0xc(r5) -/* 80072E60 0006FDC0 38 CD A9 1A */ addi r6, r13, lbl_805A94DA@sda21 +/* 80072E60 0006FDC0 38 CD A9 1A */ addi r6, r13, "mNull__Q24rstl66basic_string,Q24rstl17rmemory_allocator>"@sda21 /* 80072E64 0006FDC4 80 E2 88 28 */ lwz r7, lbl_805AA548@sda21(r2) /* 80072E68 0006FDC8 7F 7B E3 78 */ or r27, r27, r28 /* 80072E6C 0006FDCC 7D 8C D3 78 */ or r12, r12, r26 diff --git a/asm/MetroidPrime/CSlideShow.s b/asm/MetroidPrime/CSlideShow.s index 463f4c09..be933dee 100644 --- a/asm/MetroidPrime/CSlideShow.s +++ b/asm/MetroidPrime/CSlideShow.s @@ -1446,7 +1446,7 @@ lbl_80298D00: lbl_80298D04: /* 80298D04 00295C64 90 1F 00 F0 */ stw r0, 0xf0(r31) /* 80298D08 00295C68 38 00 00 00 */ li r0, 0 -/* 80298D0C 00295C6C 38 8D A9 1A */ addi r4, r13, lbl_805A94DA@sda21 +/* 80298D0C 00295C6C 38 8D A9 1A */ addi r4, r13, "mNull__Q24rstl66basic_string,Q24rstl17rmemory_allocator>"@sda21 /* 80298D10 00295C70 38 61 01 E0 */ addi r3, r1, 0x1e0 /* 80298D14 00295C74 90 81 01 E0 */ stw r4, 0x1e0(r1) /* 80298D18 00295C78 38 80 01 00 */ li r4, 0x100 diff --git a/asm/MetroidPrime/CSplashScreen.s b/asm/MetroidPrime/CSplashScreen.s index e947b1d1..c0930c7e 100644 --- a/asm/MetroidPrime/CSplashScreen.s +++ b/asm/MetroidPrime/CSplashScreen.s @@ -826,14 +826,14 @@ sub_80028bd8: /* 80028BDC 00025B3C 7C 08 02 A6 */ mflr r0 /* 80028BE0 00025B40 38 80 FF FF */ li r4, -1 /* 80028BE4 00025B44 90 01 00 14 */ stw r0, 0x14(r1) -/* 80028BE8 00025B48 48 00 00 15 */ bl sub_80028bfc +/* 80028BE8 00025B48 48 00 00 15 */ bl __dt__13CFontImageDefFv /* 80028BEC 00025B4C 80 01 00 14 */ lwz r0, 0x14(r1) /* 80028BF0 00025B50 7C 08 03 A6 */ mtlr r0 /* 80028BF4 00025B54 38 21 00 10 */ addi r1, r1, 0x10 /* 80028BF8 00025B58 4E 80 00 20 */ blr -.global sub_80028bfc -sub_80028bfc: +.global __dt__13CFontImageDefFv +__dt__13CFontImageDefFv: /* 80028BFC 00025B5C 94 21 FF D0 */ stwu r1, -0x30(r1) /* 80028C00 00025B60 7C 08 02 A6 */ mflr r0 /* 80028C04 00025B64 90 01 00 34 */ stw r0, 0x34(r1) diff --git a/configure.py b/configure.py index aba395ed..75085b22 100755 --- a/configure.py +++ b/configure.py @@ -602,7 +602,7 @@ LIBS = [ "Kyoto/CResLoader", ["Kyoto/rstl/rstl_map", False], "Kyoto/rstl/rstl_strings", - "Kyoto/rstl/RstlExtras", + ["Kyoto/rstl/RstlExtras", False], ["Kyoto/Streams/CInputStream", True], ["Kyoto/Streams/CMemoryInStream", True], ["Kyoto/Streams/CMemoryStreamOut", True], diff --git a/include/Kyoto/Animation/CSegId.hpp b/include/Kyoto/Animation/CSegId.hpp index 6c174a13..00f6572d 100644 --- a/include/Kyoto/Animation/CSegId.hpp +++ b/include/Kyoto/Animation/CSegId.hpp @@ -8,7 +8,7 @@ class CSegId { public: CSegId() : x0_id(-1) {} - CSegId(CInputStream& in) : x0_id(in.Get()) {} + CSegId(CInputStream& in) : x0_id(in.ReadInt32()) {} private: uchar x0_id; }; diff --git a/include/Kyoto/Basics/CCast.hpp b/include/Kyoto/Basics/CCast.hpp index 365738b3..4887035a 100644 --- a/include/Kyoto/Basics/CCast.hpp +++ b/include/Kyoto/Basics/CCast.hpp @@ -17,6 +17,8 @@ inline uchar ToUint8(register float in) { return *ptr; } +inline uchar ToUint8(int c) { return static_cast(c); } + inline float ToReal32(register const uchar& in) { register float r; asm { @@ -50,6 +52,7 @@ inline float LtoF(int in) { return static_cast< float >(in); } #else inline uchar ToUint8(float in) { return static_cast< uchar >(in); } +inline uchar ToUint8(int c) { return static_cast(c); } inline float ToReal32(uchar in) { return static_cast< float >(in); } inline short FtoS(float in) { return static_cast< short >(in); } inline ushort FtoUS(float in) { return static_cast< ushort >(in); } @@ -58,6 +61,7 @@ inline float LtoF(int in) { return static_cast< float >(in); } #endif inline int ToInt32(float in) { return static_cast< int >(in); } +inline char ToChar(int c) { return ToUint8(c) ; } } // namespace CCast #endif // _CCAST diff --git a/include/Kyoto/rstl/StringExtras.hpp b/include/Kyoto/rstl/StringExtras.hpp deleted file mode 100644 index 9f153ccf..00000000 --- a/include/Kyoto/rstl/StringExtras.hpp +++ /dev/null @@ -1,12 +0,0 @@ -#ifndef _STRINGEXTRAS -#define _STRINGEXTRAS - -#include "rstl/string.hpp" - -class CStringExtras { - public: - static int CompareCaseInsensitive(const rstl::string&, const rstl::string&); - static int IndexOfSubstring(const rstl::string&, const rstl::string&); -}; - -#endif // _STRINGEXTRAS diff --git a/include/rstl/StringExtras.hpp b/include/rstl/StringExtras.hpp new file mode 100644 index 00000000..415bef55 --- /dev/null +++ b/include/rstl/StringExtras.hpp @@ -0,0 +1,19 @@ +#ifndef _RSTL_STRINGEXTRAS +#define _RSTL_STRINGEXTRAS + +#include "rstl/string.hpp" +#include "rstl/vector.hpp" + +class CStringExtras { +public: + static int IndexOfSubstring(const rstl::string&, const rstl::string&); + static int CompareCaseInsensitive(const rstl::string&, const rstl::string&); + static char ConvertToUpperCase(char c); + static rstl::string CreateFromInteger(int v); + static rstl::string ConvertToANSI(const rstl::wstring& str); + static rstl::wstring ConvertToUNICODE(const rstl::string& str); + static rstl::string ReadString(CInputStream& in); + static rstl::vector TokenizeString(const rstl::string&, const char*, int); +}; + +#endif // _RSTL_STRINGEXTRAS diff --git a/include/rstl/rc_ptr.hpp b/include/rstl/rc_ptr.hpp index 9af0dfd5..707d79fb 100644 --- a/include/rstl/rc_ptr.hpp +++ b/include/rstl/rc_ptr.hpp @@ -8,6 +8,7 @@ class CRefData { public: CRefData(const void* ptr) : x0_ptr(ptr), x4_refCount(1) {} CRefData(const void* ptr, int refCount) : x0_ptr(ptr), x4_refCount(refCount) {} + ~CRefData() {} void* GetPtr() const { return const_cast< void* >(x0_ptr); } int GetRefCount() const { return x4_refCount; } diff --git a/include/rstl/string.hpp b/include/rstl/string.hpp index 709534b1..8ffe9dcd 100644 --- a/include/rstl/string.hpp +++ b/include/rstl/string.hpp @@ -26,6 +26,7 @@ class basic_string { uint x8_size; uint _pad; // Alloc? + void internal_prepare_to_write(int len, bool); void internal_allocate(int size); // { // x4_cow = reinterpret_cast(new uchar[size * sizeof(_CharTp) + @@ -99,6 +100,8 @@ public: ~basic_string() { internal_dereference(); } size_t size() const { return x8_size; } + void reserve(int len) { internal_prepare_to_write(len, true); } + void assign(const basic_string&); basic_string& operator=(const basic_string& other) { assign(other); @@ -107,13 +110,15 @@ public: basic_string operator+(const _CharTp*); void append(const basic_string& other); void append(int, _CharTp); + void append(const _CharTp*, int); int _eq_helper(const basic_string& other) const; bool operator==(const basic_string& other) const; bool operator<(const basic_string& other) const; - const char* data() const { return x0_ptr; } + const _CharTp* data() const { return x0_ptr; } void PutTo(COutputStream& out) const; + const _CharTp at(int idx) const { return data()[idx]; } }; template < typename _CharTp, typename Traits, typename Alloc > diff --git a/src/Kyoto/Animation/DolphinCVirtualBone.cpp b/src/Kyoto/Animation/DolphinCVirtualBone.cpp index 80859f87..00870727 100644 --- a/src/Kyoto/Animation/DolphinCVirtualBone.cpp +++ b/src/Kyoto/Animation/DolphinCVirtualBone.cpp @@ -5,7 +5,7 @@ static rstl::reserved_vector< SSkinWeighting, 3 > StreamInSkinWeighting(CInputStream& in) { rstl::reserved_vector< SSkinWeighting, 3 > weights; - int weightCount = in.Get< uint >(); + int weightCount = in.ReadInt32(); if (weightCount > 3) { for (int i = 0; i < 3; ++i) { diff --git a/src/Kyoto/rstl/RstlExtras.cpp b/src/Kyoto/rstl/RstlExtras.cpp new file mode 100644 index 00000000..2fa4ac42 --- /dev/null +++ b/src/Kyoto/rstl/RstlExtras.cpp @@ -0,0 +1,112 @@ +#include "rstl/StringExtras.hpp" +#include "rstl/rc_ptr.hpp" +#include "Kyoto/Alloc/CMemory.hpp" + +#include "Kyoto/Basics/CCast.hpp" +#include "Kyoto/Streams/CInputStream.hpp" + +namespace rstl { +CRefData CRefData::sNull(nullptr, 0x1000000 - 1); +} + +int CStringExtras::IndexOfSubstring(const rstl::string& left, const rstl::string& right) { + int rightSize = right.size(); + if (rightSize == 0) { + return 0; + } + int leftSize = left.size(); + if (leftSize == 0) { + return -1; + } + + int i; + int j; + for (int i = 0; i < (leftSize - rightSize) + 1; ++i) { + for (int j = 0; j < rightSize; ++j) { + if (ConvertToUpperCase(right.at(i)) != ConvertToUpperCase(left.at(i + j))) { + break; + } + } + if (j == rightSize) { + return i; + } + } + return -1; +} +int CStringExtras::CompareCaseInsensitive(const rstl::string&, const rstl::string&) {} +char CStringExtras::ConvertToUpperCase(char c) { + if (c >= CCast::ToChar('a') && c <= CCast::ToChar('z')) { + return (c - CCast::ToChar(' ')) & 0xFF; + } + + return c; +} + +rstl::string CStringExtras::CreateFromInteger(int v) { + int iVar3 = ((v >> 31) ^ v) - (v >> 31); + int iVar4 = 0; + uchar tmp[24]; + if (v == 0) { + return rstl::string_l("0"); + } + + uchar* ptr = &tmp[0]; + while (iVar3 > 0) { + ++iVar4; + int iVar1 = iVar3 / 10 + (iVar3 >> 31); + *ptr = iVar3 + (((iVar1 - (iVar1 >> 31)) * 10) + '0'); + ++ptr; + iVar3 = iVar1 - (iVar1 >> 31); + } + + rstl::string ret; + if (v < 0) { + ret.append("-"); + } + + for (int i = 0; i < iVar4; ++i) { + ret.append(1, tmp[iVar4 - i]); + } + + return ret; +} + +rstl::string CStringExtras::ConvertToANSI(const rstl::wstring& str) { + rstl::string ret; + ret.reserve(str.size() + 1); + + for (int i = 0; i < (int)str.size(); ++i) { + ret.assign(ret + (char)(str.at(i))); + } + return ret; +} +rstl::wstring CStringExtras::ConvertToUNICODE(const rstl::string& str) { + rstl::wstring ret; + ret.reserve(str.size() + 1); + + for (int i = 0; i < (int)str.size(); ++i) { + ret.append(1, (wchar_t)str.at(i)); + } + return ret; +} + +rstl::string CStringExtras::ReadString(CInputStream& in) { + rstl::string ret; + int strLen = in.ReadInt32(); + ret.reserve(strLen); + while (strLen > 0) { + int len = strLen > 512u ? 512 : strLen; + char tmp[512]; + in.ReadBytes(tmp, len); + ret.append(tmp, len); + strLen -= len; + } + + return ret; +} + +rstl::vector< rstl::string > CStringExtras::TokenizeString(const rstl::string& string, + const char* delims, int expectedSize) { + rstl::vector< rstl::string > ret; + ret.reserve(expectedSize); +}