diff --git a/asm/battle_frontier_1.s b/asm/battle_frontier_1.s index 1aa100d79..a68dbf329 100644 --- a/asm/battle_frontier_1.s +++ b/asm/battle_frontier_1.s @@ -5,859 +5,6 @@ .text - thumb_func_start sub_819314C -sub_819314C: @ 819314C - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0x80 - lsls r0, 24 - lsrs r0, 24 - str r0, [sp, 0x34] - lsls r1, 24 - lsrs r6, r1, 24 - movs r0, 0 - str r0, [sp, 0x3C] - movs r7, 0 - movs r1, 0 - str r1, [sp, 0x40] - movs r2, 0 - str r2, [sp, 0x44] - mov r9, r2 - movs r0, 0x1 - ldr r3, [sp, 0x34] - ands r0, r3 - cmp r0, 0 - beq _08193186 - movs r7, 0x8 - str r7, [sp, 0x3C] - movs r7, 0x9 - movs r0, 0x2 - mov r9, r0 -_08193186: - movs r0, 0x2 - ldr r1, [sp, 0x34] - ands r0, r1 - cmp r0, 0 - beq _08193196 - movs r2, 0x80 - lsls r2, 1 - str r2, [sp, 0x40] -_08193196: - movs r0, 0x4 - ldr r3, [sp, 0x34] - ands r0, r3 - cmp r0, 0 - beq _081931A4 - movs r0, 0xA0 - str r0, [sp, 0x44] -_081931A4: - movs r0, 0x8 - ldr r1, [sp, 0x34] - ands r0, r1 - cmp r0, 0 - beq _081931B2 - ldr r2, =0xffffff00 - str r2, [sp, 0x40] -_081931B2: - movs r0, 0x10 - ldr r3, [sp, 0x34] - ands r0, r3 - cmp r0, 0 - beq _081931C2 - movs r0, 0xA0 - negs r0, r0 - str r0, [sp, 0x44] -_081931C2: - ldr r4, =gUnknown_0203CD78 - ldr r1, [r4] - adds r1, 0x11 - adds r0, r6, 0 - bl sub_8192F08 - str r0, [sp, 0x38] - movs r5, 0 - mov r1, sp - adds r1, 0x1C - str r1, [sp, 0x48] - mov r2, sp - adds r2, 0x24 - str r2, [sp, 0x4C] - lsls r1, r6, 1 - mov r3, sp - adds r3, 0x2C - str r3, [sp, 0x50] - ldr r0, [sp, 0x40] - adds r0, 0x30 - mov r8, r0 - ldr r2, [sp, 0x44] - adds r2, 0x58 - str r2, [sp, 0x78] - movs r3, 0xC - add r3, r9 - mov r10, r3 - ldr r0, [sp, 0x40] - adds r0, 0xC0 - str r0, [sp, 0x7C] - mov r2, r9 - adds r2, 0xD - str r2, [sp, 0x74] - ldr r3, [sp, 0x3C] - adds r3, 0x1 - mov r9, r3 - ldr r0, [sp, 0x3C] - adds r0, 0x2 - str r0, [sp, 0x54] - ldr r2, [sp, 0x3C] - adds r2, 0x5 - str r2, [sp, 0x5C] - adds r3, r7, 0 - adds r3, 0x8 - str r3, [sp, 0x6C] - adds r0, r7, 0x6 - str r0, [sp, 0x64] - adds r2, r7, 0x7 - str r2, [sp, 0x68] - lsls r3, r6, 2 - str r3, [sp, 0x58] - adds r0, r7, 0x5 - str r0, [sp, 0x60] - ldr r0, [r4] - adds r0, 0x11 - mov r12, r0 - ldr r0, =gSaveBlock2Ptr - ldr r4, [r0] - ldr r0, =gUnknown_0860D3C6 - movs r3, 0 - adds r1, r6 - adds r1, r0 - ldrb r6, [r1] -_08193240: - ldr r1, [sp, 0x48] - adds r2, r3, r1 - mov r7, r12 - adds r0, r7, r5 - ldrb r0, [r0] - str r0, [r2] - ldr r7, [sp, 0x4C] - adds r1, r3, r7 - lsls r0, 2 - adds r0, r4, r0 - ldr r7, =0x00000d24 - adds r0, r7 - ldrh r0, [r0] - lsls r0, 22 - lsrs r0, 22 - str r0, [r1] - ldr r0, [r2] - lsls r0, 2 - adds r0, r4, r0 - ldr r1, =0x00000d25 - adds r0, r1 - ldrb r1, [r0] - lsls r0, r1, 27 - lsrs r0, 30 - cmp r0, r6 - bhi _0819329C - lsls r0, r1, 29 - cmp r0, 0 - bge _0819329C - ldr r2, [sp, 0x50] - adds r1, r3, r2 - movs r0, 0x1 - b _081932A2 - .pool -_0819329C: - ldr r7, [sp, 0x50] - adds r1, r3, r7 - movs r0, 0 -_081932A2: - str r0, [r1] - adds r3, 0x4 - adds r5, 0x1 - cmp r5, 0x1 - ble _08193240 - ldr r1, [sp, 0x24] - ldr r0, =0x000003ff - cmp r1, r0 - bne _081932D4 - ldr r0, =gSaveBlock2Ptr - ldr r0, [r0] - ldrb r0, [r0, 0x8] - bl PlayerGenderToFrontTrainerPicId - lsls r0, 16 - lsrs r0, 16 - mov r2, r8 - ldr r3, [sp, 0x78] - mov r1, r10 - str r1, [sp] - b _081932F8 - .pool -_081932D4: - ldr r0, =0x000003fe - cmp r1, r0 - bne _081932E4 - bl GetDomeBrainTrainerPicId - b _081932EC - .pool -_081932E4: - lsls r0, r1, 16 - lsrs r0, 16 - bl GetFrontierTrainerFrontSpriteId -_081932EC: - lsls r0, 24 - lsrs r0, 24 - mov r2, r8 - ldr r3, [sp, 0x78] - mov r7, r10 - str r7, [sp] -_081932F8: - ldr r1, =0x0000ffff - str r1, [sp, 0x4] - movs r1, 0x1 - bl CreateTrainerPicSprite - ldr r1, =gUnknown_0203CD78 - ldr r1, [r1] - ldr r2, [sp, 0x3C] - adds r1, r2 - strb r0, [r1] - movs r0, 0x1E - ldr r3, [sp, 0x34] - ands r0, r3 - cmp r0, 0 - beq _08193334 - ldr r2, =gSprites - ldr r0, =gUnknown_0203CD78 - ldr r0, [r0] - ldr r7, [sp, 0x3C] - adds r0, r7 - ldrb r1, [r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r2 - adds r0, 0x3E - ldrb r1, [r0] - movs r2, 0x4 - orrs r1, r2 - strb r1, [r0] -_08193334: - ldr r0, [sp, 0x2C] - cmp r0, 0 - beq _0819335A - ldr r2, =gSprites - ldr r0, =gUnknown_0203CD78 - ldr r0, [r0] - ldr r1, [sp, 0x3C] - adds r0, r1 - ldrb r1, [r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r2 - ldrb r2, [r0, 0x5] - movs r1, 0xF - ands r1, r2 - movs r2, 0x30 - orrs r1, r2 - strb r1, [r0, 0x5] -_0819335A: - ldr r2, [sp, 0x4C] - ldr r1, [r2, 0x4] - ldr r0, =0x000003ff - cmp r1, r0 - bne _08193388 - ldr r0, =gSaveBlock2Ptr - ldr r0, [r0] - ldrb r0, [r0, 0x8] - bl PlayerGenderToFrontTrainerPicId - lsls r0, 16 - lsrs r0, 16 - b _081933B0 - .pool -_08193388: - ldr r0, =0x000003fe - cmp r1, r0 - bne _081933A4 - bl GetDomeBrainTrainerPicId - lsls r0, 24 - lsrs r0, 24 - ldr r2, [sp, 0x7C] - ldr r3, [sp, 0x78] - ldr r1, [sp, 0x74] - str r1, [sp] - b _081933B8 - .pool -_081933A4: - lsls r0, r1, 16 - lsrs r0, 16 - bl GetFrontierTrainerFrontSpriteId - lsls r0, 24 - lsrs r0, 24 -_081933B0: - ldr r2, [sp, 0x7C] - ldr r3, [sp, 0x78] - ldr r7, [sp, 0x74] - str r7, [sp] -_081933B8: - ldr r1, =0x0000ffff - str r1, [sp, 0x4] - movs r1, 0x1 - bl CreateTrainerPicSprite - ldr r1, =gUnknown_0203CD78 - ldr r1, [r1] - add r1, r9 - strb r0, [r1] - movs r0, 0x1E - ldr r1, [sp, 0x34] - ands r0, r1 - cmp r0, 0 - beq _081933F0 - ldr r2, =gSprites - ldr r0, =gUnknown_0203CD78 - ldr r0, [r0] - add r0, r9 - ldrb r1, [r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r2 - adds r0, 0x3E - ldrb r1, [r0] - movs r2, 0x4 - orrs r1, r2 - strb r1, [r0] -_081933F0: - ldr r2, [sp, 0x50] - ldr r0, [r2, 0x4] - cmp r0, 0 - beq _08193416 - ldr r2, =gSprites - ldr r0, =gUnknown_0203CD78 - ldr r0, [r0] - add r0, r9 - ldrb r1, [r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r2 - ldrb r2, [r0, 0x5] - movs r1, 0xF - ands r1, r2 - movs r2, 0x30 - orrs r1, r2 - strb r1, [r0, 0x5] -_08193416: - movs r5, 0 - ldr r3, [sp, 0x38] - lsls r3, 2 - str r3, [sp, 0x70] - mov r8, r5 - ldr r6, =gUnknown_0203CD78 - ldr r7, =gSprites - ldr r4, [sp, 0x54] - mov r9, r5 - movs r0, 0x1 - mov r10, r0 -_0819342C: - ldr r1, [sp, 0x24] - ldr r0, =0x000003ff - cmp r1, r0 - bne _08193464 - ldr r0, =gSaveBlock2Ptr - ldr r2, [r0] - ldr r1, [sp, 0x1C] - lsls r0, r1, 1 - adds r0, r1 - lsls r0, 1 - add r0, r9 - ldr r1, =0x00000d64 - adds r2, r1 - adds r2, r0 - ldrh r0, [r2] - b _081934B0 - .pool -_08193464: - ldr r0, =0x000003fe - cmp r1, r0 - bne _08193490 - ldr r0, =gSaveBlock2Ptr - ldr r2, [r0] - ldr r1, [sp, 0x1C] - lsls r0, r1, 1 - adds r0, r1 - lsls r0, 1 - add r0, r9 - ldr r1, =0x00000d64 - adds r2, r1 - adds r2, r0 - ldrh r0, [r2] - b _081934B0 - .pool -_08193490: - ldr r0, =gSaveBlock2Ptr - ldr r2, [r0] - ldr r1, [sp, 0x1C] - lsls r0, r1, 1 - adds r0, r1 - lsls r0, 1 - add r0, r9 - ldr r1, =0x00000d64 - adds r2, r1 - adds r2, r0 - ldrh r1, [r2] - ldr r0, =gFacilityTrainerMons - ldr r0, [r0] - lsls r1, 4 - adds r1, r0 - ldrh r0, [r1] -_081934B0: - ldr r1, =gUnknown_0860D3A8 - adds r1, r5, r1 - ldrb r2, [r1] - ldr r3, [sp, 0x40] - orrs r2, r3 - ldr r1, =gUnknown_0860D3AB - adds r1, r5, r1 - ldrb r3, [r1] - ldr r1, [sp, 0x44] - adds r3, r1 - mov r1, r8 - str r1, [sp] - str r1, [sp, 0x4] - mov r1, r10 - str r1, [sp, 0x8] - ldr r1, =sub_8190938 - bl CreateMonIcon - ldr r1, [r6] - adds r1, r4 - strb r0, [r1] - ldr r0, [r6] - adds r0, r4 - ldrb r1, [r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r7 - ldrb r1, [r0, 0x5] - movs r3, 0xD - negs r3, r3 - adds r2, r3, 0 - ands r1, r2 - strb r1, [r0, 0x5] - movs r0, 0x1E - ldr r1, [sp, 0x34] - ands r0, r1 - cmp r0, 0 - beq _08193516 - ldr r0, [r6] - adds r0, r4 - ldrb r1, [r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r7 - adds r0, 0x3E - ldrb r1, [r0] - movs r2, 0x4 - orrs r1, r2 - strb r1, [r0] -_08193516: - ldr r0, [sp, 0x2C] - cmp r0, 0 - beq _08193548 - ldr r0, [r6] - adds r0, r4 - ldrb r0, [r0] - lsls r1, r0, 4 - adds r1, r0 - lsls r1, 2 - adds r1, r7 - ldrb r2, [r1, 0x5] - movs r0, 0xF - ands r0, r2 - movs r2, 0x30 - orrs r0, r2 - strb r0, [r1, 0x5] - ldr r0, [r6] - adds r0, r4 - ldrb r1, [r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r7 - mov r2, r10 - strh r2, [r0, 0x34] -_08193548: - adds r4, 0x1 - movs r3, 0x2 - add r9, r3 - adds r5, 0x1 - cmp r5, 0x2 - bgt _08193556 - b _0819342C -_08193556: - movs r5, 0 - ldr r6, =gUnknown_0203CD78 - ldr r7, =gSprites - mov r8, r7 - ldr r4, [sp, 0x5C] - mov r9, r5 - movs r7, 0 -_08193564: - ldr r0, [sp, 0x4C] - ldr r1, [r0, 0x4] - ldr r0, =0x000003ff - cmp r1, r0 - bne _081935AC - ldr r0, =gSaveBlock2Ptr - ldr r2, [r0] - ldr r3, [sp, 0x48] - ldr r1, [r3, 0x4] - lsls r0, r1, 1 - adds r0, r1 - lsls r0, 1 - add r0, r9 - ldr r1, =0x00000d64 - adds r2, r1 - adds r2, r0 - ldrh r0, [r2] - b _081935FA - .pool -_081935AC: - ldr r0, =0x000003fe - cmp r1, r0 - bne _081935D8 - ldr r0, =gSaveBlock2Ptr - ldr r2, [r0] - ldr r0, [sp, 0x48] - ldr r1, [r0, 0x4] - lsls r0, r1, 1 - adds r0, r1 - lsls r0, 1 - add r0, r9 - ldr r1, =0x00000d64 - adds r2, r1 - adds r2, r0 - ldrh r0, [r2] - b _081935FA - .pool -_081935D8: - ldr r0, =gSaveBlock2Ptr - ldr r2, [r0] - ldr r0, [sp, 0x48] - ldr r1, [r0, 0x4] - lsls r0, r1, 1 - adds r0, r1 - lsls r0, 1 - add r0, r9 - ldr r1, =0x00000d64 - adds r2, r1 - adds r2, r0 - ldrh r1, [r2] - ldr r0, =gFacilityTrainerMons - ldr r0, [r0] - lsls r1, 4 - adds r1, r0 - ldrh r0, [r1] -_081935FA: - ldr r1, =gUnknown_0860D3AE - adds r1, r5, r1 - ldrb r2, [r1] - ldr r3, [sp, 0x40] - orrs r2, r3 - ldr r1, =gUnknown_0860D3B1 - adds r1, r5, r1 - ldrb r3, [r1] - ldr r1, [sp, 0x44] - adds r3, r1 - str r7, [sp] - str r7, [sp, 0x4] - movs r1, 0x1 - str r1, [sp, 0x8] - ldr r1, =sub_8190938 - bl CreateMonIcon - ldr r1, [r6] - adds r1, r4 - strb r0, [r1] - ldr r0, [r6] - adds r0, r4 - ldrb r1, [r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - add r0, r8 - ldrb r1, [r0, 0x5] - movs r3, 0xD - negs r3, r3 - adds r2, r3, 0 - ands r1, r2 - strb r1, [r0, 0x5] - movs r0, 0x1E - ldr r1, [sp, 0x34] - ands r0, r1 - cmp r0, 0 - beq _0819365E - ldr r0, [r6] - adds r0, r4 - ldrb r1, [r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - add r0, r8 - adds r0, 0x3E - ldrb r1, [r0] - movs r2, 0x4 - orrs r1, r2 - strb r1, [r0] -_0819365E: - ldr r2, [sp, 0x50] - ldr r0, [r2, 0x4] - cmp r0, 0 - beq _08193692 - ldr r0, [r6] - adds r0, r4 - ldrb r0, [r0] - lsls r1, r0, 4 - adds r1, r0 - lsls r1, 2 - add r1, r8 - ldrb r2, [r1, 0x5] - movs r0, 0xF - ands r0, r2 - movs r2, 0x30 - orrs r0, r2 - strb r0, [r1, 0x5] - ldr r0, [r6] - adds r0, r4 - ldrb r1, [r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - add r0, r8 - movs r1, 0x1 - strh r1, [r0, 0x34] -_08193692: - adds r4, 0x1 - movs r3, 0x2 - add r9, r3 - adds r5, 0x1 - cmp r5, 0x2 - bgt _081936A0 - b _08193564 -_081936A0: - add r0, sp, 0xC - movs r5, 0 - strb r5, [r0, 0x6] - adds r1, r0, 0 - movs r0, 0x2 - strb r0, [r1, 0x7] - adds r0, r1, 0 - ldrb r0, [r0, 0x6] - strb r0, [r1, 0x8] - adds r0, r1, 0 - ldrb r0, [r0, 0x7] - strb r0, [r1, 0x9] - adds r0, r1, 0 - strb r5, [r0, 0xA] - strb r5, [r0, 0xB] - adds r3, r0, 0 - ldrb r2, [r3, 0xC] - movs r1, 0x10 - negs r1, r1 - adds r0, r1, 0 - ands r0, r2 - strb r0, [r3, 0xC] - adds r2, r3, 0 - movs r0, 0xE0 - strb r0, [r2, 0xC] - ldrb r0, [r2, 0xD] - ands r1, r0 - strb r1, [r2, 0xD] - adds r1, r2, 0 - movs r0, 0xD0 - strb r0, [r1, 0xD] - ldr r4, =gStringVar4 - ldr r0, =gBattleDomeWinStringsPointers - ldr r7, [sp, 0x70] - adds r0, r7, r0 - ldr r1, [r0] - adds r0, r4, 0 - bl StringExpandPlaceholders - str r4, [sp, 0xC] - add r0, sp, 0xC - add r1, sp, 0x6C - ldrb r1, [r1] - strb r1, [r0, 0x4] - adds r1, r0, 0 - movs r0, 0x1 - strb r0, [r1, 0x5] - ldr r4, [sp, 0x6C] - adds r0, r4, 0 - bl PutWindowTilemap - adds r0, r4, 0 - movs r1, 0x3 - bl CopyWindowToVram - add r0, sp, 0xC - strb r5, [r0, 0x8] - adds r1, r0, 0 - strb r5, [r0, 0x7] - strb r5, [r1, 0x9] - movs r1, 0 - movs r2, 0 - bl AddTextPrinter - ldr r1, [sp, 0x24] - ldr r0, =0x000003ff - cmp r1, r0 - bne _0819375C - ldr r0, =gStringVar1 - ldr r1, =gSaveBlock2Ptr - ldr r1, [r1] - bl StringCopy - b _0819377E - .pool -_0819375C: - ldr r0, =0x000003fe - cmp r1, r0 - bne _08193774 - ldr r0, =gStringVar1 - bl CopyDomeBrainTrainerName - b _0819377E - .pool -_08193774: - ldr r0, =gStringVar1 - lsls r1, 16 - lsrs r1, 16 - bl CopyDomeOpponentName -_0819377E: - add r0, sp, 0xC - movs r4, 0x2 - strb r4, [r0, 0x5] - strb r4, [r0, 0xA] - ldr r5, =gStringVar1 - str r5, [sp, 0xC] - add r2, sp, 0x64 - ldrb r2, [r2] - strb r2, [r0, 0x4] - ldrb r0, [r0, 0x5] - ldr r1, [sp, 0xC] - add r2, sp, 0xC - ldrb r3, [r2, 0xA] - movs r2, 0x40 - bl GetStringCenterAlignXOffsetWithLetterSpacing - add r1, sp, 0xC - strb r0, [r1, 0x8] - adds r0, r1, 0 - strb r4, [r0, 0x7] - strb r4, [r1, 0x9] - ldr r4, [sp, 0x64] - adds r0, r4, 0 - bl PutWindowTilemap - adds r0, r4, 0 - movs r1, 0x3 - bl CopyWindowToVram - add r0, sp, 0xC - movs r1, 0 - movs r2, 0 - bl AddTextPrinter - ldr r3, [sp, 0x4C] - ldr r1, [r3, 0x4] - ldr r0, =0x000003ff - cmp r1, r0 - bne _081937E4 - ldr r0, =gSaveBlock2Ptr - ldr r1, [r0] - adds r0, r5, 0 - bl StringCopy - b _08193802 - .pool -_081937E4: - ldr r0, =0x000003fe - cmp r1, r0 - bne _081937F8 - adds r0, r5, 0 - bl CopyDomeBrainTrainerName - b _08193802 - .pool -_081937F8: - lsls r1, 16 - lsrs r1, 16 - adds r0, r5, 0 - bl CopyDomeOpponentName -_08193802: - ldr r0, =gStringVar1 - str r0, [sp, 0xC] - add r0, sp, 0xC - movs r6, 0 - add r7, sp, 0x68 - ldrb r7, [r7] - strb r7, [r0, 0x4] - ldrb r0, [r0, 0x5] - ldr r1, [sp, 0xC] - add r2, sp, 0xC - ldrb r3, [r2, 0xA] - movs r2, 0x40 - bl GetStringCenterAlignXOffsetWithLetterSpacing - add r1, sp, 0xC - strb r0, [r1, 0x8] - adds r0, r1, 0 - movs r5, 0x2 - strb r5, [r0, 0x7] - strb r5, [r1, 0x9] - ldr r4, [sp, 0x68] - adds r0, r4, 0 - bl PutWindowTilemap - adds r0, r4, 0 - movs r1, 0x3 - bl CopyWindowToVram - add r0, sp, 0xC - movs r1, 0 - movs r2, 0 - bl AddTextPrinter - add r0, sp, 0xC - strb r6, [r0, 0xA] - ldr r0, =gBattleDomeMatchNumberPointers - ldr r1, [sp, 0x58] - adds r0, r1, r0 - ldr r0, [r0] - str r0, [sp, 0xC] - add r0, sp, 0xC - add r2, sp, 0x60 - ldrb r2, [r2] - strb r2, [r0, 0x4] - ldrb r0, [r0, 0x5] - ldr r1, [sp, 0xC] - add r2, sp, 0xC - ldrb r3, [r2, 0xA] - movs r2, 0xA0 - bl GetStringCenterAlignXOffsetWithLetterSpacing - add r1, sp, 0xC - strb r0, [r1, 0x8] - adds r0, r1, 0 - strb r5, [r0, 0x7] - strb r5, [r1, 0x9] - ldr r4, [sp, 0x60] - adds r0, r4, 0 - bl PutWindowTilemap - adds r0, r4, 0 - movs r1, 0x3 - bl CopyWindowToVram - add r0, sp, 0xC - movs r1, 0 - movs r2, 0 - bl AddTextPrinter - add sp, 0x80 - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_819314C - thumb_func_start sub_81938A4 sub_81938A4: @ 81938A4 push {lr} diff --git a/asm/battle_frontier_2.s b/asm/battle_frontier_2.s index ad7975875..7d17f5c6c 100644 --- a/asm/battle_frontier_2.s +++ b/asm/battle_frontier_2.s @@ -20049,7 +20049,7 @@ sub_81A4E04: @ 81A4E04 bl sub_81953A0 lsls r0, 16 lsrs r0, 16 - bl sub_818FC78 + bl GetTrainerMonCountInBits adds r4, r0, 0 b _081A4E46 .pool diff --git a/src/battle_frontier_1.c b/src/battle_frontier_1.c index 0c718ed74..ccead0845 100644 --- a/src/battle_frontier_1.c +++ b/src/battle_frontier_1.c @@ -105,9 +105,15 @@ extern const u8 gUnknown_0860C988[31][16]; extern const u8 gUnknown_0860D3F1[][2]; extern const u8 gUnknown_0860D3C4[][3]; extern const u8 gUnknown_0860D3B4[]; +extern const u8 gUnknown_0860D3A8[]; +extern const u8 gUnknown_0860D3AB[]; +extern const u8 gUnknown_0860D3AE[]; +extern const u8 gUnknown_0860D3B1[]; extern const u8 *const gBattleDomePotentialPointers[]; extern const u8 *const gBattleDomeOpponentStylePointers[]; extern const u8 *const gBattleDomeOpponentStatsPointers[]; +extern const u8 *const gBattleDomeWinStringsPointers[]; +extern const u8 *const gBattleDomeMatchNumberPointers[]; // gfx extern const u8 gUnknown_08D83D50[]; @@ -127,7 +133,7 @@ void SwapDomeTrainers(s32 id1, s32 id2, u16 *statsArray); void CalcDomeMonStats(u16 species, s32 level, s32 ivs, u8 evBits, u8 nature, s32 *stats); void CreateDomeTrainerMons(u16 tournamentTrainerId); u16 TrainerIdToTournamentId(u16 trainerId); -s32 sub_818FC78(u16 tournamentTrainerId); +s32 GetTrainerMonCountInBits(u16 tournamentTrainerId); s32 sub_818FCBC(u16 tournamentTrainerId, bool8 arg1); s32 sub_818FDB8(u16 tournamentTrainerId, bool8 arg1); s32 sub_818FFC0(s32 move, s32 species, s32 arg2); @@ -138,7 +144,7 @@ void sub_8190CD4(u8 taskId); void sub_8194220(u8 taskId); void sub_8194B54(void); void sub_8194B70(void); -void sub_819314C(u8, u8); +static void DrawMatchInfoOnCard(u8 flags, u8 matchNo); static void DisplayTrainerInfoOnCard(u8 flags, u8 trainerTournamentId); u8 sub_819221C(u8 taskId); s32 sub_8192F08(u8, u8*); @@ -979,7 +985,7 @@ void CreateDomeTrainerMons(u16 tournamentTrainerId) s32 i, bits; ZeroEnemyPartyMons(); - bits = sub_818FC78(tournamentTrainerId); + bits = GetTrainerMonCountInBits(tournamentTrainerId); otId = Random32(); if (Random() % 10 > 5) { @@ -1007,7 +1013,7 @@ void CreateDomeTrainerMons(u16 tournamentTrainerId) } } -s32 sub_818FC78(u16 tournamentTrainerId) +s32 GetTrainerMonCountInBits(u16 tournamentTrainerId) { s32 bits; if (Random() & 1) @@ -1695,7 +1701,7 @@ void sub_8190400(u8 taskId) gTasks[i].data[4] = r7; if (r9 == 2) { - sub_819314C(0, r5); + DrawMatchInfoOnCard(0, r5); gUnknown_0203CD78->unk_10 = 1; } else @@ -1730,7 +1736,11 @@ void sub_8190400(u8 taskId) } } -void sub_8190790(struct Sprite *sprite) +// Note: Card scrolling up means the current card goes down and another one appears from top. +// The same is true for scrolling left. +// That means that the sprite needs to move with the moving card in the opposite scrolling direction. + +static void SpriteCb_TrainerIconCardScrollUp(struct Sprite *sprite) { sprite->pos1.y += 4; if (sprite->data[0] != 0) @@ -1750,7 +1760,7 @@ void sub_8190790(struct Sprite *sprite) } } -void sub_81907F8(struct Sprite *sprite) +static void SpriteCb_TrainerIconCardScrollDown(struct Sprite *sprite) { sprite->pos1.y -= 4; if (sprite->data[0] != 0) @@ -1770,7 +1780,7 @@ void sub_81907F8(struct Sprite *sprite) } } -void sub_8190860(struct Sprite *sprite) +static void SpriteCb_TrainerIconCardScrollLeft(struct Sprite *sprite) { sprite->pos1.x += 4; if (sprite->data[0] != 0) @@ -1790,7 +1800,7 @@ void sub_8190860(struct Sprite *sprite) } } -void sub_81908CC(struct Sprite *sprite) +static void SpriteCb_TrainerIconCardScrollRight(struct Sprite *sprite) { sprite->pos1.x -= 4; if (sprite->data[0] != 0) @@ -1810,15 +1820,17 @@ void sub_81908CC(struct Sprite *sprite) } } -void sub_8190938(struct Sprite *sprite) +#define sMonIconStill data[3] + +static void SpriteCb_MonIcon(struct Sprite *sprite) { - if (!sprite->data[3]) + if (!sprite->sMonIconStill) UpdateMonIconFrame(sprite); } -void sub_8190950(struct Sprite *sprite) +static void SpriteCb_MonIconCardScrollUp(struct Sprite *sprite) { - if (!sprite->data[3]) + if (!sprite->sMonIconStill) UpdateMonIconFrame(sprite); sprite->pos1.y += 4; if (sprite->data[0] != 0) @@ -1826,7 +1838,7 @@ void sub_8190950(struct Sprite *sprite) if (sprite->pos1.y >= -16) sprite->invisible = 0; if (++sprite->data[1] == 40) - sprite->callback = sub_8190938; + sprite->callback = SpriteCb_MonIcon; } else { @@ -1838,9 +1850,9 @@ void sub_8190950(struct Sprite *sprite) } } -void sub_81909CC(struct Sprite *sprite) +static void SpriteCb_MonIconCardScrollDown(struct Sprite *sprite) { - if (!sprite->data[3]) + if (!sprite->sMonIconStill) UpdateMonIconFrame(sprite); sprite->pos1.y -= 4; if (sprite->data[0] != 0) @@ -1848,7 +1860,7 @@ void sub_81909CC(struct Sprite *sprite) if (sprite->pos1.y <= 176) sprite->invisible = 0; if (++sprite->data[1] == 40) - sprite->callback = sub_8190938; + sprite->callback = SpriteCb_MonIcon; } else { @@ -1860,9 +1872,9 @@ void sub_81909CC(struct Sprite *sprite) } } -void sub_8190A48(struct Sprite *sprite) +static void SpriteCb_MonIconCardScrollLeft(struct Sprite *sprite) { - if (!sprite->data[3]) + if (!sprite->sMonIconStill) UpdateMonIconFrame(sprite); sprite->pos1.x += 4; if (sprite->data[0] != 0) @@ -1870,7 +1882,7 @@ void sub_8190A48(struct Sprite *sprite) if (sprite->pos1.x >= -16) sprite->invisible = 0; if (++sprite->data[1] == 64) - sprite->callback = sub_8190938; + sprite->callback = SpriteCb_MonIcon; } else { @@ -1882,9 +1894,9 @@ void sub_8190A48(struct Sprite *sprite) } } -void sub_8190AC4(struct Sprite *sprite) +static void SpriteCb_MonIconCardScrollRight(struct Sprite *sprite) { - if (!sprite->data[3]) + if (!sprite->sMonIconStill) UpdateMonIconFrame(sprite); sprite->pos1.x -= 4; if (sprite->data[0] != 0) @@ -1892,7 +1904,7 @@ void sub_8190AC4(struct Sprite *sprite) if (sprite->pos1.x <= 256) sprite->invisible = 0; if (++sprite->data[1] == 64) - sprite->callback = sub_8190938; + sprite->callback = SpriteCb_MonIcon; } else { @@ -2006,10 +2018,11 @@ void sub_8190C6C(struct Sprite *sprite) void sub_8190CD4(u8 taskId) { s32 i; - s32 var; + s32 windowId = 0; s32 r9 = gTasks[taskId].data[3]; s32 taskId2 = gTasks[taskId].data[4]; - s32 trainerTournamentId, arg2; + s32 trainerTournamentId = 0; + s32 matchNo = 0; switch (gTasks[taskId].data[0]) { @@ -2035,11 +2048,11 @@ void sub_8190CD4(u8 taskId) case 1 ... 8: gTasks[taskId].data[5] = i; if (gTasks[taskId].data[2] != 0) - var = 9; + windowId = 9; else - var = 0; + windowId = 0; - for (i = var; i < var + 9; i++) + for (i = windowId; i < windowId + 9; i++) { CopyWindowToVram(i, 2); FillWindowPixelBuffer(i, 0); @@ -2093,8 +2106,8 @@ void sub_8190CD4(u8 taskId) { if (gUnknown_0203CD78->unk_10 == 0) { - arg2 = gTasks[taskId2].data[1] - 16; - sub_8192F08(arg2, gUnknown_0203CD78->unk_11); + matchNo = gTasks[taskId2].data[1] - 16; + sub_8192F08(matchNo, gUnknown_0203CD78->unk_11); gBattle_BG2_X = 0; gBattle_BG2_Y = 320; trainerTournamentId = gUnknown_0203CD78->unk_11[0]; @@ -2102,8 +2115,8 @@ void sub_8190CD4(u8 taskId) } else if (gUnknown_0203CD78->unk_10 == 2) { - arg2 = gTasks[taskId2].data[1] - 16; - sub_8192F08(arg2, gUnknown_0203CD78->unk_11); + matchNo = gTasks[taskId2].data[1] - 16; + sub_8192F08(matchNo, gUnknown_0203CD78->unk_11); gBattle_BG2_X = 0; gBattle_BG2_Y = 320; trainerTournamentId = gUnknown_0203CD78->unk_11[1]; @@ -2113,8 +2126,8 @@ void sub_8190CD4(u8 taskId) { gBattle_BG2_X = 256; gBattle_BG2_Y = 160; - arg2 = gTasks[taskId2].data[1] - 16; - sub_819314C(gTasks[taskId].data[2] | 0x10, arg2); + matchNo = gTasks[taskId2].data[1] - 16; + DrawMatchInfoOnCard(gTasks[taskId].data[2] | 0x10, matchNo); } } @@ -2124,7 +2137,7 @@ void sub_8190CD4(u8 taskId) { if (gUnknown_0203CD78->arr[i] != 0xFF) { - gSprites[gUnknown_0203CD78->arr[i]].callback = sub_8190790; + gSprites[gUnknown_0203CD78->arr[i]].callback = SpriteCb_TrainerIconCardScrollUp; gSprites[gUnknown_0203CD78->arr[i]].data[0] = gTasks[taskId].data[2] ^ 1; gSprites[gUnknown_0203CD78->arr[i]].data[1] = 0; gSprites[gUnknown_0203CD78->arr[i]].data[2] = i; @@ -2135,7 +2148,7 @@ void sub_8190CD4(u8 taskId) { if (gUnknown_0203CD78->arr[i] != 0xFF) { - gSprites[gUnknown_0203CD78->arr[i]].callback = sub_8190950; + gSprites[gUnknown_0203CD78->arr[i]].callback = SpriteCb_MonIconCardScrollUp; gSprites[gUnknown_0203CD78->arr[i]].data[0] = gTasks[taskId].data[2] ^ 1; gSprites[gUnknown_0203CD78->arr[i]].data[1] = 0; gSprites[gUnknown_0203CD78->arr[i]].data[2] = i; @@ -2148,7 +2161,7 @@ void sub_8190CD4(u8 taskId) { if (gUnknown_0203CD78->arr[i] != 0xFF) { - gSprites[gUnknown_0203CD78->arr[i]].callback = sub_8190790; + gSprites[gUnknown_0203CD78->arr[i]].callback = SpriteCb_TrainerIconCardScrollUp; gSprites[gUnknown_0203CD78->arr[i]].data[0] = gTasks[taskId].data[2]; gSprites[gUnknown_0203CD78->arr[i]].data[1] = 0; gSprites[gUnknown_0203CD78->arr[i]].data[2] = i; @@ -2159,7 +2172,7 @@ void sub_8190CD4(u8 taskId) { if (gUnknown_0203CD78->arr[i] != 0xFF) { - gSprites[gUnknown_0203CD78->arr[i]].callback = sub_8190950; + gSprites[gUnknown_0203CD78->arr[i]].callback = SpriteCb_MonIconCardScrollUp; gSprites[gUnknown_0203CD78->arr[i]].data[0] = gTasks[taskId].data[2]; gSprites[gUnknown_0203CD78->arr[i]].data[1] = 0; gSprites[gUnknown_0203CD78->arr[i]].data[2] = i; @@ -2209,8 +2222,8 @@ void sub_8190CD4(u8 taskId) { if (gUnknown_0203CD78->unk_10 == 0) { - arg2 = gTasks[taskId2].data[1] - 16; - sub_8192F08(arg2, gUnknown_0203CD78->unk_11); + matchNo = gTasks[taskId2].data[1] - 16; + sub_8192F08(matchNo, gUnknown_0203CD78->unk_11); gBattle_BG2_X = 0; gBattle_BG2_Y = 160; trainerTournamentId = gUnknown_0203CD78->unk_11[0]; @@ -2218,8 +2231,8 @@ void sub_8190CD4(u8 taskId) } else if (gUnknown_0203CD78->unk_10 == 2) { - arg2 = gTasks[taskId2].data[1] - 16; - sub_8192F08(arg2, gUnknown_0203CD78->unk_11); + matchNo = gTasks[taskId2].data[1] - 16; + sub_8192F08(matchNo, gUnknown_0203CD78->unk_11); gBattle_BG2_X = 0; gBattle_BG2_Y = 160; trainerTournamentId = gUnknown_0203CD78->unk_11[1]; @@ -2229,8 +2242,8 @@ void sub_8190CD4(u8 taskId) { gBattle_BG2_X = 256; gBattle_BG2_Y = 0; - arg2 = gTasks[taskId2].data[1] - 16; - sub_819314C(gTasks[taskId].data[2] | 4, arg2); + matchNo = gTasks[taskId2].data[1] - 16; + DrawMatchInfoOnCard(gTasks[taskId].data[2] | 4, matchNo); } } @@ -2240,7 +2253,7 @@ void sub_8190CD4(u8 taskId) { if (gUnknown_0203CD78->arr[i] != 0xFF) { - gSprites[gUnknown_0203CD78->arr[i]].callback = sub_81907F8; + gSprites[gUnknown_0203CD78->arr[i]].callback = SpriteCb_TrainerIconCardScrollDown; gSprites[gUnknown_0203CD78->arr[i]].data[0] = gTasks[taskId].data[2] ^ 1; gSprites[gUnknown_0203CD78->arr[i]].data[1] = 0; gSprites[gUnknown_0203CD78->arr[i]].data[2] = i; @@ -2251,7 +2264,7 @@ void sub_8190CD4(u8 taskId) { if (gUnknown_0203CD78->arr[i] != 0xFF) { - gSprites[gUnknown_0203CD78->arr[i]].callback = sub_81909CC; + gSprites[gUnknown_0203CD78->arr[i]].callback = SpriteCb_MonIconCardScrollDown; gSprites[gUnknown_0203CD78->arr[i]].data[0] = gTasks[taskId].data[2] ^ 1; gSprites[gUnknown_0203CD78->arr[i]].data[1] = 0; gSprites[gUnknown_0203CD78->arr[i]].data[2] = i; @@ -2264,7 +2277,7 @@ void sub_8190CD4(u8 taskId) { if (gUnknown_0203CD78->arr[i] != 0xFF) { - gSprites[gUnknown_0203CD78->arr[i]].callback = sub_81907F8; + gSprites[gUnknown_0203CD78->arr[i]].callback = SpriteCb_TrainerIconCardScrollDown; gSprites[gUnknown_0203CD78->arr[i]].data[0] = gTasks[taskId].data[2]; gSprites[gUnknown_0203CD78->arr[i]].data[1] = 0; gSprites[gUnknown_0203CD78->arr[i]].data[2] = i; @@ -2275,7 +2288,7 @@ void sub_8190CD4(u8 taskId) { if (gUnknown_0203CD78->arr[i] != 0xFF) { - gSprites[gUnknown_0203CD78->arr[i]].callback = sub_81909CC; + gSprites[gUnknown_0203CD78->arr[i]].callback = SpriteCb_MonIconCardScrollDown; gSprites[gUnknown_0203CD78->arr[i]].data[0] = gTasks[taskId].data[2]; gSprites[gUnknown_0203CD78->arr[i]].data[1] = 0; gSprites[gUnknown_0203CD78->arr[i]].data[2] = i; @@ -2313,8 +2326,8 @@ void sub_8190CD4(u8 taskId) { gBattle_BG2_X = 256; gBattle_BG2_Y = 0; - trainerTournamentId = gUnknown_0860D15C[(gTasks[taskId2].data[1] * 4) + (gUnknown_0203CD78->unk_10 - 1)]; - sub_819314C(gTasks[taskId].data[2] | 8, trainerTournamentId); + matchNo = gUnknown_0860D15C[(gTasks[taskId2].data[1] * 4) + (gUnknown_0203CD78->unk_10 - 1)]; + DrawMatchInfoOnCard(gTasks[taskId].data[2] | 8, matchNo); } for (i = 0; i < DOME_TOURNAMENT_TRAINERS_COUNT / 2; i++) @@ -2323,7 +2336,7 @@ void sub_8190CD4(u8 taskId) { if (gUnknown_0203CD78->arr[i] != 0xFF) { - gSprites[gUnknown_0203CD78->arr[i]].callback = sub_8190860; + gSprites[gUnknown_0203CD78->arr[i]].callback = SpriteCb_TrainerIconCardScrollLeft; gSprites[gUnknown_0203CD78->arr[i]].data[0] = gTasks[taskId].data[2] ^ 1; gSprites[gUnknown_0203CD78->arr[i]].data[1] = 0; gSprites[gUnknown_0203CD78->arr[i]].data[2] = i; @@ -2334,7 +2347,7 @@ void sub_8190CD4(u8 taskId) { if (gUnknown_0203CD78->arr[i] != 0xFF) { - gSprites[gUnknown_0203CD78->arr[i]].callback = sub_8190A48; + gSprites[gUnknown_0203CD78->arr[i]].callback = SpriteCb_MonIconCardScrollLeft; gSprites[gUnknown_0203CD78->arr[i]].data[0] = gTasks[taskId].data[2] ^ 1; gSprites[gUnknown_0203CD78->arr[i]].data[1] = 0; gSprites[gUnknown_0203CD78->arr[i]].data[2] = i; @@ -2347,7 +2360,7 @@ void sub_8190CD4(u8 taskId) { if (gUnknown_0203CD78->arr[i] != 0xFF) { - gSprites[gUnknown_0203CD78->arr[i]].callback = sub_8190860; + gSprites[gUnknown_0203CD78->arr[i]].callback = SpriteCb_TrainerIconCardScrollLeft; gSprites[gUnknown_0203CD78->arr[i]].data[0] = gTasks[taskId].data[2]; gSprites[gUnknown_0203CD78->arr[i]].data[1] = 0; gSprites[gUnknown_0203CD78->arr[i]].data[2] = i; @@ -2358,7 +2371,7 @@ void sub_8190CD4(u8 taskId) { if (gUnknown_0203CD78->arr[i] != 0xFF) { - gSprites[gUnknown_0203CD78->arr[i]].callback = sub_8190A48; + gSprites[gUnknown_0203CD78->arr[i]].callback = SpriteCb_MonIconCardScrollLeft; gSprites[gUnknown_0203CD78->arr[i]].data[0] = gTasks[taskId].data[2]; gSprites[gUnknown_0203CD78->arr[i]].data[1] = 0; gSprites[gUnknown_0203CD78->arr[i]].data[2] = i; @@ -2396,8 +2409,8 @@ void sub_8190CD4(u8 taskId) { gBattle_BG2_X = 0; gBattle_BG2_Y = 160; - arg2 = gTasks[taskId2].data[1] - 16; - sub_819314C(gTasks[taskId].data[2] | 8, arg2); + matchNo = gTasks[taskId2].data[1] - 16; + DrawMatchInfoOnCard(gTasks[taskId].data[2] | 8, matchNo); } for (i = 0; i < DOME_TOURNAMENT_TRAINERS_COUNT / 2; i++) @@ -2406,7 +2419,7 @@ void sub_8190CD4(u8 taskId) { if (gUnknown_0203CD78->arr[i] != 0xFF) { - gSprites[gUnknown_0203CD78->arr[i]].callback = sub_8190860; + gSprites[gUnknown_0203CD78->arr[i]].callback = SpriteCb_TrainerIconCardScrollLeft; gSprites[gUnknown_0203CD78->arr[i]].data[0] = gTasks[taskId].data[2] ^ 1; gSprites[gUnknown_0203CD78->arr[i]].data[1] = 0; gSprites[gUnknown_0203CD78->arr[i]].data[2] = i; @@ -2417,7 +2430,7 @@ void sub_8190CD4(u8 taskId) { if (gUnknown_0203CD78->arr[i] != 0xFF) { - gSprites[gUnknown_0203CD78->arr[i]].callback = sub_8190A48; + gSprites[gUnknown_0203CD78->arr[i]].callback = SpriteCb_MonIconCardScrollLeft; gSprites[gUnknown_0203CD78->arr[i]].data[0] = gTasks[taskId].data[2] ^ 1; gSprites[gUnknown_0203CD78->arr[i]].data[1] = 0; gSprites[gUnknown_0203CD78->arr[i]].data[2] = i; @@ -2430,7 +2443,7 @@ void sub_8190CD4(u8 taskId) { if (gUnknown_0203CD78->arr[i] != 0xFF) { - gSprites[gUnknown_0203CD78->arr[i]].callback = sub_8190860; + gSprites[gUnknown_0203CD78->arr[i]].callback = SpriteCb_TrainerIconCardScrollLeft; gSprites[gUnknown_0203CD78->arr[i]].data[0] = gTasks[taskId].data[2]; gSprites[gUnknown_0203CD78->arr[i]].data[1] = 0; gSprites[gUnknown_0203CD78->arr[i]].data[2] = i; @@ -2441,7 +2454,7 @@ void sub_8190CD4(u8 taskId) { if (gUnknown_0203CD78->arr[i] != 0xFF) { - gSprites[gUnknown_0203CD78->arr[i]].callback = sub_8190A48; + gSprites[gUnknown_0203CD78->arr[i]].callback = SpriteCb_MonIconCardScrollLeft; gSprites[gUnknown_0203CD78->arr[i]].data[0] = gTasks[taskId].data[2]; gSprites[gUnknown_0203CD78->arr[i]].data[1] = 0; gSprites[gUnknown_0203CD78->arr[i]].data[2] = i; @@ -2478,8 +2491,8 @@ void sub_8190CD4(u8 taskId) gBattle_BG2_X = 0; gBattle_BG2_Y = 0; } - trainerTournamentId = gUnknown_0860D15C[(gUnknown_0203CD78->unk_10 - 1) + (gTasks[taskId2].data[1] * 4)]; - sub_819314C(gTasks[taskId].data[2] | 2, trainerTournamentId); + matchNo = gUnknown_0860D15C[(gUnknown_0203CD78->unk_10 - 1) + (gTasks[taskId2].data[1] * 4)]; + DrawMatchInfoOnCard(gTasks[taskId].data[2] | 2, matchNo); for (i = 0; i < DOME_TOURNAMENT_TRAINERS_COUNT / 2; i++) { @@ -2487,7 +2500,7 @@ void sub_8190CD4(u8 taskId) { if (gUnknown_0203CD78->arr[i] != 0xFF) { - gSprites[gUnknown_0203CD78->arr[i]].callback = sub_81908CC; + gSprites[gUnknown_0203CD78->arr[i]].callback = SpriteCb_TrainerIconCardScrollRight; gSprites[gUnknown_0203CD78->arr[i]].data[0] = gTasks[taskId].data[2] ^ 1; gSprites[gUnknown_0203CD78->arr[i]].data[1] = 0; gSprites[gUnknown_0203CD78->arr[i]].data[2] = i; @@ -2498,7 +2511,7 @@ void sub_8190CD4(u8 taskId) { if (gUnknown_0203CD78->arr[i] != 0xFF) { - gSprites[gUnknown_0203CD78->arr[i]].callback = sub_8190AC4; + gSprites[gUnknown_0203CD78->arr[i]].callback = SpriteCb_MonIconCardScrollRight; gSprites[gUnknown_0203CD78->arr[i]].data[0] = gTasks[taskId].data[2] ^ 1; gSprites[gUnknown_0203CD78->arr[i]].data[1] = 0; gSprites[gUnknown_0203CD78->arr[i]].data[2] = i; @@ -2511,7 +2524,7 @@ void sub_8190CD4(u8 taskId) { if (gUnknown_0203CD78->arr[i] != 0xFF) { - gSprites[gUnknown_0203CD78->arr[i]].callback = sub_81908CC; + gSprites[gUnknown_0203CD78->arr[i]].callback = SpriteCb_TrainerIconCardScrollRight; gSprites[gUnknown_0203CD78->arr[i]].data[0] = gTasks[taskId].data[2]; gSprites[gUnknown_0203CD78->arr[i]].data[1] = 0; gSprites[gUnknown_0203CD78->arr[i]].data[2] = i; @@ -2522,7 +2535,7 @@ void sub_8190CD4(u8 taskId) { if (gUnknown_0203CD78->arr[i] != 0xFF) { - gSprites[gUnknown_0203CD78->arr[i]].callback = sub_8190AC4; + gSprites[gUnknown_0203CD78->arr[i]].callback = SpriteCb_MonIconCardScrollRight; gSprites[gUnknown_0203CD78->arr[i]].data[0] = gTasks[taskId].data[2]; gSprites[gUnknown_0203CD78->arr[i]].data[1] = 0; gSprites[gUnknown_0203CD78->arr[i]].data[2] = i; @@ -2560,8 +2573,8 @@ void sub_8190CD4(u8 taskId) { gBattle_BG2_X = 0; gBattle_BG2_Y = 160; - arg2 = gTasks[taskId2].data[1] - 16; - sub_819314C(gTasks[taskId].data[2] | 2, arg2); + matchNo = gTasks[taskId2].data[1] - 16; + DrawMatchInfoOnCard(gTasks[taskId].data[2] | 2, matchNo); } for (i = 0; i < DOME_TOURNAMENT_TRAINERS_COUNT / 2; i++) @@ -2570,7 +2583,7 @@ void sub_8190CD4(u8 taskId) { if (gUnknown_0203CD78->arr[i] != 0xFF) { - gSprites[gUnknown_0203CD78->arr[i]].callback = sub_81908CC; + gSprites[gUnknown_0203CD78->arr[i]].callback = SpriteCb_TrainerIconCardScrollRight; gSprites[gUnknown_0203CD78->arr[i]].data[0] = gTasks[taskId].data[2] ^ 1; gSprites[gUnknown_0203CD78->arr[i]].data[1] = 0; gSprites[gUnknown_0203CD78->arr[i]].data[2] = i; @@ -2581,7 +2594,7 @@ void sub_8190CD4(u8 taskId) { if (gUnknown_0203CD78->arr[i] != 0xFF) { - gSprites[gUnknown_0203CD78->arr[i]].callback = sub_8190AC4; + gSprites[gUnknown_0203CD78->arr[i]].callback = SpriteCb_MonIconCardScrollRight; gSprites[gUnknown_0203CD78->arr[i]].data[0] = gTasks[taskId].data[2] ^ 1; gSprites[gUnknown_0203CD78->arr[i]].data[1] = 0; gSprites[gUnknown_0203CD78->arr[i]].data[2] = i; @@ -2594,7 +2607,7 @@ void sub_8190CD4(u8 taskId) { if (gUnknown_0203CD78->arr[i] != 0xFF) { - gSprites[gUnknown_0203CD78->arr[i]].callback = sub_81908CC; + gSprites[gUnknown_0203CD78->arr[i]].callback = SpriteCb_TrainerIconCardScrollRight; gSprites[gUnknown_0203CD78->arr[i]].data[0] = gTasks[taskId].data[2]; gSprites[gUnknown_0203CD78->arr[i]].data[1] = 0; gSprites[gUnknown_0203CD78->arr[i]].data[2] = i; @@ -2605,7 +2618,7 @@ void sub_8190CD4(u8 taskId) { if (gUnknown_0203CD78->arr[i] != 0xFF) { - gSprites[gUnknown_0203CD78->arr[i]].callback = sub_8190AC4; + gSprites[gUnknown_0203CD78->arr[i]].callback = SpriteCb_MonIconCardScrollRight; gSprites[gUnknown_0203CD78->arr[i]].data[0] = gTasks[taskId].data[2]; gSprites[gUnknown_0203CD78->arr[i]].data[1] = 0; gSprites[gUnknown_0203CD78->arr[i]].data[2] = i; @@ -2866,7 +2879,7 @@ static void DisplayTrainerInfoOnCard(u8 flags, u8 trainerTournamentId) if (trainerId == TRAINER_PLAYER) { gUnknown_0203CD78->arr[2 + i + arrId] = CreateMonIcon(gSaveBlock2Ptr->frontier.domeMonId[trainerTournamentId][i], - sub_8190938, + SpriteCb_MonIcon, x | gUnknown_0860D340[i], y + gUnknown_0860D343[i], 0, 0, TRUE); @@ -2875,7 +2888,7 @@ static void DisplayTrainerInfoOnCard(u8 flags, u8 trainerTournamentId) else if (trainerId == TRAINER_FRONTIER_BRAIN) { gUnknown_0203CD78->arr[2 + i + arrId] = CreateMonIcon(gSaveBlock2Ptr->frontier.domeMonId[trainerTournamentId][i], - sub_8190938, + SpriteCb_MonIcon, x | gUnknown_0860D340[i], y + gUnknown_0860D343[i], 0, 0, TRUE); @@ -2884,7 +2897,7 @@ static void DisplayTrainerInfoOnCard(u8 flags, u8 trainerTournamentId) else { gUnknown_0203CD78->arr[2 + i + arrId] = CreateMonIcon(gFacilityTrainerMons[gSaveBlock2Ptr->frontier.domeMonId[trainerTournamentId][i]].species, - sub_8190938, + SpriteCb_MonIcon, x | gUnknown_0860D340[i], y + gUnknown_0860D343[i], 0, 0, TRUE); @@ -3250,3 +3263,212 @@ s32 sub_8192F08(u8 arg0, u8 *arg1) else return retVal + 1; } + +static void DrawMatchInfoOnCard(u8 flags, u8 matchNo) +{ + struct TextSubPrinter textPrinter; + s32 tournamentIds[2]; + s32 trainerIds[2]; + bool32 lost[2]; + s32 i; + s32 winStringId = 0; + s32 arrId = 0; + s32 windowId = 0; + s32 x = 0, y = 0; + u8 palSlot = 0; + + if (flags & 1) + arrId = 8, windowId = 9, palSlot = 2; + if (flags & 2) + x = 256; + if (flags & 4) + y = 160; + if (flags & 8) + x = -256; + if (flags & 0x10) + y = -160; + + // Copy trainers information to handy arrays. + winStringId = sub_8192F08(matchNo, gUnknown_0203CD78->unk_11); + for (i = 0; i < 2; i++) + { + tournamentIds[i] = gUnknown_0203CD78->unk_11[i]; + trainerIds[i] = gSaveBlock2Ptr->frontier.domeTrainers[tournamentIds[i]].trainerId; + if (gSaveBlock2Ptr->frontier.domeTrainers[tournamentIds[i]].unk2 <= gUnknown_0860D3C4[matchNo][2] + && gSaveBlock2Ptr->frontier.domeTrainers[tournamentIds[i]].unk1) + lost[i] = TRUE; + else + lost[i] = FALSE; + } + + // Draw first trainer sprite. + if (trainerIds[0] == TRAINER_PLAYER) + gUnknown_0203CD78->arr[arrId] = CreateTrainerPicSprite(PlayerGenderToFrontTrainerPicId(gSaveBlock2Ptr->playerGender), TRUE, x + 48, y + 88, palSlot + 12, 0xFFFF); + else if (trainerIds[0] == TRAINER_FRONTIER_BRAIN) + gUnknown_0203CD78->arr[arrId] = CreateTrainerPicSprite(GetDomeBrainTrainerPicId(), TRUE, x + 48, y + 88, palSlot + 12, 0xFFFF); + else + gUnknown_0203CD78->arr[arrId] = CreateTrainerPicSprite(GetFrontierTrainerFrontSpriteId(trainerIds[0]), TRUE, x + 48, y + 88, palSlot + 12, 0xFFFF); + + if (flags & 0x1E) + gSprites[gUnknown_0203CD78->arr[arrId]].invisible = 1; + if (lost[0]) + gSprites[gUnknown_0203CD78->arr[arrId]].oam.paletteNum = 3; + + // Draw second trainer sprite. + if (trainerIds[1] == TRAINER_PLAYER) + gUnknown_0203CD78->arr[1 + arrId] = CreateTrainerPicSprite(PlayerGenderToFrontTrainerPicId(gSaveBlock2Ptr->playerGender), TRUE, x + 192, y + 88, palSlot + 13, 0xFFFF); + else if (trainerIds[1] == TRAINER_FRONTIER_BRAIN) + gUnknown_0203CD78->arr[1 + arrId] = CreateTrainerPicSprite(GetDomeBrainTrainerPicId(), TRUE, x + 192, y + 88, palSlot + 13, 0xFFFF); + else + gUnknown_0203CD78->arr[1 + arrId] = CreateTrainerPicSprite(GetFrontierTrainerFrontSpriteId(trainerIds[1]), TRUE, x + 192, y + 88, palSlot + 13, 0xFFFF); + + if (flags & 0x1E) + gSprites[gUnknown_0203CD78->arr[1 + arrId]].invisible = 1; + if (lost[1]) + gSprites[gUnknown_0203CD78->arr[1 + arrId]].oam.paletteNum = 3; + + // Draw first trainer's pokemon icons. + for (i = 0; i < 3; i++) + { + if (trainerIds[0] == TRAINER_PLAYER) + { + gUnknown_0203CD78->arr[2 + i + arrId] = CreateMonIcon(gSaveBlock2Ptr->frontier.domeMonId[tournamentIds[0]][i], + SpriteCb_MonIcon, + x | gUnknown_0860D3A8[i], + y + gUnknown_0860D3AB[i], + 0, 0, TRUE); + gSprites[gUnknown_0203CD78->arr[2 + i + arrId]].oam.priority = 0; + } + else if (trainerIds[0] == TRAINER_FRONTIER_BRAIN) + { + gUnknown_0203CD78->arr[2 + i + arrId] = CreateMonIcon(gSaveBlock2Ptr->frontier.domeMonId[tournamentIds[0]][i], + SpriteCb_MonIcon, + x | gUnknown_0860D3A8[i], + y + gUnknown_0860D3AB[i], + 0, 0, TRUE); + gSprites[gUnknown_0203CD78->arr[2 + i + arrId]].oam.priority = 0; + } + else + { + gUnknown_0203CD78->arr[2 + i + arrId] = CreateMonIcon(gFacilityTrainerMons[gSaveBlock2Ptr->frontier.domeMonId[tournamentIds[0]][i]].species, + SpriteCb_MonIcon, + x | gUnknown_0860D3A8[i], + y + gUnknown_0860D3AB[i], + 0, 0, TRUE); + gSprites[gUnknown_0203CD78->arr[2 + i + arrId]].oam.priority = 0; + } + + if (flags & 0x1E) + gSprites[gUnknown_0203CD78->arr[2 + i + arrId]].invisible = 1; + if (lost[0]) + { + gSprites[gUnknown_0203CD78->arr[2 + i + arrId]].oam.paletteNum = 3; + gSprites[gUnknown_0203CD78->arr[2 + i + arrId]].sMonIconStill = TRUE; + } + } + + // Draw second trainer's pokemon icons. + for (i = 0; i < 3; i++) + { + if (trainerIds[1] == TRAINER_PLAYER) + { + gUnknown_0203CD78->arr[5 + i + arrId] = CreateMonIcon(gSaveBlock2Ptr->frontier.domeMonId[tournamentIds[1]][i], + SpriteCb_MonIcon, + x | gUnknown_0860D3AE[i], + y + gUnknown_0860D3B1[i], + 0, 0, TRUE); + gSprites[gUnknown_0203CD78->arr[5 + i + arrId]].oam.priority = 0; + } + else if (trainerIds[1] == TRAINER_FRONTIER_BRAIN) + { + gUnknown_0203CD78->arr[5 + i + arrId] = CreateMonIcon(gSaveBlock2Ptr->frontier.domeMonId[tournamentIds[1]][i], + SpriteCb_MonIcon, + x | gUnknown_0860D3AE[i], + y + gUnknown_0860D3B1[i], + 0, 0, TRUE); + gSprites[gUnknown_0203CD78->arr[5 + i + arrId]].oam.priority = 0; + } + else + { + gUnknown_0203CD78->arr[5 + i + arrId] = CreateMonIcon(gFacilityTrainerMons[gSaveBlock2Ptr->frontier.domeMonId[tournamentIds[1]][i]].species, + SpriteCb_MonIcon, + x | gUnknown_0860D3AE[i], + y + gUnknown_0860D3B1[i], + 0, 0, TRUE); + gSprites[gUnknown_0203CD78->arr[5 + i + arrId]].oam.priority = 0; + } + + if (flags & 0x1E) + gSprites[gUnknown_0203CD78->arr[5 + i + arrId]].invisible = 1; + if (lost[1]) + { + gSprites[gUnknown_0203CD78->arr[5 + i + arrId]].oam.paletteNum = 3; + gSprites[gUnknown_0203CD78->arr[5 + i + arrId]].sMonIconStill = TRUE; + } + } + + // Print the win string (or 'Let the battle begin!' one). + textPrinter.x = 0; + textPrinter.y = 2; + textPrinter.currentX = textPrinter.x; + textPrinter.currentY = textPrinter.y; + textPrinter.letterSpacing = 0; + textPrinter.lineSpacing = 0; + textPrinter.fontColor_l = 0; + textPrinter.fgColor = 14; + textPrinter.bgColor = 0; + textPrinter.shadowColor = 13; + StringExpandPlaceholders(gStringVar4, gBattleDomeWinStringsPointers[winStringId]); + textPrinter.current_text_offset = gStringVar4; + textPrinter.windowId = windowId + 8; + textPrinter.fontId = 1; + PutWindowTilemap(windowId + 8); + CopyWindowToVram(windowId + 8, 3); + textPrinter.currentX = 0; + textPrinter.currentY = textPrinter.y = 0; + AddTextPrinter(&textPrinter, 0, NULL); + + // Print first trainer's name. + if (trainerIds[0] == TRAINER_PLAYER) + StringCopy(gStringVar1, gSaveBlock2Ptr->playerName); + else if (trainerIds[0] == TRAINER_FRONTIER_BRAIN) + CopyDomeBrainTrainerName(gStringVar1); + else + CopyDomeOpponentName(gStringVar1, trainerIds[0]); + + textPrinter.fontId = 2; + textPrinter.letterSpacing = 2; + textPrinter.current_text_offset = gStringVar1; + textPrinter.windowId = windowId + 6; + textPrinter.currentX = GetStringCenterAlignXOffsetWithLetterSpacing(textPrinter.fontId, textPrinter.current_text_offset, 0x40, textPrinter.letterSpacing); + textPrinter.currentY = textPrinter.y = 2; + PutWindowTilemap(windowId + 6); + CopyWindowToVram(windowId + 6, 3); + AddTextPrinter(&textPrinter, 0, NULL); + + // Print second trainer's name. + if (trainerIds[1] == TRAINER_PLAYER) + StringCopy(gStringVar1, gSaveBlock2Ptr->playerName); + else if (trainerIds[1] == TRAINER_FRONTIER_BRAIN) + CopyDomeBrainTrainerName(gStringVar1); + else + CopyDomeOpponentName(gStringVar1, trainerIds[1]); + + textPrinter.current_text_offset = gStringVar1; + textPrinter.windowId = windowId + 7; + textPrinter.currentX = GetStringCenterAlignXOffsetWithLetterSpacing(textPrinter.fontId, textPrinter.current_text_offset, 0x40, textPrinter.letterSpacing); + textPrinter.currentY = textPrinter.y = 2; + PutWindowTilemap(windowId + 7); + CopyWindowToVram(windowId + 7, 3); + AddTextPrinter(&textPrinter, 0, NULL); + + // Print match number. + textPrinter.letterSpacing = 0; + textPrinter.current_text_offset = gBattleDomeMatchNumberPointers[matchNo]; + textPrinter.windowId = windowId + 5; + textPrinter.currentX = GetStringCenterAlignXOffsetWithLetterSpacing(textPrinter.fontId, textPrinter.current_text_offset, 0xA0, textPrinter.letterSpacing); + textPrinter.currentY = textPrinter.y = 2; + PutWindowTilemap(windowId + 5); + CopyWindowToVram(windowId + 5, 3); + AddTextPrinter(&textPrinter, 0, NULL); +}