From b97f0a561dc0398eabce40ff8bc4b404d9c126ba Mon Sep 17 00:00:00 2001 From: elijah-thomas774 Date: Sun, 3 Nov 2024 10:49:11 -0500 Subject: [PATCH] remove cM::calcTimer --- config/SOUE01/rels/d_t_gekotagNP/symbols.txt | 2 +- config/SOUE01/rels/d_t_touchNP/symbols.txt | 2 +- .../SOUE01/rels/d_t_tumble_weedNP/symbols.txt | 2 +- config/SOUE01/symbols.txt | 4 ++-- include/c/c_math.h | 8 -------- src/REL/d/t/d_t_gekotag.cpp | 7 +++---- src/REL/d/t/d_t_touch.cpp | 6 +++--- src/REL/d/t/d_t_tumble_weed.cpp | 18 +++++------------- src/d/a/obj/d_a_obj_switch.cpp | 5 ++--- src/d/tg/d_t_switch.cpp | 8 ++++---- 10 files changed, 22 insertions(+), 40 deletions(-) diff --git a/config/SOUE01/rels/d_t_gekotagNP/symbols.txt b/config/SOUE01/rels/d_t_gekotagNP/symbols.txt index 5eb85e030..77fdf8d64 100644 --- a/config/SOUE01/rels/d_t_gekotagNP/symbols.txt +++ b/config/SOUE01/rels/d_t_gekotagNP/symbols.txt @@ -21,7 +21,7 @@ initializeState_Wait__10dTgGekoTagFv = .text:0x00000660; // type:function size:0 executeState_Wait__10dTgGekoTagFv = .text:0x00000670; // type:function size:0x4 finalizeState_Wait__10dTgGekoTagFv = .text:0x00000680; // type:function size:0x4 doExecute__10dTgGekoTagFv = .text:0x00000690; // type:function size:0x1A8 -calcTimer__2cMFPUs_Us = .text:0x00000840; // type:function size:0x1C +calcTimer__4sLibFPUs_Us = .text:0x00000840; // type:function size:0x1C __dt__10dTgGekoTagFv = .text:0x00000860; // type:function size:0xE0 getStateID__79sStateMgr_c<10dTgGekoTag,20sStateMethodUsr_FI_c,12sFStateFct_c,13sStateIDChk_c>CFv = .text:0x00000940; // type:function size:0x10 build__26sFStateFct_c<10dTgGekoTag>FRC12sStateIDIf_c = .text:0x00000950; // type:function size:0x60 diff --git a/config/SOUE01/rels/d_t_touchNP/symbols.txt b/config/SOUE01/rels/d_t_touchNP/symbols.txt index d5104afe9..213edde55 100644 --- a/config/SOUE01/rels/d_t_touchNP/symbols.txt +++ b/config/SOUE01/rels/d_t_touchNP/symbols.txt @@ -17,7 +17,7 @@ executeState__80sStateMgr_c<11dTgTouchTag,20sStateMethodUsr_FI_c,12sFStateFct_c, draw__11dTgTouchTagFv = .text:0x00000590; // type:function size:0x8 initializeState_Wait__11dTgTouchTagFv = .text:0x000005A0; // type:function size:0xC executeState_Wait__11dTgTouchTagFv = .text:0x000005B0; // type:function size:0x138 -calcTimer__2cMFPUs_Us = .text:0x000006F0; // type:function size:0x1C +calcTimer__4sLibFPUs_Us = .text:0x000006F0; // type:function size:0x1C finalizeState_Wait__11dTgTouchTagFv = .text:0x00000710; // type:function size:0x4 __dt__11dTgTouchTagFv = .text:0x00000720; // type:function size:0xC8 getStateID__80sStateMgr_c<11dTgTouchTag,20sStateMethodUsr_FI_c,12sFStateFct_c,13sStateIDChk_c>CFv = .text:0x000007F0; // type:function size:0x10 diff --git a/config/SOUE01/rels/d_t_tumble_weedNP/symbols.txt b/config/SOUE01/rels/d_t_tumble_weedNP/symbols.txt index 5f46264df..eed1849c3 100644 --- a/config/SOUE01/rels/d_t_tumble_weedNP/symbols.txt +++ b/config/SOUE01/rels/d_t_tumble_weedNP/symbols.txt @@ -14,7 +14,7 @@ changeState__84sStateMgr_c<15dTgTumbleWeed_c,20sStateMethodUsr_FI_c,12sFStateFct doDelete__15dTgTumbleWeed_cFv = .text:0x00000490; // type:function size:0x8 actorExecute__15dTgTumbleWeed_cFv = .text:0x000004A0; // type:function size:0x48 executeState__84sStateMgr_c<15dTgTumbleWeed_c,20sStateMethodUsr_FI_c,12sFStateFct_c,13sStateIDChk_c>Fv = .text:0x000004F0; // type:function size:0x10 -decr__FPUs = .text:0x00000500; // type:function size:0x1C +calcTimer__4sLibFPUs_Us = .text:0x00000500; // type:function size:0x1C draw__15dTgTumbleWeed_cFv = .text:0x00000520; // type:function size:0x8 initializeState_AreaOut__15dTgTumbleWeed_cFv = .text:0x00000530; // type:function size:0x4 executeState_AreaOut__15dTgTumbleWeed_cFv = .text:0x00000540; // type:function size:0xA0 diff --git a/config/SOUE01/symbols.txt b/config/SOUE01/symbols.txt index 14c62493b..55c140692 100644 --- a/config/SOUE01/symbols.txt +++ b/config/SOUE01/symbols.txt @@ -1418,13 +1418,13 @@ fn_80037A30 = .text:0x80037A30; // type:function size:0xCC fn_80037B00 = .text:0x80037B00; // type:function size:0x20 fn_80037B20 = .text:0x80037B20; // type:function size:0x4C fn_80037B70 = .text:0x80037B70; // type:function size:0x1D4 -calcTimer__2cMFPUs_Us = .text:0x80037D50; // type:function size:0x1C +calcTimer__4sLibFPUs_Us = .text:0x80037D50; // type:function size:0x1C fn_80037D70 = .text:0x80037D70; // type:function size:0x158 fn_80037ED0 = .text:0x80037ED0; // type:function size:0x14 fn_80037EF0 = .text:0x80037EF0; // type:function size:0xA4 fn_80037FA0 = .text:0x80037FA0; // type:function size:0x220 fn_800381C0 = .text:0x800381C0; // type:function size:0x2F0 -calcTimer__2cMFPUc_Uc = .text:0x800384B0; // type:function size:0x1C +calcTimer__4sLibFPUc_Uc = .text:0x800384B0; // type:function size:0x1C fn_800384D0 = .text:0x800384D0; // type:function size:0x64 fn_80038540 = .text:0x80038540; // type:function size:0x108 fn_80038650 = .text:0x80038650; // type:function size:0x144 diff --git a/include/c/c_math.h b/include/c/c_math.h index 9c051d65e..5bb3504b0 100644 --- a/include/c/c_math.h +++ b/include/c/c_math.h @@ -11,14 +11,6 @@ int rndInt(int max); f32 rndF(f32 max); f32 rndFX(f32 amp); -template -T calcTimer(T *value) { - if (*(T *)value != 0) { - *value = *value - 1; - } - return *value; -} - } // namespace cM #endif diff --git a/src/REL/d/t/d_t_gekotag.cpp b/src/REL/d/t/d_t_gekotag.cpp index 32df50846..0d18f69d9 100644 --- a/src/REL/d/t/d_t_gekotag.cpp +++ b/src/REL/d/t/d_t_gekotag.cpp @@ -1,13 +1,12 @@ #include "d/t/d_t_gekotag.h" -#include "c/c_math.h" #include "common.h" #include "d/a/d_a_player.h" #include "d/a/e/d_a_e_geko.h" #include "d/a/obj/d_a_obj_base.h" -#include "f/f_base.h" #include "f/f_profile_name.h" #include "m/m_angle.h" +#include "s/s_Math.h" #pragma explicit_zero_data on static u32 initialRotX = 0; @@ -60,8 +59,8 @@ void dTgGekoTag::executeState_Wait() { void dTgGekoTag::finalizeState_Wait() {} void dTgGekoTag::doExecute() { - cM::calcTimer(&mTimer2); - if (cM::calcTimer(&mTimer1) != 0) { + sLib::calcTimer(&mTimer2); + if (sLib::calcTimer(&mTimer1) != 0) { return; } diff --git a/src/REL/d/t/d_t_touch.cpp b/src/REL/d/t/d_t_touch.cpp index 352f2f54a..ac23f2fba 100644 --- a/src/REL/d/t/d_t_touch.cpp +++ b/src/REL/d/t/d_t_touch.cpp @@ -1,9 +1,9 @@ #include "d/t/d_t_touch.h" #include "c/c_math.h" -#include "toBeSorted/area_math.h" #include "d/flag/sceneflag_manager.h" - +#include "s/s_Math.h" +#include "toBeSorted/area_math.h" SPECIAL_ACTOR_PROFILE(TOUCH_TAG, dTgTouchTag, fProfile::TOUCH_TAG, 0x028E, 0, 0); @@ -59,7 +59,7 @@ void dTgTouchTag::executeState_Wait() { actor = static_cast(fManager_c::searchBaseByProfName(ACTIVATORS[mActivatorIndex], actor)); } - if (cM::calcTimer(&mFlagTimer) == 0) { + if (sLib::calcTimer(&mFlagTimer) == 0) { if (mZoneFlag != 0xFF && SceneflagManager::sInstance->checkBoolFlag(roomid, mZoneFlag)) { SceneflagManager::sInstance->unsetFlag(roomid, mZoneFlag); } diff --git a/src/REL/d/t/d_t_tumble_weed.cpp b/src/REL/d/t/d_t_tumble_weed.cpp index 538f932e1..9c5cc926e 100644 --- a/src/REL/d/t/d_t_tumble_weed.cpp +++ b/src/REL/d/t/d_t_tumble_weed.cpp @@ -1,7 +1,8 @@ #include "d/t/d_t_tumble_weed.h" -#include "c/c_math.h" #include "m/m_vec.h" +#include "s/s_Math.h" + SPECIAL_ACTOR_PROFILE(TUMBLE_WEED_TAG, dTgTumbleWeed_c, fProfile::TUMBLE_WEED_TAG, 0x0244, 0, 0); @@ -16,32 +17,23 @@ int dTgTumbleWeed_c::create() { return SUCCEEDED; } -u16 decr(u16 *num); - int dTgTumbleWeed_c::doDelete() { return SUCCEEDED; } int dTgTumbleWeed_c::actorExecute() { mStateMgr.executeState(); - decr(&tumbleweedTimer); + sLib::calcTimer(&tumbleweedTimer); return SUCCEEDED; } -u16 decr(u16 *num) { - if (*num != 0) { - (*num)--; - } - return *num; -} - int dTgTumbleWeed_c::draw() { return SUCCEEDED; } void dTgTumbleWeed_c::initializeState_AreaOut() {} void dTgTumbleWeed_c::executeState_AreaOut() { - if (decr(&windTimer) == 0) { + if (sLib::calcTimer(&windTimer) == 0) { windTimer = 0x96; if (shouldDoWind()) { mStateMgr.changeState(StateID_Wind); @@ -62,7 +54,7 @@ void dTgTumbleWeed_c::executeState_AreaIn() { } tumbleweedTimer = 600; } - if (decr(&windTimer) == 0) { + if (sLib::calcTimer(&windTimer) == 0) { windTimer = 0x96; if (shouldDoWind()) { mStateMgr.changeState(StateID_Wind); diff --git a/src/d/a/obj/d_a_obj_switch.cpp b/src/d/a/obj/d_a_obj_switch.cpp index 2131d02b3..4c3e6ec30 100644 --- a/src/d/a/obj/d_a_obj_switch.cpp +++ b/src/d/a/obj/d_a_obj_switch.cpp @@ -1,12 +1,11 @@ #include "d/a/obj/d_a_obj_switch.h" -#include "c/c_math.h" #include "d/a/d_a_player.h" #include "d/col/bg/d_bg_s.h" #include "d/col/bg/d_bg_w.h" +#include "d/flag/sceneflag_manager.h" #include "nw4r/g3d/g3d_resfile.h" #include "s/s_Math.h" -#include "d/flag/sceneflag_manager.h" SPECIAL_ACTOR_PROFILE(OBJ_SW, dAcOsw_c, fProfile::OBJ_SW, 0x12B, 0, 0x1002); @@ -269,7 +268,7 @@ void dAcOsw_c::executeState_OffWait() { if (field_0x5F1 != 0) { field_0x5F3 = 1; } - if (mSwitchType != 1 && cM::calcTimer(&field_0x5EC) == 0 && field_0x5F3 == 0) { + if (mSwitchType != 1 && sLib::calcTimer(&field_0x5EC) == 0 && field_0x5F3 == 0) { mStateMgr.changeState(StateID_Off); } } diff --git a/src/d/tg/d_t_switch.cpp b/src/d/tg/d_t_switch.cpp index f7c1141be..c7f400da4 100644 --- a/src/d/tg/d_t_switch.cpp +++ b/src/d/tg/d_t_switch.cpp @@ -1,8 +1,8 @@ #include "d/t/d_t_switch.h" -#include "c/c_math.h" -#include "toBeSorted/event.h" #include "d/flag/sceneflag_manager.h" +#include "s/s_Math.h" +#include "toBeSorted/event.h" #include "toBeSorted/scgame.h" @@ -144,7 +144,7 @@ void dTgSw_c::initializeState_On() { mTimer = 4; } void dTgSw_c::executeState_On() { - if (cM::calcTimer(&mTimer) == 0) { + if (sLib::calcTimer(&mTimer) == 0) { mStateMgr.changeState(StateID_OffWait); } } @@ -173,7 +173,7 @@ void dTgSw_c::executeState_Off() { mActorEvent.scheduleEvent(event, 0); return; } - if (cM::calcTimer(&mTimer) == 0) { + if (sLib::calcTimer(&mTimer) == 0) { if (mThird2 == 1) { resetAllSwitches(); } else if (mThird2 != 2) {