Alchemy

save_state.h

games/tbs/include/save_state.h on GitHub

Functions, without a comment: WaitDma.

Structures

SaveSlotHeader

struct SaveSlotHeader

The header of a save sector in flash: its signature, the record it holds, its checksum and its sequence number.

FieldDeclared as
signatureu8 signature[7]CAMELOT, unterminated
recordIdu8 recordIdFile n's records are n and n + 3 (n from 0 to 2); 16 marks a free sector.
checksumu16 checksumlow half of the payload's checksum
sequenceu16 sequencethe highest is the current copy; restarts after 65000
reservedu8 reserved[4]not named by TBS code

Used by SaveState_InitializeWorkspace, SaveState_InvalidateSlot, SaveState_ReadSlotAndCheckChecksum, SaveState_WriteRecord.

Line 18

SaveSummary

struct SaveSummary

A save file's summary for the file screen: the leader's name, level and class, the area, play time, coins, Djinn and party.

FieldDeclared as
slotHeaderu8 slotHeader[16]room for the record's SaveSlotHeader
nameu8 name[12]the leader's
levelu8 levelthe leader's; 0 for an empty file
classIdu8 classIdthe leader's
areau16 areaarea name number (Scene_GetAreaNameIndex)
playTimeu32 playTimeframes
coinsu32 coins
djinnu8 djinn[4]the party's Djinn of each element
partys8 party[5]up to four party members, ended by -1
sendFlags8 sendFlagCopied from GameState.unk20f, which saving at the end of the game sets; the file menu for cleared data lists a file without it as not cleared.
flagCounts8 flagCounthow many of game flags 48 to 127 are set
hasFlag20u8 hasFlag20FLAG_CHILDHOOD is set; remaps the party's sprites
paletteGlowu16 paletteGlow : 8bits: 15..8 paletteGlowSub | 7..0 paletteGlow @{ GameState.paletteGlow[0]
paletteGlowSubu16 paletteGlowSub : 8GameState.paletteGlow[1]
framesu16 frames@} Low half of GameState.buildStamp; a file below the current stamp is listed as from an older build.
unk38u8 unk38[4]Filled on reading: the play time from the file's second record. A file whose playTime differs is listed as corrupted.
checksumu32 checksumthe sum of the 968 words from gGameFlagBytes

Used by SaveMenu_DrawDjinnCounts, SaveMenu_DrawFileSummary, SaveMenu_SelectSlot, SaveMenu_ShowPartySprites, SaveState_BuildSummaryHeader, SaveState_CountRecordsExcludingFlagged, SaveState_FindFreeSummarySlot, SaveState_LoadSummaryRecords, SaveState_ScanRecordFlags.

Line 29

SaveWorkspace

struct SaveWorkspace

The save work: which of the 16 flash sectors hold a record, their record ids and sequence numbers, one sector's buffer and the three files' summaries.

FieldDeclared as
occupiedu8 occupied[16]1 for a sector holding the current copy of a record
recordIdu8 recordId[16]each sector's record; 16 for none
sequenceu16 sequence[16]each sector's sequence number
header, payload, record, bytes, slotunion { struct { struct SaveSlotHeader header; u8 payload[0xff0]; } record; u8 bytes[0x1000]; } slotone sector, read from or written to flash
summarystruct SaveSummary summary[3]each file's, read from its first record

Used by SaveMenu_SelectSlot, SaveState_ChecksumWorkspace, SaveState_FindLatestSlot, SaveState_GetLatestSequence, SaveState_InitializeWorkspace, SaveState_InvalidateSlot, SaveState_LoadSummaryRecords, SaveState_ReadRecordPayload, SaveState_ReadSlotAndCheckChecksum, SaveState_WriteRecord, SaveState_WriteWorkspaceSlot, Save_WriteSelectedSlot, gSaveWorkspace.

Line 61

Macros, without a comment: GUARD_SAVE_STATE_H, DMA3_BUSY, START_DMA, WAIT_DMA.

Globals, without a comment: gSaveWorkspace, gTitleSendOptionEnabled.

On this page