From 98d8dbfd8a2e6759a38d70573256c22fb386e07d Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Sun, 28 Oct 2018 00:50:06 +0200 Subject: [PATCH] Up to sub_81a443c --- asm/battle_frontier_2.s | 1092 -------------------------------------- data/battle_frontier_2.s | 2 +- include/global.h | 5 +- src/battle_frontier_2.c | 370 +++++++++++++ 4 files changed, 373 insertions(+), 1096 deletions(-) diff --git a/asm/battle_frontier_2.s b/asm/battle_frontier_2.s index 68c2f54657..b17daa99e5 100644 --- a/asm/battle_frontier_2.s +++ b/asm/battle_frontier_2.s @@ -7,1098 +7,6 @@ - - thumb_func_start sub_81A3ACC -sub_81A3ACC: @ 81A3ACC - push {r4,r5,lr} - movs r2, 0 - ldr r5, =gSaveBlock2Ptr - ldr r4, =0x00000cb4 - ldr r0, =0x0000ffff - adds r3, r0, 0 -_081A3AD8: - ldr r0, [r5] - lsls r1, r2, 1 - adds r0, r4 - adds r0, r1 - ldrh r1, [r0] - orrs r1, r3 - strh r1, [r0] - adds r2, 0x1 - cmp r2, 0x13 - ble _081A3AD8 - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81A3ACC - - thumb_func_start sub_81A3B00 -sub_81A3B00: @ 81A3B00 - push {lr} - ldr r0, =gTrainerBattleOpponent_A - ldrh r1, [r0] - ldr r0, =0x000003fe - cmp r1, r0 - bne _081A3B20 - ldr r1, =gSpecialVar_Result - movs r0, 0x1 - b _081A3B24 - .pool -_081A3B20: - ldr r1, =gSpecialVar_Result - movs r0, 0 -_081A3B24: - strh r0, [r1] - pop {r0} - bx r0 - .pool - thumb_func_end sub_81A3B00 - - thumb_func_start sub_81A3B30 -sub_81A3B30: @ 81A3B30 - push {r4,r5,lr} - adds r4, r0, 0 - lsls r4, 24 - lsrs r4, 23 - ldr r1, =0x000008c4 - adds r0, r4, r1 - bl FlagGet - adds r5, r0, 0 - ldr r0, =0x000008c5 - adds r4, r0 - adds r0, r4, 0 - bl FlagGet - adds r5, r0 - lsls r5, 24 - lsrs r5, 24 - adds r0, r5, 0 - pop {r4,r5} - pop {r1} - bx r1 - .pool - thumb_func_end sub_81A3B30 - - thumb_func_start sub_81A3B64 -sub_81A3B64: @ 81A3B64 - push {r4-r7,lr} - mov r7, r9 - mov r6, r8 - push {r6,r7} - movs r5, 0 - ldr r0, =gSaveBlock2Ptr - ldr r0, [r0] - ldr r1, =0x00000ca9 - adds r0, r1 - ldrb r0, [r0] - lsls r0, 30 - lsrs r4, r0, 30 - ldr r0, =0x000040cf - bl VarGet - lsls r0, 16 - lsrs r7, r0, 16 - ldr r0, =0x000040ce - bl VarGet - lsls r0, 16 - lsrs r6, r0, 16 - cmp r7, 0x6 - bhi _081A3C78 - lsls r0, r7, 2 - ldr r1, =_081A3BB4 - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .pool - .align 2, 0 -_081A3BB4: - .4byte _081A3BD0 - .4byte _081A3BE4 - .4byte _081A3C00 - .4byte _081A3C18 - .4byte _081A3C2C - .4byte _081A3C44 - .4byte _081A3C60 -_081A3BD0: - ldr r0, =gSaveBlock2Ptr - ldr r0, [r0] - lsls r1, r4, 1 - lsls r2, r6, 2 - adds r1, r2 - movs r2, 0xCE - lsls r2, 4 - b _081A3C68 - .pool -_081A3BE4: - ldr r0, =gSaveBlock2Ptr - ldr r0, [r0] - lsls r1, r4, 1 - lsls r2, r6, 2 - adds r1, r2 - ldr r2, =0x00000d0c - adds r0, r2 - adds r0, r1 - ldrh r5, [r0] - b _081A3C78 - .pool -_081A3C00: - ldr r0, =gSaveBlock2Ptr - ldr r0, [r0] - lsls r1, r4, 1 - lsls r2, r6, 2 - adds r1, r2 - ldr r2, =0x00000dc8 - b _081A3C68 - .pool -_081A3C18: - ldr r0, =gSaveBlock2Ptr - ldr r0, [r0] - lsls r1, r4, 1 - ldr r2, =0x00000dda - b _081A3C68 - .pool -_081A3C2C: - ldr r0, =gSaveBlock2Ptr - ldr r0, [r0] - lsls r1, r4, 1 - lsls r2, r6, 2 - adds r1, r2 - ldr r2, =0x00000de2 - b _081A3C68 - .pool -_081A3C44: - ldr r0, =gSaveBlock2Ptr - ldr r0, [r0] - lsls r1, r4, 1 - ldr r2, =0x00000e04 - adds r0, r2 - adds r0, r1 - ldrh r0, [r0] - movs r1, 0xE - b _081A3C70 - .pool -_081A3C60: - ldr r0, =gSaveBlock2Ptr - ldr r0, [r0] - lsls r1, r4, 1 - ldr r2, =0x00000e1a -_081A3C68: - adds r0, r2 - adds r0, r1 - ldrh r0, [r0] - movs r1, 0x7 -_081A3C70: - bl __udivsi3 - lsls r0, 16 - lsrs r5, r0, 16 -_081A3C78: - cmp r5, 0 - beq _081A3C7E - subs r5, 0x1 -_081A3C7E: - cmp r5, 0x1D - bls _081A3C84 - movs r5, 0x1D -_081A3C84: - ldr r2, =gUnknown_086118B4 - lsls r1, r7, 2 - adds r1, r6, r1 - lsls r0, r5, 3 - subs r0, r5 - lsls r0, 2 - adds r1, r0 - adds r7, r1, r2 - ldrb r5, [r7] - ldr r0, =gTrainerBattleOpponent_A - mov r9, r0 - ldrh r0, [r0] - ldr r1, =0x000003fe - mov r8, r1 - cmp r0, r8 - bne _081A3CA6 - adds r5, 0xA -_081A3CA6: - ldr r6, =gSaveBlock2Ptr - ldr r1, [r6] - ldr r4, =0x00000eb8 - adds r1, r4 - ldrh r0, [r1] - adds r0, r5 - strh r0, [r1] - ldr r0, =gStringVar1 - adds r1, r5, 0 - movs r2, 0 - movs r3, 0x2 - bl ConvertIntToDecimalStringN - ldr r0, [r6] - adds r2, r0, r4 - ldrh r0, [r2] - ldr r1, =0x0000270f - cmp r0, r1 - bls _081A3CCE - strh r1, [r2] -_081A3CCE: - ldr r0, [r6] - ldr r4, =0x00000eba - adds r0, r4 - ldrh r5, [r0] - ldrb r0, [r7] - adds r5, r0 - bl sub_80EED60 - mov r2, r9 - ldrh r0, [r2] - cmp r0, r8 - bne _081A3CEE - adds r5, 0xA - movs r0, 0xA - bl sub_80EED60 -_081A3CEE: - ldr r0, =0x0000ffff - cmp r5, r0 - ble _081A3CF6 - adds r5, r0, 0 -_081A3CF6: - ldr r0, [r6] - adds r0, r4 - strh r5, [r0] - pop {r3,r4} - mov r8, r3 - mov r9, r4 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81A3B64 - - thumb_func_start sub_81A3D30 -sub_81A3D30: @ 81A3D30 - push {r4,lr} - ldr r0, =0x000040cf - bl VarGet - ldr r4, =gSpecialVar_Result - lsls r0, 24 - lsrs r0, 24 - bl sub_81A3B30 - lsls r0, 24 - lsrs r0, 24 - strh r0, [r4] - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81A3D30 - - thumb_func_start sub_81A3D58 -sub_81A3D58: @ 81A3D58 - push {r4,lr} - ldr r0, =0x000040cf - bl VarGet - lsls r0, 16 - lsrs r4, r0, 16 - lsls r0, r4, 24 - lsrs r0, 24 - bl sub_81A3B30 - lsls r0, 24 - cmp r0, 0 - bne _081A3D88 - lsls r0, r4, 17 - ldr r1, =0x8C4 << 16 - adds r0, r1 - lsrs r0, 16 - bl FlagSet - b _081A3D94 - .pool -_081A3D88: - lsls r0, r4, 17 - ldr r1, =0x8C5 << 16 - adds r0, r1 - lsrs r0, 16 - bl FlagSet -_081A3D94: - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81A3D58 - - thumb_func_start sub_81A3DA0 -sub_81A3DA0: @ 81A3DA0 - push {lr} - ldr r0, =gBattleTypeFlags - ldr r1, =gSpecialVar_0x8005 - ldrh r1, [r1] - ldr r2, [r0] - ands r2, r1 - cmp r2, 0 - beq _081A3DC4 - ldr r1, =gSpecialVar_Result - movs r0, 0x1 - strh r0, [r1] - b _081A3DC8 - .pool -_081A3DC4: - ldr r0, =gSpecialVar_Result - strh r2, [r0] -_081A3DC8: - pop {r0} - bx r0 - .pool - thumb_func_end sub_81A3DA0 - - thumb_func_start sub_81A3DD0 -sub_81A3DD0: @ 81A3DD0 - push {r4-r6,lr} - adds r5, r2, 0 - lsls r0, 16 - lsrs r6, r0, 16 - lsls r1, 24 - lsrs r4, r1, 24 - adds r0, r6, 0 - bl SpeciesToNationalPokedexNum - lsls r0, 16 - lsrs r0, 16 - movs r1, 0x1 - bl GetSetPokedexFlag - lsls r0, 24 - cmp r0, 0 - beq _081A3ED6 - adds r0, r4, 0x1 - lsls r0, 24 - lsrs r4, r0, 24 - subs r0, r4, 0x1 - cmp r0, 0xA - bhi _081A3EA0 - lsls r0, 2 - ldr r1, =_081A3E0C - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .pool - .align 2, 0 -_081A3E0C: - .4byte _081A3E38 - .4byte _081A3E68 - .4byte _081A3E38 - .4byte _081A3EA0 - .4byte _081A3E38 - .4byte _081A3EA0 - .4byte _081A3E38 - .4byte _081A3EA0 - .4byte _081A3E38 - .4byte _081A3EA0 - .4byte _081A3E38 -_081A3E38: - cmp r5, r4 - bne _081A3E50 - ldr r0, =gStringVar1 - ldr r1, =gText_SpaceAndSpace - bl StringAppend - b _081A3EC8 - .pool -_081A3E50: - cmp r5, r4 - ble _081A3EC8 - ldr r0, =gStringVar1 - ldr r1, =gText_CommaSpace - bl StringAppend - b _081A3EC8 - .pool -_081A3E68: - cmp r4, r5 - bne _081A3E80 - ldr r0, =gStringVar1 - ldr r1, =gText_SpaceAndSpace - bl StringAppend - b _081A3E88 - .pool -_081A3E80: - ldr r0, =gStringVar1 - ldr r1, =gText_CommaSpace - bl StringAppend -_081A3E88: - ldr r0, =gStringVar1 - ldr r1, =gText_NewLine - bl StringAppend - b _081A3EC8 - .pool -_081A3EA0: - cmp r4, r5 - bne _081A3EB8 - ldr r0, =gStringVar1 - ldr r1, =gText_SpaceAndSpace - bl StringAppend - b _081A3EC0 - .pool -_081A3EB8: - ldr r0, =gStringVar1 - ldr r1, =gText_CommaSpace - bl StringAppend -_081A3EC0: - ldr r0, =gStringVar1 - ldr r1, =gText_ScrollTextUp - bl StringAppend -_081A3EC8: - ldr r0, =gStringVar1 - movs r1, 0xB - muls r1, r6 - ldr r2, =gSpeciesNames - adds r1, r2 - bl StringAppend -_081A3ED6: - adds r0, r4, 0 - pop {r4-r6} - pop {r1} - bx r1 - .pool - thumb_func_end sub_81A3DD0 - - thumb_func_start sub_81A3EF0 -sub_81A3EF0: @ 81A3EF0 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - ldr r2, [sp, 0x20] - ldr r4, [sp, 0x24] - mov r9, r4 - ldr r4, [sp, 0x28] - mov r10, r4 - ldr r7, [sp, 0x2C] - lsls r0, 16 - lsrs r4, r0, 16 - lsls r1, 16 - lsrs r6, r1, 16 - lsls r3, 24 - lsrs r3, 24 - mov r12, r3 - lsls r2, 24 - lsrs r2, 24 - mov r8, r2 - movs r2, 0 - movs r0, 0xCE - lsls r0, 1 - cmp r4, r0 - beq _081A3FBE - cmp r4, 0 - beq _081A3FBE - ldr r0, =gUnknown_08611C9A - ldrh r1, [r0] - ldr r5, =0x0000ffff - adds r3, r0, 0 - cmp r1, r5 - beq _081A3F54 - cmp r1, r4 - beq _081A3F48 - adds r1, r3, 0 -_081A3F3A: - adds r1, 0x2 - adds r2, 0x1 - ldrh r0, [r1] - cmp r0, r5 - beq _081A3F54 - cmp r0, r4 - bne _081A3F3A -_081A3F48: - lsls r0, r2, 1 - adds r0, r3 - ldrh r1, [r0] - ldr r0, =0x0000ffff - cmp r1, r0 - bne _081A3FBE -_081A3F54: - mov r0, r12 - cmp r0, 0 - bne _081A3F60 - mov r1, r8 - cmp r1, 0x32 - bhi _081A3FBE -_081A3F60: - movs r2, 0 - ldrb r3, [r7] - cmp r2, r3 - bge _081A3F80 - mov r1, r9 - ldrh r0, [r1] - cmp r0, r4 - beq _081A3F80 - adds r5, r3, 0 -_081A3F72: - adds r1, 0x2 - adds r2, 0x1 - cmp r2, r5 - bge _081A3F80 - ldrh r0, [r1] - cmp r0, r4 - bne _081A3F72 -_081A3F80: - cmp r2, r3 - bne _081A3FBE - cmp r6, 0 - beq _081A3FAA - movs r2, 0 - cmp r2, r3 - bge _081A3FA6 - mov r1, r10 - ldrh r0, [r1] - cmp r0, r6 - beq _081A3FA6 - adds r5, r3, 0 -_081A3F98: - adds r1, 0x2 - adds r2, 0x1 - cmp r2, r5 - bge _081A3FA6 - ldrh r0, [r1] - cmp r0, r6 - bne _081A3F98 -_081A3FA6: - cmp r2, r3 - bne _081A3FBE -_081A3FAA: - lsls r0, r3, 1 - add r0, r9 - strh r4, [r0] - ldrb r0, [r7] - lsls r0, 1 - add r0, r10 - strh r6, [r0] - ldrb r0, [r7] - adds r0, 0x1 - strb r0, [r7] -_081A3FBE: - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81A3EF0 - - thumb_func_start sub_81A3FD4 -sub_81A3FD4: @ 81A3FD4 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0x34 - movs r0, 0 - str r0, [sp, 0x2C] - add r4, sp, 0x28 - strb r0, [r4] - ldr r0, =0x000040ce - bl VarGet - lsls r0, 16 - lsrs r0, 16 - mov r10, r4 - cmp r0, 0x1 - beq _081A4016 - cmp r0, 0x1 - bgt _081A4008 - cmp r0, 0 - beq _081A4010 - b _081A402A - .pool -_081A4008: - cmp r0, 0x3 - bgt _081A402A - movs r0, 0x2 - b _081A4028 -_081A4010: - movs r1, 0x3 - str r1, [sp, 0x2C] - b _081A402A -_081A4016: - ldr r0, =0x000040cf - bl VarGet - lsls r0, 16 - movs r1, 0x3 - str r1, [sp, 0x2C] - cmp r0, 0 - bne _081A402A - movs r0, 0x4 -_081A4028: - str r0, [sp, 0x2C] -_081A402A: - movs r1, 0 - mov r9, r1 - b _081A4040 - .pool -_081A4034: - mov r1, r10 - ldrb r0, [r1] - ldr r1, [sp, 0x2C] - cmp r0, r1 - blt _081A4040 - b _081A41E0 -_081A4040: - mov r5, r9 - movs r0, 0 - mov r1, r10 - strb r0, [r1] - mov r0, r9 - adds r0, 0x1 - str r0, [sp, 0x30] -_081A404E: - movs r0, 0x64 - adds r4, r5, 0 - muls r4, r0 - ldr r0, =gPlayerParty - adds r4, r0 - adds r0, r4, 0 - movs r1, 0x41 - bl GetMonData - lsls r0, 16 - lsrs r0, 16 - mov r8, r0 - adds r0, r4, 0 - movs r1, 0xC - bl GetMonData - lsls r0, 16 - lsrs r7, r0, 16 - adds r0, r4, 0 - movs r1, 0x38 - bl GetMonData - lsls r0, 24 - lsrs r6, r0, 24 - adds r0, r4, 0 - movs r1, 0x39 - bl GetMonData - lsls r0, 16 - lsrs r4, r0, 16 - ldr r0, =0x000040cf - bl VarGet - lsls r0, 16 - lsrs r0, 16 - cmp r0, 0x6 - bne _081A40C8 - cmp r7, 0 - bne _081A40E4 - ldr r0, =gSpecialVar_Result - ldrb r3, [r0] - str r6, [sp] - add r1, sp, 0x10 - str r1, [sp, 0x4] - add r0, sp, 0x1C - str r0, [sp, 0x8] - mov r0, r10 - str r0, [sp, 0xC] - mov r0, r8 - movs r1, 0 - adds r2, r4, 0 - bl sub_81A3EF0 - b _081A40E4 - .pool -_081A40C8: - ldr r0, =gSpecialVar_Result - ldrb r3, [r0] - str r6, [sp] - add r1, sp, 0x10 - str r1, [sp, 0x4] - add r0, sp, 0x1C - str r0, [sp, 0x8] - mov r0, r10 - str r0, [sp, 0xC] - mov r0, r8 - adds r1, r7, 0 - adds r2, r4, 0 - bl sub_81A3EF0 -_081A40E4: - adds r5, 0x1 - cmp r5, 0x5 - ble _081A40EC - movs r5, 0 -_081A40EC: - cmp r5, r9 - bne _081A404E - ldr r1, [sp, 0x30] - mov r9, r1 - cmp r1, 0x5 - ble _081A4034 - mov r1, r10 - ldrb r0, [r1] - ldr r1, [sp, 0x2C] - cmp r0, r1 - bge _081A41E0 - movs r6, 0 - ldr r0, =gUnknown_08611C9A - ldrh r2, [r0] - ldr r1, =0x0000ffff - mov r8, r0 - cmp r2, r1 - beq _081A4134 - mov r4, r8 -_081A4112: - adds r0, r2, 0 - bl SpeciesToNationalPokedexNum - lsls r0, 16 - lsrs r0, 16 - movs r1, 0x1 - bl GetSetPokedexFlag - lsls r0, 24 - cmp r0, 0 - beq _081A412A - adds r6, 0x1 -_081A412A: - adds r4, 0x2 - ldrh r2, [r4] - ldr r0, =0x0000ffff - cmp r2, r0 - bne _081A4112 -_081A4134: - ldr r1, =gStringVar1 - movs r0, 0xFF - strb r0, [r1] - ldr r1, =gSpecialVar_0x8004 - movs r0, 0x1 - strh r0, [r1] - movs r0, 0 - mov r1, r10 - strb r0, [r1] - mov r1, r8 - ldrh r0, [r1] - ldr r1, =0x0000ffff - cmp r0, r1 - beq _081A416A - mov r5, r10 - adds r7, r1, 0 - mov r4, r8 -_081A4156: - ldrh r0, [r4] - ldrb r1, [r5] - adds r2, r6, 0 - bl sub_81A3DD0 - strb r0, [r5] - adds r4, 0x2 - ldrh r0, [r4] - cmp r0, r7 - bne _081A4156 -_081A416A: - mov r0, r10 - ldrb r4, [r0] - cmp r4, 0 - bne _081A41A4 - ldr r4, =gStringVar1 - ldr r1, =gText_Space2 - adds r0, r4, 0 - bl StringAppend - ldr r1, =gText_Are - adds r0, r4, 0 - bl StringAppend - b _081A4202 - .pool -_081A41A4: - movs r0, 0x1 - ands r0, r4 - cmp r0, 0 - beq _081A41C0 - ldr r0, =gStringVar1 - ldr r1, =gText_ScrollTextUp - bl StringAppend - b _081A41C8 - .pool -_081A41C0: - ldr r0, =gStringVar1 - ldr r1, =gText_Space2 - bl StringAppend -_081A41C8: - ldr r0, =gStringVar1 - ldr r1, =gText_Are2 - bl StringAppend - b _081A4202 - .pool -_081A41E0: - ldr r1, =gSpecialVar_0x8004 - movs r0, 0 - strh r0, [r1] - ldr r0, =gSaveBlock2Ptr - ldr r2, [r0] - ldr r0, =gSpecialVar_Result - ldrb r0, [r0] - ldr r1, =0x00000ca9 - adds r2, r1 - movs r1, 0x3 - ands r1, r0 - ldrb r3, [r2] - movs r0, 0x4 - negs r0, r0 - ands r0, r3 - orrs r0, r1 - strb r0, [r2] -_081A4202: - add sp, 0x34 - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81A3FD4 - - thumb_func_start sub_81A4224 -sub_81A4224: @ 81A4224 - push {lr} - bl ValidateEReaderTrainer - pop {r0} - bx r0 - thumb_func_end sub_81A4224 - - thumb_func_start sub_81A4230 -sub_81A4230: @ 81A4230 - push {r4-r7,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 - bls _081A425A - b _081A4394 -_081A425A: - lsls r0, 2 - ldr r1, =_081A4278 - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .pool - .align 2, 0 -_081A4278: - .4byte _081A4294 - .4byte _081A42DC - .4byte _081A431C - .4byte _081A4338 - .4byte _081A434C - .4byte _081A4368 - .4byte _081A437C -_081A4294: - ldr r7, =gSaveBlock2Ptr - ldr r0, [r7] - lsls r4, 1 - lsls r1, r5, 2 - adds r1, r4, r1 - movs r6, 0xCE - lsls r6, 4 - adds r3, r0, r6 - adds r2, r3, r1 - ldrh r1, [r2] - ldr r0, =0x0000270e - cmp r1, r0 - bhi _081A4394 - adds r0, r1, 0x1 - strh r0, [r2] - cmp r5, 0 - bne _081A4394 - adds r0, r3, r4 - ldrh r1, [r0] - movs r0, 0x20 - bl SetGameStat - ldr r1, [r7] - adds r0, r1, r6 - adds r0, r4 - ldrh r0, [r0] - ldr r2, =0x00000d02 - adds r1, r2 - b _081A4392 - .pool -_081A42DC: - ldr r6, =gSaveBlock2Ptr - ldr r0, [r6] - lsls r2, r4, 1 - lsls r1, r5, 2 - adds r1, r2, r1 - ldr r3, =0x00000d0c - adds r0, r3 - adds r3, r0, r1 - ldrh r0, [r3] - ldr r2, =0x0000270e - cmp r0, r2 - bhi _081A42F8 - adds r0, 0x1 - strh r0, [r3] -_081A42F8: - ldr r0, [r6] - ldr r3, =0x00000d1c - adds r0, r3 - adds r1, r0, r1 - ldrh r0, [r1] - cmp r0, r2 - bhi _081A4394 - adds r0, 0x1 - b _081A4392 - .pool -_081A431C: - ldr r0, =gSaveBlock2Ptr - ldr r2, [r0] - lsls r0, r4, 1 - lsls r1, r5, 2 - adds r0, r1 - ldr r1, =0x00000dc8 - adds r2, r1 - adds r1, r2, r0 - b _081A4388 - .pool -_081A4338: - ldr r0, =gSaveBlock2Ptr - ldr r0, [r0] - lsls r1, r4, 1 - ldr r2, =0x00000dda - adds r0, r2 - b _081A4386 - .pool -_081A434C: - ldr r0, =gSaveBlock2Ptr - ldr r2, [r0] - lsls r0, r4, 1 - lsls r1, r5, 2 - adds r0, r1 - ldr r3, =0x00000de2 - adds r2, r3 - adds r1, r2, r0 - b _081A4388 - .pool -_081A4368: - ldr r0, =gSaveBlock2Ptr - ldr r0, [r0] - lsls r1, r4, 1 - ldr r2, =0x00000e04 - adds r0, r2 - b _081A4386 - .pool -_081A437C: - ldr r0, =gSaveBlock2Ptr - ldr r0, [r0] - lsls r1, r4, 1 - ldr r3, =0x00000e1a - adds r0, r3 -_081A4386: - adds r1, r0, r1 -_081A4388: - ldrh r3, [r1] - ldr r0, =0x0000270e - cmp r3, r0 - bhi _081A4394 - adds r0, r3, 0x1 -_081A4392: - strh r0, [r1] -_081A4394: - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81A4230 - - thumb_func_start sub_81A43A8 -sub_81A43A8: @ 81A43A8 - push {r4-r6,lr} - sub sp, 0x4 - movs r4, 0 - ldr r6, =gSaveBlock1Ptr - movs r5, 0x64 -_081A43B2: - ldr r0, =gSaveBlock2Ptr - ldr r0, [r0] - lsls r1, r4, 1 - ldr r2, =0x00000caa - adds r0, r2 - adds r1, r0, r1 - ldrh r0, [r1] - cmp r0, 0 - beq _081A43EE - adds r1, r0, 0 - muls r1, r5 - movs r0, 0xEA - lsls r0, 1 - adds r1, r0 - ldr r0, [r6] - adds r0, r1 - movs r1, 0xC - movs r2, 0 - bl GetMonData - mov r1, sp - strh r0, [r1] - adds r0, r4, 0 - muls r0, r5 - ldr r1, =gPlayerParty - adds r0, r1 - movs r1, 0xC - mov r2, sp - bl SetMonData -_081A43EE: - adds r0, r4, 0x1 - lsls r0, 24 - lsrs r4, r0, 24 - cmp r4, 0x3 - bls _081A43B2 - add sp, 0x4 - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81A43A8 - - thumb_func_start sub_81A4410 -sub_81A4410: @ 81A4410 - push {r4,lr} - ldr r4, =gSpecialVar_Result - bl MoveRecordedBattleToSaveData - strh r0, [r4] - ldr r0, =gSaveBlock2Ptr - ldr r1, [r0] - ldr r0, =0x00000ca9 - adds r1, r0 - ldrb r0, [r1] - movs r2, 0x8 - orrs r0, r2 - strb r0, [r1] - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81A4410 - - thumb_func_start sub_81A443C -sub_81A443C: @ 81A443C - push {lr} - ldr r0, =gSpecialVar_0x8005 - ldrh r0, [r0] - cmp r0, 0 - beq _081A4450 - cmp r0, 0x1 - beq _081A4464 - b _081A446E - .pool -_081A4450: - ldr r0, =gStringVar1 - ldr r1, =gTrainerBattleOpponent_A - ldrh r1, [r1] - bl GetFrontierTrainerName - b _081A446E - .pool -_081A4464: - ldr r0, =gStringVar2 - ldr r1, =gTrainerBattleOpponent_A - ldrh r1, [r1] - bl GetFrontierTrainerName -_081A446E: - pop {r0} - bx r0 - .pool - thumb_func_end sub_81A443C - thumb_func_start sub_81A447C sub_81A447C: @ 81A447C push {r4-r7,lr} diff --git a/data/battle_frontier_2.s b/data/battle_frontier_2.s index 51b62461d8..fbe9e87983 100644 --- a/data/battle_frontier_2.s +++ b/data/battle_frontier_2.s @@ -85,7 +85,7 @@ gUnknown_08611C18:: @ 8611C18 .4byte sub_81A1B1C .4byte sub_81A1B28 .4byte sub_81A1B38 - .4byte sub_81A1B98 + .4byte sub_81A1B98 @ x7 .4byte sub_81A31FC .4byte sub_81A35EC .4byte sub_81A3B00 diff --git a/include/global.h b/include/global.h index 7f5a025bef..9a03300b29 100644 --- a/include/global.h +++ b/include/global.h @@ -447,9 +447,8 @@ struct BattleFrontier /*0xE6C*/ u16 field_E6C; /*0xE6E*/ u16 field_E6E; /*0xE70*/ struct Struct_field_E70 field_E70[6]; - /*0xEB8*/ u16 frontierBattlePoints; - /*0xEBA*/ u8 field_EBA; - /*0xEBB*/ u8 field_EBB; + /*0xEB8*/ u16 battlePoints; + /*0xEBA*/ u16 field_EBA; /*0xEBC*/ u32 battlesCount; /*0xEC0*/ u16 field_EC0[16]; /*0xEE0*/ u8 field_EE0; diff --git a/src/battle_frontier_2.c b/src/battle_frontier_2.c index 693a1180f1..eefa95ab03 100644 --- a/src/battle_frontier_2.c +++ b/src/battle_frontier_2.c @@ -19,9 +19,13 @@ #include "link.h" #include "tv.h" #include "apprentice.h" +#include "pokedex.h" #include "recorded_battle.h" +#include "data2.h" #include "constants/battle_frontier.h" #include "constants/trainers.h" +#include "constants/species.h" +#include "constants/game_stat.h" extern u8 gUnknown_0203CEF8[]; @@ -1124,3 +1128,369 @@ u32 GetCurrentFacilityWinStreak(void) return 0; } } + +void sub_81A3ACC(void) +{ + s32 i; + + for (i = 0; i < 20; i++) + gSaveBlock2Ptr->frontier.field_CB4[i] |= 0xFFFF; +} + +void sub_81A3B00(void) +{ + if (gTrainerBattleOpponent_A == TRAINER_FRONTIER_BRAIN) + gSpecialVar_Result = TRUE; + else + gSpecialVar_Result = FALSE; +} + +u8 sub_81A3B30(u8 facility) +{ + return FlagGet(FLAG_SYS_TOWER_SILVER + facility * 2) + + FlagGet(FLAG_SYS_TOWER_GOLD + facility * 2); +} + +extern const u8 gUnknown_086118B4[29][7][4]; + +void sub_81A3B64(void) +{ + s32 challengeNum = 0; + s32 lvlMode = gSaveBlock2Ptr->frontier.lvlMode; + s32 facility = VarGet(VAR_FRONTIER_FACILITY); + s32 battleMode = VarGet(VAR_FRONTIER_BATTLE_MODE); + s32 points; + + switch (facility) + { + case FRONTIER_FACILITY_TOWER: + challengeNum = gSaveBlock2Ptr->frontier.towerWinStreaks[battleMode][lvlMode] / 7; + break; + case FRONTIER_FACILITY_DOME: + challengeNum = gSaveBlock2Ptr->frontier.domeWinStreaks[battleMode][lvlMode]; + break; + case FRONTIER_FACILITY_PALACE: + challengeNum = gSaveBlock2Ptr->frontier.palaceWinStreaks[battleMode][lvlMode] / 7; + break; + case FRONTIER_FACILITY_ARENA: + challengeNum = gSaveBlock2Ptr->frontier.arenaWinStreaks[lvlMode] / 7; + break; + case FRONTIER_FACILITY_FACTORY: + challengeNum = gSaveBlock2Ptr->frontier.factoryWinStreaks[battleMode][lvlMode] / 7; + break; + case FRONTIER_FACILITY_PIKE: + challengeNum = gSaveBlock2Ptr->frontier.pikeWinStreaks[lvlMode] / 14; + break; + case FRONTIER_FACILITY_PYRAMID: + challengeNum = gSaveBlock2Ptr->frontier.pyramidWinStreaks[lvlMode] / 7; + break; + } + + if (challengeNum != 0) + challengeNum--; + if (challengeNum > ARRAY_COUNT(gUnknown_086118B4)) + challengeNum = ARRAY_COUNT(gUnknown_086118B4); + + points = gUnknown_086118B4[challengeNum][facility][battleMode]; + if (gTrainerBattleOpponent_A == TRAINER_FRONTIER_BRAIN) + points += 10; + gSaveBlock2Ptr->frontier.battlePoints += points; + ConvertIntToDecimalStringN(gStringVar1, points, STR_CONV_MODE_LEFT_ALIGN, 2); + if (gSaveBlock2Ptr->frontier.battlePoints > 9999) + gSaveBlock2Ptr->frontier.battlePoints = 9999; + + points = gSaveBlock2Ptr->frontier.field_EBA; + points += gUnknown_086118B4[challengeNum][facility][battleMode]; + sub_80EED60(gUnknown_086118B4[challengeNum][facility][battleMode]); + if (gTrainerBattleOpponent_A == TRAINER_FRONTIER_BRAIN) + { + points += 10; + sub_80EED60(10); + } + if (points > 0xFFFF) + points = 0xFFFF; + gSaveBlock2Ptr->frontier.field_EBA = points; +} + +void sub_81A3D30(void) +{ + s32 facility = VarGet(VAR_FRONTIER_FACILITY); + gSpecialVar_Result = sub_81A3B30(facility); +} + +void sub_81A3D58(void) +{ + s32 facility = VarGet(VAR_FRONTIER_FACILITY); + if (sub_81A3B30(facility) == 0) + FlagSet(FLAG_SYS_TOWER_SILVER + facility * 2); + else + FlagSet(FLAG_SYS_TOWER_GOLD + facility * 2); +} + +void sub_81A3DA0(void) +{ + if (gBattleTypeFlags & gSpecialVar_0x8005) + gSpecialVar_Result = TRUE; + else + gSpecialVar_Result = FALSE; +} + +extern const u8 gText_SpaceAndSpace[]; +extern const u8 gText_CommaSpace[]; +extern const u8 gText_NewLine[]; +extern const u8 gText_ScrollTextUp[]; +extern const u8 gText_Space2[]; +extern const u8 gText_Are[]; +extern const u8 gText_Are2[]; + +u8 sub_81A3DD0(u16 species, u8 arg1, s32 arg2) +{ + if (GetSetPokedexFlag(SpeciesToNationalPokedexNum(species), FLAG_GET_CAUGHT)) + { + arg1++; + switch (arg1) + { + case 1: + case 3: + case 5: + case 7: + case 9: + case 11: + if (arg2 == arg1) + StringAppend(gStringVar1, gText_SpaceAndSpace); + else if (arg2 > arg1) + StringAppend(gStringVar1, gText_CommaSpace); + break; + case 2: + if (arg1 == arg2) + StringAppend(gStringVar1, gText_SpaceAndSpace); + else + StringAppend(gStringVar1, gText_CommaSpace); + StringAppend(gStringVar1, gText_NewLine); + break; + default: + if (arg1 == arg2) + StringAppend(gStringVar1, gText_SpaceAndSpace); + else + StringAppend(gStringVar1, gText_CommaSpace); + StringAppend(gStringVar1, gText_ScrollTextUp); + break; + } + StringAppend(gStringVar1, gSpeciesNames[species]); + } + + return arg1; +} + +extern const u16 gUnknown_08611C9A[]; + +void AppendIfValid(u16 species, u16 heldItem, u16 hp, u8 lvlMode, u8 monLevel, u16 *speciesArray, u16 *itemsArray, u8 *count) +{ + s32 i = 0; + + if (species == SPECIES_EGG || species == SPECIES_NONE) + return; + + for (i = 0; gUnknown_08611C9A[i] != 0xFFFF && gUnknown_08611C9A[i] != species; i++) + ; + + if (gUnknown_08611C9A[i] != 0xFFFF) + return; + if (lvlMode == FRONTIER_LVL_50 && monLevel > 50) + return; + + for (i = 0; i < *count && speciesArray[i] != species; i++) + ; + if (i != *count) + return; + + if (heldItem != 0) + { + for (i = 0; i < *count && itemsArray[i] != heldItem; i++) + ; + if (i != *count) + return; + } + + speciesArray[*count] = species; + itemsArray[*count] = heldItem; + (*count)++; +} + +void sub_81A3FD4(void) +{ + u16 speciesArray[6]; + u16 itemArray[6]; + s32 monId = 0; + s32 toChoose = 0; + u8 count = 0; + s32 battleMode = VarGet(VAR_FRONTIER_BATTLE_MODE); + s32 monIdLooper; + + switch (battleMode) + { + case FRONTIER_MODE_SINGLES: + toChoose = 3; + break; + case FRONTIER_MODE_MULTIS: + case FRONTIER_MODE_LINK_MULTIS: + toChoose = 2; + break; + case FRONTIER_MODE_DOUBLES: + if (VarGet(VAR_FRONTIER_FACILITY) == FRONTIER_FACILITY_TOWER) + toChoose = 4; + else + toChoose = 3; + break; + } + + monIdLooper = 0; + do + { + monId = monIdLooper; + count = 0; + do + { + u16 species = GetMonData(&gPlayerParty[monId], MON_DATA_SPECIES2); + u16 heldItem = GetMonData(&gPlayerParty[monId], MON_DATA_HELD_ITEM); + u8 level = GetMonData(&gPlayerParty[monId], MON_DATA_LEVEL); + u16 hp = GetMonData(&gPlayerParty[monId], MON_DATA_HP); + if (VarGet(VAR_FRONTIER_FACILITY) == FRONTIER_FACILITY_PYRAMID) + { + if (heldItem == 0) + AppendIfValid(species, heldItem, hp, gSpecialVar_Result, level, speciesArray, itemArray, &count); + } + else + { + AppendIfValid(species, heldItem, hp, gSpecialVar_Result, level, speciesArray, itemArray, &count); + } + monId++; + if (monId >= PARTY_SIZE) + monId = 0; + } while (monId != monIdLooper); + + monIdLooper++; + } while (monIdLooper < PARTY_SIZE && count < toChoose); + + if (count < toChoose) + { + s32 i; + s32 caughtBannedMons = 0; + s32 species = gUnknown_08611C9A[0]; + for (i = 0; species != 0xFFFF; i++, species = gUnknown_08611C9A[i]) + { + if (GetSetPokedexFlag(SpeciesToNationalPokedexNum(species), FLAG_GET_CAUGHT)) + caughtBannedMons++; + } + gStringVar1[0] = EOS; + gSpecialVar_0x8004 = 1; + count = 0; + for (i = 0; gUnknown_08611C9A[i] != 0xFFFF; i++) + count = sub_81A3DD0(gUnknown_08611C9A[i], count, caughtBannedMons); + + if (count == 0) + { + StringAppend(gStringVar1, gText_Space2); + StringAppend(gStringVar1, gText_Are); + } + else + { + if (count & 1) + StringAppend(gStringVar1, gText_ScrollTextUp); + else + StringAppend(gStringVar1, gText_Space2); + StringAppend(gStringVar1, gText_Are2); + } + } + else + { + gSpecialVar_0x8004 = 0; + gSaveBlock2Ptr->frontier.lvlMode = gSpecialVar_Result; + } +} + +void sub_81A4224(void) +{ + ValidateEReaderTrainer(); +} + +void sub_81A4230(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: + if (gSaveBlock2Ptr->frontier.towerWinStreaks[battleMode][lvlMode] < 9999) + { + gSaveBlock2Ptr->frontier.towerWinStreaks[battleMode][lvlMode]++; + if (battleMode == FRONTIER_MODE_SINGLES) + { + SetGameStat(GAME_STAT_BATTLE_TOWER_BEST_STREAK, gSaveBlock2Ptr->frontier.towerWinStreaks[battleMode][lvlMode]); + gSaveBlock2Ptr->frontier.field_D02 = gSaveBlock2Ptr->frontier.towerWinStreaks[battleMode][lvlMode]; + } + } + break; + case FRONTIER_FACILITY_DOME: + if (gSaveBlock2Ptr->frontier.domeWinStreaks[battleMode][lvlMode] < 9999) + gSaveBlock2Ptr->frontier.domeWinStreaks[battleMode][lvlMode]++; + if (gSaveBlock2Ptr->frontier.domeTotalChampionships[battleMode][lvlMode] < 9999) + gSaveBlock2Ptr->frontier.domeTotalChampionships[battleMode][lvlMode]++; + break; + case FRONTIER_FACILITY_PALACE: + if (gSaveBlock2Ptr->frontier.palaceWinStreaks[battleMode][lvlMode] < 9999) + gSaveBlock2Ptr->frontier.palaceWinStreaks[battleMode][lvlMode]++; + break; + case FRONTIER_FACILITY_ARENA: + if (gSaveBlock2Ptr->frontier.arenaWinStreaks[lvlMode] < 9999) + gSaveBlock2Ptr->frontier.arenaWinStreaks[lvlMode]++; + break; + case FRONTIER_FACILITY_FACTORY: + if (gSaveBlock2Ptr->frontier.factoryWinStreaks[battleMode][lvlMode] < 9999) + gSaveBlock2Ptr->frontier.factoryWinStreaks[battleMode][lvlMode]++; + break; + case FRONTIER_FACILITY_PIKE: + if (gSaveBlock2Ptr->frontier.pikeWinStreaks[lvlMode] < 9999) + gSaveBlock2Ptr->frontier.pikeWinStreaks[lvlMode]++; + break; + case FRONTIER_FACILITY_PYRAMID: + if (gSaveBlock2Ptr->frontier.pyramidWinStreaks[lvlMode] < 9999) + gSaveBlock2Ptr->frontier.pyramidWinStreaks[lvlMode]++; + break; + } +} + +void sub_81A43A8(void) +{ + u8 i; + + for (i = 0; i < 4; i++) + { + if (gSaveBlock2Ptr->frontier.selectedPartyMons[i] != 0) + { + u16 item = GetMonData(&gSaveBlock1Ptr->playerParty[gSaveBlock2Ptr->frontier.selectedPartyMons[i] - 1], MON_DATA_HELD_ITEM, NULL); + SetMonData(&gPlayerParty[i], MON_DATA_HELD_ITEM, &item); + } + } +} + +void sub_81A4410(void) +{ + gSpecialVar_Result = MoveRecordedBattleToSaveData(); + gSaveBlock2Ptr->frontier.field_CA9_b = 1; +} + +void sub_81A443C(void) +{ + switch (gSpecialVar_0x8005) + { + case 0: + GetFrontierTrainerName(gStringVar1, gTrainerBattleOpponent_A); + break; + case 1: + GetFrontierTrainerName(gStringVar2, gTrainerBattleOpponent_A); + break; + } +}