mirror of
https://github.com/Ninjdai1/pokeemerald.git
synced 2024-12-25 19:24:16 +01:00
begin load_save.c
This commit is contained in:
parent
7ba62bcac8
commit
92892d140a
@ -307,7 +307,7 @@ c2_copyright_1: @ 816CEAC
|
||||
bl sub_815355C
|
||||
lsls r0, 16
|
||||
lsrs r0, 16
|
||||
bl InitSaveBlockPointersWithRandomOffset
|
||||
bl SetSaveBlocksPointers
|
||||
bl sub_808447C
|
||||
bl ResetSaveCounters
|
||||
movs r0, 0
|
||||
|
@ -52672,8 +52672,8 @@ SetBerryPowder: @ 802467C
|
||||
.pool
|
||||
thumb_func_end SetBerryPowder
|
||||
|
||||
thumb_func_start sub_8024690
|
||||
sub_8024690: @ 8024690
|
||||
thumb_func_start ApplyNewEncyprtionKeyToBerryPowder
|
||||
ApplyNewEncyprtionKeyToBerryPowder: @ 8024690
|
||||
push {lr}
|
||||
adds r1, r0, 0
|
||||
ldr r0, =gSaveBlock2Ptr
|
||||
@ -52681,11 +52681,11 @@ sub_8024690: @ 8024690
|
||||
movs r2, 0xFA
|
||||
lsls r2, 1
|
||||
adds r0, r2
|
||||
bl apply_u32_xor_crypto
|
||||
bl ApplyNewEncyprtionKeyToWord
|
||||
pop {r0}
|
||||
bx r0
|
||||
.pool
|
||||
thumb_func_end sub_8024690
|
||||
thumb_func_end ApplyNewEncyprtionKeyToBerryPowder
|
||||
|
||||
thumb_func_start sub_80246AC
|
||||
sub_80246AC: @ 80246AC
|
||||
|
118
asm/load_save.s
118
asm/load_save.s
@ -5,97 +5,9 @@
|
||||
|
||||
.text
|
||||
|
||||
thumb_func_start CheckForFlashMemory
|
||||
@ void CheckForFlashMemory()
|
||||
CheckForFlashMemory: @ 8076B68
|
||||
push {lr}
|
||||
bl IdentifyFlash
|
||||
lsls r0, 16
|
||||
cmp r0, 0
|
||||
bne _08076B84
|
||||
ldr r1, =gFlashMemoryPresent
|
||||
movs r0, 0x1
|
||||
str r0, [r1]
|
||||
bl StartFlashMemoryTimer
|
||||
b _08076B8A
|
||||
.pool
|
||||
_08076B84:
|
||||
ldr r1, =gFlashMemoryPresent
|
||||
movs r0, 0
|
||||
str r0, [r1]
|
||||
_08076B8A:
|
||||
pop {r0}
|
||||
bx r0
|
||||
.pool
|
||||
thumb_func_end CheckForFlashMemory
|
||||
|
||||
thumb_func_start ClearSav2
|
||||
ClearSav2: @ 8076B94
|
||||
push {lr}
|
||||
sub sp, 0x4
|
||||
mov r1, sp
|
||||
movs r0, 0
|
||||
strh r0, [r1]
|
||||
ldr r1, =gUnknown_02024A54
|
||||
ldr r2, =0x010007d6
|
||||
mov r0, sp
|
||||
bl CpuSet
|
||||
add sp, 0x4
|
||||
pop {r0}
|
||||
bx r0
|
||||
.pool
|
||||
thumb_func_end ClearSav2
|
||||
|
||||
thumb_func_start ClearSav1
|
||||
ClearSav1: @ 8076BB8
|
||||
push {lr}
|
||||
sub sp, 0x4
|
||||
mov r1, sp
|
||||
movs r0, 0
|
||||
strh r0, [r1]
|
||||
ldr r1, =gUnknown_02025A00
|
||||
ldr r2, =0x01001f04
|
||||
mov r0, sp
|
||||
bl CpuSet
|
||||
add sp, 0x4
|
||||
pop {r0}
|
||||
bx r0
|
||||
.pool
|
||||
thumb_func_end ClearSav1
|
||||
|
||||
thumb_func_start InitSaveBlockPointersWithRandomOffset
|
||||
@ void InitSaveBlockPointersWithRandomOffset(u8 offset)
|
||||
InitSaveBlockPointersWithRandomOffset: @ 8076BDC
|
||||
push {r4,r5,lr}
|
||||
adds r4, r0, 0
|
||||
lsls r4, 16
|
||||
lsrs r4, 16
|
||||
ldr r5, =gSaveBlock1Ptr
|
||||
bl Random
|
||||
adds r4, r0
|
||||
movs r0, 0x7C
|
||||
ands r4, r0
|
||||
ldr r1, =gSaveBlock2Ptr
|
||||
ldr r0, =gUnknown_02024A54
|
||||
adds r0, r4, r0
|
||||
str r0, [r1]
|
||||
ldr r0, =gUnknown_02025A00
|
||||
adds r0, r4, r0
|
||||
str r0, [r5]
|
||||
ldr r1, =gUnknown_03005D94
|
||||
ldr r0, =gUnknown_02029808
|
||||
adds r4, r0
|
||||
str r4, [r1]
|
||||
bl SetBagItemsPointers
|
||||
bl SetDecorationInventoriesPointers
|
||||
pop {r4,r5}
|
||||
pop {r0}
|
||||
bx r0
|
||||
.pool
|
||||
thumb_func_end InitSaveBlockPointersWithRandomOffset
|
||||
|
||||
thumb_func_start saveblock_randomize_and_relocate
|
||||
saveblock_randomize_and_relocate: @ 8076C2C
|
||||
thumb_func_start MoveSaveBlocks_ResetHeap
|
||||
MoveSaveBlocks_ResetHeap: @ 8076C2C
|
||||
push {r4-r7,lr}
|
||||
mov r7, r10
|
||||
mov r6, r9
|
||||
@ -126,7 +38,7 @@ saveblock_randomize_and_relocate: @ 8076C2C
|
||||
ldr r0, =0x02000f2c
|
||||
adds r2, r7, 0
|
||||
bl memcpy
|
||||
ldr r0, =gUnknown_03005D94
|
||||
ldr r0, =gPokemonStoragePtr
|
||||
mov r8, r0
|
||||
ldr r1, [r0]
|
||||
ldr r0, =0x000083d0
|
||||
@ -141,7 +53,7 @@ saveblock_randomize_and_relocate: @ 8076C2C
|
||||
adds r1, r0
|
||||
ldrb r0, [r4, 0xD]
|
||||
adds r0, r1
|
||||
bl InitSaveBlockPointersWithRandomOffset
|
||||
bl SetSaveBlocksPointers
|
||||
ldr r1, =gSaveBlock2Ptr
|
||||
ldr r0, [r1]
|
||||
adds r1, r4, 0
|
||||
@ -173,7 +85,7 @@ saveblock_randomize_and_relocate: @ 8076C2C
|
||||
lsrs r0, 16
|
||||
adds r4, r0
|
||||
adds r0, r4, 0
|
||||
bl saveblock_apply_crypto
|
||||
bl ApplyNewEncyprtionKeyToAllEncryptedData
|
||||
ldr r1, =gSaveBlock2Ptr
|
||||
ldr r0, [r1]
|
||||
adds r0, 0xAC
|
||||
@ -187,7 +99,7 @@ saveblock_randomize_and_relocate: @ 8076C2C
|
||||
pop {r0}
|
||||
bx r0
|
||||
.pool
|
||||
thumb_func_end saveblock_randomize_and_relocate
|
||||
thumb_func_end MoveSaveBlocks_ResetHeap
|
||||
|
||||
thumb_func_start sav2_x1_query_bit1
|
||||
sav2_x1_query_bit1: @ 8076D24
|
||||
@ -713,8 +625,8 @@ ApplyNewEncyprtionKeyToHword: @ 8077100
|
||||
.pool
|
||||
thumb_func_end ApplyNewEncyprtionKeyToHword
|
||||
|
||||
thumb_func_start apply_u32_xor_crypto
|
||||
apply_u32_xor_crypto: @ 8077118
|
||||
thumb_func_start ApplyNewEncyprtionKeyToWord
|
||||
ApplyNewEncyprtionKeyToWord: @ 8077118
|
||||
ldr r2, =gSaveBlock2Ptr
|
||||
ldr r3, [r2]
|
||||
adds r3, 0xAC
|
||||
@ -725,24 +637,24 @@ apply_u32_xor_crypto: @ 8077118
|
||||
str r2, [r0]
|
||||
bx lr
|
||||
.pool
|
||||
thumb_func_end apply_u32_xor_crypto
|
||||
thumb_func_end ApplyNewEncyprtionKeyToWord
|
||||
|
||||
thumb_func_start saveblock_apply_crypto
|
||||
saveblock_apply_crypto: @ 8077130
|
||||
thumb_func_start ApplyNewEncyprtionKeyToAllEncryptedData
|
||||
ApplyNewEncyprtionKeyToAllEncryptedData: @ 8077130
|
||||
push {r4,r5,lr}
|
||||
adds r4, r0, 0
|
||||
bl sub_8084864
|
||||
bl ApplyNewEncyprtionKeyToGameStats
|
||||
adds r0, r4, 0
|
||||
bl ApplyNewEncyprtionKeyToBagItems_
|
||||
adds r0, r4, 0
|
||||
bl sub_8024690
|
||||
bl ApplyNewEncyprtionKeyToBerryPowder
|
||||
ldr r5, =gSaveBlock1Ptr
|
||||
ldr r0, [r5]
|
||||
movs r1, 0x92
|
||||
lsls r1, 3
|
||||
adds r0, r1
|
||||
adds r1, r4, 0
|
||||
bl apply_u32_xor_crypto
|
||||
bl ApplyNewEncyprtionKeyToWord
|
||||
ldr r0, [r5]
|
||||
ldr r1, =0x00000494
|
||||
adds r0, r1
|
||||
@ -752,6 +664,6 @@ saveblock_apply_crypto: @ 8077130
|
||||
pop {r0}
|
||||
bx r0
|
||||
.pool
|
||||
thumb_func_end saveblock_apply_crypto
|
||||
thumb_func_end ApplyNewEncyprtionKeyToAllEncryptedData
|
||||
|
||||
.align 2, 0 @ Don't pad with nop.
|
||||
|
@ -133,7 +133,7 @@ _0817764E:
|
||||
bls _081775FC
|
||||
_08177658:
|
||||
movs r7, 0
|
||||
ldr r1, =gUnknown_03005D94
|
||||
ldr r1, =gPokemonStoragePtr
|
||||
mov r9, r1
|
||||
_0817765E:
|
||||
movs r6, 0
|
||||
@ -233,7 +233,7 @@ _0817773C:
|
||||
ldr r1, =gSpecialVar_0x8006
|
||||
movs r0, 0x1
|
||||
strh r0, [r1]
|
||||
ldr r2, =gUnknown_03005D94
|
||||
ldr r2, =gPokemonStoragePtr
|
||||
ldr r1, [sp]
|
||||
lsls r0, r1, 2
|
||||
adds r0, r1
|
||||
|
24
asm/rom4.s
24
asm/rom4.s
@ -238,8 +238,8 @@ _08084854:
|
||||
.pool
|
||||
thumb_func_end sav12_xor_set
|
||||
|
||||
thumb_func_start sub_8084864
|
||||
sub_8084864: @ 8084864
|
||||
thumb_func_start ApplyNewEncyprtionKeyToGameStats
|
||||
ApplyNewEncyprtionKeyToGameStats: @ 8084864
|
||||
push {r4-r6,lr}
|
||||
adds r5, r0, 0
|
||||
movs r4, 0
|
||||
@ -251,7 +251,7 @@ _0808486C:
|
||||
ldr r0, [r6]
|
||||
adds r0, r1
|
||||
adds r1, r5, 0
|
||||
bl apply_u32_xor_crypto
|
||||
bl ApplyNewEncyprtionKeyToWord
|
||||
adds r0, r4, 0x1
|
||||
lsls r0, 24
|
||||
lsrs r4, r0, 24
|
||||
@ -261,7 +261,7 @@ _0808486C:
|
||||
pop {r0}
|
||||
bx r0
|
||||
.pool
|
||||
thumb_func_end sub_8084864
|
||||
thumb_func_end ApplyNewEncyprtionKeyToGameStats
|
||||
|
||||
thumb_func_start CopyFieldObjectTemplatesToSav1
|
||||
@ void CopyFieldObjectTemplatesToSav1()
|
||||
@ -3713,7 +3713,7 @@ _0808644C:
|
||||
bl overworld_bg_setup
|
||||
bl script_env_1_init
|
||||
bl script_env_2_disable
|
||||
bl saveblock_randomize_and_relocate_
|
||||
bl MoveSaveBlocks_ResetHeap_
|
||||
bl sub_80867D8
|
||||
b _08086506
|
||||
_08086462:
|
||||
@ -3838,7 +3838,7 @@ _08086570:
|
||||
bl mli0_load_map
|
||||
b _08086622
|
||||
_0808657C:
|
||||
bl saveblock_randomize_and_relocate_
|
||||
bl MoveSaveBlocks_ResetHeap_
|
||||
bl sub_80867D8
|
||||
b _08086622
|
||||
_08086586:
|
||||
@ -3941,7 +3941,7 @@ _0808664C:
|
||||
beq _0808668A
|
||||
b _0808668E
|
||||
_08086656:
|
||||
bl saveblock_randomize_and_relocate_
|
||||
bl MoveSaveBlocks_ResetHeap_
|
||||
bl sub_80867D8
|
||||
movs r0, 0
|
||||
bl sub_8086988
|
||||
@ -4006,7 +4006,7 @@ _080866B4:
|
||||
.4byte _0808679A
|
||||
_080866EC:
|
||||
bl sub_808631C
|
||||
bl saveblock_randomize_and_relocate_
|
||||
bl MoveSaveBlocks_ResetHeap_
|
||||
bl sub_80867D8
|
||||
b _08086792
|
||||
_080866FA:
|
||||
@ -4106,14 +4106,14 @@ _080867B4:
|
||||
bx r0
|
||||
thumb_func_end do_load_map_stuff_loop
|
||||
|
||||
thumb_func_start saveblock_randomize_and_relocate_
|
||||
saveblock_randomize_and_relocate_: @ 80867C8
|
||||
thumb_func_start MoveSaveBlocks_ResetHeap_
|
||||
MoveSaveBlocks_ResetHeap_: @ 80867C8
|
||||
push {lr}
|
||||
bl sub_81BE6AC
|
||||
bl saveblock_randomize_and_relocate
|
||||
bl MoveSaveBlocks_ResetHeap
|
||||
pop {r0}
|
||||
bx r0
|
||||
thumb_func_end saveblock_randomize_and_relocate_
|
||||
thumb_func_end MoveSaveBlocks_ResetHeap_
|
||||
|
||||
thumb_func_start sub_80867D8
|
||||
sub_80867D8: @ 80867D8
|
||||
|
@ -3065,7 +3065,7 @@ _08036758:
|
||||
thumb_func_start sub_8036760
|
||||
sub_8036760: @ 8036760
|
||||
push {lr}
|
||||
bl saveblock_randomize_and_relocate
|
||||
bl MoveSaveBlocks_ResetHeap
|
||||
bl sub_8056F28
|
||||
bl dp11_init
|
||||
bl init_uns_table_pokemon_copy
|
||||
|
@ -20562,7 +20562,7 @@ nullsub_98: @ 80D1D08
|
||||
thumb_func_start get_preferred_box
|
||||
@ char get_preferred_box()
|
||||
get_preferred_box: @ 80D1D0C
|
||||
ldr r0, =gUnknown_03005D94
|
||||
ldr r0, =gPokemonStoragePtr
|
||||
ldr r0, [r0]
|
||||
ldrb r0, [r0]
|
||||
bx lr
|
||||
@ -20576,7 +20576,7 @@ sub_80D1D18: @ 80D1D18
|
||||
lsrs r1, r0, 24
|
||||
cmp r1, 0xD
|
||||
bhi _080D1D28
|
||||
ldr r0, =gUnknown_03005D94
|
||||
ldr r0, =gPokemonStoragePtr
|
||||
ldr r0, [r0]
|
||||
strb r1, [r0]
|
||||
_080D1D28:
|
||||
@ -20597,7 +20597,7 @@ get_pokemon_data_from_any_box: @ 80D1D30
|
||||
bhi _080D1D6C
|
||||
cmp r4, 0x1D
|
||||
bhi _080D1D6C
|
||||
ldr r2, =gUnknown_03005D94
|
||||
ldr r2, =gPokemonStoragePtr
|
||||
lsls r0, r3, 2
|
||||
adds r0, r3
|
||||
lsls r1, r0, 4
|
||||
@ -20635,7 +20635,7 @@ set_pokemon_data_from_any_box: @ 80D1D74
|
||||
bhi _080D1DAC
|
||||
cmp r4, 0x1D
|
||||
bhi _080D1DAC
|
||||
ldr r2, =gUnknown_03005D94
|
||||
ldr r2, =gPokemonStoragePtr
|
||||
lsls r0, r3, 2
|
||||
adds r0, r3
|
||||
lsls r1, r0, 4
|
||||
@ -20665,7 +20665,7 @@ get_pokemon_data_from_selected_box: @ 80D1DB8
|
||||
adds r2, r1, 0
|
||||
lsls r3, 24
|
||||
lsrs r3, 24
|
||||
ldr r0, =gUnknown_03005D94
|
||||
ldr r0, =gPokemonStoragePtr
|
||||
ldr r0, [r0]
|
||||
ldrb r0, [r0]
|
||||
adds r1, r3, 0
|
||||
@ -20683,7 +20683,7 @@ set_pokemon_data_from_selected_box: @ 80D1DD8
|
||||
adds r3, r2, 0
|
||||
lsls r4, 24
|
||||
lsrs r4, 24
|
||||
ldr r0, =gUnknown_03005D94
|
||||
ldr r0, =gPokemonStoragePtr
|
||||
ldr r0, [r0]
|
||||
ldrb r0, [r0]
|
||||
adds r1, r4, 0
|
||||
@ -20707,7 +20707,7 @@ sub_80D1DFC: @ 80D1DFC
|
||||
bhi _080D1E38
|
||||
cmp r4, 0x1D
|
||||
bhi _080D1E38
|
||||
ldr r2, =gUnknown_03005D94
|
||||
ldr r2, =gPokemonStoragePtr
|
||||
lsls r0, r3, 2
|
||||
adds r0, r3
|
||||
lsls r1, r0, 4
|
||||
@ -20745,7 +20745,7 @@ sub_80D1E44: @ 80D1E44
|
||||
bhi _080D1E84
|
||||
cmp r2, 0x1D
|
||||
bhi _080D1E84
|
||||
ldr r6, =gUnknown_03005D94
|
||||
ldr r6, =gPokemonStoragePtr
|
||||
lsls r1, r0, 2
|
||||
adds r1, r0
|
||||
lsls r0, r1, 4
|
||||
@ -20786,7 +20786,7 @@ sub_80D1E90: @ 80D1E90
|
||||
bhi _080D1EC6
|
||||
cmp r4, 0x1D
|
||||
bhi _080D1EC6
|
||||
ldr r2, =gUnknown_03005D94
|
||||
ldr r2, =gPokemonStoragePtr
|
||||
lsls r0, r3, 2
|
||||
adds r0, r3
|
||||
lsls r1, r0, 4
|
||||
@ -20822,7 +20822,7 @@ sub_80D1ED0: @ 80D1ED0
|
||||
bhi _080D1F10
|
||||
cmp r4, 0x1D
|
||||
bhi _080D1F10
|
||||
ldr r2, =gUnknown_03005D94
|
||||
ldr r2, =gPokemonStoragePtr
|
||||
lsls r0, r3, 2
|
||||
adds r0, r3
|
||||
lsls r1, r0, 4
|
||||
@ -20860,7 +20860,7 @@ sub_80D1F18: @ 80D1F18
|
||||
bhi _080D1F4E
|
||||
cmp r1, 0x1D
|
||||
bhi _080D1F4E
|
||||
ldr r0, =gUnknown_03005D94
|
||||
ldr r0, =gPokemonStoragePtr
|
||||
ldr r0, [r0]
|
||||
lsls r3, r1, 2
|
||||
adds r3, r1
|
||||
@ -20895,7 +20895,7 @@ sub_80D1F58: @ 80D1F58
|
||||
bhi _080D1F8E
|
||||
cmp r2, 0x1D
|
||||
bhi _080D1F8E
|
||||
ldr r0, =gUnknown_03005D94
|
||||
ldr r0, =gPokemonStoragePtr
|
||||
ldr r1, [r0]
|
||||
lsls r3, r2, 2
|
||||
adds r3, r2
|
||||
@ -20950,7 +20950,7 @@ sub_80D1F98: @ 80D1F98
|
||||
bhi _080D2004
|
||||
cmp r6, 0x1D
|
||||
bhi _080D2004
|
||||
ldr r2, =gUnknown_03005D94
|
||||
ldr r2, =gPokemonStoragePtr
|
||||
lsls r0, r7, 2
|
||||
adds r0, r7
|
||||
lsls r1, r0, 4
|
||||
@ -20995,7 +20995,7 @@ sub_80D2018: @ 80D2018
|
||||
bhi _080D2048
|
||||
cmp r4, 0x1D
|
||||
bhi _080D2048
|
||||
ldr r2, =gUnknown_03005D94
|
||||
ldr r2, =gPokemonStoragePtr
|
||||
lsls r0, r3, 2
|
||||
adds r0, r3
|
||||
lsls r1, r0, 4
|
||||
@ -21028,7 +21028,7 @@ sub_80D2054: @ 80D2054
|
||||
bhi _080D2088
|
||||
cmp r4, 0x1D
|
||||
bhi _080D2088
|
||||
ldr r2, =gUnknown_03005D94
|
||||
ldr r2, =gPokemonStoragePtr
|
||||
lsls r0, r3, 2
|
||||
adds r0, r3
|
||||
lsls r1, r0, 4
|
||||
@ -21062,7 +21062,7 @@ get_pokemon_by_box_and_pos: @ 80D2094
|
||||
bhi _080D20C8
|
||||
cmp r4, 0x1D
|
||||
bhi _080D20C8
|
||||
ldr r2, =gUnknown_03005D94
|
||||
ldr r2, =gPokemonStoragePtr
|
||||
lsls r0, r3, 2
|
||||
adds r0, r3
|
||||
lsls r1, r0, 4
|
||||
@ -21095,7 +21095,7 @@ sav3_get_box_name: @ 80D20D0
|
||||
movs r0, 0
|
||||
b _080D20EC
|
||||
_080D20DE:
|
||||
ldr r0, =gUnknown_03005D94
|
||||
ldr r0, =gPokemonStoragePtr
|
||||
lsls r1, r2, 3
|
||||
adds r1, r2
|
||||
ldr r2, =0x00008344
|
||||
@ -21118,7 +21118,7 @@ sub_80D20F8: @ 80D20F8
|
||||
movs r0, 0
|
||||
b _080D2112
|
||||
_080D2106:
|
||||
ldr r0, =gUnknown_03005D94
|
||||
ldr r0, =gPokemonStoragePtr
|
||||
ldr r0, [r0]
|
||||
ldr r2, =0x000083c2
|
||||
adds r0, r2
|
||||
@ -21141,7 +21141,7 @@ sub_80D2120: @ 80D2120
|
||||
bhi _080D213E
|
||||
cmp r1, 0x10
|
||||
bhi _080D213E
|
||||
ldr r0, =gUnknown_03005D94
|
||||
ldr r0, =gPokemonStoragePtr
|
||||
ldr r0, [r0]
|
||||
ldr r3, =0x000083c2
|
||||
adds r0, r3
|
||||
@ -21271,7 +21271,7 @@ sub_80D2218: @ 80D2218
|
||||
push {r7}
|
||||
sub sp, 0x4
|
||||
movs r2, 0
|
||||
ldr r0, =gUnknown_03005D94
|
||||
ldr r0, =gPokemonStoragePtr
|
||||
mov r8, r0
|
||||
movs r7, 0x4
|
||||
_080D2228:
|
||||
@ -21321,7 +21321,7 @@ sub_80D2270: @ 80D2270
|
||||
bhi _080D22C8
|
||||
cmp r2, 0x1D
|
||||
bhi _080D22C8
|
||||
ldr r6, =gUnknown_03005D94
|
||||
ldr r6, =gPokemonStoragePtr
|
||||
lsls r1, r0, 2
|
||||
adds r1, r0
|
||||
lsls r0, r1, 4
|
||||
@ -21371,7 +21371,7 @@ sub_80D22D0: @ 80D22D0
|
||||
push {r6,r7}
|
||||
movs r7, 0
|
||||
movs r0, 0
|
||||
ldr r1, =gUnknown_03005D94
|
||||
ldr r1, =gPokemonStoragePtr
|
||||
mov r9, r1
|
||||
_080D22E0:
|
||||
lsls r1, r0, 2
|
||||
@ -21428,7 +21428,7 @@ sub_80D233C: @ 80D233C
|
||||
push {r6,r7}
|
||||
movs r7, 0
|
||||
movs r0, 0
|
||||
ldr r1, =gUnknown_03005D94
|
||||
ldr r1, =gPokemonStoragePtr
|
||||
mov r9, r1
|
||||
_080D234C:
|
||||
lsls r1, r0, 2
|
||||
@ -21490,7 +21490,7 @@ sub_80D23A8: @ 80D23A8
|
||||
strh r0, [r1, 0x2]
|
||||
movs r0, 0
|
||||
mov r8, r0
|
||||
ldr r7, =gUnknown_03005D94
|
||||
ldr r7, =gPokemonStoragePtr
|
||||
movs r5, 0x4
|
||||
_080D23C0:
|
||||
movs r6, 0
|
||||
|
@ -29,7 +29,7 @@ sub_81700F8: @ 81700F8
|
||||
bl sub_815355C
|
||||
lsls r0, 16
|
||||
lsrs r0, 16
|
||||
bl InitSaveBlockPointersWithRandomOffset
|
||||
bl SetSaveBlocksPointers
|
||||
bl sub_808447C
|
||||
bl ResetSaveCounters
|
||||
movs r0, 0
|
||||
|
@ -184,7 +184,8 @@ struct SaveBlock2
|
||||
/*0xEE1*/ u8 field_EE1;
|
||||
/*0xEE2*/ u8 field_EE2[7];
|
||||
/*0xEE9*/ u8 field_EE9;
|
||||
/*0xEEA*/ u8 field_EEA[22];
|
||||
/*0xEEA*/ u8 field_EEA[66];
|
||||
// sizeof=0xF2C
|
||||
};
|
||||
|
||||
extern struct SaveBlock2 *gSaveBlock2Ptr;
|
||||
@ -618,6 +619,23 @@ struct ContestWinner
|
||||
u8 contestRank;
|
||||
};
|
||||
|
||||
struct DaycareMon
|
||||
{
|
||||
struct BoxPokemon mon;
|
||||
struct MailStruct mail;
|
||||
u8 OT_name[OT_NAME_LENGTH + 1];
|
||||
u8 monName[11];
|
||||
u8 language;
|
||||
u32 stepsTaken;
|
||||
};
|
||||
|
||||
struct DaycareData
|
||||
{
|
||||
struct DaycareMon mons[2];
|
||||
u32 offspringPersonality;
|
||||
u8 stepCounter;
|
||||
};
|
||||
|
||||
#define FLAGS_NUMBER 300
|
||||
#define VARS_NUMBER 256
|
||||
|
||||
@ -686,33 +704,26 @@ struct SaveBlock1
|
||||
/*0x????*/ u16 unk2B1C[6];
|
||||
/*0x????*/ u16 unk2B28[6];
|
||||
/*0x????*/ u16 unk2B34[6];
|
||||
/*0x????*/ u16 unk2B40[6];
|
||||
/*0x????*/ u16 unk2B3A[3];
|
||||
/*0x2BE0*/ struct MailStruct mail[16];
|
||||
/*0x2E20*/ u8 additionalPhrases; // bitfield for 33 additional phrases in easy chat system
|
||||
/*0x2E20*/ u8 additionalPhrases[5]; // bitfield for 33 additional phrases in easy chat system
|
||||
/*0x2E25*/ u8 unk2E25[3]; // possibly padding?
|
||||
/*0x2E28*/ OldMan oldMan;
|
||||
/*0x2e64*/ struct EasyChatPair easyChatPairs[5]; //Dewford trend [0] and some other stuff
|
||||
/*0x2e8c*/ u8 filler_2E8C[0x4];
|
||||
/*0x2e90*/ struct ContestWinner contestWinners[13]; // 0 - 5 used in contest hall, 6 - 7 unused?, 8 - 12 museum
|
||||
|
||||
// TODO: fix
|
||||
|
||||
/*0x????*/ struct BoxPokemon daycareData[2];
|
||||
/*0x????*/ struct RecordMixing_UnknownStruct filler_303C;
|
||||
/*0x????*/ u8 filler_30B4[0x2];
|
||||
/*0x????*/ u8 filler_30B6;
|
||||
/*0x????*/ u8 filler_30B7[1];
|
||||
/*0x????*/ struct LinkBattleRecord linkBattleRecords[5];
|
||||
/*0x????*/ u8 filler_3108[8];
|
||||
|
||||
/*0x3030*/ struct DaycareData daycare;
|
||||
/*0x3150*/ struct LinkBattleRecord linkBattleRecords[5];
|
||||
/*0x31A0*/ u8 filler_31A0[8];
|
||||
/*0x31A8*/ u8 giftRibbons[52];
|
||||
/*0x31DC*/ struct Roamer roamer;
|
||||
/*0x31F8*/ struct EnigmaBerry enigmaBerry;
|
||||
|
||||
// TODO: fix
|
||||
/*0x????*/ struct RamScript ramScript;
|
||||
/*0x????*/ struct RecordMixingGift recordMixingGift;
|
||||
/*0x????*/ u8 unk3A8C[52]; //pokedex related
|
||||
/*0x3728*/ struct RamScript ramScript;
|
||||
/*0x3B14*/ struct RecordMixingGift recordMixingGift;
|
||||
/*0x3B24*/ u8 seen2[52];
|
||||
/*0x3B58*/ u8 lilycoveLady[536]; // TODO: convert to a union
|
||||
/*0x3D70*/ u8 babyPhrase[24]; // TODO: convert to a struct
|
||||
// sizeof: 0x3D88
|
||||
};
|
||||
|
||||
extern struct SaveBlock1* gSaveBlock1Ptr;
|
||||
|
20
include/load_save.h
Normal file
20
include/load_save.h
Normal file
@ -0,0 +1,20 @@
|
||||
#ifndef GUARD_LOAD_SAVE_H
|
||||
#define GUARD_LOAD_SAVE_H
|
||||
|
||||
extern bool32 gFlashMemoryPresent;
|
||||
|
||||
void CheckForFlashMemory(void);
|
||||
void MoveSaveBlocks_ResetHeap(void);
|
||||
bool32 GetSecretBase2Field_9(void);
|
||||
void ClearSecretBase2Field_9(void);
|
||||
void SetSecretBase2Field_9(void);
|
||||
void SetSecretBase2Field_9_AndHideBG(void);
|
||||
void ClearSecretBase2Field_9_2(void);
|
||||
void SavePlayerParty(void);
|
||||
void LoadPlayerParty(void);
|
||||
void SaveSerializedGame(void);
|
||||
void LoadSerializedGame(void);
|
||||
void LoadPlayerBag(void);
|
||||
void SavePlayerBag(void);
|
||||
|
||||
#endif // GUARD_LOAD_SAVE_H
|
@ -261,6 +261,14 @@ struct Pokemon
|
||||
extern struct Pokemon gPlayerParty[6];
|
||||
extern struct Pokemon gEnemyParty[6];
|
||||
|
||||
struct PokemonStorage
|
||||
{
|
||||
/*0x0000*/ u8 currentBox;
|
||||
/*0x0001*/ struct BoxPokemon boxes[14][30];
|
||||
/*0x8344*/ u8 boxNames[14][9];
|
||||
/*0x83C2*/ u8 boxWallpapers[14];
|
||||
};
|
||||
|
||||
struct BaseStats
|
||||
{
|
||||
/* 0x00 */ u8 baseHP;
|
||||
|
@ -74,6 +74,7 @@ SECTIONS {
|
||||
asm/daycare.o(.text);
|
||||
asm/egg_hatch.o(.text);
|
||||
asm/rom_8072304.o(.text);
|
||||
src/load_save.o(.text);
|
||||
asm/load_save.o(.text);
|
||||
asm/trade.o(.text);
|
||||
asm/berry_blender.o(.text);
|
||||
|
104
src/load_save.c
Normal file
104
src/load_save.c
Normal file
@ -0,0 +1,104 @@
|
||||
#include "global.h"
|
||||
#include "gba/flash_internal.h"
|
||||
#include "load_save.h"
|
||||
#include "main.h"
|
||||
#include "pokemon.h"
|
||||
#include "rng.h"
|
||||
#include "malloc.h"
|
||||
|
||||
extern u8 gPlayerPartyCount;
|
||||
extern struct PokemonStorage* gPokemonStoragePtr;
|
||||
extern void* gUnknown_0203CF5C;
|
||||
extern u8 gHeap[0x1C000];
|
||||
|
||||
extern bool16 IdentifyFlash(void);
|
||||
extern void SetBagItemsPointers(void);
|
||||
extern void SetDecorationInventoriesPointers(void);
|
||||
extern void InitHeap(void *heapStart, u32 heapSize);
|
||||
|
||||
void ApplyNewEncyprtionKeyToAllEncryptedData(u32 encryptionKey);
|
||||
|
||||
#define SAVEBLOCK_MOVE_RANGE 128
|
||||
|
||||
EWRAM_DATA struct SaveBlock2 gSaveblock2 = {0};
|
||||
EWRAM_DATA u8 gSaveblock2_DMA[SAVEBLOCK_MOVE_RANGE] = {0};
|
||||
|
||||
EWRAM_DATA struct SaveBlock1 gSaveblock1 = {0};
|
||||
EWRAM_DATA u8 gSaveblock1_DMA[SAVEBLOCK_MOVE_RANGE] = {0};
|
||||
|
||||
EWRAM_DATA struct PokemonStorage gPokemonStorage = {0};
|
||||
EWRAM_DATA u8 gSaveblock3_DMA[SAVEBLOCK_MOVE_RANGE] = {0};
|
||||
|
||||
void CheckForFlashMemory(void)
|
||||
{
|
||||
if (!IdentifyFlash())
|
||||
{
|
||||
gFlashMemoryPresent = TRUE;
|
||||
InitFlashTimer();
|
||||
}
|
||||
else
|
||||
gFlashMemoryPresent = FALSE;
|
||||
}
|
||||
|
||||
void ClearSav2(void)
|
||||
{
|
||||
CpuFill16(0, &gSaveblock2, sizeof(struct SaveBlock2) + sizeof(gSaveblock2_DMA));
|
||||
}
|
||||
|
||||
void ClearSav1(void)
|
||||
{
|
||||
CpuFill16(0, &gSaveblock1, sizeof(struct SaveBlock1) + sizeof(gSaveblock1_DMA));
|
||||
}
|
||||
|
||||
void SetSaveBlocksPointers(u16 offset)
|
||||
{
|
||||
struct SaveBlock1** sav1_LocalVar = &gSaveBlock1Ptr;
|
||||
|
||||
offset = (offset + Random()) & (SAVEBLOCK_MOVE_RANGE - 4);
|
||||
|
||||
gSaveBlock2Ptr = (void*)(&gSaveblock2) + offset;
|
||||
*sav1_LocalVar = (void*)(&gSaveblock1) + offset;
|
||||
gPokemonStoragePtr = (void*)(&gPokemonStorage) + offset;
|
||||
|
||||
SetBagItemsPointers();
|
||||
SetDecorationInventoriesPointers();
|
||||
}
|
||||
/*
|
||||
void MoveSaveBlocks_ResetHeap(void)
|
||||
{
|
||||
void *vblankCB, *hblankCB;
|
||||
u32 encryptionKey;
|
||||
|
||||
// save interrupt functions and turn them off
|
||||
vblankCB = gMain.vblankCallback;
|
||||
hblankCB = gMain.hblankCallback;
|
||||
gMain.vblankCallback = NULL;
|
||||
gMain.hblankCallback = NULL;
|
||||
gUnknown_0203CF5C = NULL;
|
||||
|
||||
// copy saveblocks' content
|
||||
memcpy(gHeap, gSaveBlock2Ptr, sizeof(struct SaveBlock2));
|
||||
memcpy(gHeap + sizeof(struct SaveBlock2), gSaveBlock1Ptr, sizeof(struct SaveBlock1));
|
||||
memcpy(gHeap + sizeof(struct SaveBlock2) + sizeof(struct SaveBlock1), gPokemonStoragePtr, sizeof(struct PokemonStorage));
|
||||
|
||||
// change saveblocks' pointers
|
||||
// argument is a sum of the individual trainerId bytes
|
||||
SetSaveBlocksPointers(gHeap[10] + gHeap[11] + gHeap[12] + gHeap[13]);
|
||||
|
||||
// restore saveblock data since the pointers changed
|
||||
memcpy(gSaveBlock2Ptr, gHeap, sizeof(struct SaveBlock2));
|
||||
memcpy(gSaveBlock1Ptr, gHeap + sizeof(struct SaveBlock2), sizeof(struct SaveBlock1));
|
||||
memcpy(gPokemonStoragePtr, gHeap + sizeof(struct SaveBlock2) + sizeof(struct SaveBlock1), sizeof(struct PokemonStorage));
|
||||
|
||||
// heap was destroyed in the copying process, so reset it
|
||||
InitHeap(gHeap, sizeof(gHeap));
|
||||
|
||||
// restore interrupt functions
|
||||
gMain.hblankCallback = hblankCB;
|
||||
gMain.vblankCallback = vblankCB;
|
||||
|
||||
// create a new encryption key
|
||||
encryptionKey = (Random() << 0x10) + (Random());
|
||||
ApplyNewEncyprtionKeyToAllEncryptedData(encryptionKey);
|
||||
gSaveBlock2Ptr->encryptionKey = encryptionKey;
|
||||
}*/
|
12
src/main.c
12
src/main.c
@ -34,9 +34,9 @@ extern struct SoundInfo gSoundInfo;
|
||||
extern u32 gFlashMemoryPresent;
|
||||
extern u32 IntrMain[];
|
||||
extern u8 gHeap[];
|
||||
extern struct SaveBlock2 gUnknown_02024A54;
|
||||
extern char *gUnknown_03005D94;
|
||||
extern char gUnknown_02029808[];
|
||||
extern struct SaveBlock2 gSaveblock2;
|
||||
extern char *gPokemonStoragePtr;
|
||||
extern char gPokemonStorage[];
|
||||
extern u32 gBattleTypeFlags;
|
||||
extern u8 gUnknown_03002748;
|
||||
extern u32 *gUnknown_0203CF5C;
|
||||
@ -185,8 +185,8 @@ static void InitMainCallbacks(void)
|
||||
gMain.vblankCounter2 = 0;
|
||||
gMain.callback1 = NULL;
|
||||
SetMainCallback2(c2_copyright_1);
|
||||
gSaveBlock2Ptr = &gUnknown_02024A54;
|
||||
gUnknown_03005D94 = gUnknown_02029808;
|
||||
gSaveBlock2Ptr = &gSaveblock2;
|
||||
gPokemonStoragePtr = gPokemonStorage;
|
||||
}
|
||||
|
||||
static void CallCallbacks(void)
|
||||
@ -368,7 +368,7 @@ static void VBlankIntr(void)
|
||||
gMain.intrCheck |= INTR_FLAG_VBLANK;
|
||||
}
|
||||
|
||||
void StartFlashMemoryTimer(void)
|
||||
void InitFlashTimer(void)
|
||||
{
|
||||
SetFlashTimerIntr(2, gIntrTable + 0x7);
|
||||
}
|
||||
|
@ -5,7 +5,7 @@
|
||||
|
||||
extern struct SaveSectionOffsets gSaveSectionOffsets[0xE];
|
||||
extern struct SaveSectionLocation gRamSaveSectionLocations[0xE];
|
||||
extern void *gUnknown_03005D94;
|
||||
extern void *gPokemonStoragePtr;
|
||||
extern u8 gDecompressionBuffer[];
|
||||
extern u32 gFlashMemoryPresent;
|
||||
extern u16 gUnknown_03006294;
|
||||
@ -593,7 +593,7 @@ void UpdateSaveAddresses(void)
|
||||
|
||||
for(i = 5; i < 14; i++)
|
||||
{
|
||||
gRamSaveSectionLocations[i].data = gUnknown_03005D94 + gSaveSectionOffsets[i].toAdd;
|
||||
gRamSaveSectionLocations[i].data = gPokemonStoragePtr + gSaveSectionOffsets[i].toAdd;
|
||||
gRamSaveSectionLocations[i].size = gSaveSectionOffsets[i].size;
|
||||
}
|
||||
}
|
||||
@ -630,7 +630,7 @@ _081531AC:\n\
|
||||
bge _081531AC\n\
|
||||
movs r4, 0x5\n\
|
||||
ldr r1, =gRamSaveSectionLocations\n\
|
||||
ldr r5, =gUnknown_03005D94\n\
|
||||
ldr r5, =gPokemonStoragePtr\n\
|
||||
ldr r0, =gSaveSectionOffsets\n\
|
||||
adds r3, r1, 0\n\
|
||||
adds r3, 0x28\n\
|
||||
|
@ -251,7 +251,7 @@ gSaveBlock1Ptr: @ 3005D8C
|
||||
gSaveBlock2Ptr: @ 3005D90
|
||||
.space 0x4
|
||||
|
||||
gUnknown_03005D94: @ 3005D94
|
||||
gPokemonStoragePtr: @ 3005D94
|
||||
.space 0x4
|
||||
|
||||
gUnknown_03005D98: @ 3005D98
|
||||
|
@ -662,14 +662,7 @@ gUnknown_02024A38: @ 2024A38
|
||||
gUnknown_02024A4C: @ 2024A4C
|
||||
.space 0x8
|
||||
|
||||
gUnknown_02024A54: @ 2024A54
|
||||
.space 0xFAC
|
||||
|
||||
gUnknown_02025A00: @ 2025A00
|
||||
.space 0x3E08
|
||||
|
||||
gUnknown_02029808: @ 2029808
|
||||
.space 0x8450
|
||||
.include "src/load_save.o"
|
||||
|
||||
gUnknown_02031C58: @ 2031C58
|
||||
.space 0x528
|
||||
|
Loading…
Reference in New Issue
Block a user