Skip to content

Commit

Permalink
Fix cLib_calcTimer (#1963)
Browse files Browse the repository at this point in the history
* Fix cLib_calcTimer

* Clean up some additional RELs
  • Loading branch information
jakepatzer authored Oct 21, 2023
1 parent 0ae34ed commit d61ae29
Show file tree
Hide file tree
Showing 15 changed files with 18 additions and 185 deletions.
20 changes: 10 additions & 10 deletions Progress.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,22 @@ Section | Percentage | Decompiled (bytes) | Total (bytes)
.init | 97.972973% | 9280 | 9472
.extab | 100.000000% | 96 | 96
.extabindex | 100.000000% | 96 | 96
.text | 34.326954% | 1234584 | 3596544
.text | 34.328845% | 1234652 | 3596544
.ctors | 100.000000% | 448 | 448
.dtors | 100.000000% | 32 | 32
.rodata | 100.000000% | 193856 | 193856
.data | 100.000000% | 197632 | 197632
.sdata | 100.000000% | 1408 | 1408
.sdata2 | 100.000000% | 20832 | 20832
Total | 41.249821% | 1658520 | 4020672
Total | 41.251512% | 1658588 | 4020672

## Total

Section | Percentage | Decompiled (bytes) | Total (bytes)
---|---|---|---
main.dol | 41.249821% | 1658520 | 4020672
RELs | 34.630503% | 3982620 | 11500324
Total | 36.345219% | 5641140 | 15520996
main.dol | 41.251512% | 1658588 | 4020672
RELs | 34.631963% | 3982788 | 11500324
Total | 36.346740% | 5641376 | 15520996

## RELs

Expand Down Expand Up @@ -622,7 +622,7 @@ d_a_obj_swLight | 40.346767% | 3444 | 8536
d_a_obj_swchain | 24.473297% | 3996 | 16328
d_a_obj_swhang | 38.446450% | 3920 | 10196
d_a_obj_sword | 45.479963% | 1952 | 4292
d_a_obj_swpropeller | 98.552722% | 5720 | 5804
d_a_obj_swpropeller | 100.000000% | 5804 | 5804
d_a_obj_swpush | 31.657104% | 3752 | 11852
d_a_obj_swpush2 | 34.150019% | 3624 | 10612
d_a_obj_swpush5 | 39.210384% | 2900 | 7396
Expand Down Expand Up @@ -690,7 +690,7 @@ d_a_path_line | 100.000000% | 508 | 508
d_a_peru | 33.139234% | 10244 | 30912
d_a_ppolamp | 42.341463% | 1736 | 4100
d_a_scene_exit | 61.359223% | 1264 | 2060
d_a_scene_exit2 | 99.075297% | 3000 | 3028
d_a_scene_exit2 | 100.000000% | 3028 | 3028
d_a_set_bgobj | 100.000000% | 1108 | 1108
d_a_shop_item | 43.088737% | 2020 | 4688
d_a_skip_2D | 100.000000% | 1332 | 1332
Expand Down Expand Up @@ -723,7 +723,7 @@ d_a_tag_escape | 100.000000% | 712 | 712
d_a_tag_event | 31.075697% | 1248 | 4016
d_a_tag_evt | 37.815126% | 1620 | 4284
d_a_tag_evtarea | 100.000000% | 3548 | 3548
d_a_tag_evtmsg | 99.225664% | 3588 | 3616
d_a_tag_evtmsg | 100.000000% | 3616 | 3616
d_a_tag_firewall | 35.325132% | 1608 | 4552
d_a_tag_gra | 100.000000% | 800 | 800
d_a_tag_gstart | 100.000000% | 1208 | 1208
Expand All @@ -747,7 +747,7 @@ d_a_tag_mmsg | 100.000000% | 1960 | 1960
d_a_tag_msg | 37.563971% | 1468 | 3908
d_a_tag_mstop | 43.995098% | 1436 | 3264
d_a_tag_mwait | 100.000000% | 2896 | 2896
d_a_tag_myna2 | 98.401826% | 1724 | 1752
d_a_tag_myna2 | 100.000000% | 1752 | 1752
d_a_tag_myna_light | 100.000000% | 3124 | 3124
d_a_tag_pachi | 100.000000% | 2528 | 2528
d_a_tag_poFire | 100.000000% | 1688 | 1688
Expand Down Expand Up @@ -785,4 +785,4 @@ d_a_vrbox2 | 44.907111% | 2804 | 6244
d_a_warp_bug | 100.000000% | 2024 | 2024
d_a_ykgr | 44.400631% | 2252 | 5072
f_pc_profile_lst | 100.000000% | 28156 | 28156
Total | 34.630503% | 3982620 | 11500324
Total | 34.631963% | 3982788 | 11500324

This file was deleted.

9 changes: 0 additions & 9 deletions asm/d/msg/d_msg_flow/func_8024DAB0.s

This file was deleted.

9 changes: 0 additions & 9 deletions asm/rel/d/a/d_a_scene_exit2/d_a_scene_exit2/func_8059E7D0.s

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

9 changes: 0 additions & 9 deletions asm/rel/d/a/tag/d_a_tag_evtmsg/d_a_tag_evtmsg/func_8048D760.s

This file was deleted.

9 changes: 0 additions & 9 deletions asm/rel/d/a/tag/d_a_tag_myna2/d_a_tag_myna2/func_80D5CA18.s

This file was deleted.

3 changes: 2 additions & 1 deletion include/SSystem/SComponent/c_lib.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ inline T cLib_maxLimit(T val, T max) {

template <typename T>
T cLib_calcTimer(T* value) {
if (*value != 0) {
// Casting 0 to u16 may not be correct, but is matching for now
if (*value != (u16)0) {
*value = *value - 1;
}
return *value;
Expand Down
14 changes: 1 addition & 13 deletions rel/d/a/d_a_scene_exit2/d_a_scene_exit2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
#include "d/com/d_com_inf_game.h"
#include "d/d_procname.h"

extern "C" u8 func_8059E7D0(u8*);

/* 8059E838-8059E844 000000 000C+00 1/1 0/0 0/0 .data cNullVec__6Z2Calc */
static u8 cNullVec__6Z2Calc[12] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
Expand Down Expand Up @@ -151,7 +149,7 @@ int daScExit_c::demoProc() {

switch (act_id) {
case WAIT_e:
if (func_8059E7D0(&mTimer) == 0) {
if (cLib_calcTimer(&mTimer) == 0) {
dComIfGp_evmng_cutEnd(mStaffID);
}
break;
Expand Down Expand Up @@ -205,16 +203,6 @@ static int daScExit_Create(daScExit_c* i_this) {
return i_this->create();
}

/* 8059E7D0-8059E7EC 0006F0 001C+00 1/1 0/0 0/0 .text cLib_calcTimer<Uc>__FPUc */
#pragma push
#pragma optimization_level 0
#pragma optimizewithasm off
extern "C" asm u8 func_8059E7D0(u8* param_0) {
nofralloc
#include "asm/rel/d/a/d_a_scene_exit2/d_a_scene_exit2/func_8059E7D0.s"
}
#pragma pop

/* 8059E8CC-8059E8EC -00001 0020+00 1/0 0/0 0/0 .data l_daScExit_Method */
static actor_method_class l_daScExit_Method = {
(process_method_func)daScExit_Create, (process_method_func)daScExit_Delete,
Expand Down
40 changes: 3 additions & 37 deletions rel/d/a/obj/d_a_obj_swpropeller/d_a_obj_swpropeller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@
#define TYPE_BOOMERANG 0 // only turns when hit with boomerang
#define TYPE_WIND 1 // automatically turns

extern "C" u16 func_8059B26C(u16*);
extern "C" u8 func_8059B288(u8*);
extern "C" s16 func_8059B2A4(s16*);

/* 8059A518-8059A5C8 000078 00B0+00 1/1 0/0 0/0 .text nodeCallBack__FP8J3DJointi */
static int nodeCallBack(J3DJoint* i_joint, int param_1) {
if (param_1 == 0) {
Expand Down Expand Up @@ -181,7 +177,7 @@ void daObjSwPr_c::switchCtrl() {

if (mRotateSpeed == 0) {
i_fopAcM_offSwitch(this, sw);
} else if (func_8059B2A4(&mSwDelayTimer) == 0) {
} else if (cLib_calcTimer(&mSwDelayTimer) == 0) {
i_fopAcM_onSwitch(this, sw);
}
}
Expand Down Expand Up @@ -222,7 +218,7 @@ void daObjSwPr_c::execute_type_boomerang() {
}
}

if (func_8059B288(&field_0x83a) != 0) {
if (cLib_calcTimer(&field_0x83a) != 0) {
mRotateSpeed = 0x2000;
}

Expand Down Expand Up @@ -279,7 +275,7 @@ void daObjSwPr_c::execute_type_wind() {
}
}
}
} else if (mSwOffDelayTimer != 0 && func_8059B26C(&mSwOffDelayTimer) == 0) {
} else if (mSwOffDelayTimer != 0 && cLib_calcTimer(&mSwOffDelayTimer) == 0) {
i_fopAcM_offSwitch(this, sw);
}

Expand Down Expand Up @@ -353,36 +349,6 @@ static int daObjSwPr_Create(fopAc_ac_c* i_this) {
return static_cast<daObjSwPr_c*>(i_this)->create();
}

/* 8059B26C-8059B288 000DCC 001C+00 1/1 0/0 0/0 .text cLib_calcTimer<Us>__FPUs */
#pragma push
#pragma optimization_level 0
#pragma optimizewithasm off
extern "C" asm u16 func_8059B26C(u16* param_0) {
nofralloc
#include "asm/rel/d/a/obj/d_a_obj_swpropeller/d_a_obj_swpropeller/func_8059B26C.s"
}
#pragma pop

/* 8059B288-8059B2A4 000DE8 001C+00 1/1 0/0 0/0 .text cLib_calcTimer<Uc>__FPUc */
#pragma push
#pragma optimization_level 0
#pragma optimizewithasm off
extern "C" asm u8 func_8059B288(u8* param_0) {
nofralloc
#include "asm/rel/d/a/obj/d_a_obj_swpropeller/d_a_obj_swpropeller/func_8059B288.s"
}
#pragma pop

/* 8059B2A4-8059B2C0 000E04 001C+00 1/1 0/0 0/0 .text cLib_calcTimer<s>__FPs */
#pragma push
#pragma optimization_level 0
#pragma optimizewithasm off
extern "C" asm s16 func_8059B2A4(s16* param_0) {
nofralloc
#include "asm/rel/d/a/obj/d_a_obj_swpropeller/d_a_obj_swpropeller/func_8059B2A4.s"
}
#pragma pop

/* 8059B38C-8059B3AC -00001 0020+00 1/0 0/0 0/0 .data l_daObjSwPr_Method */
static actor_method_class l_daObjSwPr_Method = {
(process_method_func)daObjSwPr_Create, (process_method_func)daObjSwPr_Delete,
Expand Down
14 changes: 1 addition & 13 deletions rel/d/a/tag/d_a_tag_evtmsg/d_a_tag_evtmsg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
#include "d/com/d_com_inf_game.h"
#include "d/d_procname.h"

extern "C" int func_8048D760(int*);

/* 8048D818-8048D824 000000 000C+00 2/2 0/0 0/0 .data cNullVec__6Z2Calc */
static u8 cNullVec__6Z2Calc[12] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
Expand Down Expand Up @@ -236,7 +234,7 @@ BOOL daTag_EvtMsg_c::ECut_wait(int i_staffID) {
mTimer = timer;
}

if (func_8048D760(&mTimer) == 0) {
if (cLib_calcTimer(&mTimer) == 0) {
return 1;
}

Expand Down Expand Up @@ -271,16 +269,6 @@ static int daTag_EvtMsg_IsDelete(void* i_this) {
/* 8048D6F0-8048D760 000830 0070+00 1/0 0/0 0/0 .text __dt__14daTag_EvtMsg_cFv */
daTag_EvtMsg_c::~daTag_EvtMsg_c() {}

/* 8048D760-8048D77C 0008A0 001C+00 1/1 0/0 0/0 .text cLib_calcTimer<i>__FPi */
#pragma push
#pragma optimization_level 0
#pragma optimizewithasm off
extern "C" asm int func_8048D760(int* param_0) {
nofralloc
#include "asm/rel/d/a/tag/d_a_tag_evtmsg/d_a_tag_evtmsg/func_8048D760.s"
}
#pragma pop

/* 8048D884-8048D8A4 -00001 0020+00 1/0 0/0 0/0 .data daTag_EvtMsg_MethodTable */
static actor_method_class daTag_EvtMsg_MethodTable = {
(process_method_func)daTag_EvtMsg_Create, (process_method_func)daTag_EvtMsg_Delete,
Expand Down
17 changes: 1 addition & 16 deletions rel/d/a/tag/d_a_tag_myna2/d_a_tag_myna2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@
#include "JSystem/JKernel/JKRHeap.h"
#include "d/d_procname.h"

// clib_calcTimer
extern "C" void func_80D5CA18(s16*);

/* 80D5C698-80D5C708 000078 0070+00 1/1 0/0 0/0 .text create__12daTagMyna2_cFv */
s32 daTagMyna2_c::create() {
fopAcM_SetupActor(this, daTagMyna2_c);
Expand Down Expand Up @@ -49,9 +46,7 @@ s32 daTagMyna2_c::execute() {
if (i_dComIfGp_event_runCheck()) {
mTimer = 5;
} else {
// func_80D5CA18 is clib_calcTimer.
// It should be compiler generated, but it causes matching issues currently.
func_80D5CA18(&mTimer);
cLib_calcTimer(&mTimer);
}

return 1;
Expand All @@ -75,16 +70,6 @@ static s32 daTagMyna2_Delete(daTagMyna2_c* i_this) {
return 1;
}

/* 80D5CA18-80D5CA34 0003F8 001C+00 1/1 0/0 0/0 .text cLib_calcTimer<s>__FPs */
#pragma push
#pragma optimization_level 0
#pragma optimizewithasm off
extern "C" asm void func_80D5CA18(s16* param_0) {
nofralloc
#include "asm/rel/d/a/tag/d_a_tag_myna2/d_a_tag_myna2/func_80D5CA18.s"
}
#pragma pop

/* ############################################################################################## */
/* 80D5CA64-80D5CA84 -00001 0020+00 1/0 0/0 0/0 .data l_daTagMyna2_Method */
static actor_method_class l_daTagMyna2_Method = {
Expand Down
21 changes: 0 additions & 21 deletions src/d/msg/d_msg_flow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2113,21 +2113,10 @@ int dMsgFlow_c::event020(mesg_flow_node_event* flow_node, fopAc_ac_c* actor) {

/* 8024CD84-8024CDAC 2476C4 0028+00 1/0 0/0 0/0 .text
* event021__10dMsgFlow_cFP20mesg_flow_node_eventP10fopAc_ac_c */
#ifdef NONMATCHING
int dMsgFlow_c::event021(mesg_flow_node_event* param_0, fopAc_ac_c* param_1) {
cLib_calcTimer(&field_0x3c);
return 1;
}
#else
#pragma push
#pragma optimization_level 0
#pragma optimizewithasm off
asm int dMsgFlow_c::event021(mesg_flow_node_event* param_0, fopAc_ac_c* param_1) {
nofralloc
#include "asm/d/msg/d_msg_flow/event021__10dMsgFlow_cFP20mesg_flow_node_eventP10fopAc_ac_c.s"
}
#pragma pop
#endif

/* ############################################################################################## */
/* 80454DA8-80454DAC 0033A8 0004+00 1/1 0/0 0/0 .sdata2 @6273 */
Expand Down Expand Up @@ -2615,14 +2604,4 @@ int dMsgFlow_c::event042(mesg_flow_node_event*, fopAc_ac_c*) {
return 1;
}

/* 8024DAB0-8024DACC 2483F0 001C+00 3/3 0/0 0/0 .text cLib_calcTimer<l>__FPl */
#pragma push
#pragma optimization_level 0
#pragma optimizewithasm off
extern "C" asm void func_8024DAB0(void* _this, s32* param_0) {
nofralloc
#include "asm/d/msg/d_msg_flow/func_8024DAB0.s"
}
#pragma pop

/* 80399CB0-80399CB0 026310 0000+00 0/0 0/0 0/0 .rodata @stringBase0 */

0 comments on commit d61ae29

Please sign in to comment.