From f2a5bb9ad3ff009a546a5c49f0f46e5132ca70a6 Mon Sep 17 00:00:00 2001 From: jiangzhengwenjz <15051292+jiangzhengwenjz@users.noreply.github.com> Date: Fri, 2 Feb 2024 12:02:49 -0600 Subject: [PATCH 1/4] Fully decompile sub_A710 Co-Authored-By: Kermalis <29823718+Kermalis@users.noreply.github.com> --- src/intro.c | 169 ++-------------------------------------------------- 1 file changed, 4 insertions(+), 165 deletions(-) diff --git a/src/intro.c b/src/intro.c index 2cc578d..ffaa871 100644 --- a/src/intro.c +++ b/src/intro.c @@ -1163,7 +1163,6 @@ void sub_A674(void) gMain.unk2E8[2].unk2 = gUnknown_0202ADA0[0xD]; } -#ifdef NONMATCHING void sub_A710(void) { gUnknown_0202ADA0[0x12]--; @@ -1193,16 +1192,16 @@ void sub_A710(void) DmaCopy16(3, gUnknown_03005C00, (void*) 0x0600E000, 0x800); gUnknown_0202ADA0[0x6] = 0; gUnknown_0202ADA0[0x7] = 0; - gMain.unk2E8[1].unk0 = 0; - // gMain.unk2E8[1].unk2 = 0; // TODO uncomment this line without everything falling apart + gMain.unk2E8[1].unk0 = gUnknown_0202ADA0[0x6]; + gMain.unk2E8[1].unk2 = gUnknown_0202ADA0[0x7]; } else if (gUnknown_0202ADA0[0x10] == 4) { DmaCopy16(3, gUnknown_0201B180, (void*) 0x0600E000, 0x800); gUnknown_0202ADA0[0x6] = 0; gUnknown_0202ADA0[0x7] = 0; - gMain.unk2E8[1].unk0 = 0; - gMain.unk2E8[1].unk2 = 0; + gMain.unk2E8[1].unk0 = gUnknown_0202ADA0[0x6]; + gMain.unk2E8[1].unk2 = gUnknown_0202ADA0[0x7]; } gUnknown_0202ADA0[0x10]++; @@ -1212,166 +1211,6 @@ void sub_A710(void) gUnknown_0202C790 += 2; } } -#else -NAKED -void sub_A710(void) -{ - asm_unified("\n\ - push {r4, r5, r6, lr}\n\ - ldr r5, _0800A7C8 @ =gUnknown_0202ADA0\n\ - ldrh r0, [r5, #0x24]\n\ - subs r0, #1\n\ - movs r6, #0\n\ - strh r0, [r5, #0x24]\n\ - ldr r2, _0800A7CC @ =gUnknown_0202BF10\n\ - ldrh r0, [r2]\n\ - movs r1, #1\n\ - ands r0, r1\n\ - cmp r0, #0\n\ - bne _0800A742\n\ - ldrh r0, [r5]\n\ - subs r0, #1\n\ - strh r0, [r5]\n\ - ldrh r0, [r5, #2]\n\ - adds r0, #1\n\ - strh r0, [r5, #2]\n\ - ldr r1, _0800A7D0 @ =gUnknown_0201A450\n\ - ldrh r0, [r1]\n\ - adds r0, #2\n\ - strh r0, [r1]\n\ - ldrh r0, [r1, #2]\n\ - subs r0, #2\n\ - strh r0, [r1, #2]\n\ -_0800A742:\n\ - movs r1, #0\n\ - ldrsh r0, [r2, r1]\n\ - movs r1, #3\n\ - bl __modsi3\n\ - lsls r0, r0, #0x10\n\ - cmp r0, #0\n\ - bne _0800A776\n\ - ldr r0, _0800A7D4 @ =0x040000D4\n\ - movs r3, #0xa0\n\ - lsls r3, r3, #0x13\n\ - str r3, [r0]\n\ - ldr r4, _0800A7D8 @ =gUnknown_0202BE70\n\ - str r4, [r0, #4]\n\ - ldr r1, _0800A7DC @ =0x80000010\n\ - str r1, [r0, #8]\n\ - ldr r2, [r0, #8]\n\ - ldr r2, _0800A7E0 @ =0x05000040\n\ - str r2, [r0]\n\ - str r3, [r0, #4]\n\ - str r1, [r0, #8]\n\ - ldr r3, [r0, #8]\n\ - str r4, [r0]\n\ - str r2, [r0, #4]\n\ - str r1, [r0, #8]\n\ - ldr r0, [r0, #8]\n\ -_0800A776:\n\ - ldr r4, _0800A7E4 @ =gMain\n\ - ldrh r1, [r5]\n\ - movs r2, #0xba\n\ - lsls r2, r2, #2\n\ - adds r0, r4, r2\n\ - strh r1, [r0]\n\ - ldrh r1, [r5, #2]\n\ - adds r2, #2\n\ - adds r0, r4, r2\n\ - strh r1, [r0]\n\ - ldrh r1, [r5, #0x24]\n\ - adds r2, #0xa\n\ - adds r0, r4, r2\n\ - strh r1, [r0]\n\ - ldrh r1, [r5, #0x26]\n\ - adds r2, #2\n\ - adds r0, r4, r2\n\ - strh r1, [r0]\n\ - bl sub_A87C\n\ - movs r1, #0x20\n\ - ldrsh r0, [r5, r1]\n\ - cmp r0, #2\n\ - bne _0800A7F4\n\ - ldr r1, _0800A7D4 @ =0x040000D4\n\ - ldr r0, _0800A7E8 @ =gUnknown_03005C00\n\ - str r0, [r1]\n\ - ldr r0, _0800A7EC @ =0x0600E000\n\ - str r0, [r1, #4]\n\ - ldr r0, _0800A7F0 @ =0x80000400\n\ - str r0, [r1, #8]\n\ - ldr r0, [r1, #8]\n\ - strh r6, [r5, #0xc]\n\ - strh r6, [r5, #0xe]\n\ - movs r2, #0xbb\n\ - lsls r2, r2, #2\n\ - adds r0, r4, r2\n\ - strh r6, [r0]\n\ - movs r1, #0\n\ - adds r2, #2\n\ - b _0800A818\n\ - .align 2, 0\n\ -_0800A7C8: .4byte gUnknown_0202ADA0\n\ -_0800A7CC: .4byte gUnknown_0202BF10\n\ -_0800A7D0: .4byte gUnknown_0201A450\n\ -_0800A7D4: .4byte 0x040000D4\n\ -_0800A7D8: .4byte gUnknown_0202BE70\n\ -_0800A7DC: .4byte 0x80000010\n\ -_0800A7E0: .4byte 0x05000040\n\ -_0800A7E4: .4byte gMain\n\ -_0800A7E8: .4byte gUnknown_03005C00\n\ -_0800A7EC: .4byte 0x0600E000\n\ -_0800A7F0: .4byte 0x80000400\n\ -_0800A7F4:\n\ - cmp r0, #4\n\ - bne _0800A81C\n\ - ldr r1, _0800A840 @ =0x040000D4\n\ - ldr r0, _0800A844 @ =gUnknown_0201B180\n\ - str r0, [r1]\n\ - ldr r0, _0800A848 @ =0x0600E000\n\ - str r0, [r1, #4]\n\ - ldr r0, _0800A84C @ =0x80000400\n\ - str r0, [r1, #8]\n\ - ldr r0, [r1, #8]\n\ - strh r6, [r5, #0xc]\n\ - strh r6, [r5, #0xe]\n\ - movs r1, #0xbb\n\ - lsls r1, r1, #2\n\ - adds r0, r4, r1\n\ - strh r6, [r0]\n\ - movs r1, #0\n\ - ldr r2, _0800A850 @ =0x000002EE\n\ -_0800A818:\n\ - adds r0, r4, r2\n\ - strh r1, [r0]\n\ -_0800A81C:\n\ - ldr r1, _0800A854 @ =gUnknown_0202ADA0\n\ - ldrh r0, [r1, #0x20]\n\ - adds r0, #1\n\ - strh r0, [r1, #0x20]\n\ - lsls r0, r0, #0x10\n\ - asrs r0, r0, #0x10\n\ - cmp r0, #0x1d\n\ - ble _0800A838\n\ - movs r0, #0\n\ - strh r0, [r1, #0x20]\n\ - ldr r1, _0800A858 @ =gUnknown_0202C790\n\ - ldrb r0, [r1]\n\ - adds r0, #2\n\ - strb r0, [r1]\n\ -_0800A838:\n\ - pop {r4, r5, r6}\n\ - pop {r0}\n\ - bx r0\n\ - .align 2, 0\n\ -_0800A840: .4byte 0x040000D4\n\ -_0800A844: .4byte gUnknown_0201B180\n\ -_0800A848: .4byte 0x0600E000\n\ -_0800A84C: .4byte 0x80000400\n\ -_0800A850: .4byte 0x000002EE\n\ -_0800A854: .4byte gUnknown_0202ADA0\n\ -_0800A858: .4byte gUnknown_0202C790"); -} -#endif void nullsub_8(void) { From 8c66d8b779befb0efd1817abf5960f8881a7eb2e Mon Sep 17 00:00:00 2001 From: WhenGryphonsFly <84215159+WhenGryphonsFly@users.noreply.github.com> Date: Fri, 2 Feb 2024 18:17:37 -0600 Subject: [PATCH 2/4] Decompile sub_A860 --- asm/intro.s | 14 -------------- src/intro.c | 7 +++++++ 2 files changed, 7 insertions(+), 14 deletions(-) diff --git a/asm/intro.s b/asm/intro.s index c475ab8..26ae1d3 100644 --- a/asm/intro.s +++ b/asm/intro.s @@ -4,20 +4,6 @@ .text - thumb_func_start sub_A860 -sub_A860: @ 0x0800A860 - push {lr} - bl sub_10480 - bl sub_10544 - ldr r1, _0800A878 @ =gUnknown_0202C790 - ldrb r0, [r1] - adds r0, #1 - strb r0, [r1] - pop {r0} - bx r0 - .align 2, 0 -_0800A878: .4byte gUnknown_0202C790 - thumb_func_start sub_A87C sub_A87C: @ 0x0800A87C push {r4, r5, r6, r7, lr} diff --git a/src/intro.c b/src/intro.c index ffaa871..aaa5d3e 100644 --- a/src/intro.c +++ b/src/intro.c @@ -1215,3 +1215,10 @@ void sub_A710(void) void nullsub_8(void) { } + +void sub_A860(void) +{ + sub_10480(); + sub_10544(); + gUnknown_0202C790++; +} From 244c1ee27d0faae0c59387d9ea84297ead0e5ef5 Mon Sep 17 00:00:00 2001 From: WhenGryphonsFly <84215159+WhenGryphonsFly@users.noreply.github.com> Date: Sat, 10 Feb 2024 17:09:50 -0600 Subject: [PATCH 3/4] Decompile sub_A87C through sub_AC20 --- asm/intro.s | 455 -------------------------------------------- include/variables.h | 7 + src/intro.c | 156 +++++++++++++++ 3 files changed, 163 insertions(+), 455 deletions(-) diff --git a/asm/intro.s b/asm/intro.s index 26ae1d3..67cf176 100644 --- a/asm/intro.s +++ b/asm/intro.s @@ -4,461 +4,6 @@ .text - thumb_func_start sub_A87C -sub_A87C: @ 0x0800A87C - push {r4, r5, r6, r7, lr} - mov r7, r8 - push {r7} - ldr r4, _0800A92C @ =gMain - ldrh r0, [r4, #0x38] - ldr r0, _0800A930 @ =0x00001F50 - strh r0, [r4, #0x38] - ldrh r0, [r4, #0x3a] - ldr r0, _0800A934 @ =0x00000808 - strh r0, [r4, #0x3a] - ldr r1, _0800A938 @ =0x04000050 - ldrh r0, [r4, #0x38] - strh r0, [r1] - adds r1, #2 - ldrh r0, [r4, #0x3a] - strh r0, [r1] - movs r0, #0xbe - lsls r0, r0, #2 - adds r5, r4, r0 - movs r0, #1 - strh r0, [r5] - ldr r0, _0800A93C @ =gUnknown_086A795C - movs r1, #1 - adds r2, r5, #0 - bl LoadSpriteSets - ldrh r0, [r5] - cmp r0, #1 - bne _0800A91C - ldr r0, _0800A940 @ =gUnknown_0201A450 - ldrh r1, [r0] - strh r1, [r5, #2] - ldrh r0, [r0, #2] - strh r0, [r5, #4] - ldr r7, _0800A944 @ =gOamBuffer - movs r2, #0xd - rsbs r2, r2, #0 - mov r8, r2 - ldr r0, _0800A948 @ =0xFFFFFE00 - mov ip, r0 - movs r2, #0xc0 - lsls r2, r2, #2 - adds r4, r4, r2 - movs r6, #3 -_0800A8D4: - ldrh r2, [r4] - lsls r2, r2, #3 - adds r2, r2, r7 - ldrb r1, [r2, #5] - mov r0, r8 - ands r0, r1 - movs r1, #4 - orrs r0, r1 - strb r0, [r2, #5] - ldrh r3, [r4] - lsls r3, r3, #3 - adds r3, r3, r7 - movs r0, #2 - ldrsh r1, [r4, r0] - movs r2, #2 - ldrsh r0, [r5, r2] - adds r1, r1, r0 - ldr r2, _0800A94C @ =0x000001FF - adds r0, r2, #0 - ands r1, r0 - ldrh r2, [r3, #2] - mov r0, ip - ands r0, r2 - orrs r0, r1 - strh r0, [r3, #2] - ldrh r1, [r4] - lsls r1, r1, #3 - adds r1, r1, r7 - ldrb r0, [r5, #4] - ldrb r2, [r4, #4] - adds r0, r0, r2 - strb r0, [r1] - adds r4, #8 - subs r6, #1 - cmp r6, #0 - bge _0800A8D4 -_0800A91C: - movs r0, #0 - strh r0, [r5] - pop {r3} - mov r8, r3 - pop {r4, r5, r6, r7} - pop {r0} - bx r0 - .align 2, 0 -_0800A92C: .4byte gMain -_0800A930: .4byte 0x00001F50 -_0800A934: .4byte 0x00000808 -_0800A938: .4byte 0x04000050 -_0800A93C: .4byte gUnknown_086A795C -_0800A940: .4byte gUnknown_0201A450 -_0800A944: .4byte gOamBuffer -_0800A948: .4byte 0xFFFFFE00 -_0800A94C: .4byte 0x000001FF - - thumb_func_start sub_A950 -sub_A950: @ 0x0800A950 - push {lr} - bl sub_0518 - ldr r1, _0800A964 @ =gUnknown_0202C790 - ldrb r0, [r1] - adds r0, #1 - strb r0, [r1] - pop {r0} - bx r0 - .align 2, 0 -_0800A964: .4byte gUnknown_0202C790 - - thumb_func_start sub_A968 -sub_A968: @ 0x0800A968 - push {r4, lr} - movs r2, #0x80 - lsls r2, r2, #0x13 - movs r0, #0 - strh r0, [r2] - ldr r1, _0800AA50 @ =0x04000008 - movs r3, #0xcc - lsls r3, r3, #8 - adds r0, r3, #0 - strh r0, [r1] - ldrh r0, [r2] - movs r3, #0x80 - lsls r3, r3, #1 - adds r1, r3, #0 - orrs r0, r1 - strh r0, [r2] - ldr r1, _0800AA54 @ =0x0400000A - ldr r3, _0800AA58 @ =0x0000DA01 - adds r0, r3, #0 - strh r0, [r1] - ldrh r0, [r2] - movs r3, #0x80 - lsls r3, r3, #2 - adds r1, r3, #0 - orrs r0, r1 - strh r0, [r2] - ldr r1, _0800AA5C @ =0x0400000E - ldr r3, _0800AA60 @ =0x00001E03 - adds r0, r3, #0 - strh r0, [r1] - ldrh r0, [r2] - movs r3, #0x80 - lsls r3, r3, #4 - adds r1, r3, #0 - orrs r0, r1 - strh r0, [r2] - ldr r0, _0800AA64 @ =0x040000D4 - ldr r1, _0800AA68 @ =gUnknown_080E5F60 - str r1, [r0] - ldr r1, _0800AA6C @ =0x06006000 - str r1, [r0, #4] - ldr r3, _0800AA70 @ =0x80001000 - str r3, [r0, #8] - ldr r1, [r0, #8] - ldr r1, _0800AA74 @ =gUnknown_080E7F60 - str r1, [r0] - ldr r1, _0800AA78 @ =0x0600D000 - str r1, [r0, #4] - str r3, [r0, #8] - ldr r1, [r0, #8] - ldr r1, _0800AA7C @ =gUnknown_080E1740 - str r1, [r0] - ldr r1, _0800AA80 @ =0x0600F000 - str r1, [r0, #4] - ldr r1, _0800AA84 @ =0x80000400 - str r1, [r0, #8] - ldr r1, [r0, #8] - ldr r1, _0800AA88 @ =gUnknown_080E1F40 - str r1, [r0] - movs r1, #0xc0 - lsls r1, r1, #0x13 - str r1, [r0, #4] - ldr r1, _0800AA8C @ =0x80002000 - str r1, [r0, #8] - ldr r1, [r0, #8] - ldr r1, _0800AA90 @ =gUnknown_080E1540 - str r1, [r0] - movs r1, #0xa0 - lsls r1, r1, #0x13 - str r1, [r0, #4] - ldr r1, _0800AA94 @ =0x80000030 - str r1, [r0, #8] - ldr r0, [r0, #8] - ldr r4, _0800AA98 @ =gMain - ldrh r0, [r2] - strh r0, [r4, #0x16] - bl sub_AAA8 - ldr r2, _0800AA9C @ =gUnknown_0202ADA0 - ldrh r1, [r2] - movs r3, #0xba - lsls r3, r3, #2 - adds r0, r4, r3 - strh r1, [r0] - ldrh r1, [r2, #2] - adds r3, #2 - adds r0, r4, r3 - strh r1, [r0] - ldrh r1, [r2, #0xc] - adds r3, #2 - adds r0, r4, r3 - strh r1, [r0] - ldrh r1, [r2, #0xe] - adds r3, #2 - adds r0, r4, r3 - strh r1, [r0] - ldrh r1, [r2, #0x18] - adds r3, #6 - adds r0, r4, r3 - strh r1, [r0] - ldrh r0, [r2, #0x1a] - ldr r1, _0800AAA0 @ =0x000002F6 - adds r4, r4, r1 - strh r0, [r4] - bl sub_0CBC - bl sub_10424 - ldr r1, _0800AAA4 @ =gUnknown_0202C790 - ldrb r0, [r1] - adds r0, #2 - strb r0, [r1] - pop {r4} - pop {r0} - bx r0 - .align 2, 0 -_0800AA50: .4byte 0x04000008 -_0800AA54: .4byte 0x0400000A -_0800AA58: .4byte 0x0000DA01 -_0800AA5C: .4byte 0x0400000E -_0800AA60: .4byte 0x00001E03 -_0800AA64: .4byte 0x040000D4 -_0800AA68: .4byte gUnknown_080E5F60 -_0800AA6C: .4byte 0x06006000 -_0800AA70: .4byte 0x80001000 -_0800AA74: .4byte gUnknown_080E7F60 -_0800AA78: .4byte 0x0600D000 -_0800AA7C: .4byte gUnknown_080E1740 -_0800AA80: .4byte 0x0600F000 -_0800AA84: .4byte 0x80000400 -_0800AA88: .4byte gUnknown_080E1F40 -_0800AA8C: .4byte 0x80002000 -_0800AA90: .4byte gUnknown_080E1540 -_0800AA94: .4byte 0x80000030 -_0800AA98: .4byte gMain -_0800AA9C: .4byte gUnknown_0202ADA0 -_0800AAA0: .4byte 0x000002F6 -_0800AAA4: .4byte gUnknown_0202C790 - - thumb_func_start sub_AAA8 -sub_AAA8: @ 0x0800AAA8 - ldr r0, _0800AAD8 @ =gUnknown_0202ADA0 - movs r2, #0 - movs r1, #0x1c - strh r1, [r0] - ldr r1, _0800AADC @ =0x0000FF20 - strh r1, [r0, #2] - strh r2, [r0, #4] - movs r1, #0xf - strh r1, [r0, #6] - ldr r1, _0800AAE0 @ =0x0000FF64 - strh r1, [r0, #0xc] - movs r1, #0xe0 - strh r1, [r0, #0xe] - strh r2, [r0, #0x10] - ldr r1, _0800AAE4 @ =0x0000FFF1 - strh r1, [r0, #0x12] - strh r2, [r0, #0x18] - strh r2, [r0, #0x1a] - strh r2, [r0, #0x20] - ldr r0, _0800AAE8 @ =gUnknown_0202BF10 - strh r2, [r0] - ldr r0, _0800AAEC @ =gUnknown_0202A578 - strh r2, [r0] - bx lr - .align 2, 0 -_0800AAD8: .4byte gUnknown_0202ADA0 -_0800AADC: .4byte 0x0000FF20 -_0800AAE0: .4byte 0x0000FF64 -_0800AAE4: .4byte 0x0000FFF1 -_0800AAE8: .4byte gUnknown_0202BF10 -_0800AAEC: .4byte gUnknown_0202A578 - - thumb_func_start nullsub_9 -nullsub_9: @ 0x0800AAF0 - bx lr - - thumb_func_start sub_AAF4 -sub_AAF4: @ 0x0800AAF4 - push {r4, lr} - ldr r3, _0800AB7C @ =gUnknown_0202ADA0 - ldrh r4, [r3, #6] - ldrh r1, [r3, #2] - adds r0, r4, r1 - strh r0, [r3, #2] - ldrh r2, [r3, #0x12] - ldrh r1, [r3, #0xe] - adds r0, r2, r1 - strh r0, [r3, #0xe] - ldrh r0, [r3, #0x18] - subs r0, #1 - strh r0, [r3, #0x18] - ldrh r0, [r3] - subs r0, #1 - strh r0, [r3] - ldrh r0, [r3, #0xc] - adds r0, #1 - strh r0, [r3, #0xc] - ldr r0, _0800AB80 @ =gUnknown_0202BF10 - ldrh r0, [r0] - movs r1, #1 - ands r0, r1 - cmp r0, #0 - bne _0800AB2E - subs r0, r4, #1 - strh r0, [r3, #6] - adds r0, r2, #1 - strh r0, [r3, #0x12] -_0800AB2E: - ldr r1, _0800AB84 @ =gMain - ldrh r2, [r3] - movs r4, #0xba - lsls r4, r4, #2 - adds r0, r1, r4 - strh r2, [r0] - ldrh r2, [r3, #2] - adds r4, #2 - adds r0, r1, r4 - strh r2, [r0] - ldrh r2, [r3, #0xc] - adds r4, #2 - adds r0, r1, r4 - strh r2, [r0] - ldrh r2, [r3, #0xe] - adds r4, #2 - adds r0, r1, r4 - strh r2, [r0] - ldrh r0, [r3, #0x18] - movs r2, #0xbd - lsls r2, r2, #2 - adds r1, r1, r2 - strh r0, [r1] - ldrh r0, [r3, #0x20] - adds r0, #1 - strh r0, [r3, #0x20] - lsls r0, r0, #0x10 - asrs r0, r0, #0x10 - cmp r0, #0x27 - ble _0800AB76 - movs r0, #0 - strh r0, [r3, #0x20] - ldr r1, _0800AB88 @ =gUnknown_0202C790 - ldrb r0, [r1] - adds r0, #2 - strb r0, [r1] -_0800AB76: - pop {r4} - pop {r0} - bx r0 - .align 2, 0 -_0800AB7C: .4byte gUnknown_0202ADA0 -_0800AB80: .4byte gUnknown_0202BF10 -_0800AB84: .4byte gMain -_0800AB88: .4byte gUnknown_0202C790 - - thumb_func_start nullsub_10 -nullsub_10: @ 0x0800AB8C - bx lr - - thumb_func_start sub_AB90 -sub_AB90: @ 0x0800AB8E - push {r4, lr} - ldr r3, _0800AC10 @ =gUnknown_0202ADA0 - ldrh r4, [r3, #6] - ldrh r1, [r3, #2] - adds r0, r4, r1 - strh r0, [r3, #2] - ldrh r2, [r3, #0x12] - ldrh r1, [r3, #0xe] - adds r0, r2, r1 - strh r0, [r3, #0xe] - ldrh r0, [r3, #0x18] - subs r0, #1 - strh r0, [r3, #0x18] - ldrh r0, [r3] - subs r0, #1 - strh r0, [r3] - ldrh r0, [r3, #0xc] - adds r0, #1 - strh r0, [r3, #0xc] - ldr r0, _0800AC14 @ =gUnknown_0202BF10 - ldrh r0, [r0] - movs r1, #1 - ands r0, r1 - cmp r0, #0 - bne _0800ABCA - subs r0, r4, #1 - strh r0, [r3, #6] - adds r0, r2, #1 - strh r0, [r3, #0x12] -_0800ABCA: - ldr r1, _0800AC18 @ =gMain - ldrh r2, [r3] - movs r4, #0xba - lsls r4, r4, #2 - adds r0, r1, r4 - strh r2, [r0] - ldrh r2, [r3, #2] - adds r4, #2 - adds r0, r1, r4 - strh r2, [r0] - ldrh r2, [r3, #0xc] - adds r4, #2 - adds r0, r1, r4 - strh r2, [r0] - ldrh r2, [r3, #0xe] - adds r4, #2 - adds r0, r1, r4 - strh r2, [r0] - ldrh r0, [r3, #0x18] - movs r2, #0xbd - lsls r2, r2, #2 - adds r1, r1, r2 - strh r0, [r1] - bl sub_10480 - bl sub_10544 - ldr r1, _0800AC1C @ =gUnknown_0202C790 - ldrb r0, [r1] - adds r0, #1 - strb r0, [r1] - pop {r4} - pop {r0} - bx r0 - .align 2, 0 -_0800AC10: .4byte gUnknown_0202ADA0 -_0800AC14: .4byte gUnknown_0202BF10 -_0800AC18: .4byte gMain -_0800AC1C: .4byte gUnknown_0202C790 - - thumb_func_start sub_AC20 -sub_AC20: @ 0x0800AC20 - push {lr} - bl sub_0518 - ldr r1, _0800AC34 @ =gUnknown_0202C790 - ldrb r0, [r1] - adds r0, #1 - strb r0, [r1] - pop {r0} - bx r0 - .align 2, 0 -_0800AC34: .4byte gUnknown_0202C790 - thumb_func_start sub_AC38 sub_AC38: @ 0x0800AC38 push {r4, lr} diff --git a/include/variables.h b/include/variables.h index 68449ec..0e00736 100644 --- a/include/variables.h +++ b/include/variables.h @@ -276,4 +276,11 @@ extern struct SpriteGroup gUnknown_0200D078[]; extern struct UnkStruct_086A7768 gUnknown_086A7798[0x4]; extern s32 gUnknown_0201C188; +extern const struct SpriteSet *const gUnknown_086A795C[]; +extern u8 gUnknown_080E1540[]; +extern u8 gUnknown_080E1740[]; +extern u8 gUnknown_080E1F40[]; +extern u8 gUnknown_080E5F60[]; +extern u8 gUnknown_080E7F60[]; + #endif // GUARD_VARIABLES_H diff --git a/src/intro.c b/src/intro.c index aaa5d3e..bbe68d5 100644 --- a/src/intro.c +++ b/src/intro.c @@ -9,6 +9,7 @@ extern void sub_10170(u8 *, u32, u32, u32); void sub_FEB8(u32, u8 *, u32); void sub_A628(void); void sub_A87C(void); +void sub_AAA8(void); extern StateFunc gIntroStateFuncs[15]; extern u8 gUnknown_080798C0[]; @@ -1222,3 +1223,158 @@ void sub_A860(void) sub_10544(); gUnknown_0202C790++; } + +void sub_A87C(void) +{ + s32 i; + struct SpriteGroup *puVar4; + struct OamDataSimple *puVar2; + + gMain.blendControl = 0x1F50; + gMain.blendAlpha = 0x808; + REG_BLDCNT = gMain.blendControl; + REG_BLDALPHA = gMain.blendAlpha; + + puVar4 = &gMain.spriteGroups[0]; + puVar4->available = 1; + LoadSpriteSets(gUnknown_086A795C, 0x1, puVar4); + + if (puVar4->available == 1) + { + puVar4->baseX = gUnknown_0201A450.unk0; + puVar4->baseY = gUnknown_0201A450.unk2; + + for (i = 0; i < 4; i++) + { + puVar2 = &puVar4->oam[i]; + gOamBuffer[puVar2->oamId].priority = 1; + gOamBuffer[puVar2->oamId].x = puVar2->xOffset + puVar4->baseX; + gOamBuffer[puVar2->oamId].y = puVar2->yOffset + puVar4->baseY; + } + } + puVar4->available = 0; +} + +void sub_A950(void) +{ + sub_0518(); + gUnknown_0202C790++; +} + +void sub_A968(void) +{ + // TODO use proper constants - see LoadEReaderGraphics? + REG_DISPCNT = 0; + REG_BG0CNT = 0xCC00; + REG_DISPCNT |= 0x100; + REG_BG1CNT = 0xDA01; + REG_DISPCNT |= 0x200; + REG_BG3CNT = 0x1E03; + REG_DISPCNT |= 0x800; + + DmaCopy16(3, gUnknown_080E5F60, (void *) 0x6006000, 0x2000); + DmaCopy16(3, gUnknown_080E7F60, (void *) 0x600D000, 0x2000); + DmaCopy16(3, gUnknown_080E1740, (void *) 0x600F000, 0x800); + DmaCopy16(3, gUnknown_080E1F40, (void *) 0x6000000, 0x4000); + DmaCopy16(3, gUnknown_080E1540, PLTT, 0x60); + gMain.unk16 = REG_DISPCNT; + + sub_AAA8(); + gMain.unk2E8[0].unk0 = gUnknown_0202ADA0[0x0]; + gMain.unk2E8[0].unk2 = gUnknown_0202ADA0[0x1]; + gMain.unk2E8[1].unk0 = gUnknown_0202ADA0[0x6]; + gMain.unk2E8[1].unk2 = gUnknown_0202ADA0[0x7]; + gMain.unk2E8[3].unk0 = gUnknown_0202ADA0[0xC]; + gMain.unk2E8[3].unk2 = gUnknown_0202ADA0[0xD]; + + sub_0CBC(); + sub_10424(); + gUnknown_0202C790 += 2; +} + +void sub_AAA8(void) +{ + gUnknown_0202ADA0[0x0] = 0x1C; + gUnknown_0202ADA0[0x1] = 0xFF20; + gUnknown_0202ADA0[0x2] = 0; + gUnknown_0202ADA0[0x3] = 0xF; + gUnknown_0202ADA0[0x6] = 0xFF64; + gUnknown_0202ADA0[0x7] = 0xE0; + gUnknown_0202ADA0[0x8] = 0; + gUnknown_0202ADA0[0x9] = 0xFFF1; + gUnknown_0202ADA0[0xC] = 0; + gUnknown_0202ADA0[0xD] = 0; + gUnknown_0202ADA0[0x10] = 0; + + gUnknown_0202BF10 = 0; + gUnknown_0202A578 = 0; +} + +void nullsub_9(void) +{ +} + +void sub_AAF4(void) +{ + gUnknown_0202ADA0[0x1] += gUnknown_0202ADA0[0x3]; + gUnknown_0202ADA0[0x7] += gUnknown_0202ADA0[0x9]; + gUnknown_0202ADA0[0xC]--; + gUnknown_0202ADA0[0x0]--; + gUnknown_0202ADA0[0x6]++; + + if (gUnknown_0202BF10 % 2 == 0) + { + gUnknown_0202ADA0[0x3]--; + gUnknown_0202ADA0[0x9]++; + } + + gMain.unk2E8[0].unk0 = gUnknown_0202ADA0[0x0]; + gMain.unk2E8[0].unk2 = gUnknown_0202ADA0[0x1]; + gMain.unk2E8[1].unk0 = gUnknown_0202ADA0[0x6]; + gMain.unk2E8[1].unk2 = gUnknown_0202ADA0[0x7]; + gMain.unk2E8[3].unk0 = gUnknown_0202ADA0[0xC]; + + gUnknown_0202ADA0[0x10]++; + if (0x27 < gUnknown_0202ADA0[0x10]) + { + gUnknown_0202ADA0[0x10] = 0; + gUnknown_0202C790 += 2; + } +} + +void nullsub_10(void) +{ +} + +void sub_AB90(void) +{ + // TODO Near duplicate of sub_AAF4 + gUnknown_0202ADA0[0x1] += gUnknown_0202ADA0[0x3]; + gUnknown_0202ADA0[0x7] += gUnknown_0202ADA0[0x9]; + gUnknown_0202ADA0[0xC]--; + gUnknown_0202ADA0[0x0]--; + gUnknown_0202ADA0[0x6]++; + + if (gUnknown_0202BF10 % 2 == 0) + { + gUnknown_0202ADA0[0x3]--; + gUnknown_0202ADA0[0x9]++; + } + + gMain.unk2E8[0].unk0 = gUnknown_0202ADA0[0x0]; + gMain.unk2E8[0].unk2 = gUnknown_0202ADA0[0x1]; + gMain.unk2E8[1].unk0 = gUnknown_0202ADA0[0x6]; + gMain.unk2E8[1].unk2 = gUnknown_0202ADA0[0x7]; + gMain.unk2E8[3].unk0 = gUnknown_0202ADA0[0xC]; + + sub_10480(); + sub_10544(); + gUnknown_0202C790++; +} + +void sub_AC20(void) +{ + // TODO Duplicate of sub_A950? + sub_0518(); + gUnknown_0202C790++; +} From 935e229308e143ee26e0be4c31bddb27596d1eb9 Mon Sep 17 00:00:00 2001 From: WhenGryphonsFly <84215159+WhenGryphonsFly@users.noreply.github.com> Date: Sat, 10 Feb 2024 19:08:24 -0600 Subject: [PATCH 4/4] Decompile sub_AC38, sub_ADFC, and sub_AE74 --- asm/intro.s | 376 -------------------------------------------- include/variables.h | 13 +- src/ereader.c | 2 +- src/intro.c | 112 +++++++++++++ 4 files changed, 125 insertions(+), 378 deletions(-) diff --git a/asm/intro.s b/asm/intro.s index 67cf176..440bf5f 100644 --- a/asm/intro.s +++ b/asm/intro.s @@ -4,382 +4,6 @@ .text - thumb_func_start sub_AC38 -sub_AC38: @ 0x0800AC38 - push {r4, lr} - movs r2, #0x80 - lsls r2, r2, #0x13 - movs r1, #0x80 - lsls r1, r1, #5 - adds r0, r1, #0 - strh r0, [r2] - ldr r1, _0800AD78 @ =0x04000008 - movs r3, #0xc0 - lsls r3, r3, #4 - adds r0, r3, #0 - strh r0, [r1] - ldrh r0, [r2] - movs r4, #0x80 - lsls r4, r4, #1 - adds r1, r4, #0 - orrs r0, r1 - strh r0, [r2] - ldr r1, _0800AD7C @ =0x0400000A - ldr r3, _0800AD80 @ =0x00004E01 - adds r0, r3, #0 - strh r0, [r1] - ldrh r0, [r2] - movs r4, #0x80 - lsls r4, r4, #2 - adds r1, r4, #0 - orrs r0, r1 - strh r0, [r2] - ldr r1, _0800AD84 @ =0x0400000C - ldr r3, _0800AD88 @ =0x00005C02 - adds r0, r3, #0 - strh r0, [r1] - ldrh r0, [r2] - movs r4, #0x80 - lsls r4, r4, #3 - adds r1, r4, #0 - orrs r0, r1 - strh r0, [r2] - ldr r1, _0800AD8C @ =0x0400000E - ldr r3, _0800AD90 @ =0x00001E03 - adds r0, r3, #0 - strh r0, [r1] - ldrh r0, [r2] - movs r4, #0x80 - lsls r4, r4, #4 - adds r1, r4, #0 - orrs r0, r1 - strh r0, [r2] - ldr r0, _0800AD94 @ =0x040000D4 - ldr r1, _0800AD98 @ =gUnknown_080F1980 - str r1, [r0] - ldr r1, _0800AD9C @ =0x06006000 - str r1, [r0, #4] - ldr r3, _0800ADA0 @ =0x80000400 - str r3, [r0, #8] - ldr r1, [r0, #8] - ldr r1, _0800ADA4 @ =gUnknown_080EB160 - str r1, [r0] - ldr r1, _0800ADA8 @ =0x06007000 - str r1, [r0, #4] - ldr r2, _0800ADAC @ =0x80000800 - str r2, [r0, #8] - ldr r1, [r0, #8] - ldr r1, _0800ADB0 @ =gUnknown_080EA160 - str r1, [r0] - ldr r1, _0800ADB4 @ =0x0600E000 - str r1, [r0, #4] - str r2, [r0, #8] - ldr r1, [r0, #8] - ldr r1, _0800ADB8 @ =gUnknown_080EC160 - str r1, [r0] - ldr r1, _0800ADBC @ =0x0600F000 - str r1, [r0, #4] - str r3, [r0, #8] - ldr r1, [r0, #8] - ldr r1, _0800ADC0 @ =gUnknown_080EC960 - str r1, [r0] - movs r1, #0xc0 - lsls r1, r1, #0x13 - str r1, [r0, #4] - ldr r1, _0800ADC4 @ =0x80001400 - str r1, [r0, #8] - ldr r1, [r0, #8] - ldr r1, _0800ADC8 @ =gUnknown_080BD4C0 - str r1, [r0] - ldr r1, _0800ADCC @ =gUnknown_03000000 - str r1, [r0, #4] - ldr r1, _0800ADD0 @ =0x80002000 - str r1, [r0, #8] - ldr r1, [r0, #8] - ldr r3, _0800ADD4 @ =gUnknown_080E9F60 - str r3, [r0] - movs r1, #0xa0 - lsls r1, r1, #0x13 - str r1, [r0, #4] - ldr r2, _0800ADD8 @ =0x800000C0 - str r2, [r0, #8] - ldr r1, [r0, #8] - ldr r1, _0800ADDC @ =gUnknown_080F2180 - str r1, [r0] - ldr r1, _0800ADE0 @ =0x06010000 - str r1, [r0, #4] - ldr r1, _0800ADE4 @ =0x80001800 - str r1, [r0, #8] - ldr r1, [r0, #8] - str r3, [r0] - ldr r1, _0800ADE8 @ =0x05000200 - str r1, [r0, #4] - str r2, [r0, #8] - ldr r0, [r0, #8] - bl sub_ADFC - bl sub_B0E8 - ldr r1, _0800ADEC @ =gMain - ldr r2, _0800ADF0 @ =gUnknown_0202ADA0 - ldrh r3, [r2] - movs r4, #0xba - lsls r4, r4, #2 - adds r0, r1, r4 - strh r3, [r0] - ldrh r3, [r2, #2] - adds r4, #2 - adds r0, r1, r4 - strh r3, [r0] - ldrh r3, [r2, #0xc] - adds r4, #2 - adds r0, r1, r4 - strh r3, [r0] - ldrh r3, [r2, #0xe] - adds r4, #2 - adds r0, r1, r4 - strh r3, [r0] - ldrh r3, [r2, #0x18] - adds r4, #2 - adds r0, r1, r4 - strh r3, [r0] - ldrh r3, [r2, #0x1a] - adds r4, #2 - adds r0, r1, r4 - strh r3, [r0] - ldrh r3, [r2, #0x24] - adds r4, #2 - adds r0, r1, r4 - strh r3, [r0] - ldrh r0, [r2, #0x26] - ldr r2, _0800ADF4 @ =0x000002F6 - adds r1, r1, r2 - strh r0, [r1] - bl sub_0CBC - bl sub_10424 - ldr r1, _0800ADF8 @ =gUnknown_0202C790 - ldrb r0, [r1] - adds r0, #1 - strb r0, [r1] - pop {r4} - pop {r0} - bx r0 - .align 2, 0 -_0800AD78: .4byte 0x04000008 -_0800AD7C: .4byte 0x0400000A -_0800AD80: .4byte 0x00004E01 -_0800AD84: .4byte 0x0400000C -_0800AD88: .4byte 0x00005C02 -_0800AD8C: .4byte 0x0400000E -_0800AD90: .4byte 0x00001E03 -_0800AD94: .4byte 0x040000D4 -_0800AD98: .4byte gUnknown_080F1980 -_0800AD9C: .4byte 0x06006000 -_0800ADA0: .4byte 0x80000400 -_0800ADA4: .4byte gUnknown_080EB160 -_0800ADA8: .4byte 0x06007000 -_0800ADAC: .4byte 0x80000800 -_0800ADB0: .4byte gUnknown_080EA160 -_0800ADB4: .4byte 0x0600E000 -_0800ADB8: .4byte gUnknown_080EC160 -_0800ADBC: .4byte 0x0600F000 -_0800ADC0: .4byte gUnknown_080EC960 -_0800ADC4: .4byte 0x80001400 -_0800ADC8: .4byte gUnknown_080BD4C0 -_0800ADCC: .4byte gUnknown_03000000 -_0800ADD0: .4byte 0x80002000 -_0800ADD4: .4byte gUnknown_080E9F60 -_0800ADD8: .4byte 0x800000C0 -_0800ADDC: .4byte gUnknown_080F2180 -_0800ADE0: .4byte 0x06010000 -_0800ADE4: .4byte 0x80001800 -_0800ADE8: .4byte 0x05000200 -_0800ADEC: .4byte gMain -_0800ADF0: .4byte gUnknown_0202ADA0 -_0800ADF4: .4byte 0x000002F6 -_0800ADF8: .4byte gUnknown_0202C790 - - thumb_func_start sub_ADFC -sub_ADFC: @ 0x0800ADFC - push {r4, r5, lr} - ldr r1, _0800AE54 @ =gUnknown_0201A450 - movs r5, #0 - movs r2, #0xb4 - strh r2, [r1, #0x10] - ldr r0, _0800AE58 @ =0x0000FFBC - strh r0, [r1, #0x12] - strh r2, [r1] - strh r0, [r1, #2] - movs r0, #0x80 - strh r0, [r1, #0x20] - movs r0, #0x88 - strh r0, [r1, #0x22] - ldr r4, _0800AE5C @ =gUnknown_0202ADA0 - ldr r0, _0800AE60 @ =0x0000FF58 - strh r0, [r4] - adds r0, #0x40 - strh r0, [r4, #2] - strh r5, [r4, #8] - strh r5, [r4, #0xa] - strh r5, [r4, #4] - ldr r0, _0800AE64 @ =gUnknown_03002300 - ldr r1, _0800AE68 @ =0x06002EE0 - movs r2, #8 - movs r3, #8 - bl sub_10708 - movs r0, #0xa5 - strh r0, [r4, #0xc] - strh r5, [r4, #0xe] - strh r5, [r4, #0x14] - movs r0, #0xa0 - strh r0, [r4, #0x18] - strh r5, [r4, #0x1a] - strh r5, [r4, #0x20] - strh r5, [r4, #0x24] - strh r5, [r4, #0x26] - ldr r0, _0800AE6C @ =gUnknown_0202BF10 - strh r5, [r0] - ldr r0, _0800AE70 @ =gUnknown_0202A578 - strh r5, [r0] - pop {r4, r5} - pop {r0} - bx r0 - .align 2, 0 -_0800AE54: .4byte gUnknown_0201A450 -_0800AE58: .4byte 0x0000FFBC -_0800AE5C: .4byte gUnknown_0202ADA0 -_0800AE60: .4byte 0x0000FF58 -_0800AE64: .4byte gUnknown_03002300 -_0800AE68: .4byte 0x06002EE0 -_0800AE6C: .4byte gUnknown_0202BF10 -_0800AE70: .4byte gUnknown_0202A578 - - thumb_func_start sub_AE74 -sub_AE74: @ 0x0800AE74 - push {r4, lr} - ldr r1, _0800AF5C @ =gUnknown_0201A450 - ldrh r0, [r1, #0x10] - subs r0, #0x10 - strh r0, [r1, #0x10] - ldrh r0, [r1, #0x12] - adds r0, #0xa - strh r0, [r1, #0x12] - ldrh r0, [r1] - subs r0, #0x10 - strh r0, [r1] - ldrh r0, [r1, #2] - adds r0, #0xa - strh r0, [r1, #2] - ldrh r0, [r1, #0x20] - adds r0, #5 - strh r0, [r1, #0x20] - ldrh r0, [r1, #0x22] - subs r0, #3 - strh r0, [r1, #0x22] - ldr r4, _0800AF60 @ =gUnknown_0202ADA0 - ldrh r0, [r4, #0xc] - subs r0, #0x10 - strh r0, [r4, #0xc] - ldrh r0, [r4, #0xe] - adds r0, #1 - strh r0, [r4, #0xe] - ldrh r0, [r4, #0x18] - subs r0, #0x10 - strh r0, [r4, #0x18] - ldrh r1, [r4, #4] - ldrh r2, [r4] - adds r0, r1, r2 - strh r0, [r4] - ldrh r0, [r4, #2] - adds r0, #9 - strh r0, [r4, #2] - adds r1, #1 - strh r1, [r4, #4] - ldrh r0, [r4, #0xa] - adds r0, #1 - strh r0, [r4, #0xa] - ldr r2, _0800AF64 @ =gUnknown_086A79FC - movs r3, #8 - ldrsh r1, [r4, r3] - lsls r1, r1, #2 - adds r1, r1, r2 - lsls r0, r0, #0x10 - asrs r0, r0, #0x10 - movs r2, #2 - ldrsh r1, [r1, r2] - cmp r0, r1 - ble _0800AF02 - ldrh r0, [r4, #8] - adds r0, #1 - strh r0, [r4, #8] - ldr r1, _0800AF68 @ =gUnknown_086A7A1C - movs r3, #8 - ldrsh r0, [r4, r3] - lsls r0, r0, #1 - adds r0, r0, r1 - movs r1, #0 - ldrsh r0, [r0, r1] - lsls r0, r0, #1 - ldr r1, _0800AF6C @ =gUnknown_03000000 - adds r0, r0, r1 - ldr r1, _0800AF70 @ =0x06002EE0 - movs r2, #8 - movs r3, #8 - bl sub_10708 -_0800AF02: - bl sub_B0E8 - ldr r1, _0800AF74 @ =gMain - ldrh r2, [r4] - movs r3, #0xba - lsls r3, r3, #2 - adds r0, r1, r3 - strh r2, [r0] - ldrh r2, [r4, #2] - adds r3, #2 - adds r0, r1, r3 - strh r2, [r0] - ldrh r2, [r4, #0xc] - adds r3, #2 - adds r0, r1, r3 - strh r2, [r0] - ldrh r2, [r4, #0xe] - adds r3, #2 - adds r0, r1, r3 - strh r2, [r0] - ldrh r2, [r4, #0x18] - adds r3, #2 - adds r0, r1, r3 - strh r2, [r0] - ldrh r0, [r4, #0x1a] - ldr r2, _0800AF78 @ =0x000002F2 - adds r1, r1, r2 - strh r0, [r1] - ldrh r0, [r4, #0x20] - adds r0, #1 - strh r0, [r4, #0x20] - lsls r0, r0, #0x10 - asrs r0, r0, #0x10 - cmp r0, #9 - ble _0800AF54 - movs r0, #0 - strh r0, [r4, #0x20] - ldr r1, _0800AF7C @ =gUnknown_0202C790 - ldrb r0, [r1] - adds r0, #1 - strb r0, [r1] -_0800AF54: - pop {r4} - pop {r0} - bx r0 - .align 2, 0 -_0800AF5C: .4byte gUnknown_0201A450 -_0800AF60: .4byte gUnknown_0202ADA0 -_0800AF64: .4byte gUnknown_086A79FC -_0800AF68: .4byte gUnknown_086A7A1C -_0800AF6C: .4byte gUnknown_03000000 -_0800AF70: .4byte 0x06002EE0 -_0800AF74: .4byte gMain -_0800AF78: .4byte 0x000002F2 -_0800AF7C: .4byte gUnknown_0202C790 - thumb_func_start sub_AF80 sub_AF80: @ 0x0800AF80 push {r4, lr} diff --git a/include/variables.h b/include/variables.h index 0e00736..bba8cf8 100644 --- a/include/variables.h +++ b/include/variables.h @@ -20,7 +20,7 @@ extern u16 gUnknown_0201A520[]; extern u16 gUnknown_0201AD20[]; extern u32 gUnknown_0201A500[]; extern u16 gUnknown_0201A920[]; -extern u8 gUnknown_03000000[]; +extern u16 gUnknown_03000000[]; extern u8 gUnknown_03001800[3][0x800]; //extern ? gOamBuffer; //extern ? IntrMain_Buffer; @@ -283,4 +283,15 @@ extern u8 gUnknown_080E1F40[]; extern u8 gUnknown_080E5F60[]; extern u8 gUnknown_080E7F60[]; +extern u16 gUnknown_03002300[]; + +extern u8 gUnknown_080E9F60[]; +extern u8 gUnknown_080EA160[]; +extern u8 gUnknown_080EB160[]; +extern u8 gUnknown_080EC160[]; +extern u8 gUnknown_080EC960[]; +extern u8 gUnknown_080F1980[]; +extern u8 gUnknown_080F2180[]; +extern s16 gUnknown_086A7A1C[]; + #endif // GUARD_VARIABLES_H diff --git a/src/ereader.c b/src/ereader.c index bf1065e..781e638 100644 --- a/src/ereader.c +++ b/src/ereader.c @@ -42,7 +42,7 @@ extern u8 gUnknown_0807DD00[]; extern u8 gUnknown_0807D000[]; extern u8 gUnknown_08089960[]; extern u8 gUnknown_08089B60[]; -extern u8 gUnknown_03000000[]; +extern u16 gUnknown_03000000[]; extern u8 gUnknown_08080500[]; extern u8 gUnknown_080897E0[]; extern u8 gUnknown_0807FD00[]; diff --git a/src/intro.c b/src/intro.c index bbe68d5..a634614 100644 --- a/src/intro.c +++ b/src/intro.c @@ -10,6 +10,8 @@ void sub_FEB8(u32, u8 *, u32); void sub_A628(void); void sub_A87C(void); void sub_AAA8(void); +void sub_ADFC(void); +extern void sub_B0E8(void); extern StateFunc gIntroStateFuncs[15]; extern u8 gUnknown_080798C0[]; @@ -104,6 +106,7 @@ struct UnkStruct_086A7768 { extern struct UnkStruct_086A7768 gUnknown_086A7768[0x8]; extern struct UnkStruct_086A7768 gUnknown_086A7798[0x4]; +extern struct UnkStruct_086A7768 gUnknown_086A79FC[]; void IntroMain(void) { gIntroStateFuncs[gMain.subState](); @@ -1378,3 +1381,112 @@ void sub_AC20(void) sub_0518(); gUnknown_0202C790++; } + +void sub_AC38(void) +{ + // TODO use proper constants - see LoadEReaderGraphics? + REG_DISPCNT = 0x1000; + REG_BG0CNT = 0xC00; + REG_DISPCNT |= 0x100; + REG_BG1CNT = 0x4E01; + REG_DISPCNT |= 0x200; + REG_BG2CNT = 0x5C02; + REG_DISPCNT |= 0x400; + REG_BG3CNT = 0x1E03; + REG_DISPCNT |= 0x800; + + DmaCopy16(3, gUnknown_080F1980, (void *) 0x6006000, 0x800); + DmaCopy16(3, gUnknown_080EB160, (void *) 0x6007000, 0x1000); + DmaCopy16(3, gUnknown_080EA160, (void *) 0x600E000, 0x1000); + DmaCopy16(3, gUnknown_080EC160, (void *) 0x600F000, 0x800); + DmaCopy16(3, gUnknown_080EC960, (void *) 0x6000000, 0x2800); + DmaCopy16(3, gUnknown_080BD4C0, gUnknown_03000000, 0x4000); + DmaCopy16(3, gUnknown_080E9F60, (void *) 0x5000000, 0x180); + DmaCopy16(3, gUnknown_080F2180, (void *) 0x6010000, 0x3000); + DmaCopy16(3, gUnknown_080E9F60, OBJ_PLTT, 0x180); + + sub_ADFC(); + sub_B0E8(); + + gMain.unk2E8[0].unk0 = gUnknown_0202ADA0[0x0]; + gMain.unk2E8[0].unk2 = gUnknown_0202ADA0[0x1]; + gMain.unk2E8[1].unk0 = gUnknown_0202ADA0[0x6]; + gMain.unk2E8[1].unk2 = gUnknown_0202ADA0[0x7]; + gMain.unk2E8[2].unk0 = gUnknown_0202ADA0[0xC]; + gMain.unk2E8[2].unk2 = gUnknown_0202ADA0[0xD]; + gMain.unk2E8[3].unk0 = gUnknown_0202ADA0[0x12]; + gMain.unk2E8[3].unk2 = gUnknown_0202ADA0[0x13]; + + sub_0CBC(); + sub_10424(); + gUnknown_0202C790++; +} + +void sub_ADFC(void) +{ + gUnknown_0201A450.unk10 = 0xB4; + gUnknown_0201A450.unk12 = 0xFFBC; + gUnknown_0201A450.unk0 = 0xB4; + gUnknown_0201A450.unk2 = 0xFFBC; + gUnknown_0201A450.unk20 = 0x80; + gUnknown_0201A450.unk22 = 0x88; + + gUnknown_0202ADA0[0x0] = 0xFF58; + gUnknown_0202ADA0[0x1] = 0xFF98; + gUnknown_0202ADA0[0x4] = 0; + gUnknown_0202ADA0[0x5] = 0; + gUnknown_0202ADA0[0x2] = 0; + + sub_10708(&gUnknown_03002300, (void *) 0x6002ee0, 8, 8); + + gUnknown_0202ADA0[0x6] = 0xA5; + gUnknown_0202ADA0[0x7] = 0; + gUnknown_0202ADA0[0xA] = 0; + gUnknown_0202ADA0[0xC] = 0xA0; + gUnknown_0202ADA0[0xD] = 0; + gUnknown_0202ADA0[0x10] = 0; + gUnknown_0202ADA0[0x12] = 0; + gUnknown_0202ADA0[0x13] = 0; + + gUnknown_0202BF10 = 0; + gUnknown_0202A578 = 0; +} + +void sub_AE74(void) +{ + gUnknown_0201A450.unk10 -= 0x10; + gUnknown_0201A450.unk12 += 0xA; + gUnknown_0201A450.unk0 -= 0x10; + gUnknown_0201A450.unk2 += 0xA; + gUnknown_0201A450.unk20 += 0x5; + gUnknown_0201A450.unk22 -= 0x3; + + gUnknown_0202ADA0[0x6] -= 0x10; + gUnknown_0202ADA0[0x7]++; + gUnknown_0202ADA0[0xC] -= 0x10; + gUnknown_0202ADA0[0x0] += gUnknown_0202ADA0[0x2]; + gUnknown_0202ADA0[0x1] += 0x9; + gUnknown_0202ADA0[0x2]++; + gUnknown_0202ADA0[0x5]++; + + if (gUnknown_0202ADA0[0x5] > gUnknown_086A79FC[gUnknown_0202ADA0[0x4]].unk2) + { + gUnknown_0202ADA0[0x4]++; + sub_10708(&gUnknown_03000000[gUnknown_086A7A1C[gUnknown_0202ADA0[0x4]]], (void *) 0x6002EE0, 8, 8); + } + + sub_B0E8(); + gMain.unk2E8[0].unk0 = gUnknown_0202ADA0[0x0]; + gMain.unk2E8[0].unk2 = gUnknown_0202ADA0[0x1]; + gMain.unk2E8[1].unk0 = gUnknown_0202ADA0[0x6]; + gMain.unk2E8[1].unk2 = gUnknown_0202ADA0[0x7]; + gMain.unk2E8[2].unk0 = gUnknown_0202ADA0[0xC]; + gMain.unk2E8[2].unk2 = gUnknown_0202ADA0[0xD]; + + gUnknown_0202ADA0[0x10]++; + if (9 < gUnknown_0202ADA0[0x10]) + { + gUnknown_0202ADA0[0x10] = 0; + gUnknown_0202C790++; + } +}