diff --git a/src/battle/item/coconut/aux.c b/src/battle/item/coconut/aux.c index 7bdb8f65a7..90de342e35 100644 --- a/src/battle/item/coconut/aux.c +++ b/src/battle/item/coconut/aux.c @@ -3,7 +3,8 @@ MenuIcon* D_802A1E80; void* D_80108A64; // an image -ApiStatus func_802A1000_72F720(ScriptInstance* script, s32 isInitialCall) { +// Returns time to sleep for on SI_VAR(0). +ApiStatus N(GiveRefund)(ScriptInstance* script, s32 isInitialCall) { BattleStatus* battleStatus = BATTLE_STATUS; Actor* player = PLAYER_ACTOR; s32 sellValue = gItemTable[battleStatus->selectedItemID].sellValue; @@ -11,9 +12,8 @@ ApiStatus func_802A1000_72F720(ScriptInstance* script, s32 isInitialCall) { f32 posY = player->currentPos.y + player->size.y; f32 posZ; f32 facingAngleSign = 0.0f; - s32 outVal = 0; + s32 sleepTime = 0; - // If Refund is equipped, the player gets if (heroes_is_ability_active(player, Ability_REFUND) && sellValue > 0) { s32 iconX; s32 iconY; @@ -33,7 +33,7 @@ ApiStatus func_802A1000_72F720(ScriptInstance* script, s32 isInitialCall) { facingAngleSign += 30.0f; } - outVal = (i * 3) + 30; + sleepTime = (i * 3) + 30; posX = player->currentPos.x; posY = player->currentPos.y; @@ -44,12 +44,12 @@ ApiStatus func_802A1000_72F720(ScriptInstance* script, s32 isInitialCall) { set_icon_render_pos(D_802A1E80, iconX + 36, iconY - 63); } - script->varTable[0] = outVal; + script->varTable[0] = sleepTime; return ApiStatus_DONE2; } -ApiStatus func_802A11D4_72F8F4(ScriptInstance* script, s32 isInitialCall) { +ApiStatus N(GiveRefundCleanup)(ScriptInstance* script, s32 isInitialCall) { BattleStatus* battleStatus = BATTLE_STATUS; s32 sellValue = gItemTable[battleStatus->selectedItemID].sellValue; @@ -78,10 +78,10 @@ Script D_802A1240_72F960 = SCRIPT({ PlayEffect(51, 1, SI_VAR(0), SI_VAR(3), SI_VAR(2), 1.0, 30, 0, 0, 0, 0, 0, 0, 0); MakeItemEntity(SI_VAR(10), SI_VAR(0), SI_VAR(1), SI_VAR(2), 1, 0); SI_VAR(10) = SI_VAR(0); - func_802A1000_72F720(); + N(GiveRefund)(); sleep SI_VAR(0); sleep 15; - func_802A11D4_72F8F4(); + N(GiveRefundCleanup)(); RemoveItemEntity(SI_VAR(10)); } else { GetActorPos(0, SI_VAR(0), SI_VAR(1), SI_VAR(2)); @@ -112,10 +112,10 @@ Script D_802A1544_72FC64 = SCRIPT({ SI_VAR(1) += 45; MakeItemEntity(SI_VAR(10), SI_VAR(0), SI_VAR(1), SI_VAR(2), 1, 0); SI_VAR(14) = SI_VAR(0); - func_802A1000_72F720(); + N(GiveRefund)(); sleep SI_VAR(0); sleep 15; - func_802A11D4_72F8F4(); + N(GiveRefundCleanup)(); RemoveItemEntity(SI_VAR(14)); }); diff --git a/src/code_F5750.c b/src/code_F5750.c index bc71e89ad1..ecdf44fa7c 100644 --- a/src/code_F5750.c +++ b/src/code_F5750.c @@ -13,8 +13,10 @@ typedef struct UnkF5750 { /* 0x24 */ f32 unk_24; } UnkF5750; +typedef UnkF5750* UnkF5750List[0x40]; + extern s16 D_802DB5B0; -extern UnkF5750** D_802DB7C0; +extern UnkF5750List* D_802DB7C0; ApiStatus HidePlayerShadow(ScriptInstance* script, s32 isInitialCall) { Bytecode* args = script->ptrReadPos; @@ -471,14 +473,14 @@ ApiStatus func_802D3474(ScriptInstance* script, s32 isInitialCall) { UnkF5750* temp; s32 i; - for (i = 0; i < 0x40; i++) { - temp = D_802DB7C0[i]; + for (i = 0; i < ARRAY_COUNT(*D_802DB7C0); i++) { + temp = (*D_802DB7C0)[i]; if (temp->unk_00 < 0) { break; } } - if (i >= 0x40) { + if (i >= ARRAY_COUNT(*D_802DB7C0)) { return ApiStatus_DONE2; } @@ -506,8 +508,8 @@ ApiStatus func_802D354C(ScriptInstance* script, s32 isInitialCall) { UnkF5750* temp; s32 i; - for (i = 0; i < 0x40; i++) { - temp = D_802DB7C0[i]; + for (i = 0; i < ARRAY_COUNT(*D_802DB7C0); i++) { + temp = (*D_802DB7C0)[i]; if (temp->unk_00 < 0) { break; } @@ -563,7 +565,7 @@ INCLUDE_ASM(s32, "code_F5750", func_802D3FC8); INCLUDE_ASM(s32, "code_F5750", func_802D4050); UnkF5750* func_802D4164(s32 index) { - return D_802DB7C0[index]; + return (*D_802DB7C0)[index]; } INCLUDE_ASM(s32, "code_F5750", func_802D417C); @@ -575,7 +577,7 @@ INCLUDE_ASM(s32, "code_F5750", func_802D42AC); INCLUDE_ASM(s32, "code_F5750", func_802D4364); void func_802D43AC(s32 index, f32 arg1, f32 arg2, f32 arg3) { - UnkF5750* temp = D_802DB7C0[index]; + UnkF5750* temp = (*D_802DB7C0)[index]; temp->unk_1C = arg1; temp->unk_20 = arg2; @@ -583,7 +585,7 @@ void func_802D43AC(s32 index, f32 arg1, f32 arg2, f32 arg3) { } void func_802D43D0(s32 index, s32 arg1, s32 arg2, s32 arg3) { - UnkF5750* temp = D_802DB7C0[index]; + UnkF5750* temp = (*D_802DB7C0)[index]; temp->unk_10 = arg1; temp->unk_14 = arg2;