From a54fa23b5f30b0c6cc24f211137b3f6c892b3cd5 Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Wed, 15 Aug 2018 15:49:50 +0200 Subject: [PATCH] Begin battle frontier 1 --- asm/battle_frontier_1.s | 1792 --------------------------------------- include/global.h | 60 +- ld_script.txt | 2 + src/battle_frontier_1.c | 1235 +++++++++++++++++++++++++++ 4 files changed, 1285 insertions(+), 1804 deletions(-) create mode 100644 src/battle_frontier_1.c diff --git a/asm/battle_frontier_1.s b/asm/battle_frontier_1.s index e353cb4755..6715dadea7 100644 --- a/asm/battle_frontier_1.s +++ b/asm/battle_frontier_1.s @@ -5,1798 +5,6 @@ .text - thumb_func_start sub_818E9AC -sub_818E9AC: @ 818E9AC - push {lr} - ldr r1, =gUnknown_0860D090 - ldr r0, =gSpecialVar_0x8004 - ldrh r0, [r0] - lsls r0, 2 - adds r0, r1 - ldr r0, [r0] - bl _call_via_r0 - pop {r0} - bx r0 - .pool - thumb_func_end sub_818E9AC - - thumb_func_start sub_818E9CC -sub_818E9CC: @ 818E9CC - push {r4-r7,lr} - ldr r4, =gSaveBlock2Ptr - ldr r0, [r4] - ldr r1, =0x00000ca9 - adds r0, r1 - ldrb r0, [r0] - lsls r0, 30 - lsrs r5, r0, 30 - ldr r0, =0x000040ce - bl VarGet - lsls r0, 16 - lsrs r7, r0, 16 - ldr r0, [r4] - ldr r2, =0x00000ca8 - adds r0, r2 - movs r6, 0 - strb r6, [r0] - ldr r1, [r4] - adds r2, 0xA - adds r0, r1, r2 - strh r6, [r0] - ldr r0, =0x00000ca9 - adds r1, r0 - ldrb r2, [r1] - movs r0, 0x5 - negs r0, r0 - ands r0, r2 - strb r0, [r1] - ldr r1, [r4] - ldr r2, =0x00000ca9 - adds r1, r2 - ldrb r2, [r1] - movs r0, 0x9 - negs r0, r0 - ands r0, r2 - strb r0, [r1] - ldr r4, [r4] - ldr r0, =0x00000cdc - adds r3, r4, r0 - ldr r2, =gUnknown_0860D0EC - lsls r1, r5, 2 - lsls r0, r7, 3 - adds r1, r0 - adds r1, r2 - ldr r0, [r3] - ldr r1, [r1] - ands r0, r1 - cmp r0, 0 - bne _0818EA3E - lsls r0, r5, 1 - lsls r1, r7, 2 - adds r0, r1 - ldr r2, =0x00000d0c - adds r1, r4, r2 - adds r1, r0 - strh r6, [r1] -_0818EA3E: - ldr r0, =gSaveBlock1Ptr - ldr r0, [r0] - movs r1, 0x4 - ldrsb r1, [r0, r1] - movs r2, 0x5 - ldrsb r2, [r0, r2] - movs r3, 0x1 - negs r3, r3 - movs r0, 0 - bl saved_warp2_set - ldr r0, =gTrainerBattleOpponent_A - strh r6, [r0] - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_818E9CC - - thumb_func_start sub_818EA84 -sub_818EA84: @ 818EA84 - push {r4-r6,lr} - ldr r0, =gSaveBlock2Ptr - ldr r0, [r0] - ldr r1, =0x00000ca9 - adds r0, r1 - ldrb r0, [r0] - lsls r0, 30 - lsrs r5, r0, 30 - ldr r0, =0x000040ce - bl VarGet - lsls r0, 16 - lsrs r6, r0, 16 - ldr r0, =gSpecialVar_0x8005 - ldrh r0, [r0] - cmp r0, 0x9 - bls _0818EAA8 - b _0818ED10 -_0818EAA8: - lsls r0, 2 - ldr r1, =_0818EAC8 - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .pool - .align 2, 0 -_0818EAC8: - .4byte _0818EAF0 - .4byte _0818EB14 - .4byte _0818EB48 - .4byte _0818EB64 - .4byte _0818EB80 - .4byte _0818EB98 - .4byte _0818EBB4 - .4byte _0818EC40 - .4byte _0818ECD0 - .4byte _0818ECF4 -_0818EAF0: - ldr r3, =gSpecialVar_Result - ldr r0, =gSaveBlock2Ptr - ldr r0, [r0] - lsls r1, r5, 1 - lsls r2, r6, 2 - adds r1, r2 - ldr r2, =0x00000d0c - adds r0, r2 - adds r0, r1 - ldrh r0, [r0] - strh r0, [r3] - b _0818ED10 - .pool -_0818EB14: - ldr r4, =gSpecialVar_Result - ldr r0, =gSaveBlock2Ptr - ldr r2, [r0] - ldr r3, =0x00000cdc - adds r2, r3 - ldr r3, =gUnknown_0860D0EC - lsls r0, r5, 2 - lsls r1, r6, 3 - adds r0, r1 - adds r0, r3 - ldr r1, [r2] - ldr r0, [r0] - ands r1, r0 - negs r0, r1 - orrs r0, r1 - lsrs r0, 31 - strh r0, [r4] - b _0818ED10 - .pool -_0818EB48: - ldr r1, =gSpecialVar_Result - ldr r0, =gSaveBlock2Ptr - ldr r0, [r0] - ldr r2, =0x00000d08 - adds r0, r2 - ldrb r0, [r0] - lsls r0, 31 - b _0818ECBE - .pool -_0818EB64: - ldr r1, =gSpecialVar_Result - ldr r0, =gSaveBlock2Ptr - ldr r0, [r0] - ldr r3, =0x00000d08 - adds r0, r3 - ldrb r0, [r0] - lsls r0, 30 - b _0818ECBE - .pool -_0818EB80: - ldr r1, =gSpecialVar_Result - ldr r0, =gSaveBlock2Ptr - ldr r0, [r0] - ldr r2, =0x00000d08 - adds r0, r2 - b _0818ECBA - .pool -_0818EB98: - ldr r1, =gSpecialVar_Result - ldr r0, =gSaveBlock2Ptr - ldr r0, [r0] - ldr r3, =0x00000d08 - adds r0, r3 - ldrb r0, [r0] - lsls r0, 28 - b _0818ECBE - .pool -_0818EBB4: - ldr r0, =0x000040ce - bl VarGet - lsls r0, 16 - lsrs r0, 16 - cmp r0, 0x1 - bne _0818EC04 - cmp r5, 0 - beq _0818EBE8 - ldr r1, =gSpecialVar_Result - ldr r0, =gSaveBlock2Ptr - ldr r0, [r0] - ldr r2, =0x00000d08 - adds r0, r2 - ldrb r0, [r0] - lsls r0, 26 - b _0818ECBE - .pool -_0818EBE8: - ldr r1, =gSpecialVar_Result - ldr r0, =gSaveBlock2Ptr - ldr r0, [r0] - ldr r3, =0x00000d08 - adds r0, r3 - ldrb r0, [r0] - lsls r0, 27 - b _0818ECBE - .pool -_0818EC04: - cmp r5, 0 - beq _0818EC24 - ldr r1, =gSpecialVar_Result - ldr r0, =gSaveBlock2Ptr - ldr r0, [r0] - ldr r2, =0x00000d08 - adds r0, r2 - ldrb r0, [r0] - lsls r0, 30 - b _0818ECBE - .pool -_0818EC24: - ldr r1, =gSpecialVar_Result - ldr r0, =gSaveBlock2Ptr - ldr r0, [r0] - ldr r3, =0x00000d08 - adds r0, r3 - ldrb r0, [r0] - lsls r0, 31 - b _0818ECBE - .pool -_0818EC40: - ldr r0, =0x000040ce - bl VarGet - lsls r0, 16 - lsrs r0, 16 - cmp r0, 0x1 - bne _0818EC90 - cmp r5, 0 - beq _0818EC74 - ldr r1, =gSpecialVar_Result - ldr r0, =gSaveBlock2Ptr - ldr r0, [r0] - ldr r2, =0x00000d08 - adds r0, r2 - ldrb r0, [r0] - lsrs r0, 7 - strh r0, [r1] - b _0818ED10 - .pool -_0818EC74: - ldr r1, =gSpecialVar_Result - ldr r0, =gSaveBlock2Ptr - ldr r0, [r0] - ldr r3, =0x00000d08 - adds r0, r3 - ldrb r0, [r0] - lsls r0, 25 - b _0818ECBE - .pool -_0818EC90: - cmp r5, 0 - beq _0818ECB0 - ldr r1, =gSpecialVar_Result - ldr r0, =gSaveBlock2Ptr - ldr r0, [r0] - ldr r2, =0x00000d08 - adds r0, r2 - ldrb r0, [r0] - lsls r0, 28 - b _0818ECBE - .pool -_0818ECB0: - ldr r1, =gSpecialVar_Result - ldr r0, =gSaveBlock2Ptr - ldr r0, [r0] - ldr r3, =0x00000d08 - adds r0, r3 -_0818ECBA: - ldrb r0, [r0] - lsls r0, 29 -_0818ECBE: - lsrs r0, 31 - strh r0, [r1] - b _0818ED10 - .pool -_0818ECD0: - bl sub_81B8558 - ldr r2, =gUnknown_0203CEF8 - ldr r0, =gSaveBlock2Ptr - ldr r0, [r0] - movs r1, 0xCB - lsls r1, 4 - adds r0, r1 - ldrh r1, [r0] - strb r1, [r2] - ldrh r0, [r0] - lsrs r0, 8 - strb r0, [r2, 0x1] - b _0818ED10 - .pool -_0818ECF4: - ldr r2, =gSpecialVar_Result - ldr r0, =gSaveBlock2Ptr - ldr r1, [r0] - ldr r3, =0x00000d0a - adds r0, r1, r3 - ldrb r0, [r0] - lsls r0, 1 - adds r3, 0x1 - adds r1, r3 - ldr r3, =0x0000fffd - adds r0, r3 - ldrb r1, [r1] - adds r0, r1 - strh r0, [r2] -_0818ED10: - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_818EA84 - - thumb_func_start sub_818ED28 -sub_818ED28: @ 818ED28 - 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, =gSpecialVar_0x8005 - ldrh r0, [r0] - cmp r0, 0x8 - bls _0818ED4C - b _0818F01E -_0818ED4C: - lsls r0, 2 - ldr r1, =_0818ED6C - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .pool - .align 2, 0 -_0818ED6C: - .4byte _0818ED90 - .4byte _0818EDB4 - .4byte _0818EE10 - .4byte _0818EE34 - .4byte _0818EE5C - .4byte _0818EE78 - .4byte _0818EEA0 - .4byte _0818EF50 - .4byte _0818F008 -_0818ED90: - ldr r0, =gSaveBlock2Ptr - ldr r2, [r0] - lsls r0, r4, 1 - lsls r1, r5, 2 - adds r0, r1 - ldr r1, =0x00000d0c - adds r2, r1 - adds r2, r0 - ldr r0, =gSpecialVar_0x8006 - ldrh r0, [r0] - strh r0, [r2] - b _0818F01E - .pool -_0818EDB4: - ldr r0, =gSpecialVar_0x8006 - ldrh r0, [r0] - cmp r0, 0 - beq _0818EDE8 - ldr r0, =gSaveBlock2Ptr - ldr r2, [r0] - ldr r0, =0x00000cdc - adds r2, r0 - ldr r3, =gUnknown_0860D0EC - lsls r1, r4, 2 - lsls r0, r5, 3 - adds r1, r0 - adds r1, r3 - ldr r0, [r2] - ldr r1, [r1] - orrs r0, r1 - str r0, [r2] - b _0818F01E - .pool -_0818EDE8: - ldr r0, =gSaveBlock2Ptr - ldr r2, [r0] - ldr r1, =0x00000cdc - adds r2, r1 - ldr r3, =gUnknown_0860D0FC - lsls r1, r4, 2 - lsls r0, r5, 3 - adds r1, r0 - adds r1, r3 - ldr r0, [r2] - ldr r1, [r1] - ands r0, r1 - str r0, [r2] - b _0818F01E - .pool -_0818EE10: - ldr r0, =gSaveBlock2Ptr - ldr r2, [r0] - ldr r0, =gSpecialVar_0x8006 - ldrb r0, [r0] - ldr r1, =0x00000d08 - adds r2, r1 - movs r1, 0x1 - ands r1, r0 - ldrb r3, [r2] - movs r0, 0x2 - negs r0, r0 - b _0818EF74 - .pool -_0818EE34: - ldr r0, =gSaveBlock2Ptr - ldr r3, [r0] - ldr r0, =gSpecialVar_0x8006 - ldrb r0, [r0] - ldr r2, =0x00000d08 - adds r3, r2 - movs r1, 0x1 - ands r1, r0 - lsls r1, 1 - ldrb r2, [r3] - movs r0, 0x3 - negs r0, r0 - b _0818EFF4 - .pool -_0818EE5C: - ldr r0, =gSaveBlock2Ptr - ldr r3, [r0] - ldr r0, =gSpecialVar_0x8006 - ldrb r0, [r0] - ldr r1, =0x00000d08 - adds r3, r1 - b _0818EFE8 - .pool -_0818EE78: - ldr r0, =gSaveBlock2Ptr - ldr r3, [r0] - ldr r0, =gSpecialVar_0x8006 - ldrb r0, [r0] - ldr r2, =0x00000d08 - adds r3, r2 - movs r1, 0x1 - ands r1, r0 - lsls r1, 3 - ldrb r2, [r3] - movs r0, 0x9 - negs r0, r0 - b _0818EFF4 - .pool -_0818EEA0: - ldr r0, =0x000040ce - bl VarGet - lsls r0, 16 - lsrs r1, r0, 16 - cmp r1, 0x1 - bne _0818EF00 - cmp r4, 0 - beq _0818EEDC - ldr r0, =gSaveBlock2Ptr - ldr r3, [r0] - ldr r0, =gSpecialVar_0x8006 - ldrb r0, [r0] - ldr r2, =0x00000d08 - adds r3, r2 - ands r1, r0 - lsls r1, 5 - ldrb r2, [r3] - movs r0, 0x21 - negs r0, r0 - b _0818EFF4 - .pool -_0818EEDC: - ldr r0, =gSaveBlock2Ptr - ldr r3, [r0] - ldr r0, =gSpecialVar_0x8006 - ldrb r0, [r0] - ldr r2, =0x00000d08 - adds r3, r2 - ands r1, r0 - lsls r1, 4 - ldrb r2, [r3] - movs r0, 0x11 - negs r0, r0 - b _0818EFF4 - .pool -_0818EF00: - cmp r4, 0 - beq _0818EF2C - ldr r0, =gSaveBlock2Ptr - ldr r3, [r0] - ldr r0, =gSpecialVar_0x8006 - ldrb r0, [r0] - ldr r1, =0x00000d08 - adds r3, r1 - movs r1, 0x1 - ands r1, r0 - lsls r1, 1 - ldrb r2, [r3] - movs r0, 0x3 - negs r0, r0 - b _0818EFF4 - .pool -_0818EF2C: - ldr r0, =gSaveBlock2Ptr - ldr r2, [r0] - ldr r0, =gSpecialVar_0x8006 - ldrb r0, [r0] - ldr r1, =0x00000d08 - adds r2, r1 - movs r1, 0x1 - ands r1, r0 - ldrb r3, [r2] - movs r0, 0x2 - negs r0, r0 - b _0818EF74 - .pool -_0818EF50: - ldr r0, =0x000040ce - bl VarGet - lsls r0, 16 - lsrs r1, r0, 16 - cmp r1, 0x1 - bne _0818EFB0 - cmp r4, 0 - beq _0818EF8C - ldr r0, =gSaveBlock2Ptr - ldr r2, [r0] - ldr r0, =gSpecialVar_0x8006 - ldrb r1, [r0] - ldr r0, =0x00000d08 - adds r2, r0 - lsls r1, 7 - ldrb r3, [r2] - movs r0, 0x7F -_0818EF74: - ands r0, r3 - orrs r0, r1 - strb r0, [r2] - b _0818F01E - .pool -_0818EF8C: - ldr r0, =gSaveBlock2Ptr - ldr r3, [r0] - ldr r0, =gSpecialVar_0x8006 - ldrb r0, [r0] - ldr r2, =0x00000d08 - adds r3, r2 - ands r1, r0 - lsls r1, 6 - ldrb r2, [r3] - movs r0, 0x41 - negs r0, r0 - b _0818EFF4 - .pool -_0818EFB0: - cmp r4, 0 - beq _0818EFDC - ldr r0, =gSaveBlock2Ptr - ldr r3, [r0] - ldr r0, =gSpecialVar_0x8006 - ldrb r0, [r0] - ldr r1, =0x00000d08 - adds r3, r1 - movs r1, 0x1 - ands r1, r0 - lsls r1, 3 - ldrb r2, [r3] - movs r0, 0x9 - negs r0, r0 - b _0818EFF4 - .pool -_0818EFDC: - ldr r0, =gSaveBlock2Ptr - ldr r3, [r0] - ldr r0, =gSpecialVar_0x8006 - ldrb r0, [r0] - ldr r2, =0x00000d08 - adds r3, r2 -_0818EFE8: - movs r1, 0x1 - ands r1, r0 - lsls r1, 2 - ldrb r2, [r3] - movs r0, 0x5 - negs r0, r0 -_0818EFF4: - ands r0, r2 - orrs r0, r1 - strb r0, [r3] - b _0818F01E - .pool -_0818F008: - ldr r0, =gSaveBlock2Ptr - ldr r2, [r0] - ldr r0, =gUnknown_0203CEF8 - ldrb r1, [r0] - ldrb r0, [r0, 0x1] - lsls r0, 8 - orrs r1, r0 - movs r0, 0xCB - lsls r0, 4 - adds r2, r0 - strh r1, [r2] -_0818F01E: - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_818ED28 - - thumb_func_start sub_818F02C -sub_818F02C: @ 818F02C - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0x3C - movs r0, 0 - str r0, [sp, 0x8] - str r0, [sp, 0xC] - str r0, [sp, 0x10] - movs r0, 0x20 - bl AllocZeroed - str r0, [sp, 0x18] - movs r0, 0x18 - bl AllocZeroed - str r0, [sp, 0x1C] - ldr r4, =gSaveBlock2Ptr - ldr r1, [r4] - ldr r2, =0x00000ca9 - adds r0, r1, r2 - ldrb r0, [r0] - lsls r0, 30 - lsrs r0, 30 - adds r0, 0x1 - ldr r3, =0x00000d0a - adds r1, r3 - strb r0, [r1] - ldr r0, =0x000040ce - bl VarGet - ldr r1, [r4] - adds r0, 0x1 - ldr r5, =0x00000d0b - adds r1, r5 - strb r0, [r1] - ldr r2, [r4] - ldr r7, =0x00000d24 - adds r3, r2, r7 - ldrh r0, [r3] - ldr r5, =0x000003ff - adds r1, r5, 0 - orrs r0, r1 - strh r0, [r3] - ldr r3, =0x00000d25 - adds r2, r3 - ldrb r1, [r2] - movs r0, 0x5 - negs r0, r0 - ands r0, r1 - strb r0, [r2] - ldr r1, [r4] - adds r1, r3 - ldrb r2, [r1] - movs r0, 0x19 - negs r0, r0 - ands r0, r2 - strb r0, [r1] - ldr r1, [r4] - adds r1, r3 - ldrb r2, [r1] - movs r0, 0x1F - ands r0, r2 - strb r0, [r1] - movs r7, 0 - mov r10, r7 - mov r8, r4 - ldr r0, =gBattleScripting + 0x14 - mov r9, r0 - movs r4, 0 -_0818F0BA: - mov r1, r8 - ldr r0, [r1] - ldr r2, =0x00000caa - adds r0, r2 - adds r0, r4 - ldrh r0, [r0] - movs r3, 0x64 - muls r0, r3 - add r0, r9 - movs r1, 0xB - movs r2, 0 - bl GetMonData - mov r5, r8 - ldr r1, [r5] - ldr r7, =0x00000d64 - adds r1, r7 - adds r1, r4 - strh r0, [r1] - movs r5, 0 - mov r0, r10 - lsls r7, r0, 4 - adds r6, r7, 0 -_0818F0E8: - mov r1, r8 - ldr r0, [r1] - ldr r2, =0x00000caa - adds r0, r2 - adds r0, r4 - ldrh r0, [r0] - movs r3, 0x64 - muls r0, r3 - add r0, r9 - adds r1, r5, 0 - adds r1, 0xD - movs r2, 0 - bl GetMonData - mov r2, r8 - ldr r1, [r2] - ldr r3, =0x00000efc - adds r1, r3 - adds r1, r6 - strh r0, [r1] - adds r6, 0x2 - adds r5, 0x1 - cmp r5, 0x3 - ble _0818F0E8 - movs r5, 0 - ldr r6, =gSaveBlock2Ptr -_0818F11C: - ldr r0, [r6] - ldr r1, =0x00000caa - adds r0, r1 - adds r0, r4 - ldrh r0, [r0] - movs r2, 0x64 - muls r0, r2 - add r0, r9 - adds r1, r5, 0 - adds r1, 0x1A - movs r2, 0 - bl GetMonData - ldr r1, [r6] - adds r2, r5, r7 - ldr r3, =0x00000f04 - adds r1, r3 - adds r1, r2 - strb r0, [r1] - adds r5, 0x1 - cmp r5, 0x5 - ble _0818F11C - mov r5, r8 - ldr r0, [r5] - ldr r1, =0x00000caa - adds r0, r1 - adds r0, r4 - ldrh r0, [r0] - movs r2, 0x64 - muls r0, r2 - add r0, r9 - bl GetNature - ldr r1, [r5] - adds r1, r7 - ldr r3, =0x00000f0a - adds r1, r3 - strb r0, [r1] - adds r4, 0x2 - movs r5, 0x1 - add r10, r5 - mov r7, r10 - cmp r7, 0x2 - ble _0818F0BA - mov r10, r5 - movs r0, 0x4 - str r0, [sp, 0x34] - movs r1, 0x6 - str r1, [sp, 0x38] -_0818F17E: - mov r2, r10 - cmp r2, 0x5 - ble _0818F22C -_0818F184: - bl sub_81A39C4 - lsls r0, 24 - lsrs r0, 24 - movs r1, 0 - bl sub_8162548 - lsls r0, 16 - lsrs r4, r0, 16 - movs r5, 0x1 - cmp r5, r10 - bge _0818F1CA - ldr r3, =gSaveBlock2Ptr - ldr r0, [r3] - ldr r7, =0x00000d28 - adds r0, r7 - ldrh r0, [r0] - lsls r0, 22 - lsrs r0, 22 - adds r2, r3, 0 - cmp r0, r4 - beq _0818F1CA - ldr r3, =0x00000d24 -_0818F1B2: - adds r5, 0x1 - cmp r5, r10 - bge _0818F1CA - ldr r0, [r2] - lsls r1, r5, 2 - adds r0, r1 - adds r0, r3 - ldrh r0, [r0] - lsls r0, 22 - lsrs r0, 22 - cmp r0, r4 - bne _0818F1B2 -_0818F1CA: - cmp r5, r10 - bne _0818F184 - ldr r0, =gSaveBlock2Ptr - ldr r3, [r0] - ldr r1, [sp, 0x34] - adds r3, r1 - ldr r2, =0x00000d24 - adds r3, r2 - ldr r5, =0x000003ff - adds r0, r5, 0 - adds r2, r4, 0 - ands r2, r0 - ldrh r0, [r3] - ldr r7, =0xfffffc00 - adds r1, r7, 0 - b _0818F292 - .pool -_0818F22C: - bl sub_81A39C4 - adds r0, 0x1 - lsls r0, 24 - lsrs r0, 24 - movs r1, 0 - bl sub_8162548 - lsls r0, 16 - lsrs r4, r0, 16 - movs r5, 0x1 - cmp r5, r10 - bge _0818F274 - ldr r1, =gSaveBlock2Ptr - ldr r0, [r1] - ldr r2, =0x00000d28 - adds r0, r2 - ldrh r0, [r0] - lsls r0, 22 - lsrs r0, 22 - adds r2, r1, 0 - cmp r0, r4 - beq _0818F274 - ldr r3, =0x00000d24 -_0818F25C: - adds r5, 0x1 - cmp r5, r10 - bge _0818F274 - ldr r0, [r2] - lsls r1, r5, 2 - adds r0, r1 - adds r0, r3 - ldrh r0, [r0] - lsls r0, 22 - lsrs r0, 22 - cmp r0, r4 - bne _0818F25C -_0818F274: - cmp r5, r10 - bne _0818F22C - ldr r5, =gSaveBlock2Ptr - ldr r3, [r5] - ldr r7, [sp, 0x34] - adds r3, r7 - ldr r0, =0x00000d24 - adds r3, r0 - ldr r1, =0x000003ff - adds r0, r1, 0 - adds r2, r4, 0 - ands r2, r0 - ldrh r0, [r3] - ldr r5, =0xfffffc00 - adds r1, r5, 0 -_0818F292: - ands r0, r1 - orrs r0, r2 - strh r0, [r3] - movs r5, 0 - lsls r4, 16 - str r4, [sp, 0x2C] - ldr r7, [sp, 0x38] - str r7, [sp, 0x20] -_0818F2A2: - lsls r0, r5, 1 - mov r9, r0 - adds r1, r5, 0x1 - str r1, [sp, 0x24] - lsls r2, r5, 2 - str r2, [sp, 0x28] -_0818F2AE: - ldr r3, [sp, 0x2C] - lsrs r0, r3, 16 - bl sub_8163524 - lsls r0, 16 - lsrs r6, r0, 16 - movs r7, 0 - cmp r7, r5 - bge _0818F300 - ldr r0, =gSaveBlock2Ptr - ldr r0, [r0] - ldr r1, [sp, 0x8] - mov r8, r1 - ldr r2, [sp, 0xC] - mov r12, r2 - ldr r3, =0x00000d64 - adds r0, r3 - ldr r1, [sp, 0x20] - adds r4, r1, r0 -_0818F2D4: - ldrh r3, [r4] - cmp r3, r6 - beq _0818F300 - ldr r2, =gUnknown_0203BC8C - ldr r1, [r2] - lsls r0, r6, 4 - adds r2, r0, r1 - ldrh r0, [r2] - cmp r8, r0 - beq _0818F300 - cmp r12, r0 - beq _0818F300 - lsls r0, r3, 4 - adds r0, r1 - ldrb r0, [r0, 0xA] - ldrb r2, [r2, 0xA] - cmp r0, r2 - beq _0818F300 - adds r4, 0x2 - adds r7, 0x1 - cmp r7, r5 - blt _0818F2D4 -_0818F300: - cmp r7, r5 - bne _0818F2AE - ldr r3, =gSaveBlock2Ptr - ldr r0, [r3] - ldr r1, [sp, 0x38] - add r1, r9 - ldr r5, =0x00000d64 - adds r0, r5 - adds r0, r1 - strh r6, [r0] - ldr r2, [sp, 0x28] - add r2, sp - adds r2, 0x8 - ldr r0, =gUnknown_0203BC8C - ldr r1, [r0] - lsls r0, r6, 4 - adds r0, r1 - ldrh r0, [r0] - str r0, [r2] - ldr r5, [sp, 0x24] - cmp r5, 0x2 - ble _0818F2A2 - ldr r2, [r3] - ldr r7, [sp, 0x34] - adds r2, r7 - ldr r0, =0x00000d25 - adds r2, r0 - ldrb r0, [r2] - movs r3, 0x5 - negs r3, r3 - adds r1, r3, 0 - ands r0, r1 - strb r0, [r2] - ldr r5, =gSaveBlock2Ptr - ldr r2, [r5] - adds r2, r7 - ldr r7, =0x00000d25 - adds r2, r7 - ldrb r0, [r2] - subs r3, 0x14 - adds r1, r3, 0 - ands r0, r1 - strb r0, [r2] - ldr r1, [r5] - ldr r5, [sp, 0x34] - adds r1, r5 - adds r1, r7 - ldrb r2, [r1] - movs r0, 0x1F - ands r0, r2 - strb r0, [r1] - adds r5, 0x4 - str r5, [sp, 0x34] - ldr r7, [sp, 0x38] - adds r7, 0x6 - str r7, [sp, 0x38] - movs r0, 0x1 - add r10, r0 - mov r1, r10 - cmp r1, 0xF - bgt _0818F37C - b _0818F17E -_0818F37C: - movs r7, 0 - ldr r2, [sp, 0x18] - strh r7, [r2] - movs r3, 0 - mov r10, r3 - ldr r6, =gBitTable - ldr r5, =gBaseStats -_0818F38A: - ldr r0, =gSaveBlock2Ptr - ldr r0, [r0] - mov r2, r10 - lsls r1, r2, 1 - ldr r3, =0x00000caa - adds r0, r3 - adds r0, r1 - ldrh r0, [r0] - subs r4, r0, 0x1 - movs r0, 0x64 - muls r4, r0 - ldr r0, =gPlayerParty - adds r4, r0 - adds r0, r4, 0 - movs r1, 0x3B - movs r2, 0 - bl GetMonData - ldr r2, [sp, 0x18] - ldrh r1, [r2] - adds r1, r0 - strh r1, [r2] - adds r0, r4, 0 - movs r1, 0x3C - movs r2, 0 - bl GetMonData - ldr r3, [sp, 0x18] - ldrh r1, [r3] - adds r1, r0 - strh r1, [r3] - adds r0, r4, 0 - movs r1, 0x3E - movs r2, 0 - bl GetMonData - ldr r2, [sp, 0x18] - ldrh r1, [r2] - adds r1, r0 - strh r1, [r2] - adds r0, r4, 0 - movs r1, 0x3F - movs r2, 0 - bl GetMonData - ldr r3, [sp, 0x18] - ldrh r1, [r3] - adds r1, r0 - strh r1, [r3] - adds r0, r4, 0 - movs r1, 0x3D - movs r2, 0 - bl GetMonData - ldr r2, [sp, 0x18] - ldrh r1, [r2] - adds r1, r0 - strh r1, [r2] - adds r0, r4, 0 - movs r1, 0x3A - movs r2, 0 - bl GetMonData - ldr r3, [sp, 0x18] - ldrh r1, [r3] - adds r1, r0 - strh r1, [r3] - adds r0, r4, 0 - movs r1, 0xB - movs r2, 0 - bl GetMonData - lsls r1, r0, 3 - subs r1, r0 - lsls r1, 2 - adds r1, r5 - ldrb r0, [r1, 0x6] - lsls r0, 2 - adds r0, r6 - ldr r0, [r0] - orrs r7, r0 - adds r0, r4, 0 - movs r1, 0xB - movs r2, 0 - bl GetMonData - lsls r1, r0, 3 - subs r1, r0 - lsls r1, 2 - adds r1, r5 - ldrb r0, [r1, 0x7] - lsls r0, 2 - adds r0, r6 - ldr r0, [r0] - orrs r7, r0 - movs r0, 0x1 - add r10, r0 - mov r1, r10 - cmp r1, 0x2 - ble _0818F38A - movs r4, 0 - movs r1, 0x1 - movs r5, 0x1F -_0818F458: - adds r0, r7, 0 - ands r0, r1 - cmp r0, 0 - beq _0818F462 - adds r4, 0x1 -_0818F462: - asrs r7, 1 - subs r5, 0x1 - cmp r5, 0 - bge _0818F458 - bl sub_8165C40 - lsls r0, 24 - lsrs r0, 24 - str r0, [sp, 0x14] - adds r2, r0, 0 - adds r0, r4, 0 - muls r0, r2 - movs r1, 0x14 - bl __divsi3 - ldr r3, [sp, 0x18] - ldrh r1, [r3] - adds r1, r0 - strh r1, [r3] - movs r5, 0x1 - mov r10, r5 - adds r6, r3, 0 - adds r6, 0x2 - movs r7, 0x2 - str r7, [sp, 0x30] -_0818F494: - movs r7, 0 - strh r7, [r6] - ldr r1, =gSaveBlock2Ptr - ldr r0, [r1] - mov r2, r10 - lsls r1, r2, 2 - adds r0, r1 - ldr r3, =0x00000d24 - adds r0, r3 - ldrh r0, [r0] - lsls r0, 22 - lsrs r0, 22 - bl sub_8190168 - lsls r0, 24 - lsrs r0, 24 - mov r8, r0 - movs r5, 0 - ldr r0, [sp, 0x30] - mov r9, r0 -_0818F4BC: - ldr r1, =gSaveBlock2Ptr - ldr r0, [r1] - mov r4, r9 - add r4, r10 - adds r4, r5 - lsls r4, 1 - ldr r2, =0x00000d64 - adds r0, r2 - adds r0, r4 - ldrh r1, [r0] - ldr r3, =gUnknown_0203BC8C - ldr r0, [r3] - lsls r1, 4 - adds r1, r0 - ldrh r0, [r1] - ldrb r3, [r1, 0xB] - ldrb r1, [r1, 0xC] - str r1, [sp] - ldr r1, [sp, 0x1C] - str r1, [sp, 0x4] - ldr r1, [sp, 0x14] - mov r2, r8 - bl sub_818F720 - ldr r2, [sp, 0x1C] - ldr r1, [r2, 0x4] - ldrh r0, [r6] - adds r0, r1 - ldr r1, [r2, 0x8] - adds r0, r1 - ldr r1, [r2, 0x10] - adds r0, r1 - ldr r1, [r2, 0x14] - adds r0, r1 - ldr r1, [r2, 0xC] - adds r0, r1 - ldr r1, [r2] - adds r0, r1 - strh r0, [r6] - ldr r3, =gSaveBlock2Ptr - ldr r0, [r3] - ldr r1, =0x00000d64 - adds r0, r1 - adds r0, r4 - ldrh r0, [r0] - ldr r2, =gUnknown_0203BC8C - ldr r1, [r2] - lsls r0, 4 - adds r0, r1 - ldrh r0, [r0] - lsls r1, r0, 3 - subs r1, r0 - lsls r1, 2 - ldr r3, =gBaseStats - adds r1, r3 - ldrb r0, [r1, 0x6] - lsls r0, 2 - ldr r2, =gBitTable - adds r0, r2 - ldr r0, [r0] - orrs r7, r0 - ldrb r0, [r1, 0x7] - lsls r0, 2 - adds r0, r2 - ldr r0, [r0] - orrs r7, r0 - adds r5, 0x1 - cmp r5, 0x2 - ble _0818F4BC - movs r4, 0 - movs r1, 0x1 - movs r5, 0x1F -_0818F54C: - adds r0, r7, 0 - ands r0, r1 - cmp r0, 0 - beq _0818F556 - adds r4, 0x1 -_0818F556: - asrs r7, 1 - subs r5, 0x1 - cmp r5, 0 - bge _0818F54C - ldr r3, [sp, 0x14] - adds r0, r4, 0 - muls r0, r3 - movs r1, 0x14 - bl __divsi3 - ldrh r1, [r6] - adds r1, r0 - strh r1, [r6] - adds r6, 0x2 - ldr r5, [sp, 0x30] - adds r5, 0x2 - str r5, [sp, 0x30] - movs r7, 0x1 - add r10, r7 - mov r0, r10 - cmp r0, 0xF - ble _0818F494 - movs r1, 0 - mov r10, r1 - ldr r2, =0x000003ff - mov r8, r2 -_0818F58A: - mov r5, r10 - adds r5, 0x1 - adds r7, r5, 0 - cmp r5, 0xF - bgt _0818F626 - mov r3, r10 - lsls r0, r3, 1 - ldr r1, [sp, 0x18] - adds r6, r0, r1 - lsls r0, r5, 1 - adds r4, r0, r1 -_0818F5A0: - ldrh r1, [r6] - ldrh r0, [r4] - cmp r1, r0 - bcc _0818F5C2 - cmp r1, r0 - bne _0818F61E - ldr r0, =gSaveBlock2Ptr - ldr r1, [r0] - lsls r0, r5, 2 - adds r0, r1, r0 - ldr r2, =0x00000d24 - adds r0, r2 - ldrh r0, [r0] - lsls r2, r0, 22 - lsrs r0, r2, 22 - cmp r0, r8 - bne _0818F602 -_0818F5C2: - mov r0, r10 - adds r1, r5, 0 - ldr r2, [sp, 0x18] - bl sub_818F904 - b _0818F600 - .pool -_0818F600: - b _0818F61E -_0818F602: - mov r3, r10 - lsls r0, r3, 2 - adds r0, r1, r0 - ldr r1, =0x00000d24 - adds r0, r1 - ldrh r0, [r0] - lsls r0, 22 - cmp r0, r2 - bls _0818F61E - mov r0, r10 - adds r1, r5, 0 - ldr r2, [sp, 0x18] - bl sub_818F904 -_0818F61E: - adds r4, 0x2 - adds r5, 0x1 - cmp r5, 0xF - ble _0818F5A0 -_0818F626: - mov r10, r7 - mov r2, r10 - cmp r2, 0xE - ble _0818F58A - bl sub_81A3610 - lsls r0, 24 - cmp r0, 0 - beq _0818F6EE - movs r3, 0 - mov r10, r3 - ldr r0, =gSaveBlock2Ptr - ldr r1, [r0] - ldr r4, =0x00000d24 - adds r1, r4 - ldrh r1, [r1] - lsls r1, 22 - lsrs r1, 22 - ldr r3, =0x000003ff - adds r2, r0, 0 - ldr r6, =gUnknown_0860D3F1 - cmp r1, r3 - beq _0818F674 - adds r5, r2, 0 -_0818F656: - movs r7, 0x1 - add r10, r7 - mov r0, r10 - cmp r0, 0xF - bgt _0818F674 - ldr r0, [r5] - mov r7, r10 - lsls r1, r7, 2 - adds r0, r1 - adds r0, r4 - ldrh r0, [r0] - lsls r0, 22 - lsrs r0, 22 - cmp r0, r3 - bne _0818F656 -_0818F674: - mov r1, r10 - lsls r0, r1, 1 - adds r0, r6 - ldrb r0, [r0] - cmp r0, 0 - beq _0818F6AC - movs r5, 0 - ldr r2, [r2] - ldr r3, =0x00000d24 - adds r2, r3 - ldrh r1, [r2] - ldr r0, =0xfffffc00 - ands r0, r1 - ldr r7, =0x000003fe - adds r1, r7, 0 - b _0818F6BE - .pool -_0818F6AC: - movs r5, 0x1 - ldr r2, [r2] - ldr r0, =0x00000d28 - adds r2, r0 - ldrh r1, [r2] - ldr r0, =0xfffffc00 - ands r0, r1 - ldr r3, =0x000003fe - adds r1, r3, 0 -_0818F6BE: - orrs r0, r1 - strh r0, [r2] - movs r7, 0 - mov r10, r7 - lsls r0, r5, 1 - adds r0, r5 - lsls r4, r0, 1 -_0818F6CC: - mov r1, r10 - lsls r0, r1, 24 - lsrs r0, 24 - bl sub_81A4FF0 - ldr r1, =gSaveBlock2Ptr - ldr r1, [r1] - ldr r2, =0x00000d64 - adds r1, r2 - adds r1, r4 - strh r0, [r1] - adds r4, 0x2 - movs r3, 0x1 - add r10, r3 - mov r5, r10 - cmp r5, 0x2 - ble _0818F6CC -_0818F6EE: - ldr r0, [sp, 0x18] - bl Free - ldr r0, [sp, 0x1C] - bl Free - add sp, 0x3C - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_818F02C - - thumb_func_start sub_818F720 -sub_818F720: @ 818F720 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0x1C - adds r7, r1, 0 - mov r9, r2 - ldr r1, [sp, 0x3C] - ldr r2, [sp, 0x40] - mov r8, r2 - lsls r0, 16 - lsrs r6, r0, 16 - lsls r3, 24 - lsrs r5, r3, 24 - lsls r1, 24 - lsrs r1, 24 - str r1, [sp, 0x18] - movs r1, 0 - adds r4, r5, 0 - movs r3, 0x1 - movs r2, 0x5 -_0818F74C: - adds r0, r4, 0 - ands r0, r3 - cmp r0, 0 - beq _0818F756 - adds r1, 0x1 -_0818F756: - lsrs r4, 1 - subs r2, 0x1 - cmp r2, 0 - bge _0818F74C - movs r0, 0xFF - lsls r0, 1 - bl __divsi3 - lsls r0, 16 - lsrs r3, r0, 16 - lsls r0, r6, 3 - mov r10, r0 - movs r1, 0 - mov r12, r1 - mov r1, sp - movs r2, 0x5 -_0818F776: - mov r0, r12 - str r0, [r1] - adds r0, r5, 0 - ands r0, r4 - cmp r0, 0 - beq _0818F784 - str r3, [r1] -_0818F784: - lsls r0, r4, 25 - lsrs r4, r0, 24 - adds r1, 0x4 - subs r2, 0x1 - cmp r2, 0 - bge _0818F776 - ldr r0, =0x0000012f - cmp r6, r0 - bne _0818F7A0 - movs r0, 0x1 - b _0818F7CA - .pool -_0818F7A0: - mov r2, r10 - subs r0, r2, r6 - lsls r0, 2 - ldr r1, =gBaseStats - adds r0, r1 - ldrb r0, [r0] - lsls r0, 1 - mov r2, r9 - adds r1, r0, r2 - ldr r0, [sp] - cmp r0, 0 - bge _0818F7BA - adds r0, 0x3 -_0818F7BA: - asrs r0, 2 - adds r0, r1, r0 - muls r0, r7 - movs r1, 0x64 - bl __divsi3 - adds r0, r7 - adds r0, 0xA -_0818F7CA: - mov r1, r8 - str r0, [r1] - mov r2, r10 - subs r0, r2, r6 - lsls r0, 2 - ldr r1, =gBaseStats - adds r4, r0, r1 - ldrb r0, [r4, 0x1] - lsls r0, 1 - mov r2, r9 - adds r1, r0, r2 - ldr r0, [sp, 0x4] - cmp r0, 0 - bge _0818F7E8 - adds r0, 0x3 -_0818F7E8: - asrs r0, 2 - adds r0, r1, r0 - muls r0, r7 - movs r1, 0x64 - bl __divsi3 - adds r1, r0, 0 - adds r1, 0x5 - mov r0, r8 - str r1, [r0, 0x4] - lsls r1, 16 - lsrs r1, 16 - ldr r0, [sp, 0x18] - movs r2, 0x1 - bl ModifyStatByNature - lsls r0, 24 - lsrs r0, 24 - mov r1, r8 - str r0, [r1, 0x4] - ldrb r0, [r4, 0x2] - lsls r0, 1 - mov r2, r9 - adds r1, r0, r2 - ldr r0, [sp, 0x8] - cmp r0, 0 - bge _0818F820 - adds r0, 0x3 -_0818F820: - asrs r0, 2 - adds r0, r1, r0 - muls r0, r7 - movs r1, 0x64 - bl __divsi3 - adds r1, r0, 0 - adds r1, 0x5 - mov r0, r8 - str r1, [r0, 0x8] - lsls r1, 16 - lsrs r1, 16 - ldr r0, [sp, 0x18] - movs r2, 0x2 - bl ModifyStatByNature - lsls r0, 24 - lsrs r0, 24 - mov r1, r8 - str r0, [r1, 0x8] - ldrb r0, [r4, 0x3] - lsls r0, 1 - mov r2, r9 - adds r1, r0, r2 - ldr r0, [sp, 0xC] - cmp r0, 0 - bge _0818F858 - adds r0, 0x3 -_0818F858: - asrs r0, 2 - adds r0, r1, r0 - muls r0, r7 - movs r1, 0x64 - bl __divsi3 - adds r1, r0, 0 - adds r1, 0x5 - mov r0, r8 - str r1, [r0, 0xC] - lsls r1, 16 - lsrs r1, 16 - ldr r0, [sp, 0x18] - movs r2, 0x3 - bl ModifyStatByNature - lsls r0, 24 - lsrs r0, 24 - mov r1, r8 - str r0, [r1, 0xC] - ldrb r0, [r4, 0x4] - lsls r0, 1 - mov r2, r9 - adds r1, r0, r2 - ldr r0, [sp, 0x10] - cmp r0, 0 - bge _0818F890 - adds r0, 0x3 -_0818F890: - asrs r0, 2 - adds r0, r1, r0 - muls r0, r7 - movs r1, 0x64 - bl __divsi3 - adds r1, r0, 0 - adds r1, 0x5 - mov r0, r8 - str r1, [r0, 0x10] - lsls r1, 16 - lsrs r1, 16 - ldr r0, [sp, 0x18] - movs r2, 0x4 - bl ModifyStatByNature - lsls r0, 24 - lsrs r0, 24 - mov r1, r8 - str r0, [r1, 0x10] - ldrb r0, [r4, 0x5] - lsls r0, 1 - mov r1, r9 - adds r2, r0, r1 - ldr r0, [sp, 0x14] - cmp r0, 0 - bge _0818F8C8 - adds r0, 0x3 -_0818F8C8: - asrs r0, 2 - adds r0, r2, r0 - muls r0, r7 - movs r1, 0x64 - bl __divsi3 - adds r1, r0, 0 - adds r1, 0x5 - mov r2, r8 - str r1, [r2, 0x14] - lsls r1, 16 - lsrs r1, 16 - ldr r0, [sp, 0x18] - movs r2, 0x5 - bl ModifyStatByNature - lsls r0, 24 - lsrs r0, 24 - mov r1, r8 - str r0, [r1, 0x14] - add sp, 0x1C - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_818F720 - - thumb_func_start sub_818F904 -sub_818F904: @ 818F904 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - lsls r3, r0, 1 - mov r12, r3 - adds r4, r3, r2 - ldrh r5, [r4] - lsls r7, r1, 1 - mov r9, r7 - add r2, r9 - ldrh r3, [r2] - strh r3, [r4] - strh r5, [r2] - ldr r2, =gSaveBlock2Ptr - ldr r5, [r2] - lsls r6, r0, 2 - adds r6, r5, r6 - ldr r3, =0x00000d24 - adds r6, r3 - ldrh r7, [r6] - mov r10, r7 - mov r2, r10 - lsls r2, 22 - mov r8, r2 - lsls r2, r1, 2 - adds r5, r2 - adds r5, r3 - ldrh r4, [r5] - lsls r4, 22 - lsrs r4, 22 - ldr r3, =0xfffffc00 - adds r2, r3, 0 - mov r7, r10 - ands r2, r7 - orrs r2, r4 - strh r2, [r6] - mov r2, r8 - lsrs r2, 22 - mov r8, r2 - ldrh r2, [r5] - ands r3, r2 - mov r7, r8 - orrs r3, r7 - strh r3, [r5] - ldr r2, =gSaveBlock2Ptr - mov r8, r2 - add r12, r0 - add r9, r1 - mov r3, r9 - lsls r4, r3, 1 - mov r7, r12 - lsls r3, r7, 1 - ldr r7, =0x00000d64 - movs r6, 0x2 -_0818F974: - mov r1, r8 - ldr r0, [r1] - adds r0, r7 - adds r2, r0, r3 - ldrh r5, [r2] - adds r0, r4 - ldrh r1, [r0] - strh r1, [r2] - strh r5, [r0] - adds r4, 0x2 - adds r3, 0x2 - subs r6, 0x1 - cmp r6, 0 - bge _0818F974 - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_818F904 thumb_func_start sub_818F9B0 sub_818F9B0: @ 818F9B0 diff --git a/include/global.h b/include/global.h index 1a179d8586..0d2167c475 100644 --- a/include/global.h +++ b/include/global.h @@ -330,6 +330,21 @@ struct EmeraldBattleTowerRecord /*0xE8*/ u32 checksum; }; +struct FrontierMonData +{ + u16 moves[4]; + u8 evs[6]; + u8 nature; +}; + +struct FrontierUnkStruct1 +{ + u16 unk0:10; + u16 unk1:1; + u16 unk2:2; + u16 unk3:3; +}; + struct BattleFrontier { /*0x64C*/ struct EmeraldBattleTowerRecord battleTower; @@ -352,9 +367,11 @@ struct BattleFrontier /*0xCA9*/ u8 field_CA9_d:1; // 0x20 /*0xCA9*/ u8 field_CA9_e:1; // 0x40 /*0xCA9*/ u8 field_CA9_f:1; // 0x80 - /*0xCAA*/ u16 field_CAA[4]; + /*0xCAA*/ u16 field_CAA[3]; + /*0xCB0*/ u16 field_CB0; /*0xCB2*/ u16 field_CB2; - /*0xCB4*/ u16 field_CB4[22]; + /*0xCB4*/ u16 field_CB4[20]; + /*0xCDC*/ u32 field_CDC; /*0xCE0*/ u16 field_CE0[4][2]; /*0xCF0*/ u16 field_CF0[2]; /*0xCF4*/ u16 field_CF4[2]; @@ -362,17 +379,33 @@ struct BattleFrontier /*0xCFC*/ u16 field_CFC[5]; /*0xD06*/ u8 field_D06; /*0xD07*/ u8 field_D07; - /*0xD08*/ u8 filler_D08; + /*0xD08*/ u8 field_D08_0:1; + /*0xD08*/ u8 field_D08_1:1; + /*0xD08*/ u8 field_D08_2:1; + /*0xD08*/ u8 field_D08_3:1; + /*0xD08*/ u8 field_D08_4:1; + /*0xD08*/ u8 field_D08_5:1; + /*0xD08*/ u8 field_D08_6:1; + /*0xD08*/ u8 field_D08_7:1; /*0xD09*/ u8 filler_D09; - /*0xD0A*/ u8 filler_D0A; - /*0xD0B*/ u8 filler_D0B; - /*0xD0C*/ u16 field_D0C[2]; - /*0xD10*/ u8 filler_D10; - /*0xD11*/ u8 filler_D11; - /*0xD12*/ u8 filler_D12; - /*0xD13*/ u8 filler_D13; + /*0xD0A*/ u8 field_D0A; + /*0xD0B*/ u8 field_D0B; + /*0xD0C*/ u16 field_D0C[2][2]; /*0xD14*/ u16 field_D14[2]; - /*0xD18*/ u8 field_D18[0xB0]; + /*0xD18*/ u8 field_D18; + /*0xD19*/ u8 field_D19; + /*0xD1A*/ u8 field_D1A; + /*0xD1B*/ u8 field_D1B; + /*0xD1C*/ u8 field_D1C; + /*0xD1D*/ u8 field_D1D; + /*0xD1E*/ u8 field_D1E; + /*0xD1F*/ u8 field_D1F; + /*0xD20*/ u8 field_D20; + /*0xD21*/ u8 field_D21; + /*0xD22*/ u8 field_D22; + /*0xD23*/ u8 field_D23; + /*0xD24*/ struct FrontierUnkStruct1 field_D24[16]; + /*0xD64*/ u16 field_D64[16][3]; /*0xDC8*/ u16 field_DC8[2]; /*0xDCC*/ u8 filler_DCC[4]; /*0xDD0*/ u16 field_DD0[2]; @@ -409,7 +442,10 @@ struct BattleFrontier /*0xEBA*/ u8 field_EBA[39]; /*0xEE1*/ u8 field_EE1[2][PLAYER_NAME_LENGTH]; /*0xEF1*/ u8 field_EF1[2][4]; - /*0xEF9*/ u8 field_EF9[51]; + /*0xEF9*/ u8 field_EF9; + /*0xEFA*/ u8 field_EFA; + /*0xEFB*/ u8 field_EFB; + /*0xEFC*/ struct FrontierMonData field_EFC[3]; }; struct SaveBlock2 diff --git a/ld_script.txt b/ld_script.txt index 5f9d356173..0ee9c61c29 100644 --- a/ld_script.txt +++ b/ld_script.txt @@ -242,6 +242,7 @@ SECTIONS { src/battle_controller_recorded_player.o(.text); src/battle_dome_cards.o(.text); src/lilycove_lady.o(.text); + src/battle_frontier_1.o(.text); asm/battle_frontier_1.o(.text); src/menu.o(.text); asm/battle_frontier_2.o(.text); @@ -521,6 +522,7 @@ SECTIONS { src/battle_controller_recorded_player.o(.rodata); src/battle_dome_cards.o(.rodata); src/lilycove_lady.o(.rodata); + src/battle_frontier_1.o(.rodata); data/battle_frontier_1.o(.rodata); src/menu.o(.rodata); data/battle_frontier_2.o(.rodata); diff --git a/src/battle_frontier_1.c b/src/battle_frontier_1.c new file mode 100644 index 0000000000..b84e919732 --- /dev/null +++ b/src/battle_frontier_1.c @@ -0,0 +1,1235 @@ +#include "global.h" +#include "battle.h" +#include "battle_setup.h" +#include "battle_frontier_1.h" +#include "event_data.h" +#include "overworld.h" +#include "util.h" +#include "malloc.h" +#include "constants/species.h" + +struct Unknown_0203BC8C_Struct +{ + u16 field_0; + u8 field_2; + u8 field_3; + u8 field_4; + u8 field_5; + u8 field_6; + u8 field_7; + u8 field_8; + u8 field_9; + u8 field_A; + u8 field_B; + u8 field_C; + u8 field_D; + u8 field_E; +}; + +extern struct Unknown_0203BC8C_Struct *gUnknown_0203BC8C; + +extern void sub_81B8558(void); +extern u32 sub_81A39C4(void); +extern u16 sub_8162548(u8, u8); +extern u16 sub_8163524(u16); +extern u8 sub_8165C40(void); + +extern u8 gUnknown_0203CEF8[]; + +extern void (* const gUnknown_0860D090[])(void); +extern const u32 gUnknown_0860D0EC[][2]; +extern const u32 gUnknown_0860D0FC[][2]; + +// This file's functions. +u8 sub_8190168(u16); +void sub_818F720(u16 species, s32 level, s32 ivs, u8 evBits, u8 nature, s32 *stats); + +// code +void sub_818E9AC(void) +{ + gUnknown_0860D090[gSpecialVar_0x8004](); +} + +void sub_818E9CC(void) +{ + u32 lvlMode = gSaveBlock2Ptr->frontier.chosenLvl; + u32 id = VarGet(VAR_0x40CE); + + gSaveBlock2Ptr->frontier.field_CA8 = 0; + gSaveBlock2Ptr->frontier.field_CB2 = 0; + gSaveBlock2Ptr->frontier.field_CA9_a = 0; + gSaveBlock2Ptr->frontier.field_CA9_b = 0; + if (!(gSaveBlock2Ptr->frontier.field_CDC & gUnknown_0860D0EC[id][lvlMode])) + gSaveBlock2Ptr->frontier.field_D0C[id][lvlMode] = 0; + + saved_warp2_set(0, gSaveBlock1Ptr->location.mapGroup, gSaveBlock1Ptr->location.mapNum, -1); + gTrainerBattleOpponent_A = 0; +} + +void sub_818EA84(void) +{ + u32 lvlMode = gSaveBlock2Ptr->frontier.chosenLvl; + u32 id = VarGet(VAR_0x40CE); + + switch (gSpecialVar_0x8005) + { + case 0: + gSpecialVar_Result = gSaveBlock2Ptr->frontier.field_D0C[id][lvlMode]; + break; + case 1: + gSpecialVar_Result = ((gSaveBlock2Ptr->frontier.field_CDC & gUnknown_0860D0EC[id][lvlMode]) != 0); + break; + case 2: + gSpecialVar_Result = gSaveBlock2Ptr->frontier.field_D08_0; + break; + case 3: + gSpecialVar_Result = gSaveBlock2Ptr->frontier.field_D08_1; + break; + case 4: + gSpecialVar_Result = gSaveBlock2Ptr->frontier.field_D08_2; + break; + case 5: + gSpecialVar_Result = gSaveBlock2Ptr->frontier.field_D08_3; + break; + case 6: + if (VarGet(VAR_0x40CE) == 1) + { + if (lvlMode) + gSpecialVar_Result = gSaveBlock2Ptr->frontier.field_D08_5; + else + gSpecialVar_Result = gSaveBlock2Ptr->frontier.field_D08_4; + } + else + { + if (lvlMode) + gSpecialVar_Result = gSaveBlock2Ptr->frontier.field_D08_1; + else + gSpecialVar_Result = gSaveBlock2Ptr->frontier.field_D08_0; + } + break; + case 7: + if (VarGet(VAR_0x40CE) == 1) + { + if (lvlMode) + gSpecialVar_Result = gSaveBlock2Ptr->frontier.field_D08_7; + else + gSpecialVar_Result = gSaveBlock2Ptr->frontier.field_D08_6; + } + else + { + if (lvlMode) + gSpecialVar_Result = gSaveBlock2Ptr->frontier.field_D08_3; + else + gSpecialVar_Result = gSaveBlock2Ptr->frontier.field_D08_2; + } + break; + case 8: + sub_81B8558(); + gUnknown_0203CEF8[0] = gSaveBlock2Ptr->frontier.field_CB0; + gUnknown_0203CEF8[1] = gSaveBlock2Ptr->frontier.field_CB0 >> 8; + break; + case 9: + gSpecialVar_Result = (gSaveBlock2Ptr->frontier.field_D0A * 2) - 3 + gSaveBlock2Ptr->frontier.field_D0B; + break; + } +} + +void sub_818ED28(void) +{ + u32 lvlMode = gSaveBlock2Ptr->frontier.chosenLvl; + u32 id = VarGet(VAR_0x40CE); + + switch (gSpecialVar_0x8005) + { + case 0: + gSaveBlock2Ptr->frontier.field_D0C[id][lvlMode] = gSpecialVar_0x8006; + break; + case 1: + if (gSpecialVar_0x8006) + gSaveBlock2Ptr->frontier.field_CDC |= gUnknown_0860D0EC[id][lvlMode]; + else + gSaveBlock2Ptr->frontier.field_CDC &= gUnknown_0860D0FC[id][lvlMode]; + break; + case 2: + gSaveBlock2Ptr->frontier.field_D08_0 = gSpecialVar_0x8006; + break; + case 3: + gSaveBlock2Ptr->frontier.field_D08_1 = gSpecialVar_0x8006; + break; + case 4: + gSaveBlock2Ptr->frontier.field_D08_2 = gSpecialVar_0x8006; + break; + case 5: + gSaveBlock2Ptr->frontier.field_D08_3 = gSpecialVar_0x8006; + break; + case 6: + if (VarGet(VAR_0x40CE) == 1) + { + if (lvlMode) + gSaveBlock2Ptr->frontier.field_D08_5 = gSpecialVar_0x8006; + else + gSaveBlock2Ptr->frontier.field_D08_4 = gSpecialVar_0x8006; + } + else + { + if (lvlMode) + gSaveBlock2Ptr->frontier.field_D08_1 = gSpecialVar_0x8006; + else + gSaveBlock2Ptr->frontier.field_D08_0 = gSpecialVar_0x8006; + } + break; + case 7: + if (VarGet(VAR_0x40CE) == 1) + { + if (lvlMode) + gSaveBlock2Ptr->frontier.field_D08_7 = gSpecialVar_0x8006; + else + gSaveBlock2Ptr->frontier.field_D08_6 = gSpecialVar_0x8006; + } + else + { + if (lvlMode) + gSaveBlock2Ptr->frontier.field_D08_3 = gSpecialVar_0x8006; + else + gSaveBlock2Ptr->frontier.field_D08_2 = gSpecialVar_0x8006; + } + break; + case 8: + gSaveBlock2Ptr->frontier.field_CB0 = T1_READ_16(gUnknown_0203CEF8); + break; + } +} + +#ifdef NONMATCHING +// Not even close, this function is insane. +void sub_818F02C(void) +{ + s32 i, j, k, l; + u32 array[16]; + u32 var_28; + u32 var_24; + s32 var_38; + s32 monTypesBits, monTypesCount; + u32 var_54 = 0; + u32 var_50 = 0; + u32 var_4C = 0; + u32 *var_40 = AllocZeroed(0x20); + u16 *var_44 = AllocZeroed(0x18); + u32 var_48; + + gSaveBlock2Ptr->frontier.field_D0A = gSaveBlock2Ptr->frontier.chosenLvl + 1; + gSaveBlock2Ptr->frontier.field_D0B = VarGet(VAR_0x40CE) + 1; + gSaveBlock2Ptr->frontier.field_D24[0].unk0 = 0x3FF; + gSaveBlock2Ptr->frontier.field_D24[0].unk1 = 0; + gSaveBlock2Ptr->frontier.field_D24[0].unk2 = 0; + gSaveBlock2Ptr->frontier.field_D24[0].unk3 = 0; + + for (i = 0; i < 3; i++) + { + gSaveBlock2Ptr->frontier.field_D64[i] = GetMonData(&gPlayerParty[gSaveBlock2Ptr->frontier.field_CAA[i] - 1], MON_DATA_SPECIES, NULL); + for (j = 0; j < 4; j++) + gSaveBlock2Ptr->frontier.field_EFC[i].moves[j] = GetMonData(&gPlayerParty[gSaveBlock2Ptr->frontier.field_CAA[i] - 1], MON_DATA_MOVE1 + j, NULL); + for (j = 0; j < 6; j++) + gSaveBlock2Ptr->frontier.field_EFC[i].evs[j] = GetMonData(&gPlayerParty[gSaveBlock2Ptr->frontier.field_CAA[i] - 1], MON_DATA_HP_EV + j, NULL); + + gSaveBlock2Ptr->frontier.field_EFC[i].nature = GetNature(&gPlayerParty[gSaveBlock2Ptr->frontier.field_CAA[i] - 1]); + } + + var_28 = 4; + var_24 = 6; + for (l = j; l < 16; l++) + { + u16 val; + if (l > 5) + { + while (1) + { + val = sub_8162548(sub_81A39C4(), 0); + for (k = 1; k < l; k++) + { + if (gSaveBlock2Ptr->frontier.field_D24[k].unk0 == val) + break; + } + if (k != l) + { + gSaveBlock2Ptr->frontier.field_D24[var_28].unk0 = val; + break; + } + } + } + else + { + while (1) + { + val = sub_8162548(sub_81A39C4() + 1, 0); + for (k = 1; k < l; k++) + { + if (gSaveBlock2Ptr->frontier.field_D24[k].unk0 == val) + break; + } + if (k != l) + { + gSaveBlock2Ptr->frontier.field_D24[var_28].unk0 = val; + break; + } + } + } + + for (var_38 = 0; var_38 < 3; var_38++) + { + u16 val2; + do + { + val2 = sub_8163524(val); + for (i = 0; i < l; i++) + { + if (gSaveBlock2Ptr->frontier.field_D64[i] == val2) + break; + if (var_54 == gUnknown_0203BC8C[val2].field_0) + break; + if (var_50 == gUnknown_0203BC8C[val2].field_0) + break; + if (gUnknown_0203BC8C[gSaveBlock2Ptr->frontier.field_D64[i]].field_A == gUnknown_0203BC8C[val2].field_A) + break; + } + } while (i != var_38); + + gSaveBlock2Ptr->frontier.field_D64[var_24] = val2; + array[var_38] = gUnknown_0203BC8C[val2].field_0; + } + + gSaveBlock2Ptr->frontier.field_D24[var_28].unk1 = 0; + gSaveBlock2Ptr->frontier.field_D24[var_28].unk2 = 0; + gSaveBlock2Ptr->frontier.field_D24[var_28].unk3 = 0; + } + + for (i = 0; i < 3; i++) + { + struct Pokemon *mon = &gPlayerParty[gSaveBlock2Ptr->frontier.field_CAA[i] - 1]; + var_44[0] += GetMonData(mon, MON_DATA_ATK, NULL); + var_44[0] += GetMonData(mon, MON_DATA_DEF, NULL); + var_44[0] += GetMonData(mon, MON_DATA_SPATK, NULL); + var_44[0] += GetMonData(mon, MON_DATA_SPDEF, NULL); + var_44[0] += GetMonData(mon, MON_DATA_SPEED, NULL); + var_44[0] += GetMonData(mon, MON_DATA_MAX_HP, NULL); + monTypesBits |= gBitTable[gBaseStats[GetMonData(mon, MON_DATA_SPECIES, NULL)].type1]; + monTypesBits |= gBitTable[gBaseStats[GetMonData(mon, MON_DATA_SPECIES, NULL)].type2]; + } + + for (monTypesCount = 0, i = 0; i < 31; i++) + { + if (monTypesBits & 1) + monTypesCount++; + monTypesBits >>= 1; + } + + var_48 = sub_8165C40(); + var_44[0] += (monTypesCount * var_48) / 20; + + for (i = 0; i < 16; i++) + { + u8 r8; + + var_44[i + 1] = 0; + r8 = sub_8190168(gSaveBlock2Ptr->frontier.field_D24[i].unk0); + for (j = 0; j < 3; j++) + { + sub_818F720(gSaveBlock2Ptr->frontier.field_D64[i]); + } + } + + Free(var_44); + Free(var_40); +} +#else +NAKED +void sub_818F02C(void) +{ + asm_unified("\n\ + push {r4-r7,lr}\n\ + mov r7, r10\n\ + mov r6, r9\n\ + mov r5, r8\n\ + push {r5-r7}\n\ + sub sp, 0x3C\n\ + movs r0, 0\n\ + str r0, [sp, 0x8]\n\ + str r0, [sp, 0xC]\n\ + str r0, [sp, 0x10]\n\ + movs r0, 0x20\n\ + bl AllocZeroed\n\ + str r0, [sp, 0x18]\n\ + movs r0, 0x18\n\ + bl AllocZeroed\n\ + str r0, [sp, 0x1C]\n\ + ldr r4, =gSaveBlock2Ptr\n\ + ldr r1, [r4]\n\ + ldr r2, =0x00000ca9\n\ + adds r0, r1, r2\n\ + ldrb r0, [r0]\n\ + lsls r0, 30\n\ + lsrs r0, 30\n\ + adds r0, 0x1\n\ + ldr r3, =0x00000d0a\n\ + adds r1, r3\n\ + strb r0, [r1]\n\ + ldr r0, =0x000040ce\n\ + bl VarGet\n\ + ldr r1, [r4]\n\ + adds r0, 0x1\n\ + ldr r5, =0x00000d0b\n\ + adds r1, r5\n\ + strb r0, [r1]\n\ + ldr r2, [r4]\n\ + ldr r7, =0x00000d24\n\ + adds r3, r2, r7\n\ + ldrh r0, [r3]\n\ + ldr r5, =0x000003ff\n\ + adds r1, r5, 0\n\ + orrs r0, r1\n\ + strh r0, [r3]\n\ + ldr r3, =0x00000d25\n\ + adds r2, r3\n\ + ldrb r1, [r2]\n\ + movs r0, 0x5\n\ + negs r0, r0\n\ + ands r0, r1\n\ + strb r0, [r2]\n\ + ldr r1, [r4]\n\ + adds r1, r3\n\ + ldrb r2, [r1]\n\ + movs r0, 0x19\n\ + negs r0, r0\n\ + ands r0, r2\n\ + strb r0, [r1]\n\ + ldr r1, [r4]\n\ + adds r1, r3\n\ + ldrb r2, [r1]\n\ + movs r0, 0x1F\n\ + ands r0, r2\n\ + strb r0, [r1]\n\ + movs r7, 0\n\ + mov r10, r7\n\ + mov r8, r4\n\ + ldr r0, =gBattleScripting + 0x14\n\ + mov r9, r0\n\ + movs r4, 0\n\ +_0818F0BA:\n\ + mov r1, r8\n\ + ldr r0, [r1]\n\ + ldr r2, =0x00000caa\n\ + adds r0, r2\n\ + adds r0, r4\n\ + ldrh r0, [r0]\n\ + movs r3, 0x64\n\ + muls r0, r3\n\ + add r0, r9\n\ + movs r1, 0xB\n\ + movs r2, 0\n\ + bl GetMonData\n\ + mov r5, r8\n\ + ldr r1, [r5]\n\ + ldr r7, =0x00000d64\n\ + adds r1, r7\n\ + adds r1, r4\n\ + strh r0, [r1]\n\ + movs r5, 0\n\ + mov r0, r10\n\ + lsls r7, r0, 4\n\ + adds r6, r7, 0\n\ +_0818F0E8:\n\ + mov r1, r8\n\ + ldr r0, [r1]\n\ + ldr r2, =0x00000caa\n\ + adds r0, r2\n\ + adds r0, r4\n\ + ldrh r0, [r0]\n\ + movs r3, 0x64\n\ + muls r0, r3\n\ + add r0, r9\n\ + adds r1, r5, 0\n\ + adds r1, 0xD\n\ + movs r2, 0\n\ + bl GetMonData\n\ + mov r2, r8\n\ + ldr r1, [r2]\n\ + ldr r3, =0x00000efc\n\ + adds r1, r3\n\ + adds r1, r6\n\ + strh r0, [r1]\n\ + adds r6, 0x2\n\ + adds r5, 0x1\n\ + cmp r5, 0x3\n\ + ble _0818F0E8\n\ + movs r5, 0\n\ + ldr r6, =gSaveBlock2Ptr\n\ +_0818F11C:\n\ + ldr r0, [r6]\n\ + ldr r1, =0x00000caa\n\ + adds r0, r1\n\ + adds r0, r4\n\ + ldrh r0, [r0]\n\ + movs r2, 0x64\n\ + muls r0, r2\n\ + add r0, r9\n\ + adds r1, r5, 0\n\ + adds r1, 0x1A\n\ + movs r2, 0\n\ + bl GetMonData\n\ + ldr r1, [r6]\n\ + adds r2, r5, r7\n\ + ldr r3, =0x00000f04\n\ + adds r1, r3\n\ + adds r1, r2\n\ + strb r0, [r1]\n\ + adds r5, 0x1\n\ + cmp r5, 0x5\n\ + ble _0818F11C\n\ + mov r5, r8\n\ + ldr r0, [r5]\n\ + ldr r1, =0x00000caa\n\ + adds r0, r1\n\ + adds r0, r4\n\ + ldrh r0, [r0]\n\ + movs r2, 0x64\n\ + muls r0, r2\n\ + add r0, r9\n\ + bl GetNature\n\ + ldr r1, [r5]\n\ + adds r1, r7\n\ + ldr r3, =0x00000f0a\n\ + adds r1, r3\n\ + strb r0, [r1]\n\ + adds r4, 0x2\n\ + movs r5, 0x1\n\ + add r10, r5\n\ + mov r7, r10\n\ + cmp r7, 0x2\n\ + ble _0818F0BA\n\ + mov r10, r5\n\ + movs r0, 0x4\n\ + str r0, [sp, 0x34]\n\ + movs r1, 0x6\n\ + str r1, [sp, 0x38]\n\ +_0818F17E:\n\ + mov r2, r10\n\ + cmp r2, 0x5\n\ + ble _0818F22C\n\ +_0818F184:\n\ + bl sub_81A39C4\n\ + lsls r0, 24\n\ + lsrs r0, 24\n\ + movs r1, 0\n\ + bl sub_8162548\n\ + lsls r0, 16\n\ + lsrs r4, r0, 16\n\ + movs r5, 0x1\n\ + cmp r5, r10\n\ + bge _0818F1CA\n\ + ldr r3, =gSaveBlock2Ptr\n\ + ldr r0, [r3]\n\ + ldr r7, =0x00000d28\n\ + adds r0, r7\n\ + ldrh r0, [r0]\n\ + lsls r0, 22\n\ + lsrs r0, 22\n\ + adds r2, r3, 0\n\ + cmp r0, r4\n\ + beq _0818F1CA\n\ + ldr r3, =0x00000d24\n\ +_0818F1B2:\n\ + adds r5, 0x1\n\ + cmp r5, r10\n\ + bge _0818F1CA\n\ + ldr r0, [r2]\n\ + lsls r1, r5, 2\n\ + adds r0, r1\n\ + adds r0, r3\n\ + ldrh r0, [r0]\n\ + lsls r0, 22\n\ + lsrs r0, 22\n\ + cmp r0, r4\n\ + bne _0818F1B2\n\ +_0818F1CA:\n\ + cmp r5, r10\n\ + bne _0818F184\n\ + ldr r0, =gSaveBlock2Ptr\n\ + ldr r3, [r0]\n\ + ldr r1, [sp, 0x34]\n\ + adds r3, r1\n\ + ldr r2, =0x00000d24\n\ + adds r3, r2\n\ + ldr r5, =0x000003ff\n\ + adds r0, r5, 0\n\ + adds r2, r4, 0\n\ + ands r2, r0\n\ + ldrh r0, [r3]\n\ + ldr r7, =0xfffffc00\n\ + adds r1, r7, 0\n\ + b _0818F292\n\ + .pool\n\ +_0818F22C:\n\ + bl sub_81A39C4\n\ + adds r0, 0x1\n\ + lsls r0, 24\n\ + lsrs r0, 24\n\ + movs r1, 0\n\ + bl sub_8162548\n\ + lsls r0, 16\n\ + lsrs r4, r0, 16\n\ + movs r5, 0x1\n\ + cmp r5, r10\n\ + bge _0818F274\n\ + ldr r1, =gSaveBlock2Ptr\n\ + ldr r0, [r1]\n\ + ldr r2, =0x00000d28\n\ + adds r0, r2\n\ + ldrh r0, [r0]\n\ + lsls r0, 22\n\ + lsrs r0, 22\n\ + adds r2, r1, 0\n\ + cmp r0, r4\n\ + beq _0818F274\n\ + ldr r3, =0x00000d24\n\ +_0818F25C:\n\ + adds r5, 0x1\n\ + cmp r5, r10\n\ + bge _0818F274\n\ + ldr r0, [r2]\n\ + lsls r1, r5, 2\n\ + adds r0, r1\n\ + adds r0, r3\n\ + ldrh r0, [r0]\n\ + lsls r0, 22\n\ + lsrs r0, 22\n\ + cmp r0, r4\n\ + bne _0818F25C\n\ +_0818F274:\n\ + cmp r5, r10\n\ + bne _0818F22C\n\ + ldr r5, =gSaveBlock2Ptr\n\ + ldr r3, [r5]\n\ + ldr r7, [sp, 0x34]\n\ + adds r3, r7\n\ + ldr r0, =0x00000d24\n\ + adds r3, r0\n\ + ldr r1, =0x000003ff\n\ + adds r0, r1, 0\n\ + adds r2, r4, 0\n\ + ands r2, r0\n\ + ldrh r0, [r3]\n\ + ldr r5, =0xfffffc00\n\ + adds r1, r5, 0\n\ +_0818F292:\n\ + ands r0, r1\n\ + orrs r0, r2\n\ + strh r0, [r3]\n\ + movs r5, 0\n\ + lsls r4, 16\n\ + str r4, [sp, 0x2C]\n\ + ldr r7, [sp, 0x38]\n\ + str r7, [sp, 0x20]\n\ +_0818F2A2:\n\ + lsls r0, r5, 1\n\ + mov r9, r0\n\ + adds r1, r5, 0x1\n\ + str r1, [sp, 0x24]\n\ + lsls r2, r5, 2\n\ + str r2, [sp, 0x28]\n\ +_0818F2AE:\n\ + ldr r3, [sp, 0x2C]\n\ + lsrs r0, r3, 16\n\ + bl sub_8163524\n\ + lsls r0, 16\n\ + lsrs r6, r0, 16\n\ + movs r7, 0\n\ + cmp r7, r5\n\ + bge _0818F300\n\ + ldr r0, =gSaveBlock2Ptr\n\ + ldr r0, [r0]\n\ + ldr r1, [sp, 0x8]\n\ + mov r8, r1\n\ + ldr r2, [sp, 0xC]\n\ + mov r12, r2\n\ + ldr r3, =0x00000d64\n\ + adds r0, r3\n\ + ldr r1, [sp, 0x20]\n\ + adds r4, r1, r0\n\ +_0818F2D4:\n\ + ldrh r3, [r4]\n\ + cmp r3, r6\n\ + beq _0818F300\n\ + ldr r2, =gUnknown_0203BC8C\n\ + ldr r1, [r2]\n\ + lsls r0, r6, 4\n\ + adds r2, r0, r1\n\ + ldrh r0, [r2]\n\ + cmp r8, r0\n\ + beq _0818F300\n\ + cmp r12, r0\n\ + beq _0818F300\n\ + lsls r0, r3, 4\n\ + adds r0, r1\n\ + ldrb r0, [r0, 0xA]\n\ + ldrb r2, [r2, 0xA]\n\ + cmp r0, r2\n\ + beq _0818F300\n\ + adds r4, 0x2\n\ + adds r7, 0x1\n\ + cmp r7, r5\n\ + blt _0818F2D4\n\ +_0818F300:\n\ + cmp r7, r5\n\ + bne _0818F2AE\n\ + ldr r3, =gSaveBlock2Ptr\n\ + ldr r0, [r3]\n\ + ldr r1, [sp, 0x38]\n\ + add r1, r9\n\ + ldr r5, =0x00000d64\n\ + adds r0, r5\n\ + adds r0, r1\n\ + strh r6, [r0]\n\ + ldr r2, [sp, 0x28]\n\ + add r2, sp\n\ + adds r2, 0x8\n\ + ldr r0, =gUnknown_0203BC8C\n\ + ldr r1, [r0]\n\ + lsls r0, r6, 4\n\ + adds r0, r1\n\ + ldrh r0, [r0]\n\ + str r0, [r2]\n\ + ldr r5, [sp, 0x24]\n\ + cmp r5, 0x2\n\ + ble _0818F2A2\n\ + ldr r2, [r3]\n\ + ldr r7, [sp, 0x34]\n\ + adds r2, r7\n\ + ldr r0, =0x00000d25\n\ + adds r2, r0\n\ + ldrb r0, [r2]\n\ + movs r3, 0x5\n\ + negs r3, r3\n\ + adds r1, r3, 0\n\ + ands r0, r1\n\ + strb r0, [r2]\n\ + ldr r5, =gSaveBlock2Ptr\n\ + ldr r2, [r5]\n\ + adds r2, r7\n\ + ldr r7, =0x00000d25\n\ + adds r2, r7\n\ + ldrb r0, [r2]\n\ + subs r3, 0x14\n\ + adds r1, r3, 0\n\ + ands r0, r1\n\ + strb r0, [r2]\n\ + ldr r1, [r5]\n\ + ldr r5, [sp, 0x34]\n\ + adds r1, r5\n\ + adds r1, r7\n\ + ldrb r2, [r1]\n\ + movs r0, 0x1F\n\ + ands r0, r2\n\ + strb r0, [r1]\n\ + adds r5, 0x4\n\ + str r5, [sp, 0x34]\n\ + ldr r7, [sp, 0x38]\n\ + adds r7, 0x6\n\ + str r7, [sp, 0x38]\n\ + movs r0, 0x1\n\ + add r10, r0\n\ + mov r1, r10\n\ + cmp r1, 0xF\n\ + bgt _0818F37C\n\ + b _0818F17E\n\ +_0818F37C:\n\ + movs r7, 0\n\ + ldr r2, [sp, 0x18]\n\ + strh r7, [r2]\n\ + movs r3, 0\n\ + mov r10, r3\n\ + ldr r6, =gBitTable\n\ + ldr r5, =gBaseStats\n\ +_0818F38A:\n\ + ldr r0, =gSaveBlock2Ptr\n\ + ldr r0, [r0]\n\ + mov r2, r10\n\ + lsls r1, r2, 1\n\ + ldr r3, =0x00000caa\n\ + adds r0, r3\n\ + adds r0, r1\n\ + ldrh r0, [r0]\n\ + subs r4, r0, 0x1\n\ + movs r0, 0x64\n\ + muls r4, r0\n\ + ldr r0, =gPlayerParty\n\ + adds r4, r0\n\ + adds r0, r4, 0\n\ + movs r1, 0x3B\n\ + movs r2, 0\n\ + bl GetMonData\n\ + ldr r2, [sp, 0x18]\n\ + ldrh r1, [r2]\n\ + adds r1, r0\n\ + strh r1, [r2]\n\ + adds r0, r4, 0\n\ + movs r1, 0x3C\n\ + movs r2, 0\n\ + bl GetMonData\n\ + ldr r3, [sp, 0x18]\n\ + ldrh r1, [r3]\n\ + adds r1, r0\n\ + strh r1, [r3]\n\ + adds r0, r4, 0\n\ + movs r1, 0x3E\n\ + movs r2, 0\n\ + bl GetMonData\n\ + ldr r2, [sp, 0x18]\n\ + ldrh r1, [r2]\n\ + adds r1, r0\n\ + strh r1, [r2]\n\ + adds r0, r4, 0\n\ + movs r1, 0x3F\n\ + movs r2, 0\n\ + bl GetMonData\n\ + ldr r3, [sp, 0x18]\n\ + ldrh r1, [r3]\n\ + adds r1, r0\n\ + strh r1, [r3]\n\ + adds r0, r4, 0\n\ + movs r1, 0x3D\n\ + movs r2, 0\n\ + bl GetMonData\n\ + ldr r2, [sp, 0x18]\n\ + ldrh r1, [r2]\n\ + adds r1, r0\n\ + strh r1, [r2]\n\ + adds r0, r4, 0\n\ + movs r1, 0x3A\n\ + movs r2, 0\n\ + bl GetMonData\n\ + ldr r3, [sp, 0x18]\n\ + ldrh r1, [r3]\n\ + adds r1, r0\n\ + strh r1, [r3]\n\ + adds r0, r4, 0\n\ + movs r1, 0xB\n\ + movs r2, 0\n\ + bl GetMonData\n\ + lsls r1, r0, 3\n\ + subs r1, r0\n\ + lsls r1, 2\n\ + adds r1, r5\n\ + ldrb r0, [r1, 0x6]\n\ + lsls r0, 2\n\ + adds r0, r6\n\ + ldr r0, [r0]\n\ + orrs r7, r0\n\ + adds r0, r4, 0\n\ + movs r1, 0xB\n\ + movs r2, 0\n\ + bl GetMonData\n\ + lsls r1, r0, 3\n\ + subs r1, r0\n\ + lsls r1, 2\n\ + adds r1, r5\n\ + ldrb r0, [r1, 0x7]\n\ + lsls r0, 2\n\ + adds r0, r6\n\ + ldr r0, [r0]\n\ + orrs r7, r0\n\ + movs r0, 0x1\n\ + add r10, r0\n\ + mov r1, r10\n\ + cmp r1, 0x2\n\ + ble _0818F38A\n\ + movs r4, 0\n\ + movs r1, 0x1\n\ + movs r5, 0x1F\n\ +_0818F458:\n\ + adds r0, r7, 0\n\ + ands r0, r1\n\ + cmp r0, 0\n\ + beq _0818F462\n\ + adds r4, 0x1\n\ +_0818F462:\n\ + asrs r7, 1\n\ + subs r5, 0x1\n\ + cmp r5, 0\n\ + bge _0818F458\n\ + bl sub_8165C40\n\ + lsls r0, 24\n\ + lsrs r0, 24\n\ + str r0, [sp, 0x14]\n\ + adds r2, r0, 0\n\ + adds r0, r4, 0\n\ + muls r0, r2\n\ + movs r1, 0x14\n\ + bl __divsi3\n\ + ldr r3, [sp, 0x18]\n\ + ldrh r1, [r3]\n\ + adds r1, r0\n\ + strh r1, [r3]\n\ + movs r5, 0x1\n\ + mov r10, r5\n\ + adds r6, r3, 0\n\ + adds r6, 0x2\n\ + movs r7, 0x2\n\ + str r7, [sp, 0x30]\n\ +_0818F494:\n\ + movs r7, 0\n\ + strh r7, [r6]\n\ + ldr r1, =gSaveBlock2Ptr\n\ + ldr r0, [r1]\n\ + mov r2, r10\n\ + lsls r1, r2, 2\n\ + adds r0, r1\n\ + ldr r3, =0x00000d24\n\ + adds r0, r3\n\ + ldrh r0, [r0]\n\ + lsls r0, 22\n\ + lsrs r0, 22\n\ + bl sub_8190168\n\ + lsls r0, 24\n\ + lsrs r0, 24\n\ + mov r8, r0\n\ + movs r5, 0\n\ + ldr r0, [sp, 0x30]\n\ + mov r9, r0\n\ +_0818F4BC:\n\ + ldr r1, =gSaveBlock2Ptr\n\ + ldr r0, [r1]\n\ + mov r4, r9\n\ + add r4, r10\n\ + adds r4, r5\n\ + lsls r4, 1\n\ + ldr r2, =0x00000d64\n\ + adds r0, r2\n\ + adds r0, r4\n\ + ldrh r1, [r0]\n\ + ldr r3, =gUnknown_0203BC8C\n\ + ldr r0, [r3]\n\ + lsls r1, 4\n\ + adds r1, r0\n\ + ldrh r0, [r1]\n\ + ldrb r3, [r1, 0xB]\n\ + ldrb r1, [r1, 0xC]\n\ + str r1, [sp]\n\ + ldr r1, [sp, 0x1C]\n\ + str r1, [sp, 0x4]\n\ + ldr r1, [sp, 0x14]\n\ + mov r2, r8\n\ + bl sub_818F720\n\ + ldr r2, [sp, 0x1C]\n\ + ldr r1, [r2, 0x4]\n\ + ldrh r0, [r6]\n\ + adds r0, r1\n\ + ldr r1, [r2, 0x8]\n\ + adds r0, r1\n\ + ldr r1, [r2, 0x10]\n\ + adds r0, r1\n\ + ldr r1, [r2, 0x14]\n\ + adds r0, r1\n\ + ldr r1, [r2, 0xC]\n\ + adds r0, r1\n\ + ldr r1, [r2]\n\ + adds r0, r1\n\ + strh r0, [r6]\n\ + ldr r3, =gSaveBlock2Ptr\n\ + ldr r0, [r3]\n\ + ldr r1, =0x00000d64\n\ + adds r0, r1\n\ + adds r0, r4\n\ + ldrh r0, [r0]\n\ + ldr r2, =gUnknown_0203BC8C\n\ + ldr r1, [r2]\n\ + lsls r0, 4\n\ + adds r0, r1\n\ + ldrh r0, [r0]\n\ + lsls r1, r0, 3\n\ + subs r1, r0\n\ + lsls r1, 2\n\ + ldr r3, =gBaseStats\n\ + adds r1, r3\n\ + ldrb r0, [r1, 0x6]\n\ + lsls r0, 2\n\ + ldr r2, =gBitTable\n\ + adds r0, r2\n\ + ldr r0, [r0]\n\ + orrs r7, r0\n\ + ldrb r0, [r1, 0x7]\n\ + lsls r0, 2\n\ + adds r0, r2\n\ + ldr r0, [r0]\n\ + orrs r7, r0\n\ + adds r5, 0x1\n\ + cmp r5, 0x2\n\ + ble _0818F4BC\n\ + movs r4, 0\n\ + movs r1, 0x1\n\ + movs r5, 0x1F\n\ +_0818F54C:\n\ + adds r0, r7, 0\n\ + ands r0, r1\n\ + cmp r0, 0\n\ + beq _0818F556\n\ + adds r4, 0x1\n\ +_0818F556:\n\ + asrs r7, 1\n\ + subs r5, 0x1\n\ + cmp r5, 0\n\ + bge _0818F54C\n\ + ldr r3, [sp, 0x14]\n\ + adds r0, r4, 0\n\ + muls r0, r3\n\ + movs r1, 0x14\n\ + bl __divsi3\n\ + ldrh r1, [r6]\n\ + adds r1, r0\n\ + strh r1, [r6]\n\ + adds r6, 0x2\n\ + ldr r5, [sp, 0x30]\n\ + adds r5, 0x2\n\ + str r5, [sp, 0x30]\n\ + movs r7, 0x1\n\ + add r10, r7\n\ + mov r0, r10\n\ + cmp r0, 0xF\n\ + ble _0818F494\n\ + movs r1, 0\n\ + mov r10, r1\n\ + ldr r2, =0x000003ff\n\ + mov r8, r2\n\ +_0818F58A:\n\ + mov r5, r10\n\ + adds r5, 0x1\n\ + adds r7, r5, 0\n\ + cmp r5, 0xF\n\ + bgt _0818F626\n\ + mov r3, r10\n\ + lsls r0, r3, 1\n\ + ldr r1, [sp, 0x18]\n\ + adds r6, r0, r1\n\ + lsls r0, r5, 1\n\ + adds r4, r0, r1\n\ +_0818F5A0:\n\ + ldrh r1, [r6]\n\ + ldrh r0, [r4]\n\ + cmp r1, r0\n\ + bcc _0818F5C2\n\ + cmp r1, r0\n\ + bne _0818F61E\n\ + ldr r0, =gSaveBlock2Ptr\n\ + ldr r1, [r0]\n\ + lsls r0, r5, 2\n\ + adds r0, r1, r0\n\ + ldr r2, =0x00000d24\n\ + adds r0, r2\n\ + ldrh r0, [r0]\n\ + lsls r2, r0, 22\n\ + lsrs r0, r2, 22\n\ + cmp r0, r8\n\ + bne _0818F602\n\ +_0818F5C2:\n\ + mov r0, r10\n\ + adds r1, r5, 0\n\ + ldr r2, [sp, 0x18]\n\ + bl sub_818F904\n\ + b _0818F600\n\ + .pool\n\ +_0818F600:\n\ + b _0818F61E\n\ +_0818F602:\n\ + mov r3, r10\n\ + lsls r0, r3, 2\n\ + adds r0, r1, r0\n\ + ldr r1, =0x00000d24\n\ + adds r0, r1\n\ + ldrh r0, [r0]\n\ + lsls r0, 22\n\ + cmp r0, r2\n\ + bls _0818F61E\n\ + mov r0, r10\n\ + adds r1, r5, 0\n\ + ldr r2, [sp, 0x18]\n\ + bl sub_818F904\n\ +_0818F61E:\n\ + adds r4, 0x2\n\ + adds r5, 0x1\n\ + cmp r5, 0xF\n\ + ble _0818F5A0\n\ +_0818F626:\n\ + mov r10, r7\n\ + mov r2, r10\n\ + cmp r2, 0xE\n\ + ble _0818F58A\n\ + bl sub_81A3610\n\ + lsls r0, 24\n\ + cmp r0, 0\n\ + beq _0818F6EE\n\ + movs r3, 0\n\ + mov r10, r3\n\ + ldr r0, =gSaveBlock2Ptr\n\ + ldr r1, [r0]\n\ + ldr r4, =0x00000d24\n\ + adds r1, r4\n\ + ldrh r1, [r1]\n\ + lsls r1, 22\n\ + lsrs r1, 22\n\ + ldr r3, =0x000003ff\n\ + adds r2, r0, 0\n\ + ldr r6, =gUnknown_0860D3F1\n\ + cmp r1, r3\n\ + beq _0818F674\n\ + adds r5, r2, 0\n\ +_0818F656:\n\ + movs r7, 0x1\n\ + add r10, r7\n\ + mov r0, r10\n\ + cmp r0, 0xF\n\ + bgt _0818F674\n\ + ldr r0, [r5]\n\ + mov r7, r10\n\ + lsls r1, r7, 2\n\ + adds r0, r1\n\ + adds r0, r4\n\ + ldrh r0, [r0]\n\ + lsls r0, 22\n\ + lsrs r0, 22\n\ + cmp r0, r3\n\ + bne _0818F656\n\ +_0818F674:\n\ + mov r1, r10\n\ + lsls r0, r1, 1\n\ + adds r0, r6\n\ + ldrb r0, [r0]\n\ + cmp r0, 0\n\ + beq _0818F6AC\n\ + movs r5, 0\n\ + ldr r2, [r2]\n\ + ldr r3, =0x00000d24\n\ + adds r2, r3\n\ + ldrh r1, [r2]\n\ + ldr r0, =0xfffffc00\n\ + ands r0, r1\n\ + ldr r7, =0x000003fe\n\ + adds r1, r7, 0\n\ + b _0818F6BE\n\ + .pool\n\ +_0818F6AC:\n\ + movs r5, 0x1\n\ + ldr r2, [r2]\n\ + ldr r0, =0x00000d28\n\ + adds r2, r0\n\ + ldrh r1, [r2]\n\ + ldr r0, =0xfffffc00\n\ + ands r0, r1\n\ + ldr r3, =0x000003fe\n\ + adds r1, r3, 0\n\ +_0818F6BE:\n\ + orrs r0, r1\n\ + strh r0, [r2]\n\ + movs r7, 0\n\ + mov r10, r7\n\ + lsls r0, r5, 1\n\ + adds r0, r5\n\ + lsls r4, r0, 1\n\ +_0818F6CC:\n\ + mov r1, r10\n\ + lsls r0, r1, 24\n\ + lsrs r0, 24\n\ + bl sub_81A4FF0\n\ + ldr r1, =gSaveBlock2Ptr\n\ + ldr r1, [r1]\n\ + ldr r2, =0x00000d64\n\ + adds r1, r2\n\ + adds r1, r4\n\ + strh r0, [r1]\n\ + adds r4, 0x2\n\ + movs r3, 0x1\n\ + add r10, r3\n\ + mov r5, r10\n\ + cmp r5, 0x2\n\ + ble _0818F6CC\n\ +_0818F6EE:\n\ + ldr r0, [sp, 0x18]\n\ + bl Free\n\ + ldr r0, [sp, 0x1C]\n\ + bl Free\n\ + add sp, 0x3C\n\ + pop {r3-r5}\n\ + mov r8, r3\n\ + mov r9, r4\n\ + mov r10, r5\n\ + pop {r4-r7}\n\ + pop {r0}\n\ + bx r0\n\ + .pool\n\ +\n\ + "); +} +#endif // NONMATCHING + +#define CALC_STAT(base, statIndex) \ +{ \ + u8 baseStat = gBaseStats[species].base; \ + stats[statIndex] = (((2 * baseStat + ivs + evs[statIndex] / 4) * level) / 100) + 5; \ + stats[statIndex] = (u8) ModifyStatByNature(nature, stats[statIndex], statIndex); \ +} + +void sub_818F720(u16 species, s32 level, s32 ivs, u8 evBits, u8 nature, s32 *stats) +{ + s32 i, count; + u8 bits; + u16 resultingEvs; + s32 evs[6]; + + count = 0, bits = evBits; + for (i = 0; i < 6; bits >>= 1, i++) + { + if (bits & 1) + count++; + } + + resultingEvs = 510 / count; + for (i = 0; i < 6; bits <<= 1, i++) + { + evs[i] = 0; + if (evBits & bits) + evs[i] = resultingEvs; + } + + if (species == SPECIES_SHEDINJA) + { + stats[STAT_HP] = 1; + } + else + { + s32 n = 2 * gBaseStats[species].baseHP; + stats[STAT_HP] = (((n + ivs + evs[STAT_HP] / 4) * level) / 100) + level + 10; + } + + CALC_STAT(baseAttack, STAT_ATK); + CALC_STAT(baseDefense, STAT_DEF); + CALC_STAT(baseSpeed, STAT_SPEED); + CALC_STAT(baseSpAttack, STAT_SPATK); + CALC_STAT(baseSpDefense, STAT_SPDEF); +} + +#define SWAP_16(x, y) \ +{ \ + temp = x; \ + x = y; \ + y = temp; \ +} + +void sub_818F904(s32 id1, s32 id2, u16 *dst) +{ + s32 i; + u16 temp; + + SWAP_16(dst[id1], dst[id2]); + SWAP_16(gSaveBlock2Ptr->frontier.field_D24[id1].unk0, gSaveBlock2Ptr->frontier.field_D24[id2].unk0); + + for (i = 0; i < 3; i++) + SWAP_16(gSaveBlock2Ptr->frontier.field_D64[id1][i], gSaveBlock2Ptr->frontier.field_D64[id2][i]); +}