summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoryenatch <yenatch@gmail.com>2017-09-20 23:37:59 -0400
committerGitHub <noreply@github.com>2017-09-20 23:37:59 -0400
commited9e0e20547e2c96833cddea67c6b423ef7af7ef (patch)
treee9666a04c3fd57eedd27a341a94fcf57150fd822
parent40c1e81d03f4e4fc21675564ca5b879a577a399e (diff)
parent27903a102b3b99da6fb8f0a18957598bff65b428 (diff)
Merge pull request #37 from PikalaxALT/berry_fix_program
Berry fix program
-rwxr-xr-xasm/berry_fix_program.s584
-rw-r--r--asm/title_screen.s2
-rw-r--r--data/data_emerald2.s62
-rw-r--r--data/data_emerald2pre1.s35
-rw-r--r--data/graphics.s58
-rw-r--r--data/text/move_descriptions.inc3
-rw-r--r--include/bg.h23
-rw-r--r--include/gba/multiboot.h26
-rw-r--r--include/gpu_regs.h6
-rw-r--r--include/menu.h2
-rw-r--r--include/multiboot.h2
-rw-r--r--include/text.h4
-rw-r--r--include/unknown_task.h11
-rw-r--r--include/window.h2
-rw-r--r--ld_script.txt4
-rw-r--r--src/berry_fix_program.c531
-rw-r--r--src/bg.c189
-rw-r--r--src/multiboot.c2
-rw-r--r--src/text.c6
-rw-r--r--src/window.c2
-rw-r--r--sym_bss.txt5
21 files changed, 782 insertions, 777 deletions
diff --git a/asm/berry_fix_program.s b/asm/berry_fix_program.s
index 19ed0babd..2428f2984 100755
--- a/asm/berry_fix_program.s
+++ b/asm/berry_fix_program.s
@@ -5,588 +5,4 @@
.text
- thumb_func_start sub_81BF384
-sub_81BF384: @ 81BF384
- push {r4,lr}
- ldr r0, =0x0000ffff
- bl DisableInterrupts
- movs r0, 0x1
- bl EnableInterrupts
- bl m4aSoundVSyncOff
- movs r0, 0
- bl SetVBlankCallback
- bl ResetSpriteData
- bl ResetTasks
- bl remove_some_task
- movs r0, 0
- movs r1, 0
- bl SetGpuReg
- ldr r4, =gUnknown_030012B8
- movs r0, 0x50
- bl AllocZeroed
- str r0, [r4]
- movs r1, 0
- strb r1, [r0]
- ldr r1, [r4]
- movs r0, 0x6
- strb r0, [r1, 0x1]
- ldr r0, =sub_81BF3DC
- bl SetMainCallback2
- pop {r4}
- pop {r0}
- bx r0
- .pool
- thumb_func_end sub_81BF384
-
- thumb_func_start sub_81BF3DC
-sub_81BF3DC: @ 81BF3DC
- push {r4,r5,lr}
- sub sp, 0x4
- ldr r1, =gUnknown_030012B8
- ldr r0, [r1]
- ldrb r0, [r0]
- adds r5, r1, 0
- cmp r0, 0x7
- bls _081BF3EE
- b _081BF592
-_081BF3EE:
- lsls r0, 2
- ldr r1, =_081BF400
- adds r0, r1
- ldr r0, [r0]
- mov pc, r0
- .pool
- .align 2, 0
-_081BF400:
- .4byte _081BF420
- .4byte _081BF430
- .4byte _081BF45C
- .4byte _081BF488
- .4byte _081BF4BC
- .4byte _081BF514
- .4byte _081BF552
- .4byte _081BF574
-_081BF420:
- bl sub_81BF5A4
- ldr r0, =gUnknown_030012B8
- ldr r1, [r0]
- movs r0, 0x1
- b _081BF590
- .pool
-_081BF430:
- movs r0, 0x5
- bl sub_81BF7A4
- cmp r0, 0x5
- beq _081BF43C
- b _081BF592
-_081BF43C:
- ldr r0, =gMain
- ldrh r1, [r0, 0x2E]
- movs r0, 0x1
- ands r0, r1
- cmp r0, 0
- bne _081BF44A
- b _081BF592
-_081BF44A:
- ldr r0, =gUnknown_030012B8
- ldr r1, [r0]
- movs r0, 0x2
- b _081BF590
- .pool
-_081BF45C:
- movs r0, 0
- bl sub_81BF7A4
- cmp r0, 0
- beq _081BF468
- b _081BF592
-_081BF468:
- ldr r0, =gMain
- ldrh r1, [r0, 0x2E]
- movs r0, 0x1
- ands r0, r1
- cmp r0, 0
- bne _081BF476
- b _081BF592
-_081BF476:
- ldr r0, =gUnknown_030012B8
- ldr r1, [r0]
- movs r0, 0x3
- b _081BF590
- .pool
-_081BF488:
- movs r0, 0x1
- bl sub_81BF7A4
- cmp r0, 0x1
- beq _081BF494
- b _081BF592
-_081BF494:
- ldr r4, =gUnknown_030012B8
- ldr r0, [r4]
- ldr r1, =gUnknown_089A6550
- str r1, [r0, 0x2C]
- adds r0, 0x4F
- movs r5, 0
- strb r5, [r0]
- ldr r0, [r4]
- adds r0, 0x4
- bl MultiBootInit
- ldr r1, [r4]
- strh r5, [r1, 0x2]
- movs r0, 0x4
- b _081BF590
- .pool
-_081BF4BC:
- adds r4, r5, 0
- ldr r0, [r4]
- adds r0, 0x4
- bl MultiBootMain
- ldr r4, [r4]
- ldrb r0, [r4, 0x1C]
- cmp r0, 0
- bne _081BF4D8
- ldr r0, [r4, 0x20]
- ldr r1, =0x00020200
- ands r0, r1
- cmp r0, r1
- beq _081BF4E4
-_081BF4D8:
- movs r0, 0
- strh r0, [r4, 0x2]
- b _081BF592
- .pool
-_081BF4E4:
- ldrh r0, [r4, 0x2]
- adds r0, 0x1
- strh r0, [r4, 0x2]
- lsls r0, 16
- lsrs r0, 16
- cmp r0, 0xB4
- bls _081BF592
- adds r0, r4, 0x4
- ldr r1, =gMultiBootProgram_BerryGlitchFix_Start
- ldr r2, =gMultiBootProgram_BerryGlitchFix_End
- subs r2, r1
- movs r3, 0x1
- str r3, [sp]
- movs r3, 0x4
- bl MultiBootStartMaster
- ldr r1, [r5]
- movs r0, 0x5
- b _081BF590
- .pool
-_081BF514:
- movs r0, 0x2
- bl sub_81BF7A4
- adds r4, r0, 0
- cmp r4, 0x2
- bne _081BF592
- ldr r5, =gUnknown_030012B8
- ldr r0, [r5]
- adds r0, 0x4
- bl MultiBootMain
- ldr r0, [r5]
- adds r0, 0x4
- bl MultiBootCheckComplete
- cmp r0, 0
- beq _081BF540
- ldr r1, [r5]
- movs r0, 0x6
- b _081BF590
- .pool
-_081BF540:
- ldr r1, [r5]
- adds r0, r1, 0
- adds r0, 0x22
- ldrb r0, [r0]
- ands r4, r0
- cmp r4, 0
- bne _081BF592
- movs r0, 0x7
- b _081BF590
-_081BF552:
- movs r0, 0x3
- bl sub_81BF7A4
- cmp r0, 0x3
- bne _081BF592
- ldr r0, =gMain
- ldrh r1, [r0, 0x2E]
- movs r0, 0x1
- ands r0, r1
- cmp r0, 0
- beq _081BF592
- bl DoSoftReset
- b _081BF592
- .pool
-_081BF574:
- movs r0, 0x4
- bl sub_81BF7A4
- cmp r0, 0x4
- bne _081BF592
- ldr r0, =gMain
- ldrh r1, [r0, 0x2E]
- movs r0, 0x1
- ands r0, r1
- cmp r0, 0
- beq _081BF592
- ldr r0, =gUnknown_030012B8
- ldr r1, [r0]
- movs r0, 0x1
-_081BF590:
- strb r0, [r1]
-_081BF592:
- add sp, 0x4
- pop {r4,r5}
- pop {r0}
- bx r0
- .pool
- thumb_func_end sub_81BF3DC
-
- thumb_func_start sub_81BF5A4
-sub_81BF5A4: @ 81BF5A4
- push {r4-r6,lr}
- mov r6, r8
- push {r6}
- sub sp, 0x10
- movs r0, 0x8
- movs r1, 0
- bl SetGpuReg
- movs r0, 0xA
- movs r1, 0
- bl SetGpuReg
- movs r0, 0x10
- movs r1, 0
- bl SetGpuReg
- movs r0, 0x12
- movs r1, 0
- bl SetGpuReg
- movs r0, 0x14
- movs r1, 0
- bl SetGpuReg
- movs r0, 0x16
- movs r1, 0
- bl SetGpuReg
- movs r0, 0x50
- movs r1, 0
- bl SetGpuReg
- movs r1, 0
- str r1, [sp, 0xC]
- ldr r4, =0x040000d4
- add r0, sp, 0xC
- str r0, [r4]
- movs r0, 0xC0
- lsls r0, 19
- str r0, [r4, 0x4]
- ldr r0, =0x85006000
- str r0, [r4, 0x8]
- ldr r0, [r4, 0x8]
- str r1, [sp, 0xC]
- add r0, sp, 0xC
- str r0, [r4]
- movs r0, 0xE0
- lsls r0, 19
- str r0, [r4, 0x4]
- ldr r2, =0x85000100
- str r2, [r4, 0x8]
- ldr r0, [r4, 0x8]
- str r1, [sp, 0xC]
- add r0, sp, 0xC
- str r0, [r4]
- movs r0, 0xA0
- lsls r0, 19
- str r0, [r4, 0x4]
- str r2, [r4, 0x8]
- ldr r0, [r4, 0x8]
- movs r0, 0
- bl ResetBgsAndClearDma3BusyFlags
- ldr r1, =gUnknown_08618108
- movs r0, 0
- movs r2, 0x2
- bl InitBgsFromTemplates
- movs r0, 0
- movs r1, 0
- movs r2, 0
- bl ChangeBgX
- movs r0, 0
- movs r1, 0
- movs r2, 0
- bl ChangeBgY
- movs r0, 0x1
- movs r1, 0
- movs r2, 0
- bl ChangeBgX
- movs r0, 0x1
- movs r1, 0
- movs r2, 0
- bl ChangeBgY
- ldr r0, =gUnknown_08618110
- bl InitWindows
- bl DeactivateAllTextPrinters
- ldr r0, =gUnknown_08618138
- str r0, [r4]
- ldr r0, =0x050001e0
- str r0, [r4, 0x4]
- ldr r0, =0x84000008
- str r0, [r4, 0x8]
- ldr r0, [r4, 0x8]
- movs r0, 0
- movs r1, 0x40
- bl SetGpuReg
- movs r0, 0x2
- movs r1, 0
- bl FillWindowPixelBuffer
- movs r0, 0x3
- movs r1, 0
- bl FillWindowPixelBuffer
- movs r0, 0
- movs r1, 0xAA
- bl FillWindowPixelBuffer
- ldr r5, =gUnknown_08617E9B
- movs r0, 0
- adds r1, r5, 0
- movs r2, 0
- bl GetStringWidth
- adds r1, r0, 0
- movs r4, 0x78
- subs r0, r4, r1
- lsrs r1, r0, 31
- adds r0, r1
- asrs r0, 1
- lsls r2, r0, 24
- lsrs r2, 24
- ldr r6, =gUnknown_0861815B
- str r6, [sp]
- movs r0, 0x1
- negs r0, r0
- mov r8, r0
- str r0, [sp, 0x4]
- str r5, [sp, 0x8]
- movs r0, 0x2
- movs r1, 0
- movs r3, 0x3
- bl box_print
- ldr r5, =gUnknown_08617E8D
- movs r0, 0
- adds r1, r5, 0
- movs r2, 0
- bl GetStringWidth
- adds r1, r0, 0
- subs r4, r1
- lsrs r0, r4, 31
- adds r4, r0
- asrs r4, 1
- adds r0, r4, 0
- adds r0, 0x78
- lsls r2, r0, 24
- lsrs r2, 24
- str r6, [sp]
- mov r0, r8
- str r0, [sp, 0x4]
- str r5, [sp, 0x8]
- movs r0, 0x2
- movs r1, 0
- movs r3, 0x3
- bl box_print
- movs r0, 0
- adds r1, r5, 0
- movs r2, 0
- bl GetStringWidth
- adds r1, r0, 0
- movs r0, 0x70
- subs r0, r1
- lsrs r1, r0, 31
- adds r0, r1
- asrs r0, 1
- lsls r2, r0, 24
- lsrs r2, 24
- str r6, [sp]
- mov r0, r8
- str r0, [sp, 0x4]
- str r5, [sp, 0x8]
- movs r0, 0x3
- movs r1, 0
- movs r3, 0
- bl box_print
- ldr r4, =gUnknown_08617E78
- movs r0, 0x1
- adds r1, r4, 0
- movs r2, 0
- bl GetStringWidth
- adds r1, r0, 0
- movs r0, 0xD0
- subs r0, r1
- lsrs r1, r0, 31
- adds r0, r1
- asrs r0, 1
- lsls r2, r0, 24
- lsrs r2, 24
- ldr r0, =gUnknown_08618158
- str r0, [sp]
- mov r0, r8
- str r0, [sp, 0x4]
- str r4, [sp, 0x8]
- movs r0, 0
- movs r1, 0x1
- movs r3, 0x2
- bl box_print
- movs r0, 0x2
- movs r1, 0x2
- bl CopyWindowToVram
- movs r0, 0x3
- movs r1, 0x2
- bl CopyWindowToVram
- movs r0, 0
- movs r1, 0x2
- bl CopyWindowToVram
- add sp, 0x10
- pop {r3}
- mov r8, r3
- pop {r4-r6}
- pop {r0}
- bx r0
- .pool
- thumb_func_end sub_81BF5A4
-
- thumb_func_start sub_81BF7A4
-sub_81BF7A4: @ 81BF7A4
- push {r4,r5,lr}
- adds r4, r0, 0
- ldr r5, =gUnknown_030012B8
- ldr r0, [r5]
- ldrb r0, [r0, 0x1]
- cmp r0, r4
- bne _081BF7BC
- adds r0, r4, 0
- b _081BF7DC
- .pool
-_081BF7BC:
- cmp r0, 0x6
- bne _081BF7CC
- adds r0, r4, 0
- bl sub_81BF7E8
- ldr r0, [r5]
- strb r4, [r0, 0x1]
- b _081BF7D6
-_081BF7CC:
- bl sub_81BF8D8
- ldr r1, [r5]
- movs r0, 0x6
- strb r0, [r1, 0x1]
-_081BF7D6:
- ldr r0, =gUnknown_030012B8
- ldr r0, [r0]
- ldrb r0, [r0, 0x1]
-_081BF7DC:
- pop {r4,r5}
- pop {r1}
- bx r1
- .pool
- thumb_func_end sub_81BF7A4
-
- thumb_func_start sub_81BF7E8
-sub_81BF7E8: @ 81BF7E8
- push {r4-r6,lr}
- sub sp, 0xC
- adds r6, r0, 0
- movs r0, 0x20
- str r0, [sp]
- str r0, [sp, 0x4]
- movs r0, 0
- movs r1, 0
- movs r2, 0
- movs r3, 0
- bl FillBgTilemapBufferRect_Palette0
- movs r0, 0x1
- movs r1, 0xAA
- bl FillWindowPixelBuffer
- ldr r0, =gUnknown_08618158
- str r0, [sp]
- movs r0, 0x1
- negs r0, r0
- str r0, [sp, 0x4]
- ldr r0, =gUnknown_08618160
- lsls r4, r6, 2
- adds r0, r4, r0
- ldr r0, [r0]
- str r0, [sp, 0x8]
- movs r0, 0x1
- movs r1, 0x1
- movs r2, 0
- movs r3, 0
- bl box_print
- movs r0, 0x1
- bl PutWindowTilemap
- movs r0, 0x1
- movs r1, 0x2
- bl CopyWindowToVram
- cmp r6, 0x5
- bhi _081BF87E
- ldr r0, =_081BF850
- adds r0, r4, r0
- ldr r0, [r0]
- mov pc, r0
- .pool
- .align 2, 0
-_081BF850:
- .4byte _081BF868
- .4byte _081BF870
- .4byte _081BF868
- .4byte _081BF868
- .4byte _081BF868
- .4byte _081BF878
-_081BF868:
- movs r0, 0x2
- bl PutWindowTilemap
- b _081BF87E
-_081BF870:
- movs r0, 0x3
- bl PutWindowTilemap
- b _081BF87E
-_081BF878:
- movs r0, 0
- bl PutWindowTilemap
-_081BF87E:
- movs r0, 0
- bl CopyBgTilemapBufferToVram
- ldr r5, =gUnknown_08618178
- lsls r4, r6, 1
- adds r4, r6
- lsls r4, 2
- adds r0, r4, r5
- ldr r0, [r0]
- ldr r1, =0x06004000
- bl LZ77UnCompVram
- adds r0, r5, 0x4
- adds r0, r4, r0
- ldr r0, [r0]
- ldr r1, =0x0600f800
- bl LZ77UnCompVram
- adds r5, 0x8
- adds r4, r5
- ldr r0, [r4]
- movs r1, 0xA0
- lsls r1, 19
- ldr r2, =0x04000040
- bl CpuSet
- movs r0, 0
- bl ShowBg
- movs r0, 0x1
- bl ShowBg
- add sp, 0xC
- pop {r4-r6}
- pop {r0}
- bx r0
- .pool
- thumb_func_end sub_81BF7E8
-
- thumb_func_start sub_81BF8D8
-sub_81BF8D8: @ 81BF8D8
- push {lr}
- movs r0, 0
- bl HideBg
- movs r0, 0x1
- bl HideBg
- pop {r0}
- bx r0
- thumb_func_end sub_81BF8D8
-
.align 2, 0 @ Don't pad with nop.
diff --git a/asm/title_screen.s b/asm/title_screen.s
index 39247aef4..15037e80d 100644
--- a/asm/title_screen.s
+++ b/asm/title_screen.s
@@ -1259,7 +1259,7 @@ c2_berry_program_update_screen_1: @ 80AAF28
cmp r0, 0
bne _080AAF3E
bl m4aMPlayAllStop
- ldr r0, =sub_81BF384
+ ldr r0, =InitBerryFixProgram
bl SetMainCallback2
_080AAF3E:
pop {r0}
diff --git a/data/data_emerald2.s b/data/data_emerald2.s
index 7efcbbecf..e363e7365 100644
--- a/data/data_emerald2.s
+++ b/data/data_emerald2.s
@@ -2,68 +2,6 @@
.include "constants/constants.inc"
.section .rodata
-
-
-gUnknown_08617274:: @ 8617274
- .incbin "baserom.gba", 0x617274, 0x920
-
-gUnknown_08617B94:: @ 8617B94
- .incbin "baserom.gba", 0x617b94, 0xb0
-
-gUnknown_08617C44:: @ 8617C44
- .incbin "baserom.gba", 0x617c44, 0x120
-
-gUnknown_08617D64:: @ 8617D64
- .incbin "baserom.gba", 0x617d64, 0x30
-
-gUnknown_08617D94:: @ 8617D94
- .incbin "baserom.gba", 0x617d94, 0x10
-
-gUnknown_08617DA4:: @ 8617DA4
- .incbin "baserom.gba", 0x617da4, 0x5c
-
-gUnknown_08617E00:: @ 8617E00
- .incbin "baserom.gba", 0x617e00, 0x18
-
-gUnknown_08617E18:: @ 8617E18
- .incbin "baserom.gba", 0x617e18, 0x1c
-
-gUnknown_08617E34:: @ 8617E34
- .incbin "baserom.gba", 0x617e34, 0x2c
-
-gUnknown_08617E60:: @ 8617E60
- .incbin "baserom.gba", 0x617e60, 0x18
-
-gUnknown_08617E78:: @ 8617E78
- .incbin "baserom.gba", 0x617e78, 0x15
-
-gUnknown_08617E8D:: @ 8617E8D
- .incbin "baserom.gba", 0x617e8d, 0xe
-
-gUnknown_08617E9B:: @ 8617E9B
- .incbin "baserom.gba", 0x617e9b, 0x26d
-
-gUnknown_08618108:: @ 8618108
- .incbin "baserom.gba", 0x618108, 0x8
-
-gUnknown_08618110:: @ 8618110
- .incbin "baserom.gba", 0x618110, 0x28
-
-gUnknown_08618138:: @ 8618138
- .incbin "baserom.gba", 0x618138, 0x20
-
-gUnknown_08618158:: @ 8618158
- .incbin "baserom.gba", 0x618158, 0x3
-
-gUnknown_0861815B:: @ 861815B
- .incbin "baserom.gba", 0x61815b, 0x5
-
-gUnknown_08618160:: @ 8618160
- .incbin "baserom.gba", 0x618160, 0x18
-
-gUnknown_08618178:: @ 8618178
- .incbin "baserom.gba", 0x618178, 0x49
-
@ 86181C1
.include "data/text/move_descriptions.inc"
diff --git a/data/data_emerald2pre1.s b/data/data_emerald2pre1.s
new file mode 100644
index 000000000..f6238dd06
--- /dev/null
+++ b/data/data_emerald2pre1.s
@@ -0,0 +1,35 @@
+ .include "asm/macros.inc"
+ .include "constants/constants.inc"
+
+ .section .rodata
+
+
+gUnknown_08617274:: @ 8617274
+ .incbin "baserom.gba", 0x617274, 0x920
+
+gUnknown_08617B94:: @ 8617B94
+ .incbin "baserom.gba", 0x617b94, 0xb0
+
+gUnknown_08617C44:: @ 8617C44
+ .incbin "baserom.gba", 0x617c44, 0x120
+
+gUnknown_08617D64:: @ 8617D64
+ .incbin "baserom.gba", 0x617d64, 0x30
+
+gUnknown_08617D94:: @ 8617D94
+ .incbin "baserom.gba", 0x617d94, 0x10
+
+gUnknown_08617DA4:: @ 8617DA4
+ .incbin "baserom.gba", 0x617da4, 0x5c
+
+gUnknown_08617E00:: @ 8617E00
+ .incbin "baserom.gba", 0x617e00, 0x18
+
+gUnknown_08617E18:: @ 8617E18
+ .incbin "baserom.gba", 0x617e18, 0x1c
+
+gUnknown_08617E34:: @ 8617E34
+ .incbin "baserom.gba", 0x617e34, 0x2c
+
+gUnknown_08617E60:: @ 8617E60
+ .incbin "baserom.gba", 0x617e60, 0x18
diff --git a/data/graphics.s b/data/graphics.s
index 98365f5e8..d9657a783 100644
--- a/data/graphics.s
+++ b/data/graphics.s
@@ -959,7 +959,7 @@ gUnknown_08DD4BF0:: @ 8DD4BF0
gUnknown_08DD4C4C:: @ 8DD4C4C
.incbin "baserom.gba", 0xdd4c4c, 0xac
-
+
.align 2
gUnknown_08DD4CF8:: @ 8DD4CF8
.incbin "graphics/interface/unk_change_case.4bpp.lz"
@@ -994,7 +994,61 @@ gUnknown_08DD7300:: @ 8DD7300
.incbin "baserom.gba", 0xdd7300, 0x60
gUnknown_08DD7360:: @ 8DD7360
- .incbin "baserom.gba", 0xdd7360, 0x4084
+ .incbin "baserom.gba", 0xdd7360, 0x1420
+
+gUnknown_08DD8780:: @ 8DD8780
+ .incbin "baserom.gba", 0xdd8780, 0x40
+
+gUnknown_08DD87C0:: @ 8DD87C0
+ .incbin "baserom.gba", 0xdd87c0, 0x720
+
+gUnknown_08DD8EE0:: @ 8DD8EE0
+ .incbin "baserom.gba", 0xdd8ee0, 0x1a0
+
+gUnknown_08DD9080:: @ 8DD9080
+ .incbin "baserom.gba", 0xdd9080, 0x60
+
+gUnknown_08DD90E0:: @ 8DD90E0
+ .incbin "baserom.gba", 0xdd90e0, 0x638
+
+gUnknown_08DD9718:: @ 8DD9718
+ .incbin "baserom.gba", 0xdd9718, 0x15c
+
+gUnknown_08DD9874:: @ 8DD9874
+ .incbin "baserom.gba", 0xdd9874, 0x40
+
+gUnknown_08DD98B4:: @ 8DD98B4
+ .incbin "baserom.gba", 0xdd98b4, 0x5a4
+
+gUnknown_08DD9E58:: @ 8DD9E58
+ .incbin "baserom.gba", 0xdd9e58, 0x194
+
+gUnknown_08DD9FEC:: @ 8DD9FEC
+ .incbin "baserom.gba", 0xdd9fec, 0x40
+
+gUnknown_08DDA02C:: @ 8DDA02C
+ .incbin "baserom.gba", 0xdda02c, 0x610
+
+gUnknown_08DDA63C:: @ 8DDA63C
+ .incbin "baserom.gba", 0xdda63c, 0x1c4
+
+gUnknown_08DDA800:: @ 8DDA800
+ .incbin "baserom.gba", 0xdda800, 0x40
+
+gUnknown_08DDA840:: @ 8DDA840
+ .incbin "baserom.gba", 0xdda840, 0x600
+
+gUnknown_08DDAE40:: @ 8DDAE40
+ .incbin "baserom.gba", 0xddae40, 0x1a0
+
+gUnknown_08DDAFE0:: @ 8DDAFE0
+ .incbin "baserom.gba", 0xddafe0, 0x40
+
+gUnknown_08DDB020:: @ 8DDB020
+ .incbin "baserom.gba", 0xddb020, 0x2a4
+
+gUnknown_08DDB2C4:: @ 8DDB2C4
+ .incbin "baserom.gba", 0xddb2c4, 0x120
gUnknown_08DDB3E4:: @ 8DDB3E4
.incbin "baserom.gba", 0xddb3e4, 0x80
diff --git a/data/text/move_descriptions.inc b/data/text/move_descriptions.inc
index 454e49ae1..0f6b1adbf 100644
--- a/data/text/move_descriptions.inc
+++ b/data/text/move_descriptions.inc
@@ -1,3 +1,6 @@
+gNullMoveDescription:: @ 86181C0
+ .string "$"
+
gPoundMoveDescription:: @ 86181C1
.string "Pounds the foe with\nforelegs or tail.$"
diff --git a/include/bg.h b/include/bg.h
new file mode 100644
index 000000000..444d3f3c2
--- /dev/null
+++ b/include/bg.h
@@ -0,0 +1,23 @@
+#ifndef GUARD_bg_H
+#define GUARD_bg_H
+
+struct BgTemplate {
+ u32 bg:2;
+ u32 charBaseIndex:2;
+ u32 mapBaseIndex:5;
+ u32 screenSize:2;
+ u32 paletteMode:1;
+ u32 priority:2;
+ u32 baseTile:10;
+};
+
+void ResetBgsAndClearDma3BusyFlags(u32);
+void InitBgsFromTemplates(u8, const struct BgTemplate *, u8);
+u32 ChangeBgX(u8, u32, u8);
+u32 ChangeBgY(u8, u32, u8);
+void FillBgTilemapBufferRect_Palette0(u8 bg, u16 tileNum, u8 x, u8 y, u8 width, u8 height);
+void ShowBg(u8);
+void HideBg(u8);
+void CopyBgTilemapBufferToVram(u8);
+
+#endif //GUARD_bg_H
diff --git a/include/gba/multiboot.h b/include/gba/multiboot.h
index e88b43a19..14b6594b2 100644
--- a/include/gba/multiboot.h
+++ b/include/gba/multiboot.h
@@ -8,19 +8,19 @@
struct MultiBootParam
{
- u32 system_work[5];
- u8 handshake_data;
- u8 padding;
- u16 handshake_timeout;
- u8 probe_count;
- u8 client_data[MULTIBOOT_NCHILD];
- u8 palette_data;
- u8 response_bit;
- u8 client_bit;
- u8 reserved1;
- u8 *boot_srcp;
- u8 *boot_endp;
- u8 *masterp;
+ u32 system_work[5]; // 00
+ u8 handshake_data; // 14
+ u8 padding; // 15
+ u16 handshake_timeout; // 16
+ u8 probe_count; // 18
+ u8 client_data[MULTIBOOT_NCHILD]; // 19
+ u8 palette_data; // 1c
+ u8 response_bit; // 1d
+ u8 client_bit; // 1e
+ u8 reserved1; // 1f
+ const u8 *boot_srcp; // 20
+ const u8 *boot_endp; // 24
+ const u8 *masterp;
u8 *reserved2[MULTIBOOT_NCHILD];
u32 system_work2[4];
u8 sendflag;
diff --git a/include/gpu_regs.h b/include/gpu_regs.h
index 28b97fb6e..1039b618f 100644
--- a/include/gpu_regs.h
+++ b/include/gpu_regs.h
@@ -1,6 +1,3 @@
-//
-// Created by scott on 9/15/2017.
-//
#ifndef GUARD_GPU_REGS_H
#define GUARD_GPU_REGS_H
@@ -10,6 +7,9 @@
// Exported RAM declarations
// Exported ROM declarations
+void DisableInterrupts(u16);
+void EnableInterrupts(u16);
+void SetGpuReg(u8, u16);
void ClearGpuRegBits(u8 regOffset, u16 mask);
#endif //GUARD_GPU_REGS_H
diff --git a/include/menu.h b/include/menu.h
index c8aafcb30..9a23401e0 100644
--- a/include/menu.h
+++ b/include/menu.h
@@ -15,4 +15,6 @@ struct MenuAction2
void (*func)(u8);
};
+void box_print(u8, u8, u8, u8, const void *, s8, const u8 *);
+
#endif // GUARD_MENU_H
diff --git a/include/multiboot.h b/include/multiboot.h
index 950c853d0..d4700ff4e 100644
--- a/include/multiboot.h
+++ b/include/multiboot.h
@@ -15,7 +15,7 @@
void MultiBootInit(struct MultiBootParam *mp);
int MultiBootMain(struct MultiBootParam *mp);
void MultiBootStartProbe(struct MultiBootParam *mp);
-void MultiBootStartMaster(struct MultiBootParam *mp, u8 *srcp, int length, u8 palette_color, s8 palette_speed);
+void MultiBootStartMaster(struct MultiBootParam *mp, const u8 *srcp, int length, u8 palette_color, s8 palette_speed);
int MultiBootCheckComplete(struct MultiBootParam *mp);
#endif // GUARD_MULTIBOOT_H
diff --git a/include/text.h b/include/text.h
index 73e6e5437..c61f6cc98 100644
--- a/include/text.h
+++ b/include/text.h
@@ -186,9 +186,9 @@ bool8 TextPrinterWaitWithDownArrow(struct TextPrinter *textPrinter);
bool8 TextPrinterWait(struct TextPrinter *textPrinter);
void DrawDownArrow(u8 windowId, u16 x, u16 y, u8 bgColor, bool8 drawArrow, u8 *counter, u8 *yCoordIndex);
u16 RenderText(struct TextPrinter *textPrinter);
-u32 GetStringWidthFixedWidthFont(u8 *str, u8 fontId, u8 letterSpacing);
+u32 GetStringWidthFixedWidthFont(const u8 *str, u8 fontId, u8 letterSpacing);
u32 (*GetFontWidthFunc(u8 glyphId))(u16, bool32);
-s32 GetStringWidth(u8 fontId, u8 *str, s16 letterSpacing);
+u32 GetStringWidth(u8 fontId, const u8 *str, s16 letterSpacing);
u8 RenderTextFont9(u8 *pixels, u8 fontId, u8 *str);
u8 DrawKeypadIcon(u8 windowId, u8 keypadIconId, u16 x, u16 y);
u8 GetKeypadIconTileOffset(u8 keypadIconId);
diff --git a/include/unknown_task.h b/include/unknown_task.h
new file mode 100644
index 000000000..f59ca9ac3
--- /dev/null
+++ b/include/unknown_task.h
@@ -0,0 +1,11 @@
+#ifndef GUARD_unknown_task_H
+#define GUARD_unknown_task_H
+
+// Exported type declarations
+
+// Exported RAM declarations
+
+// Exported ROM declarations
+void remove_some_task(void);
+
+#endif //GUARD_unknown_task_H
diff --git a/include/window.h b/include/window.h
index 36a71a1e0..20e5fefa3 100644
--- a/include/window.h
+++ b/include/window.h
@@ -30,7 +30,7 @@ struct Window
u8 *tileData;
};
-bool16 InitWindows(struct WindowTemplate *templates);
+bool16 InitWindows(const struct WindowTemplate *templates);
u16 AddWindow(const struct WindowTemplate *template);
int AddWindowWithoutTileMap(struct WindowTemplate *template);
void RemoveWindow(u8 windowId);
diff --git a/ld_script.txt b/ld_script.txt
index 392946e70..177f36888 100644
--- a/ld_script.txt
+++ b/ld_script.txt
@@ -259,7 +259,7 @@ SECTIONS {
asm/battle_controller_player_partner.o(.text);
asm/fldeff_groundshake.o(.text);
asm/fossil_specials.o(.text);
- asm/berry_fix_program.o(.text);
+ src/berry_fix_program.o(.text);
asm/pokemon_summary_screen.o(.text);
asm/pokenav.o(.text);
asm/rayquaza_scene.o(.text);
@@ -382,6 +382,8 @@ SECTIONS {
src/lilycove_lady.o(.rodata);
data/data_emerald.o(.rodata);
data/battle_controller_player_partner.o(.rodata);
+ data/data_emerald2pre1.o(.rodata);
+ src/berry_fix_program.o(.rodata);
data/data_emerald2.o(.rodata);
data/fonts.o(.rodata);
data/mystery_event_msg.o(.rodata);
diff --git a/src/berry_fix_program.c b/src/berry_fix_program.c
new file mode 100644
index 000000000..f04308ae8
--- /dev/null
+++ b/src/berry_fix_program.c
@@ -0,0 +1,531 @@
+
+// Includes
+#include "global.h"
+#include "gpu_regs.h"
+#include "multiboot.h"
+#include "malloc.h"
+#include "bg.h"
+#include "main.h"
+#include "sprite.h"
+#include "task.h"
+#include "unknown_task.h"
+#include "window.h"
+#include "menu.h"
+#include "m4a.h"
+
+// Static type declarations
+
+typedef struct {
+ u8 state;
+ u8 unk1;
+ u16 unk2;
+ struct MultiBootParam mb;
+} berryfix_t;
+
+// Static RAM declarations
+
+static berryfix_t *berry_fix_mb_manager;
+
+// Static ROM declarations
+
+static void berry_fix_main(void);
+static void berry_fix_gpu_set(void);
+static int berry_fix_text_update(int);
+static void berry_fix_text_print(int);
+static void berry_fix_bg_hide(void);
+
+// .rodata
+
+static const u8 gUnknown_08617E78[] = _("Berry Program Update");
+static const u8 gUnknown_08617E8D[] = _("Ruby/Sapphire");
+static const u8 gUnknown_08617E9B[] = _("Emerald");
+
+static const u8 Unknown_08617EA3[] = _("The Berry Program on your POKéMON\nRuby/Sapphire Game Pak will be updated.\n{COLOR RED}{SHADOW LIGHT_RED}Press the A Button.");
+static const u8 Unknown_08617F07[] = _("Please ensure the connection of your\nGame Boy Advance system matches this.\n{COLOR RED}{SHADOW LIGHT_RED}YES: Press the A Button.\nNO: Turn off the power and try again.");
+static const u8 Unknown_08617F97[] = _("Please turn on the power of POKéMON\nRuby/Sapphire while holding START and\nSELECT simultaneously. Then, ensure\nthe picture above appears.");
+static const u8 Unknown_08618020[] = _("Transmitting. Please wait.\n{COLOR RED}{SHADOW LIGHT_RED}Please do not turn off the power or\nunplug the Game Boy Advance Game\nLink Cable.");
+static const u8 Unknown_08618092[] = _("Please follow the instructions on your\nPOKéMON Ruby/Sapphire screen.");
+static const u8 Unknown_086180D7[] = _("Transmission failure.\n{COLOR RED}{SHADOW LIGHT_RED}Please try again.");
+
+static const struct BgTemplate gUnknown_08618108[] = {
+ {
+ 0, 0, 30, 0, 0, 0
+ }, {
+ 1, 1, 31, 0, 0, 1
+ }
+};
+
+static const struct WindowTemplate gUnknown_08618110[] = {
+ {0, 2, 4, 26, 2, 15, 0x001},
+ {0, 1, 11, 28, 8, 15, 0x035},
+ {0, 0, 8, 30, 2, 15, 0x115},
+ {0, 8, 0, 14, 2, 15, 0x151},
+ {-1}
+};
+
+static const u16 gUnknown_08618138[] = {
+ 0x7fff, 0x7fff, 0x318c, 0x675a,
+ 0x043c, 0x3aff, 0x0664, 0x4bd2,
+ 0x6546, 0x7b14, 0x7fff, 0x318c,
+ 0x675a, 0x0000, 0x0000, 0x0000
+};
+
+static const u8 gUnknown_08618158[] = {10, 11, 12};
+static const u8 gUnknown_0861815B[] = { 0, 10, 13};
+
+static const u8 *const gUnknown_08618160[] = {
+ Unknown_08617F07,
+ Unknown_08617F97,
+ Unknown_08618020,
+ Unknown_08618092,
+ Unknown_086180D7,
+ Unknown_08617EA3
+};
+
+extern const u8 gUnknown_08DD87C0[];
+extern const u8 gUnknown_08DD8EE0[];
+extern const u8 gUnknown_08DD8780[];
+extern const u8 gUnknown_08DD90E0[];
+extern const u8 gUnknown_08DD9718[];
+extern const u8 gUnknown_08DD9080[];
+extern const u8 gUnknown_08DD98B4[];
+extern const u8 gUnknown_08DD9E58[];
+extern const u8 gUnknown_08DD9874[];
+extern const u8 gUnknown_08DDA02C[];
+extern const u8 gUnknown_08DDA63C[];
+extern const u8 gUnknown_08DD9FEC[];
+extern const u8 gUnknown_08DDA840[];
+extern const u8 gUnknown_08DDAE40[];
+extern const u8 gUnknown_08DDA800[];
+extern const u8 gUnknown_08DDB020[];
+extern const u8 gUnknown_08DDB2C4[];
+extern const u8 gUnknown_08DDAFE0[];
+
+static const u8 *const gUnknown_08618178[][3] = {
+ {
+ gUnknown_08DD87C0,
+ gUnknown_08DD8EE0,
+ gUnknown_08DD8780
+ }, {
+ gUnknown_08DD90E0,
+ gUnknown_08DD9718,
+ gUnknown_08DD9080
+ }, {
+ gUnknown_08DD98B4,
+ gUnknown_08DD9E58,
+ gUnknown_08DD9874
+ }, {
+ gUnknown_08DDA02C,
+ gUnknown_08DDA63C,
+ gUnknown_08DD9FEC
+ }, {
+ gUnknown_08DDA840,
+ gUnknown_08DDAE40,
+ gUnknown_08DDA800
+ }, {
+ gUnknown_08DDB020,
+ gUnknown_08DDB2C4,
+ gUnknown_08DDAFE0
+ },
+};
+
+extern const u8 gUnknown_089A6550[0xC0];
+extern const u8 gMultiBootProgram_BerryGlitchFix_Start[0x3b34];
+extern const u8 gMultiBootProgram_BerryGlitchFix_End[];
+
+// .text
+
+void InitBerryFixProgram(void)
+{
+ DisableInterrupts(0xFFFF);
+ EnableInterrupts(0x0001);
+ m4aSoundVSyncOff();
+ SetVBlankCallback(NULL);
+ ResetSpriteData();
+ ResetTasks();
+ remove_some_task();
+ SetGpuReg(REG_OFFSET_DISPCNT, 0x0000);
+ berry_fix_mb_manager = AllocZeroed(0x50);
+ berry_fix_mb_manager->state = 0;
+ berry_fix_mb_manager->unk1 = 6;
+ SetMainCallback2(berry_fix_main);
+}
+
+static void berry_fix_main(void)
+{
+ switch (berry_fix_mb_manager->state)
+ {
+ case 0:
+ berry_fix_gpu_set();
+ berry_fix_mb_manager->state = 1;
+ break;
+ case 1:
+ if (berry_fix_text_update(5) == 5 && (gMain.newKeys & A_BUTTON))
+ {
+ berry_fix_mb_manager->state = 2;
+ }
+ break;
+ case 2:
+ if (berry_fix_text_update(0) == 0 && (gMain.newKeys & A_BUTTON))
+ {
+ berry_fix_mb_manager->state = 3;
+ }
+ break;
+ case 3:
+ if (berry_fix_text_update(1) == 1)
+ {
+ berry_fix_mb_manager->mb.masterp = gUnknown_089A6550;
+ berry_fix_mb_manager->mb.server_type = 0;
+ MultiBootInit(&berry_fix_mb_manager->mb);
+ berry_fix_mb_manager->unk2 = 0;
+ berry_fix_mb_manager->state = 4;
+ }
+ break;
+ case 4:
+ MultiBootMain(&berry_fix_mb_manager->mb);
+ if (berry_fix_mb_manager->mb.probe_count != 0 || (!(berry_fix_mb_manager->mb.response_bit & 2) || !(berry_fix_mb_manager->mb.client_bit & 2)))
+ {
+ berry_fix_mb_manager->unk2 = 0;
+ }
+ else if (++ berry_fix_mb_manager->unk2 > 180)
+ {
+ MultiBootStartMaster(&berry_fix_mb_manager->mb, gMultiBootProgram_BerryGlitchFix_Start, (u32)(gMultiBootProgram_BerryGlitchFix_End - gMultiBootProgram_BerryGlitchFix_Start), 4, 1);
+ berry_fix_mb_manager->state = 5;
+ }
+ break;
+ case 5:
+ if (berry_fix_text_update(2) == 2) {
+ MultiBootMain(&berry_fix_mb_manager->mb);
+ if (MultiBootCheckComplete(&berry_fix_mb_manager->mb)) {
+ berry_fix_mb_manager->state = 6;
+ }
+ else if (!(berry_fix_mb_manager->mb.client_bit & 2)) {
+ berry_fix_mb_manager->state = 7;
+ }
+ }
+ break;
+ case 6:
+ if (berry_fix_text_update(3) == 3 && gMain.newKeys & A_BUTTON)
+ {
+ DoSoftReset();
+ }
+ break;
+ case 7:
+ if (berry_fix_text_update(4) == 4 && gMain.newKeys & A_BUTTON)
+ {
+ berry_fix_mb_manager->state = 1;
+ }
+ break;
+ }
+}
+
+#ifdef NONMATCHING
+static void berry_fix_gpu_set(void)
+{
+ s32 width;
+
+ SetGpuReg(REG_OFFSET_BG0CNT, 0x0000);
+ SetGpuReg(REG_OFFSET_BG1CNT, 0x0000);
+ SetGpuReg(REG_OFFSET_BG0HOFS, 0x0000);
+ SetGpuReg(REG_OFFSET_BG0VOFS, 0x0000);
+ SetGpuReg(REG_OFFSET_BG1HOFS, 0x0000);
+ SetGpuReg(REG_OFFSET_BG1VOFS, 0x0000);
+ SetGpuReg(REG_OFFSET_BLDCNT, 0x0000);
+
+ DmaFill32(3, 0, VRAM, VRAM_SIZE);
+ DmaFill32(3, 0, OAM, OAM_SIZE);
+ DmaFill32(3, 0, PLTT, PLTT_SIZE);
+ ResetBgsAndClearDma3BusyFlags(0);
+
+ InitBgsFromTemplates(0, gUnknown_08618108, ARRAY_COUNT(gUnknown_08618108));
+ ChangeBgX(0, 0, 0);
+ ChangeBgY(0, 0, 0);
+ ChangeBgX(1, 0, 0);
+ ChangeBgY(1, 0, 0);
+ InitWindows(gUnknown_08618110);
+ DeactivateAllTextPrinters();
+
+ DmaCopy32(3, gUnknown_08618138, BG_PLTT + 0x1E0, 0x20);
+ SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_OBJ_1D_MAP);
+ FillWindowPixelBuffer(2, 0);
+ FillWindowPixelBuffer(3, 0);
+ FillWindowPixelBuffer(0, 0xAA);
+
+// This block is a meme among memes
+ width = (0x78 - GetStringWidth(0, gUnknown_08617E9B, 0)) / 2;
+ box_print(2, 0, width, 3, gUnknown_0861815B, -1, gUnknown_08617E9B);
+ width = (s32)(0x78 - GetStringWidth(0, gUnknown_08617E9B, 0)) / 2 + 0x78;
+ box_print(2, 0, width, 3, gUnknown_0861815B, -1, gUnknown_08617E8D);
+ width = (0x70 - GetStringWidth(0, gUnknown_08617E8D, 0)) / 2;
+ box_print(3, 0, width, 0, gUnknown_0861815B, -1, gUnknown_08617E8D);
+ width = (0xd0 - GetStringWidth(1, gUnknown_08617E78, 0)) / 2;
+ box_print(0, 1, width, 2, gUnknown_08618158, -1, gUnknown_08617E78);
+
+ CopyWindowToVram(2, 2);
+ CopyWindowToVram(3, 2);
+ CopyWindowToVram(0, 2);
+}
+
+#else
+__attribute__((naked)) static void berry_fix_gpu_set(void)
+{
+ asm(".syntax unified\n"
+ "\tpush {r4-r6,lr}\n"
+ "\tmov r6, r8\n"
+ "\tpush {r6}\n"
+ "\tsub sp, 0x10\n"
+ "\tmovs r0, 0x8\n"
+ "\tmovs r1, 0\n"
+ "\tbl SetGpuReg\n"
+ "\tmovs r0, 0xA\n"
+ "\tmovs r1, 0\n"
+ "\tbl SetGpuReg\n"
+ "\tmovs r0, 0x10\n"
+ "\tmovs r1, 0\n"
+ "\tbl SetGpuReg\n"
+ "\tmovs r0, 0x12\n"
+ "\tmovs r1, 0\n"
+ "\tbl SetGpuReg\n"
+ "\tmovs r0, 0x14\n"
+ "\tmovs r1, 0\n"
+ "\tbl SetGpuReg\n"
+ "\tmovs r0, 0x16\n"
+ "\tmovs r1, 0\n"
+ "\tbl SetGpuReg\n"
+ "\tmovs r0, 0x50\n"
+ "\tmovs r1, 0\n"
+ "\tbl SetGpuReg\n"
+ "\tmovs r1, 0\n"
+ "\tstr r1, [sp, 0xC]\n"
+ "\tldr r4, =0x040000d4\n"
+ "\tadd r0, sp, 0xC\n"
+ "\tstr r0, [r4]\n"
+ "\tmovs r0, 0xC0\n"
+ "\tlsls r0, 19\n"
+ "\tstr r0, [r4, 0x4]\n"
+ "\tldr r0, =0x85006000\n"
+ "\tstr r0, [r4, 0x8]\n"
+ "\tldr r0, [r4, 0x8]\n"
+ "\tstr r1, [sp, 0xC]\n"
+ "\tadd r0, sp, 0xC\n"
+ "\tstr r0, [r4]\n"
+ "\tmovs r0, 0xE0\n"
+ "\tlsls r0, 19\n"
+ "\tstr r0, [r4, 0x4]\n"
+ "\tldr r2, =0x85000100\n"
+ "\tstr r2, [r4, 0x8]\n"
+ "\tldr r0, [r4, 0x8]\n"
+ "\tstr r1, [sp, 0xC]\n"
+ "\tadd r0, sp, 0xC\n"
+ "\tstr r0, [r4]\n"
+ "\tmovs r0, 0xA0\n"
+ "\tlsls r0, 19\n"
+ "\tstr r0, [r4, 0x4]\n"
+ "\tstr r2, [r4, 0x8]\n"
+ "\tldr r0, [r4, 0x8]\n"
+ "\tmovs r0, 0\n"
+ "\tbl ResetBgsAndClearDma3BusyFlags\n"
+ "\tldr r1, =gUnknown_08618108\n"
+ "\tmovs r0, 0\n"
+ "\tmovs r2, 0x2\n"
+ "\tbl InitBgsFromTemplates\n"
+ "\tmovs r0, 0\n"
+ "\tmovs r1, 0\n"
+ "\tmovs r2, 0\n"
+ "\tbl ChangeBgX\n"
+ "\tmovs r0, 0\n"
+ "\tmovs r1, 0\n"
+ "\tmovs r2, 0\n"
+ "\tbl ChangeBgY\n"
+ "\tmovs r0, 0x1\n"
+ "\tmovs r1, 0\n"
+ "\tmovs r2, 0\n"
+ "\tbl ChangeBgX\n"
+ "\tmovs r0, 0x1\n"
+ "\tmovs r1, 0\n"
+ "\tmovs r2, 0\n"
+ "\tbl ChangeBgY\n"
+ "\tldr r0, =gUnknown_08618110\n"
+ "\tbl InitWindows\n"
+ "\tbl DeactivateAllTextPrinters\n"
+ "\tldr r0, =gUnknown_08618138\n"
+ "\tstr r0, [r4]\n"
+ "\tldr r0, =0x050001e0\n"
+ "\tstr r0, [r4, 0x4]\n"
+ "\tldr r0, =0x84000008\n"
+ "\tstr r0, [r4, 0x8]\n"
+ "\tldr r0, [r4, 0x8]\n"
+ "\tmovs r0, 0\n"
+ "\tmovs r1, 0x40\n"
+ "\tbl SetGpuReg\n"
+ "\tmovs r0, 0x2\n"
+ "\tmovs r1, 0\n"
+ "\tbl FillWindowPixelBuffer\n"
+ "\tmovs r0, 0x3\n"
+ "\tmovs r1, 0\n"
+ "\tbl FillWindowPixelBuffer\n"
+ "\tmovs r0, 0\n"
+ "\tmovs r1, 0xAA\n"
+ "\tbl FillWindowPixelBuffer\n"
+ "\tldr r5, =gUnknown_08617E9B\n"
+ "\tmovs r0, 0\n"
+ "\tadds r1, r5, 0\n"
+ "\tmovs r2, 0\n"
+ "\tbl GetStringWidth\n"
+ "\tadds r1, r0, 0\n"
+ "\tmovs r4, 0x78\n"
+ "\tsubs r0, r4, r1\n"
+ "\tlsrs r1, r0, 31\n"
+ "\tadds r0, r1\n"
+ "\tasrs r0, 1\n"
+ "\tlsls r2, r0, 24\n"
+ "\tlsrs r2, 24\n"
+ "\tldr r6, =gUnknown_0861815B\n"
+ "\tstr r6, [sp]\n"
+ "\tmovs r0, 0x1\n"
+ "\tnegs r0, r0\n"
+ "\tmov r8, r0\n"
+ "\tstr r0, [sp, 0x4]\n"
+ "\tstr r5, [sp, 0x8]\n"
+ "\tmovs r0, 0x2\n"
+ "\tmovs r1, 0\n"
+ "\tmovs r3, 0x3\n"
+ "\tbl box_print\n"
+ "\tldr r5, =gUnknown_08617E8D\n"
+ "\tmovs r0, 0\n"
+ "\tadds r1, r5, 0\n"
+ "\tmovs r2, 0\n"
+ "\tbl GetStringWidth\n"
+ "\tadds r1, r0, 0\n"
+ "\tsubs r4, r1\n"
+ "\tlsrs r0, r4, 31\n"
+ "\tadds r4, r0\n"
+ "\tasrs r4, 1\n"
+ "\tadds r0, r4, 0\n"
+ "\tadds r0, 0x78\n"
+ "\tlsls r2, r0, 24\n"
+ "\tlsrs r2, 24\n"
+ "\tstr r6, [sp]\n"
+ "\tmov r0, r8\n"
+ "\tstr r0, [sp, 0x4]\n"
+ "\tstr r5, [sp, 0x8]\n"
+ "\tmovs r0, 0x2\n"
+ "\tmovs r1, 0\n"
+ "\tmovs r3, 0x3\n"
+ "\tbl box_print\n"
+ "\tmovs r0, 0\n"
+ "\tadds r1, r5, 0\n"
+ "\tmovs r2, 0\n"
+ "\tbl GetStringWidth\n"
+ "\tadds r1, r0, 0\n"
+ "\tmovs r0, 0x70\n"
+ "\tsubs r0, r1\n"
+ "\tlsrs r1, r0, 31\n"
+ "\tadds r0, r1\n"
+ "\tasrs r0, 1\n"
+ "\tlsls r2, r0, 24\n"
+ "\tlsrs r2, 24\n"
+ "\tstr r6, [sp]\n"
+ "\tmov r0, r8\n"
+ "\tstr r0, [sp, 0x4]\n"
+ "\tstr r5, [sp, 0x8]\n"
+ "\tmovs r0, 0x3\n"
+ "\tmovs r1, 0\n"
+ "\tmovs r3, 0\n"
+ "\tbl box_print\n"
+ "\tldr r4, =gUnknown_08617E78\n"
+ "\tmovs r0, 0x1\n"
+ "\tadds r1, r4, 0\n"
+ "\tmovs r2, 0\n"
+ "\tbl GetStringWidth\n"
+ "\tadds r1, r0, 0\n"
+ "\tmovs r0, 0xD0\n"
+ "\tsubs r0, r1\n"
+ "\tlsrs r1, r0, 31\n"
+ "\tadds r0, r1\n"
+ "\tasrs r0, 1\n"
+ "\tlsls r2, r0, 24\n"
+ "\tlsrs r2, 24\n"
+ "\tldr r0, =gUnknown_08618158\n"
+ "\tstr r0, [sp]\n"
+ "\tmov r0, r8\n"
+ "\tstr r0, [sp, 0x4]\n"
+ "\tstr r4, [sp, 0x8]\n"
+ "\tmovs r0, 0\n"
+ "\tmovs r1, 0x1\n"
+ "\tmovs r3, 0x2\n"
+ "\tbl box_print\n"
+ "\tmovs r0, 0x2\n"
+ "\tmovs r1, 0x2\n"
+ "\tbl CopyWindowToVram\n"
+ "\tmovs r0, 0x3\n"
+ "\tmovs r1, 0x2\n"
+ "\tbl CopyWindowToVram\n"
+ "\tmovs r0, 0\n"
+ "\tmovs r1, 0x2\n"
+ "\tbl CopyWindowToVram\n"
+ "\tadd sp, 0x10\n"
+ "\tpop {r3}\n"
+ "\tmov r8, r3\n"
+ "\tpop {r4-r6}\n"
+ "\tpop {r0}\n"
+ "\tbx r0\n"
+ "\t.pool\n"
+ ".syntax divided");
+}
+#endif
+
+static int berry_fix_text_update(int checkval)
+{
+ if (berry_fix_mb_manager->unk1 == checkval)
+ {
+ return checkval;
+ }
+ if (berry_fix_mb_manager->unk1 == 6)
+ {
+ berry_fix_text_print(checkval);
+ berry_fix_mb_manager->unk1 = checkval;
+ }
+ else
+ {
+ berry_fix_bg_hide();
+ berry_fix_mb_manager->unk1 = 6;
+ }
+ return berry_fix_mb_manager->unk1;
+}
+
+static void berry_fix_text_print(int scene)
+{
+ FillBgTilemapBufferRect_Palette0(0, 0, 0, 0, 32, 32);
+ FillWindowPixelBuffer(1, 0xAA);
+ box_print(1, 1, 0, 0, gUnknown_08618158, -1, gUnknown_08618160[scene]);
+ PutWindowTilemap(1);
+ CopyWindowToVram(1, 2);
+ switch (scene)
+ {
+ case 0:
+ case 2:
+ case 3:
+ case 4:
+ PutWindowTilemap(2);
+ break;
+ case 1:
+ PutWindowTilemap(3);
+ break;
+ case 5:
+ PutWindowTilemap(0);
+ break;
+ }
+ CopyBgTilemapBufferToVram(0);
+ LZ77UnCompVram(gUnknown_08618178[scene][0], (void *)BG_CHAR_ADDR(1));
+ LZ77UnCompVram(gUnknown_08618178[scene][1], (void *)BG_SCREEN_ADDR(31));
+ CpuCopy32(gUnknown_08618178[scene][2], (void *)BG_PLTT, 0x100);
+ ShowBg(0);
+ ShowBg(1);
+}
+
+static void berry_fix_bg_hide()
+{
+ HideBg(0);
+ HideBg(1);
+}
diff --git a/src/bg.c b/src/bg.c
index 8979eaecd..390a99d50 100644
--- a/src/bg.c
+++ b/src/bg.c
@@ -1,5 +1,6 @@
#include "global.h"
#include "dma3.h"
+#include "bg.h"
#define DISPCNT_ALL_BG_AND_MODE_BITS 0x0F07
@@ -22,33 +23,23 @@ struct BgControl {
u16 priority:2;
u16 mosaic:1;
u16 wraparound:1;
-
+
u16 charBaseIndex:2;
u16 mapBaseIndex:5;
u16 paletteMode:1;
-
+
u8 unknown_2;
u8 unknown_3;
} configs[4];
-
- u16 bgVisibilityAndMode;
-};
-struct BgTemplate {
- u32 bg:2;
- u32 charBaseIndex:2;
- u32 mapBaseIndex:5;
- u32 screenSize:2;
- u32 paletteMode:1;
- u32 priority:2;
- u32 baseTile:10;
+ u16 bgVisibilityAndMode;
};
struct BgConfig2 {
u32 baseTile:10;
u32 basePalette:4;
u32 unk_3:18;
-
+
void* tilemap;
u32 bg_x;
u32 bg_y;
@@ -103,7 +94,7 @@ void ResetBgControlStructs(void)
struct BgConfig* bgConfigs = &gGpuBgConfigs.configs[0];
struct BgConfig zeroedConfig = gZeroedBgControlStruct;
int i;
-
+
for (i = 0; i < 4; i++)
{
bgConfigs[i] = zeroedConfig;
@@ -126,40 +117,40 @@ void SetBgControlAttributes(u8 bg, u8 charBaseIndex, u8 mapBaseIndex, u8 screenS
{
gGpuBgConfigs.configs[bg].charBaseIndex = charBaseIndex & 0x3;
}
-
+
if (mapBaseIndex != 0xFF)
{
gGpuBgConfigs.configs[bg].mapBaseIndex = mapBaseIndex & 0x1F;
}
-
+
if (screenSize != 0xFF)
{
gGpuBgConfigs.configs[bg].screenSize = screenSize & 0x3;
}
-
+
if (paletteMode != 0xFF)
{
gGpuBgConfigs.configs[bg].paletteMode = paletteMode;
}
-
+
if (priority != 0xFF)
{
gGpuBgConfigs.configs[bg].priority = priority & 0x3;
}
-
+
if (mosaic != 0xFF)
{
gGpuBgConfigs.configs[bg].mosaic = mosaic & 0x1;
}
-
+
if (wraparound != 0xFF)
{
gGpuBgConfigs.configs[bg].wraparound = wraparound;
}
-
+
gGpuBgConfigs.configs[bg].unknown_2 = 0;
gGpuBgConfigs.configs[bg].unknown_3 = 0;
-
+
gGpuBgConfigs.configs[bg].visible = 1;
}
}
@@ -188,7 +179,7 @@ u16 GetBgControlAttribute(u8 bg, u8 attributeId)
return gGpuBgConfigs.configs[bg].wraparound;
}
}
-
+
return 0xFF;
}
@@ -196,7 +187,7 @@ u8 LoadBgVram(u8 bg, void *src, u16 size, u16 destOffset, u8 mode)
{
u16 offset;
s8 cursor;
-
+
if (IsInvalidBg(bg) == FALSE && gGpuBgConfigs.configs[bg].visible != FALSE)
{
switch (mode)
@@ -211,11 +202,11 @@ u8 LoadBgVram(u8 bg, void *src, u16 size, u16 destOffset, u8 mode)
cursor = -1;
goto end;
}
-
+
offset = destOffset + offset;
-
+
cursor = RequestDma3Copy(src, (void*)(offset + BG_VRAM), size, 0);
-
+
if (cursor == -1)
{
return -1;
@@ -225,7 +216,7 @@ u8 LoadBgVram(u8 bg, void *src, u16 size, u16 destOffset, u8 mode)
{
return -1;
}
-
+
end:
return cursor;
}
@@ -242,9 +233,9 @@ void ShowBgInternal(u8 bg)
(gGpuBgConfigs.configs[bg].mapBaseIndex << 8) |
(gGpuBgConfigs.configs[bg].wraparound << 13) |
(gGpuBgConfigs.configs[bg].screenSize << 14);
-
+
SetGpuReg((bg << 1) + 0x8, value);
-
+
gGpuBgConfigs.bgVisibilityAndMode |= 1 << (bg + 8);
gGpuBgConfigs.bgVisibilityAndMode &= DISPCNT_ALL_BG_AND_MODE_BITS;
}
@@ -273,7 +264,7 @@ void SetBgAffineInternal(u8 bg, u32 srcCenterX, u32 srcCenterY, s16 dispCenterX,
{
struct BgAffineSrcData src;
struct BgAffineDstData dest;
-
+
switch (gGpuBgConfigs.bgVisibilityAndMode & 0x7)
{
case 1:
@@ -288,7 +279,7 @@ void SetBgAffineInternal(u8 bg, u32 srcCenterX, u32 srcCenterY, s16 dispCenterX,
default:
return;
}
-
+
src.texX = srcCenterX;
src.texY = srcCenterY;
src.scrX = dispCenterX;
@@ -296,7 +287,7 @@ void SetBgAffineInternal(u8 bg, u32 srcCenterX, u32 srcCenterY, s16 dispCenterX,
src.sx = scaleX;
src.sy = scaleY;
src.alpha = rotationAngle;
-
+
BgAffineSet(&src, &dest, 1);
SetGpuReg(REG_OFFSET_BG2PA, dest.pa);
@@ -326,20 +317,20 @@ void ResetBgsAndClearDma3BusyFlags(u32 leftoverFireRedLeafGreenVariable)
{
int i;
ResetBgs();
-
+
for (i = 0; i < 4; i++)
{
gDmaBusyBitfield[i] = 0;
}
-
+
gUnneededFireRedVariable = leftoverFireRedLeafGreenVariable;
}
-void InitBgsFromTemplates(u8 bgMode, struct BgTemplate *templates, u8 numTemplates)
+void InitBgsFromTemplates(u8 bgMode, const struct BgTemplate *templates, u8 numTemplates)
{
int i;
u8 bg;
-
+
SetBgModeInternal(bgMode);
ResetBgControlStructs();
@@ -355,11 +346,11 @@ void InitBgsFromTemplates(u8 bgMode, struct BgTemplate *templates, u8 numTemplat
templates[i].priority,
0,
0);
-
+
gGpuBgConfigs2[bg].baseTile = templates[i].baseTile;
gGpuBgConfigs2[bg].basePalette = 0;
gGpuBgConfigs2[bg].unk_3 = 0;
-
+
gGpuBgConfigs2[bg].tilemap = NULL;
gGpuBgConfigs2[bg].bg_x = 0;
gGpuBgConfigs2[bg].bg_y = 0;
@@ -367,10 +358,10 @@ void InitBgsFromTemplates(u8 bgMode, struct BgTemplate *templates, u8 numTemplat
}
}
-void InitBgFromTemplate(struct BgTemplate *template)
+void InitBgFromTemplate(const struct BgTemplate *template)
{
u8 bg = template->bg;
-
+
if (bg < 4)
{
SetBgControlAttributes(bg,
@@ -381,11 +372,11 @@ void InitBgFromTemplate(struct BgTemplate *template)
template->priority,
0,
0);
-
+
gGpuBgConfigs2[bg].baseTile = template->baseTile;
gGpuBgConfigs2[bg].basePalette = 0;
gGpuBgConfigs2[bg].unk_3 = 0;
-
+
gGpuBgConfigs2[bg].tilemap = NULL;
gGpuBgConfigs2[bg].bg_x = 0;
gGpuBgConfigs2[bg].bg_y = 0;
@@ -401,7 +392,7 @@ u16 LoadBgTiles(u8 bg, void* src, u16 size, u16 destOffset)
{
u16 tileOffset;
u8 cursor;
-
+
if (GetBgControlAttribute(bg, BG_CTRL_ATTR_PALETTEMODE) == 0)
{
tileOffset = (gGpuBgConfigs2[bg].baseTile + destOffset) * 0x20;
@@ -410,37 +401,37 @@ u16 LoadBgTiles(u8 bg, void* src, u16 size, u16 destOffset)
{
tileOffset = (gGpuBgConfigs2[bg].baseTile + destOffset) * 0x40;
}
-
+
cursor = LoadBgVram(bg, src, size, tileOffset, DISPCNT_MODE_1);
-
+
if (cursor == 0xFF)
{
return -1;
}
-
+
gDmaBusyBitfield[cursor / 0x20] |= (1 << (cursor % 0x20));
-
+
if (gUnneededFireRedVariable == 1)
{
DummiedOutFireRedLeafGreenTileAllocFunc(bg, tileOffset / 0x20, size / 0x20, 1);
}
-
+
return cursor;
}
u16 LoadBgTilemap(u8 bg, void *src, u16 size, u16 destOffset)
{
u8 cursor;
-
+
cursor = LoadBgVram(bg, src, size, destOffset * 2, DISPCNT_MODE_2);
-
+
if (cursor == 0xFF)
{
return -1;
}
-
+
gDmaBusyBitfield[cursor / 0x20] |= (1 << (cursor % 0x20));
-
+
return cursor;
}
@@ -448,12 +439,12 @@ u16 Unused_LoadBgPalette(u8 bg, void *src, u16 size, u16 destOffset)
{
u16 paletteOffset;
s8 cursor;
-
+
if (IsInvalidBg32(bg) == FALSE)
{
paletteOffset = (gGpuBgConfigs2[bg].basePalette * 0x20) + (destOffset * 2);
cursor = RequestDma3Copy(src, (void*)(paletteOffset + BG_PLTT), size, 0);
-
+
if (cursor == -1)
{
return -1;
@@ -475,14 +466,14 @@ bool8 IsDma3ManagerBusyWithBgCopy(void)
u8 mod;
u8 div;
s8 reqSpace;
-
+
int i;
-
+
for (i = 0; i < 0x80; i++)
{
div = i / 0x20;
mod = i % 0x20;
-
+
if ((gDmaBusyBitfield[div] & (1 << mod)) != FALSE)
{
reqSpace = CheckForSpaceForDma3Request(i);
@@ -490,7 +481,7 @@ bool8 IsDma3ManagerBusyWithBgCopy(void)
{
return TRUE;
}
-
+
gDmaBusyBitfield[div] &= ~(1 << mod);
}
}
@@ -634,12 +625,12 @@ u32 ChangeBgX(u8 bg, u32 value, u8 op)
u8 mode;
u16 temp1;
u16 temp2;
-
+
if (IsInvalidBg32(bg) != FALSE || GetBgControlAttribute(bg, BG_CTRL_ATTR_VISIBLE) == 0)
{
return -1;
}
-
+
switch (op)
{
case 0:
@@ -653,9 +644,9 @@ u32 ChangeBgX(u8 bg, u32 value, u8 op)
gGpuBgConfigs2[bg].bg_x -= value;
break;
}
-
+
mode = GetBgMode();
-
+
switch (bg)
{
case 0:
@@ -695,7 +686,7 @@ u32 ChangeBgX(u8 bg, u32 value, u8 op)
}
break;
}
-
+
return gGpuBgConfigs2[bg].bg_x;
}
@@ -713,12 +704,12 @@ u32 ChangeBgY(u8 bg, u32 value, u8 op)
u8 mode;
u16 temp1;
u16 temp2;
-
+
if (IsInvalidBg32(bg) != FALSE || GetBgControlAttribute(bg, BG_CTRL_ATTR_VISIBLE) == 0)
{
return -1;
}
-
+
switch (op)
{
case 0:
@@ -732,9 +723,9 @@ u32 ChangeBgY(u8 bg, u32 value, u8 op)
gGpuBgConfigs2[bg].bg_y -= value;
break;
}
-
+
mode = GetBgMode();
-
+
switch (bg)
{
case 0:
@@ -774,7 +765,7 @@ u32 ChangeBgY(u8 bg, u32 value, u8 op)
}
break;
}
-
+
return gGpuBgConfigs2[bg].bg_y;
}
@@ -783,12 +774,12 @@ u32 ChangeBgY_ScreenOff(u8 bg, u32 value, u8 op)
u8 mode;
u16 temp1;
u16 temp2;
-
+
if (IsInvalidBg32(bg) != FALSE || GetBgControlAttribute(bg, BG_CTRL_ATTR_VISIBLE) == 0)
{
return -1;
}
-
+
switch (op)
{
case 0:
@@ -802,9 +793,9 @@ u32 ChangeBgY_ScreenOff(u8 bg, u32 value, u8 op)
gGpuBgConfigs2[bg].bg_y -= value;
break;
}
-
+
mode = GetBgMode();
-
+
switch (bg)
{
case 0:
@@ -820,7 +811,7 @@ u32 ChangeBgY_ScreenOff(u8 bg, u32 value, u8 op)
{
temp1 = gGpuBgConfigs2[2].bg_y >> 0x8;
SetGpuReg_ForcedBlank(REG_OFFSET_BG2VOFS, temp1);
-
+
}
else
{
@@ -845,7 +836,7 @@ u32 ChangeBgY_ScreenOff(u8 bg, u32 value, u8 op)
}
break;
}
-
+
return gGpuBgConfigs2[bg].bg_y;
}
@@ -868,13 +859,13 @@ u8 Unused_AdjustBgMosaic(u8 a1, u8 a2)
u16 result;
s16 test1;
s16 test2;
-
+
result = GetGpuReg(REG_OFFSET_MOSAIC);
-
+
test1 = result & 0xF;
test2 = (result >> 4) & 0xF;
result &= 0xFF00;
-
+
switch (a2)
{
case 0:
@@ -929,12 +920,12 @@ u8 Unused_AdjustBgMosaic(u8 a1, u8 a2)
}
break;
}
-
+
result |= ((test2 << 0x4) & 0xF0);
result |= (test1 & 0xF);
-
+
SetGpuReg(REG_OFFSET_MOSAIC, result);
-
+
return result;
}
@@ -981,7 +972,7 @@ void CopyToBgTilemapBuffer(u8 bg, void *src, u16 mode, u16 destOffset)
void CopyBgTilemapBufferToVram(u8 bg)
{
u16 sizeToLoad;
-
+
if (IsInvalidBg32(bg) == FALSE && IsTileMapOutsideWram(bg) == FALSE)
{
switch (GetBgType(bg))
@@ -1006,7 +997,7 @@ void CopyToBgTilemapBufferRect(u8 bg, void* src, u8 destX, u8 destY, u8 width, u
u16 destX16;
u16 destY16;
u16 mode;
-
+
if (IsInvalidBg32(bg) == FALSE && IsTileMapOutsideWram(bg) == FALSE)
{
switch (GetBgType(bg))
@@ -1047,11 +1038,11 @@ void CopyRectToBgTilemapBufferRect(u8 bg, void* src, u8 srcX, u8 srcY, u8 srcWid
u16 attribute;
u16 mode;
u16 mode2;
-
+
void* srcCopy;
u16 destX16;
u16 destY16;
-
+
if (IsInvalidBg32(bg) == FALSE && IsTileMapOutsideWram(bg) == FALSE)
{
attribute = GetBgControlAttribute(bg, BG_CTRL_ATTR_SCREENSIZE);
@@ -1336,7 +1327,7 @@ void FillBgTilemapBufferRect_Palette0(u8 bg, u16 tileNum, u8 x, u8 y, u8 width,
u16 x16;
u16 y16;
u16 mode;
-
+
if (IsInvalidBg32(bg) == FALSE && IsTileMapOutsideWram(bg) == FALSE)
{
switch (GetBgType(bg))
@@ -1375,10 +1366,10 @@ void WriteSequenceToBgTilemapBuffer(u8 bg, u16 firstTileNum, u8 x, u8 y, u8 widt
u16 mode2;
u16 attribute;
u16 mode3;
-
+
u16 x16;
u16 y16;
-
+
if (IsInvalidBg32(bg) == FALSE && IsTileMapOutsideWram(bg) == FALSE)
{
attribute = GetBgControlAttribute(bg, BG_CTRL_ATTR_SCREENSIZE);
@@ -1414,9 +1405,9 @@ void WriteSequenceToBgTilemapBuffer(u8 bg, u16 firstTileNum, u8 x, u8 y, u8 widt
u16 GetBgMetricTextMode(u8 bg, u8 whichMetric)
{
u8 attribute;
-
+
attribute = GetBgControlAttribute(bg, BG_CTRL_ATTR_SCREENSIZE);
-
+
switch (whichMetric)
{
case 0:
@@ -1462,9 +1453,9 @@ u16 GetBgMetricTextMode(u8 bg, u8 whichMetric)
u32 GetBgMetricAffineMode(u8 bg, u8 whichMetric)
{
u8 attribute;
-
+
attribute = GetBgControlAttribute(bg, BG_CTRL_ATTR_SCREENSIZE);
-
+
switch (whichMetric)
{
case 0:
@@ -1491,7 +1482,7 @@ u32 GetTileMapIndexFromCoords(s32 x, s32 y, s32 screenSize, u32 screenWidth, u32
{
x = x & (screenWidth - 1);
y = y & (screenHeight - 1);
-
+
switch (screenSize)
{
case 0:
@@ -1526,7 +1517,7 @@ void CopyTileMapEntry(u16 *src, u16 *dest, s32 palette1, u32 tileOffset, u32 pal
test = ((*dest & 0xFC00) + (palette2 << 12)) | ((*src + tileOffset) & 0x3FF);
break;
}
-
+
*dest = test;
}
#else
@@ -1586,10 +1577,10 @@ _08002B3C:\n\
u32 GetBgType(u8 bg)
{
u8 mode;
-
+
mode = GetBgMode();
-
-
+
+
switch (bg)
{
case 0:
@@ -1621,7 +1612,7 @@ u32 GetBgType(u8 bg)
}
break;
}
-
+
return 0xFFFF;
}
diff --git a/src/multiboot.c b/src/multiboot.c
index 80291ff46..7fd6df2d0 100644
--- a/src/multiboot.c
+++ b/src/multiboot.c
@@ -316,7 +316,7 @@ void MultiBootStartProbe(struct MultiBootParam *mp)
mp->probe_count = 1;
}
-void MultiBootStartMaster(struct MultiBootParam *mp, u8 *srcp, int length, u8 palette_color, s8 palette_speed)
+void MultiBootStartMaster(struct MultiBootParam *mp, const u8 *srcp, int length, u8 palette_color, s8 palette_speed)
{
int i = 0;
diff --git a/src/text.c b/src/text.c
index cad8326e3..aa4e201c0 100644
--- a/src/text.c
+++ b/src/text.c
@@ -2779,7 +2779,7 @@ _08005D6E:\n\
bx r1");
}
-u32 GetStringWidthFixedWidthFont(u8 *str, u8 fontId, u8 letterSpacing)
+u32 GetStringWidthFixedWidthFont(const u8 *str, u8 fontId, u8 letterSpacing)
{
int i;
u8 width;
@@ -2788,7 +2788,7 @@ u32 GetStringWidthFixedWidthFont(u8 *str, u8 fontId, u8 letterSpacing)
u8 line;
int strPos;
u8 lineWidths[8];
- u8 *strLocal;
+ const u8 *strLocal;
for (i = 0; i < 8; i++)
{
@@ -2883,7 +2883,7 @@ u32 (*GetFontWidthFunc(u8 glyphId))(u16, bool32)
return 0;
}
-s32 GetStringWidth(u8 fontId, u8 *str, s16 letterSpacing)
+u32 GetStringWidth(u8 fontId, const u8 *str, s16 letterSpacing)
{
bool8 isJapanese;
int minGlyphWidth;
diff --git a/src/window.c b/src/window.c
index 574b13aa0..164031bee 100644
--- a/src/window.c
+++ b/src/window.c
@@ -35,7 +35,7 @@ static void nullsub_8(void)
}
-bool16 InitWindows(struct WindowTemplate *templates)
+bool16 InitWindows(const struct WindowTemplate *templates)
{
int i;
void *bgTilemapBuffer;
diff --git a/sym_bss.txt b/sym_bss.txt
index 070e7e5f9..ce2549850 100644
--- a/sym_bss.txt
+++ b/sym_bss.txt
@@ -129,7 +129,7 @@ gUnknown_03000E06: @ 3000E06
.space 0x2
.include "src/play_time.o"
-
+
.align 2
gUnknown_03000E0C: @ 3000E0C
@@ -376,8 +376,7 @@ gUnknown_03001298: @ 3001298
gUnknown_030012A8: @ 30012A8
.space 0x10
-gUnknown_030012B8: @ 30012B8
- .space 0x4
+ .include "src/berry_fix_program.o"
gUnknown_030012BC: @ 30012BC
.space 0x4