Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 43 additions & 20 deletions include/d/actor/d_a_obj_timer.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef D_A_OBJ_TIMER_H
#define D_A_OBJ_TIMER_H

#include "f_op/f_op_actor_mng.h"
#include "d/d_a_obj.h"

/**
* @ingroup actors-objects
Expand All @@ -11,34 +11,57 @@
* @details
*
*/
class daObjTimer : public fopAc_ac_c {
public:
class Act_c {
namespace daObjTimer {
class Act_c : public fopAc_ac_c {
public:
struct Prm_e {};
typedef void (daObjTimer::Act_c::*modeProc)();

/* 80485198 */ void _create();
enum Prm_e {
PRM_0 = 0,
PRM_1 = 1,
PRM_2 = 2,
PRM_8 = 8,
PRM_16 = 16,
PRM_24 = 24,
PRM_26 = 26,
};

/* 80485198 */ int _create();
/* 8048526C */ bool _delete();
/* 80485274 */ void mode_wait_init();
/* 80485284 */ void mode_wait();
/* 804852E0 */ void mode_count_init();
/* 80485324 */ void mode_count();
/* 804854BC */ void _execute();
};
/* 804854BC */ int _execute();

int prm_get_swSave() {
return daObj::PrmAbstract(this,PRM_8, PRM_16);
}

private:
/* 0x568 */ u8 field_0x568[0x574 - 0x568];
};
int prm_get_sw2Save() {
return daObj::PrmAbstract(this, PRM_8, PRM_8);
}

STATIC_ASSERT(sizeof(daObjTimer) == 0x574);
int prm_get_time() {
return daObj::PrmAbstract(this, PRM_8, PRM_0);
}

int prm_get_SeStop() {
return daObj::PrmAbstract(this, PRM_1, PRM_26);
}

int prm_get_demoStop() {
return daObj::PrmAbstract(this, PRM_2, PRM_24);
}

private:
/* 0x568 */ int field_0x568;
/* 0x56C */ int field_0x56c;
/* 0x570 */ u8 field_0x570;
/* 0x571 */ u8 field_0x571[0x574 - 0x571];
};
}

struct daObj {
public:
template <typename A1>
void PrmAbstract(/* ... */);
/* 8048561C */ /* daObj::PrmAbstract<daObjTimer::Act_c::Prm_e> */
void func_8048561C(void* _this, fopAc_ac_c const*, daObjTimer::Act_c::Prm_e,
daObjTimer::Act_c::Prm_e);
};
STATIC_ASSERT(sizeof(daObjTimer::Act_c) == 0x574);

#endif /* D_A_OBJ_TIMER_H */
243 changes: 100 additions & 143 deletions src/d/actor/d_a_obj_timer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,49 +4,29 @@
*/

#include "d/actor/d_a_obj_timer.h"
#include "dol2asm.h"

//
// Forward References:
//

extern "C" void _create__Q210daObjTimer5Act_cFv();
extern "C" bool _delete__Q210daObjTimer5Act_cFv();
extern "C" void mode_wait_init__Q210daObjTimer5Act_cFv();
extern "C" void mode_wait__Q210daObjTimer5Act_cFv();
extern "C" void mode_count_init__Q210daObjTimer5Act_cFv();
extern "C" void mode_count__Q210daObjTimer5Act_cFv();
extern "C" void _execute__Q210daObjTimer5Act_cFv();
extern "C" static void func_804855A4();
extern "C" static void func_804855C4();
extern "C" static void func_804855E8();
extern "C" static bool func_8048560C();
extern "C" static bool func_80485614();
extern "C" void func_8048561C(void* _this, fopAc_ac_c const*, daObjTimer::Act_c::Prm_e,
daObjTimer::Act_c::Prm_e);

//
// External References:
//

