From f344adf1672486d682572340c1332839fd01d297 Mon Sep 17 00:00:00 2001 From: Henrique Gemignani Passos Lima Date: Thu, 17 Nov 2022 17:46:10 +0200 Subject: [PATCH] Add CAnimationDatabaseGame Former-commit-id: 1f30508cd360d541d0df60237243699965e2a96d --- asm/Kyoto/Animation/CAnimTreeSequence.s | 3 +- asm/Kyoto/Animation/CAnimation.s | 2 +- asm/Kyoto/Animation/CAnimationSet.s | 7 +-- asm/Kyoto/Animation/CMetaAnimBlend.s | 9 ++- asm/Kyoto/Animation/CMetaAnimPhaseBlend.s | 9 ++- asm/Kyoto/Animation/CMetaAnimRandom.s | 13 ++-- asm/Kyoto/Animation/CMetaAnimSequence.s | 13 ++-- asm/Kyoto/Animation/CMetaTransMetaAnim.s | 5 +- asm/MetroidPrime/CAnimData.s | 16 ++--- asm/MetroidPrime/CAnimationDatabaseGame.s | 21 +++---- .../Factories/CCharacterFactory.s | 14 ++--- configure.py | 2 +- include/Kyoto/Animation/CAnimation.hpp | 18 ++++++ include/Kyoto/Animation/CPrimitive.hpp | 15 +++++ include/Kyoto/Animation/IMetaAnim.hpp | 33 ++++++++++ .../MetroidPrime/CAnimationDatabaseGame.hpp | 48 +++++++++++++++ include/rstl/iterator.hpp | 30 +++++++++ include/rstl/pointer_iterator.hpp | 11 +--- include/rstl/red_black_tree.hpp | 16 +++++ include/rstl/set.hpp | 3 + include/rstl/vector.hpp | 61 +++++++++++++++---- src/MetroidPrime/CAnimationDatabaseGame.cpp | 36 +++++++++++ 22 files changed, 303 insertions(+), 82 deletions(-) create mode 100644 include/Kyoto/Animation/CAnimation.hpp create mode 100644 include/Kyoto/Animation/CPrimitive.hpp create mode 100644 include/Kyoto/Animation/IMetaAnim.hpp create mode 100644 include/MetroidPrime/CAnimationDatabaseGame.hpp create mode 100644 include/rstl/iterator.hpp create mode 100644 src/MetroidPrime/CAnimationDatabaseGame.cpp diff --git a/asm/Kyoto/Animation/CAnimTreeSequence.s b/asm/Kyoto/Animation/CAnimTreeSequence.s index 930ebf5a..a8822c7d 100644 --- a/asm/Kyoto/Animation/CAnimTreeSequence.s +++ b/asm/Kyoto/Animation/CAnimTreeSequence.s @@ -85,7 +85,7 @@ lbl_802DABA0: /* 802DABA0 002D7B00 28 1C 00 00 */ cmplwi r28, 0 /* 802DABA4 002D7B04 41 82 00 0C */ beq lbl_802DABB0 /* 802DABA8 002D7B08 7F 83 E3 78 */ mr r3, r28 -/* 802DABAC 002D7B0C 4B D5 63 85 */ bl sub_80030f30 +/* 802DABAC 002D7B0C 4B D5 63 85 */ bl "ReleaseData__Q24rstl18rc_ptr<9IMetaAnim>Fv" lbl_802DABB0: /* 802DABB0 002D7B10 3B 9C 00 04 */ addi r28, r28, 4 lbl_802DABB4: @@ -3246,4 +3246,3 @@ lbl_803D6D40: # ROM: 0x3D3D40 .4byte 0x003F3F28 .4byte 0x3F3F2900 - diff --git a/asm/Kyoto/Animation/CAnimation.s b/asm/Kyoto/Animation/CAnimation.s index a011d935..6ba2adea 100644 --- a/asm/Kyoto/Animation/CAnimation.s +++ b/asm/Kyoto/Animation/CAnimation.s @@ -23,7 +23,7 @@ __ct__10CAnimationFR12CInputStream: /* 802D6DC4 002D3D24 80 85 00 04 */ lwz r4, 4(r5) /* 802D6DC8 002D3D28 38 04 00 01 */ addi r0, r4, 1 /* 802D6DCC 002D3D2C 90 05 00 04 */ stw r0, 4(r5) -/* 802D6DD0 002D3D30 4B D5 A1 61 */ bl sub_80030f30 +/* 802D6DD0 002D3D30 4B D5 A1 61 */ bl "ReleaseData__Q24rstl18rc_ptr<9IMetaAnim>Fv" /* 802D6DD4 002D3D34 80 01 00 24 */ lwz r0, 0x24(r1) /* 802D6DD8 002D3D38 7F C3 F3 78 */ mr r3, r30 /* 802D6DDC 002D3D3C 83 E1 00 1C */ lwz r31, 0x1c(r1) diff --git a/asm/Kyoto/Animation/CAnimationSet.s b/asm/Kyoto/Animation/CAnimationSet.s index 362606a2..de2d481a 100644 --- a/asm/Kyoto/Animation/CAnimationSet.s +++ b/asm/Kyoto/Animation/CAnimationSet.s @@ -870,7 +870,7 @@ lbl_802D7A84: /* 802D7A8C 002D49EC 34 1E 00 10 */ addic. r0, r30, 0x10 /* 802D7A90 002D49F0 41 82 00 0C */ beq lbl_802D7A9C /* 802D7A94 002D49F4 38 7E 00 10 */ addi r3, r30, 0x10 -/* 802D7A98 002D49F8 4B D5 94 99 */ bl sub_80030f30 +/* 802D7A98 002D49F8 4B D5 94 99 */ bl "ReleaseData__Q24rstl18rc_ptr<9IMetaAnim>Fv" lbl_802D7A9C: /* 802D7A9C 002D49FC 28 1E 00 00 */ cmplwi r30, 0 /* 802D7AA0 002D4A00 41 82 00 0C */ beq lbl_802D7AAC @@ -963,7 +963,7 @@ lbl_802D7BC4: /* 802D7BD0 002D4B30 90 1A 00 04 */ stw r0, 4(r26) /* 802D7BD4 002D4B34 41 82 00 0C */ beq lbl_802D7BE0 /* 802D7BD8 002D4B38 7F A3 EB 78 */ mr r3, r29 -/* 802D7BDC 002D4B3C 4B D5 93 55 */ bl sub_80030f30 +/* 802D7BDC 002D4B3C 4B D5 93 55 */ bl "ReleaseData__Q24rstl18rc_ptr<9IMetaAnim>Fv" lbl_802D7BE0: /* 802D7BE0 002D4B40 38 61 00 0C */ addi r3, r1, 0xc /* 802D7BE4 002D4B44 48 06 5E FD */ bl "internal_dereference__Q24rstl66basic_string,Q24rstl17rmemory_allocator>Fv" @@ -1070,7 +1070,7 @@ lbl_802D7D30: /* 802D7D38 002D4C98 34 1A 00 10 */ addic. r0, r26, 0x10 /* 802D7D3C 002D4C9C 41 82 00 0C */ beq lbl_802D7D48 /* 802D7D40 002D4CA0 38 7A 00 10 */ addi r3, r26, 0x10 -/* 802D7D44 002D4CA4 4B D5 91 ED */ bl sub_80030f30 +/* 802D7D44 002D4CA4 4B D5 91 ED */ bl "ReleaseData__Q24rstl18rc_ptr<9IMetaAnim>Fv" lbl_802D7D48: /* 802D7D48 002D4CA8 28 1A 00 00 */ cmplwi r26, 0 /* 802D7D4C 002D4CAC 41 82 00 0C */ beq lbl_802D7D58 @@ -1352,4 +1352,3 @@ lbl_803D6D28: # ROM: 0x3D3D28 .asciz "??(??)" .balign 4 - diff --git a/asm/Kyoto/Animation/CMetaAnimBlend.s b/asm/Kyoto/Animation/CMetaAnimBlend.s index b369ba71..ed1090ce 100644 --- a/asm/Kyoto/Animation/CMetaAnimBlend.s +++ b/asm/Kyoto/Animation/CMetaAnimBlend.s @@ -34,12 +34,12 @@ __dt__14CMetaAnimBlendFv: /* 802DF914 002DC874 90 1E 00 00 */ stw r0, 0(r30) /* 802DF918 002DC878 41 82 00 0C */ beq lbl_802DF924 /* 802DF91C 002DC87C 38 7E 00 08 */ addi r3, r30, 8 -/* 802DF920 002DC880 4B D5 16 11 */ bl sub_80030f30 +/* 802DF920 002DC880 4B D5 16 11 */ bl "ReleaseData__Q24rstl18rc_ptr<9IMetaAnim>Fv" lbl_802DF924: /* 802DF924 002DC884 34 1E 00 04 */ addic. r0, r30, 4 /* 802DF928 002DC888 41 82 00 0C */ beq lbl_802DF934 /* 802DF92C 002DC88C 38 7E 00 04 */ addi r3, r30, 4 -/* 802DF930 002DC890 4B D5 16 01 */ bl sub_80030f30 +/* 802DF930 002DC890 4B D5 16 01 */ bl "ReleaseData__Q24rstl18rc_ptr<9IMetaAnim>Fv" lbl_802DF934: /* 802DF934 002DC894 28 1E 00 00 */ cmplwi r30, 0 /* 802DF938 002DC898 41 82 00 10 */ beq lbl_802DF948 @@ -471,7 +471,7 @@ __ct__14CMetaAnimBlendFR12CInputStream: /* 802DFF6C 002DCECC 80 85 00 04 */ lwz r4, 4(r5) /* 802DFF70 002DCED0 38 04 00 01 */ addi r0, r4, 1 /* 802DFF74 002DCED4 90 05 00 04 */ stw r0, 4(r5) -/* 802DFF78 002DCED8 4B D5 0F B9 */ bl sub_80030f30 +/* 802DFF78 002DCED8 4B D5 0F B9 */ bl "ReleaseData__Q24rstl18rc_ptr<9IMetaAnim>Fv" /* 802DFF7C 002DCEDC 7F E4 FB 78 */ mr r4, r31 /* 802DFF80 002DCEE0 38 61 00 08 */ addi r3, r1, 8 /* 802DFF84 002DCEE4 48 00 00 59 */ bl CreateMetaAnim__16CMetaAnimFactoryFR12CInputStream @@ -482,7 +482,7 @@ __ct__14CMetaAnimBlendFR12CInputStream: /* 802DFF98 002DCEF8 80 85 00 04 */ lwz r4, 4(r5) /* 802DFF9C 002DCEFC 38 04 00 01 */ addi r0, r4, 1 /* 802DFFA0 002DCF00 90 05 00 04 */ stw r0, 4(r5) -/* 802DFFA4 002DCF04 4B D5 0F 8D */ bl sub_80030f30 +/* 802DFFA4 002DCF04 4B D5 0F 8D */ bl "ReleaseData__Q24rstl18rc_ptr<9IMetaAnim>Fv" /* 802DFFA8 002DCF08 7F E3 FB 78 */ mr r3, r31 /* 802DFFAC 002DCF0C 48 05 EC 7D */ bl ReadFloat__12CInputStreamFv /* 802DFFB0 002DCF10 D0 3E 00 0C */ stfs f1, 0xc(r30) @@ -504,4 +504,3 @@ lbl_803D6D58: # ROM: 0x3D3D58 .asciz "??(??)" .balign 4 - diff --git a/asm/Kyoto/Animation/CMetaAnimPhaseBlend.s b/asm/Kyoto/Animation/CMetaAnimPhaseBlend.s index c398a35d..5f3096fb 100644 --- a/asm/Kyoto/Animation/CMetaAnimPhaseBlend.s +++ b/asm/Kyoto/Animation/CMetaAnimPhaseBlend.s @@ -68,12 +68,12 @@ __dt__19CMetaAnimPhaseBlendFv: /* 802E026C 002DD1CC 90 1E 00 00 */ stw r0, 0(r30) /* 802E0270 002DD1D0 41 82 00 0C */ beq lbl_802E027C /* 802E0274 002DD1D4 38 7E 00 08 */ addi r3, r30, 8 -/* 802E0278 002DD1D8 4B D5 0C B9 */ bl sub_80030f30 +/* 802E0278 002DD1D8 4B D5 0C B9 */ bl "ReleaseData__Q24rstl18rc_ptr<9IMetaAnim>Fv" lbl_802E027C: /* 802E027C 002DD1DC 34 1E 00 04 */ addic. r0, r30, 4 /* 802E0280 002DD1E0 41 82 00 0C */ beq lbl_802E028C /* 802E0284 002DD1E4 38 7E 00 04 */ addi r3, r30, 4 -/* 802E0288 002DD1E8 4B D5 0C A9 */ bl sub_80030f30 +/* 802E0288 002DD1E8 4B D5 0C A9 */ bl "ReleaseData__Q24rstl18rc_ptr<9IMetaAnim>Fv" lbl_802E028C: /* 802E028C 002DD1EC 28 1E 00 00 */ cmplwi r30, 0 /* 802E0290 002DD1F0 41 82 00 10 */ beq lbl_802E02A0 @@ -556,7 +556,7 @@ __ct__19CMetaAnimPhaseBlendFR12CInputStream: /* 802E0978 002DD8D8 80 85 00 04 */ lwz r4, 4(r5) /* 802E097C 002DD8DC 38 04 00 01 */ addi r0, r4, 1 /* 802E0980 002DD8E0 90 05 00 04 */ stw r0, 4(r5) -/* 802E0984 002DD8E4 4B D5 05 AD */ bl sub_80030f30 +/* 802E0984 002DD8E4 4B D5 05 AD */ bl "ReleaseData__Q24rstl18rc_ptr<9IMetaAnim>Fv" /* 802E0988 002DD8E8 7F E4 FB 78 */ mr r4, r31 /* 802E098C 002DD8EC 38 61 00 08 */ addi r3, r1, 8 /* 802E0990 002DD8F0 4B FF F6 4D */ bl CreateMetaAnim__16CMetaAnimFactoryFR12CInputStream @@ -567,7 +567,7 @@ __ct__19CMetaAnimPhaseBlendFR12CInputStream: /* 802E09A4 002DD904 80 85 00 04 */ lwz r4, 4(r5) /* 802E09A8 002DD908 38 04 00 01 */ addi r0, r4, 1 /* 802E09AC 002DD90C 90 05 00 04 */ stw r0, 4(r5) -/* 802E09B0 002DD910 4B D5 05 81 */ bl sub_80030f30 +/* 802E09B0 002DD910 4B D5 05 81 */ bl "ReleaseData__Q24rstl18rc_ptr<9IMetaAnim>Fv" /* 802E09B4 002DD914 7F E3 FB 78 */ mr r3, r31 /* 802E09B8 002DD918 48 05 E2 71 */ bl ReadFloat__12CInputStreamFv /* 802E09BC 002DD91C D0 3E 00 0C */ stfs f1, 0xc(r30) @@ -602,4 +602,3 @@ lbl_803D6D68: # ROM: 0x3D3D68 .asciz "??(??)" .balign 4 - diff --git a/asm/Kyoto/Animation/CMetaAnimRandom.s b/asm/Kyoto/Animation/CMetaAnimRandom.s index d9806116..198ed481 100644 --- a/asm/Kyoto/Animation/CMetaAnimRandom.s +++ b/asm/Kyoto/Animation/CMetaAnimRandom.s @@ -78,7 +78,7 @@ lbl_802E0FF4: /* 802E0FF8 002DDF58 41 82 00 10 */ beq lbl_802E1008 /* 802E0FFC 002DDF5C 41 82 00 0C */ beq lbl_802E1008 /* 802E1000 002DDF60 7F C3 F3 78 */ mr r3, r30 -/* 802E1004 002DDF64 4B D4 FF 2D */ bl sub_80030f30 +/* 802E1004 002DDF64 4B D4 FF 2D */ bl "ReleaseData__Q24rstl18rc_ptr<9IMetaAnim>Fv" lbl_802E1008: /* 802E1008 002DDF68 3B DE 00 08 */ addi r30, r30, 8 lbl_802E100C: @@ -142,7 +142,7 @@ lbl_802E10B4: /* 802E10CC 002DE02C 80 85 00 04 */ lwz r4, 4(r5) /* 802E10D0 002DE030 38 04 00 01 */ addi r0, r4, 1 /* 802E10D4 002DE034 90 05 00 04 */ stw r0, 4(r5) -/* 802E10D8 002DE038 4B D4 FE 59 */ bl sub_80030f30 +/* 802E10D8 002DE038 4B D4 FE 59 */ bl "ReleaseData__Q24rstl18rc_ptr<9IMetaAnim>Fv" /* 802E10DC 002DE03C 7F A3 EB 78 */ mr r3, r29 /* 802E10E0 002DE040 48 05 DB A5 */ bl ReadLong__12CInputStreamFv /* 802E10E4 002DE044 80 A1 00 0C */ lwz r5, 0xc(r1) @@ -181,9 +181,9 @@ lbl_802E1158: /* 802E115C 002DE0BC 38 61 00 10 */ addi r3, r1, 0x10 /* 802E1160 002DE0C0 38 04 00 01 */ addi r0, r4, 1 /* 802E1164 002DE0C4 90 01 00 1C */ stw r0, 0x1c(r1) -/* 802E1168 002DE0C8 4B D4 FD C9 */ bl sub_80030f30 +/* 802E1168 002DE0C8 4B D4 FD C9 */ bl "ReleaseData__Q24rstl18rc_ptr<9IMetaAnim>Fv" /* 802E116C 002DE0CC 38 61 00 0C */ addi r3, r1, 0xc -/* 802E1170 002DE0D0 4B D4 FD C1 */ bl sub_80030f30 +/* 802E1170 002DE0D0 4B D4 FD C1 */ bl "ReleaseData__Q24rstl18rc_ptr<9IMetaAnim>Fv" /* 802E1174 002DE0D4 3B DE 00 01 */ addi r30, r30, 1 lbl_802E1178: /* 802E1178 002DE0D8 7C 1E F8 00 */ cmpw r30, r31 @@ -291,7 +291,7 @@ lbl_802E12A8: /* 802E12E8 002DE248 48 05 E2 C1 */ bl DoPut__13COutputStreamFPCvUl /* 802E12EC 002DE24C 3B DE 00 08 */ addi r30, r30, 8 /* 802E12F0 002DE250 38 61 00 10 */ addi r3, r1, 0x10 -/* 802E12F4 002DE254 4B D4 FC 3D */ bl sub_80030f30 +/* 802E12F4 002DE254 4B D4 FC 3D */ bl "ReleaseData__Q24rstl18rc_ptr<9IMetaAnim>Fv" lbl_802E12F8: /* 802E12F8 002DE258 7C 1E F8 40 */ cmplw r30, r31 /* 802E12FC 002DE25C 40 82 FF AC */ bne lbl_802E12A8 @@ -529,7 +529,7 @@ lbl_802E1624: /* 802E1628 002DE588 41 82 00 10 */ beq lbl_802E1638 /* 802E162C 002DE58C 41 82 00 0C */ beq lbl_802E1638 /* 802E1630 002DE590 7F 63 DB 78 */ mr r3, r27 -/* 802E1634 002DE594 4B D4 F8 FD */ bl sub_80030f30 +/* 802E1634 002DE594 4B D4 F8 FD */ bl "ReleaseData__Q24rstl18rc_ptr<9IMetaAnim>Fv" lbl_802E1638: /* 802E1638 002DE598 3B 7B 00 08 */ addi r27, r27, 8 lbl_802E163C: @@ -556,4 +556,3 @@ lbl_803D6D78: # ROM: 0x3D3D78 .asciz "??(??)" .balign 4 - diff --git a/asm/Kyoto/Animation/CMetaAnimSequence.s b/asm/Kyoto/Animation/CMetaAnimSequence.s index 9076a703..b4ee4188 100644 --- a/asm/Kyoto/Animation/CMetaAnimSequence.s +++ b/asm/Kyoto/Animation/CMetaAnimSequence.s @@ -47,7 +47,7 @@ lbl_802E16D0: /* 802E16D0 002DE630 28 1E 00 00 */ cmplwi r30, 0 /* 802E16D4 002DE634 41 82 00 0C */ beq lbl_802E16E0 /* 802E16D8 002DE638 7F C3 F3 78 */ mr r3, r30 -/* 802E16DC 002DE63C 4B D4 F8 55 */ bl sub_80030f30 +/* 802E16DC 002DE63C 4B D4 F8 55 */ bl "ReleaseData__Q24rstl18rc_ptr<9IMetaAnim>Fv" lbl_802E16E0: /* 802E16E0 002DE640 3B DE 00 04 */ addi r30, r30, 4 lbl_802E16E4: @@ -117,7 +117,7 @@ lbl_802E17A0: /* 802E17B8 002DE718 80 85 00 04 */ lwz r4, 4(r5) /* 802E17BC 002DE71C 38 04 00 01 */ addi r0, r4, 1 /* 802E17C0 002DE720 90 05 00 04 */ stw r0, 4(r5) -/* 802E17C4 002DE724 4B D4 F7 6D */ bl sub_80030f30 +/* 802E17C4 002DE724 4B D4 F7 6D */ bl "ReleaseData__Q24rstl18rc_ptr<9IMetaAnim>Fv" /* 802E17C8 002DE728 80 01 00 24 */ lwz r0, 0x24(r1) /* 802E17CC 002DE72C 80 A1 00 28 */ lwz r5, 0x28(r1) /* 802E17D0 002DE730 7C 00 28 00 */ cmpw r0, r5 @@ -146,7 +146,7 @@ lbl_802E181C: /* 802E1820 002DE780 38 61 00 1C */ addi r3, r1, 0x1c /* 802E1824 002DE784 38 04 00 01 */ addi r0, r4, 1 /* 802E1828 002DE788 90 01 00 24 */ stw r0, 0x24(r1) -/* 802E182C 002DE78C 4B D4 F7 05 */ bl sub_80030f30 +/* 802E182C 002DE78C 4B D4 F7 05 */ bl "ReleaseData__Q24rstl18rc_ptr<9IMetaAnim>Fv" /* 802E1830 002DE790 3B DE 00 01 */ addi r30, r30, 1 lbl_802E1834: /* 802E1834 002DE794 7C 1E F8 00 */ cmpw r30, r31 @@ -211,7 +211,7 @@ lbl_802E1904: /* 802E1904 002DE864 28 1D 00 00 */ cmplwi r29, 0 /* 802E1908 002DE868 41 82 00 0C */ beq lbl_802E1914 /* 802E190C 002DE86C 7F A3 EB 78 */ mr r3, r29 -/* 802E1910 002DE870 4B D4 F6 21 */ bl sub_80030f30 +/* 802E1910 002DE870 4B D4 F6 21 */ bl "ReleaseData__Q24rstl18rc_ptr<9IMetaAnim>Fv" lbl_802E1914: /* 802E1914 002DE874 3B BD 00 04 */ addi r29, r29, 4 lbl_802E1918: @@ -398,7 +398,7 @@ lbl_802E1B8C: /* 802E1B9C 002DEAFC 90 01 00 38 */ stw r0, 0x38(r1) /* 802E1BA0 002DEB00 4B D4 F4 01 */ bl sub_80030fa0 /* 802E1BA4 002DEB04 38 61 00 20 */ addi r3, r1, 0x20 -/* 802E1BA8 002DEB08 4B D4 F3 89 */ bl sub_80030f30 +/* 802E1BA8 002DEB08 4B D4 F3 89 */ bl "ReleaseData__Q24rstl18rc_ptr<9IMetaAnim>Fv" lbl_802E1BAC: /* 802E1BAC 002DEB0C 7C 1E F8 40 */ cmplw r30, r31 /* 802E1BB0 002DEB10 40 82 FF 38 */ bne lbl_802E1AE8 @@ -545,7 +545,7 @@ lbl_802E1DA0: /* 802E1DA0 002DED00 28 1D 00 00 */ cmplwi r29, 0 /* 802E1DA4 002DED04 41 82 00 0C */ beq lbl_802E1DB0 /* 802E1DA8 002DED08 7F A3 EB 78 */ mr r3, r29 -/* 802E1DAC 002DED0C 4B D4 F1 85 */ bl sub_80030f30 +/* 802E1DAC 002DED0C 4B D4 F1 85 */ bl "ReleaseData__Q24rstl18rc_ptr<9IMetaAnim>Fv" lbl_802E1DB0: /* 802E1DB0 002DED10 3B BD 00 04 */ addi r29, r29, 4 lbl_802E1DB4: @@ -572,4 +572,3 @@ lbl_803D6D80: # ROM: 0x3D3D80 .asciz "??(??)" .balign 4 - diff --git a/asm/Kyoto/Animation/CMetaTransMetaAnim.s b/asm/Kyoto/Animation/CMetaTransMetaAnim.s index 1fe99ff2..face925c 100644 --- a/asm/Kyoto/Animation/CMetaTransMetaAnim.s +++ b/asm/Kyoto/Animation/CMetaTransMetaAnim.s @@ -31,7 +31,7 @@ __dt__18CMetaTransMetaAnimFv: /* 802E2008 002DEF68 90 1E 00 00 */ stw r0, 0(r30) /* 802E200C 002DEF6C 41 82 00 0C */ beq lbl_802E2018 /* 802E2010 002DEF70 38 7E 00 04 */ addi r3, r30, 4 -/* 802E2014 002DEF74 4B D4 EF 1D */ bl sub_80030f30 +/* 802E2014 002DEF74 4B D4 EF 1D */ bl "ReleaseData__Q24rstl18rc_ptr<9IMetaAnim>Fv" lbl_802E2018: /* 802E2018 002DEF78 28 1E 00 00 */ cmplwi r30, 0 /* 802E201C 002DEF7C 41 82 00 10 */ beq lbl_802E202C @@ -172,7 +172,7 @@ __ct__18CMetaTransMetaAnimFR12CInputStream: /* 802E21F4 002DF154 80 85 00 04 */ lwz r4, 4(r5) /* 802E21F8 002DF158 38 04 00 01 */ addi r0, r4, 1 /* 802E21FC 002DF15C 90 05 00 04 */ stw r0, 4(r5) -/* 802E2200 002DF160 4B D4 ED 31 */ bl sub_80030f30 +/* 802E2200 002DF160 4B D4 ED 31 */ bl "ReleaseData__Q24rstl18rc_ptr<9IMetaAnim>Fv" /* 802E2204 002DF164 80 01 00 24 */ lwz r0, 0x24(r1) /* 802E2208 002DF168 7F E3 FB 78 */ mr r3, r31 /* 802E220C 002DF16C 83 E1 00 1C */ lwz r31, 0x1c(r1) @@ -187,4 +187,3 @@ lbl_803D6D90: # ROM: 0x3D3D90 .asciz "??(??)" .balign 4 - diff --git a/asm/MetroidPrime/CAnimData.s b/asm/MetroidPrime/CAnimData.s index 7e4ed7f3..7b377102 100644 --- a/asm/MetroidPrime/CAnimData.s +++ b/asm/MetroidPrime/CAnimData.s @@ -3573,7 +3573,7 @@ GetAnimationDuration__9CAnimDataCFi: /* 8002C51C 0002947C 80 85 00 04 */ lwz r4, 4(r5) /* 8002C520 00029480 38 04 00 01 */ addi r0, r4, 1 /* 8002C524 00029484 90 05 00 04 */ stw r0, 4(r5) -/* 8002C528 00029488 48 00 4A 09 */ bl sub_80030f30 +/* 8002C528 00029488 48 00 4A 09 */ bl "ReleaseData__Q24rstl18rc_ptr<9IMetaAnim>Fv" /* 8002C52C 0002948C 38 61 00 18 */ addi r3, r1, 0x18 /* 8002C530 00029490 48 00 4E 7D */ bl sub_800313ac /* 8002C534 00029494 88 61 00 08 */ lbz r3, 8(r1) @@ -3714,7 +3714,7 @@ lbl_8002C718: /* 8002C724 00029684 90 01 00 5C */ stw r0, 0x5c(r1) /* 8002C728 00029688 90 01 00 60 */ stw r0, 0x60(r1) /* 8002C72C 0002968C 90 01 00 58 */ stw r0, 0x58(r1) -/* 8002C730 00029690 48 00 48 01 */ bl sub_80030f30 +/* 8002C730 00029690 48 00 48 01 */ bl "ReleaseData__Q24rstl18rc_ptr<9IMetaAnim>Fv" /* 8002C734 00029694 FC 20 F8 90 */ fmr f1, f31 /* 8002C738 00029698 E3 E1 00 98 */ psq_l f31, 152(r1), 0, qr0 /* 8002C73C 0002969C CB E1 00 90 */ lfd f31, 0x90(r1) @@ -4132,7 +4132,7 @@ lbl_8002CC5C: /* 8002CCE4 00029C44 7D 89 03 A6 */ mtctr r12 /* 8002CCE8 00029C48 4E 80 04 21 */ bctrl /* 8002CCEC 00029C4C 38 61 00 10 */ addi r3, r1, 0x10 -/* 8002CCF0 00029C50 48 00 42 41 */ bl sub_80030f30 +/* 8002CCF0 00029C50 48 00 42 41 */ bl "ReleaseData__Q24rstl18rc_ptr<9IMetaAnim>Fv" /* 8002CCF4 00029C54 38 61 00 14 */ addi r3, r1, 0x14 /* 8002CCF8 00029C58 48 00 46 B5 */ bl sub_800313ac /* 8002CCFC 00029C5C 2C 1F FF FF */ cmpwi r31, -1 @@ -4156,7 +4156,7 @@ lbl_8002CC5C: /* 8002CD44 00029CA4 7D 89 03 A6 */ mtctr r12 /* 8002CD48 00029CA8 4E 80 04 21 */ bctrl /* 8002CD4C 00029CAC 38 61 00 08 */ addi r3, r1, 8 -/* 8002CD50 00029CB0 48 00 41 E1 */ bl sub_80030f30 +/* 8002CD50 00029CB0 48 00 41 E1 */ bl "ReleaseData__Q24rstl18rc_ptr<9IMetaAnim>Fv" /* 8002CD54 00029CB4 38 61 00 0C */ addi r3, r1, 0xc /* 8002CD58 00029CB8 48 00 46 55 */ bl sub_800313ac lbl_8002CD5C: @@ -5824,7 +5824,7 @@ GetAverageVelocity__9CAnimDataCFi: /* 8002E574 0002B4D4 80 85 00 04 */ lwz r4, 4(r5) /* 8002E578 0002B4D8 38 04 00 01 */ addi r0, r4, 1 /* 8002E57C 0002B4DC 90 05 00 04 */ stw r0, 4(r5) -/* 8002E580 0002B4E0 48 00 29 B1 */ bl sub_80030f30 +/* 8002E580 0002B4E0 48 00 29 B1 */ bl "ReleaseData__Q24rstl18rc_ptr<9IMetaAnim>Fv" /* 8002E584 0002B4E4 88 61 00 08 */ lbz r3, 8(r1) /* 8002E588 0002B4E8 38 00 00 00 */ li r0, 0 /* 8002E58C 0002B4EC 88 A1 00 0C */ lbz r5, 0xc(r1) @@ -6000,7 +6000,7 @@ lbl_8002E7D4: /* 8002E7E0 0002B740 90 01 00 5C */ stw r0, 0x5c(r1) /* 8002E7E4 0002B744 90 01 00 60 */ stw r0, 0x60(r1) /* 8002E7E8 0002B748 90 01 00 58 */ stw r0, 0x58(r1) -/* 8002E7EC 0002B74C 48 00 27 45 */ bl sub_80030f30 +/* 8002E7EC 0002B74C 48 00 27 45 */ bl "ReleaseData__Q24rstl18rc_ptr<9IMetaAnim>Fv" /* 8002E7F0 0002B750 FC 20 F8 90 */ fmr f1, f31 /* 8002E7F4 0002B754 E3 E1 00 B8 */ psq_l f31, 184(r1), 0, qr0 /* 8002E7F8 0002B758 CB E1 00 B0 */ lfd f31, 0xb0(r1) @@ -8840,8 +8840,8 @@ lbl_80030F1C: /* 80030F28 0002DE88 38 21 00 10 */ addi r1, r1, 0x10 /* 80030F2C 0002DE8C 4E 80 00 20 */ blr -.global sub_80030f30 -sub_80030f30: +.global "ReleaseData__Q24rstl18rc_ptr<9IMetaAnim>Fv" +"ReleaseData__Q24rstl18rc_ptr<9IMetaAnim>Fv": /* 80030F30 0002DE90 94 21 FF F0 */ stwu r1, -0x10(r1) /* 80030F34 0002DE94 7C 08 02 A6 */ mflr r0 /* 80030F38 0002DE98 90 01 00 14 */ stw r0, 0x14(r1) diff --git a/asm/MetroidPrime/CAnimationDatabaseGame.s b/asm/MetroidPrime/CAnimationDatabaseGame.s index 78cca26e..0e70e0f9 100644 --- a/asm/MetroidPrime/CAnimationDatabaseGame.s +++ b/asm/MetroidPrime/CAnimationDatabaseGame.s @@ -3,8 +3,8 @@ .section .data .balign 8 -.global lbl_803DA320 -lbl_803DA320: +.global __vt__22CAnimationDatabaseGame +__vt__22CAnimationDatabaseGame: # ROM: 0x3D7320 .4byte 0 .4byte 0 @@ -81,7 +81,7 @@ lbl_8006D884: /* 8006D8E4 0006A844 93 C1 00 2C */ stw r30, 0x2c(r1) /* 8006D8E8 0006A848 90 01 00 10 */ stw r0, 0x10(r1) /* 8006D8EC 0006A84C 90 01 00 14 */ stw r0, 0x14(r1) -/* 8006D8F0 0006A850 48 00 00 41 */ bl sub_8006d930 +/* 8006D8F0 0006A850 48 00 00 41 */ bl "insert,Q24rstl18less<10CPrimitive>,Q24rstl17rmemory_allocator>8iterator>__Q24rstl47vector<10CPrimitive,Q24rstl17rmemory_allocator>FQ24rstl114pointer_iterator<10CPrimitive,Q24rstl47vector<10CPrimitive,Q24rstl17rmemory_allocator>,Q24rstl17rmemory_allocator>Q34rstl130red_black_tree<10CPrimitive,10CPrimitive,0,Q24rstl22identity<10CPrimitive>,Q24rstl18less<10CPrimitive>,Q24rstl17rmemory_allocator>8iteratorQ34rstl130red_black_tree<10CPrimitive,10CPrimitive,0,Q24rstl22identity<10CPrimitive>,Q24rstl18less<10CPrimitive>,Q24rstl17rmemory_allocator>8iterator" /* 8006D8F4 0006A854 80 81 00 48 */ lwz r4, 0x48(r1) /* 8006D8F8 0006A858 28 04 00 00 */ cmplwi r4, 0 /* 8006D8FC 0006A85C 41 82 00 0C */ beq lbl_8006D908 @@ -99,8 +99,8 @@ lbl_8006D908: /* 8006D928 0006A888 38 21 00 70 */ addi r1, r1, 0x70 /* 8006D92C 0006A88C 4E 80 00 20 */ blr -.global sub_8006d930 -sub_8006d930: +.global "insert,Q24rstl18less<10CPrimitive>,Q24rstl17rmemory_allocator>8iterator>__Q24rstl47vector<10CPrimitive,Q24rstl17rmemory_allocator>FQ24rstl114pointer_iterator<10CPrimitive,Q24rstl47vector<10CPrimitive,Q24rstl17rmemory_allocator>,Q24rstl17rmemory_allocator>Q34rstl130red_black_tree<10CPrimitive,10CPrimitive,0,Q24rstl22identity<10CPrimitive>,Q24rstl18less<10CPrimitive>,Q24rstl17rmemory_allocator>8iteratorQ34rstl130red_black_tree<10CPrimitive,10CPrimitive,0,Q24rstl22identity<10CPrimitive>,Q24rstl18less<10CPrimitive>,Q24rstl17rmemory_allocator>8iterator" +"insert,Q24rstl18less<10CPrimitive>,Q24rstl17rmemory_allocator>8iterator>__Q24rstl47vector<10CPrimitive,Q24rstl17rmemory_allocator>FQ24rstl114pointer_iterator<10CPrimitive,Q24rstl47vector<10CPrimitive,Q24rstl17rmemory_allocator>,Q24rstl17rmemory_allocator>Q34rstl130red_black_tree<10CPrimitive,10CPrimitive,0,Q24rstl22identity<10CPrimitive>,Q24rstl18less<10CPrimitive>,Q24rstl17rmemory_allocator>8iteratorQ34rstl130red_black_tree<10CPrimitive,10CPrimitive,0,Q24rstl22identity<10CPrimitive>,Q24rstl18less<10CPrimitive>,Q24rstl17rmemory_allocator>8iterator": /* 8006D930 0006A890 94 21 FF D0 */ stwu r1, -0x30(r1) /* 8006D934 0006A894 7C 08 02 A6 */ mflr r0 /* 8006D938 0006A898 90 01 00 34 */ stw r0, 0x34(r1) @@ -396,7 +396,7 @@ GetMetaAnimName__22CAnimationDatabaseGameCFUi: "__ct__22CAnimationDatabaseGameFRCQ24rstl47vector<10CAnimation,Q24rstl17rmemory_allocator>": /* 8006DD1C 0006AC7C 94 21 FF D0 */ stwu r1, -0x30(r1) /* 8006DD20 0006AC80 7C 08 02 A6 */ mflr r0 -/* 8006DD24 0006AC84 3C A0 80 3E */ lis r5, lbl_803D9BE0@ha +/* 8006DD24 0006AC84 3C A0 80 3E */ lis r5, __vt__18CAnimationDatabase@ha /* 8006DD28 0006AC88 90 01 00 34 */ stw r0, 0x34(r1) /* 8006DD2C 0006AC8C 38 00 00 00 */ li r0, 0 /* 8006DD30 0006AC90 93 E1 00 2C */ stw r31, 0x2c(r1) @@ -405,7 +405,7 @@ GetMetaAnimName__22CAnimationDatabaseGameCFUi: /* 8006DD3C 0006AC9C 93 A1 00 24 */ stw r29, 0x24(r1) /* 8006DD40 0006ACA0 7C 9D 23 78 */ mr r29, r4 /* 8006DD44 0006ACA4 98 01 00 10 */ stb r0, 0x10(r1) -/* 8006DD48 0006ACA8 38 05 9B E0 */ addi r0, r5, lbl_803D9BE0@l +/* 8006DD48 0006ACA8 38 05 9B E0 */ addi r0, r5, __vt__18CAnimationDatabase@l /* 8006DD4C 0006ACAC 90 03 00 00 */ stw r0, 0(r3) /* 8006DD50 0006ACB0 88 01 00 10 */ lbz r0, 0x10(r1) /* 8006DD54 0006ACB4 98 03 00 0C */ stb r0, 0xc(r3) @@ -426,9 +426,9 @@ lbl_8006DD74: /* 8006DD8C 0006ACEC 48 2D 30 B5 */ bl __dt__6CTokenFv lbl_8006DD90: /* 8006DD90 0006ACF0 38 80 00 00 */ li r4, 0 -/* 8006DD94 0006ACF4 3C 60 80 3E */ lis r3, lbl_803DA320@ha +/* 8006DD94 0006ACF4 3C 60 80 3E */ lis r3, __vt__22CAnimationDatabaseGame@ha /* 8006DD98 0006ACF8 98 81 00 10 */ stb r4, 0x10(r1) -/* 8006DD9C 0006ACFC 38 03 A3 20 */ addi r0, r3, lbl_803DA320@l +/* 8006DD9C 0006ACFC 38 03 A3 20 */ addi r0, r3, __vt__22CAnimationDatabaseGame@l /* 8006DDA0 0006AD00 38 7F 00 10 */ addi r3, r31, 0x10 /* 8006DDA4 0006AD04 90 1F 00 00 */ stw r0, 0(r31) /* 8006DDA8 0006AD08 90 9F 00 14 */ stw r4, 0x14(r31) @@ -682,7 +682,7 @@ lbl_8006E0F4: /* 8006E0F4 0006B054 28 1B 00 00 */ cmplwi r27, 0 /* 8006E0F8 0006B058 41 82 00 0C */ beq lbl_8006E104 /* 8006E0FC 0006B05C 7F 63 DB 78 */ mr r3, r27 -/* 8006E100 0006B060 4B FC 2E 31 */ bl sub_80030f30 +/* 8006E100 0006B060 4B FC 2E 31 */ bl "ReleaseData__Q24rstl18rc_ptr<9IMetaAnim>Fv" lbl_8006E104: /* 8006E104 0006B064 3B 7B 00 04 */ addi r27, r27, 4 lbl_8006E108: @@ -710,4 +710,3 @@ lbl_803CD250: .asciz "??(??)" .byte 0x4D .asciz "eta-animation name unavailable in Release mode." - diff --git a/asm/MetroidPrime/Factories/CCharacterFactory.s b/asm/MetroidPrime/Factories/CCharacterFactory.s index 1a4de6a2..746aa4fb 100644 --- a/asm/MetroidPrime/Factories/CCharacterFactory.s +++ b/asm/MetroidPrime/Factories/CCharacterFactory.s @@ -29,8 +29,8 @@ lbl_803D9BD4: .4byte 0 .4byte sub_80033d50 -.global lbl_803D9BE0 -lbl_803D9BE0: +.global __vt__18CAnimationDatabase +__vt__18CAnimationDatabase: # ROM: 0x3D6BE0 .4byte 0 .4byte 0 @@ -2015,9 +2015,9 @@ sub_80033440: /* 8003345C 000303BC 93 81 00 20 */ stw r28, 0x20(r1) /* 80033460 000303C0 7C 9C 23 78 */ mr r28, r4 /* 80033464 000303C4 41 82 00 B8 */ beq lbl_8003351C -/* 80033468 000303C8 3C 60 80 3E */ lis r3, lbl_803DA320@ha +/* 80033468 000303C8 3C 60 80 3E */ lis r3, __vt__22CAnimationDatabaseGame@ha /* 8003346C 000303CC 34 1F 00 10 */ addic. r0, r31, 0x10 -/* 80033470 000303D0 38 03 A3 20 */ addi r0, r3, lbl_803DA320@l +/* 80033470 000303D0 38 03 A3 20 */ addi r0, r3, __vt__22CAnimationDatabaseGame@l /* 80033474 000303D4 90 1F 00 00 */ stw r0, 0(r31) /* 80033478 000303D8 41 82 00 54 */ beq lbl_800334CC /* 8003347C 000303DC 80 1F 00 14 */ lwz r0, 0x14(r31) @@ -2033,7 +2033,7 @@ lbl_800334A0: /* 800334A0 00030400 28 1D 00 00 */ cmplwi r29, 0 /* 800334A4 00030404 41 82 00 0C */ beq lbl_800334B0 /* 800334A8 00030408 7F A3 EB 78 */ mr r3, r29 -/* 800334AC 0003040C 4B FF DA 85 */ bl sub_80030f30 +/* 800334AC 0003040C 4B FF DA 85 */ bl "ReleaseData__Q24rstl18rc_ptr<9IMetaAnim>Fv" lbl_800334B0: /* 800334B0 00030410 3B BD 00 04 */ addi r29, r29, 4 lbl_800334B4: @@ -2046,9 +2046,9 @@ lbl_800334B4: lbl_800334CC: /* 800334CC 0003042C 28 1F 00 00 */ cmplwi r31, 0 /* 800334D0 00030430 41 82 00 3C */ beq lbl_8003350C -/* 800334D4 00030434 3C 60 80 3E */ lis r3, lbl_803D9BE0@ha +/* 800334D4 00030434 3C 60 80 3E */ lis r3, __vt__18CAnimationDatabase@ha /* 800334D8 00030438 34 1F 00 04 */ addic. r0, r31, 4 -/* 800334DC 0003043C 38 03 9B E0 */ addi r0, r3, lbl_803D9BE0@l +/* 800334DC 0003043C 38 03 9B E0 */ addi r0, r3, __vt__18CAnimationDatabase@l /* 800334E0 00030440 90 1F 00 00 */ stw r0, 0(r31) /* 800334E4 00030444 41 82 00 28 */ beq lbl_8003350C /* 800334E8 00030448 88 1F 00 0C */ lbz r0, 0xc(r31) diff --git a/configure.py b/configure.py index 084f3010..c58da97a 100755 --- a/configure.py +++ b/configure.py @@ -81,7 +81,7 @@ LIBS = [ "MetroidPrime/Cameras/CGameCamera", "MetroidPrime/CGameArea", "MetroidPrime/HUD/CSamusHud", - "MetroidPrime/CAnimationDatabaseGame", + ["MetroidPrime/CAnimationDatabaseGame", False], "MetroidPrime/CTransitionDatabaseGame", ["MetroidPrime/Tweaks/CTweakPlayerControl", True], "MetroidPrime/Tweaks/CTweakPlayerGun", diff --git a/include/Kyoto/Animation/CAnimation.hpp b/include/Kyoto/Animation/CAnimation.hpp new file mode 100644 index 00000000..eeb755f5 --- /dev/null +++ b/include/Kyoto/Animation/CAnimation.hpp @@ -0,0 +1,18 @@ +#ifndef _CANIMATION +#define _CANIMATION + +#include "rstl/rc_ptr.hpp" +#include "rstl/string.hpp" + +class IMetaAnim; + +class CAnimation { +public: + const rstl::rc_ptr< IMetaAnim >& GetMetaAnim() const { return x10_anim; } + +private: + rstl::string x0_name; + rstl::rc_ptr< IMetaAnim > x10_anim; +}; + +#endif // _CANIMATION diff --git a/include/Kyoto/Animation/CPrimitive.hpp b/include/Kyoto/Animation/CPrimitive.hpp new file mode 100644 index 00000000..4df591ef --- /dev/null +++ b/include/Kyoto/Animation/CPrimitive.hpp @@ -0,0 +1,15 @@ +#ifndef _CPRIMITIVE +#define _CPRIMITIVE + +#include "Kyoto/SObjectTag.hpp" + +#include "rstl/string.hpp" + +class CPrimitive { +private: + CAssetId x0_animId; + int x4_animIdx; + rstl::string x8_animName; +}; + +#endif // _CPRIMITIVE diff --git a/include/Kyoto/Animation/IMetaAnim.hpp b/include/Kyoto/Animation/IMetaAnim.hpp new file mode 100644 index 00000000..75b52589 --- /dev/null +++ b/include/Kyoto/Animation/IMetaAnim.hpp @@ -0,0 +1,33 @@ +#ifndef _IMETAANIM +#define _IMETAANIM + +#include "rstl/rc_ptr.hpp" +#include "rstl/set.hpp" + +enum EMetaAnimType { kMAT_Play, kMAT_Blend, kMAT_PhaseBlend, kMAT_Random, kMAT_Sequence }; + +class CAnimTreeNode; +class CPrimitive; +class CCharAnimTime; +class IAnimReader; +class CAnimSysContext; +class CMetaAnimTreeBuildOrders; +class CPreAdvanceIndicator; + +class IMetaAnim { +public: + virtual ~IMetaAnim(); + + virtual rstl::rc_ptr< CAnimTreeNode > + GetAnimationTree(const CAnimSysContext& animSys, const CMetaAnimTreeBuildOrders& orders) const; + virtual void GetUniquePrimitives(rstl::set< CPrimitive >& primsOut) const = 0; + virtual EMetaAnimType GetType() const = 0; + virtual rstl::rc_ptr< CAnimTreeNode > + VGetAnimationTree(const CAnimSysContext& animSys, + const CMetaAnimTreeBuildOrders& orders) const = 0; + + static void AdvanceAnim(IAnimReader& anim, const CCharAnimTime& dt); + static CCharAnimTime GetTime(const CPreAdvanceIndicator& ind, const IAnimReader& anim); +}; + +#endif // _IMETAANIM diff --git a/include/MetroidPrime/CAnimationDatabaseGame.hpp b/include/MetroidPrime/CAnimationDatabaseGame.hpp new file mode 100644 index 00000000..ba4713e6 --- /dev/null +++ b/include/MetroidPrime/CAnimationDatabaseGame.hpp @@ -0,0 +1,48 @@ +#ifndef _CANIMATIONDATABASEGAME +#define _CANIMATIONDATABASEGAME + +#include "Kyoto/TToken.hpp" + +#include "rstl/optional_object.hpp" +#include "rstl/rc_ptr.hpp" +#include "rstl/set.hpp" +#include "rstl/string.hpp" +#include "rstl/vector.hpp" + +class CPrimitive; +class CAnimation; +class IMetaAnim; + +class CAnimationDatabase { +public: + CAnimationDatabase() + : x4_(false ? rstl::optional_object< CToken >() : rstl::optional_object_null()) {} + + virtual ~CAnimationDatabase(); + virtual const rstl::rc_ptr< IMetaAnim >& GetMetaAnim(uint idx) const = 0; + virtual uint GetNumMetaAnims() const = 0; + virtual rstl::string GetMetaAnimName(uint idx) const = 0; + virtual void GetAllUniquePrimitives(rstl::vector< CPrimitive >& primsOut) const = 0; + virtual void GetUniquePrimitivesFromMetaAnim(rstl::set< CPrimitive >& primsOut, + const rstl::string& name) const = 0; + +private: + rstl::optional_object< CToken > x4_; +}; + +class CAnimationDatabaseGame final : public CAnimationDatabase { +public: + explicit CAnimationDatabaseGame(const rstl::vector< CAnimation >& anims); + + const rstl::rc_ptr< IMetaAnim >& GetMetaAnim(uint idx) const override; + uint GetNumMetaAnims() const override; + rstl::string GetMetaAnimName(uint idx) const override; + void GetAllUniquePrimitives(rstl::vector< CPrimitive >& primsOut) const override; + void GetUniquePrimitivesFromMetaAnim(rstl::set< CPrimitive >& primsOut, + const rstl::string& name) const override; + +private: + rstl::vector< rstl::rc_ptr< IMetaAnim > > x10_anims; +}; + +#endif // _CANIMATIONDATABASEGAME diff --git a/include/rstl/iterator.hpp b/include/rstl/iterator.hpp new file mode 100644 index 00000000..1eb252fb --- /dev/null +++ b/include/rstl/iterator.hpp @@ -0,0 +1,30 @@ +#ifndef _RSTL_ITERATOR +#define _RSTL_ITERATOR + +namespace rstl { + +struct input_iterator_tag {}; +struct output_iterator_tag {}; +struct forward_iterator_tag : public input_iterator_tag {}; +struct bidirectional_iterator_tag : public forward_iterator_tag {}; +struct random_access_iterator_tag : public bidirectional_iterator_tag {}; + +template < typename It > +typename It::difference_type __distance(It first, It last, forward_iterator_tag) { + typename It::difference_type result = 0; + It it = first; + while (it != last) { + ++result; + ++it; + } + return result; +} + +template < typename It > +typename It::difference_type distance(It first, It last) { + return __distance(first, last, typename It::iterator_category()); +} + +} // namespace rstl + +#endif // _RSTL_ITERATOR diff --git a/include/rstl/pointer_iterator.hpp b/include/rstl/pointer_iterator.hpp index 75d65bbd..cd153e61 100644 --- a/include/rstl/pointer_iterator.hpp +++ b/include/rstl/pointer_iterator.hpp @@ -5,13 +5,9 @@ #include "types.h" #include "rstl/construct.hpp" +#include "rstl/iterator.hpp" namespace rstl { -struct input_iterator_tag {}; -struct output_iterator_tag {}; -struct forward_iterator_tag : public input_iterator_tag {}; -struct bidirectional_iterator_tag : public forward_iterator_tag {}; -struct random_access_iterator_tag : public bidirectional_iterator_tag {}; template < typename T, typename Vec, typename Alloc > class const_pointer_iterator { @@ -131,10 +127,7 @@ inline typename It::difference_type __distance(It first, It last, random_access_ return last - first; } -template < typename It > -inline typename It::difference_type distance(It first, It last) { - return __distance(first, last, typename It::iterator_category()); -} + } // namespace rstl #endif // _RSTL_POINTER_ITERATOR diff --git a/include/rstl/red_black_tree.hpp b/include/rstl/red_black_tree.hpp index fbe8de7e..e0ac7d3e 100644 --- a/include/rstl/red_black_tree.hpp +++ b/include/rstl/red_black_tree.hpp @@ -5,6 +5,7 @@ #include "rstl/pair.hpp" #include "rstl/rmemory_allocator.hpp" +#include "rstl/iterator.hpp" namespace rstl { template < typename P > @@ -82,6 +83,10 @@ private: public: struct const_iterator { + typedef int difference_type; + typedef forward_iterator_tag iterator_category; + typedef P* value_type; + node* mNode; const header* mHeader; // bool x8_; @@ -136,6 +141,15 @@ public: return const_iterator(nullptr, &x8_header, false); } + iterator begin() { + // TODO + return iterator(x8_header.get_leftmost(), &x8_header, false); + } + iterator end() { + // TODO + return iterator(nullptr, &x8_header, false); + } + const_iterator find(const T& key) const { node* n = x8_header.get_root(); node* needle = nullptr; @@ -197,6 +211,8 @@ public: x4_count = 0; } + int size() const { return x4_count; } + private: uchar x0_; uchar x1_; diff --git a/include/rstl/set.hpp b/include/rstl/set.hpp index b9e50be0..c8b5d599 100644 --- a/include/rstl/set.hpp +++ b/include/rstl/set.hpp @@ -24,11 +24,14 @@ public: const_iterator begin() const { return inner.begin(); } const_iterator end() const { return inner.end(); } + iterator begin() { return inner.begin(); } + iterator end() { return inner.end(); } iterator find(const T& key) { return inner.find(key); } const_iterator find(const T& key) const { return inner.find(key); } void erase(iterator it) { inner.erase(it); } + int size() const { return inner.size(); } private: rep_type inner; }; diff --git a/include/rstl/vector.hpp b/include/rstl/vector.hpp index 31db9826..5b90b535 100644 --- a/include/rstl/vector.hpp +++ b/include/rstl/vector.hpp @@ -48,7 +48,7 @@ public: uninitialized_fill_n(xc_items, count, v); } vector(int count, const T& v, const Alloc& alloc); - + vector(const vector& other) : x4_count(other.x4_count), x8_capacity(other.x8_capacity) { if (other.x4_count == 0 && other.x8_capacity == 0) { xc_items = nullptr; @@ -65,7 +65,8 @@ public: void reserve(int size); void resize(int size, const T& in); - iterator insert(iterator it, const T& value); // TODO + iterator insert(iterator it, const T& value); + template < typename from_iterator > iterator insert(iterator it, from_iterator begin, from_iterator end); @@ -104,15 +105,7 @@ public: protected: template < typename In > - void insert_into(iterator at, int n, In in) { - // int insertAt = xc_items + n; - // TODO: finish - if (x8_capacity < n) { - int newCapacity = x8_capacity != 0 ? x8_capacity * 2 : 4; - T* newData; - x0_allocator.allocate(newData, newCapacity); - } - } + iterator insert_into(iterator at, int n, In in); }; template < typename T, typename Alloc > @@ -149,6 +142,50 @@ typename vector< T, Alloc >::iterator vector< T, Alloc >::insert(iterator it, co return begin() + diff; } +template < typename T, typename Alloc > +template < typename from_iterator > +typename vector< T, Alloc >::iterator vector< T, Alloc >::insert(iterator it, from_iterator begin, + from_iterator end) { + return insert_into(it, rstl::distance(begin, end), begin); +} + +template < typename T, typename Alloc > +template < typename In > +typename vector< T, Alloc >::iterator vector< T, Alloc >::insert_into(iterator at, int n, In in) { + // TODO: correct + // An implementation can be found in CAnimationDatabaseGame.o + int newCount = x4_count + n; + if (newCount <= x8_capacity) { + int diffFromAt = at - begin(); + int diff = x4_count - diffFromAt - 1; + + for (int i = diff; 0 <= diff; --i) { + construct(xc_items + (diffFromAt + i), xc_items[i]); + destroy(data() + i); + } + + uninitialized_copy_n(in, n, begin() + diffFromAt); + + x4_count += n; + + } else { + int newCapacity = x8_capacity != 0 ? x8_capacity * 2 : 4; + for (; newCapacity < newCount; newCapacity *= 2); + T* newData; + x0_allocator.allocate(newData, newCapacity); + + int diffFromAt = at - begin(); + uninitialized_copy_n(begin(), diffFromAt, newData); + uninitialized_copy_n(in, n, newData + diffFromAt); + uninitialized_copy_n(begin() + diffFromAt, x4_count - diffFromAt, newData + diffFromAt + n); + destroy(xc_items, xc_items + x4_count); + x0_allocator.deallocate(xc_items); + xc_items = newData; + x8_capacity = newCapacity; + x4_count += n; + } +} + template < typename T, typename Alloc > vector< T, Alloc >& vector< T, Alloc >::operator=(const vector< T, Alloc >& other) { if (this == &other) @@ -177,7 +214,7 @@ typename vector< T, Alloc >::iterator vector< T, Alloc >::erase(iterator first, destroy(first, last); iterator start = begin(); int newCount = rstl::distance(first, start); - + iterator moved = start + newCount; for (iterator it = last; it != end(); ++it) { construct(&*moved, *it); diff --git a/src/MetroidPrime/CAnimationDatabaseGame.cpp b/src/MetroidPrime/CAnimationDatabaseGame.cpp new file mode 100644 index 00000000..a422839b --- /dev/null +++ b/src/MetroidPrime/CAnimationDatabaseGame.cpp @@ -0,0 +1,36 @@ +#include "MetroidPrime/CAnimationDatabaseGame.hpp" + +#include "Kyoto/Animation/CAnimation.hpp" +#include "Kyoto/Animation/CPrimitive.hpp" +#include "Kyoto/Animation/IMetaAnim.hpp" + +CAnimationDatabaseGame::CAnimationDatabaseGame(const rstl::vector< CAnimation >& anims) { + rstl::vector< CAnimation >::const_iterator it = anims.begin(), end = anims.end(); + x10_anims.reserve(anims.size()); + for (; it != end; ++it) + x10_anims.push_back(it->GetMetaAnim()); +} + +rstl::string CAnimationDatabaseGame::GetMetaAnimName(uint idx) const { + return "Meta-animation name unavailable in Release mode."; +} + +uint CAnimationDatabaseGame::GetNumMetaAnims() const { return x10_anims.size(); } + +const rstl::rc_ptr< IMetaAnim >& CAnimationDatabaseGame::GetMetaAnim(uint idx) const { + return x10_anims[idx]; +} + +void CAnimationDatabaseGame::GetAllUniquePrimitives(rstl::vector< CPrimitive >& primsOut) const { + rstl::set< CPrimitive > primitives; + uint animCount = x10_anims.size(); + for (uint i = 0; i < animCount; ++i) { + x10_anims[i]->GetUniquePrimitives(primitives); + } + + primsOut.reserve(primsOut.size() + primitives.size()); + primsOut.insert(primsOut.end(), primitives.begin(), primitives.end()); +} + +void CAnimationDatabaseGame::GetUniquePrimitivesFromMetaAnim(rstl::set< CPrimitive >& primsOut, + const rstl::string& name) const {}