Skip to content

Commit

Permalink
m_Do_MemCardRWmng work
Browse files Browse the repository at this point in the history
  • Loading branch information
magcius committed Jul 14, 2024
1 parent 2a958f1 commit 0614e8c
Show file tree
Hide file tree
Showing 9 changed files with 265 additions and 29 deletions.
4 changes: 4 additions & 0 deletions include/JSystem/JKernel/JKRAram.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@ inline u8* JKRAramToMainRam(u32 p1, u8* p2, u32 p3, JKRExpandSwitch p4, u32 p5,
return JKRAram::aramToMainRam(p1, p2, p3, p4, p5, p6, p7, p8);
}

inline u8* JKRAramToMainRam(JKRAramBlock* block, u8* dst, u32 size, u32 p4 = 0, JKRExpandSwitch expandSwitch = EXPAND_SWITCH_UNKNOWN0, u32 p5 = 0, JKRHeap* heap = NULL, int p6 = -1, u32* p7 = 0) {
return JKRAram::aramToMainRam(block, dst, size, p4, expandSwitch, p5, heap, p6, p7);
}

inline JKRAramBlock *JKRMainRamToAram(u8 *buf, u32 bufSize, u32 alignedSize, JKRExpandSwitch expandSwitch, u32 fileSize, JKRHeap *heap, int id) {
return JKRAram::mainRamToAram(buf, bufSize, alignedSize, expandSwitch, fileSize, heap, id);
}
Expand Down
9 changes: 9 additions & 0 deletions include/d/d_com_inf_game.h
Original file line number Diff line number Diff line change
Expand Up @@ -504,6 +504,7 @@ class dComIfG_play_c {

JKRAramBlock* getPictureBoxData(int i) { return mPictureBoxData[i]; }
void setPictureBoxData(JKRAramBlock* aramBlock, int i) { mPictureBoxData[i] = aramBlock; }
bool isPictureFlag(u8 i) { return mPictureFlag & (1 << i); }
void offPictureFlag(u8 i) {
u8 mask = (1 << i);
mPictureFlag &= ~mask;
Expand Down Expand Up @@ -1199,6 +1200,10 @@ inline void dComIfGs_setTurnRestart(const cXyz& i_pos, s16 i_angle, s8 i_roomNo,
g_dComIfG_gameInfo.save.getTurnRestart().set(i_pos, i_angle, i_roomNo, i_param, i_shipPos, i_shipAngle, i_hasShip);
}

inline u8 dComIfGs_getDataNum() {
g_dComIfG_gameInfo.save.getDataNum();
}

inline u8 dComIfGs_getPlayerPriestFlag() {
return g_dComIfG_gameInfo.save.getPlayer().getPriest().getFlag();
}
Expand Down Expand Up @@ -2617,6 +2622,10 @@ inline void dComIfGp_setPictureBoxData(JKRAramBlock* aramBlock, int i) {
g_dComIfG_gameInfo.play.setPictureBoxData(aramBlock, i);
}

inline bool dComIfGp_isPictureFlag(u8 i) {
g_dComIfG_gameInfo.play.isPictureFlag(i);
}

inline void dComIfGp_offPictureFlag(u8 i) {
g_dComIfG_gameInfo.play.offPictureFlag(i);
}
Expand Down
6 changes: 3 additions & 3 deletions include/d/d_save.h
Original file line number Diff line number Diff line change
Expand Up @@ -813,11 +813,11 @@ class dSv_info_c {
void removeZone(int zoneNo) { mZone[zoneNo].reset(); }
void initDan(s8 i_stage) { mDan.init(i_stage); }

void getDataNum() {}
u8 getDataNum() { return mDataNum; }
void getMemCardCheckID() {}
void getNewFile() {}
void getNoFile() {}
void setDataNum(u8) {}
void setDataNum(u8 num) { mDataNum = num; }
void setMemCardCheckID(u64) {}
void setNewFile(u8) {}
void setNoFile(u8) {}
Expand All @@ -838,7 +838,7 @@ class dSv_info_c {
/* 0x1128 */ dSv_restart_c mRestart;
/* 0x1158 */ dSv_event_c mTmp;
/* 0x1258 */ dSv_turnRestart_c mTurnRestart;
/* 0x1290 */ u8 field_0x1290;
/* 0x1290 */ u8 mDataNum;
/* 0x1291 */ u8 field_0x1291;
/* 0x1292 */ u8 field_0x1292;
/* 0x1298 */ s64 field_0x1298;
Expand Down
34 changes: 34 additions & 0 deletions include/dolphin/card.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,36 @@ struct CARDFileInfo {
/* 0x12 */ u16 __padding;
};

struct CARDStat {
u8 fileName[32];
u32 dataLength;
u32 lastModified;
u8 gameCode[4];
u8 company[2];

u8 bannerFmt;
u32 iconAddr;
u16 iconFormat;
u16 iconSpeed;
u32 commentAddr;

u32 offsetBanner;
u32 offsetBannerTlut;
u32 offsetIcon[8];
u32 offsetIconTlut;
u32 offsetData;
};

#define CARDGetBannerFormat(stat) ((stat)->bannerFmt & 0x03)
#define CARDGetIconAnim(stat) ((stat)->bannerFmt & 0x04)
#define CARDGetIconFormat(stat, n) ((stat)->iconFormat >> (2 * (n)) & 0x03)
#define CARDGetIconSpeed(stat, n) ((stat)->iconSpeed >> (2 * (n)) & 0x03)

#define CARDSetBannerFormat(stat, v) ((stat)->bannerFmt = (u8)(((stat)->bannerFmt & ~0x03) | (v)))
#define CARDSetIconAnim(stat, v) ((stat)->bannerFmt = (u8)(((stat)->bannerFmt & ~0x04) | (v)))
#define CARDSetIconFormat(stat, n, v) ((stat)->iconFormat = (u16)(((stat)->iconFormat & ~(0x03 << (2 * (n)))) | ((v) << (2 * (n)))))
#define CARDSetIconSpeed(stat, n, v) ((stat)->iconSpeed = (u16)(((stat)->iconSpeed & ~(0x03 << (2 * (n)))) | ((v) << (2 * (n)))))

enum {
CARD_ERROR_UNLOCKED = 1,
CARD_ERROR_READY = 0,
Expand All @@ -38,6 +68,8 @@ enum {

void CARDInit();
BOOL CARDProbe(s32);
s32 CARDGetStatus(s32, s32, CARDStat*);
s32 CARDSetStatus(s32, s32, CARDStat*);
s32 CARDOpen(s32, const char*, CARDFileInfo*);
s32 CARDClose(CARDFileInfo*);
s32 CARDCreate(s32, const char*, s32, CARDFileInfo*);
Expand All @@ -47,6 +79,8 @@ s32 CARDUnmount(s32);
s32 CARDMount(s32, void*, void*);
s32 CARDCheck(s32);
s32 CARDFreeBlocks(s32, s32*, s32*);
s32 CARDRead(CARDFileInfo*, void*, s32, s32);
s32 CARDWrite(CARDFileInfo*, const void*, s32, s32);

#ifdef __cplusplus
}
Expand Down
2 changes: 1 addition & 1 deletion include/m_Do/m_Do_MemCard.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class mDoMemCd_Ctrl_c {

/* 0x0000 */ u8 mData[0x1650];
/* 0x1650 */ s32 mCardCommand;
/* 0x1654 */ s32 mCardState;
/* 0x1654 */ u8* mCardBuf;
/* 0x1658 */ u8 mCardSlot;
/* 0x1659 */ u8 field_0x1659;
/* 0x165A */ u8 field_0x165A;
Expand Down
10 changes: 5 additions & 5 deletions include/m_Do/m_Do_MemCardRWmng.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ s32 mDoMemCdRWm_Restore2(CARDFileInfo*);
#endif
void mDoMemCdRWm_BuildHeader(mDoMemCdRWm_HeaderData*);
void mDoMemCdRWm_SetCardStat(CARDFileInfo*);
void mDoMemCdRWm_CheckCardStat(CARDFileInfo*);
void mDoMemCdRWm_CalcCheckSum(void*, u32);
void mDoMemCdRWm_CalcCheckSumPictData(void*, u32);
BOOL mDoMemCdRWm_CheckCardStat(CARDFileInfo*);
u32 mDoMemCdRWm_CalcCheckSum(void*, u32);
u16 mDoMemCdRWm_CalcCheckSumPictData(void*, u32);
BOOL mDoMemCdRWm_TestCheckSumPictData(void*);
void mDoMemCdRWm_SetCheckSumPictData(u8*);
void mDoMemCdRWm_CalcCheckSumGameData(void*, u32);
void mDoMemCdRWm_TestCheckSumGameData(void*);
unsigned long long mDoMemCdRWm_CalcCheckSumGameData(void*, u32);
BOOL mDoMemCdRWm_TestCheckSumGameData(void*);
void mDoMemCdRWm_SetCheckSumGameData(u8*, u8);

#endif /* M_DO_M_DO_MEMCARDRWMNG_H */
2 changes: 1 addition & 1 deletion include/m_Do/m_Do_dvd_thread.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ typedef void* (*mDoDvdThd_callback_func)(void*);

class mDoDvdThd_command_c : public node_class {
public:
/* 0x0C */ bool mIsDone;
/* 0x0C */ volatile bool mIsDone;
/* 0x10 vtable*/
public:
virtual ~mDoDvdThd_command_c();
Expand Down
2 changes: 1 addition & 1 deletion src/m_Do/m_Do_MemCard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ mDoMemCd_Ctrl_c::mDoMemCd_Ctrl_c() {
void mDoMemCd_Ctrl_c::ThdInit() {
CARDInit();
mCardCommand = 0;
mCardState = 0;
mCardBuf = NULL;
field_0x1659 = 0;
field_0x165A = 2;
field_0x1660 = CARD_NO_COMMAND;
Expand Down
Loading

0 comments on commit 0614e8c

Please sign in to comment.