From a1776db0cf354109f14f2e5205f2d53980eb7f50 Mon Sep 17 00:00:00 2001 From: Henrique Gemignani Passos Lima Date: Tue, 18 Oct 2022 23:21:14 +0300 Subject: [PATCH] Also match CGameLight Former-commit-id: f091a58822be6087796d7b571cbc468494a77f0c --- asm/MetroidPrime/CExplosion.s | 2 +- asm/MetroidPrime/CGameLight.s | 16 +++--- asm/MetroidPrime/CGameProjectile.s | 2 +- asm/MetroidPrime/CParticleGenInfo.s | 2 +- asm/MetroidPrime/Enemies/CDrone.s | 4 +- asm/MetroidPrime/Enemies/CThardus.s | 2 +- asm/MetroidPrime/Player/CMorphBall.s | 2 +- asm/MetroidPrime/Player/CPlayerGun.s | 2 +- .../ScriptObjects/CScriptEffect.s | 2 +- .../ScriptObjects/CScriptGunTurret.s | 2 +- asm/MetroidPrime/Weapons/CBomb.s | 2 +- asm/MetroidPrime/Weapons/CIceImpact.s | 2 +- asm/MetroidPrime/Weapons/CNewFlameThrower.s | 2 +- asm/MetroidPrime/Weapons/CPlasmaProjectile.s | 2 +- asm/MetroidPrime/Weapons/CShockWave.s | 2 +- configure.py | 2 +- include/Kyoto/Graphics/CLight.hpp | 3 + include/MetroidPrime/CGameLight.hpp | 7 ++- src/MetroidPrime/CGameLight.cpp | 56 +++++++++++++++++++ 19 files changed, 87 insertions(+), 27 deletions(-) create mode 100644 src/MetroidPrime/CGameLight.cpp diff --git a/asm/MetroidPrime/CExplosion.s b/asm/MetroidPrime/CExplosion.s index e0e6a26b..e9df51a3 100644 --- a/asm/MetroidPrime/CExplosion.s +++ b/asm/MetroidPrime/CExplosion.s @@ -286,7 +286,7 @@ lbl_8005A378: /* 8005A464 000573C4 39 1C 00 34 */ addi r8, r28, 0x34 /* 8005A468 000573C8 39 21 00 28 */ addi r9, r1, 0x28 /* 8005A46C 000573CC 39 41 00 58 */ addi r10, r1, 0x58 -/* 8005A470 000573D0 48 05 B3 B5 */ bl "__ct__10CGameLightF9TUniqueIdbRCQ24rstl66basic_string,Q24rstl17rmemory_allocator>RC12CTransform4f9TUniqueIdRC6CLightUiUif" +/* 8005A470 000573D0 48 05 B3 B5 */ bl "__ct__10CGameLightF9TUniqueId7TAreaIdbRCQ24rstl66basic_string,Q24rstl17rmemory_allocator>RC12CTransform4f9TUniqueIdRC6CLightUiUif" /* 8005A474 000573D4 7C 7A 1B 78 */ mr r26, r3 lbl_8005A478: /* 8005A478 000573D8 7F E3 FB 78 */ mr r3, r31 diff --git a/asm/MetroidPrime/CGameLight.s b/asm/MetroidPrime/CGameLight.s index 5447f229..2d722b72 100644 --- a/asm/MetroidPrime/CGameLight.s +++ b/asm/MetroidPrime/CGameLight.s @@ -3,8 +3,8 @@ .section .data .balign 8 -.global lbl_803DF3B8 -lbl_803DF3B8: +.global __vt__10CGameLight +__vt__10CGameLight: # ROM: 0x3DC3B8 .4byte 0 .4byte 0 @@ -65,9 +65,9 @@ __dt__10CGameLightFv: /* 800B55B4 000B2514 93 C1 00 08 */ stw r30, 8(r1) /* 800B55B8 000B2518 7C 7E 1B 79 */ or. r30, r3, r3 /* 800B55BC 000B251C 41 82 00 28 */ beq lbl_800B55E4 -/* 800B55C0 000B2520 3C A0 80 3E */ lis r5, lbl_803DF3B8@ha +/* 800B55C0 000B2520 3C A0 80 3E */ lis r5, __vt__10CGameLight@ha /* 800B55C4 000B2524 38 80 00 00 */ li r4, 0 -/* 800B55C8 000B2528 38 05 F3 B8 */ addi r0, r5, lbl_803DF3B8@l +/* 800B55C8 000B2528 38 05 F3 B8 */ addi r0, r5, __vt__10CGameLight@l /* 800B55CC 000B252C 90 1E 00 00 */ stw r0, 0(r30) /* 800B55D0 000B2530 4B FA 01 21 */ bl __dt__6CActorFv /* 800B55D4 000B2534 7F E0 07 35 */ extsh. r0, r31 @@ -237,8 +237,8 @@ SetLight__10CGameLightFRC6CLight: /* 800B581C 000B277C 38 21 00 10 */ addi r1, r1, 0x10 /* 800B5820 000B2780 4E 80 00 20 */ blr -.global "__ct__10CGameLightF9TUniqueIdbRCQ24rstl66basic_string,Q24rstl17rmemory_allocator>RC12CTransform4f9TUniqueIdRC6CLightUiUif" -"__ct__10CGameLightF9TUniqueIdbRCQ24rstl66basic_string,Q24rstl17rmemory_allocator>RC12CTransform4f9TUniqueIdRC6CLightUiUif": +.global "__ct__10CGameLightF9TUniqueId7TAreaIdbRCQ24rstl66basic_string,Q24rstl17rmemory_allocator>RC12CTransform4f9TUniqueIdRC6CLightUiUif" +"__ct__10CGameLightF9TUniqueId7TAreaIdbRCQ24rstl66basic_string,Q24rstl17rmemory_allocator>RC12CTransform4f9TUniqueIdRC6CLightUiUif": /* 800B5824 000B2784 94 21 FE C0 */ stwu r1, -0x140(r1) /* 800B5828 000B2788 7C 08 02 A6 */ mflr r0 /* 800B582C 000B278C 3D 60 80 57 */ lis r11, NullConnectionList__7CEntity@ha @@ -323,9 +323,9 @@ lbl_800B5954: /* 800B5960 000B28C0 41 82 00 08 */ beq lbl_800B5968 /* 800B5964 000B28C4 48 25 FF CD */ bl Free__7CMemoryFPCv lbl_800B5968: -/* 800B5968 000B28C8 3C 60 80 3E */ lis r3, lbl_803DF3B8@ha +/* 800B5968 000B28C8 3C 60 80 3E */ lis r3, __vt__10CGameLight@ha /* 800B596C 000B28CC 7F A4 EB 78 */ mr r4, r29 -/* 800B5970 000B28D0 38 03 F3 B8 */ addi r0, r3, lbl_803DF3B8@l +/* 800B5970 000B28D0 38 03 F3 B8 */ addi r0, r3, __vt__10CGameLight@l /* 800B5974 000B28D4 38 77 00 EC */ addi r3, r23, 0xec /* 800B5978 000B28D8 90 17 00 00 */ stw r0, 0(r23) /* 800B597C 000B28DC A0 1C 00 00 */ lhz r0, 0(r28) diff --git a/asm/MetroidPrime/CGameProjectile.s b/asm/MetroidPrime/CGameProjectile.s index ff74f8b8..f056af28 100644 --- a/asm/MetroidPrime/CGameProjectile.s +++ b/asm/MetroidPrime/CGameProjectile.s @@ -584,7 +584,7 @@ lbl_800378E8: /* 800379AC 0003490C 39 21 00 18 */ addi r9, r1, 0x18 /* 800379B0 00034910 93 A1 00 08 */ stw r29, 8(r1) /* 800379B4 00034914 90 01 00 0C */ stw r0, 0xc(r1) -/* 800379B8 00034918 48 07 DE 6D */ bl "__ct__10CGameLightF9TUniqueIdbRCQ24rstl66basic_string,Q24rstl17rmemory_allocator>RC12CTransform4f9TUniqueIdRC6CLightUiUif" +/* 800379B8 00034918 48 07 DE 6D */ bl "__ct__10CGameLightF9TUniqueId7TAreaIdbRCQ24rstl66basic_string,Q24rstl17rmemory_allocator>RC12CTransform4f9TUniqueIdRC6CLightUiUif" /* 800379BC 0003491C 7C 7F 1B 78 */ mr r31, r3 lbl_800379C0: /* 800379C0 00034920 7F 83 E3 78 */ mr r3, r28 diff --git a/asm/MetroidPrime/CParticleGenInfo.s b/asm/MetroidPrime/CParticleGenInfo.s index 04dac9ae..64953738 100644 --- a/asm/MetroidPrime/CParticleGenInfo.s +++ b/asm/MetroidPrime/CParticleGenInfo.s @@ -161,7 +161,7 @@ lbl_800B776C: /* 800B78C0 000B4820 39 21 00 14 */ addi r9, r1, 0x14 /* 800B78C4 000B4824 39 41 00 88 */ addi r10, r1, 0x88 /* 800B78C8 000B4828 38 C0 00 00 */ li r6, 0 -/* 800B78CC 000B482C 4B FF DF 59 */ bl "__ct__10CGameLightF9TUniqueIdbRCQ24rstl66basic_string,Q24rstl17rmemory_allocator>RC12CTransform4f9TUniqueIdRC6CLightUiUif" +/* 800B78CC 000B482C 4B FF DF 59 */ bl "__ct__10CGameLightF9TUniqueId7TAreaIdbRCQ24rstl66basic_string,Q24rstl17rmemory_allocator>RC12CTransform4f9TUniqueIdRC6CLightUiUif" /* 800B78D0 000B4830 7C 7A 1B 78 */ mr r26, r3 lbl_800B78D4: /* 800B78D4 000B4834 7F A3 EB 78 */ mr r3, r29 diff --git a/asm/MetroidPrime/Enemies/CDrone.s b/asm/MetroidPrime/Enemies/CDrone.s index b85b2bea..a442f299 100644 --- a/asm/MetroidPrime/Enemies/CDrone.s +++ b/asm/MetroidPrime/Enemies/CDrone.s @@ -8735,7 +8735,7 @@ lbl_80166498: /* 801665A0 00163500 39 21 00 1C */ addi r9, r1, 0x1c /* 801665A4 00163504 90 01 00 08 */ stw r0, 8(r1) /* 801665A8 00163508 90 01 00 0C */ stw r0, 0xc(r1) -/* 801665AC 0016350C 4B F4 F2 79 */ bl "__ct__10CGameLightF9TUniqueIdbRCQ24rstl66basic_string,Q24rstl17rmemory_allocator>RC12CTransform4f9TUniqueIdRC6CLightUiUif" +/* 801665AC 0016350C 4B F4 F2 79 */ bl "__ct__10CGameLightF9TUniqueId7TAreaIdbRCQ24rstl66basic_string,Q24rstl17rmemory_allocator>RC12CTransform4f9TUniqueIdRC6CLightUiUif" /* 801665B0 00163510 7C 7D 1B 78 */ mr r29, r3 lbl_801665B4: /* 801665B4 00163514 7F 80 07 75 */ extsb. r0, r28 @@ -9884,7 +9884,7 @@ lbl_801675E4: /* 801676A4 00164604 39 21 00 1C */ addi r9, r1, 0x1c /* 801676A8 00164608 90 01 00 08 */ stw r0, 8(r1) /* 801676AC 0016460C 90 01 00 0C */ stw r0, 0xc(r1) -/* 801676B0 00164610 4B F4 E1 75 */ bl "__ct__10CGameLightF9TUniqueIdbRCQ24rstl66basic_string,Q24rstl17rmemory_allocator>RC12CTransform4f9TUniqueIdRC6CLightUiUif" +/* 801676B0 00164610 4B F4 E1 75 */ bl "__ct__10CGameLightF9TUniqueId7TAreaIdbRCQ24rstl66basic_string,Q24rstl17rmemory_allocator>RC12CTransform4f9TUniqueIdRC6CLightUiUif" /* 801676B4 00164614 7C 7D 1B 78 */ mr r29, r3 lbl_801676B8: /* 801676B8 00164618 7F 80 07 75 */ extsb. r0, r28 diff --git a/asm/MetroidPrime/Enemies/CThardus.s b/asm/MetroidPrime/Enemies/CThardus.s index e97d84c1..ed975073 100644 --- a/asm/MetroidPrime/Enemies/CThardus.s +++ b/asm/MetroidPrime/Enemies/CThardus.s @@ -8330,7 +8330,7 @@ lbl_801E14FC: /* 801E15A4 001DE504 39 21 00 A0 */ addi r9, r1, 0xa0 /* 801E15A8 001DE508 39 41 02 F4 */ addi r10, r1, 0x2f4 /* 801E15AC 001DE50C 38 C0 00 00 */ li r6, 0 -/* 801E15B0 001DE510 4B ED 42 75 */ bl "__ct__10CGameLightF9TUniqueIdbRCQ24rstl66basic_string,Q24rstl17rmemory_allocator>RC12CTransform4f9TUniqueIdRC6CLightUiUif" +/* 801E15B0 001DE510 4B ED 42 75 */ bl "__ct__10CGameLightF9TUniqueId7TAreaIdbRCQ24rstl66basic_string,Q24rstl17rmemory_allocator>RC12CTransform4f9TUniqueIdRC6CLightUiUif" /* 801E15B4 001DE514 7C 73 1B 78 */ mr r19, r3 lbl_801E15B8: /* 801E15B8 001DE518 7E 63 9B 78 */ mr r3, r19 diff --git a/asm/MetroidPrime/Player/CMorphBall.s b/asm/MetroidPrime/Player/CMorphBall.s index afcd47a0..cf4aa83f 100644 --- a/asm/MetroidPrime/Player/CMorphBall.s +++ b/asm/MetroidPrime/Player/CMorphBall.s @@ -9807,7 +9807,7 @@ lbl_800F583C: /* 800F5924 000F2884 39 21 00 18 */ addi r9, r1, 0x18 /* 800F5928 000F2888 39 41 00 64 */ addi r10, r1, 0x64 /* 800F592C 000F288C 38 C0 00 00 */ li r6, 0 -/* 800F5930 000F2890 4B FB FE F5 */ bl "__ct__10CGameLightF9TUniqueIdbRCQ24rstl66basic_string,Q24rstl17rmemory_allocator>RC12CTransform4f9TUniqueIdRC6CLightUiUif" +/* 800F5930 000F2890 4B FB FE F5 */ bl "__ct__10CGameLightF9TUniqueId7TAreaIdbRCQ24rstl66basic_string,Q24rstl17rmemory_allocator>RC12CTransform4f9TUniqueIdRC6CLightUiUif" /* 800F5934 000F2894 7C 7D 1B 78 */ mr r29, r3 lbl_800F5938: /* 800F5938 000F2898 7F E3 FB 78 */ mr r3, r31 diff --git a/asm/MetroidPrime/Player/CPlayerGun.s b/asm/MetroidPrime/Player/CPlayerGun.s index 5ab0646e..90d3d2af 100644 --- a/asm/MetroidPrime/Player/CPlayerGun.s +++ b/asm/MetroidPrime/Player/CPlayerGun.s @@ -1684,7 +1684,7 @@ CreateGunLight__10CPlayerGunFR13CStateManager: /* 8003B8A8 00038808 39 21 00 14 */ addi r9, r1, 0x14 /* 8003B8AC 0003880C 39 41 00 30 */ addi r10, r1, 0x30 /* 8003B8B0 00038810 38 C0 00 00 */ li r6, 0 -/* 8003B8B4 00038814 48 07 9F 71 */ bl "__ct__10CGameLightF9TUniqueIdbRCQ24rstl66basic_string,Q24rstl17rmemory_allocator>RC12CTransform4f9TUniqueIdRC6CLightUiUif" +/* 8003B8B4 00038814 48 07 9F 71 */ bl "__ct__10CGameLightF9TUniqueId7TAreaIdbRCQ24rstl66basic_string,Q24rstl17rmemory_allocator>RC12CTransform4f9TUniqueIdRC6CLightUiUif" /* 8003B8B8 00038818 7C 7C 1B 78 */ mr r28, r3 lbl_8003B8BC: /* 8003B8BC 0003881C 7F E3 FB 78 */ mr r3, r31 diff --git a/asm/MetroidPrime/ScriptObjects/CScriptEffect.s b/asm/MetroidPrime/ScriptObjects/CScriptEffect.s index 064ef680..acab3d9e 100644 --- a/asm/MetroidPrime/ScriptObjects/CScriptEffect.s +++ b/asm/MetroidPrime/ScriptObjects/CScriptEffect.s @@ -988,7 +988,7 @@ lbl_8008E580: /* 8008E674 0008B5D4 39 1F 00 34 */ addi r8, r31, 0x34 /* 8008E678 0008B5D8 39 21 00 30 */ addi r9, r1, 0x30 /* 8008E67C 0008B5DC 39 41 01 BC */ addi r10, r1, 0x1bc -/* 8008E680 0008B5E0 48 02 71 A5 */ bl "__ct__10CGameLightF9TUniqueIdbRCQ24rstl66basic_string,Q24rstl17rmemory_allocator>RC12CTransform4f9TUniqueIdRC6CLightUiUif" +/* 8008E680 0008B5E0 48 02 71 A5 */ bl "__ct__10CGameLightF9TUniqueId7TAreaIdbRCQ24rstl66basic_string,Q24rstl17rmemory_allocator>RC12CTransform4f9TUniqueIdRC6CLightUiUif" /* 8008E684 0008B5E4 7C 79 1B 78 */ mr r25, r3 lbl_8008E688: /* 8008E688 0008B5E8 7F C3 F3 78 */ mr r3, r30 diff --git a/asm/MetroidPrime/ScriptObjects/CScriptGunTurret.s b/asm/MetroidPrime/ScriptObjects/CScriptGunTurret.s index 6c8a2946..ed0975ac 100644 --- a/asm/MetroidPrime/ScriptObjects/CScriptGunTurret.s +++ b/asm/MetroidPrime/ScriptObjects/CScriptGunTurret.s @@ -5382,7 +5382,7 @@ lbl_8021A2B0: /* 8021A3AC 0021730C 39 1E 00 34 */ addi r8, r30, 0x34 /* 8021A3B0 00217310 39 21 00 30 */ addi r9, r1, 0x30 /* 8021A3B4 00217314 39 41 01 50 */ addi r10, r1, 0x150 -/* 8021A3B8 00217318 4B E9 B4 6D */ bl "__ct__10CGameLightF9TUniqueIdbRCQ24rstl66basic_string,Q24rstl17rmemory_allocator>RC12CTransform4f9TUniqueIdRC6CLightUiUif" +/* 8021A3B8 00217318 4B E9 B4 6D */ bl "__ct__10CGameLightF9TUniqueId7TAreaIdbRCQ24rstl66basic_string,Q24rstl17rmemory_allocator>RC12CTransform4f9TUniqueIdRC6CLightUiUif" /* 8021A3BC 0021731C 7C 7D 1B 78 */ mr r29, r3 lbl_8021A3C0: /* 8021A3C0 00217320 7F E3 FB 78 */ mr r3, r31 diff --git a/asm/MetroidPrime/Weapons/CBomb.s b/asm/MetroidPrime/Weapons/CBomb.s index ed78ba71..c8a63efd 100644 --- a/asm/MetroidPrime/Weapons/CBomb.s +++ b/asm/MetroidPrime/Weapons/CBomb.s @@ -391,7 +391,7 @@ lbl_8008FD98: /* 8008FE7C 0008CDDC 39 21 00 30 */ addi r9, r1, 0x30 /* 8008FE80 0008CDE0 39 41 00 7C */ addi r10, r1, 0x7c /* 8008FE84 0008CDE4 38 C0 00 00 */ li r6, 0 -/* 8008FE88 0008CDE8 48 02 59 9D */ bl "__ct__10CGameLightF9TUniqueIdbRCQ24rstl66basic_string,Q24rstl17rmemory_allocator>RC12CTransform4f9TUniqueIdRC6CLightUiUif" +/* 8008FE88 0008CDE8 48 02 59 9D */ bl "__ct__10CGameLightF9TUniqueId7TAreaIdbRCQ24rstl66basic_string,Q24rstl17rmemory_allocator>RC12CTransform4f9TUniqueIdRC6CLightUiUif" /* 8008FE8C 0008CDEC 7C 7B 1B 78 */ mr r27, r3 lbl_8008FE90: /* 8008FE90 0008CDF0 7F E3 FB 78 */ mr r3, r31 diff --git a/asm/MetroidPrime/Weapons/CIceImpact.s b/asm/MetroidPrime/Weapons/CIceImpact.s index 6ad020ae..beaedb22 100644 --- a/asm/MetroidPrime/Weapons/CIceImpact.s +++ b/asm/MetroidPrime/Weapons/CIceImpact.s @@ -1563,7 +1563,7 @@ lbl_801B7058: /* 801B7144 001B40A4 39 1C 00 34 */ addi r8, r28, 0x34 /* 801B7148 001B40A8 39 21 00 28 */ addi r9, r1, 0x28 /* 801B714C 001B40AC 39 41 00 58 */ addi r10, r1, 0x58 -/* 801B7150 001B40B0 4B EF E6 D5 */ bl "__ct__10CGameLightF9TUniqueIdbRCQ24rstl66basic_string,Q24rstl17rmemory_allocator>RC12CTransform4f9TUniqueIdRC6CLightUiUif" +/* 801B7150 001B40B0 4B EF E6 D5 */ bl "__ct__10CGameLightF9TUniqueId7TAreaIdbRCQ24rstl66basic_string,Q24rstl17rmemory_allocator>RC12CTransform4f9TUniqueIdRC6CLightUiUif" /* 801B7154 001B40B4 7C 7A 1B 78 */ mr r26, r3 lbl_801B7158: /* 801B7158 001B40B8 7F E3 FB 78 */ mr r3, r31 diff --git a/asm/MetroidPrime/Weapons/CNewFlameThrower.s b/asm/MetroidPrime/Weapons/CNewFlameThrower.s index 9c469e73..072821fd 100644 --- a/asm/MetroidPrime/Weapons/CNewFlameThrower.s +++ b/asm/MetroidPrime/Weapons/CNewFlameThrower.s @@ -1093,7 +1093,7 @@ lbl_80261D70: /* 80261E3C 0025ED9C 39 21 00 18 */ addi r9, r1, 0x18 /* 80261E40 0025EDA0 39 41 00 3C */ addi r10, r1, 0x3c /* 80261E44 0025EDA4 38 C0 00 00 */ li r6, 0 -/* 80261E48 0025EDA8 4B E5 39 DD */ bl "__ct__10CGameLightF9TUniqueIdbRCQ24rstl66basic_string,Q24rstl17rmemory_allocator>RC12CTransform4f9TUniqueIdRC6CLightUiUif" +/* 80261E48 0025EDA8 4B E5 39 DD */ bl "__ct__10CGameLightF9TUniqueId7TAreaIdbRCQ24rstl66basic_string,Q24rstl17rmemory_allocator>RC12CTransform4f9TUniqueIdRC6CLightUiUif" /* 80261E4C 0025EDAC 7C 7B 1B 78 */ mr r27, r3 lbl_80261E50: /* 80261E50 0025EDB0 7F 00 07 75 */ extsb. r0, r24 diff --git a/asm/MetroidPrime/Weapons/CPlasmaProjectile.s b/asm/MetroidPrime/Weapons/CPlasmaProjectile.s index 505724a6..23d196d8 100644 --- a/asm/MetroidPrime/Weapons/CPlasmaProjectile.s +++ b/asm/MetroidPrime/Weapons/CPlasmaProjectile.s @@ -550,7 +550,7 @@ lbl_80177178: /* 8017720C 0017416C 39 1A 00 34 */ addi r8, r26, 0x34 /* 80177210 00174170 39 21 00 18 */ addi r9, r1, 0x18 /* 80177214 00174174 90 01 00 0C */ stw r0, 0xc(r1) -/* 80177218 00174178 4B F3 E6 0D */ bl "__ct__10CGameLightF9TUniqueIdbRCQ24rstl66basic_string,Q24rstl17rmemory_allocator>RC12CTransform4f9TUniqueIdRC6CLightUiUif" +/* 80177218 00174178 4B F3 E6 0D */ bl "__ct__10CGameLightF9TUniqueId7TAreaIdbRCQ24rstl66basic_string,Q24rstl17rmemory_allocator>RC12CTransform4f9TUniqueIdRC6CLightUiUif" /* 8017721C 0017417C 7C 79 1B 78 */ mr r25, r3 lbl_80177220: /* 80177220 00174180 7F A3 EB 78 */ mr r3, r29 diff --git a/asm/MetroidPrime/Weapons/CShockWave.s b/asm/MetroidPrime/Weapons/CShockWave.s index eced0d1a..beb1c1ac 100644 --- a/asm/MetroidPrime/Weapons/CShockWave.s +++ b/asm/MetroidPrime/Weapons/CShockWave.s @@ -223,7 +223,7 @@ lbl_802317D4: /* 802318C0 0022E820 39 1C 00 34 */ addi r8, r28, 0x34 /* 802318C4 0022E824 39 21 00 28 */ addi r9, r1, 0x28 /* 802318C8 0022E828 39 41 00 58 */ addi r10, r1, 0x58 -/* 802318CC 0022E82C 4B E8 3F 59 */ bl "__ct__10CGameLightF9TUniqueIdbRCQ24rstl66basic_string,Q24rstl17rmemory_allocator>RC12CTransform4f9TUniqueIdRC6CLightUiUif" +/* 802318CC 0022E82C 4B E8 3F 59 */ bl "__ct__10CGameLightF9TUniqueId7TAreaIdbRCQ24rstl66basic_string,Q24rstl17rmemory_allocator>RC12CTransform4f9TUniqueIdRC6CLightUiUif" /* 802318D0 0022E830 7C 7A 1B 78 */ mr r26, r3 lbl_802318D4: /* 802318D4 0022E834 7F E3 FB 78 */ mr r3, r31 diff --git a/configure.py b/configure.py index 1a9126d1..acd4d503 100755 --- a/configure.py +++ b/configure.py @@ -110,7 +110,7 @@ LIBS = [ ["MetroidPrime/UserNames", True], "MetroidPrime/ScriptObjects/CScriptGenerator", "MetroidPrime/ScriptObjects/CScriptCameraWaypoint", - "MetroidPrime/CGameLight", + ["MetroidPrime/CGameLight", False], "MetroidPrime/Tweaks/CTweakTargeting", "MetroidPrime/Tweaks/CTweakAutoMapper", ["MetroidPrime/CParticleGenInfoGeneric", True], diff --git a/include/Kyoto/Graphics/CLight.hpp b/include/Kyoto/Graphics/CLight.hpp index 053706b2..090d8995 100644 --- a/include/Kyoto/Graphics/CLight.hpp +++ b/include/Kyoto/Graphics/CLight.hpp @@ -48,6 +48,9 @@ public: float GetRadius() const; const CColor& GetColor() const { return x18_color; } + void SetPriority(uint priority) { x3c_priority = priority; } + void SetLightId(uint lightId) { x40_lightId = lightId; } + CVector3f GetNormalIndependentLightingAtPoint(const CVector3f& point) const; static CLight BuildDirectional(const CVector3f& dir, const CColor& color); diff --git a/include/MetroidPrime/CGameLight.hpp b/include/MetroidPrime/CGameLight.hpp index c493e2f7..e0444be4 100644 --- a/include/MetroidPrime/CGameLight.hpp +++ b/include/MetroidPrime/CGameLight.hpp @@ -10,12 +10,13 @@ public: CGameLight(TUniqueId uid, TAreaId aid, bool active, const rstl::string& name, const CTransform4f& xf, TUniqueId parentId, const CLight& light, uint sourceId, uint priority, float lifeTime); + ~CGameLight(); - void Accept(IVisitor& visitor) override; - void Think(float dt, CStateManager& mgr) override; - void SetLightPriorityAndId(); void SetLight(const CLight& light); CLight GetLight() const; + void Think(float dt, CStateManager& mgr) override; + void Accept(IVisitor& visitor) override; + void SetLightPriorityAndId(); private: TUniqueId xe8_parentId; diff --git a/src/MetroidPrime/CGameLight.cpp b/src/MetroidPrime/CGameLight.cpp new file mode 100644 index 00000000..ded1c874 --- /dev/null +++ b/src/MetroidPrime/CGameLight.cpp @@ -0,0 +1,56 @@ +#include "MetroidPrime/CGameLight.hpp" + +#include "MetroidPrime/CActorParameters.hpp" + +CGameLight::CGameLight(TUniqueId uid, TAreaId aid, bool active, const rstl::string& name, + const CTransform4f& xf, TUniqueId parentId, const CLight& light, + uint sourceId, uint priority, float lifeTime) +: CActor(uid, active, name, CEntityInfo(aid, CEntity::NullConnectionList), xf, + CModelData::CModelDataNull(), CMaterialList(kMT_NoStepLogic), CActorParameters::None(), + kInvalidUniqueId) +, xe8_parentId(parentId) +, xec_light(light) +, x13c_lightId(sourceId) +, x140_priority(priority) +, x144_lifeTime(lifeTime) { + // Needs to not inline CLight copy constructor + xec_light.GetRadius(); + xec_light.GetIntensity(); + SetLightPriorityAndId(); +} + +void CGameLight::SetLight(const CLight& light) { + xec_light = light; + xec_light.GetRadius(); + xec_light.GetIntensity(); + SetLightPriorityAndId(); +} + +CLight CGameLight::GetLight() const { + CLight ret = xec_light; + + ret.SetPosition(x34_transform * xec_light.GetPosition()); + + if (ret.GetType() != kLT_Point) + ret.SetDirection(x34_transform.Rotate(xec_light.GetDirection()).AsNormalized()); + + return ret; +} + +void CGameLight::Think(float dt, CStateManager& mgr) override { + if (x144_lifeTime > 0.f) { + x144_lifeTime -= dt; + + if (x144_lifeTime <= 0.f) + mgr.FreeScriptObject(GetUniqueId()); + } +} + +void CGameLight::Accept(IVisitor& visitor) override { visitor.Visit(*this); } + +void CGameLight::SetLightPriorityAndId() { + xec_light.SetPriority(x140_priority); + xec_light.SetLightId(x13c_lightId); +} + +CGameLight::~CGameLight() {}