The save: magic, version, checksum, and defaults when anything is off. More...
#include <snes.h>#include <snes/sram.h>#include <snes/debug.h>#include "game.h"#include "save.h"Functions | |
| static void | defaults (void) |
| The values a fresh game starts with. | |
| 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_rec [8] |
| The record as it sits in RAM. | |
| u8 | save_status |
| What saveLoad() found. | |
| u8 | save_wins |
| Rounds won, capped at 255. | |
The save: magic, version, checksum, and defaults when anything is off.
Record (8 bytes): 'S' 'D' | version | best (u16, little-endian) | wins | 0 | checksum of the seven bytes before. The record is flat bytes, never a struct dumped as is: no padding or endianness to depend on, and a layout change is a version bump.
|
static |
The values a fresh game starts with.
| 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
Note a won round and write the record.
time beat the best. < frames on the clock: 30 s at 60 Hz
| u16 save_best |
Best time in frames, or SAVE_NONE.
| u8 save_rec[8] |
The record as it sits in RAM.
| u8 save_status |
What saveLoad() found.
| u8 save_wins |
Rounds won, capped at 255.