Skip to content

Commit

Permalink
added protection against corrupted saves
Browse files Browse the repository at this point in the history
  • Loading branch information
LeonarthCG committed Feb 15, 2019
1 parent de0dc57 commit 11f1cc6
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
Binary file modified ASM/boot.elf
Binary file not shown.
14 changes: 14 additions & 0 deletions ASM/boot.s
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,19 @@ strb r1,[r0,#15] @set the offset for the bg map 3

@set the first 4 bytes of the save to 0
ldr r0,=#0x0E000000
ldrb r1,[r0,#2]
cmp r1,#3
bhi resetSave
ldrb r1,[r0]
ldrb r2,[r0,#1]
lsl r2,#8
orr r1,r2
ldr r2,=#540
cmp r1,r2
bhi resetSave
ldrb r1,[r0,#3]
cmp r1,#1
bhi resetSave
mov r2,#0xFF
ldrb r1,[r0]
cmp r1,r2
Expand All @@ -75,6 +88,7 @@ bne dontset0
ldrb r1,[r0,#3]
cmp r1,r2
bne dontset0
resetSave:
mov r1,#0
strb r1,[r0]
strb r1,[r0,#1]
Expand Down
Binary file modified rom.gba
Binary file not shown.

0 comments on commit 11f1cc6

Please sign in to comment.