From 290b0c0e3cebd173bf8e8af93145969f9c1e57e1 Mon Sep 17 00:00:00 2001 From: bismurphy Date: Sat, 26 Aug 2023 15:15:59 -0400 Subject: [PATCH] Resolve remaining duplicates for CollectGold (#514) Most overlays have the same CollectGold function (st0 is an odd one out, there may be others). I noticed in the duplicates report (https://raw.githubusercontent.com/Xeeynamo/sotn-decomp/gh-duplicates/duplicates.txt) that there were 3 overlays which still had placeholders in. This PR resolves that and finishes decompiling all of them. The C code in all of these is copied from the `wrp` version, if it matters. Symbols have been changed to account for different data locations across overlays. I have attempted to be as formulaic as possible with these. In most of these, there is a function which is called at the end of the function. In the `cen` version, it is `func_8019BBA4`. I have also decompiled that function in every overlay, so once this PR is in, I will submit another for those functions. --- config/symbols.us.stcen.txt | 2 ++ config/symbols.us.stdre.txt | 2 ++ config/symbols.us.strwrp.txt | 2 ++ src/st/cen/11280.c | 22 +++++++++++++++++++++- src/st/cen/cen.h | 2 ++ src/st/dre/173C4.c | 22 +++++++++++++++++++++- src/st/dre/dre.h | 2 ++ src/st/rwrp/A59C.c | 22 +++++++++++++++++++++- src/st/rwrp/rwrp.h | 3 ++- 9 files changed, 75 insertions(+), 4 deletions(-) diff --git a/config/symbols.us.stcen.txt b/config/symbols.us.stcen.txt index 6077c8769..a3cf9e76c 100644 --- a/config/symbols.us.stcen.txt +++ b/config/symbols.us.stcen.txt @@ -3,6 +3,7 @@ PfnEntityUpdates = 0x80180394; g_InitializeData0 = 0x80180410; g_InitializeEntityData0 = 0x8018041C; UNK_Invincibility0 = 0x801807B8; +c_GoldPrizes = 0x80180F58; g_Rooms = 0x801812D4; EntityBackgroundBlock = 0x8018D600; EntityUnkId12 = 0x8018D6E0; @@ -38,6 +39,7 @@ UnkEntityFunc0 = 0x80194D08; SetStep = 0x80194EA4; InitializeEntity = 0x80194F74; CollectHeart = 0x801958F4; +CollectGold = 0x80195974; CollectSubweapon = 0x80195A50; EntityPrizeDrop = 0x80195C84; EntityExplosion = 0x801964F8; diff --git a/config/symbols.us.stdre.txt b/config/symbols.us.stdre.txt index 7f1a24fc2..79fde20a5 100644 --- a/config/symbols.us.stdre.txt +++ b/config/symbols.us.stdre.txt @@ -10,6 +10,7 @@ g_eBreakableanimSets = 0x80180640; g_eBreakableBlendModes = 0x80180650; g_CloneShootOrder = 0x801807D4; UNK_Invincibility0 = 0x8018097C; +c_GoldPrizes = 0x8018111C; c_HeartPrizes = 0x801811AC; g_Rooms = 0x80181498; EntityUnkId11 = 0x80191A64; @@ -53,6 +54,7 @@ UnkEntityFunc0 = 0x8019AE4C; SetStep = 0x8019AFE8; SetSubStep = 0x8019B008; InitializeEntity = 0x8019B0B8; +CollectGold = 0x8019BAB8; CollectSubweapon = 0x8019BB94; CollectHeartVessel = 0x8019BCAC; CollectLifeVessel = 0x8019BD50; diff --git a/config/symbols.us.strwrp.txt b/config/symbols.us.strwrp.txt index 5db32fa87..ceb4a44f3 100644 --- a/config/symbols.us.strwrp.txt +++ b/config/symbols.us.strwrp.txt @@ -3,6 +3,7 @@ PfnEntityUpdates = 0x801803E4; g_InitializeData0 = 0x8018044C; g_InitializeEntityData0 = 0x80180458; UNK_Invincibility0 = 0x80180690; +c_GoldPrizes = 0x80180E30; g_Rooms = 0x801811AC; EntityBreakable = 0x8018908C; Random = 0x8018A168; @@ -20,6 +21,7 @@ UnkEntityFunc0 = 0x8018E024; SetStep = 0x8018E1C0; InitializeEntity = 0x8018E290; ReplaceBreakableWithItemDrop = 0x8018E978; +CollectGold = 0x8018EC90; CollectSubweapon = 0x8018ED6C; EntityPrizeDrop = 0x8018EFA0; EntityEquipItemDrop = 0x8018F9B4; diff --git a/src/st/cen/11280.c b/src/st/cen/11280.c index 4db4d0734..c9e5f2754 100644 --- a/src/st/cen/11280.c +++ b/src/st/cen/11280.c @@ -766,7 +766,27 @@ void CollectHeart(u16 index) { DestroyEntity(g_CurrentEntity); } -INCLUDE_ASM("asm/us/st/cen/nonmatchings/11280", func_80195974); +void CollectGold(u16 goldSize) { + s32 *gold, *unk; + u16 goldSizeIndex; + + g_api.PlaySfx(NA_SE_PL_COLLECT_GOLD); + gold = &g_Status.gold; + goldSizeIndex = goldSize - 2; + *gold += c_GoldPrizes[goldSizeIndex]; + if (*gold > MAX_GOLD) { + *gold = MAX_GOLD; + } + + unk = &D_80097410; + if (*unk) { + g_api.FreePrimitives(D_80097414); + *unk = 0; + } + + func_8019BBA4(D_80180F30[goldSizeIndex], 1); + DestroyEntity(g_CurrentEntity); +} void CollectSubweapon(u16 subWeaponIdx) { Entity* player = &PLAYER; diff --git a/src/st/cen/cen.h b/src/st/cen/cen.h index b1e92a978..d3dd27a12 100644 --- a/src/st/cen/cen.h +++ b/src/st/cen/cen.h @@ -66,6 +66,8 @@ extern u8 D_80180780[]; // Animation extern s16 D_80180BBC[]; extern u16 D_80180EEC[]; extern u16 D_80180F1C[]; +extern u8* D_80180F30[]; +extern s32 c_GoldPrizes[]; extern s8 D_80180FE8[]; extern u16 D_801811C8[]; extern u16 D_801811D8[]; diff --git a/src/st/dre/173C4.c b/src/st/dre/173C4.c index da41e6d9c..a6f109238 100644 --- a/src/st/dre/173C4.c +++ b/src/st/dre/173C4.c @@ -824,7 +824,27 @@ void func_8019BA38(u16 arg0) { DestroyEntity(g_CurrentEntity); } -INCLUDE_ASM("asm/us/st/dre/nonmatchings/173C4", func_8019BAB8); +void CollectGold(u16 goldSize) { + s32 *gold, *unk; + u16 goldSizeIndex; + + g_api.PlaySfx(NA_SE_PL_COLLECT_GOLD); + gold = &g_Status.gold; + goldSizeIndex = goldSize - 2; + *gold += c_GoldPrizes[goldSizeIndex]; + if (*gold > MAX_GOLD) { + *gold = MAX_GOLD; + } + + unk = &D_80097410; + if (*unk) { + g_api.FreePrimitives(D_80097414); + *unk = 0; + } + + func_801A1CE8(D_801810F4[goldSizeIndex], 1); + DestroyEntity(g_CurrentEntity); +} void CollectSubweapon(u16 subWeaponIdx) { Entity* player = &PLAYER; diff --git a/src/st/dre/dre.h b/src/st/dre/dre.h index e7c724615..6ba65d332 100644 --- a/src/st/dre/dre.h +++ b/src/st/dre/dre.h @@ -117,6 +117,8 @@ extern u8 D_80181324[]; extern u16 D_80181328[]; extern u16 D_801810B0[]; extern u16 D_801810E0[]; +extern u8* D_801810F4[]; +extern s32 c_GoldPrizes[]; // *** EntitySoulStealOrb properties START *** diff --git a/src/st/rwrp/A59C.c b/src/st/rwrp/A59C.c index fcf5d7a49..d9259250f 100644 --- a/src/st/rwrp/A59C.c +++ b/src/st/rwrp/A59C.c @@ -347,7 +347,27 @@ INCLUDE_ASM("asm/us/st/rwrp/nonmatchings/A59C", func_8018EAB4); INCLUDE_ASM("asm/us/st/rwrp/nonmatchings/A59C", func_8018EC10); -INCLUDE_ASM("asm/us/st/rwrp/nonmatchings/A59C", func_8018EC90); +void CollectGold(u16 goldSize) { + s32 *gold, *unk; + u16 goldSizeIndex; + + g_api.PlaySfx(NA_SE_PL_COLLECT_GOLD); + gold = &g_Status.gold; + goldSizeIndex = goldSize - 2; + *gold += c_GoldPrizes[goldSizeIndex]; + if (*gold > MAX_GOLD) { + *gold = MAX_GOLD; + } + + unk = &D_80097410; + if (*unk) { + g_api.FreePrimitives(D_80097414); + *unk = 0; + } + + func_80194EC0(D_80180E08[goldSizeIndex], 1); + DestroyEntity(g_CurrentEntity); +} void CollectSubweapon(u16 subWeaponIdx) { Entity* player = &PLAYER; diff --git a/src/st/rwrp/rwrp.h b/src/st/rwrp/rwrp.h index 5ff223bf6..34fcb2f5b 100644 --- a/src/st/rwrp/rwrp.h +++ b/src/st/rwrp/rwrp.h @@ -20,9 +20,10 @@ extern u16 g_InitializeData0[]; extern u16 D_80181110[]; // *** EntitySoulStealOrb properties END *** - +extern s32 c_GoldPrizes[]; extern u16 D_80180DC4[]; extern u16 D_80180DF4[]; +extern u8* D_80180E08[]; extern u16 UNK_Update0[]; extern u16 UNK_Invincibility0[];