From 8945d46f0913ec203975ef08864f0dbd6ef6a371 Mon Sep 17 00:00:00 2001 From: lepelog <25211966+lepelog@users.noreply.github.com> Date: Wed, 8 Jun 2022 21:50:29 +0200 Subject: [PATCH] progress --- include/SSystem/SComponent/c_xyz.h | 6 +- include/d/com/d_com_inf_game.h | 29 + include/d/d_demo.h | 35 ++ include/d/d_gameover.h | 46 ++ include/d/d_stage.h | 8 +- include/d/event/d_event_data.h | 24 +- include/d/event/d_event_manager.h | 1 + include/d/kankyo/d_kankyo.h | 2 + include/dolphin/mtx/vec.h | 6 + include/f_op/f_op_msg_mng.h | 5 +- libs/SSystem/SComponent/c_m3d_g_aab.cpp | 8 +- src/d/d_demo.cpp | 34 +- src/d/d_gameover.cpp | 84 +-- src/d/d_name.cpp | 1 + src/d/event/d_event_data.cpp | 694 +++++++++++++++++------- src/f_op/f_op_msg_mng.cpp | 4 +- 16 files changed, 663 insertions(+), 324 deletions(-) diff --git a/include/SSystem/SComponent/c_xyz.h b/include/SSystem/SComponent/c_xyz.h index e218303fc17..2492f929066 100644 --- a/include/SSystem/SComponent/c_xyz.h +++ b/include/SSystem/SComponent/c_xyz.h @@ -72,11 +72,7 @@ struct cXyz : Vec { /* 80267128 */ s16 atan2sX_Z() const; /* 80267150 */ s16 atan2sY_XZ() const; - void setAll(f32 f) { - z = f; - y = f; - x = f; - } + void setAll(f32 f) { set(f, f, f); } void setMin(const cXyz& other) { if (x > other.x) { diff --git a/include/d/com/d_com_inf_game.h b/include/d/com/d_com_inf_game.h index ce6b801e643..9a905f66a29 100644 --- a/include/d/com/d_com_inf_game.h +++ b/include/d/com/d_com_inf_game.h @@ -389,6 +389,10 @@ public: mWindow[i].setMode(mode); } + char* getLastPlayStageName() { return mLastPlayStageName; } + + u8 getGameoverStatus() { return mGameoverStatus; } + public: /* 0x00000 */ dBgS mBgs; /* 0x01404 */ dCcS mCcs; @@ -651,6 +655,7 @@ void dComIfG_get_timelayer(int* layer); int dComIfG_resDelete(request_of_phase_process_class* i_phase, char const* resName); int dComIfG_changeOpeningScene(scene_class* scene, s16 procName); int dComIfG_resLoad(request_of_phase_process_class* i_phase, char const* arc_name); +BOOL dComIfGs_isStageSwitch(int i_stageNo, int i_no); inline void dComIfG_setBrightness(u8 brightness) { g_dComIfG_gameInfo.mFadeBrightness = brightness; @@ -2059,6 +2064,14 @@ inline void dComIfGp_evmng_cutEnd(int param_0) { dComIfGp_getPEvtManager()->cutEnd(param_0); } +inline int i_dComIfGp_evmng_getMyStaffId(const char* pName, fopAc_ac_c* pActor, int param_2) { + return dComIfGp_getPEvtManager()->getMyStaffId(pName, pActor, param_2); +} + +inline int dComIfGp_evmng_getIsAddvance(int param_0) { + return dComIfGp_getPEvtManager()->getIsAddvance(param_0); +} + inline int* dComIfGp_evmng_getMyIntegerP(int index, char* name) { return (int*)dComIfGp_getPEvtManager()->getMySubstanceP(index, name, dEvDtData_c::TYPE_INT); } @@ -2071,6 +2084,14 @@ inline f32* dComIfGp_evmng_getMyFloatP(int index, char* name) { return (f32*)dComIfGp_getPEvtManager()->getMySubstanceP(index, name, dEvDtData_c::TYPE_FLOAT); } +inline cXyz* dComIfGp_evmng_getMyXyzP(int index, char* name) { + return (cXyz*)dComIfGp_getPEvtManager()->getMySubstanceP(index, name, dEvDtData_c::TYPE_VEC); +} + +inline int dComIfGp_evmng_getMySubstanceNum(int index, char* name) { + return dComIfGp_getPEvtManager()->getMySubstanceNum(index, name); +} + inline void dComIfGp_evmng_create() { g_dComIfG_gameInfo.play.getEvtManager().create(); } @@ -2253,4 +2274,12 @@ inline daAlink_c* daAlink_getAlinkActorClass() { return (daAlink_c*)g_dComIfG_gameInfo.play.getPlayerPtr(LINK_PTR); } +inline char* dComIfGp_getLastPlayStageName() { + return g_dComIfG_gameInfo.play.getLastPlayStageName(); +} + +inline u8 dComIfGp_getGameoverStatus() { + return g_dComIfG_gameInfo.play.getGameoverStatus(); +} + #endif /* D_COM_D_COM_INF_GAME_H */ diff --git a/include/d/d_demo.h b/include/d/d_demo.h index 003c01ad631..0ff56ba4fee 100644 --- a/include/d/d_demo.h +++ b/include/d/d_demo.h @@ -3,4 +3,39 @@ #include "dolphin/types.h" +class cXyz; +struct dDemo_c { + /* 80039678 */ void create(); + /* 80039910 */ void remove(); + /* 80039B6C */ void start(u8 const*, cXyz*, f32); + /* 80039CF8 */ void end(); + /* 80039D4C */ void branch(); + /* 80039DA4 */ void update(); + /* 80039EDC */ void setBranchType(u16); + /* 80039EEC */ void setBranchId(u16, s16); + /* 80039F04 */ void reset(); + + static u32 getFrameNoMsg() { return m_frameNoMsg; } + + static u16 m_branchId[1 + 3 /* padding */]; + static u8 m_system[4]; + static u8 m_control[4]; + static u8 m_stage[4]; + static u8 m_audio[4]; + static u8 m_particle[4]; + static u8 m_message[4]; + static u8 m_factory[4]; + static u8 m_mesgControl[4]; + static u8 m_object[4]; + static u8 m_data[4]; + static u8 m_frame[4]; + static u8 m_translation[4]; + static f32 m_rotationY; + static u32 m_frameNoMsg; + static u8 m_mode[4]; + static u8 m_status[4]; + static u8 m_branchType[2 + 2 /* padding */]; + static u8 m_branchData[4]; +}; + #endif /* D_D_DEMO_H */ diff --git a/include/d/d_gameover.h b/include/d/d_gameover.h index a4e496374c5..318cf8756bc 100644 --- a/include/d/d_gameover.h +++ b/include/d/d_gameover.h @@ -1,6 +1,52 @@ #ifndef D_D_GAMEOVER_H #define D_D_GAMEOVER_H +#include "d/msg/d_msg_class.h" #include "dolphin/types.h" +#include "f_op/f_op_msg_mng.h" + +struct dGameover_c : msg_class { + /* 8019B044 */ void _create(); + /* 8019B2F4 */ void _execute(); + /* 8019B384 */ void playerAnmWait_init(); + /* 8019B388 */ void playerAnmWait_proc(); + /* 8019B3A0 */ void dispFadeOut_init(); + /* 8019B3E8 */ void dispFadeOut_proc(); + /* 8019B40C */ void dispWait_init(); + /* 8019B454 */ void dispWait_proc(); + /* 8019B478 */ void demoFadeIn_init(); + /* 8019B484 */ void demoFadeIn_proc(); + /* 8019B4D8 */ void demoFadeOut_init(); + /* 8019B4E4 */ void demoFadeOut_proc(); + /* 8019B560 */ void saveOpen_init(); + /* 8019B564 */ void saveOpen_proc(); + /* 8019B5A4 */ void saveMove_init(); + /* 8019B5A8 */ void saveMove_proc(); + /* 8019B5F0 */ void saveClose_init(); + /* 8019B5F4 */ void saveClose_proc(); + /* 8019B7BC */ void deleteWait_init(); + /* 8019B7C0 */ void deleteWait_proc(); + /* 8019B7C4 */ void _draw(); + /* 8019B864 */ void _delete(); + s32 deleteCheck() { return _0x108 == 8; } + + /* 0x100 */ u8 _0x100[0x118 - 0x100]; + /* 0x108 */ u8 _0x108; +}; // size unknown + +s32 d_GameOver_Create(u8 param_0); +void d_GameOver_Delete(unsigned int& param_0); +inline s32 d_GameOver_CheckDelete(unsigned int& id) { + if (id != UINT32_MAX) { + dGameover_c* gameover = (dGameover_c*)fopMsgM_SearchByID(id); + if (gameover != NULL) { + return gameover->deleteCheck(); + } else { + return 0; + } + } else { + return 0; + } +} #endif /* D_D_GAMEOVER_H */ diff --git a/include/d/d_stage.h b/include/d/d_stage.h index 032fac58c65..597a4e81121 100644 --- a/include/d/d_stage.h +++ b/include/d/d_stage.h @@ -890,7 +890,7 @@ inline u32 dStage_stagInfo_GetArg0(stage_stag_info_class* p_info) { return (p_info->field_0x0c >> 0x14) & 0xFF; } -inline s8 dStage_sclsInfo_getSceneLayer(stage_scls_info_class* p_info) { +inline int dStage_sclsInfo_getSceneLayer(stage_scls_info_class* p_info) { return p_info->field_0xb & 0xF; } @@ -898,12 +898,12 @@ inline s8 dStage_sclsInfo_getWipe(stage_scls_info_class* p_info) { return p_info->mWipe; } -inline s8 dStage_sclsInfo_getWipeTime(stage_scls_info_class* p_info) { - return p_info->field_0xb >> 5; +inline u32 dStage_sclsInfo_getWipeTime(stage_scls_info_class* p_info) { + return (p_info->field_0xb & 0xF0) >> 5; } inline int dStage_sclsInfo_getTimeH(stage_scls_info_class* p_info) { - return ((p_info->field_0xb & 0xF0) >> 4) | ((p_info->field_0xa & 0x0F) << 4); + return ((p_info->field_0xa & 0xF0) >> 4) | (p_info->field_0xb & 0x10); } inline u32 dStage_FileList_dt_getMiniMap(dStage_FileList_dt_c* p_fList) { diff --git a/include/d/event/d_event_data.h b/include/d/event/d_event_data.h index 1d2e77e3571..feed849256b 100644 --- a/include/d/event/d_event_data.h +++ b/include/d/event/d_event_data.h @@ -2,6 +2,7 @@ #define D_EVENT_D_EVENT_DATA_H #include "d/d_stage.h" +#include "d/msg/d_msg_class.h" #include "d/save/d_save.h" #include "dolphin/types.h" @@ -81,6 +82,14 @@ public: /* 0xC */ TYPE_CREATE, }; + struct StaffWork { + unsigned int _0; + msg_class* mLMsg; + unsigned int mMsgNo; + s32 mMsgSubstanceNum; + int* mMsgSubstanceP; + }; + void specialProc_WaitStart(int); void specialProc_WaitProc(int); void specialProc(); @@ -101,7 +110,9 @@ public: int getStartCut() { return mStartCut; } // private: - /* 0x00 */ char mName[32]; + /* 0x00 */ char mName[8]; + /* 0x08 */ StaffWork mWork; + /* 0x0C */ u8 field_0x1C[0x20 - 0x1C]; /* 0x20 */ s32 mTagID; /* 0x24 */ u32 mIndex; /* 0x28 */ u32 mFlagID; @@ -121,7 +132,7 @@ public: class dEvDtEvent_c { public: int finishCheck(); - void forceFinish(); + int forceFinish(); void specialStaffProc(dEvDtStaff_c*); int getNStaff() { return mNStaff; } int getStaff(int idx) { return mStaff[idx]; } @@ -136,8 +147,7 @@ public: /* 0x7C */ int mNStaff; /* 0x80 */ u8 field_0x80[4]; /* 0x84 */ int field_0x84; - /* 0x88 */ int field_0x88[2]; - /* 0x90 */ int field_0x90; + /* 0x88 */ int field_0x88[3]; /* 0x94 */ bool mPlaySound; /* 0x95 */ u8 field_0x95[0xF]; /* 0xA4 */ int mEventState; @@ -147,9 +157,9 @@ public: class dEvDtFlag_c { public: dEvDtFlag_c() {} - void flagCheck(int); - void flagSet(int); - bool flagMaxCheck(int); + BOOL flagCheck(int); + BOOL flagSet(int); + BOOL flagMaxCheck(int); void init(); #define FlagMax 0x2800 diff --git a/include/d/event/d_event_manager.h b/include/d/event/d_event_manager.h index 344f1f59ad6..fc4dffb85b5 100644 --- a/include/d/event/d_event_manager.h +++ b/include/d/event/d_event_manager.h @@ -72,6 +72,7 @@ public: dEvDtBase_c& getBase() { return mEventList[mCurrentEventType]; } void setFlag(int flag) { mFlags.flagSet(flag); } + int flagCheck(int flag) { return mFlags.flagCheck(flag); } static int getIndexCompositId(s16 param_0) { return param_0 != -1 ? (u8)param_0 : -1; } static int getTypeCompositId(s16 param_0) { return param_0 == -1 ? 0 : param_0 >> 8; } diff --git a/include/d/kankyo/d_kankyo.h b/include/d/kankyo/d_kankyo.h index 11b0607e4c8..ccdd271eaae 100644 --- a/include/d/kankyo/d_kankyo.h +++ b/include/d/kankyo/d_kankyo.h @@ -24,6 +24,8 @@ s32 dKy_daynight_check(); void dKy_clear_game_init(); void dKy_setLight_init(); u8 dKy_pol_sound_get(cBgS_PolyInfo const* param_0); +void dKy_instant_rainchg(); +void dKy_instant_timechg(f32); struct LIGHT_INFLUENCE { /* 800CFC7C */ ~LIGHT_INFLUENCE(); diff --git a/include/dolphin/mtx/vec.h b/include/dolphin/mtx/vec.h index 2b8091fb5a5..d52c79d4501 100644 --- a/include/dolphin/mtx/vec.h +++ b/include/dolphin/mtx/vec.h @@ -35,6 +35,12 @@ struct SVec { y = oY; z = oZ; } + + void setall(s16 val) { + x = val; + y = val; + z = val; + } }; extern "C" { diff --git a/include/f_op/f_op_msg_mng.h b/include/f_op/f_op_msg_mng.h index 85c00e2f5be..05abfdc3f06 100644 --- a/include/f_op/f_op_msg_mng.h +++ b/include/f_op/f_op_msg_mng.h @@ -36,8 +36,9 @@ u32 fopMsgM_Create(s16, fopMsgCreateFunc, void*); void fopMsgM_setMessageID(unsigned int); void fopMsgM_destroyExpHeap(JKRExpHeap*); s32 fopMsgM_setStageLayer(void*); -void fopMsgM_messageSetDemo(u32 param_0); +int fopMsgM_messageSet(u32 param_0, u32 param_1); +int fopMsgM_messageSetDemo(u32 param_0); msg_class* fopMsgM_SearchByID(unsigned int param_0); char* fopMsgM_messageGet(char* msg, u32 string_id); -#endif \ No newline at end of file +#endif diff --git a/libs/SSystem/SComponent/c_m3d_g_aab.cpp b/libs/SSystem/SComponent/c_m3d_g_aab.cpp index ed535664d67..beeafc6817b 100644 --- a/libs/SSystem/SComponent/c_m3d_g_aab.cpp +++ b/libs/SSystem/SComponent/c_m3d_g_aab.cpp @@ -39,8 +39,12 @@ bool cM3dGAab::TopPlaneYUnder(f32 pY) const { /* 8026ECF8-8026ED1C 0024+00 s=0 e=6 z=0 None .text ClearForMinMax__8cM3dGAabFv */ void cM3dGAab::ClearForMinMax(void) { - mMin.setAll(1000000000.0f); - mMax.setAll(-1000000000.0f); + mMin.z = 1000000000.0f; + mMin.y = 1000000000.0f; + mMin.x = 1000000000.0f; + mMax.z = -1000000000.0f; + mMax.y = -1000000000.0f; + mMax.x = -1000000000.0f; } /* 8026ED1C-8026ED60 0044+00 s=1 e=3 z=0 None .text SetMinMax__8cM3dGAabFRC4cXyz */ diff --git a/src/d/d_demo.cpp b/src/d/d_demo.cpp index 4d8d7c3ad42..bc2072fe75b 100644 --- a/src/d/d_demo.cpp +++ b/src/d/d_demo.cpp @@ -221,38 +221,6 @@ struct dDemo_camera_c { /* 80039FFC */ ~dDemo_camera_c(); }; -struct dDemo_c { - /* 80039678 */ void create(); - /* 80039910 */ void remove(); - /* 80039B6C */ void start(u8 const*, cXyz*, f32); - /* 80039CF8 */ void end(); - /* 80039D4C */ void branch(); - /* 80039DA4 */ void update(); - /* 80039EDC */ void setBranchType(u16); - /* 80039EEC */ void setBranchId(u16, s16); - /* 80039F04 */ void reset(); - - static u16 m_branchId[1 + 3 /* padding */]; - static u8 m_system[4]; - static u8 m_control[4]; - static u8 m_stage[4]; - static u8 m_audio[4]; - static u8 m_particle[4]; - static u8 m_message[4]; - static u8 m_factory[4]; - static u8 m_mesgControl[4]; - static u8 m_object[4]; - static u8 m_data[4]; - static u8 m_frame[4]; - static u8 m_translation[4]; - static f32 m_rotationY; - static u8 m_frameNoMsg[4]; - static u8 m_mode[4]; - static u8 m_status[4]; - static u8 m_branchType[2 + 2 /* padding */]; - static u8 m_branchData[4]; -}; - struct dDemo_ambient_c { /* 80038DF0 */ void JSGSetColor(_GXColor); /* 800394C8 */ ~dDemo_ambient_c(); @@ -1013,7 +981,7 @@ u8 dDemo_c::m_translation[4]; f32 dDemo_c::m_rotationY; /* 80450E34-80450E38 000334 0004+00 2/2 1/1 0/0 .sbss m_frameNoMsg__7dDemo_c */ -u8 dDemo_c::m_frameNoMsg[4]; +u32 dDemo_c::m_frameNoMsg; /* 80450E38-80450E3C 000338 0004+00 4/4 4/4 0/0 .sbss m_mode__7dDemo_c */ u8 dDemo_c::m_mode[4]; diff --git a/src/d/d_gameover.cpp b/src/d/d_gameover.cpp index 33f61dc2dc2..e3f7aba547a 100644 --- a/src/d/d_gameover.cpp +++ b/src/d/d_gameover.cpp @@ -13,8 +13,6 @@ struct request_of_phase_process_class {}; -struct msg_class {}; - struct mDoRst { static u8 mResetData[4 + 4 /* padding */]; }; @@ -28,8 +26,6 @@ struct mDoGph_gInf_c { static f32 mFadeRate; }; -struct fopAc_ac_c {}; - struct dSv_player_item_c { /* 80032FB8 */ void setItem(int, u8); /* 80033030 */ void getItem(int, bool) const; @@ -86,31 +82,6 @@ struct dGov_HIO_c { /* 8019C06C */ ~dGov_HIO_c(); }; -struct dGameover_c { - /* 8019B044 */ void _create(); - /* 8019B2F4 */ void _execute(); - /* 8019B384 */ void playerAnmWait_init(); - /* 8019B388 */ void playerAnmWait_proc(); - /* 8019B3A0 */ void dispFadeOut_init(); - /* 8019B3E8 */ void dispFadeOut_proc(); - /* 8019B40C */ void dispWait_init(); - /* 8019B454 */ void dispWait_proc(); - /* 8019B478 */ void demoFadeIn_init(); - /* 8019B484 */ void demoFadeIn_proc(); - /* 8019B4D8 */ void demoFadeOut_init(); - /* 8019B4E4 */ void demoFadeOut_proc(); - /* 8019B560 */ void saveOpen_init(); - /* 8019B564 */ void saveOpen_proc(); - /* 8019B5A4 */ void saveMove_init(); - /* 8019B5A8 */ void saveMove_proc(); - /* 8019B5F0 */ void saveClose_init(); - /* 8019B5F4 */ void saveClose_proc(); - /* 8019B7BC */ void deleteWait_init(); - /* 8019B7C0 */ void deleteWait_proc(); - /* 8019B7C4 */ void _draw(); - /* 8019B864 */ void _delete(); -}; - struct dDlst_base_c {}; struct dDlst_list_c { @@ -122,8 +93,6 @@ struct dDlst_Gameover_CAPTURE_c { /* 8019C2CC */ ~dDlst_Gameover_CAPTURE_c(); }; -struct JKRArchive {}; - struct dDlst_GameOverScrnDraw_c { /* 8019B940 */ dDlst_GameOverScrnDraw_c(JKRArchive*); /* 8019BBFC */ ~dDlst_GameOverScrnDraw_c(); @@ -131,24 +100,6 @@ struct dDlst_GameOverScrnDraw_c { /* 8019BCF4 */ void draw(); }; -struct cXyz {}; - -struct ResTLUT {}; - -struct ResTIMG {}; - -struct JKRHeap { - /* 802CE5CC */ void freeAll(); - /* 802CE784 */ void getTotalFreeSize(); -}; - -struct JGeometry { - template - struct TBox2 {}; - /* TBox2 */ - struct TBox2__template0 {}; -}; - struct JFWDisplay { static u8 sManager[4]; }; @@ -254,38 +205,6 @@ extern "C" void setPriority__9J2DScreenFPCcUlP10JKRArchive(); extern "C" void draw__9J2DScreenFffPC14J2DGrafContext(); extern "C" void func_802FC800(); extern "C" void setString__10J2DTextBoxFPCce(); -extern "C" void C_MTXOrtho(); -extern "C" void GXSetVtxDesc(); -extern "C" void GXClearVtxDesc(); -extern "C" void GXSetVtxAttrFmt(); -extern "C" void GXSetTexCoordGen2(); -extern "C" void GXSetNumTexGens(); -extern "C" void GXPixModeSync(); -extern "C" void GXBegin(); -extern "C" void GXSetCullMode(); -extern "C" void GXSetTexCopySrc(); -extern "C" void GXSetTexCopyDst(); -extern "C" void GXCopyTex(); -extern "C" void GXSetNumChans(); -extern "C" void GXInitTexObj(); -extern "C" void GXInitTexObjLOD(); -extern "C" void GXLoadTexObj(); -extern "C" void GXSetTevColorIn(); -extern "C" void GXSetTevAlphaIn(); -extern "C" void GXSetTevColorOp(); -extern "C" void GXSetTevAlphaOp(); -extern "C" void GXSetAlphaCompare(); -extern "C" void GXSetTevOrder(); -extern "C" void GXSetNumTevStages(); -extern "C" void GXSetFog(); -extern "C" void GXSetFogRangeAdj(); -extern "C" void GXSetBlendMode(); -extern "C" void GXSetZMode(); -extern "C" void GXSetZCompLoc(); -extern "C" void GXSetDither(); -extern "C" void GXSetProjection(); -extern "C" void GXLoadPosMtxImm(); -extern "C" void GXSetCurrentMtx(); extern "C" void __register_global_object(); extern "C" void __ptmf_scall(); extern "C" void _savegpr_24(); @@ -297,7 +216,6 @@ extern "C" void _restgpr_29(); extern "C" void strcmp(); extern "C" extern u8 g_mDoMtx_identity[48 + 24 /* padding */]; extern "C" extern void* g_fopMsg_Method[5 + 1 /* padding */]; -extern "C" extern void* g_fpcLf_Method[5 + 1 /* padding */]; extern "C" extern void* __vt__12dDlst_base_c[3]; extern "C" u8 saveBitLabels__16dSv_event_flag_c[1644 + 4 /* padding */]; extern "C" extern void* __vt__14mDoHIO_entry_c[3]; @@ -981,7 +899,7 @@ static asm void dGameover_Create(msg_class* param_0) { #pragma push #pragma optimization_level 0 #pragma optimizewithasm off -asm void d_GameOver_Create(u8 param_0) { +asm s32 d_GameOver_Create(u8 param_0) { nofralloc #include "asm/d/d_gameover/d_GameOver_Create__FUc.s" } diff --git a/src/d/d_name.cpp b/src/d/d_name.cpp index fa74ecb42d3..7ed8aed09a2 100644 --- a/src/d/d_name.cpp +++ b/src/d/d_name.cpp @@ -1428,6 +1428,7 @@ s32 dName_c::getMenuPosIdx(u8 selPos) { case 3: return 3; } + //!@bug UB: no default return } /* 80251094-8025115C 24B9D4 00C8+00 1/0 0/0 0/0 .text draw__14dDlst_NameIN_cFv */ diff --git a/src/d/event/d_event_data.cpp b/src/d/event/d_event_data.cpp index 9f3c49323ca..b28ca2bd6b3 100644 --- a/src/d/event/d_event_data.cpp +++ b/src/d/event/d_event_data.cpp @@ -5,22 +5,16 @@ #include "d/event/d_event_data.h" #include "d/com/d_com_inf_game.h" +#include "d/d_demo.h" +#include "d/d_gameover.h" #include "dol2asm.h" #include "dolphin/types.h" +#include "f_op/f_op_msg_mng.h" // // Types: // -struct dDemo_c { - /* 80039B6C */ void start(u8 const*, cXyz*, f32); - /* 80039CF8 */ void end(); - - static u8 m_control[4]; - static u8 m_frameNoMsg[4]; - static u8 m_mode[4]; -}; - struct dCamera_c { /* 80181170 */ void StartBlure(int, fopAc_ac_c*, f32, f32); }; @@ -136,92 +130,109 @@ extern "C" u8 m_mode__7dDemo_c[4]; extern "C" f32 mWipeRate__12dDlst_list_c; extern "C" u8 mAudioMgrPtr__10Z2AudioMgr[4 + 4 /* padding */]; +inline dEvent_manager_c& dComIfGp_getEventManager() { + return g_dComIfG_gameInfo.play.getEvtManager(); +} + // // Declarations: // +inline BOOL dComIfGs_isEventBit(u16 id) { + return g_dComIfG_gameInfo.info.getEvent().isEventBit(id); +} + +struct TelopDataStruct { + s32 mName; + u16 mTelopNo; + u16 _6; + u16 _8; + // padding +}; + /* ############################################################################################## */ /* 803A7FB0-803A8238 0050D0 0288+00 2/2 0/0 0/0 .data TelopData */ -SECTION_DATA static u8 TelopData[648] = { - 0x44, 0x30, 0x35, 0x00, 0x04, 0x4D, 0x10, 0x69, 0x00, 0x03, 0x00, 0x00, 0x44, 0x30, 0x35, 0x41, - 0x04, 0x4D, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x44, 0x30, 0x35, 0x42, 0x04, 0x4D, 0xFF, 0xFF, - 0x00, 0x00, 0x00, 0x00, 0x44, 0x30, 0x34, 0x00, 0x04, 0x4E, 0xFF, 0xFF, 0x00, 0x01, 0x00, 0x00, - 0x44, 0x30, 0x34, 0x41, 0x04, 0x4E, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x44, 0x30, 0x34, 0x42, - 0x04, 0x4E, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x44, 0x30, 0x31, 0x00, 0x04, 0x4F, 0x12, 0x78, - 0x00, 0x03, 0x00, 0x00, 0x44, 0x30, 0x31, 0x41, 0x04, 0x4F, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, - 0x44, 0x30, 0x31, 0x42, 0x04, 0x4F, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x44, 0x31, 0x30, 0x00, - 0x04, 0x50, 0x13, 0x2C, 0x00, 0x03, 0x00, 0x00, 0x44, 0x31, 0x30, 0x41, 0x04, 0x50, 0xFF, 0xFF, - 0x00, 0x00, 0x00, 0x00, 0x44, 0x31, 0x30, 0x42, 0x04, 0x50, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, - 0x44, 0x31, 0x31, 0x00, 0x04, 0x51, 0x14, 0x78, 0x00, 0x03, 0x00, 0x00, 0x44, 0x31, 0x31, 0x41, - 0x04, 0x51, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x44, 0x31, 0x31, 0x42, 0x04, 0x51, 0xFF, 0xFF, - 0x00, 0x00, 0x00, 0x00, 0x44, 0x30, 0x36, 0x00, 0x04, 0x52, 0x15, 0x59, 0x00, 0x03, 0x00, 0x00, - 0x44, 0x30, 0x36, 0x41, 0x04, 0x52, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x44, 0x30, 0x36, 0x42, - 0x04, 0x52, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x44, 0x30, 0x37, 0x00, 0x04, 0x53, 0x16, 0x39, - 0x00, 0x03, 0x00, 0x00, 0x44, 0x30, 0x37, 0x41, 0x04, 0x53, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, - 0x44, 0x30, 0x37, 0x42, 0x04, 0x53, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x44, 0x30, 0x38, 0x00, - 0x04, 0x54, 0xFF, 0xFF, 0x00, 0x01, 0x00, 0x00, 0x44, 0x30, 0x38, 0x41, 0x04, 0x54, 0xFF, 0xFF, - 0x00, 0x00, 0x00, 0x00, 0x44, 0x30, 0x38, 0x42, 0x04, 0x54, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, - 0x44, 0x30, 0x38, 0x43, 0x04, 0x54, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x44, 0x30, 0x38, 0x44, - 0x04, 0x54, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x44, 0x30, 0x39, 0x00, 0x04, 0x55, 0xFF, 0xFF, - 0x00, 0x01, 0x00, 0x00, 0x44, 0x30, 0x39, 0x41, 0x04, 0x55, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, - 0x44, 0x30, 0x39, 0x42, 0x04, 0x55, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x44, 0x30, 0x39, 0x43, - 0x04, 0x55, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x46, 0x30, 0x30, 0x00, 0x04, 0x56, 0xFF, 0xFF, - 0x00, 0x01, 0x00, 0x00, 0x46, 0x31, 0x30, 0x33, 0x04, 0x57, 0x00, 0x0A, 0x00, 0x03, 0x00, 0x00, - 0x52, 0x30, 0x31, 0x00, 0x04, 0x57, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x46, 0x31, 0x30, 0x39, - 0x04, 0x58, 0xFF, 0xFF, 0x00, 0x01, 0x00, 0x00, 0x52, 0x31, 0x30, 0x39, 0x04, 0x58, 0xFF, 0xFF, - 0x00, 0x00, 0x00, 0x00, 0x52, 0x32, 0x30, 0x39, 0x04, 0x58, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, - 0x46, 0x31, 0x31, 0x32, 0x04, 0x59, 0x04, 0x09, 0x00, 0x03, 0x00, 0x00, 0x46, 0x31, 0x31, 0x33, - 0x04, 0x5A, 0x04, 0x00, 0x00, 0x03, 0x00, 0x00, 0x46, 0x31, 0x30, 0x38, 0x04, 0x5B, 0xFF, 0xFF, - 0x00, 0x01, 0x00, 0x00, 0x52, 0x31, 0x30, 0x38, 0x04, 0x5B, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, - 0x46, 0x31, 0x31, 0x35, 0x04, 0x5C, 0x04, 0x1E, 0x00, 0x03, 0x00, 0x00, 0x46, 0x31, 0x31, 0x31, - 0x04, 0x5E, 0xFF, 0xFF, 0x00, 0x01, 0x00, 0x00, 0x46, 0x31, 0x32, 0x34, 0x04, 0x5F, 0xFF, 0xFF, - 0x00, 0x01, 0x00, 0x00, 0x46, 0x31, 0x31, 0x34, 0x04, 0x60, 0x08, 0x00, 0x00, 0x03, 0x00, 0x00, - 0x46, 0x31, 0x32, 0x35, 0x04, 0x61, 0x0A, 0x0C, 0x00, 0x03, 0x00, 0x00, 0x46, 0x31, 0x32, 0x31, - 0x04, 0x62, 0x06, 0x2D, 0x00, 0x03, 0x00, 0x00, 0x46, 0x31, 0x32, 0x32, 0x04, 0x62, 0x06, 0x2D, - 0x00, 0x03, 0x00, 0x00, 0x46, 0x31, 0x32, 0x33, 0x04, 0x62, 0x06, 0x2D, 0x00, 0x03, 0x00, 0x00, - 0x46, 0x31, 0x31, 0x37, 0x04, 0x63, 0xFF, 0xFF, 0x00, 0x01, 0x00, 0x00, 0x46, 0x31, 0x32, 0x38, - 0x04, 0x6E, 0x03, 0x2E, 0x00, 0x03, 0x00, 0x00, 0x52, 0x31, 0x32, 0x38, 0x04, 0x6E, 0xFF, 0xFF, - 0x00, 0x00, 0x00, 0x00, 0x46, 0x31, 0x32, 0x37, 0x04, 0x74, 0xFF, 0xFF, 0x00, 0x01, 0x00, 0x00, - 0x52, 0x31, 0x32, 0x37, 0x04, 0x74, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x46, 0x31, 0x32, 0x36, - 0x04, 0x75, 0xFF, 0xFF, 0x00, 0x01, 0x00, 0x00, -}; +static TelopDataStruct TelopData[] = { + {'D05\0', 1101, 4201, 3}, {'D05A', 1101, -1, 0}, {'D05B', 1101, -1, 0}, + {'D04\0', 1102, -1, 1}, {'D04A', 1102, -1, 0}, {'D04B', 1102, -1, 0}, + {'D01\0', 1103, 4728, 3}, {'D01A', 1103, -1, 0}, {'D01B', 1103, -1, 0}, + {'D10\0', 1104, 4908, 3}, {'D10A', 1104, -1, 0}, {'D10B', 1104, -1, 0}, + {'D11\0', 1105, 5240, 3}, {'D11A', 1105, -1, 0}, {'D11B', 1105, -1, 0}, + {'D06\0', 1106, 5465, 3}, {'D06A', 1106, -1, 0}, {'D06B', 1106, -1, 0}, + {'D07\0', 1107, 5689, 3}, {'D07A', 1107, -1, 0}, {'D07B', 1107, -1, 0}, + {'D08\0', 1108, -1, 1}, {'D08A', 1108, -1, 0}, {'D08B', 1108, -1, 0}, + {'D08C', 1108, -1, 0}, {'D08D', 1108, -1, 0}, {'D09\0', 1109, -1, 1}, + {'D09A', 1109, -1, 0}, {'D09B', 1109, -1, 0}, {'D09C', 1109, -1, 0}, + {'F00\0', 1110, -1, 1}, {'F103', 1111, 10, 3}, {'R01\0', 1111, -1, 0}, + {'F109', 1112, -1, 1}, {'R109', 1112, -1, 0}, {'R209', 1112, -1, 0}, + {'F112', 1113, 1033, 3}, {'F113', 1114, 1024, 3}, {'F108', 1115, -1, 1}, + {'R108', 1115, -1, 0}, {'F115', 1116, 1054, 3}, {'F111', 1118, -1, 1}, + {'F124', 1119, -1, 1}, {'F114', 1120, 2048, 3}, {'F125', 1121, 2572, 3}, + {'F121', 1122, 1581, 3}, {'F122', 1122, 1581, 3}, {'F123', 1122, 1581, 3}, + {'F117', 1123, -1, 1}, {'F128', 1134, 814, 3}, {'R128', 1134, -1, 0}, + {'F127', 1140, -1, 1}, {'R127', 1140, -1, 0}, {'F126', 1141, -1, 1}}; /* 80450640-80450648 0000C0 0004+04 2/2 0/0 0/0 .sdata numTelopData */ -SECTION_SDATA static u32 numTelopData[1 + 1 /* padding */] = { - 0x00000036, - /* padding */ - 0x00000000, -}; +static s32 numTelopData = ARRAY_SIZE(TelopData); /* 8004372C-800437C4 03E06C 0098+00 2/2 0/0 0/0 .text getTelopNo__FPCc */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -static asm void getTelopNo(char const* param_0) { - nofralloc -#include "asm/d/event/d_event_data/getTelopNo__FPCc.s" +static u16 getTelopNo(char const* pName) { + s32 val = + ((pName[3] == 'B' ? 'd' : pName[0]) << 0x18 | pName[4] << 0x10 | pName[5] << 8 | pName[6]); + for (s32 i = 0; i < numTelopData; i++) { + if (val == TelopData[i].mName) { + return TelopData[i].mTelopNo; + } + } + return 0xFFFF; } -#pragma pop /* 800437C4-800437F0 03E104 002C+00 1/1 0/0 0/0 .text getTelopNo__Fv */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -static asm void getTelopNo() { - nofralloc -#include "asm/d/event/d_event_data/getTelopNo__Fv.s" +static u16 getTelopNo() { + return getTelopNo(dComIfGp_getStartStageName()); } -#pragma pop /* 800437F0-80043A14 03E130 0224+00 1/1 0/0 0/0 .text getStartTelopNo__Fv */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -static asm void getStartTelopNo() { - nofralloc -#include "asm/d/event/d_event_data/getStartTelopNo__Fv.s" +static u16 getStartTelopNo() { + const char* startStageName = dComIfGp_getStartStageName(); + const char* lastPlayStateName = dComIfGp_getLastPlayStageName(); + if (strcmp(startStageName, lastPlayStateName) == 0) { + return 0xFFFF; + } + TelopDataStruct* telopData = NULL; + s32 val = ((startStageName[3] == 'B' ? 'd' : startStageName[0]) << 0x18 | + startStageName[4] << 0x10 | startStageName[5] << 8 | startStageName[6]); + for (s32 i = 0; i < numTelopData; i++) { + if (val == TelopData[i].mName) { + telopData = &TelopData[i]; + break; + } + } + if (telopData == NULL || telopData->_8 == 0) { + return 0xFFFF; + } else if (telopData->_8 == 2 && telopData->_6 != 0xFFFF && + !dComIfGs_isEventBit(telopData->_6)) { + return 0xFFFF; + } else if (telopData->_8 == 3 && telopData->_6 != 0xFFFF && + !dComIfGs_isStageSwitch(telopData->_6 >> 8, telopData->_6 & 0xFF)) { + return 0xFFFF; + } else { + TelopDataStruct* lastTelopData = NULL; + val = ((lastPlayStateName[3] == 'B' ? 'd' : lastPlayStateName[0]) << 0x18 | + lastPlayStateName[4] << 0x10 | lastPlayStateName[5] << 8 | lastPlayStateName[6]); + for (s32 i = 0; i < numTelopData; i++) { + if (val == TelopData[i].mName) { + lastTelopData = &TelopData[i]; + break; + } + } + if (lastTelopData != NULL && telopData->mTelopNo == lastTelopData->mTelopNo) { + return 0xFFFF; + } else { + return telopData->mTelopNo; + } + } } -#pragma pop /* ############################################################################################## */ /* 80379DD0-80379DD0 006430 0000+00 0/0 0/0 0/0 .rodata @stringBase0 */ @@ -255,6 +266,7 @@ SECTION_SDATA2 static f64 lit_4267 = 4503601774854144.0 /* cast s32 to float */; /* 80043A14-80043D60 03E354 034C+00 1/1 0/0 0/0 .text dEvDt_Next_Stage__Fii */ // bunch of issues with sclsInfo section. regalloc for the rest +// TODO: try struct on stack #ifdef NONMATCHING static int dEvDt_Next_Stage(int index, int wipe_type) { char* stage; @@ -281,18 +293,19 @@ static int dEvDt_Next_Stage(int index, int wipe_type) { } if (info != NULL && id >= 0 && id < info->numEntries) { - stage = info->mEntries[id].mStage; - point = info->mEntries[id].mStart; - roomNo = info->mEntries[id].mRoom; - layer = dStage_sclsInfo_getSceneLayer(&info->mEntries[id]); - wipe = dStage_sclsInfo_getWipe(&info->mEntries[id]); - wipe_time = dStage_sclsInfo_getWipeTime(&info->mEntries[id]); + stage_scls_info_class* stgInfo = &info->mEntries[id]; + stage = stgInfo->mStage; + point = stgInfo->mStart; + roomNo = stgInfo->mRoom; + layer = dStage_sclsInfo_getSceneLayer(stgInfo); + wipe = dStage_sclsInfo_getWipe(stgInfo); + wipe_time = dStage_sclsInfo_getWipeTime(stgInfo); if (wipe == 15) { wipe = 0; } - s8 timeH = dStage_sclsInfo_getTimeH(&info->mEntries[id]); + int timeH = dStage_sclsInfo_getTimeH(stgInfo); if (timeH >= 0 && timeH <= 23) { setHour = true; hour = timeH; @@ -367,31 +380,38 @@ static asm int dEvDt_Next_Stage(int param_0, int param_1) { #endif /* 80043D60-80043DC8 03E6A0 0068+00 3/3 0/0 0/0 .text flagCheck__11dEvDtFlag_cFi */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm void dEvDtFlag_c::flagCheck(int param_0) { - nofralloc -#include "asm/d/event/d_event_data/flagCheck__11dEvDtFlag_cFi.s" +BOOL dEvDtFlag_c::flagCheck(int param_0) { + if (flagMaxCheck(param_0)) { + return FALSE; + } else { + if (mFlags[(u32)param_0 / 0x20] & (1 << (param_0 & 0x1F))) { + return TRUE; + } else { + return FALSE; + } + } } -#pragma pop /* 80043DC8-80043E30 03E708 0068+00 2/2 1/1 0/0 .text flagSet__11dEvDtFlag_cFi */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm void dEvDtFlag_c::flagSet(int param_0) { - nofralloc -#include "asm/d/event/d_event_data/flagSet__11dEvDtFlag_cFi.s" +BOOL dEvDtFlag_c::flagSet(int param_0) { + if (flagMaxCheck(param_0)) { + return FALSE; + } else { + mFlags[(u32)param_0 / 0x20] |= (1 << (param_0 & 0x1F)); + return TRUE; + } } -#pragma pop -bool dEvDtFlag_c::flagMaxCheck(int flag_id) { +BOOL dEvDtFlag_c::flagMaxCheck(int flag_id) { if (flag_id == -1) { - return true; + return TRUE; } - return FlagMax <= flag_id; + if (FlagMax <= flag_id) { + return TRUE; + } else { + return FALSE; + } } void dEvDtFlag_c::init() { @@ -401,35 +421,38 @@ void dEvDtFlag_c::init() { } /* 80043E78-80043EFC 03E7B8 0084+00 0/0 1/1 0/0 .text finishCheck__12dEvDtEvent_cFv */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm int dEvDtEvent_c::finishCheck() { - nofralloc -#include "asm/d/event/d_event_data/finishCheck__12dEvDtEvent_cFv.s" +int dEvDtEvent_c::finishCheck() { + for (int i = 0; i < 3; i++) { + int tmp = field_0x88[i]; + if (tmp == -1) { + return 1; + } + if (!dComIfGp_getEventManager().flagCheck(tmp)) { + return 0; + } + } + return 1; } -#pragma pop /* 80043EFC-80043F70 03E83C 0074+00 0/0 1/1 0/0 .text forceFinish__12dEvDtEvent_cFv */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm void dEvDtEvent_c::forceFinish() { - nofralloc -#include "asm/d/event/d_event_data/forceFinish__12dEvDtEvent_cFv.s" +int dEvDtEvent_c::forceFinish() { + for (int i = 0; i < 3; i++) { + int tmp = field_0x88[i]; + if (tmp == -1) { + return 1; + } + dComIfGp_getEventManager().setFlag(tmp); + } + return 1; } -#pragma pop /* 80043F70-80043FD8 03E8B0 0068+00 0/0 1/1 0/0 .text * specialStaffProc__12dEvDtEvent_cFP12dEvDtStaff_c */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm void dEvDtEvent_c::specialStaffProc(dEvDtStaff_c* param_0) { - nofralloc -#include "asm/d/event/d_event_data/specialStaffProc__12dEvDtEvent_cFP12dEvDtStaff_c.s" +void dEvDtEvent_c::specialStaffProc(dEvDtStaff_c* param_0) { + for (int i = 0; i < mNStaff; i++) { + param_0[mStaff[i]].specialProc(); + } } -#pragma pop /* ############################################################################################## */ /* 80379DD0-80379DD0 006430 0000+00 0/0 0/0 0/0 .rodata @stringBase0 */ @@ -439,57 +462,56 @@ SECTION_DEAD static char const* const stringBase_80379E0D = "Timer"; #pragma pop /* 80043FD8-8004403C 03E918 0064+00 4/4 0/0 0/0 .text specialProc_WaitStart__12dEvDtStaff_cFi */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm void dEvDtStaff_c::specialProc_WaitStart(int param_0) { - nofralloc -#include "asm/d/event/d_event_data/specialProc_WaitStart__12dEvDtStaff_cFi.s" +void dEvDtStaff_c::specialProc_WaitStart(int param_0) { + int* timer = dComIfGp_evmng_getMyIntegerP(param_0, "Timer"); + if (timer == NULL) { + field_0x36 = 0; + } else { + field_0x36 = *timer; + } } -#pragma pop /* 8004403C-80044080 03E97C 0044+00 4/4 0/0 0/0 .text specialProc_WaitProc__12dEvDtStaff_cFi */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm void dEvDtStaff_c::specialProc_WaitProc(int param_0) { - nofralloc -#include "asm/d/event/d_event_data/specialProc_WaitProc__12dEvDtStaff_cFi.s" +void dEvDtStaff_c::specialProc_WaitProc(int param_0) { + if (field_0x36 > 0) { + field_0x36--; + } else { + dComIfGp_evmng_cutEnd(param_0); + } } -#pragma pop - -/* ############################################################################################## */ -/* 803A8238-803A8270 -00001 0034+04 1/1 0/0 0/0 .data @4398 */ -SECTION_DATA static void* lit_4398[13 + 1 /* padding */] = { - (void*)(((char*)specialProc__12dEvDtStaff_cFv) + 0xA0), - (void*)(((char*)specialProc__12dEvDtStaff_cFv) + 0x50), - (void*)(((char*)specialProc__12dEvDtStaff_cFv) + 0xA0), - (void*)(((char*)specialProc__12dEvDtStaff_cFv) + 0x68), - (void*)(((char*)specialProc__12dEvDtStaff_cFv) + 0x48), - (void*)(((char*)specialProc__12dEvDtStaff_cFv) + 0xA0), - (void*)(((char*)specialProc__12dEvDtStaff_cFv) + 0x40), - (void*)(((char*)specialProc__12dEvDtStaff_cFv) + 0x94), - (void*)(((char*)specialProc__12dEvDtStaff_cFv) + 0x8C), - (void*)(((char*)specialProc__12dEvDtStaff_cFv) + 0x9C), - (void*)(((char*)specialProc__12dEvDtStaff_cFv) + 0xA0), - (void*)(((char*)specialProc__12dEvDtStaff_cFv) + 0x38), - (void*)(((char*)specialProc__12dEvDtStaff_cFv) + 0x70), - /* padding */ - NULL, -}; /* 80044080-80044134 03E9C0 00B4+00 2/1 0/0 0/0 .text specialProc__12dEvDtStaff_cFv */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm void dEvDtStaff_c::specialProc() { - nofralloc -#include "asm/d/event/d_event_data/specialProc__12dEvDtStaff_cFv.s" -} -#pragma pop - -inline dEvent_manager_c& dComIfGp_getEventManager() { - return g_dComIfG_gameInfo.play.getEvtManager(); +void dEvDtStaff_c::specialProc() { + switch (mType) { + case 0xB: + specialProcPackage(); + break; + case 6: + specialProcDirector(); + break; + case 4: + specialProcTimekeeper(); + break; + case 1: + dComIfGp_evmng_cutEnd(mIndex); + break; + case 3: + specialProcEffect(); + break; + case 0xC: + specialProcCreate(); + dComIfGp_evmng_cutEnd(mIndex); + break; + case 8: + specialProcSound(); + break; + case 7: + specialProcMessage(); + break; + case 9: + specialProcLight(); + break; + } } /* 80044134-80044170 03EA74 003C+00 0/0 1/1 0/0 .text init__12dEvDtStaff_cFv */ @@ -531,6 +553,46 @@ SECTION_SDATA2 static f64 lit_4461 = 24.0; /* 80044190-80044324 03EAD0 0194+00 1/1 0/0 0/0 .text specialProcLight__12dEvDtStaff_cFv */ +#ifdef NM +// matches besides floats +void dEvDtStaff_c::specialProcLight() { + int staffId = i_dComIfGp_evmng_getMyStaffId("LIGHT", NULL, 0); + if (staffId != -1) { + char* nowCutNameP = dComIfGp_getEventManager().getMyNowCutName(staffId); + if (dComIfGp_evmng_getIsAddvance(staffId)) { + int nowCutName = *(int*)nowCutNameP; + f32* hourP; + switch (nowCutName) { + case 'CHAN': + hourP = dComIfGp_evmng_getMyFloatP(staffId, "Hour"); + if (hourP != NULL) { + dKy_instant_timechg(*hourP * 15.0f); + } + int* weatherP = dComIfGp_evmng_getMyIntegerP(staffId, "Weather"); + if (weatherP != NULL) { + switch (*weatherP) { + case 0: + dKy_instant_rainchg(); + } + } + break; + case 'ADD_': + hourP = dComIfGp_evmng_getMyFloatP(staffId, "Hour"); + if (hourP != NULL) { + f32 hours = dComIfGs_getTime() * (1.0f / 15.0f); + hours += *hourP; + while (hours >= 24.0) { + hours -= 24.0; + } + dKy_instant_timechg(hours * 15.0f); + } + break; + } + } + dComIfGp_evmng_cutEnd(staffId); + } +} +#else #pragma push #pragma optimization_level 0 #pragma optimizewithasm off @@ -539,27 +601,183 @@ asm void dEvDtStaff_c::specialProcLight() { #include "asm/d/event/d_event_data/specialProcLight__12dEvDtStaff_cFv.s" } #pragma pop - -/* ############################################################################################## */ -/* 80379DD0-80379DD0 006430 0000+00 0/0 0/0 0/0 .rodata @stringBase0 */ -#pragma push -#pragma force_active on -SECTION_DEAD static char const* const stringBase_80379E21 = "MESSAGE"; -SECTION_DEAD static char const* const stringBase_80379E29 = "msgNo"; -SECTION_DEAD static char const* const stringBase_80379E2F = "No"; -SECTION_DEAD static char const* const stringBase_80379E32 = "Type"; -SECTION_DEAD static char const* const stringBase_80379E37 = "ForStart"; -#pragma pop +#endif /* 80044324-80044A58 03EC64 0734+00 1/1 0/0 0/0 .text specialProcMessage__12dEvDtStaff_cFv */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm void dEvDtStaff_c::specialProcMessage() { - nofralloc -#include "asm/d/event/d_event_data/specialProcMessage__12dEvDtStaff_cFv.s" +void dEvDtStaff_c::specialProcMessage() { + StaffWork* work = &mWork; + int staffId = i_dComIfGp_evmng_getMyStaffId("MESSAGE", NULL, 0); + if (staffId == -1) { + return; + } + char* nowCutName = dComIfGp_getEventManager().getMyNowCutName(staffId); + if (dComIfGp_evmng_getIsAddvance(staffId)) { + switch (*(int*)nowCutName) { + case 'WAIT': + specialProc_WaitStart(staffId); + break; + case 'CREA': + case 'SHOW': + work->_0 = UINT32_MAX; + work->mLMsg = NULL; + work->mMsgSubstanceNum = dComIfGp_evmng_getMySubstanceNum(staffId, "msgNo"); + work->mMsgSubstanceP = dComIfGp_evmng_getMyIntegerP(staffId, "msgNo"); + if (work->mMsgSubstanceNum < 1) { + work->mMsgSubstanceNum = dComIfGp_evmng_getMySubstanceNum(staffId, "No"); + work->mMsgSubstanceP = dComIfGp_evmng_getMyIntegerP(staffId, "No"); + } + work->mMsgNo = *work->mMsgSubstanceP; + field_0x42 = 0; + break; + case 'END\0': + case 'FINI': + work->mLMsg->field_0xf8 = 0x10; + break; + case 'CONT': + work->mLMsg->field_0xf8 = 0xF; + int* ptr = dComIfGp_evmng_getMyIntegerP(staffId, "msgNo"); + if (ptr == NULL) { + ptr = dComIfGp_evmng_getMyIntegerP(staffId, "No"); + } + work->mMsgNo = *ptr; + fopMsgM_messageSet(work->mMsgNo, 1000); + break; + case 'SAVE': + work->mMsgNo = 1; + int* typeP = dComIfGp_evmng_getMyIntegerP(staffId, "Type"); + if (typeP != NULL && *typeP == 1) { + work->mMsgNo = 2; + } + work->_0 = d_GameOver_Create(work->mMsgNo); + break; + case 'TELO': + int* forStartP = dComIfGp_evmng_getMyIntegerP(staffId, "ForStart"); + if (forStartP != NULL && *forStartP != 0) { + work->mMsgNo = getStartTelopNo(); + } else { + char* stageP = dComIfGp_evmng_getMyStringP(staffId, "Stage"); + int* noP = dComIfGp_evmng_getMyIntegerP(staffId, "No"); + if (noP != NULL) { + work->mMsgNo = *noP; + } else if (stageP != NULL) { + work->mMsgNo = getTelopNo(stageP); + } else { + work->mMsgNo = getTelopNo(); + } + } + field_0x42 = 0; + if (work->mMsgNo != 0xFFFF) { + work->_0 = fopMsgM_messageSetDemo(work->mMsgNo); + } + } + } + switch (*(int*)nowCutName) { + case 'WAIT': + specialProc_WaitProc(staffId); + break; + case 'CREA': + switch (field_0x42) { + case 0: + work->_0 = fopMsgM_messageSet(work->mMsgNo, 1000); + if (work->_0 != UINT32_MAX) { + field_0x42++; + } + break; + case 1: + work->mLMsg = fopMsgM_SearchByID(work->_0); + if (work->mLMsg != NULL) { + field_0x42++; + } + break; + case 2: + dComIfGp_evmng_cutEnd(staffId); + break; + } + break; + case 'PUSH': + if (work->mLMsg->field_0xf8 == 0xE) { + dComIfGp_evmng_cutEnd(staffId); + } + break; + case 'TELO': + dComIfGp_evmng_cutEnd(staffId); + break; + case 'SHOW': + switch (field_0x42) { + case 0: + work->_0 = fopMsgM_messageSet(work->mMsgNo, 1000); + if (work->_0 != UINT32_MAX) { + field_0x42 = 1; + } else { + break; + } + case 1: + work->mLMsg = fopMsgM_SearchByID(work->_0); + if (work->mLMsg == NULL) { + break; + } + switch (work->mLMsg->field_0xf8) { + case 0xE: + work->mLMsg->field_0xf8 = 0x10; + break; + case 0x11: + break; + case 0x12: + work->mLMsg->field_0xf8 = 0x13; + work->_0 = UINT32_MAX; + work->mLMsg = NULL; + work->mMsgSubstanceNum--; + if (work->mMsgSubstanceNum != 0) { + field_0x42 = 0; + work->mMsgSubstanceP++; + work->mMsgNo = *work->mMsgSubstanceP; + } else { + dComIfGp_evmng_cutEnd(staffId); + field_0x42 = 99; + } + break; + default: + break; + } + break; + default: + dComIfGp_evmng_cutEnd(staffId); + break; + } + break; + case 'DELE': + case 'FINI': + if (work->mLMsg == NULL) { + dComIfGp_evmng_cutEnd(staffId); + } else if (work->mLMsg->field_0xf8 == 0x12) { + work->mLMsg->field_0xf8 = 0x13; + work->_0 = UINT32_MAX; + work->mLMsg = NULL; + dComIfGp_evmng_cutEnd(staffId); + } + break; + case 'CONT': + dComIfGp_evmng_cutEnd(staffId); + break; + case 'END\0': + switch (work->mLMsg->field_0xf8) { + case 0x11: + case 0x12: + dComIfGp_evmng_cutEnd(staffId); + break; + } + break; + case 'SAVE': + if (d_GameOver_CheckDelete(work->_0) && dComIfGp_getGameoverStatus() == 1) { + dComIfGp_evmng_cutEnd(staffId); + d_GameOver_Delete(work->_0); + } + break; + default: + dComIfGp_evmng_cutEnd(staffId); + break; + } } -#pragma pop /* ############################################################################################## */ /* 80379DD0-80379DD0 006430 0000+00 0/0 0/0 0/0 .rodata @stringBase0 */ @@ -576,6 +794,54 @@ SECTION_SDATA2 static f32 lit_4669 = -1.0f; /* 80044A58-80044CB8 03F398 0260+00 1/1 0/0 0/0 .text specialProcSound__12dEvDtStaff_cFv */ +#ifdef NONMATCHING +// matches besides floats +void dEvDtStaff_c::specialProcSound() { + int staffId = i_dComIfGp_evmng_getMyStaffId("SOUND", NULL, 0); + if (staffId == -1) { + return; + } + char* nowCutName = dComIfGp_getEventManager().getMyNowCutName(staffId); + if (dComIfGp_evmng_getIsAddvance(staffId)) { + switch (*(int*)nowCutName) { + case 'WAIT': + specialProc_WaitStart(staffId); + break; + case 'STRM': + mDoAud_bgmStreamPlay(); + break; + case 'NOMS': + specialProc_WaitStart(staffId); + break; + case 'RIDD': + int* typeP = dComIfGp_evmng_getMyIntegerP(staffId, "Type"); + if (typeP != NULL && *typeP == 1) { + mDoAud_seStart(0xC, NULL, 0, 0); + } else { + mDoAud_seStart(0xD, NULL, 0, 0); + } + break; + case 'BGMS': + int* timerP = dComIfGp_evmng_getMyIntegerP(staffId, "Timer"); + if (timerP != NULL) { + mDoAud_bgmStop(*timerP); + } + } + } + switch (*(int*)nowCutName) { + case 'WAIT': + specialProc_WaitProc(staffId); + break; + case 'NOMS': + if (mSoundWait <= dDemo_c::getFrameNoMsg()) { + dComIfGp_evmng_cutEnd(staffId); + } + break; + default: + dComIfGp_evmng_cutEnd(staffId); + } +} +#else #pragma push #pragma optimization_level 0 #pragma optimizewithasm off @@ -584,6 +850,7 @@ asm void dEvDtStaff_c::specialProcSound() { #include "asm/d/event/d_event_data/specialProcSound__12dEvDtStaff_cFv.s" } #pragma pop +#endif /* ############################################################################################## */ /* 80379DD0-80379DD0 006430 0000+00 0/0 0/0 0/0 .rodata @stringBase0 */ @@ -599,6 +866,60 @@ SECTION_DEAD static char const* const stringBase_80379E65 = "SCALE"; /* 80044CB8-80044EE4 03F5F8 022C+00 1/1 0/0 0/0 .text specialProcCreate__12dEvDtStaff_cFv */ +#ifdef NONMATCHING +void dEvDtStaff_c::specialProcCreate() { + // regalloc + char* name; + u32 arg; + cXyz pos; + csXyz angle; + cXyz scale; + char* nowCutName; + dStage_objectNameInf* objNameInf; + int staffId; + staffId = i_dComIfGp_evmng_getMyStaffId("CREATER", NULL, 0); + if (staffId == -1) { + return; + } + nowCutName = dComIfGp_getEventManager().getMyNowCutName(staffId); + if (dComIfGp_evmng_getIsAddvance(staffId)) { + switch (*(int*)nowCutName) { + case 'WAIT': + break; + case 'CREA': + name = dComIfGp_evmng_getMyStringP(staffId, "MAKECAST"); + objNameInf = dStage_searchName(name); + int* argP = dComIfGp_evmng_getMyIntegerP(staffId, "ARG"); + if (argP == NULL) { + arg = UINT32_MAX; + } else { + arg = *argP; + } + cXyz* posP = dComIfGp_evmng_getMyXyzP(staffId, "POS"); + if (posP == NULL) { + pos = ((fopAc_ac_c*)dComIfGp_getPlayer(0))->getPosition(); + } else { + pos = *posP; + } + int* angleP = dComIfGp_evmng_getMyIntegerP(staffId, "ANGLE"); + if (angleP == NULL) { + angle.setall(0); + } else { + angle.set(angleP[0], angleP[1], angleP[2]); + } + cXyz* scaleP = dComIfGp_evmng_getMyXyzP(staffId, "SCALE"); + if (scaleP == NULL) { + scale.setAll(1.0f); + } else { + scale = *scaleP; + } + fopAcM_create(objNameInf->mProcName, arg, &pos, dComIfGp_roomControl_getStayNo(), + &angle, &scale, objNameInf->mSubtype); + break; + } + } +} +#else #pragma push #pragma optimization_level 0 #pragma optimizewithasm off @@ -607,6 +928,7 @@ asm void dEvDtStaff_c::specialProcCreate() { #include "asm/d/event/d_event_data/specialProcCreate__12dEvDtStaff_cFv.s" } #pragma pop +#endif /* ############################################################################################## */ /* 80379DD0-80379DD0 006430 0000+00 0/0 0/0 0/0 .rodata @stringBase0 */ diff --git a/src/f_op/f_op_msg_mng.cpp b/src/f_op/f_op_msg_mng.cpp index ff889b9ded5..264661a4e11 100644 --- a/src/f_op/f_op_msg_mng.cpp +++ b/src/f_op/f_op_msg_mng.cpp @@ -201,7 +201,7 @@ asm void fopMsgM_messageSet(u32 param_0, fopAc_ac_c* param_1, u32 param_2) { #pragma push #pragma optimization_level 0 #pragma optimizewithasm off -asm void fopMsgM_messageSet(u32 param_0, u32 param_1) { +asm int fopMsgM_messageSet(u32 param_0, u32 param_1) { nofralloc #include "asm/f_op/f_op_msg_mng/fopMsgM_messageSet__FUlUl.s" } @@ -211,7 +211,7 @@ asm void fopMsgM_messageSet(u32 param_0, u32 param_1) { #pragma push #pragma optimization_level 0 #pragma optimizewithasm off -asm void fopMsgM_messageSetDemo(u32 param_0) { +asm int fopMsgM_messageSetDemo(u32 param_0) { nofralloc #include "asm/f_op/f_op_msg_mng/fopMsgM_messageSetDemo__FUl.s" }