From a6db7b2419e0130a7f9686edd998764dc205d449 Mon Sep 17 00:00:00 2001 From: golem galvanize Date: Mon, 10 Dec 2018 02:38:23 -0500 Subject: [PATCH] decompiled up to brm_cancel_1 --- asm/party_menu.s | 1835 --------------------------------------------- include/menu.h | 3 + include/strings.h | 1 + src/party_menu.c | 609 ++++++++++++++- 4 files changed, 612 insertions(+), 1836 deletions(-) diff --git a/asm/party_menu.s b/asm/party_menu.s index 3b28ab8d4d..17ebaab513 100644 --- a/asm/party_menu.s +++ b/asm/party_menu.s @@ -5,1841 +5,6 @@ .text - thumb_func_start sub_81B31B0 -sub_81B31B0: @ 81B31B0 - push {r4-r7,lr} - mov r7, r9 - mov r6, r8 - push {r6,r7} - sub sp, 0x1C - lsls r0, 24 - lsrs r4, r0, 24 - cmp r4, 0x1 - beq _081B320C - cmp r4, 0x1 - bgt _081B31CC - cmp r4, 0 - beq _081B31D2 - b _081B321C -_081B31CC: - cmp r4, 0x2 - beq _081B3214 - b _081B321C -_081B31D2: - ldr r0, =gUnknown_0203CEC4 - ldr r1, [r0] - ldrb r0, [r1, 0x17] - lsls r0, 1 - movs r3, 0x13 - subs r3, r0 - lsls r3, 24 - lsrs r3, 24 - movs r0, 0xA - str r0, [sp] - ldrb r0, [r1, 0x17] - lsls r0, 25 - lsrs r0, 24 - str r0, [sp, 0x4] - movs r0, 0xE - str r0, [sp, 0x8] - ldr r0, =0x000002e9 - str r0, [sp, 0xC] - add r0, sp, 0x14 - movs r1, 0x2 - movs r2, 0x13 - bl SetWindowTemplateFields - b _081B3226 - .pool -_081B320C: - ldr r0, =gUnknown_08615950 - b _081B321E - .pool -_081B3214: - ldr r0, =gUnknown_08615958 - b _081B321E - .pool -_081B321C: - ldr r0, =gUnknown_08615960 -_081B321E: - ldr r1, [r0, 0x4] - ldr r0, [r0] - str r0, [sp, 0x14] - str r1, [sp, 0x18] -_081B3226: - add r0, sp, 0x14 - bl AddWindow - ldr r6, =gUnknown_0203CEC4 - ldr r1, [r6] - strb r0, [r1, 0xC] - ldr r0, [r6] - ldrb r0, [r0, 0xC] - movs r1, 0 - movs r2, 0x4F - movs r3, 0xD - bl SetWindowBorderStyle - cmp r4, 0x3 - bne _081B3250 - ldr r0, [r6] - b _081B32E2 - .pool -_081B3250: - movs r0, 0x1 - movs r1, 0 - bl GetMenuCursorDimensionByFont - lsls r0, 24 - lsrs r0, 24 - mov r9, r0 - movs r0, 0x1 - movs r1, 0x2 - bl GetFontAttribute - lsls r0, 24 - lsrs r0, 24 - mov r8, r0 - movs r5, 0 - ldr r0, [r6] - ldrb r0, [r0, 0x17] - cmp r5, r0 - bcs _081B32CA - adds r7, r6, 0 - movs r6, 0 -_081B327A: - ldr r1, [r7] - adds r0, r1, 0 - adds r0, 0xF - adds r4, r0, r5 - ldrb r0, [r4] - movs r2, 0x3 - cmp r0, 0x12 - bls _081B328C - movs r2, 0x4 -_081B328C: - ldrb r0, [r1, 0xC] - lsls r3, r5, 4 - adds r3, 0x1 - lsls r3, 24 - lsrs r3, 24 - mov r1, r8 - str r1, [sp] - str r6, [sp, 0x4] - lsls r1, r2, 1 - adds r1, r2 - ldr r2, =gUnknown_086157FC - adds r1, r2 - str r1, [sp, 0x8] - str r6, [sp, 0xC] - ldr r2, =gUnknown_08615C08 - ldrb r1, [r4] - lsls r1, 3 - adds r1, r2 - ldr r1, [r1] - str r1, [sp, 0x10] - movs r1, 0x1 - mov r2, r9 - bl AddTextPrinterParameterized4 - adds r0, r5, 0x1 - lsls r0, 24 - lsrs r5, r0, 24 - ldr r0, [r7] - ldrb r0, [r0, 0x17] - cmp r5, r0 - bcc _081B327A -_081B32CA: - ldr r4, =gUnknown_0203CEC4 - ldr r1, [r4] - ldrb r0, [r1, 0xC] - ldrb r1, [r1, 0x17] - movs r2, 0 - movs r3, 0x1 - bl InitMenuInUpperLeftCorner - movs r0, 0x2 - bl schedule_bg_copy_tilemap_to_vram - ldr r0, [r4] -_081B32E2: - ldrb r0, [r0, 0xC] - add sp, 0x1C - pop {r3,r4} - mov r8, r3 - mov r9, r4 - pop {r4-r7} - pop {r1} - bx r1 - .pool - thumb_func_end sub_81B31B0 - - thumb_func_start sub_81B3300 -sub_81B3300: @ 81B3300 - push {r4,lr} - sub sp, 0x10 - adds r4, r0, 0 - movs r0, 0x6 - movs r1, 0 - movs r2, 0x4F - movs r3, 0xD - bl SetWindowBorderStyle - ldr r2, =gTextFlags - ldrb r0, [r2] - movs r1, 0x1 - orrs r0, r1 - strb r0, [r2] - bl GetPlayerTextSpeedDelay - adds r3, r0, 0 - lsls r3, 24 - lsrs r3, 24 - movs r0, 0 - str r0, [sp] - movs r0, 0x2 - str r0, [sp, 0x4] - movs r0, 0x1 - str r0, [sp, 0x8] - movs r0, 0x3 - str r0, [sp, 0xC] - movs r0, 0x6 - movs r1, 0x1 - adds r2, r4, 0 - bl AddTextPrinterParameterized2 - add sp, 0x10 - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81B3300 - - thumb_func_start sub_81B334C -sub_81B334C: @ 81B334C - push {lr} - ldr r0, =gUnknown_08615968 - movs r1, 0x4F - movs r2, 0xD - movs r3, 0 - bl CreateYesNoMenu - pop {r0} - bx r0 - .pool - thumb_func_end sub_81B334C - - thumb_func_start sub_81B3364 -sub_81B3364: @ 81B3364 - push {r4,lr} - ldr r0, =gUnknown_08615970 - bl AddWindow - ldr r4, =gUnknown_0203CEC4 - ldr r1, [r4] - strb r0, [r1, 0xC] - ldr r0, [r4] - ldrb r0, [r0, 0xC] - movs r1, 0 - movs r2, 0x4F - movs r3, 0xD - bl SetWindowBorderStyle - ldr r0, [r4] - ldrb r0, [r0, 0xC] - pop {r4} - pop {r1} - bx r1 - .pool - thumb_func_end sub_81B3364 - - thumb_func_start sub_81B3394 -sub_81B3394: @ 81B3394 - push {r4,lr} - ldr r4, =gUnknown_0203CEC4 - ldr r0, [r4] - ldrb r0, [r0, 0xC] - bl ClearWindowTilemap - ldr r0, [r4] - adds r0, 0xC - bl sub_81B302C - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81B3394 - - thumb_func_start sub_81B33B4 -sub_81B33B4: @ 81B33B4 - push {r4,lr} - lsls r1, 24 - lsrs r1, 24 - lsls r2, 24 - lsrs r2, 24 - cmp r2, 0 - bne _081B33C8 - bl sub_81B3414 - b _081B3400 -_081B33C8: - ldr r4, =gUnknown_0203CEC4 - ldr r1, [r4] - ldr r0, =gUnknown_08615D70 - adds r0, r2, r0 - ldrb r0, [r0] - strb r0, [r1, 0x17] - movs r3, 0 - ldr r0, [r4] - ldrb r0, [r0, 0x17] - cmp r3, r0 - bcs _081B3400 - ldr r1, =gUnknown_08615D38 - lsls r0, r2, 2 - adds r2, r0, r1 -_081B33E4: - ldr r1, [r4] - adds r1, 0xF - adds r1, r3 - ldr r0, [r2] - adds r0, r3 - ldrb r0, [r0] - strb r0, [r1] - adds r0, r3, 0x1 - lsls r0, 24 - lsrs r3, r0, 24 - ldr r0, [r4] - ldrb r0, [r0, 0x17] - cmp r3, r0 - bcc _081B33E4 -_081B3400: - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81B33B4 - - thumb_func_start sub_81B3414 -sub_81B3414: @ 81B3414 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0x4 - mov r9, r0 - lsls r1, 24 - lsrs r1, 24 - mov r10, r1 - ldr r2, =gUnknown_0203CEC4 - ldr r1, [r2] - movs r0, 0 - strb r0, [r1, 0x17] - ldr r1, [r2] - adds r0, r1, 0 - adds r0, 0xF - adds r1, 0x17 - movs r2, 0 - bl AppendToList - movs r7, 0 - ldr r0, =gUnknown_08615D7E - ldrh r0, [r0] - str r0, [sp] -_081B3446: - movs r4, 0 - adds r0, r7, 0x1 - mov r8, r0 - ldr r1, [sp] - cmp r1, 0xE - beq _081B34A0 - movs r0, 0x64 - mov r6, r10 - muls r6, r0 - ldr r5, =gUnknown_08615D7E -_081B345A: - mov r1, r9 - adds r0, r1, r6 - adds r1, r7, 0 - adds r1, 0xD - bl GetMonData - lsls r1, r4, 1 - adds r1, r5 - ldrh r1, [r1] - cmp r0, r1 - bne _081B3490 - ldr r0, =gUnknown_0203CEC4 - ldr r1, [r0] - adds r0, r1, 0 - adds r0, 0xF - adds r1, 0x17 - adds r2, r4, 0 - adds r2, 0x13 - lsls r2, 24 - lsrs r2, 24 - bl AppendToList - b _081B34A0 - .pool -_081B3490: - adds r0, r4, 0x1 - lsls r0, 24 - lsrs r4, r0, 24 - lsls r0, r4, 1 - adds r0, r5 - ldrh r0, [r0] - cmp r0, 0xE - bne _081B345A -_081B34A0: - mov r1, r8 - lsls r0, r1, 24 - lsrs r7, r0, 24 - cmp r7, 0x3 - bls _081B3446 - bl InBattlePike - lsls r0, 24 - cmp r0, 0 - bne _081B3518 - mov r0, r9 - adds r0, 0x64 - movs r1, 0xB - bl GetMonData - cmp r0, 0 - beq _081B34D2 - ldr r0, =gUnknown_0203CEC4 - ldr r1, [r0] - adds r0, r1, 0 - adds r0, 0xF - adds r1, 0x17 - movs r2, 0x1 - bl AppendToList -_081B34D2: - movs r0, 0x64 - mov r1, r10 - muls r1, r0 - adds r0, r1, 0 - add r0, r9 - movs r1, 0xC - bl GetMonData - lsls r0, 16 - lsrs r0, 16 - bl ItemIsMail - lsls r0, 24 - cmp r0, 0 - beq _081B3508 - ldr r0, =gUnknown_0203CEC4 - ldr r1, [r0] - adds r0, r1, 0 - adds r0, 0xF - adds r1, 0x17 - movs r2, 0x6 - bl AppendToList - b _081B3518 - .pool -_081B3508: - ldr r0, =gUnknown_0203CEC4 - ldr r1, [r0] - adds r0, r1, 0 - adds r0, 0xF - adds r1, 0x17 - movs r2, 0x3 - bl AppendToList -_081B3518: - ldr r0, =gUnknown_0203CEC4 - ldr r1, [r0] - adds r0, r1, 0 - adds r0, 0xF - adds r1, 0x17 - movs r2, 0x2 - bl AppendToList - add sp, 0x4 - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81B3414 - - thumb_func_start sub_81B353C -sub_81B353C: @ 81B353C - push {r4,lr} - adds r4, r0, 0 - ldr r1, =gUnknown_0203CEC8 - ldrb r0, [r1, 0x8] - lsls r0, 28 - lsrs r0, 28 - adds r2, r1, 0 - cmp r0, 0xC - bhi _081B35FE - lsls r0, 2 - ldr r1, =_081B3560 - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .pool - .align 2, 0 -_081B3560: - .4byte _081B3594 - .4byte _081B35B0 - .4byte _081B35FE - .4byte _081B35FE - .4byte _081B35BC - .4byte _081B35FE - .4byte _081B35DC - .4byte _081B35FE - .4byte _081B35EE - .4byte _081B35F2 - .4byte _081B35F6 - .4byte _081B35FE - .4byte _081B35FA -_081B3594: - bl InMultiBattleRoom - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - beq _081B35AC - adds r0, r4, 0 - movs r1, 0x2D - bl GetMonData - cmp r0, 0 - beq _081B35FE -_081B35AC: - movs r1, 0x1 - b _081B3600 -_081B35B0: - adds r0, r4, 0 - bl sub_81B8A2C - lsls r0, 24 - lsrs r1, r0, 24 - b _081B3600 -_081B35BC: - movs r0, 0x9 - ldrsb r0, [r2, r0] - bl sub_81B856C - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0 - beq _081B35D4 - cmp r0, 0x1 - beq _081B35D8 - movs r1, 0x7 - b _081B3600 -_081B35D4: - movs r1, 0x4 - b _081B3600 -_081B35D8: - movs r1, 0x5 - b _081B3600 -_081B35DC: - adds r0, r4, 0 - movs r1, 0x2D - bl GetMonData - movs r1, 0x6 - cmp r0, 0 - beq _081B3600 - movs r1, 0x7 - b _081B3600 -_081B35EE: - movs r1, 0xA - b _081B3600 -_081B35F2: - movs r1, 0xB - b _081B3600 -_081B35F6: - movs r1, 0xC - b _081B3600 -_081B35FA: - movs r1, 0xD - b _081B3600 -_081B35FE: - movs r1, 0 -_081B3600: - adds r0, r1, 0 - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_81B353C - - thumb_func_start sub_81B3608 -sub_81B3608: @ 81B3608 - push {r4-r7,lr} - mov r7, r8 - push {r7} - lsls r0, 24 - lsrs r0, 24 - mov r8, r0 - ldr r4, =gUnknown_0203CEC8 - movs r1, 0x9 - ldrsb r1, [r4, r1] - movs r0, 0x64 - muls r0, r1 - ldr r7, =gPlayerParty - adds r5, r0, r7 - ldr r1, =gStringVar1 - adds r0, r5, 0 - bl GetMonNickname - ldr r0, =gUnknown_0203CEC4 - ldr r0, [r0] - adds r0, 0xD - bl sub_81B302C - ldrb r1, [r4, 0x8] - movs r0, 0xF - ands r0, r1 - cmp r0, 0xC - beq _081B3674 - ldrb r4, [r4, 0x9] - adds r0, r5, 0 - bl sub_81B353C - adds r2, r0, 0 - lsls r2, 24 - lsrs r2, 24 - adds r0, r7, 0 - adds r1, r4, 0 - bl sub_81B33B4 - movs r0, 0 - bl sub_81B31B0 - movs r0, 0x15 - bl display_pokemon_menu_message - b _081B36EA - .pool -_081B3674: - adds r0, r5, 0 - movs r1, 0xC - bl GetMonData - lsls r0, 16 - lsrs r6, r0, 16 - cmp r6, 0 - bne _081B36C0 - ldr r4, =gStringVar4 - ldr r1, =gText_PkmnNotHolding - adds r0, r4, 0 - bl StringExpandPlaceholders - adds r0, r4, 0 - movs r1, 0x1 - bl sub_81B1B5C - movs r0, 0x2 - bl schedule_bg_copy_tilemap_to_vram - ldr r1, =gTasks - mov r2, r8 - lsls r0, r2, 2 - add r0, r8 - lsls r0, 3 - adds r0, r1 - ldr r1, =sub_81B469C - str r1, [r0] - movs r0, 0 - b _081B36EC - .pool -_081B36C0: - ldrb r4, [r4, 0x9] - adds r0, r5, 0 - bl sub_81B353C - adds r2, r0, 0 - lsls r2, 24 - lsrs r2, 24 - adds r0, r7, 0 - adds r1, r4, 0 - bl sub_81B33B4 - movs r0, 0x1 - bl sub_81B31B0 - ldr r1, =gStringVar2 - adds r0, r6, 0 - bl CopyItemName - movs r0, 0x1A - bl display_pokemon_menu_message -_081B36EA: - movs r0, 0x1 -_081B36EC: - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r1} - bx r1 - .pool - thumb_func_end sub_81B3608 - - thumb_func_start sub_81B36FC -sub_81B36FC: @ 81B36FC - push {r4,lr} - lsls r0, 24 - lsrs r4, r0, 24 - adds r0, r4, 0 - bl sub_81B3608 - lsls r0, 24 - cmp r0, 0 - beq _081B3720 - ldr r1, =gTasks - lsls r0, r4, 2 - adds r0, r4 - lsls r0, 3 - adds r0, r1 - movs r1, 0xFF - strh r1, [r0, 0x8] - ldr r1, =sub_81B3730 - str r1, [r0] -_081B3720: - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81B36FC - - thumb_func_start sub_81B3730 -sub_81B3730: @ 81B3730 - push {r4-r6,lr} - lsls r0, 24 - lsrs r6, r0, 24 - ldr r0, =gPaletteFade - ldrb r1, [r0, 0x7] - movs r0, 0x80 - ands r0, r1 - cmp r0, 0 - bne _081B37EE - bl sub_81221EC - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - beq _081B37EE - lsls r0, r6, 2 - adds r0, r6 - lsls r0, 3 - ldr r1, =gTasks + 0x8 - adds r5, r0, r1 - ldr r0, =gUnknown_0203CEC4 - ldr r0, [r0] - ldrb r0, [r0, 0x17] - cmp r0, 0x3 - bhi _081B3774 - bl Menu_ProcessInputNoWrapAround_other - b _081B3778 - .pool -_081B3774: - bl ProcessMenuInput_other -_081B3778: - lsls r0, 24 - lsrs r4, r0, 24 - bl GetMenuCursorPos - lsls r0, 24 - lsrs r0, 24 - strh r0, [r5] - lsls r0, r4, 24 - asrs r5, r0, 24 - movs r0, 0x2 - negs r0, r0 - cmp r5, r0 - beq _081B37EE - adds r0, 0x1 - cmp r5, r0 - bne _081B37CC - movs r0, 0x5 - bl PlaySE - ldr r4, =gUnknown_0203CEC4 - ldr r0, [r4] - adds r0, 0xE - bl sub_81B302C - ldr r2, =gUnknown_08615C08 - ldr r0, [r4] - ldrb r1, [r0, 0x17] - adds r0, r1 - ldrb r0, [r0, 0xE] - lsls r0, 3 - adds r2, 0x4 - adds r0, r2 - ldr r1, [r0] - adds r0, r6, 0 - bl _call_via_r1 - b _081B37EE - .pool -_081B37CC: - ldr r4, =gUnknown_0203CEC4 - ldr r0, [r4] - adds r0, 0xE - bl sub_81B302C - ldr r1, =gUnknown_08615C08 - ldr r0, [r4] - adds r0, 0xF - adds r0, r5 - ldrb r0, [r0] - lsls r0, 3 - adds r1, 0x4 - adds r0, r1 - ldr r1, [r0] - adds r0, r6, 0 - bl _call_via_r1 -_081B37EE: - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81B3730 - - thumb_func_start sub_81B37FC -sub_81B37FC: @ 81B37FC - push {r4,lr} - adds r4, r0, 0 - lsls r4, 24 - lsrs r4, 24 - movs r0, 0x5 - bl PlaySE - ldr r0, =gUnknown_0203CEC4 - ldr r1, [r0] - ldr r0, =sub_81B3828 - str r0, [r1, 0x4] - adds r0, r4, 0 - bl sub_81B12C0 - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81B37FC - - thumb_func_start sub_81B3828 -sub_81B3828: @ 81B3828 - push {r4,lr} - sub sp, 0x4 - ldr r4, =gUnknown_0203CEC8 - ldrb r1, [r4, 0x8] - movs r0, 0xF - ands r0, r1 - cmp r0, 0x1 - bne _081B3868 - bl pokemon_change_order - ldr r1, =gPlayerParty - ldrb r2, [r4, 0x9] - ldr r0, =gPlayerPartyCount - ldrb r3, [r0] - subs r3, 0x1 - lsls r3, 24 - lsrs r3, 24 - ldr r0, =sub_81B3894 - str r0, [sp] - movs r0, 0x1 - bl ShowPokemonSummaryScreen - b _081B3880 - .pool -_081B3868: - ldr r1, =gPlayerParty - ldrb r2, [r4, 0x9] - ldr r0, =gPlayerPartyCount - ldrb r3, [r0] - subs r3, 0x1 - lsls r3, 24 - lsrs r3, 24 - ldr r0, =sub_81B3894 - str r0, [sp] - movs r0, 0 - bl ShowPokemonSummaryScreen -_081B3880: - add sp, 0x4 - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81B3828 - - thumb_func_start sub_81B3894 -sub_81B3894: @ 81B3894 - push {lr} - sub sp, 0xC - ldr r2, =gPaletteFade - ldrb r0, [r2, 0x8] - movs r1, 0x80 - orrs r0, r1 - strb r0, [r2, 0x8] - ldr r3, =gUnknown_0203CEC8 - ldr r0, =gUnknown_0203CF20 - ldrb r0, [r0] - strb r0, [r3, 0x9] - ldrb r0, [r3, 0x8] - lsls r0, 28 - lsrs r0, 28 - ldrb r2, [r3, 0xB] - movs r1, 0x15 - str r1, [sp] - ldr r1, =sub_81B36FC - str r1, [sp, 0x4] - ldr r1, [r3] - str r1, [sp, 0x8] - movs r1, 0xFF - movs r3, 0x1 - bl sub_81B0038 - add sp, 0xC - pop {r0} - bx r0 - .pool - thumb_func_end sub_81B3894 - - thumb_func_start brm_switch -brm_switch: @ 81B38DC - push {r4-r6,lr} - adds r6, r0, 0 - lsls r6, 24 - lsrs r6, 24 - movs r0, 0x5 - bl PlaySE - ldr r5, =gUnknown_0203CEC8 - movs r0, 0x8 - strb r0, [r5, 0xB] - ldr r4, =gUnknown_0203CEC4 - ldr r0, [r4] - adds r0, 0xD - bl sub_81B302C - ldr r0, [r4] - adds r0, 0xC - bl sub_81B302C - movs r0, 0x3 - bl display_pokemon_menu_message - ldrb r0, [r5, 0x9] - movs r1, 0x1 - bl sub_81B0FCC - ldrb r0, [r5, 0x9] - strb r0, [r5, 0xA] - ldr r1, =gTasks - lsls r0, r6, 2 - adds r0, r6 - lsls r0, 3 - adds r0, r1 - ldr r1, =sub_81B1370 - str r1, [r0] - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end brm_switch - - thumb_func_start sub_81B3938 -sub_81B3938: @ 81B3938 - push {r4-r7,lr} - sub sp, 0xC - lsls r0, 24 - lsrs r7, r0, 24 - lsls r0, r7, 2 - adds r0, r7 - lsls r0, 3 - ldr r1, =gTasks + 0x8 - adds r6, r0, r1 - ldr r3, =gUnknown_0203CEC8 - movs r1, 0xA - ldrsb r1, [r3, r1] - movs r0, 0x9 - ldrsb r0, [r3, r0] - cmp r1, r0 - bne _081B3968 - adds r0, r7, 0 - bl sub_81B407C - b _081B3ABA - .pool -_081B3968: - add r2, sp, 0x8 - movs r0, 0x9 - ldrsb r0, [r3, r0] - ldr r1, =gUnknown_0203CEDC - ldr r1, [r1] - lsls r0, 4 - adds r0, r1 - ldrb r0, [r0, 0x8] - movs r4, 0 - strb r0, [r2] - adds r0, r2, 0 - ldrb r0, [r0] - movs r1, 0x1 - bl GetWindowAttribute - strh r0, [r6] - add r0, sp, 0x8 - ldrb r0, [r0] - movs r1, 0x2 - bl GetWindowAttribute - strh r0, [r6, 0x2] - add r0, sp, 0x8 - ldrb r0, [r0] - movs r1, 0x3 - bl GetWindowAttribute - strh r0, [r6, 0x4] - add r0, sp, 0x8 - ldrb r0, [r0] - movs r1, 0x4 - bl GetWindowAttribute - strh r0, [r6, 0x6] - strh r4, [r6, 0x10] - movs r1, 0x4 - ldrsh r0, [r6, r1] - cmp r0, 0xA - bne _081B39C4 - movs r2, 0x1 - negs r2, r2 - adds r0, r2, 0 - b _081B39C6 - .pool -_081B39C4: - movs r0, 0x1 -_081B39C6: - strh r0, [r6, 0x14] - add r2, sp, 0x8 - ldr r0, =gUnknown_0203CEC8 - ldrb r0, [r0, 0xA] - lsls r0, 24 - asrs r0, 24 - ldr r1, =gUnknown_0203CEDC - ldr r1, [r1] - lsls r0, 4 - adds r0, r1 - ldrb r0, [r0, 0x8] - movs r4, 0 - strb r0, [r2, 0x1] - adds r0, r2, 0 - ldrb r0, [r0, 0x1] - movs r1, 0x1 - bl GetWindowAttribute - strh r0, [r6, 0x8] - add r0, sp, 0x8 - ldrb r0, [r0, 0x1] - movs r1, 0x2 - bl GetWindowAttribute - strh r0, [r6, 0xA] - add r0, sp, 0x8 - ldrb r0, [r0, 0x1] - movs r1, 0x3 - bl GetWindowAttribute - strh r0, [r6, 0xC] - add r0, sp, 0x8 - ldrb r0, [r0, 0x1] - movs r1, 0x4 - bl GetWindowAttribute - strh r0, [r6, 0xE] - strh r4, [r6, 0x12] - movs r1, 0xC - ldrsh r0, [r6, r1] - cmp r0, 0xA - bne _081B3A2C - movs r2, 0x1 - negs r2, r2 - adds r0, r2, 0 - b _081B3A2E - .pool -_081B3A2C: - movs r0, 0x1 -_081B3A2E: - strh r0, [r6, 0x16] - ldr r4, =gUnknown_0203CEF0 - movs r0, 0x4 - ldrsh r1, [r6, r0] - movs r2, 0x6 - ldrsh r0, [r6, r2] - lsls r0, 1 - muls r0, r1 - bl Alloc - str r0, [r4] - ldr r5, =gUnknown_0203CEF4 - movs r0, 0xC - ldrsh r1, [r6, r0] - movs r2, 0xE - ldrsh r0, [r6, r2] - lsls r0, 1 - muls r0, r1 - bl Alloc - str r0, [r5] - ldr r1, [r4] - ldrb r2, [r6] - ldrb r3, [r6, 0x2] - ldrb r0, [r6, 0x4] - str r0, [sp] - ldrb r0, [r6, 0x6] - str r0, [sp, 0x4] - movs r0, 0 - bl sub_8199CBC - ldr r1, [r5] - ldrb r2, [r6, 0x8] - ldrb r3, [r6, 0xA] - ldrb r0, [r6, 0xC] - str r0, [sp] - ldrb r0, [r6, 0xE] - str r0, [sp, 0x4] - movs r0, 0 - bl sub_8199CBC - add r0, sp, 0x8 - ldrb r0, [r0] - bl ClearWindowTilemap - add r0, sp, 0x8 - ldrb r0, [r0, 0x1] - bl ClearWindowTilemap - ldr r4, =gUnknown_0203CEC8 - movs r0, 0x9 - strb r0, [r4, 0xB] - ldrb r0, [r4, 0x9] - movs r1, 0x1 - bl sub_81B0FCC - ldrb r0, [r4, 0xA] - movs r1, 0x1 - bl sub_81B0FCC - adds r0, r7, 0 - bl sub_81B3CC0 - ldr r1, =gTasks - lsls r0, r7, 2 - adds r0, r7 - lsls r0, 3 - adds r0, r1 - ldr r1, =sub_81B3D48 - str r1, [r0] -_081B3ABA: - add sp, 0xC - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81B3938 - - thumb_func_start sub_81B3AD8 -sub_81B3AD8: @ 81B3AD8 - push {r4-r7,lr} - mov r7, r8 - push {r7} - adds r6, r2, 0 - mov r12, r3 - ldr r7, [sp, 0x18] - lsls r0, 16 - lsrs r3, r0, 16 - adds r5, r3, 0 - lsls r1, 16 - lsrs r2, r1, 16 - mov r8, r2 - lsls r0, r3, 16 - asrs r1, r0, 16 - lsls r0, r2, 16 - asrs r0, 16 - adds r4, r1, r0 - cmp r4, 0 - blt _081B3B02 - cmp r1, 0x1F - ble _081B3B06 -_081B3B02: - movs r0, 0 - b _081B3B34 -_081B3B06: - cmp r1, 0 - bge _081B3B1A - negs r0, r1 - strb r0, [r6] - movs r0, 0 - mov r1, r12 - strb r0, [r1] - adds r0, r2, r3 - strb r0, [r7] - b _081B3B32 -_081B3B1A: - movs r0, 0 - strb r0, [r6] - mov r0, r12 - strb r5, [r0] - cmp r4, 0x1F - ble _081B3B2E - movs r0, 0x20 - subs r0, r5 - strb r0, [r7] - b _081B3B32 -_081B3B2E: - mov r1, r8 - strb r1, [r7] -_081B3B32: - movs r0, 0x1 -_081B3B34: - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r1} - bx r1 - thumb_func_end sub_81B3AD8 - - thumb_func_start sub_81B3B40 -sub_81B3B40: @ 81B3B40 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0x34 - str r0, [sp, 0x28] - ldr r0, [sp, 0x54] - ldr r4, [sp, 0x58] - lsls r2, 16 - lsrs r2, 16 - mov r9, r2 - lsls r3, 16 - lsls r0, 16 - lsrs r0, 16 - mov r10, r0 - lsls r4, 16 - lsrs r4, 16 - str r4, [sp, 0x30] - lsls r1, 16 - asrs r7, r1, 16 - lsrs r0, r3, 16 - str r0, [sp, 0x2C] - asrs r3, 16 - mov r8, r3 - mov r5, sp - adds r5, 0x25 - mov r6, sp - adds r6, 0x26 - str r6, [sp] - adds r0, r7, 0 - mov r1, r8 - add r2, sp, 0x24 - adds r3, r5, 0 - bl sub_81B3AD8 - lsls r0, 24 - cmp r0, 0 - beq _081B3BFA - ldrb r2, [r5] - mov r1, r9 - lsls r0, r1, 24 - lsrs r0, 24 - mov r9, r0 - ldrb r0, [r6] - str r0, [sp] - mov r1, r10 - lsls r0, r1, 24 - lsrs r4, r0, 24 - str r4, [sp, 0x4] - movs r0, 0 - movs r1, 0 - mov r3, r9 - bl FillBgTilemapBufferRect_Palette0 - ldr r1, [sp, 0x30] - lsls r0, r1, 16 - asrs r0, 16 - adds r0, r7, r0 - lsls r0, 16 - asrs r0, 16 - str r6, [sp] - mov r1, r8 - add r2, sp, 0x24 - adds r3, r5, 0 - bl sub_81B3AD8 - lsls r0, 24 - cmp r0, 0 - beq _081B3BFA - add r0, sp, 0x24 - ldrb r2, [r0] - ldr r1, [sp, 0x2C] - lsls r0, r1, 24 - lsrs r0, 24 - str r0, [sp] - str r4, [sp, 0x4] - ldrb r0, [r5] - str r0, [sp, 0x8] - mov r0, r9 - str r0, [sp, 0xC] - ldrb r0, [r6] - str r0, [sp, 0x10] - str r4, [sp, 0x14] - movs r0, 0x11 - str r0, [sp, 0x18] - movs r0, 0 - str r0, [sp, 0x1C] - str r0, [sp, 0x20] - ldr r1, [sp, 0x28] - movs r3, 0 - bl CopyRectToBgTilemapBufferRect -_081B3BFA: - add sp, 0x34 - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - thumb_func_end sub_81B3B40 - - thumb_func_start sub_81B3C0C -sub_81B3C0C: @ 81B3C0C - push {r4,lr} - ldr r4, =gSprites - ldrb r2, [r0, 0xB] - lsls r3, r2, 4 - adds r3, r2 - lsls r3, 2 - adds r3, r4 - lsls r1, 16 - asrs r1, 13 - ldrh r2, [r3, 0x24] - adds r2, r1 - strh r2, [r3, 0x24] - ldrb r3, [r0, 0xA] - lsls r2, r3, 4 - adds r2, r3 - lsls r2, 2 - adds r2, r4 - ldrh r3, [r2, 0x24] - adds r3, r1 - strh r3, [r2, 0x24] - ldrb r3, [r0, 0x9] - lsls r2, r3, 4 - adds r2, r3 - lsls r2, 2 - adds r2, r4 - ldrh r3, [r2, 0x24] - adds r3, r1 - strh r3, [r2, 0x24] - ldrb r2, [r0, 0xC] - lsls r0, r2, 4 - adds r0, r2 - lsls r0, 2 - adds r0, r4 - ldrh r2, [r0, 0x24] - adds r2, r1 - strh r2, [r0, 0x24] - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81B3C0C - - thumb_func_start sub_81B3C60 -sub_81B3C60: @ 81B3C60 - push {r4,lr} - lsls r0, 24 - lsrs r0, 24 - lsls r1, r0, 2 - adds r1, r0 - lsls r1, 3 - ldr r0, =gTasks + 0x8 - adds r4, r1, r0 - movs r1, 0x14 - ldrsh r0, [r4, r1] - cmp r0, 0 - beq _081B3C8E - ldr r2, =gUnknown_0203CEDC - ldr r0, =gUnknown_0203CEC8 - movs r1, 0x9 - ldrsb r1, [r0, r1] - lsls r1, 4 - ldr r0, [r2] - adds r0, r1 - movs r2, 0x14 - ldrsh r1, [r4, r2] - bl sub_81B3C0C -_081B3C8E: - movs r1, 0x16 - ldrsh r0, [r4, r1] - cmp r0, 0 - beq _081B3CAC - ldr r2, =gUnknown_0203CEDC - ldr r0, =gUnknown_0203CEC8 - movs r1, 0xA - ldrsb r1, [r0, r1] - lsls r1, 4 - ldr r0, [r2] - adds r0, r1 - movs r2, 0x16 - ldrsh r1, [r4, r2] - bl sub_81B3C0C -_081B3CAC: - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81B3C60 - - thumb_func_start sub_81B3CC0 -sub_81B3CC0: @ 81B3CC0 - push {r4-r6,lr} - sub sp, 0x8 - lsls r0, 24 - lsrs r0, 24 - lsls r1, r0, 2 - adds r1, r0 - lsls r1, 3 - ldr r0, =gTasks + 0x8 - adds r5, r1, r0 - movs r1, 0x14 - ldrsh r0, [r5, r1] - cmp r0, 0 - beq _081B3D00 - ldr r0, =gUnknown_0203CEF0 - ldr r0, [r0] - ldrh r1, [r5, 0x10] - ldrh r2, [r5] - adds r1, r2 - lsls r1, 16 - asrs r1, 16 - movs r3, 0x2 - ldrsh r2, [r5, r3] - movs r4, 0x4 - ldrsh r3, [r5, r4] - movs r6, 0x6 - ldrsh r4, [r5, r6] - str r4, [sp] - movs r6, 0x14 - ldrsh r4, [r5, r6] - str r4, [sp, 0x4] - bl sub_81B3B40 -_081B3D00: - movs r1, 0x16 - ldrsh r0, [r5, r1] - cmp r0, 0 - beq _081B3D2E - ldr r0, =gUnknown_0203CEF4 - ldr r0, [r0] - ldrh r1, [r5, 0x12] - ldrh r2, [r5, 0x8] - adds r1, r2 - lsls r1, 16 - asrs r1, 16 - movs r3, 0xA - ldrsh r2, [r5, r3] - movs r4, 0xC - ldrsh r3, [r5, r4] - movs r6, 0xE - ldrsh r4, [r5, r6] - str r4, [sp] - movs r6, 0x16 - ldrsh r4, [r5, r6] - str r4, [sp, 0x4] - bl sub_81B3B40 -_081B3D2E: - movs r0, 0 - bl schedule_bg_copy_tilemap_to_vram - add sp, 0x8 - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81B3CC0 - - thumb_func_start sub_81B3D48 -sub_81B3D48: @ 81B3D48 - push {r4-r7,lr} - mov r7, r8 - push {r7} - sub sp, 0xC - adds r4, r0, 0 - lsls r4, 24 - lsrs r4, 24 - lsls r0, r4, 2 - adds r0, r4 - lsls r7, r0, 3 - ldr r0, =gTasks + 0x8 - mov r8, r0 - adds r6, r7, r0 - adds r0, r4, 0 - bl sub_81B3CC0 - adds r0, r4, 0 - bl sub_81B3C60 - ldrh r1, [r6, 0x14] - ldrh r2, [r6, 0x10] - adds r1, r2 - strh r1, [r6, 0x10] - ldrh r0, [r6, 0x16] - ldrh r3, [r6, 0x12] - adds r0, r3 - strh r0, [r6, 0x12] - add r2, sp, 0x8 - ldrh r0, [r6] - adds r0, r1 - strh r0, [r2] - adds r1, r2, 0 - ldrh r0, [r6, 0x12] - ldrh r3, [r6, 0x8] - adds r2, r0, r3 - strh r2, [r1, 0x2] - adds r0, r1, 0 - ldrh r0, [r0] - cmp r0, 0x21 - bls _081B3E3A - lsls r0, r2, 16 - lsrs r0, 16 - cmp r0, 0x21 - bls _081B3E3A - movs r1, 0x14 - ldrsh r0, [r6, r1] - negs r0, r0 - strh r0, [r6, 0x14] - movs r2, 0x16 - ldrsh r0, [r6, r2] - negs r0, r0 - strh r0, [r6, 0x16] - bl swap_pokemon_and_oams - ldr r4, =gUnknown_0203CEC8 - ldrb r0, [r4, 0x9] - bl sub_81B0948 - ldrb r0, [r4, 0xA] - bl sub_81B0948 - movs r0, 0x9 - ldrsb r0, [r4, r0] - ldr r5, =gUnknown_0203CEDC - ldr r1, [r5] - lsls r0, 4 - adds r0, r1 - ldrb r0, [r0, 0x8] - bl PutWindowTilemap - movs r0, 0xA - ldrsb r0, [r4, r0] - ldr r1, [r5] - lsls r0, 4 - adds r0, r1 - ldrb r0, [r0, 0x8] - bl PutWindowTilemap - ldr r0, =gUnknown_0203CEF0 - ldr r1, [r0] - ldrb r2, [r6] - ldrb r3, [r6, 0x2] - ldrb r0, [r6, 0x4] - str r0, [sp] - ldrb r0, [r6, 0x6] - str r0, [sp, 0x4] - movs r0, 0 - bl sub_8199CBC - ldr r0, =gUnknown_0203CEF4 - ldr r1, [r0] - ldrb r2, [r6, 0x8] - ldrb r3, [r6, 0xA] - ldrb r0, [r6, 0xC] - str r0, [sp] - ldrb r0, [r6, 0xE] - str r0, [sp, 0x4] - movs r0, 0 - bl sub_8199CBC - movs r0, 0x9 - ldrsb r0, [r4, r0] - ldr r1, [r5] - lsls r0, 4 - adds r0, r1 - ldrb r0, [r0, 0x8] - bl ClearWindowTilemap - movs r0, 0xA - ldrsb r0, [r4, r0] - ldr r1, [r5] - lsls r0, 4 - adds r0, r1 - ldrb r0, [r0, 0x8] - bl ClearWindowTilemap - mov r0, r8 - subs r0, 0x8 - adds r0, r7, r0 - ldr r1, =sub_81B3E60 - str r1, [r0] -_081B3E3A: - add sp, 0xC - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81B3D48 - - thumb_func_start sub_81B3E60 -sub_81B3E60: @ 81B3E60 - push {r4-r6,lr} - lsls r0, 24 - lsrs r6, r0, 24 - lsls r0, r6, 2 - adds r0, r6 - lsls r0, 3 - ldr r1, =gTasks + 0x8 - adds r4, r0, r1 - adds r0, r6, 0 - bl sub_81B3CC0 - adds r0, r6, 0 - bl sub_81B3C60 - movs r1, 0x14 - ldrsh r0, [r4, r1] - cmp r0, 0 - bne _081B3EE4 - movs r2, 0x16 - ldrsh r0, [r4, r2] - cmp r0, 0 - bne _081B3EE4 - ldr r5, =gUnknown_0203CEC8 - movs r0, 0x9 - ldrsb r0, [r5, r0] - ldr r4, =gUnknown_0203CEDC - ldr r1, [r4] - lsls r0, 4 - adds r0, r1 - ldrb r0, [r0, 0x8] - bl PutWindowTilemap - movs r0, 0xA - ldrsb r0, [r5, r0] - ldr r1, [r4] - lsls r0, 4 - adds r0, r1 - ldrb r0, [r0, 0x8] - bl PutWindowTilemap - movs r0, 0 - bl schedule_bg_copy_tilemap_to_vram - ldr r0, =gUnknown_0203CEF0 - ldr r0, [r0] - bl Free - ldr r0, =gUnknown_0203CEF4 - ldr r0, [r0] - bl Free - adds r0, r6, 0 - bl sub_81B407C - b _081B3F08 - .pool -_081B3EE4: - ldrh r1, [r4, 0x14] - ldrh r0, [r4, 0x10] - adds r1, r0 - strh r1, [r4, 0x10] - ldrh r0, [r4, 0x16] - ldrh r2, [r4, 0x12] - adds r0, r2 - strh r0, [r4, 0x12] - lsls r1, 16 - asrs r1, 16 - cmp r1, 0 - bne _081B3EFE - strh r1, [r4, 0x14] -_081B3EFE: - movs r1, 0x12 - ldrsh r0, [r4, r1] - cmp r0, 0 - bne _081B3F08 - strh r0, [r4, 0x16] -_081B3F08: - pop {r4-r6} - pop {r0} - bx r0 - thumb_func_end sub_81B3E60 - - thumb_func_start oamt_swap_pos -oamt_swap_pos: @ 81B3F10 - push {r4-r6,lr} - mov r6, r10 - mov r5, r9 - mov r4, r8 - push {r4-r6} - ldrb r3, [r0] - ldrb r2, [r1] - strb r2, [r0] - strb r3, [r1] - ldr r5, =gSprites - ldrb r2, [r0] - lsls r3, r2, 4 - adds r3, r2 - lsls r3, 2 - adds r3, r5 - ldrh r6, [r3, 0x20] - ldrh r2, [r3, 0x22] - mov r8, r2 - ldrh r2, [r3, 0x24] - mov r9, r2 - ldrh r2, [r3, 0x26] - mov r10, r2 - ldrb r4, [r1] - lsls r2, r4, 4 - adds r2, r4 - lsls r2, 2 - adds r2, r5 - ldrh r2, [r2, 0x20] - strh r2, [r3, 0x20] - ldrb r2, [r0] - lsls r3, r2, 4 - adds r3, r2 - lsls r3, 2 - adds r3, r5 - ldrb r4, [r1] - lsls r2, r4, 4 - adds r2, r4 - lsls r2, 2 - adds r2, r5 - ldrh r2, [r2, 0x22] - strh r2, [r3, 0x22] - ldrb r2, [r0] - lsls r3, r2, 4 - adds r3, r2 - lsls r3, 2 - adds r3, r5 - ldrb r4, [r1] - lsls r2, r4, 4 - adds r2, r4 - lsls r2, 2 - adds r2, r5 - ldrh r2, [r2, 0x24] - strh r2, [r3, 0x24] - ldrb r0, [r0] - lsls r2, r0, 4 - adds r2, r0 - lsls r2, 2 - adds r2, r5 - ldrb r3, [r1] - lsls r0, r3, 4 - adds r0, r3 - lsls r0, 2 - adds r0, r5 - ldrh r0, [r0, 0x26] - strh r0, [r2, 0x26] - ldrb r2, [r1] - lsls r0, r2, 4 - adds r0, r2 - lsls r0, 2 - adds r0, r5 - strh r6, [r0, 0x20] - ldrb r2, [r1] - lsls r0, r2, 4 - adds r0, r2 - lsls r0, 2 - adds r0, r5 - mov r2, r8 - strh r2, [r0, 0x22] - ldrb r2, [r1] - lsls r0, r2, 4 - adds r0, r2 - lsls r0, 2 - adds r0, r5 - mov r2, r9 - strh r2, [r0, 0x24] - ldrb r1, [r1] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r5 - mov r1, r10 - strh r1, [r0, 0x26] - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end oamt_swap_pos - - thumb_func_start swap_pokemon_and_oams -swap_pokemon_and_oams: @ 81B3FDC - push {r4-r6,lr} - sub sp, 0x8 - ldr r1, =gUnknown_0203CEDC - ldr r2, =gUnknown_0203CEC8 - movs r3, 0x9 - ldrsb r3, [r2, r3] - lsls r0, r3, 4 - ldr r1, [r1] - adds r0, r1, r0 - str r0, [sp] - ldrb r2, [r2, 0xA] - lsls r2, 24 - asrs r2, 24 - lsls r0, r2, 4 - adds r0, r1, r0 - str r0, [sp, 0x4] - movs r1, 0x64 - adds r4, r3, 0 - muls r4, r1 - ldr r0, =gPlayerParty - adds r4, r0 - adds r5, r2, 0 - muls r5, r1 - adds r5, r0 - movs r0, 0x64 - bl Alloc - adds r6, r0, 0 - adds r1, r4, 0 - movs r2, 0x64 - bl memcpy - adds r0, r4, 0 - adds r1, r5, 0 - movs r2, 0x64 - bl memcpy - adds r0, r5, 0 - adds r1, r6, 0 - movs r2, 0x64 - bl memcpy - adds r0, r6, 0 - bl Free - ldr r0, [sp] - adds r0, 0xB - ldr r1, [sp, 0x4] - adds r1, 0xB - bl oamt_swap_pos - ldr r0, [sp] - adds r0, 0xA - ldr r1, [sp, 0x4] - adds r1, 0xA - bl oamt_swap_pos - ldr r0, [sp] - adds r0, 0x9 - ldr r1, [sp, 0x4] - adds r1, 0x9 - bl oamt_swap_pos - ldr r0, [sp] - adds r0, 0xC - ldr r1, [sp, 0x4] - adds r1, 0xC - bl oamt_swap_pos - add sp, 0x8 - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end swap_pokemon_and_oams - - thumb_func_start sub_81B407C -sub_81B407C: @ 81B407C - push {r4,r5,lr} - adds r5, r0, 0 - lsls r5, 24 - lsrs r5, 24 - ldr r0, =gUnknown_0203CEC4 - ldr r0, [r0] - adds r0, 0xD - bl sub_81B302C - ldr r4, =gUnknown_0203CEC8 - movs r0, 0 - strb r0, [r4, 0xB] - ldrb r0, [r4, 0x9] - movs r1, 0 - bl sub_81B0FCC - ldrb r0, [r4, 0xA] - strb r0, [r4, 0x9] - ldrb r0, [r4, 0xA] - movs r1, 0x1 - bl sub_81B0FCC - movs r0, 0 - bl display_pokemon_menu_message - ldr r1, =gTasks - lsls r0, r5, 2 - adds r0, r5 - lsls r0, 3 - adds r0, r1 - ldr r1, =sub_81B1370 - str r1, [r0] - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81B407C - - thumb_func_start brm_cancel_1 -brm_cancel_1: @ 81B40D4 - push {r4,r5,lr} - lsls r0, 24 - lsrs r5, r0, 24 - movs r0, 0x5 - bl PlaySE - ldr r4, =gUnknown_0203CEC4 - ldr r0, [r4] - adds r0, 0xC - bl sub_81B302C - ldr r0, [r4] - adds r0, 0xD - bl sub_81B302C - ldr r0, =gUnknown_0203CEC8 - ldrb r1, [r0, 0x8] - movs r0, 0xF - ands r0, r1 - cmp r0, 0x6 - bne _081B4110 - movs r0, 0xF - bl display_pokemon_menu_message - b _081B4116 - .pool -_081B4110: - movs r0, 0 - bl display_pokemon_menu_message -_081B4116: - ldr r0, =gTasks - lsls r1, r5, 2 - adds r1, r5 - lsls r1, 3 - adds r1, r0 - ldr r0, =sub_81B1370 - str r0, [r1] - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end brm_cancel_1 - thumb_func_start sub_81B4134 sub_81B4134: @ 81B4134 push {r4,r5,lr} diff --git a/include/menu.h b/include/menu.h index eb525efe98..60be8361ff 100644 --- a/include/menu.h +++ b/include/menu.h @@ -90,5 +90,8 @@ void sub_8198204(const u8 *string, const u8 *string2, u8 a3, u8 a4, bool8 copyTo void sub_8197AE8(bool8 copyToVram); void sub_81997AC(u8 windowId, u8 a4, u8 a6, u8 a7, const struct MenuAction *strs); s8 Menu_ProcessInputGridLayout(void); +u8 InitMenuInUpperLeftCorner(u8 windowId, u8 itemCount, u8 initialCursorPos, bool8 APressMuted); +s8 Menu_ProcessInputNoWrapAround_other(void); +void sub_8199CBC(u8 bgId, u16 *dest, u8 left, u8 top, u8 width, u8 height); #endif // GUARD_MENU_H diff --git a/include/strings.h b/include/strings.h index 22ff75bc57..0ec3526ea1 100644 --- a/include/strings.h +++ b/include/strings.h @@ -406,6 +406,7 @@ extern const u8 gText_SwitchPkmnItem[]; extern const u8 gText_SwitchedPkmnItem[]; extern const u8 gText_BagFullCouldNotRemoveItem[]; extern const u8 gText_PkmnCantParticipate[]; +extern const u8 gText_PkmnNotHolding[]; //pokedex text extern const u8 gText_CryOf[]; diff --git a/src/party_menu.c b/src/party_menu.c index 8339506573..c43beaadb0 100755 --- a/src/party_menu.c +++ b/src/party_menu.c @@ -2,9 +2,11 @@ #include "battle.h" #include "battle_controllers.h" #include "battle_interface.h" +#include "battle_pike.h" #include "bg.h" #include "constants/battle.h" #include "constants/items.h" +#include "constants/moves.h" #include "constants/rgb.h" #include "constants/songs.h" #include "constants/species.h" @@ -12,6 +14,7 @@ #include "data2.h" #include "decompress.h" #include "event_data.h" +#include "field_specials.h" #include "fldeff_softboiled.h" #include "gpu_regs.h" #include "graphics.h" @@ -28,10 +31,12 @@ #include "party_menu.h" #include "pokemon.h" #include "pokemon_icon.h" +#include "pokemon_summary_screen.h" #include "rom_8011DC0.h" #include "scanline_effect.h" #include "sound.h" #include "sprite.h" +#include "start_menu.h" #include "string_util.h" #include "strings.h" #include "task.h" @@ -57,7 +62,8 @@ struct Unk_203CEC4 { u32 unk9_0:7; u32 unkA_0:14; u8 unkC[3]; - u8 fillerF[9]; + u8 unkF[8]; + u8 unk17; u16 unk18[0xB0]; u8 filler[0xA0]; s16 unk218[16]; @@ -77,6 +83,11 @@ struct Unk_203CEE4 { u8 filler[0x800]; }; +struct Unk_8615C08 { + const u8 *textPtr; + TaskFunc func; +}; + // BELOW TO BE PUT IN EWRAM extern struct Unk_203CEC4 *gUnknown_0203CEC4; @@ -85,7 +96,10 @@ extern struct Unk_203CEDC *gUnknown_0203CEDC; extern u8 *gUnknown_0203CEE0; extern struct Unk_203CEE4 *gUnknown_0203CEE4; extern u8 gUnknown_0203CEE8; +extern u16 *gUnknown_0203CEF0; +extern u16 *gUnknown_0203CEF4; extern u8 gSelectedOrderFromParty[]; +extern u8 gUnknown_0203CF20; // summary screen? // ABOVE TO BE PUT IN EWRAM @@ -112,6 +126,11 @@ extern struct WindowTemplate gUnknown_08615930; extern struct WindowTemplate gUnknown_08615938; extern struct WindowTemplate gUnknown_08615940; extern struct WindowTemplate gUnknown_08615948; +extern struct WindowTemplate gUnknown_08615950; +extern struct WindowTemplate gUnknown_08615958; +extern struct WindowTemplate gUnknown_08615960; +extern struct WindowTemplate gUnknown_08615968; +extern struct WindowTemplate gUnknown_08615970; extern u8 gUnknown_08615988[]; extern u8 gUnknown_086159CE[]; extern u8 gUnknown_08615A14[]; @@ -142,6 +161,10 @@ extern u8 gUnknown_08615AEE[]; extern u8 gUnknown_08615AF1[]; extern const u8 *gUnknown_08615AF4[]; extern const u8 *gUnknown_08615B60[]; +extern struct Unk_8615C08 gUnknown_08615C08[]; +extern u8 *gUnknown_08615D38[]; +extern u8 gUnknown_08615D70[]; +extern const u16 gUnknown_08615D7E[]; // ABOVE TO BE CONVERTED TO C @@ -255,6 +278,18 @@ void sub_81B227C(u8); bool8 sub_81B2370(u16, u8); u16 sub_81B2360(u8); bool8 sub_81B314C(void); +void sub_81B3414(struct Pokemon*, u8); +u8 sub_81B8A2C(struct Pokemon*); +u8 sub_81B856C(s8); +void sub_81B469C(u8); +void sub_81B3730(u8); +void sub_81B3828(void); +void pokemon_change_order(void); +void sub_81B3894(void); +void sub_81B3CC0(u8); +void sub_81B3D48(u8); +void swap_pokemon_and_oams(void); +void sub_81B3E60(u8); void sub_81B0038(u8 a, u8 b, u8 c, u8 d, u8 e, TaskFunc f, MainCallback g) { @@ -2784,3 +2819,575 @@ bool8 sub_81B314C(void) } return FALSE; } + +u8 sub_81B31B0(u8 a) +{ + struct WindowTemplate window; + u8 cursorDimension; + u8 fontAttribute; + u8 i; + + switch (a) + { + case 0: + SetWindowTemplateFields(&window, 2, 19, 19 - (gUnknown_0203CEC4->unk17 * 2), 10, gUnknown_0203CEC4->unk17 * 2, 14, 0x2E9); + break; + case 1: + window = gUnknown_08615950; + break; + case 2: + window = gUnknown_08615958; + break; + default: + window = gUnknown_08615960; + break; + } + + gUnknown_0203CEC4->unkC[0] = AddWindow(&window); + SetWindowBorderStyle(gUnknown_0203CEC4->unkC[0], 0, 0x4F, 13); + if (a == 3) + return gUnknown_0203CEC4->unkC[0]; + cursorDimension = GetMenuCursorDimensionByFont(1, 0); + fontAttribute = GetFontAttribute(1, 2); + + for (i = 0; i < gUnknown_0203CEC4->unk17; i++) + { + u8 unk = (gUnknown_0203CEC4->unkF[i] > 18) ? 4 : 3; + AddTextPrinterParameterized4(gUnknown_0203CEC4->unkC[0], 1, cursorDimension, (i * 16) + 1, fontAttribute, 0, gUnknown_086157FC[unk], 0, gUnknown_08615C08[gUnknown_0203CEC4->unkF[i]].textPtr); + } + + InitMenuInUpperLeftCorner(gUnknown_0203CEC4->unkC[0], gUnknown_0203CEC4->unk17, 0, 1); + schedule_bg_copy_tilemap_to_vram(2); + + return gUnknown_0203CEC4->unkC[0]; +} + +void sub_81B3300(const u8 *text) +{ + SetWindowBorderStyle(6, 0, 0x4F, 13); + gTextFlags.canABSpeedUpPrint = TRUE; + AddTextPrinterParameterized2(6, 1, text, GetPlayerTextSpeedDelay(), 0, 2, 1, 3); +} + +void sub_81B334C(void) +{ + CreateYesNoMenu(&gUnknown_08615968, 0x4F, 13, 0); +} + +u8 sub_81B3364(void) +{ + gUnknown_0203CEC4->unkC[0] = AddWindow(&gUnknown_08615970); + SetWindowBorderStyle(gUnknown_0203CEC4->unkC[0], 0, 0x4F, 13); + return gUnknown_0203CEC4->unkC[0]; +} + +void sub_81B3394(void) +{ + ClearWindowTilemap(gUnknown_0203CEC4->unkC[0]); + sub_81B302C(&gUnknown_0203CEC4->unkC[0]); +} + +void sub_81B33B4(struct Pokemon *mons, u8 a, u8 b) +{ + u8 i; + + if (b == 0) + { + sub_81B3414(mons, a); + } + else + { + gUnknown_0203CEC4->unk17 = gUnknown_08615D70[b]; + for (i = 0; i < gUnknown_0203CEC4->unk17; i++) + gUnknown_0203CEC4->unkF[i] = gUnknown_08615D38[b][i]; + } +} + +void sub_81B3414(struct Pokemon *mons, u8 a) +{ + u8 i, j; + + gUnknown_0203CEC4->unk17 = 0; + AppendToList(gUnknown_0203CEC4->unkF, &gUnknown_0203CEC4->unk17, 0); + for (i = 0; i < 4; i++) + { + for (j = 0; gUnknown_08615D7E[j] != MOVE_SWORDS_DANCE; j++) + { + if (GetMonData(&mons[a], i + MON_DATA_MOVE1) == gUnknown_08615D7E[j]) + { + AppendToList(gUnknown_0203CEC4->unkF, &gUnknown_0203CEC4->unk17, j + 19); + break; + } + } + } + if (!InBattlePike()) + { + if (GetMonData(&mons[1], MON_DATA_SPECIES) != SPECIES_NONE) + AppendToList(gUnknown_0203CEC4->unkF, &gUnknown_0203CEC4->unk17, 1); + if (ItemIsMail(GetMonData(&mons[a], MON_DATA_HELD_ITEM))) + AppendToList(gUnknown_0203CEC4->unkF, &gUnknown_0203CEC4->unk17, 6); + else + AppendToList(gUnknown_0203CEC4->unkF, &gUnknown_0203CEC4->unk17, 3); + } + AppendToList(gUnknown_0203CEC4->unkF, &gUnknown_0203CEC4->unk17, 2); +} + +u8 sub_81B353C(struct Pokemon *mon) +{ + u32 returnVar; + + switch (gUnknown_0203CEC8.unk8_0) + { + case 0: + if (InMultiBattleRoom() == TRUE || GetMonData(mon, MON_DATA_IS_EGG) != FALSE) + returnVar = 1; + else + returnVar = 0; + break; + case 1: + returnVar = sub_81B8A2C(mon); + break; + case 4: + switch (sub_81B856C(gUnknown_0203CEC8.unk9)) + { + default: + returnVar = 7; + break; + case 0: + returnVar = 4; + break; + case 1: + returnVar = 5; + break; + } + break; + case 6: + returnVar = (GetMonData(mon, MON_DATA_IS_EGG) != FALSE) ? 7 : 6; + break; + case 8: + returnVar = 10; + break; + case 9: + returnVar = 11; + break; + case 10: + returnVar = 12; + break; + case 12: + returnVar = 13; + break; + default: + returnVar = 0; + break; + } + return returnVar; +} + +bool8 sub_81B3608(u8 taskId) +{ + struct Pokemon *mon = &gPlayerParty[gUnknown_0203CEC8.unk9]; + u16 item; + + GetMonNickname(mon, gStringVar1); + sub_81B302C(&gUnknown_0203CEC4->unkC[1]); + if (gUnknown_0203CEC8.unk8_0 != 12) + { + sub_81B33B4(gPlayerParty, gUnknown_0203CEC8.unk9, sub_81B353C(mon)); + sub_81B31B0(0); + display_pokemon_menu_message(21); + } + else + { + item = GetMonData(mon, MON_DATA_HELD_ITEM); + if (item != ITEM_NONE) + { + sub_81B33B4(gPlayerParty, gUnknown_0203CEC8.unk9, sub_81B353C(mon)); + sub_81B31B0(1); + CopyItemName(item, gStringVar2); + display_pokemon_menu_message(26); + } + else + { + StringExpandPlaceholders(gStringVar4, gText_PkmnNotHolding); + sub_81B1B5C(gStringVar4, 1); + schedule_bg_copy_tilemap_to_vram(2); + gTasks[taskId].func = sub_81B469C; + return FALSE; + } + } + return TRUE; +} + +void sub_81B36FC(u8 taskId) +{ + if (sub_81B3608(taskId) != FALSE) + { + gTasks[taskId].data[0] = 0xFF; + gTasks[taskId].func = sub_81B3730; + } +} + +void sub_81B3730(u8 taskId) +{ + s16 *data; + s8 input; + + if (gPaletteFade.active == FALSE && sub_81221EC() != TRUE) + { + data = gTasks[taskId].data; + if (gUnknown_0203CEC4->unk17 <= 3) + input = Menu_ProcessInputNoWrapAround_other(); + else + input = ProcessMenuInput_other(); + data[0] = GetMenuCursorPos(); + if (input != -2) + { + if (input == -1) + { + PlaySE(SE_SELECT); + sub_81B302C(&gUnknown_0203CEC4->unkC[2]); + gUnknown_08615C08[gUnknown_0203CEC4->unkF[gUnknown_0203CEC4->unk17 - 1]].func(taskId); + } + else + { + sub_81B302C(&gUnknown_0203CEC4->unkC[2]); + gUnknown_08615C08[gUnknown_0203CEC4->unkF[input]].func(taskId); + } + } + } +} + +void sub_81B37FC(u8 taskId) +{ + PlaySE(SE_SELECT); + gUnknown_0203CEC4->unk4 = sub_81B3828; + sub_81B12C0(taskId); +} + +void sub_81B3828(void) +{ + if (gUnknown_0203CEC8.unk8_0 == 1) + { + pokemon_change_order(); + ShowPokemonSummaryScreen(PSS_MODE_UNK1, gPlayerParty, gUnknown_0203CEC8.unk9, gPlayerPartyCount - 1, sub_81B3894); + } + else + { + ShowPokemonSummaryScreen(PSS_MODE_NORMAL, gPlayerParty, gUnknown_0203CEC8.unk9, gPlayerPartyCount - 1, sub_81B3894); + } +} + +void sub_81B3894(void) +{ + gPaletteFade.bufferTransferDisabled = TRUE; + gUnknown_0203CEC8.unk9 = gUnknown_0203CF20; + sub_81B0038(gUnknown_0203CEC8.unk8_0, 0xFF, gUnknown_0203CEC8.unkB, 1, 21, sub_81B36FC, gUnknown_0203CEC8.unk0); +} + +void brm_switch(u8 taskId) +{ + PlaySE(SE_SELECT); + gUnknown_0203CEC8.unkB = 8; + sub_81B302C(&gUnknown_0203CEC4->unkC[1]); + sub_81B302C(&gUnknown_0203CEC4->unkC[0]); + display_pokemon_menu_message(3); + sub_81B0FCC(gUnknown_0203CEC8.unk9, 1); + gUnknown_0203CEC8.unkA = gUnknown_0203CEC8.unk9; + gTasks[taskId].func = sub_81B1370; +} + +void sub_81B3938(u8 taskId) +{ + s16 *data = gTasks[taskId].data; + u8 windowIds[2]; + + if (gUnknown_0203CEC8.unkA == gUnknown_0203CEC8.unk9) + { + sub_81B407C(taskId); + } + else + { + windowIds[0] = gUnknown_0203CEDC[gUnknown_0203CEC8.unk9].unk8; + data[0] = GetWindowAttribute(windowIds[0], WINDOW_TILEMAP_LEFT); + data[1] = GetWindowAttribute(windowIds[0], WINDOW_TILEMAP_TOP); + data[2] = GetWindowAttribute(windowIds[0], WINDOW_WIDTH); + data[3] = GetWindowAttribute(windowIds[0], WINDOW_HEIGHT); + data[8] = 0; + if (data[2] == 10) + data[10] = -1; + else + data[10] = 1; + windowIds[1] = gUnknown_0203CEDC[gUnknown_0203CEC8.unkA].unk8; + data[4] = GetWindowAttribute(windowIds[1], WINDOW_TILEMAP_LEFT); + data[5] = GetWindowAttribute(windowIds[1], WINDOW_TILEMAP_TOP); + data[6] = GetWindowAttribute(windowIds[1], WINDOW_WIDTH); + data[7] = GetWindowAttribute(windowIds[1], WINDOW_HEIGHT); + data[9] = 0; + if (data[6] == 10) + data[11] = -1; + else + data[11] = 1; + gUnknown_0203CEF0 = Alloc(data[2] * (data[3] << 1)); + gUnknown_0203CEF4 = Alloc(data[6] * (data[7] << 1)); + sub_8199CBC(0, gUnknown_0203CEF0, data[0], data[1], data[2], data[3]); + sub_8199CBC(0, gUnknown_0203CEF4, data[4], data[5], data[6], data[7]); + ClearWindowTilemap(windowIds[0]); + ClearWindowTilemap(windowIds[1]); + gUnknown_0203CEC8.unkB = 9; + sub_81B0FCC(gUnknown_0203CEC8.unk9, 1); + sub_81B0FCC(gUnknown_0203CEC8.unkA, 1); + sub_81B3CC0(taskId); + gTasks[taskId].func = sub_81B3D48; + } +} + +#ifdef NONMATCHING +bool8 sub_81B3AD8(s16 a, s16 b, u8 *c, u8 *d, u8 *e) +{ + + if ((a + b) < 0 || a > 31) + { + return FALSE; + } + if (a < 0) + { + *c = -a; + *d = 0; + *e = a + b; + return TRUE; + } + else + { + *c = 0; + *d = a; + if ((a + b) > 31) + *e = 32 - a; + else + *e = b; + return TRUE; + } + +} +#else +NAKED +bool8 sub_81B3AD8(s16 a, s16 b, u8 *c, u8 *d, u8 *e) +{ + asm_unified("push {r4-r7,lr}\n\ + mov r7, r8\n\ + push {r7}\n\ + adds r6, r2, 0\n\ + mov r12, r3\n\ + ldr r7, [sp, 0x18]\n\ + lsls r0, 16\n\ + lsrs r3, r0, 16\n\ + adds r5, r3, 0\n\ + lsls r1, 16\n\ + lsrs r2, r1, 16\n\ + mov r8, r2\n\ + lsls r0, r3, 16\n\ + asrs r1, r0, 16\n\ + lsls r0, r2, 16\n\ + asrs r0, 16\n\ + adds r4, r1, r0\n\ + cmp r4, 0\n\ + blt _081B3B02\n\ + cmp r1, 0x1F\n\ + ble _081B3B06\n\ +_081B3B02:\n\ + movs r0, 0\n\ + b _081B3B34\n\ +_081B3B06:\n\ + cmp r1, 0\n\ + bge _081B3B1A\n\ + negs r0, r1\n\ + strb r0, [r6]\n\ + movs r0, 0\n\ + mov r1, r12\n\ + strb r0, [r1]\n\ + adds r0, r2, r3\n\ + strb r0, [r7]\n\ + b _081B3B32\n\ +_081B3B1A:\n\ + movs r0, 0\n\ + strb r0, [r6]\n\ + mov r0, r12\n\ + strb r5, [r0]\n\ + cmp r4, 0x1F\n\ + ble _081B3B2E\n\ + movs r0, 0x20\n\ + subs r0, r5\n\ + strb r0, [r7]\n\ + b _081B3B32\n\ +_081B3B2E:\n\ + mov r1, r8\n\ + strb r1, [r7]\n\ +_081B3B32:\n\ + movs r0, 0x1\n\ +_081B3B34:\n\ + pop {r3}\n\ + mov r8, r3\n\ + pop {r4-r7}\n\ + pop {r1}\n\ + bx r1\n"); +} +#endif + +void sub_81B3B40(const void *rectSrc, s16 a, s16 b, s16 c, s16 d, s16 e) +{ + u8 f, g, h; + + if (sub_81B3AD8(a, c, &f, &g, &h) != FALSE) + { + FillBgTilemapBufferRect_Palette0(0, 0, g, b, h, d); + if (sub_81B3AD8(a + e, c, &f, &g, &h) != FALSE) + CopyRectToBgTilemapBufferRect(0, rectSrc, f, 0, c, d, g, b, h, d, 17, 0, 0); + } +} + +void sub_81B3C0C(struct Unk_203CEDC *ptr, s16 a) +{ + gSprites[ptr->unkB].pos2.x += a * 8; + gSprites[ptr->unkA].pos2.x += a * 8; + gSprites[ptr->unk9].pos2.x += a * 8; + gSprites[ptr->unkC].pos2.x += a * 8; +} + +void sub_81B3C60(u8 taskId) +{ + s16 *data = gTasks[taskId].data; + + if (data[10] != 0) + sub_81B3C0C(&gUnknown_0203CEDC[gUnknown_0203CEC8.unk9], data[10]); + if (data[11] != 0) + sub_81B3C0C(&gUnknown_0203CEDC[gUnknown_0203CEC8.unkA], data[11]); +} + +void sub_81B3CC0(u8 taskId) +{ + s16 *data = gTasks[taskId].data; + + if (data[10] != 0) + sub_81B3B40(gUnknown_0203CEF0, data[0] + data[8], data[1], data[2], data[3], data[10]); + if (data[11] != 0) + sub_81B3B40(gUnknown_0203CEF4, data[4] + data[9], data[5], data[6], data[7], data[11]); + schedule_bg_copy_tilemap_to_vram(0); +} + +void sub_81B3D48(u8 taskId) +{ + s16 *data = gTasks[taskId].data; + u16 tilemapRelatedMaybe[2]; + + sub_81B3CC0(taskId); + sub_81B3C60(taskId); + data[8] += data[10]; + data[9] += data[11]; + tilemapRelatedMaybe[0] = data[0] + data[8]; + tilemapRelatedMaybe[1] = data[4] + data[9]; + if (tilemapRelatedMaybe[0] > 33 && tilemapRelatedMaybe[1] > 33) + { + data[10] *= -1; + data[11] *= -1; + swap_pokemon_and_oams(); + sub_81B0948(gUnknown_0203CEC8.unk9); + sub_81B0948(gUnknown_0203CEC8.unkA); + PutWindowTilemap(gUnknown_0203CEDC[gUnknown_0203CEC8.unk9].unk8); + PutWindowTilemap(gUnknown_0203CEDC[gUnknown_0203CEC8.unkA].unk8); + sub_8199CBC(0, gUnknown_0203CEF0, data[0], data[1], data[2], data[3]); + sub_8199CBC(0, gUnknown_0203CEF4, data[4], data[5], data[6], data[7]); + ClearWindowTilemap(gUnknown_0203CEDC[gUnknown_0203CEC8.unk9].unk8); + ClearWindowTilemap(gUnknown_0203CEDC[gUnknown_0203CEC8.unkA].unk8); + gTasks[taskId].func = sub_81B3E60; + } +} + +void sub_81B3E60(u8 taskId) +{ + s16 *data = gTasks[taskId].data; + + sub_81B3CC0(taskId); + sub_81B3C60(taskId); + if (data[10] == 0 && data[11] == 0) + { + PutWindowTilemap(gUnknown_0203CEDC[gUnknown_0203CEC8.unk9].unk8); + PutWindowTilemap(gUnknown_0203CEDC[gUnknown_0203CEC8.unkA].unk8); + schedule_bg_copy_tilemap_to_vram(0); + Free(gUnknown_0203CEF0); + Free(gUnknown_0203CEF4); + sub_81B407C(taskId); + } + else + { + data[8] += data[10]; + data[9] += data[11]; + if (data[8] == 0) + data[10] = 0; + if (data[9] == 0) + data[11] = 0; + } +} + +void oamt_swap_pos(u8 *spriteIdPtr1, u8 *spriteIdPtr2) +{ + u8 spriteIdBuffer = *spriteIdPtr1; + u16 xBuffer1, yBuffer1, xBuffer2, yBuffer2; + + *spriteIdPtr1 = *spriteIdPtr2; + *spriteIdPtr2 = spriteIdBuffer; + xBuffer1 = gSprites[*spriteIdPtr1].pos1.x; + yBuffer1 = gSprites[*spriteIdPtr1].pos1.y; + xBuffer2 = gSprites[*spriteIdPtr1].pos2.x; + yBuffer2 = gSprites[*spriteIdPtr1].pos2.y; + gSprites[*spriteIdPtr1].pos1.x = gSprites[*spriteIdPtr2].pos1.x; + gSprites[*spriteIdPtr1].pos1.y = gSprites[*spriteIdPtr2].pos1.y; + gSprites[*spriteIdPtr1].pos2.x = gSprites[*spriteIdPtr2].pos2.x; + gSprites[*spriteIdPtr1].pos2.y = gSprites[*spriteIdPtr2].pos2.y; + gSprites[*spriteIdPtr2].pos1.x = xBuffer1; + gSprites[*spriteIdPtr2].pos1.y = yBuffer1; + gSprites[*spriteIdPtr2].pos2.x = xBuffer2; + gSprites[*spriteIdPtr2].pos2.y = yBuffer2; +} + +void swap_pokemon_and_oams(void) +{ + struct Unk_203CEDC *structPtrs[2]; + struct Pokemon *mon1, *mon2; + struct Pokemon *monBuffer; + + structPtrs[0] = &gUnknown_0203CEDC[gUnknown_0203CEC8.unk9]; + structPtrs[1] = &gUnknown_0203CEDC[gUnknown_0203CEC8.unkA]; + mon1 = &gPlayerParty[gUnknown_0203CEC8.unk9]; + mon2 = &gPlayerParty[gUnknown_0203CEC8.unkA]; + monBuffer = Alloc(sizeof(struct Pokemon)); + *monBuffer = *mon1; + *mon1 = *mon2; + *mon2 = *monBuffer; + Free(monBuffer); + oamt_swap_pos(&structPtrs[0]->unkB, &structPtrs[1]->unkB); + oamt_swap_pos(&structPtrs[0]->unkA, &structPtrs[1]->unkA); + oamt_swap_pos(&structPtrs[0]->unk9, &structPtrs[1]->unk9); + oamt_swap_pos(&structPtrs[0]->unkC, &structPtrs[1]->unkC); +} + +void sub_81B407C(u8 taskId) +{ + sub_81B302C(&gUnknown_0203CEC4->unkC[1]); + gUnknown_0203CEC8.unkB = 0; + sub_81B0FCC(gUnknown_0203CEC8.unk9, 0); + gUnknown_0203CEC8.unk9 = gUnknown_0203CEC8.unkA; + sub_81B0FCC(gUnknown_0203CEC8.unkA, 1); + display_pokemon_menu_message(0); + gTasks[taskId].func = sub_81B1370; +} + +void brm_cancel_1(u8 taskId) +{ + PlaySE(SE_SELECT); + sub_81B302C(&gUnknown_0203CEC4->unkC[0]); + sub_81B302C(&gUnknown_0203CEC4->unkC[1]); + if (gUnknown_0203CEC8.unk8_0 == 6) + display_pokemon_menu_message(15); + else + display_pokemon_menu_message(0); + gTasks[taskId].func = sub_81B1370; +}