Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
fio.h File Reference

Go to the source code of this file.

Functions

b32 fio_load_globals (void)
 
b32 fio_save_globals (void)
 
b32 fio_load_game (s32 saveSlot)
 
void fio_save_game (s32 saveSlot)
 
void fio_erase_game (s32 saveSlot)
 

Variables

SaveFileSummary gSaveSlotSummary [4]
 
SaveSlotMetadata gSaveSlotMetadata [4]
 
SaveGlobals gSaveGlobals
 

Function Documentation

◆ fio_load_globals()

b32 fio_load_globals ( void )

Definition at line 75 of file fio.c.

75 {
78 return TRUE;
79 }
80
83 return TRUE;
84 }
85
86 bzero(&gSaveGlobals, sizeof(gSaveGlobals));
87 return FALSE;
88}
#define GLOBALS_PAGE_2
Definition fio.c:13
b32 fio_read_flash(s32 pageNum, void *readBuffer, u32 numBytes)
Definition fio.c:236
SaveGlobals gSaveGlobals
Definition fio.c:20
b32 fio_validate_globals_checksums(void)
Definition fio.c:63
#define GLOBALS_PAGE_1
Definition fio.c:12

Referenced by filemenu_init(), and state_step_startup().

◆ fio_save_globals()

b32 fio_save_globals ( void )

Definition at line 90 of file fio.c.

90 {
91 s32 checksum;
92
95 gSaveGlobals.crc2 = ~gSaveGlobals.crc1;
96 checksum = fio_calc_globals_checksum();
97 gSaveGlobals.crc1 = checksum;
98 gSaveGlobals.crc2 = ~checksum;
103 return TRUE;
104}
void fio_erase_flash(s32 pageNum)
Definition fio.c:292
s32 fio_calc_globals_checksum(void)
Definition fio.c:52
b32 fio_write_flash(s32 pageNum, s8 *readBuffer, u32 numBytes)
Definition fio.c:264
char MagicSaveString[]
Definition fio.c:23
char magicString[16]
Definition versioning.h:10

Referenced by filemenu_yesno_handle_input().

◆ fio_load_game()

b32 fio_load_game ( s32 saveSlot)

Definition at line 167 of file fio.c.

167 {
168 gGameStatusPtr->saveSlot = saveSlot;
169
171 fio_read_flash(LogicalSaveInfo[saveSlot].slot, &gCurrentSaveFile, MAX(sizeof(VanillaSaveData), sizeof(SaveData)));
172
173 if (strcmp(gCurrentSaveFile.magicString, MagicSaveString) == 0) {
176 }
179 return TRUE;
180 }
181 return FALSE;
182}
BSS SaveInfo LogicalSaveInfo[4]
Definition fio.c:16
b32 fio_fetch_saved_file_info(void)
Definition fio.c:124
SaveData gCurrentSaveFile
Definition fio.c:21
SaveFileSummary gSaveSlotSummary[4]
GameStatus * gGameStatusPtr
Definition main_loop.c:32
void fio_deserialize_state()
Load game data from gCurrentSaveFile Performs version checking and supports potential migration betwe...
Definition versioning.c:36
SaveFileSummary summary
Definition versioning.h:170
char magicString[16]
Definition versioning.h:144
s32 saveCount
Definition versioning.h:153
SaveData struct from unmodified Paper Mario.
Definition versioning.h:107

Referenced by filemenu_init(), filemenu_main_handle_input(), filemenu_yesno_handle_input(), and state_step_startup().

◆ fio_save_game()

void fio_save_game ( s32 saveSlot)

Definition at line 184 of file fio.c.

184 {
186
187 gGameStatusPtr->saveSlot = saveSlot;
188
190
194
196
198
199 // adding 1 accounts for null terminator
201
206
207 gCurrentSaveFile.saveSlot = saveSlot;
210
212 gCurrentSaveFile.crc2 = ~gCurrentSaveFile.crc1;
214 gCurrentSaveFile.crc2 = ~gCurrentSaveFile.crc1;
215
218}
#define DX_MOD_VER_MAJOR
Definition config.h:8
#define DX_MOD_NAME
Creates the version string that appears on the file select menu.
Definition config.h:7
#define DX_MOD_VER_PATCH
Definition config.h:10
#define DX_MOD_VER_MINOR
Definition config.h:9
#define ASSERT(condition)
s32 get_spirits_rescued(void)
Definition fio.c:29
BSS s32 NextAvailablePhysicalSave
Definition fio.c:18
s32 fio_calc_file_checksum(SaveData *saveData)
Definition fio.c:106
#define ARRAY_COUNT(arr)
Definition macros.h:40
PlayerData gPlayerData
Definition 77480.c:40
void fio_serialize_state()
Store current game data to gCurrentSaveFile.
Definition versioning.c:9
s8 majorVersion
Definition versioning.h:146
s8 minorVersion
Definition versioning.h:147
char modName[28]
Definition versioning.h:145
s32 saveSlot
Definition versioning.h:152
s8 patchVersion
Definition versioning.h:148

Referenced by entity_SaveBlock_save_data(), filemenu_main_handle_input(), and filemenu_yesno_handle_input().

◆ fio_erase_game()

void fio_erase_game ( s32 saveSlot)

Definition at line 220 of file fio.c.

220 {
221 s32 i;
222
224
225 for (i = 0; i < ARRAY_COUNT(PhysicalSaveInfo); i++) {
226 if (PhysicalSaveInfo[i].slot == saveSlot) {
228 }
229 }
230}
BSS SaveInfo PhysicalSaveInfo[6]
Definition fio.c:17

Referenced by filemenu_yesno_handle_input().

Variable Documentation

◆ gSaveSlotSummary

SaveFileSummary gSaveSlotSummary[4]
extern

Definition at line 50 of file state_title_screen.c.

50 {
51 { .filename = { FILENAME_ERROR } },
52 { .filename = { FILENAME_ERROR } },
53 { .filename = { FILENAME_ERROR } },
54 { .filename = { FILENAME_ERROR } },
55};
#define FILENAME_ERROR

Referenced by filemenu_draw_contents_file_info(), filemenu_draw_contents_file_title(), filemenu_init(), filemenu_main_handle_input(), filemenu_yesno_handle_input(), fio_load_game(), and fio_save_game().

◆ gSaveSlotMetadata

SaveSlotMetadata gSaveSlotMetadata[4]
extern

Definition at line 57 of file state_title_screen.c.

57 {
58 { .hasData = TRUE },
59 { .hasData = TRUE },
60 { .hasData = TRUE },
61 { .hasData = TRUE },
62};

Referenced by filemenu_draw_contents_file_info(), filemenu_draw_contents_file_title(), filemenu_init(), filemenu_main_handle_input(), filemenu_yesno_draw_prompt_contents(), and filemenu_yesno_handle_input().

◆ gSaveGlobals