mirror of
https://github.com/YohannDR/mzm.git
synced 2024-11-23 13:09:43 +00:00
Add sram_misc.c
This commit is contained in:
parent
290002f19e
commit
0325e2a2e8
@ -2,7 +2,7 @@
|
||||
|
||||
This is a work in progress decompilation of Metroid - Zero Mission.
|
||||
|
||||
2422/2721 functions decompiled (89.01%, 299 left)
|
||||
2424/2721 functions decompiled (89.08%, 297 left)
|
||||
Progress can be seen here : https://docs.google.com/spreadsheets/d/1X8XarD5evY8ZI7r_GQqh1pYmdVMbBcINYfRBUlogmKY/edit#gid=0
|
||||
|
||||
**This decomp is not shiftable, don't use it as a base to work on anything**
|
||||
|
@ -2,528 +2,6 @@
|
||||
|
||||
.syntax unified
|
||||
|
||||
thumb_func_start do_sram_operation
|
||||
do_sram_operation: @ 0x08000c48
|
||||
push {r4, r5, r6, r7, lr}
|
||||
sub sp, #4
|
||||
lsls r0, r0, #0x18
|
||||
lsrs r1, r0, #0x18
|
||||
adds r2, r1, #0
|
||||
movs r4, #0
|
||||
ldr r0, lbl_08000c68 @ =gSramCorruptFlag
|
||||
ldrb r0, [r0]
|
||||
cmp r0, #0
|
||||
beq lbl_08000cb8
|
||||
cmp r1, #0xe
|
||||
beq lbl_08000c6c
|
||||
cmp r1, #0xf
|
||||
beq lbl_08000c80
|
||||
b lbl_08000faa
|
||||
.align 2, 0
|
||||
lbl_08000c68: .4byte gSramCorruptFlag
|
||||
lbl_08000c6c:
|
||||
ldr r1, lbl_08000c78 @ =0x0000ffff
|
||||
ldr r2, lbl_08000c7c @ =0x02038000
|
||||
movs r3, #0x80
|
||||
lsls r3, r3, #8
|
||||
b lbl_08000c9e
|
||||
.align 2, 0
|
||||
lbl_08000c78: .4byte 0x0000ffff
|
||||
lbl_08000c7c: .4byte 0x02038000
|
||||
lbl_08000c80:
|
||||
ldr r1, lbl_08000cac @ =0x0000ffff
|
||||
ldr r3, lbl_08000cb0 @ =0x08754bc8
|
||||
ldr r0, lbl_08000cb4 @ =gMostRecentSaveFile
|
||||
movs r2, #0
|
||||
ldrsb r2, [r0, r2]
|
||||
lsls r0, r2, #3
|
||||
adds r0, r0, r2
|
||||
lsls r0, r0, #4
|
||||
adds r0, r0, r2
|
||||
lsls r0, r0, #5
|
||||
adds r0, #0x80
|
||||
ldr r2, [r3]
|
||||
adds r2, r2, r0
|
||||
movs r3, #0x91
|
||||
lsls r3, r3, #5
|
||||
lbl_08000c9e:
|
||||
movs r0, #0x10
|
||||
str r0, [sp]
|
||||
movs r0, #3
|
||||
bl BitFill
|
||||
b lbl_08000faa
|
||||
.align 2, 0
|
||||
lbl_08000cac: .4byte 0x0000ffff
|
||||
lbl_08000cb0: .4byte 0x08754bc8
|
||||
lbl_08000cb4: .4byte gMostRecentSaveFile
|
||||
lbl_08000cb8:
|
||||
cmp r2, #0x10
|
||||
bls lbl_08000cbe
|
||||
b lbl_08000faa
|
||||
lbl_08000cbe:
|
||||
lsls r0, r2, #2
|
||||
ldr r1, lbl_08000cc8 @ =lbl_08000ccc
|
||||
adds r0, r0, r1
|
||||
ldr r0, [r0]
|
||||
mov pc, r0
|
||||
.align 2, 0
|
||||
lbl_08000cc8: .4byte lbl_08000ccc
|
||||
lbl_08000ccc: @ jump table
|
||||
.4byte lbl_08000d10 @ case 0
|
||||
.4byte lbl_08000d60 @ case 1
|
||||
.4byte lbl_08000d7c @ case 2
|
||||
.4byte lbl_08000da0 @ case 3
|
||||
.4byte lbl_08000dd8 @ case 4
|
||||
.4byte lbl_08000e14 @ case 5
|
||||
.4byte lbl_08000e34 @ case 6
|
||||
.4byte lbl_08000e58 @ case 7
|
||||
.4byte lbl_08000e78 @ case 8
|
||||
.4byte lbl_08000e9c @ case 9
|
||||
.4byte lbl_08000ec0 @ case 10
|
||||
.4byte lbl_08000ee4 @ case 11
|
||||
.4byte lbl_08000f20 @ case 12
|
||||
.4byte lbl_08000f34 @ case 13
|
||||
.4byte lbl_08000f4c @ case 14
|
||||
.4byte lbl_08000f60 @ case 15
|
||||
.4byte lbl_08000f98 @ case 16
|
||||
lbl_08000d10:
|
||||
ldr r2, lbl_08000d4c @ =0x040000d4
|
||||
ldr r6, lbl_08000d50 @ =0x08754bc8
|
||||
ldr r0, [r6]
|
||||
str r0, [r2]
|
||||
ldr r3, lbl_08000d54 @ =0x00006d40
|
||||
adds r1, r0, r3
|
||||
str r1, [r2, #4]
|
||||
ldr r1, lbl_08000d58 @ =0x80000020
|
||||
str r1, [r2, #8]
|
||||
ldr r1, [r2, #8]
|
||||
ldr r5, lbl_08000d5c @ =0x08754bcc
|
||||
ldr r1, [r5]
|
||||
movs r2, #0x40
|
||||
bl SramWriteChecked
|
||||
adds r4, r0, #0
|
||||
cmp r4, #0
|
||||
beq lbl_08000d36
|
||||
b lbl_08000faa
|
||||
lbl_08000d36:
|
||||
ldr r0, [r6]
|
||||
ldr r1, lbl_08000d54 @ =0x00006d40
|
||||
adds r0, r0, r1
|
||||
ldr r1, [r5]
|
||||
ldr r2, lbl_08000d54 @ =0x00006d40
|
||||
adds r1, r1, r2
|
||||
movs r2, #0x40
|
||||
bl SramWriteChecked
|
||||
b lbl_08000fa8
|
||||
.align 2, 0
|
||||
lbl_08000d4c: .4byte 0x040000d4
|
||||
lbl_08000d50: .4byte 0x08754bc8
|
||||
lbl_08000d54: .4byte 0x00006d40
|
||||
lbl_08000d58: .4byte 0x80000020
|
||||
lbl_08000d5c: .4byte 0x08754bcc
|
||||
lbl_08000d60:
|
||||
ldr r0, lbl_08000d74 @ =0x08754bc8
|
||||
ldr r0, [r0]
|
||||
adds r0, #0x40
|
||||
ldr r1, lbl_08000d78 @ =0x08754bcc
|
||||
ldr r1, [r1]
|
||||
adds r1, #0x40
|
||||
movs r2, #0x40
|
||||
bl SramWriteChecked
|
||||
b lbl_08000fa8
|
||||
.align 2, 0
|
||||
lbl_08000d74: .4byte 0x08754bc8
|
||||
lbl_08000d78: .4byte 0x08754bcc
|
||||
lbl_08000d7c:
|
||||
ldr r0, lbl_08000d94 @ =0x08754bc8
|
||||
ldr r0, [r0]
|
||||
ldr r2, lbl_08000d98 @ =0x00006d40
|
||||
adds r0, r0, r2
|
||||
ldr r1, lbl_08000d9c @ =0x08754bcc
|
||||
ldr r1, [r1]
|
||||
adds r1, r1, r2
|
||||
movs r2, #0x40
|
||||
bl SramWriteChecked
|
||||
b lbl_08000fa8
|
||||
.align 2, 0
|
||||
lbl_08000d94: .4byte 0x08754bc8
|
||||
lbl_08000d98: .4byte 0x00006d40
|
||||
lbl_08000d9c: .4byte 0x08754bcc
|
||||
lbl_08000da0:
|
||||
ldr r1, lbl_08000dcc @ =0x08754bc8
|
||||
ldr r0, lbl_08000dd0 @ =gMostRecentSaveFile
|
||||
ldrb r0, [r0]
|
||||
lsls r0, r0, #0x18
|
||||
asrs r0, r0, #0x18
|
||||
lsls r2, r0, #3
|
||||
adds r2, r2, r0
|
||||
lsls r2, r2, #4
|
||||
adds r2, r2, r0
|
||||
lsls r2, r2, #5
|
||||
adds r2, #0x80
|
||||
ldr r0, [r1]
|
||||
adds r0, r0, r2
|
||||
ldr r1, lbl_08000dd4 @ =0x08754bcc
|
||||
ldr r1, [r1]
|
||||
adds r1, r1, r2
|
||||
movs r2, #0x91
|
||||
lsls r2, r2, #5
|
||||
bl SramWriteChecked
|
||||
b lbl_08000fa8
|
||||
.align 2, 0
|
||||
lbl_08000dcc: .4byte 0x08754bc8
|
||||
lbl_08000dd0: .4byte gMostRecentSaveFile
|
||||
lbl_08000dd4: .4byte 0x08754bcc
|
||||
lbl_08000dd8:
|
||||
ldr r1, lbl_08000e04 @ =0x08754bc8
|
||||
ldr r0, lbl_08000e08 @ =gMostRecentSaveFile
|
||||
ldrb r0, [r0]
|
||||
lsls r0, r0, #0x18
|
||||
asrs r0, r0, #0x18
|
||||
lsls r2, r0, #3
|
||||
adds r2, r2, r0
|
||||
lsls r2, r2, #4
|
||||
adds r2, r2, r0
|
||||
lsls r2, r2, #5
|
||||
ldr r3, lbl_08000e0c @ =0x000036e0
|
||||
adds r2, r2, r3
|
||||
ldr r0, [r1]
|
||||
adds r0, r0, r2
|
||||
ldr r1, lbl_08000e10 @ =0x08754bcc
|
||||
ldr r1, [r1]
|
||||
adds r1, r1, r2
|
||||
movs r2, #0x91
|
||||
lsls r2, r2, #5
|
||||
bl SramWriteChecked
|
||||
b lbl_08000fa8
|
||||
.align 2, 0
|
||||
lbl_08000e04: .4byte 0x08754bc8
|
||||
lbl_08000e08: .4byte gMostRecentSaveFile
|
||||
lbl_08000e0c: .4byte 0x000036e0
|
||||
lbl_08000e10: .4byte 0x08754bcc
|
||||
lbl_08000e14:
|
||||
ldr r0, lbl_08000e2c @ =0x08754bc8
|
||||
ldr r0, [r0]
|
||||
movs r2, #0xdb
|
||||
lsls r2, r2, #7
|
||||
adds r0, r0, r2
|
||||
ldr r1, lbl_08000e30 @ =0x08754bcc
|
||||
ldr r1, [r1]
|
||||
adds r1, r1, r2
|
||||
movs r2, #0x40
|
||||
bl SramWriteChecked
|
||||
b lbl_08000fa8
|
||||
.align 2, 0
|
||||
lbl_08000e2c: .4byte 0x08754bc8
|
||||
lbl_08000e30: .4byte 0x08754bcc
|
||||
lbl_08000e34:
|
||||
ldr r0, lbl_08000e4c @ =0x08754bc8
|
||||
ldr r0, [r0]
|
||||
ldr r2, lbl_08000e50 @ =0x00006dc0
|
||||
adds r0, r0, r2
|
||||
ldr r1, lbl_08000e54 @ =0x08754bcc
|
||||
ldr r1, [r1]
|
||||
adds r1, r1, r2
|
||||
movs r2, #0x40
|
||||
bl SramWriteChecked
|
||||
b lbl_08000fa8
|
||||
.align 2, 0
|
||||
lbl_08000e4c: .4byte 0x08754bc8
|
||||
lbl_08000e50: .4byte 0x00006dc0
|
||||
lbl_08000e54: .4byte 0x08754bcc
|
||||
lbl_08000e58:
|
||||
ldr r0, lbl_08000e70 @ =0x08754bc8
|
||||
ldr r0, [r0]
|
||||
movs r2, #0xdc
|
||||
lsls r2, r2, #7
|
||||
adds r0, r0, r2
|
||||
ldr r1, lbl_08000e74 @ =0x08754bcc
|
||||
ldr r1, [r1]
|
||||
adds r1, r1, r2
|
||||
movs r2, #0x40
|
||||
bl SramWriteChecked
|
||||
b lbl_08000fa8
|
||||
.align 2, 0
|
||||
lbl_08000e70: .4byte 0x08754bc8
|
||||
lbl_08000e74: .4byte 0x08754bcc
|
||||
lbl_08000e78:
|
||||
ldr r0, lbl_08000e90 @ =0x08754bc8
|
||||
ldr r0, [r0]
|
||||
ldr r2, lbl_08000e94 @ =0x00006e40
|
||||
adds r0, r0, r2
|
||||
ldr r1, lbl_08000e98 @ =0x08754bcc
|
||||
ldr r1, [r1]
|
||||
adds r1, r1, r2
|
||||
movs r2, #0x40
|
||||
bl SramWriteChecked
|
||||
b lbl_08000fa8
|
||||
.align 2, 0
|
||||
lbl_08000e90: .4byte 0x08754bc8
|
||||
lbl_08000e94: .4byte 0x00006e40
|
||||
lbl_08000e98: .4byte 0x08754bcc
|
||||
lbl_08000e9c:
|
||||
ldr r0, lbl_08000eb8 @ =0x08754bc8
|
||||
ldr r0, [r0]
|
||||
movs r2, #0xdd
|
||||
lsls r2, r2, #7
|
||||
adds r0, r0, r2
|
||||
ldr r1, lbl_08000ebc @ =0x08754bcc
|
||||
ldr r1, [r1]
|
||||
adds r1, r1, r2
|
||||
movs r2, #0x80
|
||||
lsls r2, r2, #1
|
||||
bl SramWriteChecked
|
||||
b lbl_08000fa8
|
||||
.align 2, 0
|
||||
lbl_08000eb8: .4byte 0x08754bc8
|
||||
lbl_08000ebc: .4byte 0x08754bcc
|
||||
lbl_08000ec0:
|
||||
ldr r0, lbl_08000edc @ =0x08754bc8
|
||||
ldr r0, [r0]
|
||||
movs r2, #0xdf
|
||||
lsls r2, r2, #7
|
||||
adds r0, r0, r2
|
||||
ldr r1, lbl_08000ee0 @ =0x08754bcc
|
||||
ldr r1, [r1]
|
||||
adds r1, r1, r2
|
||||
movs r2, #0x80
|
||||
lsls r2, r2, #1
|
||||
bl SramWriteChecked
|
||||
b lbl_08000fa8
|
||||
.align 2, 0
|
||||
lbl_08000edc: .4byte 0x08754bc8
|
||||
lbl_08000ee0: .4byte 0x08754bcc
|
||||
lbl_08000ee4:
|
||||
ldr r6, lbl_08000f18 @ =0x08754bc8
|
||||
ldr r0, [r6]
|
||||
movs r2, #0xe1
|
||||
lsls r2, r2, #7
|
||||
adds r0, r0, r2
|
||||
ldr r5, lbl_08000f1c @ =0x08754bcc
|
||||
ldr r1, [r5]
|
||||
adds r1, r1, r2
|
||||
movs r7, #0x80
|
||||
lsls r7, r7, #2
|
||||
adds r2, r7, #0
|
||||
bl SramWriteChecked
|
||||
adds r4, r0, #0
|
||||
cmp r4, #0
|
||||
bne lbl_08000faa
|
||||
ldr r0, [r6]
|
||||
movs r2, #0xe5
|
||||
lsls r2, r2, #7
|
||||
adds r0, r0, r2
|
||||
ldr r1, [r5]
|
||||
adds r1, r1, r2
|
||||
adds r2, r7, #0
|
||||
bl SramWriteChecked
|
||||
b lbl_08000fa8
|
||||
.align 2, 0
|
||||
lbl_08000f18: .4byte 0x08754bc8
|
||||
lbl_08000f1c: .4byte 0x08754bcc
|
||||
lbl_08000f20:
|
||||
ldr r0, lbl_08000f2c @ =0x0203ff70
|
||||
ldr r1, lbl_08000f30 @ =0x0e007f70
|
||||
movs r2, #0x10
|
||||
bl SramWriteChecked
|
||||
b lbl_08000fa8
|
||||
.align 2, 0
|
||||
lbl_08000f2c: .4byte 0x0203ff70
|
||||
lbl_08000f30: .4byte 0x0e007f70
|
||||
lbl_08000f34:
|
||||
ldr r0, lbl_08000f44 @ =0x0203f800
|
||||
ldr r1, lbl_08000f48 @ =0x0e007800
|
||||
movs r2, #0xa0
|
||||
lsls r2, r2, #2
|
||||
bl SramWriteChecked
|
||||
b lbl_08000fa8
|
||||
.align 2, 0
|
||||
lbl_08000f44: .4byte 0x0203f800
|
||||
lbl_08000f48: .4byte 0x0e007800
|
||||
lbl_08000f4c:
|
||||
movs r0, #0xe0
|
||||
lsls r0, r0, #0x14
|
||||
ldr r1, lbl_08000f5c @ =0x02038000
|
||||
movs r2, #0x80
|
||||
lsls r2, r2, #8
|
||||
bl SramWriteUnchecked
|
||||
b lbl_08000faa
|
||||
.align 2, 0
|
||||
lbl_08000f5c: .4byte 0x02038000
|
||||
lbl_08000f60:
|
||||
ldr r1, lbl_08000f8c @ =0x08754bcc
|
||||
ldr r0, lbl_08000f90 @ =gMostRecentSaveFile
|
||||
ldrb r0, [r0]
|
||||
lsls r0, r0, #0x18
|
||||
asrs r0, r0, #0x18
|
||||
lsls r2, r0, #3
|
||||
adds r2, r2, r0
|
||||
lsls r2, r2, #4
|
||||
adds r2, r2, r0
|
||||
lsls r2, r2, #5
|
||||
adds r2, #0x80
|
||||
ldr r0, [r1]
|
||||
adds r0, r0, r2
|
||||
ldr r1, lbl_08000f94 @ =0x08754bc8
|
||||
ldr r1, [r1]
|
||||
adds r1, r1, r2
|
||||
movs r2, #0x91
|
||||
lsls r2, r2, #5
|
||||
bl SramWriteUnchecked
|
||||
b lbl_08000faa
|
||||
.align 2, 0
|
||||
lbl_08000f8c: .4byte 0x08754bcc
|
||||
lbl_08000f90: .4byte gMostRecentSaveFile
|
||||
lbl_08000f94: .4byte 0x08754bc8
|
||||
lbl_08000f98:
|
||||
ldr r0, lbl_08000fb4 @ =0x08754bcc
|
||||
ldr r0, [r0]
|
||||
ldr r1, lbl_08000fb8 @ =0x08754bc8
|
||||
ldr r1, [r1]
|
||||
movs r2, #0x80
|
||||
lsls r2, r2, #8
|
||||
bl SramCheck
|
||||
lbl_08000fa8:
|
||||
adds r4, r0, #0
|
||||
lbl_08000faa:
|
||||
adds r0, r4, #0
|
||||
add sp, #4
|
||||
pop {r4, r5, r6, r7}
|
||||
pop {r1}
|
||||
bx r1
|
||||
.align 2, 0
|
||||
lbl_08000fb4: .4byte 0x08754bcc
|
||||
lbl_08000fb8: .4byte 0x08754bc8
|
||||
|
||||
thumb_func_start sub_08000fbc
|
||||
sub_08000fbc: @ 0x08000fbc
|
||||
push {r4, r5, lr}
|
||||
lsls r0, r0, #0x18
|
||||
lsrs r1, r0, #0x18
|
||||
adds r2, r1, #0
|
||||
movs r5, #0x80
|
||||
lsls r5, r5, #2
|
||||
ldr r0, lbl_08000ff0 @ =gUnk_3000c20
|
||||
ldrb r0, [r0]
|
||||
lsls r4, r0, #9
|
||||
movs r0, #0x91
|
||||
lsls r0, r0, #5
|
||||
cmp r4, r0
|
||||
ble lbl_08000fda
|
||||
ldr r0, lbl_08000ff4 @ =0xffffede0
|
||||
adds r5, r4, r0
|
||||
lbl_08000fda:
|
||||
ldr r0, lbl_08000ff8 @ =gSramCorruptFlag
|
||||
ldrb r0, [r0]
|
||||
cmp r0, #0
|
||||
bne lbl_0800108e
|
||||
cmp r1, #1
|
||||
beq lbl_08001024
|
||||
cmp r1, #1
|
||||
bgt lbl_08000ffc
|
||||
cmp r1, #0
|
||||
beq lbl_08001002
|
||||
b lbl_0800108e
|
||||
.align 2, 0
|
||||
lbl_08000ff0: .4byte gUnk_3000c20
|
||||
lbl_08000ff4: .4byte 0xffffede0
|
||||
lbl_08000ff8: .4byte gSramCorruptFlag
|
||||
lbl_08000ffc:
|
||||
cmp r2, #2
|
||||
beq lbl_08001064
|
||||
b lbl_0800108e
|
||||
lbl_08001002:
|
||||
ldr r1, lbl_0800101c @ =0x08754bc8
|
||||
ldr r0, lbl_08001020 @ =gMostRecentSaveFile
|
||||
ldrb r0, [r0]
|
||||
lsls r0, r0, #0x18
|
||||
asrs r0, r0, #0x18
|
||||
lsls r2, r0, #3
|
||||
adds r2, r2, r0
|
||||
lsls r2, r2, #4
|
||||
adds r2, r2, r0
|
||||
lsls r2, r2, #5
|
||||
adds r2, #0x80
|
||||
b lbl_0800103c
|
||||
.align 2, 0
|
||||
lbl_0800101c: .4byte 0x08754bc8
|
||||
lbl_08001020: .4byte gMostRecentSaveFile
|
||||
lbl_08001024:
|
||||
ldr r1, lbl_08001054 @ =0x08754bc8
|
||||
ldr r0, lbl_08001058 @ =gMostRecentSaveFile
|
||||
ldrb r0, [r0]
|
||||
lsls r0, r0, #0x18
|
||||
asrs r0, r0, #0x18
|
||||
lsls r2, r0, #3
|
||||
adds r2, r2, r0
|
||||
lsls r2, r2, #4
|
||||
adds r2, r2, r0
|
||||
lsls r2, r2, #5
|
||||
ldr r0, lbl_0800105c @ =0x000036e0
|
||||
adds r2, r2, r0
|
||||
lbl_0800103c:
|
||||
ldr r0, [r1]
|
||||
adds r0, r0, r2
|
||||
adds r0, r0, r4
|
||||
ldr r1, lbl_08001060 @ =0x08754bcc
|
||||
ldr r1, [r1]
|
||||
adds r1, r1, r2
|
||||
adds r1, r1, r4
|
||||
adds r2, r5, #0
|
||||
bl SramWriteChecked
|
||||
b lbl_0800108e
|
||||
.align 2, 0
|
||||
lbl_08001054: .4byte 0x08754bc8
|
||||
lbl_08001058: .4byte gMostRecentSaveFile
|
||||
lbl_0800105c: .4byte 0x000036e0
|
||||
lbl_08001060: .4byte 0x08754bcc
|
||||
lbl_08001064:
|
||||
ldr r1, lbl_080010b0 @ =0x08754bcc
|
||||
ldr r0, lbl_080010b4 @ =gMostRecentSaveFile
|
||||
ldrb r0, [r0]
|
||||
lsls r0, r0, #0x18
|
||||
asrs r0, r0, #0x18
|
||||
lsls r2, r0, #3
|
||||
adds r2, r2, r0
|
||||
lsls r2, r2, #4
|
||||
adds r2, r2, r0
|
||||
lsls r2, r2, #5
|
||||
adds r2, #0x80
|
||||
ldr r0, [r1]
|
||||
adds r0, r0, r2
|
||||
adds r0, r0, r4
|
||||
ldr r1, lbl_080010b8 @ =0x08754bc8
|
||||
ldr r1, [r1]
|
||||
adds r1, r1, r2
|
||||
adds r1, r1, r4
|
||||
adds r2, r5, #0
|
||||
bl SramWriteUnchecked
|
||||
lbl_0800108e:
|
||||
movs r2, #0
|
||||
adds r1, r4, r5
|
||||
ldr r0, lbl_080010bc @ =0x0000121f
|
||||
cmp r1, r0
|
||||
bgt lbl_0800109a
|
||||
movs r2, #1
|
||||
lbl_0800109a:
|
||||
ldr r1, lbl_080010c0 @ =gUnk_3000c20
|
||||
ldrb r0, [r1]
|
||||
adds r0, r0, r2
|
||||
muls r0, r2, r0
|
||||
strb r0, [r1]
|
||||
movs r0, #1
|
||||
eors r2, r0
|
||||
adds r0, r2, #0
|
||||
pop {r4, r5}
|
||||
pop {r1}
|
||||
bx r1
|
||||
.align 2, 0
|
||||
lbl_080010b0: .4byte 0x08754bcc
|
||||
lbl_080010b4: .4byte gMostRecentSaveFile
|
||||
lbl_080010b8: .4byte 0x08754bc8
|
||||
lbl_080010bc: .4byte 0x0000121f
|
||||
lbl_080010c0: .4byte gUnk_3000c20
|
||||
|
||||
thumb_func_start sub_080010c4
|
||||
sub_080010c4: @ 0x080010c4
|
||||
push {r4, r5, r6, r7, lr}
|
@ -22909,9 +22909,9 @@ lbl_080732bc:
|
||||
beq lbl_080732d2
|
||||
lbl_080732c2:
|
||||
movs r0, #0xe
|
||||
bl do_sram_operation
|
||||
bl DoSramOperation
|
||||
movs r0, #0x10
|
||||
bl do_sram_operation
|
||||
bl DoSramOperation
|
||||
cmp r0, #0
|
||||
bne lbl_080732bc
|
||||
lbl_080732d2:
|
||||
@ -23000,7 +23000,7 @@ lbl_08073360:
|
||||
mvns r0, r1
|
||||
str r0, [r4, #4]
|
||||
movs r0, #0
|
||||
bl do_sram_operation
|
||||
bl DoSramOperation
|
||||
pop {r4, r5, r6}
|
||||
pop {r0}
|
||||
bx r0
|
||||
@ -23079,7 +23079,7 @@ lbl_08073418:
|
||||
bl DMATransfer
|
||||
movs r6, #0
|
||||
movs r0, #0
|
||||
bl do_sram_operation
|
||||
bl DoSramOperation
|
||||
b lbl_080734a4
|
||||
lbl_08073432:
|
||||
ldr r3, lbl_0807346c @ =0x00006d40
|
||||
@ -23091,7 +23091,7 @@ lbl_08073432:
|
||||
bl DMATransfer
|
||||
movs r6, #0
|
||||
movs r0, #0
|
||||
bl do_sram_operation
|
||||
bl DoSramOperation
|
||||
mov r0, r8
|
||||
cmp r0, #0
|
||||
beq lbl_080734a4
|
||||
@ -23104,7 +23104,7 @@ lbl_08073432:
|
||||
movs r3, #0x40
|
||||
bl DMATransfer
|
||||
movs r0, #1
|
||||
bl do_sram_operation
|
||||
bl DoSramOperation
|
||||
b lbl_080734a4
|
||||
.align 2, 0
|
||||
lbl_0807346c: .4byte 0x00006d40
|
||||
@ -23119,7 +23119,7 @@ lbl_08073470:
|
||||
movs r3, #0x40
|
||||
bl DMATransfer
|
||||
movs r0, #1
|
||||
bl do_sram_operation
|
||||
bl DoSramOperation
|
||||
cmp r7, #0
|
||||
beq lbl_080734a4
|
||||
ldr r1, [r4]
|
||||
@ -23130,7 +23130,7 @@ lbl_08073470:
|
||||
movs r3, #0x40
|
||||
bl DMATransfer
|
||||
movs r0, #2
|
||||
bl do_sram_operation
|
||||
bl DoSramOperation
|
||||
lbl_080734a4:
|
||||
cmp r6, #0
|
||||
bne lbl_080734b8
|
||||
@ -23358,7 +23358,7 @@ lbl_08073658:
|
||||
lbl_08073664: .4byte gUnk_3000c20
|
||||
lbl_08073668:
|
||||
movs r0, #0
|
||||
bl sub_08000fbc
|
||||
bl unk_fbc
|
||||
cmp r0, #0
|
||||
beq lbl_080736c4
|
||||
b lbl_080736a2
|
||||
@ -23567,7 +23567,7 @@ lbl_08073808:
|
||||
lbl_08073818: .4byte gUnk_3000c20
|
||||
lbl_0807381c:
|
||||
movs r0, #2
|
||||
bl sub_08000fbc
|
||||
bl unk_fbc
|
||||
cmp r0, #0
|
||||
beq lbl_080738e6
|
||||
b lbl_080738c6
|
||||
@ -23601,7 +23601,7 @@ lbl_08073860: .4byte gDifficulty
|
||||
lbl_08073864: .4byte gUnk_3000c20
|
||||
lbl_08073868:
|
||||
movs r0, #0
|
||||
bl sub_08000fbc
|
||||
bl unk_fbc
|
||||
cmp r0, #0
|
||||
beq lbl_080738e6
|
||||
ldr r2, lbl_0807388c @ =gSaveFilesInfo
|
||||
@ -23905,7 +23905,7 @@ lbl_08073ac0:
|
||||
lbl_08073ad0: .4byte gUnk_3000c20
|
||||
lbl_08073ad4:
|
||||
movs r0, #2
|
||||
bl sub_08000fbc
|
||||
bl unk_fbc
|
||||
cmp r0, #0
|
||||
beq lbl_08073b9a
|
||||
b lbl_08073b7a
|
||||
@ -23938,7 +23938,7 @@ lbl_08073b14: .4byte gDifficulty
|
||||
lbl_08073b18: .4byte gUnk_3000c20
|
||||
lbl_08073b1c:
|
||||
movs r0, #0
|
||||
bl sub_08000fbc
|
||||
bl unk_fbc
|
||||
cmp r0, #0
|
||||
beq lbl_08073b9a
|
||||
ldr r2, lbl_08073b40 @ =gSaveFilesInfo
|
||||
@ -24044,7 +24044,7 @@ lbl_08073be8: @ jump table
|
||||
.4byte lbl_08073ccc @ case 5
|
||||
lbl_08073c00:
|
||||
movs r0, #4
|
||||
bl sub_08000fbc
|
||||
bl unk_fbc
|
||||
cmp r0, #0
|
||||
beq lbl_08073cd2
|
||||
ldr r1, lbl_08073c14 @ =gSramOperationStage
|
||||
@ -24079,7 +24079,7 @@ lbl_08073c48: .4byte gUnk_3000c20
|
||||
lbl_08073c4c: .4byte gSramOperationStage
|
||||
lbl_08073c50:
|
||||
movs r0, #0
|
||||
bl sub_08000fbc
|
||||
bl unk_fbc
|
||||
cmp r0, #0
|
||||
beq lbl_08073cd2
|
||||
ldr r2, lbl_08073c78 @ =gSaveFilesInfo
|
||||
@ -25023,7 +25023,7 @@ lbl_080743f0:
|
||||
lsls r3, r3, #5
|
||||
bl DMATransfer
|
||||
movs r0, #4
|
||||
bl do_sram_operation
|
||||
bl DoSramOperation
|
||||
movs r0, #1
|
||||
ldr r1, [sp, #4]
|
||||
strb r0, [r1]
|
||||
@ -25113,7 +25113,7 @@ lbl_080744d8:
|
||||
mov r3, sb
|
||||
bl BitFill
|
||||
movs r0, #3
|
||||
bl do_sram_operation
|
||||
bl DoSramOperation
|
||||
mov r2, r8
|
||||
movs r1, #0
|
||||
ldrsb r1, [r2, r1]
|
||||
@ -25132,7 +25132,7 @@ lbl_080744d8:
|
||||
mov r3, sb
|
||||
bl BitFill
|
||||
movs r0, #4
|
||||
bl do_sram_operation
|
||||
bl DoSramOperation
|
||||
mov r4, r8
|
||||
movs r1, #0
|
||||
ldrsb r1, [r4, r1]
|
||||
@ -25805,7 +25805,7 @@ lbl_08074a28:
|
||||
mvns r0, r1
|
||||
strh r0, [r5, #4]
|
||||
movs r0, #5
|
||||
bl do_sram_operation
|
||||
bl DoSramOperation
|
||||
pop {r4, r5}
|
||||
pop {r0}
|
||||
bx r0
|
||||
@ -26003,7 +26003,7 @@ lbl_08074bae:
|
||||
mvns r0, r1
|
||||
strh r0, [r5, #4]
|
||||
movs r0, #8
|
||||
bl do_sram_operation
|
||||
bl DoSramOperation
|
||||
pop {r4, r5}
|
||||
pop {r0}
|
||||
bx r0
|
||||
@ -26210,7 +26210,7 @@ lbl_08074d48:
|
||||
mvns r0, r1
|
||||
strh r0, [r5, #4]
|
||||
movs r0, #6
|
||||
bl do_sram_operation
|
||||
bl DoSramOperation
|
||||
pop {r4, r5, r6, r7}
|
||||
pop {r0}
|
||||
bx r0
|
||||
@ -26347,7 +26347,7 @@ lbl_08074e6e:
|
||||
str r0, [r6, #8]
|
||||
ldr r0, [r6, #8]
|
||||
movs r0, #7
|
||||
bl do_sram_operation
|
||||
bl DoSramOperation
|
||||
b lbl_08074eee
|
||||
.align 2, 0
|
||||
lbl_08074e98: .4byte 0x00006dc0
|
||||
@ -26368,7 +26368,7 @@ lbl_08074ea0:
|
||||
str r2, [r6, #8]
|
||||
ldr r0, [r6, #8]
|
||||
movs r0, #6
|
||||
bl do_sram_operation
|
||||
bl DoSramOperation
|
||||
mov r0, sp
|
||||
movs r1, #0
|
||||
strh r1, [r0]
|
||||
@ -26383,7 +26383,7 @@ lbl_08074ea0:
|
||||
str r2, [r6, #8]
|
||||
ldr r0, [r6, #8]
|
||||
movs r0, #7
|
||||
bl do_sram_operation
|
||||
bl DoSramOperation
|
||||
lbl_08074ee2:
|
||||
movs r0, #1
|
||||
add r8, r0
|
||||
@ -26419,7 +26419,7 @@ lbl_08074f04:
|
||||
str r0, [r1, #8]
|
||||
ldr r0, [r1, #8]
|
||||
movs r0, #6
|
||||
bl do_sram_operation
|
||||
bl DoSramOperation
|
||||
b lbl_08074eee
|
||||
.align 2, 0
|
||||
lbl_08074f2c: .4byte 0x040000d4
|
||||
@ -26519,7 +26519,7 @@ lbl_08074fb2:
|
||||
mvns r0, r1
|
||||
strh r0, [r5, #0x14]
|
||||
movs r0, #9
|
||||
bl do_sram_operation
|
||||
bl DoSramOperation
|
||||
pop {r4, r5, r6, r7}
|
||||
pop {r0}
|
||||
bx r0
|
||||
@ -26657,7 +26657,7 @@ lbl_080750d4:
|
||||
str r0, [r4, #8]
|
||||
ldr r0, [r4, #8]
|
||||
movs r0, #0xa
|
||||
bl do_sram_operation
|
||||
bl DoSramOperation
|
||||
b lbl_08075156
|
||||
.align 2, 0
|
||||
lbl_08075104: .4byte 0x80000080
|
||||
@ -26678,7 +26678,7 @@ lbl_08075108:
|
||||
adds r3, r5, #0
|
||||
bl BitFill
|
||||
movs r0, #9
|
||||
bl do_sram_operation
|
||||
bl DoSramOperation
|
||||
mov r0, sb
|
||||
ldr r2, [r0]
|
||||
movs r1, #0xdf
|
||||
@ -26690,7 +26690,7 @@ lbl_08075108:
|
||||
adds r3, r5, #0
|
||||
bl BitFill
|
||||
movs r0, #0xa
|
||||
bl do_sram_operation
|
||||
bl DoSramOperation
|
||||
lbl_0807514a:
|
||||
movs r2, #1
|
||||
add r8, r2
|
||||
@ -26733,7 +26733,7 @@ lbl_0807517c:
|
||||
str r0, [r1, #8]
|
||||
ldr r0, [r1, #8]
|
||||
movs r0, #9
|
||||
bl do_sram_operation
|
||||
bl DoSramOperation
|
||||
b lbl_08075156
|
||||
.align 2, 0
|
||||
lbl_080751a4: .4byte 0x040000d4
|
||||
@ -26910,7 +26910,7 @@ sub_080751d8: @ 0x080751d8
|
||||
adds r4, r4, r0
|
||||
strb r1, [r4]
|
||||
movs r0, #0xd
|
||||
bl do_sram_operation
|
||||
bl DoSramOperation
|
||||
add sp, #4
|
||||
pop {r4, r5, r6, r7}
|
||||
pop {r0}
|
||||
@ -27181,7 +27181,7 @@ lbl_08075568:
|
||||
strb r3, [r0]
|
||||
movs r0, #1
|
||||
lbl_0807556e:
|
||||
bl sub_08000fbc
|
||||
bl unk_fbc
|
||||
cmp r0, #0
|
||||
beq lbl_08075590
|
||||
lbl_08075576:
|
||||
@ -27320,7 +27320,7 @@ lbl_08075680:
|
||||
strb r3, [r5]
|
||||
movs r0, #1
|
||||
lbl_08075686:
|
||||
bl sub_08000fbc
|
||||
bl unk_fbc
|
||||
cmp r0, #0
|
||||
beq lbl_08075696
|
||||
ldr r1, lbl_080756a0 @ =gSramOperationStage
|
||||
@ -27524,13 +27524,13 @@ lbl_08075800: @ jump table
|
||||
.4byte lbl_08075828 @ case 4
|
||||
lbl_08075814:
|
||||
movs r0, #3
|
||||
bl do_sram_operation
|
||||
bl DoSramOperation
|
||||
b lbl_08075828
|
||||
lbl_0807581c:
|
||||
movs r0, #3
|
||||
bl do_sram_operation
|
||||
bl DoSramOperation
|
||||
movs r0, #4
|
||||
bl do_sram_operation
|
||||
bl DoSramOperation
|
||||
lbl_08075828:
|
||||
ldr r3, lbl_08075844 @ =gSaveFilesInfo
|
||||
ldr r2, lbl_08075848 @ =gMostRecentSaveFile
|
||||
|
@ -4513,7 +4513,7 @@ lbl_08079d34: .4byte gUnk_3000c20
|
||||
lbl_08079d38: .4byte gMostRecentSaveFile
|
||||
lbl_08079d3c:
|
||||
movs r0, #0
|
||||
bl sub_08000fbc
|
||||
bl unk_fbc
|
||||
cmp r0, #0
|
||||
bne lbl_08079d48
|
||||
b lbl_08079ec0
|
||||
@ -4547,7 +4547,7 @@ lbl_08079d7c: .4byte gMostRecentSaveFile
|
||||
lbl_08079d80: .4byte sNonGameplayRamPointer
|
||||
lbl_08079d84:
|
||||
movs r0, #1
|
||||
bl sub_08000fbc
|
||||
bl unk_fbc
|
||||
cmp r0, #0
|
||||
bne lbl_08079d90
|
||||
b lbl_08079ec0
|
||||
|
@ -11,6 +11,6 @@ extern void* sObjPalramPointer;
|
||||
extern u32* sVisitedMinimapTilesPointer;
|
||||
extern union NonGameplayRAM* sNonGameplayRamPointer;
|
||||
extern struct Sram* sSramEwramPointer;
|
||||
extern void* sSramFlashPointer;
|
||||
extern struct Sram* sSramFlashPointer;
|
||||
|
||||
#endif /* SHORTCUT_POINTERS_H */
|
||||
|
23
include/sram_misc.h
Normal file
23
include/sram_misc.h
Normal file
@ -0,0 +1,23 @@
|
||||
#ifndef SRAM_MISC
|
||||
#define SRAM_MISC
|
||||
|
||||
#include "types.h"
|
||||
|
||||
#define SRAM_OPERATION_WRITE_FILE_SCREEN_OPTIONS 0
|
||||
#define SRAM_OPERATION_SAVE_MOST_RECENT_FILE 5
|
||||
#define SRAM_OPERATION_SAVE_LANGUAGE 6
|
||||
#define SRAM_OPERATION_SAVE_LANGUAGE2 7
|
||||
#define SRAM_OPERATION_SAVE_SOUND_MODE 8
|
||||
#define SRAM_OPERATION_SAVE_TIME_ATTACK 9
|
||||
#define SRAM_OPERATION_SAVE_TIME_ATTACK2 10
|
||||
#define SRAM_OPERATION_SAVE_RECORDED_DEMO 11
|
||||
#define SRAM_OPERATION_SAVE_DEMO_RAM 13
|
||||
#define SRAM_OPERATION_READ_ALL_FLASH 14
|
||||
#define SRAM_OPERATION_READ_RECENT_FILE_UNCHECKED 15
|
||||
#define SRAM_OPERATION_CHECK_ALL 16
|
||||
|
||||
void EraseSram(void);
|
||||
u8* DoSramOperation(u8 operation);
|
||||
u32 unk_fbc(u8 param_1);
|
||||
|
||||
#endif /* SRAM_MISC */
|
@ -4,6 +4,8 @@
|
||||
#include "types.h"
|
||||
#include "macros.h"
|
||||
#include "gba.h"
|
||||
#include "sram_misc.h"
|
||||
|
||||
#include "structs/game_state.h"
|
||||
#include "structs/samus.h"
|
||||
#include "structs/scroll.h"
|
||||
@ -12,19 +14,6 @@
|
||||
#include "structs/time_attack.h"
|
||||
#include "structs/demo.h"
|
||||
|
||||
#define SRAM_OPERATION_WRITE_FILE_SCREEN_OPTIONS 0
|
||||
#define SRAM_OPERATION_SAVE_MOST_RECENT_FILE 5
|
||||
#define SRAM_OPERATION_SAVE_LANGUAGE 6
|
||||
#define SRAM_OPERATION_SAVE_LANGUAGE2 7
|
||||
#define SRAM_OPERATION_SAVE_SOUND_MODE 8
|
||||
#define SRAM_OPERATION_SAVE_TIME_ATTACK 9
|
||||
#define SRAM_OPERATION_SAVE_TIME_ATTACK2 10
|
||||
#define SRAM_OPERATION_SAVE_RECORDED_DEMO 11
|
||||
#define SRAM_OPERATION_SAVE_DEMO_RAM 13
|
||||
#define SRAM_OPERATION_READ_ALL_FLASH 14
|
||||
#define SRAM_OPERATION_READ_RECENT_FILE_UNCHECKED 15
|
||||
#define SRAM_OPERATION_CHECK_ALL 16
|
||||
|
||||
#define CORRUPTED_FILE_FLAG_CURRENT 1
|
||||
#define CORRUPTED_FILE_FLAG_CURRENT_AND_BACKUP 2
|
||||
|
||||
@ -114,7 +103,6 @@ struct SaveFile {
|
||||
struct InGameTimer inGameTimerAtBosses[MAX_AMOUNT_OF_IGT_AT_BOSSES];
|
||||
|
||||
struct SaveMusicInfo musicInfo;
|
||||
u32 unk_248;
|
||||
|
||||
u32 inGameCutscenesTriggered[1];
|
||||
|
||||
|
@ -395,8 +395,8 @@ SECTIONS {
|
||||
src/init_helpers.o(.text);
|
||||
src/fixed_point.o(.text);
|
||||
src/callbacks.o(.text);
|
||||
src/erase_sram_func.o(.text);
|
||||
asm/disasm_0x08000c48.o(.text);
|
||||
src/sram_misc.o(.text);
|
||||
asm/disasm_0x080010c4.o(.text);
|
||||
asm/disasm_0x08002a58.o(.text);
|
||||
asm/syscalls.o(.text);
|
||||
asm/disasm_0x080051d4.o(.text);
|
||||
|
@ -52,6 +52,6 @@ union NonGameplayRAM* sNonGameplayRamPointer = &gNonGameplayRAM;
|
||||
FORCE_RODATA
|
||||
struct Sram* sSramEwramPointer = EWRAM_BASE + 0x38000;
|
||||
FORCE_RODATA
|
||||
void* sSramFlashPointer = SRAM_BASE;
|
||||
struct Sram* sSramFlashPointer = SRAM_BASE;
|
||||
|
||||
const u8 sTempArray_754bd0[0x9ad8] = INCBIN_U8("data/Blob_754bd0_75e6a8.bin");
|
||||
|
@ -165,7 +165,7 @@ void DemoEnd(void)
|
||||
dma_set(3, gDemoInputData, gSramDemoInputData, DMA_ENABLE << 16 | DEMO_MAX_DURATION);
|
||||
dma_set(3, gDemoInputDuration, gSramDemoInputDuration, DMA_ENABLE << 16 | DEMO_MAX_DURATION);
|
||||
|
||||
do_sram_operation(SRAM_OPERATION_SAVE_RECORDED_DEMO);
|
||||
DoSramOperation(SRAM_OPERATION_SAVE_RECORDED_DEMO);
|
||||
|
||||
// Debug leftover
|
||||
gGameModeSub2 = 16;
|
||||
|
@ -1,15 +0,0 @@
|
||||
#include "funcs.h"
|
||||
#include "gba.h"
|
||||
#include "globals.h"
|
||||
#include "memory.h"
|
||||
#include "sram/sram.h"
|
||||
#include "types.h"
|
||||
#include "structs/save_file.h"
|
||||
|
||||
void EraseSram(void)
|
||||
{
|
||||
BitFill(3, 0xffff, &gSram, SRAM_SIZE, 16);
|
||||
if (!gSramCorruptFlag) {
|
||||
SramWriteChecked((u8*)&gSram, SRAM_BASE, SRAM_SIZE);
|
||||
}
|
||||
}
|
@ -26,8 +26,6 @@
|
||||
#include "structs/save_file.h"
|
||||
#include "structs/visual_effects.h"
|
||||
|
||||
u8* do_sram_operation(u8);
|
||||
|
||||
/**
|
||||
* @brief 7329c | 64 | Fully reads the flash save into Ewram
|
||||
*
|
||||
@ -49,8 +47,8 @@ void SramRead_All(void)
|
||||
|
||||
for (i = 3; i != 0; i--)
|
||||
{
|
||||
do_sram_operation(SRAM_OPERATION_READ_ALL_FLASH);
|
||||
if (do_sram_operation(SRAM_OPERATION_CHECK_ALL) == NULL)
|
||||
DoSramOperation(SRAM_OPERATION_READ_ALL_FLASH);
|
||||
if (DoSramOperation(SRAM_OPERATION_CHECK_ALL) == NULL)
|
||||
break;
|
||||
}
|
||||
|
||||
@ -113,7 +111,7 @@ void SramWrite_FileScreenOptionsUnlocked(void)
|
||||
pOptions->checksum = checksum;
|
||||
pOptions->notChecksum = ~checksum;
|
||||
|
||||
do_sram_operation(SRAM_OPERATION_WRITE_FILE_SCREEN_OPTIONS);
|
||||
DoSramOperation(SRAM_OPERATION_WRITE_FILE_SCREEN_OPTIONS);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -158,7 +156,7 @@ void SramRead_FileScreenOptionsUnlocked(void)
|
||||
DMATransfer(3, &sSramEwramPointer->fileScreenOptions_fileB, &sSramEwramPointer->fileScreenOptions_fileA,
|
||||
sizeof(sSramEwramPointer->fileScreenOptions_fileA), 0x10);
|
||||
fileASanityCheck = 0;
|
||||
do_sram_operation(SRAM_OPERATION_WRITE_FILE_SCREEN_OPTIONS);
|
||||
DoSramOperation(SRAM_OPERATION_WRITE_FILE_SCREEN_OPTIONS);
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -166,13 +164,13 @@ void SramRead_FileScreenOptionsUnlocked(void)
|
||||
DMATransfer(3, &sSramEwramPointer->fileScreenOptions_fileC, &sSramEwramPointer->fileScreenOptions_fileA,
|
||||
sizeof(sSramEwramPointer->fileScreenOptions_fileA), 0x10);
|
||||
fileASanityCheck = 0;
|
||||
do_sram_operation(SRAM_OPERATION_WRITE_FILE_SCREEN_OPTIONS);
|
||||
DoSramOperation(SRAM_OPERATION_WRITE_FILE_SCREEN_OPTIONS);
|
||||
|
||||
if (fileBSanityCheck)
|
||||
{
|
||||
DMATransfer(3, &sSramEwramPointer->fileScreenOptions_fileA, &sSramEwramPointer->fileScreenOptions_fileB,
|
||||
sizeof(sSramEwramPointer->fileScreenOptions_fileB), 0x10);
|
||||
do_sram_operation(1);
|
||||
DoSramOperation(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -180,12 +178,12 @@ void SramRead_FileScreenOptionsUnlocked(void)
|
||||
{
|
||||
DMATransfer(3, &sSramEwramPointer->fileScreenOptions_fileA, &sSramEwramPointer->fileScreenOptions_fileB,
|
||||
sizeof(sSramEwramPointer->fileScreenOptions_fileB), 0x10);
|
||||
do_sram_operation(1);
|
||||
DoSramOperation(1);
|
||||
if (fileCSanityCheck != 0)
|
||||
{
|
||||
DMATransfer(3, &sSramEwramPointer->fileScreenOptions_fileA, &sSramEwramPointer->fileScreenOptions_fileC,
|
||||
sizeof(sSramEwramPointer->fileScreenOptions_fileC), 0x10);
|
||||
do_sram_operation(2);
|
||||
DoSramOperation(2);
|
||||
}
|
||||
}
|
||||
|
||||
@ -920,7 +918,7 @@ void unk_743a4(void)
|
||||
DMATransfer(3, &sSramEwramPointer->files[gMostRecentSaveFile],
|
||||
&sSramEwramPointer->filesCopy[gMostRecentSaveFile], sizeof(struct SaveFile), 16);
|
||||
|
||||
do_sram_operation(4);
|
||||
DoSramOperation(4);
|
||||
gSaveFilesInfo[i].exists = TRUE;
|
||||
}
|
||||
else if (flag == CORRUPTED_FILE_FLAG_CURRENT)
|
||||
@ -938,9 +936,9 @@ void unk_743a4(void)
|
||||
else if (flag > 2)
|
||||
{
|
||||
BitFill(3, USHORT_MAX, &sSramEwramPointer->files[gMostRecentSaveFile], sizeof(struct SaveFile), 16);
|
||||
do_sram_operation(3);
|
||||
DoSramOperation(3);
|
||||
BitFill(3, USHORT_MAX, &sSramEwramPointer->filesCopy[gMostRecentSaveFile], sizeof(struct SaveFile), 16);
|
||||
do_sram_operation(4);
|
||||
DoSramOperation(4);
|
||||
gSaveFilesInfo[gMostRecentSaveFile].corruptionFlag = 0;
|
||||
}
|
||||
else
|
||||
@ -1168,7 +1166,7 @@ void SramWrite_MostRecentSaveFile(void)
|
||||
pSave->checksum = checksum;
|
||||
pSave->notChecksum = ~checksum;
|
||||
|
||||
do_sram_operation(SRAM_OPERATION_SAVE_MOST_RECENT_FILE);
|
||||
DoSramOperation(SRAM_OPERATION_SAVE_MOST_RECENT_FILE);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1281,7 +1279,7 @@ void SramWrite_SoundMode(void)
|
||||
pSave->checksum = checksum;
|
||||
pSave->notChecksum = ~checksum;
|
||||
|
||||
do_sram_operation(SRAM_OPERATION_SAVE_SOUND_MODE);
|
||||
DoSramOperation(SRAM_OPERATION_SAVE_SOUND_MODE);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1399,7 +1397,7 @@ void SramWrite_Language(void)
|
||||
pSave->checksum = checksum;
|
||||
pSave->notChecksum = ~checksum;
|
||||
|
||||
do_sram_operation(SRAM_OPERATION_SAVE_LANGUAGE);
|
||||
DoSramOperation(SRAM_OPERATION_SAVE_LANGUAGE);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1467,7 +1465,7 @@ u32 SramRead_Language(void)
|
||||
dma_set(3, &sSramEwramPointer->languagesSave[0], &sSramEwramPointer->languagesSave[1],
|
||||
DMA_ENABLE << 16 | sizeof(sSramEwramPointer->languagesSave[1]) / 2);
|
||||
|
||||
do_sram_operation(SRAM_OPERATION_SAVE_LANGUAGE2);
|
||||
DoSramOperation(SRAM_OPERATION_SAVE_LANGUAGE2);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -1476,7 +1474,7 @@ u32 SramRead_Language(void)
|
||||
dma_set(3, &sSramEwramPointer->languagesSave[1], &sSramEwramPointer->languagesSave[0],
|
||||
DMA_ENABLE << 16 | sizeof(sSramEwramPointer->languagesSave[0]) / 2);
|
||||
|
||||
do_sram_operation(SRAM_OPERATION_SAVE_LANGUAGE);
|
||||
DoSramOperation(SRAM_OPERATION_SAVE_LANGUAGE);
|
||||
break;
|
||||
}
|
||||
else
|
||||
@ -1485,13 +1483,13 @@ u32 SramRead_Language(void)
|
||||
dma_set(3, &buffer, &sSramEwramPointer->languagesSave[0],
|
||||
(DMA_ENABLE | DMA_SRC_FIXED) << 16 | sizeof(sSramEwramPointer->languagesSave[0]) / 2);
|
||||
|
||||
do_sram_operation(SRAM_OPERATION_SAVE_LANGUAGE);
|
||||
DoSramOperation(SRAM_OPERATION_SAVE_LANGUAGE);
|
||||
|
||||
buffer = 0;
|
||||
dma_set(3, &buffer, &sSramEwramPointer->languagesSave[1],
|
||||
(DMA_ENABLE | DMA_SRC_FIXED) << 16 | sizeof(sSramEwramPointer->languagesSave[1]) / 2);
|
||||
|
||||
do_sram_operation(SRAM_OPERATION_SAVE_LANGUAGE2);
|
||||
DoSramOperation(SRAM_OPERATION_SAVE_LANGUAGE2);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1546,7 +1544,7 @@ void SramWrite_TimeAttack(void)
|
||||
pSave->checksum = checksum;
|
||||
pSave->notChecksum = ~checksum;
|
||||
|
||||
do_sram_operation(SRAM_OPERATION_SAVE_TIME_ATTACK);
|
||||
DoSramOperation(SRAM_OPERATION_SAVE_TIME_ATTACK);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1612,7 +1610,7 @@ void SramRead_TimeAttack(void)
|
||||
dma_set(3, &sSramEwramPointer->timeAttackSaves[0], &sSramEwramPointer->timeAttackSaves[1],
|
||||
DMA_ENABLE << 16 | sizeof(sSramEwramPointer->timeAttackSaves[1]) / 2);
|
||||
|
||||
do_sram_operation(SRAM_OPERATION_SAVE_TIME_ATTACK2);
|
||||
DoSramOperation(SRAM_OPERATION_SAVE_TIME_ATTACK2);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -1621,16 +1619,16 @@ void SramRead_TimeAttack(void)
|
||||
dma_set(3, &sSramEwramPointer->timeAttackSaves[1], &sSramEwramPointer->timeAttackSaves[0],
|
||||
DMA_ENABLE << 16 | sizeof(sSramEwramPointer->timeAttackSaves[0]) / 2);
|
||||
|
||||
do_sram_operation(SRAM_OPERATION_SAVE_TIME_ATTACK);
|
||||
DoSramOperation(SRAM_OPERATION_SAVE_TIME_ATTACK);
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
BitFill(3, USHORT_MAX, &sSramEwramPointer->timeAttackSaves[0], sizeof(sSramEwramPointer->timeAttackSaves[0]), 16);
|
||||
do_sram_operation(SRAM_OPERATION_SAVE_TIME_ATTACK);
|
||||
DoSramOperation(SRAM_OPERATION_SAVE_TIME_ATTACK);
|
||||
|
||||
BitFill(3, USHORT_MAX, &sSramEwramPointer->timeAttackSaves[1], sizeof(sSramEwramPointer->timeAttackSaves[1]), 16);
|
||||
do_sram_operation(SRAM_OPERATION_SAVE_TIME_ATTACK2);
|
||||
DoSramOperation(SRAM_OPERATION_SAVE_TIME_ATTACK2);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1683,7 +1681,7 @@ void SramWrite_ToEwram_DemoRam(void)
|
||||
pFile->text[7] = 'D';
|
||||
|
||||
pFile->useMotherShipDoors = gUseMotherShipDoors;
|
||||
do_sram_operation(SRAM_OPERATION_SAVE_DEMO_RAM);
|
||||
DoSramOperation(SRAM_OPERATION_SAVE_DEMO_RAM);
|
||||
}
|
||||
|
||||
void SramLoad_DemoRamValues(u8 loadSamusData, u8 demoNumber)
|
||||
@ -1915,12 +1913,12 @@ void unk_757c8(u8 file)
|
||||
switch (gSaveFilesInfo[gMostRecentSaveFile].corruptionFlag)
|
||||
{
|
||||
case CORRUPTED_FILE_FLAG_CURRENT:
|
||||
do_sram_operation(3);
|
||||
DoSramOperation(3);
|
||||
break;
|
||||
|
||||
case CORRUPTED_FILE_FLAG_CURRENT_AND_BACKUP:
|
||||
do_sram_operation(3);
|
||||
do_sram_operation(4);
|
||||
DoSramOperation(3);
|
||||
DoSramOperation(4);
|
||||
break;
|
||||
|
||||
case 0:
|
||||
|
202
src/sram_misc.c
Normal file
202
src/sram_misc.c
Normal file
@ -0,0 +1,202 @@
|
||||
#include "sram_misc.h"
|
||||
#include "gba.h"
|
||||
#include "globals.h"
|
||||
#include "memory.h"
|
||||
#include "sram/sram.h"
|
||||
#include "types.h"
|
||||
#include "structs/save_file.h"
|
||||
|
||||
#include "data/shortcut_pointers.h"
|
||||
|
||||
/**
|
||||
* @brief c04 | 44 | Fully erases all the contents of the Sram
|
||||
*
|
||||
*/
|
||||
void EraseSram(void)
|
||||
{
|
||||
// Clear Ewram buffer
|
||||
BitFill(3, USHORT_MAX, &gSram, SRAM_SIZE, 16);
|
||||
|
||||
if (!gSramCorruptFlag)
|
||||
{
|
||||
// Send cleared Ewram buffer to flash
|
||||
SramWriteChecked((u8*)&gSram, SRAM_BASE, SRAM_SIZE);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief c48 | 374 | Performs an sram operation
|
||||
*
|
||||
* @param operation Operation to perform
|
||||
* @return u8* Pointer to difference
|
||||
*/
|
||||
u8* DoSramOperation(u8 operation)
|
||||
{
|
||||
u8* diff;
|
||||
|
||||
diff = NULL;
|
||||
if (gSramCorruptFlag)
|
||||
{
|
||||
switch (operation)
|
||||
{
|
||||
case SRAM_OPERATION_READ_ALL_FLASH:
|
||||
BitFill(3, USHORT_MAX, &gSram, SRAM_SIZE, 16);
|
||||
break;
|
||||
|
||||
case SRAM_OPERATION_READ_RECENT_FILE_UNCHECKED:
|
||||
BitFill(3, USHORT_MAX, &sSramEwramPointer->files[gMostRecentSaveFile], sizeof(struct SaveFile), 16);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (operation)
|
||||
{
|
||||
case SRAM_OPERATION_WRITE_FILE_SCREEN_OPTIONS:
|
||||
dma_set(3, &sSramEwramPointer->fileScreenOptions_fileA, &sSramEwramPointer->fileScreenOptions_fileC,
|
||||
DMA_ENABLE << 16 | sizeof(struct SaveFileScreenOptions) / sizeof(u16));
|
||||
|
||||
diff = SramWriteChecked((u8*)&sSramEwramPointer->fileScreenOptions_fileA,
|
||||
(u8*)&sSramFlashPointer->fileScreenOptions_fileA, sizeof(struct SaveFileScreenOptions));
|
||||
|
||||
if (diff != NULL)
|
||||
break;
|
||||
|
||||
diff = SramWriteChecked((u8*)&sSramEwramPointer->fileScreenOptions_fileC,
|
||||
(u8*)&sSramFlashPointer->fileScreenOptions_fileC, sizeof(struct SaveFileScreenOptions));
|
||||
break;
|
||||
|
||||
case 1:
|
||||
diff = SramWriteChecked((u8*)&sSramEwramPointer->fileScreenOptions_fileB,
|
||||
(u8*)&sSramFlashPointer->fileScreenOptions_fileB, sizeof(struct SaveFileScreenOptions));
|
||||
break;
|
||||
|
||||
case 2:
|
||||
diff = SramWriteChecked((u8*)&sSramEwramPointer->fileScreenOptions_fileC,
|
||||
(u8*)&sSramFlashPointer->fileScreenOptions_fileC, sizeof(struct SaveFileScreenOptions));
|
||||
break;
|
||||
|
||||
case 3:
|
||||
diff = SramWriteChecked((u8*)&sSramEwramPointer->files[gMostRecentSaveFile],
|
||||
(u8*)&sSramFlashPointer->files[gMostRecentSaveFile], sizeof(struct SaveFile));
|
||||
break;
|
||||
|
||||
case 4:
|
||||
diff = SramWriteChecked((u8*)&sSramEwramPointer->filesCopy[gMostRecentSaveFile],
|
||||
(u8*)&sSramFlashPointer->filesCopy[gMostRecentSaveFile], sizeof(struct SaveFile));
|
||||
break;
|
||||
|
||||
case SRAM_OPERATION_SAVE_MOST_RECENT_FILE:
|
||||
diff = SramWriteChecked((u8*)&sSramEwramPointer->mostRecentFileSave,
|
||||
(u8*)&sSramFlashPointer->mostRecentFileSave, sizeof(struct SaveValue));
|
||||
break;
|
||||
|
||||
case SRAM_OPERATION_SAVE_LANGUAGE:
|
||||
diff = SramWriteChecked((u8*)&sSramEwramPointer->languagesSave[0],
|
||||
(u8*)&sSramFlashPointer->languagesSave[0], sizeof(struct SaveValue));
|
||||
break;
|
||||
|
||||
case SRAM_OPERATION_SAVE_LANGUAGE2:
|
||||
diff = SramWriteChecked((u8*)&sSramEwramPointer->languagesSave[1],
|
||||
(u8*)&sSramFlashPointer->languagesSave[1], sizeof(struct SaveValue));
|
||||
break;
|
||||
|
||||
case SRAM_OPERATION_SAVE_SOUND_MODE:
|
||||
diff = SramWriteChecked((u8*)&sSramEwramPointer->soundModeSave,
|
||||
(u8*)&sSramFlashPointer->soundModeSave, sizeof(struct SaveValue));
|
||||
break;
|
||||
|
||||
case SRAM_OPERATION_SAVE_TIME_ATTACK:
|
||||
diff = SramWriteChecked((u8*)&sSramEwramPointer->timeAttackSaves[0],
|
||||
(u8*)&sSramFlashPointer->timeAttackSaves[0], sizeof(struct SaveTimeAttack));
|
||||
break;
|
||||
|
||||
case SRAM_OPERATION_SAVE_TIME_ATTACK2:
|
||||
diff = SramWriteChecked((u8*)&sSramEwramPointer->timeAttackSaves[1],
|
||||
(u8*)&sSramFlashPointer->timeAttackSaves[1], sizeof(struct SaveTimeAttack));
|
||||
break;
|
||||
|
||||
case SRAM_OPERATION_SAVE_RECORDED_DEMO:
|
||||
diff = SramWriteChecked((u8*)&sSramEwramPointer->demoInputData,
|
||||
(u8*)&sSramFlashPointer->demoInputData, sizeof(sSramEwramPointer->demoInputData));
|
||||
|
||||
if (diff != NULL)
|
||||
break;
|
||||
|
||||
diff = SramWriteChecked((u8*)&sSramEwramPointer->demoInputDuration,
|
||||
(u8*)&sSramFlashPointer->demoInputDuration, sizeof(sSramEwramPointer->demoInputDuration));
|
||||
break;
|
||||
|
||||
case 12:
|
||||
diff = SramWriteChecked((u8*)&gSram.unk_7f70,
|
||||
SRAM_BASE + OFFSET_OF(struct Sram, unk_7f70), sizeof(gSram.unk_7f70));
|
||||
break;
|
||||
|
||||
case SRAM_OPERATION_SAVE_DEMO_RAM:
|
||||
diff = SramWriteChecked((u8*)&gSram.demoSave,
|
||||
SRAM_BASE + OFFSET_OF(struct Sram, demoSave), sizeof(struct SaveDemo));
|
||||
break;
|
||||
|
||||
case SRAM_OPERATION_READ_ALL_FLASH:
|
||||
SramWriteUnchecked(SRAM_BASE, (u8*)&gSram, SRAM_SIZE);
|
||||
break;
|
||||
|
||||
case SRAM_OPERATION_READ_RECENT_FILE_UNCHECKED:
|
||||
SramWriteUnchecked((u8*)&sSramFlashPointer->files[gMostRecentSaveFile],
|
||||
(u8*)&sSramEwramPointer->files[gMostRecentSaveFile], sizeof(struct SaveFile));
|
||||
break;
|
||||
|
||||
case SRAM_OPERATION_CHECK_ALL:
|
||||
diff = SramCheck((u8*)sSramFlashPointer, (u8*)sSramEwramPointer, SRAM_SIZE);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return diff;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief fbc | 108 | To document
|
||||
*
|
||||
* @param param_1 To document
|
||||
* @return u32 To document
|
||||
*/
|
||||
u32 unk_fbc(u8 param_1)
|
||||
{
|
||||
u32 size;
|
||||
i32 var_0;
|
||||
i32 var_1;
|
||||
|
||||
size = 0x200;
|
||||
var_0 = gUnk_3000c20 * size;
|
||||
if (var_0 > (i32)sizeof(struct SaveFile))
|
||||
size = var_0 - sizeof(struct SaveFile);
|
||||
|
||||
if (!gSramCorruptFlag)
|
||||
{
|
||||
switch (param_1)
|
||||
{
|
||||
case 0:
|
||||
SramWriteChecked(((u8*)&sSramEwramPointer->files[gMostRecentSaveFile]) + var_0,
|
||||
((u8*)&sSramFlashPointer->files[gMostRecentSaveFile]) + var_0, size);
|
||||
break;
|
||||
|
||||
case 1:
|
||||
SramWriteChecked(((u8*)&sSramEwramPointer->filesCopy[gMostRecentSaveFile]) + var_0,
|
||||
((u8*)&sSramFlashPointer->filesCopy[gMostRecentSaveFile]) + var_0, size);
|
||||
break;
|
||||
|
||||
case 2:
|
||||
SramWriteUnchecked(((u8*)&sSramFlashPointer->files[gMostRecentSaveFile]) + var_0,
|
||||
((u8*)&sSramEwramPointer->files[gMostRecentSaveFile]) + var_0, size);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
var_1 = FALSE;
|
||||
if ((i32)(var_0 + size) < (i32)sizeof(struct SaveFile))
|
||||
var_1 = TRUE;
|
||||
|
||||
gUnk_3000c20 = (gUnk_3000c20 + var_1) * var_1;
|
||||
|
||||
return var_1 ^ TRUE;
|
||||
}
|
Loading…
Reference in New Issue
Block a user