extern "C" void __ct__10fopAc_ac_cFv();
extern "C" void fopAcM_delete__FP10fopAc_ac_c();
extern "C" void fopDwTg_DrawQTo__FP16create_tag_class();
extern "C" void offSwitch__10dSv_info_cFii();
extern "C" void isSwitch__10dSv_info_cCFii();
extern "C" void seStart__7Z2SeMgrF10JAISoundIDPC3VecUlScffffUc();
extern "C" void __ptmf_scall();
extern "C" extern u8 g_dComIfG_gameInfo[122384];
extern "C" u8 mAudioMgrPtr__10Z2AudioMgr[4 + 4 /* padding */];
extern "C" extern u8 data_804856E8[4];

//
// Declarations:
//
#include "d/d_com_inf_game.h"
#include "f_op/f_op_actor_mng.h"

UNK_REL_DATA

/* 80485198-8048526C 000078 00D4+00 1/1 0/0 0/0 .text _create__Q210daObjTimer5Act_cFv */
void daObjTimer::Act_c::_create() {
// NONMATCHING
int daObjTimer::Act_c::_create() {
int rv;
fopAcM_SetupActor(this, Act_c);
fopAcM_offDraw(this);

if (fopAcM_isSwitch(this, prm_get_sw2Save())) {
rv = 5;
} else {
if (fopAcM_isSwitch(this, prm_get_swSave())) {
mode_count_init();
} else {
mode_wait_init();
}
rv = 4;
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the 5 and 4 here can be replaced with cPhs_ERROR_e and cPhs_COMPLEATE_e

return rv;
}

/* 8048526C-80485274 00014C 0008+00 1/1 0/0 0/0 .text _delete__Q210daObjTimer5Act_cFv */
Expand All @@ -56,136 +36,113 @@ bool daObjTimer::Act_c::_delete() {

/* 80485274-80485284 000154 0010+00 2/2 0/0 0/0 .text mode_wait_init__Q210daObjTimer5Act_cFv */
void daObjTimer::Act_c::mode_wait_init() {
// NONMATCHING
field_0x56c = 0;
field_0x568 = 0;
}

/* 80485284-804852E0 000164 005C+00 1/0 0/0 0/0 .text mode_wait__Q210daObjTimer5Act_cFv
*/
/* 80485284-804852E0 000164 005C+00 1/0 0/0 0/0 .text mode_wait__Q210daObjTimer5Act_cFv */
void daObjTimer::Act_c::mode_wait() {
// NONMATCHING
if (fopAcM_isSwitch(this, prm_get_swSave())) {
mode_count_init();
}
}

/* 804852E0-80485324 0001C0 0044+00 2/2 0/0 0/0 .text mode_count_init__Q210daObjTimer5Act_cFv */
void daObjTimer::Act_c::mode_count_init() {
// NONMATCHING
field_0x56c = prm_get_time() * 15;
field_0x568 = 1;
}

/* ############################################################################################## */
/* 80485640-80485644 000000 0004+00 1/1 0/0 0/0 .rodata @3720 */
SECTION_RODATA static f32 const lit_3720 = 1.0f;
COMPILER_STRIP_GATE(0x80485640, &lit_3720);

/* 80485644-80485648 000004 0004+00 1/1 0/0 0/0 .rodata @3721 */
SECTION_RODATA static f32 const lit_3721 = -1.0f;
COMPILER_STRIP_GATE(0x80485644, &lit_3721);

/* 80485324-804854BC 000204 0198+00 1/0 0/0 0/0 .text mode_count__Q210daObjTimer5Act_cFv
*/
/* 80485324-804854BC 000204 0198+00 1/0 0/0 0/0 .text mode_count__Q210daObjTimer5Act_cFv */
void daObjTimer::Act_c::mode_count() {
// NONMATCHING
Z2SoundID soundID;

if (!field_0x570) {
field_0x56c--;
if (prm_get_SeStop() && ((field_0x56c / 30) * field_0x56c - field_0x56c) == 0) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fairly sure that pattern there with field_0x56c is a modulo operation?

if (dComIfGp_event_runCheck() && prm_get_demoStop()) {
field_0x56c += 30;
}

int iVar1 = field_0x56c / 30;
if (iVar1 <= 20) {
if (iVar1 > 10) {
soundID = JA_SE_SYS_EV_TIMER_20;
} else if (iVar1 > 5) {
soundID = JA_SE_SYS_EV_TIMER_10;
} else if (iVar1 > 0) {
soundID = JA_SE_SYS_EV_TIMER_5;
} else {
soundID = JA_SE_SYS_EV_TIMER_0;
}

mDoAud_seStart(soundID, 0, 0, 0);
}
}

if (field_0x56c > 0) {
if (fopAcM_isSwitch(this, prm_get_swSave())) {
return;
}
}

fopAcM_offSwitch(this, prm_get_swSave());
mode_wait_init();
}
}

/* ############################################################################################## */
/* 80485648-80485654 000000 000C+00 1/1 0/0 0/0 .data cNullVec__6Z2Calc */
SECTION_DATA static u8 cNullVec__6Z2Calc[12] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};

/* 80485654-80485668 00000C 0004+10 0/0 0/0 0/0 .data @1787 */
#pragma push
#pragma force_active on
SECTION_DATA static u32 lit_1787[1 + 4 /* padding */] = {
0x02000201,
/* padding */
0x40080000,
0x00000000,
0x3FE00000,
0x00000000,
};
#pragma pop

/* 80485668-80485674 -00001 000C+00 0/1 0/0 0/0 .data @3726 */
#pragma push
#pragma force_active on
SECTION_DATA static void* lit_3726[3] = {
(void*)NULL,
(void*)0xFFFFFFFF,
(void*)mode_wait__Q210daObjTimer5Act_cFv,
};
#pragma pop

/* 80485674-80485680 -00001 000C+00 0/1 0/0 0/0 .data @3727 */
#pragma push
#pragma force_active on
SECTION_DATA static void* lit_3727[3] = {
(void*)NULL,
(void*)0xFFFFFFFF,
(void*)mode_count__Q210daObjTimer5Act_cFv,
};
#pragma pop

/* 80485680-80485698 000038 0018+00 0/1 0/0 0/0 .data mode_proc$3725 */
#pragma push
#pragma force_active on
SECTION_DATA static u8 mode_proc[24] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};
#pragma pop

