diff --git a/asm/pokenav_unk_9.s b/asm/pokenav_unk_9.s deleted file mode 100644 index 5a91510fd..000000000 --- a/asm/pokenav_unk_9.s +++ /dev/null @@ -1,1194 +0,0 @@ - .include "asm/macros.inc" - .include "constants/constants.inc" - - .syntax unified - -@ File centered around AllocSubstruct(9) - - - - thumb_func_start sub_81CFB28 -sub_81CFB28: @ 81CFB28 - push {lr} - movs r0, 0x9 - bl GetSubstructPtr - ldr r0, [r0, 0x1C] - adds r0, 0x4 - pop {r1} - bx r1 - thumb_func_end sub_81CFB28 - - thumb_func_start sub_81CFB38 -sub_81CFB38: @ 81CFB38 - push {lr} - movs r0, 0x9 - bl GetSubstructPtr - ldr r0, [r0, 0x1C] - ldrh r0, [r0] - pop {r1} - bx r1 - thumb_func_end sub_81CFB38 - - thumb_func_start sub_81CFB48 -sub_81CFB48: @ 81CFB48 - push {r4,lr} - movs r0, 0x9 - bl GetSubstructPtr - adds r4, r0, 0 - bl GetSelectedMatchCall - ldr r1, [r4, 0x1C] - lsls r0, 2 - adds r1, r0 - ldrh r0, [r1, 0x6] - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_81CFB48 - - thumb_func_start sub_81CFB64 -sub_81CFB64: @ 81CFB64 - push {lr} - movs r0, 0x9 - bl GetSubstructPtr - ldr r0, [r0, 0x1C] - ldrh r0, [r0, 0x2] - pop {r1} - bx r1 - thumb_func_end sub_81CFB64 - - thumb_func_start sub_81CFB74 -sub_81CFB74: @ 81CFB74 - push {lr} - ldr r2, =gUnknown_086235D8 - lsls r1, r0, 2 - adds r1, r2 - ldr r1, [r1] - bl _call_via_r1 - pop {r1} - bx r1 - .pool - thumb_func_end sub_81CFB74 - - thumb_func_start sub_81CFB8C -sub_81CFB8C: @ 81CFB8C - push {r4-r6,lr} - sub sp, 0x4 - movs r0, 0x9 - bl GetSubstructPtr - adds r6, r0, 0 - ldr r0, [r6, 0x1C] - movs r1, 0 - strh r1, [r0] - ldr r0, [r6, 0x1C] - strh r1, [r0, 0x2] - ldr r1, =0xffffff00 - ldr r0, [sp] - ands r0, r1 - movs r1, 0xE - orrs r0, r1 - str r0, [sp] - movs r5, 0 -_081CFBB0: - movs r0, 0x64 - adds r1, r5, 0 - muls r1, r0 - ldr r0, =gPlayerParty - adds r4, r1, r0 - adds r0, r4, 0 - movs r1, 0x5 - bl GetMonData - cmp r0, 0 - beq _081CFC10 - adds r0, r4, 0 - movs r1, 0x6 - bl GetMonData - cmp r0, 0 - bne _081CFC0A - adds r0, r4, 0 - movs r1, 0x4 - bl GetMonData - cmp r0, 0 - bne _081CFC0A - adds r0, r4, 0 - movs r1, 0x52 - bl GetMonData - adds r3, r0, 0 - cmp r3, 0 - beq _081CFC0A - lsls r1, r5, 24 - lsrs r1, 16 - ldr r2, =0xffff00ff - ldr r0, [sp] - ands r0, r2 - orrs r0, r1 - lsls r2, r3, 16 - ldr r1, =0x0000ffff - ands r0, r1 - orrs r0, r2 - str r0, [sp] - adds r0, r6, 0 - mov r1, sp - bl sub_81CFCEC -_081CFC0A: - adds r5, 0x1 - cmp r5, 0x5 - ble _081CFBB0 -_081CFC10: - movs r0, 0x1 - add sp, 0x4 - pop {r4-r6} - pop {r1} - bx r1 - .pool - thumb_func_end sub_81CFB8C - - thumb_func_start sub_81CFC2C -sub_81CFC2C: @ 81CFC2C - push {lr} - movs r0, 0x9 - bl GetSubstructPtr - movs r1, 0 - str r1, [r0, 0x10] - str r1, [r0, 0xC] - movs r0, 0x1 - pop {r1} - bx r1 - thumb_func_end sub_81CFC2C - - thumb_func_start sub_81CFC40 -sub_81CFC40: @ 81CFC40 - push {r4-r7,lr} - mov r7, r9 - mov r6, r8 - push {r6,r7} - sub sp, 0x4 - movs r0, 0x9 - bl GetSubstructPtr - mov r8, r0 - ldr r7, [r0, 0xC] - ldr r6, [r0, 0x10] - movs r0, 0 - mov r9, r0 - cmp r7, 0xD - bgt _081CFCD4 - b _081CFCC8 -_081CFC60: - adds r0, r7, 0 - adds r1, r6, 0 - bl CheckBoxMonSanityAt - cmp r0, 0 - beq _081CFCA6 - lsls r0, r7, 24 - lsrs r5, r0, 24 - lsls r0, r6, 24 - lsrs r4, r0, 24 - adds r0, r5, 0 - adds r1, r4, 0 - movs r2, 0x52 - bl GetBoxMonDataAt - adds r3, r0, 0 - cmp r3, 0 - beq _081CFCA6 - ldr r1, =0xffffff00 - ldr r0, [sp] - ands r0, r1 - orrs r0, r5 - lsls r2, r4, 8 - ldr r1, =0xffff00ff - ands r0, r1 - orrs r0, r2 - lsls r2, r3, 16 - ldr r1, =0x0000ffff - ands r0, r1 - orrs r0, r2 - str r0, [sp] - mov r0, r8 - mov r1, sp - bl sub_81CFCEC -_081CFCA6: - movs r1, 0x1 - add r9, r1 - adds r6, 0x1 - mov r0, r9 - cmp r0, 0xE - ble _081CFCC8 - mov r1, r8 - str r7, [r1, 0xC] - str r6, [r1, 0x10] - movs r0, 0x3 - b _081CFCDC - .pool -_081CFCC8: - cmp r6, 0x1D - ble _081CFC60 - movs r6, 0 - adds r7, 0x1 - cmp r7, 0xD - ble _081CFCC8 -_081CFCD4: - movs r0, 0x1 - mov r1, r8 - str r0, [r1, 0x14] - movs r0, 0x4 -_081CFCDC: - add sp, 0x4 - pop {r3,r4} - mov r8, r3 - mov r9, r4 - pop {r4-r7} - pop {r1} - bx r1 - thumb_func_end sub_81CFC40 - - thumb_func_start sub_81CFCEC -sub_81CFCEC: @ 81CFCEC - push {r4-r7,lr} - adds r5, r0, 0 - adds r7, r1, 0 - movs r1, 0 - ldr r0, [r5, 0x1C] - ldrh r2, [r0] - lsrs r3, r2, 1 - cmp r2, r3 - beq _081CFD1C - adds r6, r0, 0 - ldrh r4, [r7, 0x2] -_081CFD02: - lsls r0, r3, 2 - adds r0, r6, r0 - ldrh r0, [r0, 0x6] - cmp r4, r0 - bls _081CFD10 - adds r2, r3, 0 - b _081CFD12 -_081CFD10: - adds r1, r3, 0x1 -_081CFD12: - subs r0, r2, r1 - lsrs r0, 1 - adds r3, r1, r0 - cmp r2, r3 - bne _081CFD02 -_081CFD1C: - ldr r0, [r5, 0x1C] - ldrh r2, [r0] - lsls r6, r3, 2 - cmp r2, r3 - bls _081CFD40 - lsls r0, r2, 2 - subs r4, r0, 0x4 -_081CFD2A: - ldr r0, [r5, 0x1C] - lsls r1, r2, 2 - adds r0, 0x4 - adds r1, r0, r1 - adds r0, r4 - ldr r0, [r0] - str r0, [r1] - subs r4, 0x4 - subs r2, 0x1 - cmp r2, r3 - bhi _081CFD2A -_081CFD40: - ldr r0, [r5, 0x1C] - adds r0, 0x4 - adds r0, r6 - ldr r1, [r7] - str r1, [r0] - ldr r1, [r5, 0x1C] - ldrh r0, [r1] - adds r0, 0x1 - strh r0, [r1] - pop {r4-r7} - pop {r0} - bx r0 - thumb_func_end sub_81CFCEC - - thumb_func_start sub_81CFD58 -sub_81CFD58: @ 81CFD58 - push {r4-r6,lr} - movs r5, 0 -_081CFD5C: - movs r0, 0x64 - adds r1, r5, 0 - muls r1, r0 - ldr r0, =gPlayerParty - adds r4, r1, r0 - adds r0, r4, 0 - movs r1, 0x5 - bl GetMonData - cmp r0, 0 - beq _081CFD8A - adds r0, r4, 0 - movs r1, 0x6 - bl GetMonData - cmp r0, 0 - bne _081CFD8A - adds r0, r4, 0 - movs r1, 0x53 - bl GetMonData - cmp r0, 0 - bne _081CFDB2 -_081CFD8A: - adds r5, 0x1 - cmp r5, 0x5 - ble _081CFD5C - movs r5, 0 -_081CFD92: - movs r4, 0 - lsls r6, r5, 24 -_081CFD96: - adds r0, r5, 0 - adds r1, r4, 0 - bl CheckBoxMonSanityAt - cmp r0, 0 - beq _081CFDBC - lsls r1, r4, 24 - lsrs r1, 24 - lsrs r0, r6, 24 - movs r2, 0x53 - bl GetBoxMonDataAt - cmp r0, 0 - beq _081CFDBC -_081CFDB2: - movs r0, 0x1 - b _081CFDCA - .pool -_081CFDBC: - adds r4, 0x1 - cmp r4, 0x1D - ble _081CFD96 - adds r5, 0x1 - cmp r5, 0xD - ble _081CFD92 - movs r0, 0 -_081CFDCA: - pop {r4-r6} - pop {r1} - bx r1 - thumb_func_end sub_81CFD58 - - thumb_func_start sub_81CFDD0 -sub_81CFDD0: @ 81CFDD0 - push {r4,lr} - movs r1, 0x81 - lsls r1, 4 - movs r0, 0xA - bl AllocSubstruct - adds r4, r0, 0 - cmp r4, 0 - beq _081CFE00 - ldr r0, =sub_81CFEB8 - movs r1, 0x1 - bl CreateLoopedTask - str r0, [r4, 0x4] - ldr r0, =sub_81CFE84 - str r0, [r4] - movs r0, 0 - str r0, [r4, 0xC] - movs r0, 0x1 - b _081CFE02 - .pool -_081CFE00: - movs r0, 0 -_081CFE02: - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_81CFDD0 - - thumb_func_start sub_81CFE08 -sub_81CFE08: @ 81CFE08 - push {r4,lr} - movs r1, 0x81 - lsls r1, 4 - movs r0, 0xA - bl AllocSubstruct - adds r4, r0, 0 - cmp r4, 0 - beq _081CFE38 - ldr r0, =sub_81CFEB8 - movs r1, 0x1 - bl CreateLoopedTask - str r0, [r4, 0x4] - ldr r0, =sub_81CFE84 - str r0, [r4] - movs r0, 0x1 - str r0, [r4, 0xC] - b _081CFE3A - .pool -_081CFE38: - movs r0, 0 -_081CFE3A: - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_81CFE08 - - thumb_func_start sub_81CFE40 -sub_81CFE40: @ 81CFE40 - push {r4,r5,lr} - adds r4, r0, 0 - movs r0, 0xA - bl GetSubstructPtr - adds r5, r0, 0 - ldr r0, =gUnknown_086237B8 - lsls r4, 2 - adds r4, r0 - ldr r0, [r4] - movs r1, 0x1 - bl CreateLoopedTask - str r0, [r5, 0x4] - ldr r0, =sub_81CFE84 - str r0, [r5] - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81CFE40 - - thumb_func_start sub_81CFE70 -sub_81CFE70: @ 81CFE70 - push {lr} - movs r0, 0xA - bl GetSubstructPtr - ldr r0, [r0] - bl _call_via_r0 - pop {r1} - bx r1 - thumb_func_end sub_81CFE70 - - thumb_func_start sub_81CFE84 -sub_81CFE84: @ 81CFE84 - push {lr} - movs r0, 0xA - bl GetSubstructPtr - ldr r0, [r0, 0x4] - bl IsLoopedTaskActive - pop {r1} - bx r1 - thumb_func_end sub_81CFE84 - - thumb_func_start sub_81CFE98 -sub_81CFE98: @ 81CFE98 - push {r4,lr} - movs r0, 0xA - bl GetSubstructPtr - adds r4, r0, 0 - bl sub_81C8234 - ldrb r0, [r4, 0x8] - bl RemoveWindow - movs r0, 0xA - bl FreePokenavSubstruct - pop {r4} - pop {r0} - bx r0 - thumb_func_end sub_81CFE98 - - thumb_func_start sub_81CFEB8 -sub_81CFEB8: @ 81CFEB8 - push {r4,r5,lr} - sub sp, 0x4 - adds r4, r0, 0 - movs r0, 0xA - bl GetSubstructPtr - adds r5, r0, 0 - cmp r4, 0x5 - bls _081CFECC - b _081CFFF2 -_081CFECC: - lsls r0, r4, 2 - ldr r1, =_081CFEDC - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .pool - .align 2, 0 -_081CFEDC: - .4byte _081CFEF4 - .4byte _081CFF48 - .4byte _081CFF76 - .4byte _081CFF94 - .4byte _081CFFA4 - .4byte _081CFFDE -_081CFEF4: - ldr r0, =gUnknown_086237B0 - movs r1, 0x2 - bl InitBgTemplates - ldr r1, =gUnknown_08623604 - movs r0, 0 - str r0, [sp] - movs r0, 0x1 - movs r2, 0 - movs r3, 0 - bl decompress_and_copy_tile_data_to_vram - adds r1, r5, 0 - adds r1, 0x10 - movs r0, 0x1 - bl SetBgTilemapBuffer - ldr r1, =gUnknown_086236CC - movs r0, 0x1 - movs r2, 0 - movs r3, 0 - bl CopyToBgTilemapBuffer - ldr r0, =gUnknown_086235E4 - movs r1, 0x10 - movs r2, 0x20 - bl CopyPaletteIntoBufferUnfaded - movs r0, 0x1 - bl CopyBgTilemapBufferToVram -_081CFF32: - movs r0, 0 - b _081CFFF4 - .pool -_081CFF48: - bl free_temp_tile_data_buffers_if_possible - lsls r0, 24 - cmp r0, 0 - bne _081CFFEE - bl sub_81CFB18 - cmp r0, 0 - beq _081CFFEE - movs r0, 0x1 - movs r1, 0 - movs r2, 0 - bl ChangeBgX - movs r0, 0x1 - movs r1, 0 - movs r2, 0 - bl ChangeBgY - movs r0, 0x1 - bl ShowBg - b _081CFF32 -_081CFF76: - bl free_temp_tile_data_buffers_if_possible - lsls r0, 24 - cmp r0, 0 - bne _081CFFEE - ldr r0, =gUnknown_08623790 - movs r1, 0x20 - movs r2, 0x20 - bl CopyPaletteIntoBufferUnfaded - bl sub_81D0304 - b _081CFF32 - .pool -_081CFF94: - bl sub_81C8224 - cmp r0, 0 - bne _081CFFEE - adds r0, r5, 0 - bl sub_81D024C - b _081CFF32 -_081CFFA4: - bl free_temp_tile_data_buffers_if_possible - lsls r0, 24 - cmp r0, 0 - bne _081CFFEE - movs r0, 0x2 - bl ShowBg - movs r0, 0x3 - bl HideBg - movs r0, 0x9 - bl sub_81C7BA4 - movs r0, 0x1 - bl sub_81C7AC0 - ldr r0, [r5, 0xC] - cmp r0, 0 - bne _081CFF32 - movs r0, 0x2 - bl LoadLeftHeaderGfxForIndex - movs r0, 0x2 - movs r1, 0x1 - movs r2, 0 - bl sub_81C7FA0 - b _081CFF32 -_081CFFDE: - bl IsPaletteFadeActive - cmp r0, 0 - bne _081CFFEE - bl sub_81C8010 - cmp r0, 0 - beq _081CFFF2 -_081CFFEE: - movs r0, 0x2 - b _081CFFF4 -_081CFFF2: - movs r0, 0x4 -_081CFFF4: - add sp, 0x4 - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_81CFEB8 - - thumb_func_start sub_81CFFFC -sub_81CFFFC: @ 81CFFFC - push {r4,r5,lr} - adds r4, r0, 0 - movs r0, 0xA - bl GetSubstructPtr - adds r5, r0, 0 - cmp r4, 0x1 - beq _081D004A - cmp r4, 0x1 - bgt _081D0016 - cmp r4, 0 - beq _081D0020 - b _081D006A -_081D0016: - cmp r4, 0x2 - beq _081D0052 - cmp r4, 0x3 - beq _081D005C - b _081D006A -_081D0020: - bl MatchCall_MoveCursorUp - cmp r0, 0x1 - beq _081D0038 - cmp r0, 0x1 - bgt _081D0032 - cmp r0, 0 - beq _081D006A - b _081D0058 -_081D0032: - cmp r0, 0x2 - beq _081D0042 - b _081D0058 -_081D0038: - movs r0, 0x5 - bl PlaySE - movs r0, 0x7 - b _081D006C -_081D0042: - movs r0, 0x5 - bl PlaySE - b _081D0058 -_081D004A: - bl sub_81C8630 - cmp r0, 0 - bne _081D0066 -_081D0052: - adds r0, r5, 0 - bl sub_81D0288 -_081D0058: - movs r0, 0 - b _081D006C -_081D005C: - bl IsDma3ManagerBusyWithBgCopy - lsls r0, 24 - cmp r0, 0 - beq _081D006A -_081D0066: - movs r0, 0x2 - b _081D006C -_081D006A: - movs r0, 0x4 -_081D006C: - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_81CFFFC - - thumb_func_start sub_81D0074 -sub_81D0074: @ 81D0074 - push {r4,r5,lr} - adds r4, r0, 0 - movs r0, 0xA - bl GetSubstructPtr - adds r5, r0, 0 - cmp r4, 0x1 - beq _081D00C2 - cmp r4, 0x1 - bgt _081D008E - cmp r4, 0 - beq _081D0098 - b _081D00E2 -_081D008E: - cmp r4, 0x2 - beq _081D00CA - cmp r4, 0x3 - beq _081D00D4 - b _081D00E2 -_081D0098: - bl MatchCall_MoveCursorDown - cmp r0, 0x1 - beq _081D00B0 - cmp r0, 0x1 - bgt _081D00AA - cmp r0, 0 - beq _081D00E2 - b _081D00D0 -_081D00AA: - cmp r0, 0x2 - beq _081D00BA - b _081D00D0 -_081D00B0: - movs r0, 0x5 - bl PlaySE - movs r0, 0x7 - b _081D00E4 -_081D00BA: - movs r0, 0x5 - bl PlaySE - b _081D00D0 -_081D00C2: - bl sub_81C8630 - cmp r0, 0 - bne _081D00DE -_081D00CA: - adds r0, r5, 0 - bl sub_81D0288 -_081D00D0: - movs r0, 0 - b _081D00E4 -_081D00D4: - bl IsDma3ManagerBusyWithBgCopy - lsls r0, 24 - cmp r0, 0 - beq _081D00E2 -_081D00DE: - movs r0, 0x2 - b _081D00E4 -_081D00E2: - movs r0, 0x4 -_081D00E4: - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_81D0074 - - thumb_func_start sub_81D00EC -sub_81D00EC: @ 81D00EC - push {r4,r5,lr} - adds r4, r0, 0 - movs r0, 0xA - bl GetSubstructPtr - adds r5, r0, 0 - cmp r4, 0x1 - beq _081D013A - cmp r4, 0x1 - bgt _081D0106 - cmp r4, 0 - beq _081D0110 - b _081D015A -_081D0106: - cmp r4, 0x2 - beq _081D0142 - cmp r4, 0x3 - beq _081D014C - b _081D015A -_081D0110: - bl MatchCall_PageUp - cmp r0, 0x1 - beq _081D0128 - cmp r0, 0x1 - bgt _081D0122 - cmp r0, 0 - beq _081D015A - b _081D0148 -_081D0122: - cmp r0, 0x2 - beq _081D0132 - b _081D0148 -_081D0128: - movs r0, 0x5 - bl PlaySE - movs r0, 0x7 - b _081D015C -_081D0132: - movs r0, 0x5 - bl PlaySE - b _081D0148 -_081D013A: - bl sub_81C8630 - cmp r0, 0 - bne _081D0156 -_081D0142: - adds r0, r5, 0 - bl sub_81D0288 -_081D0148: - movs r0, 0 - b _081D015C -_081D014C: - bl IsDma3ManagerBusyWithBgCopy - lsls r0, 24 - cmp r0, 0 - beq _081D015A -_081D0156: - movs r0, 0x2 - b _081D015C -_081D015A: - movs r0, 0x4 -_081D015C: - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_81D00EC - - thumb_func_start sub_81D0164 -sub_81D0164: @ 81D0164 - push {r4,r5,lr} - adds r4, r0, 0 - movs r0, 0xA - bl GetSubstructPtr - adds r5, r0, 0 - cmp r4, 0x1 - beq _081D01B2 - cmp r4, 0x1 - bgt _081D017E - cmp r4, 0 - beq _081D0188 - b _081D01D2 -_081D017E: - cmp r4, 0x2 - beq _081D01BA - cmp r4, 0x3 - beq _081D01C4 - b _081D01D2 -_081D0188: - bl MatchCall_PageDown - cmp r0, 0x1 - beq _081D01A0 - cmp r0, 0x1 - bgt _081D019A - cmp r0, 0 - beq _081D01D2 - b _081D01C0 -_081D019A: - cmp r0, 0x2 - beq _081D01AA - b _081D01C0 -_081D01A0: - movs r0, 0x5 - bl PlaySE - movs r0, 0x7 - b _081D01D4 -_081D01AA: - movs r0, 0x5 - bl PlaySE - b _081D01C0 -_081D01B2: - bl sub_81C8630 - cmp r0, 0 - bne _081D01CE -_081D01BA: - adds r0, r5, 0 - bl sub_81D0288 -_081D01C0: - movs r0, 0 - b _081D01D4 -_081D01C4: - bl IsDma3ManagerBusyWithBgCopy - lsls r0, 24 - cmp r0, 0 - beq _081D01D2 -_081D01CE: - movs r0, 0x2 - b _081D01D4 -_081D01D2: - movs r0, 0x4 -_081D01D4: - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_81D0164 - - thumb_func_start sub_81D01DC -sub_81D01DC: @ 81D01DC - push {lr} - cmp r0, 0 - beq _081D01E8 - cmp r0, 0x1 - beq _081D01FC - b _081D0214 -_081D01E8: - movs r0, 0x5 - bl PlaySE - movs r0, 0 - bl sub_81C7AC0 - bl sub_81C78A0 - movs r0, 0 - b _081D0216 -_081D01FC: - bl IsPaletteFadeActive - cmp r0, 0 - bne _081D020C - bl MainMenuLoopedTaskIsBusy - cmp r0, 0 - beq _081D0210 -_081D020C: - movs r0, 0x2 - b _081D0216 -_081D0210: - bl sub_81C7FDC -_081D0214: - movs r0, 0x4 -_081D0216: - pop {r1} - bx r1 - thumb_func_end sub_81D01DC - - thumb_func_start sub_81D021C -sub_81D021C: @ 81D021C - push {lr} - cmp r0, 0 - beq _081D0228 - cmp r0, 0x1 - beq _081D0238 - b _081D0244 -_081D0228: - movs r0, 0x5 - bl PlaySE - movs r0, 0 - bl sub_81C7AC0 - movs r0, 0 - b _081D0246 -_081D0238: - bl IsPaletteFadeActive - cmp r0, 0 - beq _081D0244 - movs r0, 0x2 - b _081D0246 -_081D0244: - movs r0, 0x4 -_081D0246: - pop {r1} - bx r1 - thumb_func_end sub_81D021C - - thumb_func_start sub_81D024C -sub_81D024C: @ 81D024C - push {r4,lr} - adds r4, r0, 0 - ldr r0, =gUnknown_086237D4 - bl AddWindow - strh r0, [r4, 0x8] - lsls r0, 24 - lsrs r0, 24 - bl PutWindowTilemap - bl sub_81CFB38 - adds r2, r0, 0 - ldrh r0, [r4, 0x8] - movs r1, 0 - bl sub_81D02B0 - ldrb r0, [r4, 0x8] - movs r1, 0x1 - bl CopyWindowToVram - adds r0, r4, 0 - bl sub_81D0288 - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81D024C - - thumb_func_start sub_81D0288 -sub_81D0288: @ 81D0288 - push {r4,r5,lr} - adds r5, r0, 0 - bl GetSelectedMatchCall - adds r4, r0, 0 - bl sub_81CFB38 - adds r2, r0, 0 - ldrh r0, [r5, 0x8] - adds r4, 0x1 - adds r1, r4, 0 - bl sub_81D02B0 - ldrb r0, [r5, 0x8] - movs r1, 0x2 - bl CopyWindowToVram - pop {r4,r5} - pop {r0} - bx r0 - thumb_func_end sub_81D0288 - - thumb_func_start sub_81D02B0 -sub_81D02B0: @ 81D02B0 - push {r4,r5,lr} - sub sp, 0x1C - adds r4, r0, 0 - adds r5, r2, 0 - add r0, sp, 0xC - movs r2, 0x1 - movs r3, 0x3 - bl ConvertIntToDecimalStringN - movs r1, 0xBA - strb r1, [r0] - adds r0, 0x1 - adds r1, r5, 0 - movs r2, 0x1 - movs r3, 0x3 - bl ConvertIntToDecimalStringN - movs r0, 0x1 - add r1, sp, 0xC - movs r2, 0x38 - bl GetStringCenterAlignXOffset - adds r3, r0, 0 - lsls r4, 24 - lsrs r4, 24 - lsls r3, 24 - lsrs r3, 24 - movs r0, 0x1 - str r0, [sp] - movs r0, 0xFF - str r0, [sp, 0x4] - movs r0, 0 - str r0, [sp, 0x8] - adds r0, r4, 0 - movs r1, 0x1 - add r2, sp, 0xC - bl AddTextPrinterParameterized - add sp, 0x1C - pop {r4,r5} - pop {r0} - bx r0 - thumb_func_end sub_81D02B0 - - thumb_func_start sub_81D0304 -sub_81D0304: @ 81D0304 - push {r4,lr} - sub sp, 0x18 - bl sub_81CFB28 - str r0, [sp] - bl sub_81CFB38 - mov r1, sp - movs r4, 0 - strh r0, [r1, 0x4] - movs r0, 0x4 - strb r0, [r1, 0x8] - bl sub_81CFB64 - mov r1, sp - strh r0, [r1, 0x6] - movs r0, 0xD - strb r0, [r1, 0x9] - movs r0, 0x11 - strb r0, [r1, 0xA] - mov r0, sp - movs r2, 0x1 - strb r2, [r0, 0xB] - movs r0, 0x8 - strb r0, [r1, 0xC] - movs r0, 0x2 - strb r0, [r1, 0xD] - mov r0, sp - strb r2, [r0, 0xE] - ldr r0, =sub_81D035C - str r0, [sp, 0x10] - str r4, [sp, 0x14] - ldr r0, =gUnknown_086237B4 - movs r2, 0 - bl sub_81C81D4 - add sp, 0x18 - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81D0304 - - thumb_func_start sub_81D035C -sub_81D035C: @ 81D035C - push {r4-r7,lr} - mov r7, r8 - push {r7} - adds r6, r1, 0 - adds r7, r0, 0 - ldrb r0, [r7] - cmp r0, 0xE - bne _081D03A4 - ldrb r1, [r7, 0x1] - movs r0, 0x64 - adds r4, r1, 0 - muls r4, r0 - ldr r0, =gPlayerParty - adds r4, r0 - adds r0, r4, 0 - bl GetMonGender - lsls r0, 24 - lsrs r5, r0, 24 - adds r0, r4, 0 - bl GetLevelFromMonExp - lsls r0, 24 - lsrs r0, 24 - mov r8, r0 - ldr r2, =gStringVar3 - adds r0, r4, 0 - movs r1, 0x2 - bl GetMonData - b _081D03CC - .pool -_081D03A4: - ldrb r0, [r7] - ldrb r1, [r7, 0x1] - bl GetBoxedMonPtr - adds r4, r0, 0 - bl GetBoxMonGender - lsls r0, 24 - lsrs r5, r0, 24 - adds r0, r4, 0 - bl GetLevelFromBoxMonExp - lsls r0, 24 - lsrs r0, 24 - mov r8, r0 - ldr r2, =gStringVar3 - adds r0, r4, 0 - movs r1, 0x2 - bl GetBoxMonData -_081D03CC: - ldr r4, =gStringVar3 - adds r0, r4, 0 - bl StringGetEnd10 - adds r0, r6, 0 - movs r1, 0x1 - adds r2, r4, 0 - movs r3, 0x3C - bl sub_81DB494 - adds r6, r0, 0 - cmp r5, 0 - beq _081D03F8 - cmp r5, 0xFE - beq _081D0400 - ldr r1, =gUnknown_086237F4 - b _081D0402 - .pool -_081D03F8: - ldr r1, =gUnknown_086237DC - b _081D0402 - .pool -_081D0400: - ldr r1, =gUnknown_086237E8 -_081D0402: - ldr r4, =gStringVar1 - adds r0, r4, 0 - bl StringCopy - movs r1, 0xBA - strb r1, [r0] - adds r0, 0x1 - movs r1, 0xF9 - strb r1, [r0] - adds r0, 0x1 - movs r1, 0x5 - strb r1, [r0] - adds r0, 0x1 - mov r1, r8 - movs r2, 0 - movs r3, 0x3 - bl ConvertIntToDecimalStringN - adds r0, r6, 0 - movs r1, 0x1 - adds r2, r4, 0 - movs r3, 0x36 - bl sub_81DB494 - adds r6, r0, 0 - ldrh r1, [r7, 0x2] - movs r2, 0x1 - movs r3, 0x2 - bl ConvertIntToDecimalStringN - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81D035C - - .align 2, 0 @ Don't pad with nop. diff --git a/ld_script.txt b/ld_script.txt index 339855e23..8d451338c 100644 --- a/ld_script.txt +++ b/ld_script.txt @@ -317,7 +317,6 @@ SECTIONS { src/pokenav_unk_7.o(.text); src/pokenav_unk_8.o(.text); src/pokenav_unk_9.o(.text); - asm/pokenav_unk_9.o(.text); src/pokenav_unk_10.o(.text); src/pokenav_match_call_data.o(.text); src/menu_specialized.o(.text); diff --git a/src/pokenav_unk_8.c b/src/pokenav_unk_8.c index a758c59f5..e07cba97c 100644 --- a/src/pokenav_unk_8.c +++ b/src/pokenav_unk_8.c @@ -387,7 +387,7 @@ bool32 sub_81CF3D0(void) return unk->callback(); } -static bool32 sub_81CF3E4(void) +bool32 sub_81CF3E4(void) { struct PokenavSub8 * unk = GetSubstructPtr(8); return IsLoopedTaskActive(unk->ltid); diff --git a/src/pokenav_unk_9.c b/src/pokenav_unk_9.c index 7feee3c1d..fdc4a3328 100644 --- a/src/pokenav_unk_9.c +++ b/src/pokenav_unk_9.c @@ -1,68 +1,91 @@ #include "global.h" #include "pokenav.h" #include "bg.h" +#include "menu.h" #include "window.h" +#include "sound.h" +#include "string_util.h" +#include "international_string_util.h" +#include "constants/songs.h" struct PokenavSub9 { u32 (*unk0)(struct PokenavSub9*); u32 loopedTaskId; - u8 filler[0xC]; + u16 winid; + s32 unkC; + s32 unk10; u32 unk14; u32 unk18; struct PokenavSub18 *unk1C; }; -u32 sub_81CFA68(struct PokenavSub9 *structPtr); -u32 sub_81CFA88(struct PokenavSub9 *structPtr); -u32 sub_81CFB08(struct PokenavSub9 *structPtr); -u32 sub_81CFB10(struct PokenavSub9 *structPtr); -u32 sub_81CFB8C(void); -u32 sub_81CFC2C(void); -u32 sub_81CFC40(void); -u32 sub_81CFB74(s32 state); -u32 sub_81CFFFC(s32 state); -u32 sub_81D0074(s32 state); -u32 sub_81D00EC(s32 state); -u32 sub_81D0164(s32 state); -u32 sub_81D01DC(s32 state); -u32 sub_81D021C(s32 state); +struct PokenavSub10 +{ + bool32 (*callback)(void); + u32 ltid; + u16 winid; + bool32 unkC; + u16 buff[0x400]; +}; -u32 (*const gUnknown_086235D8[])(void) = +static u32 sub_81CFA68(struct PokenavSub9 *structPtr); +static u32 sub_81CFA88(struct PokenavSub9 *structPtr); +static u32 sub_81CFB08(struct PokenavSub9 *structPtr); +static u32 sub_81CFB10(struct PokenavSub9 *structPtr); +static u32 sub_81CFB8C(s32 state); +static u32 sub_81CFC2C(s32 state); +static u32 sub_81CFC40(s32 state); +static u32 sub_81CFB74(s32 state); +static void sub_81CFCEC(struct PokenavSub9 *structPtr, struct PokenavMonList *item); +static u32 sub_81CFEB8(s32 state); +static bool32 sub_81CFE84(void); +static u32 sub_81CFFFC(s32 state); +static u32 sub_81D0074(s32 state); +static u32 sub_81D00EC(s32 state); +static u32 sub_81D0164(s32 state); +static u32 sub_81D01DC(s32 state); +static u32 sub_81D021C(s32 state); +static void sub_81D02B0(s32 windowId, s32 val1, s32 val2); +static void sub_81D024C(struct PokenavSub10 *ptr); +static void sub_81D0288(struct PokenavSub10 *ptr); +static void sub_81D0304(void); +static void sub_81D035C(struct PokenavMonList *, u8 *); + +static u32 (*const gUnknown_086235D8[])(s32 state) = { sub_81CFB8C, sub_81CFC2C, sub_81CFC40 }; -const u16 gUnknown_086235E4[] = INCBIN_U16("graphics/pokenav/ui_ribbons.gbapal"); -const u32 gUnknown_08623604[] = INCBIN_U32("graphics/pokenav/ui_ribbons.4bpp.lz"); -const u32 gUnknown_086236CC[] = INCBIN_U32("graphics/pokenav/ui_ribbons.bin.lz"); -const u16 gUnknown_08623790[] = INCBIN_U16("graphics/pokenav/8623790.gbapal"); +static const u16 gUnknown_086235E4[] = INCBIN_U16("graphics/pokenav/ui_ribbons.gbapal"); +static const u32 gUnknown_08623604[] = INCBIN_U32("graphics/pokenav/ui_ribbons.4bpp.lz"); +static const u32 gUnknown_086236CC[] = INCBIN_U32("graphics/pokenav/ui_ribbons.bin.lz"); +static const u16 gUnknown_08623790[] = INCBIN_U16("graphics/pokenav/8623790.gbapal"); -const struct BgTemplate gUnknown_086237B0 = +static const struct BgTemplate gUnknown_086237B0[] = { - .bg = 1, - .charBaseIndex = 1, - .mapBaseIndex = 0x06, - .screenSize = 0, - .paletteMode = 0, - .priority = 2, - .baseTile = 0 + { + .bg = 1, + .charBaseIndex = 1, + .mapBaseIndex = 0x06, + .screenSize = 0, + .paletteMode = 0, + .priority = 2, + .baseTile = 0 + }, { + .bg = 2, + .charBaseIndex = 2, + .mapBaseIndex = 0x07, + .screenSize = 0, + .paletteMode = 0, + .priority = 3, + .baseTile = 0 + } }; -const struct BgTemplate gUnknown_086237B4 = -{ - .bg = 2, - .charBaseIndex = 2, - .mapBaseIndex = 0x07, - .screenSize = 0, - .paletteMode = 0, - .priority = 3, - .baseTile = 0 -}; - -const LoopedTask gUnknown_086237B8[] = +static const LoopedTask gUnknown_086237B8[] = { NULL, sub_81CFFFC, @@ -73,7 +96,7 @@ const LoopedTask gUnknown_086237B8[] = sub_81D021C }; -const struct WindowTemplate gUnknown_086237D4 = +static const struct WindowTemplate gUnknown_086237D4 = { .bg = 1, .tilemapLeft = 1, @@ -84,9 +107,9 @@ const struct WindowTemplate gUnknown_086237D4 = .baseBlock = 20 }; -const u8 gUnknown_086237DC[] = _("{COLOR_HIGHLIGHT_SHADOW}{LIGHT_RED}{WHITE}{GREEN}♂{COLOR_HIGHLIGHT_SHADOW}{DARK_GREY}{WHITE}{LIGHT_GREY}"); -const u8 gUnknown_086237E8[] = _("{COLOR_HIGHLIGHT_SHADOW}{LIGHT_GREEN}{WHITE}{BLUE}♀{COLOR_HIGHLIGHT_SHADOW}{DARK_GREY}{WHITE}{LIGHT_GREY}"); -const u8 gUnknown_086237F4[] = _("{UNK_SPACER}"); +static const u8 gUnknown_086237DC[] = _("{COLOR_HIGHLIGHT_SHADOW}{LIGHT_RED}{WHITE}{GREEN}♂{COLOR_HIGHLIGHT_SHADOW}{DARK_GREY}{WHITE}{LIGHT_GREY}"); +static const u8 gUnknown_086237E8[] = _("{COLOR_HIGHLIGHT_SHADOW}{LIGHT_GREEN}{WHITE}{BLUE}♀{COLOR_HIGHLIGHT_SHADOW}{DARK_GREY}{WHITE}{LIGHT_GREY}"); +static const u8 gUnknown_086237F4[] = _("{UNK_SPACER}"); bool32 sub_81CF9BC(void) { @@ -130,14 +153,14 @@ void sub_81CFA48(void) FreePokenavSubstruct(9); } -u32 sub_81CFA68(struct PokenavSub9 *structPtr) +static u32 sub_81CFA68(struct PokenavSub9 *structPtr) { if (!IsLoopedTaskActive(structPtr->loopedTaskId)) structPtr->unk0 = sub_81CFA88; return 0; } -u32 sub_81CFA88(struct PokenavSub9 *structPtr) +static u32 sub_81CFA88(struct PokenavSub9 *structPtr) { if (gMain.newAndRepeatedKeys & DPAD_UP) return 1; @@ -163,18 +186,541 @@ u32 sub_81CFA88(struct PokenavSub9 *structPtr) return 0; } -u32 sub_81CFB08(struct PokenavSub9 *structPtr) +static u32 sub_81CFB08(struct PokenavSub9 *structPtr) { return 0x186a5; } -u32 sub_81CFB10(struct PokenavSub9 *structPtr) +static u32 sub_81CFB10(struct PokenavSub9 *structPtr) { return 0x186ad; } -u32 sub_81CFB18(void) +static u32 sub_81CFB18(void) { struct PokenavSub9 *structPtr = GetSubstructPtr(9); return structPtr->unk14; } + +static struct PokenavMonList * sub_81CFB28(void) +{ + struct PokenavSub9 * ptr = GetSubstructPtr(9); + return ptr->unk1C->unk4; +} + +static s32 sub_81CFB38(void) +{ + struct PokenavSub9 * ptr = GetSubstructPtr(9); + return ptr->unk1C->unk0; +} + +static s32 sub_81CFB48(void) +{ + struct PokenavSub9 * ptr = GetSubstructPtr(9); + s32 idx = GetSelectedMatchCall(); + return ptr->unk1C->unk4[idx].unk6; +} + +static s32 sub_81CFB64(void) +{ + struct PokenavSub9 * ptr = GetSubstructPtr(9); + return ptr->unk1C->unk2; +} + +static u32 sub_81CFB74(s32 state) +{ + return gUnknown_086235D8[state](state); +} + +static u32 sub_81CFB8C(s32 state) +{ + s32 i; + struct PokenavMonList item; + struct PokenavSub9 * ptr = GetSubstructPtr(9); + + ptr->unk1C->unk0 = 0; + ptr->unk1C->unk2 = 0; + item.boxId = 14; + for (i = 0; i < PARTY_SIZE; i++) + { + struct Pokemon * pokemon = &gPlayerParty[i]; + if (!GetMonData(pokemon, MON_DATA_SANITY_HAS_SPECIES)) + return LT_INC_AND_CONTINUE; + if (!GetMonData(pokemon, MON_DATA_SANITY_IS_EGG) && !GetMonData(pokemon, MON_DATA_SANITY_IS_BAD_EGG)) + { + u32 ribbonCount = GetMonData(pokemon, MON_DATA_RIBBON_COUNT); + if (ribbonCount != 0) + { + item.monId = i; + item.unk6 = ribbonCount; + sub_81CFCEC(ptr, &item); + } + } + } + + return LT_INC_AND_CONTINUE; +} + +static u32 sub_81CFC2C(s32 state) +{ + struct PokenavSub9 * ptr = GetSubstructPtr(9); + ptr->unk10 = 0; + ptr->unkC = 0; + return LT_INC_AND_CONTINUE; +} + +static u32 sub_81CFC40(s32 state) +{ + struct PokenavSub9 * ptr = GetSubstructPtr(9); + s32 boxId = ptr->unkC; + s32 monId = ptr->unk10; + s32 boxCount = 0; + struct PokenavMonList item; + + while (boxId < TOTAL_BOXES_COUNT) + { + while (monId < IN_BOX_COUNT) + { + if (CheckBoxMonSanityAt(boxId, monId)) + { + u32 ribbonCount = GetBoxMonDataAt(boxId, monId, MON_DATA_RIBBON_COUNT); + if (ribbonCount != 0) + { + item.boxId = boxId; + item.monId = monId; + item.unk6 = ribbonCount; + sub_81CFCEC(ptr, &item); + } + } + boxCount++; + monId++; + if (boxCount > 14) + { + ptr->unkC = boxId; + ptr->unk10 = monId; + return LT_CONTINUE; + } + } + monId = 0; + boxId++; + } + + ptr->unk14 = 1; + return LT_FINISH; +} + +static void sub_81CFCEC(struct PokenavSub9 *structPtr, struct PokenavMonList *item) +{ + u32 left = 0; + u32 right = structPtr->unk1C->unk0; + u32 insertionIdx = left + (right - left) / 2; + + while (right != insertionIdx) + { + if (item->unk6 > structPtr->unk1C->unk4[insertionIdx].unk6) + right = insertionIdx; + else + left = insertionIdx + 1; + insertionIdx = left + (right - left) / 2; + } + for (right = structPtr->unk1C->unk0; right > insertionIdx; right--) + structPtr->unk1C->unk4[right] = structPtr->unk1C->unk4[right - 1]; + structPtr->unk1C->unk4[insertionIdx] = *item; + structPtr->unk1C->unk0++; +} + +static bool32 sub_81CFD58(void) +{ + s32 i, j; + + for (i = 0; i < PARTY_SIZE; i++) + { + struct Pokemon * mon = &gPlayerParty[i]; + if (!GetMonData(mon, MON_DATA_SANITY_HAS_SPECIES)) + continue; + if (GetMonData(mon, MON_DATA_SANITY_IS_EGG)) + continue; + if (GetMonData(mon, MON_DATA_RIBBONS)) + return TRUE; + } + + for (i = 0; i < TOTAL_BOXES_COUNT; i++) + { + for (j = 0; j < IN_BOX_COUNT; j++) + { + if (!CheckBoxMonSanityAt(i, j)) + continue; + if (GetBoxMonDataAt(i, j, MON_DATA_RIBBONS)) + return TRUE; + } + } + + return FALSE; +} + +bool32 sub_81CFDD0(void) +{ + struct PokenavSub10 * ptr = AllocSubstruct(10, sizeof(struct PokenavSub10)); + if (ptr == NULL) + return FALSE; + ptr->ltid = CreateLoopedTask(sub_81CFEB8, 1); + ptr->callback = sub_81CFE84; + ptr->unkC = FALSE; + return TRUE; +} + +bool32 sub_81CFE08(void) +{ + struct PokenavSub10 * ptr = AllocSubstruct(10, sizeof(struct PokenavSub10)); + if (ptr == NULL) + return FALSE; + ptr->ltid = CreateLoopedTask(sub_81CFEB8, 1); + ptr->callback = sub_81CFE84; + ptr->unkC = TRUE; + return TRUE; +} + +void sub_81CFE40(s32 idx) +{ + struct PokenavSub10 * ptr = GetSubstructPtr(10); + ptr->ltid = CreateLoopedTask(gUnknown_086237B8[idx], 1); + ptr->callback = sub_81CFE84; +} + +bool32 sub_81CFE70(void) +{ + struct PokenavSub10 * ptr = GetSubstructPtr(10); + return ptr->callback(); +} + +bool32 sub_81CFE84(void) +{ + struct PokenavSub10 * ptr = GetSubstructPtr(10); + return IsLoopedTaskActive(ptr->ltid); +} + +void sub_81CFE98(void) +{ + struct PokenavSub10 * ptr = GetSubstructPtr(10); + sub_81C8234(); + RemoveWindow(ptr->winid); + FreePokenavSubstruct(10); +} + +static u32 sub_81CFEB8(s32 state) +{ + struct PokenavSub10 * unk = GetSubstructPtr(10); + switch (state) + { + case 0: + InitBgTemplates(gUnknown_086237B0, NELEMS(gUnknown_086237B0)); + decompress_and_copy_tile_data_to_vram(1, gUnknown_08623604, 0, 0, 0); + SetBgTilemapBuffer(1, unk->buff); + CopyToBgTilemapBuffer(1, gUnknown_086236CC, 0, 0); + CopyPaletteIntoBufferUnfaded(gUnknown_086235E4, 0x10, 0x20); + CopyBgTilemapBufferToVram(1); + return LT_INC_AND_PAUSE; + case 1: + if (free_temp_tile_data_buffers_if_possible()) + return LT_PAUSE; + if (!sub_81CFB18()) + return LT_PAUSE; + ChangeBgX(1, 0, 0); + ChangeBgY(1, 0, 0); + ShowBg(1); + return LT_INC_AND_PAUSE; + case 2: + if (free_temp_tile_data_buffers_if_possible()) + return LT_PAUSE; + CopyPaletteIntoBufferUnfaded(gUnknown_08623790, 0x20, 0x20); + sub_81D0304(); + return LT_INC_AND_PAUSE; + case 3: + if (sub_81C8224()) + return LT_PAUSE; + sub_81D024C(unk); + return LT_INC_AND_PAUSE; + case 4: + if (free_temp_tile_data_buffers_if_possible()) + return LT_PAUSE; + ShowBg(2); + HideBg(3); + sub_81C7BA4(9); + sub_81C7AC0(1); + if (!unk->unkC) + { + LoadLeftHeaderGfxForIndex(2); + sub_81C7FA0(2, 1, 0); + } + return LT_INC_AND_PAUSE; + case 5: + if (IsPaletteFadeActive()) + return LT_PAUSE; + if (sub_81C8010()) + return LT_PAUSE; + break; + } + return LT_FINISH; +} + +static u32 sub_81CFFFC(s32 state) +{ + struct PokenavSub10 * unk = GetSubstructPtr(10); + switch (state) + { + case 0: + switch (MatchCall_MoveCursorUp()) + { + case 0: + return LT_FINISH; + case 1: + PlaySE(SE_SELECT); + return LT_SET_STATE(2); + case 2: + PlaySE(SE_SELECT); + break; + } + return LT_INC_AND_PAUSE; + case 1: + if (sub_81C8630()) + return LT_PAUSE; + // fallthrough + case 2: + sub_81D0288(unk); + return LT_INC_AND_PAUSE; + case 3: + if (IsDma3ManagerBusyWithBgCopy()) + return LT_PAUSE; + break; + } + return LT_FINISH; +} + +static u32 sub_81D0074(s32 state) +{ + struct PokenavSub10 * unk = GetSubstructPtr(10); + switch (state) + { + case 0: + switch (MatchCall_MoveCursorDown()) + { + case 0: + return LT_FINISH; + case 1: + PlaySE(SE_SELECT); + return LT_SET_STATE(2); + case 2: + PlaySE(SE_SELECT); + break; + } + return LT_INC_AND_PAUSE; + case 1: + if (sub_81C8630()) + return LT_PAUSE; + // fallthrough + case 2: + sub_81D0288(unk); + return LT_INC_AND_PAUSE; + case 3: + if (IsDma3ManagerBusyWithBgCopy()) + return LT_PAUSE; + break; + } + return LT_FINISH; +} + +static u32 sub_81D00EC(s32 state) +{ + struct PokenavSub10 * unk = GetSubstructPtr(10); + switch (state) + { + case 0: + switch (MatchCall_PageUp()) + { + case 0: + return LT_FINISH; + case 1: + PlaySE(SE_SELECT); + return LT_SET_STATE(2); + case 2: + PlaySE(SE_SELECT); + break; + } + return LT_INC_AND_PAUSE; + case 1: + if (sub_81C8630()) + return LT_PAUSE; + // fallthrough + case 2: + sub_81D0288(unk); + return LT_INC_AND_PAUSE; + case 3: + if (IsDma3ManagerBusyWithBgCopy()) + return LT_PAUSE; + break; + } + return LT_FINISH; +} + +static u32 sub_81D0164(s32 state) +{ + struct PokenavSub10 * unk = GetSubstructPtr(10); + switch (state) + { + case 0: + switch (MatchCall_PageDown()) + { + case 0: + return LT_FINISH; + case 1: + PlaySE(SE_SELECT); + return LT_SET_STATE(2); + case 2: + PlaySE(SE_SELECT); + break; + } + return LT_INC_AND_PAUSE; + case 1: + if (sub_81C8630()) + return LT_PAUSE; + // fallthrough + case 2: + sub_81D0288(unk); + return LT_INC_AND_PAUSE; + case 3: + if (IsDma3ManagerBusyWithBgCopy()) + return LT_PAUSE; + break; + } + return LT_FINISH; +} + +static u32 sub_81D01DC(s32 state) +{ + switch (state) + { + case 0: + PlaySE(SE_SELECT); + sub_81C7AC0(0); + sub_81C78A0(); + return LT_INC_AND_PAUSE; + case 1: + if (IsPaletteFadeActive()) + return LT_PAUSE; + if (MainMenuLoopedTaskIsBusy()) + return LT_PAUSE; + sub_81C7FDC(); + break; + } + return LT_FINISH; +} + +static u32 sub_81D021C(s32 state) +{ + switch (state) + { + case 0: + PlaySE(SE_SELECT); + sub_81C7AC0(0); + return LT_INC_AND_PAUSE; + case 1: + if (IsPaletteFadeActive()) + return LT_PAUSE; + break; + } + return LT_FINISH; +} + +static void sub_81D024C(struct PokenavSub10 * ptr) +{ + s32 r2; + ptr->winid = AddWindow(&gUnknown_086237D4); + PutWindowTilemap(ptr->winid); + r2 = sub_81CFB38(); + sub_81D02B0(ptr->winid, 0, r2); + CopyWindowToVram(ptr->winid, 1); + sub_81D0288(ptr); +} + +static void sub_81D0288(struct PokenavSub10 * ptr) +{ + s32 r4 = GetSelectedMatchCall(); + s32 r2 = sub_81CFB38(); + sub_81D02B0(ptr->winid, r4 + 1, r2); + CopyWindowToVram(ptr->winid, 2); +} + +static void sub_81D02B0(s32 windowId, s32 val1, s32 val2) +{ + u8 strbuf[16]; + u32 x; + + u8 * ptr = strbuf; + ptr = ConvertIntToDecimalStringN(ptr, val1, STR_CONV_MODE_RIGHT_ALIGN, 3); + *ptr++ = CHAR_SLASH; + ConvertIntToDecimalStringN(ptr, val2, STR_CONV_MODE_RIGHT_ALIGN, 3); + x = GetStringCenterAlignXOffset(1, strbuf, 56); + AddTextPrinterParameterized(windowId, 1, strbuf,x, 1, 0xFF, NULL); +} + +static void sub_81D0304(void) +{ + struct MatchCallListTemplate template; + template.unk0 = sub_81CFB28(); + template.unk4 = sub_81CFB38(); + template.unk8 = 4; + template.unk6 = sub_81CFB64(); + template.unk9 = 13; + template.unkA = 17; + template.unkB = 1; + template.unkC = 8; + template.unkD = 2; + template.unkE = 1; + template.unk10 = sub_81D035C; + template.unk14 = NULL; + sub_81C81D4(&gUnknown_086237B0[1], &template, 0); +} + +static void sub_81D035C(struct PokenavMonList * item0, u8 * dest) +{ + u8 gender; + u8 level; + u8 * s; + const u8 * genderStr; + struct PokenavMonList * item = item0; + if (item->boxId == 14) + { + struct Pokemon * mon = &gPlayerParty[item->monId]; + gender = GetMonGender(mon); + level = GetLevelFromMonExp(mon); + GetMonData(mon, MON_DATA_NICKNAME, gStringVar3); + } + else + { + struct BoxPokemon * mon = GetBoxedMonPtr(item->boxId, item->monId); + gender = GetBoxMonGender(mon); + level = GetLevelFromBoxMonExp(mon); + GetBoxMonData(mon, MON_DATA_NICKNAME, gStringVar3); + } + StringGetEnd10(gStringVar3); + dest = sub_81DB494(dest, 1, gStringVar3, 60); + switch (gender) + { + default: + genderStr = gUnknown_086237F4; + break; + case MON_MALE: + genderStr = gUnknown_086237DC; + break; + case MON_FEMALE: + genderStr = gUnknown_086237E8; + break; + } + s = StringCopy(gStringVar1, genderStr); + *s++ = CHAR_SLASH; + *s++ = CHAR_SPECIAL_F9; + *s++ = 5; // LV + ConvertIntToDecimalStringN(s, level, STR_CONV_MODE_LEFT_ALIGN, 3); + dest = sub_81DB494(dest, 1, gStringVar1, 54); + ConvertIntToDecimalStringN(dest, item->unk6, STR_CONV_MODE_RIGHT_ALIGN, 2); +}