Exact match (23/23, diffs 0). DOL SHA1 26116613f624061ba99c8d1a299aaa6efa85670d. Adds ChannelSlot/ChannelPage overlays (slots at +0x30, page stride 0xC0) so the loop uses typed .valid/.titleId instead of raw byte loads.
205 lines
6.8 KiB
C++
205 lines
6.8 KiB
C++
#ifndef IPL_SAVE_DATA_MANAGER_H
|
|
#define IPL_SAVE_DATA_MANAGER_H
|
|
|
|
#include <private/es.h>
|
|
#include <revolution.h>
|
|
#include <revolution/net/NETDigest.h>
|
|
|
|
#include <egg/core.h>
|
|
|
|
#include "system/iplChannelManager.h"
|
|
|
|
#include "keyboard/tiSaveData.h"
|
|
#include "system/iplNand.h"
|
|
|
|
#define SAVEDATA_VERSION 3
|
|
|
|
namespace ipl {
|
|
#ifdef IPL_SD_CHANNEL_SELECT_ACCESS
|
|
namespace scene {
|
|
class SDChannelSelect;
|
|
}
|
|
#endif
|
|
namespace channel {
|
|
class Manager;
|
|
}
|
|
namespace savedata {
|
|
extern "C" BOOL isTitleCached(void* manager, ESTitleId titleId);
|
|
|
|
struct ChannelSlot {
|
|
u8 valid; // 0x00 (primaryType)
|
|
u8 pad[3]; // 0x01
|
|
s32 titleId; // 0x04 (sceneID)
|
|
u8 rest[8]; // 0x08
|
|
};
|
|
|
|
struct ChannelPage {
|
|
u8 pad[0x30];
|
|
ChannelSlot slots[MAX_CHANNEL_INDEX]; // 0x30
|
|
};
|
|
|
|
class Manager {
|
|
public:
|
|
Manager(EGG::Heap* heap);
|
|
virtual ~Manager();
|
|
|
|
void initManager();
|
|
|
|
void setPrevPage(int prevPage);
|
|
#ifdef IPL_SD_CHANNEL_TITLE_CPP
|
|
int& getSDPrevPage() { return mData.prevSDPage; }
|
|
#endif
|
|
void setChanInfo(int page, int index, const channel::SInfo& chanInfo);
|
|
void setMemoSetting(const textinput::extend::savedata::MemoSetting& memoSetting);
|
|
|
|
nand::File* flushAsync(EGG::Heap* flushHeap);
|
|
|
|
ESTitleId hasChannel(ESTitleId titleId, int* outIndex = NULL, int* outPage = NULL) const;
|
|
|
|
int getNumValidChannel() const;
|
|
|
|
BOOL isFinished(nand::File* file);
|
|
BOOL isResetAcceptable();
|
|
|
|
void setDefaultSaveData();
|
|
void updateVersion(u32 newVersion, u32 oldVersion);
|
|
|
|
BOOL updateChanInfos();
|
|
|
|
void setLastPrevPage(int page) { mLastPrevPage = page; }
|
|
|
|
int getPrevPage() { return mLastPrevPage; }
|
|
|
|
#ifdef IPL_SD_CHANNEL_SELECT_ACCESS
|
|
int getLastSDPrevPage() { return mLastSDPrevPage; }
|
|
void setLastSDPrevPage(int page) { mLastSDPrevPage = page; }
|
|
BOOL didntGotoSDMenu() const { return mData.didntGotoSDMenu; }
|
|
void setDidntGotoSDMenu(BOOL value) { mData.didntGotoSDMenu = value; }
|
|
#endif
|
|
|
|
#ifdef IPL_SDMEMORY_TITLE_CACHE_ACCESS
|
|
const ESTitleId* getTitleCache() const { return &mData.titleCache[0][0]; }
|
|
ESTitleId getTitleCacheEntry(int index) const { return (&mData.titleCache[0][0])[index]; }
|
|
#endif
|
|
#ifdef IPL_SD_CHANNEL_SELECT_CPP
|
|
ESTitleId getCachedTitle(int index) const {
|
|
if (index < 0 || index >= MAX_CHANNEL_TOTAL) {
|
|
return 0;
|
|
}
|
|
return (&mData.titleCache[0][0])[index];
|
|
}
|
|
#endif
|
|
|
|
bool hasPhotoMP3Dummy() { return mbPhotoMP3; }
|
|
bool hasPhoto2Title() { return mbPhoto2; }
|
|
bool hasPhoto2DummyCheck() { return mbPhoto2Check; }
|
|
|
|
ESTitleId getPhotoID() { return mPhotoId; }
|
|
|
|
channel::SInfo& getChanInfo(int page, int index) { return mData.chanInfo[page][index]; }
|
|
textinput::extend::savedata::MemoSetting getMemoSetting() { return mData.memoSetting; }
|
|
|
|
void pushTitleCache(ESTitleId titleId);
|
|
|
|
private:
|
|
#ifdef IPL_SD_CHANNEL_SELECT_ACCESS
|
|
friend class ipl::scene::SDChannelSelect;
|
|
#endif
|
|
BOOL checkValidApp(ESTitleId titleId);
|
|
|
|
static void initManagerTask(void* work);
|
|
static void initManagerTask_();
|
|
|
|
void setDefaultHeader();
|
|
void setDefaultSDMenu();
|
|
void setDefaultKeyboard();
|
|
void setDefaultTVRC();
|
|
|
|
void deleteInvalidTitle(ESTitleId* titleIds, u32 titleCount);
|
|
void checkSpecialTitles(ESTitleId* titleIds, u32 titleCount);
|
|
void checkTmpTitle(ESTitleId* titleIds, u32 titleCount);
|
|
|
|
int getAvailableInList(const ESTitleId* titleIds, u32 titleCount);
|
|
int getAvailableNumInList(const ESTitleId* titleIds, u32 titleCount);
|
|
|
|
int isEqualChannel(ESTitleId titleId0, ESTitleId titleId1);
|
|
int isDefaultChannel(ESTitleId32 titleType, ESTitleId32 titleCode);
|
|
|
|
void makePriorTitleIDList(ESTitleId* titleIdsOut, ESTitleId* titleIdsIn, u32 titleCount);
|
|
void integrateTitleIDList(ESTitleId* titleIdsOut, ESTitleId* titleIdsIn, u32 titleCount);
|
|
void makeTmpList(ESTitleId* titleIdsOut, u32 availableCount, ESTitleId* titleIdsIn, u32 titleCount);
|
|
void moveTitleTmpToPrior(ESTitleId* titleIdsOut, const ESTitleId* titleIdsIn);
|
|
|
|
BOOL doUpdateChanInfos(ESTitleId* titleIds);
|
|
|
|
BOOL nand_error_handling(int code);
|
|
|
|
/**
|
|
* VERSION HISTORY
|
|
* ===============
|
|
* Version 1 - Initial version
|
|
* Version 2 - Same as version 1 but memoSetting is initialized differently.
|
|
* Version 3 - Add SD Card menu save data and `titleCache`
|
|
*/
|
|
// CURRENT VERSION IS 3 !!
|
|
typedef struct Data {
|
|
// Meta data
|
|
u8 sig[4]; // 0x00 (Always `RIPL`)
|
|
u32 fileSize; // 0x04
|
|
u32 version; // 0x08
|
|
|
|
// Channel related
|
|
int prevPage; // 0x0C
|
|
channel::SInfo chanInfo[MAX_CHANNEL_PAGE][MAX_CHANNEL_INDEX]; // 0x10
|
|
|
|
// Keyboard
|
|
textinput::extend::savedata::MemoSetting memoSetting; // 0x310
|
|
|
|
// TVRC Data
|
|
u8 tvrcData[4]; // 0x318
|
|
|
|
/* VERSION 3 DATA */
|
|
|
|
BOOL didntGotoSDMenu; // 0x31C
|
|
ESTitleId titleCache[MAX_CHANNEL_PAGE][MAX_CHANNEL_INDEX]; // 0x320
|
|
int prevSDPage; // 0x4A0
|
|
|
|
/* END OF VERSION 3 DATA */
|
|
|
|
u8 padding[0x0C]; // 0x4A4
|
|
|
|
// Sums
|
|
u8 MD5Sum[NET_MD5_DIGEST_SIZE]; // 0x4B0
|
|
} Data;
|
|
|
|
EGG::Heap* mpHeap; // 0x04
|
|
u8 unused_0x08[24];
|
|
|
|
Data mData; // 0x20
|
|
|
|
int mLastPrevPage; // 0x4E0
|
|
int mLastSDPrevPage; // 0x4E4
|
|
bool mbBadSDPrevPage; // 0x4E8
|
|
|
|
nand::File* mpFile; // 0x4EC
|
|
nand::File* mpUpdatedFile; // 0x4F0
|
|
|
|
bool mbInit; // 0x4F4
|
|
|
|
bool mbPhoto2; // 0x4F5
|
|
bool mbPhoto2Check; // 0x4F6
|
|
bool mbPhotoMP3; // 0x4F7
|
|
ESTitleId mPhotoId; // 0x4F8
|
|
|
|
int mLastError; // 0x500
|
|
|
|
u8 unused_0x504[28];
|
|
|
|
friend class channel::Manager;
|
|
friend BOOL isTitleCached(void* manager, ESTitleId titleId);
|
|
};
|
|
} // namespace savedata
|
|
} // namespace ipl
|
|
|
|
#endif // IPL_SAVE_DATA_MANAGER_H
|