90 }
while (status < index);
113 empty[count++] = index;
126 index = empty[index];
149 return (
u32)((0 - result) | result) >> 0x1F;
262 return (
u32)((0 - deletionResult) | deletionResult) >> 0x1F;
279 sum += work->
slot.record.payload[offset + 0];
280 sum += work->
slot.record.payload[offset + 1];
281 sum += work->
slot.record.payload[offset + 2];
282 sum += work->
slot.record.payload[offset + 3];
283 sum += work->
slot.record.payload[offset + 4];
284 sum += work->
slot.record.payload[offset + 5];
285 sum += work->
slot.record.payload[offset + 6];
286 sum += work->
slot.record.payload[offset + 7];
288 }
while (offset <= limit);
305 if (latestSequence < work->
sequence[i]) {
344 difference = *left - *right;
365 if (latestSequence < work->
sequence[i])
369 return latestSequence;
392 ReadFlash(index, 0, (
u8 *)summary,
sizeof(*summary));
static __inline__ void Dma_Set(const volatile void *source, volatile void *destination, u32 control, volatile u32 *channel)
Starts a DMA transfer: stores the source, destination and control words into channel's registers with...
#define Dma_Fill32(value, destination, size)
Fills size bytes at destination with the word value by DMA3.
s32 SetFlashTimerIntr(u8 timerIndex, void(**callback)(void))
Selects a hardware timer and returns its timeout interrupt callback.
void ReadFlash(u16 sector, u32 offset, u8 *destination, s32 size)
Copies the RAM reader and reads a range using the standard sector geometry.
s32 Flash_VerifySector(u16 sector, s32 source)
Copies the verifier to RAM and compares a standard flash sector with source data.
s32 IdentifyFlash(void)
Selects matching chip handlers, falling back to the final table entry when unknown.
void Runtime_SetIrqHandler(u32 irq, s32 vcount, InterruptHandler handler)
Installs handler for interrupt irq and enables that interrupt, or with a null handler disables it and...
void WaitFrames(s32 frames)
The game's frame loop: runs frames frames and returns.
void * Runtime_AllocateBlock(s32 kind, s32 size)
As Runtime_AllocateHeapBlock, but tries EWRAM first, for blocks that need room more than speed: the b...
#define DMA_COPY_WORDS(n)
InterruptHandler gIrqHandlers[IRQ_COUNT]
The handler the IWRAM dispatcher calls for each interrupt source.
u32 Random16(void)
Advances the game's random number generator (the C library's classic linear congruential one),...
void Runtime_ReleaseHeapBlock(s32 slot)
u32 SaveState_ReadRecordPayload(s32 recordId, void *destination)
Loads the current copy of record recordId into destination.
u32 SaveState_FindLatestSlot(s32 recordId)
Returns the occupied sector holding the newest copy of record recordId, or 16.
u16(*) EraseSectorProc(u16)
@ SAVE_FLASH_IDENTIFY_ATTEMPTS
s32 SaveState_LoadSummaryRecords(void)
Reads the summary at the start of each of the three save files into summary for the file select scree...
u32 SaveState_ReleaseWorkspace(void)
Removes the flash timer handler and frees the save workspace's heap slot.
u32 SaveState_DeleteRecord(s32 recordId)
Invalidates the current copy of record recordId.
u32 SaveState_GetLatestSequence(s32 recordId)
Returns the highest sequence number among the copies of record recordId.
u32 SaveState_SelectWriteSlot(s32 mode)
Picks the free sector to write record mode to, at random.
s32 SaveState_WriteRecord(s32 recordId, void *source)
Saves 0xff0 bytes from source as record recordId: writes the new copy with the next sequence number,...
u32 SaveState_WriteWorkspaceSlot(s32 sector)
Programs the workspace's sector buffer into flash sector sector and verifies it, through the flash li...
s32 SaveState_ReadSlotAndCheckChecksum(s32 index)
Reads flash sector index into the workspace's sector buffer.
s32 SaveState_InvalidateSlot(s32 index)
Overwrites sector index with a header for no record (id 16) and clears its occupied entry.
s32 SaveState_CompareBytes(u8 *left, u8 *right, s32 count)
Compares count bytes, as memcmp does.
UNUSED u16 SaveState_EraseSlotSector(u16 sector)
Erases flash sector sector with the flash library's routine for this chip.
s32 SaveState_ChecksumWorkspace(void)
Sums the first 0xfe8 payload bytes of the workspace's sector buffer; the final eight payload bytes ar...
s32 SaveState_InitializeWorkspace(void)
Allocates the save workspace (heap slot HEAP_SLOT_SAVE), installs the flash library's timer 2 handler...
What every part of the runtime object shares: its includes and the library call two parts make.
struct SaveWorkspace * gSaveWorkspace
#define START_DMA(source_, destination_, control_)
const u8 gSave_Signature[]
The signature that marks a save record.
const u8 gSave_HeaderTemplate[8]
The record header's first eight bytes, with no terminator.
s32 _call_via_r3(s32, s32, s32, s32)
A save file's summary for the file screen: the leader's name, level and class, the area,...
u8 unk38[4]
Filled on reading: the play time from the file's second record.
The save work: which of the 16 flash sectors hold a record, their record ids and sequence numbers,...
struct SaveSummary summary[3]
each file's, read from its first record
u8 recordId[16]
each sector's record; 16 for none
u8 occupied[16]
1 for a sector holding the current copy of a record
u16 sequence[16]
each sector's sequence number
union SaveWorkspace::@331263107057156204162071305274032234046256201132 slot
one sector, read from or written to flash