diff --git a/configure.py b/configure.py index 35cd0a3a3..aa4f37804 100644 --- a/configure.py +++ b/configure.py @@ -1266,7 +1266,7 @@ def DolphinLib(lib_name, objects): ActorRel(NonMatching, "d_a_obj_demo_barrel"), ActorRel(NonMatching, "d_a_obj_doguu"), ActorRel(Matching, "d_a_obj_doguu_demo"), - ActorRel(NonMatching, "d_a_obj_gryw00"), + ActorRel(Matching, "d_a_obj_gryw00", extra_cflags=['-pragma "nosyminline on"']), ActorRel(Matching, "d_a_obj_hfuck1", extra_cflags=['-pragma "nosyminline on"']), ActorRel(Matching, "d_a_obj_hole", extra_cflags=['-pragma "nosyminline on"']), ActorRel(NonMatching, "d_a_obj_ice"), diff --git a/include/d/actor/d_a_obj_gryw00.h b/include/d/actor/d_a_obj_gryw00.h index b8af598f8..49693abdd 100644 --- a/include/d/actor/d_a_obj_gryw00.h +++ b/include/d/actor/d_a_obj_gryw00.h @@ -1,33 +1,64 @@ #ifndef D_A_OBJ_GRYW00_H #define D_A_OBJ_GRYW00_H +#include "JSystem/JParticle/JPAEmitter.h" + +#include "m_Do/m_Do_ext.h" #include "f_op/f_op_actor.h" -class daObjGryw00_c : public fopAc_ac_c { +#include "d/d_a_obj.h" +#include "d/d_bg_s_movebg_actor.h" + +class daObjGryw00_c : public dBgS_MoveBgActor { public: - void param_get_swSave() const {} + enum Param_e { + PRM_SWSAVE_W = 0x08, + PRM_SWSAVE_S = 0x00, + }; + typedef void (daObjGryw00_c::*ModeFunc)(); + + s32 param_get_swSave() const { + return daObj::PrmAbstract(this, PRM_SWSAVE_W, PRM_SWSAVE_S); + } f32 get_draw_water_lv(void*); - void setup_high_water_level_btk_anm(); + BOOL setup_high_water_level_btk_anm(); void particle_set(); void particle_move(); void particle_delete(); void set_se(); - void CreateHeap(); - s32 Create(); - void Mthd_Create(); + int CreateHeap(); + int Create(); + s32 Mthd_Create(); BOOL Delete(); - void Mthd_Delete(); + BOOL Mthd_Delete(); void switch_wait_act_proc(); void spread_water_face_act_proc(); void water_level_move_wait_act_proc(); void anime_loop_start_wait_act_proc(); void high_water_level_act_proc(); - void Execute(float(**)[3][4]); + BOOL Execute(Mtx**); BOOL Draw(); public: - /* Place member variables here */ + /* 0x2C8 */ request_of_phase_process_class mPhs; + /* 0x2D0 */ J3DModel* mpModel; + /* 0x2D4 */ Mtx mMtx; + /* 0x304 */ mDoExt_btkAnm mBtk; + /* 0x318 */ mDoExt_bckAnm mBck; + /* 0x328 */ s32 mActivationSwitch; + /* 0x32C */ void (daObjGryw00_c::*modeFunc)(); + /* 0x338 */ BOOL mIsHidden; + /* 0x33C */ f32 mWaterLv; + /* 0x340 */ f32 mWaterMaxLv; + /* 0x344 */ f32 mWaterLvIncrement; + /* 0x348 */ f32 mWaveAmplitude; + /* 0x34C */ f32 mWaveMaxAmplitude; + /* 0x350 */ f32 mWaveAmplitudeIncrement; + /* 0x354 */ f32 mWaterLvFinalYPos; // never read ? at least by this class + /* 0x358 */ BOOL mShouldPlaySe; + /* 0x35C */ s32 mGeyserSeRemaining; + /* 0x360 */ JPABaseEmitter* mpEmitters[2]; }; #endif /* D_A_OBJ_GRYW00_H */ diff --git a/include/m_Do/m_Do_ext.h b/include/m_Do/m_Do_ext.h index bfc394c75..cde1bb016 100644 --- a/include/m_Do/m_Do_ext.h +++ b/include/m_Do/m_Do_ext.h @@ -28,6 +28,7 @@ class mDoExt_baseAnm { J3DFrameCtrl* getFrameCtrl() { return mFrameCtrl; } f32 getPlaySpeed() { return mFrameCtrl->getRate(); } void setPlaySpeed(f32 speed) { mFrameCtrl->setRate(speed); } + BOOL checkFrame(f32 frame) { return mFrameCtrl->checkPass(frame); } f32 getFrame() { return mFrameCtrl->getFrame(); } f32 getEndFrame() { return mFrameCtrl->getEnd(); } void setFrame(f32 frame) { mFrameCtrl->setFrame(frame); } diff --git a/src/d/actor/d_a_obj_gryw00.cpp b/src/d/actor/d_a_obj_gryw00.cpp index cf10e33b7..a419784c5 100644 --- a/src/d/actor/d_a_obj_gryw00.cpp +++ b/src/d/actor/d_a_obj_gryw00.cpp @@ -3,122 +3,295 @@ // Translation Unit: d_a_obj_gryw00.cpp // -#include "d/actor/d_a_obj_gryw00.h" +#include "d/d_com_inf_game.h" +#include "d/d_particle.h" #include "d/d_procname.h" +#include "d/actor/d_a_obj_gryw00.h" +#include "d/res/res_gryw00.h" + +#define SPREAD_PHASE_ANIM_LEN 95 +#define RISE_PHASE_ANIM_LEN 299 +#define WATER_WAVE_GROWTH_SPEED 0.10526316 +#define WATER_RISE_SPEED 1.6777408 +#define WAVE_AMPLITUDE -10 +#define HIGH_WATER_LEVEL 510 +#define GEYSER_SOUND_LEN 310 + +namespace { +static const char l_arcname[] = "Gryw00"; +} + /* 00000078-00000090 .text get_draw_water_lv__13daObjGryw00_cFPv */ -f32 daObjGryw00_c::get_draw_water_lv(void*) { - /* Nonmatching */ +f32 daObjGryw00_c::get_draw_water_lv(void* p) { + daObjGryw00_c* actr = static_cast(p); + return actr->home.pos.y + actr->mWaterLv + actr->mWaveAmplitude; } /* 00000090-00000168 .text setup_high_water_level_btk_anm__13daObjGryw00_cFv */ -void daObjGryw00_c::setup_high_water_level_btk_anm() { - /* Nonmatching */ +BOOL daObjGryw00_c::setup_high_water_level_btk_anm() { + BOOL ret = TRUE; + J3DAnmTextureSRTKey* btk_anm_p = static_cast(dComIfG_getObjectRes(l_arcname, GRYW00_BTK_GRYW00)); + JUT_ASSERT(223, btk_anm_p != 0); + if (!mBtk.init(mpModel->getModelData(), btk_anm_p, 1, J3DFrameCtrl::LOOP_REPEAT_e, 1.0f, 0x191, -1, -1, 0)) { + ret = FALSE; + } + return ret; } /* 00000168-000002D0 .text particle_set__13daObjGryw00_cFv */ void daObjGryw00_c::particle_set() { - /* Nonmatching */ + cXyz homePos = this->home.pos; + dComIfGp_particle_set(0x8295U, &homePos, NULL, NULL, 0xff, NULL, -1, NULL, &tevStr.mColorK0, NULL); + dComIfGp_particle_set(0x8297U, &homePos, NULL, NULL, 0xff, NULL, -1, NULL, &tevStr.mColorK0, NULL); + mpEmitters[0] = dComIfGp_particle_set(0x8296U, &homePos, NULL, NULL, 0xff, NULL, -1, NULL, + &tevStr.mColorK0, NULL); + mpEmitters[1] = dComIfGp_particle_set(0x8298U, &homePos, NULL, NULL, 0xff, NULL, -1, NULL, + &tevStr.mColorK0, NULL); } /* 000002D0-00000338 .text particle_move__13daObjGryw00_cFv */ void daObjGryw00_c::particle_move() { - /* Nonmatching */ + cXyz waterPos(this->home.pos.x, this->home.pos.y + mWaterLv, this->home.pos.z); + + if (mpEmitters[0]) { + mpEmitters[0]->setGlobalTranslation(waterPos); + } + if (mpEmitters[1]) { + mpEmitters[1]->setGlobalTranslation(waterPos); + } } /* 00000338-0000038C .text particle_delete__13daObjGryw00_cFv */ void daObjGryw00_c::particle_delete() { - /* Nonmatching */ + if (mpEmitters[0]) { + mpEmitters[0]->becomeInvalidEmitter(); + mpEmitters[0] = NULL; + } + if (mpEmitters[1]) { + mpEmitters[1]->becomeInvalidEmitter(); + mpEmitters[1] = NULL; + } } /* 0000038C-000004C4 .text set_se__13daObjGryw00_cFv */ void daObjGryw00_c::set_se() { - /* Nonmatching */ + if (mShouldPlaySe != TRUE) { + return; + } + if (mWaterLv >= HIGH_WATER_LEVEL) { + mShouldPlaySe = FALSE; + } + if (mGeyserSeRemaining > 0) { + mGeyserSeRemaining--; + fopAcM_seStartCurrent(this, JA_SE_OBJ_RDUN_MAE_GEYSER, 0); + } + fopAcM_seStartCurrent(this, JA_SE_OBJ_RDUN_MAE_W_OUT, 0); + fopAcM_seStartCurrent(this, JA_SE_OBJ_RDUN_MAE_W_UP, 0); } /* 000004C4-00000654 .text CreateHeap__13daObjGryw00_cFv */ -void daObjGryw00_c::CreateHeap() { - /* Nonmatching */ +int daObjGryw00_c::CreateHeap() { + BOOL ret = TRUE; + J3DModelData* mdlData = static_cast(dComIfG_getObjectRes(l_arcname, GRYW00_BDL_GRYW00)); + J3DAnmTextureSRTKey* pbtk = static_cast(dComIfG_getObjectRes(l_arcname, GRYW00_BTK_GRYW00)); + J3DAnmTransform* pbck = static_cast(dComIfG_getObjectRes(l_arcname, GRYW00_BCK_GRYW00)); + if (!mdlData || !pbtk || !pbck) { + JUT_PANIC(409); + ret = FALSE; + } else { + mpModel = mDoExt_J3DModel__create(mdlData, 0x80000U, 0x11000222U); + BOOL btk_inited = mBtk.init(mpModel->getModelData(), pbtk, TRUE, + J3DFrameCtrl::LOOP_ONCE_e, 0.0f, 0, 0x190, FALSE, 0); + BOOL bck_inited = mBck.init(mpModel->getModelData(), pbck, TRUE, + J3DFrameCtrl::LOOP_ONCE_e, 0.0f, 0, -1, FALSE); + if (!mpModel || !btk_inited || !bck_inited) { + ret = FALSE; + } + } + return ret; } /* 00000654-000007D4 .text Create__13daObjGryw00_cFv */ -s32 daObjGryw00_c::Create() { - /* Nonmatching */ +int daObjGryw00_c::Create() { + mActivationSwitch = param_get_swSave(); + mWaterLvFinalYPos = HIGH_WATER_LEVEL + home.pos.y; + if (mActivationSwitch != 0xff && fopAcM_isSwitch(this, mActivationSwitch) == TRUE) { + /* Puzzle already solved on load, water already high, only static animation */ + setup_high_water_level_btk_anm(); + mBck.setFrame(RISE_PHASE_ANIM_LEN); + mIsHidden = FALSE; + + modeFunc = &high_water_level_act_proc; + + mWaterLv = HIGH_WATER_LEVEL; + mWaterMaxLv = HIGH_WATER_LEVEL; + + mWaveAmplitude = WAVE_AMPLITUDE; + mWaveMaxAmplitude = WAVE_AMPLITUDE; + } else { + /* Waiting state until puzzle is solved */ + mIsHidden = TRUE; + + modeFunc = &switch_wait_act_proc; + mWaterLv = -5; + mWaterMaxLv = -5; + + mWaveAmplitude = 0; + mWaveMaxAmplitude = 0; + } + mpModel->setBaseScale(this->scale); + mDoMtx_stack_c::transS(this->home.pos.x, + this->home.pos.y + mWaterLv + mWaveAmplitude, + this->home.pos.z); + mpModel->setBaseTRMtx(mDoMtx_stack_c::get()); + fopAcM_SetMtx(this, mpModel->getBaseTRMtx()); + return TRUE; } /* 000007D4-0000090C .text Mthd_Create__13daObjGryw00_cFv */ -void daObjGryw00_c::Mthd_Create() { - /* Nonmatching */ +s32 daObjGryw00_c::Mthd_Create() { + fopAcM_SetupActor(this, daObjGryw00_c); + s32 phase_state = dComIfG_resLoad(&mPhs, l_arcname); + + if (phase_state == cPhs_COMPLEATE_e) { + phase_state = MoveBGCreate(l_arcname, 0xf, dBgS_MoveBGProc_Trans, 0x9a0); + JUT_ASSERT(519, (phase_state == cPhs_COMPLEATE_e) || (phase_state == cPhs_ERROR_e)); + } + return phase_state; } /* 00000A0C-00000A30 .text Delete__13daObjGryw00_cFv */ BOOL daObjGryw00_c::Delete() { - /* Nonmatching */ + particle_delete(); + return TRUE; } /* 00000A30-00000A7C .text Mthd_Delete__13daObjGryw00_cFv */ -void daObjGryw00_c::Mthd_Delete() { - /* Nonmatching */ +BOOL daObjGryw00_c::Mthd_Delete() { + int res = MoveBGDelete(); + dComIfG_resDelete(&mPhs, l_arcname); + return res; } /* 00000A7C-00000B50 .text switch_wait_act_proc__13daObjGryw00_cFv */ void daObjGryw00_c::switch_wait_act_proc() { - /* Nonmatching */ + if (mActivationSwitch == 0xff) { + return; + } + if (!(fopAcM_isSwitch(this, mActivationSwitch) == TRUE)) { + return; + } + mBtk.setPlaySpeed(1.0f); + mBck.setPlaySpeed(1.0f); + /* Waves get larger, water spreads, but water level stays still */ + mWaveAmplitudeIncrement = -WATER_WAVE_GROWTH_SPEED; + mWaveMaxAmplitude = WAVE_AMPLITUDE; + mWaterLvIncrement = WATER_WAVE_GROWTH_SPEED; + mWaterMaxLv = 5; + particle_set(); + mGeyserSeRemaining = GEYSER_SOUND_LEN; + mShouldPlaySe = TRUE; + mIsHidden = FALSE; + modeFunc = &spread_water_face_act_proc; } /* 00000B50-00000BB0 .text spread_water_face_act_proc__13daObjGryw00_cFv */ void daObjGryw00_c::spread_water_face_act_proc() { - /* Nonmatching */ + if (mBtk.checkFrame(SPREAD_PHASE_ANIM_LEN)) { + modeFunc = &water_level_move_wait_act_proc; + } } /* 00000BB0-00000C44 .text water_level_move_wait_act_proc__13daObjGryw00_cFv */ void daObjGryw00_c::water_level_move_wait_act_proc() { - /* Nonmatching */ + if (mBtk.checkFrame(RISE_PHASE_ANIM_LEN)) { + mWaterLvIncrement = WATER_RISE_SPEED; + mWaterMaxLv = HIGH_WATER_LEVEL; + modeFunc = &anime_loop_start_wait_act_proc; + mBck.setPlaySpeed(0); + mBck.setFrame(RISE_PHASE_ANIM_LEN); + } } /* 00000C44-00000CD0 .text anime_loop_start_wait_act_proc__13daObjGryw00_cFv */ void daObjGryw00_c::anime_loop_start_wait_act_proc() { - /* Nonmatching */ + if (mBtk.isStop()) { + particle_delete(); + setup_high_water_level_btk_anm(); + modeFunc = &high_water_level_act_proc; + } } /* 00000CD0-00000CD4 .text high_water_level_act_proc__13daObjGryw00_cFv */ -void daObjGryw00_c::high_water_level_act_proc() { - /* Nonmatching */ -} +void daObjGryw00_c::high_water_level_act_proc() {} /* 00000CD4-00000E30 .text Execute__13daObjGryw00_cFPPA3_A4_f */ -void daObjGryw00_c::Execute(float(**)[3][4]) { - /* Nonmatching */ +int daObjGryw00_c::Execute(Mtx** pMtx) { + mWaveAmplitude += mWaveAmplitudeIncrement; + if (mWaveAmplitude < mWaveMaxAmplitude) { + mWaveAmplitude = mWaveMaxAmplitude; + mWaveAmplitudeIncrement = 0; + } + mWaterLv += mWaterLvIncrement; + if (mWaterLv > mWaterMaxLv) { + mWaterLv = mWaterMaxLv; + mWaterLvIncrement = 0; + } + + f32 z_for_trans = this->home.pos.z; + f32 draw_water_lv = get_draw_water_lv(this); + mDoMtx_stack_c::transS(this->home.pos.x, draw_water_lv, z_for_trans); + mpModel->setBaseTRMtx(mDoMtx_stack_c::get()); + mDoMtx_stack_c::transS(this->home.pos.x, this->home.pos.y + mWaterLv, this->home.pos.z); + mDoMtx_stack_c::scaleM(this->scale); + cMtx_copy(mDoMtx_stack_c::get(), mMtx); + *pMtx = &mMtx; + + particle_move(); + set_se(); + mBtk.play(); + mBck.play(); + + (this->*modeFunc)(); + return TRUE; } /* 00000E30-00000ECC .text Draw__13daObjGryw00_cFv */ BOOL daObjGryw00_c::Draw() { - /* Nonmatching */ + if (!mIsHidden) { + g_env_light.settingTevStruct(TEV_TYPE_BG1, &this->current.pos, &tevStr); + g_env_light.setLightTevColorType(mpModel, &tevStr); + mBtk.entry(mpModel->getModelData()); + mBck.entry(mpModel->getModelData()); + mDoExt_modelUpdateDL(mpModel); + } + return TRUE; } /* 00000ECC-00000EEC .text daObjGryw00_Create__FP13daObjGryw00_c */ -static s32 daObjGryw00_Create(daObjGryw00_c*) { - /* Nonmatching */ +static s32 daObjGryw00_Create(daObjGryw00_c* i_this) { + return i_this->Mthd_Create(); } /* 00000EEC-00000F0C .text daObjGryw00_Delete__FP13daObjGryw00_c */ -static BOOL daObjGryw00_Delete(daObjGryw00_c*) { - /* Nonmatching */ +static BOOL daObjGryw00_Delete(daObjGryw00_c* i_this) { + return i_this->Mthd_Delete(); } /* 00000F0C-00000F2C .text daObjGryw00_Execute__FP13daObjGryw00_c */ -static BOOL daObjGryw00_Execute(daObjGryw00_c*) { - /* Nonmatching */ +static BOOL daObjGryw00_Execute(daObjGryw00_c* i_this) { + return i_this->MoveBGExecute(); } /* 00000F2C-00000F58 .text daObjGryw00_Draw__FP13daObjGryw00_c */ -static BOOL daObjGryw00_Draw(daObjGryw00_c*) { - /* Nonmatching */ +static BOOL daObjGryw00_Draw(daObjGryw00_c* i_this) { + return i_this->MoveBGDraw(); } /* 00000F58-00000F84 .text daObjGryw00_IsDelete__FP13daObjGryw00_c */ -static BOOL daObjGryw00_IsDelete(daObjGryw00_c*) { - /* Nonmatching */ +static BOOL daObjGryw00_IsDelete(daObjGryw00_c* i_this) { + return i_this->MoveBGIsDelete(); } static actor_method_class l_daObjGryw00_Method = {