From b105d20d1e0297d0c858fe99a0946e5c07da81c1 Mon Sep 17 00:00:00 2001 From: Marcus Huderle Date: Thu, 21 Feb 2019 17:40:20 -0600 Subject: [PATCH] Decompile chunk of easy_chat.c --- asm/easy_chat.s | 2635 --------------------------------------- data/easy_chat.s | 13 +- include/dewford_trend.h | 1 + include/strings.h | 9 + src/easy_chat.c | 2054 +++++++++++++++++++++++++----- 5 files changed, 1749 insertions(+), 2963 deletions(-) diff --git a/asm/easy_chat.s b/asm/easy_chat.s index 7a46f12c5..271d1bce1 100644 --- a/asm/easy_chat.s +++ b/asm/easy_chat.s @@ -5,2641 +5,6 @@ .text - thumb_func_start sub_811ACDC -sub_811ACDC: @ 811ACDC - push {r4-r6,lr} - ldr r2, =gMain - ldrh r1, [r2, 0x2E] - movs r0, 0x1 - ands r0, r1 - cmp r0, 0 - beq _0811AD4A - ldr r0, =gUnknown_0203A118 - ldr r0, [r0] - ldrb r0, [r0, 0x5] - lsls r0, 24 - asrs r0, 24 - cmp r0, 0x1 - beq _0811AD3E - b _0811AD24 - .pool -_0811AD04: - movs r0, 0x20 - ands r0, r2 - lsls r0, 16 - lsrs r3, r0, 16 - cmp r3, 0 - bne _0811ADE0 - movs r0, 0x80 - ands r0, r2 - cmp r0, 0 - bne _0811ADD0 - movs r0, 0x10 - ands r0, r2 - cmp r0, 0 - bne _0811ADC0 - movs r0, 0 - b _0811AE32 -_0811AD24: - cmp r0, 0x1 - bgt _0811AD2E - cmp r0, 0 - beq _0811AD38 - b _0811AD4A -_0811AD2E: - cmp r0, 0x2 - beq _0811ADF6 - cmp r0, 0x3 - beq _0811AD44 - b _0811AD4A -_0811AD38: - bl sub_811B184 - b _0811ADFA -_0811AD3E: - bl sub_811B150 - b _0811ADFA -_0811AD44: - bl sub_811B264 - b _0811ADFA -_0811AD4A: - ldrh r2, [r2, 0x2E] - movs r0, 0x2 - ands r0, r2 - cmp r0, 0 - bne _0811ADF0 - movs r0, 0x8 - ands r0, r2 - cmp r0, 0 - bne _0811ADF6 - movs r0, 0x40 - ands r0, r2 - cmp r0, 0 - beq _0811AD04 - ldr r2, =gUnknown_0203A118 - ldr r1, [r2] - ldrb r0, [r1, 0x6] - subs r0, 0x1 - strb r0, [r1, 0x6] -_0811AD6E: - adds r6, r2, 0 -_0811AD70: - adds r5, r6, 0 - ldr r4, [r5] - movs r3, 0x6 - ldrsb r3, [r4, r3] - ldr r2, =gUnknown_08597550 - ldrb r1, [r4, 0x1] - lsls r0, r1, 1 - adds r0, r1 - lsls r0, 3 - adds r1, r0, r2 - ldrb r0, [r1, 0x2] - cmp r3, r0 - bne _0811AE00 - bl sub_811BA3C - movs r2, 0x3 - cmp r0, 0 - beq _0811AD96 - movs r2, 0x4 -_0811AD96: - ldr r1, [r5] - movs r0, 0x5 - ldrsb r0, [r1, r0] - cmp r0, 0 - bge _0811ADA4 - subs r0, r2, 0x1 - strb r0, [r1, 0x5] -_0811ADA4: - ldr r1, [r5] - movs r0, 0x5 - ldrsb r0, [r1, r0] - cmp r0, r2 - blt _0811ADB2 - movs r0, 0 - strb r0, [r1, 0x5] -_0811ADB2: - movs r0, 0x3 - b _0811AE32 - .pool -_0811ADC0: - ldr r2, =gUnknown_0203A118 - ldr r1, [r2] - ldrb r0, [r1, 0x5] - adds r0, 0x1 - strb r0, [r1, 0x5] - b _0811AD6E - .pool -_0811ADD0: - ldr r1, =gUnknown_0203A118 - ldr r0, [r1] - strb r3, [r0, 0x6] - adds r6, r1, 0 - b _0811AD70 - .pool -_0811ADE0: - ldr r2, =gUnknown_0203A118 - ldr r1, [r2] - ldrb r0, [r1, 0x5] - subs r0, 0x1 - strb r0, [r1, 0x5] - b _0811AD6E - .pool -_0811ADF0: - bl sub_811B150 - b _0811ADFA -_0811ADF6: - bl sub_811B1B4 -_0811ADFA: - lsls r0, 16 - lsrs r0, 16 - b _0811AE32 -_0811AE00: - movs r0, 0x5 - ldrsb r0, [r4, r0] - ldrb r1, [r1, 0x1] - cmp r0, r1 - blt _0811AE0E - subs r0, r1, 0x1 - strb r0, [r4, 0x5] -_0811AE0E: - bl sub_811AB44 - cmp r0, 0 - beq _0811AE28 - ldr r2, [r6] - ldr r0, [r2, 0x4] - ldr r1, =0x00ffff00 - ands r0, r1 - ldr r1, =0x00040100 - cmp r0, r1 - bne _0811AE28 - movs r0, 0 - strb r0, [r2, 0x5] -_0811AE28: - ldr r0, =gUnknown_0203A118 - ldr r1, [r0] - movs r0, 0 - strb r0, [r1, 0x4] - movs r0, 0x2 -_0811AE32: - pop {r4-r6} - pop {r1} - bx r1 - .pool - thumb_func_end sub_811ACDC - - thumb_func_start sub_811AE44 -sub_811AE44: @ 811AE44 - push {lr} - ldr r1, =gMain - ldrh r2, [r1, 0x2E] - movs r0, 0x2 - ands r0, r2 - adds r3, r1, 0 - cmp r0, 0 - beq _0811AE60 - bl sub_811B32C - b _0811AEF6 - .pool -_0811AE60: - movs r0, 0x1 - ands r0, r2 - cmp r0, 0 - beq _0811AEAE - ldr r0, =gUnknown_0203A118 - ldr r2, [r0] - movs r1, 0xA - ldrsb r1, [r2, r1] - movs r0, 0x1 - negs r0, r0 - cmp r1, r0 - beq _0811AE84 - bl sub_811B2B0 - b _0811AEF6 - .pool -_0811AE84: - movs r0, 0xB - ldrsb r0, [r2, r0] - cmp r0, 0x1 - beq _0811AEA2 - cmp r0, 0x1 - bgt _0811AE96 - cmp r0, 0 - beq _0811AE9C - b _0811AEAE -_0811AE96: - cmp r0, 0x2 - beq _0811AEA8 - b _0811AEAE -_0811AE9C: - bl sub_811B33C - b _0811AEF6 -_0811AEA2: - bl sub_811B368 - b _0811AEF6 -_0811AEA8: - bl sub_811B32C - b _0811AEF6 -_0811AEAE: - ldrh r1, [r3, 0x2E] - movs r0, 0x4 - ands r0, r1 - cmp r0, 0 - beq _0811AEBE - bl sub_811B33C - b _0811AEF6 -_0811AEBE: - ldrh r1, [r3, 0x30] - movs r0, 0x40 - ands r0, r1 - cmp r0, 0 - beq _0811AECC - movs r0, 0x2 - b _0811AEF2 -_0811AECC: - movs r0, 0x80 - ands r0, r1 - cmp r0, 0 - beq _0811AED8 - movs r0, 0x3 - b _0811AEF2 -_0811AED8: - movs r0, 0x20 - ands r0, r1 - cmp r0, 0 - beq _0811AEE4 - movs r0, 0x1 - b _0811AEF2 -_0811AEE4: - movs r0, 0x10 - ands r0, r1 - cmp r0, 0 - bne _0811AEF0 - movs r0, 0 - b _0811AEFA -_0811AEF0: - movs r0, 0 -_0811AEF2: - bl sub_811B528 -_0811AEF6: - lsls r0, 16 - lsrs r0, 16 -_0811AEFA: - pop {r1} - bx r1 - thumb_func_end sub_811AE44 - - thumb_func_start sub_811AF00 -sub_811AF00: @ 811AF00 - push {lr} - ldr r2, =gMain - ldrh r1, [r2, 0x2E] - movs r0, 0x2 - ands r0, r1 - cmp r0, 0 - beq _0811AF24 - ldr r0, =gUnknown_0203A118 - ldr r1, [r0] - movs r0, 0x2 - strb r0, [r1, 0x4] - movs r0, 0xE - b _0811AF86 - .pool -_0811AF24: - movs r0, 0x1 - ands r0, r1 - cmp r0, 0 - beq _0811AF32 - bl sub_811B394 - b _0811AF82 -_0811AF32: - movs r0, 0x8 - ands r0, r1 - cmp r0, 0 - beq _0811AF3E - movs r0, 0x4 - b _0811AF7E -_0811AF3E: - movs r0, 0x4 - ands r0, r1 - cmp r0, 0 - beq _0811AF4A - movs r0, 0x5 - b _0811AF7E -_0811AF4A: - ldrh r1, [r2, 0x30] - movs r0, 0x40 - ands r0, r1 - cmp r0, 0 - beq _0811AF58 - movs r0, 0x2 - b _0811AF7E -_0811AF58: - movs r0, 0x80 - ands r0, r1 - cmp r0, 0 - beq _0811AF64 - movs r0, 0x3 - b _0811AF7E -_0811AF64: - movs r0, 0x20 - ands r0, r1 - cmp r0, 0 - beq _0811AF70 - movs r0, 0x1 - b _0811AF7E -_0811AF70: - movs r0, 0x10 - ands r0, r1 - cmp r0, 0 - bne _0811AF7C - movs r0, 0 - b _0811AF86 -_0811AF7C: - movs r0, 0 -_0811AF7E: - bl sub_811B794 -_0811AF82: - lsls r0, 16 - lsrs r0, 16 -_0811AF86: - pop {r1} - bx r1 - thumb_func_end sub_811AF00 - - thumb_func_start sub_811AF8C -sub_811AF8C: @ 811AF8C - push {lr} - bl Menu_ProcessInputNoWrapClearOnChoose - lsls r0, 24 - asrs r1, r0, 24 - cmp r1, 0 - beq _0811AFC0 - cmp r1, 0 - bgt _0811AFA8 - movs r0, 0x1 - negs r0, r0 - cmp r1, r0 - beq _0811AFAC - b _0811AFE4 -_0811AFA8: - cmp r1, 0x1 - bne _0811AFE4 -_0811AFAC: - bl sub_811B2A4 - ldr r1, =gUnknown_0203A118 - ldr r1, [r1] - strb r0, [r1, 0x4] - movs r0, 0x7 - b _0811AFE6 - .pool -_0811AFC0: - ldr r0, =gSpecialVar_Result - strh r1, [r0] - ldr r0, =gUnknown_0203A118 - ldr r0, [r0] - ldrb r0, [r0] - subs r0, 0x11 - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bhi _0811AFD8 - bl sub_811B3E4 -_0811AFD8: - movs r0, 0x18 - b _0811AFE6 - .pool -_0811AFE4: - movs r0, 0 -_0811AFE6: - pop {r1} - bx r1 - thumb_func_end sub_811AF8C - - thumb_func_start sub_811AFEC -sub_811AFEC: @ 811AFEC - push {r4,lr} - bl Menu_ProcessInputNoWrapClearOnChoose - lsls r0, 24 - asrs r1, r0, 24 - cmp r1, 0 - beq _0811B020 - cmp r1, 0 - bgt _0811B008 - movs r0, 0x1 - negs r0, r0 - cmp r1, r0 - beq _0811B00C - b _0811B038 -_0811B008: - cmp r1, 0x1 - bne _0811B038 -_0811B00C: - bl sub_811B2A4 - ldr r1, =gUnknown_0203A118 - ldr r1, [r1] - strb r0, [r1, 0x4] - movs r0, 0x7 - b _0811B03A - .pool -_0811B020: - bl sub_811BE9C - ldr r4, =gSpecialVar_Result - bl sub_811B4EC - strh r0, [r4] - bl sub_811B3E4 - movs r0, 0x18 - b _0811B03A - .pool -_0811B038: - movs r0, 0 -_0811B03A: - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_811AFEC - - thumb_func_start sub_811B040 -sub_811B040: @ 811B040 - push {lr} - bl Menu_ProcessInputNoWrapClearOnChoose - lsls r0, 24 - asrs r1, r0, 24 - cmp r1, 0 - beq _0811B070 - cmp r1, 0 - bgt _0811B05C - movs r0, 0x1 - negs r0, r0 - cmp r1, r0 - beq _0811B060 - b _0811B084 -_0811B05C: - cmp r1, 0x1 - bne _0811B084 -_0811B060: - ldr r0, =gUnknown_0203A118 - ldr r1, [r0] - movs r0, 0x1 - strb r0, [r1, 0x4] - movs r0, 0x7 - b _0811B086 - .pool -_0811B070: - bl sub_811B418 - ldr r0, =gUnknown_0203A118 - ldr r1, [r0] - movs r0, 0x1 - strb r0, [r1, 0x4] - movs r0, 0x8 - b _0811B086 - .pool -_0811B084: - movs r0, 0 -_0811B086: - pop {r1} - bx r1 - thumb_func_end sub_811B040 - - thumb_func_start sub_811B08C -sub_811B08C: @ 811B08C - push {lr} - ldr r0, =gMain - ldrh r1, [r0, 0x2E] - movs r0, 0x1 - ands r0, r1 - cmp r0, 0 - beq _0811B0A4 - movs r0, 0x1A - b _0811B0B8 - .pool -_0811B0A4: - movs r0, 0x2 - ands r0, r1 - cmp r0, 0 - bne _0811B0B0 - movs r0, 0 - b _0811B0B8 -_0811B0B0: - bl sub_811B150 - lsls r0, 16 - lsrs r0, 16 -_0811B0B8: - pop {r1} - bx r1 - thumb_func_end sub_811B08C - - thumb_func_start sub_811B0BC -sub_811B0BC: @ 811B0BC - push {lr} - ldr r0, =gMain - ldrh r1, [r0, 0x2E] - movs r0, 0x3 - ands r0, r1 - cmp r0, 0 - bne _0811B0D4 - movs r0, 0 - b _0811B0E0 - .pool -_0811B0D4: - bl sub_811B2A4 - ldr r1, =gUnknown_0203A118 - ldr r1, [r1] - strb r0, [r1, 0x4] - movs r0, 0x7 -_0811B0E0: - pop {r1} - bx r1 - .pool - thumb_func_end sub_811B0BC - - thumb_func_start sub_811B0E8 -sub_811B0E8: @ 811B0E8 - ldr r0, =gUnknown_0203A118 - ldr r1, [r0] - movs r0, 0xA - strb r0, [r1, 0x4] - movs r0, 0x6 - bx lr - .pool - thumb_func_end sub_811B0E8 - - thumb_func_start sub_811B0F8 -sub_811B0F8: @ 811B0F8 - push {r4,lr} - bl Menu_ProcessInputNoWrapClearOnChoose - lsls r0, 24 - asrs r1, r0, 24 - cmp r1, 0 - beq _0811B134 - cmp r1, 0 - bgt _0811B114 - movs r0, 0x1 - negs r0, r0 - cmp r1, r0 - beq _0811B118 - b _0811B148 -_0811B114: - cmp r1, 0x1 - bne _0811B148 -_0811B118: - bl sub_811B454 - ldr r2, =gUnknown_0203A118 - ldr r1, [r2] - movs r0, 0 - strb r0, [r1, 0x8] - ldr r1, [r2] - movs r0, 0x8 - strb r0, [r1, 0x4] - movs r0, 0x1F - b _0811B14A - .pool -_0811B134: - ldr r4, =gSpecialVar_Result - bl sub_811B4EC - strh r0, [r4] - bl sub_811B3E4 - movs r0, 0x18 - b _0811B14A - .pool -_0811B148: - movs r0, 0 -_0811B14A: - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_811B0F8 - - thumb_func_start sub_811B150 -sub_811B150: @ 811B150 - push {lr} - ldr r1, =gUnknown_0203A118 - ldr r2, [r1] - ldrb r0, [r2] - cmp r0, 0x13 - beq _0811B160 - cmp r0, 0xB - bne _0811B174 -_0811B160: - ldrb r0, [r2, 0x4] - strb r0, [r2, 0x8] - ldr r1, [r1] - movs r0, 0x8 - strb r0, [r1, 0x4] - movs r0, 0x22 - b _0811B180 - .pool -_0811B174: - ldrb r0, [r2, 0x4] - strb r0, [r2, 0x8] - ldr r1, [r1] - movs r0, 0x4 - strb r0, [r1, 0x4] - movs r0, 0x5 -_0811B180: - pop {r1} - bx r1 - thumb_func_end sub_811B150 - - thumb_func_start sub_811B184 -sub_811B184: @ 811B184 - push {lr} - ldr r2, =gUnknown_0203A118 - ldr r0, [r2] - ldrb r1, [r0, 0x4] - strb r1, [r0, 0x8] - ldr r1, [r2] - ldrb r0, [r1] - cmp r0, 0x6 - bne _0811B1A8 - ldrb r0, [r1, 0x4] - strb r0, [r1, 0x8] - ldr r1, [r2] - movs r0, 0x8 - strb r0, [r1, 0x4] - movs r0, 0x20 - b _0811B1AE - .pool -_0811B1A8: - movs r0, 0x5 - strb r0, [r1, 0x4] - movs r0, 0x4 -_0811B1AE: - pop {r1} - bx r1 - thumb_func_end sub_811B184 - - thumb_func_start sub_811B1B4 -sub_811B1B4: @ 811B1B4 - push {r4,lr} - ldr r4, =gUnknown_0203A118 - ldr r1, [r4] - ldrb r0, [r1, 0x4] - strb r0, [r1, 0x8] - ldr r1, [r4] - ldrb r0, [r1] - cmp r0, 0x11 - bne _0811B1DC - bl sub_811BD64 - cmp r0, 0 - bne _0811B1FA - bl sub_811BDB0 - cmp r0, 0 - bne _0811B1E8 - b _0811B256 - .pool -_0811B1DC: - cmp r0, 0x12 - bne _0811B204 - bl sub_811BDB0 - cmp r0, 0 - beq _0811B1F2 -_0811B1E8: - ldr r1, [r4] - movs r0, 0x8 - strb r0, [r1, 0x4] - movs r0, 0x1E - b _0811B25C -_0811B1F2: - bl sub_811BD64 - cmp r0, 0 - beq _0811B256 -_0811B1FA: - ldr r1, [r4] - movs r0, 0x8 - strb r0, [r1, 0x4] - movs r0, 0x1D - b _0811B25C -_0811B204: - cmp r0, 0x9 - beq _0811B20C - cmp r0, 0xD - bne _0811B21E -_0811B20C: - bl sub_811BD2C - cmp r0, 0 - bne _0811B256 - ldr r1, [r4] - movs r0, 0x8 - strb r0, [r1, 0x4] - movs r0, 0x21 - b _0811B25C -_0811B21E: - cmp r0, 0x13 - beq _0811B226 - cmp r0, 0xB - bne _0811B238 -_0811B226: - bl sub_811BCF4 - cmp r0, 0 - beq _0811B256 - ldr r1, [r4] - movs r0, 0x8 - strb r0, [r1, 0x4] - movs r0, 0x22 - b _0811B25C -_0811B238: - cmp r0, 0x14 - beq _0811B258 - bl sub_811BCF4 - cmp r0, 0x1 - beq _0811B24C - bl sub_811B4EC - cmp r0, 0 - bne _0811B256 -_0811B24C: - ldr r1, [r4] - movs r0, 0x4 - strb r0, [r1, 0x4] - movs r0, 0x5 - b _0811B25C -_0811B256: - ldr r1, [r4] -_0811B258: - movs r0, 0x6 - strb r0, [r1, 0x4] -_0811B25C: - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_811B1B4 - - thumb_func_start sub_811B264 -sub_811B264: @ 811B264 - push {lr} - ldr r2, =gUnknown_0203A118 - ldr r1, [r2] - ldrb r0, [r1, 0x4] - strb r0, [r1, 0x8] - ldr r0, [r2] - ldrb r0, [r0] - cmp r0, 0x11 - beq _0811B28E - cmp r0, 0x11 - bgt _0811B284 - cmp r0, 0xF - beq _0811B28A - b _0811B29E - .pool -_0811B284: - cmp r0, 0x12 - beq _0811B296 - b _0811B29E -_0811B28A: - movs r0, 0x19 - b _0811B2A0 -_0811B28E: - bl sub_811B3E4 - movs r0, 0x1C - b _0811B2A0 -_0811B296: - bl sub_811B3E4 - movs r0, 0x1B - b _0811B2A0 -_0811B29E: - movs r0, 0 -_0811B2A0: - pop {r1} - bx r1 - thumb_func_end sub_811B264 - - thumb_func_start sub_811B2A4 -sub_811B2A4: @ 811B2A4 - ldr r0, =gUnknown_0203A118 - ldr r0, [r0] - ldrb r0, [r0, 0x8] - bx lr - .pool - thumb_func_end sub_811B2A4 - - thumb_func_start sub_811B2B0 -sub_811B2B0: @ 811B2B0 - push {lr} - ldr r0, =gUnknown_0203A118 - ldr r0, [r0] - ldrb r0, [r0, 0x9] - cmp r0, 0 - bne _0811B2DC - bl sub_811B8E8 - lsls r0, 24 - lsrs r0, 24 - bl sub_811F3B8 - adds r1, r0, 0 - lsls r1, 24 - lsrs r1, 24 - movs r0, 0 - bl sub_811F548 - b _0811B2EC - .pool -_0811B2DC: - bl sub_811B908 - adds r1, r0, 0 - lsls r1, 16 - lsrs r1, 16 - movs r0, 0x1 - bl sub_811F548 -_0811B2EC: - bl sub_811F5B0 - lsls r0, 16 - lsrs r0, 16 - cmp r0, 0 - beq _0811B324 - ldr r2, =gUnknown_0203A118 - ldr r3, [r2] - subs r0, 0x1 - lsrs r1, r0, 31 - adds r0, r1 - asrs r0, 1 - movs r1, 0 - strb r0, [r3, 0xF] - ldr r0, [r2] - strb r1, [r0, 0xE] - ldr r0, [r2] - strb r1, [r0, 0x10] - ldr r0, [r2] - strb r1, [r0, 0x11] - ldr r1, [r2] - movs r0, 0x3 - strb r0, [r1, 0x4] - movs r0, 0xB - b _0811B326 - .pool -_0811B324: - movs r0, 0 -_0811B326: - pop {r1} - bx r1 - thumb_func_end sub_811B2B0 - - thumb_func_start sub_811B32C -sub_811B32C: @ 811B32C - ldr r0, =gUnknown_0203A118 - ldr r1, [r0] - movs r0, 0 - strb r0, [r1, 0x4] - movs r0, 0xA - bx lr - .pool - thumb_func_end sub_811B32C - - thumb_func_start sub_811B33C -sub_811B33C: @ 811B33C - push {lr} - ldr r1, =gUnknown_0203A118 - ldr r0, [r1] - movs r2, 0 - strb r2, [r0, 0xA] - ldr r0, [r1] - strb r2, [r0, 0xB] - ldr r0, [r1] - strb r2, [r0, 0xC] - ldr r1, [r1] - ldrb r0, [r1, 0x9] - cmp r0, 0 - bne _0811B360 - movs r0, 0x1 - strb r0, [r1, 0x9] - b _0811B362 - .pool -_0811B360: - strb r2, [r1, 0x9] -_0811B362: - movs r0, 0x17 - pop {r1} - bx r1 - thumb_func_end sub_811B33C - - thumb_func_start sub_811B368 -sub_811B368: @ 811B368 - push {lr} - ldr r0, =gUnknown_0203A118 - ldr r0, [r0] - ldrb r0, [r0] - cmp r0, 0x6 - beq _0811B388 - ldr r0, =0x0000ffff - bl sub_811B488 - movs r0, 0x1 - b _0811B390 - .pool -_0811B388: - movs r0, 0x20 - bl PlaySE - movs r0, 0 -_0811B390: - pop {r1} - bx r1 - thumb_func_end sub_811B368 - - thumb_func_start sub_811B394 -sub_811B394: @ 811B394 - push {r4,r5,lr} - bl sub_811B940 - lsls r0, 16 - lsrs r0, 16 - bl sub_811F578 - lsls r0, 16 - lsrs r4, r0, 16 - adds r0, r4, 0 - bl sub_811BF88 - adds r5, r0, 0 - cmp r5, 0 - beq _0811B3BC - movs r0, 0x20 - bl PlaySE - movs r0, 0 - b _0811B3DC -_0811B3BC: - adds r0, r4, 0 - bl sub_811B488 - ldr r0, =gUnknown_0203A118 - ldr r1, [r0] - ldrb r0, [r1] - cmp r0, 0x6 - bne _0811B3D8 - movs r0, 0x9 - strb r0, [r1, 0x4] - movs r0, 0xD - b _0811B3DC - .pool -_0811B3D8: - strb r5, [r1, 0x4] - movs r0, 0xC -_0811B3DC: - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_811B394 - - thumb_func_start sub_811B3E4 -sub_811B3E4: @ 811B3E4 - push {r4,r5,lr} - movs r4, 0 - ldr r3, =gUnknown_0203A118 - ldr r0, [r3] - ldrb r0, [r0, 0x7] - cmp r4, r0 - bge _0811B40E - adds r5, r3, 0 -_0811B3F4: - ldr r3, [r5] - ldr r1, [r3, 0x38] - lsls r2, r4, 1 - adds r1, r2, r1 - adds r0, r3, 0 - adds r0, 0x3C - adds r0, r2 - ldrh r0, [r0] - strh r0, [r1] - adds r4, 0x1 - ldrb r3, [r3, 0x7] - cmp r4, r3 - blt _0811B3F4 -_0811B40E: - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_811B3E4 - - thumb_func_start sub_811B418 -sub_811B418: @ 811B418 - push {r4,r5,lr} - movs r3, 0 - ldr r2, =gUnknown_0203A118 - ldr r0, [r2] - ldrb r0, [r0, 0x7] - cmp r3, r0 - bge _0811B444 - adds r5, r2, 0 - ldr r0, =0x0000ffff - adds r4, r0, 0 -_0811B42C: - ldr r2, [r5] - lsls r0, r3, 1 - adds r1, r2, 0 - adds r1, 0x3C - adds r1, r0 - ldrh r0, [r1] - orrs r0, r4 - strh r0, [r1] - adds r3, 0x1 - ldrb r2, [r2, 0x7] - cmp r3, r2 - blt _0811B42C -_0811B444: - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_811B418 - - thumb_func_start sub_811B454 -sub_811B454: @ 811B454 - push {r4,r5,lr} - movs r4, 0 - ldr r3, =gUnknown_0203A118 - ldr r0, [r3] - ldrb r0, [r0, 0x7] - cmp r4, r0 - bge _0811B47E - adds r5, r3, 0 -_0811B464: - ldr r3, [r5] - lsls r1, r4, 1 - adds r2, r3, 0 - adds r2, 0x3C - adds r2, r1 - ldr r0, [r3, 0x38] - adds r1, r0 - ldrh r0, [r1] - strh r0, [r2] - adds r4, 0x1 - ldrb r3, [r3, 0x7] - cmp r4, r3 - blt _0811B464 -_0811B47E: - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_811B454 - - thumb_func_start sub_811B488 -sub_811B488: @ 811B488 - push {r4,lr} - adds r4, r0, 0 - lsls r4, 16 - lsrs r4, 16 - bl sub_811B8C8 - lsls r0, 16 - ldr r1, =gUnknown_0203A118 - ldr r1, [r1] - lsrs r0, 15 - adds r1, 0x3C - adds r1, r0 - strh r4, [r1] - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_811B488 - - thumb_func_start sub_811B4AC -sub_811B4AC: @ 811B4AC - push {r4,r5,lr} - movs r2, 0 - ldr r0, =gUnknown_0203A118 - ldr r0, [r0] - ldrb r1, [r0, 0x7] - cmp r2, r1 - bcs _0811B4E2 - adds r5, r1, 0 - adds r4, r0, 0 - adds r4, 0x3C - ldr r3, [r0, 0x38] -_0811B4C2: - lsls r0, r2, 1 - adds r1, r4, r0 - adds r0, r3 - ldrh r1, [r1] - ldrh r0, [r0] - cmp r1, r0 - beq _0811B4D8 - movs r0, 0x1 - b _0811B4E4 - .pool -_0811B4D8: - adds r0, r2, 0x1 - lsls r0, 16 - lsrs r2, r0, 16 - cmp r2, r5 - bcc _0811B4C2 -_0811B4E2: - movs r0, 0 -_0811B4E4: - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_811B4AC - - thumb_func_start sub_811B4EC -sub_811B4EC: @ 811B4EC - push {lr} - ldr r0, =gUnknown_0203A118 - ldr r0, [r0] - ldrb r0, [r0] - subs r0, 0x11 - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bhi _0811B51C - bl sub_811BD64 - cmp r0, 0 - bne _0811B50E - bl sub_811BDB0 - cmp r0, 0 - beq _0811B518 -_0811B50E: - movs r0, 0 - b _0811B524 - .pool -_0811B518: - movs r0, 0x1 - b _0811B524 -_0811B51C: - bl sub_811B4AC - lsls r0, 24 - lsrs r0, 24 -_0811B524: - pop {r1} - bx r1 - thumb_func_end sub_811B4EC - - thumb_func_start sub_811B528 -sub_811B528: @ 811B528 - push {lr} - adds r2, r0, 0 - ldr r0, =gUnknown_0203A118 - ldr r3, [r0] - movs r1, 0xA - ldrsb r1, [r3, r1] - movs r0, 0x1 - negs r0, r0 - cmp r1, r0 - beq _0811B558 - ldrb r0, [r3, 0x9] - cmp r0, 0 - bne _0811B550 - adds r0, r2, 0 - bl sub_811B568 - b _0811B55E - .pool -_0811B550: - adds r0, r2, 0 - bl sub_811B634 - b _0811B55E -_0811B558: - adds r0, r2, 0 - bl sub_811B6C4 -_0811B55E: - lsls r0, 16 - lsrs r0, 16 - pop {r1} - bx r1 - thumb_func_end sub_811B528 - - thumb_func_start sub_811B568 -sub_811B568: @ 811B568 - push {r4,lr} - cmp r0, 0x1 - beq _0811B5DE - cmp r0, 0x1 - bcc _0811B5FE - cmp r0, 0x2 - beq _0811B57C - cmp r0, 0x3 - beq _0811B5A4 - b _0811B62A -_0811B57C: - ldr r0, =gUnknown_0203A118 - ldr r1, [r0] - movs r0, 0xB - ldrsb r0, [r1, r0] - ldrb r3, [r1, 0xC] - cmn r0, r3 - beq _0811B62A - ldrb r2, [r1, 0xB] - cmp r0, 0 - beq _0811B59C - subs r0, r2, 0x1 - strb r0, [r1, 0xB] -_0811B594: - movs r0, 0xF - b _0811B62C - .pool -_0811B59C: - subs r0, r3, 0x1 - strb r0, [r1, 0xC] - movs r0, 0x11 - b _0811B62C -_0811B5A4: - ldr r0, =gUnknown_0203A118 - ldr r2, [r0] - movs r1, 0xB - ldrsb r1, [r2, r1] - ldrb r3, [r2, 0xC] - adds r1, r3 - ldrb r0, [r2, 0xD] - subs r0, 0x1 - cmp r1, r0 - bge _0811B62A - ldrb r1, [r2, 0xB] - movs r0, 0xB - ldrsb r0, [r2, r0] - cmp r0, 0x2 - bgt _0811B5D0 - adds r0, r1, 0x1 - strb r0, [r2, 0xB] - movs r4, 0xF - b _0811B5D6 - .pool -_0811B5D0: - adds r0, r3, 0x1 - strb r0, [r2, 0xC] - movs r4, 0x10 -_0811B5D6: - bl sub_811B978 - adds r0, r4, 0 - b _0811B62C -_0811B5DE: - ldr r0, =gUnknown_0203A118 - ldr r1, [r0] - ldrb r2, [r1, 0xA] - movs r0, 0xA - ldrsb r0, [r1, r0] - cmp r0, 0 - beq _0811B5F8 - subs r0, r2, 0x1 - strb r0, [r1, 0xA] - b _0811B594 - .pool -_0811B5F8: - bl sub_811B744 - b _0811B594 -_0811B5FE: - ldr r0, =gUnknown_0203A118 - ldr r1, [r0] - ldrb r2, [r1, 0xA] - movs r0, 0xA - ldrsb r0, [r1, r0] - cmp r0, 0 - bgt _0811B624 - adds r0, r2, 0x1 - strb r0, [r1, 0xA] - bl sub_811B9C8 - lsls r0, 24 - cmp r0, 0 - beq _0811B594 - bl sub_811B744 - b _0811B594 - .pool -_0811B624: - bl sub_811B744 - b _0811B594 -_0811B62A: - movs r0, 0 -_0811B62C: - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_811B568 - - thumb_func_start sub_811B634 -sub_811B634: @ 811B634 - push {lr} - cmp r0, 0x1 - beq _0811B6A0 - cmp r0, 0x1 - bcc _0811B684 - cmp r0, 0x2 - beq _0811B64A - cmp r0, 0x3 - beq _0811B66A - movs r0, 0 - b _0811B6BC -_0811B64A: - ldr r0, =gUnknown_0203A118 - ldr r1, [r0] - ldrb r2, [r1, 0xB] - movs r0, 0xB - ldrsb r0, [r1, r0] - cmp r0, 0 - ble _0811B660 - subs r0, r2, 0x1 - b _0811B662 - .pool -_0811B660: - movs r0, 0x3 -_0811B662: - strb r0, [r1, 0xB] - bl sub_811B978 - b _0811B6BA -_0811B66A: - ldr r0, =gUnknown_0203A118 - ldr r1, [r0] - ldrb r2, [r1, 0xB] - movs r0, 0xB - ldrsb r0, [r1, r0] - cmp r0, 0x2 - bgt _0811B680 - adds r0, r2, 0x1 - b _0811B662 - .pool -_0811B680: - movs r0, 0 - b _0811B662 -_0811B684: - ldr r0, =gUnknown_0203A118 - ldr r1, [r0] - ldrb r0, [r1, 0xA] - adds r0, 0x1 - strb r0, [r1, 0xA] - bl sub_811B9C8 - lsls r0, 24 - cmp r0, 0 - beq _0811B6BA - b _0811B6B6 - .pool -_0811B6A0: - ldr r2, =gUnknown_0203A118 - ldr r1, [r2] - ldrb r0, [r1, 0xA] - subs r0, 0x1 - strb r0, [r1, 0xA] - ldr r0, [r2] - ldrb r0, [r0, 0xA] - lsls r0, 24 - asrs r0, 24 - cmp r0, 0 - bge _0811B6BA -_0811B6B6: - bl sub_811B744 -_0811B6BA: - movs r0, 0xF -_0811B6BC: - pop {r1} - bx r1 - .pool - thumb_func_end sub_811B634 - - thumb_func_start sub_811B6C4 -sub_811B6C4: @ 811B6C4 - push {lr} - adds r2, r0, 0 - cmp r2, 0x1 - beq _0811B714 - cmp r2, 0x1 - bcc _0811B728 - cmp r2, 0x2 - beq _0811B6DC - cmp r2, 0x3 - beq _0811B6F8 - movs r0, 0 - b _0811B73A -_0811B6DC: - ldr r0, =gUnknown_0203A118 - ldr r1, [r0] - ldrb r3, [r1, 0xB] - movs r0, 0xB - ldrsb r0, [r1, r0] - cmp r0, 0 - beq _0811B6F4 - subs r0, r3, 0x1 - b _0811B736 - .pool -_0811B6F4: - strb r2, [r1, 0xB] - b _0811B738 -_0811B6F8: - ldr r0, =gUnknown_0203A118 - ldr r1, [r0] - ldrb r2, [r1, 0xB] - movs r0, 0xB - ldrsb r0, [r1, r0] - cmp r0, 0x1 - bgt _0811B710 - adds r0, r2, 0x1 - b _0811B736 - .pool -_0811B710: - movs r0, 0 - b _0811B736 -_0811B714: - ldr r0, =gUnknown_0203A118 - ldr r1, [r0] - ldrb r0, [r1, 0xB] - adds r0, 0x1 - strb r0, [r1, 0xB] - bl sub_811B768 - b _0811B738 - .pool -_0811B728: - ldr r2, =gUnknown_0203A118 - ldr r1, [r2] - movs r0, 0 - strb r0, [r1, 0xA] - ldr r1, [r2] - ldrb r0, [r1, 0xB] - adds r0, 0x1 -_0811B736: - strb r0, [r1, 0xB] -_0811B738: - movs r0, 0xF -_0811B73A: - pop {r1} - bx r1 - .pool - thumb_func_end sub_811B6C4 - - thumb_func_start sub_811B744 -sub_811B744: @ 811B744 - push {lr} - ldr r2, =gUnknown_0203A118 - ldr r1, [r2] - movs r0, 0xFF - strb r0, [r1, 0xA] - ldr r2, [r2] - ldrb r1, [r2, 0xB] - movs r0, 0xB - ldrsb r0, [r2, r0] - cmp r0, 0 - beq _0811B75E - subs r0, r1, 0x1 - strb r0, [r2, 0xB] -_0811B75E: - pop {r0} - bx r0 - .pool - thumb_func_end sub_811B744 - - thumb_func_start sub_811B768 -sub_811B768: @ 811B768 - push {r4,lr} - ldr r4, =gUnknown_0203A118 - ldr r1, [r4] - ldrb r0, [r1, 0x9] - cmp r0, 0 - bne _0811B784 - movs r0, 0x1 - strb r0, [r1, 0xA] - bl sub_811B978 - b _0811B78E - .pool -_0811B784: - ldrb r0, [r1, 0xB] - bl sub_811B960 - ldr r1, [r4] - strb r0, [r1, 0xA] -_0811B78E: - pop {r4} - pop {r0} - bx r0 - thumb_func_end sub_811B768 - - thumb_func_start sub_811B794 -sub_811B794: @ 811B794 - push {r4,lr} - cmp r0, 0x5 - bls _0811B79C - b _0811B8C0 -_0811B79C: - lsls r0, 2 - ldr r1, =_0811B7AC - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .pool - .align 2, 0 -_0811B7AC: - .4byte _0811B848 - .4byte _0811B826 - .4byte _0811B7C4 - .4byte _0811B7F0 - .4byte _0811B870 - .4byte _0811B890 -_0811B7C4: - ldr r0, =gUnknown_0203A118 - ldr r1, [r0] - movs r0, 0x11 - ldrsb r0, [r1, r0] - ldrb r3, [r1, 0xE] - adds r0, r3 - cmp r0, 0 - bgt _0811B7D6 - b _0811B8C0 -_0811B7D6: - ldrb r2, [r1, 0x11] - movs r0, 0x11 - ldrsb r0, [r1, r0] - cmp r0, 0 - ble _0811B7E8 - subs r0, r2, 0x1 - b _0811B80E - .pool -_0811B7E8: - subs r0, r3, 0x1 - strb r0, [r1, 0xE] - movs r4, 0x13 - b _0811B81E -_0811B7F0: - ldr r0, =gUnknown_0203A118 - ldr r1, [r0] - movs r0, 0x11 - ldrsb r0, [r1, r0] - ldrb r3, [r1, 0xE] - adds r0, r3 - ldrb r2, [r1, 0xF] - cmp r0, r2 - bge _0811B8C0 - ldrb r2, [r1, 0x11] - movs r0, 0x11 - ldrsb r0, [r1, r0] - cmp r0, 0x2 - bgt _0811B818 - adds r0, r2, 0x1 -_0811B80E: - strb r0, [r1, 0x11] - movs r4, 0x12 - b _0811B81E - .pool -_0811B818: - adds r0, r3, 0x1 - strb r0, [r1, 0xE] - movs r4, 0x14 -_0811B81E: - bl sub_811B9A0 - adds r0, r4, 0 - b _0811B8C2 -_0811B826: - ldr r0, =gUnknown_0203A118 - ldr r1, [r0] - ldrb r2, [r1, 0x10] - movs r0, 0x10 - ldrsb r0, [r1, r0] - cmp r0, 0 - ble _0811B83C - subs r0, r2, 0x1 - b _0811B83E - .pool -_0811B83C: - movs r0, 0x1 -_0811B83E: - strb r0, [r1, 0x10] - bl sub_811B9A0 -_0811B844: - movs r0, 0x12 - b _0811B8C2 -_0811B848: - ldr r4, =gUnknown_0203A118 - ldr r1, [r4] - ldrb r2, [r1, 0x10] - movs r0, 0x10 - ldrsb r0, [r1, r0] - cmp r0, 0 - bgt _0811B866 - adds r0, r2, 0x1 - strb r0, [r1, 0x10] - bl sub_811BA1C - lsls r0, 24 - cmp r0, 0 - beq _0811B844 - ldr r1, [r4] -_0811B866: - movs r0, 0 - strb r0, [r1, 0x10] - b _0811B844 - .pool -_0811B870: - ldr r0, =gUnknown_0203A118 - ldr r2, [r0] - ldrb r0, [r2, 0xE] - adds r1, r0, 0 - cmp r1, 0 - beq _0811B8C0 - cmp r1, 0x3 - bls _0811B888 - subs r0, 0x4 - b _0811B88A - .pool -_0811B888: - movs r0, 0 -_0811B88A: - strb r0, [r2, 0xE] - movs r0, 0x15 - b _0811B8C2 -_0811B890: - ldr r3, =gUnknown_0203A118 - ldr r1, [r3] - ldrb r2, [r1, 0xE] - ldrb r0, [r1, 0xF] - subs r0, 0x4 - cmp r2, r0 - bgt _0811B8C0 - adds r0, r2, 0x4 - strb r0, [r1, 0xE] - ldr r2, [r3] - ldrb r1, [r2, 0xE] - ldrb r3, [r2, 0xF] - subs r0, r3, 0x3 - cmp r1, r0 - ble _0811B8B4 - adds r0, r3, 0 - adds r0, 0xFD - strb r0, [r2, 0xE] -_0811B8B4: - bl sub_811B9A0 - movs r0, 0x16 - b _0811B8C2 - .pool -_0811B8C0: - movs r0, 0 -_0811B8C2: - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_811B794 - - thumb_func_start sub_811B8C8 -sub_811B8C8: @ 811B8C8 - ldr r0, =gUnknown_0203A118 - ldr r0, [r0] - movs r2, 0x6 - ldrsb r2, [r0, r2] - ldrb r1, [r0, 0x2] - muls r1, r2 - ldrb r0, [r0, 0x5] - lsls r0, 24 - asrs r0, 24 - adds r0, r1 - lsls r0, 16 - lsrs r0, 16 - bx lr - .pool - thumb_func_end sub_811B8C8 - - thumb_func_start sub_811B8E8 -sub_811B8E8: @ 811B8E8 - ldr r0, =gUnknown_0203A118 - ldr r0, [r0] - movs r1, 0xB - ldrsb r1, [r0, r1] - ldrb r2, [r0, 0xC] - adds r1, r2 - lsls r1, 1 - ldrb r0, [r0, 0xA] - lsls r0, 24 - asrs r0, 24 - adds r0, r1 - lsls r0, 16 - lsrs r0, 16 - bx lr - .pool - thumb_func_end sub_811B8E8 - - thumb_func_start sub_811B908 -sub_811B908: @ 811B908 - push {lr} - ldr r0, =gUnknown_0203A118 - ldr r1, [r0] - ldrb r0, [r1, 0xA] - movs r3, 0 - cmp r0, 0x6 - bhi _0811B91A - movs r3, 0xA - ldrsb r3, [r1, r3] -_0811B91A: - ldrb r0, [r1, 0xB] - movs r2, 0 - cmp r0, 0x3 - bhi _0811B926 - movs r2, 0xB - ldrsb r2, [r1, r2] -_0811B926: - ldr r0, =gUnknown_08597748 - lsls r1, r2, 3 - subs r1, r2 - adds r1, r3, r1 - adds r1, r0 - ldrb r0, [r1] - pop {r1} - bx r1 - .pool - thumb_func_end sub_811B908 - - thumb_func_start sub_811B940 -sub_811B940: @ 811B940 - ldr r0, =gUnknown_0203A118 - ldr r0, [r0] - movs r1, 0x11 - ldrsb r1, [r0, r1] - ldrb r2, [r0, 0xE] - adds r1, r2 - lsls r1, 1 - ldrb r0, [r0, 0x10] - lsls r0, 24 - asrs r0, 24 - adds r0, r1 - lsls r0, 16 - lsrs r0, 16 - bx lr - .pool - thumb_func_end sub_811B940 - - thumb_func_start sub_811B960 -sub_811B960: @ 811B960 - push {lr} - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0 - beq _0811B96E - cmp r0, 0x1 - beq _0811B972 -_0811B96E: - movs r0, 0x6 - b _0811B974 -_0811B972: - movs r0, 0x5 -_0811B974: - pop {r1} - bx r1 - thumb_func_end sub_811B960 - - thumb_func_start sub_811B978 -sub_811B978: @ 811B978 - push {lr} - b _0811B98E -_0811B97C: - ldr r0, =gUnknown_0203A118 - ldr r1, [r0] - ldrb r2, [r1, 0xA] - movs r0, 0xA - ldrsb r0, [r1, r0] - cmp r0, 0 - beq _0811B998 - subs r0, r2, 0x1 - strb r0, [r1, 0xA] -_0811B98E: - bl sub_811B9C8 - lsls r0, 24 - cmp r0, 0 - bne _0811B97C -_0811B998: - pop {r0} - bx r0 - .pool - thumb_func_end sub_811B978 - - thumb_func_start sub_811B9A0 -sub_811B9A0: @ 811B9A0 - push {lr} - b _0811B9B6 -_0811B9A4: - ldr r0, =gUnknown_0203A118 - ldr r1, [r0] - ldrb r2, [r1, 0x10] - movs r0, 0x10 - ldrsb r0, [r1, r0] - cmp r0, 0 - beq _0811B9C0 - subs r0, r2, 0x1 - strb r0, [r1, 0x10] -_0811B9B6: - bl sub_811BA1C - lsls r0, 24 - cmp r0, 0 - bne _0811B9A4 -_0811B9C0: - pop {r0} - bx r0 - .pool - thumb_func_end sub_811B9A0 - - thumb_func_start sub_811B9C8 -sub_811B9C8: @ 811B9C8 - push {r4,lr} - ldr r4, =gUnknown_0203A118 - ldr r1, [r4] - ldrb r0, [r1, 0x9] - cmp r0, 0 - bne _0811B9F8 - bl sub_811B8E8 - adds r4, r0, 0 - bl sub_811F3AC - movs r1, 0 - lsls r0, 24 - lsls r4, 16 - lsrs r4, 16 - lsrs r0, 24 - cmp r4, r0 - bcc _0811B9EE - movs r1, 0x1 -_0811B9EE: - adds r0, r1, 0 - b _0811BA14 - .pool -_0811B9F8: - ldrb r0, [r1, 0xB] - bl sub_811B960 - movs r2, 0 - ldr r1, [r4] - ldrb r1, [r1, 0xA] - lsls r1, 24 - asrs r1, 24 - lsls r0, 24 - lsrs r0, 24 - cmp r1, r0 - ble _0811BA12 - movs r2, 0x1 -_0811BA12: - adds r0, r2, 0 -_0811BA14: - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_811B9C8 - - thumb_func_start sub_811BA1C -sub_811BA1C: @ 811BA1C - push {r4,lr} - bl sub_811B940 - adds r4, r0, 0 - bl sub_811F5B0 - movs r1, 0 - lsls r4, 16 - lsls r0, 16 - cmp r4, r0 - bcc _0811BA34 - movs r1, 0x1 -_0811BA34: - adds r0, r1, 0 - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_811BA1C - - thumb_func_start sub_811BA3C -sub_811BA3C: @ 811BA3C - ldr r2, =gUnknown_08597550 - ldr r0, =gUnknown_0203A118 - ldr r0, [r0] - ldrb r1, [r0, 0x1] - lsls r0, r1, 1 - adds r0, r1 - lsls r0, 3 - adds r0, r2 - ldrb r0, [r0, 0x3] - lsrs r0, 7 - bx lr - .pool - thumb_func_end sub_811BA3C - - thumb_func_start sub_811BA5C -sub_811BA5C: @ 811BA5C - ldr r0, =gUnknown_0203A118 - ldr r0, [r0] - ldrb r0, [r0] - bx lr - .pool - thumb_func_end sub_811BA5C - - thumb_func_start sub_811BA68 -sub_811BA68: @ 811BA68 - ldr r2, =gUnknown_08597550 - ldr r0, =gUnknown_0203A118 - ldr r0, [r0] - ldrb r1, [r0, 0x1] - lsls r0, r1, 1 - adds r0, r1 - lsls r0, 3 - adds r0, r2 - ldrb r0, [r0, 0x3] - lsls r0, 25 - lsrs r0, 25 - bx lr - .pool - thumb_func_end sub_811BA68 - - thumb_func_start sub_811BA88 -sub_811BA88: @ 811BA88 - ldr r0, =gUnknown_0203A118 - ldr r0, [r0] - ldr r0, [r0, 0x34] - bx lr - .pool - thumb_func_end sub_811BA88 - - thumb_func_start sub_811BA94 -sub_811BA94: @ 811BA94 - ldr r0, =gUnknown_0203A118 - ldr r0, [r0] - adds r0, 0x3C - bx lr - .pool - thumb_func_end sub_811BA94 - - thumb_func_start sub_811BAA0 -sub_811BAA0: @ 811BAA0 - ldr r0, =gUnknown_0203A118 - ldr r0, [r0] - ldrb r0, [r0, 0x3] - bx lr - .pool - thumb_func_end sub_811BAA0 - - thumb_func_start sub_811BAAC -sub_811BAAC: @ 811BAAC - ldr r0, =gUnknown_0203A118 - ldr r0, [r0] - ldrb r0, [r0, 0x2] - bx lr - .pool - thumb_func_end sub_811BAAC - - thumb_func_start sub_811BAB8 -sub_811BAB8: @ 811BAB8 - ldr r0, =gUnknown_0203A118 - ldr r0, [r0] - ldrb r0, [r0, 0x5] - bx lr - .pool - thumb_func_end sub_811BAB8 - - thumb_func_start sub_811BAC4 -sub_811BAC4: @ 811BAC4 - ldr r0, =gUnknown_0203A118 - ldr r0, [r0] - ldrb r0, [r0, 0x6] - bx lr - .pool - thumb_func_end sub_811BAC4 - - thumb_func_start sub_811BAD0 -sub_811BAD0: @ 811BAD0 - push {r4,r5,lr} - ldr r4, =gUnknown_08597550 - ldr r2, =gUnknown_0203A118 - ldr r5, [r2] - ldrb r3, [r5, 0x1] - lsls r2, r3, 1 - adds r2, r3 - lsls r2, 3 - adds r3, r4, 0 - adds r3, 0x8 - adds r2, r3 - ldr r2, [r2] - str r2, [r0] - ldrb r2, [r5, 0x1] - lsls r0, r2, 1 - adds r0, r2 - lsls r0, 3 - adds r4, 0xC - adds r0, r4 - ldr r0, [r0] - str r0, [r1] - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_811BAD0 - - thumb_func_start sub_811BB08 -sub_811BB08: @ 811BB08 - push {r4,r5,lr} - ldr r4, =gUnknown_08597550 - ldr r2, =gUnknown_0203A118 - ldr r5, [r2] - ldrb r3, [r5, 0x1] - lsls r2, r3, 1 - adds r2, r3 - lsls r2, 3 - adds r3, r4, 0 - adds r3, 0x10 - adds r2, r3 - ldr r2, [r2] - str r2, [r0] - ldrb r2, [r5, 0x1] - lsls r0, r2, 1 - adds r0, r2 - lsls r0, 3 - adds r4, 0x14 - adds r0, r4 - ldr r0, [r0] - str r0, [r1] - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_811BB08 - - thumb_func_start sub_811BB40 -sub_811BB40: @ 811BB40 - push {lr} - adds r2, r0, 0 - ldr r0, =gUnknown_0203A118 - ldr r0, [r0] - ldrb r0, [r0] - cmp r0, 0x4 - bne _0811BB5C - ldr r0, =gText_StopGivingPkmnMail - b _0811BB7A - .pool -_0811BB5C: - cmp r0, 0x4 - blt _0811BB78 - cmp r0, 0x10 - bgt _0811BB78 - cmp r0, 0xF - blt _0811BB78 - ldr r0, =gText_LikeToQuitQuiz - str r0, [r2] - ldr r0, =gText_ChallengeQuestionMark - b _0811BB7E - .pool -_0811BB78: - ldr r0, =gText_QuitEditing -_0811BB7A: - str r0, [r2] - movs r0, 0 -_0811BB7E: - str r0, [r1] - pop {r0} - bx r0 - .pool - thumb_func_end sub_811BB40 - - thumb_func_start sub_811BB88 -sub_811BB88: @ 811BB88 - ldr r2, =gText_AllTextBeingEditedWill - str r2, [r0] - ldr r0, =gText_BeDeletedThatOkay - str r0, [r1] - bx lr - .pool - thumb_func_end sub_811BB88 - - thumb_func_start sub_811BB9C -sub_811BB9C: @ 811BB9C - ldr r2, =gUnknown_0203A118 - ldr r3, [r2] - ldrb r2, [r3, 0xA] - strb r2, [r0] - ldrb r0, [r3, 0xB] - strb r0, [r1] - bx lr - .pool - thumb_func_end sub_811BB9C - - thumb_func_start sub_811BBB0 -sub_811BBB0: @ 811BBB0 - ldr r0, =gUnknown_0203A118 - ldr r0, [r0] - ldrb r0, [r0, 0x9] - bx lr - .pool - thumb_func_end sub_811BBB0 - - thumb_func_start sub_811BBBC -sub_811BBBC: @ 811BBBC - ldr r0, =gUnknown_0203A118 - ldr r0, [r0] - ldrb r0, [r0, 0xC] - bx lr - .pool - thumb_func_end sub_811BBBC - - thumb_func_start sub_811BBC8 -sub_811BBC8: @ 811BBC8 - ldr r2, =gUnknown_0203A118 - ldr r3, [r2] - ldrb r2, [r3, 0x10] - strb r2, [r0] - ldrb r0, [r3, 0x11] - strb r0, [r1] - bx lr - .pool - thumb_func_end sub_811BBC8 - - thumb_func_start sub_811BBDC -sub_811BBDC: @ 811BBDC - ldr r0, =gUnknown_0203A118 - ldr r0, [r0] - ldrb r0, [r0, 0xE] - bx lr - .pool - thumb_func_end sub_811BBDC - - thumb_func_start sub_811BBE8 -sub_811BBE8: @ 811BBE8 - ldr r0, =gUnknown_0203A118 - ldr r0, [r0] - ldrb r0, [r0, 0xF] - bx lr - .pool - thumb_func_end sub_811BBE8 - - thumb_func_start sub_811BBF4 -sub_811BBF4: @ 811BBF4 - movs r0, 0 - bx lr - thumb_func_end sub_811BBF4 - - thumb_func_start sub_811BBF8 -sub_811BBF8: @ 811BBF8 - push {lr} - ldr r0, =gUnknown_0203A118 - ldr r1, [r0] - ldrb r0, [r1, 0x4] - cmp r0, 0x2 - beq _0811BC10 - cmp r0, 0x3 - beq _0811BC1A - b _0811BC24 - .pool -_0811BC10: - ldrb r0, [r1, 0x9] - cmp r0, 0 - bne _0811BC24 - ldrb r0, [r1, 0xC] - b _0811BC1C -_0811BC1A: - ldrb r0, [r1, 0xE] -_0811BC1C: - cmp r0, 0 - beq _0811BC24 - movs r0, 0x1 - b _0811BC26 -_0811BC24: - movs r0, 0 -_0811BC26: - pop {r1} - bx r1 - thumb_func_end sub_811BBF8 - - thumb_func_start sub_811BC2C -sub_811BC2C: @ 811BC2C - push {lr} - ldr r0, =gUnknown_0203A118 - ldr r2, [r0] - ldrb r0, [r2, 0x4] - cmp r0, 0x2 - beq _0811BC44 - cmp r0, 0x3 - beq _0811BC5A - b _0811BC68 - .pool -_0811BC44: - ldrb r0, [r2, 0x9] - cmp r0, 0 - bne _0811BC68 - ldrb r1, [r2, 0xC] - adds r1, 0x4 - ldrb r0, [r2, 0xD] - subs r0, 0x1 - cmp r1, r0 - bgt _0811BC68 - movs r0, 0x1 - b _0811BC6A -_0811BC5A: - ldrb r0, [r2, 0xE] - adds r0, 0x4 - ldrb r2, [r2, 0xF] - cmp r0, r2 - bgt _0811BC68 - movs r0, 0x1 - b _0811BC6A -_0811BC68: - movs r0, 0 -_0811BC6A: - pop {r1} - bx r1 - thumb_func_end sub_811BC2C - - thumb_func_start sub_811BC70 -sub_811BC70: @ 811BC70 - push {lr} - bl sub_811BA3C - pop {r1} - bx r1 - thumb_func_end sub_811BC70 - - thumb_func_start sub_811BC7C -sub_811BC7C: @ 811BC7C - push {r4,r5,lr} - adds r5, r0, 0 - lsls r1, 24 - lsrs r3, r1, 24 - movs r2, 0 - cmp r2, r3 - bcs _0811BCB2 - ldr r0, =gUnknown_0203A118 - ldr r0, [r0] - adds r4, r0, 0 - adds r4, 0x3C -_0811BC92: - lsls r0, r2, 1 - adds r1, r0, r5 - adds r0, r4, r0 - ldrh r1, [r1] - ldrh r0, [r0] - cmp r1, r0 - beq _0811BCA8 - movs r0, 0x1 - b _0811BCB4 - .pool -_0811BCA8: - adds r0, r2, 0x1 - lsls r0, 24 - lsrs r2, r0, 24 - cmp r2, r3 - bcc _0811BC92 -_0811BCB2: - movs r0, 0 -_0811BCB4: - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_811BC7C - - thumb_func_start sub_811BCBC -sub_811BCBC: @ 811BCBC - ldr r0, =gUnknown_0203A118 - ldr r0, [r0] - ldrb r0, [r0, 0x12] - bx lr - .pool - thumb_func_end sub_811BCBC - - thumb_func_start sub_811BCC8 -sub_811BCC8: @ 811BCC8 - push {lr} - lsls r0, 24 - lsrs r3, r0, 24 - movs r1, 0 - ldr r2, =gUnknown_08597550 -_0811BCD2: - ldrb r0, [r2] - cmp r0, r3 - bne _0811BCE4 - lsls r0, r1, 24 - lsrs r0, 24 - b _0811BCEE - .pool -_0811BCE4: - adds r2, 0x18 - adds r1, 0x1 - cmp r1, 0x14 - bls _0811BCD2 - movs r0, 0 -_0811BCEE: - pop {r1} - bx r1 - thumb_func_end sub_811BCC8 - - thumb_func_start sub_811BCF4 -sub_811BCF4: @ 811BCF4 - push {r4,lr} - movs r2, 0 - ldr r0, =gUnknown_0203A118 - ldr r0, [r0] - ldrb r1, [r0, 0x7] - cmp r2, r1 - bge _0811BD24 - ldr r4, =0x0000ffff - adds r3, r1, 0 - adds r1, r0, 0 - adds r1, 0x3C -_0811BD0A: - ldrh r0, [r1] - cmp r0, r4 - beq _0811BD1C - movs r0, 0 - b _0811BD26 - .pool -_0811BD1C: - adds r1, 0x2 - adds r2, 0x1 - cmp r2, r3 - blt _0811BD0A -_0811BD24: - movs r0, 0x1 -_0811BD26: - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_811BCF4 - - thumb_func_start sub_811BD2C -sub_811BD2C: @ 811BD2C - push {r4,lr} - movs r2, 0 - ldr r0, =gUnknown_0203A118 - ldr r0, [r0] - ldrb r1, [r0, 0x7] - cmp r2, r1 - bge _0811BD5C - ldr r4, =0x0000ffff - adds r3, r1, 0 - adds r1, r0, 0 - adds r1, 0x3C -_0811BD42: - ldrh r0, [r1] - cmp r0, r4 - bne _0811BD54 - movs r0, 0 - b _0811BD5E - .pool -_0811BD54: - adds r1, 0x2 - adds r2, 0x1 - cmp r2, r3 - blt _0811BD42 -_0811BD5C: - movs r0, 0x1 -_0811BD5E: - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_811BD2C - - thumb_func_start sub_811BD64 -sub_811BD64: @ 811BD64 - push {r4,lr} - ldr r0, =gUnknown_0203A118 - ldr r0, [r0] - ldrb r0, [r0] - cmp r0, 0x11 - bne _0811BD80 - bl sub_811BCF4 - b _0811BD9C - .pool -_0811BD7C: - movs r0, 0 - b _0811BD9C -_0811BD80: - ldr r0, =gSaveBlock1Ptr - ldr r0, [r0] - movs r2, 0 - ldr r3, =0x0000ffff - ldr r4, =0x00003b5a - adds r1, r0, r4 -_0811BD8C: - ldrh r0, [r1] - cmp r0, r3 - bne _0811BD7C - adds r1, 0x2 - adds r2, 0x1 - cmp r2, 0x8 - ble _0811BD8C - movs r0, 0x1 -_0811BD9C: - pop {r4} - pop {r1} - bx r1 - .pool - thumb_func_end sub_811BD64 - - thumb_func_start sub_811BDB0 -sub_811BDB0: @ 811BDB0 - push {lr} - ldr r0, =gUnknown_0203A118 - ldr r0, [r0] - ldrb r0, [r0] - cmp r0, 0x12 - bne _0811BDC8 - bl sub_811BCF4 - b _0811BDDE - .pool -_0811BDC8: - ldr r0, =gSaveBlock1Ptr - ldr r0, [r0] - ldr r1, =0x00003b58 - adds r0, r1 - movs r2, 0 - ldrh r1, [r0, 0x14] - ldr r0, =0x0000ffff - cmp r1, r0 - bne _0811BDDC - movs r2, 0x1 -_0811BDDC: - adds r0, r2, 0 -_0811BDDE: - pop {r1} - bx r1 - .pool - thumb_func_end sub_811BDB0 - - thumb_func_start sub_811BDF0 -sub_811BDF0: @ 811BDF0 - push {r4-r6,lr} - sub sp, 0x20 - adds r6, r0, 0 - ldr r0, =gSaveBlock1Ptr - ldr r4, [r0] - bl DynamicPlaceholderTextUtil_Reset - ldr r0, =0x00003b70 - adds r5, r4, r0 - adds r0, r5, 0 - bl StringLength - lsls r0, 16 - cmp r0, 0 - beq _0811BE34 - ldr r1, =0x00003b85 - adds r0, r4, r1 - ldrb r2, [r0] - mov r0, sp - adds r1, r5, 0 - bl TVShowConvertInternationalString - movs r0, 0 - mov r1, sp - bl DynamicPlaceholderTextUtil_SetPlaceholderPtr - b _0811BE3C - .pool -_0811BE34: - ldr r1, =gText_Lady - movs r0, 0 - bl DynamicPlaceholderTextUtil_SetPlaceholderPtr -_0811BE3C: - ldr r1, =gText_F700sQuiz - adds r0, r6, 0 - bl DynamicPlaceholderTextUtil_ExpandPlaceholders - add sp, 0x20 - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_811BDF0 - - thumb_func_start sub_811BE54 -sub_811BE54: @ 811BE54 - push {r4,r5,lr} - ldr r0, =gUnknown_0203A118 - ldr r0, [r0] - adds r4, r0, 0 - adds r4, 0x3C - ldr r2, =gStringVar2 - movs r5, 0 - b _0811BE86 - .pool -_0811BE6C: - ldrh r1, [r4] - adds r0, r2, 0 - movs r2, 0 - bl CopyEasyChatWordPadded - adds r2, r0, 0 - movs r0, 0 - strb r0, [r2] - adds r2, 0x1 - adds r4, 0x2 - adds r5, 0x1 - ldr r0, =gUnknown_0203A118 - ldr r0, [r0] -_0811BE86: - ldrb r0, [r0, 0x7] - cmp r5, r0 - blt _0811BE6C - subs r2, 0x1 - movs r0, 0xFF - strb r0, [r2] - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_811BE54 - - thumb_func_start sub_811BE9C -sub_811BE9C: @ 811BE9C - push {r4,r5,lr} - ldr r5, =gUnknown_0203A118 - ldr r0, [r5] - ldrb r0, [r0] - cmp r0, 0x9 - beq _0811BEF0 - cmp r0, 0x9 - bgt _0811BEB8 - cmp r0, 0 - beq _0811BEC2 - b _0811BF14 - .pool -_0811BEB8: - cmp r0, 0xD - beq _0811BF0C - cmp r0, 0x14 - beq _0811BED0 - b _0811BF14 -_0811BEC2: - ldr r0, =0x00000865 - bl FlagSet - b _0811BF14 - .pool -_0811BED0: - bl sub_811BF20 - adds r1, r0, 0 - cmp r1, 0 - beq _0811BEE4 - ldr r1, =gSpecialVar_0x8004 - movs r0, 0x2 - b _0811BF12 - .pool -_0811BEE4: - ldr r0, =gSpecialVar_0x8004 - strh r1, [r0] - b _0811BF14 - .pool -_0811BEF0: - bl sub_811BE54 - ldr r4, =gSpecialVar_0x8004 - ldr r0, [r5] - adds r0, 0x3C - bl sub_81226D8 - lsls r0, 24 - lsrs r0, 24 - strh r0, [r4] - b _0811BF14 - .pool -_0811BF0C: - bl sub_811BF40 - ldr r1, =gSpecialVar_0x8004 -_0811BF12: - strh r0, [r1] -_0811BF14: - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_811BE9C - - thumb_func_start sub_811BF20 -sub_811BF20: @ 811BF20 - push {lr} - ldr r0, =gUnknown_08597764 - movs r1, 0x4 - bl sub_811BC7C - movs r1, 0 - lsls r0, 24 - cmp r0, 0 - bne _0811BF34 - movs r1, 0x1 -_0811BF34: - adds r0, r1, 0 - pop {r1} - bx r1 - .pool - thumb_func_end sub_811BF20 - - thumb_func_start sub_811BF40 -sub_811BF40: @ 811BF40 - push {r4,r5,lr} - movs r4, 0 - movs r5, 0x80 - lsls r5, 9 -_0811BF48: - lsls r0, r4, 2 - ldr r1, =gUnknown_0859776C - adds r0, r1 - movs r1, 0x2 - bl sub_811BC7C - lsls r0, 24 - cmp r0, 0 - bne _0811BF64 - lsrs r0, r5, 16 - b _0811BF72 - .pool -_0811BF64: - movs r0, 0x80 - lsls r0, 9 - adds r5, r0 - adds r4, 0x1 - cmp r4, 0x4 - ble _0811BF48 - movs r0, 0 -_0811BF72: - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_811BF40 - - thumb_func_start sub_811BF78 -sub_811BF78: @ 811BF78 - ldr r0, =gUnknown_0203A118 - ldr r1, [r0] - movs r0, 0 - strb r0, [r1, 0x13] - bx lr - .pool - thumb_func_end sub_811BF78 - - thumb_func_start sub_811BF88 -sub_811BF88: @ 811BF88 - movs r0, 0 - bx lr - thumb_func_end sub_811BF88 - - thumb_func_start sub_811BF8C -sub_811BF8C: @ 811BF8C - push {lr} - bl sub_811CE94 - lsls r0, 24 - cmp r0, 0 - beq _0811BF9C - movs r0, 0x1 - b _0811BF9E -_0811BF9C: - movs r0, 0 -_0811BF9E: - pop {r1} - bx r1 - thumb_func_end sub_811BF8C - thumb_func_start sub_811BFA4 sub_811BFA4: @ 811BFA4 push {r4,lr} diff --git a/data/easy_chat.s b/data/easy_chat.s index ce416dfbc..4725f15d9 100644 --- a/data/easy_chat.s +++ b/data/easy_chat.s @@ -17,7 +17,7 @@ gUnknown_08597530:: @ 8597530 .4byte 0x0000001b .4byte sub_811A938 -gUnknown_08597550:: @ 8597550 +gEasyChatScreenTemplates:: @ 8597550 .byte 0x00, 0x02, 0x02, 0x00 .align 2 @@ -208,13 +208,20 @@ gUnknown_08597550:: @ 8597550 .4byte gText_IsAsShownOkay gUnknown_08597748:: @ 8597748 - .byte 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x00, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x00, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a + .byte 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x00 + .byte 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x00 + .byte 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13 + .byte 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a gUnknown_08597764:: @ 8597764 .2byte 0x0209, 0x140b, 0x1030, 0x102a gUnknown_0859776C:: @ 859776C - .2byte 0x1240, 0x0628, 0x061f, 0x2204, 0x1422, 0x0197, 0x0415, 0x0198, 0x2207, 0x0449 + .2byte 0x1240, 0x0628 + .2byte 0x061f, 0x2204 + .2byte 0x1422, 0x0197 + .2byte 0x0415, 0x0198 + .2byte 0x2207, 0x0449 .align 2 gUnknown_08597780:: @ 8597780 diff --git a/include/dewford_trend.h b/include/dewford_trend.h index dac5ea6c9..608a925f5 100644 --- a/include/dewford_trend.h +++ b/include/dewford_trend.h @@ -4,5 +4,6 @@ void InitDewfordTrend(void); void UpdateDewfordTrendPerDay(u16); void UpdateDewfordTrendPerDay(u16 days); +bool8 sub_81226D8(u16 *a); #endif // GUARD_DEWFORDTREND_H diff --git a/include/strings.h b/include/strings.h index 3acbc1c55..af1625140 100644 --- a/include/strings.h +++ b/include/strings.h @@ -2413,5 +2413,14 @@ extern const u8 gUnknown_085EDC45[]; extern const u8 gUnknown_085EDB00[]; extern const u8 gUnknown_085EDC84[]; +// Easy Chat Entry +extern const u8 gText_StopGivingPkmnMail[]; +extern const u8 gText_LikeToQuitQuiz[]; +extern const u8 gText_ChallengeQuestionMark[]; +extern const u8 gText_QuitEditing[]; +extern const u8 gText_AllTextBeingEditedWill[]; +extern const u8 gText_BeDeletedThatOkay[]; +extern const u8 gText_Lady[]; +extern const u8 gText_F700sQuiz[]; #endif // GUARD_STRINGS_H diff --git a/src/easy_chat.c b/src/easy_chat.c index 7158253d1..5f5d20e16 100644 --- a/src/easy_chat.c +++ b/src/easy_chat.c @@ -2,20 +2,24 @@ // Includes #include "global.h" #include "alloc.h" -#include "constants/songs.h" -#include "sound.h" -#include "overworld.h" -#include "task.h" -#include "main.h" -#include "link.h" -#include "field_weather.h" -#include "window.h" -#include "palette.h" -#include "event_data.h" +#include "dewford_trend.h" +#include "dynamic_placeholder_text_util.h" #include "easy_chat.h" +#include "event_data.h" +#include "field_weather.h" +#include "international_string_util.h" +#include "link.h" +#include "main.h" +#include "menu.h" +#include "overworld.h" +#include "palette.h" +#include "sound.h" #include "string_util.h" - -// Static type declarations +#include "strings.h" +#include "task.h" +#include "window.h" +#include "constants/flags.h" +#include "constants/songs.h" #define EZCHAT_TASK_STATE 0 #define EZCHAT_TASK_KIND 1 @@ -24,38 +28,52 @@ #define EZCHAT_TASK_UNK06 6 #define EZCHAT_TASK_SIZE 7 -// Static RAM declarations - -EWRAM_DATA struct +struct EasyChatScreenTemplate { - u8 kind; - u8 unk_01; - u8 unk_02; - u8 unk_03; - u8 unk_04; - s8 unk_05; - s8 unk_06; - u8 unk_07; - u8 unk_08; - u8 unk_09; - u8 unk_0a; - u8 unk_0b; - u8 unk_0c; - 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; + u8 unk_00; + u8 numColumns; + u8 numRows; + u8 unk_03_0:7; + u8 unk_03_7:1; + const u8 *titleText; + const u8 *instructionsText1; + const u8 *instructionsText2; + const u8 *confirmText1; + const u8 *confirmText2; +}; +struct EasyChatScreen +{ + /*0x00*/ u8 kind; + /*0x01*/ u8 templateId; + /*0x02*/ u8 numColumns; + /*0x03*/ u8 numRows; + /*0x04*/ u8 state; + /*0x05*/ s8 mainCursorColumn; + /*0x06*/ s8 mainCursorRow; + /*0x07*/ u8 unk_07; + /*0x08*/ u8 unk_08; + /*0x09*/ u8 unk_09; + /*0x0A*/ s8 unk_0a; + /*0x0B*/ s8 unk_0b; + /*0x0C*/ u8 unk_0c; + /*0x0D*/ u8 unk_0d; + /*0x0E*/ u8 unk_0e; + /*0x0F*/ u8 unk_0f; + /*0x10*/ s8 unk_10; + /*0x11*/ s8 unk_11; + /*0x12*/ u8 sizeParam; + /*0x13*/ u8 unk_13; + /*0x14*/ u8 unk_14[0x20]; + /*0x34*/ const u8 *titleText; + /*0x38*/ u16 *words; + /*0x3C*/ u16 ecWordBuffer[9]; +}; + +EWRAM_DATA struct EasyChatScreen *gEasyChatScreen = NULL; EWRAM_DATA void *gUnknown_0203A11C = 0; EWRAM_DATA void *gUnknown_0203A120 = 0; -// Static ROM declarations - static void sub_811A2C0(u8); static void sub_811A278(void); static bool8 sub_811A428(u8); @@ -68,23 +86,23 @@ static bool8 EasyChat_AllocateResources(u8, u16 *, u8); static void EasyChat_FreeResources(void); static u16 sub_811AAAC(void); static u16 sub_811AB68(void); -u16 sub_811ACDC(void); -u16 sub_811AE44(void); -u16 sub_811AF00(void); -u16 sub_811AF8C(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); -u16 sub_811B150(void); +static u16 sub_811ACDC(void); +static u16 sub_811AE44(void); +static u16 sub_811AF00(void); +static u16 sub_811AF8C(void); +static u16 sub_811AFEC(void); +static u16 sub_811B040(void); +static u16 sub_811B08C(void); +static u16 sub_811B0BC(void); +static u16 sub_811B0E8(void); +static u16 sub_811B0F8(void); +static u16 sub_811B150(void); u16 sub_811B1B4(void); u8 sub_811BA68(void); -u8 sub_811BCC8(u8); -void sub_811BDF0(u8 *); +static u8 sub_811BCC8(u8); +static void sub_811BDF0(u8 *); void sub_811BF78(void); -bool8 sub_811BF8C(void); +static bool8 sub_811BF8C(void); bool8 sub_811BFA4(void); void sub_811C13C(void); /*static*/ void sub_811C158(u16); @@ -92,23 +110,60 @@ void sub_811C13C(void); bool8 sub_811F28C(void); void sub_811F2B8(void); u8 sub_811F3AC(void); - -// .rodata +int sub_811BA3C(void); +int sub_811B184(void); +int sub_811B264(void); +static int sub_811B32C(void); +static int sub_811B2B0(void); +static int sub_811B33C(void); +static int sub_811B368(void); +static u16 sub_811B528(int); +static u16 sub_811B794(u32); +static int sub_811B394(void); +static u8 sub_811B2A4(void); +static void sub_811B3E4(void); +static void sub_811BE9C(void); +static int sub_811B4EC(void); +static void sub_811B418(void); +static void sub_811B454(void); +static int sub_811BD64(void); +static int sub_811BDB0(void); +static int sub_811BD2C(void); +int sub_811BCF4(void); +static u16 sub_811B8E8(void); +int sub_811F3B8(u8); +void sub_811F548(int, u16); +static int sub_811B908(void); +u16 sub_811F5B0(void); +static void sub_811B488(u16); +u16 sub_811B940(void); +u16 sub_811F578(u16); +int sub_811BF88(int); +static u16 sub_811B8C8(void); +static int sub_811B568(u32); +static int sub_811B634(u32); +static int sub_811B6C4(u32); +static void sub_811B978(void); +static void sub_811B744(void); +static u8 sub_811B9C8(void); +static void sub_811B768(void); +static u8 sub_811B960(u8); +static void sub_811B9A0(void); +static u8 sub_811BA1C(void); +static int sub_811BF20(void); +static u16 sub_811BF40(void); +u8 sub_811CE94(void); +u8 *CopyEasyChatWordPadded(u8 *, u16, u16); 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 +extern const struct EasyChatScreenTemplate gEasyChatScreenTemplates[21]; +extern const u8 gUnknown_08597748[][7]; +extern const u16 gUnknown_08597764[]; +extern const u16 gUnknown_0859776C[][2]; void sub_811A20C(u8 kind, u16 *words, MainCallback callback, u8 sizeParam) { @@ -444,66 +499,66 @@ void sub_811A938(void) static bool8 EasyChat_AllocateResources(u8 kind, u16 *words, u8 sizeParam) { - u8 r6; + u8 templateId; int i; - gUnknown_0203A118 = malloc(sizeof(*gUnknown_0203A118)); - if (gUnknown_0203A118 == NULL) + gEasyChatScreen = malloc(sizeof(*gEasyChatScreen)); + if (gEasyChatScreen == 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); + gEasyChatScreen->kind = kind; + gEasyChatScreen->words = words; + gEasyChatScreen->mainCursorColumn = 0; + gEasyChatScreen->mainCursorRow = 0; + gEasyChatScreen->unk_09 = 0; + gEasyChatScreen->sizeParam = sizeParam; + gEasyChatScreen->unk_13 = 0; + templateId = sub_811BCC8(kind); if (kind == 0x10) { - sub_811BDF0(gUnknown_0203A118->unk_14); - gUnknown_0203A118->src = gUnknown_0203A118->unk_14; - gUnknown_0203A118->unk_04 = 7; + sub_811BDF0(gEasyChatScreen->unk_14); + gEasyChatScreen->titleText = gEasyChatScreen->unk_14; + gEasyChatScreen->state = 7; } else { - gUnknown_0203A118->unk_04 = 0; - gUnknown_0203A118->src = gUnknown_08597550[r6].data; + gEasyChatScreen->state = 0; + gEasyChatScreen->titleText = gEasyChatScreenTemplates[templateId].titleText; } - 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) + gEasyChatScreen->numColumns = gEasyChatScreenTemplates[templateId].numColumns; + gEasyChatScreen->numRows = gEasyChatScreenTemplates[templateId].numRows; + gEasyChatScreen->unk_07 = gEasyChatScreen->numColumns * gEasyChatScreen->numRows; + gEasyChatScreen->templateId = templateId; + if (gEasyChatScreen->unk_07 > 9) { - gUnknown_0203A118->unk_07 = 9; + gEasyChatScreen->unk_07 = 9; } if (words != NULL) { - CpuCopy16(words, gUnknown_0203A118->ecWordBuffer, gUnknown_0203A118->unk_07 * sizeof(u16)); + CpuCopy16(words, gEasyChatScreen->ecWordBuffer, gEasyChatScreen->unk_07 * sizeof(u16)); } else { - for (i = 0; i < gUnknown_0203A118->unk_07; i ++) + for (i = 0; i < gEasyChatScreen->unk_07; i ++) { - gUnknown_0203A118->ecWordBuffer[i] = -1; + gEasyChatScreen->ecWordBuffer[i] = -1; } - gUnknown_0203A118->words = gUnknown_0203A118->ecWordBuffer; + gEasyChatScreen->words = gEasyChatScreen->ecWordBuffer; } - gUnknown_0203A118->unk_0d = (sub_811F3AC() - 1) / 2 + 1; + gEasyChatScreen->unk_0d = (sub_811F3AC() - 1) / 2 + 1; return TRUE; } static void EasyChat_FreeResources(void) { - if (gUnknown_0203A118 != NULL) - FREE_AND_SET_NULL(gUnknown_0203A118); + if (gEasyChatScreen != NULL) + FREE_AND_SET_NULL(gEasyChatScreen); } static u16 sub_811AAAC(void) { - switch (gUnknown_0203A118->unk_04) + switch (gEasyChatScreen->state) { case 0: return sub_811AB68(); @@ -549,263 +604,1612 @@ 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; + gEasyChatScreen->state = 2; + gEasyChatScreen->unk_0a = 0; + gEasyChatScreen->unk_0b = 0; + gEasyChatScreen->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--; + gEasyChatScreen->mainCursorRow--; } else if (gMain.newKeys & DPAD_LEFT) - { // FIXME: See note below - gUnknown_0203A118->unk_05--; + { + gEasyChatScreen->mainCursorColumn--; } else if (gMain.newKeys & DPAD_DOWN) - { // FIXME: See note below - gUnknown_0203A118->unk_06++; + { + gEasyChatScreen->mainCursorRow++; } else if (gMain.newKeys & DPAD_RIGHT) - { // FIXME: See note below - gUnknown_0203A118->unk_05++; + { + gEasyChatScreen->mainCursorColumn++; } else { return 0; } - if (gUnknown_0203A118->unk_06 < 0) + + if (gEasyChatScreen->mainCursorRow < 0) + gEasyChatScreen->mainCursorRow = gEasyChatScreenTemplates[gEasyChatScreen->templateId].numRows; + + if (gEasyChatScreen->mainCursorRow > gEasyChatScreenTemplates[gEasyChatScreen->templateId].numRows) + gEasyChatScreen->mainCursorRow = 0; + + if (gEasyChatScreen->mainCursorRow == gEasyChatScreenTemplates[gEasyChatScreen->templateId].numRows) { - 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; + if (gEasyChatScreen->mainCursorColumn > 2) + gEasyChatScreen->mainCursorColumn = 2; + + gEasyChatScreen->state = 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; - } + + if (gEasyChatScreen->mainCursorColumn < 0) + gEasyChatScreen->mainCursorColumn = gEasyChatScreenTemplates[gEasyChatScreen->templateId].numColumns - 1; + + if (gEasyChatScreen->mainCursorColumn >= gEasyChatScreenTemplates[gEasyChatScreen->templateId].numColumns) + gEasyChatScreen->mainCursorColumn = 0; + + if (sub_811AB44() && gEasyChatScreen->mainCursorColumn == 1 && gEasyChatScreen->mainCursorRow == 4) + gEasyChatScreen->mainCursorColumn = 0; + return 2; } #else -__attribute__((naked)) static u16 sub_811AB68(void) +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"); + asm_unified("\n\ + push {r4-r7,lr}\n\ + ldr r0, =gMain\n\ + ldrh r1, [r0, 0x2E]\n\ + movs r0, 0x1\n\ + ands r0, r1\n\ + cmp r0, 0\n\ + beq _0811ABB8\n\ + bl sub_811BF78\n\ + ldr r1, =gEasyChatScreen\n\ + ldr r3, [r1]\n\ + movs r2, 0\n\ + movs r0, 0x2\n\ + strb r0, [r3, 0x4]\n\ + ldr r0, [r1]\n\ + strb r2, [r0, 0xA]\n\ + ldr r0, [r1]\n\ + strb r2, [r0, 0xB]\n\ + ldr r0, [r1]\n\ + strb r2, [r0, 0xC]\n\ + movs r0, 0x9\n\ + b RETURN\n\ + .pool\n\ +_0811AB9C:\n\ + movs r0, 0x20\n\ + ands r0, r1\n\ + cmp r0, 0\n\ + bne _0811AC68_dpad_left\n\ + movs r0, 0x80\n\ + ands r0, r1\n\ + cmp r0, 0\n\ + bne _0811AC58_dpad_down\n\ + movs r0, 0x10\n\ + ands r0, r1\n\ + cmp r0, 0\n\ + bne _0811AC48_dpad_right\n\ + movs r0, 0\n\ + b RETURN\n\ +_0811ABB8:\n\ + movs r0, 0x2\n\ + ands r0, r1\n\ + cmp r0, 0\n\ + bne _0811AC78_b_button\n\ + movs r0, 0x8\n\ + ands r0, r1\n\ + cmp r0, 0\n\ + bne _0811AC7E_start_button\n\ + movs r0, 0x40\n\ + ands r0, r1\n\ + cmp r0, 0\n\ + beq _0811AB9C\n\ + ldr r2, =gEasyChatScreen\n\ + ldr r1, [r2]\n\ + ldrb r0, [r1, 0x6]\n\ + subs r0, 0x1\n\ +_0811ABD8:\n\ + strb r0, [r1, 0x6]\n\ +_0811ABDA:\n\ + adds r7, r2, 0\n\ + adds r4, r7, 0\n\ + ldr r2, [r4]\n\ + movs r0, 0x6\n\ + ldrsb r0, [r2, r0]\n\ + ldr r6, =gEasyChatScreenTemplates\n\ + cmp r0, 0\n\ + bge _0811ABF8\n\ + ldrb r0, [r2, 0x1]\n\ + lsls r1, r0, 1\n\ + adds r1, r0\n\ + lsls r1, 3\n\ + adds r1, r6\n\ + ldrb r0, [r1, 0x2]\n\ + strb r0, [r2, 0x6]\n\ +_0811ABF8:\n\ + ldr r3, [r4]\n\ + movs r2, 0x6\n\ + ldrsb r2, [r3, r2]\n\ + adds r5, r6, 0\n\ + ldrb r1, [r3, 0x1]\n\ + lsls r0, r1, 1\n\ + adds r0, r1\n\ + lsls r0, 3\n\ + adds r0, r5\n\ + ldrb r0, [r0, 0x2]\n\ + cmp r2, r0\n\ + ble _0811AC14\n\ + movs r0, 0\n\ + strb r0, [r3, 0x6]\n\ +_0811AC14:\n\ + ldr r3, [r4]\n\ + movs r2, 0x6\n\ + ldrsb r2, [r3, r2]\n\ + ldrb r1, [r3, 0x1]\n\ + lsls r0, r1, 1\n\ + adds r0, r1\n\ + lsls r0, 3\n\ + adds r1, r0, r5\n\ + ldrb r0, [r1, 0x2]\n\ + cmp r2, r0\n\ + bne _0811AC88\n\ + movs r0, 0x5\n\ + ldrsb r0, [r3, r0]\n\ + cmp r0, 0x2\n\ + ble _0811AC36\n\ + movs r0, 0x2\n\ + strb r0, [r3, 0x5]\n\ +_0811AC36:\n\ + ldr r1, [r4]\n\ + movs r0, 0x1\n\ + strb r0, [r1, 0x4]\n\ + movs r0, 0x3\n\ + b RETURN\n\ + .pool\n\ +_0811AC48_dpad_right:\n\ + ldr r2, =gEasyChatScreen\n\ + ldr r1, [r2]\n\ + ldrb r0, [r1, 0x5]\n\ + adds r0, 0x1\n\ + strb r0, [r1, 0x5]\n\ + b _0811ABDA\n\ + .pool\n\ +_0811AC58_dpad_down:\n\ + ldr r2, =gEasyChatScreen\n\ + ldr r1, [r2]\n\ + ldrb r0, [r1, 0x6]\n\ + adds r0, 0x1\n\ + b _0811ABD8\n\ + .pool\n\ +_0811AC68_dpad_left:\n\ + ldr r2, =gEasyChatScreen\n\ + ldr r1, [r2]\n\ + ldrb r0, [r1, 0x5]\n\ + subs r0, 0x1\n\ + strb r0, [r1, 0x5]\n\ + b _0811ABDA\n\ + .pool\n\ +_0811AC78_b_button:\n\ + bl sub_811B150\n\ + b _0811AC82\n\ +_0811AC7E_start_button:\n\ + bl sub_811B1B4\n\ +_0811AC82:\n\ + lsls r0, 16\n\ + lsrs r0, 16\n\ + b RETURN\n\ +_0811AC88:\n\ + movs r0, 0x5\n\ + ldrsb r0, [r3, r0]\n\ + cmp r0, 0\n\ + bge _0811AC96\n\ + ldrb r0, [r1, 0x1]\n\ + subs r0, 0x1\n\ + strb r0, [r3, 0x5]\n\ +_0811AC96:\n\ + ldr r3, [r4]\n\ + movs r2, 0x5\n\ + ldrsb r2, [r3, r2]\n\ + ldrb r1, [r3, 0x1]\n\ + lsls r0, r1, 1\n\ + adds r0, r1\n\ + lsls r0, 3\n\ + adds r0, r6\n\ + ldrb r0, [r0, 0x1]\n\ + cmp r2, r0\n\ + blt _0811ACB0\n\ + movs r0, 0\n\ + strb r0, [r3, 0x5]\n\ +_0811ACB0:\n\ + bl sub_811AB44\n\ + cmp r0, 0\n\ + beq _0811ACCA\n\ + ldr r2, [r7]\n\ + ldr r0, [r2, 0x4]\n\ + ldr r1, =0x00ffff00\n\ + ands r0, r1\n\ + ldr r1, =0x00040100\n\ + cmp r0, r1\n\ + bne _0811ACCA\n\ + movs r0, 0\n\ + strb r0, [r2, 0x5]\n\ +_0811ACCA:\n\ + movs r0, 0x2\n\ +RETURN:\n\ + pop {r4-r7}\n\ + pop {r1}\n\ + bx r1\n\ + .pool"); +} +#endif // NONMATCHING + +#ifdef NONMATCHING +static u16 sub_811ACDC(void) +{ + int numFooterColumns; + + if (gMain.newKeys & A_BUTTON) + { + switch (gEasyChatScreen->mainCursorColumn) + { + case 0: + return sub_811B184(); + case 1: + return sub_811B150(); + case 2: + return sub_811B1B4(); + case 3: + return sub_811B264(); + } + } + + if (gMain.newKeys & B_BUTTON) + return sub_811B150(); + else if (gMain.newKeys & START_BUTTON) + return sub_811B1B4(); + else if (gMain.newKeys & DPAD_UP) + gEasyChatScreen->mainCursorRow--; + else if (gMain.newKeys & DPAD_LEFT) + gEasyChatScreen->mainCursorColumn--; + else if (gMain.newKeys & DPAD_DOWN) + gEasyChatScreen->mainCursorRow = 0; + else if (gMain.newKeys & DPAD_RIGHT) + gEasyChatScreen->mainCursorColumn++; + else + return 0; + + if (gEasyChatScreen->mainCursorRow == gEasyChatScreenTemplates[gEasyChatScreen->templateId].numRows) + { + numFooterColumns = sub_811BA3C() ? 4 : 3; + if (gEasyChatScreen->mainCursorColumn < 0) + gEasyChatScreen->mainCursorColumn = numFooterColumns - 1; + + if (gEasyChatScreen->mainCursorColumn >= numFooterColumns) + gEasyChatScreen->mainCursorColumn = 0; + + return 3; + } + + if (gEasyChatScreen->mainCursorColumn >= gEasyChatScreenTemplates[gEasyChatScreen->templateId].numColumns) + gEasyChatScreen->mainCursorColumn = gEasyChatScreenTemplates[gEasyChatScreen->templateId].numColumns - 1; + + if (sub_811AB44() && gEasyChatScreen->mainCursorColumn == 1 && gEasyChatScreen->mainCursorRow == 4) + gEasyChatScreen->mainCursorColumn = 0; + + gEasyChatScreen->state = 0; + return 2; +} +#else +NAKED +static u16 sub_811ACDC(void) +{ + asm_unified("\n\ + push {r4-r6,lr}\n\ + ldr r2, =gMain\n\ + ldrh r1, [r2, 0x2E]\n\ + movs r0, 0x1\n\ + ands r0, r1\n\ + cmp r0, 0\n\ + beq _0811AD4A\n\ + ldr r0, =gEasyChatScreen\n\ + ldr r0, [r0]\n\ + ldrb r0, [r0, 0x5]\n\ + lsls r0, 24\n\ + asrs r0, 24\n\ + cmp r0, 0x1\n\ + beq _0811AD3E\n\ + b _0811AD24\n\ + .pool\n\ +_0811AD04:\n\ + movs r0, 0x20\n\ + ands r0, r2\n\ + lsls r0, 16\n\ + lsrs r3, r0, 16\n\ + cmp r3, 0\n\ + bne _0811ADE0\n\ + movs r0, 0x80\n\ + ands r0, r2\n\ + cmp r0, 0\n\ + bne _0811ADD0\n\ + movs r0, 0x10\n\ + ands r0, r2\n\ + cmp r0, 0\n\ + bne _0811ADC0\n\ + movs r0, 0\n\ + b _0811AE32\n\ +_0811AD24:\n\ + cmp r0, 0x1\n\ + bgt _0811AD2E\n\ + cmp r0, 0\n\ + beq _0811AD38\n\ + b _0811AD4A\n\ +_0811AD2E:\n\ + cmp r0, 0x2\n\ + beq _0811ADF6\n\ + cmp r0, 0x3\n\ + beq _0811AD44\n\ + b _0811AD4A\n\ +_0811AD38:\n\ + bl sub_811B184\n\ + b _0811ADFA\n\ +_0811AD3E:\n\ + bl sub_811B150\n\ + b _0811ADFA\n\ +_0811AD44:\n\ + bl sub_811B264\n\ + b _0811ADFA\n\ +_0811AD4A:\n\ + ldrh r2, [r2, 0x2E]\n\ + movs r0, 0x2\n\ + ands r0, r2\n\ + cmp r0, 0\n\ + bne _0811ADF0\n\ + movs r0, 0x8\n\ + ands r0, r2\n\ + cmp r0, 0\n\ + bne _0811ADF6\n\ + movs r0, 0x40\n\ + ands r0, r2\n\ + cmp r0, 0\n\ + beq _0811AD04\n\ + ldr r2, =gEasyChatScreen\n\ + ldr r1, [r2]\n\ + ldrb r0, [r1, 0x6]\n\ + subs r0, 0x1\n\ + strb r0, [r1, 0x6]\n\ +_0811AD6E:\n\ + adds r6, r2, 0\n\ +_0811AD70:\n\ + adds r5, r6, 0\n\ + ldr r4, [r5]\n\ + movs r3, 0x6\n\ + ldrsb r3, [r4, r3]\n\ + ldr r2, =gEasyChatScreenTemplates\n\ + ldrb r1, [r4, 0x1]\n\ + lsls r0, r1, 1\n\ + adds r0, r1\n\ + lsls r0, 3\n\ + adds r1, r0, r2\n\ + ldrb r0, [r1, 0x2]\n\ + cmp r3, r0\n\ + bne _0811AE00\n\ + bl sub_811BA3C\n\ + movs r2, 0x3\n\ + cmp r0, 0\n\ + beq _0811AD96\n\ + movs r2, 0x4\n\ +_0811AD96:\n\ + ldr r1, [r5]\n\ + movs r0, 0x5\n\ + ldrsb r0, [r1, r0]\n\ + cmp r0, 0\n\ + bge _0811ADA4\n\ + subs r0, r2, 0x1\n\ + strb r0, [r1, 0x5]\n\ +_0811ADA4:\n\ + ldr r1, [r5]\n\ + movs r0, 0x5\n\ + ldrsb r0, [r1, r0]\n\ + cmp r0, r2\n\ + blt _0811ADB2\n\ + movs r0, 0\n\ + strb r0, [r1, 0x5]\n\ +_0811ADB2:\n\ + movs r0, 0x3\n\ + b _0811AE32\n\ + .pool\n\ +_0811ADC0:\n\ + ldr r2, =gEasyChatScreen\n\ + ldr r1, [r2]\n\ + ldrb r0, [r1, 0x5]\n\ + adds r0, 0x1\n\ + strb r0, [r1, 0x5]\n\ + b _0811AD6E\n\ + .pool\n\ +_0811ADD0:\n\ + ldr r1, =gEasyChatScreen\n\ + ldr r0, [r1]\n\ + strb r3, [r0, 0x6]\n\ + adds r6, r1, 0\n\ + b _0811AD70\n\ + .pool\n\ +_0811ADE0:\n\ + ldr r2, =gEasyChatScreen\n\ + ldr r1, [r2]\n\ + ldrb r0, [r1, 0x5]\n\ + subs r0, 0x1\n\ + strb r0, [r1, 0x5]\n\ + b _0811AD6E\n\ + .pool\n\ +_0811ADF0:\n\ + bl sub_811B150\n\ + b _0811ADFA\n\ +_0811ADF6:\n\ + bl sub_811B1B4\n\ +_0811ADFA:\n\ + lsls r0, 16\n\ + lsrs r0, 16\n\ + b _0811AE32\n\ +_0811AE00:\n\ + movs r0, 0x5\n\ + ldrsb r0, [r4, r0]\n\ + ldrb r1, [r1, 0x1]\n\ + cmp r0, r1\n\ + blt _0811AE0E\n\ + subs r0, r1, 0x1\n\ + strb r0, [r4, 0x5]\n\ +_0811AE0E:\n\ + bl sub_811AB44\n\ + cmp r0, 0\n\ + beq _0811AE28\n\ + ldr r2, [r6]\n\ + ldr r0, [r2, 0x4]\n\ + ldr r1, =0x00ffff00\n\ + ands r0, r1\n\ + ldr r1, =0x00040100\n\ + cmp r0, r1\n\ + bne _0811AE28\n\ + movs r0, 0\n\ + strb r0, [r2, 0x5]\n\ +_0811AE28:\n\ + ldr r0, =gEasyChatScreen\n\ + ldr r1, [r0]\n\ + movs r0, 0\n\ + strb r0, [r1, 0x4]\n\ + movs r0, 0x2\n\ +_0811AE32:\n\ + pop {r4-r6}\n\ + pop {r1}\n\ + bx r1\n\ + .pool"); +} +#endif // NONMATCHING + +static u16 sub_811AE44(void) +{ + if (gMain.newKeys & B_BUTTON) + return sub_811B32C(); + + if (gMain.newKeys & A_BUTTON) + { + if (gEasyChatScreen->unk_0a != -1) + return sub_811B2B0(); + + switch (gEasyChatScreen->unk_0b) + { + case 0: + return sub_811B33C(); + case 1: + return sub_811B368(); + case 2: + return sub_811B32C(); + } + } + + if (gMain.newKeys & SELECT_BUTTON) + return sub_811B33C(); + + if (gMain.newAndRepeatedKeys & DPAD_UP) + return sub_811B528(2); + + if (gMain.newAndRepeatedKeys & DPAD_DOWN) + return sub_811B528(3); + + if (gMain.newAndRepeatedKeys & DPAD_LEFT) + return sub_811B528(1); + + if (gMain.newAndRepeatedKeys & DPAD_RIGHT) + return sub_811B528(0); + + return 0; +} + +static u16 sub_811AF00(void) +{ + if (gMain.newKeys & B_BUTTON) + { + gEasyChatScreen->state = 2; + return 14; + } + + if (gMain.newKeys & A_BUTTON) + return sub_811B394(); + + if (gMain.newKeys & START_BUTTON) + return sub_811B794(4); + + if (gMain.newKeys & SELECT_BUTTON) + return sub_811B794(5); + + if (gMain.newAndRepeatedKeys & DPAD_UP) + return sub_811B794(2); + + if (gMain.newAndRepeatedKeys & DPAD_DOWN) + return sub_811B794(3); + + if (gMain.newAndRepeatedKeys & DPAD_LEFT) + return sub_811B794(1); + + if (gMain.newAndRepeatedKeys & DPAD_RIGHT) + return sub_811B794(0); + + return 0; +} + +static u16 sub_811AF8C(void) +{ + u8 var0; + + switch (Menu_ProcessInputNoWrapClearOnChoose()) + { + case MENU_B_PRESSED: // B Button + case 1: // No + gEasyChatScreen->state = sub_811B2A4(); + return 7; + case 0: // Yes + gSpecialVar_Result = 0; + var0 = gEasyChatScreen->kind - 17; + if (var0 < 2) + sub_811B3E4(); + + return 24; + default: + return 0; + } +} + +static u16 sub_811AFEC(void) +{ + switch (Menu_ProcessInputNoWrapClearOnChoose()) + { + case MENU_B_PRESSED: // B Button + case 1: // No + gEasyChatScreen->state = sub_811B2A4(); + return 7; + case 0: // Yes + sub_811BE9C(); + gSpecialVar_Result = sub_811B4EC(); + sub_811B3E4(); + return 24; + default: + return 0; + } +} + +static u16 sub_811B040(void) +{ + switch (Menu_ProcessInputNoWrapClearOnChoose()) + { + case MENU_B_PRESSED: // B Button + case 1: // No + gEasyChatScreen->state = 1; + return 7; + case 0: // Yes + sub_811B418(); + gEasyChatScreen->state = 1; + return 8; + default: + return 0; + } +} + +static u16 sub_811B08C(void) +{ + if (gMain.newKeys & A_BUTTON) + return 26; + + if (gMain.newKeys & B_BUTTON) + return sub_811B150(); + + return 0; +} + +static u16 sub_811B0BC(void) +{ + if (gMain.newKeys & (A_BUTTON | B_BUTTON)) + { + gEasyChatScreen->state = sub_811B2A4(); + return 7; + } + + return 0; +} + +static u16 sub_811B0E8(void) +{ + gEasyChatScreen->state = 10; + return 6; +} + +static u16 sub_811B0F8(void) +{ + switch (Menu_ProcessInputNoWrapClearOnChoose()) + { + case MENU_B_PRESSED: // B Button + case 1: // No + sub_811B454(); + gEasyChatScreen->unk_08 = 0; + gEasyChatScreen->state = 8; + return 31; + case 0: // Yes + gSpecialVar_Result = sub_811B4EC(); + sub_811B3E4(); + return 24; + default: + return 0; + } +} + +static u16 sub_811B150(void) +{ + if (gEasyChatScreen->kind == 19 || gEasyChatScreen->kind == 11) + { + gEasyChatScreen->unk_08 = gEasyChatScreen->state; + gEasyChatScreen->state = 8; + return 34; + } + else + { + gEasyChatScreen->unk_08 = gEasyChatScreen->state; + gEasyChatScreen->state = 4; + return 5; + } +} + +int sub_811B184(void) +{ + gEasyChatScreen->unk_08 = gEasyChatScreen->state; + if (gEasyChatScreen->kind != 6) + { + gEasyChatScreen->state = 5; + return 4; + } + else + { + gEasyChatScreen->unk_08 = gEasyChatScreen->state; + gEasyChatScreen->state = 8; + return 32; + } +} + +u16 sub_811B1B4(void) +{ + gEasyChatScreen->unk_08 = gEasyChatScreen->state; + if (gEasyChatScreen->kind == 17) + { + if (sub_811BD64()) + { + gEasyChatScreen->state = 8; + return 29; + } + + if (sub_811BDB0()) + { + gEasyChatScreen->state = 8; + return 30; + } + + gEasyChatScreen->state = 6; + return 6; + } + else if (gEasyChatScreen->kind == 18) + { + if (sub_811BDB0()) + { + gEasyChatScreen->state = 8; + return 30; + } + + if (sub_811BD64()) + { + gEasyChatScreen->state = 8; + return 29; + } + + gEasyChatScreen->state = 6; + return 6; + } + else if (gEasyChatScreen->kind == 9 || gEasyChatScreen->kind == 13) + { + if (!sub_811BD2C()) + { + gEasyChatScreen->state = 8; + return 33; + } + + gEasyChatScreen->state = 6; + return 6; + } + else if (gEasyChatScreen->kind == 19 || gEasyChatScreen->kind == 11) + { + if (sub_811BCF4()) + { + gEasyChatScreen->state = 8; + return 34; + } + + gEasyChatScreen->state = 6; + return 6; + } + else if (gEasyChatScreen->kind == 20) + { + gEasyChatScreen->state = 6; + return 6; + } + else + { + if (sub_811BCF4() == 1 || !sub_811B4EC()) + { + gEasyChatScreen->state = 4; + return 5; + } + + gEasyChatScreen->state = 6; + return 6; + } +} + +int sub_811B264(void) +{ + gEasyChatScreen->unk_08 = gEasyChatScreen->state; + switch (gEasyChatScreen->kind) + { + case 15: + return 25; + case 17: + sub_811B3E4(); + return 28; + case 18: + sub_811B3E4(); + return 27; + default: + return 0; + } +} + +static u8 sub_811B2A4(void) +{ + return gEasyChatScreen->unk_08; +} + +static int sub_811B2B0(void) +{ + u16 var1; + + if (gEasyChatScreen->unk_09 == 0) + { + u8 var0 = sub_811F3B8(sub_811B8E8()); + sub_811F548(0, var0); + } + else + { + sub_811F548(1, sub_811B908()); + } + + var1 = sub_811F5B0(); + if (var1 == 0) + return 0; + + gEasyChatScreen->unk_0f = (var1 - 1) / 2; + gEasyChatScreen->unk_0e = 0; + gEasyChatScreen->unk_10 = 0; + gEasyChatScreen->unk_11 = 0; + gEasyChatScreen->state = 3; + return 11; +} + +static int sub_811B32C(void) +{ + gEasyChatScreen->state = 0; + return 10; +} + +static int sub_811B33C(void) +{ + gEasyChatScreen->unk_0a = 0; + gEasyChatScreen->unk_0b = 0; + gEasyChatScreen->unk_0c = 0; + if (!gEasyChatScreen->unk_09) + gEasyChatScreen->unk_09 = 1; + else + gEasyChatScreen->unk_09 = 0; + + return 23; +} + +static int sub_811B368(void) +{ + if (gEasyChatScreen->kind == 6) + { + PlaySE(SE_HAZURE); + return 0; + } + else + { + sub_811B488(0xFFFF); + return 1; + } +} + +static int sub_811B394(void) +{ + u16 easyChatWord = sub_811F578(sub_811B940()); + if (sub_811BF88(easyChatWord)) + { + PlaySE(SE_HAZURE); + return 0; + } + else + { + sub_811B488(easyChatWord); + if (gEasyChatScreen->kind != 6) + { + gEasyChatScreen->state = 0; + return 12; + } + else + { + gEasyChatScreen->state = 9; + return 13; + } + } +} + +static void sub_811B3E4(void) +{ + int i; + for (i = 0; i < gEasyChatScreen->unk_07; i++) + gEasyChatScreen->words[i] = gEasyChatScreen->ecWordBuffer[i]; +} + +static void sub_811B418(void) +{ + int i; + for (i = 0; i < gEasyChatScreen->unk_07; i++) + gEasyChatScreen->ecWordBuffer[i] = 0xFFFF; +} + +static void sub_811B454(void) +{ + int i; + for (i = 0; i < gEasyChatScreen->unk_07; i++) + gEasyChatScreen->ecWordBuffer[i] = gEasyChatScreen->words[i]; +} + +static void sub_811B488(u16 easyChatWord) +{ + u16 index = sub_811B8C8(); + gEasyChatScreen->ecWordBuffer[index] = easyChatWord; +} + +static u8 sub_811B4AC(void) +{ + u16 i; + for (i = 0; i < gEasyChatScreen->unk_07; i++) + { + if (gEasyChatScreen->ecWordBuffer[i] != gEasyChatScreen->words[i]) + return 1; + } + + return 0; +} + +static int sub_811B4EC(void) +{ + u8 var0 = gEasyChatScreen->kind - 17; + if (var0 < 2) + { + if (sub_811BD64()) + return 0; + + if (sub_811BDB0()) + return 0; + + return 1; + } + else + { + return sub_811B4AC(); + } +} + +static u16 sub_811B528(int arg0) +{ + if (gEasyChatScreen->unk_0a != -1) + { + if (gEasyChatScreen->unk_09 == 0) + return sub_811B568(arg0); + else + return sub_811B634(arg0); + } + else + { + return sub_811B6C4(arg0); + } +} + +static int sub_811B568(u32 arg0) +{ + switch (arg0) + { + case 2: + if (gEasyChatScreen->unk_0b != -gEasyChatScreen->unk_0c) + { + if (gEasyChatScreen->unk_0b) + { + gEasyChatScreen->unk_0b--; + return 15; + } + else + { + gEasyChatScreen->unk_0c--; + return 17; + } + } + break; + case 3: + if (gEasyChatScreen->unk_0b + gEasyChatScreen->unk_0c < gEasyChatScreen->unk_0d - 1) + { + int var0; + if (gEasyChatScreen->unk_0b < 3) + { + gEasyChatScreen->unk_0b++; + var0 = 15; + } + else + { + gEasyChatScreen->unk_0c++; + var0 = 16; + } + + sub_811B978(); + return var0; + } + break; + case 1: + if (gEasyChatScreen->unk_0a) + gEasyChatScreen->unk_0a--; + else + sub_811B744(); + + return 15; + case 0: + if (gEasyChatScreen->unk_0a < 1) + { + gEasyChatScreen->unk_0a++; + if (sub_811B9C8()) + sub_811B744(); + } + else + { + sub_811B744(); + } + return 15; + } + + return 0; +} + +static int sub_811B634(u32 arg0) +{ + switch (arg0) + { + case 2: + if (gEasyChatScreen->unk_0b > 0) + gEasyChatScreen->unk_0b--; + else + gEasyChatScreen->unk_0b = 3; + + sub_811B978(); + return 15; + case 3: + if (gEasyChatScreen->unk_0b < 3) + gEasyChatScreen->unk_0b++; + else + gEasyChatScreen->unk_0b = 0; + + sub_811B978(); + return 15; + case 0: + gEasyChatScreen->unk_0a++; + if (sub_811B9C8()) + sub_811B744(); + + return 15; + case 1: + gEasyChatScreen->unk_0a--; + if (gEasyChatScreen->unk_0a < 0) + sub_811B744(); + + return 15; + } + + return 0; +} + +static int sub_811B6C4(u32 arg0) +{ + switch (arg0) + { + case 2: + if (gEasyChatScreen->unk_0b) + gEasyChatScreen->unk_0b--; + else + gEasyChatScreen->unk_0b = 2; + + return 15; + case 3: + if (gEasyChatScreen->unk_0b < 2) + gEasyChatScreen->unk_0b++; + else + gEasyChatScreen->unk_0b = 0; + + return 15; + case 1: + gEasyChatScreen->unk_0b++; + sub_811B768(); + return 15; + case 0: + gEasyChatScreen->unk_0a = 0; + gEasyChatScreen->unk_0b++; + return 15; + } + + return 0; +} + +static void sub_811B744(void) +{ + gEasyChatScreen->unk_0a = 0xFF; + if (gEasyChatScreen->unk_0b) + gEasyChatScreen->unk_0b--; +} + +static void sub_811B768(void) +{ + if (gEasyChatScreen->unk_09 == 0) + { + gEasyChatScreen->unk_0a = 1; + sub_811B978(); + } + else + { + gEasyChatScreen->unk_0a = sub_811B960(gEasyChatScreen->unk_0b); + } +} + +static u16 sub_811B794(u32 arg0) +{ + u16 result; + switch (arg0) + { + case 2: + if (gEasyChatScreen->unk_11 + gEasyChatScreen->unk_0e > 0) + { + if (gEasyChatScreen->unk_11 > 0) + { + gEasyChatScreen->unk_11--; + result = 18; + } + else + { + gEasyChatScreen->unk_0e--; + result = 19; + } + + sub_811B9A0(); + return result; + } + break; + case 3: + if (gEasyChatScreen->unk_11 + gEasyChatScreen->unk_0e < gEasyChatScreen->unk_0f) + { + if (gEasyChatScreen->unk_11 < 3) + { + gEasyChatScreen->unk_11++; + result = 18; + } + else + { + gEasyChatScreen->unk_0e++; + result = 20; + } + + sub_811B9A0(); + return result; + } + break; + case 1: + if (gEasyChatScreen->unk_10 > 0) + gEasyChatScreen->unk_10--; + else + gEasyChatScreen->unk_10 = 1; + + sub_811B9A0(); + return 18; + case 0: + if (gEasyChatScreen->unk_10 < 1) + { + gEasyChatScreen->unk_10++; + if (sub_811BA1C()) + gEasyChatScreen->unk_10 = 0; + } + else + { + gEasyChatScreen->unk_10 = 0; + } + return 18; + case 4: + if (gEasyChatScreen->unk_0e) + { + if (gEasyChatScreen->unk_0e > 3) + gEasyChatScreen->unk_0e -= 4; + else + gEasyChatScreen->unk_0e = 0; + + return 21; + } + break; + case 5: + if (gEasyChatScreen->unk_0e <= gEasyChatScreen->unk_0f - 4) + { + gEasyChatScreen->unk_0e += 4; + if (gEasyChatScreen->unk_0e > gEasyChatScreen->unk_0f - 3) + gEasyChatScreen->unk_0e = gEasyChatScreen->unk_0f + 0xFD; + + sub_811B9A0(); + return 22; + } + break; + } + + return 0; +} + +static u16 sub_811B8C8(void) +{ + return (gEasyChatScreen->mainCursorRow * gEasyChatScreen->numColumns) + gEasyChatScreen->mainCursorColumn; +} + +static u16 sub_811B8E8(void) +{ + return 2 * (gEasyChatScreen->unk_0b + gEasyChatScreen->unk_0c) + gEasyChatScreen->unk_0a; +} + +static int sub_811B908(void) +{ + int var0 = (u8)gEasyChatScreen->unk_0a < 7 ? gEasyChatScreen->unk_0a : 0; + int var1 = (u8)gEasyChatScreen->unk_0b < 4 ? gEasyChatScreen->unk_0b : 0; + return gUnknown_08597748[var1][var0]; +} + +u16 sub_811B940(void) +{ + return 2 * (gEasyChatScreen->unk_11 + gEasyChatScreen->unk_0e) + gEasyChatScreen->unk_10; +} + +static u8 sub_811B960(u8 arg0) +{ + switch (arg0) + { + case 0: + default: + return 6; + case 1: + return 5; + } +} + +static void sub_811B978(void) +{ + while (sub_811B9C8()) + { + if (gEasyChatScreen->unk_0a) + gEasyChatScreen->unk_0a--; + else + break; + } +} + +static void sub_811B9A0(void) +{ + while (sub_811BA1C()) + { + if (gEasyChatScreen->unk_10) + gEasyChatScreen->unk_10--; + else + break; + } +} + +static u8 sub_811B9C8(void) +{ + if (gEasyChatScreen->unk_09 == 0) + return sub_811B8E8() >= sub_811F3AC() ? 1 : 0; + else + return gEasyChatScreen->unk_0a > sub_811B960(gEasyChatScreen->unk_0b) ? 1 : 0; +} + +static u8 sub_811BA1C(void) +{ + return sub_811B940() >= sub_811F5B0() ? 1 : 0; +} + +int sub_811BA3C(void) +{ + return gEasyChatScreenTemplates[gEasyChatScreen->templateId].unk_03_7; +} + +u8 sub_811BA5C(void) +{ + return gEasyChatScreen->kind; +} + +u8 sub_811BA68(void) +{ + return gEasyChatScreenTemplates[gEasyChatScreen->templateId].unk_03_0; +} + +const u8 *sub_811BA88(void) +{ + return gEasyChatScreen->titleText; +} + +u16 *sub_811BA94(void) +{ + return gEasyChatScreen->ecWordBuffer; +} + +u8 sub_811BAA0(void) +{ + return gEasyChatScreen->numRows; +} + +u8 sub_811BAAC(void) +{ + return gEasyChatScreen->numColumns; +} + +u8 sub_811BAB8(void) +{ + return gEasyChatScreen->mainCursorColumn; +} + +u8 sub_811BAC4(void) +{ + return gEasyChatScreen->mainCursorRow; +} + +void sub_811BAD0(const u8 **str1, const u8 **str2) +{ + *str1 = gEasyChatScreenTemplates[gEasyChatScreen->templateId].instructionsText1; + *str2 = gEasyChatScreenTemplates[gEasyChatScreen->templateId].instructionsText2; +} + +void sub_811BB08(const u8 **str1, const u8 **str2) +{ + *str1 = gEasyChatScreenTemplates[gEasyChatScreen->templateId].confirmText1; + *str2 = gEasyChatScreenTemplates[gEasyChatScreen->templateId].confirmText2; +} + +void sub_811BB40(const u8 **str1, const u8 **str2) +{ + switch (gEasyChatScreen->kind) + { + case 4: + *str1 = gText_StopGivingPkmnMail; + *str2 = NULL; + break; + case 15: + case 16: + *str1 = gText_LikeToQuitQuiz; + *str2 = gText_ChallengeQuestionMark; + break; + default: + *str1 = gText_QuitEditing; + *str2 = NULL; + break; + } + +} + +void sub_811BB88(const u8 **str1, const u8 **str2) +{ + *str1 = gText_AllTextBeingEditedWill; + *str2 = gText_BeDeletedThatOkay; +} + +void sub_811BB9C(u8 *arg0, u8 *arg1) +{ + *arg0 = gEasyChatScreen->unk_0a; + *arg1 = gEasyChatScreen->unk_0b; +} + +u8 sub_811BBB0(void) +{ + return gEasyChatScreen->unk_09; +} + +u8 sub_811BBBC(void) +{ + return gEasyChatScreen->unk_0c; +} + +void sub_811BBC8(u8 *arg0, u8 *arg1) +{ + *arg0 = gEasyChatScreen->unk_10; + *arg1 = gEasyChatScreen->unk_11; +} + +u8 sub_811BBDC(void) +{ + return gEasyChatScreen->unk_0e; +} + +u8 sub_811BBE8(void) +{ + return gEasyChatScreen->unk_0f; +} + +static u8 unref_sub_811BBF4(void) +{ + return 0; +} + +int sub_811BBF8(void) +{ + switch (gEasyChatScreen->state) + { + case 2: + if (gEasyChatScreen->unk_09 == 0 && gEasyChatScreen->unk_0c) + return 1; + break; + case 3: + if (gEasyChatScreen->unk_0e) + return 1; + break; + } + + return 0; +} + +int sub_811BC2C(void) +{ + switch (gEasyChatScreen->state) + { + case 2: + if (gEasyChatScreen->unk_09 == 0 && gEasyChatScreen->unk_0c + 4 <= gEasyChatScreen->unk_0d - 1) + return 1; + break; + case 3: + if (gEasyChatScreen->unk_0e + 4 <= gEasyChatScreen->unk_0f) + return 1; + break; + } + + return 0; +} + +int sub_811BC70(void) +{ + return sub_811BA3C(); +} + +u8 sub_811BC7C(const u16 *arg0, u8 arg1) +{ + u8 i; + + for (i = 0; i < arg1; i++) + { + if (arg0[i] != gEasyChatScreen->ecWordBuffer[i]) + return 1; + } + + return 0; +} + +u8 sub_811BCBC(void) +{ + return gEasyChatScreen->sizeParam; +} + +static u8 sub_811BCC8(u8 entryType) +{ + u32 i; + + for (i = 0; i < ARRAY_COUNT(gEasyChatScreenTemplates); i++) + { + if (gEasyChatScreenTemplates[i].unk_00 == entryType) + return i; + } + + return 0; +} + +int sub_811BCF4(void) +{ + int i; + + for (i = 0; i < gEasyChatScreen->unk_07; i++) + { + if (gEasyChatScreen->ecWordBuffer[i] != 0xFFFF) + return 0; + } + + return 1; +} + +static int sub_811BD2C(void) +{ + int i; + + for (i = 0; i < gEasyChatScreen->unk_07; i++) + { + if (gEasyChatScreen->ecWordBuffer[i] == 0xFFFF) + return 0; + } + + return 1; +} + +static int sub_811BD64(void) +{ + int i; + struct SaveBlock1 *saveBlock1; + + if (gEasyChatScreen->kind == 17) + return sub_811BCF4(); + + saveBlock1 = gSaveBlock1Ptr; + for (i = 0; i < 9; i++) + { + if (saveBlock1->lilycoveLady.quiz.unk_002[i] != 0xFFFF) + return 0; + } + + return 1; +} + +static int sub_811BDB0(void) +{ + struct LilycoveLadyQuiz *quiz; + if (gEasyChatScreen->kind == 18) + return sub_811BCF4(); + + quiz = &gSaveBlock1Ptr->lilycoveLady.quiz; + return quiz->unk_014 == 0xFFFF ? 1 : 0; +} + +static void sub_811BDF0(u8 *arg0) +{ + u8 name[32]; + struct SaveBlock1 *saveBlock1 = gSaveBlock1Ptr; + DynamicPlaceholderTextUtil_Reset(); + if (StringLength(saveBlock1->lilycoveLady.quiz.playerName) != 0) + { + TVShowConvertInternationalString(name, saveBlock1->lilycoveLady.quiz.playerName, saveBlock1->lilycoveLady.quiz.language); + DynamicPlaceholderTextUtil_SetPlaceholderPtr(0, name); + } + else + { + DynamicPlaceholderTextUtil_SetPlaceholderPtr(0, gText_Lady); + } + + DynamicPlaceholderTextUtil_ExpandPlaceholders(arg0, gText_F700sQuiz); +} + +static void sub_811BE54(void) +{ + int i; + u16 *ecWord; + u8 *str; + + ecWord = gEasyChatScreen->ecWordBuffer; + str = gStringVar2; + i = 0; + while (i < gEasyChatScreen->unk_07) + { + str = CopyEasyChatWordPadded(str, *ecWord, 0); + *str = 0; + str++; + ecWord++; + i++; + } + + str--; + str[0] = 0xFF; +} + +static void sub_811BE9C(void) +{ + switch (gEasyChatScreen->kind) + { + case 0: + FlagSet(FLAG_SYS_CHAT_USED); + break; + case 20: + if (sub_811BF20()) + gSpecialVar_0x8004 = 2; + else + gSpecialVar_0x8004 = 0; + break; + case 9: + sub_811BE54(); + gSpecialVar_0x8004 = sub_81226D8(gEasyChatScreen->ecWordBuffer); + break; + case 13: + gSpecialVar_0x8004 = sub_811BF40(); + break; + } +} + +static int sub_811BF20(void) +{ + return sub_811BC7C(gUnknown_08597764, 4) == 0; +} + +static u16 sub_811BF40(void) +{ + int i; + for (i = 0; i < 5; i++) + { + if (!sub_811BC7C(gUnknown_0859776C[i], 2)) + return i + 1; + } + + return 0; +} + +void sub_811BF78(void) +{ + gEasyChatScreen->unk_13 = 0; +} + +int sub_811BF88(int easyChatWord) +{ + return 0; +} + +static bool8 sub_811BF8C(void) +{ + if (!sub_811CE94()) + return 0; + else + return 1; } -#endif