mirror of
https://github.com/Xeeynamo/sotn-decomp.git
synced 2025-02-21 13:41:58 +00:00
De-duplicate CollectGold (#1211)
This one had some small differences in MAD and ST0, so I worked them in as ifdef. Also, I cleaned up the function a bit, by removing the unneeded pointers. The GoldSizeIndex local variable is unneeded. It is possible to just use the goldSize argument, and do `-=2`, but I think using the local variable makes it more readable, so I left it in place.
This commit is contained in:
parent
dc3eb208e5
commit
1bcc1a2197
@ -71,7 +71,7 @@ EntityWarpRoom = 0x09244d28;
|
||||
EntityWarpSmallRocks = 0x09245c50;
|
||||
g_eRedDoorUV = 0x09246080;
|
||||
UNK_Invincibility0 = 0x09246098;
|
||||
D_80180E08 = 0x092464A8;
|
||||
g_goldCollectTexts = 0x092464A8;
|
||||
c_GoldPrizes = 0x092464D0;
|
||||
c_HeartPrizes = 0x09246500;
|
||||
D_80180EC4 = 0x09246508;
|
||||
|
@ -21,6 +21,8 @@ g_testCollPrizeTable = 0x80180968;
|
||||
g_testCollRandTable = 0x801809A8;
|
||||
g_eDamageDisplayClut = 0x801809C4;
|
||||
g_bigRedFireballAnim = 0x80180E40;
|
||||
g_goldCollectTexts = 0x80180D60;
|
||||
c_GoldPrizes = 0x80180D88;
|
||||
g_eUnk14SpawnRots = 0x80180FAC;
|
||||
unk14_yVel = 0x80180FE4;
|
||||
unk14_startFrame = 0x80180FFC;
|
||||
|
@ -19,6 +19,7 @@ g_testCollPrizeTable = 0x80180B38;
|
||||
g_testCollRandTable = 0x80180B78;
|
||||
g_eDamageDisplayClut = 0x80180B94;
|
||||
g_eRedDoorUV = 0x80180BA4;
|
||||
g_goldCollectTexts = 0x80180F30;
|
||||
c_GoldPrizes = 0x80180F58;
|
||||
c_HeartPrizes = 0x80180FE8;
|
||||
g_bigRedFireballAnim = 0x80181014;
|
||||
|
@ -26,6 +26,7 @@ g_testCollPrizeTable = 0x80180CFC;
|
||||
g_testCollRandTable = 0x80180D3C;
|
||||
g_eDamageDisplayClut = 0x80180D58;
|
||||
g_eRedDoorUV = 0x80180D68;
|
||||
g_goldCollectTexts = 0x801810F4;
|
||||
c_GoldPrizes = 0x8018111C;
|
||||
c_HeartPrizes = 0x801811AC;
|
||||
g_bigRedFireballAnim = 0x801811D8;
|
||||
|
@ -26,6 +26,7 @@ g_testCollPrizeTable = 0x80182040;
|
||||
g_testCollRandTable = 0x80182080;
|
||||
g_eDamageDisplayClut = 0x8018209C;
|
||||
g_eRedDoorUV = 0x801820AC;
|
||||
g_goldCollectTexts = 0x80182438;
|
||||
c_GoldPrizes = 0x80182460;
|
||||
c_HeartPrizes = 0x801824F0;
|
||||
g_bigRedFireballAnim = 0x8018251C;
|
||||
|
@ -26,6 +26,7 @@ g_testCollPrizeTable = 0x801819CC;
|
||||
g_testCollRandTable = 0x80181A0C;
|
||||
g_eDamageDisplayClut = 0x80181A28;
|
||||
g_eRedDoorUV = 0x80181A38;
|
||||
g_goldCollectTexts = 0x80181DC4;
|
||||
c_GoldPrizes = 0x80181DEC;
|
||||
c_HeartPrizes = 0x80181E7C;
|
||||
g_bigRedFireballAnim = 0x80181EA8;
|
||||
|
@ -26,6 +26,7 @@ g_testCollPrizeTable = 0x801818F4;
|
||||
g_testCollRandTable = 0x80181934;
|
||||
g_eDamageDisplayClut = 0x80181950;
|
||||
g_eRedDoorUV = 0x80181960;
|
||||
g_goldCollectTexts = 0x80181CEC;
|
||||
c_GoldPrizes = 0x80181D14;
|
||||
c_HeartPrizes = 0x80181DA4;
|
||||
g_bigRedFireballAnim = 0x80181DD0;
|
||||
|
@ -14,6 +14,7 @@ g_testCollElementLookup = 0x801809F0;
|
||||
g_testColliFrames = 0x80180A04;
|
||||
g_testCollPrizeTable = 0x80180A10;
|
||||
g_testCollRandTable = 0x80180A50;
|
||||
g_goldCollectTexts = 0x80180E08;
|
||||
c_GoldPrizes = 0x80180E30;
|
||||
c_HeartPrizes = 0x80180EC0;
|
||||
g_bigRedFireballAnim = 0x80180EEC;
|
||||
|
@ -17,6 +17,7 @@ g_testCollElementLookup = 0x80181948;
|
||||
g_testColliFrames = 0x8018195C;
|
||||
g_eDamageDisplayClut = 0x80181968;
|
||||
g_eRedDoorUV = 0x80181978;
|
||||
c_GoldPrizes = 0x80181CF0;
|
||||
g_bigRedFireballAnim = 0x80181DA4;
|
||||
g_eUnk14SpawnRots = 0x80181EA0;
|
||||
unk14_yVel = 0x80181ED8;
|
||||
|
@ -951,7 +951,7 @@ typedef struct {
|
||||
/* 80097BD8 */ s32 statsTotal[4];
|
||||
/* 80097BE8 */ u32 level;
|
||||
/* 80097BEC */ u32 exp;
|
||||
/* 80097BF0 */ u32 gold;
|
||||
/* 80097BF0 */ s32 gold;
|
||||
/* 80097BF4 */ s32 killCount;
|
||||
/* 80097BF8 */ u32 D_80097BF8;
|
||||
/* 80097BFC */ u32 subWeapon;
|
||||
|
@ -404,27 +404,7 @@ INCLUDE_ASM("st/cen/nonmatchings/11280", func_80195798);
|
||||
|
||||
#include "../collect_heart.h"
|
||||
|
||||
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 = &g_unkGraphicsStruct.BottomCornerTextTimer;
|
||||
if (*unk) {
|
||||
g_api.FreePrimitives(g_unkGraphicsStruct.BottomCornerTextPrims);
|
||||
*unk = 0;
|
||||
}
|
||||
|
||||
BottomCornerText(D_80180F30[goldSizeIndex], 1);
|
||||
DestroyEntity(g_CurrentEntity);
|
||||
}
|
||||
#include "../collect_gold.h"
|
||||
|
||||
void CollectSubweapon(u16 subWeaponIdx) {
|
||||
Entity* player = &PLAYER;
|
||||
|
@ -74,8 +74,6 @@ 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 c_HeartPrizes[];
|
||||
extern u16 D_801811C8[];
|
||||
extern u16 D_801811D8[];
|
||||
|
24
src/st/collect_gold.h
Normal file
24
src/st/collect_gold.h
Normal file
@ -0,0 +1,24 @@
|
||||
extern u32 c_GoldPrizes[];
|
||||
extern u8* g_goldCollectTexts[];
|
||||
|
||||
void CollectGold(u16 goldSize) {
|
||||
#ifdef VERSION_BETA
|
||||
g_api.PlaySfx(0x69D); // MAD seems to use its own sfx id set.
|
||||
#else
|
||||
g_api.PlaySfx(NA_SE_PL_COLLECT_GOLD);
|
||||
#endif
|
||||
goldSize -= 2;
|
||||
g_Status.gold += c_GoldPrizes[goldSize];
|
||||
if (g_Status.gold > MAX_GOLD) {
|
||||
g_Status.gold = MAX_GOLD;
|
||||
}
|
||||
#if STAGE != STAGE_STAGE_ST0
|
||||
if (g_unkGraphicsStruct.BottomCornerTextTimer) {
|
||||
g_api.FreePrimitives(g_unkGraphicsStruct.BottomCornerTextPrims);
|
||||
g_unkGraphicsStruct.BottomCornerTextTimer = 0;
|
||||
}
|
||||
|
||||
BottomCornerText(g_goldCollectTexts[goldSize], 1);
|
||||
DestroyEntity(g_CurrentEntity);
|
||||
#endif
|
||||
}
|
@ -467,27 +467,7 @@ void func_8019BA38(u16 arg0) {
|
||||
DestroyEntity(g_CurrentEntity);
|
||||
}
|
||||
|
||||
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 = &g_unkGraphicsStruct.BottomCornerTextTimer;
|
||||
if (*unk) {
|
||||
g_api.FreePrimitives(g_unkGraphicsStruct.BottomCornerTextPrims);
|
||||
*unk = 0;
|
||||
}
|
||||
|
||||
BottomCornerText(D_801810F4[goldSizeIndex], 1);
|
||||
DestroyEntity(g_CurrentEntity);
|
||||
}
|
||||
#include "../collect_gold.h"
|
||||
|
||||
void CollectSubweapon(u16 subWeaponIdx) {
|
||||
Entity* player = &PLAYER;
|
||||
|
@ -119,8 +119,6 @@ extern u8 D_80181338[];
|
||||
extern u16 D_801811A4[];
|
||||
extern u16 D_801810B0[];
|
||||
extern u16 D_801810E0[];
|
||||
extern u8* D_801810F4[];
|
||||
extern s32 c_GoldPrizes[];
|
||||
|
||||
// *** EntitySoulStealOrb properties START ***
|
||||
|
||||
|
@ -1031,31 +1031,7 @@ void func_801934D0(u16 arg0) {
|
||||
|
||||
INCLUDE_ASM("asm/us/st/mad/nonmatchings/EDB8", CollectHeart);
|
||||
|
||||
extern void* const D_80180D60[];
|
||||
extern const s32 D_80180D88[]; // c_GoldPrizes
|
||||
|
||||
void CollectGold(u16 goldSize) { // CollectGold
|
||||
s32 *gold, *unk;
|
||||
u16 goldSizeIndex;
|
||||
|
||||
g_api.PlaySfx(0x69D);
|
||||
gold = &g_Status.gold;
|
||||
goldSizeIndex = goldSize - 2;
|
||||
*gold += D_80180D88[goldSizeIndex];
|
||||
if (*gold > MAX_GOLD) {
|
||||
*gold = MAX_GOLD;
|
||||
}
|
||||
|
||||
unk = &g_unkGraphicsStruct.BottomCornerTextTimer;
|
||||
if (*unk) {
|
||||
g_api.FreePrimitives(
|
||||
g_unkGraphicsStruct.BottomCornerTextPrims); // g_api.FreePrimitives
|
||||
*unk = 0;
|
||||
}
|
||||
|
||||
BottomCornerText(D_80180D60[goldSizeIndex], 1);
|
||||
DestroyEntity(g_CurrentEntity);
|
||||
}
|
||||
#include "../collect_gold.h"
|
||||
|
||||
void func_801937BC(void) {}
|
||||
|
||||
|
@ -435,27 +435,7 @@ void func_801C6198(u16 arg0) {
|
||||
|
||||
#include "../collect_heart.h"
|
||||
|
||||
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 = &g_unkGraphicsStruct.BottomCornerTextTimer;
|
||||
if (*unk) {
|
||||
g_api.FreePrimitives(g_unkGraphicsStruct.BottomCornerTextPrims);
|
||||
*unk = 0;
|
||||
}
|
||||
|
||||
BottomCornerText(D_80182438[goldSizeIndex], 1);
|
||||
DestroyEntity(g_CurrentEntity);
|
||||
}
|
||||
#include "../collect_gold.h"
|
||||
|
||||
void CollectSubweapon(u16 subWeaponIdx) {
|
||||
Entity* player = &PLAYER;
|
||||
|
@ -183,7 +183,6 @@ extern s16 D_801820C4[];
|
||||
extern s16 D_801832D8[];
|
||||
extern u8 D_801832E8[];
|
||||
extern u16 D_801823F4[];
|
||||
extern u8* D_80182438[];
|
||||
extern u16 D_80182424[];
|
||||
extern u8* D_80182488[];
|
||||
extern u16 D_801824E8[];
|
||||
@ -194,7 +193,6 @@ extern u16 D_80182628[];
|
||||
extern s32 D_80182638[];
|
||||
extern u8 D_8018267C[];
|
||||
extern ObjInit2 D_80182764[];
|
||||
extern s32 c_GoldPrizes[];
|
||||
extern u8 D_8018383C[];
|
||||
extern s32 D_801838F4[];
|
||||
extern s16 D_80183858[];
|
||||
|
@ -430,27 +430,7 @@ void func_801BDA08(u16 arg0) {
|
||||
|
||||
#include "../collect_heart.h"
|
||||
|
||||
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 = &g_unkGraphicsStruct.BottomCornerTextTimer;
|
||||
if (*unk) {
|
||||
g_api.FreePrimitives(g_unkGraphicsStruct.BottomCornerTextPrims);
|
||||
*unk = 0;
|
||||
}
|
||||
|
||||
BottomCornerText(D_80181DC4[goldSizeIndex], 1);
|
||||
DestroyEntity(g_CurrentEntity);
|
||||
}
|
||||
#include "../collect_gold.h"
|
||||
|
||||
void CollectSubweapon(u16 subWeaponIdx) {
|
||||
Entity* player = &PLAYER;
|
||||
|
@ -219,8 +219,6 @@ extern u16 UNK_Invincibility0[];
|
||||
extern s16 D_80181A50[];
|
||||
extern u16 D_80181D80[];
|
||||
extern u16 D_80181DB0[];
|
||||
extern const u32* D_80181DC4[];
|
||||
extern const s32 c_GoldPrizes[];
|
||||
extern u16 D_80181E74[];
|
||||
extern s8 c_HeartPrizes[];
|
||||
extern s32 D_80181E80[];
|
||||
|
@ -465,27 +465,7 @@ void func_801BDE20(u16 arg0) {
|
||||
|
||||
#include "../collect_heart.h"
|
||||
|
||||
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 = &g_unkGraphicsStruct.BottomCornerTextTimer;
|
||||
if (*unk) {
|
||||
g_api.FreePrimitives(g_unkGraphicsStruct.BottomCornerTextPrims);
|
||||
*unk = 0;
|
||||
}
|
||||
|
||||
BottomCornerText(D_80181CEC[goldSizeIndex], 1);
|
||||
DestroyEntity(g_CurrentEntity);
|
||||
}
|
||||
#include "../collect_gold.h"
|
||||
|
||||
void CollectSubweapon(u16 subWeaponIdx) {
|
||||
Entity* player = &PLAYER;
|
||||
|
@ -268,8 +268,6 @@ extern u16 D_80181CD8[];
|
||||
extern u8* D_80181D3C[];
|
||||
extern u16 D_80180C94[];
|
||||
extern u16 D_80182424[];
|
||||
extern u32* D_80181CEC[];
|
||||
extern s32 c_GoldPrizes[];
|
||||
extern u16 D_80180CA0[];
|
||||
extern u32 D_80182488[];
|
||||
extern u16 D_80180C58[];
|
||||
|
@ -287,27 +287,7 @@ extern s8 c_HeartPrizes[];
|
||||
|
||||
#include "../collect_heart.h"
|
||||
|
||||
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 = &g_unkGraphicsStruct.BottomCornerTextTimer;
|
||||
if (*unk) {
|
||||
g_api.FreePrimitives(g_unkGraphicsStruct.BottomCornerTextPrims);
|
||||
*unk = 0;
|
||||
}
|
||||
|
||||
BottomCornerText(D_80180E08[goldSizeIndex], 1);
|
||||
DestroyEntity(g_CurrentEntity);
|
||||
}
|
||||
#include "../collect_gold.h"
|
||||
|
||||
void CollectSubweapon(u16 subWeaponIdx) {
|
||||
Entity* player = &PLAYER;
|
||||
|
@ -25,7 +25,6 @@ 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[];
|
||||
|
@ -827,15 +827,7 @@ void CollectHeart(u16 index) {
|
||||
DestroyEntity(g_CurrentEntity);
|
||||
}
|
||||
|
||||
void CollectGold(u16 index) {
|
||||
g_api.PlaySfx(0x6A9);
|
||||
index -= 2;
|
||||
g_Status.gold += D_80181CF0[index];
|
||||
|
||||
if ((s32)g_Status.gold > 0xF423F) {
|
||||
g_Status.gold = 0xF423F;
|
||||
}
|
||||
}
|
||||
#include "../collect_gold.h"
|
||||
|
||||
void func_801B61D4(void) {}
|
||||
|
||||
|
@ -937,7 +937,7 @@ extern u8 D_80186EF0[];
|
||||
extern u8 D_80186EF8[];
|
||||
extern u8 D_80186F00[];
|
||||
extern u8 D_80186F08[];
|
||||
u8* D_80180E08[] = {
|
||||
u8* g_goldCollectTexts[] = {
|
||||
// u8 is an assumption
|
||||
/* E08 */ D_80186F08,
|
||||
/* E0C */ D_80186F00,
|
||||
@ -951,7 +951,7 @@ u8* D_80180E08[] = {
|
||||
/* E2C */ D_80186EC0,
|
||||
};
|
||||
|
||||
s32 c_GoldPrizes[] = {
|
||||
u32 c_GoldPrizes[] = {
|
||||
1, 25, 50, 100, 250, 400, 700, 1000, 2000, 5000,
|
||||
};
|
||||
|
||||
|
@ -3,11 +3,9 @@
|
||||
extern LayoutEntity* D_80180310[];
|
||||
extern u16 D_80180DC4[];
|
||||
extern u16 D_80180DF4[];
|
||||
extern u8* D_80180E08[];
|
||||
extern s8 c_HeartPrizes[];
|
||||
extern u8* D_80180E58[];
|
||||
extern u16 D_80180EB8[];
|
||||
extern s32 c_GoldPrizes[];
|
||||
extern u16 g_ItemIconSlots[];
|
||||
extern u16 UNK_Invincibility0[];
|
||||
|
||||
@ -74,27 +72,7 @@ void func_8018CB34(u16 arg0) {
|
||||
|
||||
#include "../collect_heart.h"
|
||||
|
||||
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 = &g_unkGraphicsStruct.BottomCornerTextTimer;
|
||||
if (*unk) {
|
||||
g_api.FreePrimitives(g_unkGraphicsStruct.BottomCornerTextPrims);
|
||||
*unk = 0;
|
||||
}
|
||||
|
||||
BottomCornerText(D_80180E08[goldSizeIndex], 1);
|
||||
DestroyEntity(g_CurrentEntity);
|
||||
}
|
||||
#include "../collect_gold.h"
|
||||
|
||||
void CollectSubweapon(u16 subWeaponIdx) {
|
||||
Entity* player = &PLAYER;
|
||||
|
@ -71,25 +71,7 @@ void CollectHeart(u16 arg0) {
|
||||
DestroyEntity(g_CurrentEntity);
|
||||
}
|
||||
|
||||
extern u8* D_80180E08[];
|
||||
extern s32 c_GoldPrizes[];
|
||||
|
||||
void CollectGold(u16 goldSize) {
|
||||
g_api.PlaySfx(NA_SE_PL_COLLECT_GOLD);
|
||||
goldSize -= 2;
|
||||
g_Status.gold += c_GoldPrizes[goldSize];
|
||||
if ((s32)g_Status.gold > MAX_GOLD) {
|
||||
g_Status.gold = MAX_GOLD;
|
||||
}
|
||||
|
||||
if (g_unkGraphicsStruct.BottomCornerTextTimer) {
|
||||
g_api.FreePrimitives(g_unkGraphicsStruct.BottomCornerTextPrims);
|
||||
g_unkGraphicsStruct.BottomCornerTextTimer = 0;
|
||||
}
|
||||
|
||||
BottomCornerText(D_80180E08[goldSize], 1);
|
||||
DestroyEntity(g_CurrentEntity);
|
||||
}
|
||||
#include "../collect_gold.h"
|
||||
|
||||
extern u16 D_80180DC4[];
|
||||
extern u16 D_80180DF4[];
|
||||
|
Loading…
x
Reference in New Issue
Block a user