/* 804854BC-804855A4 00039C 00E8+00 1/1 0/0 0/0 .text _execute__Q210daObjTimer5Act_cFv */
void daObjTimer::Act_c::_execute() {
// NONMATCHING
int daObjTimer::Act_c::_execute() {
static daObjTimer::Act_c::modeProc const mode_proc[2] = {
&daObjTimer::Act_c::mode_wait,
&daObjTimer::Act_c::mode_count,
};

if (fopAcM_isSwitch(this, prm_get_sw2Save())) {
fopAcM_delete(this);
return 1;
} else {
(this->*mode_proc[field_0x568])();
return 1;
}
}

/* 804855A4-804855C4 000484 0020+00 1/0 0/0 0/0 .text
* Mthd_Create__Q210daObjTimer27@unnamed@d_a_obj_timer_cpp@FPv */
static void func_804855A4() {
// NONMATCHING
/* 804855A4-804855C0 .text daObjTimer::@unnamed@d_a_obj_timer_cpp@::Mthd_Create */
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

all of these functions / data that have @unnamed@d_a_obj_timer_cpp@ in them should be wrapped in an anonymous namespace to get the name mangling correct

int Mthd_Create(fopAc_ac_c* i_this) {
return static_cast<daObjTimer::Act_c*>(i_this)->_create();
}

/* 804855C4-804855E8 0004A4 0024+00 1/0 0/0 0/0 .text
* Mthd_Delete__Q210daObjTimer27@unnamed@d_a_obj_timer_cpp@FPv */
static void func_804855C4() {
// NONMATCHING
/* 804855C4-804855E4 .text daObjTimer::@unnamed@d_a_obj_timer_cpp@::Mthd_Delete */
int Mthd_Delete(fopAc_ac_c* i_this) {
return static_cast<daObjTimer::Act_c*>(i_this)->_delete();
}

/* 804855E8-8048560C 0004C8 0024+00 1/0 0/0 0/0 .text
* Mthd_Execute__Q210daObjTimer27@unnamed@d_a_obj_timer_cpp@FPv */
static void func_804855E8() {
/* 804855E8-80485608 .text daObjTimer::@unnamed@d_a_obj_timer_cpp@::Mthd_Execute */
int Mthd_Execute(fopAc_ac_c* i_this) {
// NONMATCHING
return static_cast<daObjTimer::Act_c*>(i_this)->_execute();
}

/* 8048560C-80485614 0004EC 0008+00 1/0 0/0 0/0 .text
* Mthd_Draw__Q210daObjTimer27@unnamed@d_a_obj_timer_cpp@FPv */
static bool func_8048560C() {
return true;
}

/* 80485614-8048561C 0004F4 0008+00 1/0 0/0 0/0 .text
* Mthd_IsDelete__Q210daObjTimer27@unnamed@d_a_obj_timer_cpp@FPv */
static bool func_80485614() {
return true;
/* 8048560C-80485610 .text daObjTimer::@unnamed@d_a_obj_timer_cpp@::Mthd_Draw */
int Mthd_Draw(fopAc_ac_c* i_this) {
return 1;
}

/* 8048561C-80485638 0004FC 001C+00 5/5 0/0 0/0 .text
* PrmAbstract<Q310daObjTimer5Act_c5Prm_e>__5daObjFPC10fopAc_ac_cQ310daObjTimer5Act_c5Prm_eQ310daObjTimer5Act_c5Prm_e
*/
extern "C" void func_8048561C(void* _this, fopAc_ac_c const* param_0,
daObjTimer::Act_c::Prm_e param_1,
daObjTimer::Act_c::Prm_e param_2) {
// NONMATCHING
/* 80485614-80485618 .text daObjTimer::@unnamed@d_a_obj_timer_cpp@::Mthd_IsDelete */
int Mthd_IsDelete(fopAc_ac_c* i_this) {
return 1;
}

/* ############################################################################################## */
/* 80485698-804856B8 -00001 0020+00 1/0 0/0 0/0 .data
* Mthd_Table__Q210daObjTimer27@unnamed@d_a_obj_timer_cpp@ */
static actor_method_class data_80485698 = {
(process_method_func)func_804855A4,
(process_method_func)func_804855C4,
(process_method_func)func_804855E8,
(process_method_func)func_80485614,
(process_method_func)func_8048560C,
actor_method_class l_daTimer_Method = {
(process_method_func)Mthd_Create,
(process_method_func)Mthd_Delete,
(process_method_func)Mthd_Execute,
(process_method_func)Mthd_Draw,
(process_method_func)Mthd_IsDelete,
};

/* 804856B8-804856E8 -00001 0030+00 0/0 0/0 1/0 .data g_profile_Obj_Timer */
Expand All @@ -195,12 +152,12 @@ extern actor_process_profile_definition g_profile_Obj_Timer = {
fpcPi_CURRENT_e, // mListPrio
PROC_Obj_Timer, // mProcName
&g_fpcLf_Method.base, // sub_method
sizeof(daObjTimer), // mSize
sizeof(daObjTimer::Act_c), // mSize
0, // mSizeOther
0, // mParameters
&g_fopAc_Method.base, // sub_method
22, // mPriority
&data_80485698, // sub_method
&l_daTimer_Method, // sub_method
0x00040000, // mStatus
fopAc_ACTOR_e, // mActorType
fopAc_CULLBOX_0_e, // cullType
Expand Down