2017-09-03 12:13:01 +00:00
|
|
|
#ifndef GUARD_SAVE_H
|
|
|
|
#define GUARD_SAVE_H
|
|
|
|
|
|
|
|
struct SaveSectionLocation
|
|
|
|
{
|
|
|
|
void *data;
|
|
|
|
u16 size;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct SaveSection
|
|
|
|
{
|
|
|
|
u8 data[0xFF4];
|
|
|
|
u16 id;
|
|
|
|
u16 checksum;
|
|
|
|
u32 security;
|
|
|
|
u32 counter;
|
|
|
|
}; // size is 0x1000
|
|
|
|
|
|
|
|
// headless save section?
|
|
|
|
struct UnkSaveSection
|
|
|
|
{
|
|
|
|
u8 data[0xFF4];
|
|
|
|
u32 security;
|
|
|
|
}; // size is 0xFF8
|
|
|
|
|
|
|
|
struct SaveSectionOffsets
|
|
|
|
{
|
2018-12-07 13:01:59 +00:00
|
|
|
u16 toAdd;
|
|
|
|
u16 size;
|
2017-09-03 12:13:01 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// Emerald changes this definition to be the sectors per slot.
|
2018-08-30 18:10:57 +00:00
|
|
|
#define NUM_SECTORS_PER_SLOT 16
|
2017-09-03 12:13:01 +00:00
|
|
|
|
|
|
|
#define UNKNOWN_CHECK_VALUE 0x8012025
|
2019-04-04 15:55:18 +00:00
|
|
|
#define SPECIAL_SECTION_SENTINEL 0xB39D
|
2017-09-03 12:13:01 +00:00
|
|
|
|
|
|
|
// SetDamagedSectorBits states
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
ENABLE,
|
|
|
|
DISABLE,
|
|
|
|
CHECK // unused
|
|
|
|
};
|
|
|
|
|
|
|
|
// Do save types
|
|
|
|
enum
|
|
|
|
{
|
2018-02-15 22:54:34 +00:00
|
|
|
SAVE_NORMAL,
|
|
|
|
SAVE_LINK,
|
|
|
|
//EREADER_SAVE, // deprecated in Emerald
|
2018-12-07 13:01:59 +00:00
|
|
|
SAVE_LINK2, // unknown 2nd link save
|
2018-02-15 22:54:34 +00:00
|
|
|
SAVE_HALL_OF_FAME,
|
|
|
|
SAVE_OVERWRITE_DIFFERENT_FILE,
|
|
|
|
SAVE_HALL_OF_FAME_ERASE_BEFORE // unused
|
2017-09-03 12:13:01 +00:00
|
|
|
};
|
|
|
|
|
2020-01-12 20:27:37 +00:00
|
|
|
#define SECTOR_ID_SAVEBLOCK2 0
|
|
|
|
#define SECTOR_ID_SAVEBLOCK1_START 1
|
|
|
|
#define SECTOR_ID_SAVEBLOCK1_END 4
|
|
|
|
#define SECTOR_ID_PKMN_STORAGE_START 5
|
|
|
|
#define SECTOR_ID_PKMN_STORAGE_END 13
|
2018-11-18 18:37:18 +00:00
|
|
|
#define SECTOR_SAVE_SLOT_LENGTH 14
|
2020-01-12 20:27:37 +00:00
|
|
|
// Save Slot 1: 0-13; Save Slot 2: 14-27
|
2018-11-18 18:37:18 +00:00
|
|
|
#define SECTOR_ID_HOF_1 28
|
|
|
|
#define SECTOR_ID_HOF_2 29
|
|
|
|
#define SECTOR_ID_TRAINER_HILL 30
|
|
|
|
#define SECTOR_ID_RECORDED_BATTLE 31
|
|
|
|
#define SECTORS_COUNT 32
|
2017-11-13 17:07:23 +00:00
|
|
|
|
2020-01-12 20:27:37 +00:00
|
|
|
#define SAVE_STATUS_EMPTY 0
|
|
|
|
#define SAVE_STATUS_OK 1
|
|
|
|
#define SAVE_STATUS_CORRUPT 2
|
|
|
|
#define SAVE_STATUS_NO_FLASH 4
|
|
|
|
#define SAVE_STATUS_ERROR 0xFF
|
|
|
|
|
2018-09-09 23:01:39 +00:00
|
|
|
extern u16 gLastWrittenSector;
|
|
|
|
extern u32 gLastSaveCounter;
|
|
|
|
extern u16 gLastKnownGoodSector;
|
|
|
|
extern u32 gDamagedSaveSectors;
|
|
|
|
extern u32 gSaveCounter;
|
|
|
|
extern struct SaveSection *gFastSaveSection;
|
|
|
|
extern u16 gUnknown_03006208;
|
|
|
|
extern u16 gSaveFileStatus;
|
|
|
|
extern void (*gGameContinueCallback)(void);
|
|
|
|
extern struct SaveSectionLocation gRamSaveSectionLocations[];
|
|
|
|
extern u16 gUnknown_03006294;
|
|
|
|
|
|
|
|
extern struct SaveSection gSaveDataBuffer;
|
|
|
|
|
2017-09-03 12:13:01 +00:00
|
|
|
void ClearSaveData(void);
|
2018-02-15 22:54:34 +00:00
|
|
|
void Save_ResetSaveCounters(void);
|
2017-10-06 22:33:35 +00:00
|
|
|
u8 HandleSavingData(u8 saveType);
|
2017-11-13 17:07:23 +00:00
|
|
|
u8 TrySavingData(u8 saveType);
|
2018-10-30 20:45:26 +00:00
|
|
|
bool8 sub_8153380(void);
|
2017-11-13 17:07:23 +00:00
|
|
|
bool8 sub_81533AC(void);
|
2020-01-12 20:27:37 +00:00
|
|
|
bool8 sub_81533E0(void);
|
|
|
|
bool8 sub_8153408(void);
|
|
|
|
bool8 FullSaveGame(void);
|
2019-02-27 03:04:44 +00:00
|
|
|
bool8 CheckSaveFile(void);
|
2020-01-12 20:27:37 +00:00
|
|
|
u8 Save_LoadGameData(u8 saveType);
|
2017-09-16 02:12:45 +00:00
|
|
|
u16 sub_815355C(void);
|
2019-04-04 15:55:18 +00:00
|
|
|
u32 TryReadSpecialSaveSection(u8 sector, u8* dst);
|
|
|
|
u32 TryWriteSpecialSaveSection(u8 sector, u8* src);
|
2020-06-03 22:00:53 +00:00
|
|
|
void Task_LinkSave(u8 taskId);
|
2017-09-03 12:13:01 +00:00
|
|
|
|
2019-03-02 08:18:08 +00:00
|
|
|
// save_failed_screen.c
|
|
|
|
void DoSaveFailedScreen(u8 saveType);
|
|
|
|
|
2017-09-03 13:39:33 +00:00
|
|
|
#endif // GUARD_SAVE_H
|