Skip to content

Commit

Permalink
d_save fixes, d_a_andsw dComIfGp fix
Browse files Browse the repository at this point in the history
  • Loading branch information
magcius committed Sep 12, 2023
1 parent ec47c5a commit a5bf46f
Show file tree
Hide file tree
Showing 6 changed files with 88 additions and 49 deletions.
73 changes: 51 additions & 22 deletions include/d/d_com_inf_game.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ class dComIfG_play_c {
dStage_roomControl_c* getRoomControl() { return &mRoomCtrl; }
dStage_stageDt_c& getStage() { return mStageData; }
dEvt_control_c& getEvent() { return mEvtCtrl; }
dEvent_manager_c& getEvtManager() { return mEvtManager; }

const char* getStartStageName() { return mCurStage.getName(); }
s8 getStartStageRoomNo() { return mCurStage.getRoomNo(); }
Expand Down Expand Up @@ -148,7 +149,7 @@ class dComIfG_play_c {
/* 0x3EB0 */ dStage_stageDt_c mStageData;
/* 0x3F34 */ dStage_roomControl_c mRoomCtrl;
/* 0x3F38 */ dEvt_control_c mEvtCtrl;
/* 0x402C */ dEvent_manager_c mEventMgr;
/* 0x402C */ dEvent_manager_c mEvtManager;
/* 0x4568 */ dAttention_c mAttention;
/* 0x46F8 */ u8 field_0x46F8[0x4700 - 0x46F8];
/* 0x4700 */ dVibration_c mVibration;
Expand Down Expand Up @@ -310,7 +311,7 @@ class dComIfG_inf_c {

void ct();

/* 0x00000 */ dSv_info_c info;
/* 0x00000 */ dSv_info_c save;
/* 0x012A0 */ dComIfG_play_c play;
/* 0x05D1C */ dDlst_list_c drawlist;
/* 0x1BF50 */ u8 field_0x1BF50[0x1BFC0 - 0x1BF50];
Expand All @@ -330,83 +331,95 @@ extern dComIfG_inf_c g_dComIfG_gameInfo;
u8 dComIfGs_checkGetItem(u8);

inline u8 dComIfGs_getSelectEquip(int param_0) {
return g_dComIfG_gameInfo.info.getPlayer().getPlayerStatusA().getSelectEquip(param_0);
return g_dComIfG_gameInfo.save.getPlayer().getPlayerStatusA().getSelectEquip(param_0);
}

inline u8 dComIfGs_getItem(int param_0) {
return g_dComIfG_gameInfo.info.getPlayer().getItem().getItem(param_0);
return g_dComIfG_gameInfo.save.getPlayer().getItem().getItem(param_0);
}

inline void dComIfGs_setEventReg(u16 i_reg, u8 i_no) {
g_dComIfG_gameInfo.info.getEvent().setEventReg(i_reg, i_no);
g_dComIfG_gameInfo.save.getEvent().setEventReg(i_reg, i_no);
}

inline BOOL dComIfGs_isEventBit(u16 id) {
return g_dComIfG_gameInfo.info.getEvent().isEventBit(id);
return g_dComIfG_gameInfo.save.getEvent().isEventBit(id);
}

inline void dComIfGs_setRestartRoomParam(u32 i_param) {
g_dComIfG_gameInfo.info.getRestart().setRoomParam(i_param);
g_dComIfG_gameInfo.save.getRestart().setRoomParam(i_param);
}

inline void dComIfGs_setStartPoint(s16 i_point) {
g_dComIfG_gameInfo.info.getRestart().setStartPoint(i_point);
g_dComIfG_gameInfo.save.getRestart().setStartPoint(i_point);
}

inline int dComIfGs_getTriforceNum() {
return g_dComIfG_gameInfo.info.getPlayer().getCollect().getTriforceNum();
return g_dComIfG_gameInfo.save.getPlayer().getCollect().getTriforceNum();
}

inline u8 dComIfGs_getOptVibration() {
return g_dComIfG_gameInfo.info.getPlayer().getConfig().getVibration();
return g_dComIfG_gameInfo.save.getPlayer().getConfig().getVibration();
}

inline BOOL dComIfGs_isTbox(int i_no) {
return g_dComIfG_gameInfo.info.getMemory().getBit().isTbox(i_no);
return g_dComIfG_gameInfo.save.getMemory().getBit().isTbox(i_no);
}

inline BOOL dComIfGs_isSaveTbox(int i_stageNo, int i_no) {
return g_dComIfG_gameInfo.info.getSavedata().getSave(i_stageNo).getBit().isTbox(i_no);
return g_dComIfG_gameInfo.save.getSavedata().getSave(i_stageNo).getBit().isTbox(i_no);
}

inline void dComIfGs_onTbox(int i_no) {
g_dComIfG_gameInfo.info.getMemory().getBit().onTbox(i_no);
g_dComIfG_gameInfo.save.getMemory().getBit().onTbox(i_no);
}

inline void dComIfGs_onSaveTbox(int i_stageNo, int i_no) {
g_dComIfG_gameInfo.info.getSavedata().getSave(i_stageNo).getBit().onTbox(i_no);
g_dComIfG_gameInfo.save.getSavedata().getSave(i_stageNo).getBit().onTbox(i_no);
}

inline BOOL dComIfGs_isStageBossEnemy() {
return g_dComIfG_gameInfo.info.getMemory().getBit().isStageBossEnemy();
return g_dComIfG_gameInfo.save.getMemory().getBit().isStageBossEnemy();
}

inline void dComIfGs_onStageLife() {
g_dComIfG_gameInfo.info.getMemory().getBit().onStageLife();
g_dComIfG_gameInfo.save.getMemory().getBit().onStageLife();
}

inline BOOL dComIfGs_isStageLife() {
return g_dComIfG_gameInfo.info.getMemory().getBit().isStageLife();
return g_dComIfG_gameInfo.save.getMemory().getBit().isStageLife();
}

inline BOOL dComIfGs_isCollect(int i_idx, u8 i_item) {
return g_dComIfG_gameInfo.info.getPlayer().getCollect().isCollect(i_idx, i_item);
return g_dComIfG_gameInfo.save.getPlayer().getCollect().isCollect(i_idx, i_item);
}

inline void dComIfGs_onCollect(int i_idx, u8 i_item) {
g_dComIfG_gameInfo.info.getPlayer().getCollect().onCollect(i_idx, i_item);
g_dComIfG_gameInfo.save.getPlayer().getCollect().onCollect(i_idx, i_item);
}

inline BOOL dComIfGs_isTact(u8 i_no) {
return g_dComIfG_gameInfo.info.getPlayer().getCollect().isTact(i_no);
return g_dComIfG_gameInfo.save.getPlayer().getCollect().isTact(i_no);
}

inline BOOL dComIfGs_isTriforce(u8 i_no) {
return g_dComIfG_gameInfo.info.getPlayer().getCollect().isTriforce(i_no);
return g_dComIfG_gameInfo.save.getPlayer().getCollect().isTriforce(i_no);
}

inline BOOL dComIfGs_isSymbol(u8 i_no) {
return g_dComIfG_gameInfo.info.getPlayer().getCollect().isSymbol(i_no);
return g_dComIfG_gameInfo.save.getPlayer().getCollect().isSymbol(i_no);
}

inline void dComIfGs_onSwitch(int i_no, int i_roomNo) {
g_dComIfG_gameInfo.save.onSwitch(i_no, i_roomNo);
}

inline void dComIfGs_offSwitch(int i_no, int i_roomNo) {
g_dComIfG_gameInfo.save.offSwitch(i_no, i_roomNo);
}

inline BOOL dComIfGs_isSwitch(s32 i_no, s32 i_roomNo) {
return g_dComIfG_gameInfo.save.isSwitch(i_no, i_roomNo);
}

/**
Expand Down Expand Up @@ -492,6 +505,22 @@ inline daPy_lk_c* daPy_getPlayerLinkActorClass() {
return (daPy_lk_c*)g_dComIfG_gameInfo.play.getPlayerPtr(0);
}

/**
* === EVENT ===
*/

inline dEvent_manager_c& dComIfGp_getEventManager() {
return g_dComIfG_gameInfo.play.getEvtManager();
}

inline u32 dComIfGp_evmng_getEventIdx(char *pName, u8 evNo) {
return dComIfGp_getEventManager().getEventIdx(pName, evNo);
}

inline BOOL dComIfGp_evmng_endCheck(s16 eventID) {
return g_dComIfG_gameInfo.play.getEvtManager().endCheck(eventID);
}

/**
* === DRAWLIST ===
*/
Expand Down
2 changes: 1 addition & 1 deletion include/d/d_save.h
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ STATIC_ASSERT(sizeof(dSv_player_info_c) == 0x5C);
class dSv_player_config_c {
public:
/* 8005BF2C */ void init();
/* 8005BFA4 */ void checkVibration();
/* 8005BFA4 */ s32 checkVibration();

u8 getVibration() const { return mVibration; }

Expand Down
2 changes: 1 addition & 1 deletion include/d/d_stage.h
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,7 @@ class dStage_roomControl_c {
static void setStayNo(int);
static s8 GetTimePass();
static void setZoneNo(int, int);
static int getZoneNo(int);
static int getZoneNo(int i_roomNo);

static s8 getStayNo() { return mStayNo; }
static s8 getMemoryBlockID(int i_roomNo) { return mStatus[i_roomNo].mMemBlockID; }
Expand Down
2 changes: 1 addition & 1 deletion include/f_op/f_op_actor_mng.h
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ inline f32 fopAcM_getCullSizeSphereR(const fopAc_ac_c* i_actor) {

inline void dComIfGs_onSwitch(int i_no, int i_roomNo);
inline void dComIfGs_offSwitch(int i_no, int i_roomNo);
inline BOOL dComIfGs_isSwitch(int i_no, int i_roomNo);
inline BOOL dComIfGs_isSwitch(s32 i_no, s32 i_roomNo);
inline void dComIfGs_offActor(int i_no, int i_roomNo);

inline void i_fopAcM_onSwitch(const fopAc_ac_c* pActor, int sw) {
Expand Down
20 changes: 10 additions & 10 deletions src/d/actor/d_a_andsw2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ BOOL daAndsw2_c::chkAllSw2() {
return false;
}
for (int i = 0; i < num; i++) {
if (!g_dComIfG_gameInfo.info.isSwitch(topSw+i, getRoomNo())) {
if (!dComIfGs_isSwitch(topSw+i, getRoomNo())) {
return false;
}
}
Expand All @@ -115,7 +115,7 @@ static s32 daAndsw2_actionOnAll(daAndsw2_c* i_this) {
} else {
int room = i_this->getRoomNo();
int sw = i_this->getSwbit();
g_dComIfG_gameInfo.info.onSwitch(sw, room);
dComIfGs_onSwitch(sw, room);

if (i_this->getType() == TYPE_CONTINUOUS) {
i_this->mAction = ACT_OFF;
Expand All @@ -138,7 +138,7 @@ static s32 daAndsw2_actionTimer(daAndsw2_c* i_this) {
} else {
int room = i_this->getRoomNo();
int sw = i_this->getSwbit();
g_dComIfG_gameInfo.info.onSwitch(sw, room);
dComIfGs_onSwitch(sw, room);

if (i_this->getType() == TYPE_CONTINUOUS) {
i_this->mAction = ACT_WAIT;
Expand All @@ -153,7 +153,7 @@ static s32 daAndsw2_actionOrder(daAndsw2_c* i_this) {
i_this->mAction = ACT_EVENT;
int room = i_this->getRoomNo();
int sw = i_this->getSwbit();
g_dComIfG_gameInfo.info.onSwitch(sw, room);
dComIfGs_onSwitch(sw, room);
} else if (i_this->getType() == TYPE_CONTINUOUS && !i_this->chkAllSw2()) {
i_this->mAction = ACT_ON_ALL;
} else {
Expand All @@ -165,7 +165,7 @@ static s32 daAndsw2_actionOrder(daAndsw2_c* i_this) {
/* 00000438-000004BC .text daAndsw2_actionEvent__FP10daAndsw2_c */
static s32 daAndsw2_actionEvent(daAndsw2_c* i_this) {
dComIfG_play_c* play = &g_dComIfG_gameInfo.play;
if (play->mEventMgr.endCheck(i_this->mEventIdx)) {
if (dComIfGp_evmng_endCheck(i_this->mEventIdx)) {
if (i_this->getType() == TYPE_CONTINUOUS) {
i_this->mAction = ACT_OFF;
} else {
Expand All @@ -182,7 +182,7 @@ static s32 daAndsw2_actionOff(daAndsw2_c* i_this) {
i_this->mAction = ACT_ON_ALL;
int room = i_this->getRoomNo();
int sw = i_this->getSwbit();
g_dComIfG_gameInfo.info.offSwitch(sw, room);
dComIfGs_offSwitch(sw, room);
}
return 1;
}
Expand Down Expand Up @@ -212,27 +212,27 @@ s32 daAndsw2_c::create() {

switch (getType()) {
case TYPE_ONE_OFF:
if (sw == 0xFF || g_dComIfG_gameInfo.info.isSwitch(sw, getRoomNo())) {
if (sw == 0xFF || dComIfGs_isSwitch(sw, getRoomNo())) {
// Switch invalid or already set.
mAction = ACT_WAIT;
} else {
// Switch not yet set, check for the condition to be met.
mAction = ACT_ON_ALL;
}
mEventIdx = g_dComIfG_gameInfo.play.mEventMgr.getEventIdx(NULL, getEventNo());
mEventIdx = dComIfGp_evmng_getEventIdx(NULL, getEventNo());
break;
case TYPE_CONTINUOUS:
if (sw == 0xFF) {
// Switch invalid.
mAction = ACT_WAIT;
} else if (g_dComIfG_gameInfo.info.isSwitch(sw, getRoomNo())) {
} else if (dComIfGs_isSwitch(sw, getRoomNo())) {
// Switch already set, wait for the condition to no longer be met.
mAction = ACT_OFF;
} else {
// Switch not yet set, check for the condition to be met.
mAction = ACT_ON_ALL;
}
mEventIdx = g_dComIfG_gameInfo.play.mEventMgr.getEventIdx(NULL, getEventNo());
mEventIdx = dComIfGp_evmng_getEventIdx(NULL, getEventNo());
break;
default:
// Invalid type, do nothing.
Expand Down
38 changes: 24 additions & 14 deletions src/d/d_save.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@
#include "d/d_save.h"
#include "d/d_save_init.h"
#include "d/d_com_inf_game.h"
#include "d/d_item_data.h"
#include "d/d_stage.h"
#include "JSystem/JUtility/JUTAssert.h"
#include "JSystem/JUtility/JUTGamePad.h"
#include "MSL_C/string.h"
#include "SSystem/SComponent/c_lib.h"
#include "SSystem/SComponent/c_math.h"
Expand Down Expand Up @@ -67,7 +70,7 @@ void dSv_player_status_a_c::init() {
case 29:
case 30:
case 31:
item = g_dComIfG_gameInfo.info.getPlayer().mGetItem.mItemFlags[item_idx + 13];
item = g_dComIfG_gameInfo.save.getPlayer().mGetItem.mItemFlags[item_idx + 13];
break;
case 32:
case 33:
Expand All @@ -82,7 +85,7 @@ void dSv_player_status_a_c::init() {
case 41:
case 42:
case 43:
item = g_dComIfG_gameInfo.info.getPlayer().mGetItem.mItemFlags[item_idx + 9];
item = g_dComIfG_gameInfo.save.getPlayer().mGetItem.mItemFlags[item_idx + 9];
break;
case 44:
case 45:
Expand All @@ -97,7 +100,7 @@ void dSv_player_status_a_c::init() {
case 53:
case 54:
case 55:
item = g_dComIfG_gameInfo.info.getPlayer().mGetItem.mItemFlags[item_idx + 5];
item = g_dComIfG_gameInfo.save.getPlayer().mGetItem.mItemFlags[item_idx + 5];
break;
}

Expand Down Expand Up @@ -352,13 +355,23 @@ void dSv_player_item_record_c::init() {
}

/* 8005987C-80059894 .text resetTimer__24dSv_player_item_record_cFUs */
void dSv_player_item_record_c::resetTimer(u16) {
/* Nonmatching */
void dSv_player_item_record_c::resetTimer(u16 timer) {
mTimer = timer;
g_dComIfG_gameInfo.play.field_0x4956 = 0;
}

/* 80059894-800598D0 .text decTimer__24dSv_player_item_record_cFv */
void dSv_player_item_record_c::decTimer() {
/* Nonmatching */
if (g_dComIfG_gameInfo.play.field_0x4956 != 1)
return;

if (mTimer != 0) {
mTimer--;
return;
}

mTimer = 0;
g_dComIfG_gameInfo.play.field_0x4956 = 0;
}

/* 800598D0-800598D8 .text getTimer__24dSv_player_item_record_cFv */
Expand Down Expand Up @@ -815,8 +828,11 @@ void dSv_player_config_c::init() {
}

/* 8005BFA4-8005BFC8 .text checkVibration__19dSv_player_config_cFv */
void dSv_player_config_c::checkVibration() {
/* Nonmatching */
s32 dSv_player_config_c::checkVibration() {
if (JUTGamePad::sRumbleSupported)
return g_dComIfG_gameInfo.play.field_0x4963;

return 0;
}

/* 8005BFC8-8005BFD4 .text init__19dSv_player_priest_cFv */
Expand Down Expand Up @@ -867,7 +883,6 @@ void dSv_memBit_c::init() {
mVisitedRoom[i] = 0;
}

field_0x20 = 0;
mDungeonItem = 0;
}

Expand Down Expand Up @@ -1265,11 +1280,6 @@ void dSv_info_c::onSwitch(int i_no, int i_roomNo) {
}
}

/* 8005DCD0-8005DCEC .text getZoneNo__20dStage_roomControl_cFi */
int dStage_roomControl_c::getZoneNo(int param_0) {
/* Nonmatching */
}

/* 8005DCEC-8005DE98 .text offSwitch__10dSv_info_cFii */
void dSv_info_c::offSwitch(int i_no, int i_roomNo) {
JUT_ASSERT(3448,
Expand Down

0 comments on commit a5bf46f

Please sign in to comment.