Merge pull request #527 from GriffinRichards/sync-more-save

Sync save sector checks
This commit is contained in:
GriffinR
2022-08-06 18:22:56 -04:00
committed by GitHub
5 changed files with 70 additions and 50 deletions
+4
View File
@@ -129,6 +129,10 @@ extern u8 gStringVar4[];
#define NUM_FLAG_BYTES ROUND_BITS_TO_BYTES(FLAGS_COUNT)
#define NUM_ADDITIONAL_PHRASE_BYTES ROUND_BITS_TO_BYTES(NUM_ADDITIONAL_PHRASES)
// This produces an error at compile-time if expr is zero.
// It looks like file.c:line: size of array `id' is negative
#define STATIC_ASSERT(expr, id) typedef char id[(expr) ? 1 : -1];
struct Coords8
{
s8 x;
+12 -7
View File
@@ -9,7 +9,10 @@
#define SECTOR_FOOTER_SIZE 128
#define SECTOR_SIZE (SECTOR_DATA_SIZE + SECTOR_FOOTER_SIZE)
#define FILE_SIGNATURE 0x08012025 // signature value to determine if a sector is in use
#define NUM_SAVE_SLOTS 2
// If the sector's signature field is not this value then the sector is either invalid or empty.
#define SECTOR_SIGNATURE 0x08012025
#define SPECIAL_SECTOR_SENTINEL 0xB39D
@@ -26,12 +29,19 @@
#define SECTOR_ID_TRAINER_TOWER_2 31
#define SECTORS_COUNT 32
#define NUM_HOF_SECTORS 2
#define SAVE_STATUS_EMPTY 0
#define SAVE_STATUS_OK 1
#define SAVE_STATUS_INVALID 2
#define SAVE_STATUS_NO_FLASH 4
#define SAVE_STATUS_ERROR 0xFF
// Special sector id value for certain save functions
// to indicate that all sectors should be used
// instead of a specific sector.
#define FULL_SAVE_SLOT 0xFFFF
enum
{
SAVE_NORMAL,
@@ -58,16 +68,11 @@ struct SaveSector
u16 checksum;
u32 signature;
u32 counter;
}; // size is 0x1000
}; // size is SECTOR_SIZE (0x1000)
#define SECTOR_SIGNATURE_OFFSET offsetof(struct SaveSector, signature)
#define SECTOR_COUNTER_OFFSET offsetof(struct SaveSector, counter)
// Special sector id value for certain save functions
// to indicate that all sectors should be used
// instead of a specific sector.
#define FULL_SAVE_SLOT 0xFFFF
// operations for SetDamagedSectorBits
enum
{