diff --git a/configure.py b/configure.py index 8a5588790..faa37f577 100644 --- a/configure.py +++ b/configure.py @@ -252,13 +252,13 @@ config.libs = [ Object(NonMatching, "m_Do/m_Do_ext.cpp"), Object(NonMatching, "m_Do/m_Do_lib.cpp"), Object(Matching, "m_Do/m_Do_hostIO.cpp"), - Object(NonMatching, "m_Do/m_Do_Reset.cpp"), + Object(Matching, "m_Do/m_Do_Reset.cpp"), Object(NonMatching, "m_Do/m_Do_dvd_thread.cpp"), - Object(NonMatching, "m_Do/m_Do_DVDError.cpp"), + Object(Matching, "m_Do/m_Do_DVDError.cpp"), Object(NonMatching, "m_Do/m_Do_MemCard.cpp"), Object(NonMatching, "m_Do/m_Do_MemCardRWmng.cpp"), Object(NonMatching, "m_Do/m_Do_gba_com.cpp"), - Object(NonMatching, "m_Do/m_Do_machine_exception.cpp"), + Object(Matching, "m_Do/m_Do_machine_exception.cpp"), # c Object(NonMatching, "c/c_damagereaction.cpp"), @@ -395,7 +395,7 @@ config.libs = [ Object(NonMatching, "d/d_wood.cpp"), Object(NonMatching, "d/d_flower.cpp"), Object(NonMatching, "d/d_item_data.cpp"), - Object(NonMatching, "d/d_seafightgame.cpp"), + Object(Matching, "d/d_seafightgame.cpp"), Object(NonMatching, "d/d_spline_path.cpp"), Object(NonMatching, "d/d_s_actor_data_mng.cpp"), Object(NonMatching, "d/d_item.cpp"), diff --git a/include/d/actor/d_a_mgameboard.h b/include/d/actor/d_a_mgameboard.h new file mode 100644 index 000000000..623d62e97 --- /dev/null +++ b/include/d/actor/d_a_mgameboard.h @@ -0,0 +1,69 @@ +#ifndef D_A_MGAMEBOARD_H +#define D_A_MGAMEBOARD_H + +#include "f_op/f_op_actor_mng.h" +#include "d/d_seafightgame.h" +#include "d/d_lib.h" + +class dDlst_2DNumber_c; +class dDlst_2DMinigame_c; +class dDlst_2DObject_c; + +class daMgBoard_c : public fopAc_ac_c { +public: + void checkClearGame(); + void getScore(); + void reqStartGame(); + void checkEndGame(); + void setGInfoDraw(); + void clrGInfoDraw(); + void CreateHeap(); + void set_2dposition(); + void CreateInit(); + void MiniGameInit(); + void set_mtx(); + void _execute(); + void execGameMain(); + void execEndGame(); + void MinigameMain(); + void CursorMove(); + void _draw(); + + /* 0x290 */ request_of_phase_process_class mPhase; + /* 0x298 */ J3DModel* mpBoardModel; + /* 0x29C */ J3DModel* mpCursorModel; + /* 0x2A0 */ J3DModel* mpHitModel[20]; + /* 0x2F0 */ J3DModel* mpMissModel[32]; + /* 0x370 */ J3DModel* mpShip2Model[2]; + /* 0x378 */ J3DModel* mpShip3Model[2]; + /* 0x380 */ J3DModel* mpShip4Model; + /* 0x384 */ u8 field_0x384[0x468 - 0x384]; + /* 0x468 */ u8 mBoardPosX; + /* 0x469 */ u8 mBoardPosY; + /* 0x46A */ u8 field_0x46A[0x46C - 0x46A]; + /* 0x46C */ int mLastFirePosX; + /* 0x470 */ int mLastFirePosY; + /* 0x474 */ u8 field_0x474[0x47C - 0x474]; + /* 0x47C */ dSeaFightGame_info_c mSeaFightGame; + /* 0x57C */ u8 field_0x57C[0x580 - 0x57C]; + /* 0x580 */ int mMissModelCount; + /* 0x584 */ int mHitModelCount; + /* 0x588 */ s16 mMinigameStartIdx; + /* 0x58A */ s16 mMinigameEndIdx; + /* 0x58C */ STControl mStickControl; + /* 0x5B4 */ cXyz mNPCPos; + /* 0x5C0 */ dDlst_2DNumber_c* mpNumber0; + /* 0x5C4 */ dDlst_2DNumber_c* mpNumber1; + /* 0x5C8 */ dDlst_2DMinigame_c* mpMinigameDList; + /* 0x5CC */ dDlst_2DObject_c* mpSquidIcon[3]; + /* 0x5D8 */ u8 mpBombIcons; + /* 0x5D9 */ u8 field_0x5D9[0x638 - 0x5D9]; + /* 0x638 */ int mState; + /* 0x63C */ u8 mbDraw; + /* 0x63D */ u8 mbStartGame; + /* 0x63E */ u8 mbEndGame; + /* 0x63F */ u8 mbForceEnd; + /* 0x640 */ u8 mTimer; +}; + +#endif /* D_A_MGAMEBOARD_H */ \ No newline at end of file diff --git a/include/d/d_lib.h b/include/d/d_lib.h new file mode 100644 index 000000000..994947108 --- /dev/null +++ b/include/d/d_lib.h @@ -0,0 +1,41 @@ +#ifndef D_LIB_H +#define D_LIB_H + +#include "dolphin/types.h" + +class STControl { +public: + void STControl(s16, s16, s16, s16, f32, f32, s16, s16); + void setWaitParm(s16, s16, s16, s16, f32, f32, s16, s16); + void init(); + void Xinit(); + void Yinit(); + void getValueStick(); + void getAngleStick(); + void checkTrigger(); + void checkLeftTrigger(); + void checkRightTrigger(); + void checkUpTrigger(); + void checkDownTrigger(); + + /* 0x00 */ void* vtbl; + /* 0x04 */ f32 field_0x04; + /* 0x08 */ f32 field_0x08; + /* 0x0C */ u8 field_0x0c; + /* 0x0D */ u8 field_0x0d; + /* 0x0E */ u16 field_0x0e; + /* 0x10 */ u16 field_0x10; + /* 0x12 */ u16 field_0x12; + /* 0x14 */ s16 field_0x14; + /* 0x16 */ s16 field_0x16; + /* 0x18 */ u16 field_0x18; + /* 0x1A */ u16 field_0x1a; + /* 0x1C */ u16 field_0x1c; + /* 0x1E */ u16 field_0x1e; + /* 0x20 */ u16 field_0x20; + /* 0x22 */ u16 field_0x22; + /* 0x24 */ s16 field_0x24; + /* 0x26 */ s16 field_0x26; +}; + +#endif /* D_LIB_H */ \ No newline at end of file diff --git a/include/d/d_seafightgame.h b/include/d/d_seafightgame.h new file mode 100644 index 000000000..f141cb480 --- /dev/null +++ b/include/d/d_seafightgame.h @@ -0,0 +1,32 @@ +#ifndef D_SEAFIGHTGAME_H +#define D_SEAFIGHTGAME_H + +#include "dolphin/types.h" + +struct dSeaFightGame_ship_data { + /* 0x0 */ u8 m_pos[4][2]; + /* 0x8 */ u8 field_0x8; + /* 0x9 */ u8 field_0x9; + /* 0xA */ u8 field_0xa; + /* 0xB */ u8 field_0xb; + /* 0xC */ u8 field_0xc; + /* 0xD */ u8 field_0xd; + /* 0xE */ u8 field_0xe; +}; + +class dSeaFightGame_info_c { +public: + int init(int, int); + int put_ship(u8, u8); + bool checkPutShip(int, int, int, int); + int attack(u8, u8); + + /* 0x00 */ u8 mGrid[8][8]; + /* 0x40 */ dSeaFightGame_ship_data mShips[4]; + /* 0x7C */ u8 mAliveShipNum; + /* 0x7D */ u8 mBulletNum; + /* 0x7E */ u8 mScore; + /* 0x80 */ int mDeadShipNum; +}; + +#endif /* D_SEAFIGHTGAME_H */ \ No newline at end of file diff --git a/include/m_Do/m_Do_DVDError.h b/include/m_Do/m_Do_DVDError.h new file mode 100644 index 000000000..784ab1f36 --- /dev/null +++ b/include/m_Do/m_Do_DVDError.h @@ -0,0 +1,8 @@ +#ifndef M_DO_M_DO_DVD_ERROR_H +#define M_DO_M_DO_DVD_ERROR_H + +#include "dolphin/types.h" + +void mDoDvdErr_ThdCleanup(); + +#endif /* M_DO_M_DO_DVD_ERROR_H */ diff --git a/include/m_Do/m_Do_Reset.h b/include/m_Do/m_Do_Reset.h index 325982ee5..905fdb8f9 100644 --- a/include/m_Do/m_Do_Reset.h +++ b/include/m_Do/m_Do_Reset.h @@ -13,22 +13,11 @@ struct mDoRstData { /* 0x04 */ int mResetPrepare; /* 0x08 */ int m3ButtonReset; /* 0x0C */ int m3ButtonResetPort; - /* 0x10 */ bool mShutdown; - /* 0x11 */ bool mReturnToMenu; - /* 0x12 */ u8 mLogoScnFlag; - /* 0x13 */ u8 mProgSeqFlag; - /* 0x14 */ u8 mProgChgFlag; - /* 0x15 */ u8 mWarningDispFlag; -}; // Size = 0x18 +}; // Size = 0x10 class mDoRst { public: - static void offReturnToMenu() { mResetData->mReturnToMenu = false; } - static void offShutdown() { mResetData->mShutdown = false; } - static void setWarningDispFlag(u8 flag) { mResetData->mWarningDispFlag = flag; } - static void setProgChgFlag(u8 flag) { mResetData->mProgChgFlag = flag; } - static void setProgSeqFlag(u8 flag) { mResetData->mProgSeqFlag = flag; } - static void setLogoScnFlag(u8 flag) { mResetData->mLogoScnFlag = flag; } +#if VERSION != VERSION_JP static void set3ButtonResetPort(int port) { mResetData->m3ButtonResetPort = port; } static void off3ButtonReset() { mResetData->m3ButtonReset = 0; } static void offResetPrepare() { mResetData->mResetPrepare = 0; } @@ -36,24 +25,35 @@ public: mResetData->mReset = 0; mResetData->mResetPrepare = 0; } - static u8 getLogoScnFlag() { return mResetData->mLogoScnFlag; } - static u8 getProgSeqFlag() { return mResetData->mProgSeqFlag; } - static u8 getWarningDispFlag() { return mResetData->mWarningDispFlag; } - static BOOL isReturnToMenu() { return mResetData->mReturnToMenu; } - static BOOL isShutdown() { return mResetData->mShutdown; } static int isReset() { return mResetData->mReset; } static int get3ButtonResetPort() { return mResetData->m3ButtonResetPort; } static int is3ButtonReset() { return mResetData->m3ButtonReset; } static void onReset() { mResetData->mReset = 1; } - static void onReturnToMenu() { mResetData->mReturnToMenu = true; } static void on3ButtonReset() { mResetData->m3ButtonReset = 1; } - static void onShutdown() { mResetData->mShutdown = true; } - static mDoRstData* getResetData(); - static mDoRstData* i_getResetData() { return mResetData; } + static mDoRstData* getResetData() { return mResetData; } static void setResetData(mDoRstData* rstData) { mResetData = rstData; } static mDoRstData* mResetData; +#else + static void set3ButtonResetPort(int port) { m3ButtonResetPort = port; } + static void off3ButtonReset() { m3ButtonResetFlag = 0; } + static void offResetPrepare() { mResetPrepare = 0; } + static void offReset() { + mResetFlag = 0; + mResetPrepare = 0; + } + static int isReset() { return mResetFlag; } + static int get3ButtonResetPort() { return m3ButtonResetPort; } + static int is3ButtonReset() { return m3ButtonResetFlag; } + static void onReset() { mResetFlag = 1; } + static void on3ButtonReset() { m3ButtonResetFlag = 1; } + + static int mResetPrepare; + static int mResetFlag; + static int m3ButtonResetFlag; + static int m3ButtonResetPort; +#endif }; extern bool mDoDvdErr_initialized; diff --git a/include/m_Do/m_Do_audio.h b/include/m_Do/m_Do_audio.h index 1b6445b56..ffdfdde24 100644 --- a/include/m_Do/m_Do_audio.h +++ b/include/m_Do/m_Do_audio.h @@ -16,6 +16,7 @@ public: static void offResetFlag() { mResetFlag = false; } static bool isInitFlag() { return mInitFlag; } + static void offInitFlag() { mInitFlag = false; } static bool isBgmSet() { return mBgmSet; } static void offBgmSet() { mBgmSet = false; } diff --git a/include/m_Do/m_Do_machine_exception.h b/include/m_Do/m_Do_machine_exception.h new file mode 100644 index 000000000..f3a693579 --- /dev/null +++ b/include/m_Do/m_Do_machine_exception.h @@ -0,0 +1,16 @@ +#ifndef M_DO_M_DO_MACHINE_EXCEPTION_H +#define M_DO_M_DO_MACHINE_EXCEPTION_H + +#include "dolphin/types.h" + +class JUTConsole; + +void print_f(char const*, ...); +void print(char const*); +void dispHeapInfo(); +void dispGameInfo(); +void dispDateInfo(); +void dispConsoleToTerminal(); +void exception_addition(JUTConsole* pConsole); + +#endif /* M_DO_M_DO_MACHINE_EXCEPTION_H */ \ No newline at end of file diff --git a/src/d/actor/d_a_mgameboard.cpp b/src/d/actor/d_a_mgameboard.cpp index 5c61997f1..42f1c0a49 100644 --- a/src/d/actor/d_a_mgameboard.cpp +++ b/src/d/actor/d_a_mgameboard.cpp @@ -3,7 +3,7 @@ // Translation Unit: d_a_mgameboard.cpp // -#include "d_a_mgameboard.h" +#include "d/actor/d_a_mgameboard.h" #include "dolphin/types.h" /* 000000EC-0000010C .text CheckCreateHeap__FP10fopAc_ac_c */ diff --git a/src/d/d_seafightgame.cpp b/src/d/d_seafightgame.cpp index 6ce5faf51..a3127abf1 100644 --- a/src/d/d_seafightgame.cpp +++ b/src/d/d_seafightgame.cpp @@ -3,26 +3,126 @@ // Translation Unit: d_seafightgame.cpp // -#include "d_seafightgame.h" -#include "dolphin/types.h" +#include "d/d_seafightgame.h" +#include "SSystem/SComponent/c_math.h" /* 800C1F90-800C20B0 .text init__20dSeaFightGame_info_cFii */ -void dSeaFightGame_info_c::init(int, int) { - /* Nonmatching */ +int dSeaFightGame_info_c::init(int i_bulletNum, int i_scenario) { + for (int i = 0; i < 8; i++) { + for (int j = 0; j < 8; j++) { + mGrid[i][j] = 0; + } + } + + mBulletNum = i_bulletNum; + mScore = 0; + + switch (i_scenario) { + case 1: + mAliveShipNum = 1; + put_ship(0, 2); + break; + case 2: + mAliveShipNum = 2; + put_ship(0, 2); + put_ship(1, 3); + break; + case 3: + mAliveShipNum = 3; + put_ship(0, 2); + put_ship(1, 3); + put_ship(2, 4); + break; + } + + mDeadShipNum = 0; + return 1; } /* 800C20B0-800C225C .text put_ship__20dSeaFightGame_info_cFUcUc */ -void dSeaFightGame_info_c::put_ship(unsigned char, unsigned char) { - /* Nonmatching */ +int dSeaFightGame_info_c::put_ship(u8 i_shipNo, u8 i_shipSize) { + u8 y; + u8 x; + u8 direction; + + do { + direction = (s16)cM_rndF(1000.0f) % 2; + y = (int)cM_rndF(8.0f); + x = (int)cM_rndF(8.0f); + } while (!checkPutShip(y, x, i_shipSize, direction)); + + if (direction == 0) { + for (int i = 0; i < i_shipSize; i++) { + mShips[i_shipNo].m_pos[i][0] = y; + mShips[i_shipNo].m_pos[i][1] = x + i; + mGrid[y][x + i] = i_shipNo + 102; + } + + mShips[i_shipNo].field_0xb = y; + mShips[i_shipNo].field_0xc = x; + mShips[i_shipNo].field_0xd = 0; + mShips[i_shipNo].field_0xe = i_shipSize; + } else { + for (int i = 0; i < i_shipSize; i++) { + mShips[i_shipNo].m_pos[i][0] = y + i; + mShips[i_shipNo].m_pos[i][1] = x; + mGrid[y + i][x] = i_shipNo + 102; + } + + mShips[i_shipNo].field_0xb = y; + mShips[i_shipNo].field_0xc = x; + mShips[i_shipNo].field_0xd = i_shipSize; + mShips[i_shipNo].field_0xe = 0; + } + + mShips[i_shipNo].field_0x8 = i_shipSize; + mShips[i_shipNo].field_0x9 = i_shipSize; + return 1; } /* 800C225C-800C22FC .text checkPutShip__20dSeaFightGame_info_cFiiii */ -void dSeaFightGame_info_c::checkPutShip(int, int, int, int) { - /* Nonmatching */ +bool dSeaFightGame_info_c::checkPutShip(int i_y, int i_x, int i_shipSize, int i_direction) { + if (i_direction == 0) { + for (int i = 0; i < i_shipSize; i++) { + if (i_y > 7 || i_x > 7 || mGrid[i_y][i_x] > 100) { + return false; + } + i_x++; + } + } else { + for (int i = 0; i < i_shipSize; i++) { + if (i_y > 7 || i_x > 7 || mGrid[i_y][i_x] > 100) { + return false; + } + i_y++; + } + } + + return true; } /* 800C22FC-800C239C .text attack__20dSeaFightGame_info_cFUcUc */ -void dSeaFightGame_info_c::attack(unsigned char, unsigned char) { - /* Nonmatching */ -} +int dSeaFightGame_info_c::attack(u8 i_y, u8 i_x) { + int rt = -1; + u8 uvar1 = mGrid[i_y][i_x]; + if (uvar1 == 0) { + mGrid[i_y][i_x] = 1; + } else if (uvar1 > 100) { + rt = uvar1 - 102; + + mShips[rt].field_0x9--; + if (mShips[rt].field_0x9 == 0) { + mAliveShipNum--; + mDeadShipNum++; + } + + mGrid[i_y][i_x] = 3; + } else { + return -2; + } + + mBulletNum--; + mScore++; + return rt; +} diff --git a/src/m_Do/m_Do_DVDError.cpp b/src/m_Do/m_Do_DVDError.cpp index 325eead49..204bb8e86 100644 --- a/src/m_Do/m_Do_DVDError.cpp +++ b/src/m_Do/m_Do_DVDError.cpp @@ -4,24 +4,64 @@ // #include "m_Do/m_Do_DVDError.h" -#include "dolphin/types.h" +#include "JSystem/JKernel/JKRThread.h" +#include "dolphin/os/OS.h" +#include "m_Do/m_Do_dvd_thread.h" +#include "m_Do/m_Do_ext.h" + +OSThread DvdErr_thread; +u8 DvdErr_stack[0x1000] __attribute__((aligned(16))); + +static OSAlarm Alarm; +bool mDoDvdErr_initialized; + +void mDoDvdErr_Watch(void*); +void AlarmHandler(OSAlarm*, OSContext*); /* 80018BE0-80018CA0 .text mDoDvdErr_ThdInit__Fv */ void mDoDvdErr_ThdInit() { - /* Nonmatching */ + if (!mDoDvdErr_initialized) { + OSTime time = OSGetTime(); + OSThread* curThread = OSGetCurrentThread(); + s32 priority = OSGetThreadPriority(curThread); + + OSCreateThread(&DvdErr_thread, mDoDvdErr_Watch, NULL, DvdErr_stack + sizeof(DvdErr_stack), + sizeof(DvdErr_stack), priority - 3, 1); + OSResumeThread(&DvdErr_thread); + OSCreateAlarm(&Alarm); + OSSetPeriodicAlarm(&Alarm, time, OS_BUS_CLOCK / 4, AlarmHandler); + + mDoDvdErr_initialized = true; + } } /* 80018CA0-80018CE8 .text mDoDvdErr_ThdCleanup__Fv */ void mDoDvdErr_ThdCleanup() { - /* Nonmatching */ + if (mDoDvdErr_initialized) { + OSCancelThread(&DvdErr_thread); + OSCancelAlarm(&Alarm); + mDoDvdErr_initialized = false; + } } /* 80018CE8-80018D44 .text mDoDvdErr_Watch__FPv */ void mDoDvdErr_Watch(void*) { - /* Nonmatching */ + { + JKRThread thread(OSGetCurrentThread(), 0); + } + + JKRHeap* heap = NULL; + heap->becomeCurrentHeap(); + + do { + if (DVDGetDriveStatus() == DVD_STATE_FATAL_ERROR) { + mDoDvdThd::suspend(); + } + OSSuspendThread(&DvdErr_thread); + } while (true); } /* 80018D44-80018D6C .text AlarmHandler__FP7OSAlarmP9OSContext */ void AlarmHandler(OSAlarm*, OSContext*) { - /* Nonmatching */ + OSResumeThread(&DvdErr_thread); } diff --git a/src/m_Do/m_Do_Reset.cpp b/src/m_Do/m_Do_Reset.cpp index fb4de5b1e..65be5c534 100644 --- a/src/m_Do/m_Do_Reset.cpp +++ b/src/m_Do/m_Do_Reset.cpp @@ -1,32 +1,102 @@ -// -// Generated by dtk -// Translation Unit: m_Do_Reset.cpp -// +/** + * m_Do_Reset.cpp + * Game Reset Management + */ #include "m_Do/m_Do_Reset.h" -#include "dolphin/types.h" +#include "JSystem/JUtility/JUTGamePad.h" +#include "JSystem/JUtility/JUTXfb.h" +#include "dolphin/gx/GX.h" +#include "dolphin/os/OS.h" +#include "m_Do/m_Do_DVDError.h" +#include "m_Do/m_Do_audio.h" /* 80017D40-80017D44 .text my_OSCancelAlarmAll__Fv */ -void my_OSCancelAlarmAll() { - /* Nonmatching */ -} +static void my_OSCancelAlarmAll() {} /* 80017D44-80017D7C .text destroyVideo__Fv */ void destroyVideo() { - /* Nonmatching */ + JUTVideo::destroyManager(); + GXSetDrawDoneCallback(NULL); + VISetBlack(1); + VIFlush(); + VIWaitForRetrace(); } +#if VERSION == VERSION_JP +int mDoRst::mResetFlag; +int mDoRst::mResetPrepare; +int mDoRst::m3ButtonResetFlag; +int mDoRst::m3ButtonResetPort = -1; +#else +mDoRstData* mDoRst::mResetData; +#endif + /* 80017D7C-80017E40 .text mDoRst_reset__FiUli */ -void mDoRst_reset(int, unsigned long, int) { - /* Nonmatching */ +void mDoRst_reset(int param_0, unsigned long param_1, int param_2) { + if (DVDGetDriveStatus() == DVD_STATE_FATAL_ERROR) { + do { + } while (true); + } + + JUTXfb::getManager()->clearIndex(); + mDoDvdErr_ThdCleanup(); + JUTGamePad::clearForReset(); + mDoAud_zelAudio_c::offInitFlag(); + +#if VERSION != VERSION_JP + VIWaitForRetrace(); + VIWaitForRetrace(); +#endif + + OSThread* gxThread = GXGetCurrentGXThread(); + s32 enable = OSDisableInterrupts(); + + if (gxThread != OSGetCurrentThread()) { + OSCancelThread(gxThread); + GXSetCurrentGXThread(); + } + + GXFlush(); + GXAbortFrame(); + GXDrawDone(); + OSRestoreInterrupts(enable); + destroyVideo(); + my_OSCancelAlarmAll(); + LCDisable(); +#if VERSION != VERSION_JP + OSSetSaveRegion(mDoRst::mResetData, (u8*)&mDoRst::getResetData + 0x10); +#endif + OSResetSystem(param_0, param_1, param_2); + + do { + VIWaitForRetrace(); + } while (true); } /* 80017E40-80017EF0 .text mDoRst_resetCallBack__FiPv */ -void mDoRst_resetCallBack(int, void*) { - /* Nonmatching */ -} - -/* 80017EF0-80017EF8 .text getResetData__6mDoRstFv */ -void mDoRst::getResetData() { - /* Nonmatching */ +void mDoRst_resetCallBack(int port, void*) { + if (!mDoRst::isReset()) { + if (port == -1) { + JUTGamePad::clearForReset(); + JUTGamePad::CRumble::setEnabled(0xF0000000); + } else { + if (mDoRst::is3ButtonReset()) { + JUTGamePad::C3ButtonReset::sResetOccurred = false; + JUTGamePad::C3ButtonReset::sCallback = mDoRst_resetCallBack; + JUTGamePad::C3ButtonReset::sCallbackArg = NULL; + return; + } + mDoRst::on3ButtonReset(); + mDoRst::set3ButtonResetPort(port); + JUTGamePad::clearForReset(); + JUTGamePad::CRumble::setEnabled(0xF0000000); + } +#if VERSION != VERSION_JP + if (DVDCheckDisk() == 0) { + mDoRst_reset(1, 0x80000000, 0); + } +#endif + mDoRst::onReset(); + } } diff --git a/src/m_Do/m_Do_machine_exception.cpp b/src/m_Do/m_Do_machine_exception.cpp index 906f76d65..ebeb36b0a 100644 --- a/src/m_Do/m_Do_machine_exception.cpp +++ b/src/m_Do/m_Do_machine_exception.cpp @@ -1,42 +1,104 @@ -// -// Generated by dtk -// Translation Unit: m_Do_machine_exception.cpp -// +/** + * m_Do_machine_exception.cpp + * Exception Print Functions + */ #include "m_Do/m_Do_machine_exception.h" -#include "dolphin/types.h" +#include "DynamicLink.h" +#include "JSystem/JFramework/JFWSystem.h" +#include "JSystem/JKernel/JKRAram.h" +#include "JSystem/JUtility/JUTConsole.h" +#include "d/d_com_inf_game.h" +#include "m_Do/m_Do_ext.h" +#include "m_Do/m_Do_main.h" + +static JUTConsole* sConsole; /* 8001BADC-8001BB68 .text print_f__FPCce */ -void print_f(const char*, ...) { - /* Nonmatching */ +void print_f(const char* fmt, ...) { + va_list args; + va_start(args, fmt); + JUTConsole_print_f_va_(sConsole, fmt, args); + va_end(args); } /* 8001BB68-8001BB90 .text print__FPCc */ -void print(const char*) { - /* Nonmatching */ +void print(const char* string) { + sConsole->print(string); } +static const char* unused_803396f8 = "--------------------------------------\n"; + /* 8001BB90-8001BCEC .text dispHeapInfo__Fv */ void dispHeapInfo() { - /* Nonmatching */ + JKRExpHeap* zelda = zeldaHeap; + JKRExpHeap* game = gameHeap; + JKRExpHeap* archive = archiveHeap; + + u32 zeldaFree = zelda->getFreeSize(); + u32 gameFree = game->getFreeSize(); + u32 archiveFree = archive->getFreeSize(); + u32 zeldaTotal = zelda->getTotalFreeSize(); + u32 gameTotal = game->getTotalFreeSize(); + u32 archiveTotal = archive->getTotalFreeSize(); + + print("-- Heap Free / TotalFree (KB) --\n"); + print_f(" Zelda %5d / %5d\n", zeldaFree / 1024, zeldaTotal / 1024); + print_f(" Game %5d / %5d\n", gameFree / 1024, gameTotal / 1024); + print_f("Archive %5d / %5d\n", archiveFree / 1024, archiveTotal / 1024); + print("--------------------------------\n"); + + if (JKRAram::getAramHeap()) { + JKRAram::getAramHeap()->dump(); + } + DynamicModuleControlBase::dump(); + g_dComIfG_gameInfo.mResControl.dump(); + + zelda->dump_sort(); + game->dump_sort(); + archive->dump_sort(); } /* 8001BCEC-8001BD30 .text dispGameInfo__Fv */ void dispGameInfo() { - /* Nonmatching */ + print_f("Start StageName:RoomNo [%s:%d]\n", dComIfGp_getStartStageName(), + dComIfGp_getStartStageRoomNo()); } /* 8001BD30-8001BE84 .text dispDateInfo__Fv */ void dispDateInfo() { - /* Nonmatching */ + print("------------- Date Infomation ---------\n"); + print(" FINAL VERSION\n"); + print("COMPILE USER: FINAL\n"); + print_f("COPYDATE : %17s\n", mDoMain::COPYDATE_STRING); + + OSCalendarTime time; + OSTicksToCalendarTime(mDoMain::sPowerOnTime, &time); + print_f("PowerOnTime: %04d/%2d/%2d %2d:%2d:%2d`%03d\"%03d\n", time.year, time.month, + time.day_of_month, time.hours, time.minutes, time.seconds, time.milliseconds, + time.microseconds); + + OSTicksToCalendarTime(mDoMain::sHungUpTime, &time); + print_f("HungUpTime : %04d/%2d/%2d %2d:%2d:%2d`%03d\"%03d\n", time.year, time.month, + time.day_of_month, time.hours, time.minutes, time.seconds, time.milliseconds, + time.microseconds); + + OSTicksToCalendarTime(mDoMain::sHungUpTime - mDoMain::sPowerOnTime, &time); + print_f("PlayTime : %4d days, %2d:%2d:%2d`%03d\"%03d\n", time.year_day, time.hours, + time.minutes, time.seconds, time.milliseconds, time.microseconds); + print("---------------------------------------\n"); } /* 8001BE84-8001BEAC .text dispConsoleToTerminal__Fv */ void dispConsoleToTerminal() { - /* Nonmatching */ + JFWSystem::getSystemConsole()->dumpToTerminal(0xFFFFFFFF); } /* 8001BEAC-8001BEDC .text exception_addition__FP10JUTConsole */ -void exception_addition(JUTConsole*) { - /* Nonmatching */ +void exception_addition(JUTConsole* pConsole) { + sConsole = pConsole; + dispHeapInfo(); + dispDateInfo(); + dispConsoleToTerminal(); + dispGameInfo(); }