From 37cac6396ff1f9d6a1e7094bcf871bcb1bed3a2a Mon Sep 17 00:00:00 2001 From: jeffman Date: Wed, 11 Sep 2019 21:01:17 -0400 Subject: [PATCH 01/32] Add title screen initializer hack Making the palettes compressed because it results in shorter code. --- notes/m2-sub111D0.txt | 407 ++++---- notes/m2-title-long.txt | 988 ++++++++++++++++++ .../m2-title-background-pal-copyright.bin | Bin 256 -> 0 bytes .../m2-title-background-pal-copyright.c.bin | Bin 0 -> 72 bytes src/data/m2-title-background-pal-glow.bin | 18 - src/data/m2-title-background-pal-glow.c.bin | Bin 0 -> 124 bytes src/data/m2-title-text-pal-animated.bin | Bin 448 -> 0 bytes src/data/m2-title-text-pal-animated.c.bin | Bin 0 -> 124 bytes src/data/m2-title-text-pal-static.bin | Bin 32 -> 0 bytes src/data/m2-title-text-pal-static.c.bin | Bin 0 -> 16 bytes src/m2-hack.asm | 39 +- 11 files changed, 1223 insertions(+), 229 deletions(-) create mode 100644 notes/m2-title-long.txt delete mode 100644 src/data/m2-title-background-pal-copyright.bin create mode 100644 src/data/m2-title-background-pal-copyright.c.bin delete mode 100644 src/data/m2-title-background-pal-glow.bin create mode 100644 src/data/m2-title-background-pal-glow.c.bin delete mode 100644 src/data/m2-title-text-pal-animated.bin create mode 100644 src/data/m2-title-text-pal-animated.c.bin delete mode 100644 src/data/m2-title-text-pal-static.bin create mode 100644 src/data/m2-title-text-pal-static.c.bin diff --git a/notes/m2-sub111D0.txt b/notes/m2-sub111D0.txt index 58c7892..abff02d 100644 --- a/notes/m2-sub111D0.txt +++ b/notes/m2-sub111D0.txt @@ -27,207 +27,206 @@ // 2 = HALKEN // 3 = Title screen (full) // 5 = Title screen (quick) - 080111D0 (T) push r4-r7,r14 - 080111D2 (T) mov r7,r9 - 080111D4 (T) mov r6,r8 - 080111D6 (T) push r6,r7 - 080111D8 (T) add sp,-4h - 080111DA (T) mov r5,r0 - 080111DC (T) ldr r4,=3000370h - 080111DE (T) mov r0,18h - 080111E0 (T) bl 8005B9Ch // malloc 0x18 bytes for some struct - 080111E4 (T) str r0,[r4] - 080111E6 (T) str r5,[r0] - 080111E8 (T) mov r7,0h - 080111EA (T) str r7,[r0,14h] - 080111EC (T) str r7,[r0,4h] - 080111EE (T) str r7,[r0,10h] // zero out the struct - 080111F0 (T) ldr r6,=82D6AA8h - 080111F2 (T) lsl r0,r5,3h - 080111F4 (T) sub r0,r0,r5 - 080111F6 (T) lsl r4,r0,3h // r4 = r5 * 0x38 - 080111F8 (T) add r0,r4,r6 - 080111FA (T) ldr r0,[r0] - 080111FC (T) cmp r0,0h - 080111FE (T) beq 801120Ch - 08011200 (T) mov r1,80h - 08011202 (T) lsl r1,r1,12h - 08011204 (T) mov r2,40h - 08011206 (T) lsl r2,r2,8h - 08011208 (T) bl 8005D34h - 0801120C (T) add r0,r6,4 - 0801120E (T) add r0,r4,r0 - 08011210 (T) ldr r0,[r0] - 08011212 (T) cmp r0,0h - 08011214 (T) beq 8011220h - 08011216 (T) ldr r1,=2008000h - 08011218 (T) mov r2,80h - 0801121A (T) lsl r2,r2,8h - 0801121C (T) bl 8005D34h - 08011220 (T) mov r0,r6 - 08011222 (T) add r0,8h - 08011224 (T) add r0,r4,r0 - 08011226 (T) ldr r3,[r0] - 08011228 (T) cmp r3,0h - 0801122A (T) beq 801126Ch - 0801122C (T) mov r0,1h - 0801122E (T) neg r0,r0 - 08011230 (T) cmp r3,r0 - 08011232 (T) bne 8011260h - 08011234 (T) str r7,[sp] - 08011236 (T) ldr r1,=40000D4h - 08011238 (T) mov r0,r13 - 0801123A (T) str r0,[r1] - 0801123C (T) ldr r0,=2010000h - 0801123E (T) str r0,[r1,4h] - 08011240 (T) ldr r0,=85000080h - 08011242 (T) str r0,[r1,8h] - 08011244 (T) ldr r0,[r1,8h] - 08011246 (T) b 801126Ch - 08011248 (T) lsl r0,r6,0Dh - 0801124A (T) lsl r0,r0,0Ch - 0801124C (T) ldr r0,[r5,28h] - 0801124E (T) lsr r5,r5,20h - 08011250 (T) strh r0,[r0] - 08011252 (T) lsl r0,r0,8h - 08011254 (T) lsl r4,r2,3h - 08011256 (T) lsl r0,r0,10h - 08011258 (T) lsl r0,r0,0h - 0801125A (T) lsl r1,r0,8h - 0801125C (T) lsl r0,r0,2h - 0801125E (T) strh r0,[r0,28h] - 08011260 (T) ldr r1,=2010000h - 08011262 (T) mov r2,80h - 08011264 (T) lsl r2,r2,2h - 08011266 (T) mov r0,r3 - 08011268 (T) bl 8005D34h - 0801126C (T) ldr r1,=82D6AA8h - 0801126E (T) mov r9,r1 - 08011270 (T) lsl r0,r5,3h - 08011272 (T) sub r0,r0,r5 - 08011274 (T) lsl r7,r0,3h - 08011276 (T) mov r0,r9 - 08011278 (T) add r0,0Ch - 0801127A (T) add r0,r7,r0 - 0801127C (T) ldr r0,[r0] - 0801127E (T) cmp r0,0h - 08011280 (T) beq 801128Ch - 08011282 (T) ldr r1,=2010200h - 08011284 (T) mov r2,80h - 08011286 (T) lsl r2,r2,2h - 08011288 (T) bl 8005D34h - 0801128C (T) mov r0,r9 - 0801128E (T) add r0,10h - 08011290 (T) add r0,r7,r0 - 08011292 (T) ldr r0,[r0] - 08011294 (T) cmp r0,0h - 08011296 (T) beq 80112A2h - 08011298 (T) ldr r1,=2010400h - 0801129A (T) mov r2,80h - 0801129C (T) lsl r2,r2,4h - 0801129E (T) bl 8005D34h - 080112A2 (T) mov r0,r9 - 080112A4 (T) add r0,18h - 080112A6 (T) add r0,r7,r0 - 080112A8 (T) ldr r0,[r0] - 080112AA (T) cmp r0,0h - 080112AC (T) beq 80112B8h - 080112AE (T) ldr r1,=2010C00h - 080112B0 (T) mov r2,80h - 080112B2 (T) lsl r2,r2,4h - 080112B4 (T) bl 8005D34h - 080112B8 (T) ldr r0,=2010000h - 080112BA (T) mov r8,r0 - 080112BC (T) mov r0,0h - 080112BE (T) mov r1,r8 - 080112C0 (T) strh r0,[r1] - 080112C2 (T) bl 80F47E4h - 080112C6 (T) bl 800E5E4h - 080112CA (T) ldr r4,=40000D4h - 080112CC (T) mov r0,80h - 080112CE (T) lsl r0,r0,12h - 080112D0 (T) str r0,[r4] - 080112D2 (T) ldr r0,=6008000h - 080112D4 (T) str r0,[r4,4h] - 080112D6 (T) ldr r5,=84001000h - 080112D8 (T) str r5,[r4,8h] - 080112DA (T) ldr r0,[r4,8h] - 080112DC (T) ldr r6,=4000006h - 080112DE (T) ldrh r0,[r6] - 080112E0 (T) bl 80F47E4h - 080112E4 (T) bl 800E5E4h - 080112E8 (T) ldr r0,=2004000h - 080112EA (T) str r0,[r4] - 080112EC (T) ldr r0,=600C000h - 080112EE (T) str r0,[r4,4h] - 080112F0 (T) str r5,[r4,8h] - 080112F2 (T) ldr r0,[r4,8h] - 080112F4 (T) ldrh r0,[r6] - 080112F6 (T) bl 80F47E4h - 080112FA (T) bl 800E5E4h - 080112FE (T) ldr r1,=4000008h - 08011300 (T) mov r0,r9 - 08011302 (T) add r5,r7,r0 - 08011304 (T) ldrh r0,[r5,14h] - 08011306 (T) strh r0,[r1] - 08011308 (T) add r1,2h - 0801130A (T) ldrh r0,[r5,1Ch] - 0801130C (T) strh r0,[r1] - 0801130E (T) mov r1,r8 - 08011310 (T) str r1,[r4] - 08011312 (T) mov r0,0A0h - 08011314 (T) lsl r0,r0,13h - 08011316 (T) str r0,[r4,4h] - 08011318 (T) ldr r0,=84000080h - 0801131A (T) mov r9,r0 - 0801131C (T) str r0,[r4,8h] - 0801131E (T) ldr r0,[r4,8h] - 08011320 (T) ldr r0,=2010400h - 08011322 (T) str r0,[r4] - 08011324 (T) mov r0,0C0h - 08011326 (T) lsl r0,r0,13h - 08011328 (T) str r0,[r4,4h] - 0801132A (T) ldr r1,=84000200h - 0801132C (T) mov r8,r1 - 0801132E (T) str r1,[r4,8h] - 08011330 (T) ldr r0,[r4,8h] - 08011332 (T) ldrh r0,[r6] - 08011334 (T) bl 80F47E4h - 08011338 (T) bl 800E5E4h - 0801133C (T) ldr r0,=2008000h - 0801133E (T) str r0,[r4] - 08011340 (T) ldr r0,=6010000h - 08011342 (T) str r0,[r4,4h] - 08011344 (T) ldr r0,=84002000h - 08011346 (T) str r0,[r4,8h] - 08011348 (T) ldr r0,[r4,8h] - 0801134A (T) ldrh r0,[r6] - 0801134C (T) bl 80F47E4h - 08011350 (T) bl 800E5E4h - 08011354 (T) mov r1,80h - 08011356 (T) lsl r1,r1,13h - 08011358 (T) ldrh r0,[r5,20h] - 0801135A (T) strh r0,[r1] - 0801135C (T) ldr r0,=2010200h - 0801135E (T) str r0,[r4] - 08011360 (T) ldr r0,=5000200h - 08011362 (T) str r0,[r4,4h] - 08011364 (T) mov r0,r9 - 08011366 (T) str r0,[r4,8h] - 08011368 (T) ldr r0,[r4,8h] - 0801136A (T) ldr r0,=2010C00h - 0801136C (T) str r0,[r4] - 0801136E (T) ldr r0,=6000800h - 08011370 (T) str r0,[r4,4h] - 08011372 (T) mov r1,r8 - 08011374 (T) str r1,[r4,8h] - 08011376 (T) ldr r0,[r4,8h] - 08011378 (T) ldrh r0,[r6] - 0801137A (T) add sp,4h - 0801137C (T) pop r3,r4 - 0801137E (T) mov r8,r3 - 08011380 (T) mov r9,r4 - 08011382 (T) pop r4-r7 - 08011384 (T) pop r0 - 08011386 (T) bx r0 - \ No newline at end of file +080111D0 (T) push r4-r7,r14 +080111D2 (T) mov r7,r9 +080111D4 (T) mov r6,r8 +080111D6 (T) push r6,r7 +080111D8 (T) add sp,-4h +080111DA (T) mov r5,r0 +080111DC (T) ldr r4,=3000370h +080111DE (T) mov r0,18h +080111E0 (T) bl 8005B9Ch // malloc 0x18 bytes for some struct +080111E4 (T) str r0,[r4] +080111E6 (T) str r5,[r0] +080111E8 (T) mov r7,0h +080111EA (T) str r7,[r0,14h] +080111EC (T) str r7,[r0,4h] +080111EE (T) str r7,[r0,10h] // zero out the struct +080111F0 (T) ldr r6,=82D6AA8h +080111F2 (T) lsl r0,r5,3h +080111F4 (T) sub r0,r0,r5 +080111F6 (T) lsl r4,r0,3h // r4 = r5 * 0x38 +080111F8 (T) add r0,r4,r6 +080111FA (T) ldr r0,[r0] +080111FC (T) cmp r0,0h +080111FE (T) beq 801120Ch +08011200 (T) mov r1,80h +08011202 (T) lsl r1,r1,12h +08011204 (T) mov r2,40h +08011206 (T) lsl r2,r2,8h +08011208 (T) bl 8005D34h +0801120C (T) add r0,r6,4 +0801120E (T) add r0,r4,r0 +08011210 (T) ldr r0,[r0] +08011212 (T) cmp r0,0h +08011214 (T) beq 8011220h +08011216 (T) ldr r1,=2008000h +08011218 (T) mov r2,80h +0801121A (T) lsl r2,r2,8h +0801121C (T) bl 8005D34h +08011220 (T) mov r0,r6 +08011222 (T) add r0,8h +08011224 (T) add r0,r4,r0 +08011226 (T) ldr r3,[r0] +08011228 (T) cmp r3,0h +0801122A (T) beq 801126Ch +0801122C (T) mov r0,1h +0801122E (T) neg r0,r0 +08011230 (T) cmp r3,r0 +08011232 (T) bne 8011260h +08011234 (T) str r7,[sp] +08011236 (T) ldr r1,=40000D4h +08011238 (T) mov r0,r13 +0801123A (T) str r0,[r1] +0801123C (T) ldr r0,=2010000h +0801123E (T) str r0,[r1,4h] +08011240 (T) ldr r0,=85000080h +08011242 (T) str r0,[r1,8h] +08011244 (T) ldr r0,[r1,8h] +08011246 (T) b 801126Ch +08011248 (T) lsl r0,r6,0Dh +0801124A (T) lsl r0,r0,0Ch +0801124C (T) ldr r0,[r5,28h] +0801124E (T) lsr r5,r5,20h +08011250 (T) strh r0,[r0] +08011252 (T) lsl r0,r0,8h +08011254 (T) lsl r4,r2,3h +08011256 (T) lsl r0,r0,10h +08011258 (T) lsl r0,r0,0h +0801125A (T) lsl r1,r0,8h +0801125C (T) lsl r0,r0,2h +0801125E (T) strh r0,[r0,28h] +08011260 (T) ldr r1,=2010000h +08011262 (T) mov r2,80h +08011264 (T) lsl r2,r2,2h +08011266 (T) mov r0,r3 +08011268 (T) bl 8005D34h +0801126C (T) ldr r1,=82D6AA8h +0801126E (T) mov r9,r1 +08011270 (T) lsl r0,r5,3h +08011272 (T) sub r0,r0,r5 +08011274 (T) lsl r7,r0,3h +08011276 (T) mov r0,r9 +08011278 (T) add r0,0Ch +0801127A (T) add r0,r7,r0 +0801127C (T) ldr r0,[r0] +0801127E (T) cmp r0,0h +08011280 (T) beq 801128Ch +08011282 (T) ldr r1,=2010200h +08011284 (T) mov r2,80h +08011286 (T) lsl r2,r2,2h +08011288 (T) bl 8005D34h +0801128C (T) mov r0,r9 +0801128E (T) add r0,10h +08011290 (T) add r0,r7,r0 +08011292 (T) ldr r0,[r0] +08011294 (T) cmp r0,0h +08011296 (T) beq 80112A2h +08011298 (T) ldr r1,=2010400h +0801129A (T) mov r2,80h +0801129C (T) lsl r2,r2,4h +0801129E (T) bl 8005D34h +080112A2 (T) mov r0,r9 +080112A4 (T) add r0,18h +080112A6 (T) add r0,r7,r0 +080112A8 (T) ldr r0,[r0] +080112AA (T) cmp r0,0h +080112AC (T) beq 80112B8h +080112AE (T) ldr r1,=2010C00h +080112B0 (T) mov r2,80h +080112B2 (T) lsl r2,r2,4h +080112B4 (T) bl 8005D34h +080112B8 (T) ldr r0,=2010000h +080112BA (T) mov r8,r0 +080112BC (T) mov r0,0h +080112BE (T) mov r1,r8 +080112C0 (T) strh r0,[r1] +080112C2 (T) bl 80F47E4h +080112C6 (T) bl 800E5E4h +080112CA (T) ldr r4,=40000D4h +080112CC (T) mov r0,80h +080112CE (T) lsl r0,r0,12h +080112D0 (T) str r0,[r4] +080112D2 (T) ldr r0,=6008000h +080112D4 (T) str r0,[r4,4h] +080112D6 (T) ldr r5,=84001000h +080112D8 (T) str r5,[r4,8h] +080112DA (T) ldr r0,[r4,8h] +080112DC (T) ldr r6,=4000006h +080112DE (T) ldrh r0,[r6] +080112E0 (T) bl 80F47E4h +080112E4 (T) bl 800E5E4h +080112E8 (T) ldr r0,=2004000h +080112EA (T) str r0,[r4] +080112EC (T) ldr r0,=600C000h +080112EE (T) str r0,[r4,4h] +080112F0 (T) str r5,[r4,8h] +080112F2 (T) ldr r0,[r4,8h] +080112F4 (T) ldrh r0,[r6] +080112F6 (T) bl 80F47E4h +080112FA (T) bl 800E5E4h +080112FE (T) ldr r1,=4000008h +08011300 (T) mov r0,r9 +08011302 (T) add r5,r7,r0 +08011304 (T) ldrh r0,[r5,14h] +08011306 (T) strh r0,[r1] +08011308 (T) add r1,2h +0801130A (T) ldrh r0,[r5,1Ch] +0801130C (T) strh r0,[r1] +0801130E (T) mov r1,r8 +08011310 (T) str r1,[r4] +08011312 (T) mov r0,0A0h +08011314 (T) lsl r0,r0,13h +08011316 (T) str r0,[r4,4h] +08011318 (T) ldr r0,=84000080h +0801131A (T) mov r9,r0 +0801131C (T) str r0,[r4,8h] +0801131E (T) ldr r0,[r4,8h] +08011320 (T) ldr r0,=2010400h +08011322 (T) str r0,[r4] +08011324 (T) mov r0,0C0h +08011326 (T) lsl r0,r0,13h +08011328 (T) str r0,[r4,4h] +0801132A (T) ldr r1,=84000200h +0801132C (T) mov r8,r1 +0801132E (T) str r1,[r4,8h] +08011330 (T) ldr r0,[r4,8h] +08011332 (T) ldrh r0,[r6] +08011334 (T) bl 80F47E4h +08011338 (T) bl 800E5E4h +0801133C (T) ldr r0,=2008000h +0801133E (T) str r0,[r4] +08011340 (T) ldr r0,=6010000h +08011342 (T) str r0,[r4,4h] +08011344 (T) ldr r0,=84002000h +08011346 (T) str r0,[r4,8h] +08011348 (T) ldr r0,[r4,8h] +0801134A (T) ldrh r0,[r6] +0801134C (T) bl 80F47E4h +08011350 (T) bl 800E5E4h +08011354 (T) mov r1,80h +08011356 (T) lsl r1,r1,13h +08011358 (T) ldrh r0,[r5,20h] +0801135A (T) strh r0,[r1] +0801135C (T) ldr r0,=2010200h +0801135E (T) str r0,[r4] +08011360 (T) ldr r0,=5000200h +08011362 (T) str r0,[r4,4h] +08011364 (T) mov r0,r9 +08011366 (T) str r0,[r4,8h] +08011368 (T) ldr r0,[r4,8h] +0801136A (T) ldr r0,=2010C00h +0801136C (T) str r0,[r4] +0801136E (T) ldr r0,=6000800h +08011370 (T) str r0,[r4,4h] +08011372 (T) mov r1,r8 +08011374 (T) str r1,[r4,8h] +08011376 (T) ldr r0,[r4,8h] +08011378 (T) ldrh r0,[r6] +0801137A (T) add sp,4h +0801137C (T) pop r3,r4 +0801137E (T) mov r8,r3 +08011380 (T) mov r9,r4 +08011382 (T) pop r4-r7 +08011384 (T) pop r0 +08011386 (T) bx r0 diff --git a/notes/m2-title-long.txt b/notes/m2-title-long.txt new file mode 100644 index 0000000..3b04cba --- /dev/null +++ b/notes/m2-title-long.txt @@ -0,0 +1,988 @@ +// Full title screen +// ---- +// Jump table: +// $80113F5 +// $80115A9 +// $8011499 +// $8011495 + +// 0x2E0 struct: +// Offset Length Description Value for long title screen +// ------------------------------------------------------------------------------------------------------------ +// 0 4 Palette A pointer (WRAM) -- background? x3 0x2011400 +// 4 4 Palette B pointer (WRAM) -- text or orb? x5 0x2011600 +// 8 4 Palette C pointer (WRAM) -- copyright or bg? x4 0x2011800 +// C 4 Palette D pointer (WRAM) -- text or orb? x4 0x2011A00 +// 10 4 Palette E pointer (WRAM) -- buffer? 0x2011C00 + +//============================================================================= +// $80113F5: +080113F4 (T) push r4,r5,r14 +080113F6 (T) add sp,-4h + +// malloc 0x2E0 bytes +080113F8 (T) movs r0,0B8h +080113FA (T) lsls r0,r0,2h +080113FC (T) bl 8005B9Ch +08011400 (T) adds r4,r0,0 +08011402 (T) ldr r0,=3000370h +08011404 (T) ldr r0,[r0] +08011406 (T) str r4,[r0,14h] + +// Initialize struct +// Five palette buffers +08011408 (T) ldr r0,=2011400h +0801140A (T) str r0,[r4] +0801140C (T) ldr r0,=2011600h +0801140E (T) str r0,[r4,4h] +08011410 (T) ldr r1,=2011800h +08011412 (T) str r1,[r4,8h] +08011414 (T) ldr r0,=2011A00h +08011416 (T) str r0,[r4,0Ch] +08011418 (T) ldr r0,=2011C00h +0801141A (T) str r0,[r4,10h] + +// Load first four palettes into buffers +0801141C (T) ldr r0,=8712754h +0801141E (T) movs r5,80h +08011420 (T) lsls r5,r5,2h +08011422 (T) adds r2,r5,0 +08011424 (T) bl 8005D34h +08011428 (T) ldr r0,=8712868h +0801142A (T) ldr r1,[r4,0Ch] +0801142C (T) adds r2,r5,0 +0801142E (T) bl 8005D34h +08011432 (T) ldr r0,=87126CCh +08011434 (T) ldr r1,[r4] +08011436 (T) adds r2,r5,0 +08011438 (T) bl 8005D34h +0801143C (T) ldr r0,=87127E8h +0801143E (T) ldr r1,[r4,4h] +08011440 (T) adds r2,r5,0 +08011442 (T) bl 8005D34h + +// Zero out fifth buffer +08011446 (T) movs r0,0h +08011448 (T) str r0,[sp] +0801144A (T) ldr r1,=40000D4h +0801144C (T) mov r0,r13 +0801144E (T) str r0,[r1] +08011450 (T) ldr r0,[r4,10h] +08011452 (T) str r0,[r1,4h] +08011454 (T) ldr r0,=85000080h +08011456 (T) str r0,[r1,8h] +08011458 (T) ldr r0,[r1,8h] + +// Return 0 +0801145A (T) movs r0,0h +0801145C (T) add sp,4h +0801145E (T) pop r4,r5 +08011460 (T) pop r1 +08011462 (T) bx r1 + +//============================================================================= +// $80115A9: +080115A8 (T) push r4-r7,r14 +080115AA (T) mov r7,r10 +080115AC (T) mov r6,r9 +080115AE (T) mov r5,r8 +080115B0 (T) push r5-r7 +080115B2 (T) add sp,-94h +080115B4 (T) mov r1,r13 +080115B6 (T) ldr r0,=80FCB74h +080115B8 (T) ldmia [r0]!,r2-r4 +080115BA (T) stmia [r1]!,r2-r4 +080115BC (T) add r7,sp,0Ch +080115BE (T) mov r8,r7 +080115C0 (T) mov r1,r8 +080115C2 (T) ldr r0,=80FCB80h +080115C4 (T) ldmia [r0]!,r2-r4 +080115C6 (T) stmia [r1]!,r2-r4 +080115C8 (T) ldmia [r0]!,r2,r3,r7 +080115CA (T) stmia [r1]!,r2,r3,r7 +080115CC (T) ldmia [r0]!,r4,r7 +080115CE (T) stmia [r1]!,r4,r7 +080115D0 (T) add r6,sp,2Ch +080115D2 (T) mov r1,r6 +080115D4 (T) ldr r0,=80FCBA0h +080115D6 (T) ldmia [r0]!,r2-r4 +080115D8 (T) stmia [r1]!,r2-r4 +080115DA (T) ldmia [r0]!,r2,r3,r7 +080115DC (T) stmia [r1]!,r2,r3,r7 +080115DE (T) ldmia [r0]!,r4,r7 +080115E0 (T) stmia [r1]!,r4,r7 +080115E2 (T) add r5,sp,4Ch +080115E4 (T) mov r1,r5 +080115E6 (T) ldr r0,=80FCBC0h +080115E8 (T) ldmia [r0]!,r2-r4 +080115EA (T) stmia [r1]!,r2-r4 +080115EC (T) ldmia [r0]!,r2,r3,r7 +080115EE (T) stmia [r1]!,r2,r3,r7 +080115F0 (T) ldmia [r0]!,r4,r7 +080115F2 (T) stmia [r1]!,r4,r7 +080115F4 (T) add r4,sp,6Ch +080115F6 (T) mov r1,r4 +080115F8 (T) ldr r0,=80FCBE0h +080115FA (T) ldmia [r0]!,r2,r3,r7 +080115FC (T) stmia [r1]!,r2,r3,r7 +080115FE (T) ldmia [r0]!,r2,r3,r7 +08011600 (T) stmia [r1]!,r2,r3,r7 +08011602 (T) ldmia [r0]!,r2,r3 +08011604 (T) stmia [r1]!,r2,r3 +08011606 (T) ldr r3,=3000370h +08011608 (T) ldr r7,[r3] +0801160A (T) mov r12,r7 +0801160C (T) mov r0,r12 +0801160E (T) ldr r0,[r0,14h] +08011610 (T) mov r9,r0 +08011612 (T) mov r7,r9 +08011614 (T) add r7,14h +08011616 (T) ldr r0,=3002570h +08011618 (T) ldr r1,[r0] +0801161A (T) ldr r0,=3002A30h +0801161C (T) ldr r2,[r0] +0801161E (T) lsl r0,r1,1h +08011620 (T) add r0,r0,r1 +08011622 (T) lsl r0,r0,4h +08011624 (T) add r0,r0,r2 +08011626 (T) ldrb r1,[r0,8h] +08011628 (T) cmp r1,0h +0801162A (T) beq 801162Eh +0801162C (T) b 8011730h +0801162E (T) mov r0,r9 +08011630 (T) add r0,84h +08011632 (T) str r1,[r0] +08011634 (T) mov r1,0A2h +08011636 (T) lsl r1,r1,2h +08011638 (T) add r1,r9 +0801163A (T) mov r0,88h +0801163C (T) lsl r0,r0,4h +0801163E (T) str r0,[r1] +08011640 (T) mov r2,0B2h +08011642 (T) lsl r2,r2,2h +08011644 (T) add r2,r9 +08011646 (T) ldr r1,[sp,54h] +08011648 (T) mov r0,0F0h +0801164A (T) sub r0,r0,r1 +0801164C (T) str r0,[r2] +0801164E (T) mov r1,0AEh +08011650 (T) lsl r1,r1,2h +08011652 (T) add r1,r9 +08011654 (T) mov r0,0C0h +08011656 (T) lsl r0,r0,0Ah +08011658 (T) str r0,[r1] +0801165A (T) mov r6,1h +0801165C (T) mov r7,0B2h +0801165E (T) lsl r7,r7,2h +08011660 (T) add r7,r9 +08011662 (T) mov r5,0B3h +08011664 (T) lsl r5,r5,2h +08011666 (T) add r5,r9 +08011668 (T) mov r1,r13 +0801166A (T) add r1,58h +0801166C (T) str r1,[sp,8Ch] +0801166E (T) mov r2,r13 +08011670 (T) add r2,78h +08011672 (T) str r2,[sp,90h] +08011674 (T) mov r3,0A2h +08011676 (T) lsl r3,r3,2h +08011678 (T) add r3,r9 +0801167A (T) mov r10,r3 +0801167C (T) mov r4,0A3h +0801167E (T) lsl r4,r4,2h +08011680 (T) add r4,r9 +08011682 (T) mov r8,r4 +08011684 (T) lsl r4,r6,2h +08011686 (T) ldr r0,[sp,90h] +08011688 (T) ldmia [r0]!,r1 +0801168A (T) str r0,[sp,90h] +0801168C (T) ldr r2,[sp,8Ch] +0801168E (T) ldmia [r2]!,r0 +08011690 (T) str r2,[sp,8Ch] +08011692 (T) sub r1,r1,r0 +08011694 (T) str r1,[r5] +08011696 (T) mov r0,0AEh +08011698 (T) lsl r0,r0,2h +0801169A (T) add r0,r9 +0801169C (T) add r4,r0,r4 +0801169E (T) ldr r0,[r0] +080116A0 (T) mul r0,r1 +080116A2 (T) ldr r1,[r7] +080116A4 (T) bl m2_div +080116A8 (T) str r0,[r4] +080116AA (T) ldmia [r5]!,r1 +080116AC (T) mov r3,r10 +080116AE (T) ldr r0,[r3] +080116B0 (T) mul r0,r1 +080116B2 (T) ldr r1,[r7] +080116B4 (T) bl m2_div +080116B8 (T) mov r4,r8 +080116BA (T) add r4,4h +080116BC (T) mov r8,r4 +080116BE (T) sub r4,4h +080116C0 (T) stmia [r4]!,r0 +080116C2 (T) add r6,1h +080116C4 (T) cmp r6,3h +080116C6 (T) ble 8011684h +080116C8 (T) mov r6,0h +080116CA (T) mov r10,r6 +080116CC (T) add r7,sp,2Ch +080116CE (T) mov r8,r7 +080116D0 (T) add r7,sp,6Ch +080116D2 (T) mov r5,r9 +080116D4 (T) add r5,0A8h +080116D6 (T) mov r4,r9 +080116D8 (T) add r4,88h +080116DA (T) mov r0,r4 +080116DC (T) ldr r1,=8712FB0h +080116DE (T) bl 80088E0h +080116E2 (T) strb r6,[r5] +080116E4 (T) mov r0,r4 +080116E6 (T) bl 8008A28h +080116EA (T) mov r0,r10 +080116EC (T) strb r0,[r5,0Eh] +080116EE (T) ldmia [r7]!,r0 +080116F0 (T) str r0,[r5,4h] +080116F2 (T) mov r1,r8 +080116F4 (T) add r1,4h +080116F6 (T) mov r8,r1 +080116F8 (T) sub r1,4h +080116FA (T) ldmia [r1]!,r0 +080116FC (T) str r0,[r5,8h] +080116FE (T) add r5,40h +08011700 (T) add r4,40h +08011702 (T) add r6,1h +08011704 (T) cmp r6,7h +08011706 (T) ble 80116DAh +08011708 (T) b 8011BE4h +0801170A (T) lsl r0,r0,0h +0801170C (T) ldmia [r3]!,r2,r4-r6 +0801170E (T) lsr r7,r1,20h +08011710 (T) ldmia [r3]!,r7 +08011712 (T) lsr r7,r1,20h +08011714 (T) ldmia [r3]!,r5,r7 +08011716 (T) lsr r7,r1,20h +08011718 (T) ldmia [r3]!,r6,r7 +0801171A (T) lsr r7,r1,20h +0801171C (T) ldmia [r3]!,r5-r7 +0801171E (T) lsr r7,r1,20h +08011720 (T) lsl r0,r6,0Dh +08011722 (T) lsl r0,r0,0Ch +08011724 (T) mov r5,70h +08011726 (T) lsl r0,r0,0Ch +08011728 (T) cmp r2,30h +0801172A (T) lsl r0,r0,0Ch +0801172C (T) cmp r7,0B0h +0801172E (T) lsr r1,r6,1h +08011730 (T) ldrb r0,[r0,0Bh] +08011732 (T) cmp r0,1h +08011734 (T) bne 801173Ch +08011736 (T) bl 8000C28h +0801173A (T) b 8011BE4h +0801173C (T) ldr r0,=3002500h +0801173E (T) ldrh r1,[r0] +08011740 (T) mov r0,9h +08011742 (T) and r0,r1 +08011744 (T) cmp r0,0h +08011746 (T) beq 8011774h +08011748 (T) mov r0,r9 +0801174A (T) add r0,84h +0801174C (T) ldr r0,[r0] +0801174E (T) cmp r0,0Ah +08011750 (T) ble 8011764h +08011752 (T) ldr r1,=30012D0h +08011754 (T) ldr r0,=8001825h +08011756 (T) b 8011B7Ah +08011758 (T) mov r5,0h +0801175A (T) lsl r0,r0,0Ch +0801175C (T) asr r0,r2,0Bh +0801175E (T) lsl r0,r0,0Ch +08011760 (T) add r5,r4,r0 +08011762 (T) lsr r0,r0,20h +08011764 (T) ldr r1,=30012D0h +08011766 (T) ldr r0,=8010F95h +08011768 (T) b 8011B7Ah +0801176A (T) lsl r0,r0,0h +0801176C (T) asr r0,r2,0Bh +0801176E (T) lsl r0,r0,0Ch +08011770 (T) lsr r5,r2,1Eh +08011772 (T) lsr r1,r0,20h +08011774 (T) mov r2,r12 +08011776 (T) ldr r0,[r2,4h] +08011778 (T) add r0,1h +0801177A (T) str r0,[r2,4h] +0801177C (T) mov r0,r9 +0801177E (T) add r0,84h +08011780 (T) ldr r1,[r0] +08011782 (T) mov r10,r0 +08011784 (T) cmp r1,11h +08011786 (T) bls 801178Ah +08011788 (T) b 8011B8Ch +0801178A (T) lsl r0,r1,2h +0801178C (T) ldr r1,=8011798h +0801178E (T) add r0,r0,r1 +08011790 (T) ldr r0,[r0] +08011792 (T) mov r15,r0 +08011794 (T) asr r0,r3,1Eh +08011796 (T) lsr r1,r0,20h +08011798 (T) asr r0,r4,1Fh +0801179A (T) lsr r1,r0,20h +0801179C (T) add r2,r0,r0 +0801179E (T) lsr r1,r0,20h +080117A0 (T) add r2,r5,r0 +080117A2 (T) lsr r1,r0,20h +080117A4 (T) add r0,r3,r1 +080117A6 (T) lsr r1,r0,20h +080117A8 (T) add r2,r7,r3 +080117AA (T) lsr r1,r0,20h +080117AC (T) add r6,r7,r3 +080117AE (T) lsr r1,r0,20h +080117B0 (T) add r4,r3,r5 +080117B2 (T) lsr r1,r0,20h +080117B4 (T) add r2,r6,r5 +080117B6 (T) lsr r1,r0,20h +080117B8 (T) add r2,r7,r6 +080117BA (T) lsr r1,r0,20h +080117BC (T) add r6,r3,r7 +080117BE (T) lsr r1,r0,20h +080117C0 (T) sub r2,r0,r0 +080117C2 (T) lsr r1,r0,20h +080117C4 (T) sub r2,r3,r0 +080117C6 (T) lsr r1,r0,20h +080117C8 (T) sub r0,r0,r2 +080117CA (T) lsr r1,r0,20h +080117CC (T) sub r2,r1,r2 +080117CE (T) lsr r1,r0,20h +080117D0 (T) sub r2,r5,r2 +080117D2 (T) lsr r1,r0,20h +080117D4 (T) sub r0,r3,r5 +080117D6 (T) lsr r1,r0,20h +080117D8 (T) sub r6,r4,r5 +080117DA (T) lsr r1,r0,20h +080117DC (T) sub r6,r6,r5 +080117DE (T) lsr r1,r0,20h +080117E0 (T) mov r1,r9 +080117E2 (T) add r1,7Ah +080117E4 (T) mov r2,0h +080117E6 (T) mov r0,0D0h +080117E8 (T) strh r0,[r1] +080117EA (T) add r1,2h +080117EC (T) mov r0,10h +080117EE (T) strh r0,[r1] +080117F0 (T) ldr r0,[r3] +080117F2 (T) str r2,[r0,4h] +080117F4 (T) mov r0,1h +080117F6 (T) mov r3,r10 +080117F8 (T) str r0,[r3] +080117FA (T) mov r0,0AFh +080117FC (T) bl m2_soundeffect +08011800 (T) b 8011B8Ch +08011802 (T) ldr r3,[r3] +08011804 (T) ldr r0,[r3,4h] +08011806 (T) cmp r0,2h +08011808 (T) bgt 801180Ch +0801180A (T) b 8011B8Ch +0801180C (T) mov r1,r9 +0801180E (T) add r1,7Ch +08011810 (T) ldrh r0,[r1] +08011812 (T) sub r0,1h +08011814 (T) mov r2,0h +08011816 (T) strh r0,[r1] +08011818 (T) str r2,[r3,4h] +0801181A (T) ldrh r0,[r1] +0801181C (T) cmp r0,0h +0801181E (T) beq 8011822h +08011820 (T) b 8011B8Ch +08011822 (T) mov r0,2h +08011824 (T) mov r4,r10 +08011826 (T) str r0,[r4] +08011828 (T) b 8011B8Ch +0801182A (T) ldr r3,[r3] +0801182C (T) ldr r0,[r3,4h] +0801182E (T) cmp r0,2Ch +08011830 (T) bgt 8011834h +08011832 (T) b 8011B8Ch +08011834 (T) mov r0,0h +08011836 (T) str r0,[r3,4h] +08011838 (T) mov r1,0A6h +0801183A (T) lsl r1,r1,2h +0801183C (T) add r1,r9 +0801183E (T) mov r2,0h +08011840 (T) mov r6,3h +08011842 (T) ldr r0,[r1,20h] +08011844 (T) str r0,[r1] +08011846 (T) str r2,[r1,10h] +08011848 (T) add r1,4h +0801184A (T) sub r6,1h +0801184C (T) cmp r6,0h +0801184E (T) bge 8011842h +08011850 (T) mov r0,3h +08011852 (T) mov r7,r10 +08011854 (T) str r0,[r7] +08011856 (T) b 8011B8Ch +08011858 (T) mov r6,0h +0801185A (T) mov r7,r13 +0801185C (T) sub r7,4h +0801185E (T) mov r8,r9 +08011860 (T) mov r3,0A2h +08011862 (T) lsl r3,r3,2h +08011864 (T) add r3,r9 +08011866 (T) mov r5,r9 +08011868 (T) add r5,88h +0801186A (T) ldr r0,[r3,10h] +0801186C (T) ldr r1,[r3] +0801186E (T) sub r0,r0,r1 +08011870 (T) str r0,[r3,10h] +08011872 (T) ldr r1,=2FFFh +08011874 (T) cmp r0,r1 +08011876 (T) bgt 801187Eh +08011878 (T) mov r0,0C0h +0801187A (T) lsl r0,r0,6h +0801187C (T) str r0,[r3,10h] +0801187E (T) ldr r1,[r3,20h] +08011880 (T) ldr r0,[r3,10h] +08011882 (T) add r1,r1,r0 +08011884 (T) asr r2,r1,10h +08011886 (T) ldr r0,=0FFFFh +08011888 (T) and r1,r0 +0801188A (T) str r1,[r3,20h] +0801188C (T) mov r4,84h +0801188E (T) lsl r4,r4,1h +08011890 (T) add r4,r8 +08011892 (T) ldr r0,[r4,24h] +08011894 (T) sub r1,r0,r2 +08011896 (T) str r1,[r4,24h] +08011898 (T) cmp r6,0h +0801189A (T) bne 80118ACh +0801189C (T) ldr r0,[r5,24h] +0801189E (T) add r0,r0,r2 +080118A0 (T) str r0,[r5,24h] +080118A2 (T) b 80118C0h +080118A4 (T) cmp r7,0FFh +080118A6 (T) lsl r0,r0,0h +080118A8 (T) bl lr+0FFEh +080118AA (T) lsl r0,r0,0h +080118AC (T) mov r0,84h +080118AE (T) lsl r0,r0,1h +080118B0 (T) add r0,r9 +080118B2 (T) ldr r2,[r0,24h] +080118B4 (T) sub r0,r1,r2 +080118B6 (T) ldr r1,[r7] +080118B8 (T) cmp r0,r1 +080118BA (T) bgt 80118C0h +080118BC (T) add r0,r2,r1 +080118BE (T) str r0,[r4,24h] +080118C0 (T) add r7,4h +080118C2 (T) mov r0,40h +080118C4 (T) add r8,r0 +080118C6 (T) add r3,4h +080118C8 (T) add r6,1h +080118CA (T) cmp r6,3h +080118CC (T) ble 801186Ah +080118CE (T) add r0,0C8h +080118D0 (T) add r0,r9 +080118D2 (T) ldr r1,[r0,24h] +080118D4 (T) ldr r0,[sp,54h] +080118D6 (T) cmp r1,r0 +080118D8 (T) blt 80118DCh +080118DA (T) b 8011B8Ch +080118DC (T) add r2,sp,2Ch +080118DE (T) mov r1,r9 +080118E0 (T) add r1,0ACh +080118E2 (T) add r5,sp,4Ch +080118E4 (T) mov r6,7h +080118E6 (T) ldmia [r5]!,r0 +080118E8 (T) str r0,[r1] +080118EA (T) ldmia [r2]!,r0 +080118EC (T) str r0,[r1,4h] +080118EE (T) add r1,40h +080118F0 (T) sub r6,1h +080118F2 (T) cmp r6,0h +080118F4 (T) bge 80118E6h +080118F6 (T) mov r0,4h +080118F8 (T) b 80119D8h +080118FA (T) mov r0,5h +080118FC (T) b 8011B60h +080118FE (T) ldr r3,[r3] +08011900 (T) ldr r0,[r3,4h] +08011902 (T) cmp r0,3h +08011904 (T) bgt 8011908h +08011906 (T) b 8011B8Ch +08011908 (T) mov r0,0h +0801190A (T) str r0,[r3,4h] +0801190C (T) mov r2,r9 +0801190E (T) add r2,7Eh +08011910 (T) ldrh r0,[r2] +08011912 (T) add r1,r0,1 +08011914 (T) strh r1,[r2] +08011916 (T) lsl r0,r1,10h +08011918 (T) asr r0,r0,10h +0801191A (T) cmp r0,7h +0801191C (T) ble 801193Ch +0801191E (T) mov r0,6h +08011920 (T) mov r3,r10 +08011922 (T) str r0,[r3] +08011924 (T) mov r4,r9 +08011926 (T) ldr r0,[r4,4h] +08011928 (T) str r0,[r7,8h] +0801192A (T) ldr r0,=5000200h +0801192C (T) str r0,[r7,0Ch] +0801192E (T) mov r0,20h +08011930 (T) str r0,[r7,10h] +08011932 (T) mov r0,1h +08011934 (T) str r0,[r7,4h] +08011936 (T) b 8011B4Ch +08011938 (T) lsl r0,r0,8h +0801193A (T) lsl r0,r0,14h +0801193C (T) mov r0,3h +0801193E (T) and r1,r0 +08011940 (T) lsl r1,r1,5h +08011942 (T) mov r2,r9 +08011944 (T) ldr r0,[r2,0Ch] +08011946 (T) add r0,r0,r1 +08011948 (T) str r0,[r7,8h] +0801194A (T) ldr r0,=5000200h +0801194C (T) str r0,[r7,0Ch] +0801194E (T) mov r0,20h +08011950 (T) str r0,[r7,10h] +08011952 (T) mov r0,1h +08011954 (T) str r0,[r7,4h] +08011956 (T) b 8011B4Ch +08011958 (T) lsl r0,r0,8h +0801195A (T) lsl r0,r0,14h +0801195C (T) ldr r3,[r3] +0801195E (T) ldr r0,[r3,4h] +08011960 (T) cmp r0,2Ch +08011962 (T) bgt 8011966h +08011964 (T) b 8011B8Ch +08011966 (T) mov r0,7h +08011968 (T) mov r4,r10 +0801196A (T) str r0,[r4] +0801196C (T) mov r0,0h +0801196E (T) str r0,[r3,4h] +08011970 (T) b 8011B8Ch +08011972 (T) ldr r0,[r3] +08011974 (T) ldr r0,[r0,4h] +08011976 (T) cmp r0,1h +08011978 (T) bgt 801197Ch +0801197A (T) b 8011B8Ch +0801197C (T) mov r2,r9 +0801197E (T) add r2,88h +08011980 (T) mov r1,r9 +08011982 (T) add r1,0B0h +08011984 (T) mov r6,7h +08011986 (T) ldr r0,[r1] +08011988 (T) sub r0,1h +0801198A (T) str r0,[r1] +0801198C (T) add r1,40h +0801198E (T) sub r6,1h +08011990 (T) cmp r6,0h +08011992 (T) bge 8011986h +08011994 (T) ldr r1,[r2,28h] +08011996 (T) ldr r0,[sp,0Ch] +08011998 (T) cmp r1,r0 +0801199A (T) ble 801199Eh +0801199C (T) b 8011B8Ch +0801199E (T) mov r2,r8 +080119A0 (T) mov r1,r9 +080119A2 (T) add r1,88h +080119A4 (T) mov r6,7h +080119A6 (T) ldmia [r2]!,r0 +080119A8 (T) str r0,[r1,28h] +080119AA (T) add r1,40h +080119AC (T) sub r6,1h +080119AE (T) cmp r6,0h +080119B0 (T) bge 80119A6h +080119B2 (T) mov r6,8h +080119B4 (T) mov r7,r10 +080119B6 (T) str r6,[r7] +080119B8 (T) b 8011B8Ch +080119BA (T) mov r1,r9 +080119BC (T) add r1,7Ah +080119BE (T) mov r2,0h +080119C0 (T) mov r0,0C3h +080119C2 (T) strh r0,[r1] +080119C4 (T) sub r1,2h +080119C6 (T) mov r0,88h +080119C8 (T) lsl r0,r0,5h +080119CA (T) strh r0,[r1] +080119CC (T) add r1,4h +080119CE (T) mov r0,10h +080119D0 (T) strh r0,[r1] +080119D2 (T) ldr r0,[r3] +080119D4 (T) str r2,[r0,4h] +080119D6 (T) mov r0,9h +080119D8 (T) mov r1,r10 +080119DA (T) str r0,[r1] +080119DC (T) b 8011B8Ch +080119DE (T) ldr r3,[r3] +080119E0 (T) ldr r0,[r3,4h] +080119E2 (T) cmp r0,9h +080119E4 (T) bgt 80119E8h +080119E6 (T) b 8011B8Ch +080119E8 (T) mov r1,r9 +080119EA (T) add r1,7Ch +080119EC (T) ldrh r0,[r1] +080119EE (T) sub r0,1h +080119F0 (T) mov r2,0h +080119F2 (T) strh r0,[r1] +080119F4 (T) str r2,[r3,4h] +080119F6 (T) ldrh r0,[r1] +080119F8 (T) cmp r0,0h +080119FA (T) beq 80119FEh +080119FC (T) b 8011B8Ch +080119FE (T) mov r0,0Ah +08011A00 (T) b 8011B60h +08011A02 (T) mov r0,0Bh +08011A04 (T) mov r4,r10 +08011A06 (T) str r0,[r4] +08011A08 (T) mov r0,r9 +08011A0A (T) add r0,7Eh +08011A0C (T) mov r1,0h +08011A0E (T) strh r1,[r0] +08011A10 (T) add r0,2h +08011A12 (T) strh r1,[r0] +08011A14 (T) ldr r0,[r3] +08011A16 (T) str r1,[r0,4h] +08011A18 (T) b 8011B8Ch +08011A1A (T) ldr r3,[r3] +08011A1C (T) ldr r0,[r3,4h] +08011A1E (T) cmp r0,3h +08011A20 (T) bgt 8011A24h +08011A22 (T) b 8011B8Ch +08011A24 (T) mov r0,0h +08011A26 (T) str r0,[r3,4h] +08011A28 (T) mov r0,7Eh +08011A2A (T) add r0,r9 +08011A2C (T) mov r8,r0 +08011A2E (T) ldrh r0,[r0] +08011A30 (T) add r0,1h +08011A32 (T) mov r1,r8 +08011A34 (T) strh r0,[r1] +08011A36 (T) mov r1,r9 +08011A38 (T) add r1,80h +08011A3A (T) ldrh r0,[r1] +08011A3C (T) add r2,r0,1 +08011A3E (T) strh r2,[r1] +08011A40 (T) mov r3,r8 +08011A42 (T) mov r4,0h +08011A44 (T) ldsh r0,[r3,r4] +08011A46 (T) cmp r0,7h +08011A48 (T) ble 8011B10h +08011A4A (T) mov r0,0Ch +08011A4C (T) mov r1,r10 +08011A4E (T) str r0,[r1] +08011A50 (T) mov r2,r9 +08011A52 (T) ldr r0,[r2] +08011A54 (T) str r0,[r7,8h] +08011A56 (T) mov r0,0A0h +08011A58 (T) lsl r0,r0,13h +08011A5A (T) str r0,[r7,0Ch] +08011A5C (T) mov r5,20h +08011A5E (T) str r5,[r7,10h] +08011A60 (T) mov r4,1h +08011A62 (T) str r4,[r7,4h] +08011A64 (T) mov r0,r7 +08011A66 (T) bl 8005D5Ch +08011A6A (T) add r7,14h +08011A6C (T) mov r3,r9 +08011A6E (T) ldr r0,[r3,4h] +08011A70 (T) str r0,[r7,8h] +08011A72 (T) ldr r0,=5000200h +08011A74 (T) str r0,[r7,0Ch] +08011A76 (T) str r5,[r7,10h] +08011A78 (T) str r4,[r7,4h] +08011A7A (T) b 8011B4Ch +08011A7C (T) lsl r0,r0,8h +08011A7E (T) lsl r0,r0,14h +08011A80 (T) ldr r0,[r3] +08011A82 (T) mov r1,0h +08011A84 (T) str r1,[r0,4h] +08011A86 (T) mov r0,0Dh +08011A88 (T) b 8011B60h +08011A8A (T) ldr r3,[r3] +08011A8C (T) ldr r0,[r3,4h] +08011A8E (T) cmp r0,0EFh +08011A90 (T) bgt 8011A94h +08011A92 (T) b 8011B8Ch +08011A94 (T) mov r0,0Eh +08011A96 (T) mov r4,r10 +08011A98 (T) str r0,[r4] +08011A9A (T) mov r1,r9 +08011A9C (T) add r1,7Eh +08011A9E (T) mov r0,0h +08011AA0 (T) strh r0,[r1] +08011AA2 (T) add r1,2h +08011AA4 (T) strh r0,[r1] +08011AA6 (T) str r0,[r3,4h] +08011AA8 (T) b 8011B8Ch +08011AAA (T) ldr r3,[r3] +08011AAC (T) ldr r0,[r3,4h] +08011AAE (T) cmp r0,3h +08011AB0 (T) ble 8011B8Ch +08011AB2 (T) mov r0,0h +08011AB4 (T) str r0,[r3,4h] +08011AB6 (T) mov r0,7Eh +08011AB8 (T) add r0,r9 +08011ABA (T) mov r8,r0 +08011ABC (T) ldrh r0,[r0] +08011ABE (T) add r0,1h +08011AC0 (T) mov r1,r8 +08011AC2 (T) strh r0,[r1] +08011AC4 (T) mov r1,r9 +08011AC6 (T) add r1,80h +08011AC8 (T) ldrh r0,[r1] +08011ACA (T) add r2,r0,1 +08011ACC (T) strh r2,[r1] +08011ACE (T) mov r3,r8 +08011AD0 (T) mov r4,0h +08011AD2 (T) ldsh r0,[r3,r4] +08011AD4 (T) cmp r0,7h +08011AD6 (T) ble 8011B10h +08011AD8 (T) mov r0,0Fh +08011ADA (T) mov r1,r10 +08011ADC (T) str r0,[r1] +08011ADE (T) mov r2,r9 +08011AE0 (T) ldr r0,[r2] +08011AE2 (T) str r0,[r7,8h] +08011AE4 (T) mov r0,0A0h +08011AE6 (T) lsl r0,r0,13h +08011AE8 (T) str r0,[r7,0Ch] +08011AEA (T) mov r5,20h +08011AEC (T) str r5,[r7,10h] +08011AEE (T) mov r4,1h +08011AF0 (T) str r4,[r7,4h] +08011AF2 (T) mov r0,r7 +08011AF4 (T) bl 8005D5Ch +08011AF8 (T) add r7,14h +08011AFA (T) mov r3,r9 +08011AFC (T) ldr r0,[r3,4h] +08011AFE (T) str r0,[r7,8h] +08011B00 (T) ldr r0,=5000200h +08011B02 (T) str r0,[r7,0Ch] +08011B04 (T) str r5,[r7,10h] +08011B06 (T) str r4,[r7,4h] +08011B08 (T) b 8011B4Ch +08011B0A (T) lsl r0,r0,0h +08011B0C (T) lsl r0,r0,8h +08011B0E (T) lsl r0,r0,14h +08011B10 (T) mov r4,3h +08011B12 (T) and r2,r4 +08011B14 (T) lsl r1,r2,5h +08011B16 (T) mov r2,r9 +08011B18 (T) ldr r0,[r2,8h] +08011B1A (T) add r0,r0,r1 +08011B1C (T) str r0,[r7,8h] +08011B1E (T) mov r0,0A0h +08011B20 (T) lsl r0,r0,13h +08011B22 (T) str r0,[r7,0Ch] +08011B24 (T) mov r6,20h +08011B26 (T) str r6,[r7,10h] +08011B28 (T) mov r5,1h +08011B2A (T) str r5,[r7,4h] +08011B2C (T) mov r0,r7 +08011B2E (T) bl 8005D5Ch +08011B32 (T) add r7,14h +08011B34 (T) mov r3,r8 +08011B36 (T) ldrh r0,[r3] +08011B38 (T) and r4,r0 +08011B3A (T) lsl r4,r4,5h +08011B3C (T) mov r1,r9 +08011B3E (T) ldr r0,[r1,0Ch] +08011B40 (T) add r0,r0,r4 +08011B42 (T) str r0,[r7,8h] +08011B44 (T) ldr r0,=5000200h +08011B46 (T) str r0,[r7,0Ch] +08011B48 (T) str r6,[r7,10h] +08011B4A (T) str r5,[r7,4h] +08011B4C (T) mov r0,r7 +08011B4E (T) bl 8005D5Ch +08011B52 (T) b 8011B8Ch +08011B54 (T) lsl r0,r0,8h +08011B56 (T) lsl r0,r0,14h +08011B58 (T) ldr r0,[r3] +08011B5A (T) mov r1,0h +08011B5C (T) str r1,[r0,4h] +08011B5E (T) mov r0,10h +08011B60 (T) mov r2,r10 +08011B62 (T) str r0,[r2] +08011B64 (T) b 8011B8Ch +08011B66 (T) ldr r0,[r3] +08011B68 (T) ldr r0,[r0,4h] +08011B6A (T) cmp r0,63h +08011B6C (T) ble 8011B8Ch +08011B6E (T) mov r0,11h +08011B70 (T) mov r3,r10 +08011B72 (T) str r0,[r3] +08011B74 (T) b 8011B8Ch +08011B76 (T) ldr r1,=30012D0h +08011B78 (T) ldr r0,=80B6F81h +08011B7A (T) str r0,[r1] +08011B7C (T) mov r0,1h +08011B7E (T) neg r0,r0 +08011B80 (T) b 8011BE6h +08011B82 (T) lsl r0,r0,0h +08011B84 (T) asr r0,r2,0Bh +08011B86 (T) lsl r0,r0,0Ch +08011B88 (T) ldr r1,[r0,78h] +08011B8A (T) lsr r3,r1,20h +08011B8C (T) mov r5,r9 +08011B8E (T) add r5,7Ch +08011B90 (T) mov r4,r9 +08011B92 (T) add r4,88h +08011B94 (T) mov r6,5h +08011B96 (T) mov r0,r4 +08011B98 (T) bl 8008BB0h +08011B9C (T) mov r0,r4 +08011B9E (T) mov r1,0h +08011BA0 (T) bl 8008C54h +08011BA4 (T) add r4,40h +08011BA6 (T) sub r6,1h +08011BA8 (T) cmp r6,0h +08011BAA (T) bge 8011B96h +08011BAC (T) mov r4,r10 +08011BAE (T) ldr r0,[r4] +08011BB0 (T) cmp r0,9h +08011BB2 (T) ble 8011BDCh +08011BB4 (T) mov r4,82h +08011BB6 (T) lsl r4,r4,2h +08011BB8 (T) add r4,r9 +08011BBA (T) mov r0,r4 +08011BBC (T) bl 8008BB0h +08011BC0 (T) mov r0,r4 +08011BC2 (T) mov r1,0h +08011BC4 (T) bl 8008C54h +08011BC8 (T) mov r4,92h +08011BCA (T) lsl r4,r4,2h +08011BCC (T) add r4,r9 +08011BCE (T) mov r0,r4 +08011BD0 (T) bl 8008BB0h +08011BD4 (T) mov r0,r4 +08011BD6 (T) mov r1,0h +08011BD8 (T) bl 8008C54h +08011BDC (T) ldr r0,=3000370h +08011BDE (T) ldr r1,[r0] +08011BE0 (T) ldrh r0,[r5] +08011BE2 (T) str r0,[r1,0Ch] +08011BE4 (T) mov r0,0h +08011BE6 (T) add sp,94h +08011BE8 (T) pop r3-r5 +08011BEA (T) mov r8,r3 +08011BEC (T) mov r9,r4 +08011BEE (T) mov r10,r5 +08011BF0 (T) pop r4-r7 +08011BF2 (T) pop r1 +08011BF4 (T) bx r1 + +//============================================================================= +// $8011499: +08011498 (T) push r4,r14 +0801149A (T) add sp,-4h +0801149C (T) ldr r0,=3000370h +0801149E (T) ldr r0,[r0] +080114A0 (T) ldr r4,[r0,14h] +080114A2 (T) ldr r0,=3002570h +080114A4 (T) ldr r1,[r0] +080114A6 (T) ldr r0,=3002A30h +080114A8 (T) ldr r2,[r0] +080114AA (T) lsl r0,r1,1h +080114AC (T) add r0,r0,r1 +080114AE (T) lsl r0,r0,4h +080114B0 (T) add r1,r0,r2 +080114B2 (T) ldrb r0,[r1,8h] +080114B4 (T) cmp r0,0h +080114B6 (T) bne 80114D0h +080114B8 (T) bl 8000454h +080114BC (T) bl 8005D50h +080114C0 (T) b 801156Eh +080114C2 (T) lsl r0,r0,0h +080114C4 (T) lsl r0,r6,0Dh +080114C6 (T) lsl r0,r0,0Ch +080114C8 (T) mov r5,70h +080114CA (T) lsl r0,r0,0Ch +080114CC (T) cmp r2,30h +080114CE (T) lsl r0,r0,0Ch +080114D0 (T) ldrb r0,[r1,0Bh] +080114D2 (T) cmp r0,1h +080114D4 (T) bne 80114DCh +080114D6 (T) bl 8000C28h +080114DA (T) b 801156Eh +080114DC (T) bl 80F47E4h +080114E0 (T) ldr r1,=4000010h +080114E2 (T) ldr r0,=3001B20h +080114E4 (T) ldrh r0,[r0] +080114E6 (T) strh r0,[r1] +080114E8 (T) add r1,2h +080114EA (T) ldr r0,=30012DCh +080114EC (T) ldrh r0,[r0] +080114EE (T) strh r0,[r1] +080114F0 (T) add r1,2h +080114F2 (T) ldr r0,=3001D30h +080114F4 (T) ldrh r0,[r0] +080114F6 (T) strh r0,[r1] +080114F8 (T) add r1,2h +080114FA (T) ldr r0,=30012E8h +080114FC (T) ldrh r0,[r0] +080114FE (T) strh r0,[r1] +08011500 (T) mov r0,r4 +08011502 (T) add r0,84h +08011504 (T) ldr r0,[r0] +08011506 (T) cmp r0,1h +08011508 (T) blt 8011536h +0801150A (T) cmp r0,2h +0801150C (T) ble 8011522h +0801150E (T) cmp r0,0Ah +08011510 (T) bgt 8011536h +08011512 (T) cmp r0,9h +08011514 (T) blt 8011536h +08011516 (T) mov r1,80h +08011518 (T) lsl r1,r1,13h +0801151A (T) mov r0,r4 +0801151C (T) add r0,78h +0801151E (T) ldrh r0,[r0] +08011520 (T) strh r0,[r1] +08011522 (T) ldr r1,=4000050h +08011524 (T) mov r0,r4 +08011526 (T) add r0,7Ah +08011528 (T) ldrh r0,[r0] +0801152A (T) strh r0,[r1] +0801152C (T) add r1,4h +0801152E (T) mov r0,r4 +08011530 (T) add r0,7Ch +08011532 (T) ldrh r0,[r0] +08011534 (T) strh r0,[r1] +08011536 (T) ldr r1,=40000D4h +08011538 (T) ldr r2,=30033A0h +0801153A (T) str r2,[r1] +0801153C (T) mov r0,0E0h +0801153E (T) lsl r0,r0,13h +08011540 (T) str r0,[r1,4h] +08011542 (T) ldr r0,=84000100h +08011544 (T) str r0,[r1,8h] +08011546 (T) ldr r0,[r1,8h] +08011548 (T) mov r0,0A0h +0801154A (T) str r0,[sp] +0801154C (T) mov r0,r13 +0801154E (T) str r0,[r1] +08011550 (T) str r2,[r1,4h] +08011552 (T) ldr r0,=85000100h +08011554 (T) str r0,[r1,8h] +08011556 (T) ldr r0,[r1,8h] +08011558 (T) ldr r0,=3003390h +0801155A (T) mov r1,0h +0801155C (T) str r1,[r0] +0801155E (T) ldr r0,=3003394h +08011560 (T) str r1,[r0] +08011562 (T) bl 8005D6Ch +08011566 (T) bl 800E5E4h +0801156A (T) bl 8000454h +0801156E (T) mov r0,0h +08011570 (T) add sp,4h +08011572 (T) pop r4 +08011574 (T) pop r1 +08011576 (T) bx r1 + +//============================================================================= +// $8011495: +08011494 (T) movs r0,0h +08011496 (T) bx r14 diff --git a/src/data/m2-title-background-pal-copyright.bin b/src/data/m2-title-background-pal-copyright.bin deleted file mode 100644 index 6b8fc8ccc974a1bf16ccb8196e70cbab4b40f7c4..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 256 wcmZRUVU|hLSfTUMfZNj7w$E{c=SN@TpwOskaW|5FW?APm3~|5=^dCM507C%{?EnA( diff --git a/src/data/m2-title-background-pal-copyright.c.bin b/src/data/m2-title-background-pal-copyright.c.bin new file mode 100644 index 0000000000000000000000000000000000000000..f54eac09e21b6abbff5fcf2626a1bfbebbdd0c99 GIT binary patch literal 72 zcmWe&U}RummSL7j(^#Ry@X~}T-g6X9s~vC834BPG&2AI literal 0 HcmV?d00001 diff --git a/src/data/m2-title-text-pal-animated.bin b/src/data/m2-title-text-pal-animated.bin deleted file mode 100644 index 977316bdee00cc65f6673e4179107c3616bde7c8..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 448 zcmZQzAO!9+|F8cZ7aCaZTJAc-ai--i)7^%5H1BBsQ~WRcUy_00KC^M`_c)Lm-0~rz zp@9%J*!6?tLFPl$V44q;2iXr%gK9srJji_zH3;{i%Y)nxQ3G*5HhGx;2!{`T6`=6L O4MFyYgyM#T+y?;iDxm!U diff --git a/src/data/m2-title-text-pal-animated.c.bin b/src/data/m2-title-text-pal-animated.c.bin new file mode 100644 index 0000000000000000000000000000000000000000..ba1efba1818fe07dfd90cac76e768c44807d0164 GIT binary patch literal 124 zcmWeQz{p_0!0>@_1LJ+>|Md*t<3a<=UCUh=W;o8Y+-17kkl~Kz9nF7=|78{bOA5#v z$9|6!P(J)YK0rPsG&Ima`Gfrb0C|CU5Cca4pD-W9g^(BKe_;G`QT~JQMf(qo0gM7b NZ68345A!$72LOWcG2H+F literal 0 HcmV?d00001 diff --git a/src/data/m2-title-text-pal-static.bin b/src/data/m2-title-text-pal-static.bin deleted file mode 100644 index b0a55159bb044f9b333fbd32ccbfc07efd01c7b8..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 32 NcmZQz_+O6?0svm#7GnSa diff --git a/src/data/m2-title-text-pal-static.c.bin b/src/data/m2-title-text-pal-static.c.bin new file mode 100644 index 0000000000000000000000000000000000000000..44bfd852e21c9b4f390207e96d30c9857dc15ae3 GIT binary patch literal 16 XcmWeoU|`^3VEAAEfw6#*fq?-4894(T literal 0 HcmV?d00001 diff --git a/src/m2-hack.asm b/src/m2-hack.asm index 6d10499..e6768b4 100644 --- a/src/m2-hack.asm +++ b/src/m2-hack.asm @@ -1483,7 +1483,7 @@ nop // Title screen hacks //============================================================================== -// m2_title_background_pal_copyright: File has two palettes separates by six palettes +// m2_title_background_pal_copyright: File has two palettes separated by six palettes // worth of nullspace. First palette is the copyright palette, // last palette is a placeholder for the glow palette // m2_title_background_pal_glow: 20 frames, glow effect @@ -1522,11 +1522,34 @@ nop // g+29 1 16/32 grey B // g+30 2 17/32 grey B -// Animation 3 (full title screen) +// --- Animation 3 (full title screen) --- .org 0x82D6B64 :: dh 0x008A // Enable 8-bit BG0 .org 0x80119C6 :: mov r0,0x88 // Disable BG1 -// Animation 5 (quick title screen) +// Initializer hacks: + + // Point to new compressed palettes + .org 0x801147C + dw m2_title_text_pal_animated + 4 + dw m2_title_text_pal_static + 4 + dw m2_title_background_pal_copyright + 4 + dw m2_title_background_pal_glow + 4 + + // The new palettes have different sizes (8, 20, 14, 1 palettes respectively), so encode the proper buffer pointers + .org 0x801146C + dw 0x2011500 + dw 0x2011780 + dw 0x2011940 + dw 0x2011960 + + // Define the proper expected uncompressed sizes + .org 0x801141E :: mov r5,4 :: neg r5,r5 + .org 0x8011422 :: ldr r2,[r0,r5] + .org 0x801142C :: ldr r2,[r0,r5] + .org 0x8011436 :: ldr r2,[r0,r5] + .org 0x8011440 :: ldr r2,[r0,r5] + +// --- Animation 5 (quick title screen) --- .org 0x82D6BD4 :: dh 0x008A // Enable 8-bit BG0 .org 0x82D6BE0 :: dh 0x1100 // Disable BG1 @@ -1649,17 +1672,19 @@ flyovertextLater: m2_coord_table_file: .incbin "data/m2-coord-table-file-select.bin" +.align 4 + m2_title_background_pal_copyright: -.incbin "data/m2-title-background-pal-copyright.bin" +dw 0x100 :: .incbin "data/m2-title-background-pal-copyright.c.bin" m2_title_background_pal_glow: -.incbin "data/m2-title-background-pal-glow.bin" +dw 0x280 :: .incbin "data/m2-title-background-pal-glow.c.bin" m2_title_text_pal_animated: -.incbin "data/m2-title-text-pal-animated.bin" +dw 0x1C0 :: .incbin "data/m2-title-text-pal-animated.c.bin" m2_title_text_pal_static: -.incbin "data/m2-title-text-pal-static.bin" +dw 0x20 :: .incbin "data/m2-title-text-pal-static.c.bin" //============================================================================== // Existing subroutines/data From a2d7dcfbfad04bfd0509444d33e6734c886d80b1 Mon Sep 17 00:00:00 2001 From: jeffman Date: Wed, 11 Sep 2019 23:20:55 -0400 Subject: [PATCH 02/32] Update notes --- notes/m2-sub111D0.txt | 11 +++++++++ notes/m2-title-long.txt | 54 ++++++++++++++++++++++++++++++----------- 2 files changed, 51 insertions(+), 14 deletions(-) diff --git a/notes/m2-sub111D0.txt b/notes/m2-sub111D0.txt index abff02d..7c66700 100644 --- a/notes/m2-sub111D0.txt +++ b/notes/m2-sub111D0.txt @@ -27,6 +27,17 @@ // 2 = HALKEN // 3 = Title screen (full) // 5 = Title screen (quick) + +// 0x18 byte struct: ($2028008) +// Offset Length Description +// ------------------------------------ +// 0 4 Animation number +// 4 4 Current frame +// 8 4 ? +// C 4 ? +// 10 4 ? +// 14 4 Pointer to giant 0x2E0 byte struct used in $80113F5 + 080111D0 (T) push r4-r7,r14 080111D2 (T) mov r7,r9 080111D4 (T) mov r6,r8 diff --git a/notes/m2-title-long.txt b/notes/m2-title-long.txt index 3b04cba..c072a47 100644 --- a/notes/m2-title-long.txt +++ b/notes/m2-title-long.txt @@ -82,12 +82,14 @@ //============================================================================= // $80115A9: + +// Load a bunch of constants to the stack 080115A8 (T) push r4-r7,r14 080115AA (T) mov r7,r10 080115AC (T) mov r6,r9 080115AE (T) mov r5,r8 080115B0 (T) push r5-r7 -080115B2 (T) add sp,-94h +080115B2 (T) add sp,-94h // damn... 080115B4 (T) mov r1,r13 080115B6 (T) ldr r0,=80FCB74h 080115B8 (T) ldmia [r0]!,r2-r4 @@ -129,6 +131,7 @@ 08011600 (T) stmia [r1]!,r2,r3,r7 08011602 (T) ldmia [r0]!,r2,r3 08011604 (T) stmia [r1]!,r2,r3 + 08011606 (T) ldr r3,=3000370h 08011608 (T) ldr r7,[r3] 0801160A (T) mov r12,r7 @@ -145,10 +148,12 @@ 08011620 (T) add r0,r0,r1 08011622 (T) lsl r0,r0,4h 08011624 (T) add r0,r0,r2 -08011626 (T) ldrb r1,[r0,8h] +08011626 (T) ldrb r1,[r0,8h] // appears to be a has-this-been-run-yet flag 08011628 (T) cmp r1,0h 0801162A (T) beq 801162Eh 0801162C (T) b 8011730h + +// If this is the first run: 0801162E (T) mov r0,r9 08011630 (T) add r0,84h 08011632 (T) str r1,[r0] @@ -274,11 +279,15 @@ 0801172A (T) lsl r0,r0,0Ch 0801172C (T) cmp r7,0B0h 0801172E (T) lsr r1,r6,1h -08011730 (T) ldrb r0,[r0,0Bh] +08011730 (T) ldrb r0,[r0,0Bh] // appears to be an are-we-on-the-last-run flag 08011732 (T) cmp r0,1h 08011734 (T) bne 801173Ch + +// If this is the last run: 08011736 (T) bl 8000C28h 0801173A (T) b 8011BE4h + +// Else: 0801173C (T) ldr r0,=3002500h 0801173E (T) ldrh r1,[r0] 08011740 (T) mov r0,9h @@ -889,11 +898,13 @@ 080114AC (T) add r0,r0,r1 080114AE (T) lsl r0,r0,4h 080114B0 (T) add r1,r0,r2 -080114B2 (T) ldrb r0,[r1,8h] +080114B2 (T) ldrb r0,[r1,8h] // already-executed flag 080114B4 (T) cmp r0,0h 080114B6 (T) bne 80114D0h -080114B8 (T) bl 8000454h -080114BC (T) bl 8005D50h + +// If first run: +080114B8 (T) bl 8000454h // check pad input +080114BC (T) bl 8005D50h // clears some flag 080114C0 (T) b 801156Eh 080114C2 (T) lsl r0,r0,0h 080114C4 (T) lsl r0,r6,0Dh @@ -902,31 +913,40 @@ 080114CA (T) lsl r0,r0,0Ch 080114CC (T) cmp r2,30h 080114CE (T) lsl r0,r0,0Ch + +// If not the first run: 080114D0 (T) ldrb r0,[r1,0Bh] 080114D2 (T) cmp r0,1h 080114D4 (T) bne 80114DCh + +// If last run: 080114D6 (T) bl 8000C28h 080114DA (T) b 801156Eh -080114DC (T) bl 80F47E4h + +// If not last run: +080114DC (T) bl 80F47E4h // wait for vblank + +// Set BG0 and BG1 scrolling offsets 080114E0 (T) ldr r1,=4000010h 080114E2 (T) ldr r0,=3001B20h 080114E4 (T) ldrh r0,[r0] -080114E6 (T) strh r0,[r1] +080114E6 (T) strh r0,[r1] // BG0OFSa 080114E8 (T) add r1,2h 080114EA (T) ldr r0,=30012DCh 080114EC (T) ldrh r0,[r0] -080114EE (T) strh r0,[r1] +080114EE (T) strh r0,[r1] // BG0OFSb 080114F0 (T) add r1,2h 080114F2 (T) ldr r0,=3001D30h 080114F4 (T) ldrh r0,[r0] -080114F6 (T) strh r0,[r1] +080114F6 (T) strh r0,[r1] // BG1OFSa 080114F8 (T) add r1,2h 080114FA (T) ldr r0,=30012E8h 080114FC (T) ldrh r0,[r0] -080114FE (T) strh r0,[r1] +080114FE (T) strh r0,[r1] // BG1OFSb + 08011500 (T) mov r0,r4 08011502 (T) add r0,84h -08011504 (T) ldr r0,[r0] +08011504 (T) ldr r0,[r0] // frame number 08011506 (T) cmp r0,1h 08011508 (T) blt 8011536h 0801150A (T) cmp r0,2h @@ -935,22 +955,28 @@ 08011510 (T) bgt 8011536h 08011512 (T) cmp r0,9h 08011514 (T) blt 8011536h + +// If on frames 9-A: 08011516 (T) mov r1,80h 08011518 (T) lsl r1,r1,13h 0801151A (T) mov r0,r4 0801151C (T) add r0,78h 0801151E (T) ldrh r0,[r0] 08011520 (T) strh r0,[r1] -08011522 (T) ldr r1,=4000050h + +// If on frames 1-2: +08011522 (T) ldr r1,=4000050h // BLDCNT (special effects) 08011524 (T) mov r0,r4 08011526 (T) add r0,7Ah 08011528 (T) ldrh r0,[r0] 0801152A (T) strh r0,[r1] -0801152C (T) add r1,4h +0801152C (T) add r1,4h // BLDY (brightness amount) 0801152E (T) mov r0,r4 08011530 (T) add r0,7Ch 08011532 (T) ldrh r0,[r0] 08011534 (T) strh r0,[r1] + +// If on frame 0, 3-8, or >A: 08011536 (T) ldr r1,=40000D4h 08011538 (T) ldr r2,=30033A0h 0801153A (T) str r2,[r1] From c43b2d8f2dfb10c7343fdad3a71533abd32f0146 Mon Sep 17 00:00:00 2001 From: jeffman Date: Wed, 11 Sep 2019 23:21:54 -0400 Subject: [PATCH 03/32] WIP new title screen code All it does right now is play the title screen sound for 5 seconds --- build.ps1 | 3 ++- src/c/ext.c | 4 +++- src/c/locs.c | 1 + src/c/locs.h | 1 + src/c/title.c | 32 ++++++++++++++++++++++++++++++++ src/c/title.h | 10 ++++++++++ src/m2-hack.asm | 11 +++++++++++ 7 files changed, 60 insertions(+), 2 deletions(-) create mode 100644 src/c/title.c create mode 100644 src/c/title.h diff --git a/build.ps1 b/build.ps1 index a59f039..1d87443 100644 --- a/build.ps1 +++ b/build.ps1 @@ -18,7 +18,8 @@ $input_c_files = "src/c/fileselect.c", "src/c/status.c", "src/c/battle.c", - "src/c/psi.c" + "src/c/psi.c", + "src/c/title.c" $base_c_address = 0x83755B8; $scripttool_cmd = "bin/ScriptTool/ScriptTool.dll" diff --git a/src/c/ext.c b/src/c/ext.c index 7544fb9..9b8b769 100644 --- a/src/c/ext.c +++ b/src/c/ext.c @@ -19,4 +19,6 @@ int __attribute__((naked)) m2_setupwindow(WINDOW* window, short window_x, short int __attribute__((naked)) m2_clearwindowtiles(WINDOW* window) {} int __attribute__((naked)) customcodes_parse_generic(int code, char* parserAddress, WINDOW* window, int* dest) {} void __attribute__((naked)) m2_printstr(WINDOW* window, byte* str, unsigned short x, unsigned short y, bool highlight) {} -void __attribute__((naked)) m2_setupbattlename(short value) {} \ No newline at end of file +void __attribute__((naked)) m2_setupbattlename(short value) {} +void __attribute__((naked)) m2_title_teardown() {} +void __attribute__((naked)) vblank() {} diff --git a/src/c/locs.c b/src/c/locs.c index b4fb7c9..12ffb2b 100644 --- a/src/c/locs.c +++ b/src/c/locs.c @@ -27,3 +27,4 @@ int *m2_items_offsets = (int*) 0x8B1AF94; byte *m2_items_strings = (byte*) 0x8B1A694; unsigned short *name_header_tiles = (unsigned short*) 0x8B1B8B0; PSIPrintInfo *psi_print_info = (PSIPrintInfo*) 0x8B2A9C0; +int *title_counter = (int*) 0x2011B60; diff --git a/src/c/locs.h b/src/c/locs.h index 0a49495..fc44869 100644 --- a/src/c/locs.h +++ b/src/c/locs.h @@ -34,5 +34,6 @@ extern byte *m2_items_strings; extern unsigned short *name_header_tiles; extern byte *character_general_data; extern PSIPrintInfo *psi_print_info; +extern int *title_counter; #endif diff --git a/src/c/title.c b/src/c/title.c new file mode 100644 index 0000000..aceed30 --- /dev/null +++ b/src/c/title.c @@ -0,0 +1,32 @@ +#include "title.h" +#include "locs.h" + +int title_frame_first() +{ + if (*title_counter == 0) + { + m2_soundeffect(0xAF); + } + + (*title_counter)++; + + if (*title_counter == 5 * 60) + { + m2_title_teardown(); + return -1; + } + + return 0; +} + +int title_frame_second() +{ + vblank(); + + if (*title_counter == 5 * 60) + { + m2_title_teardown(); + } + + return 0; +} diff --git a/src/c/title.h b/src/c/title.h new file mode 100644 index 0000000..29c4e79 --- /dev/null +++ b/src/c/title.h @@ -0,0 +1,10 @@ +#ifndef HEADER_TITLE_INCLUDED +#define HEADER_TITLE_INCLUDED + +int title_frame_first(); +int title_frame_second(); +extern void m2_title_teardown(); +extern void m2_soundeffect(int index); +extern void vblank(); + +#endif diff --git a/src/m2-hack.asm b/src/m2-hack.asm index e6768b4..5e0ab4e 100644 --- a/src/m2-hack.asm +++ b/src/m2-hack.asm @@ -1542,6 +1542,10 @@ nop dw 0x2011940 dw 0x2011960 + // Expand the null area after the fifth palette buffer (gives us 0x2A0 bytes of nullspace + // starting at 0x2011B60) + .org 0x8011490 :: dw 0x85000128 + // Define the proper expected uncompressed sizes .org 0x801141E :: mov r5,4 :: neg r5,r5 .org 0x8011422 :: ldr r2,[r0,r5] @@ -1549,6 +1553,11 @@ nop .org 0x8011436 :: ldr r2,[r0,r5] .org 0x8011440 :: ldr r2,[r0,r5] + // Replace per-frame functions + .org 0x82D6B7C + dw title_frame_first + 1 + dw title_frame_second + 1 + // --- Animation 5 (quick title screen) --- .org 0x82D6BD4 :: dh 0x008A // Enable 8-bit BG0 .org 0x82D6BE0 :: dh 0x1100 // Disable BG1 @@ -1749,11 +1758,13 @@ dw 0x20 :: .incbin "data/m2-title-text-pal-static.c.bin" .definelabel m2_sub_d6844 ,0x80D6844 .definelabel m2_setupbattlename ,0x80DCD00 .definelabel m2_stat_symb_checker ,0x8B0EDA4 +.definelabel vblank ,0x80F47E4 .definelabel m2_div ,0x80F49D8 .definelabel m2_remainder ,0x80F4A70 .definelabel m2_items ,0x8B1D62C .definelabel m2_default_names ,0x82B9330 .definelabel m2_psi_print_table ,0x8B2A9C0 +.definelabel m2_title_teardown ,0x8000C28 //============================================================================== // Code files From 1c4f61e7ce73af3cbd9cacfcd46e1d2267c67689 Mon Sep 17 00:00:00 2001 From: jeffman Date: Tue, 17 Sep 2019 00:04:33 -0400 Subject: [PATCH 04/32] Update notes --- notes/m2-sub111D0.txt | 14 +- notes/m2-title-long.txt | 580 +++++++++++++++++++++++++--------------- 2 files changed, 378 insertions(+), 216 deletions(-) diff --git a/notes/m2-sub111D0.txt b/notes/m2-sub111D0.txt index 7c66700..ab61c0d 100644 --- a/notes/m2-sub111D0.txt +++ b/notes/m2-sub111D0.txt @@ -18,9 +18,21 @@ // 24 4 Unused? // 28 16 Four-entry jump table // [0]: called at the start of the animation -// [1,2]: called for each frame +// [1,2]: called for each frame (seems to be setup and then commit) // [3]: called at the end of the animation +// Dump: +// ----- +// # BG0gfx OBJgfx BGpal OBJpal BG0map BG0attr BG1map BG1attr DISP jump - Start Setup Commit End +// ------------------------------------------------------------------------------------------------------------------------------------ +// [0] 08714840 00000000 087147E4 00000000 087143FC 000B 0000 00000000 0000 0000 1100 0000 00000000 0801200D 080120B1 08012035 08012011 +// [1] 00000000 00000000 00000000 00000000 08714538 000B 0000 00000000 0000 0000 1100 0001 00000000 0801200D 080120B1 08012035 08012011 +// [2] 00000000 00000000 00000000 00000000 08714688 000B 0000 00000000 0000 0000 1100 0001 00000000 0801200D 080120B1 08012035 08012011 +// [3] 0870F580 08711280 087126CC 087127E8 087128EC 000A 0000 08712CD8 010B 0000 1000 FFFF 00000000 080113F5 080115A9 08011499 08011495 +// [4] 0870F580 08711280 087126CC 087127E8 087128EC 000A 0000 08712CD8 010B 0000 1300 0001 00000000 080113F5 08011F05 08011499 08011495 +// [5] 0870F580 08711280 087126CC 087127E8 087128EC 000A 0000 08712CD8 010B 0000 1300 0001 00000000 080113F5 08011BFD 08011499 08011495 +// [6] 0871325C 00000000 08713210 00000000 08712FB8 000A 0000 00000000 0000 0000 0100 0001 00000000 0801200D 0801214D 08012035 08012011 + // r0: screen key // 0 = Nintendo // 1 = APE diff --git a/notes/m2-title-long.txt b/notes/m2-title-long.txt index c072a47..d89f8d2 100644 --- a/notes/m2-title-long.txt +++ b/notes/m2-title-long.txt @@ -6,7 +6,7 @@ // $8011499 // $8011495 -// 0x2E0 struct: +// 0x2E0 struct: (2028028) // Offset Length Description Value for long title screen // ------------------------------------------------------------------------------------------------------------ // 0 4 Palette A pointer (WRAM) -- background? x3 0x2011400 @@ -15,8 +15,31 @@ // C 4 Palette D pointer (WRAM) -- text or orb? x4 0x2011A00 // 10 4 Palette E pointer (WRAM) -- buffer? 0x2011C00 +// Sequences: +// ##: [dur] [dur] +// M2GBA EBGBA +// ----- ----- +// 00: start-up (play sound, etc.) +// 01: [ 48] earth fade-in [] B fade-in +// 02: [ 45] pause [] pause +// 03: [104] text flies in [] text flies in +// 04: [ 1] pause [] pause +// 05: [] flash text [] flash text +// 06: [] pause [] pause +// 07: [] text moves up [] do nothing +// 08: [] pause [] pause +// 09: [] background fade-in [] background fade-in +// 0A: [] pause [] pause +// 0B: [] flash all [] +// 0C: [] pause [] +// 0D: [] long pause [] +// 0E: [] flash all [] +// 0F: [] pause [] +// 10: [] long pause [] +// 11: [] quick fade-out all [] + //============================================================================= -// $80113F5: +// $80113F5: (Start) 080113F4 (T) push r4,r5,r14 080113F6 (T) add sp,-4h @@ -81,9 +104,9 @@ 08011462 (T) bx r1 //============================================================================= -// $80115A9: +// $80115A9: (Setup) -// Load a bunch of constants to the stack +// Load a bunch of constants to the stack ([80FCB74..80FCBFF] to [sp..sp+8B]) 080115A8 (T) push r4-r7,r14 080115AA (T) mov r7,r10 080115AC (T) mov r6,r9 @@ -134,14 +157,15 @@ 08011606 (T) ldr r3,=3000370h 08011608 (T) ldr r7,[r3] -0801160A (T) mov r12,r7 +0801160A (T) mov r12,r7 // r7 = r12 = 2028008 0801160C (T) mov r0,r12 0801160E (T) ldr r0,[r0,14h] 08011610 (T) mov r9,r0 -08011612 (T) mov r7,r9 +08011612 (T) mov r7,r9 // r7 = r9 = 2028028 + 08011614 (T) add r7,14h 08011616 (T) ldr r0,=3002570h -08011618 (T) ldr r1,[r0] +08011618 (T) ldr r1,[r0] // seems to always be 2? 0801161A (T) ldr r0,=3002A30h 0801161C (T) ldr r2,[r0] 0801161E (T) lsl r0,r1,1h @@ -154,172 +178,210 @@ 0801162C (T) b 8011730h // If this is the first run: -0801162E (T) mov r0,r9 -08011630 (T) add r0,84h -08011632 (T) str r1,[r0] -08011634 (T) mov r1,0A2h -08011636 (T) lsl r1,r1,2h -08011638 (T) add r1,r9 -0801163A (T) mov r0,88h -0801163C (T) lsl r0,r0,4h -0801163E (T) str r0,[r1] -08011640 (T) mov r2,0B2h -08011642 (T) lsl r2,r2,2h -08011644 (T) add r2,r9 -08011646 (T) ldr r1,[sp,54h] -08011648 (T) mov r0,0F0h -0801164A (T) sub r0,r0,r1 -0801164C (T) str r0,[r2] -0801164E (T) mov r1,0AEh -08011650 (T) lsl r1,r1,2h -08011652 (T) add r1,r9 -08011654 (T) mov r0,0C0h -08011656 (T) lsl r0,r0,0Ah -08011658 (T) str r0,[r1] -0801165A (T) mov r6,1h -0801165C (T) mov r7,0B2h -0801165E (T) lsl r7,r7,2h -08011660 (T) add r7,r9 -08011662 (T) mov r5,0B3h -08011664 (T) lsl r5,r5,2h -08011666 (T) add r5,r9 -08011668 (T) mov r1,r13 -0801166A (T) add r1,58h -0801166C (T) str r1,[sp,8Ch] -0801166E (T) mov r2,r13 -08011670 (T) add r2,78h -08011672 (T) str r2,[sp,90h] -08011674 (T) mov r3,0A2h -08011676 (T) lsl r3,r3,2h -08011678 (T) add r3,r9 -0801167A (T) mov r10,r3 -0801167C (T) mov r4,0A3h -0801167E (T) lsl r4,r4,2h -08011680 (T) add r4,r9 -08011682 (T) mov r8,r4 -08011684 (T) lsl r4,r6,2h -08011686 (T) ldr r0,[sp,90h] -08011688 (T) ldmia [r0]!,r1 -0801168A (T) str r0,[sp,90h] -0801168C (T) ldr r2,[sp,8Ch] -0801168E (T) ldmia [r2]!,r0 -08011690 (T) str r2,[sp,8Ch] -08011692 (T) sub r1,r1,r0 -08011694 (T) str r1,[r5] -08011696 (T) mov r0,0AEh -08011698 (T) lsl r0,r0,2h -0801169A (T) add r0,r9 -0801169C (T) add r4,r0,r4 -0801169E (T) ldr r0,[r0] -080116A0 (T) mul r0,r1 -080116A2 (T) ldr r1,[r7] -080116A4 (T) bl m2_div -080116A8 (T) str r0,[r4] -080116AA (T) ldmia [r5]!,r1 -080116AC (T) mov r3,r10 -080116AE (T) ldr r0,[r3] -080116B0 (T) mul r0,r1 -080116B2 (T) ldr r1,[r7] -080116B4 (T) bl m2_div -080116B8 (T) mov r4,r8 -080116BA (T) add r4,4h -080116BC (T) mov r8,r4 -080116BE (T) sub r4,4h -080116C0 (T) stmia [r4]!,r0 -080116C2 (T) add r6,1h -080116C4 (T) cmp r6,3h -080116C6 (T) ble 8011684h -080116C8 (T) mov r6,0h -080116CA (T) mov r10,r6 -080116CC (T) add r7,sp,2Ch -080116CE (T) mov r8,r7 -080116D0 (T) add r7,sp,6Ch -080116D2 (T) mov r5,r9 -080116D4 (T) add r5,0A8h -080116D6 (T) mov r4,r9 -080116D8 (T) add r4,88h -080116DA (T) mov r0,r4 -080116DC (T) ldr r1,=8712FB0h -080116DE (T) bl 80088E0h -080116E2 (T) strb r6,[r5] -080116E4 (T) mov r0,r4 -080116E6 (T) bl 8008A28h -080116EA (T) mov r0,r10 -080116EC (T) strb r0,[r5,0Eh] -080116EE (T) ldmia [r7]!,r0 -080116F0 (T) str r0,[r5,4h] -080116F2 (T) mov r1,r8 -080116F4 (T) add r1,4h -080116F6 (T) mov r8,r1 -080116F8 (T) sub r1,4h -080116FA (T) ldmia [r1]!,r0 -080116FC (T) str r0,[r5,8h] -080116FE (T) add r5,40h -08011700 (T) add r4,40h -08011702 (T) add r6,1h -08011704 (T) cmp r6,7h -08011706 (T) ble 80116DAh -08011708 (T) b 8011BE4h -0801170A (T) lsl r0,r0,0h -0801170C (T) ldmia [r3]!,r2,r4-r6 -0801170E (T) lsr r7,r1,20h -08011710 (T) ldmia [r3]!,r7 -08011712 (T) lsr r7,r1,20h -08011714 (T) ldmia [r3]!,r5,r7 -08011716 (T) lsr r7,r1,20h -08011718 (T) ldmia [r3]!,r6,r7 -0801171A (T) lsr r7,r1,20h -0801171C (T) ldmia [r3]!,r5-r7 -0801171E (T) lsr r7,r1,20h -08011720 (T) lsl r0,r6,0Dh -08011722 (T) lsl r0,r0,0Ch -08011724 (T) mov r5,70h -08011726 (T) lsl r0,r0,0Ch -08011728 (T) cmp r2,30h -0801172A (T) lsl r0,r0,0Ch -0801172C (T) cmp r7,0B0h -0801172E (T) lsr r1,r6,1h + // Set sequence index to 0 + 0801162E (T) mov r0,r9 // 2028028 + 08011630 (T) add r0,84h + 08011632 (T) str r1,[r0] + + 08011634 (T) mov r1,0A2h + 08011636 (T) lsl r1,r1,2h + 08011638 (T) add r1,r9 + 0801163A (T) mov r0,88h + 0801163C (T) lsl r0,r0,4h + 0801163E (T) str r0,[r1] // [20282B0] = 0x00000880 + + 08011640 (T) mov r2,0B2h + 08011642 (T) lsl r2,r2,2h + 08011644 (T) add r2,r9 + 08011646 (T) ldr r1,[sp,54h] // r1 = 0x68 + 08011648 (T) mov r0,0F0h + 0801164A (T) sub r0,r0,r1 + 0801164C (T) str r0,[r2] // [20282F0] = 0xF0 - 0x68 = 0x88 + + 0801164E (T) mov r1,0AEh + 08011650 (T) lsl r1,r1,2h + 08011652 (T) add r1,r9 + 08011654 (T) mov r0,0C0h + 08011656 (T) lsl r0,r0,0Ah + 08011658 (T) str r0,[r1] // [20282E0] = 0x30000 + + 0801165A (T) mov r6,1h + 0801165C (T) mov r7,0B2h + 0801165E (T) lsl r7,r7,2h + 08011660 (T) add r7,r9 // r7 = 20282F0 + 08011662 (T) mov r5,0B3h + 08011664 (T) lsl r5,r5,2h + 08011666 (T) add r5,r9 // r5 = 20282F4 + + // Looks like sp+58 and sp+78 are important variables; store their + // locations to sp+8C and sp+90. Let's call them X and Y respectively. + 08011668 (T) mov r1,r13 + 0801166A (T) add r1,58h + 0801166C (T) str r1,[sp,8Ch] + 0801166E (T) mov r2,r13 + 08011670 (T) add r2,78h + 08011672 (T) str r2,[sp,90h] + + 08011674 (T) mov r3,0A2h + 08011676 (T) lsl r3,r3,2h + 08011678 (T) add r3,r9 + 0801167A (T) mov r10,r3 // r3 = r10 = 20282B0 + 0801167C (T) mov r4,0A3h + 0801167E (T) lsl r4,r4,2h + 08011680 (T) add r4,r9 + 08011682 (T) mov r8,r4 // r4 = r8 = 20282B4 + + // So: + // r3 = 20282B0 + // r4 = 20282B4 + // r5 = 20282F4 + // r6 = loop index + // r7 = 20282F0 + // r8 = 20282B4 + // r9 = 2028028 + // r10 = 20282B0 + + // For r6 = 1 to 3: + // Load Y into r1 and increment Y + 08011684 (T) lsl r4,r6,2h + 08011686 (T) ldr r0,[sp,90h] + 08011688 (T) ldmia [r0]!,r1 + 0801168A (T) str r0,[sp,90h] + + // Load X into r0 and increment X + 0801168C (T) ldr r2,[sp,8Ch] + 0801168E (T) ldmia [r2]!,r0 + 08011690 (T) str r2,[sp,8Ch] + + 08011692 (T) sub r1,r1,r0 + 08011694 (T) str r1,[r5] + 08011696 (T) mov r0,0AEh + 08011698 (T) lsl r0,r0,2h + 0801169A (T) add r0,r9 + 0801169C (T) add r4,r0,r4 + 0801169E (T) ldr r0,[r0] + 080116A0 (T) mul r0,r1 + 080116A2 (T) ldr r1,[r7] + 080116A4 (T) bl m2_div + 080116A8 (T) str r0,[r4] + 080116AA (T) ldmia [r5]!,r1 + 080116AC (T) mov r3,r10 + 080116AE (T) ldr r0,[r3] + 080116B0 (T) mul r0,r1 + 080116B2 (T) ldr r1,[r7] + 080116B4 (T) bl m2_div + 080116B8 (T) mov r4,r8 + 080116BA (T) add r4,4h + 080116BC (T) mov r8,r4 + 080116BE (T) sub r4,4h + 080116C0 (T) stmia [r4]!,r0 + 080116C2 (T) add r6,1h + 080116C4 (T) cmp r6,3h + 080116C6 (T) ble 8011684h + + + 080116C8 (T) mov r6,0h + 080116CA (T) mov r10,r6 + 080116CC (T) add r7,sp,2Ch + 080116CE (T) mov r8,r7 + 080116D0 (T) add r7,sp,6Ch + 080116D2 (T) mov r5,r9 + 080116D4 (T) add r5,0A8h + 080116D6 (T) mov r4,r9 + 080116D8 (T) add r4,88h + 080116DA (T) mov r0,r4 + 080116DC (T) ldr r1,=8712FB0h + 080116DE (T) bl 80088E0h + 080116E2 (T) strb r6,[r5] + 080116E4 (T) mov r0,r4 + 080116E6 (T) bl 8008A28h + 080116EA (T) mov r0,r10 + 080116EC (T) strb r0,[r5,0Eh] + 080116EE (T) ldmia [r7]!,r0 + 080116F0 (T) str r0,[r5,4h] + 080116F2 (T) mov r1,r8 + 080116F4 (T) add r1,4h + 080116F6 (T) mov r8,r1 + 080116F8 (T) sub r1,4h + 080116FA (T) ldmia [r1]!,r0 + 080116FC (T) str r0,[r5,8h] + 080116FE (T) add r5,40h + 08011700 (T) add r4,40h + 08011702 (T) add r6,1h + 08011704 (T) cmp r6,7h + 08011706 (T) ble 80116DAh + 08011708 (T) b 8011BE4h + 0801170A (T) lsl r0,r0,0h + 0801170C (T) ldmia [r3]!,r2,r4-r6 + 0801170E (T) lsr r7,r1,20h + 08011710 (T) ldmia [r3]!,r7 + 08011712 (T) lsr r7,r1,20h + 08011714 (T) ldmia [r3]!,r5,r7 + 08011716 (T) lsr r7,r1,20h + 08011718 (T) ldmia [r3]!,r6,r7 + 0801171A (T) lsr r7,r1,20h + 0801171C (T) ldmia [r3]!,r5-r7 + 0801171E (T) lsr r7,r1,20h + 08011720 (T) lsl r0,r6,0Dh + 08011722 (T) lsl r0,r0,0Ch + 08011724 (T) mov r5,70h + 08011726 (T) lsl r0,r0,0Ch + 08011728 (T) cmp r2,30h + 0801172A (T) lsl r0,r0,0Ch + 0801172C (T) cmp r7,0B0h + 0801172E (T) lsr r1,r6,1h + 08011730 (T) ldrb r0,[r0,0Bh] // appears to be an are-we-on-the-last-run flag 08011732 (T) cmp r0,1h 08011734 (T) bne 801173Ch // If this is the last run: -08011736 (T) bl 8000C28h +08011736 (T) bl 8000C28h // tear-down 0801173A (T) b 8011BE4h -// Else: +// Else: check for input 0801173C (T) ldr r0,=3002500h -0801173E (T) ldrh r1,[r0] +0801173E (T) ldrh r1,[r0] // pad input 08011740 (T) mov r0,9h 08011742 (T) and r0,r1 08011744 (T) cmp r0,0h 08011746 (T) beq 8011774h -08011748 (T) mov r0,r9 -0801174A (T) add r0,84h -0801174C (T) ldr r0,[r0] -0801174E (T) cmp r0,0Ah -08011750 (T) ble 8011764h -08011752 (T) ldr r1,=30012D0h -08011754 (T) ldr r0,=8001825h -08011756 (T) b 8011B7Ah -08011758 (T) mov r5,0h -0801175A (T) lsl r0,r0,0Ch -0801175C (T) asr r0,r2,0Bh -0801175E (T) lsl r0,r0,0Ch -08011760 (T) add r5,r4,r0 -08011762 (T) lsr r0,r0,20h -08011764 (T) ldr r1,=30012D0h -08011766 (T) ldr r0,=8010F95h -08011768 (T) b 8011B7Ah -0801176A (T) lsl r0,r0,0h -0801176C (T) asr r0,r2,0Bh -0801176E (T) lsl r0,r0,0Ch -08011770 (T) lsr r5,r2,1Eh -08011772 (T) lsr r1,r0,20h + + // A/Start is pressed + 08011748 (T) mov r0,r9 + 0801174A (T) add r0,84h + 0801174C (T) ldr r0,[r0] + 0801174E (T) cmp r0,0Ah + 08011750 (T) ble 8011764h + + // If we're on the final sequence: + 08011752 (T) ldr r1,=30012D0h + 08011754 (T) ldr r0,=8001825h + 08011756 (T) b 8011B7Ah // store r0 to [r1] and return -1 + 08011758 (T) mov r5,0h + 0801175A (T) lsl r0,r0,0Ch + 0801175C (T) asr r0,r2,0Bh + 0801175E (T) lsl r0,r0,0Ch + 08011760 (T) add r5,r4,r0 + 08011762 (T) lsr r0,r0,20h + + // If we're not on the final sequence: + 08011764 (T) ldr r1,=30012D0h + 08011766 (T) ldr r0,=8010F95h + 08011768 (T) b 8011B7Ah // same + 0801176A (T) lsl r0,r0,0h + 0801176C (T) asr r0,r2,0Bh + 0801176E (T) lsl r0,r0,0Ch + 08011770 (T) lsr r5,r2,1Eh + 08011772 (T) lsr r1,r0,20h + +// Increment frame counter 08011774 (T) mov r2,r12 08011776 (T) ldr r0,[r2,4h] 08011778 (T) add r0,1h 0801177A (T) str r0,[r2,4h] + +// Check sequence number 0801177C (T) mov r0,r9 0801177E (T) add r0,84h 08011780 (T) ldr r1,[r0] @@ -327,6 +389,27 @@ 08011784 (T) cmp r1,11h 08011786 (T) bls 801178Ah 08011788 (T) b 8011B8Ch + +// Should always end up here (sequence number only goes up to 11) +// Jump table! +// [00]: 080117E0 +// [01]: 08011802 +// [02]: 0801182A +// [03]: 08011858 +// [04]: 080118FA +// [05]: 080118FE +// [06]: 0801195C +// [07]: 08011972 +// [08]: 080119BA +// [09]: 080119DE +// [0A]: 08011A02 +// [0B]: 08011A1A +// [0C]: 08011A80 +// [0D]: 08011A8A +// [0E]: 08011AAA +// [0F]: 08011B58 +// [10]: 08011B66 +// [11]: 08011B76 0801178A (T) lsl r0,r1,2h 0801178C (T) ldr r1,=8011798h 0801178E (T) add r0,r0,r1 @@ -370,25 +453,31 @@ 080117DA (T) lsr r1,r0,20h 080117DC (T) sub r6,r6,r5 080117DE (T) lsr r1,r0,20h + +// -------------------------------------------------------- +// Sequence 00 080117E0 (T) mov r1,r9 080117E2 (T) add r1,7Ah 080117E4 (T) mov r2,0h -080117E6 (T) mov r0,0D0h +080117E6 (T) mov r0,0D0h // BLDCNT 080117E8 (T) strh r0,[r1] 080117EA (T) add r1,2h -080117EC (T) mov r0,10h +080117EC (T) mov r0,10h // BLDY 080117EE (T) strh r0,[r1] 080117F0 (T) ldr r0,[r3] -080117F2 (T) str r2,[r0,4h] +080117F2 (T) str r2,[r0,4h] // reset frame index 080117F4 (T) mov r0,1h 080117F6 (T) mov r3,r10 -080117F8 (T) str r0,[r3] +080117F8 (T) str r0,[r3] // move to next sequence 080117FA (T) mov r0,0AFh -080117FC (T) bl m2_soundeffect +080117FC (T) bl m2_soundeffect // play title music 08011800 (T) b 8011B8Ch + +// -------------------------------------------------------- +// Sequence 01 08011802 (T) ldr r3,[r3] 08011804 (T) ldr r0,[r3,4h] -08011806 (T) cmp r0,2h +08011806 (T) cmp r0,2h // Every 3 frames, bump the brightness 08011808 (T) bgt 801180Ch 0801180A (T) b 8011B8Ch 0801180C (T) mov r1,r9 @@ -406,6 +495,9 @@ 08011824 (T) mov r4,r10 08011826 (T) str r0,[r4] 08011828 (T) b 8011B8Ch + +// -------------------------------------------------------- +// Sequence 02 0801182A (T) ldr r3,[r3] 0801182C (T) ldr r0,[r3,4h] 0801182E (T) cmp r0,2Ch @@ -429,6 +521,9 @@ 08011852 (T) mov r7,r10 08011854 (T) str r0,[r7] 08011856 (T) b 8011B8Ch + +// -------------------------------------------------------- +// Sequence 03 08011858 (T) mov r6,0h 0801185A (T) mov r7,r13 0801185C (T) sub r7,4h @@ -510,8 +605,14 @@ 080118F4 (T) bge 80118E6h 080118F6 (T) mov r0,4h 080118F8 (T) b 80119D8h + +// -------------------------------------------------------- +// Sequence 04 080118FA (T) mov r0,5h 080118FC (T) b 8011B60h + +// -------------------------------------------------------- +// Sequence 05 080118FE (T) ldr r3,[r3] 08011900 (T) ldr r0,[r3,4h] 08011902 (T) cmp r0,3h @@ -559,6 +660,9 @@ 08011956 (T) b 8011B4Ch 08011958 (T) lsl r0,r0,8h 0801195A (T) lsl r0,r0,14h + +// -------------------------------------------------------- +// Sequence 06 0801195C (T) ldr r3,[r3] 0801195E (T) ldr r0,[r3,4h] 08011960 (T) cmp r0,2Ch @@ -570,6 +674,9 @@ 0801196C (T) mov r0,0h 0801196E (T) str r0,[r3,4h] 08011970 (T) b 8011B8Ch + +// -------------------------------------------------------- +// Sequence 07 08011972 (T) ldr r0,[r3] 08011974 (T) ldr r0,[r0,4h] 08011976 (T) cmp r0,1h @@ -606,15 +713,21 @@ 080119B4 (T) mov r7,r10 080119B6 (T) str r6,[r7] 080119B8 (T) b 8011B8Ch + +// -------------------------------------------------------- +// Sequence 08 080119BA (T) mov r1,r9 080119BC (T) add r1,7Ah 080119BE (T) mov r2,0h 080119C0 (T) mov r0,0C3h 080119C2 (T) strh r0,[r1] + +// Enable BG0/OBJ 080119C4 (T) sub r1,2h 080119C6 (T) mov r0,88h 080119C8 (T) lsl r0,r0,5h 080119CA (T) strh r0,[r1] + 080119CC (T) add r1,4h 080119CE (T) mov r0,10h 080119D0 (T) strh r0,[r1] @@ -624,6 +737,9 @@ 080119D8 (T) mov r1,r10 080119DA (T) str r0,[r1] 080119DC (T) b 8011B8Ch + +// -------------------------------------------------------- +// Sequence 09 080119DE (T) ldr r3,[r3] 080119E0 (T) ldr r0,[r3,4h] 080119E2 (T) cmp r0,9h @@ -642,6 +758,9 @@ 080119FC (T) b 8011B8Ch 080119FE (T) mov r0,0Ah 08011A00 (T) b 8011B60h + +// -------------------------------------------------------- +// Sequence 0A 08011A02 (T) mov r0,0Bh 08011A04 (T) mov r4,r10 08011A06 (T) str r0,[r4] @@ -654,6 +773,9 @@ 08011A14 (T) ldr r0,[r3] 08011A16 (T) str r1,[r0,4h] 08011A18 (T) b 8011B8Ch + +// -------------------------------------------------------- +// Sequence 0B 08011A1A (T) ldr r3,[r3] 08011A1C (T) ldr r0,[r3,4h] 08011A1E (T) cmp r0,3h @@ -704,11 +826,17 @@ 08011A7A (T) b 8011B4Ch 08011A7C (T) lsl r0,r0,8h 08011A7E (T) lsl r0,r0,14h + +// -------------------------------------------------------- +// Sequence 0C 08011A80 (T) ldr r0,[r3] 08011A82 (T) mov r1,0h 08011A84 (T) str r1,[r0,4h] 08011A86 (T) mov r0,0Dh 08011A88 (T) b 8011B60h + +// -------------------------------------------------------- +// Sequence 0D 08011A8A (T) ldr r3,[r3] 08011A8C (T) ldr r0,[r3,4h] 08011A8E (T) cmp r0,0EFh @@ -725,6 +853,9 @@ 08011AA4 (T) strh r0,[r1] 08011AA6 (T) str r0,[r3,4h] 08011AA8 (T) b 8011B8Ch + +// -------------------------------------------------------- +// Sequence 0E 08011AAA (T) ldr r3,[r3] 08011AAC (T) ldr r0,[r3,4h] 08011AAE (T) cmp r0,3h @@ -809,6 +940,9 @@ 08011B52 (T) b 8011B8Ch 08011B54 (T) lsl r0,r0,8h 08011B56 (T) lsl r0,r0,14h + +// -------------------------------------------------------- +// Sequence 0F 08011B58 (T) ldr r0,[r3] 08011B5A (T) mov r1,0h 08011B5C (T) str r1,[r0,4h] @@ -816,6 +950,9 @@ 08011B60 (T) mov r2,r10 08011B62 (T) str r0,[r2] 08011B64 (T) b 8011B8Ch + +// -------------------------------------------------------- +// Sequence 10 08011B66 (T) ldr r0,[r3] 08011B68 (T) ldr r0,[r0,4h] 08011B6A (T) cmp r0,63h @@ -824,12 +961,16 @@ 08011B70 (T) mov r3,r10 08011B72 (T) str r0,[r3] 08011B74 (T) b 8011B8Ch + +// -------------------------------------------------------- +// Sequence 11 08011B76 (T) ldr r1,=30012D0h 08011B78 (T) ldr r0,=80B6F81h 08011B7A (T) str r0,[r1] 08011B7C (T) mov r0,1h 08011B7E (T) neg r0,r0 08011B80 (T) b 8011BE6h + 08011B82 (T) lsl r0,r0,0h 08011B84 (T) asr r0,r2,0Bh 08011B86 (T) lsl r0,r0,0Ch @@ -884,7 +1025,7 @@ 08011BF4 (T) bx r1 //============================================================================= -// $8011499: +// $8011499: (Commit) 08011498 (T) push r4,r14 0801149A (T) add sp,-4h 0801149C (T) ldr r0,=3000370h @@ -905,7 +1046,7 @@ // If first run: 080114B8 (T) bl 8000454h // check pad input 080114BC (T) bl 8005D50h // clears some flag -080114C0 (T) b 801156Eh +080114C0 (T) b 801156Eh // return 080114C2 (T) lsl r0,r0,0h 080114C4 (T) lsl r0,r6,0Dh 080114C6 (T) lsl r0,r0,0Ch @@ -920,10 +1061,10 @@ 080114D4 (T) bne 80114DCh // If last run: -080114D6 (T) bl 8000C28h -080114DA (T) b 801156Eh +080114D6 (T) bl 8000C28h // tear-down +080114DA (T) b 801156Eh // return -// If not last run: +// If neither first nor last run: 080114DC (T) bl 80F47E4h // wait for vblank // Set BG0 and BG1 scrolling offsets @@ -945,8 +1086,8 @@ 080114FE (T) strh r0,[r1] // BG1OFSb 08011500 (T) mov r0,r4 -08011502 (T) add r0,84h -08011504 (T) ldr r0,[r0] // frame number +08011502 (T) add r0,84h // r0 = 0x20280AC +08011504 (T) ldr r0,[r0] // sequence number 08011506 (T) cmp r0,1h 08011508 (T) blt 8011536h 0801150A (T) cmp r0,2h @@ -956,52 +1097,61 @@ 08011512 (T) cmp r0,9h 08011514 (T) blt 8011536h -// If on frames 9-A: -08011516 (T) mov r1,80h -08011518 (T) lsl r1,r1,13h -0801151A (T) mov r0,r4 -0801151C (T) add r0,78h -0801151E (T) ldrh r0,[r0] -08011520 (T) strh r0,[r1] +// If on sequence 9-A: + // Copy DISPCNT + 08011516 (T) mov r1,80h + 08011518 (T) lsl r1,r1,13h // r1 = 0x4000000 (DISPCNT) + 0801151A (T) mov r0,r4 + 0801151C (T) add r0,78h // r0 = 0x20280A0 + 0801151E (T) ldrh r0,[r0] + 08011520 (T) strh r0,[r1] -// If on frames 1-2: -08011522 (T) ldr r1,=4000050h // BLDCNT (special effects) -08011524 (T) mov r0,r4 -08011526 (T) add r0,7Ah -08011528 (T) ldrh r0,[r0] -0801152A (T) strh r0,[r1] -0801152C (T) add r1,4h // BLDY (brightness amount) -0801152E (T) mov r0,r4 -08011530 (T) add r0,7Ch -08011532 (T) ldrh r0,[r0] -08011534 (T) strh r0,[r1] +// If on sequence 1-2 or 9-A: + // Copy BLDCNT and BLDY + 08011522 (T) ldr r1,=4000050h // BLDCNT (special effects) + 08011524 (T) mov r0,r4 + 08011526 (T) add r0,7Ah // r0 = 0x20280A2 + 08011528 (T) ldrh r0,[r0] + 0801152A (T) strh r0,[r1] + 0801152C (T) add r1,4h // BLDY (brightness amount) + 0801152E (T) mov r0,r4 + 08011530 (T) add r0,7Ch // r0 = 0x20280A4 + 08011532 (T) ldrh r0,[r0] + 08011534 (T) strh r0,[r1] + +// For all sequences: + // Copy OAM data + 08011536 (T) ldr r1,=40000D4h + 08011538 (T) ldr r2,=30033A0h // OAM buffer + 0801153A (T) str r2,[r1] + 0801153C (T) mov r0,0E0h + 0801153E (T) lsl r0,r0,13h // r0 = 0x7000000 + 08011540 (T) str r0,[r1,4h] + 08011542 (T) ldr r0,=84000100h + 08011544 (T) str r0,[r1,8h] + 08011546 (T) ldr r0,[r1,8h] + + // Blank out OAM data + 08011548 (T) mov r0,0A0h + 0801154A (T) str r0,[sp] + 0801154C (T) mov r0,r13 + 0801154E (T) str r0,[r1] + 08011550 (T) str r2,[r1,4h] + 08011552 (T) ldr r0,=85000100h + 08011554 (T) str r0,[r1,8h] + 08011556 (T) ldr r0,[r1,8h] + + // ? + 08011558 (T) ldr r0,=3003390h + 0801155A (T) mov r1,0h + 0801155C (T) str r1,[r0] + 0801155E (T) ldr r0,=3003394h + 08011560 (T) str r1,[r0] + + 08011562 (T) bl 8005D6Ch // perform DMAs + 08011566 (T) bl 800E5E4h // something with input + 0801156A (T) bl 8000454h // something else with input -// If on frame 0, 3-8, or >A: -08011536 (T) ldr r1,=40000D4h -08011538 (T) ldr r2,=30033A0h -0801153A (T) str r2,[r1] -0801153C (T) mov r0,0E0h -0801153E (T) lsl r0,r0,13h -08011540 (T) str r0,[r1,4h] -08011542 (T) ldr r0,=84000100h -08011544 (T) str r0,[r1,8h] -08011546 (T) ldr r0,[r1,8h] -08011548 (T) mov r0,0A0h -0801154A (T) str r0,[sp] -0801154C (T) mov r0,r13 -0801154E (T) str r0,[r1] -08011550 (T) str r2,[r1,4h] -08011552 (T) ldr r0,=85000100h -08011554 (T) str r0,[r1,8h] -08011556 (T) ldr r0,[r1,8h] -08011558 (T) ldr r0,=3003390h -0801155A (T) mov r1,0h -0801155C (T) str r1,[r0] -0801155E (T) ldr r0,=3003394h -08011560 (T) str r1,[r0] -08011562 (T) bl 8005D6Ch -08011566 (T) bl 800E5E4h -0801156A (T) bl 8000454h 0801156E (T) mov r0,0h 08011570 (T) add sp,4h 08011572 (T) pop r4 @@ -1009,6 +1159,6 @@ 08011576 (T) bx r1 //============================================================================= -// $8011495: +// $8011495: (End) 08011494 (T) movs r0,0h 08011496 (T) bx r14 From 6b407d0c3b008381a93ac3d5c336d9fa0f0fd4b3 Mon Sep 17 00:00:00 2001 From: jeffman Date: Tue, 17 Sep 2019 00:06:42 -0400 Subject: [PATCH 05/32] Remove title.c etc. Not gonna try unwinding those routines into C so let's just to ASM for this hack. --- build.ps1 | 3 +-- src/c/locs.c | 1 - src/c/title.c | 32 -------------------------------- src/c/title.h | 10 ---------- 4 files changed, 1 insertion(+), 45 deletions(-) delete mode 100644 src/c/title.c delete mode 100644 src/c/title.h diff --git a/build.ps1 b/build.ps1 index 1d87443..a59f039 100644 --- a/build.ps1 +++ b/build.ps1 @@ -18,8 +18,7 @@ $input_c_files = "src/c/fileselect.c", "src/c/status.c", "src/c/battle.c", - "src/c/psi.c", - "src/c/title.c" + "src/c/psi.c" $base_c_address = 0x83755B8; $scripttool_cmd = "bin/ScriptTool/ScriptTool.dll" diff --git a/src/c/locs.c b/src/c/locs.c index 12ffb2b..b4fb7c9 100644 --- a/src/c/locs.c +++ b/src/c/locs.c @@ -27,4 +27,3 @@ int *m2_items_offsets = (int*) 0x8B1AF94; byte *m2_items_strings = (byte*) 0x8B1A694; unsigned short *name_header_tiles = (unsigned short*) 0x8B1B8B0; PSIPrintInfo *psi_print_info = (PSIPrintInfo*) 0x8B2A9C0; -int *title_counter = (int*) 0x2011B60; diff --git a/src/c/title.c b/src/c/title.c deleted file mode 100644 index aceed30..0000000 --- a/src/c/title.c +++ /dev/null @@ -1,32 +0,0 @@ -#include "title.h" -#include "locs.h" - -int title_frame_first() -{ - if (*title_counter == 0) - { - m2_soundeffect(0xAF); - } - - (*title_counter)++; - - if (*title_counter == 5 * 60) - { - m2_title_teardown(); - return -1; - } - - return 0; -} - -int title_frame_second() -{ - vblank(); - - if (*title_counter == 5 * 60) - { - m2_title_teardown(); - } - - return 0; -} diff --git a/src/c/title.h b/src/c/title.h deleted file mode 100644 index 29c4e79..0000000 --- a/src/c/title.h +++ /dev/null @@ -1,10 +0,0 @@ -#ifndef HEADER_TITLE_INCLUDED -#define HEADER_TITLE_INCLUDED - -int title_frame_first(); -int title_frame_second(); -extern void m2_title_teardown(); -extern void m2_soundeffect(int index); -extern void vblank(); - -#endif From e201fe3e51e0eff78dc3688f4a67e8d6dd9604e0 Mon Sep 17 00:00:00 2001 From: jeffman Date: Tue, 17 Sep 2019 00:07:24 -0400 Subject: [PATCH 06/32] Add a fade-in delay --- src/m2-hack.asm | 9 +++--- src/m2-title.asm | 80 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 85 insertions(+), 4 deletions(-) create mode 100644 src/m2-title.asm diff --git a/src/m2-hack.asm b/src/m2-hack.asm index 5e0ab4e..e494e9b 100644 --- a/src/m2-hack.asm +++ b/src/m2-hack.asm @@ -1553,10 +1553,10 @@ nop .org 0x8011436 :: ldr r2,[r0,r5] .org 0x8011440 :: ldr r2,[r0,r5] - // Replace per-frame functions - .org 0x82D6B7C - dw title_frame_first + 1 - dw title_frame_second + 1 +// Setup hacks: + + // Point to sequence hacks + .org 0x801179C :: dw title_sequence_01 // --- Animation 5 (quick title screen) --- .org 0x82D6BD4 :: dh 0x008A // Enable 8-bit BG0 @@ -1778,5 +1778,6 @@ dw 0x20 :: .incbin "data/m2-title-text-pal-static.c.bin" .include "m2-customcodes.asm" .include "m2-compiled.asm" .include "m2-flyover.asm" +.include "m2-title.asm" .close diff --git a/src/m2-title.asm b/src/m2-title.asm new file mode 100644 index 0000000..a748f0c --- /dev/null +++ b/src/m2-title.asm @@ -0,0 +1,80 @@ +// r3 has 2028008 +// [r3+14] has 2028028 +// [2028028+10] has pointer to our palette buffer, 0x200 bytes after which +// we have some free space to use for things +// Let's allocate some variables: +// +0x00: Sequence 01 -- initial delay flag + +//--------------------------------------------------------- +title_return: +ldr r0,=0x8011B8C +mov pc,r0 + +//--------------------------------------------------------- +// r0 = pointer to pointer little struct +title_get_buffer: +push {r1,lr} +ldr r0,[r0] +ldr r1,[r0,0x14] +ldr r0,[r1,0x10] +ldr r1,=0x200 +add r0,r0,r1 +pop {r1,pc} + +//--------------------------------------------------------- +title_sequence_01: + +// EB has a 38 frame delay between starting the music +// and starting the fade-in +push {r0-r1} +mov r0,r3 +bl title_get_buffer + +// Check if we've set our delay flag yet +ldr r1,[r0] +cmp r1,0 +beq @@unset + + @@set: + // Count to 3 like before + ldr r3,[r3] + ldr r0,[r3,4] + cmp r0,2 + bgt @@next_fade + b @@end + @@next_fade: + mov r1,r9 + add r1,0x7C + ldrh r0,[r1] + sub r0,1 + mov r2,0 + strh r0,[r1] + str r2,[r3,4] + ldrh r0,[r1] + cmp r0,0 + beq @@fade_done + b @@end + @@fade_done: + mov r0,2 + mov r4,r10 + str r0,[r4] + b @@end + + @@unset: + // Count to 0x26 before starting the fade-in + ldr r3,[r3] + ldr r1,[r3,4] + cmp r1,0x26 + bge @@unset_start_fade + b @@end + @@unset_start_fade: + mov r1,0 + str r1,[r3,4] + mov r1,1 + str r1,[r0] + +@@end: +pop {r0-r1} +b title_return + +.pool From 5756d24a46a17f37a7b51956631c3c95361e0313 Mon Sep 17 00:00:00 2001 From: jeffman Date: Tue, 17 Sep 2019 21:54:01 -0400 Subject: [PATCH 07/32] Update notes --- notes/m2-title-long.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/notes/m2-title-long.txt b/notes/m2-title-long.txt index d89f8d2..a17907f 100644 --- a/notes/m2-title-long.txt +++ b/notes/m2-title-long.txt @@ -716,6 +716,8 @@ // -------------------------------------------------------- // Sequence 08 + +// Clear BLDCNT 080119BA (T) mov r1,r9 080119BC (T) add r1,7Ah 080119BE (T) mov r2,0h From 941057bfc6ed9ede577b3cc8e9d26452a5d66053 Mon Sep 17 00:00:00 2001 From: jeffman Date: Tue, 17 Sep 2019 21:55:05 -0400 Subject: [PATCH 08/32] Add/update sequences 0, 1, 4, 5 --- src/m2-hack.asm | 30 +++++++ src/m2-title.asm | 200 ++++++++++++++++++++++++++++++++++++++--------- 2 files changed, 193 insertions(+), 37 deletions(-) diff --git a/src/m2-hack.asm b/src/m2-hack.asm index e494e9b..ac2c901 100644 --- a/src/m2-hack.asm +++ b/src/m2-hack.asm @@ -1483,6 +1483,25 @@ nop // Title screen hacks //============================================================================== +.definelabel m2_title_sequence_00, 0x80117E0 +.definelabel m2_title_sequence_01, 0x8011802 +.definelabel m2_title_sequence_02, 0x801182A +.definelabel m2_title_sequence_03, 0x8011858 +.definelabel m2_title_sequence_04, 0x80118FA +.definelabel m2_title_sequence_05, 0x80118FE +.definelabel m2_title_sequence_06, 0x801195C +.definelabel m2_title_sequence_07, 0x8011972 +.definelabel m2_title_sequence_08, 0x80119BA +.definelabel m2_title_sequence_09, 0x80119DE +.definelabel m2_title_sequence_0A, 0x8011A02 +.definelabel m2_title_sequence_0B, 0x8011A1A +.definelabel m2_title_sequence_0C, 0x8011A80 +.definelabel m2_title_sequence_0D, 0x8011A8A +.definelabel m2_title_sequence_0E, 0x8011AAA +.definelabel m2_title_sequence_0F, 0x8011B58 +.definelabel m2_title_sequence_10, 0x8011B66 +.definelabel m2_title_sequence_11, 0x8011B76 + // m2_title_background_pal_copyright: File has two palettes separated by six palettes // worth of nullspace. First palette is the copyright palette, // last palette is a placeholder for the glow palette @@ -1555,8 +1574,19 @@ nop // Setup hacks: + // Fade BG0 instead of OBJ + .org 0x80117E6 :: mov r0,0xC1 + // Point to sequence hacks + .org 0x8011798 :: dw title_sequence_00 .org 0x801179C :: dw title_sequence_01 + .org 0x80117A8 :: dw title_sequence_04 + .org 0x80117AC :: dw title_sequence_05 + +// Commit hacks: + + // Commit all things on every sequence + .org 0x8011500 :: b 0x8011516 // --- Animation 5 (quick title screen) --- .org 0x82D6BD4 :: dh 0x008A // Enable 8-bit BG0 diff --git a/src/m2-title.asm b/src/m2-title.asm index a748f0c..9ba0ad9 100644 --- a/src/m2-title.asm +++ b/src/m2-title.asm @@ -11,7 +11,8 @@ ldr r0,=0x8011B8C mov pc,r0 //--------------------------------------------------------- -// r0 = pointer to pointer little struct +// In: r0 = pointer to pointer to little struct +// Out: r0 = pointer to our buffer area (0x2011B60) title_get_buffer: push {r1,lr} ldr r0,[r0] @@ -21,12 +22,38 @@ ldr r1,=0x200 add r0,r0,r1 pop {r1,pc} +//--------------------------------------------------------- +title_sequence_00: + +// Normally the game enables BG0 in sequence 8, but we want +// it enabled from the start so copy that code to here +mov r1,r9 +add r1,0x78 +mov r0,0x88 +lsl r0,r0,5 +strh r0,[r1] + +// Copy static palette to BG pal 8 +ldr r3,[r3] +ldr r3,[r3,0x14] +ldr r1,=0x40000D4 +ldr r2,[r3,0xC] // m2_title_text_pal_static +str r2,[r1] +ldr r0,=0x5000100 +str r0,[r1,4] +ldr r0,=0x84000008 +str r0,[r1,8] +ldr r0,[r1,8] + +// Return to old sequence 0 code +ldr r0,=m2_title_sequence_00 +mov pc,r0 + //--------------------------------------------------------- title_sequence_01: // EB has a 38 frame delay between starting the music // and starting the fade-in -push {r0-r1} mov r0,r3 bl title_get_buffer @@ -36,45 +63,144 @@ cmp r1,0 beq @@unset @@set: - // Count to 3 like before - ldr r3,[r3] - ldr r0,[r3,4] - cmp r0,2 - bgt @@next_fade - b @@end - @@next_fade: - mov r1,r9 - add r1,0x7C - ldrh r0,[r1] - sub r0,1 - mov r2,0 - strh r0,[r1] - str r2,[r3,4] - ldrh r0,[r1] - cmp r0,0 - beq @@fade_done - b @@end - @@fade_done: - mov r0,2 - mov r4,r10 - str r0,[r4] - b @@end + + // Skip our code and return to the old sequence 1 code + ldr r0,=m2_title_sequence_01 + mov pc,r0 @@unset: - // Count to 0x26 before starting the fade-in - ldr r3,[r3] - ldr r1,[r3,4] - cmp r1,0x26 - bge @@unset_start_fade - b @@end - @@unset_start_fade: - mov r1,0 - str r1,[r3,4] - mov r1,1 - str r1,[r0] + + // Count to 0x26 before starting the fade-in + ldr r3,[r3] + ldr r1,[r3,4] + cmp r1,0x26 + bge @@unset_start_fade + b @@end + + @@unset_start_fade: + mov r1,0 + str r1,[r3,4] + mov r1,1 + str r1,[r0] @@end: -pop {r0-r1} +b title_return + +//--------------------------------------------------------- +title_sequence_04: + +// Just need to reset the frame counter +ldr r2,[r3] +mov r0,1 +neg r0,r0 // This gets incremented before calling the sequence subroutines, + // and we want it to be 0 on the first frame for sequence 5, + // so start it at -1 +str r0,[r2,4] + +ldr r0,=m2_title_sequence_04 +mov pc,r0 + +//--------------------------------------------------------- +title_sequence_05: + +push {r4} +ldr r3,[r3] +mov r4,r3 +ldr r0,[r4,4] // frame number + +// Frame 0-1: inverted colours +cmp r0,1 +bhi @@next1 + + // Only change the palette on frame 0 + cmp r0,1 + beq @@advance_frame + + @@inverted: + + // Load inverted BG palettes + // (all white for BG pal 0-7, + // all black for BG pal 8-F) + ldr r1,=0x40000D4 + mov r2,1 + neg r2,r2 + push {r2} + mov r2,sp + str r2,[r1] + ldr r0,=0x5000000 + str r0,[r1,4] + ldr r0,=0x85000040 + str r0,[r1,8] + ldr r0,[r1,8] + mov r2,0 + str r2,[sp] + mov r2,sp + str r2,[r1] + ldr r0,=0x5000100 + str r0,[r1,4] + ldr r0,=0x85000040 + str r0,[r1,8] + ldr r0,[r1,8] + pop {r2} + b @@advance_frame + +@@next1: +// Frame 2-29: animated text, 2 frames per palette change +cmp r0,29 +bhi @@next2 + + // Only change palette on the even frames + sub r0,2 + lsl r1,r0,0x1F + bmi @@advance_frame + + // On frame 2, we need to reset BG pal 0-7 to black + cmp r0,0 + bne @@skip_black_palettes + ldr r1,=0x40000D4 + push {r0} + mov r2,sp + str r2,[r1] + ldr r2,=0x5000000 + str r2,[r1,4] + ldr r2,=0x85000040 + str r2,[r1,8] + ldr r2,[r1,8] + add sp,4 + + @@skip_black_palettes: + // Get source palette address + ldr r3,[r3,0x14] + ldr r1,[r3,8] // m2_title_text_pal_animated + lsl r0,r0,4 + add r0,r0,r1 + + // Copy to BG pal 8 + ldr r1,=0x40000D4 + str r0,[r1] + ldr r0,=0x5000100 + str r0,[r1,4] + ldr r0,=0x84000008 + str r0,[r1,8] + ldr r0,[r1,8] + b @@advance_frame + +@@next2: +// For now let's just go to the next sequence, not sure what to do next yet +mov r0,0 +str r0,[r4,4] +mov r0,6 +ldr r1,[r4,0x14] +add r1,0x84 +str r0,[r1] +pop {r4} +b title_return + +@@advance_frame: +pop {r4} +ldr r0,[r4,4] +add r0,1 +str r0,[r4,4] b title_return .pool From 6213911edc6159a66d4c79205e91ab0e6eef0fca Mon Sep 17 00:00:00 2001 From: jeffman Date: Wed, 25 Sep 2019 23:38:03 -0400 Subject: [PATCH 09/32] Fix bad graphics rip TileMolester's default palette repeats black on some colours which made it not copy properly. This one should be fine... --- src/data/m2-title-background.bin | Bin 6667 -> 6724 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/src/data/m2-title-background.bin b/src/data/m2-title-background.bin index a0304cad56d4852b4c6f71dc6b5ee8cc88c92a05..7c511c84d2127b47ece3c3a6d66306655361b00f 100644 GIT binary patch delta 963 zcmYL`Z)lZO9LIm>o^zh_Jm)-T=RD87`vbE)&$glw=rg?*w%hhxFPr%yyLTD}Dmg)! zXl=8xAhCPZ<&4sDYA;eKC6Fv=Ym`AT+fu1uy^631+>2@u${w@aMr-T#Dt`Qad|rI{ z{=V>iEqygTe5Ru4hRUG#HNz1T`4-oL%$u4h3{RI=`nGgcY6R)G!;^?8r(9<05*UOOQ-A+VHSD8U5IlB>-DIB0Dp; z4KfW-HnhD10_>B)5kW!*vV59B0x<`AN-SFF-1t>Q;1|Ue)eNpKB;=QDculdVpm#$D zQz0dK5tPdvIiu5X0&2={vzKBNP7jvDxm+f;`gzE{fWv+?XBZZKMPYJyieVUooq}^d zk*M(YacnvM<1Pk=0dxKC7|rO}=vrhsk-bTv)5Eu>@+<38@TX)pBa?}i5qO1KP;1W6 z#Kvn{nQFW2n53}cYyZZ{^+aS1C2G`bQ#t{JbGRMMkFC3CMd?ngkv`R;mleBh$lxxS zjfTF7H^u1IP=Cj{-g~zH2Yl~By%8t96&!V49K#IJV z?%$vvL!T)};g{N2-QSeiA#+!Y+0NDxnQJ$#j4Z?L`f?4YcEsR3am50zy7NrOjj#>p z5}!K+xsGrwVZp^?`X6Bn+RwO%<7nqQp7y#NE@`u3-U_nS`xI+N`&w+Klj26byO z^;GcusJD+nDd^*FUGLqcwLk)~xdDG7aWFRnDwr!VGSnSDS~`ewY32l7u;21Zl--15 zz2)@bIyD-b9OvurdvwV63^^5Xrsa`Y&9mUJKGIyys5j5hBTF=1tl0z zTS-b{Luau?@uwII^om4iVu->;BY~U7Dhg3A#Awxs@uwj~6JwJpXsxX6x_a@xd2gTh zxtx71J9FZW2m+zBvl2;&ygzTq98e_)JYElHFTtIh*#eS4?GaP%kTl3i!X@q3vIIjj zIBtX|ZFWSVNtoJeS$wY(+z(A89JS$FV3DH?NW-}hl~oZjUhkiS+wvWP9OjVPK%9t4 zYB~3r02Jg^No|>Ju^DyS6zwlK&S|*B!`B^fP`2$iWl*~27bw7X7e<_+oYYh+P$5ls zCJ`>{&WAYDK3JB!p(hccU{tP2VOs|r znT4aU-ce61Jp5wmeMK#8O7HVZP$0qZZEZzi`Gd^o3rOV0mJQst^y|g))leQdz(xo(7Hd54QEeaM-SOz!Xj9ler7iYt0^Ell3mMagr zdo0^w0^Lp5XrFtL)Geh1!JPAlQB zRPab8Is-_L zidV{)Ha^RiVQX^Bx^3jB)i~BL#cFP}v$8}pHMXog{fmaFYH@>_EVRZ4+NTRNbx<3x zrJjK=6>8({uf%g-MX_HSNS3B|75|eGYw&4nXM}%#6KgkrDZaa0KELD@@YpGDmH@!N D!7$@p From da55c7c76521b574f12684094f045e3b5995a270 Mon Sep 17 00:00:00 2001 From: jeffman Date: Wed, 25 Sep 2019 23:38:42 -0400 Subject: [PATCH 10/32] Fix bug with clobbered register --- src/m2-title.asm | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/m2-title.asm b/src/m2-title.asm index 9ba0ad9..e8ffe42 100644 --- a/src/m2-title.asm +++ b/src/m2-title.asm @@ -27,6 +27,7 @@ title_sequence_00: // Normally the game enables BG0 in sequence 8, but we want // it enabled from the start so copy that code to here +push {r3} mov r1,r9 add r1,0x78 mov r0,0x88 @@ -44,6 +45,7 @@ str r0,[r1,4] ldr r0,=0x84000008 str r0,[r1,8] ldr r0,[r1,8] +pop {r3} // Return to old sequence 0 code ldr r0,=m2_title_sequence_00 From 03cef4736a9c5f06ae01c7ae64ba527b68f92605 Mon Sep 17 00:00:00 2001 From: jeffman Date: Wed, 25 Sep 2019 23:39:27 -0400 Subject: [PATCH 11/32] BG0 offset --- src/m2-hack.asm | 3 +++ src/m2-title.asm | 14 ++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/src/m2-hack.asm b/src/m2-hack.asm index ac2c901..8a341ab 100644 --- a/src/m2-hack.asm +++ b/src/m2-hack.asm @@ -1572,6 +1572,9 @@ nop .org 0x8011436 :: ldr r2,[r0,r5] .org 0x8011440 :: ldr r2,[r0,r5] + // Point to custom initializer routine + .org 0x82D6B78 :: dw title_initializer + 1 + // Setup hacks: // Fade BG0 instead of OBJ diff --git a/src/m2-title.asm b/src/m2-title.asm index e8ffe42..405369c 100644 --- a/src/m2-title.asm +++ b/src/m2-title.asm @@ -1,3 +1,17 @@ +//--------------------------------------------------------- +title_initializer: +push {r1} +ldr r0,=0x3001B20 +mov r1,8 // BG0 X offset +strh r1,[r0] +ldr r0,=0x30012DC +mov r1,8*6 // BG0 Y offset +strh r1,[r0] +pop {r1} +ldr r0,=0x80113F4 +mov pc,r0 // Run the existing routine + +//--------------------------------------------------------- // r3 has 2028008 // [r3+14] has 2028028 // [2028028+10] has pointer to our palette buffer, 0x200 bytes after which From f5a17d8a680fc04ff754b82d7d24d1ca72289a00 Mon Sep 17 00:00:00 2001 From: jeffman Date: Wed, 25 Sep 2019 23:39:35 -0400 Subject: [PATCH 12/32] Add more sequences --- src/m2-hack.asm | 5 +- src/m2-title.asm | 169 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 173 insertions(+), 1 deletion(-) diff --git a/src/m2-hack.asm b/src/m2-hack.asm index 8a341ab..5bb76a1 100644 --- a/src/m2-hack.asm +++ b/src/m2-hack.asm @@ -1543,7 +1543,6 @@ nop // --- Animation 3 (full title screen) --- .org 0x82D6B64 :: dh 0x008A // Enable 8-bit BG0 -.org 0x80119C6 :: mov r0,0x88 // Disable BG1 // Initializer hacks: @@ -1585,6 +1584,10 @@ nop .org 0x801179C :: dw title_sequence_01 .org 0x80117A8 :: dw title_sequence_04 .org 0x80117AC :: dw title_sequence_05 + .org 0x80117B4 :: dw title_sequence_07 + .org 0x80117B8 :: dw title_sequence_08 + .org 0x80117BC :: dw title_sequence_09 + .org 0x80117C4 :: dw title_sequence_0B // Commit hacks: diff --git a/src/m2-title.asm b/src/m2-title.asm index 405369c..0b07b42 100644 --- a/src/m2-title.asm +++ b/src/m2-title.asm @@ -219,4 +219,173 @@ add r0,1 str r0,[r4,4] b title_return +//--------------------------------------------------------- +title_sequence_07: + +// We're not moving the text so just do a delay for this sequence +ldr r3,[r3] +ldr r0,[r3,4] +cmp r0,0x2C +bgt @@nextsequence +b title_return + +@@nextsequence: +mov r0,8 +mov r4,r10 +str r0,[r4] +mov r0,0 +str r0,[r3,4] +b title_return + +//--------------------------------------------------------- +title_sequence_08: + +// We're not messing with the video registers so just do a delay for this sequence +ldr r3,[r3] +ldr r0,[r3,4] +cmp r0,0x2C +bgt @@nextsequence +b title_return + +@@nextsequence: +mov r0,9 +mov r4,r10 +str r0,[r4] +mov r0,1 +neg r0,r0 // want to start the next sequence on frame 0 +str r0,[r3,4] +b title_return + +//--------------------------------------------------------- +title_sequence_09: + +// Copyright palette fade in +push {r4-r7} +ldr r3,[r3] +mov r4,r3 +ldr r0,[r3,4] // frame number + +// Frame 0-215: re-calculate palette every frame +cmp r0,215 +bgt @@nextsequence + +add sp,-16 +str r0,[sp] +ldr r1,=215 +str r1,[sp,4] +ldr r5,[r4,0x14] +ldr r5,[r5] // copyright palette source +mov r6,5 +lsl r6,r6,24 // copyright palette dest +mov r7,0 + +@@loop: +// Scale R +ldrh r1,[r5] +lsl r1,r1,27 +lsr r1,r1,9 +ldr r0,[sp] +mul r0,r1 +ldr r1,[sp,4] +bl m2_div +lsr r0,r0,18 +str r0,[sp,8] + +// Scale G +ldrh r1,[r5] +lsr r1,r1,5 +lsl r1,r1,27 +lsr r1,r1,9 +ldr r0,[sp] +mul r0,r1 +ldr r1,[sp,4] +bl m2_div +lsr r0,r0,18 +str r0,[sp,12] + +// Scale B +ldrh r1,[r5] +lsr r1,r1,10 +lsl r1,r1,27 +lsr r1,r1,9 +ldr r0,[sp] +mul r0,r1 +ldr r1,[sp,4] +bl m2_div +lsr r0,r0,18 + +// Pack colours and store +lsl r0,r0,10 +ldr r1,[sp,12] +lsl r1,r1,5 +orr r0,r1 +ldr r1,[sp,8] +orr r0,r1 +strh r0,[r6] + +add r5,2 +add r6,2 +add r7,1 +cmp r7,16 +blt @@loop + +add sp,16 +pop {r4-r7} +b title_return + +@@nextsequence: +mov r0,0 +str r0,[r4,4] +mov r0,0xA +mov r4,r10 +str r0,[r4] +pop {r4-r7} +b title_return + +//--------------------------------------------------------- +title_sequence_0B: + +// Background palette fade in +push {r4} +ldr r3,[r3] +mov r4,r3 +ldr r0,[r3,4] // frame number + +// Frame 0-159: change palette every 8 frames +lsl r3,r0,29 +lsr r3,r3,29 +cmp r3,0 +bne @@end + +lsr r0,r0,3 // source palete index +cmp r0,20 +bge @@nextsequence + +lsl r0,r0,5 // source palette offset +ldr r3,[r4,0x14] +ldr r3,[r3,4] // source palette buffer +add r0,r0,r3 + +// Copy palette +ldr r1,=0x40000D4 +str r0,[r1] +ldr r0,=0x50000E0 +str r0,[r1,4] +ldr r0,=0x84000008 +str r0,[r1,8] +ldr r0,[r1,8] +b @@end + +@@nextsequence: +mov r0,1 +neg r0,r0 // want to start the next sequence on frame 0 +str r0,[r4,4] +mov r0,0xC +mov r4,r10 +str r0,[r4] + +@@end: +pop {r4} +b title_return + .pool From 5e98d418ea15ff1c33008d82baa03bd684e4c61a Mon Sep 17 00:00:00 2001 From: jeffman Date: Thu, 26 Sep 2019 20:36:00 -0400 Subject: [PATCH 13/32] Copy background to glow palette during copyright --- src/m2-title.asm | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/m2-title.asm b/src/m2-title.asm index 0b07b42..fdfb438 100644 --- a/src/m2-title.asm +++ b/src/m2-title.asm @@ -323,6 +323,21 @@ ldr r1,[sp,8] orr r0,r1 strh r0,[r6] +// Copy background colour to the glow palette +cmp r7,0 +bgt @@next +mov r1,0 +add r6,0xE0 +@@copyloop: +strh r0,[r6] +add r6,2 +add r1,1 +cmp r1,16 +blt @@copyloop +sub r6,0xE0 +sub r6,0x20 + +@@next: add r5,2 add r6,2 add r7,1 From 4e3c8a98b5efeb10e096429a0a6ba9be0b1a7d48 Mon Sep 17 00:00:00 2001 From: jeffman Date: Thu, 26 Sep 2019 20:45:48 -0400 Subject: [PATCH 14/32] Start background with blank palette This fixes the yellow copyright text at the start. --- src/data/m2-title-background-pal-empty.bin | Bin 0 -> 68 bytes src/m2-hack.asm | 1 + 2 files changed, 1 insertion(+) create mode 100644 src/data/m2-title-background-pal-empty.bin diff --git a/src/data/m2-title-background-pal-empty.bin b/src/data/m2-title-background-pal-empty.bin new file mode 100644 index 0000000000000000000000000000000000000000..c19fdd7a0f9b5b4b2679068796d9357c1c9b874c GIT binary patch literal 68 dcmWe&U}CUmVEDj@fd3Ip2n$2tAF>JqMgYxu9oql^ literal 0 HcmV?d00001 diff --git a/src/m2-hack.asm b/src/m2-hack.asm index 5bb76a1..6d0d1c8 100644 --- a/src/m2-hack.asm +++ b/src/m2-hack.asm @@ -1599,6 +1599,7 @@ nop .org 0x82D6BE0 :: dh 0x1100 // Disable BG1 .org 0x870F580 :: .incbin "data/m2-title-background.bin" +.org 0x87126CC :: .incbin "data/m2-title-background-pal-empty.bin" .org 0x87128EC :: .incbin "data/m2-title-background-map.bin" //============================================================================== From 92151ba9344757535b24164afb555e798f15277b Mon Sep 17 00:00:00 2001 From: jeffman Date: Thu, 26 Sep 2019 20:59:05 -0400 Subject: [PATCH 15/32] Nop the remaining title sequences --- notes/m2-title-long.txt | 16 ++++++++-------- src/m2-hack.asm | 5 +++++ src/m2-title.asm | 27 +++++++++++++++++++++++++++ 3 files changed, 40 insertions(+), 8 deletions(-) diff --git a/notes/m2-title-long.txt b/notes/m2-title-long.txt index a17907f..176a37d 100644 --- a/notes/m2-title-long.txt +++ b/notes/m2-title-long.txt @@ -28,15 +28,15 @@ // 06: [] pause [] pause // 07: [] text moves up [] do nothing // 08: [] pause [] pause -// 09: [] background fade-in [] background fade-in +// 09: [] background fade-in [] copyright fade-in // 0A: [] pause [] pause -// 0B: [] flash all [] -// 0C: [] pause [] -// 0D: [] long pause [] -// 0E: [] flash all [] -// 0F: [] pause [] -// 10: [] long pause [] -// 11: [] quick fade-out all [] +// 0B: [] flash all [] glow +// 0C: [] pause [] pause +// 0D: [] long pause [] do nothing +// 0E: [] flash all [] do nothing +// 0F: [] pause [] do nothing +// 10: [] long pause [] do nothing +// 11: [] quick fade-out all [] quick fade-out all //============================================================================= // $80113F5: (Start) diff --git a/src/m2-hack.asm b/src/m2-hack.asm index 6d0d1c8..bb677d2 100644 --- a/src/m2-hack.asm +++ b/src/m2-hack.asm @@ -1588,6 +1588,11 @@ nop .org 0x80117B8 :: dw title_sequence_08 .org 0x80117BC :: dw title_sequence_09 .org 0x80117C4 :: dw title_sequence_0B + .org 0x80117C8 :: dw title_sequence_0C + .org 0x80117CC :: dw title_sequence_0D + .org 0x80117D0 :: dw title_sequence_0D + .org 0x80117D4 :: dw title_sequence_0D + .org 0x80117D8 :: dw title_sequence_0D // Commit hacks: diff --git a/src/m2-title.asm b/src/m2-title.asm index fdfb438..beed36b 100644 --- a/src/m2-title.asm +++ b/src/m2-title.asm @@ -403,4 +403,31 @@ str r0,[r4] pop {r4} b title_return +//--------------------------------------------------------- +title_sequence_0C: + +ldr r3,[r3] +ldr r0,[r3,4] +cmp r0,0x2C +bgt @@nextsequence +b title_return + +@@nextsequence: +mov r0,0xD +mov r4,r10 +str r0,[r4] +mov r0,1 +neg r0,r0 +str r0,[r3,4] +b title_return + +//--------------------------------------------------------- +title_sequence_0D: + +mov r4,r10 +ldr r0,[r4] +add r0,1 +str r0,[r4] +b title_return + .pool From 433eea405b520212f929bb3fe3a3b44b0a4ea09a Mon Sep 17 00:00:00 2001 From: jeffman Date: Thu, 26 Sep 2019 22:25:45 -0400 Subject: [PATCH 16/32] Add sprite text resources --- notes/m2-title-sprites.txt | 16 ++++++++++++++++ src/data/m2-title-text-oam-entries.bin | Bin 0 -> 64 bytes src/data/m2-title-text-oam.bin | Bin 0 -> 168 bytes src/data/m2-title-text.bin | Bin 0 -> 4800 bytes src/m2-hack.asm | 3 +++ 5 files changed, 19 insertions(+) create mode 100644 notes/m2-title-sprites.txt create mode 100644 src/data/m2-title-text-oam-entries.bin create mode 100644 src/data/m2-title-text-oam.bin create mode 100644 src/data/m2-title-text.bin diff --git a/notes/m2-title-sprites.txt b/notes/m2-title-sprites.txt new file mode 100644 index 0000000..74c5c9a --- /dev/null +++ b/notes/m2-title-sprites.txt @@ -0,0 +1,16 @@ +712F10 +------ +Title text sprite entry table. First word is OAM source pointer, second word is number of sprites to load. + +68 2E 71 08 02 00 00 00 M (2 sprites) +78 2E 71 08 06 00 00 00 O (6 sprites) +A8 2E 71 08 02 00 00 00 T (2 sprites) +B8 2E 71 08 02 00 00 00 H (2 sprites) +C8 2E 71 08 02 00 00 00 E (2 sprites) +D8 2E 71 08 02 00 00 00 R (2 sprites) +E8 2E 71 08 04 00 00 00 Subtitle (4 sprites) +08 2F 71 08 01 00 00 00 (R) (1 sprites) + +We have nine letters to do but there's only room in the table for eight; will figure out how to expand it later. + +We'll use 32x64 sprites so that we only need one sprite for each letter (the Japanese version uses 2-6 sprites for each letter). \ No newline at end of file diff --git a/src/data/m2-title-text-oam-entries.bin b/src/data/m2-title-text-oam-entries.bin new file mode 100644 index 0000000000000000000000000000000000000000..c748848618414e30cc9bde1922070dc8f07e1a48 GIT binary patch literal 64 hcmd1ME978gU|=YK(iKp;0ZMm3=?PGJ29#a^r2#$f31I*L literal 0 HcmV?d00001 diff --git a/src/data/m2-title-text-oam.bin b/src/data/m2-title-text-oam.bin new file mode 100644 index 0000000000000000000000000000000000000000..9e59c00a74362a768315e06dabe638c919786336 GIT binary patch literal 168 ncmZQ*U^u`40zjGtN^?MI9w;pUrA45$1eBJ6(hQ6s25kWV808DH literal 0 HcmV?d00001 diff --git a/src/data/m2-title-text.bin b/src/data/m2-title-text.bin new file mode 100644 index 0000000000000000000000000000000000000000..d4814da29abe047c49aff3a674392f587f42a55e GIT binary patch literal 4800 zcmeHJUu;uV82`>bqG&|UZP#tUx_bvC@OTG^5@5Y!jei~tw~hvNl6Dz(F`94-#uCPQ zJ4j58FP$VNMWLH$V)o+7G?+B7jhPrsGq<3U0A+&`YlOhLt1w`&dzz6`90E1o?8Ii>0HM}ZeZYmS-dhZLXn-Tl&J0g+A4PI|K zeQ5fbk->mO;eu_@$IbFu(Z*IWM`^q{Wto=QCqv4slqPTyN`uY9A))7_z1IHw;S^+M z`$QN05Xu?=8YWEIT<2c9*2%a*== z)w6m={?xBG78LXkV#wF#JptSNFp|KK)T$L|@g8foXZdb+qff(@GtRtz!0*?H%ctO? zP(@3~cQb)54fj^CHnz914N#)~6@JorL;%x;_l8F&Eq@Cmz}WmmP1nwo~-Ar%f)9i!x%gGn1O5yCzJoiC1wGWoGTy6dmiP z61YX%wskU4AtH*Hf208$gBVdzk|NJSXFN`kp4KrkqGQ>6@wiIZ*19j_w=}UO%dv?`A6otj4MkjpMkrQ-QU%ph6em(pO)+ji7`Z#zq3-}xc4!!nD|q~eR2XtZ zjznNt{47POHKd^6)_T?C@EqO8W^4@lj?xD@z8Qv~_)!t9)u>}#yHqKK zBjldQ)X|{hB%D{VlUtq$AvI)Q71;sZ#oqDYb#ABkk$!)o>}KGabvEc`Ndg2~SC_Nr;`&u@}};)auzT7A0rk z0|R?|4a{Wf+T^a}lG+s%p(=>bGJbfEj!Omd9gN(W?#4ixMw1X#k&YV(M{l!NZB)`T zarli~>N-!RDfYlQ9n(I(B(Q|=C9wH}=omC)K50UV)%Vpi<1&;D2eCOjh&h`Z*#wp?ekLa_wzUIuxt)tx)kH^T znTCWuoz0S=AXbCN{Z;rKL9U_dZloaZOT+UNbq}Cm1`JSbjA~*>O?9K;F>q5ZNB5FS zid`}c4QM#lBg3abBr6p`(ScEtj-kFCu)&1a73Acn?f@Xm*{h$3YUBMBhhR?v$8t6w zIP4Y?qn2mP!^l`nIL~JLP|@;xs-LVTG9Aj59cYoonH4kc&oUu~z?lj384}=lg6QZ^;PL@0bu0zzxd7&N0$1360Rv1zfes_XbwTo$ z%c7<+IYI6&vIoq~s;{2CR;odMq2{4m&b;8r0=(tNv!dv{K`EBQ7N`O*EZpFC0Ya@V zhW#~Hx!ExE^N=l~k(43in_^Rep^DCYN>m4-t8|01c@Dv15$e@CB(_AHW)!vRn zJeM;>F~2-oF|#N&C}uEWSGZe V9*@Tk$2=YWI~^YTzPBd>z~3vDtG)mL literal 0 HcmV?d00001 diff --git a/src/m2-hack.asm b/src/m2-hack.asm index bb677d2..430e1c7 100644 --- a/src/m2-hack.asm +++ b/src/m2-hack.asm @@ -1604,8 +1604,11 @@ nop .org 0x82D6BE0 :: dh 0x1100 // Disable BG1 .org 0x870F580 :: .incbin "data/m2-title-background.bin" +.org 0x8711280 :: .incbin "data/m2-title-text.bin" .org 0x87126CC :: .incbin "data/m2-title-background-pal-empty.bin" .org 0x87128EC :: .incbin "data/m2-title-background-map.bin" +.org 0x8712E68 :: .incbin "data/m2-title-text-oam.bin" +.org 0x8712F10 :: .incbin "data/m2-title-text-oam-entries.bin" //============================================================================== // Move stuff around in order to make space for the code From a8053975ac28ec7e27ca48fcf8b303d7c507038b Mon Sep 17 00:00:00 2001 From: jeffman Date: Thu, 26 Sep 2019 22:36:43 -0400 Subject: [PATCH 17/32] Add text palette control --- src/m2-title.asm | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/src/m2-title.asm b/src/m2-title.asm index beed36b..2b5e81a 100644 --- a/src/m2-title.asm +++ b/src/m2-title.asm @@ -59,6 +59,15 @@ str r0,[r1,4] ldr r0,=0x84000008 str r0,[r1,8] ldr r0,[r1,8] + +// Copy to OBJ pal 0 as well for the text +str r2,[r1] +ldr r0,=0x5000200 +str r0,[r1,4] +ldr r0,=0x84000008 +str r0,[r1,8] +ldr r0,[r1,8] + pop {r3} // Return to old sequence 0 code @@ -150,6 +159,7 @@ bhi @@next1 ldr r0,[r1,8] mov r2,0 str r2,[sp] + mov r2,sp str r2,[r1] ldr r0,=0x5000100 @@ -157,6 +167,15 @@ bhi @@next1 ldr r0,=0x85000040 str r0,[r1,8] ldr r0,[r1,8] + + // Black for OBJ pal 0 + str r2,[r1] + ldr r0,=0x5000200 + str r0,[r1,4] + ldr r0,=0x85000040 + str r0,[r1,8] + ldr r0,[r1,8] + pop {r2} b @@advance_frame @@ -192,6 +211,7 @@ bhi @@next2 add r0,r0,r1 // Copy to BG pal 8 + mov r4,r0 ldr r1,=0x40000D4 str r0,[r1] ldr r0,=0x5000100 @@ -199,6 +219,15 @@ bhi @@next2 ldr r0,=0x84000008 str r0,[r1,8] ldr r0,[r1,8] + + // Copy to OBJ pal 0 + str r4,[r1] + ldr r0,=0x5000200 + str r0,[r1,4] + ldr r0,=0x84000008 + str r0,[r1,8] + ldr r0,[r1,8] + b @@advance_frame @@next2: From 143a212f2bc0d75ee0766ac97e0f73d1e0ca623c Mon Sep 17 00:00:00 2001 From: jeffman Date: Sat, 28 Sep 2019 01:06:00 -0400 Subject: [PATCH 18/32] Update notes --- notes/m2-title-long.txt | 11 +++++++---- notes/m2-title-sprites.txt | 13 ++++++++++++- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/notes/m2-title-long.txt b/notes/m2-title-long.txt index 176a37d..cd66052 100644 --- a/notes/m2-title-long.txt +++ b/notes/m2-title-long.txt @@ -193,7 +193,8 @@ 08011640 (T) mov r2,0B2h 08011642 (T) lsl r2,r2,2h 08011644 (T) add r2,r9 - 08011646 (T) ldr r1,[sp,54h] // r1 = 0x68 + + 08011646 (T) ldr r1,[sp,54h] // r1 = 0x68 (X coordinate of the R) 08011648 (T) mov r0,0F0h 0801164A (T) sub r0,r0,r1 0801164C (T) str r0,[r2] // [20282F0] = 0xF0 - 0x68 = 0x88 @@ -215,6 +216,8 @@ // Looks like sp+58 and sp+78 are important variables; store their // locations to sp+8C and sp+90. Let's call them X and Y respectively. + // sp+58: pointer to end X coordinate of T + // sp+78: pointer to start X coordinate of T 08011668 (T) mov r1,r13 0801166A (T) add r1,58h 0801166C (T) str r1,[sp,8Ch] @@ -254,7 +257,7 @@ 08011690 (T) str r2,[sp,8Ch] 08011692 (T) sub r1,r1,r0 - 08011694 (T) str r1,[r5] + 08011694 (T) str r1,[r5] // delta between start and end X coordinates of the T 08011696 (T) mov r0,0AEh 08011698 (T) lsl r0,r0,2h 0801169A (T) add r0,r9 @@ -263,8 +266,8 @@ 080116A0 (T) mul r0,r1 080116A2 (T) ldr r1,[r7] 080116A4 (T) bl m2_div - 080116A8 (T) str r0,[r4] - 080116AA (T) ldmia [r5]!,r1 + 080116A8 (T) str r0,[r4] // r0 = increment per frame? + 080116AA (T) ldmia [r5]!,r1 // r1 = delta 080116AC (T) mov r3,r10 080116AE (T) ldr r0,[r3] 080116B0 (T) mul r0,r1 diff --git a/notes/m2-title-sprites.txt b/notes/m2-title-sprites.txt index 74c5c9a..adbc837 100644 --- a/notes/m2-title-sprites.txt +++ b/notes/m2-title-sprites.txt @@ -13,4 +13,15 @@ E8 2E 71 08 04 00 00 00 Subtitle (4 sprites) We have nine letters to do but there's only room in the table for eight; will figure out how to expand it later. -We'll use 32x64 sprites so that we only need one sprite for each letter (the Japanese version uses 2-6 sprites for each letter). \ No newline at end of file +We'll use 32x64 sprites so that we only need one sprite for each letter (the Japanese version uses 2-6 sprites for each letter). + +Final text positions: + +18 -> 0E +38 -> 22 +68 -> 38 +80 -> 4A +A0 -> 5C +B8 -> 8C +98 -> A0 +D2 -> B5 \ No newline at end of file From e60d0bb5b23fdbf4315c7aa6b37dc526c2b390c7 Mon Sep 17 00:00:00 2001 From: jeffman Date: Sat, 28 Sep 2019 01:08:06 -0400 Subject: [PATCH 19/32] Insert new text constants Ending X values were pulled from EB. Starting X values were estimated based on the velocity of the letters in a video of EB's animation. --- src/data/m2-title-text-constants.bin | Bin 0 -> 140 bytes src/m2-hack.asm | 1 + 2 files changed, 1 insertion(+) create mode 100644 src/data/m2-title-text-constants.bin diff --git a/src/data/m2-title-text-constants.bin b/src/data/m2-title-text-constants.bin new file mode 100644 index 0000000000000000000000000000000000000000..01c927ab37579e4b6873f321a25833c8728fb907 GIT binary patch literal 140 zcmb1OU|_HS;s79)r4aK0^(z4}$UH9~jsfBxAYK5(TY>oX-~a!e|NZ}e0Em76|Ns98 Qhz%JT7#;!f6eb1+04LuW6#xJL literal 0 HcmV?d00001 diff --git a/src/m2-hack.asm b/src/m2-hack.asm index 430e1c7..1115380 100644 --- a/src/m2-hack.asm +++ b/src/m2-hack.asm @@ -1603,6 +1603,7 @@ nop .org 0x82D6BD4 :: dh 0x008A // Enable 8-bit BG0 .org 0x82D6BE0 :: dh 0x1100 // Disable BG1 +.org 0x80FCB74 :: .incbin "data/m2-title-text-constants.bin" .org 0x870F580 :: .incbin "data/m2-title-background.bin" .org 0x8711280 :: .incbin "data/m2-title-text.bin" .org 0x87126CC :: .incbin "data/m2-title-background-pal-empty.bin" From 75e48764788f666124d0d1558c04533915084f1b Mon Sep 17 00:00:00 2001 From: jeffman Date: Sat, 28 Sep 2019 01:13:14 -0400 Subject: [PATCH 20/32] Add custom text animation code --- build.ps1 | 3 ++- src/c/title.c | 36 ++++++++++++++++++++++++++++++++++++ src/c/title.h | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ src/m2-hack.asm | 1 + src/m2-title.asm | 12 ++++++++++++ 5 files changed, 99 insertions(+), 1 deletion(-) create mode 100644 src/c/title.c create mode 100644 src/c/title.h diff --git a/build.ps1 b/build.ps1 index a59f039..1d87443 100644 --- a/build.ps1 +++ b/build.ps1 @@ -18,7 +18,8 @@ $input_c_files = "src/c/fileselect.c", "src/c/status.c", "src/c/battle.c", - "src/c/psi.c" + "src/c/psi.c", + "src/c/title.c" $base_c_address = 0x83755B8; $scripttool_cmd = "bin/ScriptTool/ScriptTool.dll" diff --git a/src/c/title.c b/src/c/title.c new file mode 100644 index 0000000..458c4bf --- /dev/null +++ b/src/c/title.c @@ -0,0 +1,36 @@ +#include "title.h" + +void title_text_sequence( + TITLE_CONTROL *control, + TITLE_EXTENDED *ext, + TITLE_COORD_TABLE *coords) +{ + int duration = 140; // approximate length of EB's animation, + // from the first frame that H is visible + // until all letters have stopped moving + int frame = control->frame; + + if (frame > duration) + { + control->frame = -1; + ext->sequence++; + return; + } + + for (int i = 0; i < 8; i++) + { + int x_start = coords->x_start[i]; + int x_end = coords->x_end[i]; + int x_delta = x_end - x_start; + int x_new = (m2_div((x_delta * frame) << 12, duration) >> 12) + x_start; + + // X coordinate is only 9 bits signed, so clamp the values to a reasonable range + if (x_new < -250) + x_new = -250; + if (x_new > 250) + x_new = 250; + + ext->sprites[i].x = x_new; + ext->sprites[i].y = coords->y_end[i]; // we're not translating the sprites vertically + } +} diff --git a/src/c/title.h b/src/c/title.h new file mode 100644 index 0000000..e54ecef --- /dev/null +++ b/src/c/title.h @@ -0,0 +1,48 @@ +#ifndef HEADER_TITLE_INCLUDED +#define HEADER_TITLE_INCLUDED + +#include "types.h" + +typedef struct TITLE_COORD_TABLE { + int unknown_a[3]; + int y_end[8]; + int y_start[8]; + int x_end[8]; + int x_start[8]; +} TITLE_COORD_TABLE; + +typedef struct TITLE_SPRITE { + struct TITLE_SPRITE *prev; + void *anim_table; + void *oam_entry_table; + void *unknown_table; + int unknown_a[5]; + int x; + int y; + int unknown_b[5]; +} TITLE_SPRITE; + +typedef struct TITLE_EXTENDED { + unsigned short *pal_buffer[5]; + byte unknown_a[0x70]; + int sequence; + TITLE_SPRITE sprites[8]; + int unknown[0x16]; +} TITLE_EXTENDED; + +typedef struct TITLE_CONTROL { + int unknown_a; + int frame; + int unknown_b[3]; + TITLE_EXTENDED *ext; + int unknown_c[2]; +} TITLE_CONTROL; + +void title_text_sequence( + TITLE_CONTROL *control, + TITLE_EXTENDED *ext, + TITLE_COORD_TABLE *coords); + +extern int m2_div(int dividend, int divisor); + +#endif diff --git a/src/m2-hack.asm b/src/m2-hack.asm index 1115380..e78924f 100644 --- a/src/m2-hack.asm +++ b/src/m2-hack.asm @@ -1582,6 +1582,7 @@ nop // Point to sequence hacks .org 0x8011798 :: dw title_sequence_00 .org 0x801179C :: dw title_sequence_01 + .org 0x80117A4 :: dw title_sequence_03 .org 0x80117A8 :: dw title_sequence_04 .org 0x80117AC :: dw title_sequence_05 .org 0x80117B4 :: dw title_sequence_07 diff --git a/src/m2-title.asm b/src/m2-title.asm index 2b5e81a..91c5811 100644 --- a/src/m2-title.asm +++ b/src/m2-title.asm @@ -111,6 +111,18 @@ beq @@unset @@end: b title_return +//--------------------------------------------------------- +title_sequence_03: + +push {r0-r3} +mov r0,r2 // 0x2028008 +mov r1,r9 // 0x2028028 +mov r2,sp +add r2,0x10 // coord table on the stack +bl title_text_sequence +pop {r0-r3} +b title_return + //--------------------------------------------------------- title_sequence_04: From 4cca5277a118b6e1d2da40ee678849530ed4baf4 Mon Sep 17 00:00:00 2001 From: jeffman Date: Sun, 29 Sep 2019 12:43:08 -0400 Subject: [PATCH 21/32] Clamp text X values --- src/m2-hack.asm | 3 +++ src/m2-title.asm | 18 ++++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/src/m2-hack.asm b/src/m2-hack.asm index e78924f..8231bb4 100644 --- a/src/m2-hack.asm +++ b/src/m2-hack.asm @@ -1595,6 +1595,9 @@ nop .org 0x80117D4 :: dw title_sequence_0D .org 0x80117D8 :: dw title_sequence_0D + // Clamp initial X values for text + .org 0x80116F0 :: bl title_setup_clamp + // Commit hacks: // Commit all things on every sequence diff --git a/src/m2-title.asm b/src/m2-title.asm index 91c5811..9393c68 100644 --- a/src/m2-title.asm +++ b/src/m2-title.asm @@ -11,6 +11,24 @@ pop {r1} ldr r0,=0x80113F4 mov pc,r0 // Run the existing routine +//--------------------------------------------------------- +title_setup_clamp: +mov r1,250 +cmp r0,r1 +bgt @@clamp +neg r1,r1 +cmp r0,r1 +blt @@clamp +b @@clamp_end + +@@clamp: +mov r0,r1 + +@@clamp_end: +str r0,[r5,4] +mov r1,r8 // clobbered code +bx lr + //--------------------------------------------------------- // r3 has 2028008 // [r3+14] has 2028028 From ba43ce0af6b0827af6287114c863ff23e245e0dc Mon Sep 17 00:00:00 2001 From: jeffman Date: Sun, 29 Sep 2019 13:05:04 -0400 Subject: [PATCH 22/32] Show O and U from the start --- src/m2-hack.asm | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/m2-hack.asm b/src/m2-hack.asm index 8231bb4..199dee4 100644 --- a/src/m2-hack.asm +++ b/src/m2-hack.asm @@ -1598,6 +1598,10 @@ nop // Clamp initial X values for text .org 0x80116F0 :: bl title_setup_clamp + // Show all eight text sprites from the start + .org 0x8011B94 :: mov r6,7 + .org 0x8011BAC :: b 0x8011BDC + // Commit hacks: // Commit all things on every sequence From 7a125b19d9f5946af152ed8006a216dfedaac3f9 Mon Sep 17 00:00:00 2001 From: jeffman Date: Sun, 29 Sep 2019 14:35:58 -0400 Subject: [PATCH 23/32] Allocate space for nine sprites Need to relocate data that's stored after the sprites --- src/m2-hack.asm | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/src/m2-hack.asm b/src/m2-hack.asm index 199dee4..b27d590 100644 --- a/src/m2-hack.asm +++ b/src/m2-hack.asm @@ -1602,6 +1602,20 @@ nop .org 0x8011B94 :: mov r6,7 .org 0x8011BAC :: b 0x8011BDC + // Allocate space for nine sprites + .org 0x80113F8 :: mov r0,0xC8 + + // Relocate stuff from after the sprite data + .org 0x8011634 :: mov r1,0xB2 + .org 0x8011640 :: mov r2,0xC2 + .org 0x801164E :: mov r1,0xBE + .org 0x801165C :: mov r7,0xC2 + .org 0x8011662 :: mov r5,0xC3 + .org 0x8011674 :: mov r3,0xB2 + .org 0x801167C :: mov r4,0xB3 + .org 0x8011696 :: mov r0,0xBE + .org 0x8011838 :: mov r1,0xB6 + // Commit hacks: // Commit all things on every sequence @@ -1611,7 +1625,11 @@ nop .org 0x82D6BD4 :: dh 0x008A // Enable 8-bit BG0 .org 0x82D6BE0 :: dh 0x1100 // Disable BG1 -.org 0x80FCB74 :: .incbin "data/m2-title-text-constants.bin" +.org 0x801170C :: dw m2_title_text_constants +.org 0x8011710 :: dw m2_title_text_constants + 12 +.org 0x8011714 :: dw m2_title_text_constants + 12 + 32 +.org 0x8011718 :: dw m2_title_text_constants + 12 + 32 + 32 +.org 0x801171C :: dw m2_title_text_constants + 12 + 32 + 32 + 32 .org 0x870F580 :: .incbin "data/m2-title-background.bin" .org 0x8711280 :: .incbin "data/m2-title-text.bin" .org 0x87126CC :: .incbin "data/m2-title-background-pal-empty.bin" @@ -1749,6 +1767,11 @@ dw 0x1C0 :: .incbin "data/m2-title-text-pal-animated.c.bin" m2_title_text_pal_static: dw 0x20 :: .incbin "data/m2-title-text-pal-static.c.bin" +.align 4 + +m2_title_text_constants: +.incbin "data/m2-title-text-constants.bin" + //============================================================================== // Existing subroutines/data //============================================================================== From cc9d70cead443d527a93cc729008b28d30679528 Mon Sep 17 00:00:00 2001 From: jeffman Date: Sun, 29 Sep 2019 14:48:40 -0400 Subject: [PATCH 24/32] Relocate and expand text parameters --- src/data/m2-title-text-params.bin | Bin 0 -> 180 bytes src/m2-hack.asm | 13 +++++++++++++ 2 files changed, 13 insertions(+) create mode 100644 src/data/m2-title-text-params.bin diff --git a/src/data/m2-title-text-params.bin b/src/data/m2-title-text-params.bin new file mode 100644 index 0000000000000000000000000000000000000000..5c399b6d7be2243e61fb8cddabb0195a1a93a12c GIT binary patch literal 180 zcmd1ME978gU|=YK(iKp;0ZMm3=?PGJ29#a^rB^^{1_l-eMj&PaVrC!)K~^AU17da{ O<^baVKmf9fQW^l14=&yS literal 0 HcmV?d00001 diff --git a/src/m2-hack.asm b/src/m2-hack.asm index b27d590..66799e1 100644 --- a/src/m2-hack.asm +++ b/src/m2-hack.asm @@ -1636,6 +1636,7 @@ nop .org 0x87128EC :: .incbin "data/m2-title-background-map.bin" .org 0x8712E68 :: .incbin "data/m2-title-text-oam.bin" .org 0x8712F10 :: .incbin "data/m2-title-text-oam-entries.bin" +.org 0x8712FB0 :: dw m2_title_text_params, m2_title_text_params + 0x6C //============================================================================== // Move stuff around in order to make space for the code @@ -1772,6 +1773,18 @@ dw 0x20 :: .incbin "data/m2-title-text-pal-static.c.bin" m2_title_text_constants: .incbin "data/m2-title-text-constants.bin" +m2_title_text_params: +.incbin "data/m2-title-text-params.bin" +.org m2_title_text_params + 0x6C :: dw m2_title_text_params + 0x48 +.org m2_title_text_params + 0x74 :: dw m2_title_text_params + 0x4C +.org m2_title_text_params + 0x7C :: dw m2_title_text_params + 0x50 +.org m2_title_text_params + 0x84 :: dw m2_title_text_params + 0x54 +.org m2_title_text_params + 0x8C :: dw m2_title_text_params + 0x58 +.org m2_title_text_params + 0x94 :: dw m2_title_text_params + 0x5C +.org m2_title_text_params + 0x9C :: dw m2_title_text_params + 0x60 +.org m2_title_text_params + 0xA4 :: dw m2_title_text_params + 0x64 +.org m2_title_text_params + 0xAC :: dw m2_title_text_params + 0x68 + //============================================================================== // Existing subroutines/data //============================================================================== From 501dca758615e522eeb9d1048367aaf96cf334f0 Mon Sep 17 00:00:00 2001 From: jeffman Date: Sun, 29 Sep 2019 15:20:19 -0400 Subject: [PATCH 25/32] Complete changes for nine sprites --- src/c/title.c | 2 +- src/c/title.h | 10 +++---- src/data/m2-title-text-constants.bin | Bin 140 -> 156 bytes src/m2-hack.asm | 39 ++++++++++++++++++++++++--- 4 files changed, 41 insertions(+), 10 deletions(-) diff --git a/src/c/title.c b/src/c/title.c index 458c4bf..d4058e2 100644 --- a/src/c/title.c +++ b/src/c/title.c @@ -17,7 +17,7 @@ void title_text_sequence( return; } - for (int i = 0; i < 8; i++) + for (int i = 0; i < 9; i++) { int x_start = coords->x_start[i]; int x_end = coords->x_end[i]; diff --git a/src/c/title.h b/src/c/title.h index e54ecef..fc87f3c 100644 --- a/src/c/title.h +++ b/src/c/title.h @@ -5,10 +5,10 @@ typedef struct TITLE_COORD_TABLE { int unknown_a[3]; - int y_end[8]; - int y_start[8]; - int x_end[8]; - int x_start[8]; + int y_end[9]; + int y_start[9]; + int x_end[9]; + int x_start[9]; } TITLE_COORD_TABLE; typedef struct TITLE_SPRITE { @@ -26,7 +26,7 @@ typedef struct TITLE_EXTENDED { unsigned short *pal_buffer[5]; byte unknown_a[0x70]; int sequence; - TITLE_SPRITE sprites[8]; + TITLE_SPRITE sprites[9]; int unknown[0x16]; } TITLE_EXTENDED; diff --git a/src/data/m2-title-text-constants.bin b/src/data/m2-title-text-constants.bin index 01c927ab37579e4b6873f321a25833c8728fb907..db2000eb8c788b08f409d20d9942c3d8cf181344 100644 GIT binary patch delta 22 dcmeBSoWnT5XQBefL>~plQxh|lSyY)B7ywUQ1 Date: Sun, 29 Sep 2019 15:24:13 -0400 Subject: [PATCH 26/32] Update contributors --- CONTRIBUTORS.txt | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/CONTRIBUTORS.txt b/CONTRIBUTORS.txt index 12c1f08..c773c1d 100644 --- a/CONTRIBUTORS.txt +++ b/CONTRIBUTORS.txt @@ -1,7 +1,5 @@ -Hacking, script tool, script compiler/decompiler: - JeffMan - Hacking: + JeffMan Lorenzooone PhoenixBound @@ -24,5 +22,15 @@ Text conversion: Sterophonick Normmatt +Graphics: + JeffMan + surrashubound + Masaru + +Testing: + Eevs + John Enigma + CloverCharBoyBound + Special thanks: TragicManner From e37be4528a4a4579009bddf76c5d0c63a430b1c8 Mon Sep 17 00:00:00 2001 From: jeffman Date: Sun, 29 Sep 2019 22:24:17 -0400 Subject: [PATCH 27/32] Update copyright graphics --- src/data/m2-title-background-map.bin | Bin 817 -> 932 bytes .../m2-title-background-pal-copyright.c.bin | Bin 72 -> 70 bytes src/data/m2-title-background.bin | Bin 6724 -> 6301 bytes src/m2-hack.asm | 6 ++++++ 4 files changed, 6 insertions(+) diff --git a/src/data/m2-title-background-map.bin b/src/data/m2-title-background-map.bin index 87ffc3190482dedc44fa1560ec874e5a5ed830e2..4f4cdcd98578121404b768afc68cf95843653c9e 100644 GIT binary patch delta 248 zcmXBPM>azN06@|ABJy>D=;iBWY%I27C2YYl$ObHc9b^Y;^b)=E_2}g|Z+r)DE-@3# zW?~bC$p5m=vjB@MvCInOSY?fM*kF?_wqb`|_Q=CN2OM$~avY6v!YQ0_&IOln#WgqF zLc|^SJisGQJo5qtUU}o4v5#N%$rs;~@sV+jS!5iGO&C~$rIuN41y)*RwKbZw);gm! v^`>mFQJQSF#a3yv-3~h?w99ULq}M+C9WWSl$l)kG6{e;$v1E|{+syg{8!|*! delta 123 zcmYMiyAc6V6oBFX*cnD-M8Zvt3WWNQY^(^Q0ND*T6)1oXZU@-4-jD13=4b$+`M!3h zo9=`u)AaJyhLawB21F1uBw++&CQO-GEn1ngUdVEq4q5fz^K Oz*xY@Ec1bJ0wVzbKNw2@ literal 72 zcmWe&U}RummSL7j(^#Ry@X~v@t8ZWnog4s;Uog7EX1IO}BT%u*R?iQhSV<1rR*j~r_VOKs zV%H1c1ho%M5?SOmA|W(@duiDAQ`c!=V&6%<_(UuDBEpK5P_H@oIop%yqa-PMMF|?y z%;;5L9{mLeU{I-|!h7Uc zXv5Xxx{tBVv>G`l9F=S1_V{7S;SaNyGPJ~hZ;iFCrc-aL{`TI zJ^pf5HxOCvc%&d?^{_sA%{}kY#XqvDzM>;6W%g(F5A{GII9ZjJ58zT#dQLhLjt9?* zec|)kZhW5dgHxPrch&Nh8ATXF`jY1xKc2J5HDvE^2O}XA9ok9R7o_$LcQjPjw}KJR z`RSRM)JrVD_P5PVpiL!T?VRkm1tqpHEwkT6+qKXwmEMsWfqnf#XqUW<@=ai`?wL-s zjb$f*$>eZ~`+qo$GdfXdex6;o41O%H*5B^_rROP3E&Ba|{X)}7Gp+BAyAl}tQ~K+K zU2yNyk6iFR+bv+ZC*SJ&R3qn zDA#o+tLN2~?IY|!|BY=}P-|~G6V~WNUdb!5R(!WYeCYisuVn9ivfb_>8s?SHlKKd*e-iOHk#KY3+Q3Fl5YrW3$mF5G`;{KxbLFq#}l%y^9nC}Xmx;LUN{V~?w; z54N((4v-9nop;j*45AG|Q&ETl>@>*OJE^v!5Ogl+2Fc}&9p1vjR(B4(z^ti%zfr7+ ysHq1ASvCz7z3}#-U4uXilG8Ie_+{Z0U`Cysu}nVWlOcJo7`W_A!MdAPD%4_9tfsV@ zq=pEVx@#Nz1Gd`G`d}-zMJQIm#6>G8sfle-AwG#z5t;`zAT60#Z4!)$(g6nM@Y+a0! zvJNawx)5f;2LHr*BRDOn$2g`3y6tIK{CC9L-7H7GWe-EO8~Yw zM0RIxddO>p2#`B_E#SwK2Q1<3JusAh0^F($uaBWwB! z`Z?%i%8xd+1j-hsoY84G1~pOJ?1d2d(}$wrY$0P?-8^Jp!bN`&&3g=6Zbe~oWQt)J zgYA|OVj@=I>=xKC-A8Q5l=IEF1QjHX23UD=)}m4seDsI0{)VWGcp+)h1aP8 zb>2xD+jvDQubM}IaSAKHajzX;N35(zi7GqoO2>c*0XLJyg|W8tMv(5t8buV=lG(^U z9BTt+3aT@la5HiO%w7%|+#|EW@VDWn5ZxFa>^$9no4bF)4>mMdED^EIT!gJ&<(6Qz zz3RKRqhv>4@MVM-yI*G#tx=$!;a-O56_CmA)PHEVg%+hB2hm)|)4O2pTf z6?VcFXnNYnj@z40p`X1Z5&d+}2K@;7T$u{L(#}%EpIBKcz3+0CGo91wP@|JL$aAW3U;BmPw4lt(ms?+Gc(x(dkm*U*>yM!OvJCFGXq!Sk83<#SyySI8gBU8p!k||pE8tG`tB+N zaH1k~y>PxT?o42+tW)$Lv#Z+iF|+bO{Ox)w1ytYr%PdKp3)nK*@3B~}`OV}g3}+j| zmoJ^mlGHvllzIUTc?=C*T609)`go!kPUX+8YtQdr_}jg6=c^VPJD80=Tn_IE(I@ox a+=bhPvJ*c-%V*qYWA4(On*Sww3jYB}r1Mq) diff --git a/src/m2-hack.asm b/src/m2-hack.asm index 6d78502..649bc04 100644 --- a/src/m2-hack.asm +++ b/src/m2-hack.asm @@ -1790,12 +1790,18 @@ m2_coord_table_file: m2_title_background_pal_copyright: dw 0x100 :: .incbin "data/m2-title-background-pal-copyright.c.bin" +.align 4 + m2_title_background_pal_glow: dw 0x280 :: .incbin "data/m2-title-background-pal-glow.c.bin" +.align 4 + m2_title_text_pal_animated: dw 0x1C0 :: .incbin "data/m2-title-text-pal-animated.c.bin" +.align 4 + m2_title_text_pal_static: dw 0x20 :: .incbin "data/m2-title-text-pal-static.c.bin" From 624f3fd67a59180f6dc86034eed1e8aab486528d Mon Sep 17 00:00:00 2001 From: Lorenzo Carletti Date: Thu, 30 Sep 2021 23:24:00 +0200 Subject: [PATCH 28/32] Complete Merge --- CONTRIBUTORS.txt | 14 +- build.ps1 | 1 + notes/m2-sub111D0.txt | 255 ++++ notes/m2-title-long.txt | 1169 +++++++++++++++++ notes/m2-title-sprites.txt | 27 + src/c/ext.c | 4 +- src/c/locs.h | 1 + src/c/title.c | 36 + src/c/title.h | 48 + src/data/m2-title-background-map.bin | Bin 0 -> 932 bytes .../m2-title-background-pal-copyright.c.bin | Bin 0 -> 70 bytes src/data/m2-title-background-pal-empty.bin | Bin 0 -> 68 bytes src/data/m2-title-background-pal-glow.c.bin | Bin 0 -> 124 bytes src/data/m2-title-background.bin | Bin 0 -> 6301 bytes src/data/m2-title-text-constants.bin | Bin 0 -> 156 bytes src/data/m2-title-text-oam-entries.bin | Bin 0 -> 64 bytes src/data/m2-title-text-oam.bin | Bin 0 -> 168 bytes src/data/m2-title-text-pal-animated.c.bin | Bin 0 -> 124 bytes src/data/m2-title-text-pal-static.c.bin | Bin 0 -> 16 bytes src/data/m2-title-text-params.bin | Bin 0 -> 180 bytes src/data/m2-title-text.bin | Bin 0 -> 4800 bytes src/m2-hack.asm | 231 +++- src/m2-title.asm | 492 +++++++ 23 files changed, 2273 insertions(+), 5 deletions(-) create mode 100644 notes/m2-sub111D0.txt create mode 100644 notes/m2-title-long.txt create mode 100644 notes/m2-title-sprites.txt create mode 100644 src/c/title.c create mode 100644 src/c/title.h create mode 100644 src/data/m2-title-background-map.bin create mode 100644 src/data/m2-title-background-pal-copyright.c.bin create mode 100644 src/data/m2-title-background-pal-empty.bin create mode 100644 src/data/m2-title-background-pal-glow.c.bin create mode 100644 src/data/m2-title-background.bin create mode 100644 src/data/m2-title-text-constants.bin create mode 100644 src/data/m2-title-text-oam-entries.bin create mode 100644 src/data/m2-title-text-oam.bin create mode 100644 src/data/m2-title-text-pal-animated.c.bin create mode 100644 src/data/m2-title-text-pal-static.c.bin create mode 100644 src/data/m2-title-text-params.bin create mode 100644 src/data/m2-title-text.bin create mode 100644 src/m2-title.asm diff --git a/CONTRIBUTORS.txt b/CONTRIBUTORS.txt index 6c9a95e..2b846b8 100644 --- a/CONTRIBUTORS.txt +++ b/CONTRIBUTORS.txt @@ -1,7 +1,5 @@ -Hacking, script tool, script compiler/decompiler: - JeffMan - Hacking: + JeffMan Lorenzooone PhoenixBound @@ -25,5 +23,15 @@ Text conversion: Normmatt KillThad +Graphics: + JeffMan + surrashubound + Masaru + +Testing: + Eevs + John Enigma + CloverCharBoyBound + Special thanks: TragicManner diff --git a/build.ps1 b/build.ps1 index b0b5aa7..c26d273 100644 --- a/build.ps1 +++ b/build.ps1 @@ -26,6 +26,7 @@ $input_c_files = "src/c/battle.c", "src/c/equip.c", "src/c/psi.c", + "src/c/title.c", "src/c/luminehall.c" $base_c_address = 0x83755B8; diff --git a/notes/m2-sub111D0.txt b/notes/m2-sub111D0.txt new file mode 100644 index 0000000..ab61c0d --- /dev/null +++ b/notes/m2-sub111D0.txt @@ -0,0 +1,255 @@ +// Load intro screen + +// 82D6AA8: structs of size 0x38 +// Offset Length Description +// ------------------------------------ +// 0 4 BG0 graphics pointer (compressed) +// 4 4 Sprite graphics pointer (compressed) +// 8 4 BG palette pointer (compressed) +// C 4 Sprite palette pointer (compressed) +// 10 4 BG0 tilemap pointer (compressed) +// 14 2 BG0 attributes +// 16 2 Unused? +// 18 4 BG1 tilemap pointer (compressed) +// 1C 2 BG1 attributes +// 1E 2 Unused? +// 20 2 DISPCNT +// 22 2 Some kind of index into a jump table (negative values are special) +// 24 4 Unused? +// 28 16 Four-entry jump table +// [0]: called at the start of the animation +// [1,2]: called for each frame (seems to be setup and then commit) +// [3]: called at the end of the animation + +// Dump: +// ----- +// # BG0gfx OBJgfx BGpal OBJpal BG0map BG0attr BG1map BG1attr DISP jump - Start Setup Commit End +// ------------------------------------------------------------------------------------------------------------------------------------ +// [0] 08714840 00000000 087147E4 00000000 087143FC 000B 0000 00000000 0000 0000 1100 0000 00000000 0801200D 080120B1 08012035 08012011 +// [1] 00000000 00000000 00000000 00000000 08714538 000B 0000 00000000 0000 0000 1100 0001 00000000 0801200D 080120B1 08012035 08012011 +// [2] 00000000 00000000 00000000 00000000 08714688 000B 0000 00000000 0000 0000 1100 0001 00000000 0801200D 080120B1 08012035 08012011 +// [3] 0870F580 08711280 087126CC 087127E8 087128EC 000A 0000 08712CD8 010B 0000 1000 FFFF 00000000 080113F5 080115A9 08011499 08011495 +// [4] 0870F580 08711280 087126CC 087127E8 087128EC 000A 0000 08712CD8 010B 0000 1300 0001 00000000 080113F5 08011F05 08011499 08011495 +// [5] 0870F580 08711280 087126CC 087127E8 087128EC 000A 0000 08712CD8 010B 0000 1300 0001 00000000 080113F5 08011BFD 08011499 08011495 +// [6] 0871325C 00000000 08713210 00000000 08712FB8 000A 0000 00000000 0000 0000 0100 0001 00000000 0801200D 0801214D 08012035 08012011 + +// r0: screen key +// 0 = Nintendo +// 1 = APE +// 2 = HALKEN +// 3 = Title screen (full) +// 5 = Title screen (quick) + +// 0x18 byte struct: ($2028008) +// Offset Length Description +// ------------------------------------ +// 0 4 Animation number +// 4 4 Current frame +// 8 4 ? +// C 4 ? +// 10 4 ? +// 14 4 Pointer to giant 0x2E0 byte struct used in $80113F5 + +080111D0 (T) push r4-r7,r14 +080111D2 (T) mov r7,r9 +080111D4 (T) mov r6,r8 +080111D6 (T) push r6,r7 +080111D8 (T) add sp,-4h +080111DA (T) mov r5,r0 +080111DC (T) ldr r4,=3000370h +080111DE (T) mov r0,18h +080111E0 (T) bl 8005B9Ch // malloc 0x18 bytes for some struct +080111E4 (T) str r0,[r4] +080111E6 (T) str r5,[r0] +080111E8 (T) mov r7,0h +080111EA (T) str r7,[r0,14h] +080111EC (T) str r7,[r0,4h] +080111EE (T) str r7,[r0,10h] // zero out the struct +080111F0 (T) ldr r6,=82D6AA8h +080111F2 (T) lsl r0,r5,3h +080111F4 (T) sub r0,r0,r5 +080111F6 (T) lsl r4,r0,3h // r4 = r5 * 0x38 +080111F8 (T) add r0,r4,r6 +080111FA (T) ldr r0,[r0] +080111FC (T) cmp r0,0h +080111FE (T) beq 801120Ch +08011200 (T) mov r1,80h +08011202 (T) lsl r1,r1,12h +08011204 (T) mov r2,40h +08011206 (T) lsl r2,r2,8h +08011208 (T) bl 8005D34h +0801120C (T) add r0,r6,4 +0801120E (T) add r0,r4,r0 +08011210 (T) ldr r0,[r0] +08011212 (T) cmp r0,0h +08011214 (T) beq 8011220h +08011216 (T) ldr r1,=2008000h +08011218 (T) mov r2,80h +0801121A (T) lsl r2,r2,8h +0801121C (T) bl 8005D34h +08011220 (T) mov r0,r6 +08011222 (T) add r0,8h +08011224 (T) add r0,r4,r0 +08011226 (T) ldr r3,[r0] +08011228 (T) cmp r3,0h +0801122A (T) beq 801126Ch +0801122C (T) mov r0,1h +0801122E (T) neg r0,r0 +08011230 (T) cmp r3,r0 +08011232 (T) bne 8011260h +08011234 (T) str r7,[sp] +08011236 (T) ldr r1,=40000D4h +08011238 (T) mov r0,r13 +0801123A (T) str r0,[r1] +0801123C (T) ldr r0,=2010000h +0801123E (T) str r0,[r1,4h] +08011240 (T) ldr r0,=85000080h +08011242 (T) str r0,[r1,8h] +08011244 (T) ldr r0,[r1,8h] +08011246 (T) b 801126Ch +08011248 (T) lsl r0,r6,0Dh +0801124A (T) lsl r0,r0,0Ch +0801124C (T) ldr r0,[r5,28h] +0801124E (T) lsr r5,r5,20h +08011250 (T) strh r0,[r0] +08011252 (T) lsl r0,r0,8h +08011254 (T) lsl r4,r2,3h +08011256 (T) lsl r0,r0,10h +08011258 (T) lsl r0,r0,0h +0801125A (T) lsl r1,r0,8h +0801125C (T) lsl r0,r0,2h +0801125E (T) strh r0,[r0,28h] +08011260 (T) ldr r1,=2010000h +08011262 (T) mov r2,80h +08011264 (T) lsl r2,r2,2h +08011266 (T) mov r0,r3 +08011268 (T) bl 8005D34h +0801126C (T) ldr r1,=82D6AA8h +0801126E (T) mov r9,r1 +08011270 (T) lsl r0,r5,3h +08011272 (T) sub r0,r0,r5 +08011274 (T) lsl r7,r0,3h +08011276 (T) mov r0,r9 +08011278 (T) add r0,0Ch +0801127A (T) add r0,r7,r0 +0801127C (T) ldr r0,[r0] +0801127E (T) cmp r0,0h +08011280 (T) beq 801128Ch +08011282 (T) ldr r1,=2010200h +08011284 (T) mov r2,80h +08011286 (T) lsl r2,r2,2h +08011288 (T) bl 8005D34h +0801128C (T) mov r0,r9 +0801128E (T) add r0,10h +08011290 (T) add r0,r7,r0 +08011292 (T) ldr r0,[r0] +08011294 (T) cmp r0,0h +08011296 (T) beq 80112A2h +08011298 (T) ldr r1,=2010400h +0801129A (T) mov r2,80h +0801129C (T) lsl r2,r2,4h +0801129E (T) bl 8005D34h +080112A2 (T) mov r0,r9 +080112A4 (T) add r0,18h +080112A6 (T) add r0,r7,r0 +080112A8 (T) ldr r0,[r0] +080112AA (T) cmp r0,0h +080112AC (T) beq 80112B8h +080112AE (T) ldr r1,=2010C00h +080112B0 (T) mov r2,80h +080112B2 (T) lsl r2,r2,4h +080112B4 (T) bl 8005D34h +080112B8 (T) ldr r0,=2010000h +080112BA (T) mov r8,r0 +080112BC (T) mov r0,0h +080112BE (T) mov r1,r8 +080112C0 (T) strh r0,[r1] +080112C2 (T) bl 80F47E4h +080112C6 (T) bl 800E5E4h +080112CA (T) ldr r4,=40000D4h +080112CC (T) mov r0,80h +080112CE (T) lsl r0,r0,12h +080112D0 (T) str r0,[r4] +080112D2 (T) ldr r0,=6008000h +080112D4 (T) str r0,[r4,4h] +080112D6 (T) ldr r5,=84001000h +080112D8 (T) str r5,[r4,8h] +080112DA (T) ldr r0,[r4,8h] +080112DC (T) ldr r6,=4000006h +080112DE (T) ldrh r0,[r6] +080112E0 (T) bl 80F47E4h +080112E4 (T) bl 800E5E4h +080112E8 (T) ldr r0,=2004000h +080112EA (T) str r0,[r4] +080112EC (T) ldr r0,=600C000h +080112EE (T) str r0,[r4,4h] +080112F0 (T) str r5,[r4,8h] +080112F2 (T) ldr r0,[r4,8h] +080112F4 (T) ldrh r0,[r6] +080112F6 (T) bl 80F47E4h +080112FA (T) bl 800E5E4h +080112FE (T) ldr r1,=4000008h +08011300 (T) mov r0,r9 +08011302 (T) add r5,r7,r0 +08011304 (T) ldrh r0,[r5,14h] +08011306 (T) strh r0,[r1] +08011308 (T) add r1,2h +0801130A (T) ldrh r0,[r5,1Ch] +0801130C (T) strh r0,[r1] +0801130E (T) mov r1,r8 +08011310 (T) str r1,[r4] +08011312 (T) mov r0,0A0h +08011314 (T) lsl r0,r0,13h +08011316 (T) str r0,[r4,4h] +08011318 (T) ldr r0,=84000080h +0801131A (T) mov r9,r0 +0801131C (T) str r0,[r4,8h] +0801131E (T) ldr r0,[r4,8h] +08011320 (T) ldr r0,=2010400h +08011322 (T) str r0,[r4] +08011324 (T) mov r0,0C0h +08011326 (T) lsl r0,r0,13h +08011328 (T) str r0,[r4,4h] +0801132A (T) ldr r1,=84000200h +0801132C (T) mov r8,r1 +0801132E (T) str r1,[r4,8h] +08011330 (T) ldr r0,[r4,8h] +08011332 (T) ldrh r0,[r6] +08011334 (T) bl 80F47E4h +08011338 (T) bl 800E5E4h +0801133C (T) ldr r0,=2008000h +0801133E (T) str r0,[r4] +08011340 (T) ldr r0,=6010000h +08011342 (T) str r0,[r4,4h] +08011344 (T) ldr r0,=84002000h +08011346 (T) str r0,[r4,8h] +08011348 (T) ldr r0,[r4,8h] +0801134A (T) ldrh r0,[r6] +0801134C (T) bl 80F47E4h +08011350 (T) bl 800E5E4h +08011354 (T) mov r1,80h +08011356 (T) lsl r1,r1,13h +08011358 (T) ldrh r0,[r5,20h] +0801135A (T) strh r0,[r1] +0801135C (T) ldr r0,=2010200h +0801135E (T) str r0,[r4] +08011360 (T) ldr r0,=5000200h +08011362 (T) str r0,[r4,4h] +08011364 (T) mov r0,r9 +08011366 (T) str r0,[r4,8h] +08011368 (T) ldr r0,[r4,8h] +0801136A (T) ldr r0,=2010C00h +0801136C (T) str r0,[r4] +0801136E (T) ldr r0,=6000800h +08011370 (T) str r0,[r4,4h] +08011372 (T) mov r1,r8 +08011374 (T) str r1,[r4,8h] +08011376 (T) ldr r0,[r4,8h] +08011378 (T) ldrh r0,[r6] +0801137A (T) add sp,4h +0801137C (T) pop r3,r4 +0801137E (T) mov r8,r3 +08011380 (T) mov r9,r4 +08011382 (T) pop r4-r7 +08011384 (T) pop r0 +08011386 (T) bx r0 diff --git a/notes/m2-title-long.txt b/notes/m2-title-long.txt new file mode 100644 index 0000000..cd66052 --- /dev/null +++ b/notes/m2-title-long.txt @@ -0,0 +1,1169 @@ +// Full title screen +// ---- +// Jump table: +// $80113F5 +// $80115A9 +// $8011499 +// $8011495 + +// 0x2E0 struct: (2028028) +// Offset Length Description Value for long title screen +// ------------------------------------------------------------------------------------------------------------ +// 0 4 Palette A pointer (WRAM) -- background? x3 0x2011400 +// 4 4 Palette B pointer (WRAM) -- text or orb? x5 0x2011600 +// 8 4 Palette C pointer (WRAM) -- copyright or bg? x4 0x2011800 +// C 4 Palette D pointer (WRAM) -- text or orb? x4 0x2011A00 +// 10 4 Palette E pointer (WRAM) -- buffer? 0x2011C00 + +// Sequences: +// ##: [dur] [dur] +// M2GBA EBGBA +// ----- ----- +// 00: start-up (play sound, etc.) +// 01: [ 48] earth fade-in [] B fade-in +// 02: [ 45] pause [] pause +// 03: [104] text flies in [] text flies in +// 04: [ 1] pause [] pause +// 05: [] flash text [] flash text +// 06: [] pause [] pause +// 07: [] text moves up [] do nothing +// 08: [] pause [] pause +// 09: [] background fade-in [] copyright fade-in +// 0A: [] pause [] pause +// 0B: [] flash all [] glow +// 0C: [] pause [] pause +// 0D: [] long pause [] do nothing +// 0E: [] flash all [] do nothing +// 0F: [] pause [] do nothing +// 10: [] long pause [] do nothing +// 11: [] quick fade-out all [] quick fade-out all + +//============================================================================= +// $80113F5: (Start) +080113F4 (T) push r4,r5,r14 +080113F6 (T) add sp,-4h + +// malloc 0x2E0 bytes +080113F8 (T) movs r0,0B8h +080113FA (T) lsls r0,r0,2h +080113FC (T) bl 8005B9Ch +08011400 (T) adds r4,r0,0 +08011402 (T) ldr r0,=3000370h +08011404 (T) ldr r0,[r0] +08011406 (T) str r4,[r0,14h] + +// Initialize struct +// Five palette buffers +08011408 (T) ldr r0,=2011400h +0801140A (T) str r0,[r4] +0801140C (T) ldr r0,=2011600h +0801140E (T) str r0,[r4,4h] +08011410 (T) ldr r1,=2011800h +08011412 (T) str r1,[r4,8h] +08011414 (T) ldr r0,=2011A00h +08011416 (T) str r0,[r4,0Ch] +08011418 (T) ldr r0,=2011C00h +0801141A (T) str r0,[r4,10h] + +// Load first four palettes into buffers +0801141C (T) ldr r0,=8712754h +0801141E (T) movs r5,80h +08011420 (T) lsls r5,r5,2h +08011422 (T) adds r2,r5,0 +08011424 (T) bl 8005D34h +08011428 (T) ldr r0,=8712868h +0801142A (T) ldr r1,[r4,0Ch] +0801142C (T) adds r2,r5,0 +0801142E (T) bl 8005D34h +08011432 (T) ldr r0,=87126CCh +08011434 (T) ldr r1,[r4] +08011436 (T) adds r2,r5,0 +08011438 (T) bl 8005D34h +0801143C (T) ldr r0,=87127E8h +0801143E (T) ldr r1,[r4,4h] +08011440 (T) adds r2,r5,0 +08011442 (T) bl 8005D34h + +// Zero out fifth buffer +08011446 (T) movs r0,0h +08011448 (T) str r0,[sp] +0801144A (T) ldr r1,=40000D4h +0801144C (T) mov r0,r13 +0801144E (T) str r0,[r1] +08011450 (T) ldr r0,[r4,10h] +08011452 (T) str r0,[r1,4h] +08011454 (T) ldr r0,=85000080h +08011456 (T) str r0,[r1,8h] +08011458 (T) ldr r0,[r1,8h] + +// Return 0 +0801145A (T) movs r0,0h +0801145C (T) add sp,4h +0801145E (T) pop r4,r5 +08011460 (T) pop r1 +08011462 (T) bx r1 + +//============================================================================= +// $80115A9: (Setup) + +// Load a bunch of constants to the stack ([80FCB74..80FCBFF] to [sp..sp+8B]) +080115A8 (T) push r4-r7,r14 +080115AA (T) mov r7,r10 +080115AC (T) mov r6,r9 +080115AE (T) mov r5,r8 +080115B0 (T) push r5-r7 +080115B2 (T) add sp,-94h // damn... +080115B4 (T) mov r1,r13 +080115B6 (T) ldr r0,=80FCB74h +080115B8 (T) ldmia [r0]!,r2-r4 +080115BA (T) stmia [r1]!,r2-r4 +080115BC (T) add r7,sp,0Ch +080115BE (T) mov r8,r7 +080115C0 (T) mov r1,r8 +080115C2 (T) ldr r0,=80FCB80h +080115C4 (T) ldmia [r0]!,r2-r4 +080115C6 (T) stmia [r1]!,r2-r4 +080115C8 (T) ldmia [r0]!,r2,r3,r7 +080115CA (T) stmia [r1]!,r2,r3,r7 +080115CC (T) ldmia [r0]!,r4,r7 +080115CE (T) stmia [r1]!,r4,r7 +080115D0 (T) add r6,sp,2Ch +080115D2 (T) mov r1,r6 +080115D4 (T) ldr r0,=80FCBA0h +080115D6 (T) ldmia [r0]!,r2-r4 +080115D8 (T) stmia [r1]!,r2-r4 +080115DA (T) ldmia [r0]!,r2,r3,r7 +080115DC (T) stmia [r1]!,r2,r3,r7 +080115DE (T) ldmia [r0]!,r4,r7 +080115E0 (T) stmia [r1]!,r4,r7 +080115E2 (T) add r5,sp,4Ch +080115E4 (T) mov r1,r5 +080115E6 (T) ldr r0,=80FCBC0h +080115E8 (T) ldmia [r0]!,r2-r4 +080115EA (T) stmia [r1]!,r2-r4 +080115EC (T) ldmia [r0]!,r2,r3,r7 +080115EE (T) stmia [r1]!,r2,r3,r7 +080115F0 (T) ldmia [r0]!,r4,r7 +080115F2 (T) stmia [r1]!,r4,r7 +080115F4 (T) add r4,sp,6Ch +080115F6 (T) mov r1,r4 +080115F8 (T) ldr r0,=80FCBE0h +080115FA (T) ldmia [r0]!,r2,r3,r7 +080115FC (T) stmia [r1]!,r2,r3,r7 +080115FE (T) ldmia [r0]!,r2,r3,r7 +08011600 (T) stmia [r1]!,r2,r3,r7 +08011602 (T) ldmia [r0]!,r2,r3 +08011604 (T) stmia [r1]!,r2,r3 + +08011606 (T) ldr r3,=3000370h +08011608 (T) ldr r7,[r3] +0801160A (T) mov r12,r7 // r7 = r12 = 2028008 +0801160C (T) mov r0,r12 +0801160E (T) ldr r0,[r0,14h] +08011610 (T) mov r9,r0 +08011612 (T) mov r7,r9 // r7 = r9 = 2028028 + +08011614 (T) add r7,14h +08011616 (T) ldr r0,=3002570h +08011618 (T) ldr r1,[r0] // seems to always be 2? +0801161A (T) ldr r0,=3002A30h +0801161C (T) ldr r2,[r0] +0801161E (T) lsl r0,r1,1h +08011620 (T) add r0,r0,r1 +08011622 (T) lsl r0,r0,4h +08011624 (T) add r0,r0,r2 +08011626 (T) ldrb r1,[r0,8h] // appears to be a has-this-been-run-yet flag +08011628 (T) cmp r1,0h +0801162A (T) beq 801162Eh +0801162C (T) b 8011730h + +// If this is the first run: + // Set sequence index to 0 + 0801162E (T) mov r0,r9 // 2028028 + 08011630 (T) add r0,84h + 08011632 (T) str r1,[r0] + + 08011634 (T) mov r1,0A2h + 08011636 (T) lsl r1,r1,2h + 08011638 (T) add r1,r9 + 0801163A (T) mov r0,88h + 0801163C (T) lsl r0,r0,4h + 0801163E (T) str r0,[r1] // [20282B0] = 0x00000880 + + 08011640 (T) mov r2,0B2h + 08011642 (T) lsl r2,r2,2h + 08011644 (T) add r2,r9 + + 08011646 (T) ldr r1,[sp,54h] // r1 = 0x68 (X coordinate of the R) + 08011648 (T) mov r0,0F0h + 0801164A (T) sub r0,r0,r1 + 0801164C (T) str r0,[r2] // [20282F0] = 0xF0 - 0x68 = 0x88 + + 0801164E (T) mov r1,0AEh + 08011650 (T) lsl r1,r1,2h + 08011652 (T) add r1,r9 + 08011654 (T) mov r0,0C0h + 08011656 (T) lsl r0,r0,0Ah + 08011658 (T) str r0,[r1] // [20282E0] = 0x30000 + + 0801165A (T) mov r6,1h + 0801165C (T) mov r7,0B2h + 0801165E (T) lsl r7,r7,2h + 08011660 (T) add r7,r9 // r7 = 20282F0 + 08011662 (T) mov r5,0B3h + 08011664 (T) lsl r5,r5,2h + 08011666 (T) add r5,r9 // r5 = 20282F4 + + // Looks like sp+58 and sp+78 are important variables; store their + // locations to sp+8C and sp+90. Let's call them X and Y respectively. + // sp+58: pointer to end X coordinate of T + // sp+78: pointer to start X coordinate of T + 08011668 (T) mov r1,r13 + 0801166A (T) add r1,58h + 0801166C (T) str r1,[sp,8Ch] + 0801166E (T) mov r2,r13 + 08011670 (T) add r2,78h + 08011672 (T) str r2,[sp,90h] + + 08011674 (T) mov r3,0A2h + 08011676 (T) lsl r3,r3,2h + 08011678 (T) add r3,r9 + 0801167A (T) mov r10,r3 // r3 = r10 = 20282B0 + 0801167C (T) mov r4,0A3h + 0801167E (T) lsl r4,r4,2h + 08011680 (T) add r4,r9 + 08011682 (T) mov r8,r4 // r4 = r8 = 20282B4 + + // So: + // r3 = 20282B0 + // r4 = 20282B4 + // r5 = 20282F4 + // r6 = loop index + // r7 = 20282F0 + // r8 = 20282B4 + // r9 = 2028028 + // r10 = 20282B0 + + // For r6 = 1 to 3: + // Load Y into r1 and increment Y + 08011684 (T) lsl r4,r6,2h + 08011686 (T) ldr r0,[sp,90h] + 08011688 (T) ldmia [r0]!,r1 + 0801168A (T) str r0,[sp,90h] + + // Load X into r0 and increment X + 0801168C (T) ldr r2,[sp,8Ch] + 0801168E (T) ldmia [r2]!,r0 + 08011690 (T) str r2,[sp,8Ch] + + 08011692 (T) sub r1,r1,r0 + 08011694 (T) str r1,[r5] // delta between start and end X coordinates of the T + 08011696 (T) mov r0,0AEh + 08011698 (T) lsl r0,r0,2h + 0801169A (T) add r0,r9 + 0801169C (T) add r4,r0,r4 + 0801169E (T) ldr r0,[r0] + 080116A0 (T) mul r0,r1 + 080116A2 (T) ldr r1,[r7] + 080116A4 (T) bl m2_div + 080116A8 (T) str r0,[r4] // r0 = increment per frame? + 080116AA (T) ldmia [r5]!,r1 // r1 = delta + 080116AC (T) mov r3,r10 + 080116AE (T) ldr r0,[r3] + 080116B0 (T) mul r0,r1 + 080116B2 (T) ldr r1,[r7] + 080116B4 (T) bl m2_div + 080116B8 (T) mov r4,r8 + 080116BA (T) add r4,4h + 080116BC (T) mov r8,r4 + 080116BE (T) sub r4,4h + 080116C0 (T) stmia [r4]!,r0 + 080116C2 (T) add r6,1h + 080116C4 (T) cmp r6,3h + 080116C6 (T) ble 8011684h + + + 080116C8 (T) mov r6,0h + 080116CA (T) mov r10,r6 + 080116CC (T) add r7,sp,2Ch + 080116CE (T) mov r8,r7 + 080116D0 (T) add r7,sp,6Ch + 080116D2 (T) mov r5,r9 + 080116D4 (T) add r5,0A8h + 080116D6 (T) mov r4,r9 + 080116D8 (T) add r4,88h + 080116DA (T) mov r0,r4 + 080116DC (T) ldr r1,=8712FB0h + 080116DE (T) bl 80088E0h + 080116E2 (T) strb r6,[r5] + 080116E4 (T) mov r0,r4 + 080116E6 (T) bl 8008A28h + 080116EA (T) mov r0,r10 + 080116EC (T) strb r0,[r5,0Eh] + 080116EE (T) ldmia [r7]!,r0 + 080116F0 (T) str r0,[r5,4h] + 080116F2 (T) mov r1,r8 + 080116F4 (T) add r1,4h + 080116F6 (T) mov r8,r1 + 080116F8 (T) sub r1,4h + 080116FA (T) ldmia [r1]!,r0 + 080116FC (T) str r0,[r5,8h] + 080116FE (T) add r5,40h + 08011700 (T) add r4,40h + 08011702 (T) add r6,1h + 08011704 (T) cmp r6,7h + 08011706 (T) ble 80116DAh + 08011708 (T) b 8011BE4h + 0801170A (T) lsl r0,r0,0h + 0801170C (T) ldmia [r3]!,r2,r4-r6 + 0801170E (T) lsr r7,r1,20h + 08011710 (T) ldmia [r3]!,r7 + 08011712 (T) lsr r7,r1,20h + 08011714 (T) ldmia [r3]!,r5,r7 + 08011716 (T) lsr r7,r1,20h + 08011718 (T) ldmia [r3]!,r6,r7 + 0801171A (T) lsr r7,r1,20h + 0801171C (T) ldmia [r3]!,r5-r7 + 0801171E (T) lsr r7,r1,20h + 08011720 (T) lsl r0,r6,0Dh + 08011722 (T) lsl r0,r0,0Ch + 08011724 (T) mov r5,70h + 08011726 (T) lsl r0,r0,0Ch + 08011728 (T) cmp r2,30h + 0801172A (T) lsl r0,r0,0Ch + 0801172C (T) cmp r7,0B0h + 0801172E (T) lsr r1,r6,1h + +08011730 (T) ldrb r0,[r0,0Bh] // appears to be an are-we-on-the-last-run flag +08011732 (T) cmp r0,1h +08011734 (T) bne 801173Ch + +// If this is the last run: +08011736 (T) bl 8000C28h // tear-down +0801173A (T) b 8011BE4h + +// Else: check for input +0801173C (T) ldr r0,=3002500h +0801173E (T) ldrh r1,[r0] // pad input +08011740 (T) mov r0,9h +08011742 (T) and r0,r1 +08011744 (T) cmp r0,0h +08011746 (T) beq 8011774h + + // A/Start is pressed + 08011748 (T) mov r0,r9 + 0801174A (T) add r0,84h + 0801174C (T) ldr r0,[r0] + 0801174E (T) cmp r0,0Ah + 08011750 (T) ble 8011764h + + // If we're on the final sequence: + 08011752 (T) ldr r1,=30012D0h + 08011754 (T) ldr r0,=8001825h + 08011756 (T) b 8011B7Ah // store r0 to [r1] and return -1 + 08011758 (T) mov r5,0h + 0801175A (T) lsl r0,r0,0Ch + 0801175C (T) asr r0,r2,0Bh + 0801175E (T) lsl r0,r0,0Ch + 08011760 (T) add r5,r4,r0 + 08011762 (T) lsr r0,r0,20h + + // If we're not on the final sequence: + 08011764 (T) ldr r1,=30012D0h + 08011766 (T) ldr r0,=8010F95h + 08011768 (T) b 8011B7Ah // same + 0801176A (T) lsl r0,r0,0h + 0801176C (T) asr r0,r2,0Bh + 0801176E (T) lsl r0,r0,0Ch + 08011770 (T) lsr r5,r2,1Eh + 08011772 (T) lsr r1,r0,20h + +// Increment frame counter +08011774 (T) mov r2,r12 +08011776 (T) ldr r0,[r2,4h] +08011778 (T) add r0,1h +0801177A (T) str r0,[r2,4h] + +// Check sequence number +0801177C (T) mov r0,r9 +0801177E (T) add r0,84h +08011780 (T) ldr r1,[r0] +08011782 (T) mov r10,r0 +08011784 (T) cmp r1,11h +08011786 (T) bls 801178Ah +08011788 (T) b 8011B8Ch + +// Should always end up here (sequence number only goes up to 11) +// Jump table! +// [00]: 080117E0 +// [01]: 08011802 +// [02]: 0801182A +// [03]: 08011858 +// [04]: 080118FA +// [05]: 080118FE +// [06]: 0801195C +// [07]: 08011972 +// [08]: 080119BA +// [09]: 080119DE +// [0A]: 08011A02 +// [0B]: 08011A1A +// [0C]: 08011A80 +// [0D]: 08011A8A +// [0E]: 08011AAA +// [0F]: 08011B58 +// [10]: 08011B66 +// [11]: 08011B76 +0801178A (T) lsl r0,r1,2h +0801178C (T) ldr r1,=8011798h +0801178E (T) add r0,r0,r1 +08011790 (T) ldr r0,[r0] +08011792 (T) mov r15,r0 +08011794 (T) asr r0,r3,1Eh +08011796 (T) lsr r1,r0,20h +08011798 (T) asr r0,r4,1Fh +0801179A (T) lsr r1,r0,20h +0801179C (T) add r2,r0,r0 +0801179E (T) lsr r1,r0,20h +080117A0 (T) add r2,r5,r0 +080117A2 (T) lsr r1,r0,20h +080117A4 (T) add r0,r3,r1 +080117A6 (T) lsr r1,r0,20h +080117A8 (T) add r2,r7,r3 +080117AA (T) lsr r1,r0,20h +080117AC (T) add r6,r7,r3 +080117AE (T) lsr r1,r0,20h +080117B0 (T) add r4,r3,r5 +080117B2 (T) lsr r1,r0,20h +080117B4 (T) add r2,r6,r5 +080117B6 (T) lsr r1,r0,20h +080117B8 (T) add r2,r7,r6 +080117BA (T) lsr r1,r0,20h +080117BC (T) add r6,r3,r7 +080117BE (T) lsr r1,r0,20h +080117C0 (T) sub r2,r0,r0 +080117C2 (T) lsr r1,r0,20h +080117C4 (T) sub r2,r3,r0 +080117C6 (T) lsr r1,r0,20h +080117C8 (T) sub r0,r0,r2 +080117CA (T) lsr r1,r0,20h +080117CC (T) sub r2,r1,r2 +080117CE (T) lsr r1,r0,20h +080117D0 (T) sub r2,r5,r2 +080117D2 (T) lsr r1,r0,20h +080117D4 (T) sub r0,r3,r5 +080117D6 (T) lsr r1,r0,20h +080117D8 (T) sub r6,r4,r5 +080117DA (T) lsr r1,r0,20h +080117DC (T) sub r6,r6,r5 +080117DE (T) lsr r1,r0,20h + +// -------------------------------------------------------- +// Sequence 00 +080117E0 (T) mov r1,r9 +080117E2 (T) add r1,7Ah +080117E4 (T) mov r2,0h +080117E6 (T) mov r0,0D0h // BLDCNT +080117E8 (T) strh r0,[r1] +080117EA (T) add r1,2h +080117EC (T) mov r0,10h // BLDY +080117EE (T) strh r0,[r1] +080117F0 (T) ldr r0,[r3] +080117F2 (T) str r2,[r0,4h] // reset frame index +080117F4 (T) mov r0,1h +080117F6 (T) mov r3,r10 +080117F8 (T) str r0,[r3] // move to next sequence +080117FA (T) mov r0,0AFh +080117FC (T) bl m2_soundeffect // play title music +08011800 (T) b 8011B8Ch + +// -------------------------------------------------------- +// Sequence 01 +08011802 (T) ldr r3,[r3] +08011804 (T) ldr r0,[r3,4h] +08011806 (T) cmp r0,2h // Every 3 frames, bump the brightness +08011808 (T) bgt 801180Ch +0801180A (T) b 8011B8Ch +0801180C (T) mov r1,r9 +0801180E (T) add r1,7Ch +08011810 (T) ldrh r0,[r1] +08011812 (T) sub r0,1h +08011814 (T) mov r2,0h +08011816 (T) strh r0,[r1] +08011818 (T) str r2,[r3,4h] +0801181A (T) ldrh r0,[r1] +0801181C (T) cmp r0,0h +0801181E (T) beq 8011822h +08011820 (T) b 8011B8Ch +08011822 (T) mov r0,2h +08011824 (T) mov r4,r10 +08011826 (T) str r0,[r4] +08011828 (T) b 8011B8Ch + +// -------------------------------------------------------- +// Sequence 02 +0801182A (T) ldr r3,[r3] +0801182C (T) ldr r0,[r3,4h] +0801182E (T) cmp r0,2Ch +08011830 (T) bgt 8011834h +08011832 (T) b 8011B8Ch +08011834 (T) mov r0,0h +08011836 (T) str r0,[r3,4h] +08011838 (T) mov r1,0A6h +0801183A (T) lsl r1,r1,2h +0801183C (T) add r1,r9 +0801183E (T) mov r2,0h +08011840 (T) mov r6,3h +08011842 (T) ldr r0,[r1,20h] +08011844 (T) str r0,[r1] +08011846 (T) str r2,[r1,10h] +08011848 (T) add r1,4h +0801184A (T) sub r6,1h +0801184C (T) cmp r6,0h +0801184E (T) bge 8011842h +08011850 (T) mov r0,3h +08011852 (T) mov r7,r10 +08011854 (T) str r0,[r7] +08011856 (T) b 8011B8Ch + +// -------------------------------------------------------- +// Sequence 03 +08011858 (T) mov r6,0h +0801185A (T) mov r7,r13 +0801185C (T) sub r7,4h +0801185E (T) mov r8,r9 +08011860 (T) mov r3,0A2h +08011862 (T) lsl r3,r3,2h +08011864 (T) add r3,r9 +08011866 (T) mov r5,r9 +08011868 (T) add r5,88h +0801186A (T) ldr r0,[r3,10h] +0801186C (T) ldr r1,[r3] +0801186E (T) sub r0,r0,r1 +08011870 (T) str r0,[r3,10h] +08011872 (T) ldr r1,=2FFFh +08011874 (T) cmp r0,r1 +08011876 (T) bgt 801187Eh +08011878 (T) mov r0,0C0h +0801187A (T) lsl r0,r0,6h +0801187C (T) str r0,[r3,10h] +0801187E (T) ldr r1,[r3,20h] +08011880 (T) ldr r0,[r3,10h] +08011882 (T) add r1,r1,r0 +08011884 (T) asr r2,r1,10h +08011886 (T) ldr r0,=0FFFFh +08011888 (T) and r1,r0 +0801188A (T) str r1,[r3,20h] +0801188C (T) mov r4,84h +0801188E (T) lsl r4,r4,1h +08011890 (T) add r4,r8 +08011892 (T) ldr r0,[r4,24h] +08011894 (T) sub r1,r0,r2 +08011896 (T) str r1,[r4,24h] +08011898 (T) cmp r6,0h +0801189A (T) bne 80118ACh +0801189C (T) ldr r0,[r5,24h] +0801189E (T) add r0,r0,r2 +080118A0 (T) str r0,[r5,24h] +080118A2 (T) b 80118C0h +080118A4 (T) cmp r7,0FFh +080118A6 (T) lsl r0,r0,0h +080118A8 (T) bl lr+0FFEh +080118AA (T) lsl r0,r0,0h +080118AC (T) mov r0,84h +080118AE (T) lsl r0,r0,1h +080118B0 (T) add r0,r9 +080118B2 (T) ldr r2,[r0,24h] +080118B4 (T) sub r0,r1,r2 +080118B6 (T) ldr r1,[r7] +080118B8 (T) cmp r0,r1 +080118BA (T) bgt 80118C0h +080118BC (T) add r0,r2,r1 +080118BE (T) str r0,[r4,24h] +080118C0 (T) add r7,4h +080118C2 (T) mov r0,40h +080118C4 (T) add r8,r0 +080118C6 (T) add r3,4h +080118C8 (T) add r6,1h +080118CA (T) cmp r6,3h +080118CC (T) ble 801186Ah +080118CE (T) add r0,0C8h +080118D0 (T) add r0,r9 +080118D2 (T) ldr r1,[r0,24h] +080118D4 (T) ldr r0,[sp,54h] +080118D6 (T) cmp r1,r0 +080118D8 (T) blt 80118DCh +080118DA (T) b 8011B8Ch +080118DC (T) add r2,sp,2Ch +080118DE (T) mov r1,r9 +080118E0 (T) add r1,0ACh +080118E2 (T) add r5,sp,4Ch +080118E4 (T) mov r6,7h +080118E6 (T) ldmia [r5]!,r0 +080118E8 (T) str r0,[r1] +080118EA (T) ldmia [r2]!,r0 +080118EC (T) str r0,[r1,4h] +080118EE (T) add r1,40h +080118F0 (T) sub r6,1h +080118F2 (T) cmp r6,0h +080118F4 (T) bge 80118E6h +080118F6 (T) mov r0,4h +080118F8 (T) b 80119D8h + +// -------------------------------------------------------- +// Sequence 04 +080118FA (T) mov r0,5h +080118FC (T) b 8011B60h + +// -------------------------------------------------------- +// Sequence 05 +080118FE (T) ldr r3,[r3] +08011900 (T) ldr r0,[r3,4h] +08011902 (T) cmp r0,3h +08011904 (T) bgt 8011908h +08011906 (T) b 8011B8Ch +08011908 (T) mov r0,0h +0801190A (T) str r0,[r3,4h] +0801190C (T) mov r2,r9 +0801190E (T) add r2,7Eh +08011910 (T) ldrh r0,[r2] +08011912 (T) add r1,r0,1 +08011914 (T) strh r1,[r2] +08011916 (T) lsl r0,r1,10h +08011918 (T) asr r0,r0,10h +0801191A (T) cmp r0,7h +0801191C (T) ble 801193Ch +0801191E (T) mov r0,6h +08011920 (T) mov r3,r10 +08011922 (T) str r0,[r3] +08011924 (T) mov r4,r9 +08011926 (T) ldr r0,[r4,4h] +08011928 (T) str r0,[r7,8h] +0801192A (T) ldr r0,=5000200h +0801192C (T) str r0,[r7,0Ch] +0801192E (T) mov r0,20h +08011930 (T) str r0,[r7,10h] +08011932 (T) mov r0,1h +08011934 (T) str r0,[r7,4h] +08011936 (T) b 8011B4Ch +08011938 (T) lsl r0,r0,8h +0801193A (T) lsl r0,r0,14h +0801193C (T) mov r0,3h +0801193E (T) and r1,r0 +08011940 (T) lsl r1,r1,5h +08011942 (T) mov r2,r9 +08011944 (T) ldr r0,[r2,0Ch] +08011946 (T) add r0,r0,r1 +08011948 (T) str r0,[r7,8h] +0801194A (T) ldr r0,=5000200h +0801194C (T) str r0,[r7,0Ch] +0801194E (T) mov r0,20h +08011950 (T) str r0,[r7,10h] +08011952 (T) mov r0,1h +08011954 (T) str r0,[r7,4h] +08011956 (T) b 8011B4Ch +08011958 (T) lsl r0,r0,8h +0801195A (T) lsl r0,r0,14h + +// -------------------------------------------------------- +// Sequence 06 +0801195C (T) ldr r3,[r3] +0801195E (T) ldr r0,[r3,4h] +08011960 (T) cmp r0,2Ch +08011962 (T) bgt 8011966h +08011964 (T) b 8011B8Ch +08011966 (T) mov r0,7h +08011968 (T) mov r4,r10 +0801196A (T) str r0,[r4] +0801196C (T) mov r0,0h +0801196E (T) str r0,[r3,4h] +08011970 (T) b 8011B8Ch + +// -------------------------------------------------------- +// Sequence 07 +08011972 (T) ldr r0,[r3] +08011974 (T) ldr r0,[r0,4h] +08011976 (T) cmp r0,1h +08011978 (T) bgt 801197Ch +0801197A (T) b 8011B8Ch +0801197C (T) mov r2,r9 +0801197E (T) add r2,88h +08011980 (T) mov r1,r9 +08011982 (T) add r1,0B0h +08011984 (T) mov r6,7h +08011986 (T) ldr r0,[r1] +08011988 (T) sub r0,1h +0801198A (T) str r0,[r1] +0801198C (T) add r1,40h +0801198E (T) sub r6,1h +08011990 (T) cmp r6,0h +08011992 (T) bge 8011986h +08011994 (T) ldr r1,[r2,28h] +08011996 (T) ldr r0,[sp,0Ch] +08011998 (T) cmp r1,r0 +0801199A (T) ble 801199Eh +0801199C (T) b 8011B8Ch +0801199E (T) mov r2,r8 +080119A0 (T) mov r1,r9 +080119A2 (T) add r1,88h +080119A4 (T) mov r6,7h +080119A6 (T) ldmia [r2]!,r0 +080119A8 (T) str r0,[r1,28h] +080119AA (T) add r1,40h +080119AC (T) sub r6,1h +080119AE (T) cmp r6,0h +080119B0 (T) bge 80119A6h +080119B2 (T) mov r6,8h +080119B4 (T) mov r7,r10 +080119B6 (T) str r6,[r7] +080119B8 (T) b 8011B8Ch + +// -------------------------------------------------------- +// Sequence 08 + +// Clear BLDCNT +080119BA (T) mov r1,r9 +080119BC (T) add r1,7Ah +080119BE (T) mov r2,0h +080119C0 (T) mov r0,0C3h +080119C2 (T) strh r0,[r1] + +// Enable BG0/OBJ +080119C4 (T) sub r1,2h +080119C6 (T) mov r0,88h +080119C8 (T) lsl r0,r0,5h +080119CA (T) strh r0,[r1] + +080119CC (T) add r1,4h +080119CE (T) mov r0,10h +080119D0 (T) strh r0,[r1] +080119D2 (T) ldr r0,[r3] +080119D4 (T) str r2,[r0,4h] +080119D6 (T) mov r0,9h +080119D8 (T) mov r1,r10 +080119DA (T) str r0,[r1] +080119DC (T) b 8011B8Ch + +// -------------------------------------------------------- +// Sequence 09 +080119DE (T) ldr r3,[r3] +080119E0 (T) ldr r0,[r3,4h] +080119E2 (T) cmp r0,9h +080119E4 (T) bgt 80119E8h +080119E6 (T) b 8011B8Ch +080119E8 (T) mov r1,r9 +080119EA (T) add r1,7Ch +080119EC (T) ldrh r0,[r1] +080119EE (T) sub r0,1h +080119F0 (T) mov r2,0h +080119F2 (T) strh r0,[r1] +080119F4 (T) str r2,[r3,4h] +080119F6 (T) ldrh r0,[r1] +080119F8 (T) cmp r0,0h +080119FA (T) beq 80119FEh +080119FC (T) b 8011B8Ch +080119FE (T) mov r0,0Ah +08011A00 (T) b 8011B60h + +// -------------------------------------------------------- +// Sequence 0A +08011A02 (T) mov r0,0Bh +08011A04 (T) mov r4,r10 +08011A06 (T) str r0,[r4] +08011A08 (T) mov r0,r9 +08011A0A (T) add r0,7Eh +08011A0C (T) mov r1,0h +08011A0E (T) strh r1,[r0] +08011A10 (T) add r0,2h +08011A12 (T) strh r1,[r0] +08011A14 (T) ldr r0,[r3] +08011A16 (T) str r1,[r0,4h] +08011A18 (T) b 8011B8Ch + +// -------------------------------------------------------- +// Sequence 0B +08011A1A (T) ldr r3,[r3] +08011A1C (T) ldr r0,[r3,4h] +08011A1E (T) cmp r0,3h +08011A20 (T) bgt 8011A24h +08011A22 (T) b 8011B8Ch +08011A24 (T) mov r0,0h +08011A26 (T) str r0,[r3,4h] +08011A28 (T) mov r0,7Eh +08011A2A (T) add r0,r9 +08011A2C (T) mov r8,r0 +08011A2E (T) ldrh r0,[r0] +08011A30 (T) add r0,1h +08011A32 (T) mov r1,r8 +08011A34 (T) strh r0,[r1] +08011A36 (T) mov r1,r9 +08011A38 (T) add r1,80h +08011A3A (T) ldrh r0,[r1] +08011A3C (T) add r2,r0,1 +08011A3E (T) strh r2,[r1] +08011A40 (T) mov r3,r8 +08011A42 (T) mov r4,0h +08011A44 (T) ldsh r0,[r3,r4] +08011A46 (T) cmp r0,7h +08011A48 (T) ble 8011B10h +08011A4A (T) mov r0,0Ch +08011A4C (T) mov r1,r10 +08011A4E (T) str r0,[r1] +08011A50 (T) mov r2,r9 +08011A52 (T) ldr r0,[r2] +08011A54 (T) str r0,[r7,8h] +08011A56 (T) mov r0,0A0h +08011A58 (T) lsl r0,r0,13h +08011A5A (T) str r0,[r7,0Ch] +08011A5C (T) mov r5,20h +08011A5E (T) str r5,[r7,10h] +08011A60 (T) mov r4,1h +08011A62 (T) str r4,[r7,4h] +08011A64 (T) mov r0,r7 +08011A66 (T) bl 8005D5Ch +08011A6A (T) add r7,14h +08011A6C (T) mov r3,r9 +08011A6E (T) ldr r0,[r3,4h] +08011A70 (T) str r0,[r7,8h] +08011A72 (T) ldr r0,=5000200h +08011A74 (T) str r0,[r7,0Ch] +08011A76 (T) str r5,[r7,10h] +08011A78 (T) str r4,[r7,4h] +08011A7A (T) b 8011B4Ch +08011A7C (T) lsl r0,r0,8h +08011A7E (T) lsl r0,r0,14h + +// -------------------------------------------------------- +// Sequence 0C +08011A80 (T) ldr r0,[r3] +08011A82 (T) mov r1,0h +08011A84 (T) str r1,[r0,4h] +08011A86 (T) mov r0,0Dh +08011A88 (T) b 8011B60h + +// -------------------------------------------------------- +// Sequence 0D +08011A8A (T) ldr r3,[r3] +08011A8C (T) ldr r0,[r3,4h] +08011A8E (T) cmp r0,0EFh +08011A90 (T) bgt 8011A94h +08011A92 (T) b 8011B8Ch +08011A94 (T) mov r0,0Eh +08011A96 (T) mov r4,r10 +08011A98 (T) str r0,[r4] +08011A9A (T) mov r1,r9 +08011A9C (T) add r1,7Eh +08011A9E (T) mov r0,0h +08011AA0 (T) strh r0,[r1] +08011AA2 (T) add r1,2h +08011AA4 (T) strh r0,[r1] +08011AA6 (T) str r0,[r3,4h] +08011AA8 (T) b 8011B8Ch + +// -------------------------------------------------------- +// Sequence 0E +08011AAA (T) ldr r3,[r3] +08011AAC (T) ldr r0,[r3,4h] +08011AAE (T) cmp r0,3h +08011AB0 (T) ble 8011B8Ch +08011AB2 (T) mov r0,0h +08011AB4 (T) str r0,[r3,4h] +08011AB6 (T) mov r0,7Eh +08011AB8 (T) add r0,r9 +08011ABA (T) mov r8,r0 +08011ABC (T) ldrh r0,[r0] +08011ABE (T) add r0,1h +08011AC0 (T) mov r1,r8 +08011AC2 (T) strh r0,[r1] +08011AC4 (T) mov r1,r9 +08011AC6 (T) add r1,80h +08011AC8 (T) ldrh r0,[r1] +08011ACA (T) add r2,r0,1 +08011ACC (T) strh r2,[r1] +08011ACE (T) mov r3,r8 +08011AD0 (T) mov r4,0h +08011AD2 (T) ldsh r0,[r3,r4] +08011AD4 (T) cmp r0,7h +08011AD6 (T) ble 8011B10h +08011AD8 (T) mov r0,0Fh +08011ADA (T) mov r1,r10 +08011ADC (T) str r0,[r1] +08011ADE (T) mov r2,r9 +08011AE0 (T) ldr r0,[r2] +08011AE2 (T) str r0,[r7,8h] +08011AE4 (T) mov r0,0A0h +08011AE6 (T) lsl r0,r0,13h +08011AE8 (T) str r0,[r7,0Ch] +08011AEA (T) mov r5,20h +08011AEC (T) str r5,[r7,10h] +08011AEE (T) mov r4,1h +08011AF0 (T) str r4,[r7,4h] +08011AF2 (T) mov r0,r7 +08011AF4 (T) bl 8005D5Ch +08011AF8 (T) add r7,14h +08011AFA (T) mov r3,r9 +08011AFC (T) ldr r0,[r3,4h] +08011AFE (T) str r0,[r7,8h] +08011B00 (T) ldr r0,=5000200h +08011B02 (T) str r0,[r7,0Ch] +08011B04 (T) str r5,[r7,10h] +08011B06 (T) str r4,[r7,4h] +08011B08 (T) b 8011B4Ch +08011B0A (T) lsl r0,r0,0h +08011B0C (T) lsl r0,r0,8h +08011B0E (T) lsl r0,r0,14h +08011B10 (T) mov r4,3h +08011B12 (T) and r2,r4 +08011B14 (T) lsl r1,r2,5h +08011B16 (T) mov r2,r9 +08011B18 (T) ldr r0,[r2,8h] +08011B1A (T) add r0,r0,r1 +08011B1C (T) str r0,[r7,8h] +08011B1E (T) mov r0,0A0h +08011B20 (T) lsl r0,r0,13h +08011B22 (T) str r0,[r7,0Ch] +08011B24 (T) mov r6,20h +08011B26 (T) str r6,[r7,10h] +08011B28 (T) mov r5,1h +08011B2A (T) str r5,[r7,4h] +08011B2C (T) mov r0,r7 +08011B2E (T) bl 8005D5Ch +08011B32 (T) add r7,14h +08011B34 (T) mov r3,r8 +08011B36 (T) ldrh r0,[r3] +08011B38 (T) and r4,r0 +08011B3A (T) lsl r4,r4,5h +08011B3C (T) mov r1,r9 +08011B3E (T) ldr r0,[r1,0Ch] +08011B40 (T) add r0,r0,r4 +08011B42 (T) str r0,[r7,8h] +08011B44 (T) ldr r0,=5000200h +08011B46 (T) str r0,[r7,0Ch] +08011B48 (T) str r6,[r7,10h] +08011B4A (T) str r5,[r7,4h] +08011B4C (T) mov r0,r7 +08011B4E (T) bl 8005D5Ch +08011B52 (T) b 8011B8Ch +08011B54 (T) lsl r0,r0,8h +08011B56 (T) lsl r0,r0,14h + +// -------------------------------------------------------- +// Sequence 0F +08011B58 (T) ldr r0,[r3] +08011B5A (T) mov r1,0h +08011B5C (T) str r1,[r0,4h] +08011B5E (T) mov r0,10h +08011B60 (T) mov r2,r10 +08011B62 (T) str r0,[r2] +08011B64 (T) b 8011B8Ch + +// -------------------------------------------------------- +// Sequence 10 +08011B66 (T) ldr r0,[r3] +08011B68 (T) ldr r0,[r0,4h] +08011B6A (T) cmp r0,63h +08011B6C (T) ble 8011B8Ch +08011B6E (T) mov r0,11h +08011B70 (T) mov r3,r10 +08011B72 (T) str r0,[r3] +08011B74 (T) b 8011B8Ch + +// -------------------------------------------------------- +// Sequence 11 +08011B76 (T) ldr r1,=30012D0h +08011B78 (T) ldr r0,=80B6F81h +08011B7A (T) str r0,[r1] +08011B7C (T) mov r0,1h +08011B7E (T) neg r0,r0 +08011B80 (T) b 8011BE6h + +08011B82 (T) lsl r0,r0,0h +08011B84 (T) asr r0,r2,0Bh +08011B86 (T) lsl r0,r0,0Ch +08011B88 (T) ldr r1,[r0,78h] +08011B8A (T) lsr r3,r1,20h +08011B8C (T) mov r5,r9 +08011B8E (T) add r5,7Ch +08011B90 (T) mov r4,r9 +08011B92 (T) add r4,88h +08011B94 (T) mov r6,5h +08011B96 (T) mov r0,r4 +08011B98 (T) bl 8008BB0h +08011B9C (T) mov r0,r4 +08011B9E (T) mov r1,0h +08011BA0 (T) bl 8008C54h +08011BA4 (T) add r4,40h +08011BA6 (T) sub r6,1h +08011BA8 (T) cmp r6,0h +08011BAA (T) bge 8011B96h +08011BAC (T) mov r4,r10 +08011BAE (T) ldr r0,[r4] +08011BB0 (T) cmp r0,9h +08011BB2 (T) ble 8011BDCh +08011BB4 (T) mov r4,82h +08011BB6 (T) lsl r4,r4,2h +08011BB8 (T) add r4,r9 +08011BBA (T) mov r0,r4 +08011BBC (T) bl 8008BB0h +08011BC0 (T) mov r0,r4 +08011BC2 (T) mov r1,0h +08011BC4 (T) bl 8008C54h +08011BC8 (T) mov r4,92h +08011BCA (T) lsl r4,r4,2h +08011BCC (T) add r4,r9 +08011BCE (T) mov r0,r4 +08011BD0 (T) bl 8008BB0h +08011BD4 (T) mov r0,r4 +08011BD6 (T) mov r1,0h +08011BD8 (T) bl 8008C54h +08011BDC (T) ldr r0,=3000370h +08011BDE (T) ldr r1,[r0] +08011BE0 (T) ldrh r0,[r5] +08011BE2 (T) str r0,[r1,0Ch] +08011BE4 (T) mov r0,0h +08011BE6 (T) add sp,94h +08011BE8 (T) pop r3-r5 +08011BEA (T) mov r8,r3 +08011BEC (T) mov r9,r4 +08011BEE (T) mov r10,r5 +08011BF0 (T) pop r4-r7 +08011BF2 (T) pop r1 +08011BF4 (T) bx r1 + +//============================================================================= +// $8011499: (Commit) +08011498 (T) push r4,r14 +0801149A (T) add sp,-4h +0801149C (T) ldr r0,=3000370h +0801149E (T) ldr r0,[r0] +080114A0 (T) ldr r4,[r0,14h] +080114A2 (T) ldr r0,=3002570h +080114A4 (T) ldr r1,[r0] +080114A6 (T) ldr r0,=3002A30h +080114A8 (T) ldr r2,[r0] +080114AA (T) lsl r0,r1,1h +080114AC (T) add r0,r0,r1 +080114AE (T) lsl r0,r0,4h +080114B0 (T) add r1,r0,r2 +080114B2 (T) ldrb r0,[r1,8h] // already-executed flag +080114B4 (T) cmp r0,0h +080114B6 (T) bne 80114D0h + +// If first run: +080114B8 (T) bl 8000454h // check pad input +080114BC (T) bl 8005D50h // clears some flag +080114C0 (T) b 801156Eh // return +080114C2 (T) lsl r0,r0,0h +080114C4 (T) lsl r0,r6,0Dh +080114C6 (T) lsl r0,r0,0Ch +080114C8 (T) mov r5,70h +080114CA (T) lsl r0,r0,0Ch +080114CC (T) cmp r2,30h +080114CE (T) lsl r0,r0,0Ch + +// If not the first run: +080114D0 (T) ldrb r0,[r1,0Bh] +080114D2 (T) cmp r0,1h +080114D4 (T) bne 80114DCh + +// If last run: +080114D6 (T) bl 8000C28h // tear-down +080114DA (T) b 801156Eh // return + +// If neither first nor last run: +080114DC (T) bl 80F47E4h // wait for vblank + +// Set BG0 and BG1 scrolling offsets +080114E0 (T) ldr r1,=4000010h +080114E2 (T) ldr r0,=3001B20h +080114E4 (T) ldrh r0,[r0] +080114E6 (T) strh r0,[r1] // BG0OFSa +080114E8 (T) add r1,2h +080114EA (T) ldr r0,=30012DCh +080114EC (T) ldrh r0,[r0] +080114EE (T) strh r0,[r1] // BG0OFSb +080114F0 (T) add r1,2h +080114F2 (T) ldr r0,=3001D30h +080114F4 (T) ldrh r0,[r0] +080114F6 (T) strh r0,[r1] // BG1OFSa +080114F8 (T) add r1,2h +080114FA (T) ldr r0,=30012E8h +080114FC (T) ldrh r0,[r0] +080114FE (T) strh r0,[r1] // BG1OFSb + +08011500 (T) mov r0,r4 +08011502 (T) add r0,84h // r0 = 0x20280AC +08011504 (T) ldr r0,[r0] // sequence number +08011506 (T) cmp r0,1h +08011508 (T) blt 8011536h +0801150A (T) cmp r0,2h +0801150C (T) ble 8011522h +0801150E (T) cmp r0,0Ah +08011510 (T) bgt 8011536h +08011512 (T) cmp r0,9h +08011514 (T) blt 8011536h + +// If on sequence 9-A: + // Copy DISPCNT + 08011516 (T) mov r1,80h + 08011518 (T) lsl r1,r1,13h // r1 = 0x4000000 (DISPCNT) + 0801151A (T) mov r0,r4 + 0801151C (T) add r0,78h // r0 = 0x20280A0 + 0801151E (T) ldrh r0,[r0] + 08011520 (T) strh r0,[r1] + +// If on sequence 1-2 or 9-A: + // Copy BLDCNT and BLDY + 08011522 (T) ldr r1,=4000050h // BLDCNT (special effects) + 08011524 (T) mov r0,r4 + 08011526 (T) add r0,7Ah // r0 = 0x20280A2 + 08011528 (T) ldrh r0,[r0] + 0801152A (T) strh r0,[r1] + 0801152C (T) add r1,4h // BLDY (brightness amount) + 0801152E (T) mov r0,r4 + 08011530 (T) add r0,7Ch // r0 = 0x20280A4 + 08011532 (T) ldrh r0,[r0] + 08011534 (T) strh r0,[r1] + +// For all sequences: + // Copy OAM data + 08011536 (T) ldr r1,=40000D4h + 08011538 (T) ldr r2,=30033A0h // OAM buffer + 0801153A (T) str r2,[r1] + 0801153C (T) mov r0,0E0h + 0801153E (T) lsl r0,r0,13h // r0 = 0x7000000 + 08011540 (T) str r0,[r1,4h] + 08011542 (T) ldr r0,=84000100h + 08011544 (T) str r0,[r1,8h] + 08011546 (T) ldr r0,[r1,8h] + + // Blank out OAM data + 08011548 (T) mov r0,0A0h + 0801154A (T) str r0,[sp] + 0801154C (T) mov r0,r13 + 0801154E (T) str r0,[r1] + 08011550 (T) str r2,[r1,4h] + 08011552 (T) ldr r0,=85000100h + 08011554 (T) str r0,[r1,8h] + 08011556 (T) ldr r0,[r1,8h] + + // ? + 08011558 (T) ldr r0,=3003390h + 0801155A (T) mov r1,0h + 0801155C (T) str r1,[r0] + 0801155E (T) ldr r0,=3003394h + 08011560 (T) str r1,[r0] + + 08011562 (T) bl 8005D6Ch // perform DMAs + 08011566 (T) bl 800E5E4h // something with input + 0801156A (T) bl 8000454h // something else with input + +0801156E (T) mov r0,0h +08011570 (T) add sp,4h +08011572 (T) pop r4 +08011574 (T) pop r1 +08011576 (T) bx r1 + +//============================================================================= +// $8011495: (End) +08011494 (T) movs r0,0h +08011496 (T) bx r14 diff --git a/notes/m2-title-sprites.txt b/notes/m2-title-sprites.txt new file mode 100644 index 0000000..adbc837 --- /dev/null +++ b/notes/m2-title-sprites.txt @@ -0,0 +1,27 @@ +712F10 +------ +Title text sprite entry table. First word is OAM source pointer, second word is number of sprites to load. + +68 2E 71 08 02 00 00 00 M (2 sprites) +78 2E 71 08 06 00 00 00 O (6 sprites) +A8 2E 71 08 02 00 00 00 T (2 sprites) +B8 2E 71 08 02 00 00 00 H (2 sprites) +C8 2E 71 08 02 00 00 00 E (2 sprites) +D8 2E 71 08 02 00 00 00 R (2 sprites) +E8 2E 71 08 04 00 00 00 Subtitle (4 sprites) +08 2F 71 08 01 00 00 00 (R) (1 sprites) + +We have nine letters to do but there's only room in the table for eight; will figure out how to expand it later. + +We'll use 32x64 sprites so that we only need one sprite for each letter (the Japanese version uses 2-6 sprites for each letter). + +Final text positions: + +18 -> 0E +38 -> 22 +68 -> 38 +80 -> 4A +A0 -> 5C +B8 -> 8C +98 -> A0 +D2 -> B5 \ No newline at end of file diff --git a/src/c/ext.c b/src/c/ext.c index ee166e8..89b714b 100644 --- a/src/c/ext.c +++ b/src/c/ext.c @@ -25,4 +25,6 @@ void __attribute__((naked)) m2_setupbattlename(short value) {} void __attribute__((naked)) store_pixels_overworld() {} void __attribute__((naked)) m12_dim_palette(short* palette, int total, int dimmingFactor) {} int __attribute__((naked)) m2_jump_to_offset(byte* character) {} -byte* __attribute__((naked)) m2_malloc(int size) {} \ No newline at end of file +byte* __attribute__((naked)) m2_malloc(int size) {} +void __attribute__((naked)) m2_title_teardown() {} +void __attribute__((naked)) vblank() {} diff --git a/src/c/locs.h b/src/c/locs.h index 0a49495..fc44869 100644 --- a/src/c/locs.h +++ b/src/c/locs.h @@ -34,5 +34,6 @@ extern byte *m2_items_strings; extern unsigned short *name_header_tiles; extern byte *character_general_data; extern PSIPrintInfo *psi_print_info; +extern int *title_counter; #endif diff --git a/src/c/title.c b/src/c/title.c new file mode 100644 index 0000000..d4058e2 --- /dev/null +++ b/src/c/title.c @@ -0,0 +1,36 @@ +#include "title.h" + +void title_text_sequence( + TITLE_CONTROL *control, + TITLE_EXTENDED *ext, + TITLE_COORD_TABLE *coords) +{ + int duration = 140; // approximate length of EB's animation, + // from the first frame that H is visible + // until all letters have stopped moving + int frame = control->frame; + + if (frame > duration) + { + control->frame = -1; + ext->sequence++; + return; + } + + for (int i = 0; i < 9; i++) + { + int x_start = coords->x_start[i]; + int x_end = coords->x_end[i]; + int x_delta = x_end - x_start; + int x_new = (m2_div((x_delta * frame) << 12, duration) >> 12) + x_start; + + // X coordinate is only 9 bits signed, so clamp the values to a reasonable range + if (x_new < -250) + x_new = -250; + if (x_new > 250) + x_new = 250; + + ext->sprites[i].x = x_new; + ext->sprites[i].y = coords->y_end[i]; // we're not translating the sprites vertically + } +} diff --git a/src/c/title.h b/src/c/title.h new file mode 100644 index 0000000..fc87f3c --- /dev/null +++ b/src/c/title.h @@ -0,0 +1,48 @@ +#ifndef HEADER_TITLE_INCLUDED +#define HEADER_TITLE_INCLUDED + +#include "types.h" + +typedef struct TITLE_COORD_TABLE { + int unknown_a[3]; + int y_end[9]; + int y_start[9]; + int x_end[9]; + int x_start[9]; +} TITLE_COORD_TABLE; + +typedef struct TITLE_SPRITE { + struct TITLE_SPRITE *prev; + void *anim_table; + void *oam_entry_table; + void *unknown_table; + int unknown_a[5]; + int x; + int y; + int unknown_b[5]; +} TITLE_SPRITE; + +typedef struct TITLE_EXTENDED { + unsigned short *pal_buffer[5]; + byte unknown_a[0x70]; + int sequence; + TITLE_SPRITE sprites[9]; + int unknown[0x16]; +} TITLE_EXTENDED; + +typedef struct TITLE_CONTROL { + int unknown_a; + int frame; + int unknown_b[3]; + TITLE_EXTENDED *ext; + int unknown_c[2]; +} TITLE_CONTROL; + +void title_text_sequence( + TITLE_CONTROL *control, + TITLE_EXTENDED *ext, + TITLE_COORD_TABLE *coords); + +extern int m2_div(int dividend, int divisor); + +#endif diff --git a/src/data/m2-title-background-map.bin b/src/data/m2-title-background-map.bin new file mode 100644 index 0000000000000000000000000000000000000000..4f4cdcd98578121404b768afc68cf95843653c9e GIT binary patch literal 932 zcmZY8XK+;o5XJG|h8yxiULdppA%RN?O~r;?xM0Bsh+R=3*n2Nn^Arn;y^9TF@7QA3 zpx7JsuGqUiv0=qz90zBZ^X2TB-4AExzg2QFim^nCm)L*ZQo;235lXZxRu`kC80pAF zsrDMmiZ!z%r(B0rh0?rA9aEiDc2K1=U3Aq=cdAt<<$BOlc~X(|%Bf6h3L|@~&8gEz zX|RK-J?v>OdzaY9zV?&t&jAi}kb_f)$PRUw!)F$Mgxpaa?HI>u6a~jQ-t?+Qxk*lNqLXG6vXjk_o#NCP4cSbmsXN^noaroQ zJEz3C&U3!(f`Y~iUF2f3O3X?waj9%Vn!ikTxhu?0U72QO`R@59u5z_&Tw73jo$ECv zH*lky-0T)^b(=ZnZb6c-FM%iZyL`rDLA=!s0fP{;x&<4K4Aa`Ml(1 zuXvT$yzUKe@|L%~<6YkKz7H(mLm&CrC#g@1qkQIbzVM~5e9bq$^_}lqIroEwe&i=V z`^B#;@|)lNVf3G^SAY52;zBYaq9ocyB1)rul(ixq<hIhDp=6A))M~! DBmnC7 literal 0 HcmV?d00001 diff --git a/src/data/m2-title-background-pal-copyright.c.bin b/src/data/m2-title-background-pal-copyright.c.bin new file mode 100644 index 0000000000000000000000000000000000000000..44959ca992edcff2da4cd3a71377e3bee27b36d1 GIT binary patch literal 70 zcmWe&U}RummPzKBQ@lcl;iUn$rLS$DBf|#IkG{r1p;4UE;%+1fNHQ>dVEq4q5fz^K Oz*xY@Ec1bJ0wVzbKNw2@ literal 0 HcmV?d00001 diff --git a/src/data/m2-title-background-pal-empty.bin b/src/data/m2-title-background-pal-empty.bin new file mode 100644 index 0000000000000000000000000000000000000000..c19fdd7a0f9b5b4b2679068796d9357c1c9b874c GIT binary patch literal 68 dcmWe&U}CUmVEDj@fd3Ip2n$2tAF>JqMgYxu9oql^ literal 0 HcmV?d00001 diff --git a/src/data/m2-title-background-pal-glow.c.bin b/src/data/m2-title-background-pal-glow.c.bin new file mode 100644 index 0000000000000000000000000000000000000000..e3a782ac94ba1ca37d0e0eadd2a65dd027f3d5e3 GIT binary patch literal 124 zcmWe=U}7+4mifR~!04**L3n~}TKfn21+phqK8R0{}T-g6X9s~vC834BPG&2AI literal 0 HcmV?d00001 diff --git a/src/data/m2-title-background.bin b/src/data/m2-title-background.bin new file mode 100644 index 0000000000000000000000000000000000000000..7245ce4247e622a7b6eb7c7e85bd80ad93bdd67f GIT binary patch literal 6301 zcmeHL|9_OloqwK?>@4d+W)nh0dS*7khU%%a#3ca|cJ@g~kQVch7*by<2?E7COWED* z*JO8}T?ko$N+Ni#*gIRIg5m1bEG;IsP@jMpY_%7v_(IP+ji(;fp2zGaAwYn+nZ%UX z{?Pjan91iepZUx@^UTcqJ)dVbP>M>Wl0;>ZRoUtMtuUM}VsH~f(-C6u(A)b}ddqz-^8v~D`H-G0L`D}bbGdPu-Q9%CQabIY{T=;uIm5@%GRbsZ7_XE{rex%> z24BPqj$M-;CrVOtzDhJHg^#(n`71evsaO+%(wEQUlLU|n1E-w5n`N)e-aUO!{%nI5<+8MT zV$9E#j0Jo-LKxa887Ji(-Fi8H8ABNb#nPWd4qiqX>FZN^`O}Mf-AZp$kJ9T=dcAPF zr6@#AQL=QrO&r%UVMCsz8#_ z{zfLB`Z|i!VdX3_O~N^)#|5?m+9x$%E=TkzJ{AxqKGrOXBluWo&fONplW+6~G;e;U z%<|`Q`CFMSc>0P^TmoFQNQ8}aVgP#}FfW0?vb3V-A_VBF1kSWSbugyI46*Gz&G`)m zk%kBXVHMy)-ruM$p^dBHLP;j8wnsFLA)|B@ahPShfI2^yNyY_y7lfeiOU6dPh;hM= z=`geD73m7fcvm{B^!kXUhQNi*BkaLy3K#_{_+pR( z3ZfwEEqOrGBm>$d>K#Cw%kc~RM0d$*N%5W*XqJo*g!mRv06{pS0v#8J)8Yx87>0n_ zH3XRQI1a-GT+dIB#`h^a?vf^lcE}M}jb^drLMk_wnB#;=kM}Ed6{8idR{9Mp_b*K{ z5j?Kakma{)o|v3K=(e9QnXlZOIXManWvsf0z9TCA;N8L2*4Fi{qOyah+hW5olyiz0 zF=*vZ0>-cb1F3w)DL!MV0fNGCghQxx0V$~hhQboaKVDGi7)&0bvinswtkuN(f&3^1 zwIi^!=v`L(pJHePPF$fIDCh!L?vJTI><7c0{c_2z9B+IwyB!0=I;A0L?g04L3^mXn zQ!oT-$?yo3hohgN?r*+fYika!FgMrT!qzgLYT?yFXne1mPhre1vJ;HuiWh}8 zvq@vVfBEN=7HcZZ+5qMJK}jxx04#o5Yv}?cmlQsCp9zf|-RGGj44X6sL=doSdT70Wh1;u4aUyYsB+H0#X z6pNQcLF)YpR_>E0U!elQ3O05%3dTO>Jr=(>L-gY-Yn@SSs&|ifQ}9$@$6h8tIvig7 zhG?ar-gY@ML7EOwIUqiQmxUJr)wp;-M0ozZAhB9}=@v2m&Kh>bE{xFfnt|BWez0gi z>j&zszuHZ2Pb^B=M>(Tes`$T-UhD1$7wj>U^te{Y7Ju>BcTX9AaE<_4Pc`0S`%!b% z?(GwA+I-(DC-Wy5ol2)SbABIHi`Q1gRq!}Z5`YE?yoQZ)wVgc8Z70CbYyxz(!+6nNhCuFZLtu69+6%+og3;{5jO3GDAo+d*sMSM& z4Dm7U)z{$rGZj}C7+rI4Dcg9A_R*dri#O%*7*>UL(2|0KQ-8>0$ z{ml<~f}mhaY}aGE8Ud<{sbIGgVB=e-0sevJi~`B1IT_xZ;6@{WniO4QI5CF}fvfg^ z?W6L@Fa^W<#5y_vj|Ci`(`{`3gyWUtqDsMn>I&@wj~RT?|9(a2E_VEn{z8^A4WFZV zV_PXo+??e6JnNTN-Qa#fRl%}!QRfWb{a4Qdc%^`hp(`?L(7KhaAkb(ytQotek1H>00 zzPd2+g@~_(_?n5YAxM0Iw7d?@TAKX~)|j;vet>xeZWKDdn=Nu!Gt%s6$CR)sLzEUa zXPy?bjPtwKl{rjW27$EnA_C?oAi!Tb!Ja*PynE*G0Du7hPV-V+F^!T zfkF~UzX{b2O1DG99v+YyWmJNfUVsKzf7<}R9XE2Yo6m}n#jneO4PzCd`K8QKbw_1( z9L=2Zm5fdqK_wDVKwVe?AqBK3pjiP8K?MX9U}f|5qVOV(Nx^bnOlj*i&2P~Q?5M1u zAN66bFHIIg2Lc5yCLJkoO_%Y>N>Fg z*(1rlw;X8V=Fi-c3>7|@tlF>NttFXFub@(DzdXr~obyEY5WT5~=x(CBsGiUyH{?99 za~@0+X0}5IDv8j*Y#xL&t%LGTCE`>aw_$z5KfJBk5}|urY>Ad;TcSB= zODqTmY>9y1mhk(|p>*j8re4pyyqtaW@>q7&ygc}hkU0%P*pva^8SNSEq4IB>veoHn zvO1gGR_EPrm(}T#s;oACnVtQ`DyNUpOvJwNQEXY;3S+W?}=% zqlT2)!eT9I=OqE~g&<1Rooyp*Cv<#-Bdq^&J3{{Aq5$R|F zO2@@Kj;@Z@&fducdaXadJEGQ5eMzMvH0r@!i(5>wiS$ZErcYvivIC!!J8C z>EdW9JZSwUt0B10QfYC}l9c@9Yc=EizQI4&a?_72c6^Dn(}iE#h>_w0xva5^YMZ@-zZP4&@KNns=ux? zdVHj4RR2f4F5bA`oKlyv<9&{5NBySO#vfZ;n_h^{XZI86>&jGZ%3W~gh#&1`Oy?y$7Rk9%u*U{Q)?QD?OeHc!#%FonRCSp&px-!u@&c0;9hyKlUX(VtGWBv zd_refH<1k6ADH!x4WE$D93>QZx;Naco@DA73SKLGHokK2Xea+PkFl=I>(rpKx06pj z0fzE?|D>K;{OKeAvH4ppd9=2+t_UsZSVk5<(yGMSwl5w38?&MEMS6XA<+mR}%=IsL zu;bMww=4Ps2gytPEB(D_^5v1;v@n`Cxhs6o$$U_E{M!Nh#=Ds}bNw@;`ndM`tParR z{(Tzb-n-7&;|si<3_iDK+&}OD z>w8$eI_^K}-!v90eKs!clAGMi_q~%kN9Cwm7k{pD0{zi;8k}0<*XSUeEcw)An_5a8 z6OIS|kXkB?XqYaUaCj-5D~!F{lPf12jrNyyVT|#Ahw$9YRxKzWqm@)XtqlhzdN{S@ z#3kmW6rLE1eY*T+A0@oazGA=cmlFr}N&91d8WygW3;Y0y=ceZyj_JGc{|Rw7cI?KE XO*=w2=x~D$H|Q|MfxmtlqLTc7@gIH} literal 0 HcmV?d00001 diff --git a/src/data/m2-title-text-constants.bin b/src/data/m2-title-text-constants.bin new file mode 100644 index 0000000000000000000000000000000000000000..db2000eb8c788b08f409d20d9942c3d8cf181344 GIT binary patch literal 156 zcmb1OU|_HS;s79)r4r@?nxh27AalKdI0lG&fOr8AZw2C0K>Yge|NqYa{{KG!#J>Ok X|9=F;hKvjhkAQdz69a=PGXnzv=M)-2 literal 0 HcmV?d00001 diff --git a/src/data/m2-title-text-oam-entries.bin b/src/data/m2-title-text-oam-entries.bin new file mode 100644 index 0000000000000000000000000000000000000000..c748848618414e30cc9bde1922070dc8f07e1a48 GIT binary patch literal 64 hcmd1ME978gU|=YK(iKp;0ZMm3=?PGJ29#a^r2#$f31I*L literal 0 HcmV?d00001 diff --git a/src/data/m2-title-text-oam.bin b/src/data/m2-title-text-oam.bin new file mode 100644 index 0000000000000000000000000000000000000000..9e59c00a74362a768315e06dabe638c919786336 GIT binary patch literal 168 ncmZQ*U^u`40zjGtN^?MI9w;pUrA45$1eBJ6(hQ6s25kWV808DH literal 0 HcmV?d00001 diff --git a/src/data/m2-title-text-pal-animated.c.bin b/src/data/m2-title-text-pal-animated.c.bin new file mode 100644 index 0000000000000000000000000000000000000000..ba1efba1818fe07dfd90cac76e768c44807d0164 GIT binary patch literal 124 zcmWeQz{p_0!0>@_1LJ+>|Md*t<3a<=UCUh=W;o8Y+-17kkl~Kz9nF7=|78{bOA5#v z$9|6!P(J)YK0rPsG&Ima`Gfrb0C|CU5Cca4pD-W9g^(BKe_;G`QT~JQMf(qo0gM7b NZ68345A!$72LOWcG2H+F literal 0 HcmV?d00001 diff --git a/src/data/m2-title-text-pal-static.c.bin b/src/data/m2-title-text-pal-static.c.bin new file mode 100644 index 0000000000000000000000000000000000000000..44bfd852e21c9b4f390207e96d30c9857dc15ae3 GIT binary patch literal 16 XcmWeoU|`^3VEAAEfw6#*fq?-4894(T literal 0 HcmV?d00001 diff --git a/src/data/m2-title-text-params.bin b/src/data/m2-title-text-params.bin new file mode 100644 index 0000000000000000000000000000000000000000..5c399b6d7be2243e61fb8cddabb0195a1a93a12c GIT binary patch literal 180 zcmd1ME978gU|=YK(iKp;0ZMm3=?PGJ29#a^rB^^{1_l-eMj&PaVrC!)K~^AU17da{ O<^baVKmf9fQW^l14=&yS literal 0 HcmV?d00001 diff --git a/src/data/m2-title-text.bin b/src/data/m2-title-text.bin new file mode 100644 index 0000000000000000000000000000000000000000..d4814da29abe047c49aff3a674392f587f42a55e GIT binary patch literal 4800 zcmeHJUu;uV82`>bqG&|UZP#tUx_bvC@OTG^5@5Y!jei~tw~hvNl6Dz(F`94-#uCPQ zJ4j58FP$VNMWLH$V)o+7G?+B7jhPrsGq<3U0A+&`YlOhLt1w`&dzz6`90E1o?8Ii>0HM}ZeZYmS-dhZLXn-Tl&J0g+A4PI|K zeQ5fbk->mO;eu_@$IbFu(Z*IWM`^q{Wto=QCqv4slqPTyN`uY9A))7_z1IHw;S^+M z`$QN05Xu?=8YWEIT<2c9*2%a*== z)w6m={?xBG78LXkV#wF#JptSNFp|KK)T$L|@g8foXZdb+qff(@GtRtz!0*?H%ctO? zP(@3~cQb)54fj^CHnz914N#)~6@JorL;%x;_l8F&Eq@Cmz}WmmP1nwo~-Ar%f)9i!x%gGn1O5yCzJoiC1wGWoGTy6dmiP z61YX%wskU4AtH*Hf208$gBVdzk|NJSXFN`kp4KrkqGQ>6@wiIZ*19j_w=}UO%dv?`A6otj4MkjpMkrQ-QU%ph6em(pO)+ji7`Z#zq3-}xc4!!nD|q~eR2XtZ zjznNt{47POHKd^6)_T?C@EqO8W^4@lj?xD@z8Qv~_)!t9)u>}#yHqKK zBjldQ)X|{hB%D{VlUtq$AvI)Q71;sZ#oqDYb#ABkk$!)o>}KGabvEc`Ndg2~SC_Nr;`&u@}};)auzT7A0rk z0|R?|4a{Wf+T^a}lG+s%p(=>bGJbfEj!Omd9gN(W?#4ixMw1X#k&YV(M{l!NZB)`T zarli~>N-!RDfYlQ9n(I(B(Q|=C9wH}=omC)K50UV)%Vpi<1&;D2eCOjh&h`Z*#wp?ekLa_wzUIuxt)tx)kH^T znTCWuoz0S=AXbCN{Z;rKL9U_dZloaZOT+UNbq}Cm1`JSbjA~*>O?9K;F>q5ZNB5FS zid`}c4QM#lBg3abBr6p`(ScEtj-kFCu)&1a73Acn?f@Xm*{h$3YUBMBhhR?v$8t6w zIP4Y?qn2mP!^l`nIL~JLP|@;xs-LVTG9Aj59cYoonH4kc&oUu~z?lj384}=lg6QZ^;PL@0bu0zzxd7&N0$1360Rv1zfes_XbwTo$ z%c7<+IYI6&vIoq~s;{2CR;odMq2{4m&b;8r0=(tNv!dv{K`EBQ7N`O*EZpFC0Ya@V zhW#~Hx!ExE^N=l~k(43in_^Rep^DCYN>m4-t8|01c@Dv15$e@CB(_AHW)!vRn zJeM;>F~2-oF|#N&C}uEWSGZe V9*@Tk$2=YWI~^YTzPBd>z~3vDtG)mL literal 0 HcmV?d00001 diff --git a/src/m2-hack.asm b/src/m2-hack.asm index 83f91b9..aa33582 100644 --- a/src/m2-hack.asm +++ b/src/m2-hack.asm @@ -1781,6 +1781,196 @@ nop //Add an extra event for the "?" in "THE END..." .org 0x80A5F5C :: bl extra_event_end_question_mark +//============================================================================== +// M2 Title hacks +//============================================================================== + +.definelabel m2_title_sequence_00, 0x80117E0 +.definelabel m2_title_sequence_01, 0x8011802 +.definelabel m2_title_sequence_02, 0x801182A +.definelabel m2_title_sequence_03, 0x8011858 +.definelabel m2_title_sequence_04, 0x80118FA +.definelabel m2_title_sequence_05, 0x80118FE +.definelabel m2_title_sequence_06, 0x801195C +.definelabel m2_title_sequence_07, 0x8011972 +.definelabel m2_title_sequence_08, 0x80119BA +.definelabel m2_title_sequence_09, 0x80119DE +.definelabel m2_title_sequence_0A, 0x8011A02 +.definelabel m2_title_sequence_0B, 0x8011A1A +.definelabel m2_title_sequence_0C, 0x8011A80 +.definelabel m2_title_sequence_0D, 0x8011A8A +.definelabel m2_title_sequence_0E, 0x8011AAA +.definelabel m2_title_sequence_0F, 0x8011B58 +.definelabel m2_title_sequence_10, 0x8011B66 +.definelabel m2_title_sequence_11, 0x8011B76 + +// m2_title_background_pal_copyright: File has two palettes separated by six palettes +// worth of nullspace. First palette is the copyright palette, +// last palette is a placeholder for the glow palette +// m2_title_background_pal_glow: 20 frames, glow effect +// m2_title_text_pal_animated: 14 frames, white horizontal line scrolling top to bottom +// m2_title_text_pal_static: 1 frame, white text on black background + +// BG0 will be used for the B, the glow, and copyright info +// OAM will be used for the other letters + +// Background palette RAM layout: +// [0]: copyright +// [1-6]: (blank) +// [7]: glow +// [8]: B +// [9-15]: (blank) + +// Frame states (BG0), from EarthBound: +// Start Duration State +// -------------------------- +// 0 g Black +// g 1 1/32 grey B +// g+1 2 2/32 grey B +// g+3 2 3/32 grey B +// g+5 2 4/32 grey B +// g+7 2 5/32 grey B +// g+9 2 6/32 grey B +// g+11 2 7/32 grey B +// g+13 2 8/32 grey B +// g+15 2 9/32 grey B +// g+17 2 10/32 grey B +// g+19 2 11/32 grey B +// g+21 2 12/32 grey B +// g+23 2 13/32 grey B +// g+25 2 14/32 grey B +// g+27 2 15/32 grey B +// g+29 1 16/32 grey B +// g+30 2 17/32 grey B + +// --- Animation 3 (full title screen) --- +.org 0x82D6B64 :: dh 0x008A // Enable 8-bit BG0 + +// Initializer hacks: + + // Point to new compressed palettes + .org 0x801147C + dw m2_title_text_pal_animated + 4 + dw m2_title_text_pal_static + 4 + dw m2_title_background_pal_copyright + 4 + dw m2_title_background_pal_glow + 4 + + // The new palettes have different sizes (8, 20, 14, 1 palettes respectively), so encode the proper buffer pointers + .org 0x801146C + dw 0x2011500 + dw 0x2011780 + dw 0x2011940 + dw 0x2011960 + + // Expand the null area after the fifth palette buffer (gives us 0x2A0 bytes of nullspace + // starting at 0x2011B60) + .org 0x8011490 :: dw 0x85000128 + + // Define the proper expected uncompressed sizes + .org 0x801141E :: mov r5,4 :: neg r5,r5 + .org 0x8011422 :: ldr r2,[r0,r5] + .org 0x801142C :: ldr r2,[r0,r5] + .org 0x8011436 :: ldr r2,[r0,r5] + .org 0x8011440 :: ldr r2,[r0,r5] + + // Point to custom initializer routine + .org 0x82D6B78 :: dw title_initializer + 1 + +// Setup hacks: + + // Fade BG0 instead of OBJ + .org 0x80117E6 :: mov r0,0xC1 + + // Point to sequence hacks + .org 0x8011798 :: dw title_sequence_00 + .org 0x801179C :: dw title_sequence_01 + .org 0x80117A4 :: dw title_sequence_03 + .org 0x80117A8 :: dw title_sequence_04 + .org 0x80117AC :: dw title_sequence_05 + .org 0x80117B4 :: dw title_sequence_07 + .org 0x80117B8 :: dw title_sequence_08 + .org 0x80117BC :: dw title_sequence_09 + .org 0x80117C4 :: dw title_sequence_0B + .org 0x80117C8 :: dw title_sequence_0C + .org 0x80117CC :: dw title_sequence_0D + .org 0x80117D0 :: dw title_sequence_0D + .org 0x80117D4 :: dw title_sequence_0D + .org 0x80117D8 :: dw title_sequence_0D + + // Clamp initial X values for text + .org 0x80116F0 :: bl title_setup_clamp + + // Show all eight text sprites from the start + .org 0x8011B94 :: mov r6,8 + .org 0x8011BAC :: b 0x8011BDC + + // Allocate space for nine sprites + .org 0x80113F8 :: mov r0,0xC8 + .org 0x80115B2 :: add sp,-0xA4 + .org 0x8011BE6 :: add sp,0xA4 + + .org 0x80115CC + ldmia [r0]!,r2,r4,r7 + stmia [r1]!,r2,r4,r7 + add r6,sp,0x30 + + .org 0x80115DE + ldmia [r0]!,r2,r4,r7 + stmia [r1]!,r2,r4,r7 + add r5,sp,0x54 + + .org 0x80115F0 + ldmia [r0]!,r2,r4,r7 + stmia [r1]!,r2,r4,r7 + add r4,sp,0x78 + + .org 0x8011602 + ldmia [r0]!,r2,r3,r7 + stmia [r1]!,r2,r3,r7 + + .org 0x8011646 :: ldr r1,[sp,0x5C] + .org 0x801166A :: add r1,0x60 :: str r1,[sp,0x9C] + .org 0x8011670 :: add r2,0x84 :: str r2,[sp,0xA0] + .org 0x8011686 :: ldr r0,[sp,0xA0] + .org 0x801168A :: str r0,[sp,0xA0] :: ldr r2,[sp,0x9C] + .org 0x8011690 :: str r2,[sp,0x9C] + .org 0x80116CC :: add r7,sp,0x30 + .org 0x80116D0 :: add r7,sp,0x78 + .org 0x8011704 :: cmp r6,8 + + // Relocate stuff from after the sprite data + .org 0x8011634 :: mov r1,0xB2 + .org 0x8011640 :: mov r2,0xC2 + .org 0x801164E :: mov r1,0xBE + .org 0x801165C :: mov r7,0xC2 + .org 0x8011662 :: mov r5,0xC3 + .org 0x8011674 :: mov r3,0xB2 + .org 0x801167C :: mov r4,0xB3 + .org 0x8011696 :: mov r0,0xBE + .org 0x8011838 :: mov r1,0xB6 + +// Commit hacks: + + // Commit all things on every sequence + .org 0x8011500 :: b 0x8011516 + +// --- Animation 5 (quick title screen) --- +.org 0x82D6BD4 :: dh 0x008A // Enable 8-bit BG0 +.org 0x82D6BE0 :: dh 0x1100 // Disable BG1 + +.org 0x801170C :: dw m2_title_text_constants +.org 0x8011710 :: dw m2_title_text_constants + 12 +.org 0x8011714 :: dw m2_title_text_constants + 12 + 36 +.org 0x8011718 :: dw m2_title_text_constants + 12 + 36 + 36 +.org 0x801171C :: dw m2_title_text_constants + 12 + 36 + 36 + 36 +.org 0x870F580 :: .incbin "data/m2-title-background.bin" +.org 0x8711280 :: .incbin "data/m2-title-text.bin" +.org 0x87126CC :: .incbin "data/m2-title-background-pal-empty.bin" +.org 0x87128EC :: .incbin "data/m2-title-background-map.bin" +.org 0x8712E68 :: .incbin "data/m2-title-text-oam.bin" +.org 0x8712F10 :: .incbin "data/m2-title-text-oam-entries.bin" +.org 0x8712FB0 :: dw m2_title_text_params, m2_title_text_params + 0x6C + //============================================================================== // Move stuff around in order to make space for the code //============================================================================== @@ -2044,6 +2234,43 @@ optimized_byte_4bpp_to_1bpp_table: m12_cartridge_palettes_dimmed: .incbin "data/m12-cartridge-palettes-dimmed.bin" +.align 4 + +m2_title_background_pal_copyright: +dw 0x100 :: .incbin "data/m2-title-background-pal-copyright.c.bin" + +.align 4 + +m2_title_background_pal_glow: +dw 0x280 :: .incbin "data/m2-title-background-pal-glow.c.bin" + +.align 4 + +m2_title_text_pal_animated: +dw 0x1C0 :: .incbin "data/m2-title-text-pal-animated.c.bin" + +.align 4 + +m2_title_text_pal_static: +dw 0x20 :: .incbin "data/m2-title-text-pal-static.c.bin" + +.align 4 + +m2_title_text_constants: +.incbin "data/m2-title-text-constants.bin" + +m2_title_text_params: +.incbin "data/m2-title-text-params.bin" +.org m2_title_text_params + 0x6C :: dw m2_title_text_params + 0x48 +.org m2_title_text_params + 0x74 :: dw m2_title_text_params + 0x4C +.org m2_title_text_params + 0x7C :: dw m2_title_text_params + 0x50 +.org m2_title_text_params + 0x84 :: dw m2_title_text_params + 0x54 +.org m2_title_text_params + 0x8C :: dw m2_title_text_params + 0x58 +.org m2_title_text_params + 0x94 :: dw m2_title_text_params + 0x5C +.org m2_title_text_params + 0x9C :: dw m2_title_text_params + 0x60 +.org m2_title_text_params + 0xA4 :: dw m2_title_text_params + 0x64 +.org m2_title_text_params + 0xAC :: dw m2_title_text_params + 0x68 + .org 0x8FEE000 disclaimer_palette: .incbin "data/intro-screen-pal.bin" @@ -2054,7 +2281,6 @@ disclaimer_graphics: disclaimer_map: .incbin "data/intro-screen-map.bin" - //============================================================================== // Existing subroutines/data //============================================================================== @@ -2126,6 +2352,7 @@ disclaimer_map: .definelabel m2_sub_d6844 ,0x80D6844 .definelabel m2_setupbattlename ,0x80DCD00 .definelabel m2_stat_symb_checker ,0x8B0EDA4 +.definelabel vblank ,0x80F47E4 .definelabel m2_div ,0x80F49D8 .definelabel m2_remainder ,0x80F4A70 .definelabel cpuset ,0x80F47C0 @@ -2133,6 +2360,7 @@ disclaimer_map: .definelabel m2_items ,0x8B1D62C .definelabel m2_default_names ,0x82B9330 .definelabel m2_psi_print_table ,0x8B2A9C0 +.definelabel m2_title_teardown ,0x8000C28 //============================================================================== // Code files @@ -2150,5 +2378,6 @@ disclaimer_map: .include "m2-compiled.asm" .include "m2-flyover.asm" .include "m12-intro.asm" +.include "m2-title.asm" .close diff --git a/src/m2-title.asm b/src/m2-title.asm new file mode 100644 index 0000000..9393c68 --- /dev/null +++ b/src/m2-title.asm @@ -0,0 +1,492 @@ +//--------------------------------------------------------- +title_initializer: +push {r1} +ldr r0,=0x3001B20 +mov r1,8 // BG0 X offset +strh r1,[r0] +ldr r0,=0x30012DC +mov r1,8*6 // BG0 Y offset +strh r1,[r0] +pop {r1} +ldr r0,=0x80113F4 +mov pc,r0 // Run the existing routine + +//--------------------------------------------------------- +title_setup_clamp: +mov r1,250 +cmp r0,r1 +bgt @@clamp +neg r1,r1 +cmp r0,r1 +blt @@clamp +b @@clamp_end + +@@clamp: +mov r0,r1 + +@@clamp_end: +str r0,[r5,4] +mov r1,r8 // clobbered code +bx lr + +//--------------------------------------------------------- +// r3 has 2028008 +// [r3+14] has 2028028 +// [2028028+10] has pointer to our palette buffer, 0x200 bytes after which +// we have some free space to use for things +// Let's allocate some variables: +// +0x00: Sequence 01 -- initial delay flag + +//--------------------------------------------------------- +title_return: +ldr r0,=0x8011B8C +mov pc,r0 + +//--------------------------------------------------------- +// In: r0 = pointer to pointer to little struct +// Out: r0 = pointer to our buffer area (0x2011B60) +title_get_buffer: +push {r1,lr} +ldr r0,[r0] +ldr r1,[r0,0x14] +ldr r0,[r1,0x10] +ldr r1,=0x200 +add r0,r0,r1 +pop {r1,pc} + +//--------------------------------------------------------- +title_sequence_00: + +// Normally the game enables BG0 in sequence 8, but we want +// it enabled from the start so copy that code to here +push {r3} +mov r1,r9 +add r1,0x78 +mov r0,0x88 +lsl r0,r0,5 +strh r0,[r1] + +// Copy static palette to BG pal 8 +ldr r3,[r3] +ldr r3,[r3,0x14] +ldr r1,=0x40000D4 +ldr r2,[r3,0xC] // m2_title_text_pal_static +str r2,[r1] +ldr r0,=0x5000100 +str r0,[r1,4] +ldr r0,=0x84000008 +str r0,[r1,8] +ldr r0,[r1,8] + +// Copy to OBJ pal 0 as well for the text +str r2,[r1] +ldr r0,=0x5000200 +str r0,[r1,4] +ldr r0,=0x84000008 +str r0,[r1,8] +ldr r0,[r1,8] + +pop {r3} + +// Return to old sequence 0 code +ldr r0,=m2_title_sequence_00 +mov pc,r0 + +//--------------------------------------------------------- +title_sequence_01: + +// EB has a 38 frame delay between starting the music +// and starting the fade-in +mov r0,r3 +bl title_get_buffer + +// Check if we've set our delay flag yet +ldr r1,[r0] +cmp r1,0 +beq @@unset + + @@set: + + // Skip our code and return to the old sequence 1 code + ldr r0,=m2_title_sequence_01 + mov pc,r0 + + @@unset: + + // Count to 0x26 before starting the fade-in + ldr r3,[r3] + ldr r1,[r3,4] + cmp r1,0x26 + bge @@unset_start_fade + b @@end + + @@unset_start_fade: + mov r1,0 + str r1,[r3,4] + mov r1,1 + str r1,[r0] + +@@end: +b title_return + +//--------------------------------------------------------- +title_sequence_03: + +push {r0-r3} +mov r0,r2 // 0x2028008 +mov r1,r9 // 0x2028028 +mov r2,sp +add r2,0x10 // coord table on the stack +bl title_text_sequence +pop {r0-r3} +b title_return + +//--------------------------------------------------------- +title_sequence_04: + +// Just need to reset the frame counter +ldr r2,[r3] +mov r0,1 +neg r0,r0 // This gets incremented before calling the sequence subroutines, + // and we want it to be 0 on the first frame for sequence 5, + // so start it at -1 +str r0,[r2,4] + +ldr r0,=m2_title_sequence_04 +mov pc,r0 + +//--------------------------------------------------------- +title_sequence_05: + +push {r4} +ldr r3,[r3] +mov r4,r3 +ldr r0,[r4,4] // frame number + +// Frame 0-1: inverted colours +cmp r0,1 +bhi @@next1 + + // Only change the palette on frame 0 + cmp r0,1 + beq @@advance_frame + + @@inverted: + + // Load inverted BG palettes + // (all white for BG pal 0-7, + // all black for BG pal 8-F) + ldr r1,=0x40000D4 + mov r2,1 + neg r2,r2 + push {r2} + mov r2,sp + str r2,[r1] + ldr r0,=0x5000000 + str r0,[r1,4] + ldr r0,=0x85000040 + str r0,[r1,8] + ldr r0,[r1,8] + mov r2,0 + str r2,[sp] + + mov r2,sp + str r2,[r1] + ldr r0,=0x5000100 + str r0,[r1,4] + ldr r0,=0x85000040 + str r0,[r1,8] + ldr r0,[r1,8] + + // Black for OBJ pal 0 + str r2,[r1] + ldr r0,=0x5000200 + str r0,[r1,4] + ldr r0,=0x85000040 + str r0,[r1,8] + ldr r0,[r1,8] + + pop {r2} + b @@advance_frame + +@@next1: +// Frame 2-29: animated text, 2 frames per palette change +cmp r0,29 +bhi @@next2 + + // Only change palette on the even frames + sub r0,2 + lsl r1,r0,0x1F + bmi @@advance_frame + + // On frame 2, we need to reset BG pal 0-7 to black + cmp r0,0 + bne @@skip_black_palettes + ldr r1,=0x40000D4 + push {r0} + mov r2,sp + str r2,[r1] + ldr r2,=0x5000000 + str r2,[r1,4] + ldr r2,=0x85000040 + str r2,[r1,8] + ldr r2,[r1,8] + add sp,4 + + @@skip_black_palettes: + // Get source palette address + ldr r3,[r3,0x14] + ldr r1,[r3,8] // m2_title_text_pal_animated + lsl r0,r0,4 + add r0,r0,r1 + + // Copy to BG pal 8 + mov r4,r0 + ldr r1,=0x40000D4 + str r0,[r1] + ldr r0,=0x5000100 + str r0,[r1,4] + ldr r0,=0x84000008 + str r0,[r1,8] + ldr r0,[r1,8] + + // Copy to OBJ pal 0 + str r4,[r1] + ldr r0,=0x5000200 + str r0,[r1,4] + ldr r0,=0x84000008 + str r0,[r1,8] + ldr r0,[r1,8] + + b @@advance_frame + +@@next2: +// For now let's just go to the next sequence, not sure what to do next yet +mov r0,0 +str r0,[r4,4] +mov r0,6 +ldr r1,[r4,0x14] +add r1,0x84 +str r0,[r1] +pop {r4} +b title_return + +@@advance_frame: +pop {r4} +ldr r0,[r4,4] +add r0,1 +str r0,[r4,4] +b title_return + +//--------------------------------------------------------- +title_sequence_07: + +// We're not moving the text so just do a delay for this sequence +ldr r3,[r3] +ldr r0,[r3,4] +cmp r0,0x2C +bgt @@nextsequence +b title_return + +@@nextsequence: +mov r0,8 +mov r4,r10 +str r0,[r4] +mov r0,0 +str r0,[r3,4] +b title_return + +//--------------------------------------------------------- +title_sequence_08: + +// We're not messing with the video registers so just do a delay for this sequence +ldr r3,[r3] +ldr r0,[r3,4] +cmp r0,0x2C +bgt @@nextsequence +b title_return + +@@nextsequence: +mov r0,9 +mov r4,r10 +str r0,[r4] +mov r0,1 +neg r0,r0 // want to start the next sequence on frame 0 +str r0,[r3,4] +b title_return + +//--------------------------------------------------------- +title_sequence_09: + +// Copyright palette fade in +push {r4-r7} +ldr r3,[r3] +mov r4,r3 +ldr r0,[r3,4] // frame number + +// Frame 0-215: re-calculate palette every frame +cmp r0,215 +bgt @@nextsequence + +add sp,-16 +str r0,[sp] +ldr r1,=215 +str r1,[sp,4] +ldr r5,[r4,0x14] +ldr r5,[r5] // copyright palette source +mov r6,5 +lsl r6,r6,24 // copyright palette dest +mov r7,0 + +@@loop: +// Scale R +ldrh r1,[r5] +lsl r1,r1,27 +lsr r1,r1,9 +ldr r0,[sp] +mul r0,r1 +ldr r1,[sp,4] +bl m2_div +lsr r0,r0,18 +str r0,[sp,8] + +// Scale G +ldrh r1,[r5] +lsr r1,r1,5 +lsl r1,r1,27 +lsr r1,r1,9 +ldr r0,[sp] +mul r0,r1 +ldr r1,[sp,4] +bl m2_div +lsr r0,r0,18 +str r0,[sp,12] + +// Scale B +ldrh r1,[r5] +lsr r1,r1,10 +lsl r1,r1,27 +lsr r1,r1,9 +ldr r0,[sp] +mul r0,r1 +ldr r1,[sp,4] +bl m2_div +lsr r0,r0,18 + +// Pack colours and store +lsl r0,r0,10 +ldr r1,[sp,12] +lsl r1,r1,5 +orr r0,r1 +ldr r1,[sp,8] +orr r0,r1 +strh r0,[r6] + +// Copy background colour to the glow palette +cmp r7,0 +bgt @@next +mov r1,0 +add r6,0xE0 +@@copyloop: +strh r0,[r6] +add r6,2 +add r1,1 +cmp r1,16 +blt @@copyloop +sub r6,0xE0 +sub r6,0x20 + +@@next: +add r5,2 +add r6,2 +add r7,1 +cmp r7,16 +blt @@loop + +add sp,16 +pop {r4-r7} +b title_return + +@@nextsequence: +mov r0,0 +str r0,[r4,4] +mov r0,0xA +mov r4,r10 +str r0,[r4] +pop {r4-r7} +b title_return + +//--------------------------------------------------------- +title_sequence_0B: + +// Background palette fade in +push {r4} +ldr r3,[r3] +mov r4,r3 +ldr r0,[r3,4] // frame number + +// Frame 0-159: change palette every 8 frames +lsl r3,r0,29 +lsr r3,r3,29 +cmp r3,0 +bne @@end + +lsr r0,r0,3 // source palete index +cmp r0,20 +bge @@nextsequence + +lsl r0,r0,5 // source palette offset +ldr r3,[r4,0x14] +ldr r3,[r3,4] // source palette buffer +add r0,r0,r3 + +// Copy palette +ldr r1,=0x40000D4 +str r0,[r1] +ldr r0,=0x50000E0 +str r0,[r1,4] +ldr r0,=0x84000008 +str r0,[r1,8] +ldr r0,[r1,8] +b @@end + +@@nextsequence: +mov r0,1 +neg r0,r0 // want to start the next sequence on frame 0 +str r0,[r4,4] +mov r0,0xC +mov r4,r10 +str r0,[r4] + +@@end: +pop {r4} +b title_return + +//--------------------------------------------------------- +title_sequence_0C: + +ldr r3,[r3] +ldr r0,[r3,4] +cmp r0,0x2C +bgt @@nextsequence +b title_return + +@@nextsequence: +mov r0,0xD +mov r4,r10 +str r0,[r4] +mov r0,1 +neg r0,r0 +str r0,[r3,4] +b title_return + +//--------------------------------------------------------- +title_sequence_0D: + +mov r4,r10 +ldr r0,[r4] +add r0,1 +str r0,[r4] +b title_return + +.pool From 9ff76198d3d7cf4b432088d017f5ba17daa89e19 Mon Sep 17 00:00:00 2001 From: Lorenzo Carletti Date: Sat, 2 Oct 2021 12:36:07 +0200 Subject: [PATCH 29/32] Insert the quick title's palettes --- src/data/m2-title-quick-background-pal.c.bin | Bin 0 -> 160 bytes src/data/m2-title-quick-foreground-pal.c.bin | Bin 0 -> 100 bytes src/m2-hack.asm | 26 ++++++++++++++++--- 3 files changed, 22 insertions(+), 4 deletions(-) create mode 100644 src/data/m2-title-quick-background-pal.c.bin create mode 100644 src/data/m2-title-quick-foreground-pal.c.bin diff --git a/src/data/m2-title-quick-background-pal.c.bin b/src/data/m2-title-quick-background-pal.c.bin new file mode 100644 index 0000000000000000000000000000000000000000..8de3ccd582aa23efed8d92d4781458514ad1b18b GIT binary patch literal 160 zcmWe&U}9ikmPzKBQ@lcl;iUn$rLS$DBf|#IkG{r1p;4UE;%+1fNHQ>dVEq4q5fz^J zz*xY@EMvgvs?g4$a8iX!)km|BLHB~Lkx_}!HU_gFR+iQb4EGtBjblSXLj%hhT+3Z& lIL@@(#bCPI@Q&sk&428Q|7HJ6eh31Yi(&kM4~!QW833@IIye9T literal 0 HcmV?d00001 diff --git a/src/data/m2-title-quick-foreground-pal.c.bin b/src/data/m2-title-quick-foreground-pal.c.bin new file mode 100644 index 0000000000000000000000000000000000000000..cd42737112e89e88f05c980b8941b90a26fdb410 GIT binary patch literal 100 zcmWe&U}6A*`^?6%A)ySRf#t5{t}`4NW?Jqt-EDYBli`l$KgIvD|0V4i7(Or};C}=Y L!om>vflvVeHiaqA literal 0 HcmV?d00001 diff --git a/src/m2-hack.asm b/src/m2-hack.asm index 76524ee..b63f622 100644 --- a/src/m2-hack.asm +++ b/src/m2-hack.asm @@ -1957,6 +1957,19 @@ nop // --- Animation 5 (quick title screen) --- .org 0x82D6BD4 :: dh 0x008A // Enable 8-bit BG0 .org 0x82D6BE0 :: dh 0x1100 // Disable BG1 +.org 0x82D6BC8 :: dw m2_title_quick_background_pal +.org 0x82D6BCC :: dw m2_title_quick_foreground_pal + +// Initializer hacks + + // Point to custom initializer routine + .org 0x82D6BE8 :: dw title_initializer + 1 + +// Setup hacks: + // Remove the M2's shines + + .org 0x8011D9C :: nop :: mov r0,#1 + .org 0x8011DD2 :: nop :: mov r0,#1 .org 0x801170C :: dw m2_title_text_constants .org 0x8011710 :: dw m2_title_text_constants + 12 @@ -2231,31 +2244,35 @@ m2_end_frame1: optimized_byte_4bpp_to_1bpp_table: .incbin "data/optimized-byte-4bpp-to-1bpp-table.bin" +.align 4 m12_cartridge_palettes_dimmed: .incbin "data/m12-cartridge-palettes-dimmed.bin" .align 4 +m2_title_quick_background_pal: +.incbin "data/m2-title-quick-background-pal.c.bin" +.align 4 +m2_title_quick_foreground_pal: +.incbin "data/m2-title-quick-foreground-pal.c.bin" + +.align 4 m2_title_background_pal_copyright: dw 0x100 :: .incbin "data/m2-title-background-pal-copyright.c.bin" .align 4 - m2_title_background_pal_glow: dw 0x280 :: .incbin "data/m2-title-background-pal-glow.c.bin" .align 4 - m2_title_text_pal_animated: dw 0x1C0 :: .incbin "data/m2-title-text-pal-animated.c.bin" .align 4 - m2_title_text_pal_static: dw 0x20 :: .incbin "data/m2-title-text-pal-static.c.bin" .align 4 - m2_title_text_constants: .incbin "data/m2-title-text-constants.bin" @@ -2319,6 +2336,7 @@ disclaimer_map: .definelabel m2_insert_default_name ,0x8005708 .definelabel m2_malloc ,0x8005B9C .definelabel m2_get_hall_address ,0x800D7BC +.definelabel m2_title_quick ,0x8011BFC .definelabel m12_dim_palette ,0x80137DC .definelabel m2_enable_script ,0x80A1F6C .definelabel m2_sub_a334c ,0x80A334C From c2b19230ed67d6bf0b531dc87daeb59749c6a32f Mon Sep 17 00:00:00 2001 From: Lorenzo Carletti Date: Sat, 2 Oct 2021 12:48:24 +0200 Subject: [PATCH 30/32] Change when BG0 is enabled --- src/m2-title.asm | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/m2-title.asm b/src/m2-title.asm index 9393c68..55fb12f 100644 --- a/src/m2-title.asm +++ b/src/m2-title.asm @@ -1,5 +1,9 @@ //--------------------------------------------------------- title_initializer: + +// Normally the game enables BG0 in sequence 8, but we want +// it enabled from the start so copy that code to here + push {r1} ldr r0,=0x3001B20 mov r1,8 // BG0 X offset @@ -7,6 +11,12 @@ strh r1,[r0] ldr r0,=0x30012DC mov r1,8*6 // BG0 Y offset strh r1,[r0] +ldr r0,=0x3000370 +ldr r1,[r0,#0] +add r1,0x98 +mov r0,0x88 +lsl r0,r0,5 +strh r0,[r1] pop {r1} ldr r0,=0x80113F4 mov pc,r0 // Run the existing routine @@ -57,14 +67,7 @@ pop {r1,pc} //--------------------------------------------------------- title_sequence_00: -// Normally the game enables BG0 in sequence 8, but we want -// it enabled from the start so copy that code to here push {r3} -mov r1,r9 -add r1,0x78 -mov r0,0x88 -lsl r0,r0,5 -strh r0,[r1] // Copy static palette to BG pal 8 ldr r3,[r3] From 0f5cda234a09666b8c033d577fc5de2f510a4660 Mon Sep 17 00:00:00 2001 From: Lorenzo Carletti Date: Sat, 2 Oct 2021 13:19:57 +0200 Subject: [PATCH 31/32] Make it so the first palette isn't cleared --- src/m2-hack.asm | 3 +++ src/m2-title.asm | 15 +++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/src/m2-hack.asm b/src/m2-hack.asm index b63f622..bee9805 100644 --- a/src/m2-hack.asm +++ b/src/m2-hack.asm @@ -1962,6 +1962,9 @@ nop // Initializer hacks + // Make it so the first entry of the first palette isn't cleared + .org 0x80112BE :: bl _112be_remove_pal_blanking_quick_title + // Point to custom initializer routine .org 0x82D6BE8 :: dw title_initializer + 1 diff --git a/src/m2-title.asm b/src/m2-title.asm index 55fb12f..b1f06a3 100644 --- a/src/m2-title.asm +++ b/src/m2-title.asm @@ -21,6 +21,21 @@ pop {r1} ldr r0,=0x80113F4 mov pc,r0 // Run the existing routine +//--------------------------------------------------------- +_112be_remove_pal_blanking_quick_title: + +// Normally the game clears the first entry of the first palette +// when showing animations. We don't want that for the quick version +// of the title. + +cmp r5,#5 // Is it the quick version of the title? +beq @@rmv_pal_qt_end +mov r1,r8 // If not, blank out the first entry +strh r0,[r1,#0] + +@@rmv_pal_qt_end: +bx lr + //--------------------------------------------------------- title_setup_clamp: mov r1,250 From 83da3648c82bffae6587fd872eb381a58d4f7265 Mon Sep 17 00:00:00 2001 From: Lorenzo Carletti Date: Sat, 2 Oct 2021 16:12:55 +0200 Subject: [PATCH 32/32] Properly load the letters in the quick title --- src/data/m2-title-quick-text-coords-x.bin | Bin 0 -> 36 bytes src/data/m2-title-quick-text-coords-y.bin | Bin 0 -> 36 bytes src/m2-hack.asm | 26 ++++++++++++++++++++-- 3 files changed, 24 insertions(+), 2 deletions(-) create mode 100644 src/data/m2-title-quick-text-coords-x.bin create mode 100644 src/data/m2-title-quick-text-coords-y.bin diff --git a/src/data/m2-title-quick-text-coords-x.bin b/src/data/m2-title-quick-text-coords-x.bin new file mode 100644 index 0000000000000000000000000000000000000000..a7b612a7e3d4d3556c024ba7cdb14d39706db384 GIT binary patch literal 36 fcmd;MU|>)JVhbSl0^%4T?g8QjK)e-*PXRFiGpqx; literal 0 HcmV?d00001 diff --git a/src/data/m2-title-quick-text-coords-y.bin b/src/data/m2-title-quick-text-coords-y.bin new file mode 100644 index 0000000000000000000000000000000000000000..d441ddc8dc18a12d67ef31eff51da0af8bcf3039 GIT binary patch literal 36 Ncmb1TU|^6XfB_VU0R{j7 literal 0 HcmV?d00001 diff --git a/src/m2-hack.asm b/src/m2-hack.asm index bee9805..8e657ff 100644 --- a/src/m2-hack.asm +++ b/src/m2-hack.asm @@ -1969,10 +1969,24 @@ nop .org 0x82D6BE8 :: dw title_initializer + 1 // Setup hacks: + // Remove the M2's shines - .org 0x8011D9C :: nop :: mov r0,#1 .org 0x8011DD2 :: nop :: mov r0,#1 + + // Change the amount of loaded letters + .org 0x8011C86 :: cmp r6,#8 + .org 0x8011E14 :: mov r6,#8 + + // Change how the letters coords are loaded + .org 0x8011C04 :: add sp,#-0x48 + .org 0x8011E2E :: add sp,#0x48 + .org 0x8011C12 :: ldmia [r0]!,r2-r4 :: stmia [r1]!,r2-r4 + .org 0x8011C16 :: add r4,sp,#0x24 + .org 0x8011C26 :: ldmia [r0]!,r2-r4 :: stmia [r1]!,r2-r4 + + // Change the location of the coords + .org 0x8011C8C :: dw m2_title_quick_text_coords_y :: dw m2_title_quick_text_coords_x .org 0x801170C :: dw m2_title_text_constants .org 0x8011710 :: dw m2_title_text_constants + 12 @@ -2259,6 +2273,14 @@ m2_title_quick_background_pal: m2_title_quick_foreground_pal: .incbin "data/m2-title-quick-foreground-pal.c.bin" +.align 4 +m2_title_quick_text_coords_x: +.incbin "data/m2-title-quick-text-coords-x.bin" + +.align 4 +m2_title_quick_text_coords_y: +.incbin "data/m2-title-quick-text-coords-y.bin" + .align 4 m2_title_background_pal_copyright: dw 0x100 :: .incbin "data/m2-title-background-pal-copyright.c.bin" @@ -2339,7 +2361,7 @@ disclaimer_map: .definelabel m2_insert_default_name ,0x8005708 .definelabel m2_malloc ,0x8005B9C .definelabel m2_get_hall_address ,0x800D7BC -.definelabel m2_title_quick ,0x8011BFC +.definelabel m2_title_quick_setup ,0x8011BFC .definelabel m12_dim_palette ,0x80137DC .definelabel m2_enable_script ,0x80A1F6C .definelabel m2_sub_a334c ,0x80A334C