1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
|
#ifndef FILE_MANAGER_H
#define FILE_MANAGER_H
#include "common.h"
#include "d/a/d_a_itembase.h"
#include "egg/core/eggHeap.h"
#include "m/m_angle.h"
#include "m/m_vec.h"
#include "toBeSorted/nand_request_thread.h"
#include "toBeSorted/save_file.h"
#include "toBeSorted/save_manager.h"
enum SAVE_ITEM_ID {
};
class SkipData {
public:
/** 0x00 */ u16 data[16];
/** 0x20 */ u32 crc;
};
class SavedSaveFiles {
public:
/* 0x0000 */ char regionCode[4];
/* 0x0004 */ u8 unk1[0x1C - 0x04];
/* 0x001C */ u32 m_0x1C;
/* 0x0020 */ SaveFile saveFiles[3];
/* 0xfb60 */ SkipData skipData[3];
/* 0xfbcc */ u8 unk2[0xfbe0 - 0xfbcc];
};
class FileManager {
public:
/* 0x0000 */ SavedSaveFiles *mpSavedSaveFiles;
/* 0x0004 */ SkipData *mpSkipData; // skip data Arrary (3 entries )
/* 0x0008 */ SaveFile mFileA;
/* 0x53C8 */ SaveFile mFileB;
/* 0xA788 */ SkipData mSkipData;
/* 0xA7AC */ wchar_t mHeroNames[3][9]; // each name is 9 wchars
/* 0xA7E2 */ wchar_t mHeroName[9]; // The current Hero Name
/* 0xA7F4 */ char mCurrentArea[32];
/* 0xA814 */ u32 m_0xA814;
/* 0xA818 */ s64 mPlayTime[3];
/* 0xA830 */ s16 mCurrentHealth[3];
/* 0xA836 */ s16 mCurrentHealthCapacity[3];
/* 0xA83C */ u8 mSelectedFile;
/* 0xA83D */ u8 mIsFileEmpty[3];
/* 0xA840 */ u8 mIsFileUnk1[3];
/* 0xA843 */ u8 mIsFileInvalid[3];
/* 0xA846 */ u8 mIsFileDataDirty[3];
/* 0xA849 */ u8 mIsFileSkipDataDirty[3];
/* 0xA84C */ u8 m_0xA84C;
/* 0xA84D */ u8 m_0xA84D;
/* 0xA84E */ u8 mAntiCommitFlag;
/* 0xA84F */ u8 m_0xA84F;
public:
// the following arent part of FileManager i dont think
// void fn_80009D30(); // some ctor
// void fn_80009D40(); // some dtor
// void fn_80009D80(); // return
// void fn_80009D90(); // return
// void fn_80009DA0(); // memset(param_1, 0, 0x20) a 0x24 structure is implied here (0x20 data) a crc
// is at 0x24
FileManager();
static FileManager *create(EGG::Heap *);
bool loadSaveData(NandRequestWriteHolder *out, const char *name, bool isSkipData);
void saveSaveData(NandRequestLoadSaveFileHolder *request, bool isSkipData);
void refreshSaveFileData();
wchar_t *getFileHeroname(int fileNum);
s64 getFileSaveTime(int fileNum);
s16 getFileCurrentHealth(int fileNum);
s16 getFileHealthCapacity(int fileNum);
void fn_8000A2E0(); // idk something blank save files
u16 *getStoryFlagsMut();
const u16 *getStoryFlagsConst() const;
u16 *getItemFlagsMut();
const u16 *getItemFlagsConst();
u16 *getDungeonFlagsMut();
u16 *getDungeonFlagsConst();
u16 *getSceneFlagsMut();
u16 *getSceneFlagsConst();
u16 *getTBoxFlagsMut();
u16 *getTBoxFlagsConst();
u16 *getTempFlagsMut();
u16 *getTempFlagsConst();
u16 *getZoneFlagsMut();
u16 *getZoneFlagsConst();
u16 *getEnemyDefeatFlagsMut();
u16 *getEnemyDefeatFlagsConst();
void setStoryFlags(u16 *flags, u32 offset, u16 count);
void setItemFlags(u16 *flags, u32 offset, u16 count);
void setDungeonFlags(u16 *flags, u32 offset, u16 count);
void setSceneFlags(u16 *flags, u32 offset, u16 count);
void setTBoxFlags(u16 *flags, u32 offset, u16 count);
void setTempFlags(u16 *flags, u32 offset, u16 count);
void setZoneFlags(u16 *flags, u32 offset, u16 count);
void setEnemyDefeatFlags(u16 *flags, u32 offset, u16 count);
u16 *getSkipFlags();
void setSkipFlagsChecked(u16 *flags, u32 offset, u16 count);
void initFile(int fileNum);
void setCurrentHealthCapacity(s16 health);
u16 getCurrentHealthCapacity();
void setCurrentHealth(s16 health);
u16 getCurrentHealth();
u16 getLoadRoomT1();
u16 getLoadRoomT2();
void setLoadRoomT3(s16 room);
u16 getLoadRoomT3();
mVec3_c *getPosT1();
void setPosT2(mVec3_c *pos);
mVec3_c *getPosT2();
void setPosT3(mVec3_c *pos);
mVec3_c *getPosT3();
s16 getAngleT1();
void setAngleT2(s16 angle);
s16 getAngleT2();
void setAngleT3(s16 angle);
s16 getAngleT3();
void setPouchData(s32 slot, u32 slotData);
u32 getPouchData(s32 slot);
void setPouchItem(s32 slot, ITEM_ID item);
ITEM_ID getPouchItem(s32 slot);
void setPouchUpperData(s32 slot, s32 data);
u16 getPouchUpperData(s32 slot);
void setItemCheckData(u32 idx, u32 itemData);
u32 getItemCheckData(u32 idx);
void setItemCheckItem(u32 idx, ITEM_ID item);
ITEM_ID getItemCheckItem(u32 idx);
void setItemCheckUpperData(u32 idx, u32 itemData);
u32 getItemCheckUpperData();
void setEquippedItem(u8 bWheelItem);
u8 getEquippedItem();
void setSelectedPouchSlot(u8 slot);
u8 getSelectedPouchSlot();
void setShieldPouchSlot(u8 slot);
u8 getShieldPouchSlot();
void setAirPotionTimer(u16 time);
u16 getAirPotionTimer() const;
void setAirPotionPlusTimer(u16 time);
u16 getAirPotionPlusTimer() const;
void setStaminaPotionTimer(u16 time);
u16 getStaminaPotionTimer() const;
void setStaminaPotionPlusTimer(u16 time);
u16 getStaminaPotionPlusTimer() const;
void setGuardianPotionTimer(u16 time);
u16 getGuardianPotionTimer() const;
void setGuardianPotionPlusTimer(u16 time);
u16 getGuardianPotionPlusTimer() const;
void setDowsingSlotIdx(u8 idx);
u8 getDowsingSlotIdx();
void setBeaconPos(u32 beaconArea, u32 beaconNum, mVec3_c *pos);
mVec3_c *getBeaconPos(u32 beaconArea, u32 beaconNum);
void setEnemyKillCount(u8 enemy, u16 killCount);
u16 getEnemyKillCount(u8 enemy);
void setHitCountFromEnemy(u8 enemy, u16 hitCount);
u16 getHitCountFromEnemy(u8 enemy);
void setLoadRoomT1_FileB(s16 roomId);
u16 getLoadRoomT1_FileB();
void setEntranceT1_FileB(u8 entrance);
u8 getEntranceT1_FileB();
void setAreaT1_FileB(const char *name);
char *getAreaT1_FileB();
void setNightT1_FileB(bool night);
u8 getNightT1_FileB();
void setEntranceT1LoadFlag_FileB(u8 flag);
void setForcedLayerT1_FileB(u8 layer);
u8 getForcedLayerT1_FileB();
void setCurrentHealth_FileB(s16 health);
void setHeroname(const wchar_t *name);
wchar_t *getHeroname();
char *getAreaT1();
char *getAreaT2();
void setAreaT3(const char *name);
char *getAreaT3();
u8 getForcedLayerT1();
u8 getForcedLayerT2();
void setForcedLayerT3(u8 layer);
u8 getForcedLayerT3();
u8 getEntranceT1();
void setEntranceLoadFlagT1(u8 flag);
u8 getEntranceLoadFlagT1();
void getEntranceT2();
void setEntranceT3(u8 entrance);
u8 getEntranceT3();
bool getNightT1();
void setNightT3(bool night);
u8 getNightT3();
bool isNew_FileA();
void setSceneFlagIndex(s16 idx);
u32 getSceneFlagIndex();
s32 getFileAreaIndex();
void fn_8000CBD0(u8);
u8 fn_8000CC00();
void setFileTimes();
void setPlayTime(s64 time);
s64 getSavedTime();
void setSavedTime(s64 time);
void setBeedleShopPathSegment(u32 path);
u32 getBeedleShopPathSegment();
void setBeedleShopPathSegFrac(f32 segFrac);
f32 getBeedleShopPathSegFrac();
void setBeedleShopRotation(s16 rot);
s16 getBeedleShopRotation();
void fn_8000CF00(u32 shift);
void fn_8000CF70(u32 shift);
void setSkykeepPuzzle(u32 spot, u8 tile);
u8 getSkykeepPuzzleTile(u32 spot);
void checkFileStatus();
bool checkSkipDataCRCs();
void saveOrClearSelectedFileToFileA();
void saveOrClearToFileA(int fileNum);
void copyFileBToCurrentFile();
void copyFileAToSelectedFile();
void copyFileAToFile(int fileNum);
void copyFile(int from, int to);
void saveFileAToSelectedFile();
void saveFileAToFile(int fileNum);
void copyCurrentToFileB();
void copySelectedFileSkipData();
void copySkipData(u8 fileNum);
void setInfo_FileB();
void clearFileA();
void initBlankSaveFiles();
void initSkipData();
void unsetFileANewFile();
void saveT1SaveInfo(bool entranceT1LoadFlag);
void copyFileSkipData(int fileNum);
void clearTempFileData();
void saveAfterCredits();
SaveFile *getCurrentFile();
inline const SaveFile *getCurrentFile() const {
return isFileInactive() ? &mFileB : &mFileA;
}
u16 *getSkipFlags2();
SaveFile *getFileA();
SaveFile *getFileB();
u32 calcFileCRC(const void *data, u32 length);
void updateEmptyFiles();
void updateEmptyFileFlags();
bool isFileEmpty(u8 fileNum);
bool isFileDirty(int fileNum);
u32 get_0xA84C();
bool checkRegionCode();
bool checkFileCRC(u8 fileNum);
bool isFileInactive() const;
void setPlayerInfoFileA();
void setT3Info(const mVec3_c &pos, const mAng3_c &rot);
static void getRegionVersion(char *out);
static FileManager *GetInstance() {
return sInstance;
}
bool hasGuardianPotionPlus() const {
return getGuardianPotionPlusTimer() != 0;
}
bool hasGuardianPotionNormal() const {
return getGuardianPotionTimer() != 0;
}
bool hasAirPotionPlus() const {
return getAirPotionPlusTimer() != 0;
}
bool hasAirPotionNormal() const {
return getAirPotionTimer() != 0;
}
bool hasStaminaPotionPlus() const {
return getStaminaPotionPlusTimer() != 0;
}
bool hasStaminaPotionNormal() const {
return getStaminaPotionTimer() != 0;
}
u8 isFileInvalid() const {
return mIsFileInvalid[2];
}
void setField0xA840(u8 val) {
mIsFileUnk1[0] = val;
}
void setField0xA841(u8 val) {
mIsFileUnk1[1] = val;
}
void setField0xA842(u8 val) {
mIsFileUnk1[2] = val;
}
void setField_0xA843(u8 val) {
mIsFileInvalid[1] = val;
}
u8 getField_0xA841() const {
return mIsFileUnk1[1];
}
u8 getField_0xA842() const {
return mIsFileUnk1[2];
}
u8 getField_0xA843() const {
return mIsFileInvalid[1];
}
u8 getField_0xA84D() const {
return m_0xA84D;
}
void setField0xA84C(u8 val) {
m_0xA84C = val;
}
void setField0xA84D(u8 val) {
m_0xA84D = val;
}
void setSelectedFileNum(u8 val) {
mSelectedFile = val;
}
static FileManager *sInstance;
private:
};
#endif
|