OpenSNES
Modern Open-Source SNES Development SDK
Loading...
Searching...
No Matches
save.h File Reference

The save: one versioned, checksummed record in SRAM. More...

#include <snes.h>

Go to the source code of this file.

Macros

#define SAVE_NONE   0xFFFF
 save_best when no round was ever won.
#define SAVE_SIZE   8
 Bytes of the record.
#define SAVE_VERSION   1
 Layout version: a record of another version is not read.
Values of save_status
#define SAVE_CORRUPT   3
#define SAVE_FRESH   2
#define SAVE_NO_SRAM   4
#define SAVE_OK   1
#define SAVE_UNREAD   0

Functions

void saveLoad (void)
 Read the record; whatever is there, the globals end up valid.
u8 saveRecord (u16 time)
 Note a won round and write the record.

Variables

u16 save_best
 Best time in frames, or SAVE_NONE.
u8 save_status
 What saveLoad() found.
u8 save_wins
 Rounds won, capped at 255.

Detailed Description

The save: one versioned, checksummed record in SRAM.

Macro Definition Documentation

◆ SAVE_CORRUPT

#define SAVE_CORRUPT   3

a record whose version, checksum or content is wrong: the defaults

◆ SAVE_FRESH

#define SAVE_FRESH   2

no record (blank SRAM): the defaults

◆ SAVE_NO_SRAM

#define SAVE_NO_SRAM   4

the cartridge declares no SRAM: the defaults, nothing is written

◆ SAVE_NONE

#define SAVE_NONE   0xFFFF

save_best when no round was ever won.

◆ SAVE_OK

#define SAVE_OK   1

a valid record was read

◆ SAVE_SIZE

#define SAVE_SIZE   8

Bytes of the record.

◆ SAVE_UNREAD

#define SAVE_UNREAD   0

saveLoad() has not run

◆ SAVE_VERSION

#define SAVE_VERSION   1

Layout version: a record of another version is not read.

Function Documentation

◆ saveLoad()

void saveLoad ( void )

Read the record; whatever is there, the globals end up valid.

< the cartridge declares no SRAM: the defaults, nothing is written

< no record (blank SRAM): the defaults

< frames on the clock: 30 s at 60 Hz

< a record whose version, checksum or content is wrong: the defaults

< a valid record was read

◆ saveRecord()

u8 saveRecord ( u16 time)

Note a won round and write the record.

Returns
1 if time beat the best.

< frames on the clock: 30 s at 60 Hz

Variable Documentation

◆ save_best

u16 save_best
extern

Best time in frames, or SAVE_NONE.

◆ save_status

u8 save_status
extern

What saveLoad() found.

◆ save_wins

u8 save_wins
extern

Rounds won, capped at 255.