mirror of
https://github.com/zeldaret/tww.git
synced 2026-07-27 22:59:24 -04:00
d_seafightgame, m_Do_machine_exception, m_Do_reset, m_Do_DVDError OK (#41)
* m_Do_machine_exception OK * m_Do_Reset OK * m_Do_DVDError OK * some fixes for JP * JP OK again * d_seafightgame OK * cleanup m_Do_Reset a bit
This commit is contained in:
@@ -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 */
|
||||
|
||||
+111
-11
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
+88
-18
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user