From 8279e934b1bf3bce0ebf271cae38134af58c9375 Mon Sep 17 00:00:00 2001 From: LagoLunatic Date: Sat, 29 Jun 2024 23:18:51 -0400 Subject: [PATCH] Implement inlines for d_gameover --- include/d/d_gameover.h | 23 ++++++++++++++++++++--- include/f_op/f_op_msg_mng.h | 2 +- src/d/d_gameover.cpp | 28 +++++++++++----------------- 3 files changed, 32 insertions(+), 21 deletions(-) diff --git a/include/d/d_gameover.h b/include/d/d_gameover.h index b8e4e093c..6f6165195 100644 --- a/include/d/d_gameover.h +++ b/include/d/d_gameover.h @@ -28,6 +28,20 @@ public: mAlpha = 0.0f; } + f32 acc(s16 param_0, s16 param_1, s16 param_2) { + return ((f32)(param_1 - param_2) * (f32)(param_1 - param_2)) / ((f32)(param_0 - param_2) * (f32)(param_0 - param_2)); + } + void deleteScreen() { delete scrn; } + void setAlpha(f32 alpha) { mAlpha = alpha; } + void stopEmitter0() { + if (mpEmitter0 != NULL) + mpEmitter0->becomeInvalidEmitter(); + } + void stopEmitter1() { + if (mpEmitter1 != NULL) + mpEmitter1->becomeInvalidEmitter(); + } + virtual ~dDlst_GameOverScrnDraw_c() {} void setScreen(const char*, JKRArchive*); void valueInit(); @@ -41,7 +55,7 @@ public: virtual void draw(); -public: +private: /* 0x004 */ J2DScreen* scrn; /* 0x008 */ fopMsgM_pane_class letter[8]; #if VERSION != VERSION_JPN @@ -63,13 +77,16 @@ public: class dGameover_c : public msg_class { public: + void animeStart() { mAnimeStart = true; } + void setBackAlpha(f32 alpha) { dgo_scrn_c->setAlpha(alpha); } + s32 _create(); BOOL _execute(); BOOL _draw(); BOOL _delete(); BOOL deleteCheck(); -public: +private: /* 0x0FC */ dMenu_save_c* dMs_c; /* 0x100 */ dDlst_GameOverScrnDraw_c* dgo_scrn_c; /* 0x104 */ dDlst_Gameover_CAPTURE_c* dgo_capture_c; @@ -78,7 +95,7 @@ public: /* 0x114 */ s16 field_0x114; /* 0x116 */ s16 field_0x116; /* 0x118 */ u8 mState; - /* 0x119 */ u8 field_0x119; + /* 0x119 */ bool mAnimeStart; /* 0x11C */ u8 field_0x11c; }; diff --git a/include/f_op/f_op_msg_mng.h b/include/f_op/f_op_msg_mng.h index 79a3d1561..255f6beca 100644 --- a/include/f_op/f_op_msg_mng.h +++ b/include/f_op/f_op_msg_mng.h @@ -60,7 +60,7 @@ typedef int (*fopMsgCreateFunc)(void*); JKRExpHeap* fopMsgM_createExpHeap(u32, JKRHeap*); JKRExpHeap* fopMsgM_createExpHeap(u32); u32 fopMsgM_Create(s16, fopMsgCreateFunc, void*); -s32 fopMsgM_create(s16 param_0, fopAc_ac_c* param_1 = NULL, cXyz* param_2 = NULL, +s32 fopMsgM_create(s16 i_procName, fopAc_ac_c* param_1 = NULL, cXyz* param_2 = NULL, u32* param_3 = NULL, u32* param_4 = NULL, fopMsgCreateFunc createFunc = NULL); void fopMsgM_Delete(void* process); fopMsg_prm_class* fopMsgM_GetAppend(void* msg); diff --git a/src/d/d_gameover.cpp b/src/d/d_gameover.cpp index e4a078784..c96be69ee 100644 --- a/src/d/d_gameover.cpp +++ b/src/d/d_gameover.cpp @@ -97,7 +97,7 @@ s32 dGameover_c::_create() { field_0x114 = 90; field_0x116 = g_menuHIO.field_0xb6; - field_0x119 = 0; + mAnimeStart = false; return cPhs_COMPLEATE_e; } @@ -125,11 +125,10 @@ BOOL dGameover_c::_execute() { dMenu_flagSet(0); } - if (dgo_scrn_c->mpEmitter1 != NULL) - dgo_scrn_c->mpEmitter1->becomeInvalidEmitter(); + dgo_scrn_c->stopEmitter1(); mState = 6; } - } else if (mState != 6 && field_0x119) { + } else if (mState != 6 && mAnimeStart) { if (field_0x114 == 90) { if (dgo_scrn_c->animeOpen() == 1) { cXyz zero(0.0f, 0.0f, 0.0f); @@ -143,8 +142,7 @@ BOOL dGameover_c::_execute() { dgo_scrn_c->valueInit(); } else { if (dgo_scrn_c->animeClose() == 1) { - if (dgo_scrn_c->mpEmitter0 != NULL) - dgo_scrn_c->mpEmitter0->becomeInvalidEmitter(); + dgo_scrn_c->stopEmitter0(); if (field_0x116-- <= 0) { mState = 3; dMenu_flagSet(1); @@ -171,7 +169,7 @@ BOOL dGameover_c::_draw() { BOOL dGameover_c::_delete() { JKRHeap* oldHeap = mDoExt_setCurrentHeap(mpHeap); - delete dgo_scrn_c->scrn; + dgo_scrn_c->deleteScreen(); delete dgo_scrn_c; dMs_c->_delete(); delete dMs_c; @@ -335,15 +333,8 @@ void dDlst_GameOverScrnDraw_c::setEmitter1(cXyz pos) { mpEmitter1 = dComIfGp_particle_set2DmenuFore(0x30, &pos); } -// Fake inline -inline f32 divSquare(s16 y, f32 div) { - return (f32)y * (f32)y / div; -} - /* 8018F13C-8018F334 .text anime1__24dDlst_GameOverScrnDraw_cFi */ BOOL dDlst_GameOverScrnDraw_c::anime1(int idx) { - /* Fakematch */ - BOOL ret = FALSE; if (letter[idx].mUserArea < 5) { @@ -351,13 +342,16 @@ BOOL dDlst_GameOverScrnDraw_c::anime1(int idx) { fopMsgM_setInitAlpha(&letter[idx]); letter[idx].mUserArea++; - fopMsgM_paneTrans(&letter[idx], 0.0f, (1.0f - divSquare(letter[idx].mUserArea, 25.0f)) * -288.0f); + f32 y = (1.0f - acc(5, letter[idx].mUserArea, 0)) * -288.0f; + fopMsgM_paneTrans(&letter[idx], 0.0f, y); } else if (letter[idx].mUserArea < 7) { letter[idx].mUserArea++; - fopMsgM_paneTrans(&letter[idx], 0.0f, (divSquare(letter[idx].mUserArea - 5, 4.0f)) * -9.0f); + f32 y = acc(2, letter[idx].mUserArea - 5, 0) * -9.0f; + fopMsgM_paneTrans(&letter[idx], 0.0f, y); } else if (letter[idx].mUserArea < 9) { letter[idx].mUserArea++; - fopMsgM_paneTrans(&letter[idx], 0.0f, (1.0f - divSquare(letter[idx].mUserArea - 7, 4.0f)) * -9.0f); + f32 y = (1.0f - acc(2, letter[idx].mUserArea - 7, 0)) * -9.0f; + fopMsgM_paneTrans(&letter[idx], 0.0f, y); if (letter[idx].mUserArea == 9) mDoAud_seStart(JA_SE_EXIT_GAME_OVER); }