From 23b8510eb46340a642da0a0d4edbb24afa15a93e Mon Sep 17 00:00:00 2001 From: Banjo Kazooie Date: Sun, 3 Nov 2024 13:03:26 -0600 Subject: [PATCH] code_B6CE0.c => time.c --- decompressed.pal.yaml | 8 ++--- decompressed.us.v10.yaml | 8 ++--- include/functions.h | 2 +- include/time.h | 15 +++++++++ manual_syms.pal.txt | 4 +-- src/TTC/ch/clam.c | 2 +- src/core1/pfsmanager.c | 4 +-- src/core2/ch/bottlesbonus.c | 6 ++-- src/core2/ch/bottlesbonuscursor.c | 4 +-- src/core2/code_5C240.c | 7 +++-- src/core2/code_5C870.c | 12 ++++---- src/core2/code_73640.c | 7 ++--- src/core2/code_B6CE0.c | 51 ------------------------------- src/core2/code_BEF20.c | 2 +- src/core2/code_CBD10.c | 4 +-- src/core2/fx/common2score.c | 2 +- src/core2/fx/honeycarrierscore.c | 2 +- src/core2/gc/zoombox.c | 8 ++--- src/core2/nc/dynamicCamera.c | 6 ++-- src/core2/statetimer.c | 2 +- src/core2/time.c | 51 +++++++++++++++++++++++++++++++ 21 files changed, 110 insertions(+), 97 deletions(-) create mode 100644 include/time.h delete mode 100644 src/core2/code_B6CE0.c create mode 100644 src/core2/time.c diff --git a/decompressed.pal.yaml b/decompressed.pal.yaml index 2d9f361b..325f4c4a 100644 --- a/decompressed.pal.yaml +++ b/decompressed.pal.yaml @@ -822,7 +822,7 @@ segments: # - [0x100BFA0, c, code_B6640] #DONE # - [0x100C030, c, string] #DONE # - [0x100C5C0, c, code_B6C60] #DONE - # - [0x100C640, c, code_B6CE0] #DONE + # - [0x100C640, c, time] #DONE # - [0x100C800, c, code_B6EA0] #DONE # - [0x100D480, c, coords] #DONE # - [0x100D8A0, c, code_B7F40] #DONE @@ -1077,7 +1077,7 @@ segments: # - [0x103F3B0, .data, code_B3A80] # - [0x103F3F0, .data, code_B5040] # - [0x103F490, .data, code_B62B0] - # - [0x10407F0, .data, code_B6CE0] + # - [0x10407F0, .data, time] # - [0x1040800, .data, code_B6EA0] # - [0x1040830, .data, code_B7F40] # - [0x1040840, .data, code_B9770] @@ -1319,7 +1319,7 @@ segments: # - [0x1047920, .rodata, code_B3A80] # - [0x1047930, .rodata, string] # - [0x1047950, .rodata, code_B6C60] - # - [0x1047960, .rodata, code_B6CE0] + # - [0x1047960, .rodata, time] # - [0x1047990, .rodata, code_B9090] # - [0x10479C0, .rodata, code_B9770] # - [0x1047A50, .rodata, code_BD100] @@ -1605,7 +1605,7 @@ segments: # - [0x0106C980, .bss, code_B5E00] # - [0x0106C980, .bss, code_B62B0] # - [0x0106C980, .bss, code_B6C60] - # - [0x0106C980, .bss, code_B6CE0] + # - [0x0106C980, .bss, time] # - [0x0106C980, .bss, code_B6EA0] # - [0x0106C980, .bss, code_B8020] # - [0x0106C980, .bss, code_B8860] diff --git a/decompressed.us.v10.yaml b/decompressed.us.v10.yaml index 234da736..ae115637 100644 --- a/decompressed.us.v10.yaml +++ b/decompressed.us.v10.yaml @@ -822,7 +822,7 @@ segments: - [0x100BFA0, c, code_B6640] - [0x100C030, c, string] - [0x100C5C0, c, code_B6C60] - - [0x100C640, c, code_B6CE0] + - [0x100C640, c, time] - [0x100C800, c, code_B6EA0] - [0x100D480, c, coords] - [0x100D8A0, c, code_B7F40] @@ -1076,7 +1076,7 @@ segments: - [0x103F3B0, .data, code_B3A80] - [0x103F3F0, .data, code_B5040] - [0x103F490, .data, code_B62B0] - - [0x10407F0, .data, code_B6CE0] + - [0x10407F0, .data, time] - [0x1040800, .data, code_B6EA0] - [0x1040830, .data, code_B7F40] - [0x1040840, .data, code_B9770] @@ -1317,7 +1317,7 @@ segments: - [0x1047920, .rodata, code_B3A80] - [0x1047930, .rodata, string] - [0x1047950, .rodata, code_B6C60] - - [0x1047960, .rodata, code_B6CE0] + - [0x1047960, .rodata, time] - [0x1047990, .rodata, code_B9090] - [0x10479C0, .rodata, code_B9770] - [0x1047A50, .rodata, code_BD100] @@ -1603,7 +1603,7 @@ segments: - [0x1048560, .bss, code_B5E00] - [0x1048560, .bss, code_B62B0] - [0x1048560, .bss, code_B6C60] - - [0x1048560, .bss, code_B6CE0] + - [0x1048560, .bss, time] - [0x1048560, .bss, code_B6EA0] - [0x1048560, .bss, code_B8020] - [0x1048560, .bss, code_B8860] diff --git a/include/functions.h b/include/functions.h index 3fb9a48f..f8f15848 100644 --- a/include/functions.h +++ b/include/functions.h @@ -124,7 +124,7 @@ Actor *func_802C8C04(s32 position[3], s32 yaw, ActorInfo* actorInfo, u32 flags); Actor *marker_getActor(ActorMarker *); -f32 time_getDelta(void); +#include "time.h" void jiggy_spawn(enum jiggy_e jiggy_id, f32 pos[3]); struct3s *func_802F8264(s32 arg0); diff --git a/include/time.h b/include/time.h new file mode 100644 index 00000000..077089ad --- /dev/null +++ b/include/time.h @@ -0,0 +1,15 @@ +#ifndef __GL_TIME_H__ +#define __GL_TIME_H__ + +#include + +void time_reset(void); +void time_setDeltaReal_sec(f32 d_seconds); +void time_setDeltaReal_frames(s32 d_frames); +s32 time_getDeltaReal_frames(void); +f32 time_getDelta(void); +f32 time_func_8033DDB8(void); +f32 time_getDelta_frames(void); +void time_setMultiplier(f32 multiplier); + +#endif diff --git a/manual_syms.pal.txt b/manual_syms.pal.txt index 62773765..b928bb49 100644 --- a/manual_syms.pal.txt +++ b/manual_syms.pal.txt @@ -376,8 +376,8 @@ func_8033D564 = 0x8033d9b4; func_8033D574 = 0x8033d9c4; func_8033D594 = 0x8033d9e4; func_8033D5A4 = 0x8033d9f4; -func_8033DD04 = 0x8033e154; -func_8033DD90 = 0x8033e1e0; +time_setDeltaReal_frames = 0x8033e154; +time_getDeltaReal_frames = 0x8033e1e0; time_getDelta = 0x8033e1ec; allocUnusedBlock = 0x8033f3a8; func_8033EFB0 = 0x8033f400; diff --git a/src/TTC/ch/clam.c b/src/TTC/ch/clam.c index aa557f30..5a129da7 100644 --- a/src/TTC/ch/clam.c +++ b/src/TTC/ch/clam.c @@ -98,7 +98,7 @@ static bool __chClam_rotateTowardTarget(Actor *this, s32 arg1) { anctrl_setDuration(this->anctrl, 1.0f); - sp2C = (s32) ((f64) (60.0f / (f32) func_8033DD90()) * 0.5); + sp2C = (s32) ((f64) (60.0f / (f32) time_getDeltaReal_frames()) * 0.5); if ((this->unk1C[0] != 0.0f) || !__chClam_updateFuncTarget(this, sp2C)) { if (((f64) anctrl_getAnimTimer(this->anctrl) < 0.1) && ((f64) randf() < 0.5)) { if (this->unk1C[0] != 0.0f) { diff --git a/src/core1/pfsmanager.c b/src/core1/pfsmanager.c index ef5337e7..e0498e21 100644 --- a/src/core1/pfsmanager.c +++ b/src/core1/pfsmanager.c @@ -176,9 +176,9 @@ void pfsManager_update(void) { volatileFlag_set(VOLATILE_FLAG_63, 1); } } - func_8033DD04(sp5C); + time_setDeltaReal_frames(sp5C); } - sp5C = func_8033DD90(); + sp5C = time_getDeltaReal_frames(); randf(); for (i = 0; i < 4; i++) { if ((pfsManagerContPadData[i].button & 0x20) && (pfsManagerContPadData[i].button & 0x10)) { diff --git a/src/core2/ch/bottlesbonus.c b/src/core2/ch/bottlesbonus.c index 2c3c218c..c3df8493 100644 --- a/src/core2/ch/bottlesbonus.c +++ b/src/core2/ch/bottlesbonus.c @@ -8,7 +8,7 @@ extern void chBottlesBonusCursor_func_802DF99C(void); extern f32 *chBottlesBonusCursor_func_802E05AC(s32); extern f32 func_802E4B38(void); extern void func_8033A8F0(s32, s32, f32[4]); -extern f32 func_8033DDB8(void); +extern f32 time_func_8033DDB8(void); BKAnimationList *model_getAnimationList(BKModelBin *arg0); extern void func_8034BB08(s32); extern void func_803458E4(f32[4], f32[4], f32[4], f32); @@ -288,7 +288,7 @@ void chBottlesBonus_func_802DD8AC(BoneTransformList *arg0, s32 arg1) { actor = marker_getActor(chBottlesBonusMarker); spD4 = func_802E4B38(); - spD0 = func_8033DDB8(); + spD0 = time_func_8033DDB8(); if (D_8037DEB0 == 0) { D_8037DEB0 = 1; for(i = 0; i < CH_BOTTLES_BONUS_PUZZLE_PIECE_COUNT; i++){ @@ -452,7 +452,7 @@ void chBottlesBonus_update(Actor *this) { s32 phi_s0_2; local = (ActorLocal_core2_560F0 *) &this->local; - sp50 = func_8033DDB8(); + sp50 = time_func_8033DDB8(); if (!this->volatile_initialized) { this->volatile_initialized = TRUE; actor_collisionOff(this); diff --git a/src/core2/ch/bottlesbonuscursor.c b/src/core2/ch/bottlesbonuscursor.c index 1341fe33..a5b080c4 100644 --- a/src/core2/ch/bottlesbonuscursor.c +++ b/src/core2/ch/bottlesbonuscursor.c @@ -3,6 +3,7 @@ #include "functions.h" #include "variables.h" +#include "time.h" #ifndef ABS #define ABS(d) ((d) >= 0) ? (d) : -(d) @@ -13,7 +14,6 @@ extern u8 D_8037DCC8; //bottles bonus flags??? extern void func_8025AABC(enum comusic_e); extern f32 func_8024E420(s32, s32, s32); -extern f32 func_8033DDB8(void); extern void chBottlesBonus_func_802DEA50(s32); extern void actor_postdrawMethod(ActorMarker *); extern void chBottlesBonus_completedPuzzle(void); @@ -209,7 +209,7 @@ void chBottlesBonusCursor_update(Actor *this) { s32 sp44; sp5C = func_8024F3F4(); - sp58 = func_8033DDB8(); + sp58 = time_func_8033DDB8(); held_piece = &D_8037E248[D_8037E5C0.unk0]; if (!this->initialized) { this->initialized = TRUE; diff --git a/src/core2/code_5C240.c b/src/core2/code_5C240.c index d0b16520..1e8bdc6a 100644 --- a/src/core2/code_5C240.c +++ b/src/core2/code_5C240.c @@ -3,13 +3,14 @@ #include "functions.h" #include "variables.h" +#include "time.h" + extern void func_8023DFF0(s32); extern void comusicPlayer_update(void); extern void func_802F1A10(void *, f32); extern void func_8033DC10(void); extern void func_8033DC18(void); extern f32 func_8033DC20(void); -extern void func_8033DC9C(f32); /* .bss */ struct { @@ -115,10 +116,10 @@ void func_802E35D8(void ) { s32 sp38; if (D_8037E8C0.unk18 == 0.0f) { - func_8033DC9C(0.0f); + time_setDeltaReal_sec(0.0f); } else { func_8033DC18(); - func_8033DC9C(func_8033DC20()); + time_setDeltaReal_sec(func_8033DC20()); } func_8033DC10(); D_8037E8C0.unk18 += time_getDelta(); diff --git a/src/core2/code_5C870.c b/src/core2/code_5C870.c index bad8c4e1..fef98ff0 100644 --- a/src/core2/code_5C870.c +++ b/src/core2/code_5C870.c @@ -4,6 +4,7 @@ #include "variables.h" #include "gc/gctransition.h" +#include "time.h" extern void func_802F5374(void); extern void func_802FA0F8(void); @@ -30,7 +31,6 @@ void func_802E40E8(s32 transition); int func_802E4A08(void); f32 func_8033DC20(void); -void func_8033DC9C(f32); extern void func_80324C58(void); /* .data */ @@ -402,13 +402,13 @@ void func_802E4214(enum map_e map_id){ rand_reset(); scissorBox_setDefault(); func_80253FE8(); - func_8033DC70(); + time_reset(); func_8033DC04(); func_8031FBA0(); D_8037E8E0.game_mode = GAME_MODE_2_UNKNOWN; D_8037E8E0.unk8 = 0.0f; - func_8033DC9C(0.0f); - func_8033DD04(0); + time_setDeltaReal_sec(0.0f); + time_setDeltaReal_frames(0); func_803216D0(map_id); func_8030AFA0(map_id); func_802E3854(); @@ -419,12 +419,12 @@ void func_802E4214(enum map_e map_id){ void func_802E4384(void){ if(D_8037E8E0.unk8 == 0.0f){ - func_8033DC9C(0.0f); + time_setDeltaReal_sec(0.0f); } else{ func_8033DC18(); ; - func_8033DD04((s32)(func_8033DC20()*60.0f + 0.5)); + time_setDeltaReal_frames((s32)(func_8033DC20()*60.0f + 0.5)); } func_8033DC10(); diff --git a/src/core2/code_73640.c b/src/core2/code_73640.c index ca6382e7..34a6e1fd 100644 --- a/src/core2/code_73640.c +++ b/src/core2/code_73640.c @@ -2,6 +2,8 @@ #include "functions.h" #include "variables.h" +#include "time.h" + #define _73640_MAX(s,t) ((s < t)? t: s) #define _73640_MIN(s,t) ((s > t)? t: s) @@ -16,11 +18,6 @@ typedef struct item_print_s{ s32 func_802FAD9C(enum item_e item_id); -f32 time_getDelta(void); -f32 time_getDelta(void); - - - /* .data */ s16 D_803692E0[6] = { diff --git a/src/core2/code_B6CE0.c b/src/core2/code_B6CE0.c deleted file mode 100644 index 1f9d3ed2..00000000 --- a/src/core2/code_B6CE0.c +++ /dev/null @@ -1,51 +0,0 @@ -#include -#include "functions.h" -#include "variables.h" - -/*.data*/ -f32 D_80371E20 = 1.0f; - -/* .bss */ -f32 D_80384480; -s32 D_80384484; - -/* .code */ -void func_8033DC70(void){ - D_80384480 = 0.01f; - D_80371E20 = 1.0f; - D_80384484 = 0; -} - -void func_8033DC9C(f32 arg0){ - if(arg0 != 0.0f){ - D_80384480 = MIN(arg0, 0.05); - } - else{ - D_80384480 = 0.01f; - } -} - -void func_8033DD04(s32 arg0){ - D_80384484 = MAX(MIN(0xf, arg0) , 1); - func_8033DC9C(D_80384484*(1/60.0)); -} - -s32 func_8033DD90(void){ - return D_80384484; -} - -f32 time_getDelta(void){ - return D_80384480*D_80371E20; -} - -f32 func_8033DDB8(void){ - return viMgr_func_8024BD94()*(1/60.0); -} - -f32 func_8033DDEC(void){ - return time_getDelta()*30.0; -} - -void func_8033DE20(f32 arg0){ - D_80371E20 = arg0; -} diff --git a/src/core2/code_BEF20.c b/src/core2/code_BEF20.c index 0e7654fc..dafc751b 100644 --- a/src/core2/code_BEF20.c +++ b/src/core2/code_BEF20.c @@ -3,8 +3,8 @@ #include "functions.h" #include "variables.h" +#include "time.h" -f32 time_getDelta(void); void func_80346DB4(s32); s32 item_adjustByDiffWithHud(enum item_e item, s32 diff); diff --git a/src/core2/code_CBD10.c b/src/core2/code_CBD10.c index 0a21cf01..9a8348c2 100644 --- a/src/core2/code_CBD10.c +++ b/src/core2/code_CBD10.c @@ -6,7 +6,7 @@ #include "core2/anim/sprite.h" #include "code_B6EA0.h" -extern f32 func_8033DDEC(void); +extern f32 time_getDelta_frames(void); extern u8 func_8033E8D0(void); extern void func_8033FFE4(u8, s32, s32); extern void func_8033FC34(u8, s32); @@ -111,7 +111,7 @@ void func_80352F58(void){ f32 *sp2C = func_8033E960(); AnimSprite *sp28 = func_8033E8F4(); u8 sp27 = func_8033E8D0(); - f32 sp20 = func_8033DDEC(); + f32 sp20 = time_getDelta_frames(); if(animsprite_is_stopped(sp28)){ func_8033E984(); } diff --git a/src/core2/fx/common2score.c b/src/core2/fx/common2score.c index 6fd22108..b63c3754 100644 --- a/src/core2/fx/common2score.c +++ b/src/core2/fx/common2score.c @@ -3,8 +3,8 @@ #include "functions.h" #include "variables.h" +#include "time.h" -f32 time_getDelta(void); f32 func_802FB0DC(struct8s *); f32 func_802FB0E4(struct8s *); diff --git a/src/core2/fx/honeycarrierscore.c b/src/core2/fx/honeycarrierscore.c index 4778c2cb..adb1976f 100644 --- a/src/core2/fx/honeycarrierscore.c +++ b/src/core2/fx/honeycarrierscore.c @@ -3,11 +3,11 @@ #include "functions.h" #include "variables.h" +#include "time.h" #define _76D90_MAX(s,t) ((s < t)? t : s) #define _76D90_MIN(s,t) ((s > t)? t : s) -f32 time_getDelta(void); f32 func_802FDE60(f32); void timedFunc_set_1(f32, void (*)(s32), s32); void timedFunc_set_2(f32, void (*)(s32,s32), s32, s32); diff --git a/src/core2/gc/zoombox.c b/src/core2/gc/zoombox.c index 851cf9b3..6c49505c 100644 --- a/src/core2/gc/zoombox.c +++ b/src/core2/gc/zoombox.c @@ -5,8 +5,8 @@ #include "variables.h" #include "zoombox.h" +#include "time.h" -extern f32 func_8033DDB8(void); extern void func_80344090(BKSpriteDisplayData *self, s32 frame, Gfx **gfx); BKSprite *func_8033B6C4(enum asset_e sprite_id, BKSpriteDisplayData **arg1); @@ -883,7 +883,7 @@ void func_80316764(GcZoombox *this, s32 arg1) { } else { pfsManager_getFirstControllerFaceButtonState(0, sp38); func_8024E640(0, sp2C); - phi_f0 = func_8033DDB8(); + phi_f0 = time_func_8033DDB8(); } if (this->unkFC == NULL) @@ -1058,7 +1058,7 @@ void gczoombox_update(GcZoombox *this){ s32 sp48; f32 sp44; f32 tmp_f0; - sp48 = func_8033DD90(); + sp48 = time_getDeltaReal_frames(); if(this == NULL) return; @@ -1070,7 +1070,7 @@ void gczoombox_update(GcZoombox *this){ else{ pfsManager_getFirstControllerFaceButtonState(0, sp58); func_8024E640(0, sp4C); - tmp_f0 = func_8033DDB8(); + tmp_f0 = time_func_8033DDB8(); } switch(this->state){ diff --git a/src/core2/nc/dynamicCamera.c b/src/core2/nc/dynamicCamera.c index d2fb9ef0..a623886e 100644 --- a/src/core2/nc/dynamicCamera.c +++ b/src/core2/nc/dynamicCamera.c @@ -598,7 +598,7 @@ void func_802BD780(f32 arg0[3], f32 arg1[3], f32 arg2, f32 arg3, f32 arg4, f32 a s32 temp_s1; s32 i; - temp_s1 = func_8033DD90() * 5; + temp_s1 = time_getDeltaReal_frames() * 5; for(i = 0; i < temp_s1; i++){ func_802BD610(arg0, arg1, arg2, arg3, arg4, arg5); } @@ -758,7 +758,7 @@ void func_802BDE88(f32 *arg0, f32 *arg1, f32 arg2, f32 arg3, f32 arg4) { s32 end; s32 i; - end = func_8033DD90()*5; + end = time_getDeltaReal_frames()*5; for(i = 0; i < end; i++){ temp_f14 = arg2 - *arg1; temp_f2 = temp_f14*arg3 - *arg0; @@ -823,7 +823,7 @@ void func_802BE190(f32 arg0[3]){ return; } - end = func_8033DD90()*5; + end = time_getDeltaReal_frames()*5; ncDynamicCamera_getPosition(sp34); for(i = 0; i < end; i++){ func_802BDF5C(arg0, sp34); diff --git a/src/core2/statetimer.c b/src/core2/statetimer.c index 90836bd9..db6e7deb 100644 --- a/src/core2/statetimer.c +++ b/src/core2/statetimer.c @@ -1,5 +1,5 @@ #include "core2/statetimer.h" -extern f32 time_getDelta(void); +#include "time.h" typedef struct{ f32 now; diff --git a/src/core2/time.c b/src/core2/time.c new file mode 100644 index 00000000..94fc01fb --- /dev/null +++ b/src/core2/time.c @@ -0,0 +1,51 @@ +#include "time.h" + +#include "core1/vimgr.h" + +/*.data*/ +static f32 s_timeMultiplier = 1.0f; + +/* .bss */ +static f32 s_dTimeReal_sec; +static s32 s_dTimeReal_frames; + +/* .code */ +void time_reset(void){ + s_dTimeReal_sec = 0.01f; + s_timeMultiplier = 1.0f; + s_dTimeReal_frames = 0; +} + +void time_setDeltaReal_sec(f32 d_seconds){ + if(d_seconds != 0.0f){ + s_dTimeReal_sec = MIN(d_seconds, 0.05); + } + else{ + s_dTimeReal_sec = 0.01f; + } +} + +void time_setDeltaReal_frames(s32 d_frames){ + s_dTimeReal_frames = MAX(MIN(0xf, d_frames) , 1); + time_setDeltaReal_sec(s_dTimeReal_frames*(1/60.0)); +} + +s32 time_getDeltaReal_frames(void){ + return s_dTimeReal_frames; +} + +f32 time_getDelta(void){ + return s_dTimeReal_sec*s_timeMultiplier; +} + +f32 time_func_8033DDB8(void){ + return viMgr_func_8024BD94()*(1/60.0); +} + +f32 time_getDelta_frames(void){ + return time_getDelta()*30.0; +} + +void time_setMultiplier(f32 multiplier){ + s_timeMultiplier = multiplier; +}