From 0984461aeb32d7de6abf09ffbec17b9f619eb346 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Mon, 25 Sep 2017 08:53:25 -0400 Subject: [PATCH 01/12] Start decomp of easy_chat --- asm/easy_chat.s | 257 ------------------------------------------------ include/rom4.h | 1 + ld_script.txt | 1 + src/easy_chat.c | 141 ++++++++++++++++++++++++++ 4 files changed, 143 insertions(+), 257 deletions(-) create mode 100644 src/easy_chat.c diff --git a/asm/easy_chat.s b/asm/easy_chat.s index 20bf327ac2..bfeef4514c 100644 --- a/asm/easy_chat.s +++ b/asm/easy_chat.s @@ -5,263 +5,6 @@ .text - thumb_func_start sub_811A20C -sub_811A20C: @ 811A20C - push {r4-r6,lr} - mov r6, r9 - mov r5, r8 - push {r5,r6} - adds r6, r0, 0 - mov r8, r1 - mov r9, r2 - adds r5, r3, 0 - lsls r6, 24 - lsrs r6, 24 - lsls r5, 24 - lsrs r5, 24 - bl ResetTasks - ldr r0, =sub_811A2C0 - movs r1, 0 - bl CreateTask - adds r4, r0, 0 - lsls r4, 24 - lsrs r4, 24 - ldr r1, =gTasks - lsls r0, r4, 2 - adds r0, r4 - lsls r0, 3 - adds r0, r1 - strh r6, [r0, 0xA] - strh r5, [r0, 0x16] - adds r0, r4, 0 - movs r1, 0x2 - mov r2, r8 - bl SetWordTaskArg - adds r0, r4, 0 - movs r1, 0x4 - mov r2, r9 - bl SetWordTaskArg - ldr r0, =sub_811A278 - bl SetMainCallback2 - pop {r3,r4} - mov r8, r3 - mov r9, r4 - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_811A20C - - thumb_func_start sub_811A278 -sub_811A278: @ 811A278 - push {lr} - bl RunTasks - bl AnimateSprites - bl BuildOamBuffer - bl UpdatePaletteFade - pop {r0} - bx r0 - thumb_func_end sub_811A278 - - thumb_func_start sub_811A290 -sub_811A290: @ 811A290 - push {lr} - bl TransferPlttBuffer - bl LoadOam - bl ProcessSpriteCopyRequests - pop {r0} - bx r0 - thumb_func_end sub_811A290 - - thumb_func_start sub_811A2A4 -sub_811A2A4: @ 811A2A4 - lsls r0, 24 - lsrs r0, 24 - ldr r3, =gTasks - lsls r2, r0, 2 - adds r2, r0 - lsls r2, 3 - adds r2, r3 - str r1, [r2] - movs r0, 0 - strh r0, [r2, 0x8] - bx lr - .pool - thumb_func_end sub_811A2A4 - - thumb_func_start sub_811A2C0 -sub_811A2C0: @ 811A2C0 - push {r4,lr} - lsls r0, 24 - lsrs r4, r0, 24 - bl is_c1_link_related_active - cmp r0, 0 - bne _0811A2DC -_0811A2CE: - adds r0, r4, 0 - bl sub_811A428 - lsls r0, 24 - cmp r0, 0 - bne _0811A2CE - b _0811A2EA -_0811A2DC: - adds r0, r4, 0 - bl sub_811A428 - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - beq _0811A2F2 -_0811A2EA: - ldr r1, =sub_811A2FC - adds r0, r4, 0 - bl sub_811A2A4 -_0811A2F2: - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_811A2C0 - - thumb_func_start sub_811A2FC -sub_811A2FC: @ 811A2FC - push {r4-r6,lr} - sub sp, 0x4 - lsls r0, 24 - lsrs r2, r0, 24 - lsls r0, r2, 2 - adds r0, r2 - lsls r0, 3 - ldr r1, =gTasks + 0x8 - adds r5, r0, r1 - movs r1, 0 - ldrsh r0, [r5, r1] - cmp r0, 0x5 - bls _0811A318 - b _0811A41C -_0811A318: - lsls r0, 2 - ldr r1, =_0811A32C - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .pool - .align 2, 0 -_0811A32C: - .4byte _0811A344 - .4byte _0811A370 - .4byte _0811A3CC - .4byte _0811A3D4 - .4byte _0811A3EC - .4byte _0811A40C -_0811A344: - ldr r0, =sub_811A290 - bl SetVBlankCallback - movs r4, 0x1 - negs r4, r4 - adds r0, r4, 0 - movs r1, 0x10 - movs r2, 0 - bl BlendPalettes - movs r0, 0 - str r0, [sp] - adds r0, r4, 0 - adds r1, r4, 0 - movs r2, 0x10 - movs r3, 0 - bl BeginNormalPaletteFade - movs r0, 0x5 - b _0811A41A - .pool -_0811A370: - bl sub_811AAAC - lsls r0, 16 - lsrs r4, r0, 16 - adds r6, r4, 0 - adds r0, r4, 0 - bl sub_811A88C - cmp r0, 0 - beq _0811A39E - movs r0, 0x1 - negs r0, r0 - movs r1, 0x2 - negs r1, r1 - movs r2, 0 - str r2, [sp] - movs r3, 0x10 - bl BeginNormalPaletteFade - movs r0, 0x3 - strh r0, [r5] - strh r4, [r5, 0xC] - b _0811A41C -_0811A39E: - cmp r4, 0x18 - bne _0811A3B6 - movs r1, 0x1 - negs r1, r1 - str r0, [sp] - adds r0, r1, 0 - movs r2, 0 - movs r3, 0x10 - bl BeginNormalPaletteFade - movs r0, 0x4 - b _0811A41A -_0811A3B6: - cmp r6, 0 - beq _0811A41C - movs r0, 0x5 - bl PlaySE - adds r0, r6, 0 - bl sub_811C158 - ldrh r0, [r5] - adds r0, 0x1 - b _0811A41A -_0811A3CC: - bl sub_811C170 - lsls r0, 24 - b _0811A414 -_0811A3D4: - ldr r0, =gPaletteFade - ldrb r1, [r0, 0x7] - movs r0, 0x80 - ands r0, r1 - cmp r0, 0 - bne _0811A41C - ldrh r0, [r5, 0xC] - bl sub_811A8A4 - b _0811A41C - .pool -_0811A3EC: - ldr r0, =gPaletteFade - ldrb r1, [r0, 0x7] - movs r0, 0x80 - ands r0, r1 - cmp r0, 0 - bne _0811A41C - adds r0, r2, 0 - movs r1, 0x4 - bl GetWordTaskArg - bl sub_811A4D0 - b _0811A41C - .pool -_0811A40C: - ldr r0, =gPaletteFade - ldrb r1, [r0, 0x7] - movs r0, 0x80 - ands r0, r1 -_0811A414: - cmp r0, 0 - bne _0811A41C - movs r0, 0x1 -_0811A41A: - strh r0, [r5] -_0811A41C: - add sp, 0x4 - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_811A2FC - thumb_func_start sub_811A428 sub_811A428: @ 811A428 push {r4-r6,lr} diff --git a/include/rom4.h b/include/rom4.h index e19d277a63..9f214cfee6 100644 --- a/include/rom4.h +++ b/include/rom4.h @@ -29,5 +29,6 @@ const struct MapHeader *get_mapheader_by_bank_and_number(u8, u8); void FieldObjectMoveDestCoords(struct MapObject *, u32, s16 *, s16 *); void sub_8086230(void); void c2_exit_to_overworld_2_switch(void); +bool32 is_c1_link_related_active(void); #endif //GUARD_ROM4_H diff --git a/ld_script.txt b/ld_script.txt index b2e996ff5f..d839bb922a 100644 --- a/ld_script.txt +++ b/ld_script.txt @@ -166,6 +166,7 @@ SECTIONS { asm/item_use.o(.text); asm/battle_anim_80FE840.o(.text); asm/bike.o(.text); + src/easy_chat.o(.text); asm/easy_chat.o(.text); asm/mon_markings.o(.text); asm/mauville_old_man.o(.text); diff --git a/src/easy_chat.c b/src/easy_chat.c new file mode 100644 index 0000000000..edfab86b74 --- /dev/null +++ b/src/easy_chat.c @@ -0,0 +1,141 @@ + +// Includes +#include "global.h" +#include "songs.h" +#include "sound.h" +#include "rom4.h" +#include "task.h" +#include "main.h" +#include "palette.h" +#include "easy_chat.h" + +// Static type declarations + +// Static RAM declarations +static void sub_811A2C0(u8); +static void sub_811A278(void); +/*static*/ bool8 sub_811A428(u8); +static void sub_811A2FC(u8); +/*static*/ u16 sub_811AAAC(void); +/*static*/ bool32 sub_811A88C(u16); +/*static*/ void sub_811C158(u16); +/*static*/ bool8 sub_811C170(void); +/*static*/ void sub_811A8A4(u16); +/*static*/ void sub_811A4D0(u32); + +// Static ROM declarations + +// .rodata + +// .text + +void sub_811A20C(u8 a0, u32 a1, u32 a2, u8 a3) +{ + u8 taskId; + + ResetTasks(); + taskId = CreateTask(sub_811A2C0, 0); + gTasks[taskId].data[1] = a0; + gTasks[taskId].data[7] = a3; + SetWordTaskArg(taskId, 0x02, a1); + SetWordTaskArg(taskId, 0x04, a2); + SetMainCallback2(sub_811A278); +} + +static void sub_811A278(void) +{ + RunTasks(); + AnimateSprites(); + BuildOamBuffer(); + UpdatePaletteFade(); +} + +static void sub_811A290(void) +{ + TransferPlttBuffer(); + LoadOam(); + ProcessSpriteCopyRequests(); +} + +static void sub_811A2A4(u8 taskId, TaskFunc taskFunc) +{ + gTasks[taskId].func = taskFunc; + gTasks[taskId].data[0] = 0; +} + +static void sub_811A2C0(u8 taskId) +{ + if (!is_c1_link_related_active()) + { + while (sub_811A428(taskId)); + } + else + { + if (sub_811A428(taskId) == TRUE) + { + return; + } + } + sub_811A2A4(taskId, sub_811A2FC); +} + +static void sub_811A2FC(u8 taskId) +{ + u16 v0; + s16 *data; + + data = gTasks[taskId].data; + switch (data[0]) + { + case 0: + SetVBlankCallback(sub_811A290); + BlendPalettes(-1, 16, 0); + BeginNormalPaletteFade(-1, -1, 16, 0, 0); + data[0] = 5; + break; + case 1: + v0 = sub_811AAAC(); + if (sub_811A88C(v0)) + { + BeginNormalPaletteFade(-1, -2, 0, 16, 0); + data[0] = 3; + data[6] = v0; + } + else if (v0 == 0x18) + { + BeginNormalPaletteFade(-1, -1, 0, 16, 0); + data[0] = 4; + } + else if (v0 != 0) + { + PlaySE(SE_SELECT); + sub_811C158(v0); + data[0] ++; + } + break; + case 2: + if (!sub_811C170()) + { + data[0] = 1; + } + break; + case 3: + if (!gPaletteFade.active) + { + sub_811A8A4(data[6]); + } + break; + case 4: + if (!gPaletteFade.active) + { + sub_811A4D0(GetWordTaskArg(taskId, 0x04)); + } + break; + case 5: + if (!gPaletteFade.active) + { + data[0] = 1; + } + break; + } +} From cdfdd2a29a100e1cf3e070df24a28cf6d3e4667d Mon Sep 17 00:00:00 2001 From: scnorton Date: Mon, 25 Sep 2017 17:22:51 -0400 Subject: [PATCH 02/12] sub_811A428 --- asm/easy_chat.s | 79 ------------------------------------------------- src/easy_chat.c | 50 ++++++++++++++++++++++++++++++- 2 files changed, 49 insertions(+), 80 deletions(-) diff --git a/asm/easy_chat.s b/asm/easy_chat.s index bfeef4514c..5d7a02a84a 100644 --- a/asm/easy_chat.s +++ b/asm/easy_chat.s @@ -5,85 +5,6 @@ .text - thumb_func_start sub_811A428 -sub_811A428: @ 811A428 - push {r4-r6,lr} - lsls r0, 24 - lsrs r5, r0, 24 - lsls r0, r5, 2 - adds r0, r5 - lsls r0, 3 - ldr r1, =gTasks + 0x8 - adds r6, r0, r1 - movs r1, 0 - ldrsh r0, [r6, r1] - cmp r0, 0x4 - bhi _0811A4BC - lsls r0, 2 - ldr r1, =_0811A454 - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .pool - .align 2, 0 -_0811A454: - .4byte _0811A468 - .4byte _0811A47C - .4byte _0811A482 - .4byte _0811A498 - .4byte _0811A4B0 -_0811A468: - movs r0, 0 - bl SetVBlankCallback - bl ResetSpriteData - bl FreeAllSpritePalettes - bl ResetPaletteFade - b _0811A4C0 -_0811A47C: - bl sub_811F28C - b _0811A49C -_0811A482: - ldrb r4, [r6, 0x2] - adds r0, r5, 0 - movs r1, 0x2 - bl GetWordTaskArg - adds r1, r0, 0 - ldrb r2, [r6, 0xE] - adds r0, r4, 0 - bl sub_811A95C - b _0811A49C -_0811A498: - bl sub_811BF8C -_0811A49C: - lsls r0, 24 - cmp r0, 0 - bne _0811A4C0 - adds r0, r5, 0 - movs r1, 0x4 - bl GetWordTaskArg - bl sub_811A4D0 - b _0811A4C0 -_0811A4B0: - bl sub_811BFA4 - lsls r0, 24 - cmp r0, 0 - beq _0811A4C0 - b _0811A4C6 -_0811A4BC: - movs r0, 0 - b _0811A4C8 -_0811A4C0: - ldrh r0, [r6] - adds r0, 0x1 - strh r0, [r6] -_0811A4C6: - movs r0, 0x1 -_0811A4C8: - pop {r4-r6} - pop {r1} - bx r1 - thumb_func_end sub_811A428 - thumb_func_start sub_811A4D0 sub_811A4D0: @ 811A4D0 push {r4,lr} diff --git a/src/easy_chat.c b/src/easy_chat.c index edfab86b74..8ee46e2156 100644 --- a/src/easy_chat.c +++ b/src/easy_chat.c @@ -14,7 +14,7 @@ // Static RAM declarations static void sub_811A2C0(u8); static void sub_811A278(void); -/*static*/ bool8 sub_811A428(u8); +static bool8 sub_811A428(u8); static void sub_811A2FC(u8); /*static*/ u16 sub_811AAAC(void); /*static*/ bool32 sub_811A88C(u16); @@ -22,6 +22,10 @@ static void sub_811A2FC(u8); /*static*/ bool8 sub_811C170(void); /*static*/ void sub_811A8A4(u16); /*static*/ void sub_811A4D0(u32); +bool8 sub_811F28C(void); +bool8 sub_811A95C(u8, u32, u8); +bool8 sub_811BF8C(void); +bool8 sub_811BFA4(void); // Static ROM declarations @@ -139,3 +143,47 @@ static void sub_811A2FC(u8 taskId) break; } } + +static bool8 sub_811A428(u8 taskId) +{ + s16 *data; + + data = gTasks[taskId].data; + switch (data[0]) + { + case 0: + SetVBlankCallback(NULL); + ResetSpriteData(); + FreeAllSpritePalettes(); + ResetPaletteFade(); + break; + case 1: + if (!sub_811F28C()) + { + sub_811A4D0(GetWordTaskArg(taskId, 0x04)); + } + break; + case 2: + if (!sub_811A95C(data[1], GetWordTaskArg(taskId, 0x02), data[7])) + { + sub_811A4D0(GetWordTaskArg(taskId, 0x04)); + } + break; + case 3: + if (!sub_811BF8C()) + { + sub_811A4D0(GetWordTaskArg(taskId, 0x04)); + } + break; + case 4: + if (sub_811BFA4()) + { + return TRUE; + } + break; + default: + return FALSE; + } + data[0] ++; + return TRUE; +} From b62b67e4284b2204ac575698f9199584fe484606 Mon Sep 17 00:00:00 2001 From: scnorton Date: Mon, 25 Sep 2017 17:30:49 -0400 Subject: [PATCH 03/12] sub_811A4D0; constants for ezchat task data offsets --- asm/easy_chat.s | 15 ----------- src/easy_chat.c | 66 ++++++++++++++++++++++++++++++++----------------- 2 files changed, 43 insertions(+), 38 deletions(-) diff --git a/asm/easy_chat.s b/asm/easy_chat.s index 5d7a02a84a..8455decfe7 100644 --- a/asm/easy_chat.s +++ b/asm/easy_chat.s @@ -5,21 +5,6 @@ .text - thumb_func_start sub_811A4D0 -sub_811A4D0: @ 811A4D0 - push {r4,lr} - adds r4, r0, 0 - bl sub_811C13C - bl sub_811AA90 - bl sub_811F2B8 - bl FreeAllWindowBuffers - adds r0, r4, 0 - bl SetMainCallback2 - pop {r4} - pop {r0} - bx r0 - thumb_func_end sub_811A4D0 - thumb_func_start easy_chat_input_maybe easy_chat_input_maybe: @ 811A4F0 push {r4,r5,lr} diff --git a/src/easy_chat.c b/src/easy_chat.c index 8ee46e2156..1ff0ccc336 100644 --- a/src/easy_chat.c +++ b/src/easy_chat.c @@ -6,11 +6,19 @@ #include "rom4.h" #include "task.h" #include "main.h" +#include "window.h" #include "palette.h" #include "easy_chat.h" // Static type declarations +#define EZCHAT_TASK_STATE 0 +#define EZCHAT_TASK_UNK01 1 +#define EZCHAT_TASK_UNK02 2 +#define EZCHAT_TASK_MAINCALLBACK 4 +#define EZCHAT_TASK_UNK06 6 +#define EZCHAT_TASK_UNK07 7 + // Static RAM declarations static void sub_811A2C0(u8); static void sub_811A278(void); @@ -21,11 +29,14 @@ static void sub_811A2FC(u8); /*static*/ void sub_811C158(u16); /*static*/ bool8 sub_811C170(void); /*static*/ void sub_811A8A4(u16); -/*static*/ void sub_811A4D0(u32); +/*static*/ void sub_811A4D0(MainCallback); bool8 sub_811F28C(void); bool8 sub_811A95C(u8, u32, u8); bool8 sub_811BF8C(void); bool8 sub_811BFA4(void); +void sub_811C13C(void); +void sub_811AA90(void); +void sub_811F2B8(void); // Static ROM declarations @@ -33,16 +44,16 @@ bool8 sub_811BFA4(void); // .text -void sub_811A20C(u8 a0, u32 a1, u32 a2, u8 a3) +void sub_811A20C(u8 a0, u32 a1, MainCallback callback, u8 a3) { u8 taskId; ResetTasks(); taskId = CreateTask(sub_811A2C0, 0); - gTasks[taskId].data[1] = a0; - gTasks[taskId].data[7] = a3; - SetWordTaskArg(taskId, 0x02, a1); - SetWordTaskArg(taskId, 0x04, a2); + gTasks[taskId].data[EZCHAT_TASK_UNK01] = a0; + gTasks[taskId].data[EZCHAT_TASK_UNK07] = a3; + SetWordTaskArg(taskId, EZCHAT_TASK_UNK02, a1); + SetWordTaskArg(taskId, EZCHAT_TASK_MAINCALLBACK, (u32)callback); SetMainCallback2(sub_811A278); } @@ -64,7 +75,7 @@ static void sub_811A290(void) static void sub_811A2A4(u8 taskId, TaskFunc taskFunc) { gTasks[taskId].func = taskFunc; - gTasks[taskId].data[0] = 0; + gTasks[taskId].data[EZCHAT_TASK_STATE] = 0; } static void sub_811A2C0(u8 taskId) @@ -89,56 +100,56 @@ static void sub_811A2FC(u8 taskId) s16 *data; data = gTasks[taskId].data; - switch (data[0]) + switch (data[EZCHAT_TASK_STATE]) { case 0: SetVBlankCallback(sub_811A290); BlendPalettes(-1, 16, 0); BeginNormalPaletteFade(-1, -1, 16, 0, 0); - data[0] = 5; + data[EZCHAT_TASK_STATE] = 5; break; case 1: v0 = sub_811AAAC(); if (sub_811A88C(v0)) { BeginNormalPaletteFade(-1, -2, 0, 16, 0); - data[0] = 3; - data[6] = v0; + data[EZCHAT_TASK_STATE] = 3; + data[EZCHAT_TASK_UNK06] = v0; } else if (v0 == 0x18) { BeginNormalPaletteFade(-1, -1, 0, 16, 0); - data[0] = 4; + data[EZCHAT_TASK_STATE] = 4; } else if (v0 != 0) { PlaySE(SE_SELECT); sub_811C158(v0); - data[0] ++; + data[EZCHAT_TASK_STATE] ++; } break; case 2: if (!sub_811C170()) { - data[0] = 1; + data[EZCHAT_TASK_STATE] = 1; } break; case 3: if (!gPaletteFade.active) { - sub_811A8A4(data[6]); + sub_811A8A4(data[EZCHAT_TASK_UNK06]); } break; case 4: if (!gPaletteFade.active) { - sub_811A4D0(GetWordTaskArg(taskId, 0x04)); + sub_811A4D0((MainCallback)GetWordTaskArg(taskId, EZCHAT_TASK_MAINCALLBACK)); } break; case 5: if (!gPaletteFade.active) { - data[0] = 1; + data[EZCHAT_TASK_STATE] = 1; } break; } @@ -149,7 +160,7 @@ static bool8 sub_811A428(u8 taskId) s16 *data; data = gTasks[taskId].data; - switch (data[0]) + switch (data[EZCHAT_TASK_STATE]) { case 0: SetVBlankCallback(NULL); @@ -160,19 +171,19 @@ static bool8 sub_811A428(u8 taskId) case 1: if (!sub_811F28C()) { - sub_811A4D0(GetWordTaskArg(taskId, 0x04)); + sub_811A4D0((MainCallback)GetWordTaskArg(taskId, EZCHAT_TASK_MAINCALLBACK)); } break; case 2: - if (!sub_811A95C(data[1], GetWordTaskArg(taskId, 0x02), data[7])) + if (!sub_811A95C(data[EZCHAT_TASK_UNK01], GetWordTaskArg(taskId, EZCHAT_TASK_UNK02), data[EZCHAT_TASK_UNK07])) { - sub_811A4D0(GetWordTaskArg(taskId, 0x04)); + sub_811A4D0((MainCallback)GetWordTaskArg(taskId, EZCHAT_TASK_MAINCALLBACK)); } break; case 3: if (!sub_811BF8C()) { - sub_811A4D0(GetWordTaskArg(taskId, 0x04)); + sub_811A4D0((MainCallback)GetWordTaskArg(taskId, EZCHAT_TASK_MAINCALLBACK)); } break; case 4: @@ -184,6 +195,15 @@ static bool8 sub_811A428(u8 taskId) default: return FALSE; } - data[0] ++; + data[EZCHAT_TASK_STATE] ++; return TRUE; } + +void sub_811A4D0(MainCallback callback) +{ + sub_811C13C(); + sub_811AA90(); + sub_811F2B8(); + FreeAllWindowBuffers(); + SetMainCallback2(callback); +} From 0e75d957d675564977b2e442c16822bab390aa2c Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Mon, 25 Sep 2017 19:57:44 -0400 Subject: [PATCH 04/12] Update offset comments in save block 1 --- include/global.h | 60 +++++++++++++++++++-------------------- src/easy_chat.c | 74 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 104 insertions(+), 30 deletions(-) diff --git a/include/global.h b/include/global.h index 4014c6dde8..9793ddcf24 100644 --- a/include/global.h +++ b/include/global.h @@ -534,14 +534,14 @@ struct MailStruct struct UnkMauvilleOldManStruct { - u8 unk_2D94; - u8 unk_2D95; - /*0x2D96*/ u16 mauvilleOldMan_ecArray[6]; - /*0x2DA2*/ u16 mauvilleOldMan_ecArray2[6]; - /*0x2DAE*/ u8 playerName[8]; - /*0x2DB6*/ u8 filler_2DB6[0x3]; - /*0x2DB9*/ u8 playerTrainerId[4]; - u8 unk_2DBD; + u8 unk_2E28; + u8 unk_2E29; + /*0x2E2A*/ u16 mauvilleOldMan_ecArray[6]; + /*0x2E36*/ u16 mauvilleOldMan_ecArray2[6]; + /*0x2E42*/ u8 playerName[8]; + /*0x2E4A*/ u8 filler_2E4A[0x3]; + /*0x2E4B*/ u8 playerTrainerId[4]; + u8 unk_2E4F; }; /*size = 0x2C*/ struct UnkMauvilleOldManStruct2 @@ -579,24 +579,24 @@ struct UnknownSaveStruct2ABC struct GabbyAndTyData { - /*2b10*/ u16 mon1; - /*2b12*/ u16 mon2; - /*2b14*/ u16 lastMove; - /*2b16*/ u16 quote; - /*2b18*/ u8 mapnum; - /*2b19*/ u8 battleNum; - /*2b1a*/ u8 valA_0:1; - /*2b1a*/ u8 valA_1:1; - /*2b1a*/ u8 valA_2:1; - /*2b1a*/ u8 valA_3:1; - /*2b1a*/ u8 valA_4:1; - /*2b1a*/ u8 valA_5:3; - /*2b1b*/ u8 valB_0:1; - /*2b1b*/ u8 valB_1:1; - /*2b1b*/ u8 valB_2:1; - /*2b1b*/ u8 valB_3:1; - /*2b1b*/ u8 valB_4:1; - /*2b1b*/ u8 valB_5:3; + /*2ba4*/ u16 mon1; + /*2ba6*/ u16 mon2; + /*2ba8*/ u16 lastMove; + /*2baa*/ u16 quote; + /*2bac*/ u8 mapnum; + /*2bad*/ u8 battleNum; + /*2bae*/ u8 valA_0:1; + /*2bae*/ u8 valA_1:1; + /*2bae*/ u8 valA_2:1; + /*2bae*/ u8 valA_3:1; + /*2bae*/ u8 valA_4:1; + /*2bae*/ u8 valA_5:3; + /*2baf*/ u8 valB_0:1; + /*2baf*/ u8 valB_1:1; + /*2baf*/ u8 valB_2:1; + /*2baf*/ u8 valB_3:1; + /*2baf*/ u8 valB_4:1; + /*2baf*/ u8 valB_5:3; }; struct RecordMixing_UnknownStructSub @@ -787,10 +787,10 @@ struct SaveBlock1 /*0x????*/ u8 outbreakPokemonProbability; /*0x????*/ u16 outbreakUnk5; /*0x2BA4*/ struct GabbyAndTyData gabbyAndTyData; - /*0x????*/ u16 unk2B1C[6]; - /*0x????*/ u16 unk2B28[6]; - /*0x????*/ u16 unk2B34[6]; - /*0x????*/ u16 unk2B3A[3]; + /*0x2BB0*/ u16 unk2BB0[6]; + /*0x2BBC*/ u16 unk2BBC[6]; + /*0x2BC8*/ u16 unk2BC8[6]; + /*0x2BD4*/ u16 unk2BD4[3]; /*0x2BE0*/ struct MailStruct mail[16]; /*0x2E20*/ u8 additionalPhrases[5]; // bitfield for 33 additional phrases in easy chat system /*0x2E25*/ u8 unk2E25[3]; // possibly padding? diff --git a/src/easy_chat.c b/src/easy_chat.c index 1ff0ccc336..dd490ddf88 100644 --- a/src/easy_chat.c +++ b/src/easy_chat.c @@ -8,6 +8,7 @@ #include "main.h" #include "window.h" #include "palette.h" +#include "event_data.h" #include "easy_chat.h" // Static type declarations @@ -207,3 +208,76 @@ void sub_811A4D0(MainCallback callback) FreeAllWindowBuffers(); SetMainCallback2(callback); } +// +//void easy_chat_input_maybe(void) +//{ +// u16 i; +// u16 *words; +// OldMan *oldMan; +// u8 sizeParam = 3; +// switch (gSpecialVar_0x8004) +// { +// case 0: +// words = gSaveBlock1Ptr->unk2BB0; +// break; +// case 1: +// words = gSaveBlock1Ptr->unk2BBC; +// break; +// case 2: +// words = gSaveBlock1Ptr->unk2BC8; +// break; +// case 3: +// words = gSaveBlock1Ptr->unk2BD4; +// break; +// case 4: +// words = gSaveBlock1Ptr->mail[gSpecialVar_0x8005].words; +// break; +// case 6: +// oldMan = &gSaveBlock1Ptr->oldMan; +// for (i=0; i<6; i++) +// { +// oldMan->oldMan1.mauvilleOldMan_ecArray2[i] = oldMan->oldMan1.mauvilleOldMan_ecArray[i]; +// } +// words = oldMan->oldMan1.mauvilleOldMan_ecArray2; +// break; +// case 5: +// words = gSaveBlock1Ptr->tvShows[gSpecialVar_0x8005].bravoTrainer.var04; +// sizeParam = gSpecialVar_0x8006; +// break; +// case 7: +// words = &gSaveBlock1Ptr->tvShows[gSpecialVar_0x8005].fanclubOpinions.var1C[gSpecialVar_0x8006]; +// sizeParam = 1; +// break; +// case 8: +// words = &gSaveBlock1Ptr->tvShows[gSpecialVar_0x8005].recentHappenings.var02; +// sizeParam = 0; +// break; +// case 9: +// words = NULL; +// break; +// case 10: +// words = &gSaveBlock1Ptr->gabbyAndTyData.quote; +// *words = -1; +// sizeParam = 1; +// break; +// case 11: +// words = &gSaveBlock1Ptr->tvShows[gSpecialVar_0x8005].bravoTrainer.var04[gSpecialVar_0x8006]; +// sizeParam = 0; +// break; +// case 12: +// words = gSaveBlock1Ptr->tvShows[gSpecialVar_0x8005].fanclubOpinions.var18; +// sizeParam = 1; +// break; +// case 13: +// words = (u16 *)gStringVar3; +// sub_811F88C(words, 2); +// break; +// case 14: +// words = +// default: +// return; +// } +// overworld_free_bg_tilemaps(); +// sub_811A20C(gSpecialVar_0x8004, words, sub_80861B0, sizeParam); +//} + From 01d6114da230e8526b21cbd3ae449d87fc2ba548 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Thu, 2 Nov 2017 19:26:14 -0400 Subject: [PATCH 05/12] easy_chat_input_maybe --- asm/easy_chat.s | 278 -------------------------------------------- include/global.h | 13 ++- include/global.tv.h | 4 +- include/link.h | 1 + include/overworld.h | 2 + src/easy_chat.c | 183 ++++++++++++++++------------- src/lilycove_lady.c | 22 ++-- 7 files changed, 126 insertions(+), 377 deletions(-) diff --git a/asm/easy_chat.s b/asm/easy_chat.s index 92aa1ea0fe..206f2d9c41 100644 --- a/asm/easy_chat.s +++ b/asm/easy_chat.s @@ -5,284 +5,6 @@ .text - thumb_func_start easy_chat_input_maybe -easy_chat_input_maybe: @ 811A4F0 - push {r4,r5,lr} - movs r5, 0x3 - ldr r0, =gSpecialVar_0x8004 - ldrh r0, [r0] - cmp r0, 0x14 - bls _0811A4FE - b _0811A7D4 -_0811A4FE: - lsls r0, 2 - ldr r1, =_0811A510 - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .pool - .align 2, 0 -_0811A510: - .4byte _0811A564 - .4byte _0811A578 - .4byte _0811A58C - .4byte _0811A5A0 - .4byte _0811A5B4 - .4byte _0811A604 - .4byte _0811A5D8 - .4byte _0811A630 - .4byte _0811A664 - .4byte _0811A688 - .4byte _0811A6B4 - .4byte _0811A6D4 - .4byte _0811A708 - .4byte _0811A72C - .4byte _0811A73C - .4byte _0811A770 - .4byte _0811A7D4 - .4byte _0811A784 - .4byte _0811A798 - .4byte _0811A7AC - .4byte _0811A7BC -_0811A564: - ldr r0, =gSaveBlock1Ptr - ldr r0, [r0] - ldr r1, =0x00002bb0 - adds r4, r0, r1 - b _0811A7C2 - .pool -_0811A578: - ldr r0, =gSaveBlock1Ptr - ldr r0, [r0] - ldr r2, =0x00002bbc - adds r4, r0, r2 - b _0811A7C2 - .pool -_0811A58C: - ldr r0, =gSaveBlock1Ptr - ldr r0, [r0] - ldr r3, =0x00002bc8 - adds r4, r0, r3 - b _0811A7C2 - .pool -_0811A5A0: - ldr r0, =gSaveBlock1Ptr - ldr r0, [r0] - ldr r1, =0x00002bd4 - adds r4, r0, r1 - b _0811A7C2 - .pool -_0811A5B4: - ldr r2, =gSaveBlock1Ptr - ldr r0, =gSpecialVar_0x8005 - ldrh r1, [r0] - lsls r0, r1, 3 - adds r0, r1 - lsls r0, 2 - ldr r3, =0x00002be0 - adds r0, r3 - ldr r1, [r2] - adds r4, r1, r0 - b _0811A7C2 - .pool -_0811A5D8: - ldr r0, =gSaveBlock1Ptr - ldr r0, [r0] - ldr r2, =0x00002e36 - adds r1, r0, r2 - ldr r3, =0x00002e2a - adds r2, r0, r3 - movs r3, 0x5 -_0811A5E6: - ldrh r0, [r2] - strh r0, [r2, 0xC] - adds r2, 0x2 - subs r3, 0x1 - cmp r3, 0 - bge _0811A5E6 - adds r4, r1, 0 - b _0811A7C2 - .pool -_0811A604: - ldr r2, =gSaveBlock1Ptr - ldr r0, =gSpecialVar_0x8005 - ldrh r1, [r0] - lsls r0, r1, 3 - adds r0, r1 - lsls r0, 2 - ldr r1, [r2] - adds r0, r1 - ldr r1, =0x000027d0 - adds r4, r0, r1 - ldr r0, =gSpecialVar_0x8006 - ldrb r5, [r0] - b _0811A7C2 - .pool -_0811A630: - ldr r2, =gSaveBlock1Ptr - ldr r0, =gSpecialVar_0x8005 - ldrh r1, [r0] - lsls r0, r1, 3 - adds r0, r1 - lsls r0, 2 - ldr r3, =0x000027cc - adds r0, r3 - ldr r1, [r2] - adds r1, r0 - ldr r0, =gSpecialVar_0x8006 - ldrh r0, [r0] - lsls r0, 1 - adds r0, 0x1C - adds r4, r1, r0 - movs r5, 0x1 - b _0811A7C2 - .pool -_0811A664: - ldr r2, =gSaveBlock1Ptr - ldr r0, =gSpecialVar_0x8005 - ldrh r1, [r0] - lsls r0, r1, 3 - adds r0, r1 - lsls r0, 2 - ldr r1, [r2] - adds r0, r1 - ldr r1, =0x000027ce - adds r4, r0, r1 - movs r5, 0 - b _0811A7C2 - .pool -_0811A688: - ldr r4, =gStringVar3 - ldr r1, =gSaveBlock1Ptr - ldr r0, [r1] - ldr r2, =0x00002e6c - adds r0, r2 - ldrh r0, [r0] - strh r0, [r4] - ldr r0, [r1] - ldr r3, =0x00002e6e - adds r0, r3 - ldrh r0, [r0] - strh r0, [r4, 0x2] - b _0811A7C2 - .pool -_0811A6B4: - ldr r0, =gSaveBlock1Ptr - ldr r0, [r0] - ldr r1, =0x00002baa - adds r4, r0, r1 - ldr r2, =0x0000ffff - adds r0, r2, 0 - strh r0, [r4] - movs r5, 0x1 - b _0811A7C2 - .pool -_0811A6D4: - ldr r2, =gSaveBlock1Ptr - ldr r0, =gSpecialVar_0x8005 - ldrh r1, [r0] - lsls r0, r1, 3 - adds r0, r1 - lsls r0, 2 - ldr r3, =0x000027cc - adds r0, r3 - ldr r1, [r2] - adds r1, r0 - ldr r0, =gSpecialVar_0x8006 - ldrh r0, [r0] - lsls r0, 1 - adds r0, 0x4 - adds r4, r1, r0 - movs r5, 0 - b _0811A7C2 - .pool -_0811A708: - ldr r2, =gSaveBlock1Ptr - ldr r0, =gSpecialVar_0x8005 - ldrh r1, [r0] - lsls r0, r1, 3 - adds r0, r1 - lsls r0, 2 - ldr r1, [r2] - adds r0, r1 - ldr r1, =0x000027e4 - adds r4, r0, r1 - movs r5, 0x1 - b _0811A7C2 - .pool -_0811A72C: - ldr r4, =gStringVar3 - adds r0, r4, 0 - movs r1, 0x2 - bl InitializeEasyChatWordArray - b _0811A7C2 - .pool -_0811A73C: - ldr r2, =gSaveBlock1Ptr - ldr r0, =gSpecialVar_0x8005 - ldrh r1, [r0] - lsls r0, r1, 3 - adds r0, r1 - lsls r0, 2 - ldr r3, =0x000027cc - adds r0, r3 - ldr r1, [r2] - adds r1, r0 - adds r4, r1, 0 - adds r4, 0x14 - ldr r2, =0x0000ffff - adds r0, r2, 0 - strh r0, [r1, 0x14] - movs r5, 0x2 - b _0811A7C2 - .pool -_0811A770: - ldr r0, =gSaveBlock1Ptr - ldr r0, [r0] - ldr r3, =0x00003b6e - adds r4, r0, r3 - b _0811A7C2 - .pool -_0811A784: - ldr r0, =gSaveBlock1Ptr - ldr r0, [r0] - ldr r1, =0x00003b5a - adds r4, r0, r1 - b _0811A7C2 - .pool -_0811A798: - ldr r0, =gSaveBlock1Ptr - ldr r0, [r0] - ldr r2, =0x00003b6c - adds r4, r0, r2 - b _0811A7C2 - .pool -_0811A7AC: - ldr r0, =gSaveBlock2Ptr - ldr r0, [r0] - movs r3, 0x82 - lsls r3, 1 - adds r4, r0, r3 - b _0811A7C2 - .pool -_0811A7BC: - bl sub_801B058 - adds r4, r0, 0 -_0811A7C2: - bl overworld_free_bg_tilemaps - ldr r0, =gSpecialVar_0x8004 - ldrb r0, [r0] - ldr r2, =sub_80861B0 - adds r1, r4, 0 - adds r3, r5, 0 - bl sub_811A20C -_0811A7D4: - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end easy_chat_input_maybe - thumb_func_start sub_811A7E4 sub_811A7E4: @ 811A7E4 push {lr} diff --git a/include/global.h b/include/global.h index 16a621568e..f818f15b16 100644 --- a/include/global.h +++ b/include/global.h @@ -192,7 +192,9 @@ struct SaveBlock2 /*0xAC*/ u32 encryptionKey; // TODO: fix and verify labels - /*0xB0*/ u8 field_B0[316]; + /*0xB0*/ u8 field_B0[0x54]; + /*0x104*/ u16 unk_104[1]; + /*0x106*/ u8 filler_106[0xe6]; /*0x1EC*/ struct BerryCrush berryCrush; /*0x1FC*/ struct PokemonJumpResults pokeJump; /*0x20C*/ struct BerryPickingResults berryPick; @@ -460,8 +462,8 @@ struct LilycoveLadyQuiz /*0x000*/ u8 id; /*0x001*/ u8 phase; /*0x002*/ u16 unk_002[9]; - /*0x014*/ u16 unk_014; - /*0x016*/ u16 unk_016; + /*0x014*/ u16 unk_014[1]; + /*0x016*/ u16 unk_016[1]; /*0x018*/ u8 playerName[8]; /*0x020*/ u16 playerTrainerId[4]; /*0x028*/ u16 itemId; @@ -496,7 +498,7 @@ struct LilycoveLadyContest /*0x00e*/ u8 language; }; -typedef union // TODO +typedef union // 3b58 { struct LilycoveLadyQuiz quiz; struct LilycoveLadyFavour favour; @@ -579,13 +581,12 @@ struct SaveBlock1 /*0x2BB0*/ u16 unk2BB0[6]; /*0x2BBC*/ u16 unk2BBC[6]; /*0x2BC8*/ u16 unk2BC8[6]; - /*0x2BD4*/ u16 unk2BD4[3]; + /*0x2BD4*/ u16 unk2BD4[6]; /*0x2BE0*/ struct MailStruct mail[16]; /*0x2E20*/ u8 additionalPhrases[5]; // bitfield for 33 additional phrases in easy chat system /*0x2E25*/ u8 unk2E25[3]; // possibly padding? /*0x2E28*/ OldMan oldMan; /*0x2e64*/ struct EasyChatPair easyChatPairs[5]; //Dewford trend [0] and some other stuff - /*0x2e8c*/ u8 filler_2E8C[0x4]; /*0x2e90*/ struct ContestWinner contestWinners[13]; // 0 - 5 used in contest hall, 6 - 7 unused?, 8 - 12 museum /*0x3030*/ struct DaycareData daycare; /*0x3150*/ struct LinkBattleRecord linkBattleRecords[5]; diff --git a/include/global.tv.h b/include/global.tv.h index 5f65aa8e0a..97ac546607 100644 --- a/include/global.tv.h +++ b/include/global.tv.h @@ -91,7 +91,7 @@ typedef union // size = 0x24 /*0x0E*/ u8 pokemonNameLanguage; /*0x0F*/ u8 filler_0F[1]; /*0x10*/ u8 nickname[8]; - /*0x18*/ u8 filler_18[4]; + /*0x18*/ u16 words18[2]; /*0x1C*/ u16 words[4]; } fanclubOpinions; @@ -99,7 +99,7 @@ typedef union // size = 0x24 struct { /*0x00*/ u8 kind; /*0x01*/ bool8 active; - /*0x02*/ u8 pad02[4]; + /*0x02*/ u16 words[2]; /*0x06*/ u16 var06; /*0x08*/ u8 pad_08[3]; /*0x0b*/ u8 string_0b[12]; diff --git a/include/link.h b/include/link.h index 7a6563144a..c242b55cfb 100644 --- a/include/link.h +++ b/include/link.h @@ -192,5 +192,6 @@ void sub_8011BD0(void); u8 sub_800ABAC(void); u8 sub_800ABBC(void); void sub_800AC34(void); +u16 *sub_801B058(void); #endif // GUARD_LINK_H diff --git a/include/overworld.h b/include/overworld.h index 19bcaaf014..68aa12f0f9 100644 --- a/include/overworld.h +++ b/include/overworld.h @@ -64,5 +64,7 @@ void warp1_set_2(s8 mapGroup, s8 mapNum, s8 warpNum); void c2_load_new_map(void); void copy_saved_warp2_bank_and_enter_x_to_warp1(u8 unused); void mapldr_default(void); +void overworld_free_bg_tilemaps(void); +void sub_80861B0(void); #endif //GUARD_ROM4_H diff --git a/src/easy_chat.c b/src/easy_chat.c index 24f1a2b57e..0d02e0d5ae 100644 --- a/src/easy_chat.c +++ b/src/easy_chat.c @@ -6,6 +6,7 @@ #include "overworld.h" #include "task.h" #include "main.h" +#include "link.h" #include "window.h" #include "palette.h" #include "event_data.h" @@ -14,11 +15,11 @@ // Static type declarations #define EZCHAT_TASK_STATE 0 -#define EZCHAT_TASK_UNK01 1 -#define EZCHAT_TASK_UNK02 2 +#define EZCHAT_TASK_KIND 1 +#define EZCHAT_TASK_WORDS 2 #define EZCHAT_TASK_MAINCALLBACK 4 #define EZCHAT_TASK_UNK06 6 -#define EZCHAT_TASK_UNK07 7 +#define EZCHAT_TASK_SIZE 7 // Static RAM declarations static void sub_811A2C0(u8); @@ -45,15 +46,15 @@ void sub_811F2B8(void); // .text -void sub_811A20C(u8 a0, u32 a1, MainCallback callback, u8 a3) +void sub_811A20C(u8 kind, u16 *words, MainCallback callback, u8 sizeParam) { u8 taskId; ResetTasks(); taskId = CreateTask(sub_811A2C0, 0); - gTasks[taskId].data[EZCHAT_TASK_UNK01] = a0; - gTasks[taskId].data[EZCHAT_TASK_UNK07] = a3; - SetWordTaskArg(taskId, EZCHAT_TASK_UNK02, a1); + gTasks[taskId].data[EZCHAT_TASK_KIND] = kind; + gTasks[taskId].data[EZCHAT_TASK_SIZE] = sizeParam; + SetWordTaskArg(taskId, EZCHAT_TASK_WORDS, (u32)words); SetWordTaskArg(taskId, EZCHAT_TASK_MAINCALLBACK, (u32)callback); SetMainCallback2(sub_811A278); } @@ -176,7 +177,7 @@ static bool8 sub_811A428(u8 taskId) } break; case 2: - if (!sub_811A95C(data[EZCHAT_TASK_UNK01], GetWordTaskArg(taskId, EZCHAT_TASK_UNK02), data[EZCHAT_TASK_UNK07])) + if (!sub_811A95C(data[EZCHAT_TASK_KIND], GetWordTaskArg(taskId, EZCHAT_TASK_WORDS), data[EZCHAT_TASK_SIZE])) { sub_811A4D0((MainCallback)GetWordTaskArg(taskId, EZCHAT_TASK_MAINCALLBACK)); } @@ -208,76 +209,98 @@ void sub_811A4D0(MainCallback callback) FreeAllWindowBuffers(); SetMainCallback2(callback); } -// -//void easy_chat_input_maybe(void) -//{ -// u16 i; -// u16 *words; -// OldMan *oldMan; -// u8 sizeParam = 3; -// switch (gSpecialVar_0x8004) -// { -// case 0: -// words = gSaveBlock1Ptr->unk2BB0; -// break; -// case 1: -// words = gSaveBlock1Ptr->unk2BBC; -// break; -// case 2: -// words = gSaveBlock1Ptr->unk2BC8; -// break; -// case 3: -// words = gSaveBlock1Ptr->unk2BD4; -// break; -// case 4: -// words = gSaveBlock1Ptr->mail[gSpecialVar_0x8005].words; -// break; -// case 6: -// oldMan = &gSaveBlock1Ptr->oldMan; -// for (i=0; i<6; i++) -// { -// oldMan->oldMan1.mauvilleOldMan_ecArray2[i] = oldMan->oldMan1.mauvilleOldMan_ecArray[i]; -// } -// words = oldMan->oldMan1.mauvilleOldMan_ecArray2; -// break; -// case 5: -// words = gSaveBlock1Ptr->tvShows[gSpecialVar_0x8005].bravoTrainer.var04; -// sizeParam = gSpecialVar_0x8006; -// break; -// case 7: -// words = &gSaveBlock1Ptr->tvShows[gSpecialVar_0x8005].fanclubOpinions.var1C[gSpecialVar_0x8006]; -// sizeParam = 1; -// break; -// case 8: -// words = &gSaveBlock1Ptr->tvShows[gSpecialVar_0x8005].recentHappenings.var02; -// sizeParam = 0; -// break; -// case 9: -// words = NULL; -// break; -// case 10: -// words = &gSaveBlock1Ptr->gabbyAndTyData.quote; -// *words = -1; -// sizeParam = 1; -// break; -// case 11: -// words = &gSaveBlock1Ptr->tvShows[gSpecialVar_0x8005].bravoTrainer.var04[gSpecialVar_0x8006]; -// sizeParam = 0; -// break; -// case 12: -// words = gSaveBlock1Ptr->tvShows[gSpecialVar_0x8005].fanclubOpinions.var18; -// sizeParam = 1; -// break; -// case 13: -// words = (u16 *)gStringVar3; -// sub_811F88C(words, 2); -// break; -// case 14: -// words = -// default: -// return; -// } -// overworld_free_bg_tilemaps(); -// sub_811A20C(gSpecialVar_0x8004, words, sub_80861B0, sizeParam); -//} + +void easy_chat_input_maybe(void) +{ + int i; + u16 *words; + OldMan *oldMan; + u8 sizeParam = 3; + switch (gSpecialVar_0x8004) + { + case 0: + words = gSaveBlock1Ptr->unk2BB0; + break; + case 1: + words = gSaveBlock1Ptr->unk2BBC; + break; + case 2: + words = gSaveBlock1Ptr->unk2BC8; + break; + case 3: + words = gSaveBlock1Ptr->unk2BD4; + break; + case 4: + words = gSaveBlock1Ptr->mail[gSpecialVar_0x8005].words; + break; + case 6: + oldMan = &gSaveBlock1Ptr->oldMan; + for (i = 0; i < 6; i ++) + { + oldMan->oldMan1.mauvilleOldMan_ecArray2[i] = oldMan->oldMan1.mauvilleOldMan_ecArray[i]; + } + words = oldMan->oldMan1.mauvilleOldMan_ecArray2; + break; + case 5: + words = gSaveBlock1Ptr->tvShows[gSpecialVar_0x8005].bravoTrainer.words; + sizeParam = gSpecialVar_0x8006; + break; + case 7: + words = &gSaveBlock1Ptr->tvShows[gSpecialVar_0x8005].fanclubOpinions.words[gSpecialVar_0x8006]; + sizeParam = 1; + break; + case 8: + words = gSaveBlock1Ptr->tvShows[gSpecialVar_0x8005].unkShow04.words; + sizeParam = 0; + break; + case 9: + words = (u16 *)gStringVar3; + words[0] = gSaveBlock1Ptr->easyChatPairs[0].words[0]; + words[1] = gSaveBlock1Ptr->easyChatPairs[0].words[1]; + break; + case 10: + words = gSaveBlock1Ptr->gabbyAndTyData.quote; + *words = -1; + sizeParam = 1; + break; + case 11: + words = &gSaveBlock1Ptr->tvShows[gSpecialVar_0x8005].bravoTrainer.words[gSpecialVar_0x8006]; + sizeParam = 0; + break; + case 12: + words = gSaveBlock1Ptr->tvShows[gSpecialVar_0x8005].fanclubOpinions.words18; + sizeParam = 1; + break; + case 13: + words = (u16 *)gStringVar3; + InitializeEasyChatWordArray(words, 2); + break; + case 14: + words = gSaveBlock1Ptr->tvShows[gSpecialVar_0x8005].fanClubSpecial.words; + words[0] = -1; + sizeParam = 2; + break; + case 15: + words = gSaveBlock1Ptr->lilycoveLady.quiz.unk_016; + break; + case 16: + return; + case 17: + words = gSaveBlock1Ptr->lilycoveLady.quiz.unk_002; + break; + case 18: + words = gSaveBlock1Ptr->lilycoveLady.quiz.unk_014; + break; + case 19: + words = gSaveBlock2Ptr->unk_104; + break; + case 20: + words = sub_801B058(); + break; + default: + return; + } + overworld_free_bg_tilemaps(); + sub_811A20C(gSpecialVar_0x8004, words, sub_80861B0, sizeParam); +} diff --git a/src/lilycove_lady.c b/src/lilycove_lady.c index 3b7ae49f2e..356b1a4b75 100644 --- a/src/lilycove_lady.c +++ b/src/lilycove_lady.c @@ -508,7 +508,7 @@ static void sub_818DF00(void) { gUnknown_0203CD68->unk_002[i] = gUnknown_0860B1A4[v0][i]; } - gUnknown_0203CD68->unk_014 = gUnknown_0860B1E4[v0]; + gUnknown_0203CD68->unk_014[0] = gUnknown_0860B1E4[v0]; gUnknown_0203CD68->itemId = gUnknown_0860B204[v0]; gUnknown_0203CD68->unk_02b = v0; gUnknown_0203CD68->playerName[0] = EOS; @@ -525,8 +525,8 @@ static void SetLilycoveQuizLady(void) { gUnknown_0203CD68->unk_002[i] = -1; } - gUnknown_0203CD68->unk_014 = -1; - gUnknown_0203CD68->unk_016 = -1; + gUnknown_0203CD68->unk_014[0] = -1; + gUnknown_0203CD68->unk_016[0] = -1; for (i = 0; i < 4; i ++) { gUnknown_0203CD68->playerTrainerId[i] = 0; @@ -544,7 +544,7 @@ static void sub_818E004(void) gUnknown_0203CD68->id = LILYCOVE_LADY_QUIZ; gUnknown_0203CD68->phase = 0; gUnknown_0203CD68->unk_02a = 0; - gUnknown_0203CD68->unk_016 = -1; + gUnknown_0203CD68->unk_016[0] = -1; } u8 sub_818E038(void) @@ -572,7 +572,7 @@ u8 sub_818E06C(void) struct LilycoveLadyQuiz *quiz; quiz = &gSaveBlock1Ptr->lilycoveLady.quiz; - if (sub_811F8D8(quiz->unk_014) == 0) + if (sub_811F8D8(quiz->unk_014[0]) == 0) { i = quiz->unk_02b; do @@ -586,7 +586,7 @@ u8 sub_818E06C(void) { quiz->unk_002[j] = gUnknown_0860B1A4[i][j]; } - quiz->unk_014 = gUnknown_0860B1E4[i]; + quiz->unk_014[0] = gUnknown_0860B1E4[i]; quiz->itemId = gUnknown_0860B204[i]; quiz->unk_02b = i; quiz->playerName[0] = EOS; @@ -777,8 +777,8 @@ void sub_818E2FC(void) bool8 sub_818E308(void) { gUnknown_0203CD68 = &gSaveBlock1Ptr->lilycoveLady.quiz; - CopyEasyChatWord(gStringVar1, gUnknown_0203CD68->unk_014); - CopyEasyChatWord(gStringVar2, gUnknown_0203CD68->unk_016); + CopyEasyChatWord(gStringVar1, gUnknown_0203CD68->unk_014[0]); + CopyEasyChatWord(gStringVar2, gUnknown_0203CD68->unk_016[0]); return StringCompare(gStringVar1, gStringVar2) ? FALSE : TRUE; } @@ -803,7 +803,7 @@ void sub_818E39C(void) void sub_818E3BC(void) { gUnknown_0203CD68 = &gSaveBlock1Ptr->lilycoveLady.quiz; - gUnknown_0203CD68->unk_016 = -1; + gUnknown_0203CD68->unk_016[0] = -1; } void sub_818E3E0(void) @@ -834,7 +834,7 @@ void sub_818E430(void) { gUnknown_0203CD68->unk_002[i] = -1; } - gUnknown_0203CD68->unk_014 = -1; + gUnknown_0203CD68->unk_014[0] = -1; } void sub_818E47C(void) @@ -871,7 +871,7 @@ void sub_818E510(void) void sub_818E538(void) { gUnknown_0203CD68 = &gSaveBlock1Ptr->lilycoveLady.quiz; - CopyEasyChatWord(gStringVar3, gUnknown_0203CD68->unk_014); + CopyEasyChatWord(gStringVar3, gUnknown_0203CD68->unk_014[0]); } void sub_818E564(void) From 46068c0a6fd520f9dd0823729c5b88b7ae021f59 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Thu, 2 Nov 2017 19:34:19 -0400 Subject: [PATCH 06/12] sub_811A7E4 --- asm/easy_chat.s | 61 ------------------------------------------------- src/easy_chat.c | 43 ++++++++++++++++++++++++++++------ 2 files changed, 36 insertions(+), 68 deletions(-) diff --git a/asm/easy_chat.s b/asm/easy_chat.s index 206f2d9c41..d35d441da9 100644 --- a/asm/easy_chat.s +++ b/asm/easy_chat.s @@ -5,67 +5,6 @@ .text - thumb_func_start sub_811A7E4 -sub_811A7E4: @ 811A7E4 - push {lr} - bl UpdatePaletteFade - ldr r0, =gMain - movs r1, 0x87 - lsls r1, 3 - adds r0, r1 - ldrb r0, [r0] - cmp r0, 0 - beq _0811A804 - cmp r0, 0x1 - beq _0811A80E - b _0811A840 - .pool -_0811A804: - movs r0, 0x1 - movs r1, 0 - bl fade_screen - b _0811A840 -_0811A80E: - ldr r0, =gPaletteFade - ldrb r1, [r0, 0x7] - movs r0, 0x80 - ands r0, r1 - cmp r0, 0 - bne _0811A84E - ldr r0, =gSaveBlock1Ptr - ldr r0, [r0] - ldr r1, =0x00003b58 - adds r0, r1 - ldr r1, =0x0000ffff - strh r1, [r0, 0x16] - bl overworld_free_bg_tilemaps - bl sub_811A8F0 - b _0811A84E - .pool -_0811A840: - ldr r1, =gMain - movs r0, 0x87 - lsls r0, 3 - adds r1, r0 - ldrb r0, [r1] - adds r0, 0x1 - strb r0, [r1] -_0811A84E: - pop {r0} - bx r0 - .pool - thumb_func_end sub_811A7E4 - - thumb_func_start sub_811A858 -sub_811A858: @ 811A858 - push {lr} - ldr r0, =sub_811A7E4 - bl SetMainCallback2 - pop {r0} - bx r0 - .pool - thumb_func_end sub_811A858 - thumb_func_start sub_811A868 sub_811A868: @ 811A868 push {lr} diff --git a/src/easy_chat.c b/src/easy_chat.c index 0d02e0d5ae..c2da4dc8a7 100644 --- a/src/easy_chat.c +++ b/src/easy_chat.c @@ -7,6 +7,7 @@ #include "task.h" #include "main.h" #include "link.h" +#include "field_weather.h" #include "window.h" #include "palette.h" #include "event_data.h" @@ -26,18 +27,19 @@ static void sub_811A2C0(u8); static void sub_811A278(void); static bool8 sub_811A428(u8); static void sub_811A2FC(u8); -/*static*/ u16 sub_811AAAC(void); -/*static*/ bool32 sub_811A88C(u16); -/*static*/ void sub_811C158(u16); -/*static*/ bool8 sub_811C170(void); -/*static*/ void sub_811A8A4(u16); /*static*/ void sub_811A4D0(MainCallback); -bool8 sub_811F28C(void); +/*static*/ bool32 sub_811A88C(u16); +/*static*/ void sub_811A8A4(u16); +void sub_811A8F0(void); bool8 sub_811A95C(u8, u32, u8); +void sub_811AA90(void); +/*static*/ u16 sub_811AAAC(void); bool8 sub_811BF8C(void); bool8 sub_811BFA4(void); void sub_811C13C(void); -void sub_811AA90(void); +/*static*/ void sub_811C158(u16); +/*static*/ bool8 sub_811C170(void); +bool8 sub_811F28C(void); void sub_811F2B8(void); // Static ROM declarations @@ -304,3 +306,30 @@ void easy_chat_input_maybe(void) sub_811A20C(gSpecialVar_0x8004, words, sub_80861B0, sizeParam); } +static void sub_811A7E4(void) +{ + LilycoveLady *lilycoveLady; + + UpdatePaletteFade(); + switch (gMain.state) + { + case 0: + fade_screen(1, 0); + break; + case 1: + if (!gPaletteFade.active) + { + lilycoveLady = &gSaveBlock1Ptr->lilycoveLady; + lilycoveLady->quiz.unk_016[0] = -1; + overworld_free_bg_tilemaps(); + sub_811A8F0(); + } + return; + } + gMain.state ++; +} + +void sub_811A858(void) +{ + SetMainCallback2(sub_811A7E4); +} From 85eb28ba42f035bbf5ee2e2ffd2fecee1bf55990 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Thu, 2 Nov 2017 19:44:03 -0400 Subject: [PATCH 07/12] through sub_811A8A4 --- asm/easy_chat.s | 58 ------------------------------------------------- src/easy_chat.c | 37 +++++++++++++++++++++++++++++-- 2 files changed, 35 insertions(+), 60 deletions(-) diff --git a/asm/easy_chat.s b/asm/easy_chat.s index d35d441da9..5c89b1528d 100644 --- a/asm/easy_chat.s +++ b/asm/easy_chat.s @@ -5,64 +5,6 @@ .text - thumb_func_start sub_811A868 -sub_811A868: @ 811A868 - push {lr} - lsls r0, 16 - lsrs r2, r0, 16 - movs r0, 0 - ldr r1, =gUnknown_08597530 -_0811A872: - ldrh r3, [r1] - cmp r2, r3 - beq _0811A884 - adds r1, 0x8 - adds r0, 0x1 - cmp r0, 0x3 - bls _0811A872 - movs r0, 0x1 - negs r0, r0 -_0811A884: - pop {r1} - bx r1 - .pool - thumb_func_end sub_811A868 - - thumb_func_start sub_811A88C -sub_811A88C: @ 811A88C - push {lr} - lsls r0, 16 - lsrs r0, 16 - bl sub_811A868 - adds r1, r0, 0 - mvns r1, r1 - negs r0, r1 - orrs r0, r1 - lsrs r0, 31 - pop {r1} - bx r1 - thumb_func_end sub_811A88C - - thumb_func_start sub_811A8A4 -sub_811A8A4: @ 811A8A4 - push {r4,lr} - lsls r0, 16 - lsrs r0, 16 - bl sub_811A868 - adds r4, r0, 0 - bl ResetTasks - ldr r0, =gUnknown_08597530 - lsls r4, 3 - adds r0, 0x4 - adds r4, r0 - ldr r0, [r4] - bl sub_811A4D0 - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_811A8A4 - thumb_func_start sub_811A8CC sub_811A8CC: @ 811A8CC push {lr} diff --git a/src/easy_chat.c b/src/easy_chat.c index c2da4dc8a7..de66fb9eb5 100644 --- a/src/easy_chat.c +++ b/src/easy_chat.c @@ -28,8 +28,8 @@ static void sub_811A278(void); static bool8 sub_811A428(u8); static void sub_811A2FC(u8); /*static*/ void sub_811A4D0(MainCallback); -/*static*/ bool32 sub_811A88C(u16); -/*static*/ void sub_811A8A4(u16); +static bool32 sub_811A88C(u16); +static void sub_811A8A4(u16); void sub_811A8F0(void); bool8 sub_811A95C(u8, u32, u8); void sub_811AA90(void); @@ -46,6 +46,11 @@ void sub_811F2B8(void); // .rodata +extern const struct { + u16 word; + MainCallback callback; +} gUnknown_08597530[4]; + // .text void sub_811A20C(u8 kind, u16 *words, MainCallback callback, u8 sizeParam) @@ -333,3 +338,31 @@ void sub_811A858(void) { SetMainCallback2(sub_811A7E4); } + +static int sub_811A868(u16 word) +{ + int i; + + for (i = 0; i < ARRAY_COUNT(gUnknown_08597530); i ++) + { + if (word == gUnknown_08597530[i].word) + { + return i; + } + } + return -1; +} + +static bool32 sub_811A88C(u16 word) +{ + return sub_811A868(word) == -1 ? FALSE : TRUE; +} + +static void sub_811A8A4(u16 word) +{ + int i; + + i = sub_811A868(word); + ResetTasks(); + sub_811A4D0(gUnknown_08597530[i].callback); +} From 1049cd670d115c114f616e9118bc0fc9fb5fac64 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Thu, 2 Nov 2017 19:48:43 -0400 Subject: [PATCH 08/12] through sub_811A938 --- asm/easy_chat.s | 64 ------------------------------------------------- src/easy_chat.c | 22 ++++++++++++++++- 2 files changed, 21 insertions(+), 65 deletions(-) diff --git a/asm/easy_chat.s b/asm/easy_chat.s index 5c89b1528d..2e2284aac1 100644 --- a/asm/easy_chat.s +++ b/asm/easy_chat.s @@ -5,70 +5,6 @@ .text - thumb_func_start sub_811A8CC -sub_811A8CC: @ 811A8CC - push {lr} - ldr r0, =gSaveBlock1Ptr - ldr r1, [r0] - ldr r0, =0x00003b6e - adds r1, r0 - ldr r2, =sub_80861B0 - movs r0, 0xF - movs r3, 0x3 - bl sub_811A20C - pop {r0} - bx r0 - .pool - thumb_func_end sub_811A8CC - - thumb_func_start sub_811A8F0 -sub_811A8F0: @ 811A8F0 - push {lr} - ldr r0, =gSaveBlock1Ptr - ldr r1, [r0] - ldr r0, =0x00003b5a - adds r1, r0 - ldr r2, =sub_80861B0 - movs r0, 0x10 - movs r3, 0x3 - bl sub_811A20C - pop {r0} - bx r0 - .pool - thumb_func_end sub_811A8F0 - - thumb_func_start sub_811A914 -sub_811A914: @ 811A914 - push {lr} - ldr r0, =gSaveBlock1Ptr - ldr r1, [r0] - ldr r0, =0x00003b6c - adds r1, r0 - ldr r2, =sub_80861B0 - movs r0, 0x12 - movs r3, 0x3 - bl sub_811A20C - pop {r0} - bx r0 - .pool - thumb_func_end sub_811A914 - - thumb_func_start sub_811A938 -sub_811A938: @ 811A938 - push {lr} - ldr r0, =gSaveBlock1Ptr - ldr r1, [r0] - ldr r0, =0x00003b5a - adds r1, r0 - ldr r2, =sub_80861B0 - movs r0, 0x11 - movs r3, 0x3 - bl sub_811A20C - pop {r0} - bx r0 - .pool - thumb_func_end sub_811A938 - thumb_func_start sub_811A95C sub_811A95C: @ 811A95C push {r4-r7,lr} diff --git a/src/easy_chat.c b/src/easy_chat.c index de66fb9eb5..c1a68f4e25 100644 --- a/src/easy_chat.c +++ b/src/easy_chat.c @@ -30,7 +30,7 @@ static void sub_811A2FC(u8); /*static*/ void sub_811A4D0(MainCallback); static bool32 sub_811A88C(u16); static void sub_811A8A4(u16); -void sub_811A8F0(void); +static void sub_811A8F0(void); bool8 sub_811A95C(u8, u32, u8); void sub_811AA90(void); /*static*/ u16 sub_811AAAC(void); @@ -366,3 +366,23 @@ static void sub_811A8A4(u16 word) ResetTasks(); sub_811A4D0(gUnknown_08597530[i].callback); } + +static void sub_811A8CC(void) +{ + sub_811A20C(0xF, gSaveBlock1Ptr->lilycoveLady.quiz.unk_016, sub_80861B0, 3); +} + +static void sub_811A8F0(void) +{ + sub_811A20C(0x10, gSaveBlock1Ptr->lilycoveLady.quiz.unk_002, sub_80861B0, 3); +} + +static void sub_811A914(void) +{ + sub_811A20C(0x12, gSaveBlock1Ptr->lilycoveLady.quiz.unk_014, sub_80861B0, 3); +} + +static void sub_811A938(void) +{ + sub_811A20C(0x11, gSaveBlock1Ptr->lilycoveLady.quiz.unk_002, sub_80861B0, 3); +} From 881d222621a0f92d8548ba70bb1c5dbdfcf0555f Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Thu, 2 Nov 2017 20:37:03 -0400 Subject: [PATCH 09/12] sub_811A95C --- asm/easy_chat.s | 153 ------------------------------------------------ src/easy_chat.c | 96 ++++++++++++++++++++++++++++-- 2 files changed, 92 insertions(+), 157 deletions(-) diff --git a/asm/easy_chat.s b/asm/easy_chat.s index 2e2284aac1..efd27ccf7e 100644 --- a/asm/easy_chat.s +++ b/asm/easy_chat.s @@ -5,159 +5,6 @@ .text - thumb_func_start sub_811A95C -sub_811A95C: @ 811A95C - push {r4-r7,lr} - mov r7, r8 - push {r7} - mov r8, r1 - lsls r0, 24 - lsrs r5, r0, 24 - lsls r2, 24 - lsrs r6, r2, 24 - ldr r4, =gUnknown_0203A118 - movs r0, 0x50 - bl Alloc - str r0, [r4] - cmp r0, 0 - bne _0811A984 - movs r0, 0 - b _0811AA7E - .pool -_0811A984: - movs r7, 0 - strb r5, [r0] - ldr r0, [r4] - mov r1, r8 - str r1, [r0, 0x38] - strb r7, [r0, 0x5] - ldr r0, [r4] - strb r7, [r0, 0x6] - ldr r0, [r4] - strb r7, [r0, 0x9] - ldr r0, [r4] - strb r6, [r0, 0x12] - ldr r0, [r4] - strb r7, [r0, 0x13] - adds r0, r5, 0 - bl sub_811BCC8 - lsls r0, 24 - lsrs r6, r0, 24 - cmp r5, 0x10 - bne _0811A9C6 - ldr r0, [r4] - adds r0, 0x14 - bl sub_811BDF0 - ldr r0, [r4] - adds r1, r0, 0 - adds r1, 0x14 - str r1, [r0, 0x34] - movs r1, 0x7 - strb r1, [r0, 0x4] - lsls r0, r6, 1 - b _0811A9DE -_0811A9C6: - ldr r0, [r4] - strb r7, [r0, 0x4] - ldr r3, [r4] - ldr r1, =gUnknown_08597550 - lsls r2, r6, 1 - adds r0, r2, r6 - lsls r0, 3 - adds r1, 0x4 - adds r0, r1 - ldr r0, [r0] - str r0, [r3, 0x34] - adds r0, r2, 0 -_0811A9DE: - ldr r3, =gUnknown_0203A118 - ldr r2, [r3] - ldr r1, =gUnknown_08597550 - adds r0, r6 - lsls r0, 3 - adds r0, r1 - ldrb r1, [r0, 0x1] - strb r1, [r2, 0x2] - ldr r1, [r3] - ldrb r0, [r0, 0x2] - strb r0, [r1, 0x3] - ldr r0, [r3] - ldrb r2, [r0, 0x2] - ldrb r1, [r0, 0x3] - adds r4, r2, 0 - muls r4, r1 - adds r1, r4, 0 - strb r1, [r0, 0x7] - ldr r0, [r3] - strb r6, [r0, 0x1] - ldr r1, [r3] - ldrb r0, [r1, 0x7] - adds r4, r3, 0 - cmp r0, 0x9 - bls _0811AA14 - movs r0, 0x9 - strb r0, [r1, 0x7] -_0811AA14: - mov r0, r8 - cmp r0, 0 - beq _0811AA34 - ldr r0, [r4] - adds r1, r0, 0 - adds r1, 0x3C - ldrb r2, [r0, 0x7] - mov r0, r8 - bl CpuSet - b _0811AA64 - .pool -_0811AA34: - movs r3, 0 - ldr r0, [r4] - ldrb r0, [r0, 0x7] - cmp r3, r0 - bge _0811AA5C - adds r6, r4, 0 - ldr r1, =0x0000ffff - adds r5, r1, 0 -_0811AA44: - ldr r2, [r6] - lsls r0, r3, 1 - adds r1, r2, 0 - adds r1, 0x3C - adds r1, r0 - ldrh r0, [r1] - orrs r0, r5 - strh r0, [r1] - adds r3, 0x1 - ldrb r2, [r2, 0x7] - cmp r3, r2 - blt _0811AA44 -_0811AA5C: - ldr r1, [r4] - adds r0, r1, 0 - adds r0, 0x3C - str r0, [r1, 0x38] -_0811AA64: - bl sub_811F3AC - ldr r1, =gUnknown_0203A118 - ldr r2, [r1] - lsls r0, 24 - lsrs r0, 24 - subs r0, 0x1 - lsrs r1, r0, 31 - adds r0, r1 - asrs r0, 1 - adds r0, 0x1 - strb r0, [r2, 0xD] - movs r0, 0x1 -_0811AA7E: - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r1} - bx r1 - .pool - thumb_func_end sub_811A95C - thumb_func_start sub_811AA90 sub_811AA90: @ 811AA90 push {r4,lr} diff --git a/src/easy_chat.c b/src/easy_chat.c index c1a68f4e25..6a04d6514b 100644 --- a/src/easy_chat.c +++ b/src/easy_chat.c @@ -1,6 +1,7 @@ // Includes #include "global.h" +#include "malloc.h" #include "songs.h" #include "sound.h" #include "overworld.h" @@ -23,6 +24,31 @@ #define EZCHAT_TASK_SIZE 7 // Static RAM declarations + +EWRAM_DATA struct { + u8 kind; + u8 unk_01; + u8 unk_02; + u8 unk_03; + u8 unk_04; + u8 unk_05; + u8 unk_06; + u8 unk_07; + u8 unk_08; + u8 unk_09; + u8 filler_0a[0x3]; + u8 unk_0d; + u8 unk_0e[0x4]; + u8 sizeParam; + u8 unk_13; + u8 unk_14[0x20]; + const u8 *src; + const u16 *words; + u16 ecWordBuffer[9]; +} *gUnknown_0203A118 = NULL; + +// Static ROM declarations + static void sub_811A2C0(u8); static void sub_811A278(void); static bool8 sub_811A428(u8); @@ -31,9 +57,11 @@ static void sub_811A2FC(u8); static bool32 sub_811A88C(u16); static void sub_811A8A4(u16); static void sub_811A8F0(void); -bool8 sub_811A95C(u8, u32, u8); +static bool8 sub_811A95C(u8, u16 *, u8); void sub_811AA90(void); /*static*/ u16 sub_811AAAC(void); +u8 sub_811BCC8(u8); +void sub_811BDF0(u8 *); bool8 sub_811BF8C(void); bool8 sub_811BFA4(void); void sub_811C13C(void); @@ -41,8 +69,7 @@ void sub_811C13C(void); /*static*/ bool8 sub_811C170(void); bool8 sub_811F28C(void); void sub_811F2B8(void); - -// Static ROM declarations +u8 sub_811F3AC(void); // .rodata @@ -50,6 +77,14 @@ extern const struct { u16 word; MainCallback callback; } gUnknown_08597530[4]; +extern const struct { + u8 unk_00; + u8 unk_01; + u8 unk_02; + u8 unk_03; + u8 *data; + u8 filler_08[16]; +} gUnknown_08597550[]; // .text @@ -184,7 +219,7 @@ static bool8 sub_811A428(u8 taskId) } break; case 2: - if (!sub_811A95C(data[EZCHAT_TASK_KIND], GetWordTaskArg(taskId, EZCHAT_TASK_WORDS), data[EZCHAT_TASK_SIZE])) + if (!sub_811A95C(data[EZCHAT_TASK_KIND], (u16 *)GetWordTaskArg(taskId, EZCHAT_TASK_WORDS), data[EZCHAT_TASK_SIZE])) { sub_811A4D0((MainCallback)GetWordTaskArg(taskId, EZCHAT_TASK_MAINCALLBACK)); } @@ -386,3 +421,56 @@ static void sub_811A938(void) { sub_811A20C(0x11, gSaveBlock1Ptr->lilycoveLady.quiz.unk_002, sub_80861B0, 3); } + +static bool8 sub_811A95C(u8 kind, u16 *words, u8 sizeParam) +{ + u8 r6; + int i; + + gUnknown_0203A118 = malloc(sizeof(*gUnknown_0203A118)); + if (gUnknown_0203A118 == NULL) + { + return FALSE; + } + gUnknown_0203A118->kind = kind; + gUnknown_0203A118->words = words; + gUnknown_0203A118->unk_05 = 0; + gUnknown_0203A118->unk_06 = 0; + gUnknown_0203A118->unk_09 = 0; + gUnknown_0203A118->sizeParam = sizeParam; + gUnknown_0203A118->unk_13 = 0; + r6 = sub_811BCC8(kind); + if (kind == 0x10) + { + sub_811BDF0(gUnknown_0203A118->unk_14); + gUnknown_0203A118->src = gUnknown_0203A118->unk_14; + gUnknown_0203A118->unk_04 = 7; + } + else + { + gUnknown_0203A118->unk_04 = 0; + gUnknown_0203A118->src = gUnknown_08597550[r6].data; + } + gUnknown_0203A118->unk_02 = gUnknown_08597550[r6].unk_01; + gUnknown_0203A118->unk_03 = gUnknown_08597550[r6].unk_02; + gUnknown_0203A118->unk_07 = gUnknown_0203A118->unk_02 * gUnknown_0203A118->unk_03; + gUnknown_0203A118->unk_01 = r6; + if (gUnknown_0203A118->unk_07 > 9) + { + gUnknown_0203A118->unk_07 = 9; + } + if (words != NULL) + { + CpuCopy16(words, gUnknown_0203A118->ecWordBuffer, gUnknown_0203A118->unk_07 * sizeof(u16)); + } + else + { + for (i = 0; i < gUnknown_0203A118->unk_07; i ++) + { + gUnknown_0203A118->ecWordBuffer[i] = -1; + } + gUnknown_0203A118->words = gUnknown_0203A118->ecWordBuffer; + } + gUnknown_0203A118->unk_0d = (sub_811F3AC() - 1) / 2 + 1; + return TRUE; +} From 42c1164d721ad4fa8bd0583d142b8eea77724475 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Thu, 2 Nov 2017 20:51:13 -0400 Subject: [PATCH 10/12] sub_811AAAC --- asm/easy_chat.s | 87 ------------------------------------------------- src/easy_chat.c | 66 ++++++++++++++++++++++++++++++++----- 2 files changed, 58 insertions(+), 95 deletions(-) diff --git a/asm/easy_chat.s b/asm/easy_chat.s index efd27ccf7e..5cb89246c1 100644 --- a/asm/easy_chat.s +++ b/asm/easy_chat.s @@ -5,93 +5,6 @@ .text - thumb_func_start sub_811AA90 -sub_811AA90: @ 811AA90 - push {r4,lr} - ldr r4, =gUnknown_0203A118 - ldr r0, [r4] - cmp r0, 0 - beq _0811AAA2 - bl Free - movs r0, 0 - str r0, [r4] -_0811AAA2: - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_811AA90 - - thumb_func_start sub_811AAAC -sub_811AAAC: @ 811AAAC - push {lr} - ldr r0, =gUnknown_0203A118 - ldr r0, [r0] - ldrb r0, [r0, 0x4] - cmp r0, 0xA - bhi _0811AB3E - lsls r0, 2 - ldr r1, =_0811AACC - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .pool - .align 2, 0 -_0811AACC: - .4byte _0811AAF8 - .4byte _0811AAFE - .4byte _0811AB04 - .4byte _0811AB0A - .4byte _0811AB10 - .4byte _0811AB16 - .4byte _0811AB1C - .4byte _0811AB22 - .4byte _0811AB28 - .4byte _0811AB2E - .4byte _0811AB34 -_0811AAF8: - bl sub_811AB68 - b _0811AB38 -_0811AAFE: - bl sub_811ACDC - b _0811AB38 -_0811AB04: - bl sub_811AE44 - b _0811AB38 -_0811AB0A: - bl sub_811AF00 - b _0811AB38 -_0811AB10: - bl sub_811AF8C - b _0811AB38 -_0811AB16: - bl sub_811B040 - b _0811AB38 -_0811AB1C: - bl sub_811AFEC - b _0811AB38 -_0811AB22: - bl sub_811B08C - b _0811AB38 -_0811AB28: - bl sub_811B0BC - b _0811AB38 -_0811AB2E: - bl sub_811B0E8 - b _0811AB38 -_0811AB34: - bl sub_811B0F8 -_0811AB38: - lsls r0, 16 - lsrs r0, 16 - b _0811AB40 -_0811AB3E: - movs r0, 0 -_0811AB40: - pop {r1} - bx r1 - thumb_func_end sub_811AAAC - thumb_func_start sub_811AB44 sub_811AB44: @ 811AB44 push {lr} diff --git a/src/easy_chat.c b/src/easy_chat.c index 6a04d6514b..26f1f08b0f 100644 --- a/src/easy_chat.c +++ b/src/easy_chat.c @@ -53,13 +53,24 @@ static void sub_811A2C0(u8); static void sub_811A278(void); static bool8 sub_811A428(u8); static void sub_811A2FC(u8); -/*static*/ void sub_811A4D0(MainCallback); +static void sub_811A4D0(MainCallback); static bool32 sub_811A88C(u16); static void sub_811A8A4(u16); static void sub_811A8F0(void); -static bool8 sub_811A95C(u8, u16 *, u8); -void sub_811AA90(void); -/*static*/ u16 sub_811AAAC(void); +static bool8 EasyChat_AllocateResources(u8, u16 *, u8); +static void EasyChat_FreeResources(void); +static u16 sub_811AAAC(void); +u16 sub_811AB68(void); +u16 sub_811ACDC(void); +u16 sub_811AE44(void); +u16 sub_811AF00(void); +u16 sub_811AF8C(void); +u16 sub_811B040(void); +u16 sub_811AFEC(void); +u16 sub_811B08C(void); +u16 sub_811B0BC(void); +u16 sub_811B0E8(void); +u16 sub_811B0F8(void); u8 sub_811BCC8(u8); void sub_811BDF0(u8 *); bool8 sub_811BF8C(void); @@ -219,7 +230,7 @@ static bool8 sub_811A428(u8 taskId) } break; case 2: - if (!sub_811A95C(data[EZCHAT_TASK_KIND], (u16 *)GetWordTaskArg(taskId, EZCHAT_TASK_WORDS), data[EZCHAT_TASK_SIZE])) + if (!EasyChat_AllocateResources(data[EZCHAT_TASK_KIND], (u16 *)GetWordTaskArg(taskId, EZCHAT_TASK_WORDS), data[EZCHAT_TASK_SIZE])) { sub_811A4D0((MainCallback)GetWordTaskArg(taskId, EZCHAT_TASK_MAINCALLBACK)); } @@ -243,10 +254,10 @@ static bool8 sub_811A428(u8 taskId) return TRUE; } -void sub_811A4D0(MainCallback callback) +static void sub_811A4D0(MainCallback callback) { sub_811C13C(); - sub_811AA90(); + EasyChat_FreeResources(); sub_811F2B8(); FreeAllWindowBuffers(); SetMainCallback2(callback); @@ -422,7 +433,7 @@ static void sub_811A938(void) sub_811A20C(0x11, gSaveBlock1Ptr->lilycoveLady.quiz.unk_002, sub_80861B0, 3); } -static bool8 sub_811A95C(u8 kind, u16 *words, u8 sizeParam) +static bool8 EasyChat_AllocateResources(u8 kind, u16 *words, u8 sizeParam) { u8 r6; int i; @@ -474,3 +485,42 @@ static bool8 sub_811A95C(u8 kind, u16 *words, u8 sizeParam) gUnknown_0203A118->unk_0d = (sub_811F3AC() - 1) / 2 + 1; return TRUE; } + +static void EasyChat_FreeResources(void) +{ + if (gUnknown_0203A118 != NULL) + { + free(gUnknown_0203A118); + gUnknown_0203A118 = NULL; + } +} + +static u16 sub_811AAAC(void) +{ + switch (gUnknown_0203A118->unk_04) + { + case 0: + return sub_811AB68(); + case 1: + return sub_811ACDC(); + case 2: + return sub_811AE44(); + case 3: + return sub_811AF00(); + case 4: + return sub_811AF8C(); + case 5: + return sub_811B040(); + case 6: + return sub_811AFEC(); + case 7: + return sub_811B08C(); + case 8: + return sub_811B0BC(); + case 9: + return sub_811B0E8(); + case 10: + return sub_811B0F8(); + } + return 0; +} From 293dfc4823d6c984adc221b40be4e3705a3fa65b Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Thu, 2 Nov 2017 20:54:13 -0400 Subject: [PATCH 11/12] sub_811AB44 --- asm/easy_chat.s | 24 ------------------------ src/easy_chat.c | 15 ++++++++++++++- 2 files changed, 14 insertions(+), 25 deletions(-) diff --git a/asm/easy_chat.s b/asm/easy_chat.s index 5cb89246c1..764ed8b8e1 100644 --- a/asm/easy_chat.s +++ b/asm/easy_chat.s @@ -5,30 +5,6 @@ .text - thumb_func_start sub_811AB44 -sub_811AB44: @ 811AB44 - push {lr} - bl sub_811BA68 - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x2 - beq _0811AB5E - cmp r0, 0x2 - blt _0811AB62 - cmp r0, 0x8 - bgt _0811AB62 - cmp r0, 0x7 - blt _0811AB62 -_0811AB5E: - movs r0, 0x1 - b _0811AB64 -_0811AB62: - movs r0, 0 -_0811AB64: - pop {r1} - bx r1 - thumb_func_end sub_811AB44 - thumb_func_start sub_811AB68 sub_811AB68: @ 811AB68 push {r4-r7,lr} diff --git a/src/easy_chat.c b/src/easy_chat.c index 26f1f08b0f..9b69f1d0ae 100644 --- a/src/easy_chat.c +++ b/src/easy_chat.c @@ -65,12 +65,13 @@ u16 sub_811ACDC(void); u16 sub_811AE44(void); u16 sub_811AF00(void); u16 sub_811AF8C(void); -u16 sub_811B040(void); u16 sub_811AFEC(void); +u16 sub_811B040(void); u16 sub_811B08C(void); u16 sub_811B0BC(void); u16 sub_811B0E8(void); u16 sub_811B0F8(void); +u8 sub_811BA68(void); u8 sub_811BCC8(u8); void sub_811BDF0(u8 *); bool8 sub_811BF8C(void); @@ -524,3 +525,15 @@ static u16 sub_811AAAC(void) } return 0; } + +bool8 sub_811AB44(void) +{ + switch (sub_811BA68()) + { + case 2: + case 7: + case 8: + return TRUE; + } + return FALSE; +} From 6b84feaaf2ba492bef23a42c28603bbaa3ccd2e6 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Sat, 25 Nov 2017 13:19:06 -0500 Subject: [PATCH 12/12] nonmatching sub_811AB68 --- asm/easy_chat.s | 190 -------------------------------- src/easy_chat.c | 282 +++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 277 insertions(+), 195 deletions(-) diff --git a/asm/easy_chat.s b/asm/easy_chat.s index f1aee4b982..abc2e3429e 100644 --- a/asm/easy_chat.s +++ b/asm/easy_chat.s @@ -5,196 +5,6 @@ .text - thumb_func_start sub_811AB68 -sub_811AB68: @ 811AB68 - push {r4-r7,lr} - ldr r0, =gMain - ldrh r1, [r0, 0x2E] - movs r0, 0x1 - ands r0, r1 - cmp r0, 0 - beq _0811ABB8 - bl sub_811BF78 - ldr r1, =gUnknown_0203A118 - ldr r3, [r1] - movs r2, 0 - movs r0, 0x2 - strb r0, [r3, 0x4] - ldr r0, [r1] - strb r2, [r0, 0xA] - ldr r0, [r1] - strb r2, [r0, 0xB] - ldr r0, [r1] - strb r2, [r0, 0xC] - movs r0, 0x9 - b _0811ACCC - .pool -_0811AB9C: - movs r0, 0x20 - ands r0, r1 - cmp r0, 0 - bne _0811AC68 - movs r0, 0x80 - ands r0, r1 - cmp r0, 0 - bne _0811AC58 - movs r0, 0x10 - ands r0, r1 - cmp r0, 0 - bne _0811AC48 - movs r0, 0 - b _0811ACCC -_0811ABB8: - movs r0, 0x2 - ands r0, r1 - cmp r0, 0 - bne _0811AC78 - movs r0, 0x8 - ands r0, r1 - cmp r0, 0 - bne _0811AC7E - movs r0, 0x40 - ands r0, r1 - cmp r0, 0 - beq _0811AB9C - ldr r2, =gUnknown_0203A118 - ldr r1, [r2] - ldrb r0, [r1, 0x6] - subs r0, 0x1 -_0811ABD8: - strb r0, [r1, 0x6] -_0811ABDA: - adds r7, r2, 0 - adds r4, r7, 0 - ldr r2, [r4] - movs r0, 0x6 - ldrsb r0, [r2, r0] - ldr r6, =gUnknown_08597550 - cmp r0, 0 - bge _0811ABF8 - ldrb r0, [r2, 0x1] - lsls r1, r0, 1 - adds r1, r0 - lsls r1, 3 - adds r1, r6 - ldrb r0, [r1, 0x2] - strb r0, [r2, 0x6] -_0811ABF8: - ldr r3, [r4] - movs r2, 0x6 - ldrsb r2, [r3, r2] - adds r5, r6, 0 - ldrb r1, [r3, 0x1] - lsls r0, r1, 1 - adds r0, r1 - lsls r0, 3 - adds r0, r5 - ldrb r0, [r0, 0x2] - cmp r2, r0 - ble _0811AC14 - movs r0, 0 - strb r0, [r3, 0x6] -_0811AC14: - ldr r3, [r4] - movs r2, 0x6 - ldrsb r2, [r3, r2] - ldrb r1, [r3, 0x1] - lsls r0, r1, 1 - adds r0, r1 - lsls r0, 3 - adds r1, r0, r5 - ldrb r0, [r1, 0x2] - cmp r2, r0 - bne _0811AC88 - movs r0, 0x5 - ldrsb r0, [r3, r0] - cmp r0, 0x2 - ble _0811AC36 - movs r0, 0x2 - strb r0, [r3, 0x5] -_0811AC36: - ldr r1, [r4] - movs r0, 0x1 - strb r0, [r1, 0x4] - movs r0, 0x3 - b _0811ACCC - .pool -_0811AC48: - ldr r2, =gUnknown_0203A118 - ldr r1, [r2] - ldrb r0, [r1, 0x5] - adds r0, 0x1 - strb r0, [r1, 0x5] - b _0811ABDA - .pool -_0811AC58: - ldr r2, =gUnknown_0203A118 - ldr r1, [r2] - ldrb r0, [r1, 0x6] - adds r0, 0x1 - b _0811ABD8 - .pool -_0811AC68: - ldr r2, =gUnknown_0203A118 - ldr r1, [r2] - ldrb r0, [r1, 0x5] - subs r0, 0x1 - strb r0, [r1, 0x5] - b _0811ABDA - .pool -_0811AC78: - bl sub_811B150 - b _0811AC82 -_0811AC7E: - bl sub_811B1B4 -_0811AC82: - lsls r0, 16 - lsrs r0, 16 - b _0811ACCC -_0811AC88: - movs r0, 0x5 - ldrsb r0, [r3, r0] - cmp r0, 0 - bge _0811AC96 - ldrb r0, [r1, 0x1] - subs r0, 0x1 - strb r0, [r3, 0x5] -_0811AC96: - ldr r3, [r4] - movs r2, 0x5 - ldrsb r2, [r3, r2] - ldrb r1, [r3, 0x1] - lsls r0, r1, 1 - adds r0, r1 - lsls r0, 3 - adds r0, r6 - ldrb r0, [r0, 0x1] - cmp r2, r0 - blt _0811ACB0 - movs r0, 0 - strb r0, [r3, 0x5] -_0811ACB0: - bl sub_811AB44 - cmp r0, 0 - beq _0811ACCA - ldr r2, [r7] - ldr r0, [r2, 0x4] - ldr r1, =0x00ffff00 - ands r0, r1 - ldr r1, =0x00040100 - cmp r0, r1 - bne _0811ACCA - movs r0, 0 - strb r0, [r2, 0x5] -_0811ACCA: - movs r0, 0x2 -_0811ACCC: - pop {r4-r7} - pop {r1} - bx r1 - .pool - thumb_func_end sub_811AB68 - thumb_func_start sub_811ACDC sub_811ACDC: @ 811ACDC push {r4-r6,lr} diff --git a/src/easy_chat.c b/src/easy_chat.c index 9b69f1d0ae..0ed5bdea97 100644 --- a/src/easy_chat.c +++ b/src/easy_chat.c @@ -31,12 +31,14 @@ EWRAM_DATA struct { u8 unk_02; u8 unk_03; u8 unk_04; - u8 unk_05; - u8 unk_06; + s8 unk_05; + s8 unk_06; u8 unk_07; u8 unk_08; u8 unk_09; - u8 filler_0a[0x3]; + u8 unk_0a; + u8 unk_0b; + u8 unk_0c; u8 unk_0d; u8 unk_0e[0x4]; u8 sizeParam; @@ -60,7 +62,7 @@ static void sub_811A8F0(void); static bool8 EasyChat_AllocateResources(u8, u16 *, u8); static void EasyChat_FreeResources(void); static u16 sub_811AAAC(void); -u16 sub_811AB68(void); +static u16 sub_811AB68(void); u16 sub_811ACDC(void); u16 sub_811AE44(void); u16 sub_811AF00(void); @@ -71,9 +73,12 @@ u16 sub_811B08C(void); u16 sub_811B0BC(void); u16 sub_811B0E8(void); u16 sub_811B0F8(void); +u16 sub_811B150(void); +u16 sub_811B1B4(void); u8 sub_811BA68(void); u8 sub_811BCC8(u8); void sub_811BDF0(u8 *); +void sub_811BF78(void); bool8 sub_811BF8C(void); bool8 sub_811BFA4(void); void sub_811C13C(void); @@ -526,7 +531,7 @@ static u16 sub_811AAAC(void) return 0; } -bool8 sub_811AB44(void) +bool32 sub_811AB44(void) { switch (sub_811BA68()) { @@ -537,3 +542,270 @@ bool8 sub_811AB44(void) } return FALSE; } + +#ifdef NONMATCHING +static u16 sub_811AB68(void) +{ + if (gMain.newKeys & A_BUTTON) + { + sub_811BF78(); + gUnknown_0203A118->unk_04 = 2; + gUnknown_0203A118->unk_0a = 0; + gUnknown_0203A118->unk_0b = 0; + gUnknown_0203A118->unk_0c = 0; + return 9; + } + else if (gMain.newKeys & B_BUTTON) + { // FIXME: See note below + return sub_811B150(); + } + else if (gMain.newKeys & START_BUTTON) + { // FIXME: See note below + return sub_811B1B4(); + } + else if (gMain.newKeys & DPAD_UP) + { + gUnknown_0203A118->unk_06--; + } + else if (gMain.newKeys & DPAD_LEFT) + { // FIXME: See note below + gUnknown_0203A118->unk_05--; + } + else if (gMain.newKeys & DPAD_DOWN) + { // FIXME: See note below + gUnknown_0203A118->unk_06++; + } + else if (gMain.newKeys & DPAD_RIGHT) + { // FIXME: See note below + gUnknown_0203A118->unk_05++; + } + else + { + return 0; + } + if (gUnknown_0203A118->unk_06 < 0) + { + gUnknown_0203A118->unk_06 = gUnknown_08597550[gUnknown_0203A118->unk_01].unk_02; + } + if (gUnknown_0203A118->unk_06 > gUnknown_08597550[gUnknown_0203A118->unk_01].unk_02) + { + gUnknown_0203A118->unk_06 = 0; + } + if (gUnknown_0203A118->unk_06 == gUnknown_08597550[gUnknown_0203A118->unk_01].unk_02) + { + if (gUnknown_0203A118->unk_05 > 2) + { + gUnknown_0203A118->unk_05 = 2; + } + gUnknown_0203A118->unk_04 = 1; + return 3; + } + /* + * FIXME: right, down, left, b, and start + * should be inserted here, but aren't + */ + if (gUnknown_0203A118->unk_05 < 0) + { + gUnknown_0203A118->unk_05 = gUnknown_08597550[gUnknown_0203A118->unk_01].unk_01 - 1; + } + if (gUnknown_0203A118->unk_05 >= gUnknown_08597550[gUnknown_0203A118->unk_01].unk_01) + { + gUnknown_0203A118->unk_05 = 0; + } + if (sub_811AB44() && gUnknown_0203A118->unk_05 == 1 && gUnknown_0203A118->unk_06 == 4) + { + gUnknown_0203A118->unk_05 = 0; + } + return 2; +} +#else +__attribute__((naked)) static u16 sub_811AB68(void) +{ + asm_unified("\tpush {r4-r7,lr}\n" + "\tldr r0, =gMain\n" + "\tldrh r1, [r0, 0x2E]\n" + "\tmovs r0, 0x1\n" + "\tands r0, r1\n" + "\tcmp r0, 0\n" + "\tbeq _0811ABB8\n" + "\tbl sub_811BF78\n" + "\tldr r1, =gUnknown_0203A118\n" + "\tldr r3, [r1]\n" + "\tmovs r2, 0\n" + "\tmovs r0, 0x2\n" + "\tstrb r0, [r3, 0x4]\n" + "\tldr r0, [r1]\n" + "\tstrb r2, [r0, 0xA]\n" + "\tldr r0, [r1]\n" + "\tstrb r2, [r0, 0xB]\n" + "\tldr r0, [r1]\n" + "\tstrb r2, [r0, 0xC]\n" + "\tmovs r0, 0x9\n" + "\tb _0811ACCC_return_r0\n" + "\t.pool\n" + "_0811AB9C:\n" + "\tmovs r0, 0x20\n" + "\tands r0, r1\n" + "\tcmp r0, 0\n" + "\tbne _0811AC68_dpad_left\n" + "\tmovs r0, 0x80\n" + "\tands r0, r1\n" + "\tcmp r0, 0\n" + "\tbne _0811AC58_dpad_down\n" + "\tmovs r0, 0x10\n" + "\tands r0, r1\n" + "\tcmp r0, 0\n" + "\tbne _0811AC48_dpad_right\n" + "\tmovs r0, 0\n" + "\tb _0811ACCC_return_r0\n" + "_0811ABB8:\n" + "\tmovs r0, 0x2\n" + "\tands r0, r1\n" + "\tcmp r0, 0\n" + "\tbne _0811AC78_b_button\n" + "\tmovs r0, 0x8\n" + "\tands r0, r1\n" + "\tcmp r0, 0\n" + "\tbne _0811AC7E_start_button\n" + "\tmovs r0, 0x40\n" + "\tands r0, r1\n" + "\tcmp r0, 0\n" + "\tbeq _0811AB9C\n" + "\tldr r2, =gUnknown_0203A118\n" + "\tldr r1, [r2]\n" + "\tldrb r0, [r1, 0x6]\n" + "\tsubs r0, 0x1\n" + "_0811ABD8:\n" + "\tstrb r0, [r1, 0x6]\n" + "_0811ABDA:\n" + "\tadds r7, r2, 0\n" + "\tadds r4, r7, 0\n" + "\tldr r2, [r4]\n" + "\tmovs r0, 0x6\n" + "\tldrsb r0, [r2, r0]\n" + "\tldr r6, =gUnknown_08597550\n" + "\tcmp r0, 0\n" + "\tbge _0811ABF8\n" + "\tldrb r0, [r2, 0x1]\n" + "\tlsls r1, r0, 1\n" + "\tadds r1, r0\n" + "\tlsls r1, 3\n" + "\tadds r1, r6\n" + "\tldrb r0, [r1, 0x2]\n" + "\tstrb r0, [r2, 0x6]\n" + "_0811ABF8:\n" + "\tldr r3, [r4]\n" + "\tmovs r2, 0x6\n" + "\tldrsb r2, [r3, r2]\n" + "\tadds r5, r6, 0\n" + "\tldrb r1, [r3, 0x1]\n" + "\tlsls r0, r1, 1\n" + "\tadds r0, r1\n" + "\tlsls r0, 3\n" + "\tadds r0, r5\n" + "\tldrb r0, [r0, 0x2]\n" + "\tcmp r2, r0\n" + "\tble _0811AC14\n" + "\tmovs r0, 0\n" + "\tstrb r0, [r3, 0x6]\n" + "_0811AC14:\n" + "\tldr r3, [r4]\n" + "\tmovs r2, 0x6\n" + "\tldrsb r2, [r3, r2]\n" + "\tldrb r1, [r3, 0x1]\n" + "\tlsls r0, r1, 1\n" + "\tadds r0, r1\n" + "\tlsls r0, 3\n" + "\tadds r1, r0, r5\n" + "\tldrb r0, [r1, 0x2]\n" + "\tcmp r2, r0\n" + "\tbne _0811AC88\n" + "\tmovs r0, 0x5\n" + "\tldrsb r0, [r3, r0]\n" + "\tcmp r0, 0x2\n" + "\tble _0811AC36\n" + "\tmovs r0, 0x2\n" + "\tstrb r0, [r3, 0x5]\n" + "_0811AC36:\n" + "\tldr r1, [r4]\n" + "\tmovs r0, 0x1\n" + "\tstrb r0, [r1, 0x4]\n" + "\tmovs r0, 0x3\n" + "\tb _0811ACCC_return_r0\n" + "\t.pool\n" + "_0811AC48_dpad_right:\n" + "\tldr r2, =gUnknown_0203A118\n" + "\tldr r1, [r2]\n" + "\tldrb r0, [r1, 0x5]\n" + "\tadds r0, 0x1\n" + "\tstrb r0, [r1, 0x5]\n" + "\tb _0811ABDA\n" + "\t.pool\n" + "_0811AC58_dpad_down:\n" + "\tldr r2, =gUnknown_0203A118\n" + "\tldr r1, [r2]\n" + "\tldrb r0, [r1, 0x6]\n" + "\tadds r0, 0x1\n" + "\tb _0811ABD8\n" + "\t.pool\n" + "_0811AC68_dpad_left:\n" + "\tldr r2, =gUnknown_0203A118\n" + "\tldr r1, [r2]\n" + "\tldrb r0, [r1, 0x5]\n" + "\tsubs r0, 0x1\n" + "\tstrb r0, [r1, 0x5]\n" + "\tb _0811ABDA\n" + "\t.pool\n" + "_0811AC78_b_button:\n" + "\tbl sub_811B150\n" + "\tb _0811AC82\n" + "_0811AC7E_start_button:\n" + "\tbl sub_811B1B4\n" + "_0811AC82:\n" + "\tlsls r0, 16\n" + "\tlsrs r0, 16\n" + "\tb _0811ACCC_return_r0\n" + "_0811AC88:\n" + "\tmovs r0, 0x5\n" + "\tldrsb r0, [r3, r0]\n" + "\tcmp r0, 0\n" + "\tbge _0811AC96\n" + "\tldrb r0, [r1, 0x1]\n" + "\tsubs r0, 0x1\n" + "\tstrb r0, [r3, 0x5]\n" + "_0811AC96:\n" + "\tldr r3, [r4]\n" + "\tmovs r2, 0x5\n" + "\tldrsb r2, [r3, r2]\n" + "\tldrb r1, [r3, 0x1]\n" + "\tlsls r0, r1, 1\n" + "\tadds r0, r1\n" + "\tlsls r0, 3\n" + "\tadds r0, r6\n" + "\tldrb r0, [r0, 0x1]\n" + "\tcmp r2, r0\n" + "\tblt _0811ACB0\n" + "\tmovs r0, 0\n" + "\tstrb r0, [r3, 0x5]\n" + "_0811ACB0:\n" + "\tbl sub_811AB44\n" + "\tcmp r0, 0\n" + "\tbeq _0811ACCA\n" + "\tldr r2, [r7]\n" + "\tldr r0, [r2, 0x4]\n" + "\tldr r1, =0x00ffff00\n" + "\tands r0, r1\n" + "\tldr r1, =0x00040100\n" + "\tcmp r0, r1\n" + "\tbne _0811ACCA\n" + "\tmovs r0, 0\n" + "\tstrb r0, [r2, 0x5]\n" + "_0811ACCA:\n" + "\tmovs r0, 0x2\n" + "_0811ACCC_return_r0:\n" + "\tpop {r4-r7}\n" + "\tpop {r1}\n" + "\tbx r1\n" + "\t.pool"); +} +#endif