mirror of
https://github.com/Ninjdai1/pokeemerald.git
synced 2024-12-26 03:34:15 +01:00
begin save.s decomp, thanks revo!
This commit is contained in:
parent
907e281de6
commit
a3f602f17c
@ -15702,7 +15702,7 @@ atk60_cmd60: @ 804E868
|
||||
ldr r0, =gBattlescriptCurrInstr
|
||||
ldr r0, [r0]
|
||||
ldrb r0, [r0, 0x1]
|
||||
bl sav12_xor_increment
|
||||
bl IncrementGameStat
|
||||
_0804E882:
|
||||
ldr r1, =gBattlescriptCurrInstr
|
||||
ldr r0, [r1]
|
||||
|
@ -259,12 +259,12 @@ _0813C152:
|
||||
movs r4, 0x19
|
||||
_0813C154:
|
||||
adds r0, r4, 0
|
||||
bl sub_80847F8
|
||||
bl GetGameStat
|
||||
ldr r1, =0x0000270e
|
||||
cmp r0, r1
|
||||
bhi _0813C166
|
||||
adds r0, r4, 0
|
||||
bl sav12_xor_increment
|
||||
bl IncrementGameStat
|
||||
_0813C166:
|
||||
pop {r4}
|
||||
pop {r0}
|
||||
@ -465,7 +465,7 @@ sub_813C2F4: @ 813C2F4
|
||||
sub sp, 0xC
|
||||
ldr r4, =gStringVar1
|
||||
movs r0, 0x17
|
||||
bl sub_80847F8
|
||||
bl GetGameStat
|
||||
adds r1, r0, 0
|
||||
adds r0, r4, 0
|
||||
movs r2, 0
|
||||
@ -473,7 +473,7 @@ sub_813C2F4: @ 813C2F4
|
||||
bl ConvertIntToDecimalStringN
|
||||
ldr r4, =gStringVar2
|
||||
movs r0, 0x18
|
||||
bl sub_80847F8
|
||||
bl GetGameStat
|
||||
adds r1, r0, 0
|
||||
adds r0, r4, 0
|
||||
movs r2, 0
|
||||
@ -481,7 +481,7 @@ sub_813C2F4: @ 813C2F4
|
||||
bl ConvertIntToDecimalStringN
|
||||
ldr r4, =gStringVar3
|
||||
movs r0, 0x19
|
||||
bl sub_80847F8
|
||||
bl GetGameStat
|
||||
adds r1, r0, 0
|
||||
adds r0, r4, 0
|
||||
movs r2, 0
|
||||
|
@ -136,9 +136,9 @@ _080B06F2:
|
||||
movs r1, 0
|
||||
bl task_add_01_battle_start
|
||||
movs r0, 0x7
|
||||
bl sav12_xor_increment
|
||||
bl IncrementGameStat
|
||||
movs r0, 0x8
|
||||
bl sav12_xor_increment
|
||||
bl IncrementGameStat
|
||||
bl sub_80EECC8
|
||||
bl sub_80B1218
|
||||
pop {r4}
|
||||
@ -166,9 +166,9 @@ sub_80B072C: @ 80B072C
|
||||
movs r1, 0
|
||||
bl task_add_01_battle_start
|
||||
movs r0, 0x7
|
||||
bl sav12_xor_increment
|
||||
bl IncrementGameStat
|
||||
movs r0, 0x8
|
||||
bl sav12_xor_increment
|
||||
bl IncrementGameStat
|
||||
bl sub_80EECC8
|
||||
bl sub_80B1218
|
||||
pop {r0}
|
||||
@ -217,9 +217,9 @@ sub_80B07B4: @ 80B07B4
|
||||
movs r1, 0
|
||||
bl task_add_01_battle_start
|
||||
movs r0, 0x7
|
||||
bl sav12_xor_increment
|
||||
bl IncrementGameStat
|
||||
movs r0, 0x8
|
||||
bl sav12_xor_increment
|
||||
bl IncrementGameStat
|
||||
bl sub_80EECC8
|
||||
bl sub_80B1218
|
||||
pop {r0}
|
||||
@ -236,9 +236,9 @@ task_add_01_battle_start_with_music_and_stats: @ 80B0804
|
||||
movs r1, 0
|
||||
bl task_add_01_battle_start
|
||||
movs r0, 0x7
|
||||
bl sav12_xor_increment
|
||||
bl IncrementGameStat
|
||||
movs r0, 0x9
|
||||
bl sav12_xor_increment
|
||||
bl IncrementGameStat
|
||||
bl sub_80B1234
|
||||
pop {r0}
|
||||
bx r0
|
||||
@ -267,9 +267,9 @@ _080B0846:
|
||||
bl task_add_01_battle_start
|
||||
_080B0856:
|
||||
movs r0, 0x7
|
||||
bl sav12_xor_increment
|
||||
bl IncrementGameStat
|
||||
movs r0, 0x9
|
||||
bl sav12_xor_increment
|
||||
bl IncrementGameStat
|
||||
bl sub_80B1234
|
||||
pop {r0}
|
||||
bx r0
|
||||
@ -315,9 +315,9 @@ sub_80B08A8: @ 80B08A8
|
||||
movs r1, 0
|
||||
bl task_add_01_battle_start
|
||||
movs r0, 0x7
|
||||
bl sav12_xor_increment
|
||||
bl IncrementGameStat
|
||||
movs r0, 0x8
|
||||
bl sav12_xor_increment
|
||||
bl IncrementGameStat
|
||||
bl sub_80EECC8
|
||||
bl sub_80B1218
|
||||
pop {r0}
|
||||
@ -342,9 +342,9 @@ sub_80B08EC: @ 80B08EC
|
||||
movs r1, 0
|
||||
bl task_add_01_battle_start
|
||||
movs r0, 0x7
|
||||
bl sav12_xor_increment
|
||||
bl IncrementGameStat
|
||||
movs r0, 0x8
|
||||
bl sav12_xor_increment
|
||||
bl IncrementGameStat
|
||||
bl sub_80EECC8
|
||||
bl sub_80B1218
|
||||
pop {r0}
|
||||
@ -444,9 +444,9 @@ _080B09F4:
|
||||
bl task_add_01_battle_start
|
||||
_080B09FE:
|
||||
movs r0, 0x7
|
||||
bl sav12_xor_increment
|
||||
bl IncrementGameStat
|
||||
movs r0, 0x8
|
||||
bl sav12_xor_increment
|
||||
bl IncrementGameStat
|
||||
bl sub_80EECC8
|
||||
bl sub_80B1218
|
||||
pop {r4}
|
||||
@ -482,9 +482,9 @@ _080B0A50:
|
||||
bl task_add_01_battle_start
|
||||
_080B0A5A:
|
||||
movs r0, 0x7
|
||||
bl sav12_xor_increment
|
||||
bl IncrementGameStat
|
||||
movs r0, 0x8
|
||||
bl sav12_xor_increment
|
||||
bl IncrementGameStat
|
||||
bl sub_80EECC8
|
||||
bl sub_80B1218
|
||||
pop {r0}
|
||||
@ -540,9 +540,9 @@ _080B0AD6:
|
||||
ldr r1, =0x000001df
|
||||
bl task_add_01_battle_start
|
||||
movs r0, 0x7
|
||||
bl sav12_xor_increment
|
||||
bl IncrementGameStat
|
||||
movs r0, 0x8
|
||||
bl sav12_xor_increment
|
||||
bl IncrementGameStat
|
||||
bl sub_80EECC8
|
||||
bl sub_80B1218
|
||||
pop {r0}
|
||||
@ -1392,9 +1392,9 @@ sub_80B11A8: @ 80B11A8
|
||||
bl prev_quest_postbuffer_cursor_backup_reset
|
||||
bl overworld_poison_timer_set
|
||||
movs r0, 0x7
|
||||
bl sav12_xor_increment
|
||||
bl IncrementGameStat
|
||||
movs r0, 0x8
|
||||
bl sav12_xor_increment
|
||||
bl IncrementGameStat
|
||||
bl sub_80EECC8
|
||||
bl sub_80B1218
|
||||
_080B11F0:
|
||||
@ -1418,7 +1418,7 @@ sub_80B1204: @ 80B1204
|
||||
sub_80B1218: @ 80B1218
|
||||
push {lr}
|
||||
movs r0, 0x8
|
||||
bl sub_80847F8
|
||||
bl GetGameStat
|
||||
movs r1, 0x3C
|
||||
bl __umodsi3
|
||||
cmp r0, 0
|
||||
@ -1433,7 +1433,7 @@ _080B122E:
|
||||
sub_80B1234: @ 80B1234
|
||||
push {lr}
|
||||
movs r0, 0x9
|
||||
bl sub_80847F8
|
||||
bl GetGameStat
|
||||
movs r1, 0x14
|
||||
bl __umodsi3
|
||||
cmp r0, 0
|
||||
|
@ -5050,12 +5050,12 @@ _08082292:
|
||||
cmp r0, 0
|
||||
bne _080822A8
|
||||
movs r0, 0x22
|
||||
bl sav12_xor_increment
|
||||
bl IncrementGameStat
|
||||
b _08082458
|
||||
.pool
|
||||
_080822A8:
|
||||
movs r0, 0x21
|
||||
bl sav12_xor_increment
|
||||
bl IncrementGameStat
|
||||
b _08082458
|
||||
_080822B0:
|
||||
ldr r6, =gUnknown_020322A4
|
||||
|
@ -126,7 +126,7 @@ sub_817ADC0: @ 817ADC0
|
||||
adds r4, r0, 0
|
||||
lsls r4, 24
|
||||
lsrs r4, 24
|
||||
bl calls_flash_erase_block
|
||||
bl ClearSaveData
|
||||
adds r0, r4, 0
|
||||
bl DestroyTask
|
||||
ldr r0, =sub_817AFD4
|
||||
|
@ -543,7 +543,7 @@ _080F5D2A:
|
||||
cmp r0, 0
|
||||
bne _080F5D58
|
||||
movs r0, 0x23
|
||||
bl sav12_xor_increment
|
||||
bl IncrementGameStat
|
||||
ldr r1, =gSpecialVar_0x8005
|
||||
movs r0, 0x8
|
||||
strh r0, [r1]
|
||||
@ -580,7 +580,7 @@ _080F5D58:
|
||||
bl VarSet
|
||||
bl sub_8076D5C
|
||||
movs r0, 0x1
|
||||
bl save_game_when_memory_present
|
||||
bl TrySavingData
|
||||
bl sav2_gender2_inplace_and_xFE
|
||||
adds r0, r5, 0
|
||||
adds r1, r4, 0
|
||||
@ -662,7 +662,7 @@ _080F5E2E:
|
||||
.pool
|
||||
_080F5E78:
|
||||
movs r0, 0x24
|
||||
bl sav12_xor_increment
|
||||
bl IncrementGameStat
|
||||
ldr r1, =gUnknown_02039F20
|
||||
ldr r0, =gUnknown_02039F25
|
||||
ldrb r0, [r0]
|
||||
@ -671,7 +671,7 @@ _080F5E78:
|
||||
cmp r0, 0
|
||||
bne _080F5E92
|
||||
movs r0, 0x25
|
||||
bl sav12_xor_increment
|
||||
bl IncrementGameStat
|
||||
_080F5E92:
|
||||
ldr r0, =gUnknown_02039F2E
|
||||
ldrb r0, [r0]
|
||||
|
@ -1661,7 +1661,7 @@ _0813E99E:
|
||||
movs r1, 0x3
|
||||
bl pokedex_flag_operation
|
||||
movs r0, 0xE
|
||||
bl sav12_xor_increment
|
||||
bl IncrementGameStat
|
||||
b _0813F1A4
|
||||
.pool
|
||||
_0813EA1C:
|
||||
@ -2845,7 +2845,7 @@ _0813F4F2:
|
||||
movs r1, 0x3
|
||||
bl pokedex_flag_operation
|
||||
movs r0, 0xE
|
||||
bl sav12_xor_increment
|
||||
bl IncrementGameStat
|
||||
b _0813FCC4
|
||||
.pool
|
||||
_0813F570:
|
||||
|
@ -228,7 +228,7 @@ _0809C070:
|
||||
cmp r0, 0
|
||||
beq _0809C096
|
||||
movs r0, 0x5
|
||||
bl sav12_xor_increment
|
||||
bl IncrementGameStat
|
||||
bl increment_var_x4026_on_birth_island_modulo_100
|
||||
mov r0, sp
|
||||
adds r1, r4, 0
|
||||
@ -1395,7 +1395,7 @@ _0809CA48:
|
||||
cmp r0, 0
|
||||
beq _0809CA64
|
||||
movs r0, 0xD
|
||||
bl sav12_xor_increment
|
||||
bl IncrementGameStat
|
||||
ldr r0, =gUnknown_08291FC0
|
||||
bl script_env_1_execute_new_script
|
||||
b _0809CB28
|
||||
|
@ -993,7 +993,7 @@ _0808B0E4:
|
||||
cmp r0, 0
|
||||
beq _0808B108
|
||||
movs r0, 0x2B
|
||||
bl sav12_xor_increment
|
||||
bl IncrementGameStat
|
||||
movs r0, 0x6
|
||||
b _0808B152
|
||||
_0808B108:
|
||||
|
@ -519,16 +519,16 @@ sub_81739C4: @ 81739C4
|
||||
push {r4,r5,lr}
|
||||
lsls r0, 24
|
||||
lsrs r4, r0, 24
|
||||
ldr r1, =gUnknown_03006214
|
||||
ldr r1, =gGameContinueCallback
|
||||
ldr r0, =sub_81736D8
|
||||
str r0, [r1]
|
||||
movs r0, 0x3
|
||||
bl save_game_when_memory_present
|
||||
bl TrySavingData
|
||||
lsls r0, 24
|
||||
lsrs r0, 24
|
||||
cmp r0, 0xFF
|
||||
bne _08173A34
|
||||
ldr r0, =gUnknown_030061FC
|
||||
ldr r0, =gDamagedSaveSectors
|
||||
ldr r0, [r0]
|
||||
cmp r0, 0
|
||||
beq _08173A34
|
||||
@ -1651,7 +1651,7 @@ _081743BC:
|
||||
_081743C6:
|
||||
strh r0, [r1, 0x8]
|
||||
movs r0, 0xA
|
||||
bl sub_80847F8
|
||||
bl GetGameStat
|
||||
ldr r2, =gTasks
|
||||
adds r1, r5, r6
|
||||
lsls r1, 3
|
||||
|
@ -309,7 +309,7 @@ c2_copyright_1: @ 816CEAC
|
||||
lsrs r0, 16
|
||||
bl InitSaveBlockPointersWithRandomOffset
|
||||
bl sub_808447C
|
||||
bl sub_8152680
|
||||
bl ResetSaveCounters
|
||||
movs r0, 0
|
||||
bl sub_81534D0
|
||||
ldr r0, =gUnknown_03006210
|
||||
|
@ -536,7 +536,7 @@ ItemUseOutOfBattle_Itemfinder: @ 80FD490
|
||||
lsls r4, 24
|
||||
lsrs r4, 24
|
||||
movs r0, 0x27
|
||||
bl sav12_xor_increment
|
||||
bl IncrementGameStat
|
||||
ldr r1, =gUnknown_0203A0F4
|
||||
ldr r0, =ItemUseOnFieldCB_Itemfinder
|
||||
str r0, [r1]
|
||||
|
14
asm/link.s
14
asm/link.s
@ -622,7 +622,7 @@ _08009956:
|
||||
cmp r0, 0
|
||||
beq _08009968
|
||||
movs r0, 0x1
|
||||
bl save_game_when_memory_present
|
||||
bl TrySavingData
|
||||
_08009968:
|
||||
ldrh r1, [r4, 0x2E]
|
||||
movs r0, 0x4
|
||||
@ -20827,7 +20827,7 @@ _08013FFC:
|
||||
movs r2, 0x64
|
||||
bl memcpy
|
||||
movs r0, 0x32
|
||||
bl sav12_xor_increment
|
||||
bl IncrementGameStat
|
||||
bl sub_800A5B4
|
||||
b _0801405A
|
||||
.pool
|
||||
@ -29860,7 +29860,7 @@ _08018EC0:
|
||||
.pool
|
||||
_08018ECC:
|
||||
movs r0, 0
|
||||
bl save_game_when_memory_present
|
||||
bl TrySavingData
|
||||
b _08018EEC
|
||||
_08018ED4:
|
||||
ldr r0, =gUnknown_085EF5E0
|
||||
@ -33410,7 +33410,7 @@ _0801AB1E:
|
||||
cmp r4, r6
|
||||
ble _0801AB1E
|
||||
movs r0, 0x32
|
||||
bl sav12_xor_increment
|
||||
bl IncrementGameStat
|
||||
bl calc_player_party_count
|
||||
ldr r0, =gUnknown_02038BCA
|
||||
movs r2, 0xC0
|
||||
@ -38746,7 +38746,7 @@ _0801D6D8:
|
||||
b _0801D7FE
|
||||
_0801D6EA:
|
||||
ldrb r0, [r2, 0x4]
|
||||
bl sub_80847F8
|
||||
bl GetGameStat
|
||||
adds r2, r0, 0
|
||||
adds r0, r4, 0
|
||||
movs r1, 0x12
|
||||
@ -41252,7 +41252,7 @@ _0801EB04:
|
||||
bne _0801EBC2
|
||||
bl sub_8076D5C
|
||||
movs r0, 0
|
||||
bl save_game_when_memory_present
|
||||
bl TrySavingData
|
||||
ldr r0, =gUnknown_02022C84
|
||||
ldr r1, [r0]
|
||||
movs r0, 0x8
|
||||
@ -52525,7 +52525,7 @@ sub_8024578: @ 8024578
|
||||
adds r4, r0, 0
|
||||
movs r5, 0
|
||||
movs r0, 0x33
|
||||
bl sav12_xor_increment
|
||||
bl IncrementGameStat
|
||||
strb r5, [r4, 0xD]
|
||||
movs r1, 0
|
||||
strh r5, [r4, 0x10]
|
||||
|
@ -398,23 +398,23 @@ _08076E7A:
|
||||
.pool
|
||||
thumb_func_end save_deserialize_npcs
|
||||
|
||||
thumb_func_start save_serialize_game
|
||||
save_serialize_game: @ 8076EAC
|
||||
thumb_func_start SaveSerializedGame
|
||||
SaveSerializedGame: @ 8076EAC
|
||||
push {lr}
|
||||
bl copy_player_party_to_sav1
|
||||
bl save_serialize_npcs
|
||||
pop {r0}
|
||||
bx r0
|
||||
thumb_func_end save_serialize_game
|
||||
thumb_func_end SaveSerializedGame
|
||||
|
||||
thumb_func_start save_deserialize_game
|
||||
save_deserialize_game: @ 8076EBC
|
||||
thumb_func_start LoadSerializedGame
|
||||
LoadSerializedGame: @ 8076EBC
|
||||
push {lr}
|
||||
bl copy_player_party_from_sav1
|
||||
bl save_deserialize_npcs
|
||||
pop {r0}
|
||||
bx r0
|
||||
thumb_func_end save_deserialize_game
|
||||
thumb_func_end LoadSerializedGame
|
||||
|
||||
thumb_func_start copy_bags_and_unk_data_from_save_blocks
|
||||
copy_bags_and_unk_data_from_save_blocks: @ 8076ECC
|
||||
|
@ -1775,7 +1775,7 @@ sub_8120E74: @ 8120E74
|
||||
bne _08120E80
|
||||
movs r0, 0
|
||||
_08120E80:
|
||||
bl sub_80847F8
|
||||
bl GetGameStat
|
||||
pop {r1}
|
||||
bx r1
|
||||
thumb_func_end sub_8120E74
|
||||
|
@ -484,7 +484,7 @@ _08178D74:
|
||||
cmp r0, 0
|
||||
bne _08178E34
|
||||
movs r0, 0
|
||||
bl save_game_when_memory_present
|
||||
bl TrySavingData
|
||||
b _08178E34
|
||||
.pool
|
||||
_08178DBC:
|
||||
|
@ -1269,7 +1269,7 @@ _0809F340:
|
||||
.pool
|
||||
_0809F398:
|
||||
movs r0, 0
|
||||
bl save_game_when_memory_present
|
||||
bl TrySavingData
|
||||
lsls r0, 24
|
||||
lsrs r0, 24
|
||||
cmp r0, 0x1
|
||||
|
16
asm/rom4.s
16
asm/rom4.s
@ -155,16 +155,16 @@ _080847AC:
|
||||
bx r0
|
||||
thumb_func_end sub_80847A8
|
||||
|
||||
thumb_func_start sav12_xor_increment
|
||||
@ void sav12_xor_increment(u8 a1)
|
||||
sav12_xor_increment: @ 80847C4
|
||||
thumb_func_start IncrementGameStat
|
||||
@ void IncrementGameStat(u8 a1)
|
||||
IncrementGameStat: @ 80847C4
|
||||
push {r4,lr}
|
||||
lsls r0, 24
|
||||
lsrs r4, r0, 24
|
||||
cmp r4, 0x33
|
||||
bhi _080847EC
|
||||
adds r0, r4, 0
|
||||
bl sub_80847F8
|
||||
bl GetGameStat
|
||||
adds r1, r0, 0
|
||||
ldr r0, =0x00fffffe
|
||||
cmp r1, r0
|
||||
@ -182,10 +182,10 @@ _080847EC:
|
||||
pop {r0}
|
||||
bx r0
|
||||
.pool
|
||||
thumb_func_end sav12_xor_increment
|
||||
thumb_func_end IncrementGameStat
|
||||
|
||||
thumb_func_start sub_80847F8
|
||||
sub_80847F8: @ 80847F8
|
||||
thumb_func_start GetGameStat
|
||||
GetGameStat: @ 80847F8
|
||||
push {lr}
|
||||
lsls r0, 24
|
||||
lsrs r1, r0, 24
|
||||
@ -210,7 +210,7 @@ _08084828:
|
||||
_0808482A:
|
||||
pop {r1}
|
||||
bx r1
|
||||
thumb_func_end sub_80847F8
|
||||
thumb_func_end GetGameStat
|
||||
|
||||
thumb_func_start sav12_xor_set
|
||||
sav12_xor_set: @ 8084830
|
||||
|
10
asm/rom6.s
10
asm/rom6.s
@ -330,7 +330,7 @@ oei_rocksmash: @ 81356E4
|
||||
strh r0, [r1, 0x18]
|
||||
strh r2, [r1, 0x1A]
|
||||
movs r0, 0x13
|
||||
bl sav12_xor_increment
|
||||
bl IncrementGameStat
|
||||
movs r0, 0
|
||||
pop {r1}
|
||||
bx r1
|
||||
@ -4055,7 +4055,7 @@ _08137760:
|
||||
bl FlagSet
|
||||
_0813776C:
|
||||
movs r0, 0x1
|
||||
bl sub_80847F8
|
||||
bl GetGameStat
|
||||
cmp r0, 0
|
||||
bne _0813778E
|
||||
ldr r0, =gSaveBlock2Ptr
|
||||
@ -4132,7 +4132,7 @@ _0813780A:
|
||||
cmp r7, 0x1
|
||||
bne _0813785A
|
||||
movs r0, 0x2A
|
||||
bl sav12_xor_increment
|
||||
bl IncrementGameStat
|
||||
ldr r0, =0x0000089b
|
||||
bl FlagSet
|
||||
mov r3, sp
|
||||
@ -7336,7 +7336,7 @@ sub_8139200: @ 8139200
|
||||
sub_8139228: @ 8139228
|
||||
push {lr}
|
||||
movs r0, 0x20
|
||||
bl sub_80847F8
|
||||
bl GetGameStat
|
||||
lsls r0, 16
|
||||
lsrs r0, 16
|
||||
pop {r1}
|
||||
@ -7501,7 +7501,7 @@ sub_8139370: @ 8139370
|
||||
push {r4,lr}
|
||||
sub sp, 0x4
|
||||
movs r0, 0x2A
|
||||
bl sav12_xor_increment
|
||||
bl IncrementGameStat
|
||||
ldr r0, =0x0000089b
|
||||
bl FlagSet
|
||||
movs r1, 0x1
|
||||
|
@ -24469,7 +24469,7 @@ sub_80D3A6C: @ 80D3A6C
|
||||
strh r0, [r1, 0x18]
|
||||
strh r2, [r1, 0x1A]
|
||||
movs r0, 0x12
|
||||
bl sav12_xor_increment
|
||||
bl IncrementGameStat
|
||||
movs r0, 0
|
||||
pop {r1}
|
||||
bx r1
|
||||
@ -24507,7 +24507,7 @@ sub_80D3ABC: @ 80D3ABC
|
||||
strh r0, [r1, 0x18]
|
||||
strh r2, [r1, 0x1A]
|
||||
movs r0, 0x12
|
||||
bl sav12_xor_increment
|
||||
bl IncrementGameStat
|
||||
movs r0, 0
|
||||
pop {r1}
|
||||
bx r1
|
||||
|
@ -23687,7 +23687,7 @@ _081650DC:
|
||||
cmp r0, 0
|
||||
beq _08165132
|
||||
movs r0, 0x2A
|
||||
bl sav12_xor_increment
|
||||
bl IncrementGameStat
|
||||
mov r0, r8
|
||||
cmp r0, 0x1
|
||||
ble _08165110
|
||||
|
@ -31,7 +31,7 @@ sub_81700F8: @ 81700F8
|
||||
lsrs r0, 16
|
||||
bl InitSaveBlockPointersWithRandomOffset
|
||||
bl sub_808447C
|
||||
bl sub_8152680
|
||||
bl ResetSaveCounters
|
||||
movs r0, 0
|
||||
bl sub_81534D0
|
||||
ldr r0, =gUnknown_03006210
|
||||
|
@ -33562,7 +33562,7 @@ sub_8196D74: @ 8196D74
|
||||
bl __divsi3
|
||||
mov r8, r0
|
||||
movs r0, 0x9
|
||||
bl sub_80847F8
|
||||
bl GetGameStat
|
||||
eors r4, r5
|
||||
eors r5, r0
|
||||
adds r4, r5
|
||||
@ -60482,7 +60482,7 @@ _081A4C4E:
|
||||
bl copy_player_party_from_sav1
|
||||
bl sub_8076D5C
|
||||
movs r0, 0x1
|
||||
bl save_game_when_memory_present
|
||||
bl TrySavingData
|
||||
bl sav2_gender2_inplace_and_xFE
|
||||
strb r5, [r4]
|
||||
adds r4, r7, 0
|
||||
@ -65191,7 +65191,7 @@ sub_81A7418: @ 81A7418
|
||||
strb r0, [r1]
|
||||
bl save_serialize_map
|
||||
movs r0, 0x1
|
||||
bl save_game_when_memory_present
|
||||
bl TrySavingData
|
||||
pop {r4}
|
||||
pop {r0}
|
||||
bx r0
|
||||
@ -68828,7 +68828,7 @@ sub_81A9134: @ 81A9134
|
||||
strb r0, [r1]
|
||||
bl save_serialize_map
|
||||
movs r0, 0x1
|
||||
bl save_game_when_memory_present
|
||||
bl TrySavingData
|
||||
pop {r4}
|
||||
pop {r0}
|
||||
bx r0
|
||||
|
@ -25858,7 +25858,7 @@ sub_81CBE50: @ 81CBE50
|
||||
lsls r0, 16
|
||||
lsrs r4, r0, 16
|
||||
movs r0, 0x9
|
||||
bl sub_80847F8
|
||||
bl GetGameStat
|
||||
adds r1, r0, 0
|
||||
ldr r0, =0x0001869f
|
||||
cmp r1, r0
|
||||
|
@ -2559,7 +2559,7 @@ sub_8141800: @ 8141800
|
||||
cmp r0, 0
|
||||
beq _08141888
|
||||
movs r0, 0x1D
|
||||
bl sub_80847F8
|
||||
bl GetGameStat
|
||||
ldrh r1, [r4, 0x1E]
|
||||
adds r1, 0x1
|
||||
strh r1, [r4, 0x1E]
|
||||
|
@ -41,7 +41,7 @@ ResetSafariZoneFlag: @ 80FC0C4
|
||||
sub_80FC0D4: @ 80FC0D4
|
||||
push {lr}
|
||||
movs r0, 0x11
|
||||
bl sav12_xor_increment
|
||||
bl IncrementGameStat
|
||||
bl SetSafariZoneFlag
|
||||
bl sub_80FC244
|
||||
ldr r1, =gUnknown_0203A04C
|
||||
|
1748
asm/save.s
1748
asm/save.s
File diff suppressed because it is too large
Load Diff
@ -44,8 +44,8 @@ sub_8178F44: @ 8178F44
|
||||
.pool
|
||||
thumb_func_end sub_8178F44
|
||||
|
||||
thumb_func_start fullscreen_save_activate
|
||||
fullscreen_save_activate: @ 8178F90
|
||||
thumb_func_start DoSaveFailedScreen
|
||||
DoSaveFailedScreen: @ 8178F90
|
||||
push {r4,lr}
|
||||
adds r4, r0, 0
|
||||
lsls r4, 24
|
||||
@ -66,7 +66,7 @@ fullscreen_save_activate: @ 8178F90
|
||||
pop {r0}
|
||||
bx r0
|
||||
.pool
|
||||
thumb_func_end fullscreen_save_activate
|
||||
thumb_func_end DoSaveFailedScreen
|
||||
|
||||
thumb_func_start sub_8178FC8
|
||||
sub_8178FC8: @ 8178FC8
|
||||
@ -325,7 +325,7 @@ sub_8179288: @ 8179288
|
||||
ldr r0, =gUnknown_0203BCFE
|
||||
movs r1, 0x1
|
||||
strh r1, [r0]
|
||||
ldr r1, =gUnknown_030061FC
|
||||
ldr r1, =gDamagedSaveSectors
|
||||
ldr r0, [r1]
|
||||
cmp r0, 0
|
||||
beq _081792EC
|
||||
@ -346,7 +346,7 @@ _0817929C:
|
||||
bl sub_8178F44
|
||||
ldr r0, =gUnknown_0203BCFC
|
||||
ldrb r0, [r0]
|
||||
bl calls_flash_erase_block_3
|
||||
bl HandleSavingData
|
||||
ldr r0, [r6]
|
||||
cmp r0, 0
|
||||
beq _081792DC
|
||||
@ -381,7 +381,7 @@ _0817931C:
|
||||
ldrb r0, [r0]
|
||||
movs r1, 0x11
|
||||
bl FillWindowPixelBuffer
|
||||
ldr r0, =gUnknown_03006214
|
||||
ldr r0, =gGameContinueCallback
|
||||
ldr r0, [r0]
|
||||
cmp r0, 0
|
||||
bne _08179370
|
||||
@ -488,7 +488,7 @@ sub_8179428: @ 8179428
|
||||
lsrs r4, r0, 24
|
||||
cmp r4, 0
|
||||
bne _0817944E
|
||||
ldr r5, =gUnknown_03006214
|
||||
ldr r5, =gGameContinueCallback
|
||||
ldr r0, [r5]
|
||||
cmp r0, 0
|
||||
bne _08179448
|
||||
|
@ -1297,7 +1297,7 @@ sC3_unknown: @ 8099C58
|
||||
adds r1, 0x1
|
||||
str r1, [r0, 0x8]
|
||||
adds r0, r2, 0
|
||||
bl sav12_xor_increment
|
||||
bl IncrementGameStat
|
||||
movs r0, 0
|
||||
pop {r1}
|
||||
bx r1
|
||||
|
@ -1927,7 +1927,7 @@ sub_80E9A90: @ 80E9A90
|
||||
sub_80E9AC0: @ 80E9AC0
|
||||
push {lr}
|
||||
movs r0, 0x14
|
||||
bl sav12_xor_increment
|
||||
bl IncrementGameStat
|
||||
bl sub_80E9A90
|
||||
pop {r0}
|
||||
bx r0
|
||||
@ -2018,7 +2018,7 @@ sub_80E9B70: @ 80E9B70
|
||||
push {r4-r6,lr}
|
||||
bl sub_80E9AD0
|
||||
movs r0, 0x14
|
||||
bl sav12_xor_increment
|
||||
bl IncrementGameStat
|
||||
ldr r5, =gSaveBlock1Ptr
|
||||
ldr r0, [r5]
|
||||
ldr r4, =0x00001aaa
|
||||
|
@ -2453,7 +2453,7 @@ BuyMenuSubtractMoney: @ 80E0F88
|
||||
lsls r0, 24
|
||||
lsrs r6, r0, 24
|
||||
movs r0, 0x26
|
||||
bl sav12_xor_increment
|
||||
bl IncrementGameStat
|
||||
ldr r5, =gSaveBlock1Ptr
|
||||
ldr r0, [r5]
|
||||
movs r4, 0x92
|
||||
|
@ -1387,7 +1387,7 @@ sub_812B01C: @ 812B01C
|
||||
cmp r0, 0
|
||||
beq _0812B044
|
||||
movs r0, 0x1C
|
||||
bl sav12_xor_increment
|
||||
bl IncrementGameStat
|
||||
_0812B044:
|
||||
ldr r2, [r4]
|
||||
ldrh r1, [r2, 0x8]
|
||||
|
@ -864,7 +864,7 @@ StartMenu_Pokedex: @ 809FBB4
|
||||
.pool
|
||||
_0809FBCC:
|
||||
movs r0, 0x29
|
||||
bl sav12_xor_increment
|
||||
bl IncrementGameStat
|
||||
bl play_some_sound
|
||||
bl RemoveExtraStartMenuWindows
|
||||
bl overworld_free_bg_tilemaps
|
||||
@ -1656,14 +1656,14 @@ sub_80A0234: @ 80A0234
|
||||
sub_80A024C: @ 80A024C
|
||||
push {r4,lr}
|
||||
movs r0, 0
|
||||
bl sav12_xor_increment
|
||||
bl IncrementGameStat
|
||||
bl sub_81A9E90
|
||||
ldr r4, =gUnknown_020322D4
|
||||
ldrb r0, [r4]
|
||||
cmp r0, 0x1
|
||||
bne _080A0274
|
||||
movs r0, 0x4
|
||||
bl save_game_when_memory_present
|
||||
bl TrySavingData
|
||||
lsls r0, 24
|
||||
lsrs r1, r0, 24
|
||||
movs r0, 0
|
||||
@ -1672,7 +1672,7 @@ sub_80A024C: @ 80A024C
|
||||
.pool
|
||||
_080A0274:
|
||||
movs r0, 0
|
||||
bl save_game_when_memory_present
|
||||
bl TrySavingData
|
||||
lsls r0, 24
|
||||
lsrs r1, r0, 24
|
||||
_080A027E:
|
||||
|
@ -13829,7 +13829,7 @@ _0807EDC0:
|
||||
cmp r0, 0
|
||||
bne _0807EDCE
|
||||
movs r0, 0x15
|
||||
bl sav12_xor_increment
|
||||
bl IncrementGameStat
|
||||
_0807EDCE:
|
||||
ldr r0, =gLinkVSyncDisabled
|
||||
ldrb r0, [r0]
|
||||
@ -14676,7 +14676,7 @@ _0807F50A:
|
||||
movs r2, 0
|
||||
bl sub_807F1A8
|
||||
movs r0, 0x15
|
||||
bl sav12_xor_increment
|
||||
bl IncrementGameStat
|
||||
bl sub_8153380
|
||||
ldr r0, =gUnknown_020322A0
|
||||
ldr r0, [r0]
|
||||
|
@ -803,7 +803,7 @@ sav12_xor_get_clamped_above: @ 80C2DE4
|
||||
adds r4, r1, 0
|
||||
lsls r0, 24
|
||||
lsrs r0, 24
|
||||
bl sub_80847F8
|
||||
bl GetGameStat
|
||||
cmp r0, r4
|
||||
bls _080C2DF6
|
||||
adds r0, r4, 0
|
||||
@ -852,7 +852,7 @@ _080C2E38:
|
||||
sub_80C2E40: @ 80C2E40
|
||||
push {r4,lr}
|
||||
movs r0, 0xA
|
||||
bl sub_80847F8
|
||||
bl GetGameStat
|
||||
negs r1, r0
|
||||
orrs r1, r0
|
||||
lsrs r4, r1, 31
|
||||
@ -943,10 +943,10 @@ sub_80C2EC4: @ 80C2EC4
|
||||
ldrb r0, [r1, 0x10]
|
||||
strh r0, [r5, 0x12]
|
||||
movs r0, 0x1
|
||||
bl sub_80847F8
|
||||
bl GetGameStat
|
||||
adds r4, r0, 0
|
||||
movs r0, 0xA
|
||||
bl sub_80847F8
|
||||
bl GetGameStat
|
||||
cmp r0, 0
|
||||
bne _080C2EF6
|
||||
movs r4, 0
|
||||
|
6
asm/tv.s
6
asm/tv.s
@ -748,7 +748,7 @@ GabbyAndTyAfterInterview: @ 80EC448
|
||||
adds r0, r2
|
||||
strb r1, [r0]
|
||||
movs r0, 0x6
|
||||
bl sav12_xor_increment
|
||||
bl IncrementGameStat
|
||||
pop {r4-r6}
|
||||
pop {r0}
|
||||
bx r0
|
||||
@ -1208,7 +1208,7 @@ sub_80EC8A4: @ 80EC8A4
|
||||
movs r1, 0x18
|
||||
bl sub_80EF910
|
||||
movs r0, 0x5
|
||||
bl sub_80847F8
|
||||
bl GetGameStat
|
||||
strh r0, [r4, 0x6]
|
||||
movs r0, 0x19
|
||||
strb r0, [r4]
|
||||
@ -3238,7 +3238,7 @@ sub_80EDA80: @ 80EDA80
|
||||
ldrh r0, [r5, 0x2]
|
||||
strh r0, [r4, 0x2]
|
||||
movs r0, 0x5
|
||||
bl sub_80847F8
|
||||
bl GetGameStat
|
||||
ldrh r1, [r5, 0x6]
|
||||
subs r0, r1
|
||||
strh r0, [r4, 0x6]
|
||||
|
@ -7810,7 +7810,7 @@ sub_80AEFDC: @ 80AEFDC
|
||||
bne _080AEFF6
|
||||
_080AEFF0:
|
||||
movs r0, 0x28
|
||||
bl sav12_xor_increment
|
||||
bl IncrementGameStat
|
||||
_080AEFF6:
|
||||
pop {r0}
|
||||
bx r0
|
||||
|
@ -1882,7 +1882,7 @@ _080B5764:
|
||||
lsrs r4, r0, 16
|
||||
_080B5784:
|
||||
movs r0, 0xC
|
||||
bl sav12_xor_increment
|
||||
bl IncrementGameStat
|
||||
adds r0, r4, 0
|
||||
bl sub_80EDA3C
|
||||
bl sub_80B0698
|
||||
|
@ -3,5 +3,5 @@
|
||||
|
||||
.section .rodata
|
||||
|
||||
gUnknown_085CDC00:: @ 85CDC00
|
||||
gSaveSectionOffsets:: @ 85CDC00
|
||||
.incbin "baserom.gba", 0x5cdc00, 0x38
|
||||
|
92
include/save.h
Normal file
92
include/save.h
Normal file
@ -0,0 +1,92 @@
|
||||
#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
|
||||
{
|
||||
u16 toAdd;
|
||||
u16 size;
|
||||
};
|
||||
|
||||
// Emerald changes this definition to be the sectors per slot.
|
||||
#define NUM_SECTORS_PER_SLOT 16 // move to save.h
|
||||
|
||||
#define UNKNOWN_CHECK_VALUE 0x8012025
|
||||
|
||||
// SetDamagedSectorBits states
|
||||
enum
|
||||
{
|
||||
ENABLE,
|
||||
DISABLE,
|
||||
CHECK // unused
|
||||
};
|
||||
|
||||
// Do save types
|
||||
enum
|
||||
{
|
||||
NORMAL_SAVE,
|
||||
LINK_SAVE,
|
||||
//EREADER_SAVE, // depreciated in Emerald
|
||||
LINK2_SAVE, // unknown 2nd link save
|
||||
HOF_SAVE,
|
||||
DIFFERENT_FILE_SAVE,
|
||||
HOF_DELETE_SAVE // unused
|
||||
};
|
||||
|
||||
void ClearSaveData(void);
|
||||
void ResetSaveCounters(void);
|
||||
//bool32 ManipulateSectorBits(u8 op, u8 bit);
|
||||
//u8 save_write_to_flash(u16 a1, const struct SaveSectionLocation *a2);
|
||||
u8 HandleWriteSector(u16, const struct SaveSectionLocation *);
|
||||
//u8 HandleWriteSectorNBytes(u8 sector, u8 *data, u16 size);
|
||||
u8 TryWriteSector(u8, u8 *);
|
||||
//u32 RestoreSaveBackupVarsAndIncrement(const struct SaveSectionLocation *location);
|
||||
//u32 RestoreSaveBackupVars(const struct SaveSectionLocation *location);
|
||||
//u8 sub_812550C(u16 a1, const struct SaveSectionLocation *location);
|
||||
u8 sub_8152A34(u16 a1, const struct SaveSectionLocation *location);
|
||||
u8 ClearSaveData_2(u16, const struct SaveSectionLocation *location);
|
||||
//u8 sub_8125758(u16 a1, const struct SaveSectionLocation *location);
|
||||
//u8 sub_81257F0(u16 a1, const struct SaveSectionLocation *location);
|
||||
//u8 sub_812587C(u16 a1, const struct SaveSectionLocation *location);
|
||||
u8 sub_8152E10(u16, const struct SaveSectionLocation *location);
|
||||
u8 GetSaveValidStatus(const struct SaveSectionLocation *location);
|
||||
//u8 sub_8125B88(u8 a1, u8 *data, u16 size);
|
||||
u8 DoReadFlashWholeSection(u8, struct SaveSection *);
|
||||
u16 CalculateChecksum(void *, u16);
|
||||
//u8 HandleSavingData(u8 saveType);
|
||||
//u8 TrySavingData(u8 saveType);
|
||||
//u8 sub_8125D80(void);
|
||||
//bool8 sub_8125DA8(void);
|
||||
//u8 sub_8125DDC(void);
|
||||
//u8 sub_8125E04(void);
|
||||
//u8 sub_8125E2C(void);
|
||||
//bool8 sub_8125E6C(void);
|
||||
//u8 sub_8125EC8(u8 a1);
|
||||
//bool8 unref_sub_8125F4C(struct UnkSaveSection *a1);
|
||||
//u8 unref_sub_8125FA0(void);
|
||||
//u8 unref_sub_8125FF0(u8 *data, u16 size);
|
||||
//u8 unref_sub_8126068(u8 sector, u8 *data, u32 size);
|
||||
//u8 unref_sub_8126080(u8 sector, u8 *data);
|
||||
|
||||
#endif
|
@ -180,6 +180,7 @@ SECTIONS {
|
||||
asm/rom_8151534.o(.text);
|
||||
asm/roulette_util.o(.text);
|
||||
asm/cable_car_util.o(.text);
|
||||
src/save.o(.text);
|
||||
asm/save.o(.text);
|
||||
asm/mystery_event_script.o(.text);
|
||||
asm/field_effect_helpers.o(.text);
|
||||
|
830
src/save.c
Normal file
830
src/save.c
Normal file
@ -0,0 +1,830 @@
|
||||
#include "global.h"
|
||||
#include "gba/flash_internal.h"
|
||||
#include "save.h"
|
||||
#include "game_stat.h"
|
||||
|
||||
extern u32 gSaveCounter;
|
||||
extern u16 gLastWrittenSector;
|
||||
extern u32 gDamagedSaveSectors;
|
||||
extern u16 gLastKnownGoodSector;
|
||||
extern u32 gLastSaveCounter;
|
||||
extern u16 gUnknown_03006208;
|
||||
extern struct SaveSection *gFastSaveSection;
|
||||
extern struct SaveSection *gUnknown_0203ABBC;
|
||||
|
||||
bool32 ProgramFlashSectorAndVerify(u8 sector, u8 *data);
|
||||
void ReadFlash(u8 secotr, u32 arg1, u8* data, u32 size);
|
||||
|
||||
void ClearSaveData(void)
|
||||
{
|
||||
u16 i;
|
||||
|
||||
for (i = 0; i < NUM_SECTORS_PER_SLOT; i++)
|
||||
{
|
||||
EraseFlashSector(i);
|
||||
EraseFlashSector(i + NUM_SECTORS_PER_SLOT); // clear slot 2.
|
||||
}
|
||||
}
|
||||
|
||||
void ResetSaveCounters(void)
|
||||
{
|
||||
gSaveCounter = 0;
|
||||
gLastWrittenSector = 0;
|
||||
gDamagedSaveSectors = 0;
|
||||
}
|
||||
|
||||
bool32 SetDamagedSectorBits(u8 op, u8 bit)
|
||||
{
|
||||
bool32 retVal = FALSE;
|
||||
|
||||
switch (op)
|
||||
{
|
||||
case ENABLE:
|
||||
gDamagedSaveSectors |= (1 << bit);
|
||||
break;
|
||||
case DISABLE:
|
||||
gDamagedSaveSectors &= ~(1 << bit);
|
||||
break;
|
||||
case CHECK: // unused
|
||||
if (gDamagedSaveSectors & (1 << bit))
|
||||
retVal = TRUE;
|
||||
break;
|
||||
}
|
||||
|
||||
return retVal;
|
||||
}
|
||||
|
||||
u8 save_write_to_flash(u16 a1, const struct SaveSectionLocation *location)
|
||||
{
|
||||
u32 retVal;
|
||||
u16 i;
|
||||
|
||||
gFastSaveSection = (struct SaveSection *)&gUnknown_0203ABBC;
|
||||
|
||||
if (a1 != 0xFFFF) // for link
|
||||
{
|
||||
retVal = HandleWriteSector(a1, location);
|
||||
}
|
||||
else
|
||||
{
|
||||
gLastKnownGoodSector = gLastWrittenSector; // backup the current written sector before attempting to write.
|
||||
gLastSaveCounter = gSaveCounter;
|
||||
gLastWrittenSector++;
|
||||
gLastWrittenSector = gLastWrittenSector % 0xE; // array count save sector locations
|
||||
gSaveCounter++;
|
||||
retVal = 1;
|
||||
|
||||
for (i = 0; i < 0xE; i++)
|
||||
HandleWriteSector(i, location);
|
||||
|
||||
if (gDamagedSaveSectors != 0) // skip the damaged sector.
|
||||
{
|
||||
retVal = 0xFF;
|
||||
gLastWrittenSector = gLastKnownGoodSector;
|
||||
gSaveCounter = gLastSaveCounter;
|
||||
}
|
||||
}
|
||||
|
||||
return retVal;
|
||||
}
|
||||
|
||||
u8 HandleWriteSector(u16 a1, const struct SaveSectionLocation *location)
|
||||
{
|
||||
u16 i;
|
||||
u16 sector;
|
||||
u8 *data;
|
||||
u16 size;
|
||||
|
||||
sector = a1 + gLastWrittenSector;
|
||||
sector %= 0xE;
|
||||
sector += 0xE * (gSaveCounter % 2);
|
||||
|
||||
data = location[a1].data;
|
||||
size = location[a1].size;
|
||||
|
||||
// clear save section.
|
||||
for (i = 0; i < sizeof(struct SaveSection); i++)
|
||||
((char *)gFastSaveSection)[i] = 0;
|
||||
|
||||
gFastSaveSection->id = a1;
|
||||
gFastSaveSection->security = UNKNOWN_CHECK_VALUE;
|
||||
gFastSaveSection->counter = gSaveCounter;
|
||||
|
||||
for (i = 0; i < size; i++)
|
||||
gFastSaveSection->data[i] = data[i];
|
||||
|
||||
gFastSaveSection->checksum = CalculateChecksum(data, size);
|
||||
return TryWriteSector(sector, gFastSaveSection->data);
|
||||
}
|
||||
|
||||
u8 HandleWriteSectorNBytes(u8 sector, u8 *data, u16 size)
|
||||
{
|
||||
u16 i;
|
||||
struct SaveSection *section = (struct SaveSection *)&gUnknown_0203ABBC;
|
||||
|
||||
for (i = 0; i < sizeof(struct SaveSection); i++)
|
||||
((char *)section)[i] = 0;
|
||||
|
||||
section->security = UNKNOWN_CHECK_VALUE;
|
||||
|
||||
for (i = 0; i < size; i++)
|
||||
section->data[i] = data[i];
|
||||
|
||||
section->id = CalculateChecksum(data, size); // though this appears to be incorrect, it might be some sector checksum instead of a whole save checksum and only appears to be relevent to HOF data, if used.
|
||||
return TryWriteSector(sector, section->data);
|
||||
}
|
||||
|
||||
u8 TryWriteSector(u8 sector, u8 *data)
|
||||
{
|
||||
if (ProgramFlashSectorAndVerify(sector, data) != 0) // is damaged?
|
||||
{
|
||||
SetDamagedSectorBits(ENABLE, sector); // set damaged sector bits.
|
||||
return 0xFF;
|
||||
}
|
||||
else
|
||||
{
|
||||
SetDamagedSectorBits(DISABLE, sector); // unset damaged sector bits. it's safe now.
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
u32 RestoreSaveBackupVarsAndIncrement(const struct SaveSectionLocation *location) // location is unused
|
||||
{
|
||||
gFastSaveSection = (struct SaveSection *)&gUnknown_0203ABBC;
|
||||
gLastKnownGoodSector = gLastWrittenSector;
|
||||
gLastSaveCounter = gSaveCounter;
|
||||
gLastWrittenSector++;
|
||||
gLastWrittenSector = gLastWrittenSector % 0xE;
|
||||
gSaveCounter++;
|
||||
gUnknown_03006208 = 0;
|
||||
gDamagedSaveSectors = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
u32 RestoreSaveBackupVars(const struct SaveSectionLocation *location) // only ever called once, and gSaveBlock2 is passed to this function. location is unused
|
||||
{
|
||||
gFastSaveSection = (struct SaveSection *)&gUnknown_0203ABBC;
|
||||
gLastKnownGoodSector = gLastWrittenSector;
|
||||
gLastSaveCounter = gSaveCounter;
|
||||
gUnknown_03006208 = 0;
|
||||
gDamagedSaveSectors = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
u8 sub_81529D4(u16 a1, const struct SaveSectionLocation *location)
|
||||
{
|
||||
u8 retVal;
|
||||
|
||||
if (gUnknown_03006208 < a1 - 1)
|
||||
{
|
||||
retVal = 1;
|
||||
HandleWriteSector(gUnknown_03006208, location);
|
||||
gUnknown_03006208++;
|
||||
if (gDamagedSaveSectors)
|
||||
{
|
||||
retVal = 0xFF;
|
||||
gLastWrittenSector = gLastKnownGoodSector;
|
||||
gSaveCounter = gLastSaveCounter;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
retVal = 0xFF;
|
||||
}
|
||||
|
||||
return retVal;
|
||||
}
|
||||
|
||||
u8 sub_8152A34(u16 a1, const struct SaveSectionLocation *location)
|
||||
{
|
||||
u8 retVal = 1;
|
||||
|
||||
ClearSaveData_2(a1 - 1, location);
|
||||
|
||||
if (gDamagedSaveSectors)
|
||||
{
|
||||
retVal = 0xFF;
|
||||
gLastWrittenSector = gLastKnownGoodSector;
|
||||
gSaveCounter = gLastSaveCounter;
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
|
||||
u8 ClearSaveData_2(u16 a1, const struct SaveSectionLocation *location)
|
||||
{
|
||||
u16 i;
|
||||
u16 sector;
|
||||
u8 *data;
|
||||
u16 size;
|
||||
u8 status;
|
||||
|
||||
sector = a1 + gLastWrittenSector;
|
||||
sector %= 0xE;
|
||||
sector += 0xE * (gSaveCounter % 2);
|
||||
|
||||
data = location[a1].data;
|
||||
size = location[a1].size;
|
||||
|
||||
// clear temp save section.
|
||||
for (i = 0; i < sizeof(struct SaveSection); i++)
|
||||
((char *)gFastSaveSection)[i] = 0;
|
||||
|
||||
gFastSaveSection->id = a1;
|
||||
gFastSaveSection->security = UNKNOWN_CHECK_VALUE;
|
||||
gFastSaveSection->counter = gSaveCounter;
|
||||
|
||||
// set temp section's data.
|
||||
for (i = 0; i < size; i++)
|
||||
gFastSaveSection->data[i] = data[i];
|
||||
|
||||
// calculate checksum.
|
||||
gFastSaveSection->checksum = CalculateChecksum(data, size);
|
||||
|
||||
EraseFlashSector(sector);
|
||||
|
||||
status = 1;
|
||||
|
||||
for (i = 0; i < sizeof(struct UnkSaveSection); i++)
|
||||
{
|
||||
if (ProgramFlashByte(sector, i, ((u8 *)gFastSaveSection)[i]))
|
||||
{
|
||||
status = 0xFF;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (status == 0xFF)
|
||||
{
|
||||
SetDamagedSectorBits(ENABLE, sector);
|
||||
return 0xFF;
|
||||
}
|
||||
else
|
||||
{
|
||||
status = 1;
|
||||
|
||||
for (i = 0; i < 7; i++)
|
||||
{
|
||||
if (ProgramFlashByte(sector, 0xFF9 + i, ((u8 *)gFastSaveSection)[0xFF9 + i]))
|
||||
{
|
||||
status = 0xFF;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (status == 0xFF)
|
||||
{
|
||||
SetDamagedSectorBits(ENABLE, sector);
|
||||
return 0xFF;
|
||||
}
|
||||
else
|
||||
{
|
||||
SetDamagedSectorBits(DISABLE, sector);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
u8 sav12_xor_get(u16 a1, const struct SaveSectionLocation *location)
|
||||
{
|
||||
u16 sector;
|
||||
|
||||
sector = a1 + gLastWrittenSector; // no sub 1?
|
||||
sector %= 0xE;
|
||||
sector += 0xE * (gSaveCounter % 2);
|
||||
|
||||
if (ProgramFlashByte(sector, sizeof(struct UnkSaveSection), 0x25))
|
||||
{
|
||||
// sector is damaged, so enable the bit in gDamagedSaveSectors and restore the last written sector and save counter.
|
||||
SetDamagedSectorBits(ENABLE, sector);
|
||||
gLastWrittenSector = gLastKnownGoodSector;
|
||||
gSaveCounter = gLastSaveCounter;
|
||||
return 0xFF;
|
||||
}
|
||||
else
|
||||
{
|
||||
SetDamagedSectorBits(DISABLE, sector);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
u8 sub_8152CAC(u16 a1, const struct SaveSectionLocation *location)
|
||||
{
|
||||
u16 sector;
|
||||
|
||||
sector = a1 + gLastWrittenSector - 1;
|
||||
sector %= 0xE;
|
||||
sector += 0xE * (gSaveCounter % 2);
|
||||
|
||||
if (ProgramFlashByte(sector, sizeof(struct UnkSaveSection), ((u8 *)gFastSaveSection)[sizeof(struct UnkSaveSection)]))
|
||||
{
|
||||
// sector is damaged, so enable the bit in gDamagedSaveSectors and restore the last written sector and save counter.
|
||||
SetDamagedSectorBits(ENABLE, sector);
|
||||
gLastWrittenSector = gLastKnownGoodSector;
|
||||
gSaveCounter = gLastSaveCounter;
|
||||
return 0xFF;
|
||||
}
|
||||
else
|
||||
{
|
||||
SetDamagedSectorBits(DISABLE, sector);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
u8 sub_8152D44(u16 a1, const struct SaveSectionLocation *location)
|
||||
{
|
||||
u16 sector;
|
||||
|
||||
sector = a1 + gLastWrittenSector - 1; // no sub 1?
|
||||
sector %= 0xE;
|
||||
sector += 0xE * (gSaveCounter % 2);
|
||||
|
||||
if (ProgramFlashByte(sector, sizeof(struct UnkSaveSection), 0x25))
|
||||
{
|
||||
// sector is damaged, so enable the bit in gDamagedSaveSectors and restore the last written sector and save counter.
|
||||
SetDamagedSectorBits(ENABLE, sector);
|
||||
gLastWrittenSector = gLastKnownGoodSector;
|
||||
gSaveCounter = gLastSaveCounter;
|
||||
return 0xFF;
|
||||
}
|
||||
else
|
||||
{
|
||||
SetDamagedSectorBits(DISABLE, sector);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
u8 sub_8152DD0(u16 a1, const struct SaveSectionLocation *location)
|
||||
{
|
||||
u8 retVal;
|
||||
gFastSaveSection = (struct SaveSection *)&gUnknown_0203ABBC;
|
||||
if (a1 != 0xFFFF)
|
||||
{
|
||||
retVal = 0xFF;
|
||||
}
|
||||
else
|
||||
{
|
||||
retVal = GetSaveValidStatus(location);
|
||||
sub_8152E10(0xFFFF, location);
|
||||
}
|
||||
|
||||
return retVal;
|
||||
}
|
||||
|
||||
u8 sub_8152E10(u16 a1, const struct SaveSectionLocation *location)
|
||||
{
|
||||
u16 i;
|
||||
u16 checksum;
|
||||
u16 v3 = 0xE * (gSaveCounter % 2);
|
||||
u16 id;
|
||||
|
||||
for (i = 0; i < 0xE; i++)
|
||||
{
|
||||
DoReadFlashWholeSection(i + v3, gFastSaveSection);
|
||||
id = gFastSaveSection->id;
|
||||
if (id == 0)
|
||||
gLastWrittenSector = i;
|
||||
checksum = CalculateChecksum(gFastSaveSection->data, location[id].size);
|
||||
if (gFastSaveSection->security == UNKNOWN_CHECK_VALUE
|
||||
&& gFastSaveSection->checksum == checksum)
|
||||
{
|
||||
u16 j;
|
||||
for (j = 0; j < location[id].size; j++)
|
||||
((u8 *)location[id].data)[j] = gFastSaveSection->data[j];
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
u8 GetSaveValidStatus(const struct SaveSectionLocation *location)
|
||||
{
|
||||
u16 i;
|
||||
u16 checksum;
|
||||
u32 saveSlot1Counter = 0;
|
||||
u32 saveSlot2Counter = 0;
|
||||
u32 slotCheckField = 0;
|
||||
bool8 securityPassed = FALSE;
|
||||
u8 saveSlot1Status;
|
||||
u8 saveSlot2Status;
|
||||
|
||||
// check save slot 1.
|
||||
for (i = 0; i < 0xE; i++)
|
||||
{
|
||||
DoReadFlashWholeSection(i, gFastSaveSection);
|
||||
if (gFastSaveSection->security == UNKNOWN_CHECK_VALUE)
|
||||
{
|
||||
securityPassed = TRUE;
|
||||
checksum = CalculateChecksum(gFastSaveSection->data, location[gFastSaveSection->id].size);
|
||||
if (gFastSaveSection->checksum == checksum)
|
||||
{
|
||||
saveSlot1Counter = gFastSaveSection->counter;
|
||||
slotCheckField |= 1 << gFastSaveSection->id;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (securityPassed)
|
||||
{
|
||||
if (slotCheckField == 0x3FFF)
|
||||
saveSlot1Status = 1;
|
||||
else
|
||||
saveSlot1Status = 255;
|
||||
}
|
||||
else
|
||||
{
|
||||
saveSlot1Status = 0;
|
||||
}
|
||||
|
||||
slotCheckField = 0;
|
||||
securityPassed = FALSE;
|
||||
|
||||
// check save slot 2.
|
||||
for (i = 0; i < 0xE; i++)
|
||||
{
|
||||
DoReadFlashWholeSection(i + 0xE, gFastSaveSection);
|
||||
if (gFastSaveSection->security == UNKNOWN_CHECK_VALUE)
|
||||
{
|
||||
securityPassed = TRUE;
|
||||
checksum = CalculateChecksum(gFastSaveSection->data, location[gFastSaveSection->id].size);
|
||||
if (gFastSaveSection->checksum == checksum)
|
||||
{
|
||||
saveSlot2Counter = gFastSaveSection->counter;
|
||||
slotCheckField |= 1 << gFastSaveSection->id;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (securityPassed)
|
||||
{
|
||||
if (slotCheckField == 0x3FFF)
|
||||
saveSlot2Status = 1;
|
||||
else
|
||||
saveSlot2Status = 255;
|
||||
}
|
||||
else
|
||||
{
|
||||
saveSlot2Status = 0;
|
||||
}
|
||||
|
||||
if (saveSlot1Status == 1 && saveSlot2Status == 1)
|
||||
{
|
||||
if ((saveSlot1Counter == -1 && saveSlot2Counter == 0) || (saveSlot1Counter == 0 && saveSlot2Counter == -1))
|
||||
{
|
||||
if ((unsigned)(saveSlot1Counter + 1) < (unsigned)(saveSlot2Counter + 1))
|
||||
{
|
||||
gSaveCounter = saveSlot2Counter;
|
||||
}
|
||||
else
|
||||
{
|
||||
gSaveCounter = saveSlot1Counter;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (saveSlot1Counter < saveSlot2Counter)
|
||||
{
|
||||
gSaveCounter = saveSlot2Counter;
|
||||
}
|
||||
else
|
||||
{
|
||||
gSaveCounter = saveSlot1Counter;
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (saveSlot1Status == 1)
|
||||
{
|
||||
gSaveCounter = saveSlot1Counter;
|
||||
if (saveSlot2Status == 255)
|
||||
return 255;
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (saveSlot2Status == 1)
|
||||
{
|
||||
gSaveCounter = saveSlot2Counter;
|
||||
if (saveSlot1Status == 255)
|
||||
return 255;
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (saveSlot1Status == 0 && saveSlot2Status == 0)
|
||||
{
|
||||
gSaveCounter = 0;
|
||||
gLastWrittenSector = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
gSaveCounter = 0;
|
||||
gLastWrittenSector = 0;
|
||||
return 2;
|
||||
}
|
||||
|
||||
u8 sub_81530DC(u8 a1, u8 *data, u16 size)
|
||||
{
|
||||
u16 i;
|
||||
struct SaveSection *section = (struct SaveSection *)&gUnknown_0203ABBC;
|
||||
DoReadFlashWholeSection(a1, section);
|
||||
if (section->security == UNKNOWN_CHECK_VALUE)
|
||||
{
|
||||
u16 checksum = CalculateChecksum(section->data, size);
|
||||
if (section->id == checksum)
|
||||
{
|
||||
for (i = 0; i < size; i++)
|
||||
data[i] = section->data[i];
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
u8 DoReadFlashWholeSection(u8 sector, struct SaveSection *section)
|
||||
{
|
||||
ReadFlash(sector, 0, section->data, sizeof(struct SaveSection));
|
||||
return 1;
|
||||
}
|
||||
|
||||
u16 CalculateChecksum(void *data, u16 size)
|
||||
{
|
||||
u16 i;
|
||||
u32 checksum = 0;
|
||||
|
||||
for (i = 0; i < (size / 4); i++)
|
||||
checksum += *((u32 *)data)++;
|
||||
|
||||
return ((checksum >> 16) + checksum);
|
||||
}
|
||||
|
||||
extern struct SaveSectionOffsets gSaveSectionOffsets[0xE]; // gSaveSectionOffsets
|
||||
extern struct SaveSectionLocation gRamSaveSectionLocations[0xE]; // gRamSaveSectionLocations
|
||||
extern void *gUnknown_03005D94;
|
||||
|
||||
#ifdef NONMATCHING
|
||||
// the initial allocation of the pointer and toAdd variable doesnt match up with the original function. however, forcing it is impossible since gRamSaveSectionLocations is loaded first.
|
||||
void UpdateSaveAddresses(void)
|
||||
{
|
||||
int i;
|
||||
gRamSaveSectionLocations[0].data = gSaveBlock2Ptr + gSaveSectionOffsets[0].toAdd;
|
||||
gRamSaveSectionLocations[0].size = gSaveSectionOffsets[0].size;
|
||||
|
||||
for(i = 1; i < 5; i++)
|
||||
{
|
||||
gRamSaveSectionLocations[i].data = gSaveBlock1Ptr + gSaveSectionOffsets[i].toAdd;
|
||||
gRamSaveSectionLocations[i].size = gSaveSectionOffsets[i].size;
|
||||
}
|
||||
|
||||
for(i = 5; i < 14; i++)
|
||||
{
|
||||
gRamSaveSectionLocations[i].data = gUnknown_03005D94 + gSaveSectionOffsets[i].toAdd;
|
||||
gRamSaveSectionLocations[i].size = gSaveSectionOffsets[i].size;
|
||||
}
|
||||
}
|
||||
#else
|
||||
__attribute__((naked))
|
||||
void UpdateSaveAddresses(void)
|
||||
{
|
||||
asm(".syntax unified\n\
|
||||
push {r4,r5,lr}\n\
|
||||
ldr r3, =gRamSaveSectionLocations\n\
|
||||
ldr r0, =gSaveBlock2Ptr\n\
|
||||
ldr r2, =gSaveSectionOffsets\n\
|
||||
ldrh r1, [r2]\n\
|
||||
ldr r0, [r0]\n\
|
||||
adds r0, r1\n\
|
||||
str r0, [r3]\n\
|
||||
ldrh r0, [r2, 0x2]\n\
|
||||
strh r0, [r3, 0x4]\n\
|
||||
ldr r5, =gSaveBlock1Ptr\n\
|
||||
adds r3, 0x8\n\
|
||||
adds r2, 0x4\n\
|
||||
movs r4, 0x3\n\
|
||||
_081531AC:\n\
|
||||
ldrh r0, [r2]\n\
|
||||
ldr r1, [r5]\n\
|
||||
adds r1, r0\n\
|
||||
str r1, [r3]\n\
|
||||
ldrh r0, [r2, 0x2]\n\
|
||||
strh r0, [r3, 0x4]\n\
|
||||
adds r3, 0x8\n\
|
||||
adds r2, 0x4\n\
|
||||
subs r4, 0x1\n\
|
||||
cmp r4, 0\n\
|
||||
bge _081531AC\n\
|
||||
movs r4, 0x5\n\
|
||||
ldr r1, =gRamSaveSectionLocations\n\
|
||||
ldr r5, =gUnknown_03005D94\n\
|
||||
ldr r0, =gSaveSectionOffsets\n\
|
||||
adds r3, r1, 0\n\
|
||||
adds r3, 0x28\n\
|
||||
adds r2, r0, 0\n\
|
||||
adds r2, 0x14\n\
|
||||
_081531D2:\n\
|
||||
ldrh r0, [r2]\n\
|
||||
ldr r1, [r5]\n\
|
||||
adds r1, r0\n\
|
||||
str r1, [r3]\n\
|
||||
ldrh r0, [r2, 0x2]\n\
|
||||
strh r0, [r3, 0x4]\n\
|
||||
adds r3, 0x8\n\
|
||||
adds r2, 0x4\n\
|
||||
adds r4, 0x1\n\
|
||||
cmp r4, 0xD\n\
|
||||
ble _081531D2\n\
|
||||
pop {r4,r5}\n\
|
||||
pop {r0}\n\
|
||||
bx r0\n\
|
||||
.pool\n\
|
||||
.syntax divided");
|
||||
}
|
||||
#endif
|
||||
|
||||
extern u32 GetGameStat(u8 index); // rom4
|
||||
extern void IncrementGameStat(u8 index); // rom4
|
||||
extern void SaveSerializedGame(void); // load_save
|
||||
extern u32 gUnknown_0203CF5C;
|
||||
|
||||
u8 HandleSavingData(u8 saveType)
|
||||
{
|
||||
u8 i;
|
||||
u32 backupVar = gUnknown_0203CF5C;
|
||||
u8 *tempAddr;
|
||||
|
||||
gUnknown_0203CF5C = 0;
|
||||
UpdateSaveAddresses();
|
||||
switch (saveType)
|
||||
{
|
||||
case HOF_DELETE_SAVE: // deletes HOF before overwriting HOF completely. unused
|
||||
for (i = 0xE * 2 + 0; i < 32; i++)
|
||||
EraseFlashSector(i);
|
||||
case HOF_SAVE: // hall of fame.
|
||||
if (GetGameStat(GAME_STAT_ENTERED_HOF) < 999)
|
||||
IncrementGameStat(GAME_STAT_ENTERED_HOF);
|
||||
SaveSerializedGame();
|
||||
save_write_to_flash(0xFFFF, gRamSaveSectionLocations);
|
||||
tempAddr = (u8 *)0x201C000; // FIXME: make this a label.
|
||||
HandleWriteSectorNBytes(0x1C, tempAddr, 0xF80);
|
||||
HandleWriteSectorNBytes(0x1D, tempAddr + 0xF80, 0xF80);
|
||||
break;
|
||||
case NORMAL_SAVE: // normal save. also called by overwriting your own save.
|
||||
default:
|
||||
SaveSerializedGame();
|
||||
save_write_to_flash(0xFFFF, gRamSaveSectionLocations);
|
||||
break;
|
||||
case LINK_SAVE: // _081532C4
|
||||
case LINK2_SAVE:
|
||||
SaveSerializedGame();
|
||||
for(i = 0; i < 5; i++)
|
||||
ClearSaveData_2(i, gRamSaveSectionLocations);
|
||||
for(i = 0; i < 5; i++)
|
||||
sav12_xor_get(i, gRamSaveSectionLocations);
|
||||
break;
|
||||
// support for Ereader was removed in Emerald.
|
||||
/*
|
||||
case EREADER_SAVE: // used in mossdeep "game corner" before/after battling old man e-reader trainer
|
||||
SaveSerializedGame();
|
||||
save_write_to_flash(0, gRamSaveSectionLocations);
|
||||
break;
|
||||
*/
|
||||
case DIFFERENT_FILE_SAVE:
|
||||
for (i = (0xE * 2 + 0); i < 32; i++)
|
||||
EraseFlashSector(i); // erase HOF.
|
||||
SaveSerializedGame();
|
||||
save_write_to_flash(0xFFFF, gRamSaveSectionLocations);
|
||||
break;
|
||||
}
|
||||
gUnknown_0203CF5C = backupVar;
|
||||
return 0;
|
||||
}
|
||||
|
||||
extern u32 gFlashMemoryPresent;
|
||||
extern void DoSaveFailedScreen(u8); // save_failed_screen
|
||||
extern u16 gUnknown_03006294;
|
||||
|
||||
u8 TrySavingData(u8 saveType) // TrySave
|
||||
{
|
||||
if(gFlashMemoryPresent == TRUE)
|
||||
{
|
||||
HandleSavingData(saveType);
|
||||
if(gDamagedSaveSectors)
|
||||
DoSaveFailedScreen(saveType);
|
||||
else
|
||||
goto OK; // really?
|
||||
}
|
||||
gUnknown_03006294 = 0xFF;
|
||||
return 0xFF;
|
||||
|
||||
OK:
|
||||
gUnknown_03006294 = 1;
|
||||
return 1;
|
||||
}
|
||||
|
||||
u8 sub_8153380(void) // trade.s save
|
||||
{
|
||||
if (gFlashMemoryPresent != TRUE)
|
||||
return 1;
|
||||
UpdateSaveAddresses();
|
||||
SaveSerializedGame();
|
||||
RestoreSaveBackupVarsAndIncrement(gRamSaveSectionLocations);
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool8 sub_81533AC(void) // trade.s save
|
||||
{
|
||||
u8 retVal = sub_81529D4(0xE, gRamSaveSectionLocations);
|
||||
if (gDamagedSaveSectors)
|
||||
DoSaveFailedScreen(0);
|
||||
if (retVal == 0xFF)
|
||||
return 1;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
u8 sub_81533E0(void) // trade.s save
|
||||
{
|
||||
sub_8152A34(0xE, gRamSaveSectionLocations);
|
||||
if (gDamagedSaveSectors)
|
||||
DoSaveFailedScreen(0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
u8 sub_8153408(void) // trade.s save
|
||||
{
|
||||
sub_8152CAC(0xE, gRamSaveSectionLocations);
|
||||
if (gDamagedSaveSectors)
|
||||
DoSaveFailedScreen(0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
u8 sub_8153430(void)
|
||||
{
|
||||
if (gFlashMemoryPresent != TRUE)
|
||||
return 1;
|
||||
|
||||
UpdateSaveAddresses();
|
||||
SaveSerializedGame();
|
||||
RestoreSaveBackupVars(gRamSaveSectionLocations);
|
||||
sub_8152A34(gUnknown_03006208 + 1, gRamSaveSectionLocations);
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool8 sub_8153474(void)
|
||||
{
|
||||
u8 retVal = FALSE;
|
||||
u16 val = ++gUnknown_03006208;
|
||||
if (val <= 4)
|
||||
{
|
||||
sub_8152A34(gUnknown_03006208 + 1, gRamSaveSectionLocations);
|
||||
sub_8152D44(val, gRamSaveSectionLocations);
|
||||
}
|
||||
else
|
||||
{
|
||||
sub_8152D44(val, gRamSaveSectionLocations);
|
||||
retVal = TRUE;
|
||||
}
|
||||
if (gDamagedSaveSectors)
|
||||
DoSaveFailedScreen(1);
|
||||
return retVal;
|
||||
}
|
||||
|
||||
extern u16 gUnknown_03006210;
|
||||
extern void LoadSerializedGame(void); // load_save
|
||||
extern void (*gGameContinueCallback)(void);
|
||||
extern u8 gDecompressionBuffer[];
|
||||
|
||||
u8 sub_81534D0(u8 a1)
|
||||
{
|
||||
u8 result;
|
||||
|
||||
if (gFlashMemoryPresent != TRUE)
|
||||
{
|
||||
gUnknown_03006210 = 4;
|
||||
return 0xFF;
|
||||
}
|
||||
|
||||
UpdateSaveAddresses();
|
||||
switch (a1)
|
||||
{
|
||||
case 0:
|
||||
default:
|
||||
result = sub_8152DD0(0xFFFF, gRamSaveSectionLocations);
|
||||
LoadSerializedGame();
|
||||
gUnknown_03006210 = result;
|
||||
gGameContinueCallback = 0;
|
||||
break;
|
||||
case 3:
|
||||
result = sub_81530DC(0x1C, gDecompressionBuffer, 0xF80);
|
||||
if(result == 1)
|
||||
result = sub_81530DC(0x1D, gDecompressionBuffer + 0xF80, 0xF80);
|
||||
break;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
@ -392,22 +392,22 @@ gUnknown_030061E8: @ 30061E8
|
||||
gUnknown_030061EC: @ 30061EC
|
||||
.space 0x4
|
||||
|
||||
gUnknown_030061F0: @ 30061F0
|
||||
gLastWrittenSector: @ 30061F0
|
||||
.space 0x4
|
||||
|
||||
gUnknown_030061F4: @ 30061F4
|
||||
gLastSaveCounter: @ 30061F4
|
||||
.space 0x4
|
||||
|
||||
gUnknown_030061F8: @ 30061F8
|
||||
gLastKnownGoodSector: @ 30061F8
|
||||
.space 0x4
|
||||
|
||||
gUnknown_030061FC: @ 30061FC
|
||||
gDamagedSaveSectors: @ 30061FC
|
||||
.space 0x4
|
||||
|
||||
gUnknown_03006200: @ 3006200
|
||||
gSaveCounter: @ 3006200
|
||||
.space 0x4
|
||||
|
||||
gUnknown_03006204: @ 3006204
|
||||
gFastSaveSection: @ 3006204
|
||||
.space 0x4
|
||||
|
||||
gUnknown_03006208: @ 3006208
|
||||
@ -416,10 +416,10 @@ gUnknown_03006208: @ 3006208
|
||||
gUnknown_03006210: @ 3006210
|
||||
.space 0x4
|
||||
|
||||
gUnknown_03006214: @ 3006214
|
||||
gGameContinueCallback: @ 3006214
|
||||
.space 0xC
|
||||
|
||||
gUnknown_03006220: @ 3006220
|
||||
gRamSaveSectionLocations: @ 3006220
|
||||
.space 0x74
|
||||
|
||||
gUnknown_03006294: @ 3006294
|
||||
|
Loading…
Reference in New Issue
Block a user