diff --git a/asm/save_s.s b/asm/save_s.s index 7e6aa76a4..dfcb0311b 100644 --- a/asm/save_s.s +++ b/asm/save_s.s @@ -8,340 +8,14 @@ .rodata -_020F645C: - .word 6 -_020F6460: - .word 0x0000002A -_020F6464: - .word 0x00000000, 0x00000023, Sav2_HOF_sizeof, Sav2_HOF_init - .word 0x00000001, 0x00000026, sub_020312A4, sub_020312AC - .word 0x00000002, 0x00000027, sub_0202FBCC, sub_0202FBD4 - .word 0x00000003, 0x00000029, sub_0202FBCC, sub_0202FBD4 - .word 0x00000004, 0x0000002B, sub_0202FBCC, sub_0202FBD4 - .word 0x00000005, 0x0000002D, sub_0202FBCC, sub_0202FBD4 -_020F64C4: - .word 0x00000000, 0x00000000, Sav2_SysInfo_sizeof, Sav2_SysInfo_init - .word 0x00000001, 0x00000000, Sav2_PlayerData_sizeof, Sav2_PlayerData_init - .word 0x00000002, 0x00000000, SavArray_Party_sizeof, SavArray_Party_init - .word 0x00000003, 0x00000000, Sav2_Bag_sizeof, Sav2_Bag_init - .word 0x00000004, 0x00000000, SavArray_Flags_sizeof, SavArray_Flags_init - .word 0x00000005, 0x00000000, Save_FlyPoints_sizeof, Save_FlyPoints_init - .word 0x00000006, 0x00000000, Save_Pokedex_sizeof, Save_Pokedex_init - .word 0x00000007, 0x00000000, Sav2_Daycare_sizeof, Sav2_Daycare_init - .word 0x00000008, 0x00000000, sub_0202AEC0, sub_0202AED4 - .word 0x00000009, 0x00000000, Sav2_Misc_sizeof, Sav2_Misc_init - .word 0x0000000A, 0x00000000, sub_0203B920, sub_0203B928 - .word 0x0000000B, 0x00000000, sub_020290B8, sub_020290C8 - .word 0x0000000C, 0x00000000, sub_0202B98C, sub_0202B930 - .word 0x0000000D, 0x00000000, Sav2_Mailbox_sizeof, Sav2_Mailbox_init - .word 0x0000000E, 0x00000000, sub_0202C730, sub_0202C75C - .word 0x0000000F, 0x00000000, sub_0202C9A0, sub_0202C9A8 - .word 0x00000010, 0x00000000, GameStats_sizeof, GameStats_init - .word 0x00000011, 0x00000000, Sav2_SealCase_sizeof, Sav2_SealCase_init - .word 0x00000012, 0x00000000, Sav2_Chatot_sizeof, Sav2_Chatot_init - .word 0x00000013, 0x00000000, sub_02031000, sub_02031008 - .word 0x00000014, 0x00000000, sub_0202D938, sub_0202D93C - .word 0x00000015, 0x00000000, Save_Roamers_sizeof, Save_Roamers_init - .word 0x00000016, 0x00000000, sub_0202DB40, sub_0202DB44 - .word 0x00000017, 0x00000000, sub_0202E41C, sub_0202E424 - .word 0x00000018, 0x00000000, sub_0202E4F4, sub_0202E4FC - .word 0x00000019, 0x00000000, sub_0202C034, sub_0202C03C - .word 0x0000001A, 0x00000000, sub_0202CA24, sub_0202CA2C - .word 0x0000001B, 0x00000000, Save_MysteryGift_sizeof, Save_MysteryGift_init - .word 0x0000001C, 0x00000000, sub_0202EB30, sub_0202EB38 - .word 0x0000001D, 0x00000000, sub_02031AF0, sub_02031AF4 - .word 0x0000001E, 0x00000000, Sav2_EasyChat_sizeof, Sav2_EasyChat_init - .word 0x0000001F, 0x00000000, sub_0203170C, sub_02031710 - .word 0x00000020, 0x00000000, sub_020318C8, sub_020318CC - .word 0x00000021, 0x00000000, Sav2_FollowPoke_sizeof, Sav2_FollowPoke_init - .word 0x00000022, 0x00000000, SaveData_GSPlayerMisc_sizeof, SaveData_GSPlayerMisc_init - .word 0x00000023, 0x00000000, Save_SafariZone_sizeof, Save_SafariZone_init - .word 0x00000024, 0x00000000, Save_PhotoAlbum_sizeof, Save_PhotoAlbum_init - .word 0x00000025, 0x00000000, sub_02031904, sub_0203190C - .word 0x00000026, 0x00000000, Save_ApricornBox_sizeof, Save_ApricornBox_init - .word 0x00000027, 0x00000000, Pokewalker_sizeof, Pokewalker_init - .word 0x00000028, 0x00000000, sub_02032774, sub_02032788 - .word 0x00000029, 0x00000001, PCStorage_sizeof, PCStorage_init + .public _020F64C4 + .public _020F6460 + .public _020F6464 + .public _020F645C .text - thumb_func_start sub_020272F4 -sub_020272F4: ; 0x020272F4 - push {r3, r4, r5, r6, r7, lr} - mov r1, #1 - str r0, [sp] - mov r0, #3 - lsl r1, r1, #0xc - bl AllocFromHeapAtEnd - add r6, r0, #0 - mov r0, #1 - bl sub_0201A4BC - ldr r1, _020273AC ; =0x0002330A - ldr r0, [sp] - ldrh r0, [r0, r1] - cmp r0, #0 - bne _02027318 - mov r2, #1 - b _0202731A -_02027318: - mov r2, #0 -_0202731A: - ldr r0, [sp] - mov r1, #0 - bl FlashClobberChunkFooter - ldr r1, _020273AC ; =0x0002330A - ldr r0, [sp] - ldrh r0, [r0, r1] - cmp r0, #0 - bne _02027330 - mov r2, #1 - b _02027332 -_02027330: - mov r2, #0 -_02027332: - ldr r0, [sp] - mov r1, #1 - bl FlashClobberChunkFooter - ldr r0, [sp] - ldr r3, _020273AC ; =0x0002330A - add r2, r0, #0 - ldrh r2, [r2, r3] - mov r1, #0 - bl FlashClobberChunkFooter - ldr r0, [sp] - ldr r3, _020273AC ; =0x0002330A - add r2, r0, #0 - ldrh r2, [r2, r3] - mov r1, #1 - bl FlashClobberChunkFooter - mov r0, #0 - mov r2, #1 - mvn r0, r0 - add r1, r6, #0 - lsl r2, r2, #0xc - bl MIi_CpuClearFast - mov r4, #0 - mov r7, #1 - add r5, r4, #0 - lsl r7, r7, #0xc -_0202736C: - add r0, r5, #0 - add r1, r6, #0 - add r2, r7, #0 - bl FlashWriteChunk - add r0, r4, #0 - add r0, #0x40 - lsl r0, r0, #0xc - add r1, r6, #0 - add r2, r7, #0 - bl FlashWriteChunk - mov r0, #1 - lsl r0, r0, #0xc - add r4, r4, #1 - add r5, r5, r0 - cmp r4, #0x40 - blt _0202736C - add r0, r6, #0 - bl FreeToHeap - ldr r0, [sp] - bl Sav2_InitDynamicRegion - ldr r0, [sp] - mov r1, #0 - str r1, [r0, #4] - mov r0, #1 - bl sub_0201A4CC - mov r0, #1 - pop {r3, r4, r5, r6, r7, pc} - .balign 4, 0 -_020273AC: .word 0x0002330A - thumb_func_end sub_020272F4 - - thumb_func_start sub_020273B0 -sub_020273B0: ; 0x020273B0 - push {r4, lr} - sub sp, #8 - add r4, r0, #0 - ldr r1, [r4] - cmp r1, #0 - bne _020273C2 - add sp, #8 - mov r0, #0 - pop {r4, pc} -_020273C2: - bl Sav2_LoadDynamicRegion - cmp r0, #0 - beq _020273E8 - mov r0, #1 - str r0, [r4, #4] - mov r0, #0 - str r0, [r4, #8] - add r0, r4, #0 - add r1, sp, #4 - add r2, sp, #0 - bl sub_020279EC - add r0, r4, #0 - bl sub_02027180 - add sp, #8 - mov r0, #1 - pop {r4, pc} -_020273E8: - mov r0, #0 - add sp, #8 - pop {r4, pc} - .balign 4, 0 - thumb_func_end sub_020273B0 - - thumb_func_start sub_020273F0 -sub_020273F0: ; 0x020273F0 - push {r4, lr} - add r4, r0, #0 - ldr r0, [r4] - cmp r0, #0 - bne _020273FE - mov r0, #3 - pop {r4, pc} -_020273FE: - ldr r0, [r4, #8] - cmp r0, #0 - beq _02027454 - mov r0, #1 - bl sub_0201A4BC - ldr r0, _02027468 ; =0x0002330A - ldrh r0, [r4, r0] - cmp r0, #0 - bne _02027416 - mov r2, #1 - b _02027418 -_02027416: - mov r2, #0 -_02027418: - add r0, r4, #0 - mov r1, #0 - bl FlashClobberChunkFooter - ldr r0, _02027468 ; =0x0002330A - ldrh r0, [r4, r0] - cmp r0, #0 - bne _0202742C - mov r2, #1 - b _0202742E -_0202742C: - mov r2, #0 -_0202742E: - add r0, r4, #0 - mov r1, #1 - bl FlashClobberChunkFooter - ldr r2, _02027468 ; =0x0002330A - add r0, r4, #0 - ldrh r2, [r4, r2] - mov r1, #0 - bl FlashClobberChunkFooter - ldr r2, _02027468 ; =0x0002330A - add r0, r4, #0 - ldrh r2, [r4, r2] - mov r1, #1 - bl FlashClobberChunkFooter - mov r0, #1 - bl sub_0201A4CC -_02027454: - add r0, r4, #0 - bl sub_02027DB4 - cmp r0, #2 - bne _02027466 - mov r1, #1 - str r1, [r4, #4] - mov r1, #0 - str r1, [r4, #8] -_02027466: - pop {r4, pc} - .balign 4, 0 -_02027468: .word 0x0002330A - thumb_func_end sub_020273F0 - - thumb_func_start sub_0202746C -sub_0202746C: ; 0x0202746C - push {r3, r4, r5, lr} - add r4, r1, #0 - add r5, r0, #0 - cmp r4, #2 - blt _0202747A - bl GF_AssertFail -_0202747A: - ldr r0, [r5, #8] - cmp r0, #0 - beq _02027484 - bl GF_AssertFail -_02027484: - ldr r0, [r5, #4] - cmp r0, #1 - beq _0202748E - bl GF_AssertFail -_0202748E: - add r0, r5, #0 - add r1, r4, #0 - bl sub_02027550 -_02027496: - add r0, r5, #0 - bl sub_02027564 - cmp r0, #0 - beq _02027496 - cmp r0, #1 - beq _02027496 - pop {r3, r4, r5, pc} - .balign 4, 0 - thumb_func_end sub_0202746C - - thumb_func_start Sav2_InitDynamicRegion -Sav2_InitDynamicRegion: ; 0x020274A8 - add r2, r0, #0 - mov r1, #1 - ldr r0, _020274C4 ; =0x00023308 - str r1, [r2, #8] - strb r1, [r2, r0] - add r0, r0, #1 - strb r1, [r2, r0] - ldr r1, _020274C8 ; =0x00023014 - add r0, r2, #0 - ldr r3, _020274CC ; =Sav2_InitDynamicRegion_Internal - add r0, #0x10 - add r1, r2, r1 - bx r3 - nop -_020274C4: .word 0x00023308 -_020274C8: .word 0x00023014 -_020274CC: .word Sav2_InitDynamicRegion_Internal - thumb_func_end Sav2_InitDynamicRegion - - thumb_func_start sub_020274D0 -sub_020274D0: ; 0x020274D0 - ldr r0, [r0] - bx lr - thumb_func_end sub_020274D0 - - thumb_func_start sub_020274D4 -sub_020274D4: ; 0x020274D4 - ldr r0, [r0, #0xc] - bx lr - thumb_func_end sub_020274D4 - - thumb_func_start sub_020274D8 -sub_020274D8: ; 0x020274D8 - mov r1, #0 - str r1, [r0, #0xc] - bx lr - .balign 4, 0 - thumb_func_end sub_020274D8 - - thumb_func_start sub_020274E0 -sub_020274E0: ; 0x020274E0 - ldr r0, [r0, #4] - bx lr - thumb_func_end sub_020274E0 - - thumb_func_start sub_020274E4 -sub_020274E4: ; 0x020274E4 - ldr r0, [r0, #8] - bx lr - thumb_func_end sub_020274E4 + .public sub_020274E4 thumb_func_start sub_020274E8 sub_020274E8: ; 0x020274E8 diff --git a/asm/unk_0202B614.s b/asm/unk_0202B614.s index 4828de381..e1c00c9d8 100644 --- a/asm/unk_0202B614.s +++ b/asm/unk_0202B614.s @@ -455,8 +455,8 @@ _0202B91A: .balign 4, 0 thumb_func_end sub_0202B908 - thumb_func_start sub_0202B930 -sub_0202B930: ; 0x0202B930 + thumb_func_start Sav2_DressupData_init +Sav2_DressupData_init: ; 0x0202B930 push {r3, r4, r5, r6, r7, lr} mov r4, #0 ldr r6, _0202B980 ; =0x00001234 @@ -500,15 +500,15 @@ _0202B95C: _0202B980: .word 0x00001234 _0202B984: .word 0x000004FC _0202B988: .word 0x000007F4 - thumb_func_end sub_0202B930 + thumb_func_end Sav2_DressupData_init - thumb_func_start sub_0202B98C -sub_0202B98C: ; 0x0202B98C + thumb_func_start Sav2_DressupData_sizeof +Sav2_DressupData_sizeof: ; 0x0202B98C ldr r0, _0202B990 ; =0x00000834 bx lr .balign 4, 0 _0202B990: .word 0x00000834 - thumb_func_end sub_0202B98C + thumb_func_end Sav2_DressupData_sizeof thumb_func_start sub_0202B994 sub_0202B994: ; 0x0202B994 diff --git a/asm/unk_0202C730.s b/asm/unk_0202C730.s index b24e362b4..5a53d1bae 100644 --- a/asm/unk_0202C730.s +++ b/asm/unk_0202C730.s @@ -8,13 +8,13 @@ _021D2AF0: .text - thumb_func_start sub_0202C730 -sub_0202C730: ; 0x0202C730 + thumb_func_start Sav2_FriendGroup_sizeof +Sav2_FriendGroup_sizeof: ; 0x0202C730 mov r0, #0x42 lsl r0, r0, #2 bx lr .balign 4, 0 - thumb_func_end sub_0202C730 + thumb_func_end Sav2_FriendGroup_sizeof thumb_func_start sub_0202C738 sub_0202C738: ; 0x0202C738 @@ -39,8 +39,8 @@ _0202C74A: .balign 4, 0 thumb_func_end sub_0202C738 - thumb_func_start sub_0202C75C -sub_0202C75C: ; 0x0202C75C + thumb_func_start Sav2_FriendGroup_init +Sav2_FriendGroup_init: ; 0x0202C75C push {r4, lr} add r4, r0, #0 mov r2, #0x42 @@ -64,7 +64,7 @@ _0202C772: .balign 4, 0 _0202C784: .word 0x0000FFFF _0202C788: .word _021D2AF0 - thumb_func_end sub_0202C75C + thumb_func_end Sav2_FriendGroup_init thumb_func_start sub_0202C78C sub_0202C78C: ; 0x0202C78C diff --git a/global.inc b/global.inc index 9a14659f7..7bd797e70 100644 --- a/global.inc +++ b/global.inc @@ -27309,8 +27309,8 @@ .public sub_0202B01C .public sub_0202B404 .public sub_0202B4E4 -.public sub_0202B930 -.public sub_0202B98C +.public Sav2_DressupData_init +.public Sav2_DressupData_sizeof .public sub_0202B994 .public sub_0202B998 .public sub_0202B9B8 @@ -27370,9 +27370,9 @@ .public sub_0202C6F4 .public sub_0202C6FC .public sub_0202C714 -.public sub_0202C730 +.public Sav2_FriendGroup_sizeof .public sub_0202C738 -.public sub_0202C75C +.public Sav2_FriendGroup_init .public sub_0202C78C .public sub_0202C7B4 .public sub_0202C7C0 diff --git a/include/save.h b/include/save.h index b5196065c..80e0637d0 100644 --- a/include/save.h +++ b/include/save.h @@ -8,7 +8,7 @@ #define SAVE_PARTY 2 #define SAVE_BAG 3 #define SAVE_FLAGS 4 -#define SAVE_UNK_5 5 +#define SAVE_FLYPOINTS 5 #define SAVE_POKEDEX 6 #define SAVE_DAYCARE 7 #define SAVE_UNK_8 8 @@ -36,8 +36,8 @@ #define SAVE_EASY_CHAT 30 #define SAVE_UNK_31 31 #define SAVE_UNK_32 32 -#define SAVE_UNK_33 33 -#define SAVE_UNK_34 34 +#define SAVE_FOLLOW_POKE 33 +#define SAVE_GSPLAYERMISC 34 #define SAVE_SAFARI_ZONE 35 #define SAVE_PHOTO_ALBUM 36 #define SAVE_UNK_37 37 @@ -47,6 +47,9 @@ #define SAVE_PCSTORAGE 41 #define SAVE_BLOCK_NUM 42 +#define SAVE_PAGE_MAX 35 +#define SAVE_SECTOR_SIZE 0x1000 + #ifndef PM_ASM typedef struct SaveBlock2 SAVEDATA; diff --git a/include/save_arrays.h b/include/save_arrays.h new file mode 100644 index 000000000..754618062 --- /dev/null +++ b/include/save_arrays.h @@ -0,0 +1,27 @@ +#ifndef POKEHEARTGOLD_SAVE_ARRAYS_H +#define POKEHEARTGOLD_SAVE_ARRAYS_H + +typedef u32 (*SAVESIZEFN)(void); +typedef void (*SAVEINITFN)(void *); + +struct SaveChunkHeader { + int id; + u32 block; + SAVESIZEFN sizeFunc; + SAVEINITFN initFunc; +}; + +struct ExtraSaveChunkHeader { + int id; + u32 sector; + SAVESIZEFN sizeFunc; + SAVEINITFN initFunc; +}; + +extern const struct SaveChunkHeader _020F64C4[]; +extern const int _020F6460; + +extern const struct ExtraSaveChunkHeader _020F6464[]; +extern const int _020F645C; + +#endif //POKEHEARTGOLD_SAVE_ARRAYS_H diff --git a/main.lsf b/main.lsf index 7f17a895e..85f026359 100644 --- a/main.lsf +++ b/main.lsf @@ -88,6 +88,7 @@ Static main Object asm/unk_02026EB4.o Object asm/unk_02027010.o Object asm/unk_020270C4.o + Object src/save_arrays.o Object src/save.o Object asm/save_s.o Object asm/sav_system_info.o diff --git a/src/save.c b/src/save.c index 4cd639f95..8ff5edee9 100644 --- a/src/save.c +++ b/src/save.c @@ -1,23 +1,6 @@ #include "save.h" #include "heap.h" -typedef u32 (*SAVESIZEFN)(void); -typedef void (*SAVEINITFN)(void *); - -struct SaveChunkHeader { - int id; - u32 block; - SAVESIZEFN sizeFunc; - SAVEINITFN sizeInit; -}; - -struct ExtraSaveChunkHeader { - int id; - u32 sector; - SAVESIZEFN sizeFunc; - SAVEINITFN sizeInit; -}; - struct SavArrayHeader { int id; u32 size; @@ -52,7 +35,7 @@ struct SaveBlock2 { BOOL unk_00004; BOOL unk_00008; u32 unk_0000C; - u8 dynamic_region[0x23000]; + u8 dynamic_region[SAVE_PAGE_MAX * SAVE_SECTOR_SIZE]; u32 unk_23010; struct SavArrayHeader arrayHeaders[SAVE_BLOCK_NUM]; // 23014 struct SaveSlotSpec saveSlotSpecs[2]; // 232B4 @@ -69,20 +52,24 @@ struct SaveBlock2 { BOOL saveWritten; SAVEDATA *_021D2228; -extern const struct SaveChunkHeader _020F64C4[]; -extern const int _020F6460; - -extern const struct ExtraSaveChunkHeader _020F6464[]; -extern const int _020F645C; - BOOL SaveDetectFlash(void); void SaveBlock2_InitSubstructs(struct SavArrayHeader *headers); void sub_02027EFC(struct SaveSlotSpec *slotSpecs, struct SavArrayHeader *headers); int sub_020277D4(SAVEDATA *saveData); -void Sav2_LoadDynamicRegion(SAVEDATA *saveData); -extern u32 sub_02027170(SAVEDATA *saveData); +BOOL Sav2_LoadDynamicRegion(SAVEDATA *saveData); void sub_020279EC(SAVEDATA *saveData, int *err1, int *err2); void Sav2_InitDynamicRegion(SAVEDATA *saveData); +int FlashClobberChunkFooter(SAVEDATA *saveData, int spec, int sector); +int sub_02027DB4(SAVEDATA *saveData); +void FlashWriteChunk(u32 offset, void *data, u32 size); +void sub_02027550(SAVEDATA *saveData, int a1); +int sub_02027564(SAVEDATA *saveData); +void Sav2_InitDynamicRegion_Internal(u8 *dynamic_region, struct SavArrayHeader *headers); + +extern void sub_0201A4BC(int); +extern void sub_0201A4CC(int); +extern u32 sub_02027170(SAVEDATA *saveData); +extern void sub_02027180(SAVEDATA *saveData); SAVEDATA *SaveBlock2_new(void) { SAVEDATA *ret; @@ -152,3 +139,105 @@ void *SavArray_get(SAVEDATA *saveData, int id) { const void *SavArray_const_get(const SAVEDATA *saveData, int id) { return SavArray_get((SAVEDATA *)saveData, id); } + +BOOL sub_020272F4(SAVEDATA *saveData) { + u8 *r6; + int i; + + r6 = AllocFromHeapAtEnd(3, SAVE_SECTOR_SIZE); + sub_0201A4BC(1); + FlashClobberChunkFooter(saveData, 0, saveData->unk_2330A == 0 ? 1 : 0); + FlashClobberChunkFooter(saveData, 1, saveData->unk_2330A == 0 ? 1 : 0); + FlashClobberChunkFooter(saveData, 0, saveData->unk_2330A); + FlashClobberChunkFooter(saveData, 1, saveData->unk_2330A); + MI_CpuFillFast(r6, -1, SAVE_SECTOR_SIZE); + for (i = 0; i < 64; i++) { + FlashWriteChunk(i * SAVE_SECTOR_SIZE, r6, SAVE_SECTOR_SIZE); + FlashWriteChunk((i + 64) * SAVE_SECTOR_SIZE, r6, SAVE_SECTOR_SIZE); + } + FreeToHeap(r6); + Sav2_InitDynamicRegion(saveData); + saveData->unk_00004 = 0; + sub_0201A4CC(1); + return TRUE; +} + +BOOL sub_020273B0(SAVEDATA *saveData) { + int sp4; + int sp0; + + if (!saveData->flashChipDetected) { + return FALSE; + } + if (Sav2_LoadDynamicRegion(saveData)) { + saveData->unk_00004 = 1; + saveData->unk_00008 = 0; + sub_020279EC(saveData, &sp4, &sp0); + sub_02027180(saveData); + return TRUE; + } + return FALSE; +} + +int sub_020273F0(SAVEDATA *saveData) { + int ret; + + if (!saveData->flashChipDetected) { + return 3; + } + if (saveData->unk_00008) { + sub_0201A4BC(1); + FlashClobberChunkFooter(saveData, 0, saveData->unk_2330A == 0 ? 1 : 0); + FlashClobberChunkFooter(saveData, 1, saveData->unk_2330A == 0 ? 1 : 0); + FlashClobberChunkFooter(saveData, 0, saveData->unk_2330A); + FlashClobberChunkFooter(saveData, 1, saveData->unk_2330A); + sub_0201A4CC(1); + } + ret = sub_02027DB4(saveData); + if (ret == 2) { + saveData->unk_00004 = 1; + saveData->unk_00008 = 0; + } + return ret; +} + +int sub_0202746C(SAVEDATA *saveData, int a1) { + int ret; + + GF_ASSERT(a1 < 2); + GF_ASSERT(saveData->unk_00008 == 0); + GF_ASSERT(saveData->unk_00004 == 1); + sub_02027550(saveData, a1); + do { + ret = sub_02027564(saveData); + } while (ret == 0 || ret == 1); + return ret; +} + +void Sav2_InitDynamicRegion(SAVEDATA *saveData) { + saveData->unk_00008 = 1; + saveData->unk_23308 = 1; + saveData->unk_23309 = 1; + Sav2_InitDynamicRegion_Internal(saveData->dynamic_region, saveData->arrayHeaders); +} + +BOOL sub_020274D0(SAVEDATA *saveData) { + return saveData->flashChipDetected; +} + +u32 sub_020274D4(SAVEDATA *saveData) { + return saveData->unk_0000C; +} + +void sub_020274D8(SAVEDATA *saveData) { + saveData->unk_0000C = 0; +} + +u32 sub_020274E0(SAVEDATA *saveData) { + return saveData->unk_00004; +} + +u32 sub_020274E4(SAVEDATA *saveData) { + return saveData->unk_00008; +} + diff --git a/src/save_arrays.c b/src/save_arrays.c new file mode 100644 index 000000000..f6a2a56ad --- /dev/null +++ b/src/save_arrays.c @@ -0,0 +1,112 @@ +#include "save_arrays.h" +#include "save.h" + +#define DECL_CHUNK(prefix) extern u32 prefix##_sizeof(void); extern void prefix##_init(void *); +#define DECL_CHUNK_EX(sizefn, initfn) extern u32 sizefn(void); extern void initfn(void *); + +DECL_CHUNK(Sav2_SysInfo) +DECL_CHUNK(Sav2_PlayerData) +DECL_CHUNK(SavArray_Party) +DECL_CHUNK(Sav2_Bag) +DECL_CHUNK(SavArray_Flags) +DECL_CHUNK(Save_FlyPoints) +DECL_CHUNK(Save_Pokedex) +DECL_CHUNK(Sav2_Daycare) +DECL_CHUNK_EX(sub_0202AEC0, sub_0202AED4) +DECL_CHUNK(Sav2_Misc) +DECL_CHUNK_EX(sub_0203B920, sub_0203B928) +DECL_CHUNK_EX(sub_020290B8, sub_020290C8) +DECL_CHUNK(Sav2_DressupData) +DECL_CHUNK(Sav2_Mailbox) +DECL_CHUNK(Sav2_FriendGroup) +DECL_CHUNK_EX(sub_0202C9A0, sub_0202C9A8) +DECL_CHUNK(GameStats) +DECL_CHUNK(Sav2_SealCase) +DECL_CHUNK(Sav2_Chatot) +DECL_CHUNK_EX(sub_02031000, sub_02031008) +DECL_CHUNK_EX(sub_0202D938, sub_0202D93C) +DECL_CHUNK(Save_Roamers) +DECL_CHUNK_EX(sub_0202DB40, sub_0202DB44) +DECL_CHUNK_EX(sub_0202E41C, sub_0202E424) +DECL_CHUNK_EX(sub_0202E4F4, sub_0202E4FC) +DECL_CHUNK_EX(sub_0202C034, sub_0202C03C) +DECL_CHUNK_EX(sub_0202CA24, sub_0202CA2C) +DECL_CHUNK(Save_MysteryGift) +DECL_CHUNK_EX(sub_0202EB30, sub_0202EB38) +DECL_CHUNK_EX(sub_02031AF0, sub_02031AF4) +DECL_CHUNK(Sav2_EasyChat) +DECL_CHUNK_EX(sub_0203170C, sub_02031710) +DECL_CHUNK_EX(sub_020318C8, sub_020318CC) +DECL_CHUNK(Sav2_FollowPoke) +DECL_CHUNK(SaveData_GSPlayerMisc) +DECL_CHUNK(Save_SafariZone) +DECL_CHUNK(Save_PhotoAlbum) +DECL_CHUNK_EX(sub_02031904, sub_0203190C) +DECL_CHUNK(Save_ApricornBox) +DECL_CHUNK(Pokewalker) +DECL_CHUNK_EX(sub_02032774, sub_02032788) +DECL_CHUNK(PCStorage) + +const struct SaveChunkHeader _020F64C4[] = { + { SAVE_SYSINFO, 0, Sav2_SysInfo_sizeof, Sav2_SysInfo_init}, + { SAVE_PLAYERDATA, 0, Sav2_PlayerData_sizeof, Sav2_PlayerData_init}, + { SAVE_PARTY, 0, SavArray_Party_sizeof, SavArray_Party_init}, + { SAVE_BAG, 0, Sav2_Bag_sizeof, Sav2_Bag_init}, + { SAVE_FLAGS, 0, SavArray_Flags_sizeof, SavArray_Flags_init}, + { SAVE_FLYPOINTS, 0, Save_FlyPoints_sizeof, Save_FlyPoints_init}, + { SAVE_POKEDEX, 0, Save_Pokedex_sizeof, Save_Pokedex_init}, + { SAVE_DAYCARE, 0, Sav2_Daycare_sizeof, Sav2_Daycare_init}, + { SAVE_UNK_8, 0, sub_0202AEC0, sub_0202AED4}, + { SAVE_MISC, 0, Sav2_Misc_sizeof, Sav2_Misc_init}, + { SAVE_UNK_10, 0, sub_0203B920, sub_0203B928}, + { SAVE_UNK_11, 0, sub_020290B8, sub_020290C8}, + { SAVE_DRESSUP_DATA, 0, Sav2_DressupData_sizeof, Sav2_DressupData_init}, + { SAVE_MAILBOX, 0, Sav2_Mailbox_sizeof, Sav2_Mailbox_init}, + { SAVE_FRIEND_GROUP, 0, Sav2_FriendGroup_sizeof, Sav2_FriendGroup_init}, + { SAVE_UNK_15, 0, sub_0202C9A0, sub_0202C9A8}, + { SAVE_GAMESTATS, 0, GameStats_sizeof, GameStats_init}, + { SAVE_SEAL_CASE, 0, Sav2_SealCase_sizeof, Sav2_SealCase_init}, + { SAVE_CHATOT, 0, Sav2_Chatot_sizeof, Sav2_Chatot_init}, + { SAVE_UNK_19, 0, sub_02031000, sub_02031008}, + { SAVE_UNK_20, 0, sub_0202D938, sub_0202D93C}, + { SAVE_ROAMER, 0, Save_Roamers_sizeof, Save_Roamers_init}, + { SAVE_UNK_22, 0, sub_0202DB40, sub_0202DB44}, + { SAVE_UNK_23, 0, sub_0202E41C, sub_0202E424}, + { SAVE_UNK_24, 0, sub_0202E4F4, sub_0202E4FC}, + { SAVE_UNK_25, 0, sub_0202C034, sub_0202C03C}, + { SAVE_UNK_26, 0, sub_0202CA24, sub_0202CA2C}, + { SAVE_MYSTERY_GIFT, 0, Save_MysteryGift_sizeof, Save_MysteryGift_init}, + { SAVE_UNK_28, 0, sub_0202EB30, sub_0202EB38}, + { SAVE_UNK_29, 0, sub_02031AF0, sub_02031AF4}, + { SAVE_EASY_CHAT, 0, Sav2_EasyChat_sizeof, Sav2_EasyChat_init}, + { SAVE_UNK_31, 0, sub_0203170C, sub_02031710}, + { SAVE_UNK_32, 0, sub_020318C8, sub_020318CC}, + { SAVE_FOLLOW_POKE, 0, Sav2_FollowPoke_sizeof, Sav2_FollowPoke_init}, + { SAVE_GSPLAYERMISC, 0, SaveData_GSPlayerMisc_sizeof, SaveData_GSPlayerMisc_init}, + { SAVE_SAFARI_ZONE, 0, Save_SafariZone_sizeof, Save_SafariZone_init}, + { SAVE_PHOTO_ALBUM, 0, Save_PhotoAlbum_sizeof, Save_PhotoAlbum_init}, + { SAVE_UNK_37, 0, sub_02031904, sub_0203190C}, + { SAVE_APRICORN_BOX, 0, Save_ApricornBox_sizeof, Save_ApricornBox_init}, + { SAVE_POKEWALKER, 0, Pokewalker_sizeof, Pokewalker_init}, + { SAVE_UNK_40, 0, sub_02032774, sub_02032788}, + { SAVE_PCSTORAGE, 1, PCStorage_sizeof, PCStorage_init}, +}; +const int _020F6460 = NELEMS(_020F64C4); + +DECL_CHUNK(Sav2_HOF) +DECL_CHUNK_EX(sub_020312A4, sub_020312AC) +DECL_CHUNK_EX(sub_0202FBCC, sub_0202FBD4) +DECL_CHUNK_EX(sub_0202FBCC, sub_0202FBD4) +DECL_CHUNK_EX(sub_0202FBCC, sub_0202FBD4) +DECL_CHUNK_EX(sub_0202FBCC, sub_0202FBD4) + +const struct ExtraSaveChunkHeader _020F6464[] = { + { 0, SAVE_PAGE_MAX, Sav2_HOF_sizeof, Sav2_HOF_init }, + { 1, SAVE_PAGE_MAX + 3, sub_020312A4, sub_020312AC }, + { 2, SAVE_PAGE_MAX + 4, sub_0202FBCC, sub_0202FBD4 }, + { 3, SAVE_PAGE_MAX + 6, sub_0202FBCC, sub_0202FBD4 }, + { 4, SAVE_PAGE_MAX + 8, sub_0202FBCC, sub_0202FBD4 }, + { 5, SAVE_PAGE_MAX + 10, sub_0202FBCC, sub_0202FBD4 }, +}; + +const int _020F645C = NELEMS(_020F6464);