From 192ee78bb96bae8dc8316cdd9edf2112ad2d1777 Mon Sep 17 00:00:00 2001 From: scnorton Date: Sun, 21 Jan 2018 17:48:35 -0500 Subject: [PATCH] through sub_8006438 --- asm/text.s | 123 ----------------------------------------- include/code_800558C.h | 2 +- src/text.c | 64 ++++++++++++++++++++- 3 files changed, 63 insertions(+), 126 deletions(-) diff --git a/asm/text.s b/asm/text.s index d9140989..98b87970 100644 --- a/asm/text.s +++ b/asm/text.s @@ -5,129 +5,6 @@ .text - thumb_func_start sub_800641C -sub_800641C: - push {lr} - sub sp, 0x4 - lsls r1, 24 - lsrs r1, 24 - lsls r2, 24 - lsrs r2, 24 - movs r3, 0 - str r3, [sp] - mov r3, sp - bl sub_8006438 - add sp, 0x4 - pop {r0} - bx r0 - thumb_func_end sub_800641C - - thumb_func_start sub_8006438 -sub_8006438: - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0x1C - adds r4, r0, 0 - mov r8, r3 - lsls r1, 24 - lsrs r1, 24 - mov r10, r1 - lsls r2, 24 - lsrs r2, 24 - movs r0, 0x2 - mov r9, r0 - cmp r4, 0 - bne _0800645C - ldr r4, _080064F0 -_0800645C: - cmp r2, 0 - beq _08006464 - bl sub_8009388 -_08006464: - bl sub_800898C - movs r6, 0 - adds r5, r4, 0 - adds r5, 0xC - ldr r1, _080064F4 - str r1, [sp, 0x18] -_08006472: - ldr r0, [sp, 0x18] - adds r1, r4, 0 - ldm r1!, {r2,r3,r7} - stm r0!, {r2,r3,r7} - ldm r1!, {r2,r3,r7} - stm r0!, {r2,r3,r7} - movs r1, 0 - ldrsh r0, [r5, r1] - cmp r0, 0 - beq _080064C4 - ldr r1, _080064F8 - lsls r0, r6, 2 - adds r0, r1 - ldr r0, [r0] - str r0, [sp] - str r4, [sp, 0x4] - mov r2, r10 - str r2, [sp, 0x8] - mov r3, r9 - str r3, [sp, 0xC] - mov r7, r8 - str r7, [sp, 0x10] - movs r0, 0 - str r0, [sp, 0x14] - ldr r0, _080064FC - movs r1, 0xC0 - lsls r1, 19 - ldr r2, _08006500 - ldr r3, _08006504 - bl sub_8006554 - adds r0, r4, 0 - mov r1, r8 - bl sub_80089AC - movs r0, 0 - ldrsh r1, [r5, r0] - movs r2, 0x4 - ldrsh r0, [r5, r2] - muls r0, r1 - add r9, r0 -_080064C4: - adds r5, 0x18 - adds r4, 0x18 - ldr r3, [sp, 0x18] - adds r3, 0x18 - str r3, [sp, 0x18] - adds r6, 0x1 - cmp r6, 0x3 - ble _08006472 - ldr r2, _08006508 - ldr r0, _0800650C - ldr r1, _08006510 - str r0, [r2] - movs r0, 0x1 - strb r0, [r1] - add sp, 0x1C - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - .align 2, 0 -_080064F0: .4byte gUnknown_80B857C -_080064F4: .4byte gUnknown_202AFC0 -_080064F8: .4byte gUnknown_80B8804 -_080064FC: .4byte gUnknown_2027370 -_08006500: .4byte gUnknown_20274B4 -_08006504: .4byte gUnknown_202B038 -_08006508: .4byte gUnknown_203B078 -_0800650C: .4byte gUnknown_3000E94 -_08006510: .4byte gUnknown_20274A5 - thumb_func_end sub_8006438 - thumb_func_start nullsub_152 nullsub_152: bx lr diff --git a/include/code_800558C.h b/include/code_800558C.h index be974cc8..e1b34326 100644 --- a/include/code_800558C.h +++ b/include/code_800558C.h @@ -1,6 +1,6 @@ #ifndef GUARD_code_800558C_H #define GUARD_code_800558C_H -extern u32 gUnknown_203B078; +extern void *gUnknown_203B078; #endif //GUARD_code_800558C_H diff --git a/src/text.c b/src/text.c index 3d604169..8c6725de 100644 --- a/src/text.c +++ b/src/text.c @@ -17,13 +17,25 @@ struct UnkTextStruct1 { u8 unk46; }; +struct UnkTextStruct2 { + u8 fill00[0x0c]; + s16 unk0c; + u8 fill0e[2]; + s16 unk10; + u8 fill12[0x06]; +}; + +extern char gUnknown_3000E94[]; + EWRAM_DATA struct UnkTextStruct1 gUnknown_2027370[4]; EWRAM_DATA u8 *gUnknown_2027490[2]; EWRAM_DATA u16 gUnknown_2027498; EWRAM_DATA u8 gUnknown_20274A5; EWRAM_DATA u32 gUnknown_20274AC; EWRAM_DATA vu32 gUnknown_20274B0; -EWRAM_DATA struct OpenedFile *gUnknown_202AFB4[2]; +EWRAM_DATA u8 gUnknown_20274B4[0x3b00]; +EWRAM_DATA struct OpenedFile *gUnknown_202AFB4[3]; +EWRAM_DATA struct UnkTextStruct2 gUnknown_202AFC0[4]; EWRAM_DATA u32 gUnknown_202B020; EWRAM_DATA u32 gUnknown_202B024; EWRAM_DATA u32 gUnknown_202B028[2]; @@ -32,12 +44,19 @@ EWRAM_DATA u8 gUnknown_202B034; EWRAM_DATA u16 gUnknown_202B038[2][32][32]; u32 xxx_update_some_bg_tiles(u32 a0); +void sub_8006438(const struct UnkTextStruct2 *a0, u8 a1, u8 a2, u32 *a3); +void sub_8006554(void *a0, void *a1, void *a2, void *a3, u32 a4, const struct UnkTextStruct2 *a5, u8 a6, u32 a7, u32 *a8, u32 a9); +void sub_800898C(void); +void sub_80089AC(const struct UnkTextStruct2 *a0, void *a1); +void sub_8009388(void); +extern const struct UnkTextStruct2 gUnknown_80B857C[4]; extern const char gUnknown_80B87B4[]; extern const char gUnknown_80B87BC[]; extern const struct FileArchive gUnknown_8300500; extern const u32 gUnknown_80B87C4[8]; extern const u32 gUnknown_80B87E4[8]; +extern const u32 gUnknown_80B8804[4]; void sub_8006218(void) { @@ -71,7 +90,7 @@ void sub_8006218(void) } gUnknown_202B034 = 1; gUnknown_202B030 = 0x88888888; - gUnknown_203B078 = 0; + gUnknown_203B078 = NULL; gUnknown_20274A5 = 0; gUnknown_202B020 = 1; gUnknown_202B024 = 20; @@ -143,3 +162,44 @@ void sub_80063D8(int a0) } gUnknown_202B030 = retval; } + +void sub_800641C(void *a0, u8 a1, u8 a2) +{ + u32 r3 = 0; + sub_8006438(a0, a1, a2, &r3); +} + +void sub_8006438(const struct UnkTextStruct2 *a0, u8 a1, u8 a2, u32 *a3) +{ + int i; + u32 r9 = 2; + + if (a0 == NULL) + a0 = gUnknown_80B857C; + if (a2) + sub_8009388(); + sub_800898C(); + for (i = 0; i < 4; i++) + { + gUnknown_202AFC0[i] = a0[i]; + if (a0[i].unk0c) + { + sub_8006554(gUnknown_2027370, (void *)VRAM, gUnknown_20274B4, gUnknown_202B038, gUnknown_80B8804[i], a0 + i, a1, r9, a3, 0); + sub_80089AC(a0 + i, a3); + r9 += a0[i].unk0c * a0[i].unk10; + } + } +#ifdef NONMATCHING + gUnknown_203B078 = gUnknown_3000E94; + gUnknown_20274A5 = 1; +#else + asm(".syntax unified\n" + "\tldr r2, =gUnknown_203B078\n" + "\tldr r0, =gUnknown_3000E94\n" + "\tldr r1, =gUnknown_20274A5\n" + "\tstr r0, [r2]\n" + "\tmovs r0, 0x1\n" + "\tstrb r0, [r1]\n" + ".syntax divided"); +#endif +}