pokeemerald/asm/libagbbackup.s

1100 lines
17 KiB
ArmAsm
Raw Normal View History

2015-10-06 07:00:49 -07:00
thumb_func_start SwitchFlashBank
2015-10-10 03:12:48 -07:00
SwitchFlashBank: ; 82E185C
2015-10-06 07:00:49 -07:00
lsls r0, 24
lsrs r0, 24
2015-10-10 03:41:19 -07:00
ldr r3, =0x0e005555
2015-10-06 07:00:49 -07:00
movs r1, 0xAA
strb r1, [r3]
2015-10-10 03:41:19 -07:00
ldr r2, =0x0e002aaa
2015-10-06 07:00:49 -07:00
movs r1, 0x55
strb r1, [r2]
movs r1, 0xB0
strb r1, [r3]
movs r1, 0xE0
lsls r1, 20
strb r0, [r1]
bx lr
.align 2, 0
2015-10-10 03:41:19 -07:00
.pool
2015-10-06 07:00:49 -07:00
thumb_func_end SwitchFlashBank
thumb_func_start ReadFlashID
2015-10-10 03:12:48 -07:00
; u16 ReadFlashID()
ReadFlashID: ; 82E1880
2015-10-06 07:00:49 -07:00
push {r4,r5,lr}
sub sp, 0x44
mov r0, sp
bl SetReadFlash1
mov r5, sp
adds r5, 0x1
2015-10-10 03:41:19 -07:00
ldr r2, =0x0e005555
2015-10-06 07:00:49 -07:00
movs r0, 0xAA
strb r0, [r2]
2015-10-10 03:41:19 -07:00
ldr r1, =0x0e002aaa
2015-10-06 07:00:49 -07:00
movs r0, 0x55
strb r0, [r1]
movs r0, 0x90
strb r0, [r2]
add r1, sp, 0x40
2015-10-10 03:41:19 -07:00
ldr r2, =0x00004e20
2015-10-06 07:00:49 -07:00
adds r0, r2, 0
2015-10-10 03:50:53 -07:00
b @082E18B8
2015-10-06 07:00:49 -07:00
.align 2, 0
2015-10-10 03:41:19 -07:00
.pool
2015-10-10 03:50:53 -07:00
@082E18B4:
2015-10-06 07:00:49 -07:00
ldrh r0, [r1]
subs r0, 0x1
2015-10-10 03:50:53 -07:00
@082E18B8:
2015-10-06 07:00:49 -07:00
strh r0, [r1]
ldrh r0, [r1]
cmp r0, 0
2015-10-10 03:50:53 -07:00
bne @082E18B4
2015-10-10 03:41:19 -07:00
ldr r0, =0x0e000001
2015-10-06 07:00:49 -07:00
bl _call_via_r5
lsls r0, 24
lsrs r4, r0, 16
movs r0, 0xE0
lsls r0, 20
bl _call_via_r5
lsls r0, 24
lsrs r0, 24
orrs r4, r0
2015-10-10 03:41:19 -07:00
ldr r1, =0x0e005555
2015-10-06 07:00:49 -07:00
movs r0, 0xAA
strb r0, [r1]
2015-10-10 03:41:19 -07:00
ldr r2, =0x0e002aaa
2015-10-06 07:00:49 -07:00
movs r0, 0x55
strb r0, [r2]
movs r0, 0xF0
strb r0, [r1]
strb r0, [r1]
add r1, sp, 0x40
2015-10-10 03:41:19 -07:00
ldr r2, =0x00004e20
2015-10-06 07:00:49 -07:00
adds r0, r2, 0
2015-10-10 03:50:53 -07:00
b @082E1908
2015-10-06 07:00:49 -07:00
.align 2, 0
2015-10-10 03:41:19 -07:00
.pool
2015-10-10 03:50:53 -07:00
@082E1904:
2015-10-06 07:00:49 -07:00
ldrh r0, [r1]
subs r0, 0x1
2015-10-10 03:50:53 -07:00
@082E1908:
2015-10-06 07:00:49 -07:00
strh r0, [r1]
ldrh r0, [r1]
cmp r0, 0
2015-10-10 03:50:53 -07:00
bne @082E1904
2015-10-06 07:00:49 -07:00
adds r0, r4, 0
add sp, 0x44
pop {r4,r5}
pop {r1}
bx r1
thumb_func_end ReadFlashID
thumb_func_start FlashTimerIntr
2015-10-10 03:12:48 -07:00
; void FlashTimerIntr()
FlashTimerIntr: ; 82E191C
2015-10-06 07:00:49 -07:00
push {lr}
2015-10-10 03:41:19 -07:00
ldr r1, =0x03001a72
2015-10-06 07:00:49 -07:00
ldrh r0, [r1]
cmp r0, 0
2015-10-10 03:50:53 -07:00
beq @082E1938
2015-10-06 07:00:49 -07:00
ldrh r0, [r1]
subs r0, 0x1
strh r0, [r1]
lsls r0, 16
cmp r0, 0
2015-10-10 03:50:53 -07:00
bne @082E1938
2015-10-10 03:41:19 -07:00
ldr r1, =0x03007840
2015-10-06 07:00:49 -07:00
movs r0, 0x1
strb r0, [r1]
2015-10-10 03:50:53 -07:00
@082E1938:
2015-10-06 07:00:49 -07:00
pop {r0}
bx r0
.align 2, 0
2015-10-10 03:41:19 -07:00
.pool
2015-10-06 07:00:49 -07:00
thumb_func_end FlashTimerIntr
thumb_func_start SetFlashTimerIntr
2015-10-10 03:12:48 -07:00
; void SetFlashTimerIntr(u8 timer_id, void ( **irq_timer_func)())
SetFlashTimerIntr: ; 82E1944
2015-10-06 07:00:49 -07:00
push {lr}
adds r2, r1, 0
lsls r0, 24
lsrs r1, r0, 24
cmp r1, 0x3
2015-10-10 03:50:53 -07:00
bhi @082E1978
2015-10-10 03:41:19 -07:00
ldr r0, =0x03001a70
2015-10-06 07:00:49 -07:00
strb r1, [r0]
2015-10-10 03:41:19 -07:00
ldr r1, =0x03001a74
2015-10-06 07:00:49 -07:00
ldrb r0, [r0]
lsls r0, 2
2015-10-10 03:41:19 -07:00
ldr r3, =0x04000100
2015-10-06 07:00:49 -07:00
adds r0, r3
str r0, [r1]
2015-10-10 03:41:19 -07:00
ldr r0, =FlashTimerIntr + 1
2015-10-06 07:00:49 -07:00
str r0, [r2]
movs r0, 0
2015-10-10 03:50:53 -07:00
b @082E197A
2015-10-06 07:00:49 -07:00
.align 2, 0
2015-10-10 03:41:19 -07:00
.pool
2015-10-10 03:50:53 -07:00
@082E1978:
2015-10-06 07:00:49 -07:00
movs r0, 0x1
2015-10-10 03:50:53 -07:00
@082E197A:
2015-10-06 07:00:49 -07:00
pop {r1}
bx r1
thumb_func_end SetFlashTimerIntr
thumb_func_start StartFlashTimer
2015-10-10 03:12:48 -07:00
StartFlashTimer: ; 82E1980
2015-10-06 07:00:49 -07:00
push {r4-r6,lr}
mov r6, r10
mov r5, r9
mov r4, r8
push {r4-r6}
lsls r0, 24
lsrs r0, 24
2015-10-10 03:41:19 -07:00
ldr r1, =0x03007864
2015-10-06 07:00:49 -07:00
lsls r2, r0, 1
adds r2, r0
lsls r2, 1
ldr r0, [r1]
adds r2, r0
2015-10-10 03:41:19 -07:00
ldr r1, =0x03001a78
ldr r0, =0x04000208
2015-10-06 07:00:49 -07:00
mov r9, r0
ldrh r0, [r0]
strh r0, [r1]
movs r3, 0
mov r1, r9
strh r3, [r1]
2015-10-10 03:41:19 -07:00
ldr r0, =0x03001a74
2015-10-06 07:00:49 -07:00
mov r8, r0
ldr r4, [r0]
strh r3, [r4, 0x2]
2015-10-10 03:41:19 -07:00
ldr r6, =0x04000200
ldr r1, =0x03001a70
2015-10-06 07:00:49 -07:00
mov r10, r1
ldrb r1, [r1]
movs r5, 0x8
adds r0, r5, 0
lsls r0, r1
adds r1, r0, 0
ldrh r0, [r6]
orrs r0, r1
strh r0, [r6]
2015-10-10 03:41:19 -07:00
ldr r0, =0x03007840
2015-10-06 07:00:49 -07:00
strb r3, [r0]
2015-10-10 03:41:19 -07:00
ldr r1, =0x03001a72
2015-10-06 07:00:49 -07:00
ldrh r0, [r2]
strh r0, [r1]
adds r2, 0x2
ldrh r0, [r2]
strh r0, [r4]
adds r0, r4, 0x2
mov r1, r8
str r0, [r1]
ldrh r0, [r2, 0x2]
strh r0, [r4, 0x2]
str r4, [r1]
2015-10-10 03:41:19 -07:00
ldr r1, =0x04000202
2015-10-06 07:00:49 -07:00
mov r2, r10
ldrb r0, [r2]
lsls r5, r0
strh r5, [r1]
movs r0, 0x1
mov r3, r9
strh r0, [r3]
pop {r3-r5}
mov r8, r3
mov r9, r4
mov r10, r5
pop {r4-r6}
pop {r0}
bx r0
.align 2, 0
2015-10-10 03:41:19 -07:00
.pool
2015-10-06 07:00:49 -07:00
thumb_func_end StartFlashTimer
thumb_func_start StopFlashTimer
2015-10-10 03:12:48 -07:00
StopFlashTimer: ; 82E1A28
2015-10-10 03:41:19 -07:00
ldr r3, =0x04000208
2015-10-06 07:00:49 -07:00
movs r1, 0
strh r1, [r3]
2015-10-10 03:41:19 -07:00
ldr r2, =0x03001a74
2015-10-06 07:00:49 -07:00
ldr r0, [r2]
strh r1, [r0]
adds r0, 0x2
str r0, [r2]
strh r1, [r0]
subs r0, 0x2
str r0, [r2]
2015-10-10 03:41:19 -07:00
ldr r2, =0x04000200
ldr r0, =0x03001a70
2015-10-06 07:00:49 -07:00
ldrb r0, [r0]
movs r1, 0x8
lsls r1, r0
ldrh r0, [r2]
bics r0, r1
strh r0, [r2]
2015-10-10 03:41:19 -07:00
ldr r0, =0x03001a78
2015-10-06 07:00:49 -07:00
ldrh r0, [r0]
strh r0, [r3]
bx lr
.align 2, 0
2015-10-10 03:41:19 -07:00
.pool
2015-10-06 07:00:49 -07:00
thumb_func_end StopFlashTimer
thumb_func_start ReadFlash1
2015-10-10 03:12:48 -07:00
; u8 ReadFlash1(int address)
ReadFlash1: ; 82E1A6C
2015-10-06 07:00:49 -07:00
ldrb r0, [r0]
bx lr
thumb_func_end ReadFlash1
thumb_func_start SetReadFlash1
2015-10-10 03:12:48 -07:00
; void SetReadFlash1(u8 ( *target_func)(int address))
SetReadFlash1: ; 82E1A70
2015-10-06 07:00:49 -07:00
push {lr}
adds r2, r0, 0
2015-10-10 03:41:19 -07:00
ldr r1, =0x03007844
2015-10-06 07:00:49 -07:00
adds r0, r2, 0x1
str r0, [r1]
2015-10-10 03:41:19 -07:00
ldr r3, =ReadFlash1 + 1
2015-10-06 07:00:49 -07:00
movs r0, 0x1
eors r3, r0
2015-10-10 03:41:19 -07:00
ldr r0, =SetReadFlash1 + 1
ldr r1, =ReadFlash1 + 1
2015-10-06 07:00:49 -07:00
subs r0, r1
lsls r0, 15
2015-10-10 03:50:53 -07:00
b @082E1AA4
2015-10-06 07:00:49 -07:00
.align 2, 0
2015-10-10 03:41:19 -07:00
.pool
2015-10-10 03:50:53 -07:00
@082E1A98:
2015-10-06 07:00:49 -07:00
ldrh r0, [r3]
strh r0, [r2]
adds r3, 0x2
adds r2, 0x2
subs r0, r1, 0x1
lsls r0, 16
2015-10-10 03:50:53 -07:00
@082E1AA4:
2015-10-06 07:00:49 -07:00
lsrs r1, r0, 16
cmp r1, 0
2015-10-10 03:50:53 -07:00
bne @082E1A98
2015-10-06 07:00:49 -07:00
pop {r0}
bx r0
thumb_func_end SetReadFlash1
thumb_func_start ReadFlash_Core
2015-10-10 03:12:48 -07:00
ReadFlash_Core: ; 82E1AB0
2015-10-06 07:00:49 -07:00
push {r4,lr}
adds r4, r0, 0
subs r3, r2, 0x1
cmp r2, 0
2015-10-10 03:50:53 -07:00
beq @082E1ACC
2015-10-06 07:00:49 -07:00
movs r2, 0x1
negs r2, r2
2015-10-10 03:50:53 -07:00
@082E1ABE:
2015-10-06 07:00:49 -07:00
ldrb r0, [r4]
strb r0, [r1]
adds r4, 0x1
adds r1, 0x1
subs r3, 0x1
cmp r3, r2
2015-10-10 03:50:53 -07:00
bne @082E1ABE
@082E1ACC:
2015-10-06 07:00:49 -07:00
pop {r4}
pop {r0}
bx r0
thumb_func_end ReadFlash_Core
thumb_func_start ReadFlash
2015-10-10 03:12:48 -07:00
ReadFlash: ; 82E1AD4
2015-10-06 07:00:49 -07:00
push {r4-r7,lr}
sub sp, 0x80
adds r5, r1, 0
adds r6, r2, 0
adds r7, r3, 0
lsls r3, r0, 16
lsrs r4, r3, 16
2015-10-10 03:41:19 -07:00
ldr r2, =0x04000204
2015-10-06 07:00:49 -07:00
ldrh r0, [r2]
2015-10-10 03:41:19 -07:00
ldr r1, =0x0000fffc
2015-10-06 07:00:49 -07:00
ands r0, r1
movs r1, 0x3
orrs r0, r1
strh r0, [r2]
2015-10-10 03:41:19 -07:00
ldr r0, =0x03007850
2015-10-06 07:00:49 -07:00
ldr r0, [r0]
ldr r1, [r0]
movs r0, 0x80
lsls r0, 10
cmp r1, r0
2015-10-10 03:50:53 -07:00
bne @082E1B0C
2015-10-06 07:00:49 -07:00
lsrs r0, r3, 20
lsls r0, 24
lsrs r0, 24
bl SwitchFlashBank
movs r0, 0xF
ands r4, r0
2015-10-10 03:50:53 -07:00
@082E1B0C:
2015-10-10 03:41:19 -07:00
ldr r3, =ReadFlash_Core + 1
2015-10-06 07:00:49 -07:00
movs r0, 0x1
eors r3, r0
mov r2, sp
2015-10-10 03:41:19 -07:00
ldr r0, =ReadFlash + 1
ldr r1, =ReadFlash_Core + 1
2015-10-06 07:00:49 -07:00
subs r0, r1
lsls r0, 15
2015-10-10 03:50:53 -07:00
b @082E1B40
2015-10-06 07:00:49 -07:00
.align 2, 0
2015-10-10 03:41:19 -07:00
.pool
2015-10-10 03:50:53 -07:00
@082E1B34:
2015-10-06 07:00:49 -07:00
ldrh r0, [r3]
strh r0, [r2]
adds r3, 0x2
adds r2, 0x2
subs r0, r1, 0x1
lsls r0, 16
2015-10-10 03:50:53 -07:00
@082E1B40:
2015-10-06 07:00:49 -07:00
lsrs r1, r0, 16
cmp r1, 0
2015-10-10 03:50:53 -07:00
bne @082E1B34
2015-10-06 07:00:49 -07:00
mov r3, sp
adds r3, 0x1
2015-10-10 03:41:19 -07:00
ldr r0, =0x03007850
2015-10-06 07:00:49 -07:00
ldr r0, [r0]
ldrb r0, [r0, 0x8]
lsls r4, r0
adds r0, r4, 0
movs r2, 0xE0
lsls r2, 20
adds r1, r5, r2
adds r0, r1
adds r1, r6, 0
adds r2, r7, 0
bl _call_via_r3
add sp, 0x80
pop {r4-r7}
pop {r0}
bx r0
.align 2, 0
2015-10-10 03:41:19 -07:00
.pool
2015-10-06 07:00:49 -07:00
thumb_func_end ReadFlash
thumb_func_start VerifyFlashSector_Core
2015-10-10 03:12:48 -07:00
VerifyFlashSector_Core: ; 82E1B70
2015-10-06 07:00:49 -07:00
push {r4,r5,lr}
adds r5, r0, 0
adds r3, r1, 0
subs r4, r2, 0x1
cmp r2, 0
2015-10-10 03:50:53 -07:00
beq @082E1B96
2015-10-06 07:00:49 -07:00
movs r2, 0x1
negs r2, r2
2015-10-10 03:50:53 -07:00
@082E1B80:
2015-10-06 07:00:49 -07:00
ldrb r1, [r3]
ldrb r0, [r5]
adds r5, 0x1
adds r3, 0x1
cmp r1, r0
2015-10-10 03:50:53 -07:00
beq @082E1B90
2015-10-06 07:00:49 -07:00
subs r0, r3, 0x1
2015-10-10 03:50:53 -07:00
b @082E1B98
@082E1B90:
2015-10-06 07:00:49 -07:00
subs r4, 0x1
cmp r4, r2
2015-10-10 03:50:53 -07:00
bne @082E1B80
@082E1B96:
2015-10-06 07:00:49 -07:00
movs r0, 0
2015-10-10 03:50:53 -07:00
@082E1B98:
2015-10-06 07:00:49 -07:00
pop {r4,r5}
pop {r1}
bx r1
thumb_func_end VerifyFlashSector_Core
thumb_func_start VerifyFlashSector
2015-10-10 03:12:48 -07:00
VerifyFlashSector: ; 82E1BA0
2015-10-06 07:00:49 -07:00
push {r4,r5,lr}
sub sp, 0x100
adds r5, r1, 0
lsls r3, r0, 16
lsrs r4, r3, 16
2015-10-10 03:41:19 -07:00
ldr r2, =0x04000204
2015-10-06 07:00:49 -07:00
ldrh r0, [r2]
2015-10-10 03:41:19 -07:00
ldr r1, =0x0000fffc
2015-10-06 07:00:49 -07:00
ands r0, r1
movs r1, 0x3
orrs r0, r1
strh r0, [r2]
2015-10-10 03:41:19 -07:00
ldr r0, =0x03007850
2015-10-06 07:00:49 -07:00
ldr r0, [r0]
ldr r1, [r0]
movs r0, 0x80
lsls r0, 10
cmp r1, r0
2015-10-10 03:50:53 -07:00
bne @082E1BD4
2015-10-06 07:00:49 -07:00
lsrs r0, r3, 20
lsls r0, 24
lsrs r0, 24
bl SwitchFlashBank
movs r0, 0xF
ands r4, r0
2015-10-10 03:50:53 -07:00
@082E1BD4:
2015-10-10 03:41:19 -07:00
ldr r3, =VerifyFlashSector_Core + 1
2015-10-06 07:00:49 -07:00
movs r0, 0x1
eors r3, r0
mov r2, sp
2015-10-10 03:41:19 -07:00
ldr r0, =VerifyFlashSector + 1
ldr r1, =VerifyFlashSector_Core + 1
2015-10-06 07:00:49 -07:00
subs r0, r1
lsls r0, 15
2015-10-10 03:50:53 -07:00
b @082E1C08
2015-10-06 07:00:49 -07:00
.align 2, 0
2015-10-10 03:41:19 -07:00
.pool
2015-10-10 03:50:53 -07:00
@082E1BFC:
2015-10-06 07:00:49 -07:00
ldrh r0, [r3]
strh r0, [r2]
adds r3, 0x2
adds r2, 0x2
subs r0, r1, 0x1
lsls r0, 16
2015-10-10 03:50:53 -07:00
@082E1C08:
2015-10-06 07:00:49 -07:00
lsrs r1, r0, 16
cmp r1, 0
2015-10-10 03:50:53 -07:00
bne @082E1BFC
2015-10-06 07:00:49 -07:00
mov r3, sp
adds r3, 0x1
2015-10-10 03:41:19 -07:00
ldr r0, =0x03007850
2015-10-06 07:00:49 -07:00
ldr r0, [r0]
ldrb r1, [r0, 0x8]
lsls r4, r1
adds r1, r4, 0
movs r2, 0xE0
lsls r2, 20
adds r1, r2
ldrh r2, [r0, 0x4]
adds r0, r5, 0
bl _call_via_r3
add sp, 0x100
pop {r4,r5}
pop {r1}
bx r1
.align 2, 0
2015-10-10 03:41:19 -07:00
.pool
2015-10-06 07:00:49 -07:00
thumb_func_end VerifyFlashSector
thumb_func_start VerifyFlashSectorFirstNBytes
2015-10-10 03:12:48 -07:00
VerifyFlashSectorFirstNBytes: ; 82E1C38
2015-10-06 07:00:49 -07:00
push {r4-r6,lr}
sub sp, 0x100
adds r5, r1, 0
adds r6, r2, 0
lsls r2, r0, 16
lsrs r4, r2, 16
2015-10-10 03:41:19 -07:00
ldr r0, =0x03007850
2015-10-06 07:00:49 -07:00
ldr r0, [r0]
ldr r1, [r0]
movs r0, 0x80
lsls r0, 10
cmp r1, r0
2015-10-10 03:50:53 -07:00
bne @082E1C60
2015-10-06 07:00:49 -07:00
lsrs r0, r2, 20
lsls r0, 24
lsrs r0, 24
bl SwitchFlashBank
movs r0, 0xF
ands r4, r0
2015-10-10 03:50:53 -07:00
@082E1C60:
2015-10-10 03:41:19 -07:00
ldr r2, =0x04000204
2015-10-06 07:00:49 -07:00
ldrh r0, [r2]
2015-10-10 03:41:19 -07:00
ldr r1, =0x0000fffc
2015-10-06 07:00:49 -07:00
ands r0, r1
movs r1, 0x3
orrs r0, r1
strh r0, [r2]
2015-10-10 03:41:19 -07:00
ldr r3, =VerifyFlashSector_Core + 1
2015-10-06 07:00:49 -07:00
movs r0, 0x1
eors r3, r0
mov r2, sp
2015-10-10 03:41:19 -07:00
ldr r0, =VerifyFlashSector + 1
ldr r1, =VerifyFlashSector_Core + 1
2015-10-06 07:00:49 -07:00
subs r0, r1
lsls r0, 15
2015-10-10 03:50:53 -07:00
b @082E1CA0
2015-10-06 07:00:49 -07:00
.align 2, 0
2015-10-10 03:41:19 -07:00
.pool
2015-10-10 03:50:53 -07:00
@082E1C94:
2015-10-06 07:00:49 -07:00
ldrh r0, [r3]
strh r0, [r2]
adds r3, 0x2
adds r2, 0x2
subs r0, r1, 0x1
lsls r0, 16
2015-10-10 03:50:53 -07:00
@082E1CA0:
2015-10-06 07:00:49 -07:00
lsrs r1, r0, 16
cmp r1, 0
2015-10-10 03:50:53 -07:00
bne @082E1C94
2015-10-06 07:00:49 -07:00
mov r3, sp
adds r3, 0x1
2015-10-10 03:41:19 -07:00
ldr r0, =0x03007850
2015-10-06 07:00:49 -07:00
ldr r0, [r0]
ldrb r1, [r0, 0x8]
lsls r4, r1
adds r1, r4, 0
movs r0, 0xE0
lsls r0, 20
adds r1, r0
adds r0, r5, 0
adds r2, r6, 0
bl _call_via_r3
add sp, 0x100
pop {r4-r6}
pop {r1}
bx r1
.align 2, 0
2015-10-10 03:41:19 -07:00
.pool
2015-10-06 07:00:49 -07:00
thumb_func_end VerifyFlashSectorFirstNBytes
thumb_func_start ProgramFlashSectorsAndVerify
2015-10-10 03:12:48 -07:00
ProgramFlashSectorsAndVerify: ; 82E1CD0
2015-10-06 07:00:49 -07:00
push {r4-r6,lr}
adds r5, r1, 0
lsls r0, 16
lsrs r4, r0, 16
movs r6, 0
2015-10-10 03:50:53 -07:00
b @082E1CE2
@082E1CDC:
2015-10-06 07:00:49 -07:00
adds r0, r6, 0x1
lsls r0, 24
lsrs r6, r0, 24
2015-10-10 03:50:53 -07:00
@082E1CE2:
2015-10-06 07:00:49 -07:00
cmp r6, 0x2
2015-10-10 03:50:53 -07:00
bhi @082E1D08
2015-10-10 03:41:19 -07:00
ldr r0, =0x0300784c
2015-10-06 07:00:49 -07:00
ldr r2, [r0]
adds r0, r4, 0
adds r1, r5, 0
bl _call_via_r2
lsls r0, 16
lsrs r2, r0, 16
cmp r2, 0
2015-10-10 03:50:53 -07:00
bne @082E1CDC
2015-10-06 07:00:49 -07:00
adds r0, r4, 0
adds r1, r5, 0
bl VerifyFlashSector
adds r2, r0, 0
cmp r2, 0
2015-10-10 03:50:53 -07:00
bne @082E1CDC
@082E1D08:
2015-10-06 07:00:49 -07:00
adds r0, r2, 0
pop {r4-r6}
pop {r1}
bx r1
.align 2, 0
2015-10-10 03:41:19 -07:00
.pool
2015-10-06 07:00:49 -07:00
thumb_func_end ProgramFlashSectorsAndVerify
thumb_func_start ProgramFlashSectorsVerifyFirstNBytes
2015-10-10 03:12:48 -07:00
ProgramFlashSectorsVerifyFirstNBytes: ; 82E1D14
2015-10-06 07:00:49 -07:00
push {r4-r7,lr}
adds r5, r1, 0
adds r7, r2, 0
lsls r0, 16
lsrs r4, r0, 16
movs r6, 0
2015-10-10 03:50:53 -07:00
b @082E1D28
@082E1D22:
2015-10-06 07:00:49 -07:00
adds r0, r6, 0x1
lsls r0, 24
lsrs r6, r0, 24
2015-10-10 03:50:53 -07:00
@082E1D28:
2015-10-06 07:00:49 -07:00
cmp r6, 0x2
2015-10-10 03:50:53 -07:00
bhi @082E1D50
2015-10-10 03:41:19 -07:00
ldr r0, =0x0300784c
2015-10-06 07:00:49 -07:00
ldr r2, [r0]
adds r0, r4, 0
adds r1, r5, 0
bl _call_via_r2
lsls r0, 16
lsrs r3, r0, 16
cmp r3, 0
2015-10-10 03:50:53 -07:00
bne @082E1D22
2015-10-06 07:00:49 -07:00
adds r0, r4, 0
adds r1, r5, 0
adds r2, r7, 0
bl VerifyFlashSectorFirstNBytes
adds r3, r0, 0
cmp r3, 0
2015-10-10 03:50:53 -07:00
bne @082E1D22
@082E1D50:
2015-10-06 07:00:49 -07:00
adds r0, r3, 0
pop {r4-r7}
pop {r1}
bx r1
.align 2, 0
2015-10-10 03:41:19 -07:00
.pool
2015-10-06 07:00:49 -07:00
thumb_func_end ProgramFlashSectorsVerifyFirstNBytes
thumb_func_start IdentifyFlash
2015-10-10 03:12:48 -07:00
; _BOOL2 IdentifyFlash()
IdentifyFlash: ; 82E1D5C
2015-10-06 07:00:49 -07:00
push {r4,lr}
2015-10-10 03:41:19 -07:00
ldr r2, =0x04000204
2015-10-06 07:00:49 -07:00
ldrh r0, [r2]
2015-10-10 03:41:19 -07:00
ldr r1, =0x0000fffc
2015-10-06 07:00:49 -07:00
ands r0, r1
movs r1, 0x3
orrs r0, r1
strh r0, [r2]
bl ReadFlashID
lsls r0, 16
lsrs r3, r0, 16
2015-10-10 05:20:38 -07:00
ldr r2, =gUnknown_089A30D0
2015-10-06 07:00:49 -07:00
movs r4, 0x1
2015-10-10 03:50:53 -07:00
b @082E1D8A
2015-10-06 07:00:49 -07:00
.align 2, 0
2015-10-10 03:41:19 -07:00
.pool
2015-10-10 03:50:53 -07:00
@082E1D88:
2015-10-06 07:00:49 -07:00
adds r2, 0x4
2015-10-10 03:50:53 -07:00
@082E1D8A:
2015-10-06 07:00:49 -07:00
ldr r1, [r2]
adds r0, r1, 0
adds r0, 0x2C
ldrb r0, [r0]
cmp r0, 0
2015-10-10 03:50:53 -07:00
beq @082E1D9E
2015-10-06 07:00:49 -07:00
ldrh r0, [r1, 0x2C]
cmp r3, r0
2015-10-10 03:50:53 -07:00
bne @082E1D88
2015-10-06 07:00:49 -07:00
movs r4, 0
2015-10-10 03:50:53 -07:00
@082E1D9E:
2015-10-10 03:41:19 -07:00
ldr r1, =0x03007854
2015-10-06 07:00:49 -07:00
ldr r0, [r2]
ldr r0, [r0]
str r0, [r1]
2015-10-10 03:41:19 -07:00
ldr r1, =0x0300784c
2015-10-06 07:00:49 -07:00
ldr r0, [r2]
ldr r0, [r0, 0x4]
str r0, [r1]
2015-10-10 03:41:19 -07:00
ldr r1, =0x0300785c
2015-10-06 07:00:49 -07:00
ldr r0, [r2]
ldr r0, [r0, 0x8]
str r0, [r1]
2015-10-10 03:41:19 -07:00
ldr r1, =0x03007860
2015-10-06 07:00:49 -07:00
ldr r0, [r2]
ldr r0, [r0, 0xC]
str r0, [r1]
2015-10-10 03:41:19 -07:00
ldr r1, =0x03007848
2015-10-06 07:00:49 -07:00
ldr r0, [r2]
ldr r0, [r0, 0x10]
str r0, [r1]
2015-10-10 03:41:19 -07:00
ldr r1, =0x03007864
2015-10-06 07:00:49 -07:00
ldr r0, [r2]
ldr r0, [r0, 0x14]
str r0, [r1]
2015-10-10 03:41:19 -07:00
ldr r1, =0x03007850
2015-10-06 07:00:49 -07:00
ldr r0, [r2]
adds r0, 0x18
str r0, [r1]
adds r0, r4, 0
pop {r4}
pop {r1}
bx r1
.align 2, 0
2015-10-10 03:41:19 -07:00
.pool
2015-10-06 07:00:49 -07:00
thumb_func_end IdentifyFlash
thumb_func_start PollingSR_COMMON
2015-10-10 03:12:48 -07:00
PollingSR_COMMON: ; 82E1DFC
2015-10-06 07:00:49 -07:00
push {r4-r7,lr}
mov r7, r9
mov r6, r8
push {r6,r7}
adds r4, r1, 0
lsls r0, 24
lsrs r7, r0, 24
lsls r2, 24
lsrs r5, r2, 24
movs r0, 0
mov r8, r0
adds r0, r7, 0
bl StartFlashTimer
2015-10-10 03:41:19 -07:00
ldr r6, =0x03007844
ldr r1, =0x0e005555
2015-10-06 07:00:49 -07:00
mov r9, r1
2015-10-10 03:50:53 -07:00
b @082E1E60
2015-10-06 07:00:49 -07:00
.align 2, 0
2015-10-10 03:41:19 -07:00
.pool
2015-10-10 03:50:53 -07:00
@082E1E28:
2015-10-06 07:00:49 -07:00
movs r0, 0xF0
mov r1, r9
strb r0, [r1]
movs r0, 0xA0
lsls r0, 8
2015-10-10 03:50:53 -07:00
b @082E1E56
@082E1E34:
2015-10-10 03:41:19 -07:00
ldr r0, =0x03007840
2015-10-06 07:00:49 -07:00
ldrb r0, [r0]
cmp r0, 0
2015-10-10 03:50:53 -07:00
beq @082E1E60
2015-10-06 07:00:49 -07:00
ldr r1, [r6]
adds r0, r4, 0
bl _call_via_r1
lsls r0, 24
lsrs r0, 24
cmp r0, r5
2015-10-10 03:50:53 -07:00
beq @082E1E88
2015-10-06 07:00:49 -07:00
movs r0, 0xF0
mov r1, r9
strb r0, [r1]
movs r0, 0xC0
lsls r0, 8
2015-10-10 03:50:53 -07:00
@082E1E56:
2015-10-06 07:00:49 -07:00
orrs r7, r0
mov r8, r7
2015-10-10 03:50:53 -07:00
b @082E1E88
2015-10-06 07:00:49 -07:00
.align 2, 0
2015-10-10 03:41:19 -07:00
.pool
2015-10-10 03:50:53 -07:00
@082E1E60:
2015-10-06 07:00:49 -07:00
ldr r1, [r6]
adds r0, r4, 0
bl _call_via_r1
lsls r0, 24
lsrs r1, r0, 24
cmp r1, r5
2015-10-10 03:50:53 -07:00
beq @082E1E88
2015-10-06 07:00:49 -07:00
movs r0, 0x20
ands r0, r1
cmp r0, 0
2015-10-10 03:50:53 -07:00
beq @082E1E34
2015-10-06 07:00:49 -07:00
ldr r1, [r6]
adds r0, r4, 0
bl _call_via_r1
lsls r0, 24
lsrs r0, 24
cmp r0, r5
2015-10-10 03:50:53 -07:00
bne @082E1E28
@082E1E88:
2015-10-06 07:00:49 -07:00
bl StopFlashTimer
mov r0, r8
pop {r3,r4}
mov r8, r3
mov r9, r4
pop {r4-r7}
pop {r1}
bx r1
thumb_func_end PollingSR_COMMON
thumb_func_start EraseFlashChip
2015-10-10 03:12:48 -07:00
EraseFlashChip: ; 82E1E9C
2015-10-06 07:00:49 -07:00
push {r4-r6,lr}
sub sp, 0x40
2015-10-10 03:41:19 -07:00
ldr r5, =0x04000204
2015-10-06 07:00:49 -07:00
ldrh r1, [r5]
2015-10-10 03:41:19 -07:00
ldr r6, =0x0000fffc
2015-10-06 07:00:49 -07:00
ands r1, r6
2015-10-10 03:41:19 -07:00
ldr r0, =0x03007850
2015-10-06 07:00:49 -07:00
ldr r0, [r0]
ldrh r0, [r0, 0x10]
orrs r1, r0
strh r1, [r5]
2015-10-10 03:41:19 -07:00
ldr r1, =0x0e005555
2015-10-06 07:00:49 -07:00
movs r4, 0xAA
strb r4, [r1]
2015-10-10 03:41:19 -07:00
ldr r3, =0x0e002aaa
2015-10-06 07:00:49 -07:00
movs r2, 0x55
strb r2, [r3]
movs r0, 0x80
strb r0, [r1]
strb r4, [r1]
strb r2, [r3]
movs r0, 0x10
strb r0, [r1]
mov r0, sp
bl SetReadFlash1
2015-10-10 03:41:19 -07:00
ldr r0, =0x03007848
2015-10-06 07:00:49 -07:00
movs r1, 0xE0
lsls r1, 20
ldr r3, [r0]
movs r0, 0x3
movs r2, 0xFF
bl _call_via_r3
lsls r0, 16
lsrs r0, 16
ldrh r1, [r5]
ands r1, r6
movs r2, 0x3
orrs r1, r2
strh r1, [r5]
add sp, 0x40
pop {r4-r6}
pop {r1}
bx r1
.align 2, 0
2015-10-10 03:41:19 -07:00
.pool
2015-10-06 07:00:49 -07:00
thumb_func_end EraseFlashChip
thumb_func_start EraseFlashSector
2015-10-10 03:12:48 -07:00
EraseFlashSector: ; 82E1F10
2015-10-06 07:00:49 -07:00
push {r4-r7,lr}
sub sp, 0x40
lsls r0, 16
lsrs r6, r0, 16
2015-10-10 03:41:19 -07:00
ldr r0, =0x03007850
2015-10-06 07:00:49 -07:00
ldr r0, [r0]
ldrh r0, [r0, 0xA]
cmp r6, r0
2015-10-10 03:50:53 -07:00
bcc @082E1F30
2015-10-10 03:41:19 -07:00
ldr r0, =0x000080ff
2015-10-10 03:50:53 -07:00
b @082E1FD0
2015-10-06 07:00:49 -07:00
.align 2, 0
2015-10-10 03:41:19 -07:00
.pool
2015-10-10 03:50:53 -07:00
@082E1F30:
2015-10-06 07:00:49 -07:00
lsrs r0, r6, 4
lsls r0, 24
lsrs r0, 24
bl SwitchFlashBank
movs r0, 0xF
ands r6, r0
movs r7, 0
2015-10-10 03:50:53 -07:00
@082E1F40:
2015-10-10 03:41:19 -07:00
ldr r3, =0x04000204
2015-10-06 07:00:49 -07:00
ldrh r1, [r3]
2015-10-10 03:41:19 -07:00
ldr r0, =0x0000fffc
2015-10-06 07:00:49 -07:00
ands r1, r0
2015-10-10 03:41:19 -07:00
ldr r0, =0x03007850
2015-10-06 07:00:49 -07:00
ldr r2, [r0]
ldrh r0, [r2, 0x10]
orrs r1, r0
strh r1, [r3]
ldrb r4, [r2, 0x8]
adds r0, r6, 0
lsls r0, r4
adds r4, r0, 0
movs r0, 0xE0
lsls r0, 20
adds r4, r0
2015-10-10 03:41:19 -07:00
ldr r1, =0x0e005555
2015-10-06 07:00:49 -07:00
movs r5, 0xAA
strb r5, [r1]
2015-10-10 03:41:19 -07:00
ldr r3, =0x0e002aaa
2015-10-06 07:00:49 -07:00
movs r2, 0x55
strb r2, [r3]
movs r0, 0x80
strb r0, [r1]
strb r5, [r1]
strb r2, [r3]
movs r0, 0x30
strb r0, [r4]
mov r0, sp
bl SetReadFlash1
2015-10-10 03:41:19 -07:00
ldr r0, =0x03007848
2015-10-06 07:00:49 -07:00
ldr r3, [r0]
movs r0, 0x2
adds r1, r4, 0
movs r2, 0xFF
bl _call_via_r3
lsls r0, 16
lsrs r3, r0, 16
movs r0, 0xA0
lsls r0, 8
ands r0, r3
cmp r0, 0
2015-10-10 03:50:53 -07:00
beq @082E1FC0
2015-10-06 07:00:49 -07:00
cmp r7, 0x3
2015-10-10 03:50:53 -07:00
bhi @082E1FC0
2015-10-06 07:00:49 -07:00
adds r0, r7, 0x1
lsls r0, 16
lsrs r7, r0, 16
2015-10-10 03:50:53 -07:00
b @082E1F40
2015-10-06 07:00:49 -07:00
.align 2, 0
2015-10-10 03:41:19 -07:00
.pool
2015-10-10 03:50:53 -07:00
@082E1FC0:
2015-10-10 03:41:19 -07:00
ldr r2, =0x04000204
2015-10-06 07:00:49 -07:00
ldrh r0, [r2]
2015-10-10 03:41:19 -07:00
ldr r1, =0x0000fffc
2015-10-06 07:00:49 -07:00
ands r0, r1
movs r1, 0x3
orrs r0, r1
strh r0, [r2]
adds r0, r3, 0
2015-10-10 03:50:53 -07:00
@082E1FD0:
2015-10-06 07:00:49 -07:00
add sp, 0x40
pop {r4-r7}
pop {r1}
bx r1
.align 2, 0
2015-10-10 03:41:19 -07:00
.pool
2015-10-06 07:00:49 -07:00
thumb_func_end EraseFlashSector
thumb_func_start ProgramFlashByte
2015-10-10 03:12:48 -07:00
ProgramFlashByte: ; 82E1FE0
2015-10-06 07:00:49 -07:00
push {r4-r7,lr}
sub sp, 0x40
adds r6, r1, 0
lsls r1, r0, 16
lsrs r4, r1, 16
lsls r2, 24
lsrs r7, r2, 24
2015-10-10 03:41:19 -07:00
ldr r5, =0x03007850
2015-10-06 07:00:49 -07:00
ldr r0, [r5]
ldr r0, [r0, 0x4]
cmp r6, r0
2015-10-10 03:50:53 -07:00
bcs @082E2068
2015-10-06 07:00:49 -07:00
lsrs r0, r1, 20
lsls r0, 24
lsrs r0, 24
bl SwitchFlashBank
movs r0, 0xF
ldr r1, [r5]
ands r4, r0
ldrb r1, [r1, 0x8]
lsls r4, r1
movs r1, 0xE0
lsls r1, 20
adds r0, r6, r1
adds r4, r0
mov r0, sp
bl SetReadFlash1
2015-10-10 03:41:19 -07:00
ldr r2, =0x04000204
2015-10-06 07:00:49 -07:00
ldrh r0, [r2]
2015-10-10 03:41:19 -07:00
ldr r1, =0x0000fffc
2015-10-06 07:00:49 -07:00
ands r0, r1
ldr r1, [r5]
ldrh r1, [r1, 0x10]
orrs r0, r1
strh r0, [r2]
2015-10-10 03:41:19 -07:00
ldr r2, =0x0e005555
2015-10-06 07:00:49 -07:00
movs r0, 0xAA
strb r0, [r2]
2015-10-10 03:41:19 -07:00
ldr r1, =0x0e002aaa
2015-10-06 07:00:49 -07:00
movs r0, 0x55
strb r0, [r1]
movs r0, 0xA0
strb r0, [r2]
strb r7, [r4]
2015-10-10 03:41:19 -07:00
ldr r0, =0x03007848
2015-10-06 07:00:49 -07:00
ldr r3, [r0]
movs r0, 0x1
adds r1, r4, 0
adds r2, r7, 0
bl _call_via_r3
lsls r0, 16
lsrs r0, 16
2015-10-10 03:50:53 -07:00
b @082E206C
2015-10-06 07:00:49 -07:00
.align 2, 0
2015-10-10 03:41:19 -07:00
.pool
2015-10-10 03:50:53 -07:00
@082E2068:
2015-10-06 07:00:49 -07:00
movs r0, 0x80
lsls r0, 8
2015-10-10 03:50:53 -07:00
@082E206C:
2015-10-06 07:00:49 -07:00
add sp, 0x40
pop {r4-r7}
pop {r1}
bx r1
thumb_func_end ProgramFlashByte
thumb_func_start ProgramFlashByteInternal
2015-10-10 03:12:48 -07:00
ProgramFlashByteInternal: ; 82E2074
2015-10-06 07:00:49 -07:00
push {r4,lr}
2015-10-10 03:41:19 -07:00
ldr r4, =0x0e005555
2015-10-06 07:00:49 -07:00
movs r2, 0xAA
strb r2, [r4]
2015-10-10 03:41:19 -07:00
ldr r3, =0x0e002aaa
2015-10-06 07:00:49 -07:00
movs r2, 0x55
strb r2, [r3]
movs r2, 0xA0
strb r2, [r4]
ldrb r2, [r0]
strb r2, [r1]
2015-10-10 03:41:19 -07:00
ldr r3, =0x03007848
2015-10-06 07:00:49 -07:00
ldrb r2, [r0]
ldr r3, [r3]
movs r0, 0x1
bl _call_via_r3
lsls r0, 16
lsrs r0, 16
pop {r4}
pop {r1}
bx r1
.align 2, 0
2015-10-10 03:41:19 -07:00
.pool
2015-10-06 07:00:49 -07:00
thumb_func_end ProgramFlashByteInternal
thumb_func_start ProgramFlashSector
2015-10-10 03:12:48 -07:00
ProgramFlashSector: ; 82E20AC
2015-10-06 07:00:49 -07:00
push {r4-r7,lr}
sub sp, 0x40
adds r7, r1, 0
lsls r0, 16
lsrs r4, r0, 16
2015-10-10 03:41:19 -07:00
ldr r0, =0x03007850
2015-10-06 07:00:49 -07:00
ldr r0, [r0]
ldrh r0, [r0, 0xA]
cmp r4, r0
2015-10-10 03:50:53 -07:00
bcc @082E20CC
2015-10-10 03:41:19 -07:00
ldr r0, =0x000080ff
2015-10-10 03:50:53 -07:00
b @082E2146
2015-10-06 07:00:49 -07:00
.align 2, 0
2015-10-10 03:41:19 -07:00
.pool
2015-10-10 03:50:53 -07:00
@082E20CC:
2015-10-06 07:00:49 -07:00
adds r0, r4, 0
bl EraseFlashSector
lsls r0, 16
lsrs r5, r0, 16
cmp r5, 0
2015-10-10 03:50:53 -07:00
bne @082E2144
2015-10-06 07:00:49 -07:00
lsrs r0, r4, 4
lsls r0, 24
lsrs r0, 24
bl SwitchFlashBank
movs r0, 0xF
ands r4, r0
mov r0, sp
bl SetReadFlash1
2015-10-10 03:41:19 -07:00
ldr r3, =0x04000204
2015-10-06 07:00:49 -07:00
ldrh r1, [r3]
2015-10-10 03:41:19 -07:00
ldr r0, =0x0000fffc
2015-10-06 07:00:49 -07:00
ands r1, r0
2015-10-10 03:41:19 -07:00
ldr r0, =0x03007850
2015-10-06 07:00:49 -07:00
ldr r2, [r0]
ldrh r0, [r2, 0x10]
orrs r1, r0
strh r1, [r3]
2015-10-10 03:41:19 -07:00
ldr r1, =0x03007858
2015-10-06 07:00:49 -07:00
ldr r0, [r2, 0x4]
strh r0, [r1]
ldrb r0, [r2, 0x8]
lsls r4, r0
movs r0, 0xE0
lsls r0, 20
adds r4, r0
adds r6, r1, 0
2015-10-10 03:50:53 -07:00
b @082E212E
2015-10-06 07:00:49 -07:00
.align 2, 0
2015-10-10 03:41:19 -07:00
.pool
2015-10-10 03:50:53 -07:00
@082E2124:
2015-10-06 07:00:49 -07:00
ldrh r0, [r6]
subs r0, 0x1
strh r0, [r6]
adds r7, 0x1
adds r4, 0x1
2015-10-10 03:50:53 -07:00
@082E212E:
2015-10-06 07:00:49 -07:00
ldrh r0, [r6]
cmp r0, 0
2015-10-10 03:50:53 -07:00
beq @082E2144
2015-10-06 07:00:49 -07:00
adds r0, r7, 0
adds r1, r4, 0
bl ProgramFlashByteInternal
lsls r0, 16
lsrs r5, r0, 16
cmp r5, 0
2015-10-10 03:50:53 -07:00
beq @082E2124
@082E2144:
2015-10-06 07:00:49 -07:00
adds r0, r5, 0
2015-10-10 03:50:53 -07:00
@082E2146:
2015-10-06 07:00:49 -07:00
add sp, 0x40
pop {r4-r7}
pop {r1}
bx r1
thumb_func_end ProgramFlashSector