From a6b584eff185f88198d8e892223b0d6059ac5056 Mon Sep 17 00:00:00 2001 From: "Jasper St. Pierre" Date: Sat, 20 Jan 2024 22:22:15 -0800 Subject: [PATCH] d_s_play work --- include/JSystem/JAudio/JAIBasic.h | 6 +- include/d/actor/d_a_dai.h | 9 +- include/d/actor/d_a_npc_kg2.h | 7 +- include/d/actor/d_a_salvage.h | 13 ++- include/d/actor/d_a_steam_tag.h | 5 + include/d/actor/d_a_ykgr.h | 10 +- include/d/d_com_inf_game.h | 52 +++++++-- include/d/d_drawlist.h | 2 + include/d/d_s_play.h | 26 ++--- include/d/d_stage.h | 2 + include/m_Do/m_Do_audio.h | 8 ++ src/d/d_com_static.cpp | 18 ++-- src/d/d_s_play.cpp | 174 ++++++++++++++++++++++++++++-- 13 files changed, 290 insertions(+), 42 deletions(-) diff --git a/include/JSystem/JAudio/JAIBasic.h b/include/JSystem/JAudio/JAIBasic.h index 141efda92..6dbffd75f 100644 --- a/include/JSystem/JAudio/JAIBasic.h +++ b/include/JSystem/JAudio/JAIBasic.h @@ -3,6 +3,7 @@ #include "JSystem/JUtility/JUTAssert.h" #include "dolphin/mtx/vec.h" +#include "JSystem/JAudio/JAIBankWave.h" class JAISound; class JKRSolidHeap; @@ -82,9 +83,12 @@ public: return msCurrentHeap; } + bool checkAllWaveLoadStatus() { + return JAInter::BankWave::checkAllWaveLoadStatus(); + } + // TODO void addInitOnCodeSeScene(u32, u32) {} - void checkAllWaveLoadStatus() {} void checkEnablePrepare(u32) {} void getAudioCamera() {} void getInitDataInfo() {} diff --git a/include/d/actor/d_a_dai.h b/include/d/actor/d_a_dai.h index 3b92ace65..fc0c64ebb 100644 --- a/include/d/actor/d_a_dai.h +++ b/include/d/actor/d_a_dai.h @@ -10,7 +10,6 @@ public: void decNowItemNum() {} void incNowDaizaNum() {} void incNowItemNum() {} - void init() {} BOOL _delete(); void CreateHeap(); @@ -27,6 +26,14 @@ public: void getMsg(); void next_msgStatus(unsigned long*); + static void init() { + mNowDaizaNum = 0; + mNowItemNum = 0; + } + + static u32 mNowDaizaNum; + static u32 mNowItemNum; + public: /* 0x6C4 */ request_of_phase_process_class mPhsFdai; /* 0x6CC */ request_of_phase_process_class mPhsCloth; diff --git a/include/d/actor/d_a_npc_kg2.h b/include/d/actor/d_a_npc_kg2.h index bcdb49ffb..35f27965b 100644 --- a/include/d/actor/d_a_npc_kg2.h +++ b/include/d/actor/d_a_npc_kg2.h @@ -7,7 +7,6 @@ class daNpc_Kg2_c : public fopAc_ac_c { public: void getAttentionBasePos() {} void getEyePos() {} - void init() {} void seStart(unsigned long) {} void setAction(int (daNpc_Kg2_c::*)(void*), void*) {} void setCanonGameResult(unsigned char) {} @@ -44,6 +43,12 @@ public: BOOL _execute(); BOOL _draw(); + static void init() { + canon_game_result = 0; + } + + static s32 canon_game_result; + public: /* Place member variables here */ }; diff --git a/include/d/actor/d_a_salvage.h b/include/d/actor/d_a_salvage.h index 8a18885b6..a23861fb3 100644 --- a/include/d/actor/d_a_salvage.h +++ b/include/d/actor/d_a_salvage.h @@ -4,6 +4,8 @@ #include "f_op/f_op_actor.h" #include "d/actor/d_a_oship.h" +class daSalvage_control_c; + class daSalvage_c : public fopAc_ac_c { public: void checkRegist(int) {} @@ -28,7 +30,6 @@ public: void getScale(int) {} void getSwitchNo(int) {} void getType(int) {} - void init() {} void init_one(int) {} void isValidSalvageId() {} void setDrawMode(int, int) {} @@ -66,6 +67,16 @@ public: static void init_room(signed char); + static void init() { + mNowRoomNo = 0xFF; + mTagData_p = NULL; + mSalvageId = -1; + } + + static u8 mNowRoomNo; + static daSalvage_control_c* mTagData_p; + static s32 mSalvageId; + public: /* Place member variables here */ }; diff --git a/include/d/actor/d_a_steam_tag.h b/include/d/actor/d_a_steam_tag.h index be13839c6..264920b2c 100644 --- a/include/d/actor/d_a_steam_tag.h +++ b/include/d/actor/d_a_steam_tag.h @@ -18,6 +18,8 @@ public: void createEmitter(); void endEmitter(); + static void init(); + public: /* 0x290 */ JPABaseEmitter* mpEmitter; /* 0x294 */ u8 m294[0x296 - 0x294]; @@ -30,6 +32,9 @@ public: /* 0x408 */ dCcD_Cps mCps; /* 0x540 */ cM3dGCpsS mPntWindCpsS; /* 0x55C */ dPointWind_c mPointWind; + +public: + static s32 mEmitterNum; }; #endif /* D_A_STEAM_TAG_H */ diff --git a/include/d/actor/d_a_ykgr.h b/include/d/actor/d_a_ykgr.h index 0e748902d..b677bd86c 100644 --- a/include/d/actor/d_a_ykgr.h +++ b/include/d/actor/d_a_ykgr.h @@ -8,6 +8,13 @@ class JPABaseParticle; class daYkgr_c : public fopAc_ac_c { public: + static void init() { + m_emitter = NULL; + m_flag = 0; + m_alpha_flag = 1; + m_alpha = 0xFF; + } + static void stop() { if (m_emitter) { m_alpha_flag = 0; @@ -15,14 +22,15 @@ public: }; static JPABaseEmitter* m_emitter; + static u8 m_flag; static u8 m_alpha_flag; + static u8 m_alpha; inline s32 _create(); inline BOOL _delete(); inline BOOL _draw(); inline BOOL _execute(); void hide() {} - void init() {} void setAimRate(float) {} void setAlpha(unsigned char) {} void set_mtx() {} diff --git a/include/d/d_com_inf_game.h b/include/d/d_com_inf_game.h index b75965040..d687045c4 100644 --- a/include/d/d_com_inf_game.h +++ b/include/d/d_com_inf_game.h @@ -415,6 +415,8 @@ public: JKRArchive* getLkDemoAnmArchive() { return mpLkDArc; } void setLkDemoAnmArchive(JKRArchive* i_arc) { mpLkDArc = i_arc; } + s8 getLkDemoAnmNo() { return mLkDArcIdx; } + void setLkDemoAnmNo(s8 idx) { mLkDArcIdx = idx; } void setStatus(u16 status) { mStatus = status; } void onStatus(u16 status) { mStatus |= status; } s32 checkStatus(u16 flags) { return flags & mStatus; } @@ -492,6 +494,13 @@ public: u8 getScopeType() { return mbCamOverrideFarPlane; } void setScopeType(u8 v) { mbCamOverrideFarPlane = v; } + void setCameraInfo(int idx, camera_class* camera_p, int dlst_window_idx, int cam_idx, int p5) { + mCameraInfo[idx].mpCamera = camera_p; + mCameraInfo[idx].mDlstWindowIdx = dlst_window_idx; + mCameraInfo[idx].mCamIdx = cam_idx; + mCameraInfo[idx].field_0x06 = p5; + } + // void setCameraAttentionStatus(u32 stts) { mCameraInfo[0].mCameraAttentionStatus = stts; ) void setCurrentGrafPort(J2DOrthoGraph* i_graf) { mCurrentGrafPort = i_graf; } void setCurrentWindow(dDlst_window_c* i_window) { mCurrentWindow = i_window; } void setCurrentView(view_class* i_view) { mCurrentView = i_view; } @@ -499,10 +508,17 @@ public: s32 getWindowNum() { return mDlstWindowNum; } void setWindowNum(u8 num) { mDlstWindowNum = num; } dDlst_window_c * getWindow(int idx) { return &mDlstWindow[idx]; } + void setWindow(int idx, f32 x, f32 y, f32 w, f32 h, f32 n, f32 f, int cameraID, int mode) { + getWindow(idx)->setViewPort(x, y, w, h, n, f); + getWindow(idx)->setScissor(x, y, w, h); + getWindow(idx)->setCameraID(cameraID); + getWindow(idx)->setMode(mode); + } J2DOrthoGraph* getCurrentGrafPort() { return mCurrentGrafPort; } - JKRExpHeap * getExpHeap2D() { return mpExpHeap2D; } + JKRExpHeap* getExpHeap2D() { return mpExpHeap2D; } + void setExpHeap2D(void* heap) { mpExpHeap2D = (JKRExpHeap*)heap; } inline u8 getHeapLockFlag() { return mHeapLockFlag; } inline void setHeapLockFlag(u8 flag) { mHeapLockFlag = flag; } @@ -1267,6 +1283,10 @@ inline void dComIfGs_onCollect(int i_idx, u8 i_item) { g_dComIfG_gameInfo.save.getPlayer().getCollect().onCollect(i_idx, i_item); } +inline void dComIfGs_offCollect(int i_idx, u8 i_item) { + g_dComIfG_gameInfo.save.getPlayer().getCollect().offCollect(i_idx, i_item); +} + inline u8 dComIfGs_checkCollect(int no) { return g_dComIfG_gameInfo.save.getPlayer().getCollect().checkCollect(no); } @@ -1693,6 +1713,8 @@ inline u8 dComIfGs_checkFwaterTimer() { return g_dComIfG_gameInfo.play.checkFwaterTimer(); } +void dComIfGs_setPlayerRecollectionData(); + /** * === PLAY === */ @@ -2029,6 +2051,10 @@ inline void dComIfGp_map_clrAGBMapSendStopFlg() { // dMap_c::clrAGBMapSendStopFlg(); } +inline void dComIfGp_createDemo() { + return g_dComIfG_gameInfo.play.createDemo(); +} + inline dDemo_manager_c* dComIfGp_demo_get() { return g_dComIfG_gameInfo.play.getDemo(); } @@ -2061,6 +2087,14 @@ inline void dComIfGp_setLkDemoAnmArchive(JKRArchive* i_arc) { g_dComIfG_gameInfo.play.setLkDemoAnmArchive(i_arc); } +inline s8 dComIfGp_getLkDemoAnmNo() { + return g_dComIfG_gameInfo.play.getLkDemoAnmNo(); +} + +inline void dComIfGp_setLkDemoAnmNo(s8 idx) { + g_dComIfG_gameInfo.play.setLkDemoAnmNo(idx); +} + inline void dComIfGp_setStatus(u16 status) { g_dComIfG_gameInfo.play.setStatus(status); } @@ -2315,9 +2349,11 @@ inline void dComIfGp_plusMiniGameRupee(s16 count) { g_dComIfG_gameInfo.play.plusMiniGameRupee(count); } +inline void dComIfGp_setCameraInfo(int idx, camera_class* camera, int dlst, int cam, int p5) { g_dComIfG_gameInfo.play.setCameraInfo(idx, camera, dlst, cam, p5); } inline s32 dComIfGp_getWindowNum() { return g_dComIfG_gameInfo.play.getWindowNum(); } inline void dComIfGp_setWindowNum(u8 num) { g_dComIfG_gameInfo.play.setWindowNum(num); } inline dDlst_window_c * dComIfGp_getWindow(int idx) { return g_dComIfG_gameInfo.play.getWindow(idx); } +inline void dComIfGp_setWindow(int idx, f32 x, f32 y, f32 w, f32 h, f32 n, f32 f, int cameraID, int mode) { g_dComIfG_gameInfo.play.setWindow(idx, x, y, w, h, n, f, cameraID, mode); } inline J2DOrthoGraph* dComIfGp_getCurrentGrafPort() { return g_dComIfG_gameInfo.play.getCurrentGrafPort(); } inline void dComIfGp_setCurrentWindow(dDlst_window_c* window) { return g_dComIfG_gameInfo.play.setCurrentWindow(window); } inline void dComIfGp_setCurrentView(view_class* view) { return g_dComIfG_gameInfo.play.setCurrentView(view); } @@ -2327,9 +2363,8 @@ inline dADM_CharTbl* dComIfGp_CharTbl() { return &g_dComIfG_gameInfo.play.mADM.mCharTbl; } -inline JKRExpHeap * dComIfGp_getExpHeap2D() { - return g_dComIfG_gameInfo.play.getExpHeap2D(); -} +inline JKRExpHeap* dComIfGp_getExpHeap2D() { return g_dComIfG_gameInfo.play.getExpHeap2D(); } +inline void dComIfGp_setExpHeap2D(void* heap) { g_dComIfG_gameInfo.play.setExpHeap2D(heap); } inline u8 dComIfGp_getHeapLockFlag() { return g_dComIfG_gameInfo.play.getHeapLockFlag(); @@ -3052,6 +3087,10 @@ inline void dComIfGp_particle_createCommon(const void * pArc) { g_dComIfG_gameInfo.play.getParticle()->createCommon(pArc); } +inline void dComIfGp_particle_createScene(const void* pArc) { + g_dComIfG_gameInfo.play.getParticle()->createScene(pArc); +} + inline void dComIfGp_particle_createRoomScene(void * pData) { g_dComIfG_gameInfo.play.getParticle()->createRoomScene(pData); } @@ -3113,9 +3152,8 @@ inline u32 dComIfG_getTimerRestTimeMs() { return g_dComIfG_gameInfo.play.getTime inline void dComIfG_TimerDeleteRequest() { dComIfG_getTimerPtr()->deleteRequest(); } -inline u8 dComIfG_getBrightness() { - return g_dComIfG_gameInfo.mBrightness; -} +inline u8 dComIfG_getBrightness() { return g_dComIfG_gameInfo.mBrightness; } +inline void dComIfG_setBrightness(u8 v) { g_dComIfG_gameInfo.mBrightness = v; } class scene_class; int dComIfG_resetToOpening(scene_class* i_scene); diff --git a/include/d/d_drawlist.h b/include/d/d_drawlist.h index 96150c570..d912a4911 100644 --- a/include/d/d_drawlist.h +++ b/include/d/d_drawlist.h @@ -239,6 +239,8 @@ public: view_port_class* getViewPort() { return &mViewport; } s8 getCameraID() { return mCameraID; } + void setCameraID(int id) { mCameraID = id; } + void setMode(int mode) { mMode = mode; } private: /* 0x00 */ view_port_class mViewport; diff --git a/include/d/d_s_play.h b/include/d/d_s_play.h index 9991ef7b9..9630fb006 100644 --- a/include/d/d_s_play.h +++ b/include/d/d_s_play.h @@ -26,19 +26,19 @@ public: /* 0x1CC */ mDoDvdThd_toMainRam_c* sceneCommand; }; -class dScnPly_dark_HIO_c { +class dScnPly_dark_HIO_c : public JORReflexible { public: dScnPly_dark_HIO_c(); virtual ~dScnPly_dark_HIO_c() {} - /* 0x04 */ u8 field_0x04[0x05 - 0x04]; + /* 0x04 */ s8 mChildID; /* 0x05 */ u8 field_0x05; /* 0x06 */ u8 field_0x06; /* 0x07 */ u8 field_0x07[0x08 - 0x07]; /* 0x08 */ dStage_darkStatus_c mDarkStatus; }; -class dScnPly_reg_childHIO_c { +class dScnPly_reg_childHIO_c : public JORReflexible { public: dScnPly_reg_childHIO_c(); virtual ~dScnPly_reg_childHIO_c() {} @@ -47,12 +47,12 @@ public: /* 0x7C */ s16 mShortRegs[10]; }; -class dScnPly_env_otherHIO_c { +class dScnPly_env_otherHIO_c : public JORReflexible { public: dScnPly_env_otherHIO_c(); virtual ~dScnPly_env_otherHIO_c() {} - /* 0x04 */ u8 field_0x04; + /* 0x04 */ s8 mChildID; /* 0x05 */ u8 field_0x05; /* 0x06 */ u8 field_0x06; /* 0x07 */ u8 field_0x07; @@ -77,12 +77,12 @@ public: /* 0x44 */ f32 field_0x44; }; -class dScnPly_env_debugHIO_c { +class dScnPly_env_debugHIO_c : public JORReflexible { public: dScnPly_env_debugHIO_c(); virtual ~dScnPly_env_debugHIO_c() {} - /* 0x04 */ u8 field_0x04[0x08 - 0x04]; + /* 0x04 */ s8 mChildID; /* 0x08 */ f32 field_0x08; /* 0x0C */ f32 field_0x0c; /* 0x10 */ f32 field_0x10; @@ -95,7 +95,7 @@ public: /* 0x2C */ f32 field_0x2c; }; -class dScnPly_msg_HIO_c { +class dScnPly_msg_HIO_c : public JORReflexible { public: dScnPly_msg_HIO_c(); void dScnPly_msg_HIO_checkUpdate(u8); @@ -106,7 +106,7 @@ public: virtual ~dScnPly_msg_HIO_c() {} - /* 0x04 */ u8 field_0x04; + /* 0x04 */ s8 mChildID; /* 0x05 */ u8 mIsUpdate; /* 0x06 */ u8 field_0x06; /* 0x07 */ u8 field_0x07; @@ -119,16 +119,16 @@ public: extern dScnPly_msg_HIO_c g_msgDHIO; -class dScnPly_preLoad_HIO_c : public mDoHIO_entry_c { +class dScnPly_preLoad_HIO_c : public JORReflexible { public: virtual ~dScnPly_preLoad_HIO_c() {} }; -class dScnPly_env_HIO_c { +class dScnPly_env_HIO_c : public JORReflexible { public: virtual ~dScnPly_env_HIO_c() {} - /* 0x04 */ u8 field_0x4; + /* 0x04 */ s8 mChildID; /* 0x08 */ dScnPly_env_otherHIO_c mOther; /* 0x50 */ dScnPly_env_debugHIO_c mEnvDebug; }; @@ -137,7 +137,7 @@ class dScnPly_reg_HIO_c { public: virtual ~dScnPly_reg_HIO_c() {} - /* 0x4 */ u8 field_0x4; + /* 0x4 */ s8 mChildID; /* 0x8 */ dScnPly_reg_childHIO_c mChild[22]; }; diff --git a/include/d/d_stage.h b/include/d/d_stage.h index 3a61c3df8..ec30885df 100644 --- a/include/d/d_stage.h +++ b/include/d/d_stage.h @@ -1084,6 +1084,8 @@ int dStage_changeScene(int i_exitId, f32 speed, u32 mode, s8 room_no); void dStage_restartRoom(u32 roomParam, u32 mode); BOOL dStage_checkRestart(); +void dStage_Create(); +void dStage_Delete(); class cBgS_GndChk; int dStage_RoomCheck(cBgS_GndChk* i_gndChk); diff --git a/include/m_Do/m_Do_audio.h b/include/m_Do/m_Do_audio.h index 394e3e525..7bbfe91ee 100644 --- a/include/m_Do/m_Do_audio.h +++ b/include/m_Do/m_Do_audio.h @@ -153,6 +153,10 @@ inline void mDoAud_setLinkHp(s32 param_0, s32 param_1) { mDoAud_zelAudio_c::getInterface()->setLinkHp(param_0, param_1); } +inline void mDoAud_monsSeInit() { + mDoAud_zelAudio_c::getInterface()->monsSeInit(); +} + inline void mDoAud_monsSeStart(u32 i_seNum, Vec* param_1, u32 param_2, u32 param_3, s8 i_reverb) { mDoAud_zelAudio_c::getInterface()->monsSeStart(i_seNum, param_1, param_2, param_3, i_reverb); } @@ -258,4 +262,8 @@ inline void mDoAud_bgmNowBattle(f32 distance) { mDoAud_zelAudio_c::getInterface()->bgmNowBattle(distance); } +inline bool mDoAud_checkAllWaveLoadStatus() { + return mDoAud_zelAudio_c::getInterface()->checkAllWaveLoadStatus(); +} + #endif /* M_DO_AUDIO_H */ diff --git a/src/d/d_com_static.cpp b/src/d/d_com_static.cpp index 730df43b4..289d4da27 100644 --- a/src/d/d_com_static.cpp +++ b/src/d/d_com_static.cpp @@ -5,27 +5,29 @@ #include "dolphin/types.h" #include "d/d_com_inf_game.h" -#include "d/actor/d_a_obj_pirateship.h" #include "d/actor/d_a_agb.h" #include "d/actor/d_a_agbsw0.h" +#include "d/actor/d_a_npc_kamome.h" #include "d/actor/d_a_npc_os.h" #include "d/actor/d_a_npc_md.h" #include "d/actor/d_a_arrow.h" #include "d/actor/d_a_ib.h" -#include "d/actor/d_a_obj_movebox.h" -#include "d/actor/d_a_tag_kb_item.h" #include "d/actor/d_a_item.h" +#include "d/actor/d_a_obj_movebox.h" +#include "d/actor/d_a_obj_pirateship.h" +#include "d/actor/d_a_steam_tag.h" +#include "d/actor/d_a_tag_kb_item.h" #include "d/actor/d_a_tag_waterlevel.h" #include "d/actor/d_a_title.h" #include "d/d_procname.h" -#include "d/actor/d_a_npc_kamome.h" static Vec dummy_3569; +u32 daSteamTag_c::mEmitterNum; -// /* 8005662C-80056638 .text init__12daSteamTag_cFv */ -// void daSteamTag_c::init() { -// /* Nonmatching */ -// } +/* 8005662C-80056638 .text init__12daSteamTag_cFv */ +void daSteamTag_c::init() { + mEmitterNum = 0; +} /* 80056638-800566F0 .text getShipOffsetY__15daObjPirateshipFPsPsf */ f32 daObjPirateship::getShipOffsetY(s16* param_1, s16* param_2, f32 param_3) { diff --git a/src/d/d_s_play.cpp b/src/d/d_s_play.cpp index 04c171bda..40ff98164 100644 --- a/src/d/d_s_play.cpp +++ b/src/d/d_s_play.cpp @@ -8,10 +8,16 @@ #include "JSystem/JUtility/JUTAssert.h" #include "JSystem/JUtility/JUTConsole.h" #include "JSystem/JUtility/JUTReport.h" -#include "string.h" #include "SSystem/SComponent/c_counter.h" +#include "d/actor/d_a_dai.h" +#include "d/actor/d_a_ib.h" +#include "d/actor/d_a_npc_kg2.h" #include "d/actor/d_a_player_main.h" +#include "d/actor/d_a_salvage.h" +#include "d/actor/d_a_sea.h" +#include "d/actor/d_a_steam_tag.h" #include "d/actor/d_a_title.h" +#include "d/actor/d_a_ykgr.h" #include "d/d_com_inf_game.h" #include "d/d_com_lib_game.h" #include "d/d_kankyo_rain.h" @@ -28,6 +34,9 @@ #include "m_Do/m_Do_controller_pad.h" #include "m_Do/m_Do_dvd_thread.h" #include "m_Do/m_Do_graphic.h" +#include "m_Do/m_Do_machine.h" +#include "printf.h" +#include "string.h" namespace daObjTribox { class Act_c { @@ -473,13 +482,33 @@ int phase_01(dScnPly_ply_c* i_this) { } } -/* 802356E0-802357F4 .text phase_0__FP13dScnPly_ply_c */ -void phase_0(dScnPly_ply_c* i_this) { - /* Nonmatching */ -} - static mDoDvdThd_mountXArchive_c* l_lkDemoAnmCommand; +/* 802356E0-802357F4 .text phase_0__FP13dScnPly_ply_c */ +s32 phase_0(dScnPly_ply_c* i_this) { + /* Nonmatching */ + if (!mDoAud_checkAllWaveLoadStatus()) { + l_lkDemoAnmCommand = NULL; + + u32 darcIdx = dComIfGs_isEventBit(0x2D01) ? 1 : 0; + if (darcIdx != dComIfGp_getLkDemoAnmNo()) { + if (dComIfGp_getLkDemoAnmNo() > -1) { + dComIfGp_getLkDemoAnmArchive()->unmount(); + } + dComIfGp_setLkDemoAnmNo(darcIdx); + } + + char buf[32]; + sprintf(buf, "/res/Object/LkD%02.arc", darcIdx); + l_lkDemoAnmCommand = mDoDvdThd_mountXArchive_c::create(buf, 0, JKRArchive::MOUNT_ARAM); + JUT_ASSERT(0xd56, l_lkDemoAnmCommand != 0); + + return cPhs_NEXT_e; + } else { + return cPhs_INIT_e; + } +} + /* 802357F4-802359DC .text phase_1__FP13dScnPly_ply_c */ int phase_1(dScnPly_ply_c* i_this) { if (l_lkDemoAnmCommand != NULL) { @@ -538,18 +567,145 @@ int phase_3(dScnPly_ply_c* i_this) { return cPhs_NEXT_e; } +static s8 preLoadNo; +static bool doPreLoad; +static OSTime resPreLoadTime0; +static OSTime resPreLoadTime1; + /* 80235B0C-80236334 .text phase_4__FP13dScnPly_ply_c */ -void phase_4(dScnPly_ply_c* i_this) { +s32 phase_4(dScnPly_ply_c* i_this) { /* Nonmatching */ + + if (i_this->sceneCommand != NULL) { + JUT_ASSERT(0xdef, i_this->sceneCommand->getMemAddress()); + dComIfGp_particle_createScene(i_this->sceneCommand->getMemAddress()); + delete i_this->sceneCommand; + } else { + dComIfGp_particle_createScene(NULL); + } + + dComIfG_Ccsp()->Ct(); + dComIfGp_createDemo(); + daSea_Init(); + dSnap_Create(); + dComIfGp_setPlayerPtr(0, NULL); + g_dComIfG_gameInfo.play.mCurCamera[0] = 0; // dComIfGp_setPlayerInfo? + for (s32 i = 0; i < 3; i++) + dComIfGp_setPlayerPtr(i, NULL); + dComIfGp_setWindowNum(1); + dComIfGp_setWindow(0, 0.0f, 0.0f, mDoMch_render_c::getFbWidth(), mDoMch_render_c::getEfbHeight(), 0.0f, 1.0f, 0, 2); + dComIfGp_setCameraInfo(0, NULL, 0, 0, 0xFF); + // setCameraAttentionStatus? + dComIfGd_setWindow(NULL); + dComIfGd_setViewport(NULL); + dComIfGd_setView(NULL); + + JKRExpHeap* heap = fopMsgM_createExpHeap(0x73ea1); + JUT_ASSERT(0xe45, heap != 0); + dComIfGp_setExpHeap2D(heap); + + dStage_Create(); + mDoGph_gInf_c::setTickRate((OS_BUS_CLOCK / 4) / 60); + + g_darkHIO.mChildID = mDoHIO_root.mDoHIO_createChild("暗闇スポット", &g_darkHIO); + g_envHIO.mChildID = mDoHIO_root.mDoHIO_createChild("描画設定", &g_envHIO); + g_msgDHIO.mChildID = mDoHIO_root.mDoHIO_createChild("Message Data", &g_msgDHIO); + + new(&dComIfGp_getAttention()) dAttention_c(dComIfGp_getPlayer(0), NULL); + dComIfGp_getVibration().Init(); + daSteamTag_c::init(); + daYkgr_c::init(); + daSalvage_c::init(); + daDai_c::init(); + daNpc_Kg2_c::init(); + daIball_c::init(); + dComIfG_setBrightness(0xFF); + mDoGph_gInf_c::offFade(); + + stage_stag_info_class* stag_info = dComIfGp_getStageStagInfo(); + if (stag_info != NULL && dStage_stagInfo_GetSTType(stag_info) == dStageType_FF1_e && dComIfGs_isEventBit(0x0801)) { + dComIfGs_setSelectEquip(0, NO_ITEM); + dComIfGp_setSelectEquip(0, NO_ITEM); + dComIfGs_offCollect(0, 0); + } + + if (strcmp(dComIfGp_getStartStageName(), "GTower") == 0) { + dComIfGs_setItem(12, NO_ITEM); // take away the bow + for (s32 i = 0; i < 3; i++) { + s32 itemno = dComIfGp_getSelectItem(i); + if (itemno == BOW || itemno == MAGIC_ARROW || itemno == LIGHT_ARROW) { + dComIfGs_setSelectItem(i, NO_ITEM); + dComIfGp_setSelectItem(i); + } + } + } else if (dComIfGs_getItem(12) == NO_ITEM) { + // give the bow back + if (dComIfGs_isItem(12, 2)) + dComIfGs_setItem(12, LIGHT_ARROW); + else if (dComIfGs_isItem(12, 1)) + dComIfGs_setItem(12, MAGIC_ARROW); + else if (dComIfGs_isItem(12, 0)) + dComIfGs_setItem(12, BOW); + } + + if (strcmp(dComIfGp_getStartStageName(), "Xboss0") == 0 || strcmp(dComIfGp_getStartStageName(), "Xboss1") == 0 || strcmp(dComIfGp_getStartStageName(), "Xboss2") == 0 || strcmp(dComIfGp_getStartStageName(), "Xboss3") == 0) { + dComIfGs_setPlayerRecollectionData(); + } + + mDoAud_monsSeInit(); + + if (fpcM_GetProfName(i_this) == PROC_PLAY_SCENE) { + mDoAud_zelAudio_c::onBgmSet(); + } else { + mDoAud_zelAudio_c::offBgmSet(); + } + + dScnPly_ply_c::pauseTimer = 0; + dScnPly_ply_c::nextPauseTimer = 0; + + if (((strcmp(dComIfGp_getStartStageName(), "Hyrule") == 0 || strcmp(dComIfGp_getStartStageName(), "Hyroom") == 0 || strcmp(dComIfGp_getStartStageName(), "kenroom") == 0) && !dComIfGs_isEventBit(0x3802)) || dComIfGp_getStartStageName()[0] == 'X') { + mDoGph_gInf_c::onMonotone(); + + bool hy8 = strcmp(dComIfGp_getStartStageName(), "Hyrule") == 0 && dComIfGp_getStartStageLayer() == 8; + mDoGph_gInf_c::setMonotoneRate(400); + if (hy8) + mDoGph_gInf_c::setMonotoneRate(-600); + mDoGph_gInf_c::setMonotoneRateSpeed(0); + } else { + mDoGph_gInf_c::offMonotone(); + } + + preLoadNo = -1; + if (doPreLoad) { + // PreloadTable + } + + mDoRst::offReset(); + OSTime time = resPreLoadTime0; + JUTGamePad::clearResetOccurred(); + JUTGamePad::setResetCallback(mDoRst_resetCallBack, NULL); + + s32 rt; + if (preLoadNo < 0) + return cPhs_COMPLEATE_e; + + time = OSGetTime(); + rt = cPhs_NEXT_e; + resPreLoadTime0 = time; + + return rt; } /* 80236334-80236444 .text phase_5__FP13dScnPly_ply_c */ -void phase_5(dScnPly_ply_c* i_this) { +s32 phase_5(dScnPly_ply_c* i_this) { /* Nonmatching */ + if (preLoadNo < 0) { + return cPhs_NEXT_e; + } } /* 80236444-80236554 .text phase_6__FP13dScnPly_ply_c */ -void phase_6(dScnPly_ply_c* i_this) { +s32 phase_6(dScnPly_ply_c* i_this) { /* Nonmatching */ }