diff --git a/asm/union_room_chat.s b/asm/union_room_chat.s index e3259a2c2..fb10de87f 100755 --- a/asm/union_room_chat.s +++ b/asm/union_room_chat.s @@ -5,2253 +5,6 @@ .text - thumb_func_start sub_801DD98 -sub_801DD98: @ 801DD98 - push {r4,lr} - ldr r4, =gUnknown_02022C84 - movs r0, 0xDE - lsls r0, 1 - bl Alloc - str r0, [r4] - bl sub_801DDD0 - ldr r1, =gKeyRepeatStartDelay - movs r0, 0x14 - strh r0, [r1] - movs r0, 0 - bl SetVBlankCallback - ldr r0, =c2_081284E0 - bl SetMainCallback2 - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_801DD98 - - thumb_func_start sub_801DDD0 -sub_801DDD0: @ 801DDD0 - push {r4-r7,lr} - adds r4, r0, 0 - movs r5, 0 - movs r0, 0 - strh r0, [r4, 0x4] - strh r0, [r4, 0x6] - strb r5, [r4, 0x10] - strb r5, [r4, 0x11] - strb r5, [r4, 0x12] - strb r5, [r4, 0x14] - strb r5, [r4, 0x15] - strb r5, [r4, 0x16] - movs r0, 0xFF - strb r0, [r4, 0x1A] - bl GetLinkPlayerCount - strb r0, [r4, 0xD] - bl GetMultiplayerId - strb r0, [r4, 0x13] - strb r5, [r4, 0x17] - strb r5, [r4, 0x18] - movs r1, 0xC8 - lsls r1, 1 - adds r0, r4, r1 - bl sub_801EF1C - ldr r7, =gSaveBlock1Ptr - ldr r6, =0x00003c88 - adds r4, 0xB9 - movs r5, 0x9 -_0801DE0E: - ldr r1, [r7] - adds r1, r6 - adds r0, r4, 0 - bl StringCopy - adds r6, 0x15 - adds r4, 0x15 - subs r5, 0x1 - cmp r5, 0 - bge _0801DE0E - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_801DDD0 - - thumb_func_start sub_801DE30 -sub_801DE30: @ 801DE30 - push {r4,lr} - ldr r4, =gUnknown_02022C84 - ldr r0, [r4] - ldrb r0, [r0, 0xE] - bl DestroyTask - ldr r0, [r4] - ldrb r0, [r0, 0xF] - bl DestroyTask - ldr r0, [r4] - bl Free - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_801DE30 - - thumb_func_start c2_081284E0 -c2_081284E0: @ 801DE54 - push {r4-r6,lr} - sub sp, 0x4 - ldr r0, =gMain - movs r1, 0x87 - lsls r1, 3 - adds r6, r0, r1 - ldrb r0, [r6] - cmp r0, 0x1 - beq _0801DE8C - cmp r0, 0x1 - bgt _0801DE74 - cmp r0, 0 - beq _0801DE7A - b _0801DF04 - .pool -_0801DE74: - cmp r0, 0x2 - beq _0801DEC8 - b _0801DF04 -_0801DE7A: - bl ResetTasks - bl ResetSpriteData - bl FreeAllSpritePalettes - bl sub_801F4D0 - b _0801DEBC -_0801DE8C: - bl sub_801F5B8 - bl sub_801F534 - adds r5, r0, 0 - cmp r5, 0 - bne _0801DF04 - movs r4, 0x1 - negs r4, r4 - adds r0, r4, 0 - movs r1, 0x10 - movs r2, 0 - bl BlendPalettes - str r5, [sp] - adds r0, r4, 0 - adds r1, r4, 0 - movs r2, 0x10 - movs r3, 0 - bl BeginNormalPaletteFade - ldr r0, =sub_801DF20 - bl SetVBlankCallback -_0801DEBC: - ldrb r0, [r6] - adds r0, 0x1 - strb r0, [r6] - b _0801DF04 - .pool -_0801DEC8: - bl UpdatePaletteFade - ldr r0, =gPaletteFade - ldrb r1, [r0, 0x7] - movs r0, 0x80 - ands r0, r1 - cmp r0, 0 - bne _0801DF04 - ldr r0, =sub_801DF38 - bl SetMainCallback2 - ldr r0, =sub_801DF54 - movs r1, 0x8 - bl CreateTask - ldr r4, =gUnknown_02022C84 - ldr r1, [r4] - strb r0, [r1, 0xE] - ldr r0, =sub_801F2B4 - movs r1, 0x7 - bl CreateTask - ldr r1, [r4] - strb r0, [r1, 0xF] - bl sub_800E0E8 - movs r0, 0xE8 - movs r1, 0x96 - bl CreateWirelessStatusIndicatorSprite -_0801DF04: - add sp, 0x4 - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end c2_081284E0 - - thumb_func_start sub_801DF20 -sub_801DF20: @ 801DF20 - push {lr} - bl TransferPlttBuffer - bl LoadOam - bl ProcessSpriteCopyRequests - bl ScanlineEffect_InitHBlankDmaTransfer - pop {r0} - bx r0 - thumb_func_end sub_801DF20 - - thumb_func_start sub_801DF38 -sub_801DF38: @ 801DF38 - push {lr} - bl RunTasks - bl sub_801F5B8 - bl AnimateSprites - bl BuildOamBuffer - bl UpdatePaletteFade - pop {r0} - bx r0 - thumb_func_end sub_801DF38 - - thumb_func_start sub_801DF54 -sub_801DF54: @ 801DF54 - push {r4,lr} - ldr r4, =gUnknown_02022C84 - ldr r0, [r4] - ldrb r0, [r0, 0x17] - cmp r0, 0x2 - beq _0801DF7A - cmp r0, 0x2 - bgt _0801DF70 - cmp r0, 0x1 - beq _0801DF76 - b _0801DF8A - .pool -_0801DF70: - cmp r0, 0x3 - beq _0801DF7E - b _0801DF8A -_0801DF76: - movs r0, 0x6 - b _0801DF80 -_0801DF7A: - movs r0, 0x7 - b _0801DF80 -_0801DF7E: - movs r0, 0x8 -_0801DF80: - bl sub_801EBD4 - ldr r1, [r4] - movs r0, 0 - strb r0, [r1, 0x17] -_0801DF8A: - ldr r1, =gUnknown_082F2A7C - ldr r0, =gUnknown_02022C84 - ldr r0, [r0] - ldrh r0, [r0, 0x4] - lsls r0, 2 - adds r0, r1 - ldr r0, [r0] - bl _call_via_r0 - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_801DF54 - - thumb_func_start sub_801DFAC -sub_801DFAC: @ 801DFAC - push {r4,lr} - ldr r4, =gUnknown_02022C84 - ldr r0, [r4] - ldrh r1, [r0, 0x6] - cmp r1, 0x1 - beq _0801DFE0 - cmp r1, 0x1 - bgt _0801DFC8 - cmp r1, 0 - beq _0801DFCE - b _0801E028 - .pool -_0801DFC8: - cmp r1, 0x2 - beq _0801E018 - b _0801E028 -_0801DFCE: - movs r1, 0xC8 - lsls r1, 1 - adds r0, r1 - bl sub_801EF24 - ldr r1, [r4] - ldrh r0, [r1, 0x6] - adds r0, 0x1 - strh r0, [r1, 0x6] -_0801DFE0: - bl IsLinkTaskFinished - lsls r0, 24 - cmp r0, 0 - beq _0801E028 - bl sub_8011A9C - cmp r0, 0 - bne _0801E028 - ldr r4, =gUnknown_02022C84 - ldr r1, [r4] - movs r0, 0xC8 - lsls r0, 1 - adds r1, r0 - movs r0, 0 - movs r2, 0x28 - bl SendBlock - lsls r0, 24 - cmp r0, 0 - beq _0801E028 - ldr r1, [r4] - ldrh r0, [r1, 0x6] - adds r0, 0x1 - strh r0, [r1, 0x6] - b _0801E028 - .pool -_0801E018: - bl IsLinkTaskFinished - lsls r0, 24 - cmp r0, 0 - beq _0801E028 - movs r0, 0x1 - bl sub_801EBD4 -_0801E028: - pop {r4} - pop {r0} - bx r0 - thumb_func_end sub_801DFAC - - thumb_func_start sub_801E030 -sub_801E030: @ 801E030 - push {r4,r5,lr} - ldr r5, =gUnknown_02022C84 - ldr r3, [r5] - ldrh r0, [r3, 0x6] - cmp r0, 0 - beq _0801E048 - cmp r0, 0x1 - beq _0801E0F6 - b _0801E118 - .pool -_0801E048: - ldr r1, =gMain - ldrh r2, [r1, 0x2E] - movs r0, 0x8 - ands r0, r2 - cmp r0, 0 - beq _0801E068 - ldrb r0, [r3, 0x15] - cmp r0, 0 - beq _0801E118 - movs r0, 0x4 - bl sub_801EBD4 - b _0801E118 - .pool -_0801E068: - movs r0, 0x4 - ands r0, r2 - cmp r0, 0 - beq _0801E078 - movs r0, 0x2 - bl sub_801EBD4 - b _0801E118 -_0801E078: - ldrh r1, [r1, 0x30] - movs r0, 0x2 - ands r0, r1 - cmp r0, 0 - beq _0801E0A4 - ldrb r0, [r3, 0x15] - cmp r0, 0 - beq _0801E09C - bl sub_801ED68 - movs r0, 0x8 - movs r1, 0 - bl sub_801F5EC - ldr r1, [r5] - movs r0, 0x1 - strh r0, [r1, 0x6] - b _0801E118 -_0801E09C: - movs r0, 0x3 - bl sub_801EBD4 - b _0801E118 -_0801E0A4: - movs r4, 0x1 - adds r0, r4, 0 - ands r0, r2 - cmp r0, 0 - beq _0801E0C0 - bl sub_801EC94 - movs r0, 0x8 - movs r1, 0 - bl sub_801F5EC - movs r0, 0x2 - movs r1, 0x1 - b _0801E0EC -_0801E0C0: - movs r0, 0x80 - lsls r0, 1 - ands r0, r2 - cmp r0, 0 - beq _0801E0E0 - ldrb r0, [r3, 0x10] - cmp r0, 0x3 - beq _0801E0D8 - bl sub_801ED94 - movs r0, 0x8 - b _0801E0EA -_0801E0D8: - movs r0, 0x5 - bl sub_801EBD4 - b _0801E118 -_0801E0E0: - bl sub_801EBE4 - cmp r0, 0 - beq _0801E118 - movs r0, 0x1 -_0801E0EA: - movs r1, 0 -_0801E0EC: - bl sub_801F5EC - ldr r0, [r5] - strh r4, [r0, 0x6] - b _0801E118 -_0801E0F6: - movs r0, 0 - bl sub_801F644 - adds r4, r0, 0 - lsls r4, 24 - lsrs r4, 24 - movs r0, 0x1 - bl sub_801F644 - lsls r0, 24 - lsrs r1, r0, 24 - cmp r4, 0 - bne _0801E118 - cmp r1, 0 - bne _0801E118 - ldr r0, [r5] - strh r1, [r0, 0x6] -_0801E118: - pop {r4,r5} - pop {r0} - bx r0 - thumb_func_end sub_801E030 - - thumb_func_start sub_801E120 -sub_801E120: @ 801E120 - push {r4-r6,lr} - ldr r0, =gUnknown_02022C84 - ldr r0, [r0] - ldrh r0, [r0, 0x6] - cmp r0, 0x4 - bls _0801E12E - b _0801E23A -_0801E12E: - lsls r0, 2 - ldr r1, =_0801E140 - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .pool - .align 2, 0 -_0801E140: - .4byte _0801E154 - .4byte _0801E15E - .4byte _0801E17C - .4byte _0801E208 - .4byte _0801E21C -_0801E154: - movs r0, 0x3 - movs r1, 0 - bl sub_801F5EC - b _0801E16A -_0801E15E: - movs r0, 0 - bl sub_801F644 - lsls r0, 24 - cmp r0, 0 - bne _0801E23A -_0801E16A: - ldr r0, =gUnknown_02022C84 - ldr r1, [r0] - ldrh r0, [r1, 0x6] - adds r0, 0x1 - strh r0, [r1, 0x6] - b _0801E23A - .pool -_0801E17C: - bl Menu_ProcessInput - lsls r0, 24 - asrs r0, 8 - lsrs r6, r0, 16 - asrs r4, r0, 16 - movs r0, 0x2 - negs r0, r0 - cmp r4, r0 - beq _0801E1B4 - adds r0, 0x1 - cmp r4, r0 - beq _0801E1D4 - movs r0, 0x4 - movs r1, 0 - bl sub_801F5EC - ldr r5, =gUnknown_02022C84 - ldr r2, [r5] - ldrb r0, [r2, 0x10] - cmp r0, r4 - beq _0801E1DC - cmp r4, 0x3 - ble _0801E1EC - b _0801E1DC - .pool -_0801E1B4: - ldr r0, =gMain - ldrh r1, [r0, 0x2E] - movs r0, 0x4 - ands r0, r1 - cmp r0, 0 - beq _0801E23A - movs r0, 0x5 - bl PlaySE - movs r0, 0x1 - bl Menu_MoveCursor - b _0801E23A - .pool -_0801E1D4: - movs r0, 0x4 - movs r1, 0 - bl sub_801F5EC -_0801E1DC: - ldr r0, =gUnknown_02022C84 - ldr r1, [r0] - movs r0, 0x3 - strh r0, [r1, 0x6] - b _0801E23A - .pool -_0801E1EC: - movs r1, 0 - strb r1, [r2, 0x11] - ldr r0, [r5] - strb r1, [r0, 0x12] - movs r0, 0x5 - movs r1, 0x1 - bl sub_801F5EC - ldr r0, [r5] - strb r6, [r0, 0x10] - ldr r1, [r5] - movs r0, 0x4 - strh r0, [r1, 0x6] - b _0801E23A -_0801E208: - movs r0, 0 - bl sub_801F644 - lsls r0, 24 - cmp r0, 0 - bne _0801E23A - movs r0, 0x1 - bl sub_801EBD4 - b _0801E23A -_0801E21C: - movs r0, 0 - bl sub_801F644 - lsls r0, 24 - cmp r0, 0 - bne _0801E23A - movs r0, 0x1 - bl sub_801F644 - lsls r0, 24 - cmp r0, 0 - bne _0801E23A - movs r0, 0x1 - bl sub_801EBD4 -_0801E23A: - pop {r4-r6} - pop {r0} - bx r0 - thumb_func_end sub_801E120 - - thumb_func_start sub_801E240 -sub_801E240: @ 801E240 - push {r4,r5,lr} - ldr r1, =gUnknown_02022C84 - ldr r0, [r1] - ldrh r0, [r0, 0x6] - adds r2, r1, 0 - cmp r0, 0xA - bls _0801E250 - b _0801E458 -_0801E250: - lsls r0, 2 - ldr r1, =_0801E264 - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .pool - .align 2, 0 -_0801E264: - .4byte _0801E290 - .4byte _0801E2A8 - .4byte _0801E2C4 - .4byte _0801E322 - .4byte _0801E3D4 - .4byte _0801E424 - .4byte _0801E458 - .4byte _0801E458 - .4byte _0801E378 - .4byte _0801E338 - .4byte _0801E35C -_0801E290: - movs r0, 0x6 - movs r1, 0 - bl sub_801F5EC - ldr r0, =gUnknown_02022C84 - ldr r1, [r0] - movs r0, 0x1 - strh r0, [r1, 0x6] - b _0801E458 - .pool -_0801E2A8: - movs r0, 0 - bl sub_801F644 - lsls r0, 24 - cmp r0, 0 - beq _0801E2B6 - b _0801E458 -_0801E2B6: - ldr r0, =gUnknown_02022C84 - ldr r1, [r0] - movs r0, 0x2 - strh r0, [r1, 0x6] - b _0801E458 - .pool -_0801E2C4: - bl sub_801FF08 - lsls r0, 24 - asrs r1, r0, 24 - cmp r1, 0 - beq _0801E2E6 - cmp r1, 0 - bgt _0801E2DE - movs r0, 0x1 - negs r0, r0 - cmp r1, r0 - beq _0801E396 - b _0801E458 -_0801E2DE: - cmp r1, 0x1 - beq _0801E2E4 - b _0801E458 -_0801E2E4: - b _0801E396 -_0801E2E6: - ldr r4, =gUnknown_02022C84 - ldr r1, [r4] - ldrb r0, [r1, 0x13] - cmp r0, 0 - bne _0801E310 - movs r2, 0xC8 - lsls r2, 1 - adds r0, r1, r2 - bl sub_801EFD0 - movs r0, 0x7 - movs r1, 0 - bl sub_801F5EC - ldr r1, [r4] - movs r0, 0x9 - strh r0, [r1, 0x6] - b _0801E458 - .pool -_0801E310: - movs r2, 0xC8 - lsls r2, 1 - adds r0, r1, r2 - bl sub_801EF7C - ldr r1, [r4] - movs r0, 0x4 - strh r0, [r1, 0x6] - b _0801E458 -_0801E322: - movs r0, 0 - bl sub_801F644 - lsls r0, 24 - cmp r0, 0 - beq _0801E330 - b _0801E458 -_0801E330: - movs r0, 0x1 - bl sub_801EBD4 - b _0801E458 -_0801E338: - movs r0, 0 - bl sub_801F644 - lsls r0, 24 - cmp r0, 0 - beq _0801E346 - b _0801E458 -_0801E346: - movs r0, 0x14 - movs r1, 0 - bl sub_801F5EC - ldr r0, =gUnknown_02022C84 - ldr r1, [r0] - movs r0, 0xA - strh r0, [r1, 0x6] - b _0801E458 - .pool -_0801E35C: - movs r0, 0 - bl sub_801F644 - lsls r0, 24 - cmp r0, 0 - beq _0801E36A - b _0801E458 -_0801E36A: - ldr r0, =gUnknown_02022C84 - ldr r1, [r0] - movs r0, 0x8 - strh r0, [r1, 0x6] - b _0801E458 - .pool -_0801E378: - bl sub_801FF08 - lsls r0, 24 - asrs r5, r0, 24 - cmp r5, 0 - beq _0801E3AC - cmp r5, 0 - bgt _0801E392 - movs r0, 0x1 - negs r0, r0 - cmp r5, r0 - beq _0801E396 - b _0801E458 -_0801E392: - cmp r5, 0x1 - bne _0801E458 -_0801E396: - movs r0, 0x7 - movs r1, 0 - bl sub_801F5EC - ldr r0, =gUnknown_02022C84 - ldr r1, [r0] - movs r0, 0x3 - strh r0, [r1, 0x6] - b _0801E458 - .pool -_0801E3AC: - bl sub_80104B0 - ldr r4, =gUnknown_02022C84 - ldr r0, [r4] - movs r1, 0xC8 - lsls r1, 1 - adds r0, r1 - bl sub_801EFD0 - ldr r0, [r4] - movs r1, 0x4 - strh r1, [r0, 0x6] - movs r2, 0xDC - lsls r2, 1 - adds r0, r2 - strh r5, [r0] - b _0801E458 - .pool -_0801E3D4: - bl IsLinkTaskFinished - lsls r0, 24 - cmp r0, 0 - beq _0801E414 - bl sub_8011A9C - cmp r0, 0 - bne _0801E414 - ldr r4, =gUnknown_02022C84 - ldr r1, [r4] - movs r0, 0xC8 - lsls r0, 1 - adds r1, r0 - movs r0, 0 - movs r2, 0x28 - bl SendBlock - lsls r0, 24 - cmp r0, 0 - beq _0801E414 - ldr r1, [r4] - ldrb r0, [r1, 0x13] - cmp r0, 0 - bne _0801E410 - movs r0, 0x6 - b _0801E412 - .pool -_0801E410: - movs r0, 0x5 -_0801E412: - strh r0, [r1, 0x6] -_0801E414: - ldr r0, =gReceivedRemoteLinkPlayers - ldrb r0, [r0] - cmp r0, 0 - bne _0801E458 - b _0801E42C - .pool -_0801E424: - ldr r0, =gReceivedRemoteLinkPlayers - ldrb r0, [r0] - cmp r0, 0 - bne _0801E438 -_0801E42C: - movs r0, 0x9 - bl sub_801EBD4 - b _0801E458 - .pool -_0801E438: - ldr r3, [r2] - movs r1, 0xDC - lsls r1, 1 - adds r2, r3, r1 - ldrh r0, [r2] - adds r0, 0x1 - strh r0, [r2] - lsls r0, 16 - movs r1, 0x96 - lsls r1, 17 - cmp r0, r1 - bls _0801E458 - movs r0, 0 - strh r0, [r2] - movs r0, 0x4 - strh r0, [r3, 0x6] -_0801E458: - pop {r4,r5} - pop {r0} - bx r0 - thumb_func_end sub_801E240 - - thumb_func_start sub_801E460 -sub_801E460: @ 801E460 - push {r4,lr} - ldr r1, =gUnknown_02022C84 - ldr r0, [r1] - ldrh r0, [r0, 0x6] - adds r2, r1, 0 - cmp r0, 0x7 - bls _0801E470 - b _0801E5BC -_0801E470: - lsls r0, 2 - ldr r1, =_0801E484 - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .pool - .align 2, 0 -_0801E484: - .4byte _0801E4A4 - .4byte _0801E4C8 - .4byte _0801E4E8 - .4byte _0801E50C - .4byte _0801E540 - .4byte _0801E560 - .4byte _0801E584 - .4byte _0801E5A8 -_0801E4A4: - ldr r0, =sub_801F2B4 - bl FuncIsActiveTask - lsls r0, 24 - cmp r0, 0 - beq _0801E4B2 - b _0801E5BC -_0801E4B2: - movs r0, 0x7 - movs r1, 0 - bl sub_801F5EC - ldr r0, =gUnknown_02022C84 - ldr r1, [r0] - b _0801E59A - .pool -_0801E4C8: - movs r0, 0 - bl sub_801F644 - lsls r0, 24 - cmp r0, 0 - bne _0801E5BC - movs r0, 0x12 - movs r1, 0 - bl sub_801F5EC - ldr r0, =gUnknown_02022C84 - ldr r1, [r0] - b _0801E59A - .pool -_0801E4E8: - movs r0, 0 - bl sub_801F644 - lsls r0, 24 - cmp r0, 0 - bne _0801E5BC - ldr r4, =gUnknown_02022C84 - ldr r0, [r4] - movs r1, 0xC8 - lsls r1, 1 - adds r0, r1 - bl sub_801EFA8 - ldr r1, [r4] - b _0801E59A - .pool -_0801E50C: - bl IsLinkTaskFinished - lsls r0, 24 - cmp r0, 0 - beq _0801E5BC - bl sub_8011A9C - cmp r0, 0 - bne _0801E5BC - ldr r4, =gUnknown_02022C84 - ldr r1, [r4] - movs r0, 0xC8 - lsls r0, 1 - adds r1, r0 - movs r0, 0 - movs r2, 0x28 - bl SendBlock - lsls r0, 24 - cmp r0, 0 - beq _0801E5BC - ldr r1, [r4] - b _0801E59A - .pool -_0801E540: - bl GetBlockReceivedStatus - movs r1, 0x1 - ands r1, r0 - cmp r1, 0 - beq _0801E5BC - bl sub_8011A9C - cmp r0, 0 - bne _0801E5BC - ldr r0, =gUnknown_02022C84 - ldr r1, [r0] - b _0801E59A - .pool -_0801E560: - bl IsLinkTaskFinished - lsls r0, 24 - cmp r0, 0 - beq _0801E5BC - bl sub_8011A9C - adds r4, r0, 0 - cmp r4, 0 - bne _0801E5BC - bl sub_800AC34 - ldr r0, =gUnknown_02022C84 - ldr r1, [r0] - strh r4, [r1, 0xA] - b _0801E59A - .pool -_0801E584: - ldr r1, [r2] - ldrh r0, [r1, 0xA] - cmp r0, 0x95 - bhi _0801E590 - adds r0, 0x1 - strh r0, [r1, 0xA] -_0801E590: - ldr r0, =gReceivedRemoteLinkPlayers - ldrb r0, [r0] - cmp r0, 0 - bne _0801E5BC - ldr r1, [r2] -_0801E59A: - ldrh r0, [r1, 0x6] - adds r0, 0x1 - strh r0, [r1, 0x6] - b _0801E5BC - .pool -_0801E5A8: - ldr r1, [r2] - ldrh r0, [r1, 0xA] - cmp r0, 0x95 - bls _0801E5B8 - movs r0, 0x9 - bl sub_801EBD4 - b _0801E5BC -_0801E5B8: - adds r0, 0x1 - strh r0, [r1, 0xA] -_0801E5BC: - pop {r4} - pop {r0} - bx r0 - thumb_func_end sub_801E460 - - thumb_func_start sub_801E5C4 -sub_801E5C4: @ 801E5C4 - push {r4,r5,lr} - ldr r5, =gUnknown_02022C84 - ldr r1, [r5] - ldrh r0, [r1, 0x6] - cmp r0, 0x1 - beq _0801E604 - cmp r0, 0x1 - bgt _0801E5E0 - cmp r0, 0 - beq _0801E5EA - b _0801E662 - .pool -_0801E5E0: - cmp r0, 0x2 - beq _0801E62E - cmp r0, 0x3 - beq _0801E650 - b _0801E662 -_0801E5EA: - ldr r0, =sub_801F2B4 - bl FuncIsActiveTask - lsls r0, 24 - cmp r0, 0 - bne _0801E662 - movs r0, 0x7 - movs r1, 0 - bl sub_801F5EC - b _0801E640 - .pool -_0801E604: - movs r0, 0 - bl sub_801F644 - lsls r0, 24 - cmp r0, 0 - bne _0801E662 - bl IsLinkTaskFinished - lsls r0, 24 - cmp r0, 0 - beq _0801E662 - bl sub_8011A9C - adds r4, r0, 0 - cmp r4, 0 - bne _0801E662 - bl sub_800AC34 - ldr r1, [r5] - strh r4, [r1, 0xA] - b _0801E642 -_0801E62E: - ldrh r0, [r1, 0xA] - cmp r0, 0x95 - bhi _0801E638 - adds r0, 0x1 - strh r0, [r1, 0xA] -_0801E638: - ldr r0, =gReceivedRemoteLinkPlayers - ldrb r0, [r0] - cmp r0, 0 - bne _0801E662 -_0801E640: - ldr r1, [r5] -_0801E642: - ldrh r0, [r1, 0x6] - adds r0, 0x1 - strh r0, [r1, 0x6] - b _0801E662 - .pool -_0801E650: - ldrh r0, [r1, 0xA] - cmp r0, 0x95 - bls _0801E65E - movs r0, 0x9 - bl sub_801EBD4 - b _0801E662 -_0801E65E: - adds r0, 0x1 - strh r0, [r1, 0xA] -_0801E662: - pop {r4,r5} - pop {r0} - bx r0 - thumb_func_end sub_801E5C4 - - thumb_func_start sub_801E668 -sub_801E668: @ 801E668 - push {r4,lr} - ldr r1, =gUnknown_02022C84 - ldr r0, [r1] - ldrh r0, [r0, 0x6] - adds r2, r1, 0 - cmp r0, 0x4 - bhi _0801E75C - lsls r0, 2 - ldr r1, =_0801E688 - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .pool - .align 2, 0 -_0801E688: - .4byte _0801E69C - .4byte _0801E6C8 - .4byte _0801E6F0 - .4byte _0801E724 - .4byte _0801E748 -_0801E69C: - ldr r0, =sub_801F2B4 - bl FuncIsActiveTask - lsls r0, 24 - cmp r0, 0 - bne _0801E75C - ldr r4, =gUnknown_02022C84 - ldr r0, [r4] - ldrb r0, [r0, 0x13] - cmp r0, 0 - beq _0801E6BA - movs r0, 0x7 - movs r1, 0 - bl sub_801F5EC -_0801E6BA: - ldr r1, [r4] - b _0801E73A - .pool -_0801E6C8: - movs r0, 0 - bl sub_801F644 - lsls r0, 24 - cmp r0, 0 - bne _0801E75C - ldr r4, =gUnknown_02022C84 - ldr r0, [r4] - ldrb r0, [r0, 0x13] - cmp r0, 0 - beq _0801E6E6 - movs r0, 0x13 - movs r1, 0 - bl sub_801F5EC -_0801E6E6: - ldr r1, [r4] - b _0801E73A - .pool -_0801E6F0: - movs r0, 0 - bl sub_801F644 - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - beq _0801E75C - bl IsLinkTaskFinished - lsls r0, 24 - cmp r0, 0 - beq _0801E75C - bl sub_8011A9C - adds r4, r0, 0 - cmp r4, 0 - bne _0801E75C - bl sub_800AC34 - ldr r0, =gUnknown_02022C84 - ldr r1, [r0] - strh r4, [r1, 0xA] - b _0801E73A - .pool -_0801E724: - ldr r1, [r2] - ldrh r0, [r1, 0xA] - cmp r0, 0x95 - bhi _0801E730 - adds r0, 0x1 - strh r0, [r1, 0xA] -_0801E730: - ldr r0, =gReceivedRemoteLinkPlayers - ldrb r0, [r0] - cmp r0, 0 - bne _0801E75C - ldr r1, [r2] -_0801E73A: - ldrh r0, [r1, 0x6] - adds r0, 0x1 - strh r0, [r1, 0x6] - b _0801E75C - .pool -_0801E748: - ldr r1, [r2] - ldrh r0, [r1, 0xA] - cmp r0, 0x95 - bls _0801E758 - movs r0, 0x9 - bl sub_801EBD4 - b _0801E75C -_0801E758: - adds r0, 0x1 - strh r0, [r1, 0xA] -_0801E75C: - pop {r4} - pop {r0} - bx r0 - thumb_func_end sub_801E668 - - thumb_func_start sub_801E764 -sub_801E764: @ 801E764 - push {r4,lr} - ldr r1, =gUnknown_02022C84 - ldr r0, [r1] - ldrh r0, [r0, 0x6] - adds r4, r1, 0 - cmp r0, 0x4 - bhi _0801E830 - lsls r0, 2 - ldr r1, =_0801E784 - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .pool - .align 2, 0 -_0801E784: - .4byte _0801E798 - .4byte _0801E7C0 - .4byte _0801E7F4 - .4byte _0801E802 - .4byte _0801E820 -_0801E798: - ldr r0, =gReceivedRemoteLinkPlayers - ldrb r0, [r0] - cmp r0, 0 - bne _0801E7AC - movs r0, 0x1 - bl sub_801EBD4 - b _0801E830 - .pool -_0801E7AC: - ldr r0, [r4] - movs r1, 0xC8 - lsls r1, 1 - adds r0, r1 - bl sub_801EF4C - ldr r1, [r4] - ldrh r0, [r1, 0x6] - adds r0, 0x1 - strh r0, [r1, 0x6] -_0801E7C0: - bl IsLinkTaskFinished - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bne _0801E830 - bl sub_8011A9C - cmp r0, 0 - bne _0801E830 - ldr r4, =gUnknown_02022C84 - ldr r1, [r4] - movs r0, 0xC8 - lsls r0, 1 - adds r1, r0 - movs r0, 0 - movs r2, 0x28 - bl SendBlock - lsls r0, 24 - cmp r0, 0 - beq _0801E830 - ldr r1, [r4] - b _0801E812 - .pool -_0801E7F4: - bl sub_801EE10 - movs r0, 0x8 - movs r1, 0 - bl sub_801F5EC - b _0801E80E -_0801E802: - movs r0, 0 - bl sub_801F644 - lsls r0, 24 - cmp r0, 0 - bne _0801E830 -_0801E80E: - ldr r0, =gUnknown_02022C84 - ldr r1, [r0] -_0801E812: - ldrh r0, [r1, 0x6] - adds r0, 0x1 - strh r0, [r1, 0x6] - b _0801E830 - .pool -_0801E820: - bl IsLinkTaskFinished - lsls r0, 24 - cmp r0, 0 - beq _0801E830 - movs r0, 0x1 - bl sub_801EBD4 -_0801E830: - pop {r4} - pop {r0} - bx r0 - thumb_func_end sub_801E764 - - thumb_func_start sub_801E838 -sub_801E838: @ 801E838 - push {r4,lr} - ldr r0, =gUnknown_02022C84 - ldr r0, [r0] - ldrh r0, [r0, 0x6] - cmp r0, 0x6 - bls _0801E846 - b _0801E968 -_0801E846: - lsls r0, 2 - ldr r1, =_0801E858 - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .pool - .align 2, 0 -_0801E858: - .4byte _0801E874 - .4byte _0801E8A4 - .4byte _0801E8F8 - .4byte _0801E910 - .4byte _0801E920 - .4byte _0801E934 - .4byte _0801E94C -_0801E874: - bl sub_801EDC4 - cmp r0, 0 - beq _0801E890 - movs r0, 0x9 - movs r1, 0 - bl sub_801F5EC - ldr r0, =gUnknown_02022C84 - ldr r1, [r0] - movs r0, 0x2 - b _0801E966 - .pool -_0801E890: - movs r0, 0xD - movs r1, 0 - bl sub_801F5EC - ldr r0, =gUnknown_02022C84 - ldr r1, [r0] - movs r0, 0x5 - b _0801E966 - .pool -_0801E8A4: - ldr r0, =gMain - ldrh r1, [r0, 0x2E] - movs r0, 0x1 - ands r0, r1 - cmp r0, 0 - beq _0801E8CC - bl sub_801EDE0 - movs r0, 0xB - movs r1, 0 - bl sub_801F5EC - ldr r0, =gUnknown_02022C84 - ldr r1, [r0] - movs r0, 0x3 - b _0801E966 - .pool -_0801E8CC: - movs r4, 0x2 - adds r0, r4, 0 - ands r0, r1 - cmp r0, 0 - beq _0801E8DA - movs r0, 0xA - b _0801E95A -_0801E8DA: - bl sub_801EBE4 - cmp r0, 0 - beq _0801E968 - movs r0, 0x1 - movs r1, 0 - bl sub_801F5EC - ldr r0, =gUnknown_02022C84 - ldr r0, [r0] - strh r4, [r0, 0x6] - b _0801E968 - .pool -_0801E8F8: - movs r0, 0 - bl sub_801F644 - lsls r0, 24 - cmp r0, 0 - bne _0801E968 - ldr r0, =gUnknown_02022C84 - ldr r1, [r0] - movs r0, 0x1 - b _0801E966 - .pool -_0801E910: - movs r0, 0 - bl sub_801F644 - lsls r0, 24 - cmp r0, 0 - bne _0801E968 - movs r0, 0xA - b _0801E95A -_0801E920: - movs r0, 0 - bl sub_801F644 - lsls r0, 24 - cmp r0, 0 - bne _0801E968 - movs r0, 0x1 - bl sub_801EBD4 - b _0801E968 -_0801E934: - movs r0, 0 - bl sub_801F644 - lsls r0, 24 - cmp r0, 0 - bne _0801E968 - ldr r0, =gUnknown_02022C84 - ldr r1, [r0] - movs r0, 0x6 - b _0801E966 - .pool -_0801E94C: - ldr r0, =gMain - ldrh r1, [r0, 0x2E] - movs r0, 0x3 - ands r0, r1 - cmp r0, 0 - beq _0801E968 - movs r0, 0x7 -_0801E95A: - movs r1, 0 - bl sub_801F5EC - ldr r0, =gUnknown_02022C84 - ldr r1, [r0] - movs r0, 0x4 -_0801E966: - strh r0, [r1, 0x6] -_0801E968: - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_801E838 - - thumb_func_start sub_801E978 -sub_801E978: @ 801E978 - push {r4,lr} - sub sp, 0x4 - ldr r1, =gUnknown_02022C84 - ldr r0, [r1] - ldrh r0, [r0, 0x6] - adds r4, r1, 0 - cmp r0, 0xD - bls _0801E98A - b _0801EBC2 -_0801E98A: - lsls r0, 2 - ldr r1, =_0801E99C - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .pool - .align 2, 0 -_0801E99C: - .4byte _0801E9D4 - .4byte _0801E9EE - .4byte _0801EA14 - .4byte _0801EA58 - .4byte _0801EA7C - .4byte _0801EA98 - .4byte _0801EADC - .4byte _0801EB04 - .4byte _0801EB28 - .4byte _0801EB40 - .4byte _0801EB64 - .4byte _0801EB72 - .4byte _0801EB88 - .4byte _0801EBA8 -_0801E9D4: - ldr r1, [r4] - ldrb r0, [r1, 0x18] - cmp r0, 0 - bne _0801E9DE - b _0801EB82 -_0801E9DE: - movs r0, 0x7 - movs r1, 0 - bl sub_801F5EC - ldr r1, [r4] - movs r0, 0x1 - strh r0, [r1, 0x6] - b _0801EBC2 -_0801E9EE: - movs r0, 0 - bl sub_801F644 - lsls r0, 24 - cmp r0, 0 - beq _0801E9FC - b _0801EBC2 -_0801E9FC: - movs r0, 0xE - movs r1, 0 - bl sub_801F5EC - ldr r0, =gUnknown_02022C84 - ldr r1, [r0] - movs r0, 0x2 - strh r0, [r1, 0x6] - b _0801EBC2 - .pool -_0801EA14: - bl sub_801FF08 - lsls r0, 24 - asrs r1, r0, 24 - cmp r1, 0 - beq _0801EA40 - cmp r1, 0 - bgt _0801EA2E - movs r0, 0x1 - negs r0, r0 - cmp r1, r0 - beq _0801EA34 - b _0801EBC2 -_0801EA2E: - cmp r1, 0x1 - beq _0801EA34 - b _0801EBC2 -_0801EA34: - ldr r0, =gUnknown_02022C84 - ldr r1, [r0] - b _0801EB82 - .pool -_0801EA40: - movs r0, 0x7 - movs r1, 0 - bl sub_801F5EC - ldr r0, =gUnknown_02022C84 - ldr r1, [r0] - movs r0, 0x3 - strh r0, [r1, 0x6] - b _0801EBC2 - .pool -_0801EA58: - movs r0, 0 - bl sub_801F644 - lsls r0, 24 - cmp r0, 0 - beq _0801EA66 - b _0801EBC2 -_0801EA66: - movs r0, 0xF - movs r1, 0 - bl sub_801F5EC - ldr r0, =gUnknown_02022C84 - ldr r1, [r0] - movs r0, 0x4 - strh r0, [r1, 0x6] - b _0801EBC2 - .pool -_0801EA7C: - movs r0, 0 - bl sub_801F644 - lsls r0, 24 - cmp r0, 0 - beq _0801EA8A - b _0801EBC2 -_0801EA8A: - ldr r0, =gUnknown_02022C84 - ldr r1, [r0] - movs r0, 0x5 - strh r0, [r1, 0x6] - b _0801EBC2 - .pool -_0801EA98: - bl sub_801FF08 - lsls r0, 24 - asrs r1, r0, 24 - cmp r1, 0 - beq _0801EAC4 - cmp r1, 0 - bgt _0801EAB2 - movs r0, 0x1 - negs r0, r0 - cmp r1, r0 - beq _0801EAB8 - b _0801EBC2 -_0801EAB2: - cmp r1, 0x1 - beq _0801EAB8 - b _0801EBC2 -_0801EAB8: - ldr r0, =gUnknown_02022C84 - ldr r1, [r0] - b _0801EB82 - .pool -_0801EAC4: - movs r0, 0x7 - movs r1, 0 - bl sub_801F5EC - ldr r0, =gUnknown_02022C84 - ldr r1, [r0] - movs r0, 0x6 - strh r0, [r1, 0x6] - b _0801EBC2 - .pool -_0801EADC: - movs r0, 0 - bl sub_801F644 - lsls r0, 24 - cmp r0, 0 - bne _0801EBC2 - movs r0, 0x10 - movs r1, 0 - bl sub_801F5EC - bl sub_801EE2C - ldr r0, =gUnknown_02022C84 - ldr r1, [r0] - movs r0, 0x7 - strh r0, [r1, 0x6] - b _0801EBC2 - .pool -_0801EB04: - movs r0, 0 - bl sub_801F644 - lsls r0, 24 - cmp r0, 0 - bne _0801EBC2 - bl SetContinueGameWarpStatusToDynamicWarp - movs r0, 0 - bl TrySavingData - ldr r0, =gUnknown_02022C84 - ldr r1, [r0] - movs r0, 0x8 - strh r0, [r1, 0x6] - b _0801EBC2 - .pool -_0801EB28: - movs r0, 0x11 - movs r1, 0 - bl sub_801F5EC - ldr r0, =gUnknown_02022C84 - ldr r1, [r0] - movs r0, 0x9 - strh r0, [r1, 0x6] - b _0801EBC2 - .pool -_0801EB40: - movs r0, 0 - bl sub_801F644 - lsls r0, 24 - cmp r0, 0 - bne _0801EBC2 - movs r0, 0x37 - bl PlaySE - bl ClearContinueGameWarpStatus2 - ldr r0, =gUnknown_02022C84 - ldr r1, [r0] - movs r0, 0xA - strh r0, [r1, 0x6] - b _0801EBC2 - .pool -_0801EB64: - ldr r1, [r4] - movs r0, 0 - strb r0, [r1, 0x19] - ldr r1, [r4] - movs r0, 0xB - strh r0, [r1, 0x6] - b _0801EBC2 -_0801EB72: - ldr r0, [r4] - ldrb r1, [r0, 0x19] - adds r1, 0x1 - strb r1, [r0, 0x19] - ldr r1, [r4] - ldrb r0, [r1, 0x19] - cmp r0, 0x78 - bls _0801EBC2 -_0801EB82: - movs r0, 0xC - strh r0, [r1, 0x6] - b _0801EBC2 -_0801EB88: - movs r1, 0x1 - negs r1, r1 - movs r0, 0 - str r0, [sp] - adds r0, r1, 0 - movs r2, 0 - movs r3, 0x10 - bl BeginNormalPaletteFade - ldr r0, =gUnknown_02022C84 - ldr r1, [r0] - movs r0, 0xD - strh r0, [r1, 0x6] - b _0801EBC2 - .pool -_0801EBA8: - ldr r0, =gPaletteFade - ldrb r1, [r0, 0x7] - movs r0, 0x80 - ands r0, r1 - cmp r0, 0 - bne _0801EBC2 - bl sub_801F544 - bl sub_801DE30 - ldr r0, =CB2_ReturnToField - bl SetMainCallback2 -_0801EBC2: - add sp, 0x4 - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_801E978 - - thumb_func_start sub_801EBD4 -sub_801EBD4: @ 801EBD4 - ldr r1, =gUnknown_02022C84 - ldr r1, [r1] - movs r2, 0 - strh r0, [r1, 0x4] - strh r2, [r1, 0x6] - bx lr - .pool - thumb_func_end sub_801EBD4 - - thumb_func_start sub_801EBE4 -sub_801EBE4: @ 801EBE4 - push {lr} - ldr r0, =gMain - ldrh r2, [r0, 0x30] - movs r0, 0x40 - ands r0, r2 - lsls r0, 16 - lsrs r3, r0, 16 - cmp r3, 0 - bne _0801EC6E - movs r0, 0x80 - ands r0, r2 - cmp r0, 0 - beq _0801EC24 - ldr r0, =gUnknown_02022C84 - ldr r2, [r0] - ldr r1, =gUnknown_082F2AA4 - ldrb r0, [r2, 0x10] - adds r0, r1 - ldrb r1, [r2, 0x12] - ldrb r0, [r0] - cmp r1, r0 - bcs _0801EC20 - adds r0, r1, 0x1 - b _0801EC88 - .pool -_0801EC20: - strb r3, [r2, 0x12] - b _0801EC8A -_0801EC24: - ldr r0, =gUnknown_02022C84 - ldr r1, [r0] - ldrb r0, [r1, 0x10] - cmp r0, 0x3 - beq _0801EC6A - movs r0, 0x20 - ands r0, r2 - lsls r0, 16 - lsrs r3, r0, 16 - cmp r3, 0 - beq _0801EC52 - ldrb r0, [r1, 0x11] - cmp r0, 0 - beq _0801EC4C - subs r0, 0x1 - strb r0, [r1, 0x11] - b _0801EC8A - .pool -_0801EC4C: - movs r0, 0x4 - strb r0, [r1, 0x11] - b _0801EC8A -_0801EC52: - movs r0, 0x10 - ands r0, r2 - cmp r0, 0 - beq _0801EC6A - ldrb r0, [r1, 0x11] - cmp r0, 0x3 - bhi _0801EC66 - adds r0, 0x1 - strb r0, [r1, 0x11] - b _0801EC8A -_0801EC66: - strb r3, [r1, 0x11] - b _0801EC8A -_0801EC6A: - movs r0, 0 - b _0801EC8C -_0801EC6E: - ldr r0, =gUnknown_02022C84 - ldr r2, [r0] - ldrb r0, [r2, 0x12] - cmp r0, 0 - beq _0801EC80 - subs r0, 0x1 - b _0801EC88 - .pool -_0801EC80: - ldr r0, =gUnknown_082F2AA4 - ldrb r1, [r2, 0x10] - adds r1, r0 - ldrb r0, [r1] -_0801EC88: - strb r0, [r2, 0x12] -_0801EC8A: - movs r0, 0x1 -_0801EC8C: - pop {r1} - bx r1 - .pool - thumb_func_end sub_801EBE4 - - thumb_func_start sub_801EC94 -sub_801EC94: @ 801EC94 - push {r4-r6,lr} - sub sp, 0x18 - ldr r0, =gUnknown_02022C84 - ldr r5, [r0] - ldrb r0, [r5, 0x10] - cmp r0, 0x3 - beq _0801ECDC - ldr r3, =gUnknown_082F2BA8 - ldrb r1, [r5, 0x12] - lsls r1, 2 - adds r2, r0, 0 - lsls r0, r2, 2 - adds r0, r2 - lsls r0, 3 - adds r1, r0 - adds r1, r3 - ldr r4, [r1] - ldrb r0, [r5, 0x11] - cmp r0, 0 - beq _0801ECCE - adds r1, r0, 0 -_0801ECBE: - ldrb r0, [r4] - cmp r0, 0xF9 - bne _0801ECC6 - adds r4, 0x1 -_0801ECC6: - adds r4, 0x1 - subs r1, 0x1 - cmp r1, 0 - bne _0801ECBE -_0801ECCE: - movs r5, 0x1 - b _0801ED02 - .pool -_0801ECDC: - ldrb r0, [r5, 0x12] - lsls r1, r0, 2 - adds r1, r0 - lsls r1, 2 - adds r1, r0 - adds r1, 0xB9 - adds r1, r5, r1 - mov r0, sp - bl StringCopy - movs r1, 0 - strb r1, [r0] - movs r1, 0xFF - strb r1, [r0, 0x1] - mov r4, sp - mov r0, sp - bl StringLength_Multibyte - adds r5, r0, 0 -_0801ED02: - ldr r6, =gUnknown_02022C84 - ldr r1, [r6] - ldrb r0, [r1, 0x15] - strb r0, [r1, 0x14] - cmp r4, 0 - beq _0801ED5A - bl sub_801EE84 - adds r2, r0, 0 - subs r5, 0x1 - movs r0, 0x1 - negs r0, r0 - cmp r5, r0 - beq _0801ED56 - ldr r0, [r6] - ldrb r0, [r0, 0x15] - cmp r0, 0xE - bhi _0801ED56 - adds r3, r6, 0 -_0801ED28: - ldrb r0, [r4] - cmp r0, 0xF9 - bne _0801ED34 - strb r0, [r2] - adds r4, 0x1 - adds r2, 0x1 -_0801ED34: - ldrb r0, [r4] - strb r0, [r2] - adds r4, 0x1 - adds r2, 0x1 - ldr r1, [r3] - ldrb r0, [r1, 0x15] - adds r0, 0x1 - strb r0, [r1, 0x15] - subs r5, 0x1 - movs r0, 0x1 - negs r0, r0 - cmp r5, r0 - beq _0801ED56 - ldr r0, [r3] - ldrb r0, [r0, 0x15] - cmp r0, 0xE - bls _0801ED28 -_0801ED56: - movs r0, 0xFF - strb r0, [r2] -_0801ED5A: - add sp, 0x18 - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_801EC94 - - thumb_func_start sub_801ED68 -sub_801ED68: @ 801ED68 - push {r4,lr} - ldr r4, =gUnknown_02022C84 - ldr r1, [r4] - ldrb r0, [r1, 0x15] - strb r0, [r1, 0x14] - ldr r0, [r4] - ldrb r0, [r0, 0x15] - cmp r0, 0 - beq _0801ED8A - bl sub_801EEA8 - movs r1, 0xFF - strb r1, [r0] - ldr r1, [r4] - ldrb r0, [r1, 0x15] - subs r0, 0x1 - strb r0, [r1, 0x15] -_0801ED8A: - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_801ED68 - - thumb_func_start sub_801ED94 -sub_801ED94: @ 801ED94 - push {lr} - ldr r0, =gUnknown_02022C84 - ldr r1, [r0] - ldrb r0, [r1, 0x15] - subs r0, 0x1 - strb r0, [r1, 0x14] - bl sub_801EEA8 - adds r2, r0, 0 - ldrb r0, [r2] - cmp r0, 0xF9 - beq _0801EDB8 - ldr r1, =gUnknown_082F2AA8 - adds r0, r1 - ldrb r0, [r0] - cmp r0, 0 - beq _0801EDB8 - strb r0, [r2] -_0801EDB8: - pop {r0} - bx r0 - .pool - thumb_func_end sub_801ED94 - - thumb_func_start sub_801EDC4 -sub_801EDC4: @ 801EDC4 - push {lr} - ldr r0, =gUnknown_02022C84 - ldr r0, [r0] - ldrb r0, [r0, 0x15] - cmp r0, 0 - bne _0801EDD8 - movs r0, 0 - b _0801EDDA - .pool -_0801EDD8: - movs r0, 0x1 -_0801EDDA: - pop {r1} - bx r1 - thumb_func_end sub_801EDC4 - - thumb_func_start sub_801EDE0 -sub_801EDE0: @ 801EDE0 - push {r4,lr} - bl sub_801F114 - adds r1, r0, 0 - ldr r4, =gUnknown_02022C84 - ldr r0, [r4] - ldrb r3, [r0, 0x12] - lsls r2, r3, 2 - adds r2, r3 - lsls r2, 2 - adds r2, r3 - adds r2, 0xB9 - adds r0, r2 - bl StringCopy - ldr r1, [r4] - movs r0, 0x1 - strb r0, [r1, 0x18] - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_801EDE0 - - thumb_func_start sub_801EE10 -sub_801EE10: @ 801EE10 - ldr r1, =gUnknown_02022C84 - ldr r2, [r1] - movs r0, 0xFF - strb r0, [r2, 0x1A] - ldr r2, [r1] - movs r3, 0 - movs r0, 0xF - strb r0, [r2, 0x14] - ldr r0, [r1] - strb r3, [r0, 0x15] - bx lr - .pool - thumb_func_end sub_801EE10 - - thumb_func_start sub_801EE2C -sub_801EE2C: @ 801EE2C - push {r4-r7,lr} - mov r7, r8 - push {r7} - ldr r0, =gSaveBlock1Ptr - mov r8, r0 - ldr r7, =gUnknown_02022C84 - movs r6, 0xB9 - ldr r5, =0x00003c88 - movs r4, 0x9 -_0801EE3E: - mov r1, r8 - ldr r0, [r1] - adds r0, r5 - ldr r1, [r7] - adds r1, r6 - bl StringCopy - adds r6, 0x15 - adds r5, 0x15 - subs r4, 0x1 - cmp r4, 0 - bge _0801EE3E - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_801EE2C - - thumb_func_start sub_801EE6C -sub_801EE6C: @ 801EE6C - ldr r2, =gUnknown_02022C84 - lsls r1, r0, 2 - adds r1, r0 - lsls r1, 2 - adds r1, r0 - adds r1, 0xB9 - ldr r0, [r2] - adds r0, r1 - bx lr - .pool - thumb_func_end sub_801EE6C - - thumb_func_start sub_801EE84 -sub_801EE84: @ 801EE84 - push {lr} - ldr r0, =gUnknown_02022C84 - ldr r0, [r0] - adds r1, r0, 0 - adds r1, 0x1A - ldrb r0, [r0, 0x1A] - cmp r0, 0xFF - beq _0801EE9C -_0801EE94: - adds r1, 0x1 - ldrb r0, [r1] - cmp r0, 0xFF - bne _0801EE94 -_0801EE9C: - adds r0, r1, 0 - pop {r1} - bx r1 - .pool - thumb_func_end sub_801EE84 - - thumb_func_start sub_801EEA8 -sub_801EEA8: @ 801EEA8 - push {lr} - ldr r0, =gUnknown_02022C84 - ldr r0, [r0] - adds r2, r0, 0 - adds r2, 0x1A - adds r1, r2, 0 - ldrb r0, [r0, 0x1A] - cmp r0, 0xFF - beq _0801EECC -_0801EEBA: - adds r2, r1, 0 - ldrb r0, [r2] - cmp r0, 0xF9 - bne _0801EEC4 - adds r1, r2, 0x1 -_0801EEC4: - adds r1, 0x1 - ldrb r0, [r1] - cmp r0, 0xFF - bne _0801EEBA -_0801EECC: - adds r0, r2, 0 - pop {r1} - bx r1 - .pool - thumb_func_end sub_801EEA8 - - thumb_func_start sub_801EED8 -sub_801EED8: @ 801EED8 - push {r4,lr} - ldr r4, =gUnknown_02022C84 - ldr r0, [r4] - adds r0, 0x1A - bl StringLength_Multibyte - adds r2, r0, 0 - ldr r0, [r4] - adds r1, r0, 0 - adds r1, 0x1A - movs r4, 0 - cmp r2, 0xA - bls _0801EF0C - subs r2, 0xA - movs r3, 0 - cmp r4, r2 - bcs _0801EF0C -_0801EEFA: - ldrb r0, [r1] - cmp r0, 0xF9 - bne _0801EF02 - adds r1, 0x1 -_0801EF02: - adds r1, 0x1 - adds r4, 0x1 - adds r3, 0x1 - cmp r3, r2 - bcc _0801EEFA -_0801EF0C: - lsls r0, r4, 16 - lsrs r0, 16 - pop {r4} - pop {r1} - bx r1 - .pool - thumb_func_end sub_801EED8 - - thumb_func_start sub_801EF1C -sub_801EF1C: @ 801EF1C - movs r1, 0 - strb r1, [r0] - bx lr - thumb_func_end sub_801EF1C - - thumb_func_start sub_801EF24 -sub_801EF24: @ 801EF24 - push {r4,lr} - adds r4, r0, 0 - movs r0, 0x2 - strb r0, [r4] - adds r0, r4, 0x1 - ldr r1, =gSaveBlock2Ptr - ldr r1, [r1] - bl StringCopy - ldr r0, =gUnknown_02022C84 - ldr r0, [r0] - ldrb r0, [r0, 0x13] - strb r0, [r4, 0x9] - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_801EF24 - - thumb_func_start sub_801EF4C -sub_801EF4C: @ 801EF4C - push {r4,lr} - adds r4, r0, 0 - movs r0, 0x1 - strb r0, [r4] - adds r0, r4, 0x1 - ldr r1, =gSaveBlock2Ptr - ldr r1, [r1] - bl StringCopy - adds r4, 0x9 - ldr r0, =gUnknown_02022C84 - ldr r1, [r0] - adds r1, 0x1A - adds r0, r4, 0 - bl StringCopy - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_801EF4C - - thumb_func_start sub_801EF7C -sub_801EF7C: @ 801EF7C - push {r4,lr} - adds r4, r0, 0 - movs r0, 0x3 - strb r0, [r4] - adds r0, r4, 0x1 - ldr r1, =gSaveBlock2Ptr - ldr r1, [r1] - bl StringCopy - ldr r0, =gUnknown_02022C84 - ldr r0, [r0] - ldrb r0, [r0, 0x13] - strb r0, [r4, 0x9] - bl sub_8011A50 - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_801EF7C - - thumb_func_start sub_801EFA8 -sub_801EFA8: @ 801EFA8 - push {r4,lr} - adds r4, r0, 0 - movs r0, 0x4 - strb r0, [r4] - adds r0, r4, 0x1 - ldr r1, =gSaveBlock2Ptr - ldr r1, [r1] - bl StringCopy - ldr r0, =gUnknown_02022C84 - ldr r0, [r0] - ldrb r0, [r0, 0x13] - strb r0, [r4, 0x9] - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_801EFA8 - - thumb_func_start sub_801EFD0 -sub_801EFD0: @ 801EFD0 - push {r4,lr} - adds r4, r0, 0 - movs r0, 0x5 - strb r0, [r4] - adds r0, r4, 0x1 - ldr r1, =gSaveBlock2Ptr - ldr r1, [r1] - bl StringCopy - ldr r0, =gUnknown_02022C84 - ldr r0, [r0] - ldrb r0, [r0, 0x13] - strb r0, [r4, 0x9] - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_801EFD0 - thumb_func_start sub_801EFF8 sub_801EFF8: @ 801EFF8 push {r4-r6,lr} diff --git a/data/union_room_chat.s b/data/union_room_chat.s index 41ca06d9a..143678cd4 100755 --- a/data/union_room_chat.s +++ b/data/union_room_chat.s @@ -3,23 +3,6 @@ .section .rodata - .align 2 -gUnknown_082F2A7C:: @ 82F2A7C - .4byte sub_801DFAC - .4byte sub_801E030 - .4byte sub_801E120 - .4byte sub_801E240 - .4byte sub_801E764 - .4byte sub_801E838 - .4byte sub_801E460 - .4byte sub_801E5C4 - .4byte sub_801E668 - .4byte sub_801E978 - - .align 2 -gUnknown_082F2AA4:: @ 82F2AA4 - .byte 0x09, 0x09, 0x09, 0x09 - .align 2 gUnknown_082F2AA8:: @ 82F2AA8 .byte 0x00, 0x16, 0x17, 0x68, 0x19, 0x1a, 0x1b, 0x1c @@ -57,36 +40,9 @@ gUnknown_082F2AA8:: @ 82F2AA8 .align 2 gUnknown_082F2BA8:: @ 82F2BA8 - .4byte gUnknown_0862B9F9 - .4byte gUnknown_0862B9FF - .4byte gUnknown_0862BA05 - .4byte gUnknown_0862BA0B - .4byte gUnknown_0862BA11 - .4byte gUnknown_0862BA17 - .4byte gUnknown_0862BA1D - .4byte gUnknown_0862BA23 - .4byte gUnknown_0862BA29 - .4byte gUnknown_0862BA2F - .4byte gUnknown_0862BA35 - .4byte gUnknown_0862BA3B - .4byte gUnknown_0862BA41 - .4byte gUnknown_0862BA47 - .4byte gUnknown_0862BA4D - .4byte gUnknown_0862BA53 - .4byte gUnknown_0862BA59 - .4byte gUnknown_0862BA5F - .4byte gUnknown_0862BA65 - .4byte gUnknown_0862BA6B - .4byte gUnknown_0862BA79 - .4byte gUnknown_0862BA84 - .4byte gUnknown_0862BA8F - .4byte gUnknown_0862BA9A - .4byte gUnknown_0862BAA3 - .4byte gUnknown_0862BAAE - .4byte gUnknown_0862BAB9 - .4byte gUnknown_0862BAC4 - .4byte gUnknown_0862BACF - .4byte gUnknown_0862BADA + .4byte gUnknown_0862B9F9, gUnknown_0862B9FF, gUnknown_0862BA05, gUnknown_0862BA0B, gUnknown_0862BA11, gUnknown_0862BA17, gUnknown_0862BA1D, gUnknown_0862BA23, gUnknown_0862BA29, gUnknown_0862BA2F + .4byte gUnknown_0862BA35, gUnknown_0862BA3B, gUnknown_0862BA41, gUnknown_0862BA47, gUnknown_0862BA4D, gUnknown_0862BA53, gUnknown_0862BA59, gUnknown_0862BA5F, gUnknown_0862BA65, gUnknown_0862BA6B + .4byte gUnknown_0862BA79, gUnknown_0862BA84, gUnknown_0862BA8F, gUnknown_0862BA9A, gUnknown_0862BAA3, gUnknown_0862BAAE, gUnknown_0862BAB9, gUnknown_0862BAC4, gUnknown_0862BACF, gUnknown_0862BADA .align 2 gUnknown_082F2C20:: @ 82F2C20 diff --git a/include/global.h b/include/global.h index d738deb3c..0506c036e 100644 --- a/include/global.h +++ b/include/global.h @@ -962,7 +962,8 @@ struct SaveBlock1 /*0x3B24*/ u8 seen2[DEX_FLAGS_NO]; /*0x3B58*/ LilycoveLady lilycoveLady; /*0x3B98*/ struct TrainerNameRecord trainerNameRecords[20]; - /*0x3C88*/ u8 unk3C88[11][20]; + /*0x3C88*/ u8 unk3C88[10][21]; + /*0x3D5A*/ u8 filler3D5A[0xA]; /*0x3D64*/ struct SaveTrainerHill trainerHill; /*0x3D70*/ struct WaldaPhrase waldaPhrase; // sizeof: 0x3D88 diff --git a/include/link.h b/include/link.h index 714b6bf15..719b0f067 100644 --- a/include/link.h +++ b/include/link.h @@ -236,7 +236,6 @@ u32 LinkMain1(u8 *shouldAdvanceLinkState, u16 *sendCmd, u16 (*recvCmds)[CMD_LENG void LinkVSync(void); void Timer3Intr(void); void SerialCB(void); -u8 GetLinkPlayerCount(void); bool32 InUnionRoom(void); void sub_800E0E8(void); bool8 IsLinkTaskFinished(void); diff --git a/include/link_rfu.h b/include/link_rfu.h index 5b8ccd9fb..e341dd4f3 100644 --- a/include/link_rfu.h +++ b/include/link_rfu.h @@ -284,5 +284,8 @@ bool8 sub_800DE7C(struct UnkLinkRfuStruct_02022B14 *buff1, u8 *buff2, u8 idx); s32 sub_800E87C(u8 idx); void sub_8011BA4(void); void sub_8010198(void); +bool32 sub_8011A9C(void); +void sub_80104B0(void); +void sub_8011A50(void); #endif //GUARD_LINK_RFU_H diff --git a/include/union_room_chat.h b/include/union_room_chat.h new file mode 100755 index 000000000..dae751576 --- /dev/null +++ b/include/union_room_chat.h @@ -0,0 +1,6 @@ +#ifndef GUARD_UNION_ROOM_CHAT_H +#define GUARD_UNION_ROOM_CHAT_H + +void sub_801DD98(void); + +#endif // GUARD_UNION_ROOM_CHAT_H diff --git a/ld_script.txt b/ld_script.txt index b4f99d606..83f430ebe 100644 --- a/ld_script.txt +++ b/ld_script.txt @@ -62,6 +62,7 @@ SECTIONS { asm/mevent_server_ish.o(.text); asm/mevent_server_helpers.o(.text); asm/mevent_news.o(.text); + src/union_room_chat.o(.text); asm/union_room_chat.o(.text); asm/berry_crush.o(.text); src/berry_powder.o(.text); @@ -412,6 +413,7 @@ SECTIONS { src/mevent2.o(.rodata); data/mevent_801BAAC.o(.rodata); data/mevent_server.o(.rodata); + src/union_room_chat.o(.rodata); data/union_room_chat.o(.rodata); data/berry_crush.o(.rodata); data/berry_powder.o(.rodata); diff --git a/src/link_rfu.c b/src/link_rfu.c index a557397f0..e4295dc39 100644 --- a/src/link_rfu.c +++ b/src/link_rfu.c @@ -4729,7 +4729,7 @@ bool32 sub_8011A80(void) return FALSE; } -u8 sub_8011A9C(void) +bool32 sub_8011A9C(void) { return gUnknown_03005000.unk_ce8; } diff --git a/src/union_room.c b/src/union_room.c index 99ae4b679..e0777cdb7 100644 --- a/src/union_room.c +++ b/src/union_room.c @@ -35,6 +35,7 @@ #include "field_screen_effect.h" #include "script_pokemon_util_80F87D8.h" #include "mevent.h" +#include "union_room_chat.h" struct UnkStruct_Shared { @@ -231,7 +232,6 @@ bool32 sub_8017678(struct UnkStruct_x20 *arg0, struct UnkStruct_x1C *arg1); u32 sub_8018120(struct TradeUnkStruct *arg0, u8 multiplayerId); void sub_801807C(struct TradeUnkStruct *arg0); void sub_801AC54(void); -void sub_801DD98(void); void sub_802A9A8(u8 monId, MainCallback callback); void sub_802493C(u8 monId, MainCallback callback); void sub_8020C70(MainCallback callback); diff --git a/src/union_room_chat.c b/src/union_room_chat.c new file mode 100755 index 000000000..f7c8be9f1 --- /dev/null +++ b/src/union_room_chat.c @@ -0,0 +1,1072 @@ +#include "global.h" +#include "alloc.h" +#include "link.h" +#include "link_rfu.h" +#include "load_save.h" +#include "main.h" +#include "menu.h" +#include "overworld.h" +#include "palette.h" +#include "save.h" +#include "scanline_effect.h" +#include "sound.h" +#include "sprite.h" +#include "string_util.h" +#include "task.h" +#include "constants/rgb.h" +#include "constants/songs.h" + +struct UnionRoomChat +{ + u8 filler0[0x4]; + u16 unk4; + u16 unk6; + u8 filler8[0x2]; + u16 unkA; + u8 fillerC[0x1]; + u8 unkD; + u8 unkE; + u8 unkF; + u8 unk10; + u8 unk11; + u8 unk12; + u8 unk13; + u8 unk14; + u8 unk15; + u8 unk16; + u8 unk17; + u8 unk18; + u8 unk19; + u8 unk1A[0x9F]; + u8 unkB9[10][21]; + u8 filler18B[0x5]; + u8 unk190[0x28]; + u16 unk1B8; +}; + +static void sub_801DDD0(struct UnionRoomChat *); +static void c2_081284E0(void); +static void sub_801DF20(void); +static void sub_801DF38(void); +static void sub_801DF54(u8 taskId); +static void sub_801DFAC(void); +static void sub_801E030(void); +static void sub_801E120(void); +static void sub_801E240(void); +static void sub_801E460(void); +static void sub_801E5C4(void); +static void sub_801E668(void); +static void sub_801E764(void); +static void sub_801E838(void); +static void sub_801E978(void); +static void sub_801EBD4(u16); +static bool32 sub_801EBE4(void); +static void sub_801EC94(void); +static void sub_801ED68(void); +static void sub_801ED94(void); +static bool32 sub_801EDC4(void); +static void sub_801EDE0(void); +static void sub_801EE10(void); +static void sub_801EE2C(void); +static u8 *sub_801EE84(void); +u8 *sub_801EEA8(void); +static void sub_801EF1C(u8 *); +static void sub_801EF24(u8 *); +static void sub_801EF4C(u8 *); +static void sub_801EF7C(u8 *); +static void sub_801EFA8(u8 *); +static void sub_801EFD0(u8 *); +u8 *sub_801F114(void); +void sub_801F2B4(u8 taskId); +bool8 sub_801F4D0(void); +int sub_801F534(void); +void sub_801F544(void); +void sub_801F5B8(void); +void sub_801F5EC(u16, u8); +bool8 sub_801F644(u8); +s8 sub_801FF08(void); + +extern struct UnionRoomChat *gUnknown_02022C84; + +extern const u8 *const gUnknown_082F2BA8[][10]; +extern const u8 gUnknown_082F2AA8[]; + + +void sub_801DD98(void) +{ + gUnknown_02022C84 = Alloc(sizeof(*gUnknown_02022C84)); + sub_801DDD0(gUnknown_02022C84); + gKeyRepeatStartDelay = 20; + SetVBlankCallback(NULL); + SetMainCallback2(c2_081284E0); +} + +static void sub_801DDD0(struct UnionRoomChat *unionRoomChat) +{ + int i; + + unionRoomChat->unk4 = 0; + unionRoomChat->unk6 = 0; + unionRoomChat->unk10 = 0; + unionRoomChat->unk11 = 0; + unionRoomChat->unk12 = 0; + unionRoomChat->unk14 = 0; + unionRoomChat->unk15 = 0; + unionRoomChat->unk16 = 0; + unionRoomChat->unk1A[0] = EOS; + unionRoomChat->unkD = GetLinkPlayerCount(); + unionRoomChat->unk13 = GetMultiplayerId(); + unionRoomChat->unk17 = 0; + unionRoomChat->unk18 = 0; + sub_801EF1C(unionRoomChat->unk190); + for (i = 0; i < 10; i++) + StringCopy(unionRoomChat->unkB9[i], gSaveBlock1Ptr->unk3C88[i]); +} + +void sub_801DE30(void) +{ + DestroyTask(gUnknown_02022C84->unkE); + DestroyTask(gUnknown_02022C84->unkF); + Free(gUnknown_02022C84); +} + +static void c2_081284E0(void) +{ + switch (gMain.state) + { + case 0: + ResetTasks(); + ResetSpriteData(); + FreeAllSpritePalettes(); + sub_801F4D0(); + gMain.state++; + break; + case 1: + sub_801F5B8(); + if (!sub_801F534()) + { + BlendPalettes(0xFFFFFFFF, 16, RGB_BLACK); + BeginNormalPaletteFade(0xFFFFFFFF, -1, 16, 0, RGB_BLACK); + SetVBlankCallback(sub_801DF20); + gMain.state++; + } + break; + case 2: + UpdatePaletteFade(); + if (!gPaletteFade.active) + { + SetMainCallback2(sub_801DF38); + gUnknown_02022C84->unkE = CreateTask(sub_801DF54, 8); + gUnknown_02022C84->unkF = CreateTask(sub_801F2B4, 7); + sub_800E0E8(); + CreateWirelessStatusIndicatorSprite(232, 150); + } + break; + } +} + +static void sub_801DF20(void) +{ + TransferPlttBuffer(); + LoadOam(); + ProcessSpriteCopyRequests(); + ScanlineEffect_InitHBlankDmaTransfer(); +} + +static void sub_801DF38(void) +{ + RunTasks(); + sub_801F5B8(); + AnimateSprites(); + BuildOamBuffer(); + UpdatePaletteFade(); +} + +void (*const gUnknown_082F2A7C[])(void) = +{ + sub_801DFAC, + sub_801E030, + sub_801E120, + sub_801E240, + sub_801E764, + sub_801E838, + sub_801E460, + sub_801E5C4, + sub_801E668, + sub_801E978, +}; + +static void sub_801DF54(u8 taskId) +{ + switch (gUnknown_02022C84->unk17) + { + case 1: + sub_801EBD4(6); + gUnknown_02022C84->unk17 = 0; + break; + case 2: + sub_801EBD4(7); + gUnknown_02022C84->unk17 = 0; + break; + case 3: + sub_801EBD4(8); + gUnknown_02022C84->unk17 = 0; + break; + } + + gUnknown_082F2A7C[gUnknown_02022C84->unk4](); +} + +static void sub_801DFAC(void) +{ + switch (gUnknown_02022C84->unk6) + { + case 0: + sub_801EF24(gUnknown_02022C84->unk190); + gUnknown_02022C84->unk6++; + // fall through + case 1: + if (IsLinkTaskFinished() && !sub_8011A9C()) + { + if (SendBlock(0, gUnknown_02022C84->unk190, sizeof(gUnknown_02022C84->unk190))) + gUnknown_02022C84->unk6++; + } + break; + case 2: + if (IsLinkTaskFinished()) + sub_801EBD4(1); + break; + } +} + +static void sub_801E030(void) +{ + bool8 var0, var1; + + switch (gUnknown_02022C84->unk6) + { + case 0: + if (gMain.newKeys & START_BUTTON) + { + if (gUnknown_02022C84->unk15) + sub_801EBD4(4); + } + else if (gMain.newKeys & SELECT_BUTTON) + { + sub_801EBD4(2); + } + else if (gMain.newAndRepeatedKeys & B_BUTTON) + { + if (gUnknown_02022C84->unk15) + { + sub_801ED68(); + sub_801F5EC(8, 0); + gUnknown_02022C84->unk6 = 1; + } + else + { + sub_801EBD4(3); + } + } + else if (gMain.newKeys & A_BUTTON) + { + sub_801EC94(); + sub_801F5EC(8, 0); + sub_801F5EC(2, 1); + gUnknown_02022C84->unk6 = 1; + } + else if (gMain.newKeys & R_BUTTON) + { + if (gUnknown_02022C84->unk10 != 3) + { + sub_801ED94(); + sub_801F5EC(8, 0); + gUnknown_02022C84->unk6 = 1; + } + else + { + sub_801EBD4(5); + } + } + else if (sub_801EBE4()) + { + sub_801F5EC(1, 0); + gUnknown_02022C84->unk6 = 1; + } + break; + case 1: + var0 = sub_801F644(0); + var1 = sub_801F644(1); + if (!var0 && !var1) + gUnknown_02022C84->unk6 = 0; + break; + } +} + +static void sub_801E120(void) +{ + s16 input; + int var0; + + switch (gUnknown_02022C84->unk6) + { + case 0: + sub_801F5EC(3, 0); + gUnknown_02022C84->unk6++; + break; + case 1: + if (!sub_801F644(0)) + gUnknown_02022C84->unk6++; + break; + case 2: + input = Menu_ProcessInput(); + switch (input) + { + default: + sub_801F5EC(4, 0); + var0 = 1; + if (gUnknown_02022C84->unk10 == input || input > 3) + var0 = 0; + break; + case MENU_NOTHING_CHOSEN: + if (gMain.newKeys & SELECT_BUTTON) + { + PlaySE(SE_SELECT); + Menu_MoveCursor(1); + } + return; + case MENU_B_PRESSED: + sub_801F5EC(4, 0); + gUnknown_02022C84->unk6 = 3; + return; + } + + if (!var0) + { + gUnknown_02022C84->unk6 = 3; + return; + } + + gUnknown_02022C84->unk11 = 0; + gUnknown_02022C84->unk12 = 0; + sub_801F5EC(5, 1); + gUnknown_02022C84->unk10 = input; + gUnknown_02022C84->unk6 = 4; + break; + case 3: + if (!sub_801F644(0)) + sub_801EBD4(1); + break; + case 4: + if (!sub_801F644(0) && !sub_801F644(1)) + sub_801EBD4(1); + break; + } +} + +static void sub_801E240(void) +{ + s8 input; + + switch (gUnknown_02022C84->unk6) + { + case 0: + sub_801F5EC(6, 0); + gUnknown_02022C84->unk6 = 1; + break; + case 1: + if (!sub_801F644(0)) + gUnknown_02022C84->unk6 = 2; + break; + case 2: + input = sub_801FF08(); + switch (input) + { + case -1: + case 1: + sub_801F5EC(7, 0); + gUnknown_02022C84->unk6 = 3; + break; + case 0: + if (gUnknown_02022C84->unk13 == 0) + { + sub_801EFD0(gUnknown_02022C84->unk190); + sub_801F5EC(7, 0); + gUnknown_02022C84->unk6 = 9; + } + else + { + sub_801EF7C(gUnknown_02022C84->unk190); + gUnknown_02022C84->unk6 = 4; + } + break; + } + break; + case 3: + if (!sub_801F644(0)) + sub_801EBD4(1); + break; + case 9: + if (!sub_801F644(0)) + { + sub_801F5EC(20, 0); + gUnknown_02022C84->unk6 = 10; + } + break; + case 10: + if (!sub_801F644(0)) + gUnknown_02022C84->unk6 = 8; + break; + case 8: + input = sub_801FF08(); + switch (input) + { + case -1: + case 1: + sub_801F5EC(7, 0); + gUnknown_02022C84->unk6 = 3; + break; + case 0: + sub_80104B0(); + sub_801EFD0(gUnknown_02022C84->unk190); + gUnknown_02022C84->unk6 = 4; + gUnknown_02022C84->unk1B8 = 0; + break; + } + break; + case 4: + if (IsLinkTaskFinished() && !sub_8011A9C() && SendBlock(0, gUnknown_02022C84->unk190, sizeof(gUnknown_02022C84->unk190))) + { + if (!gUnknown_02022C84->unk13) + gUnknown_02022C84->unk6 = 6; + else + gUnknown_02022C84->unk6 = 5; + } + + if (!gReceivedRemoteLinkPlayers) + sub_801EBD4(9); + break; + case 5: + if (!gReceivedRemoteLinkPlayers) + { + sub_801EBD4(9); + } + else if (++gUnknown_02022C84->unk1B8 > 300) + { + gUnknown_02022C84->unk1B8 = 0; + gUnknown_02022C84->unk6 = 4; + } + break; + } +} + +static void sub_801E460(void) +{ + switch (gUnknown_02022C84->unk6) + { + case 0: + if (!FuncIsActiveTask(sub_801F2B4)) + { + sub_801F5EC(7, 0); + gUnknown_02022C84->unk6++; + } + break; + case 1: + if (!sub_801F644(0)) + { + sub_801F5EC(18, 0); + gUnknown_02022C84->unk6++; + } + break; + case 2: + if (!sub_801F644(0)) + { + sub_801EFA8(gUnknown_02022C84->unk190); + gUnknown_02022C84->unk6++; + } + break; + case 3: + if (IsLinkTaskFinished() && !sub_8011A9C() && SendBlock(0, gUnknown_02022C84->unk190, sizeof(gUnknown_02022C84->unk190))) + gUnknown_02022C84->unk6++; + break; + case 4: + if ((GetBlockReceivedStatus() & 1) && !sub_8011A9C()) + gUnknown_02022C84->unk6++; + break; + case 5: + if (IsLinkTaskFinished() && !sub_8011A9C()) + { + sub_800AC34(); + gUnknown_02022C84->unkA = 0; + gUnknown_02022C84->unk6++; + } + break; + case 6: + if (gUnknown_02022C84->unkA < 150) + gUnknown_02022C84->unkA++; + + if (!gReceivedRemoteLinkPlayers) + gUnknown_02022C84->unk6++; + break; + case 7: + if (gUnknown_02022C84->unkA >= 150) + sub_801EBD4(9); + else + gUnknown_02022C84->unkA++; + break; + } +} + +static void sub_801E5C4(void) +{ + switch (gUnknown_02022C84->unk6) + { + case 0: + if (!FuncIsActiveTask(sub_801F2B4)) + { + sub_801F5EC(7, 0); + gUnknown_02022C84->unk6++; + } + break; + case 1: + if (!sub_801F644(0) && IsLinkTaskFinished() && !sub_8011A9C()) + { + sub_800AC34(); + gUnknown_02022C84->unkA = 0; + gUnknown_02022C84->unk6++; + } + break; + case 2: + if (gUnknown_02022C84->unkA < 150) + gUnknown_02022C84->unkA++; + + if (!gReceivedRemoteLinkPlayers) + gUnknown_02022C84->unk6++; + break; + case 3: + if (gUnknown_02022C84->unkA >= 150) + sub_801EBD4(9); + else + gUnknown_02022C84->unkA++; + break; + } +} + +static void sub_801E668(void) +{ + switch (gUnknown_02022C84->unk6) + { + case 0: + if (!FuncIsActiveTask(sub_801F2B4)) + { + if (gUnknown_02022C84->unk13) + sub_801F5EC(7, 0); + + gUnknown_02022C84->unk6++; + } + break; + case 1: + if (!sub_801F644(0)) + { + if (gUnknown_02022C84->unk13) + sub_801F5EC(19, 0); + + gUnknown_02022C84->unk6++; + } + break; + case 2: + if (sub_801F644(0) != TRUE && IsLinkTaskFinished() && !sub_8011A9C()) + { + sub_800AC34(); + gUnknown_02022C84->unkA = 0; + gUnknown_02022C84->unk6++; + } + break; + case 3: + if (gUnknown_02022C84->unkA < 150) + gUnknown_02022C84->unkA++; + + if (!gReceivedRemoteLinkPlayers) + gUnknown_02022C84->unk6++; + break; + case 4: + if (gUnknown_02022C84->unkA >= 150) + sub_801EBD4(9); + else + gUnknown_02022C84->unkA++; + break; + } +} + +static void sub_801E764(void) +{ + switch (gUnknown_02022C84->unk6) + { + case 0: + if (!gReceivedRemoteLinkPlayers) + { + sub_801EBD4(1); + break; + } + + sub_801EF4C(gUnknown_02022C84->unk190); + gUnknown_02022C84->unk6++; + // fall through + case 1: + if (IsLinkTaskFinished() == TRUE && !sub_8011A9C() && SendBlock(0, gUnknown_02022C84->unk190, sizeof(gUnknown_02022C84->unk190))) + gUnknown_02022C84->unk6++; + break; + case 2: + sub_801EE10(); + sub_801F5EC(8, 0); + gUnknown_02022C84->unk6++; + break; + case 3: + if (!sub_801F644(0)) + gUnknown_02022C84->unk6++; + break; + case 4: + if (IsLinkTaskFinished()) + sub_801EBD4(1); + break; + } +} + +static void sub_801E838(void) +{ + switch (gUnknown_02022C84->unk6) + { + case 0: + if (sub_801EDC4()) + { + sub_801F5EC(9, 0); + gUnknown_02022C84->unk6 = 2; + } + else + { + sub_801F5EC(13, 0); + gUnknown_02022C84->unk6 = 5; + } + break; + case 1: + if (gMain.newKeys & A_BUTTON) + { + sub_801EDE0(); + sub_801F5EC(11, 0); + gUnknown_02022C84->unk6 = 3; + } + else if (gMain.newKeys & B_BUTTON) + { + sub_801F5EC(10, 0); + gUnknown_02022C84->unk6 = 4; + } + else if (sub_801EBE4()) + { + sub_801F5EC(1, 0); + gUnknown_02022C84->unk6 = 2; + } + break; + case 2: + if (!sub_801F644(0)) + gUnknown_02022C84->unk6 = 1; + break; + case 3: + if (!sub_801F644(0)) + { + sub_801F5EC(10, 0); + gUnknown_02022C84->unk6 = 4; + } + break; + case 4: + if (!sub_801F644(0)) + sub_801EBD4(1); + break; + case 5: + if (!sub_801F644(0)) + gUnknown_02022C84->unk6 = 6; + break; + case 6: + if (gMain.newKeys & (A_BUTTON | B_BUTTON)) + { + sub_801F5EC(7, 0); + gUnknown_02022C84->unk6 = 4; + } + break; + } +} + +static void sub_801E978(void) +{ + s8 input; + + switch (gUnknown_02022C84->unk6) + { + case 0: + if (!gUnknown_02022C84->unk18) + { + gUnknown_02022C84->unk6 = 12; + } + else + { + sub_801F5EC(7, 0); + gUnknown_02022C84->unk6 = 1; + } + break; + case 1: + if (!sub_801F644(0)) + { + sub_801F5EC(14, 0); + gUnknown_02022C84->unk6 = 2; + } + break; + case 2: + input = sub_801FF08(); + switch (input) + { + case -1: + case 1: + gUnknown_02022C84->unk6 = 12; + break; + case 0: + sub_801F5EC(7, 0); + gUnknown_02022C84->unk6 = 3; + break; + } + break; + case 3: + if (!sub_801F644(0)) + { + sub_801F5EC(15, 0); + gUnknown_02022C84->unk6 = 4; + } + break; + case 4: + if (!sub_801F644(0)) + gUnknown_02022C84->unk6 = 5; + break; + case 5: + input = sub_801FF08(); + switch (input) + { + case -1: + case 1: + gUnknown_02022C84->unk6 = 12; + break; + case 0: + sub_801F5EC(7, 0); + gUnknown_02022C84->unk6 = 6; + break; + } + break; + case 6: + if (!sub_801F644(0)) + { + sub_801F5EC(16, 0); + sub_801EE2C(); + gUnknown_02022C84->unk6 = 7; + } + break; + case 7: + if (!sub_801F644(0)) + { + SetContinueGameWarpStatusToDynamicWarp(); + TrySavingData(SAVE_NORMAL); + gUnknown_02022C84->unk6 = 8; + } + break; + case 8: + sub_801F5EC(17, 0); + gUnknown_02022C84->unk6 = 9; + break; + case 9: + if (!sub_801F644(0)) + { + PlaySE(SE_SAVE); + ClearContinueGameWarpStatus2(); + gUnknown_02022C84->unk6 = 10; + } + break; + case 10: + gUnknown_02022C84->unk19 = 0; + gUnknown_02022C84->unk6 = 11; + break; + case 11: + gUnknown_02022C84->unk19++; + if (gUnknown_02022C84->unk19 > 120) + gUnknown_02022C84->unk6 = 12; + break; + case 12: + BeginNormalPaletteFade(0xFFFFFFFF, -1, 0, 16, RGB_BLACK); + gUnknown_02022C84->unk6 = 13; + break; + case 13: + if (!gPaletteFade.active) + { + sub_801F544(); + sub_801DE30(); + SetMainCallback2(CB2_ReturnToField); + } + break; + } +} + +static void sub_801EBD4(u16 arg0) +{ + gUnknown_02022C84->unk4 = arg0; + gUnknown_02022C84->unk6 = 0; +} + +static const u8 sUnknown_082F2AA4[] = {9, 9, 9, 9}; + +static bool32 sub_801EBE4(void) +{ + if (!(gMain.newAndRepeatedKeys & DPAD_UP)) + { + if (gMain.newAndRepeatedKeys & DPAD_DOWN) + { + if (gUnknown_02022C84->unk12 < sUnknown_082F2AA4[gUnknown_02022C84->unk10]) + gUnknown_02022C84->unk12++; + else + gUnknown_02022C84->unk12 = 0; + + return TRUE; + } + + if (gUnknown_02022C84->unk10 != 3) + { + if (gMain.newAndRepeatedKeys & DPAD_LEFT) + { + if (gUnknown_02022C84->unk11) + gUnknown_02022C84->unk11--; + else + gUnknown_02022C84->unk11 = 4; + } + else if (gMain.newAndRepeatedKeys & DPAD_RIGHT) + { + if (gUnknown_02022C84->unk11 > 3) + gUnknown_02022C84->unk11 = 0; + else + gUnknown_02022C84->unk11++; + } + else + { + return FALSE; + } + + return TRUE; + } + + return FALSE; + } + else + { + if (gUnknown_02022C84->unk12) + gUnknown_02022C84->unk12--; + else + gUnknown_02022C84->unk12 = sUnknown_082F2AA4[gUnknown_02022C84->unk10]; + + return TRUE; + } +} + +static void sub_801EC94(void) +{ + int i; + const u8 *charsStr; + int strLength; + u8 *str; + u8 buffer[21]; + + if (gUnknown_02022C84->unk10 != 3) + { + charsStr = gUnknown_082F2BA8[gUnknown_02022C84->unk10][gUnknown_02022C84->unk12]; + for (i = 0; i < gUnknown_02022C84->unk11; i++) + { + if (*charsStr == CHAR_SPECIAL_F9) + charsStr++; + charsStr++; + } + + strLength = 1; + } + else + { + u8 *tempStr = StringCopy(buffer, gUnknown_02022C84->unkB9[gUnknown_02022C84->unk12]); + tempStr[0] = CHAR_SPACE; + tempStr[1] = EOS; + charsStr = buffer; + strLength = StringLength_Multibyte(buffer); + } + + gUnknown_02022C84->unk14 = gUnknown_02022C84->unk15; + if (!charsStr) + return; + + str = sub_801EE84(); + while (--strLength != -1 && gUnknown_02022C84->unk15 < 15) + { + if (*charsStr == CHAR_SPECIAL_F9) + { + *str = *charsStr; + charsStr++; + str++; + } + + *str = *charsStr; + charsStr++; + str++; + + gUnknown_02022C84->unk15++; + } + + *str = EOS; +} + +static void sub_801ED68(void) +{ + gUnknown_02022C84->unk14 = gUnknown_02022C84->unk15; + if (gUnknown_02022C84->unk15) + { + u8 *str = sub_801EEA8(); + *str = EOS; + gUnknown_02022C84->unk15--; + } +} + +static void sub_801ED94(void) +{ + u8 *str; + u8 character; + + gUnknown_02022C84->unk14 = gUnknown_02022C84->unk15 - 1; + str = sub_801EEA8(); + if (*str != CHAR_SPECIAL_F9) + { + character = gUnknown_082F2AA8[*str]; + if (character) + *str = character; + } +} + +static bool32 sub_801EDC4(void) +{ + if (gUnknown_02022C84->unk15) + return TRUE; + else + return FALSE; +} + +static void sub_801EDE0(void) +{ + u8 *src = sub_801F114(); + StringCopy(gUnknown_02022C84->unkB9[gUnknown_02022C84->unk12], src); + gUnknown_02022C84->unk18 = 1; +} + +static void sub_801EE10(void) +{ + gUnknown_02022C84->unk1A[0] = EOS; + gUnknown_02022C84->unk14 = 15; + gUnknown_02022C84->unk15 = 0; +} + +static void sub_801EE2C(void) +{ + int i; + for (i = 0; i < 10; i++) + StringCopy(gSaveBlock1Ptr->unk3C88[i], gUnknown_02022C84->unkB9[i]); +} + +u8 *sub_801EE6C(int arg0) +{ + return gUnknown_02022C84->unkB9[arg0]; +} + +static u8 *sub_801EE84(void) +{ + u8 *str = gUnknown_02022C84->unk1A; + while (*str != EOS) + str++; + + return str; +} + +u8 *sub_801EEA8(void) +{ + u8 *str = gUnknown_02022C84->unk1A; + u8 *str2 = str; + while (*str != EOS) + { + str2 = str; + if (*str == CHAR_SPECIAL_F9) + str++; + str++; + } + + return str2; +} + +u16 sub_801EED8(void) +{ + u8 *str; + u32 i, numChars, strLength; + + strLength = StringLength_Multibyte(gUnknown_02022C84->unk1A); + str = gUnknown_02022C84->unk1A; + numChars = 0; + if (strLength > 10) + { + strLength -= 10; + for (i = 0; i < strLength; i++) + { + if (*str == CHAR_SPECIAL_F9) + str++; + + str++; + numChars++; + } + } + + return numChars; +} + +static void sub_801EF1C(u8 *arg0) +{ + arg0[0] = CHAR_SPACE; +} + +static void sub_801EF24(u8 *arg0) +{ + arg0[0] = 2; + StringCopy(&arg0[1], gSaveBlock2Ptr->playerName); + arg0[1 + (PLAYER_NAME_LENGTH + 1)] = gUnknown_02022C84->unk13; +} + +static void sub_801EF4C(u8 *arg0) +{ + arg0[0] = 1; + StringCopy(&arg0[1], gSaveBlock2Ptr->playerName); + StringCopy(&arg0[1 + (PLAYER_NAME_LENGTH + 1)], gUnknown_02022C84->unk1A); +} + +static void sub_801EF7C(u8 *arg0) +{ + arg0[0] = 3; + StringCopy(&arg0[1], gSaveBlock2Ptr->playerName); + arg0[1 + (PLAYER_NAME_LENGTH + 1)] = gUnknown_02022C84->unk13; + sub_8011A50(); +} + +static void sub_801EFA8(u8 *arg0) +{ + arg0[0] = 4; + StringCopy(&arg0[1], gSaveBlock2Ptr->playerName); + arg0[1 + (PLAYER_NAME_LENGTH + 1)] = gUnknown_02022C84->unk13; +} + +static void sub_801EFD0(u8 *arg0) +{ + arg0[0] = 5; + StringCopy(&arg0[1], gSaveBlock2Ptr->playerName); + arg0[1 + (PLAYER_NAME_LENGTH + 1)] = gUnknown_02022C84->unk13; +}