diff --git a/asm/pokenav_unk_3.s b/asm/pokenav_unk_3.s deleted file mode 100644 index 202c573bf..000000000 --- a/asm/pokenav_unk_3.s +++ /dev/null @@ -1,986 +0,0 @@ - .include "asm/macros.inc" - .include "constants/constants.inc" - - .syntax unified - -@ File centered around AllocSubstruct(5) - - thumb_func_start sub_81CAB44 -sub_81CAB44: @ 81CAB44 - push {r4,r5,lr} - adds r4, r0, 0 - ldr r3, =gMain - ldrh r1, [r3, 0x30] - movs r0, 0x40 - ands r0, r1 - cmp r0, 0 - beq _081CAB5C - movs r0, 0x2 - b _081CABF4 - .pool -_081CAB5C: - movs r0, 0x80 - ands r0, r1 - cmp r0, 0 - beq _081CAB68 - movs r0, 0x1 - b _081CABF4 -_081CAB68: - movs r0, 0x20 - ands r0, r1 - cmp r0, 0 - beq _081CAB74 - movs r0, 0x4 - b _081CABF4 -_081CAB74: - movs r0, 0x10 - ands r0, r1 - lsls r0, 16 - lsrs r2, r0, 16 - cmp r2, 0 - beq _081CAB84 - movs r0, 0x3 - b _081CABF4 -_081CAB84: - ldrh r1, [r3, 0x2E] - movs r5, 0x1 - adds r0, r5, 0 - ands r0, r1 - cmp r0, 0 - beq _081CABD0 - ldr r0, =sub_81CAC04 - str r0, [r4, 0x18] - strh r2, [r4] - bl GetSelectedMatchCall - lsls r0, 2 - adds r1, r4, r0 - ldrb r0, [r1, 0x1C] - cmp r0, 0 - beq _081CABAE - ldrh r0, [r1, 0x1E] - bl sub_81D17E8 - cmp r0, 0 - beq _081CABC0 -_081CABAE: - ldr r0, =gUnknown_0862250A - str r0, [r4, 0x4] - movs r0, 0x2 - strh r0, [r4, 0x2] - b _081CABC6 - .pool -_081CABC0: - ldr r0, =gUnknown_08622508 - str r0, [r4, 0x4] - strh r5, [r4, 0x2] -_081CABC6: - movs r0, 0x5 - b _081CABF4 - .pool -_081CABD0: - movs r0, 0x2 - ands r0, r1 - cmp r0, 0 - beq _081CABF2 - bl GetPokenavMode - cmp r0, 0x1 - beq _081CABEC - ldr r0, =sub_81CABFC - str r0, [r4, 0x18] - movs r0, 0xF - b _081CABF4 - .pool -_081CABEC: - movs r0, 0x20 - bl PlaySE -_081CABF2: - movs r0, 0 -_081CABF4: - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_81CAB44 - - thumb_func_start sub_81CABFC -sub_81CABFC: @ 81CABFC - ldr r0, =0x000186a4 - bx lr - .pool - thumb_func_end sub_81CABFC - - thumb_func_start sub_81CAC04 -sub_81CAC04: @ 81CAC04 - push {r4,lr} - adds r4, r0, 0 - ldr r2, =gMain - ldrh r1, [r2, 0x2E] - movs r0, 0x40 - ands r0, r1 - cmp r0, 0 - beq _081CAC24 - ldrh r0, [r4] - cmp r0, 0 - beq _081CAC24 - subs r0, 0x1 - b _081CAC38 - .pool -_081CAC24: - ldrh r1, [r2, 0x2E] - movs r0, 0x80 - ands r0, r1 - cmp r0, 0 - beq _081CAC3E - ldrh r0, [r4] - ldrh r1, [r4, 0x2] - cmp r0, r1 - bcs _081CAC3E - adds r0, 0x1 -_081CAC38: - strh r0, [r4] - movs r0, 0x6 - b _081CACAC -_081CAC3E: - ldrh r1, [r2, 0x2E] - movs r0, 0x1 - ands r0, r1 - cmp r0, 0 - beq _081CAC98 - ldrh r1, [r4] - ldr r0, [r4, 0x4] - adds r0, r1 - ldrb r0, [r0] - cmp r0, 0x1 - beq _081CAC8C - cmp r0, 0x1 - bgt _081CAC5E - cmp r0, 0 - beq _081CAC64 - b _081CAC98 -_081CAC5E: - cmp r0, 0x2 - bne _081CAC98 - b _081CACA6 -_081CAC64: - bl GetPokenavMode - cmp r0, 0x1 - bne _081CAC72 - movs r0, 0x2 - bl SetPokenavMode -_081CAC72: - ldr r0, =sub_81CACF8 - str r0, [r4, 0x18] - bl sub_81CB1D0 - cmp r0, 0 - beq _081CAC88 - movs r0, 0x9 - b _081CACAC - .pool -_081CAC88: - movs r0, 0x8 - b _081CACAC -_081CAC8C: - ldr r0, =sub_81CACB8 - str r0, [r4, 0x18] - movs r0, 0xB - b _081CACAC - .pool -_081CAC98: - ldrh r1, [r2, 0x2E] - movs r0, 0x2 - ands r0, r1 - cmp r0, 0 - bne _081CACA6 - movs r0, 0 - b _081CACAC -_081CACA6: - ldr r0, =sub_81CAB44 - str r0, [r4, 0x18] - movs r0, 0x7 -_081CACAC: - pop {r4} - pop {r1} - bx r1 - .pool - thumb_func_end sub_81CAC04 - - thumb_func_start sub_81CACB8 -sub_81CACB8: @ 81CACB8 - push {lr} - adds r3, r0, 0 - ldr r2, =gMain - ldrh r1, [r2, 0x30] - movs r0, 0x40 - ands r0, r1 - cmp r0, 0 - beq _081CACD0 - movs r0, 0xC - b _081CACF0 - .pool -_081CACD0: - movs r0, 0x80 - ands r0, r1 - cmp r0, 0 - beq _081CACDC - movs r0, 0xD - b _081CACF0 -_081CACDC: - ldrh r1, [r2, 0x2E] - movs r0, 0x2 - ands r0, r1 - cmp r0, 0 - bne _081CACEA - movs r0, 0 - b _081CACF0 -_081CACEA: - ldr r0, =sub_81CAB44 - str r0, [r3, 0x18] - movs r0, 0xE -_081CACF0: - pop {r1} - bx r1 - .pool - thumb_func_end sub_81CACB8 - - thumb_func_start sub_81CACF8 -sub_81CACF8: @ 81CACF8 - push {lr} - adds r2, r0, 0 - ldr r0, =gMain - ldrh r1, [r0, 0x2E] - movs r0, 0x3 - ands r0, r1 - cmp r0, 0 - bne _081CAD10 - movs r0, 0 - b _081CAD16 - .pool -_081CAD10: - ldr r0, =sub_81CAB44 - str r0, [r2, 0x18] - movs r0, 0xA -_081CAD16: - pop {r1} - bx r1 - .pool - thumb_func_end sub_81CACF8 - - thumb_func_start sub_81CAD20 -sub_81CAD20: @ 81CAD20 - push {r4-r7,lr} - adds r5, r0, 0 - movs r0, 0x5 - bl GetSubstructPtr - adds r4, r0, 0 - cmp r5, 0x1 - beq _081CAD4C - cmp r5, 0x1 - bgt _081CAD3A - cmp r5, 0 - beq _081CAD44 - b _081CAE00 -_081CAD3A: - cmp r5, 0x2 - beq _081CAD9C - cmp r5, 0x3 - beq _081CADFC - b _081CAE00 -_081CAD44: - strh r5, [r4, 0x8] - strh r5, [r4, 0xA] -_081CAD48: - movs r0, 0x1 - b _081CAE02 -_081CAD4C: - movs r6, 0 - ldrh r5, [r4, 0x8] -_081CAD50: - adds r0, r5, 0 - bl MatchCallFlagGetByIndex - cmp r0, 0 - beq _081CAD80 - ldrh r0, [r4, 0xA] - lsls r0, 2 - adds r0, r4, r0 - strh r5, [r0, 0x1E] - ldrh r0, [r4, 0xA] - lsls r0, 2 - adds r0, r4, r0 - movs r1, 0x1 - strb r1, [r0, 0x1C] - adds r0, r5, 0 - bl sub_81D16DC - ldrh r1, [r4, 0xA] - lsls r1, 2 - adds r1, r4, r1 - strb r0, [r1, 0x1D] - ldrh r0, [r4, 0xA] - adds r0, 0x1 - strh r0, [r4, 0xA] -_081CAD80: - ldrh r0, [r4, 0x8] - adds r1, r0, 0x1 - movs r2, 0 - strh r1, [r4, 0x8] - lsls r0, r1, 16 - lsrs r0, 16 - cmp r0, 0x14 - bhi _081CADF6 - adds r6, 0x1 - adds r5, 0x1 - cmp r6, 0x1D - ble _081CAD50 - movs r0, 0x3 - b _081CAE02 -_081CAD9C: - movs r6, 0 - ldrh r5, [r4, 0x8] - movs r7, 0 -_081CADA2: - ldrh r0, [r4, 0x8] - bl sub_81D1BF8 - cmp r0, 0 - bne _081CADDC - ldrh r0, [r4, 0x8] - bl sub_81CAE08 - cmp r0, 0 - beq _081CADDC - ldrh r0, [r4, 0xA] - lsls r0, 2 - adds r0, r4, r0 - ldrh r1, [r4, 0x8] - strh r1, [r0, 0x1E] - ldrh r0, [r4, 0xA] - lsls r0, 2 - adds r0, r4, r0 - strb r7, [r0, 0x1C] - adds r0, r5, 0 - bl sub_81CB0C8 - ldrh r1, [r4, 0xA] - lsls r1, 2 - adds r1, r4, r1 - strb r0, [r1, 0x1D] - ldrh r0, [r4, 0xA] - adds r0, 0x1 - strh r0, [r4, 0xA] -_081CADDC: - ldrh r0, [r4, 0x8] - adds r0, 0x1 - strh r0, [r4, 0x8] - lsls r0, 16 - lsrs r0, 16 - cmp r0, 0x4D - bhi _081CAD48 - adds r6, 0x1 - adds r5, 0x1 - cmp r6, 0x1D - ble _081CADA2 - movs r0, 0x3 - b _081CAE02 -_081CADF6: - strh r1, [r4, 0xC] - strh r2, [r4, 0x8] - b _081CAD48 -_081CADFC: - movs r0, 0x1 - str r0, [r4, 0x10] -_081CAE00: - movs r0, 0x4 -_081CAE02: - pop {r4-r7} - pop {r1} - bx r1 - thumb_func_end sub_81CAD20 - - thumb_func_start sub_81CAE08 -sub_81CAE08: @ 81CAE08 - push {lr} - cmp r0, 0x4D - ble _081CAE12 - movs r0, 0 - b _081CAE24 -_081CAE12: - movs r1, 0xAE - lsls r1, 1 - adds r0, r1 - lsls r0, 16 - lsrs r0, 16 - bl FlagGet - lsls r0, 24 - lsrs r0, 24 -_081CAE24: - pop {r1} - bx r1 - thumb_func_end sub_81CAE08 - - thumb_func_start sub_81CAE28 -sub_81CAE28: @ 81CAE28 - push {lr} - movs r0, 0x5 - bl GetSubstructPtr - ldr r0, [r0, 0x10] - pop {r1} - bx r1 - thumb_func_end sub_81CAE28 - - thumb_func_start sub_81CAE38 -sub_81CAE38: @ 81CAE38 - push {lr} - movs r0, 0x5 - bl GetSubstructPtr - ldrh r0, [r0, 0xA] - pop {r1} - bx r1 - thumb_func_end sub_81CAE38 - - thumb_func_start sub_81CAE48 -sub_81CAE48: @ 81CAE48 - push {lr} - movs r0, 0x5 - bl GetSubstructPtr - ldrh r0, [r0, 0xC] - pop {r1} - bx r1 - thumb_func_end sub_81CAE48 - - thumb_func_start sub_81CAE58 -sub_81CAE58: @ 81CAE58 - push {lr} - movs r0, 0x5 - bl GetSubstructPtr - adds r1, r0, 0 - ldrh r0, [r1, 0xA] - ldrh r1, [r1, 0xC] - subs r0, r1 - pop {r1} - bx r1 - thumb_func_end sub_81CAE58 - - thumb_func_start sub_81CAE6C -sub_81CAE6C: @ 81CAE6C - push {r4,lr} - adds r4, r0, 0 - movs r0, 0x5 - bl GetSubstructPtr - adds r1, r0, 0 - ldrh r0, [r1, 0xC] - adds r4, r0 - ldrh r0, [r1, 0xA] - cmp r4, r0 - bge _081CAE8A - lsls r0, r4, 2 - adds r0, r1, r0 - ldrh r0, [r0, 0x1E] - b _081CAE8C -_081CAE8A: - movs r0, 0x4E -_081CAE8C: - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_81CAE6C - - thumb_func_start sub_81CAE94 -sub_81CAE94: @ 81CAE94 - push {lr} - movs r0, 0x5 - bl GetSubstructPtr - adds r0, 0x1C - pop {r1} - bx r1 - thumb_func_end sub_81CAE94 - - thumb_func_start sub_81CAEA4 -sub_81CAEA4: @ 81CAEA4 - push {r4,lr} - adds r4, r0, 0 - movs r0, 0x5 - bl GetSubstructPtr - lsls r4, 2 - adds r0, r4 - ldrb r0, [r0, 0x1D] - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_81CAEA4 - - thumb_func_start sub_81CAEBC -sub_81CAEBC: @ 81CAEBC - push {r4,lr} - adds r4, r0, 0 - movs r0, 0x5 - bl GetSubstructPtr - lsls r1, r4, 2 - adds r1, r0, r1 - ldrb r0, [r1, 0x1C] - cmp r0, 0 - bne _081CAED4 - ldrh r4, [r1, 0x1E] - b _081CAEDC -_081CAED4: - ldrh r0, [r1, 0x1E] - bl MatchCall_GetRematchTableIdx - adds r4, r0, 0 -_081CAEDC: - cmp r4, 0x4E - beq _081CAEFC - ldr r0, =gSaveBlock1Ptr - ldr r0, [r0] - ldr r1, =0x000009ca - adds r0, r1 - adds r0, r4 - ldrb r1, [r0] - negs r0, r1 - orrs r0, r1 - lsrs r0, 31 - b _081CAEFE - .pool -_081CAEFC: - movs r0, 0 -_081CAEFE: - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_81CAEBC - - thumb_func_start sub_81CAF04 -sub_81CAF04: @ 81CAF04 - push {r4,r5,lr} - adds r4, r0, 0 - movs r0, 0x5 - bl GetSubstructPtr - lsls r1, r4, 2 - adds r1, r0, r1 - ldrb r0, [r1, 0x1C] - cmp r0, 0 - bne _081CAF34 - ldrh r0, [r1, 0x1E] - bl GetTrainerIdxByRematchIdx - adds r4, r0, 0 - ldr r1, =gTrainers - lsls r0, r4, 2 - adds r0, r4 - lsls r0, 3 - adds r0, r1 - ldrb r0, [r0, 0x3] - b _081CAF6C - .pool -_081CAF34: - ldrh r5, [r1, 0x1E] - adds r0, r5, 0 - bl MatchCall_GetRematchTableIdx - adds r4, r0, 0 - cmp r4, 0x4E - bne _081CAF58 - adds r0, r5, 0 - bl sub_81D1BD0 - adds r4, r0, 0 - ldr r0, =gFacilityClassToPicIndex - adds r0, r4, r0 - ldrb r0, [r0] - b _081CAF6C - .pool -_081CAF58: - adds r0, r4, 0 - bl GetTrainerIdxByRematchIdx - adds r4, r0, 0 - ldr r0, =gTrainers - lsls r1, r4, 2 - adds r1, r4 - lsls r1, 3 - adds r1, r0 - ldrb r0, [r1, 0x3] -_081CAF6C: - pop {r4,r5} - pop {r1} - bx r1 - .pool - thumb_func_end sub_81CAF04 - - thumb_func_start sub_81CAF78 -sub_81CAF78: @ 81CAF78 - push {r4-r6,lr} - adds r5, r0, 0 - adds r6, r1, 0 - movs r0, 0x5 - bl GetSubstructPtr - adds r4, r0, 0 - movs r0, 0 - strb r0, [r6] - ldr r0, =gMapHeader - ldrb r0, [r0, 0x17] - bl Overworld_MapTypeAllowsTeleportAndFly - lsls r0, 24 - cmp r0, 0 - bne _081CAFA4 - ldr r0, =gText_CallCantBeMadeHere - b _081CAFCE - .pool -_081CAFA4: - lsls r0, r5, 2 - adds r1, r4, r0 - ldrb r0, [r1, 0x1C] - cmp r0, 0 - bne _081CAFC4 - ldrh r0, [r1, 0x1E] - bl GetTrainerIdxByRematchIdx - ldr r1, =gStringVar4 - bl SelectMatchCallMessage - strb r0, [r6] - b _081CAFCC - .pool -_081CAFC4: - ldrh r0, [r1, 0x1E] - ldr r1, =gStringVar4 - bl MatchCall_GetMessage -_081CAFCC: - ldr r0, =gStringVar4 -_081CAFCE: - pop {r4-r6} - pop {r1} - bx r1 - .pool - thumb_func_end sub_81CAF78 - - thumb_func_start sub_81CAFD8 -sub_81CAFD8: @ 81CAFD8 - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - movs r0, 0x5 - bl GetSubstructPtr - lsls r4, 2 - adds r4, r0, r4 - ldrb r0, [r4, 0x1C] - cmp r0, 0 - beq _081CB004 - ldrh r0, [r4, 0x1E] - bl MatchCall_GetRematchTableIdx - adds r1, r0, 0 - cmp r1, 0x4E - bne _081CB006 - ldrh r0, [r4, 0x1E] - adds r1, r5, 0 - bl sub_81D1B40 - b _081CB012 -_081CB004: - ldrh r1, [r4, 0x1E] -_081CB006: - ldr r2, =gUnknown_08622028 - lsls r0, r5, 2 - lsls r1, 4 - adds r0, r1 - adds r0, r2 - ldr r0, [r0] -_081CB012: - pop {r4,r5} - pop {r1} - bx r1 - .pool - thumb_func_end sub_81CAFD8 - - thumb_func_start sub_81CB01C -sub_81CB01C: @ 81CB01C - push {lr} - movs r0, 0x5 - bl GetSubstructPtr - ldrh r0, [r0] - pop {r1} - bx r1 - thumb_func_end sub_81CB01C - - thumb_func_start sub_81CB02C -sub_81CB02C: @ 81CB02C - push {r4,lr} - adds r4, r0, 0 - movs r0, 0x5 - bl GetSubstructPtr - adds r1, r0, 0 - ldrh r0, [r1, 0x2] - cmp r0, r4 - blt _081CB046 - ldr r0, [r1, 0x4] - adds r0, r4 - ldrb r0, [r0] - b _081CB048 -_081CB046: - movs r0, 0x3 -_081CB048: - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_81CB02C - - thumb_func_start sub_81CB050 -sub_81CB050: @ 81CB050 - push {r4,lr} - sub sp, 0x8 - adds r2, r0, 0 - adds r4, r1, 0 - ldrb r0, [r2] - cmp r0, 0 - bne _081CB088 - ldrh r0, [r2, 0x2] - bl GetTrainerIdxByRematchIdx - lsls r1, r0, 2 - adds r1, r0 - lsls r1, 3 - ldr r0, =gTrainers - adds r1, r0 - ldrb r2, [r1, 0x1] - movs r0, 0xD - muls r0, r2 - ldr r2, =gTrainerClassNames - adds r0, r2 - str r0, [sp] - adds r1, 0x4 - str r1, [sp, 0x4] - b _081CB092 - .pool -_081CB088: - ldrh r0, [r2, 0x2] - add r2, sp, 0x4 - mov r1, sp - bl sub_81D1A78 -_081CB092: - ldr r2, [sp] - cmp r2, 0 - beq _081CB0B4 - ldr r0, [sp, 0x4] - cmp r0, 0 - beq _081CB0B4 - adds r0, r4, 0 - movs r1, 0x7 - movs r3, 0x45 - bl sub_81DB494 - ldr r2, [sp, 0x4] - movs r1, 0x7 - movs r3, 0x33 - bl sub_81DB494 - b _081CB0C0 -_081CB0B4: - adds r0, r4, 0 - movs r1, 0x7 - movs r2, 0 - movs r3, 0x78 - bl sub_81DB494 -_081CB0C0: - add sp, 0x8 - pop {r4} - pop {r0} - bx r0 - thumb_func_end sub_81CB050 - - thumb_func_start sub_81CB0C8 -sub_81CB0C8: @ 81CB0C8 - push {lr} - ldr r1, =gRematchTable - lsls r0, 4 - adds r0, r1 - ldrh r2, [r0, 0xA] - ldrh r1, [r0, 0xC] - adds r0, r2, 0 - bl Overworld_GetMapHeaderByGroupAndId - ldrb r0, [r0, 0x14] - pop {r1} - bx r1 - .pool - thumb_func_end sub_81CB0C8 - - thumb_func_start sub_81CB0E4 -sub_81CB0E4: @ 81CB0E4 - push {r4-r7,lr} - adds r5, r0, 0 - movs r0, 0x5 - bl GetSubstructPtr - adds r7, r0, 0 - movs r6, 0x1 - adds r5, 0x1 - ldrh r0, [r7, 0xA] - cmp r5, r0 - bge _081CB120 - lsls r0, r5, 2 - adds r0, 0x1C - adds r4, r0, r7 -_081CB100: - ldrb r0, [r4] - cmp r0, 0 - beq _081CB110 - ldrh r0, [r4, 0x2] - bl sub_81D17E8 - cmp r0, 0 - beq _081CB114 -_081CB110: - adds r0, r6, 0 - b _081CB122 -_081CB114: - adds r6, 0x1 - adds r4, 0x4 - adds r5, 0x1 - ldrh r0, [r7, 0xA] - cmp r5, r0 - blt _081CB100 -_081CB120: - movs r0, 0 -_081CB122: - pop {r4-r7} - pop {r1} - bx r1 - thumb_func_end sub_81CB0E4 - - thumb_func_start sub_81CB128 -sub_81CB128: @ 81CB128 - push {r4-r6,lr} - adds r5, r0, 0 - movs r0, 0x5 - bl GetSubstructPtr - adds r1, r0, 0 - movs r6, 0x1 - negs r6, r6 - subs r5, 0x1 - cmp r5, 0 - blt _081CB162 - lsls r0, r5, 2 - adds r0, 0x1C - adds r4, r0, r1 -_081CB144: - ldrb r0, [r4] - cmp r0, 0 - beq _081CB154 - ldrh r0, [r4, 0x2] - bl sub_81D17E8 - cmp r0, 0 - beq _081CB158 -_081CB154: - adds r0, r6, 0 - b _081CB164 -_081CB158: - subs r6, 0x1 - subs r4, 0x4 - subs r5, 0x1 - cmp r5, 0 - bge _081CB144 -_081CB162: - movs r0, 0 -_081CB164: - pop {r4-r6} - pop {r1} - bx r1 - thumb_func_end sub_81CB128 - - thumb_func_start sub_81CB16C -sub_81CB16C: @ 81CB16C - push {r4,lr} - movs r4, 0 -_081CB170: - adds r0, r4, 0 - bl sub_81CAE08 - cmp r0, 0 - beq _081CB18A - ldr r0, =gSaveBlock1Ptr - ldr r0, [r0] - ldr r1, =0x000009ca - adds r0, r1 - adds r0, r4 - ldrb r0, [r0] - cmp r0, 0 - bne _081CB1B2 -_081CB18A: - adds r4, 0x1 - cmp r4, 0x4D - ble _081CB170 - movs r4, 0 -_081CB192: - adds r0, r4, 0 - bl MatchCallFlagGetByIndex - cmp r0, 0 - beq _081CB1C0 - adds r0, r4, 0 - bl MatchCall_GetRematchTableIdx - ldr r1, =gSaveBlock1Ptr - ldr r1, [r1] - ldr r2, =0x000009ca - adds r1, r2 - adds r1, r0 - ldrb r0, [r1] - cmp r0, 0 - beq _081CB1C0 -_081CB1B2: - movs r0, 0x1 - b _081CB1C8 - .pool -_081CB1C0: - adds r4, 0x1 - cmp r4, 0x14 - ble _081CB192 - movs r0, 0 -_081CB1C8: - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_81CB16C - - thumb_func_start sub_81CB1D0 -sub_81CB1D0: @ 81CB1D0 - push {r4,lr} - movs r0, 0x5 - bl GetSubstructPtr - adds r4, r0, 0 - bl GetSelectedMatchCall - adds r1, r0, 0 - lsls r0, r1, 2 - adds r4, r0 - ldrb r0, [r4, 0x1C] - cmp r0, 0 - bne _081CB218 - adds r0, r1, 0 - bl sub_81CAEA4 - ldr r1, =gMapHeader - lsls r0, 16 - lsrs r0, 16 - ldrb r1, [r1, 0x14] - cmp r0, r1 - bne _081CB258 - ldr r0, =gSaveBlock1Ptr - ldr r0, [r0] - ldr r1, =0x000009ca - adds r0, r1 - ldrh r4, [r4, 0x1E] - adds r0, r4 - ldrb r0, [r0] - b _081CB246 - .pool -_081CB218: - ldrh r0, [r4, 0x1E] - cmp r0, 0xB - bne _081CB258 - adds r0, r1, 0 - bl sub_81CAEA4 - ldr r1, =gMapHeader - lsls r0, 16 - lsrs r0, 16 - ldrb r1, [r1, 0x14] - cmp r0, r1 - bne _081CB258 - ldr r0, =0x0000086b - bl FlagGet - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bne _081CB258 - movs r0, 0x5B - bl FlagGet - lsls r0, 24 -_081CB246: - cmp r0, 0 - bne _081CB258 - movs r0, 0x1 - b _081CB25A - .pool -_081CB258: - movs r0, 0 -_081CB25A: - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_81CB1D0 - - .align 2, 0 @ Don't pad with nop. diff --git a/include/international_string_util.h b/include/international_string_util.h index 911cd6935..cf3c5f723 100644 --- a/include/international_string_util.h +++ b/include/international_string_util.h @@ -14,7 +14,7 @@ int GetMaxWidthInMenuTable(const struct MenuAction *str, int arg1); int sub_81DB3D8(const struct MenuAction *str, const u8* arg1, int arg2); int Intl_GetListMenuWidth(const struct ListMenuTemplate *listMenu); void CopyMonCategoryText(int dexNum, u8 *dest); -u8 *sub_81DB494(u8 *str, int fontId, u8 *str2, int totalStringWidth); +u8 *sub_81DB494(u8 *str, int fontId, const u8 *str2, int totalStringWidth); void PadNameString(u8 *dest, u8 padChar); void sub_81DB554(u8 *, u8); void sub_81DB5AC(u8 *); diff --git a/include/match_call.h b/include/match_call.h index 6803d2f26..014b20eb4 100644 --- a/include/match_call.h +++ b/include/match_call.h @@ -14,7 +14,8 @@ s32 GetRematchIdxByTrainerIdx(s32 trainerIdx); void InitMatchCallCounters(void); bool32 TryStartMatchCall(void); bool32 IsMatchCallTaskActive(void); -void StartMatchCallFromScript(u8* script); +void StartMatchCallFromScript(u8 *message); void sub_8197080(u8 *destStr); +bool32 SelectMatchCallMessage(int, u8 *); #endif //GUARD_MATCH_CALL_H diff --git a/include/pokenav.h b/include/pokenav.h index 7ae640637..fb2644e83 100644 --- a/include/pokenav.h +++ b/include/pokenav.h @@ -55,6 +55,19 @@ u32 GetPokenavMode(void); bool32 CanViewRibbonsMenu(void); // pokenav_match_call_ui.c +u32 GetSelectedMatchCall(void); + +// pokenav_match_call_data.c +bool32 sub_81D17E8(u32 idx); +u8 sub_81D16DC(u32 idx); +bool32 sub_81D1BF8(u32 idx); +bool32 MatchCallFlagGetByIndex(u32 idx); +u32 MatchCall_GetRematchTableIdx(u32 idx); +u32 GetTrainerIdxByRematchIdx(u32 rematchIdx); +int sub_81D1BD0(u32 idx); +void MatchCall_GetMessage(u32 idx, u8 *dest); +const u8 *sub_81D1B40(u32 idx, u32 offset); +void sub_81D1A78(u32 idx, const u8 **desc, const u8 **name); // pokenav_main_menu.c bool32 InitPokenavMainMenu(void); @@ -71,14 +84,35 @@ bool32 sub_81C9368(void); u32 sub_81C941C(void); void sub_81C9430(void); int sub_81C9894(void); +const u8 *sub_81CAF78(int index, u8 *arg1); // pokenav_unk_2.c u32 sub_81C99D4(void); void sub_81CAADC(void); // pokenav_unk_3.c +struct Pokenav3Struct_Unk1C +{ + u8 unk0; + u8 unk1; + u16 unk2; +}; bool32 sub_81CAAE8(void); u32 sub_81CAB24(void); void sub_81CAB38(void); +int sub_81CAE28(void); +int sub_81CAE38(void); +int sub_81CAE48(void); +struct Pokenav3Struct_Unk1C *sub_81CAE94(void); +u16 sub_81CAEA4(int); +bool32 sub_81CAEBC(int index); +int sub_81CAF04(int index); +const u8 *sub_81CAFD8(int index, int textType); +u16 sub_81CB01C(void); +u16 sub_81CB02C(int arg0); +void sub_81CB050(struct Pokenav3Struct_Unk1C *arg0, u8 *str); +int sub_81CB0C8(int rematchIndex); +int sub_81CB0E4(int index); +bool32 sub_81CAE08(int); #endif //GUARD_POKENAV_H diff --git a/include/strings.h b/include/strings.h index 3c141f243..5de5b8e1d 100644 --- a/include/strings.h +++ b/include/strings.h @@ -2708,4 +2708,7 @@ extern const u8 gText_Symbols[]; extern const u8 gText_Register2[]; extern const u8 gText_Exit2[]; +// Pokenav Match Call +extern const u8 gText_CallCantBeMadeHere[]; + #endif // GUARD_STRINGS_H diff --git a/ld_script.txt b/ld_script.txt index b3602c47e..9ed1e9b1c 100644 --- a/ld_script.txt +++ b/ld_script.txt @@ -306,7 +306,6 @@ SECTIONS { src/pokenav_unk_1.o(.text); asm/pokenav_unk_2.o(.text); src/pokenav_unk_3.o(.text); - asm/pokenav_unk_3.o(.text); asm/pokenav_unk_4.o(.text); asm/pokenav_unk_5.o(.text); asm/pokenav_unk_6.o(.text); diff --git a/src/international_string_util.c b/src/international_string_util.c index dfeda49e3..9dc795dd0 100644 --- a/src/international_string_util.c +++ b/src/international_string_util.c @@ -93,7 +93,7 @@ void CopyMonCategoryText(int dexNum, u8 *dest) StringCopy(str + 1, gText_Pokemon); } -u8 *sub_81DB494(u8 *str, int fontId, u8 *str2, int totalStringWidth) +u8 *sub_81DB494(u8 *str, int fontId, const u8 *str2, int totalStringWidth) { u8 *buffer; int width; diff --git a/src/match_call.c b/src/match_call.c index 35daacc3d..1f5324f02 100644 --- a/src/match_call.c +++ b/src/match_call.c @@ -8,6 +8,7 @@ #include "event_object_movement.h" #include "field_player_avatar.h" #include "main.h" +#include "match_call.h" #include "menu.h" #include "new_game.h" #include "overworld.h" @@ -74,7 +75,6 @@ struct BattleFrontierStreakInfo EWRAM_DATA struct MatchCallState gMatchCallState = {0}; EWRAM_DATA struct BattleFrontierStreakInfo gBattleFrontierStreakInfo = {0}; -bool32 SelectMatchCallMessage(int, u8 *); static u32 GetCurrentTotalMinutes(struct Time *); static u32 GetNumRegisteredNPCs(void); static u32 GetActiveMatchCallTrainerId(u32); @@ -1098,13 +1098,13 @@ bool32 TryStartMatchCall(void) return FALSE; } -void StartMatchCallFromScript(void) +void StartMatchCallFromScript(u8 *message) { gMatchCallState.triggeredFromScript = 1; StartMatchCall(); } -bool8 IsMatchCallTaskActive(void) +bool32 IsMatchCallTaskActive(void) { return FuncIsActiveTask(ExecuteMatchCall); } diff --git a/src/pokenav_match_call_data.c b/src/pokenav_match_call_data.c index 773a5be3a..02c39f98a 100644 --- a/src/pokenav_match_call_data.c +++ b/src/pokenav_match_call_data.c @@ -1101,7 +1101,7 @@ static void MatchCall_GetMessage_Type4(match_call_t matchCall, u8 *dest) sub_8197080(dest); } -void sub_81D1920(const match_call_text_data_t *sub0, u8 *dest) +static void sub_81D1920(const match_call_text_data_t *sub0, u8 *dest) { u32 i; for (i = 0; sub0[i].text != NULL; i++) @@ -1415,7 +1415,7 @@ NAKED const u8 *sub_81D1B40(u32 idx, u32 offset) } #endif -s32 sub_81D1BD0(u32 idx) +int sub_81D1BD0(u32 idx) { u32 i; @@ -1429,9 +1429,9 @@ s32 sub_81D1BD0(u32 idx) bool32 sub_81D1BF8(u32 idx) { - s32 i; + int i; - for (i = 0; i < (s32)ARRAY_COUNT(sMatchCallHeaders); i++) + for (i = 0; i < (int)ARRAY_COUNT(sMatchCallHeaders); i++) { u32 r0 = MatchCall_GetRematchTableIdx(i); if (r0 != REMATCH_TABLE_ENTRIES && r0 == idx) @@ -1442,7 +1442,7 @@ bool32 sub_81D1BF8(u32 idx) void SetMatchCallRegisteredFlag(void) { - s32 r0 = GetRematchIdxByTrainerIdx(gSpecialVar_0x8004); + int r0 = GetRematchIdxByTrainerIdx(gSpecialVar_0x8004); if (r0 >= 0) FlagSet(FLAG_MATCH_CALL_REGISTERED + r0); } diff --git a/src/pokenav_match_call_ui.c b/src/pokenav_match_call_ui.c index 36ae1b651..8134fc00e 100644 --- a/src/pokenav_match_call_ui.c +++ b/src/pokenav_match_call_ui.c @@ -82,7 +82,6 @@ struct MatchCallListTemplate extern void sub_81CBD48(u16 windowId, u32 a1); extern void sub_81DB620(u32 windowId, u32 a1, u32 a2, u32 a3, u32 a4); -extern u8 *sub_81CAFD8(u16 a0, u32 a1); void sub_81C82E4(struct UnknownSubStruct_81C81D4 *a0); u32 sub_81C91AC(struct UnknownInnerStruct_81C81D4 *a0, const struct BgTemplate *a1, struct MatchCallListTemplate *a2, s32 a3); diff --git a/src/pokenav_unk_3.c b/src/pokenav_unk_3.c index be1926e0d..2c5110143 100755 --- a/src/pokenav_unk_3.c +++ b/src/pokenav_unk_3.c @@ -1,19 +1,45 @@ #include "global.h" +#include "battle_setup.h" +#include "data.h" +#include "event_data.h" +#include "gym_leader_rematch.h" +#include "international_string_util.h" +#include "main.h" +#include "match_call.h" +#include "overworld.h" +#include "pokemon.h" #include "pokenav.h" +#include "sound.h" +#include "string_util.h" +#include "strings.h" +#include "constants/flags.h" +#include "constants/songs.h" struct Pokenav3Struct { - u8 filler0[0x8]; + u16 unk0; + u16 unk2; + const u8 *unk4; u16 unk8; - u8 fillerA[0x6]; + u16 unkA; + u16 unkC; u32 unk10; u32 unk14; - u32 (*unk18)(struct Pokenav3Struct*); - u8 filler1C[0x18C]; + u32 (*callback)(struct Pokenav3Struct*); + struct Pokenav3Struct_Unk1C unk1C[99]; }; -u32 sub_81CAB44(struct Pokenav3Struct *); -u32 sub_81CAD20(int); +static u32 sub_81CAB44(struct Pokenav3Struct *); +static u32 sub_81CABFC(struct Pokenav3Struct *); +static u32 sub_81CAC04(struct Pokenav3Struct *); +static u32 sub_81CACB8(struct Pokenav3Struct *); +static u32 sub_81CACF8(struct Pokenav3Struct *); +static u32 sub_81CAD20(int); +static bool32 sub_81CB1D0(void); + +extern const u8 gUnknown_08622508[]; +extern const u8 gUnknown_0862250A[]; +extern const u8 *const gUnknown_08622028[][4]; bool32 sub_81CAAE8(void) { @@ -21,7 +47,7 @@ bool32 sub_81CAAE8(void) if (!state) return FALSE; - state->unk18 = sub_81CAB44; + state->callback = sub_81CAB44; state->unk8 = 0; state->unk10 = 0; state->unk14 = CreateLoopedTask(sub_81CAD20, 1); @@ -31,10 +57,447 @@ bool32 sub_81CAAE8(void) u32 sub_81CAB24(void) { struct Pokenav3Struct *state = GetSubstructPtr(5); - return state->unk18(state); + return state->callback(state); } void sub_81CAB38(void) { FreePokenavSubstruct(5); } + +static u32 sub_81CAB44(struct Pokenav3Struct *state) +{ + int selectedMatchCall; + + if (gMain.newAndRepeatedKeys & DPAD_UP) + return 2; + if (gMain.newAndRepeatedKeys & DPAD_DOWN) + return 1; + if (gMain.newAndRepeatedKeys & DPAD_LEFT) + return 4; + if (gMain.newAndRepeatedKeys & DPAD_RIGHT) + return 3; + + if (gMain.newKeys & A_BUTTON) + { + state->callback = sub_81CAC04; + state->unk0 = 0; + selectedMatchCall = GetSelectedMatchCall(); + if (!state->unk1C[selectedMatchCall].unk0 || sub_81D17E8(state->unk1C[selectedMatchCall].unk2)) + { + state->unk4 = gUnknown_0862250A; + state->unk2 = 2; + } + else + { + state->unk4 = gUnknown_08622508; + state->unk2 = 1; + } + + return 5; + } + + if (gMain.newKeys & B_BUTTON) + { + if (GetPokenavMode() != POKENAV_MODE_FORCE_CALL_1) + { + state->callback = sub_81CABFC; + return 15; + } + else + { + PlaySE(SE_HAZURE); + } + } + + return 0; +} + +static u32 sub_81CABFC(struct Pokenav3Struct *state) +{ + return POKENAV_MENU_4; +} + +static u32 sub_81CAC04(struct Pokenav3Struct *state) +{ + if ((gMain.newKeys & DPAD_UP) && state->unk0) + { + state->unk0--; + return 6; + } + + if ((gMain.newKeys & DPAD_DOWN) && state->unk0 < state->unk2) + { + state->unk0++; + return 6; + } + + if (gMain.newKeys & A_BUTTON) + { + switch (state->unk4[state->unk0]) + { + case 2: + state->callback = sub_81CAB44; + return 7; + case 0: + if (GetPokenavMode() == POKENAV_MODE_FORCE_CALL_1) + SetPokenavMode(POKENAV_MODE_FORCE_CALL_2); + + state->callback = sub_81CACF8; + if (sub_81CB1D0()) + return 9; + + return 8; + case 1: + state->callback = sub_81CACB8; + return 11; + } + } + + if (gMain.newKeys & B_BUTTON) + { + state->callback = sub_81CAB44; + return 7; + } + + return 0; +} + +static u32 sub_81CACB8(struct Pokenav3Struct *state) +{ + if (gMain.newAndRepeatedKeys & DPAD_UP) + return 12; + if (gMain.newAndRepeatedKeys & DPAD_DOWN) + return 13; + + if (gMain.newKeys & B_BUTTON) + { + state->callback = sub_81CAB44; + return 14; + } + + return 0; +} + +static u32 sub_81CACF8(struct Pokenav3Struct *state) +{ + if (gMain.newKeys & (A_BUTTON | B_BUTTON)) + { + state->callback = sub_81CAB44; + return 10; + } + + return 0; +} + +static u32 sub_81CAD20(int taskState) +{ + int i, j; + struct Pokenav3Struct *state = GetSubstructPtr(5); + switch (taskState) + { + case 0: + state->unk8 = 0; + state->unkA = 0; + return LT_INC_AND_CONTINUE; + case 1: + for (i = 0, j = state->unk8; i < 30; i++, j++) + { + if (MatchCallFlagGetByIndex(j)) + { + state->unk1C[state->unkA].unk2 = j; + state->unk1C[state->unkA].unk0 = 1; + state->unk1C[state->unkA].unk1 = sub_81D16DC(j); + state->unkA++; + } + + if (++state->unk8 >= 21) // TODO: This is the size of sMatchCallHeaders + { + state->unkC = state->unk8; + state->unk8 = 0; + return LT_INC_AND_CONTINUE; + } + } + + return LT_CONTINUE; + case 2: + for (i = 0, j = state->unk8; i < 30; i++, j++) + { + if (!sub_81D1BF8(state->unk8) && sub_81CAE08(state->unk8)) + { + state->unk1C[state->unkA].unk2 = state->unk8; + state->unk1C[state->unkA].unk0 = 0; + state->unk1C[state->unkA].unk1 = sub_81CB0C8(j); + state->unkA++; + } + + if (++state->unk8 > REMATCH_TABLE_ENTRIES - 1) + return LT_INC_AND_CONTINUE; + } + + return LT_CONTINUE; + case 3: + state->unk10 = 1; + break; + } + + return LT_FINISH; +} + +bool32 sub_81CAE08(int rematchIndex) +{ + if (rematchIndex < REMATCH_TABLE_ENTRIES) + return FlagGet(FLAG_MATCH_CALL_REGISTERED + rematchIndex); + + return FALSE; +} + +int sub_81CAE28(void) +{ + struct Pokenav3Struct *state = GetSubstructPtr(5); + return state->unk10; +} + +int sub_81CAE38(void) +{ + struct Pokenav3Struct *state = GetSubstructPtr(5); + return state->unkA; +} + +int sub_81CAE48(void) +{ + struct Pokenav3Struct *state = GetSubstructPtr(5); + return state->unkC; +} + +int unref_sub_81CAE58(void) +{ + struct Pokenav3Struct *state = GetSubstructPtr(5); + return state->unkA - state->unkC; +} + +int unref_sub_81CAE6C(int arg0) +{ + struct Pokenav3Struct *state = GetSubstructPtr(5); + arg0 += state->unkC; + if (arg0 >= state->unkA) + return REMATCH_TABLE_ENTRIES; + + return state->unk1C[arg0].unk2; +} + +struct Pokenav3Struct_Unk1C *sub_81CAE94(void) +{ + struct Pokenav3Struct *state = GetSubstructPtr(5); + return state->unk1C; +} + +u16 sub_81CAEA4(int index) +{ + struct Pokenav3Struct *state = GetSubstructPtr(5); + return state->unk1C[index].unk1; +} + +bool32 sub_81CAEBC(int index) +{ + struct Pokenav3Struct *state = GetSubstructPtr(5); + if (!state->unk1C[index].unk0) + index = state->unk1C[index].unk2; + else + index = MatchCall_GetRematchTableIdx(state->unk1C[index].unk2); + + if (index == REMATCH_TABLE_ENTRIES) + return FALSE; + + return gSaveBlock1Ptr->trainerRematches[index] != 0; +} + +int sub_81CAF04(int index) +{ + int var0; + struct Pokenav3Struct *state = GetSubstructPtr(5); + if (!state->unk1C[index].unk0) + { + index = GetTrainerIdxByRematchIdx(state->unk1C[index].unk2); + return gTrainers[index].trainerPic; + } + + var0 = state->unk1C[index].unk2; + index = MatchCall_GetRematchTableIdx(var0); + if (index != REMATCH_TABLE_ENTRIES) + { + index = GetTrainerIdxByRematchIdx(index); + return gTrainers[index].trainerPic; + } + + index = sub_81D1BD0(var0); + return gFacilityClassToPicIndex[index]; +} + +const u8 *sub_81CAF78(int index, u8 *arg1) +{ + struct Pokenav3Struct *state = GetSubstructPtr(5); + *arg1 = 0; + if (!Overworld_MapTypeAllowsTeleportAndFly(gMapHeader.mapType)) + return gText_CallCantBeMadeHere; + + if (!state->unk1C[index].unk0) + *arg1 = SelectMatchCallMessage(GetTrainerIdxByRematchIdx(state->unk1C[index].unk2), gStringVar4); + else + MatchCall_GetMessage(state->unk1C[index].unk2, gStringVar4); + + return gStringVar4; +} + +const u8 *sub_81CAFD8(int index, int textType) +{ + int var0; + struct Pokenav3Struct *state = GetSubstructPtr(5); + if (state->unk1C[index].unk0) + { + var0 = MatchCall_GetRematchTableIdx(state->unk1C[index].unk2); + if (var0 == REMATCH_TABLE_ENTRIES) + return sub_81D1B40(state->unk1C[index].unk2, textType); + } + else + { + var0 = state->unk1C[index].unk2; + } + + return gUnknown_08622028[var0][textType]; +} + +u16 sub_81CB01C(void) +{ + struct Pokenav3Struct *state = GetSubstructPtr(5); + return state->unk0; +} + +u16 sub_81CB02C(int arg0) +{ + struct Pokenav3Struct *state = GetSubstructPtr(5); + if (state->unk2 < arg0) + return 3; + + return state->unk4[arg0]; +} + +void sub_81CB050(struct Pokenav3Struct_Unk1C *arg0, u8 *str) +{ + const u8 *trainerName; + const u8 *className; + if (!arg0->unk0) + { + int index = GetTrainerIdxByRematchIdx(arg0->unk2); + const struct Trainer *trainer = &gTrainers[index]; + int class = trainer->trainerClass; + className = gTrainerClassNames[class]; + trainerName = trainer->trainerName; + } + else + { + sub_81D1A78(arg0->unk2, &className, &trainerName); + } + + if (className && trainerName) + { + u8 *str2 = sub_81DB494(str, 7, className, 69); + sub_81DB494(str2, 7, trainerName, 51); + } + else + { + sub_81DB494(str, 7, NULL, 120); + } +} + +int sub_81CB0C8(int rematchIndex) +{ + int mapGroup = gRematchTable[rematchIndex].mapGroup; + int mapNum = gRematchTable[rematchIndex].mapNum; + return Overworld_GetMapHeaderByGroupAndId(mapGroup, mapNum)->regionMapSectionId; +} + +int sub_81CB0E4(int index) +{ + struct Pokenav3Struct *state = GetSubstructPtr(5); + int count = 1; + while (++index < state->unkA) + { + if (!state->unk1C[index].unk0) + return count; + if (sub_81D17E8(state->unk1C[index].unk2)) + return count; + + count++; + } + + return 0; +} + +int sub_81CB128(int index) +{ + struct Pokenav3Struct *state = GetSubstructPtr(5); + int count = -1; + while (--index >= 0) + { + if (!state->unk1C[index].unk0) + return count; + if (sub_81D17E8(state->unk1C[index].unk2)) + return count; + + count--; + } + + return 0; +} + +bool32 unref_sub_81CB16C(void) +{ + int i; + + for (i = 0; i < REMATCH_TABLE_ENTRIES; i++) + { + if (sub_81CAE08(i) && gSaveBlock1Ptr->trainerRematches[i]) + return TRUE; + } + + for (i = 0; i < 21; i++) // TODO: This is the size of sMatchCallHeaders + { + if (MatchCallFlagGetByIndex(i)) + { + int index = MatchCall_GetRematchTableIdx(i); + if (gSaveBlock1Ptr->trainerRematches[index]) + return TRUE; + } + } + + return FALSE; +} + +static bool32 sub_81CB1D0(void) +{ + struct Pokenav3Struct *state = GetSubstructPtr(5); + int index = GetSelectedMatchCall(); + if (!state->unk1C[index].unk0) + { + if (sub_81CAEA4(index) == gMapHeader.regionMapSectionId) + { + if (!gSaveBlock1Ptr->trainerRematches[state->unk1C[index].unk2]) + return TRUE; + } + } + else + { + if (state->unk1C[index].unk2 == 11) + { + if (sub_81CAEA4(index) == gMapHeader.regionMapSectionId + && FlagGet(FLAG_BADGE05_GET) == TRUE) + { + if (!FlagGet(FLAG_WATTSON_REMATCH_AVAILABLE)) + return TRUE; + } + } + } + + return FALSE; +}