diff options
| author | Dylan Ascencio <empressglatia@gmail.com> | 2023-09-16 18:13:11 -0400 |
|---|---|---|
| committer | Dylan Ascencio <empressglatia@gmail.com> | 2023-09-16 18:13:11 -0400 |
| commit | e940e4f4e0961aaa01c687dbfd96fdb6dec02cfe (patch) | |
| tree | d22f3e7228cf89ac7152517c98149b4778c6db04 /src/d | |
| parent | 331847e88ff809875cb2b643e8434a3a10b7446e (diff) | |
| parent | f0cc6a9bef1422bb5d63cfe452772a76499ea0fd (diff) | |
Merge remote-tracking branch 'upstream/main'
Diffstat (limited to 'src/d')
| -rw-r--r-- | src/d/actor/d_a_mgameboard.cpp | 2 | ||||
| -rw-r--r-- | src/d/actor/d_a_obj_Ygush00.cpp | 2 | ||||
| -rw-r--r-- | src/d/actor/d_a_obj_movebox.cpp | 12 | ||||
| -rw-r--r-- | src/d/d_seafightgame.cpp | 122 |
4 files changed, 119 insertions, 19 deletions
diff --git a/src/d/actor/d_a_mgameboard.cpp b/src/d/actor/d_a_mgameboard.cpp index 5c61997f..42f1c0a4 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/actor/d_a_obj_Ygush00.cpp b/src/d/actor/d_a_obj_Ygush00.cpp index de58d71f..f7359fe7 100644 --- a/src/d/actor/d_a_obj_Ygush00.cpp +++ b/src/d/actor/d_a_obj_Ygush00.cpp @@ -128,7 +128,7 @@ bool daObjYgush00_c::_execute() { fopAcM_seStartCurrent(this, 0x61fe, 0); } } else { - mpGryw00 = (daObjGryw00_c*)i_fopAcM_SearchByName(PROC_Obj_Gryw00); + mpGryw00 = (daObjGryw00_c*)fopAcM_SearchByName(PROC_Obj_Gryw00); } } else { fopAcM_seStartCurrent(this, 0x61fe, 0); diff --git a/src/d/actor/d_a_obj_movebox.cpp b/src/d/actor/d_a_obj_movebox.cpp index 9c2a226f..4f64281d 100644 --- a/src/d/actor/d_a_obj_movebox.cpp +++ b/src/d/actor/d_a_obj_movebox.cpp @@ -127,12 +127,12 @@ namespace daObjMovebox { s32 prm_get_buoy() const { return daObj::PrmAbstract(this, PRM_BUOY_W, PRM_BUOY_S); } s32 prm_get_dmy() const; // Unused? - BOOL is_switch1() const { return fopAcM_isSwitch(this, prm_get_swSave1()); }; - BOOL is_switch2() const { return fopAcM_isSwitch(this, prmZ_get_swSave2()); }; - void on_switch1() const { fopAcM_onSwitch(this, prm_get_swSave1()); }; - void on_switch2() const { fopAcM_onSwitch(this, prmZ_get_swSave2()); }; - void off_switch1() const { fopAcM_offSwitch(this, prm_get_swSave1()); }; - void off_switch2() const { fopAcM_offSwitch(this, prmZ_get_swSave2()); }; + BOOL is_switch1() const { return fopAcM_isSwitch((Act_c*)this, prm_get_swSave1()); }; + BOOL is_switch2() const { return fopAcM_isSwitch((Act_c*)this, prmZ_get_swSave2()); }; + void on_switch1() const { fopAcM_onSwitch((Act_c*)this, prm_get_swSave1()); }; + void on_switch2() const { fopAcM_onSwitch((Act_c*)this, prmZ_get_swSave2()); }; + void off_switch1() const { fopAcM_offSwitch((Act_c*)this, prm_get_swSave1()); }; + void off_switch2() const { fopAcM_offSwitch((Act_c*)this, prmZ_get_swSave2()); }; void prmZ_init(); void prmX_init(); diff --git a/src/d/d_seafightgame.cpp b/src/d/d_seafightgame.cpp index 6ce5faf5..a3127abf 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; +} |
