From e85051712361063b04aa7a35ff5c25aed068cab9 Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Sat, 27 Oct 2018 21:01:35 +0200 Subject: [PATCH] more battle frontier 2 --- asm/battle_frontier_2.s | 1468 +---------------------------------- include/apprentice.h | 4 +- include/battle_frontier_2.h | 6 +- include/global.h | 53 +- include/tv.h | 2 + src/battle_dome.c | 108 +-- src/battle_frontier_2.c | 494 +++++++++++- src/battle_message.c | 8 +- src/battle_tower.c | 17 +- src/overworld.c | 2 +- src/tv.c | 6 +- 11 files changed, 567 insertions(+), 1601 deletions(-) diff --git a/asm/battle_frontier_2.s b/asm/battle_frontier_2.s index c5477493d..68c2f5465 100644 --- a/asm/battle_frontier_2.s +++ b/asm/battle_frontier_2.s @@ -7,1472 +7,6 @@ - thumb_func_start sub_81A2DB4 -sub_81A2DB4: @ 81A2DB4 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0x10 - adds r5, r0, 0 - adds r4, r2, 0 - ldr r0, [sp, 0x30] - lsls r1, 16 - lsrs r6, r1, 16 - lsls r4, 24 - lsrs r4, 24 - lsls r3, 24 - lsrs r3, 24 - str r3, [sp, 0xC] - lsls r0, 24 - lsrs r0, 24 - adds r7, r0, 0 - ldr r0, =gRecordsWindowId - mov r10, r0 - ldrb r0, [r0] - str r7, [sp] - movs r1, 0xFF - mov r9, r1 - str r1, [sp, 0x4] - movs r1, 0 - mov r8, r1 - str r1, [sp, 0x8] - movs r1, 0x1 - adds r2, r5, 0 - adds r3, r4, 0 - bl AddTextPrinterParameterized - ldr r0, =0x0000270f - cmp r6, r0 - bls _081A2E00 - adds r6, r0, 0 -_081A2E00: - ldr r0, =gStringVar1 - adds r1, r6, 0 - movs r2, 0x1 - movs r3, 0x4 - bl ConvertIntToDecimalStringN - ldr r4, =gStringVar4 - ldr r1, =gText_FloorsCleared - adds r0, r4, 0 - bl StringExpandPlaceholders - mov r1, r10 - ldrb r0, [r1] - str r7, [sp] - mov r1, r9 - str r1, [sp, 0x4] - mov r1, r8 - str r1, [sp, 0x8] - movs r1, 0x1 - adds r2, r4, 0 - ldr r3, [sp, 0xC] - bl AddTextPrinterParameterized - add sp, 0x10 - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81A2DB4 - - thumb_func_start sub_81A2E54 -sub_81A2E54: @ 81A2E54 - push {r4,r5,lr} - sub sp, 0x4 - adds r4, r1, 0 - adds r5, r2, 0 - lsls r0, 24 - lsls r4, 24 - lsrs r4, 24 - lsls r5, 24 - lsrs r5, 24 - lsls r3, 24 - lsrs r3, 24 - ldr r1, =gSaveBlock2Ptr - ldr r1, [r1] - lsrs r0, 23 - ldr r2, =0x00000e1e - adds r1, r2 - adds r1, r0 - ldrh r1, [r1] - ldr r0, =gText_Record - str r3, [sp] - adds r2, r4, 0 - adds r3, r5, 0 - bl sub_81A2DB4 - add sp, 0x4 - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81A2E54 - - thumb_func_start sub_81A2E98 -sub_81A2E98: @ 81A2E98 - push {lr} - lsls r0, 24 - ldr r1, =gSaveBlock2Ptr - ldr r1, [r1] - lsrs r0, 23 - ldr r2, =0x00000e1a - adds r1, r2 - adds r1, r0 - ldrh r0, [r1] - ldr r1, =0x0000270f - cmp r0, r1 - bls _081A2EB2 - adds r0, r1, 0 -_081A2EB2: - pop {r1} - bx r1 - .pool - thumb_func_end sub_81A2E98 - - thumb_func_start sub_81A2EC4 -sub_81A2EC4: @ 81A2EC4 - push {r4-r7,lr} - mov r7, r8 - push {r7} - sub sp, 0x4 - adds r4, r0, 0 - lsls r4, 24 - lsrs r4, 24 - lsls r1, 24 - lsrs r7, r1, 24 - lsls r2, 24 - lsrs r2, 24 - mov r8, r2 - lsls r3, 24 - lsrs r6, r3, 24 - adds r0, r4, 0 - bl sub_81A2E98 - lsls r0, 16 - lsrs r5, r0, 16 - cmp r4, 0 - beq _081A2EF4 - movs r0, 0x80 - lsls r0, 6 - b _081A2EF8 -_081A2EF4: - movs r0, 0x80 - lsls r0, 5 -_081A2EF8: - bl sub_81A1C24 - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bne _081A2F18 - ldr r0, =gText_Current - str r6, [sp] - adds r1, r5, 0 - adds r2, r7, 0 - mov r3, r8 - bl sub_81A2DB4 - b _081A2F26 - .pool -_081A2F18: - ldr r0, =gText_Prev - str r6, [sp] - adds r1, r5, 0 - adds r2, r7, 0 - mov r3, r8 - bl sub_81A2DB4 -_081A2F26: - add sp, 0x4 - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81A2EC4 - - thumb_func_start sub_81A2F38 -sub_81A2F38: @ 81A2F38 - push {r4-r6,lr} - sub sp, 0xC - ldr r5, =gRecordsWindowId - ldr r0, =gUnknown_08611C74 - bl AddWindow - strb r0, [r5] - ldrb r0, [r5] - movs r1, 0 - bl NewMenuHelpers_DrawStdWindowFrame - ldrb r0, [r5] - movs r1, 0x11 - bl FillWindowPixelBuffer - ldr r4, =gStringVar4 - ldr r1, =gText_BattleQuestResults - adds r0, r4, 0 - bl StringExpandPlaceholders - adds r0, r4, 0 - movs r1, 0x2 - bl sub_81A1C4C - ldrb r0, [r5] - ldr r2, =gText_Lv502 - movs r1, 0x31 - str r1, [sp] - movs r6, 0xFF - str r6, [sp, 0x4] - movs r4, 0 - str r4, [sp, 0x8] - movs r1, 0x1 - movs r3, 0x8 - bl AddTextPrinterParameterized - ldrb r0, [r5] - ldr r2, =gText_OpenLv - movs r1, 0x61 - str r1, [sp] - str r6, [sp, 0x4] - str r4, [sp, 0x8] - movs r1, 0x1 - movs r3, 0x8 - bl AddTextPrinterParameterized - movs r0, 0xA - bl PrintHyphens - movs r0, 0 - movs r1, 0x40 - movs r2, 0x6F - movs r3, 0x31 - bl sub_81A2EC4 - movs r0, 0 - movs r1, 0x40 - movs r2, 0x6F - movs r3, 0x41 - bl sub_81A2E54 - movs r0, 0x1 - movs r1, 0x40 - movs r2, 0x6F - movs r3, 0x61 - bl sub_81A2EC4 - movs r0, 0x1 - movs r1, 0x40 - movs r2, 0x6F - movs r3, 0x71 - bl sub_81A2E54 - ldrb r0, [r5] - bl PutWindowTilemap - ldrb r0, [r5] - movs r1, 0x3 - bl CopyWindowToVram - add sp, 0xC - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81A2F38 - - thumb_func_start sub_81A2FF8 -sub_81A2FF8: @ 81A2FF8 - push {r4-r7,lr} - mov r7, r9 - mov r6, r8 - push {r6,r7} - sub sp, 0xC - ldr r4, =gRecordsWindowId - ldr r0, =gUnknown_08611C7C - bl AddWindow - strb r0, [r4] - ldrb r0, [r4] - movs r1, 0 - bl NewMenuHelpers_DrawStdWindowFrame - ldrb r0, [r4] - movs r1, 0x11 - bl FillWindowPixelBuffer - ldr r0, =gStringVar4 - mov r9, r0 - ldr r1, =gText_LinkContestResults - bl StringExpandPlaceholders - movs r0, 0x1 - mov r1, r9 - movs r2, 0xD0 - bl GetStringCenterAlignXOffset - adds r3, r0, 0 - ldrb r0, [r4] - lsls r3, 24 - lsrs r3, 24 - movs r1, 0x1 - str r1, [sp] - movs r6, 0xFF - str r6, [sp, 0x4] - movs r5, 0 - str r5, [sp, 0x8] - mov r2, r9 - bl AddTextPrinterParameterized - ldr r7, =gText_1st - movs r0, 0x1 - adds r1, r7, 0 - movs r2, 0x26 - bl GetStringRightAlignXOffset - adds r3, r0, 0 - adds r3, 0x32 - ldrb r0, [r4] - lsls r3, 24 - lsrs r3, 24 - movs r1, 0x19 - mov r8, r1 - str r1, [sp] - str r6, [sp, 0x4] - str r5, [sp, 0x8] - movs r1, 0x1 - adds r2, r7, 0 - bl AddTextPrinterParameterized - ldr r7, =gText_2nd - movs r0, 0x1 - adds r1, r7, 0 - movs r2, 0x26 - bl GetStringRightAlignXOffset - adds r3, r0, 0 - adds r3, 0x58 - ldrb r0, [r4] - lsls r3, 24 - lsrs r3, 24 - mov r2, r8 - str r2, [sp] - str r6, [sp, 0x4] - str r5, [sp, 0x8] - movs r1, 0x1 - adds r2, r7, 0 - bl AddTextPrinterParameterized - ldr r7, =gText_3rd - movs r0, 0x1 - adds r1, r7, 0 - movs r2, 0x26 - bl GetStringRightAlignXOffset - adds r3, r0, 0 - adds r3, 0x7E - ldrb r0, [r4] - lsls r3, 24 - lsrs r3, 24 - mov r1, r8 - str r1, [sp] - str r6, [sp, 0x4] - str r5, [sp, 0x8] - movs r1, 0x1 - adds r2, r7, 0 - bl AddTextPrinterParameterized - ldr r7, =gText_4th - movs r0, 0x1 - adds r1, r7, 0 - movs r2, 0x26 - bl GetStringRightAlignXOffset - adds r3, r0, 0 - adds r3, 0xA4 - ldrb r0, [r4] - lsls r3, 24 - lsrs r3, 24 - mov r2, r8 - str r2, [sp] - str r6, [sp, 0x4] - str r5, [sp, 0x8] - movs r1, 0x1 - adds r2, r7, 0 - bl AddTextPrinterParameterized - ldrb r0, [r4] - ldr r2, =gText_Cool - movs r1, 0x29 - str r1, [sp] - str r6, [sp, 0x4] - str r5, [sp, 0x8] - movs r1, 0x1 - movs r3, 0x6 - bl AddTextPrinterParameterized - ldrb r0, [r4] - ldr r2, =gText_Beauty - movs r1, 0x39 - str r1, [sp] - str r6, [sp, 0x4] - str r5, [sp, 0x8] - movs r1, 0x1 - movs r3, 0x6 - bl AddTextPrinterParameterized - ldrb r0, [r4] - ldr r2, =gText_Cute - movs r1, 0x49 - str r1, [sp] - str r6, [sp, 0x4] - str r5, [sp, 0x8] - movs r1, 0x1 - movs r3, 0x6 - bl AddTextPrinterParameterized - ldrb r0, [r4] - ldr r2, =gText_Smart - movs r1, 0x59 - str r1, [sp] - str r6, [sp, 0x4] - str r5, [sp, 0x8] - movs r1, 0x1 - movs r3, 0x6 - bl AddTextPrinterParameterized - ldrb r0, [r4] - ldr r2, =gText_Tough - movs r1, 0x69 - str r1, [sp] - str r6, [sp, 0x4] - str r5, [sp, 0x8] - movs r1, 0x1 - movs r3, 0x6 - bl AddTextPrinterParameterized - movs r1, 0 -_081A314A: - movs r5, 0 - adds r0, r1, 0x1 - mov r8, r0 - lsls r0, r1, 28 - movs r2, 0xA4 - lsls r2, 22 - adds r0, r2 - lsrs r7, r0, 24 - lsls r4, r1, 3 -_081A315C: - ldr r0, =gSaveBlock2Ptr - ldr r0, [r0] - ldr r1, =0x00000624 - adds r0, r1 - adds r0, r4 - ldrh r1, [r0] - mov r0, r9 - movs r2, 0x1 - movs r3, 0x4 - bl ConvertIntToDecimalStringN - ldr r6, =gRecordsWindowId - ldrb r0, [r6] - movs r1, 0x26 - adds r3, r5, 0 - muls r3, r1 - adds r3, 0x40 - lsls r3, 24 - lsrs r3, 24 - str r7, [sp] - movs r1, 0xFF - str r1, [sp, 0x4] - movs r1, 0 - str r1, [sp, 0x8] - movs r1, 0x1 - mov r2, r9 - bl AddTextPrinterParameterized - adds r4, 0x2 - adds r5, 0x1 - cmp r5, 0x3 - ble _081A315C - mov r1, r8 - cmp r1, 0x4 - ble _081A314A - ldrb r0, [r6] - bl PutWindowTilemap - ldrb r0, [r6] - movs r1, 0x3 - bl CopyWindowToVram - add sp, 0xC - pop {r3,r4} - mov r8, r3 - mov r9, r4 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81A2FF8 - - thumb_func_start sub_81A31FC -sub_81A31FC: @ 81A31FC - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0x24 - ldr r0, =gSaveBlock2Ptr - ldr r0, [r0] - ldr r1, =0x00000ca9 - adds r0, r1 - ldrb r0, [r0] - lsls r0, 30 - lsrs r7, r0, 30 - ldr r0, =0x000040cf - bl VarGet - lsls r0, 16 - lsrs r4, r0, 16 - ldr r0, =0x000040ce - bl VarGet - lsls r0, 16 - lsrs r0, 16 - mov r8, r0 - cmp r4, 0x6 - bls _081A3232 - b _081A35CE -_081A3232: - lsls r0, r4, 2 - ldr r1, =_081A3250 - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .pool - .align 2, 0 -_081A3250: - .4byte _081A326C - .4byte _081A33A8 - .4byte _081A3414 - .4byte _081A347C - .4byte _081A34CC - .4byte _081A354C - .4byte _081A3594 -_081A326C: - ldr r2, =gSaveBlock2Ptr - mov r9, r2 - ldr r0, [r2] - lsls r3, r7, 1 - mov r10, r3 - mov r2, r8 - lsls r1, r2, 2 - add r1, r10 - str r1, [sp, 0x20] - movs r3, 0xCE - lsls r3, 4 - adds r1, r0, r3 - ldr r2, [sp, 0x20] - adds r1, r2 - adds r3, 0x10 - adds r0, r3 - adds r0, r2 - ldrh r1, [r1] - ldrh r2, [r0] - cmp r1, r2 - bhi _081A3298 - b _081A35CE -_081A3298: - strh r1, [r0] - mov r3, r8 - cmp r3, 0x3 - bne _081A32F2 - ldr r6, =gBattleScripting - adds r6, 0x25 - ldrb r0, [r6] - movs r4, 0x1 - eors r0, r4 - lsls r1, r0, 3 - subs r1, r0 - lsls r1, 2 - ldr r5, =gLinkPlayers + 8 - adds r1, r5 - mov r0, sp - bl StringCopy - mov r0, sp - bl StripExtCtrlCodes - lsls r1, r7, 3 - ldr r0, =0x00000ee1 - adds r1, r0 - mov r2, r9 - ldr r0, [r2] - adds r0, r1 - mov r1, sp - bl StringCopy - ldrb r0, [r6] - eors r4, r0 - lsls r0, r4, 3 - subs r0, r4 - lsls r0, 2 - subs r5, 0x4 - adds r0, r5 - ldr r0, [r0] - lsls r2, r7, 2 - ldr r1, =0x00000ef1 - adds r2, r1 - mov r3, r9 - ldr r1, [r3] - adds r1, r2 - bl WriteUnalignedWord -_081A32F2: - mov r7, r9 - ldr r0, [r7] - movs r1, 0xCE - lsls r1, 4 - adds r0, r1 - ldr r2, [sp, 0x20] - adds r0, r2 - ldrh r0, [r0] - cmp r0, 0x1 - bhi _081A3308 - b _081A35CE -_081A3308: - bl sub_80EE818 - lsls r0, 24 - cmp r0, 0 - bne _081A3314 - b _081A35CE -_081A3314: - mov r3, r8 - cmp r3, 0x1 - beq _081A335A - cmp r3, 0x1 - bgt _081A3338 - cmp r3, 0 - beq _081A3344 - b _081A35CE - .pool -_081A3338: - mov r7, r8 - cmp r7, 0x2 - beq _081A3374 - cmp r7, 0x3 - beq _081A338E - b _081A35CE -_081A3344: - mov r1, r9 - ldr r0, [r1] - movs r2, 0xCE - lsls r2, 4 - adds r0, r2 - add r0, r10 - ldrh r0, [r0] - movs r1, 0x1 - bl sub_80EE8C8 - b _081A35CE -_081A335A: - mov r3, r9 - ldr r0, [r3] - mov r1, r10 - adds r1, 0x4 - movs r7, 0xCE - lsls r7, 4 - adds r0, r7 - adds r0, r1 - ldrh r0, [r0] - movs r1, 0x2 - bl sub_80EE8C8 - b _081A35CE -_081A3374: - mov r1, r9 - ldr r0, [r1] - mov r1, r10 - adds r1, 0x8 - movs r2, 0xCE - lsls r2, 4 - adds r0, r2 - adds r0, r1 - ldrh r0, [r0] - movs r1, 0x3 - bl sub_80EE8C8 - b _081A35CE -_081A338E: - mov r3, r9 - ldr r0, [r3] - mov r1, r10 - adds r1, 0xC - movs r7, 0xCE - lsls r7, 4 - adds r0, r7 - adds r0, r1 - ldrh r0, [r0] - movs r1, 0x4 - bl sub_80EE8C8 - b _081A35CE -_081A33A8: - ldr r6, =gSaveBlock2Ptr - ldr r0, [r6] - lsls r7, 1 - mov r2, r8 - lsls r1, r2, 2 - adds r4, r7, r1 - ldr r5, =0x00000d0c - adds r1, r0, r5 - adds r1, r4 - ldr r3, =0x00000d14 - adds r0, r3 - adds r0, r4 - ldrh r2, [r1] - ldrh r3, [r0] - cmp r2, r3 - bhi _081A33CA - b _081A35CE -_081A33CA: - strh r2, [r0] - ldrh r0, [r1] - cmp r0, 0x1 - bhi _081A33D4 - b _081A35CE -_081A33D4: - bl sub_80EE818 - lsls r0, 24 - cmp r0, 0 - bne _081A33E0 - b _081A35CE -_081A33E0: - mov r0, r8 - cmp r0, 0 - bne _081A3404 - ldr r0, [r6] - adds r0, r5 - adds r0, r7 - ldrh r0, [r0] - movs r1, 0x5 - bl sub_80EE8C8 - b _081A35CE - .pool -_081A3404: - ldr r0, [r6] - adds r0, r5 - adds r0, r4 - ldrh r0, [r0] - movs r1, 0x6 - bl sub_80EE8C8 - b _081A35CE -_081A3414: - ldr r6, =gSaveBlock2Ptr - ldr r0, [r6] - lsls r7, 1 - mov r2, r8 - lsls r1, r2, 2 - adds r4, r7, r1 - ldr r5, =0x00000dc8 - adds r1, r0, r5 - adds r1, r4 - movs r3, 0xDD - lsls r3, 4 - adds r0, r3 - adds r0, r4 - ldrh r2, [r1] - ldrh r3, [r0] - cmp r2, r3 - bhi _081A3438 - b _081A35CE -_081A3438: - strh r2, [r0] - ldrh r0, [r1] - cmp r0, 0x1 - bhi _081A3442 - b _081A35CE -_081A3442: - bl sub_80EE818 - lsls r0, 24 - cmp r0, 0 - bne _081A344E - b _081A35CE -_081A344E: - mov r0, r8 - cmp r0, 0 - bne _081A346C - ldr r0, [r6] - adds r0, r5 - adds r0, r7 - ldrh r0, [r0] - movs r1, 0xB - bl sub_80EE8C8 - b _081A35CE - .pool -_081A346C: - ldr r0, [r6] - adds r0, r5 - adds r0, r4 - ldrh r0, [r0] - movs r1, 0xC - bl sub_80EE8C8 - b _081A35CE -_081A347C: - ldr r6, =gSaveBlock2Ptr - ldr r1, [r6] - lsls r4, r7, 1 - ldr r5, =0x00000dda - adds r0, r1, r5 - adds r0, r4 - ldr r2, =0x00000dde - adds r1, r2 - adds r1, r4 - ldrh r2, [r0] - ldrh r3, [r1] - cmp r2, r3 - bhi _081A3498 - b _081A35CE -_081A3498: - strh r2, [r1] - ldrh r0, [r0] - cmp r0, 0x1 - bhi _081A34A2 - b _081A35CE -_081A34A2: - bl sub_80EE818 - lsls r0, 24 - cmp r0, 0 - bne _081A34AE - b _081A35CE -_081A34AE: - ldr r0, [r6] - adds r0, r5 - adds r0, r4 - ldrh r0, [r0] - movs r1, 0xA - bl sub_80EE8C8 - b _081A35CE - .pool -_081A34CC: - ldr r6, =gSaveBlock2Ptr - ldr r2, [r6] - lsls r7, 1 - mov r9, r7 - mov r7, r8 - lsls r0, r7, 2 - mov r1, r9 - adds r4, r1, r0 - ldr r5, =0x00000de2 - adds r0, r2, r5 - adds r3, r0, r4 - ldr r7, =0x00000dea - adds r0, r2, r7 - adds r0, r4 - ldrh r1, [r3] - ldrh r7, [r0] - cmp r1, r7 - bls _081A35CE - strh r1, [r0] - ldr r0, =0x00000dfa - adds r1, r2, r0 - adds r1, r4 - ldr r7, =0x00000df2 - adds r0, r2, r7 - adds r0, r4 - ldrh r0, [r0] - strh r0, [r1] - ldrh r0, [r3] - cmp r0, 0x1 - bls _081A35CE - bl sub_80EE818 - lsls r0, 24 - cmp r0, 0 - beq _081A35CE - mov r0, r8 - cmp r0, 0 - bne _081A353C - ldr r0, [r6] - adds r0, r5 - add r0, r9 - ldrh r0, [r0] - movs r1, 0x7 - bl sub_80EE8C8 - b _081A35CE - .pool -_081A353C: - ldr r0, [r6] - adds r0, r5 - adds r0, r4 - ldrh r0, [r0] - movs r1, 0x8 - bl sub_80EE8C8 - b _081A35CE -_081A354C: - ldr r6, =gSaveBlock2Ptr - ldr r1, [r6] - lsls r4, r7, 1 - ldr r5, =0x00000e04 - adds r0, r1, r5 - adds r0, r4 - ldr r2, =0x00000e08 - adds r1, r2 - adds r1, r4 - ldrh r2, [r0] - ldrh r3, [r1] - cmp r2, r3 - bls _081A35CE - strh r2, [r1] - ldrh r0, [r0] - cmp r0, 0x1 - bls _081A35CE - bl sub_80EE818 - lsls r0, 24 - cmp r0, 0 - beq _081A35CE - ldr r0, [r6] - adds r0, r5 - adds r0, r4 - ldrh r0, [r0] - movs r1, 0x9 - bl sub_80EE8C8 - b _081A35CE - .pool -_081A3594: - ldr r6, =gSaveBlock2Ptr - ldr r1, [r6] - lsls r4, r7, 1 - ldr r5, =0x00000e1a - adds r0, r1, r5 - adds r0, r4 - ldr r7, =0x00000e1e - adds r1, r7 - adds r1, r4 - ldrh r2, [r0] - ldrh r3, [r1] - cmp r2, r3 - bls _081A35CE - strh r2, [r1] - ldrh r0, [r0] - cmp r0, 0x1 - bls _081A35CE - bl sub_80EE818 - lsls r0, 24 - cmp r0, 0 - beq _081A35CE - ldr r0, [r6] - adds r0, r5 - adds r0, r4 - ldrh r0, [r0] - movs r1, 0xD - bl sub_80EE8C8 -_081A35CE: - add sp, 0x24 - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81A31FC - - thumb_func_start sub_81A35EC -sub_81A35EC: @ 81A35EC - push {r4,lr} - ldr r0, =0x000040cf - bl VarGet - ldr r4, =gSpecialVar_Result - bl sub_81A3610 - lsls r0, 24 - lsrs r0, 24 - strh r0, [r4] - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81A35EC - - thumb_func_start sub_81A3610 -sub_81A3610: @ 81A3610 - push {r4-r7,lr} - mov r7, r9 - mov r6, r8 - push {r6,r7} - movs r0, 0 - mov r8, r0 - ldr r0, =0x000040cf - bl VarGet - lsls r0, 16 - lsrs r6, r0, 16 - ldr r0, =0x000040ce - bl VarGet - adds r4, r0, 0 - lsls r4, 16 - lsrs r4, 16 - bl sub_81A39C4 - lsls r0, 16 - ldr r1, =gUnknown_08611550 - mov r9, r1 - lsls r7, r6, 2 - adds r1, 0x3 - adds r1, r7, r1 - lsrs r0, 16 - ldrb r1, [r1] - adds r5, r0, r1 - cmp r4, 0 - beq _081A365C - movs r0, 0 - b _081A36C2 - .pool -_081A365C: - lsls r0, r6, 24 - lsrs r0, 24 - bl sub_81A3B30 - lsls r0, 24 - lsrs r1, r0, 24 - cmp r1, 0 - blt _081A3680 - cmp r1, 0x1 - bgt _081A3680 - adds r0, r1, r7 - add r0, r9 - ldrb r0, [r0] - cmp r5, r0 - bne _081A36BC - adds r1, 0x1 - mov r8, r1 - b _081A36BC -_081A3680: - ldr r1, =gUnknown_08611550 - lsls r2, r6, 2 - adds r0, r2, r1 - ldrb r0, [r0] - cmp r5, r0 - bne _081A3694 - movs r0, 0x3 - b _081A36BA - .pool -_081A3694: - adds r0, r1, 0x1 - adds r0, r2, r0 - ldrb r0, [r0] - cmp r5, r0 - bne _081A36A4 - movs r1, 0x4 - mov r8, r1 - b _081A36BC -_081A36A4: - cmp r5, r0 - ble _081A36BC - subs r0, r5, r0 - adds r1, 0x2 - adds r1, r2, r1 - ldrb r1, [r1] - bl __modsi3 - cmp r0, 0 - bne _081A36BC - movs r0, 0x4 -_081A36BA: - mov r8, r0 -_081A36BC: - mov r1, r8 - lsls r0, r1, 24 - lsrs r0, 24 -_081A36C2: - pop {r3,r4} - mov r8, r3 - mov r9, r4 - pop {r4-r7} - pop {r1} - bx r1 - thumb_func_end sub_81A3610 - - thumb_func_start CopyFrontierTrainerText -CopyFrontierTrainerText: @ 81A36D0 - push {lr} - lsls r0, 24 - lsrs r0, 24 - adds r2, r0, 0 - lsls r1, 16 - lsrs r3, r1, 16 - cmp r0, 0x1 - beq _081A3766 - cmp r0, 0x1 - bgt _081A36EA - cmp r0, 0 - beq _081A36F2 - b _081A38F8 -_081A36EA: - cmp r2, 0x2 - bne _081A36F0 - b _081A3818 -_081A36F0: - b _081A38F8 -_081A36F2: - movs r0, 0xFA - lsls r0, 1 - cmp r3, r0 - bne _081A370C - ldr r0, =gSaveBlock2Ptr - ldr r0, [r0] - ldr r1, =0x00000bfc - b _081A38C4 - .pool -_081A370C: - ldr r0, =0x000003fe - cmp r3, r0 - beq _081A3786 - ldr r0, =0x0000012b - cmp r3, r0 - bhi _081A3738 - ldr r2, =gFacilityTrainers - movs r0, 0x34 - adds r1, r3, 0 - muls r1, r0 - ldr r0, [r2] - adds r0, r1 - adds r0, 0xC - bl FrontierSpeechToString - b _081A38F8 - .pool -_081A3738: - ldr r0, =0x0000018f - cmp r3, r0 - bhi _081A3758 - ldr r1, =gSaveBlock2Ptr - movs r0, 0xEC - muls r0, r3 - ldr r1, [r1] - adds r0, r1 - ldr r1, =0xfffef2b8 - b _081A38C4 - .pool -_081A3758: - adds r0, r3, 0 - adds r0, 0x70 - lsls r0, 24 - lsrs r0, 24 - bl CopyFriendsApprenticeChallengeText - b _081A38F8 -_081A3766: - movs r0, 0xFA - lsls r0, 1 - cmp r3, r0 - bne _081A3780 - ldr r0, =gSaveBlock2Ptr - ldr r0, [r0] - ldr r1, =0x00000c08 - b _081A38C4 - .pool -_081A3780: - ldr r0, =0x000003fe - cmp r3, r0 - bne _081A3794 -_081A3786: - movs r0, 0 - bl sub_81A51A8 - b _081A38F8 - .pool -_081A3794: - ldr r0, =0x0000012b - cmp r3, r0 - bhi _081A37B8 - ldr r2, =gFacilityTrainers - movs r0, 0x34 - adds r1, r3, 0 - muls r1, r0 - ldr r0, [r2] - adds r0, r1 - adds r0, 0x18 - bl FrontierSpeechToString - b _081A38F8 - .pool -_081A37B8: - ldr r0, =0x0000018f - cmp r3, r0 - bhi _081A37EC - ldr r0, =gBattleTypeFlags - ldr r0, [r0] - movs r1, 0x80 - lsls r1, 17 - ands r0, r1 - cmp r0, 0 - bne _081A387C - ldr r1, =gSaveBlock2Ptr - movs r0, 0xEC - muls r0, r3 - ldr r1, [r1] - adds r0, r1 - ldr r1, =0xfffef2c4 - b _081A38C4 - .pool -_081A37EC: - ldr r0, =gBattleTypeFlags - ldr r0, [r0] - movs r1, 0x80 - lsls r1, 17 - ands r0, r1 - cmp r0, 0 - bne _081A387C - ldr r1, =gSaveBlock2Ptr - lsls r0, r3, 4 - adds r0, r3 - lsls r0, 2 - ldr r1, [r1] - adds r0, r1 - ldr r1, =0xffff96c4 - b _081A38C4 - .pool -_081A3818: - movs r0, 0xFA - lsls r0, 1 - cmp r3, r0 - bne _081A3830 - ldr r0, =gSaveBlock2Ptr - ldr r0, [r0] - ldr r1, =0x00000c14 - b _081A38C4 - .pool -_081A3830: - ldr r0, =0x000003fe - cmp r3, r0 - bne _081A3844 - movs r0, 0x1 - bl sub_81A51A8 - b _081A38F8 - .pool -_081A3844: - ldr r0, =0x0000012b - cmp r3, r0 - bhi _081A3868 - ldr r2, =gFacilityTrainers - movs r0, 0x34 - adds r1, r3, 0 - muls r1, r0 - ldr r0, [r2] - adds r0, r1 - adds r0, 0x24 - bl FrontierSpeechToString - b _081A38F8 - .pool -_081A3868: - ldr r0, =0x0000018f - cmp r3, r0 - bhi _081A38A8 - ldr r0, =gBattleTypeFlags - ldr r0, [r0] - movs r1, 0x80 - lsls r1, 17 - ands r0, r1 - cmp r0, 0 - beq _081A3890 -_081A387C: - bl sub_81864E0 - bl FrontierSpeechToString - b _081A38F8 - .pool -_081A3890: - ldr r1, =gSaveBlock2Ptr - movs r0, 0xEC - muls r0, r3 - ldr r1, [r1] - adds r0, r1 - ldr r1, =0xfffef2d0 - b _081A38C4 - .pool -_081A38A8: - ldr r0, =gBattleTypeFlags - ldr r0, [r0] - movs r1, 0x80 - lsls r1, 17 - ands r0, r1 - cmp r0, 0 - beq _081A38D4 - bl sub_81864A8 - lsls r0, 24 - lsrs r3, r0, 24 - movs r0, 0x58 - muls r0, r3 - ldr r1, =gApprentices+0x4A -_081A38C4: - adds r0, r1 - bl FrontierSpeechToString - b _081A38F8 - .pool -_081A38D4: - ldr r0, =gSaveBlock2Ptr - ldr r1, [r0] - ldr r0, =0xfffffe70 - adds r2, r3, r0 - lsls r0, r2, 4 - adds r0, r2 - lsls r0, 2 - adds r1, r0 - adds r1, 0xDC - ldrb r0, [r1] - lsls r0, 27 - lsrs r3, r0, 27 - movs r0, 0x58 - muls r0, r3 - ldr r1, =gApprentices+0x4A - adds r0, r1 - bl FrontierSpeechToString -_081A38F8: - pop {r0} - bx r0 - .pool - thumb_func_end CopyFrontierTrainerText - - thumb_func_start sub_81A3908 -sub_81A3908: @ 81A3908 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - ldr r0, =gSaveBlock2Ptr - ldr r1, [r0] - ldr r2, =0x00000cdc - adds r1, r2 - movs r2, 0 - str r2, [r1] - movs r4, 0 - mov r9, r0 - mov r8, r9 - movs r6, 0 -_081A3926: - movs r5, 0 - lsls r7, r4, 2 - mov r10, r7 - adds r0, r4, 0x1 - mov r12, r0 -_081A3930: - mov r1, r8 - ldr r2, [r1] - lsls r3, r5, 1 - mov r7, r10 - adds r1, r3, r7 - movs r7, 0xCE - lsls r7, 4 - adds r0, r2, r7 - adds r0, r1 - strh r6, [r0] - cmp r4, 0x1 - bgt _081A3960 - adds r7, 0x2C - adds r0, r2, r7 - adds r0, r1 - strh r6, [r0] - adds r7, 0xBC - adds r0, r2, r7 - adds r0, r1 - strh r6, [r0] - adds r7, 0x1A - adds r0, r2, r7 - adds r0, r1 - strh r6, [r0] -_081A3960: - cmp r4, 0 - bne _081A3980 - mov r1, r8 - ldr r0, [r1] - ldr r2, =0x00000dda - adds r1, r0, r2 - adds r1, r3 - strh r4, [r1] - ldr r7, =0x00000e04 - adds r1, r0, r7 - adds r1, r3 - strh r4, [r1] - ldr r1, =0x00000e1a - adds r0, r1 - adds r0, r3 - strh r4, [r0] -_081A3980: - adds r5, 0x1 - cmp r5, 0x1 - ble _081A3930 - mov r4, r12 - cmp r4, 0x3 - ble _081A3926 - mov r2, r9 - ldr r0, [r2] - ldr r7, =0x00000ca8 - adds r1, r0, r7 - ldrb r0, [r1] - cmp r0, 0 - beq _081A399E - movs r0, 0x1 - strb r0, [r1] -_081A399E: - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81A3908 - - thumb_func_start sub_81A39C4 -sub_81A39C4: @ 81A39C4 - push {r4,r5,lr} - ldr r0, =gSaveBlock2Ptr - ldr r0, [r0] - ldr r1, =0x00000ca9 - adds r0, r1 - ldrb r0, [r0] - lsls r0, 30 - lsrs r4, r0, 30 - ldr r0, =0x000040ce - bl VarGet - lsls r0, 16 - lsrs r5, r0, 16 - ldr r0, =0x000040cf - bl VarGet - lsls r0, 16 - lsrs r0, 16 - cmp r0, 0x6 - bhi _081A3AC4 - lsls r0, 2 - ldr r1, =_081A3A0C - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .pool - .align 2, 0 -_081A3A0C: - .4byte _081A3A28 - .4byte _081A3A3C - .4byte _081A3A54 - .4byte _081A3A6C - .4byte _081A3A80 - .4byte _081A3A98 - .4byte _081A3AAC -_081A3A28: - ldr r0, =gSaveBlock2Ptr - ldr r0, [r0] - lsls r1, r4, 1 - lsls r2, r5, 2 - adds r1, r2 - movs r2, 0xCE - lsls r2, 4 - b _081A3AB4 - .pool -_081A3A3C: - ldr r0, =gSaveBlock2Ptr - ldr r0, [r0] - lsls r1, r4, 1 - lsls r2, r5, 2 - adds r1, r2 - ldr r2, =0x00000d0c - b _081A3AB4 - .pool -_081A3A54: - ldr r0, =gSaveBlock2Ptr - ldr r0, [r0] - lsls r1, r4, 1 - lsls r2, r5, 2 - adds r1, r2 - ldr r2, =0x00000dc8 - b _081A3AB4 - .pool -_081A3A6C: - ldr r0, =gSaveBlock2Ptr - ldr r0, [r0] - lsls r1, r4, 1 - ldr r2, =0x00000dda - b _081A3AB4 - .pool -_081A3A80: - ldr r0, =gSaveBlock2Ptr - ldr r0, [r0] - lsls r1, r4, 1 - lsls r2, r5, 2 - adds r1, r2 - ldr r2, =0x00000de2 - b _081A3AB4 - .pool -_081A3A98: - ldr r0, =gSaveBlock2Ptr - ldr r0, [r0] - lsls r1, r4, 1 - ldr r2, =0x00000e04 - b _081A3AB4 - .pool -_081A3AAC: - ldr r0, =gSaveBlock2Ptr - ldr r0, [r0] - lsls r1, r4, 1 - ldr r2, =0x00000e1a -_081A3AB4: - adds r0, r2 - adds r0, r1 - ldrh r0, [r0] - b _081A3AC6 - .pool -_081A3AC4: - movs r0, 0 -_081A3AC6: - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_81A39C4 thumb_func_start sub_81A3ACC sub_81A3ACC: @ 81A3ACC @@ -4119,7 +2653,7 @@ sub_81A513C: @ 81A513C lsrs r4, r0, 24 cmp r4, 0x2 bne _081A51A0 - bl sub_81A39C4 + bl GetCurrentFacilityWinStreak lsls r0, 16 ldr r3, =gUnknown_08611550 lsls r2, r5, 2 diff --git a/include/apprentice.h b/include/apprentice.h index ca0b04800..23e1fc8f2 100644 --- a/include/apprentice.h +++ b/include/apprentice.h @@ -9,7 +9,9 @@ struct ApprenticeTrainer u16 otId; u8 facilityClass; u16 species[APPRENTICE_SPECIES_COUNT]; - u8 rest[14]; + u8 unk; + u8 unk_; + u16 easyChatWords[6]; }; extern const struct ApprenticeTrainer gApprentices[]; diff --git a/include/battle_frontier_2.h b/include/battle_frontier_2.h index 3bd605829..c4639aded 100644 --- a/include/battle_frontier_2.h +++ b/include/battle_frontier_2.h @@ -2,8 +2,8 @@ #define GUARD_BATTLE_FRONTIER_2_H #define FRONTIER_BEFORE_TEXT 0 -#define FRONTIER_WIN_TEXT 1 -#define FRONTIER_LOSE_TEXT 2 +#define FRONTIER_PLAYER_LOST_TEXT 1 +#define FRONTIER_PLAYER_WON_TEXT 2 void CopyFrontierTrainerText(u8 whichText, u16 trainerId); void sub_81A8934(u8); @@ -15,5 +15,7 @@ void sub_81AA078(u16*, u8); void sub_81A4C30(void); bool8 sub_81A6BF4(void); u8 sub_81A6CA8(u8, u8); +void sub_81A3908(void); +u32 GetCurrentFacilityWinStreak(void); #endif // GUARD_BATTLE_FRONTIER_2_H diff --git a/include/global.h b/include/global.h index d23800139..7f5a025be 100644 --- a/include/global.h +++ b/include/global.h @@ -331,8 +331,8 @@ struct EmeraldBattleTowerRecord /*0x04*/ u8 name[PLAYER_NAME_LENGTH + 1]; /*0x0C*/ u8 trainerId[4]; /*0x10*/ u16 greeting[6]; - /*0x1C*/ u16 unk1C[6]; - /*0x28*/ u16 unk28[6]; + /*0x1C*/ u16 speechWon[6]; + /*0x28*/ u16 speechLost[6]; /*0x34*/ struct UnknownPokemonStruct party[4]; /*0xE4*/ u8 language; /*0xE8*/ u32 checksum; @@ -400,8 +400,8 @@ struct BattleFrontier /*0xCB2*/ u16 curChallengeBattleNum; // In case of battle pyramid, the floor. /*0xCB4*/ u16 field_CB4[20]; /*0xCDC*/ u32 field_CDC; - /*0xCE0*/ u16 winStreaks[4][2]; - /*0xCF0*/ u16 field_CF0[4][2]; + /*0xCE0*/ u16 towerWinStreaks[4][2]; + /*0xCF0*/ u16 towerRecordWinStreaks[4][2]; /*0xD06*/ u16 field_D00; /*0xD06*/ u16 field_D02; /*0xD06*/ u16 field_D04; @@ -418,34 +418,29 @@ struct BattleFrontier /*0xD09*/ u8 filler_D09; /*0xD0A*/ u8 field_D0A; /*0xD0B*/ u8 field_D0B; - /*0xD0C*/ u16 field_D0C[2][2]; - /*0xD14*/ u16 field_D14[2][2]; - /*0xD1C*/ u16 field_D1C[2][2]; + /*0xD0C*/ u16 domeWinStreaks[2][2]; + /*0xD14*/ u16 domeRecordWinStreaks[2][2]; + /*0xD1C*/ u16 domeTotalChampionships[2][2]; /*0xD24*/ struct BattleDomeTrainer domeTrainers[DOME_TOURNAMENT_TRAINERS_COUNT]; - /*0xD64*/ u16 domeMonId[DOME_TOURNAMENT_TRAINERS_COUNT][3]; + /*0xD64*/ u16 domeMonIds[DOME_TOURNAMENT_TRAINERS_COUNT][3]; /*0xD64*/ u16 field_DC4[2]; - /*0xDC8*/ u16 field_DC8[2][2]; - /*0xDD0*/ u16 field_DD0[2][2]; + /*0xDC8*/ u16 palaceWinStreaks[2][2]; + /*0xDD0*/ u16 palaceRecordWinStreaks[2][2]; /*0xDD8*/ u16 field_DD8; - /*0xDDA*/ u16 field_DDA[2]; - /*0xDDE*/ u16 field_DDE[2]; - /*0xDE2*/ u16 field_DE2[2][2]; - /*0xDEA*/ u16 field_DEA[2]; - /*0xDEE*/ u16 field_DEE; - /*0xDF0*/ u16 field_DF0; - /*0xDF2*/ u16 field_DF2; - /*0xDF4*/ u16 field_DF4; - /*0xDF6*/ u16 field_DF6; - /*0xDF8*/ u16 field_DF8; - /*0xDFA*/ u16 field_DFA; - /*0xDFC*/ u16 field_DFC; - /*0xDFE*/ u16 field_DFE; - /*0xE00*/ u16 field_E00; + /*0xDDA*/ u16 arenaWinStreaks[2]; + /*0xDDE*/ u16 arenaRecordStreaks[2]; + /*0xDE2*/ u16 factoryWinStreaks[2][2]; + /*0xDEA*/ u16 factoryRecordWinStreaks[2][2]; + /*0xDF6*/ u16 factoryRentsCount[2][2]; + /*0xDFA*/ u16 factoryRecordRentsCount[2][2]; /*0xE02*/ u16 field_E02; - /*0xE04*/ u16 field_E04[2]; - /*0xE08*/ u16 field_E08[9]; - /*0xE1A*/ u16 field_E1A[2]; - /*0xE1E*/ u16 field_E1E[7]; + /*0xE04*/ u16 pikeWinStreaks[2]; + /*0xE08*/ u16 pikeRecordStreaks[2]; + /*0xE0C*/ u16 pikeTotalStreaks[2]; + /*0xE10*/ u16 field_E10[5]; + /*0xE1A*/ u16 pyramidWinStreaks[2]; + /*0xE1E*/ u16 pyramidRecordStreaks[2]; + /*0xE1E*/ u16 field_E1F[5]; /*0xE2C*/ struct PyramidBag pyramidBag; /*0xE58*/ u16 field_E58; /*0xE6A*/ u16 field_E6A; @@ -517,7 +512,7 @@ struct SaveBlock2 /*0x1FC*/ struct PokemonJumpResults pokeJump; /*0x20C*/ struct BerryPickingResults berryPick; /*0x21C*/ u8 field_21C[1032]; - /*0x624*/ u16 contestLinkResults[20]; // 4 positions for 5 categories, possibly a struct or a 2d array + /*0x624*/ u16 contestLinkResults[5][4]; // 4 positions for 5 categories. /*0x64C*/ struct BattleFrontier frontier; }; // sizeof=0xF2C diff --git a/include/tv.h b/include/tv.h index 4f1d7730f..5528bada7 100644 --- a/include/tv.h +++ b/include/tv.h @@ -51,5 +51,7 @@ void BravoTrainerPokemonProfile_BeforeInterview1(u16 move); void UpdateTVScreensOnMap(int, int); void TV_PrintIntToStringVar(u8 varIdx, int value); void SaveRecordedItemPurchasesForTVShow(void); +bool8 sub_80EE818(void); +void sub_80EE8C8(u16 winStreak, u8 facilityAndMode); #endif //GUARD_TV_H diff --git a/src/battle_dome.c b/src/battle_dome.c index c54abd68c..4a12d64a3 100644 --- a/src/battle_dome.c +++ b/src/battle_dome.c @@ -3,6 +3,7 @@ #include "battle.h" #include "battle_setup.h" #include "battle_tower.h" +#include "battle_frontier_2.h" #include "battle_message.h" #include "event_data.h" #include "overworld.h" @@ -56,12 +57,11 @@ struct UnkStruct_860DD10 }; extern void sub_81B8558(void); -extern u32 sub_81A39C4(void); extern u16 sub_81A5060(u8 monId, u8 moveSlotId); extern u8 sub_81A50F0(u8, u8); extern u8 sub_81A50B0(u8); extern void sub_81A4C30(void); -extern bool8 sub_81A3610(void); +extern u8 sub_81A3610(void); extern u16 sub_81A4FF0(u8); extern void ReducePlayerPartyToThree(void); @@ -2575,7 +2575,7 @@ static void InitDomeTrainers(void) for (i = 0; i < 3; i++) { - gSaveBlock2Ptr->frontier.domeMonId[0][i] = GetMonData(&gPlayerParty[gSaveBlock2Ptr->frontier.selectedPartyMons[i] - 1], MON_DATA_SPECIES, NULL); + gSaveBlock2Ptr->frontier.domeMonIds[0][i] = GetMonData(&gPlayerParty[gSaveBlock2Ptr->frontier.selectedPartyMons[i] - 1], MON_DATA_SPECIES, NULL); for (j = 0; j < 4; j++) gSaveBlock2Ptr->frontier.field_EFC[i].moves[j] = GetMonData(&gPlayerParty[gSaveBlock2Ptr->frontier.selectedPartyMons[i] - 1], MON_DATA_MOVE1 + j, NULL); for (j = 0; j < 6; j++) @@ -2590,7 +2590,7 @@ static void InitDomeTrainers(void) { do { - trainerId = sub_8162548(sub_81A39C4(), 0); + trainerId = sub_8162548(GetCurrentFacilityWinStreak(), 0); for (j = 1; j < i; j++) { if (gSaveBlock2Ptr->frontier.domeTrainers[j].trainerId == trainerId) @@ -2603,7 +2603,7 @@ static void InitDomeTrainers(void) { do { - trainerId = sub_8162548(sub_81A39C4() + 1, 0); + trainerId = sub_8162548(GetCurrentFacilityWinStreak() + 1, 0); for (j = 1; j < i; j++) { if (gSaveBlock2Ptr->frontier.domeTrainers[j].trainerId == trainerId) @@ -2621,7 +2621,7 @@ static void InitDomeTrainers(void) monTournamentId = RandomizeFacilityTrainerMonId(trainerId); for (k = 0; k < j; k++) { - s32 checkingMonId = gSaveBlock2Ptr->frontier.domeMonId[i][k]; + s32 checkingMonId = gSaveBlock2Ptr->frontier.domeMonIds[i][k]; if (checkingMonId == monTournamentId || species[0] == gFacilityTrainerMons[monTournamentId].species || species[1] == gFacilityTrainerMons[monTournamentId].species @@ -2630,7 +2630,7 @@ static void InitDomeTrainers(void) } } while (k != j); - gSaveBlock2Ptr->frontier.domeMonId[i][j] = monTournamentId; + gSaveBlock2Ptr->frontier.domeMonIds[i][j] = monTournamentId; species[j] = gFacilityTrainerMons[monTournamentId].species; } @@ -2671,10 +2671,10 @@ static void InitDomeTrainers(void) ivs = GetDomeTrainerMonIvs(gSaveBlock2Ptr->frontier.domeTrainers[i].trainerId); for (j = 0; j < 3; j++) { - CalcDomeMonStats(gFacilityTrainerMons[gSaveBlock2Ptr->frontier.domeMonId[i][j]].species, + CalcDomeMonStats(gFacilityTrainerMons[gSaveBlock2Ptr->frontier.domeMonIds[i][j]].species, monLevel, ivs, - gFacilityTrainerMons[gSaveBlock2Ptr->frontier.domeMonId[i][j]].evSpread, - gFacilityTrainerMons[gSaveBlock2Ptr->frontier.domeMonId[i][j]].nature, + gFacilityTrainerMons[gSaveBlock2Ptr->frontier.domeMonIds[i][j]].evSpread, + gFacilityTrainerMons[gSaveBlock2Ptr->frontier.domeMonIds[i][j]].nature, statValues); statSums[i] += statValues[STAT_ATK]; @@ -2683,8 +2683,8 @@ static void InitDomeTrainers(void) statSums[i] += statValues[STAT_SPDEF]; statSums[i] += statValues[STAT_SPEED]; statSums[i] += statValues[STAT_HP]; - monTypesBits |= gBitTable[gBaseStats[gFacilityTrainerMons[gSaveBlock2Ptr->frontier.domeMonId[i][j]].species].type1]; - monTypesBits |= gBitTable[gBaseStats[gFacilityTrainerMons[gSaveBlock2Ptr->frontier.domeMonId[i][j]].species].type2]; + monTypesBits |= gBitTable[gBaseStats[gFacilityTrainerMons[gSaveBlock2Ptr->frontier.domeMonIds[i][j]].species].type1]; + monTypesBits |= gBitTable[gBaseStats[gFacilityTrainerMons[gSaveBlock2Ptr->frontier.domeMonIds[i][j]].species].type2]; } for (monTypesCount = 0, j = 0; j < 32; j++) @@ -2737,7 +2737,7 @@ static void InitDomeTrainers(void) } for (i = 0; i < 3; i++) - gSaveBlock2Ptr->frontier.domeMonId[j][i] = sub_81A4FF0(i); + gSaveBlock2Ptr->frontier.domeMonIds[j][i] = sub_81A4FF0(i); } Free(statSums); @@ -2799,7 +2799,7 @@ static void SwapDomeTrainers(s32 id1, s32 id2, u16 *statsArray) SWAP(gSaveBlock2Ptr->frontier.domeTrainers[id1].trainerId, gSaveBlock2Ptr->frontier.domeTrainers[id2].trainerId, temp); for (i = 0; i < 3; i++) - SWAP(gSaveBlock2Ptr->frontier.domeMonId[id1][i], gSaveBlock2Ptr->frontier.domeMonId[id2][i], temp); + SWAP(gSaveBlock2Ptr->frontier.domeMonIds[id1][i], gSaveBlock2Ptr->frontier.domeMonIds[id2][i], temp); } static void sub_818F9B0(void) @@ -2829,24 +2829,24 @@ static void CreateDomeMon(u8 monPartyId, u16 tournamentTrainerId, u8 tournamentM u8 fixedIv = GetDomeTrainerMonIvs(tournamentTrainerId); // BUG: Should be using trainerId instead of tournamentTrainerId. As a result, all Pokemon have ivs of 3. u8 level = SetFacilityPtrsGetLevel(); CreateMonWithEVSpreadPersonalityOTID(&gEnemyParty[monPartyId], - gFacilityTrainerMons[gSaveBlock2Ptr->frontier.domeMonId[tournamentTrainerId][tournamentMonId]].species, + gFacilityTrainerMons[gSaveBlock2Ptr->frontier.domeMonIds[tournamentTrainerId][tournamentMonId]].species, level, - gFacilityTrainerMons[gSaveBlock2Ptr->frontier.domeMonId[tournamentTrainerId][tournamentMonId]].nature, + gFacilityTrainerMons[gSaveBlock2Ptr->frontier.domeMonIds[tournamentTrainerId][tournamentMonId]].nature, fixedIv, - gFacilityTrainerMons[gSaveBlock2Ptr->frontier.domeMonId[tournamentTrainerId][tournamentMonId]].evSpread, otId); + gFacilityTrainerMons[gSaveBlock2Ptr->frontier.domeMonIds[tournamentTrainerId][tournamentMonId]].evSpread, otId); happiness = 0xFF; for (i = 0; i < 4; i++) { SetMonMoveSlot(&gEnemyParty[monPartyId], - gFacilityTrainerMons[gSaveBlock2Ptr->frontier.domeMonId[tournamentTrainerId][tournamentMonId]].moves[i], i); - if (gFacilityTrainerMons[gSaveBlock2Ptr->frontier.domeMonId[tournamentTrainerId][tournamentMonId]].moves[i] == MOVE_FRUSTRATION) + gFacilityTrainerMons[gSaveBlock2Ptr->frontier.domeMonIds[tournamentTrainerId][tournamentMonId]].moves[i], i); + if (gFacilityTrainerMons[gSaveBlock2Ptr->frontier.domeMonIds[tournamentTrainerId][tournamentMonId]].moves[i] == MOVE_FRUSTRATION) happiness = 0; } SetMonData(&gEnemyParty[monPartyId], MON_DATA_FRIENDSHIP, &happiness); SetMonData(&gEnemyParty[monPartyId], MON_DATA_HELD_ITEM, - &gBattleFrontierHeldItems[gFacilityTrainerMons[gSaveBlock2Ptr->frontier.domeMonId[tournamentTrainerId][tournamentMonId]].itemTableId]); + &gBattleFrontierHeldItems[gFacilityTrainerMons[gSaveBlock2Ptr->frontier.domeMonIds[tournamentTrainerId][tournamentMonId]].itemTableId]); } static void CreateDomeTrainerMons(u16 tournamentTrainerId) @@ -2922,7 +2922,7 @@ static s32 sub_818FCBC(u16 tournamentTrainerId, bool8 arg1) } else { - array[i] += GetTypeEffectivenessPoints(gFacilityTrainerMons[gSaveBlock2Ptr->frontier.domeMonId[tournamentTrainerId][i]].moves[moveId], + array[i] += GetTypeEffectivenessPoints(gFacilityTrainerMons[gSaveBlock2Ptr->frontier.domeMonIds[tournamentTrainerId][i]].moves[moveId], GetMonData(&gPlayerParty[playerMonId], MON_DATA_SPECIES, NULL), 0); } } @@ -2950,7 +2950,7 @@ static s32 sub_818FDB8(u16 tournamentTrainerId, bool8 arg1) } else { - array[i] += GetTypeEffectivenessPoints(gFacilityTrainerMons[gSaveBlock2Ptr->frontier.domeMonId[tournamentTrainerId][i]].moves[moveId], + array[i] += GetTypeEffectivenessPoints(gFacilityTrainerMons[gSaveBlock2Ptr->frontier.domeMonIds[tournamentTrainerId][i]].moves[moveId], GetMonData(&gPlayerParty[playerMonId], MON_DATA_SPECIES, NULL), 1); } } @@ -4756,7 +4756,7 @@ static void DisplayTrainerInfoOnCard(u8 flags, u8 trainerTournamentId) { if (trainerId == TRAINER_PLAYER) { - sBattleDomeStruct->arr[2 + i + arrId] = CreateMonIcon(gSaveBlock2Ptr->frontier.domeMonId[trainerTournamentId][i], + sBattleDomeStruct->arr[2 + i + arrId] = CreateMonIcon(gSaveBlock2Ptr->frontier.domeMonIds[trainerTournamentId][i], SpriteCb_MonIcon, x | sInfoTrainerMonX[i], y + sInfoTrainerMonY[i], @@ -4765,7 +4765,7 @@ static void DisplayTrainerInfoOnCard(u8 flags, u8 trainerTournamentId) } else if (trainerId == TRAINER_FRONTIER_BRAIN) { - sBattleDomeStruct->arr[2 + i + arrId] = CreateMonIcon(gSaveBlock2Ptr->frontier.domeMonId[trainerTournamentId][i], + sBattleDomeStruct->arr[2 + i + arrId] = CreateMonIcon(gSaveBlock2Ptr->frontier.domeMonIds[trainerTournamentId][i], SpriteCb_MonIcon, x | sInfoTrainerMonX[i], y + sInfoTrainerMonY[i], @@ -4774,7 +4774,7 @@ static void DisplayTrainerInfoOnCard(u8 flags, u8 trainerTournamentId) } else { - sBattleDomeStruct->arr[2 + i + arrId] = CreateMonIcon(gFacilityTrainerMons[gSaveBlock2Ptr->frontier.domeMonId[trainerTournamentId][i]].species, + sBattleDomeStruct->arr[2 + i + arrId] = CreateMonIcon(gFacilityTrainerMons[gSaveBlock2Ptr->frontier.domeMonIds[trainerTournamentId][i]].species, SpriteCb_MonIcon, x | sInfoTrainerMonX[i], y + sInfoTrainerMonY[i], @@ -4837,11 +4837,11 @@ static void DisplayTrainerInfoOnCard(u8 flags, u8 trainerTournamentId) { textPrinter.currentY = gUnknown_0860D346[i]; if (trainerId == TRAINER_PLAYER) - textPrinter.current_text_offset = gSpeciesNames[gSaveBlock2Ptr->frontier.domeMonId[trainerTournamentId][i]]; + textPrinter.current_text_offset = gSpeciesNames[gSaveBlock2Ptr->frontier.domeMonIds[trainerTournamentId][i]]; else if (trainerId == TRAINER_FRONTIER_BRAIN) - textPrinter.current_text_offset = gSpeciesNames[gSaveBlock2Ptr->frontier.domeMonId[trainerTournamentId][i]]; + textPrinter.current_text_offset = gSpeciesNames[gSaveBlock2Ptr->frontier.domeMonIds[trainerTournamentId][i]]; else - textPrinter.current_text_offset = gSpeciesNames[gFacilityTrainerMons[gSaveBlock2Ptr->frontier.domeMonId[trainerTournamentId][i]].species]; + textPrinter.current_text_offset = gSpeciesNames[gFacilityTrainerMons[gSaveBlock2Ptr->frontier.domeMonIds[trainerTournamentId][i]].species]; textPrinter.windowId = 1 + i + windowId; if (i == 1) @@ -4879,7 +4879,7 @@ static void DisplayTrainerInfoOnCard(u8 flags, u8 trainerTournamentId) else if (trainerId == TRAINER_PLAYER) allocatedArray[k] += sMovePointsForDomeTrainers[gSaveBlock2Ptr->frontier.field_EFC[i].moves[j]][k]; else - allocatedArray[k] += sMovePointsForDomeTrainers[gFacilityTrainerMons[gSaveBlock2Ptr->frontier.domeMonId[trainerTournamentId][i]].moves[j]][k]; + allocatedArray[k] += sMovePointsForDomeTrainers[gFacilityTrainerMons[gSaveBlock2Ptr->frontier.domeMonIds[trainerTournamentId][i]].moves[j]][k]; } } } @@ -4952,7 +4952,7 @@ static void DisplayTrainerInfoOnCard(u8 flags, u8 trainerTournamentId) { for (i = 0; i < 3; i++) { - s32 evBits = gFacilityTrainerMons[gSaveBlock2Ptr->frontier.domeMonId[trainerTournamentId][i]].evSpread; + s32 evBits = gFacilityTrainerMons[gSaveBlock2Ptr->frontier.domeMonIds[trainerTournamentId][i]].evSpread; for (k = 0, j = 0; j < 6; j++) { allocatedArray[j] = 0; @@ -4961,7 +4961,7 @@ static void DisplayTrainerInfoOnCard(u8 flags, u8 trainerTournamentId) evBits >>= 1; } k = MAX_TOTAL_EVS / k; - evBits = gFacilityTrainerMons[gSaveBlock2Ptr->frontier.domeMonId[trainerTournamentId][i]].evSpread; + evBits = gFacilityTrainerMons[gSaveBlock2Ptr->frontier.domeMonIds[trainerTournamentId][i]].evSpread; for (j = 0; j < 6; j++) { if (evBits & 1) @@ -4972,7 +4972,7 @@ static void DisplayTrainerInfoOnCard(u8 flags, u8 trainerTournamentId) allocatedArray[6] += allocatedArray[0]; for (j = 0; j < 5; j++) { - nature = gFacilityTrainerMons[gSaveBlock2Ptr->frontier.domeMonId[trainerTournamentId][i]].nature; + nature = gFacilityTrainerMons[gSaveBlock2Ptr->frontier.domeMonIds[trainerTournamentId][i]].nature; if (gNatureStatTable[nature][j] > 0) { allocatedArray[j + 7] += (allocatedArray[j + 1] * 110) / 100; @@ -5210,7 +5210,7 @@ static void DisplayMatchInfoOnCard(u8 flags, u8 matchNo) { if (trainerIds[0] == TRAINER_PLAYER) { - sBattleDomeStruct->arr[2 + i + arrId] = CreateMonIcon(gSaveBlock2Ptr->frontier.domeMonId[tournamentIds[0]][i], + sBattleDomeStruct->arr[2 + i + arrId] = CreateMonIcon(gSaveBlock2Ptr->frontier.domeMonIds[tournamentIds[0]][i], SpriteCb_MonIcon, x | sFirstTrainerMonX[i], y + sFirstTrainerMonY[i], @@ -5219,7 +5219,7 @@ static void DisplayMatchInfoOnCard(u8 flags, u8 matchNo) } else if (trainerIds[0] == TRAINER_FRONTIER_BRAIN) { - sBattleDomeStruct->arr[2 + i + arrId] = CreateMonIcon(gSaveBlock2Ptr->frontier.domeMonId[tournamentIds[0]][i], + sBattleDomeStruct->arr[2 + i + arrId] = CreateMonIcon(gSaveBlock2Ptr->frontier.domeMonIds[tournamentIds[0]][i], SpriteCb_MonIcon, x | sFirstTrainerMonX[i], y + sFirstTrainerMonY[i], @@ -5228,7 +5228,7 @@ static void DisplayMatchInfoOnCard(u8 flags, u8 matchNo) } else { - sBattleDomeStruct->arr[2 + i + arrId] = CreateMonIcon(gFacilityTrainerMons[gSaveBlock2Ptr->frontier.domeMonId[tournamentIds[0]][i]].species, + sBattleDomeStruct->arr[2 + i + arrId] = CreateMonIcon(gFacilityTrainerMons[gSaveBlock2Ptr->frontier.domeMonIds[tournamentIds[0]][i]].species, SpriteCb_MonIcon, x | sFirstTrainerMonX[i], y + sFirstTrainerMonY[i], @@ -5250,7 +5250,7 @@ static void DisplayMatchInfoOnCard(u8 flags, u8 matchNo) { if (trainerIds[1] == TRAINER_PLAYER) { - sBattleDomeStruct->arr[5 + i + arrId] = CreateMonIcon(gSaveBlock2Ptr->frontier.domeMonId[tournamentIds[1]][i], + sBattleDomeStruct->arr[5 + i + arrId] = CreateMonIcon(gSaveBlock2Ptr->frontier.domeMonIds[tournamentIds[1]][i], SpriteCb_MonIcon, x | sSecondTrainerMonX[i], y + sSecondTrainerMonY[i], @@ -5259,7 +5259,7 @@ static void DisplayMatchInfoOnCard(u8 flags, u8 matchNo) } else if (trainerIds[1] == TRAINER_FRONTIER_BRAIN) { - sBattleDomeStruct->arr[5 + i + arrId] = CreateMonIcon(gSaveBlock2Ptr->frontier.domeMonId[tournamentIds[1]][i], + sBattleDomeStruct->arr[5 + i + arrId] = CreateMonIcon(gSaveBlock2Ptr->frontier.domeMonIds[tournamentIds[1]][i], SpriteCb_MonIcon, x | sSecondTrainerMonX[i], y + sSecondTrainerMonY[i], @@ -5268,7 +5268,7 @@ static void DisplayMatchInfoOnCard(u8 flags, u8 matchNo) } else { - sBattleDomeStruct->arr[5 + i + arrId] = CreateMonIcon(gFacilityTrainerMons[gSaveBlock2Ptr->frontier.domeMonId[tournamentIds[1]][i]].species, + sBattleDomeStruct->arr[5 + i + arrId] = CreateMonIcon(gFacilityTrainerMons[gSaveBlock2Ptr->frontier.domeMonIds[tournamentIds[1]][i]].species, SpriteCb_MonIcon, x | sSecondTrainerMonX[i], y + sSecondTrainerMonY[i], @@ -5566,7 +5566,7 @@ static u16 GetWinningMove(s32 winnerTournamentId, s32 loserTournamentId, u8 roun if (gSaveBlock2Ptr->frontier.domeTrainers[winnerTournamentId].trainerId == TRAINER_FRONTIER_BRAIN) moveIds[i * 4 + j] = sub_81A5060(i, j); else - moveIds[i * 4 + j] = gFacilityTrainerMons[gSaveBlock2Ptr->frontier.domeMonId[winnerTournamentId][i]].moves[j]; + moveIds[i * 4 + j] = gFacilityTrainerMons[gSaveBlock2Ptr->frontier.domeMonIds[winnerTournamentId][i]].moves[j]; movePower = gBattleMoves[moveIds[i * 4 + j]].power; if (movePower == 0) @@ -5584,9 +5584,9 @@ static u16 GetWinningMove(s32 winnerTournamentId, s32 loserTournamentId, u8 roun do { var = Random32(); - } while (gFacilityTrainerMons[gSaveBlock2Ptr->frontier.domeMonId[loserTournamentId][k]].nature != GetNatureFromPersonality(var)); + } while (gFacilityTrainerMons[gSaveBlock2Ptr->frontier.domeMonIds[loserTournamentId][k]].nature != GetNatureFromPersonality(var)); - targetSpecies = gFacilityTrainerMons[gSaveBlock2Ptr->frontier.domeMonId[loserTournamentId][k]].species; + targetSpecies = gFacilityTrainerMons[gSaveBlock2Ptr->frontier.domeMonIds[loserTournamentId][k]].species; if (var & 1) targetAbility = gBaseStats[targetSpecies].ability2; else @@ -6193,7 +6193,7 @@ static void sub_8194F58(void) monTournamentId = RandomizeFacilityTrainerMonId(trainerId); for (k = 0; k < j; k++) { - s32 checkingMonId = gSaveBlock2Ptr->frontier.domeMonId[i][k]; + s32 checkingMonId = gSaveBlock2Ptr->frontier.domeMonIds[i][k]; if (checkingMonId == monTournamentId || species[0] == gFacilityTrainerMons[monTournamentId].species || species[1] == gFacilityTrainerMons[monTournamentId].species @@ -6202,7 +6202,7 @@ static void sub_8194F58(void) } } while (k != j); - gSaveBlock2Ptr->frontier.domeMonId[i][j] = monTournamentId; + gSaveBlock2Ptr->frontier.domeMonIds[i][j] = monTournamentId; species[j] = gFacilityTrainerMons[monTournamentId].species; } gSaveBlock2Ptr->frontier.domeTrainers[i].isEliminated = 0; @@ -6218,10 +6218,10 @@ static void sub_8194F58(void) ivs = GetDomeTrainerMonIvs(gSaveBlock2Ptr->frontier.domeTrainers[i].trainerId); for (j = 0; j < 3; j++) { - CalcDomeMonStats(gFacilityTrainerMons[gSaveBlock2Ptr->frontier.domeMonId[i][j]].species, + CalcDomeMonStats(gFacilityTrainerMons[gSaveBlock2Ptr->frontier.domeMonIds[i][j]].species, monLevel, ivs, - gFacilityTrainerMons[gSaveBlock2Ptr->frontier.domeMonId[i][j]].evSpread, - gFacilityTrainerMons[gSaveBlock2Ptr->frontier.domeMonId[i][j]].nature, + gFacilityTrainerMons[gSaveBlock2Ptr->frontier.domeMonIds[i][j]].evSpread, + gFacilityTrainerMons[gSaveBlock2Ptr->frontier.domeMonIds[i][j]].nature, statValues); statSums[i] += statValues[STAT_ATK]; @@ -6230,8 +6230,8 @@ static void sub_8194F58(void) statSums[i] += statValues[STAT_SPDEF]; statSums[i] += statValues[STAT_SPEED]; statSums[i] += statValues[STAT_HP]; - monTypesBits |= gBitTable[gBaseStats[gFacilityTrainerMons[gSaveBlock2Ptr->frontier.domeMonId[i][j]].species].type1]; - monTypesBits |= gBitTable[gBaseStats[gFacilityTrainerMons[gSaveBlock2Ptr->frontier.domeMonId[i][j]].species].type2]; + monTypesBits |= gBitTable[gBaseStats[gFacilityTrainerMons[gSaveBlock2Ptr->frontier.domeMonIds[i][j]].species].type1]; + monTypesBits |= gBitTable[gBaseStats[gFacilityTrainerMons[gSaveBlock2Ptr->frontier.domeMonIds[i][j]].species].type2]; } // Because GF hates temporary vars, trainerId acts like monTypesCount here. @@ -6347,11 +6347,11 @@ static void DecideRoundWinners(u8 roundId) { for (monId2 = 0; monId2 < 3; monId2++) { - points1 += GetTypeEffectivenessPoints(gFacilityTrainerMons[gSaveBlock2Ptr->frontier.domeMonId[tournamentId1][monId1]].moves[moveSlot], - gFacilityTrainerMons[gSaveBlock2Ptr->frontier.domeMonId[tournamentId2][monId2]].species, 2); + points1 += GetTypeEffectivenessPoints(gFacilityTrainerMons[gSaveBlock2Ptr->frontier.domeMonIds[tournamentId1][monId1]].moves[moveSlot], + gFacilityTrainerMons[gSaveBlock2Ptr->frontier.domeMonIds[tournamentId2][monId2]].species, 2); } } - species = gFacilityTrainerMons[gSaveBlock2Ptr->frontier.domeMonId[tournamentId1][monId1]].species; + species = gFacilityTrainerMons[gSaveBlock2Ptr->frontier.domeMonIds[tournamentId1][monId1]].species; points1 += ( gBaseStats[species].baseHP + gBaseStats[species].baseAttack + gBaseStats[species].baseDefense @@ -6370,11 +6370,11 @@ static void DecideRoundWinners(u8 roundId) { for (monId2 = 0; monId2 < 3; monId2++) { - points2 += GetTypeEffectivenessPoints(gFacilityTrainerMons[gSaveBlock2Ptr->frontier.domeMonId[tournamentId2][monId1]].moves[moveSlot], - gFacilityTrainerMons[gSaveBlock2Ptr->frontier.domeMonId[tournamentId1][monId2]].species, 2); + points2 += GetTypeEffectivenessPoints(gFacilityTrainerMons[gSaveBlock2Ptr->frontier.domeMonIds[tournamentId2][monId1]].moves[moveSlot], + gFacilityTrainerMons[gSaveBlock2Ptr->frontier.domeMonIds[tournamentId1][monId2]].species, 2); } } - species = gFacilityTrainerMons[gSaveBlock2Ptr->frontier.domeMonId[tournamentId2][monId1]].species; + species = gFacilityTrainerMons[gSaveBlock2Ptr->frontier.domeMonIds[tournamentId2][monId1]].species; points2 += ( gBaseStats[species].baseHP + gBaseStats[species].baseAttack + gBaseStats[species].baseDefense diff --git a/src/battle_frontier_2.c b/src/battle_frontier_2.c index 6b276106c..693a1180f 100644 --- a/src/battle_frontier_2.c +++ b/src/battle_frontier_2.c @@ -1,4 +1,5 @@ #include "global.h" +#include "battle_frontier_2.h" #include "event_data.h" #include "battle_setup.h" #include "overworld.h" @@ -14,7 +15,13 @@ #include "battle_records.h" #include "international_string_util.h" #include "string_util.h" +#include "new_game.h" +#include "link.h" +#include "tv.h" +#include "apprentice.h" +#include "recorded_battle.h" #include "constants/battle_frontier.h" +#include "constants/trainers.h" extern u8 gUnknown_0203CEF8[]; @@ -22,6 +29,7 @@ extern void (* const gUnknown_08611C18[])(void); extern const u16 gUnknown_08611BFC[][2]; extern const struct BattleFrontierTrainer gBattleFrontierTrainers[]; extern const struct WindowTemplate gUnknown_08611C74; +extern const struct WindowTemplate gUnknown_08611C7C; extern void sub_81B8558(void); @@ -31,10 +39,12 @@ void ShowTowerResultsWindow(u8); void ShowDomeResultsWindow(u8); void ShowPalaceResultsWindow(u8); void ShowPikeResultsWindow(void); -void sub_81A2C94(u8); +void ShowFactoryResultsWindow(u8); void ShowArenaResultsWindow(void); -void sub_81A2F38(void); -void sub_81A2FF8(void); +void ShowPyramidResultsWindow(void); +void ShowLinkContestResultsWindow(void); +u8 sub_81A3610(void); +void sub_81A51A8(u8); void sub_81A1780(void) { @@ -173,29 +183,29 @@ void sub_81A1B98(void) gSpecialVar_0x8006 = 0; switch (gSpecialVar_0x8005) { - case 0: + case FRONTIER_FACILITY_TOWER: ShowTowerResultsWindow(gSpecialVar_0x8006); break; - case 1: + case FRONTIER_FACILITY_DOME: ShowDomeResultsWindow(gSpecialVar_0x8006); break; - case 2: + case FRONTIER_FACILITY_PALACE: ShowPalaceResultsWindow(gSpecialVar_0x8006); break; - case 5: + case FRONTIER_FACILITY_PIKE: ShowPikeResultsWindow(); break; - case 4: - sub_81A2C94(gSpecialVar_0x8006); + case FRONTIER_FACILITY_FACTORY: + ShowFactoryResultsWindow(gSpecialVar_0x8006); break; - case 3: + case FRONTIER_FACILITY_ARENA: ShowArenaResultsWindow(); break; - case 6: - sub_81A2F38(); + case FRONTIER_FACILITY_PYRAMID: + ShowPyramidResultsWindow(); break; case 7: - sub_81A2FF8(); + ShowLinkContestResultsWindow(); break; } } @@ -254,6 +264,18 @@ extern const u8 gText_SetKOTourneyResults[]; extern const u8 gText_TimesVar1[]; extern const u8 gText_BattleSwapSingleResults[]; extern const u8 gText_BattleSwapDoubleResults[]; +extern const u8 gText_FloorsCleared[]; +extern const u8 gText_BattleQuestResults[]; +extern const u8 gText_LinkContestResults[]; +extern const u8 gText_4th[]; +extern const u8 gText_3rd[]; +extern const u8 gText_2nd[]; +extern const u8 gText_1st[]; +extern const u8 gText_Cool[]; +extern const u8 gText_Beauty[]; +extern const u8 gText_Cute[]; +extern const u8 gText_Smart[]; +extern const u8 gText_Tough[]; // Battle Tower. void TowerPrintStreak(const u8 *str, u16 num, u8 x1, u8 x2, u8 y) @@ -604,7 +626,7 @@ void ShowArenaResultsWindow(void) } // Battle Factory. -void sub_81A2A28(const u8 *str, u16 num1, u16 num2, u8 x1, u8 x2, u8 x3, u8 y) +void FactoryPrintStreak(const u8 *str, u16 num1, u16 num2, u8 x1, u8 x2, u8 x3, u8 y) { AddTextPrinterParameterized(gRecordsWindowId, 1, str, x1, y, TEXT_SPEED_FF, NULL); if (num1 > 9999) @@ -618,36 +640,36 @@ void sub_81A2A28(const u8 *str, u16 num1, u16 num2, u8 x1, u8 x2, u8 x3, u8 y) AddTextPrinterParameterized(gRecordsWindowId, 1, gStringVar4, x3, y, TEXT_SPEED_FF, NULL); } -void sub_81A2B04(u8 battleMode, u8 lvlMode, u8 x1, u8 x2, u8 x3, u8 y) +void FactoryPrintRecordStreak(u8 battleMode, u8 lvlMode, u8 x1, u8 x2, u8 x3, u8 y) { - u16 num1 = gSaveBlock2Ptr->frontier.field_DEA[battleMode][lvlMode]; - u16 num2 = gSaveBlock2Ptr->frontier.field_DFA[battleMode][lvlMode]; - sub_81A2A28(gText_Record, num1, num2, x1, x2, x3, y); + u16 num1 = gSaveBlock2Ptr->frontier.factoryRecordWinStreaks[battleMode][lvlMode]; + u16 num2 = gSaveBlock2Ptr->frontier.factoryRecordRentsCount[battleMode][lvlMode]; + FactoryPrintStreak(gText_Record, num1, num2, x1, x2, x3, y); } -u16 sub_81A2B70(u8 battleMode, u8 lvlMode) +u16 FactoryGetWinStreak(u8 battleMode, u8 lvlMode) { - u16 winStreak = gSaveBlock2Ptr->frontier.field_DE2[battleMode][lvlMode]; + u16 winStreak = gSaveBlock2Ptr->frontier.factoryWinStreaks[battleMode][lvlMode]; if (winStreak > 9999) return 9999; else return winStreak; } -u16 sub_81A2BA0(u8 battleMode, u8 lvlMode) +u16 FactoryGetRentsCount(u8 battleMode, u8 lvlMode) { - u16 rents = gSaveBlock2Ptr->frontier.field_DF2[battleMode][lvlMode]; + u16 rents = gSaveBlock2Ptr->frontier.factoryRentsCount[battleMode][lvlMode]; if (rents > 9999) return 9999; else return rents; } -void sub_81A2BD0(u8 battleMode, u8 lvlMode, u8 x1, u8 x2, u8 x3, u8 y) +void FactoryPrintPrevOrCurrentStreak(u8 battleMode, u8 lvlMode, u8 x1, u8 x2, u8 x3, u8 y) { bool8 isCurrent; - u16 winStreak = sub_81A2B70(battleMode, lvlMode); - u16 rents = sub_81A2BA0(battleMode, lvlMode); + u16 winStreak = FactoryGetWinStreak(battleMode, lvlMode); + u16 rents = FactoryGetRentsCount(battleMode, lvlMode); switch (battleMode) { default: @@ -666,12 +688,12 @@ void sub_81A2BD0(u8 battleMode, u8 lvlMode, u8 x1, u8 x2, u8 x3, u8 y) } if (isCurrent == TRUE) - sub_81A2A28(gText_Current, winStreak, rents, x1, x2, x3, y); + FactoryPrintStreak(gText_Current, winStreak, rents, x1, x2, x3, y); else - sub_81A2A28(gText_Prev, winStreak, rents, x1, x2, x3, y); + FactoryPrintStreak(gText_Prev, winStreak, rents, x1, x2, x3, y); } -void sub_81A2C94(u8 battleMode) +void ShowFactoryResultsWindow(u8 battleMode) { gRecordsWindowId = AddWindow(&gUnknown_08611C74); NewMenuHelpers_DrawStdWindowFrame(gRecordsWindowId, FALSE); @@ -686,11 +708,419 @@ void sub_81A2C94(u8 battleMode) AddTextPrinterParameterized(gRecordsWindowId, 1, gText_RentalSwap, 152, 33, TEXT_SPEED_FF, NULL); AddTextPrinterParameterized(gRecordsWindowId, 1, gText_OpenLv, 8, 97, TEXT_SPEED_FF, NULL); PrintHyphens(10); - sub_81A2BD0(battleMode, FRONTIER_LVL_50, 8, 64, 158, 49); - sub_81A2B04(battleMode, FRONTIER_LVL_50, 8, 64, 158, 65); - sub_81A2BD0(battleMode, FRONTIER_LVL_OPEN, 8, 64, 158, 113); - sub_81A2B04(battleMode, FRONTIER_LVL_OPEN, 8, 64, 158, 129); + FactoryPrintPrevOrCurrentStreak(battleMode, FRONTIER_LVL_50, 8, 64, 158, 49); + FactoryPrintRecordStreak(battleMode, FRONTIER_LVL_50, 8, 64, 158, 65); + FactoryPrintPrevOrCurrentStreak(battleMode, FRONTIER_LVL_OPEN, 8, 64, 158, 113); + FactoryPrintRecordStreak(battleMode, FRONTIER_LVL_OPEN, 8, 64, 158, 129); PutWindowTilemap(gRecordsWindowId); CopyWindowToVram(gRecordsWindowId, 3); } +// Battle Pyramid. +void PyramidPrintStreak(const u8 *str, u16 num, u8 x1, u8 x2, u8 y) +{ + AddTextPrinterParameterized(gRecordsWindowId, 1, str, x1, y, TEXT_SPEED_FF, NULL); + if (num > 9999) + num = 9999; + ConvertIntToDecimalStringN(gStringVar1, num, STR_CONV_MODE_RIGHT_ALIGN, 4); + StringExpandPlaceholders(gStringVar4, gText_FloorsCleared); + AddTextPrinterParameterized(gRecordsWindowId, 1, gStringVar4, x2, y, TEXT_SPEED_FF, NULL); +} + +void PyramidPrintRecordStreak(u8 lvlMode, u8 x1, u8 x2, u8 y) +{ + u16 num = gSaveBlock2Ptr->frontier.pyramidRecordStreaks[lvlMode]; + PyramidPrintStreak(gText_Record, num, x1, x2, y); +} + +u16 PyramidGetWinStreak(u8 lvlMode) +{ + u16 winStreak = gSaveBlock2Ptr->frontier.pyramidWinStreaks[lvlMode]; + if (winStreak > 9999) + return 9999; + else + return winStreak; +} + +void PyramidPrintPrevOrCurrentStreak(u8 lvlMode, u8 x1, u8 x2, u8 y) +{ + bool8 isCurrent; + u16 winStreak = PyramidGetWinStreak(lvlMode); + + if (lvlMode != FRONTIER_LVL_50) + isCurrent = sub_81A1C24(0x2000); + else + isCurrent = sub_81A1C24(0x1000); + + if (isCurrent == TRUE) + PyramidPrintStreak(gText_Current, winStreak, x1, x2, y); + else + PyramidPrintStreak(gText_Prev, winStreak, x1, x2, y); +} + +void ShowPyramidResultsWindow(void) +{ + gRecordsWindowId = AddWindow(&gUnknown_08611C74); + NewMenuHelpers_DrawStdWindowFrame(gRecordsWindowId, FALSE); + FillWindowPixelBuffer(gRecordsWindowId, 0x11); + StringExpandPlaceholders(gStringVar4, gText_BattleQuestResults); + sub_81A1C4C(gStringVar4, 2); + AddTextPrinterParameterized(gRecordsWindowId, 1, gText_Lv502, 8, 49, TEXT_SPEED_FF, NULL); + AddTextPrinterParameterized(gRecordsWindowId, 1, gText_OpenLv, 8, 97, TEXT_SPEED_FF, NULL); + PrintHyphens(10); + PyramidPrintPrevOrCurrentStreak(FRONTIER_LVL_50, 64, 111, 49); + PyramidPrintRecordStreak(FRONTIER_LVL_50, 64, 111, 65); + PyramidPrintPrevOrCurrentStreak(FRONTIER_LVL_OPEN, 64, 111, 97); + PyramidPrintRecordStreak(FRONTIER_LVL_OPEN, 64, 111, 113); + PutWindowTilemap(gRecordsWindowId); + CopyWindowToVram(gRecordsWindowId, 3); +} + +// Link contest. Why is it in this file? +void ShowLinkContestResultsWindow(void) +{ + const u8 *str; + s32 i, j; + s32 x; + + gRecordsWindowId = AddWindow(&gUnknown_08611C7C); + NewMenuHelpers_DrawStdWindowFrame(gRecordsWindowId, FALSE); + FillWindowPixelBuffer(gRecordsWindowId, 0x11); + + StringExpandPlaceholders(gStringVar4, gText_LinkContestResults); + x = GetStringCenterAlignXOffset(1, gStringVar4, 0xD0); + AddTextPrinterParameterized(gRecordsWindowId, 1, gStringVar4, x, 1, TEXT_SPEED_FF, NULL); + + str = gText_1st; + x = GetStringRightAlignXOffset(1, str, 0x26) + 50; + AddTextPrinterParameterized(gRecordsWindowId, 1, str, x, 25, TEXT_SPEED_FF, NULL); + + str = gText_2nd; + x = GetStringRightAlignXOffset(1, str, 0x26) + 88; + AddTextPrinterParameterized(gRecordsWindowId, 1, str, x, 25, TEXT_SPEED_FF, NULL); + + str = gText_3rd; + x = GetStringRightAlignXOffset(1, str, 0x26) + 126; + AddTextPrinterParameterized(gRecordsWindowId, 1, str, x, 25, TEXT_SPEED_FF, NULL); + + str = gText_4th; + x = GetStringRightAlignXOffset(1, str, 0x26) + 164; + AddTextPrinterParameterized(gRecordsWindowId, 1, str, x, 25, TEXT_SPEED_FF, NULL); + + x = 6; + AddTextPrinterParameterized(gRecordsWindowId, 1, gText_Cool, x, 41, TEXT_SPEED_FF, NULL); + AddTextPrinterParameterized(gRecordsWindowId, 1, gText_Beauty, x, 57, TEXT_SPEED_FF, NULL); + AddTextPrinterParameterized(gRecordsWindowId, 1, gText_Cute, x, 73, TEXT_SPEED_FF, NULL); + AddTextPrinterParameterized(gRecordsWindowId, 1, gText_Smart, x, 89, TEXT_SPEED_FF, NULL); + AddTextPrinterParameterized(gRecordsWindowId, 1, gText_Tough, x, 105, TEXT_SPEED_FF, NULL); + + for (i = 0; i < 5; i++) + { + for (j = 0; j < 4; j++) + { + ConvertIntToDecimalStringN(gStringVar4, gSaveBlock2Ptr->contestLinkResults[i][j], STR_CONV_MODE_RIGHT_ALIGN, 4); + AddTextPrinterParameterized(gRecordsWindowId, 1, gStringVar4, (j * 38) + 64, (i * 16) + 41, TEXT_SPEED_FF, NULL); + } + } + + PutWindowTilemap(gRecordsWindowId); + CopyWindowToVram(gRecordsWindowId, 3); +} + +void sub_81A31FC(void) +{ + u8 text[32]; + s32 lvlMode = gSaveBlock2Ptr->frontier.lvlMode; + s32 facility = VarGet(VAR_FRONTIER_FACILITY); + s32 battleMode = VarGet(VAR_FRONTIER_BATTLE_MODE); + + switch (facility) + { + case FRONTIER_FACILITY_TOWER: + if (gSaveBlock2Ptr->frontier.towerWinStreaks[battleMode][lvlMode] > gSaveBlock2Ptr->frontier.towerRecordWinStreaks[battleMode][lvlMode]) + { + gSaveBlock2Ptr->frontier.towerRecordWinStreaks[battleMode][lvlMode] = gSaveBlock2Ptr->frontier.towerWinStreaks[battleMode][lvlMode]; + if (battleMode == FRONTIER_MODE_LINK_MULTIS) + { + StringCopy(text, gLinkPlayers[gBattleScripting.multiplayerId ^ 1].name); + StripExtCtrlCodes(text); + StringCopy(gSaveBlock2Ptr->frontier.field_EE1[lvlMode], text); + WriteUnalignedWord(gLinkPlayers[gBattleScripting.multiplayerId ^ 1].trainerId, gSaveBlock2Ptr->frontier.field_EF1[lvlMode]); + } + if (gSaveBlock2Ptr->frontier.towerWinStreaks[battleMode][lvlMode] > 1 + && sub_80EE818()) + { + switch (battleMode) + { + case FRONTIER_MODE_SINGLES: + sub_80EE8C8(gSaveBlock2Ptr->frontier.towerWinStreaks[battleMode][lvlMode], 1); + break; + case FRONTIER_MODE_DOUBLES: + sub_80EE8C8(gSaveBlock2Ptr->frontier.towerWinStreaks[battleMode][lvlMode], 2); + break; + case FRONTIER_MODE_MULTIS: + sub_80EE8C8(gSaveBlock2Ptr->frontier.towerWinStreaks[battleMode][lvlMode], 3); + break; + case FRONTIER_MODE_LINK_MULTIS: + sub_80EE8C8(gSaveBlock2Ptr->frontier.towerWinStreaks[battleMode][lvlMode], 4); + break; + } + } + } + break; + case FRONTIER_FACILITY_DOME: + if (gSaveBlock2Ptr->frontier.domeWinStreaks[battleMode][lvlMode] > gSaveBlock2Ptr->frontier.domeRecordWinStreaks[battleMode][lvlMode]) + { + gSaveBlock2Ptr->frontier.domeRecordWinStreaks[battleMode][lvlMode] = gSaveBlock2Ptr->frontier.domeWinStreaks[battleMode][lvlMode]; + if (gSaveBlock2Ptr->frontier.domeWinStreaks[battleMode][lvlMode] > 1 + && sub_80EE818()) + { + if (battleMode == FRONTIER_MODE_SINGLES) + sub_80EE8C8(gSaveBlock2Ptr->frontier.domeWinStreaks[battleMode][lvlMode], 5); + else + sub_80EE8C8(gSaveBlock2Ptr->frontier.domeWinStreaks[battleMode][lvlMode], 6); + } + } + break; + case FRONTIER_FACILITY_PALACE: + if (gSaveBlock2Ptr->frontier.palaceWinStreaks[battleMode][lvlMode] > gSaveBlock2Ptr->frontier.palaceRecordWinStreaks[battleMode][lvlMode]) + { + gSaveBlock2Ptr->frontier.palaceRecordWinStreaks[battleMode][lvlMode] = gSaveBlock2Ptr->frontier.palaceWinStreaks[battleMode][lvlMode]; + if (gSaveBlock2Ptr->frontier.palaceWinStreaks[battleMode][lvlMode] > 1 + && sub_80EE818()) + { + if (battleMode == FRONTIER_MODE_SINGLES) + sub_80EE8C8(gSaveBlock2Ptr->frontier.palaceWinStreaks[battleMode][lvlMode], 11); + else + sub_80EE8C8(gSaveBlock2Ptr->frontier.palaceWinStreaks[battleMode][lvlMode], 12); + } + } + break; + case FRONTIER_FACILITY_ARENA: + if (gSaveBlock2Ptr->frontier.arenaWinStreaks[lvlMode] > gSaveBlock2Ptr->frontier.arenaRecordStreaks[lvlMode]) + { + gSaveBlock2Ptr->frontier.arenaRecordStreaks[lvlMode] = gSaveBlock2Ptr->frontier.arenaWinStreaks[lvlMode]; + if (gSaveBlock2Ptr->frontier.arenaWinStreaks[lvlMode] > 1 + && sub_80EE818()) + { + sub_80EE8C8(gSaveBlock2Ptr->frontier.arenaWinStreaks[lvlMode], 10); + } + } + break; + case FRONTIER_FACILITY_FACTORY: + if (gSaveBlock2Ptr->frontier.factoryWinStreaks[battleMode][lvlMode] > gSaveBlock2Ptr->frontier.factoryRecordWinStreaks[battleMode][lvlMode]) + { + gSaveBlock2Ptr->frontier.factoryRecordWinStreaks[battleMode][lvlMode] = gSaveBlock2Ptr->frontier.factoryWinStreaks[battleMode][lvlMode]; + gSaveBlock2Ptr->frontier.factoryRecordRentsCount[battleMode][lvlMode] = gSaveBlock2Ptr->frontier.factoryRentsCount[battleMode][lvlMode]; + if (gSaveBlock2Ptr->frontier.factoryWinStreaks[battleMode][lvlMode] > 1 + && sub_80EE818()) + { + if (battleMode == FRONTIER_MODE_SINGLES) + sub_80EE8C8(gSaveBlock2Ptr->frontier.factoryWinStreaks[battleMode][lvlMode], 7); + else + sub_80EE8C8(gSaveBlock2Ptr->frontier.factoryWinStreaks[battleMode][lvlMode], 8); + } + } + break; + case FRONTIER_FACILITY_PIKE: + if (gSaveBlock2Ptr->frontier.pikeWinStreaks[lvlMode] > gSaveBlock2Ptr->frontier.pikeRecordStreaks[lvlMode]) + { + gSaveBlock2Ptr->frontier.pikeRecordStreaks[lvlMode] = gSaveBlock2Ptr->frontier.pikeWinStreaks[lvlMode]; + if (gSaveBlock2Ptr->frontier.pikeWinStreaks[lvlMode] > 1 + && sub_80EE818()) + { + sub_80EE8C8(gSaveBlock2Ptr->frontier.pikeWinStreaks[lvlMode], 9); + } + } + break; + case FRONTIER_FACILITY_PYRAMID: + if (gSaveBlock2Ptr->frontier.pyramidWinStreaks[lvlMode] > gSaveBlock2Ptr->frontier.pyramidRecordStreaks[lvlMode]) + { + gSaveBlock2Ptr->frontier.pyramidRecordStreaks[lvlMode] = gSaveBlock2Ptr->frontier.pyramidWinStreaks[lvlMode]; + if (gSaveBlock2Ptr->frontier.pyramidWinStreaks[lvlMode] > 1 + && sub_80EE818()) + { + sub_80EE8C8(gSaveBlock2Ptr->frontier.pyramidWinStreaks[lvlMode], 13); + } + } + break; + } +} + +void sub_81A35EC(void) +{ + VarGet(VAR_FRONTIER_FACILITY); // Unused return value. + gSpecialVar_Result = sub_81A3610(); +} + +extern const u8 gUnknown_08611550[][4]; + +u8 sub_81A3610(void) +{ + s32 ret = 0; + s32 facility = VarGet(VAR_FRONTIER_FACILITY); + s32 battleMode = VarGet(VAR_FRONTIER_BATTLE_MODE); + u16 val = GetCurrentFacilityWinStreak(); + s32 r5 = val + gUnknown_08611550[facility][3]; + s32 symbolsCount; + + if (battleMode != FRONTIER_MODE_SINGLES) + return 0; + + symbolsCount = sub_81A3B30(facility); + switch (symbolsCount) + { + case 0: + case 1: + if (r5 == gUnknown_08611550[facility][symbolsCount]) + ret = symbolsCount + 1; + break; + case 2: + default: + if (r5 == gUnknown_08611550[facility][0]) + ret = 3; + else if (r5 == gUnknown_08611550[facility][1]) + ret = 4; + else if (r5 > gUnknown_08611550[facility][1] && (r5 - gUnknown_08611550[facility][1]) % gUnknown_08611550[facility][2] == 0) + ret = 4; + break; + } + + return ret; +} + +void CopyFrontierTrainerText(u8 whichText, u16 trainerId) +{ + switch (whichText) + { + case FRONTIER_BEFORE_TEXT: + if (trainerId == TRAINER_EREADER) + FrontierSpeechToString(gSaveBlock2Ptr->frontier.ereaderTrainer.greeting); + else if (trainerId == TRAINER_FRONTIER_BRAIN) + sub_81A51A8(0); + else if (trainerId < TRAINER_RECORD_MIXING_FRIEND) + FrontierSpeechToString(gFacilityTrainers[trainerId].speechBefore); + else if (trainerId < TRAINER_RECORD_MIXING_APPRENTICE) + FrontierSpeechToString(gSaveBlock2Ptr->frontier.towerRecords[trainerId - TRAINER_RECORD_MIXING_FRIEND].greeting); + else + CopyFriendsApprenticeChallengeText(trainerId - TRAINER_RECORD_MIXING_APPRENTICE); + break; + case FRONTIER_PLAYER_LOST_TEXT: + if (trainerId == TRAINER_EREADER) + { + FrontierSpeechToString(gSaveBlock2Ptr->frontier.ereaderTrainer.farewellPlayerLost); + } + else if (trainerId == TRAINER_FRONTIER_BRAIN) + { + sub_81A51A8(0); + } + else if (trainerId < TRAINER_RECORD_MIXING_FRIEND) + { + FrontierSpeechToString(gFacilityTrainers[trainerId].speechWin); + } + else if (trainerId < TRAINER_RECORD_MIXING_APPRENTICE) + { + if (gBattleTypeFlags & BATTLE_TYPE_RECORDED) + FrontierSpeechToString(sub_81864E0()); + else + FrontierSpeechToString(gSaveBlock2Ptr->frontier.towerRecords[trainerId - TRAINER_RECORD_MIXING_FRIEND].speechWon); + } + else + { + if (gBattleTypeFlags & BATTLE_TYPE_RECORDED) + FrontierSpeechToString(sub_81864E0()); + else + FrontierSpeechToString(gSaveBlock2Ptr->apprentices[trainerId - TRAINER_RECORD_MIXING_APPRENTICE].easyChatWords); + } + break; + case FRONTIER_PLAYER_WON_TEXT: + if (trainerId == TRAINER_EREADER) + { + FrontierSpeechToString(gSaveBlock2Ptr->frontier.ereaderTrainer.farewellPlayerWon); + } + else if (trainerId == TRAINER_FRONTIER_BRAIN) + { + sub_81A51A8(1); + } + else if (trainerId < TRAINER_RECORD_MIXING_FRIEND) + { + FrontierSpeechToString(gFacilityTrainers[trainerId].speechLose); + } + else if (trainerId < TRAINER_RECORD_MIXING_APPRENTICE) + { + if (gBattleTypeFlags & BATTLE_TYPE_RECORDED) + FrontierSpeechToString(sub_81864E0()); + else + FrontierSpeechToString(gSaveBlock2Ptr->frontier.towerRecords[trainerId - TRAINER_RECORD_MIXING_FRIEND].speechLost); + } + else + { + if (gBattleTypeFlags & BATTLE_TYPE_RECORDED) + { + trainerId = sub_81864A8(); + FrontierSpeechToString(gApprentices[trainerId].easyChatWords); + } + else + { + trainerId = gSaveBlock2Ptr->apprentices[trainerId - TRAINER_RECORD_MIXING_APPRENTICE].id; + FrontierSpeechToString(gApprentices[trainerId].easyChatWords); + } + } + break; + } +} + +void sub_81A3908(void) +{ + s32 battleMode, lvlMode; + + gSaveBlock2Ptr->frontier.field_CDC = 0; + for (battleMode = 0; battleMode < 4; battleMode++) + { + for (lvlMode = 0; lvlMode < 2; lvlMode++) + { + gSaveBlock2Ptr->frontier.towerWinStreaks[battleMode][lvlMode] = 0; + if (battleMode < FRONTIER_MODE_MULTIS) + { + gSaveBlock2Ptr->frontier.domeWinStreaks[battleMode][lvlMode] = 0; + gSaveBlock2Ptr->frontier.palaceWinStreaks[battleMode][lvlMode] = 0; + gSaveBlock2Ptr->frontier.factoryWinStreaks[battleMode][lvlMode] = 0; + } + if (battleMode == FRONTIER_MODE_SINGLES) + { + gSaveBlock2Ptr->frontier.arenaWinStreaks[lvlMode] = 0; + gSaveBlock2Ptr->frontier.pikeWinStreaks[lvlMode] = 0; + gSaveBlock2Ptr->frontier.pyramidWinStreaks[lvlMode] = 0; + } + } + } + if (gSaveBlock2Ptr->frontier.field_CA8 != 0) + gSaveBlock2Ptr->frontier.field_CA8 = 1; +} + +u32 GetCurrentFacilityWinStreak(void) +{ + s32 lvlMode = gSaveBlock2Ptr->frontier.lvlMode; + s32 battleMode = VarGet(VAR_FRONTIER_BATTLE_MODE); + s32 facility = VarGet(VAR_FRONTIER_FACILITY); + + switch (facility) + { + case FRONTIER_FACILITY_TOWER: + return gSaveBlock2Ptr->frontier.towerWinStreaks[battleMode][lvlMode]; + case FRONTIER_FACILITY_DOME: + return gSaveBlock2Ptr->frontier.domeWinStreaks[battleMode][lvlMode]; + case FRONTIER_FACILITY_PALACE: + return gSaveBlock2Ptr->frontier.palaceWinStreaks[battleMode][lvlMode]; + case FRONTIER_FACILITY_ARENA: + return gSaveBlock2Ptr->frontier.arenaWinStreaks[lvlMode]; + case FRONTIER_FACILITY_FACTORY: + return gSaveBlock2Ptr->frontier.factoryWinStreaks[battleMode][lvlMode]; + case FRONTIER_FACILITY_PIKE: + return gSaveBlock2Ptr->frontier.pikeWinStreaks[lvlMode]; + case FRONTIER_FACILITY_PYRAMID: + return gSaveBlock2Ptr->frontier.pyramidWinStreaks[lvlMode]; + default: + return 0; + } +} diff --git a/src/battle_message.c b/src/battle_message.c index 99ab8bbd6..147d0295f 100644 --- a/src/battle_message.c +++ b/src/battle_message.c @@ -2579,7 +2579,7 @@ u32 BattleStringExpandPlaceholders(const u8 *src, u8 *dst) case B_TXT_TRAINER1_LOSE_TEXT: // trainerA lose text if (gBattleTypeFlags & BATTLE_TYPE_FRONTIER) { - CopyFrontierTrainerText(FRONTIER_LOSE_TEXT, gTrainerBattleOpponent_A); + CopyFrontierTrainerText(FRONTIER_PLAYER_WON_TEXT, gTrainerBattleOpponent_A); toCpy = gStringVar4; } else if (gBattleTypeFlags & BATTLE_TYPE_TRAINER_HILL) @@ -2595,7 +2595,7 @@ u32 BattleStringExpandPlaceholders(const u8 *src, u8 *dst) case B_TXT_TRAINER1_WIN_TEXT: // trainerA win text if (gBattleTypeFlags & BATTLE_TYPE_FRONTIER) { - CopyFrontierTrainerText(FRONTIER_WIN_TEXT, gTrainerBattleOpponent_A); + CopyFrontierTrainerText(FRONTIER_PLAYER_LOST_TEXT, gTrainerBattleOpponent_A); toCpy = gStringVar4; } else if (gBattleTypeFlags & BATTLE_TYPE_TRAINER_HILL) @@ -2676,7 +2676,7 @@ u32 BattleStringExpandPlaceholders(const u8 *src, u8 *dst) case B_TXT_TRAINER2_LOSE_TEXT: if (gBattleTypeFlags & BATTLE_TYPE_FRONTIER) { - CopyFrontierTrainerText(FRONTIER_LOSE_TEXT, gTrainerBattleOpponent_B); + CopyFrontierTrainerText(FRONTIER_PLAYER_WON_TEXT, gTrainerBattleOpponent_B); toCpy = gStringVar4; } else if (gBattleTypeFlags & BATTLE_TYPE_TRAINER_HILL) @@ -2692,7 +2692,7 @@ u32 BattleStringExpandPlaceholders(const u8 *src, u8 *dst) case B_TXT_TRAINER2_WIN_TEXT: if (gBattleTypeFlags & BATTLE_TYPE_FRONTIER) { - CopyFrontierTrainerText(FRONTIER_WIN_TEXT, gTrainerBattleOpponent_B); + CopyFrontierTrainerText(FRONTIER_PLAYER_LOST_TEXT, gTrainerBattleOpponent_B); toCpy = gStringVar4; } else if (gBattleTypeFlags & BATTLE_TYPE_TRAINER_HILL) diff --git a/src/battle_tower.c b/src/battle_tower.c index 4199129b2..0f6e18169 100644 --- a/src/battle_tower.c +++ b/src/battle_tower.c @@ -33,7 +33,6 @@ extern u16 gUnknown_03006298[]; extern void sub_81A3ACC(void); extern void CreateFrontierBrainPokemon(void); extern void sub_81A6CD0(void); -extern u16 sub_81A39C4(void); extern void SetFrontierBrainTrainerGfxId(void); extern u8 GetFrontierBrainTrainerPicIndex(void); extern u8 GetFrontierBrainTrainerClass(void); @@ -364,7 +363,8 @@ static void ChooseNextBattleTowerTrainer(void) { u16 id; u32 battleMode = VarGet(VAR_FRONTIER_BATTLE_MODE); - u32 r5 = sub_81A39C4() / 7; + u16 winStreak = GetCurrentFacilityWinStreak(); + u32 challengeNum = winStreak / 7; SetFacilityPtrsGetLevel(); if (battleMode == FRONTIER_MODE_MULTIS || battleMode == FRONTIER_MODE_LINK_MULTIS) @@ -385,7 +385,7 @@ static void ChooseNextBattleTowerTrainer(void) s32 i; while (1) { - id = sub_8162548(r5, gSaveBlock2Ptr->frontier.curChallengeBattleNum); + id = sub_8162548(challengeNum, gSaveBlock2Ptr->frontier.curChallengeBattleNum); // Ensure trainer wasn't previously fought in this challenge. for (i = 0; i < gSaveBlock2Ptr->frontier.curChallengeBattleNum; i++) @@ -1516,8 +1516,8 @@ static void sub_8163EE4(void) for (i = 0; i < 6; i++) { playerRecord->greeting[i] = gSaveBlock1Ptr->unk2BBC[i]; - playerRecord->unk1C[i] = gSaveBlock1Ptr->unk2BC8[i]; - playerRecord->unk28[i] = gSaveBlock1Ptr->unk2BD4[i]; + playerRecord->speechWon[i] = gSaveBlock1Ptr->unk2BC8[i]; + playerRecord->speechLost[i] = gSaveBlock1Ptr->unk2BD4[i]; } for (i = 0; i < 4; i++) @@ -1795,7 +1795,8 @@ static void sub_8164828(void) s32 i, j, arrId; s32 monPoolId; s32 level = SetFacilityPtrsGetLevel(); - s32 challengeNum = sub_81A39C4() / 7; + u16 winStreak = GetCurrentFacilityWinStreak(); + s32 challengeNum = winStreak / 7; s32 k = gSpecialVar_LastTalked - 2; s32 trainerId = gSaveBlock2Ptr->frontier.field_CB4[k]; @@ -2425,9 +2426,9 @@ bool32 RubyBattleTowerRecordToEmerald(struct RSBattleTowerRecord *src, struct Em for (i = 0; i < 6; i++) dst->greeting[i] = src->greeting[i]; for (i = 0; i < 6; i++) - dst->unk1C[i] = gUnknown_085DFA46[i]; + dst->speechWon[i] = gUnknown_085DFA46[i]; for (i = 0; i < 6; i++) - dst->unk28[i] = gUnknown_085DFA52[i]; + dst->speechLost[i] = gUnknown_085DFA52[i]; for (i = 0; i < 3; i++) dst->party[i] = src->party[i]; diff --git a/src/overworld.c b/src/overworld.c index 8d73a6680..6fc880a54 100644 --- a/src/overworld.c +++ b/src/overworld.c @@ -52,6 +52,7 @@ #include "tv.h" #include "scanline_effect.h" #include "wild_encounter.h" +#include "battle_frontier_2.h" #include "constants/abilities.h" #include "constants/map_types.h" #include "constants/maps.h" @@ -136,7 +137,6 @@ extern void sub_8087D74(void); extern void battle_pyramid_map_load_related(u8); extern void sub_80B00E8(u8); extern void sub_80E9238(u8); -extern void sub_81A3908(void); extern void sub_81AA2F8(void); extern void sub_8195E10(void); extern void sub_80EDB44(void); diff --git a/src/tv.c b/src/tv.c index 897f9950b..faa2767b0 100644 --- a/src/tv.c +++ b/src/tv.c @@ -2500,7 +2500,7 @@ bool8 sub_80EE818(void) return TRUE; } -void sub_80EE8C8(u16 winStreak, u8 facility) +void sub_80EE8C8(u16 winStreak, u8 facilityAndMode) { TVShow *show; @@ -2512,8 +2512,8 @@ void sub_80EE8C8(u16 winStreak, u8 facility) show->frontier.active = FALSE; StringCopy(show->frontier.playerName, gSaveBlock2Ptr->playerName); show->frontier.winStreak = winStreak; - show->frontier.facility = facility; - switch (facility) + show->frontier.facility = facilityAndMode; + switch (facilityAndMode) { case 1: case 5: