diff --git a/asm/battle_frontier_1.s b/asm/battle_frontier_1.s index 6715dadea7..11f215a836 100644 --- a/asm/battle_frontier_1.s +++ b/asm/battle_frontier_1.s @@ -6,991 +6,11 @@ .text - thumb_func_start sub_818F9B0 -sub_818F9B0: @ 818F9B0 - push {lr} - ldr r0, =gStringVar1 - ldr r2, =gRoundsStringTable - ldr r1, =gSaveBlock2Ptr - ldr r1, [r1] - ldr r3, =0x00000cb2 - adds r1, r3 - ldrh r1, [r1] - lsls r1, 2 - adds r1, r2 - ldr r1, [r1] - bl StringCopy - pop {r0} - bx r0 - .pool - thumb_func_end sub_818F9B0 - thumb_func_start sub_818F9E0 -sub_818F9E0: @ 818F9E0 - push {lr} - ldr r0, =gStringVar1 - ldr r2, =gRoundsStringTable - ldr r1, =gSaveBlock2Ptr - ldr r1, [r1] - ldr r3, =0x00000cb2 - adds r1, r3 - ldrh r1, [r1] - lsls r1, 2 - adds r1, r2 - ldr r1, [r1] - bl StringCopy - ldr r0, =gStringVar2 - ldr r1, =gTrainerBattleOpponent_A - ldrh r1, [r1] - bl sub_8195898 - pop {r0} - bx r0 - .pool - thumb_func_end sub_818F9E0 - thumb_func_start sub_818FA20 -sub_818FA20: @ 818FA20 - push {r4,r5,lr} - ldr r1, =gUnknown_0203CD70 - movs r0, 0 - str r0, [r1] - ldr r4, =gPlayerParty - adds r0, r4, 0 - movs r1, 0x3A - movs r2, 0 - bl GetMonData - ldr r5, =gUnknown_0203CD74 - str r0, [r5] - adds r4, 0x64 - adds r0, r4, 0 - movs r1, 0x3A - movs r2, 0 - bl GetMonData - ldr r1, [r5] - adds r1, r0 - str r1, [r5] - bl CalculatePlayerPartyCount - ldr r0, =gTrainerBattleOpponent_A - ldrh r0, [r0] - bl sub_8195358 - lsls r0, 16 - lsrs r0, 16 - bl sub_818FBDC - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_818FA20 - thumb_func_start sub_818FA74 -sub_818FA74: @ 818FA74 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0x30 - adds r5, r2, 0 - str r3, [sp, 0x14] - lsls r0, 24 - lsrs r0, 24 - str r0, [sp, 0x10] - lsls r1, 16 - lsrs r1, 16 - str r1, [sp, 0x28] - lsls r5, 24 - lsrs r5, 24 - add r0, sp, 0xC - movs r1, 0x1 - negs r1, r1 - strb r1, [r0] - ldr r0, [sp, 0x28] - bl sub_8190168 - adds r6, r0, 0 - lsls r6, 24 - lsrs r6, 24 - str r6, [sp, 0x2C] - bl sub_8165C40 - adds r2, r0, 0 - lsls r2, 24 - lsrs r2, 24 - movs r0, 0x64 - ldr r4, [sp, 0x10] - adds r3, r4, 0 - muls r3, r0 - str r3, [sp, 0x18] - ldr r6, =gEnemyParty - adds r0, r3, r6 - ldr r7, =gSaveBlock2Ptr - ldr r4, [r7] - lsls r5, 1 - ldr r3, [sp, 0x28] - lsls r1, r3, 1 - adds r1, r3 - lsls r1, 1 - adds r1, r5, r1 - ldr r6, =0x00000d64 - adds r4, r6 - adds r4, r1 - ldrh r3, [r4] - ldr r7, =gUnknown_0203BC8C - ldr r7, [r7] - mov r8, r7 - lsls r3, 4 - add r3, r8 - ldrh r1, [r3] - ldrb r3, [r3, 0xC] - ldr r6, [sp, 0x2C] - str r6, [sp] - ldrh r4, [r4] - lsls r4, 4 - add r4, r8 - ldrb r4, [r4, 0xB] - str r4, [sp, 0x4] - ldr r7, [sp, 0x14] - str r7, [sp, 0x8] - bl CreateMonWithEVSpreadPersonalityOTID - add r0, sp, 0xC - movs r1, 0x1 - negs r1, r1 - strb r1, [r0] - movs r6, 0 - ldr r2, [sp, 0x18] - str r2, [sp, 0x1C] - mov r10, r5 - ldr r3, =0x00000d64 - mov r9, r3 - ldr r3, =gUnknown_0203BC8C - mov r4, r10 - str r4, [sp, 0x20] -_0818FB18: - ldr r7, =gSaveBlock2Ptr - ldr r1, [r7] - ldr r2, [sp, 0x28] - lsls r0, r2, 1 - adds r0, r2 - lsls r0, 1 - mov r8, r0 - mov r5, r10 - add r5, r8 - add r1, r9 - adds r1, r5 - ldrh r0, [r1] - ldr r1, [r3] - lsls r0, 4 - adds r0, r1 - lsls r4, r6, 1 - adds r0, 0x2 - adds r0, r4 - ldrh r1, [r0] - lsls r2, r6, 24 - lsrs r2, 24 - mov r12, r2 - ldr r7, [sp, 0x1C] - ldr r2, =gEnemyParty - adds r0, r7, r2 - mov r2, r12 - str r3, [sp, 0x24] - bl SetMonMoveSlot - ldr r7, =gSaveBlock2Ptr - ldr r0, [r7] - add r0, r9 - adds r0, r5 - ldrh r0, [r0] - ldr r3, [sp, 0x24] - ldr r1, [r3] - lsls r0, 4 - adds r0, r1 - adds r0, 0x2 - adds r0, r4 - ldrh r0, [r0] - cmp r0, 0xDA - bne _0818FB74 - movs r1, 0 - add r0, sp, 0xC - strb r1, [r0] -_0818FB74: - adds r6, 0x1 - cmp r6, 0x3 - ble _0818FB18 - movs r0, 0x64 - ldr r1, [sp, 0x10] - adds r4, r1, 0 - muls r4, r0 - ldr r0, =gEnemyParty - adds r4, r0 - adds r0, r4, 0 - movs r1, 0x20 - add r2, sp, 0xC - bl SetMonData - ldr r0, =gSaveBlock2Ptr - ldr r0, [r0] - ldr r1, [sp, 0x20] - add r1, r8 - ldr r2, =0x00000d64 - adds r0, r2 - adds r0, r1 - ldrh r0, [r0] - ldr r1, =gUnknown_0203BC8C - ldr r1, [r1] - lsls r0, 4 - adds r0, r1 - ldrb r2, [r0, 0xA] - lsls r2, 1 - ldr r0, =gBattleFrontierHeldItems - adds r2, r0 - adds r0, r4, 0 - movs r1, 0xC - bl SetMonData - add sp, 0x30 - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_818FA74 - - thumb_func_start sub_818FBDC -sub_818FBDC: @ 818FBDC - push {r4-r7,lr} - mov r7, r8 - push {r7} - lsls r0, 16 - lsrs r0, 16 - mov r8, r0 - movs r6, 0 - bl ZeroEnemyPartyMons - mov r0, r8 - bl sub_818FC78 - adds r5, r0, 0 - bl Random - adds r4, r0, 0 - bl Random - lsls r4, 16 - lsrs r7, r4, 16 - lsls r0, 16 - orrs r7, r0 - bl Random - lsls r0, 16 - lsrs r0, 16 - movs r1, 0xA - bl __umodsi3 - lsls r0, 16 - lsrs r0, 16 - cmp r0, 0x5 - bls _0818FC46 - movs r4, 0 -_0818FC20: - movs r0, 0x1 - ands r0, r5 - cmp r0, 0 - beq _0818FC3C - lsls r2, r4, 24 - lsrs r2, 24 - adds r0, r6, 0 - mov r1, r8 - adds r3, r7, 0 - bl sub_818FA74 - adds r0, r6, 0x1 - lsls r0, 24 - lsrs r6, r0, 24 -_0818FC3C: - asrs r5, 1 - adds r4, 0x1 - cmp r4, 0x2 - ble _0818FC20 - b _0818FC6C -_0818FC46: - movs r4, 0x2 -_0818FC48: - movs r0, 0x4 - ands r0, r5 - cmp r0, 0 - beq _0818FC64 - lsls r2, r4, 24 - lsrs r2, 24 - adds r0, r6, 0 - mov r1, r8 - adds r3, r7, 0 - bl sub_818FA74 - adds r0, r6, 0x1 - lsls r0, 24 - lsrs r6, r0, 24 -_0818FC64: - lsls r5, 1 - subs r4, 0x1 - cmp r4, 0 - bge _0818FC48 -_0818FC6C: - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r0} - bx r0 - thumb_func_end sub_818FBDC - - thumb_func_start sub_818FC78 -sub_818FC78: @ 818FC78 - push {r4,r5,lr} - lsls r0, 16 - lsrs r4, r0, 16 - adds r5, r4, 0 - bl Random - movs r1, 0x1 - ands r1, r0 - cmp r1, 0 - beq _0818FCA2 - adds r0, r4, 0 - movs r1, 0 - bl sub_818FCBC - cmp r0, 0 - bne _0818FCB6 - adds r0, r4, 0 - movs r1, 0x1 - bl sub_818FDB8 - b _0818FCB6 -_0818FCA2: - adds r0, r5, 0 - movs r1, 0 - bl sub_818FDB8 - cmp r0, 0 - bne _0818FCB6 - adds r0, r5, 0 - movs r1, 0x1 - bl sub_818FCBC -_0818FCB6: - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_818FC78 - - thumb_func_start sub_818FCBC -sub_818FCBC: @ 818FCBC - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0x1C - lsls r0, 16 - lsrs r0, 16 - mov r8, r0 - lsls r1, 24 - lsrs r1, 24 - str r1, [sp, 0xC] - movs r0, 0 - mov r9, r0 - mov r1, r8 - lsls r1, 2 - str r1, [sp, 0x18] -_0818FCDE: - mov r2, r9 - lsls r0, r2, 2 - mov r2, sp - adds r1, r2, r0 - movs r0, 0 - str r0, [r1] - movs r7, 0 - mov r0, r9 - adds r0, 0x1 - str r0, [sp, 0x14] - adds r5, r1, 0 - mov r1, r9 - lsls r1, 1 - str r1, [sp, 0x10] -_0818FCFA: - movs r6, 0 - adds r2, r7, 0x1 - mov r10, r2 -_0818FD00: - ldr r0, =gSaveBlock2Ptr - ldr r1, [r0] - ldr r2, [sp, 0x18] - adds r0, r1, r2 - ldr r2, =0x00000d24 - adds r0, r2 - ldrh r0, [r0] - lsls r0, 22 - lsrs r0, 22 - ldr r2, =0x000003fe - cmp r0, r2 - bne _0818FD3C - mov r1, r9 - lsls r0, r1, 24 - lsls r1, r7, 24 - lsrs r0, 24 - lsrs r1, 24 - bl sub_81A5060 - adds r4, r0, 0 - lsls r4, 16 - lsrs r4, 16 - b _0818FD60 - .pool -_0818FD3C: - mov r2, r8 - lsls r0, r2, 1 - add r0, r8 - lsls r0, 1 - ldr r2, [sp, 0x10] - adds r0, r2, r0 - ldr r2, =0x00000d64 - adds r1, r2 - adds r1, r0 - ldrh r0, [r1] - ldr r1, =gUnknown_0203BC8C - ldr r1, [r1] - lsls r0, 4 - adds r0, r1 - lsls r1, r7, 1 - adds r0, 0x2 - adds r0, r1 - ldrh r4, [r0] -_0818FD60: - movs r0, 0x64 - muls r0, r6 - ldr r1, =gPlayerParty - adds r0, r1 - movs r1, 0xB - movs r2, 0 - bl GetMonData - adds r1, r0, 0 - adds r0, r4, 0 - movs r2, 0 - bl sub_818FFC0 - ldr r1, [r5] - adds r1, r0 - str r1, [r5] - adds r6, 0x1 - cmp r6, 0x2 - ble _0818FD00 - mov r7, r10 - cmp r7, 0x3 - ble _0818FCFA - ldr r0, [sp, 0x14] - mov r9, r0 - cmp r0, 0x2 - ble _0818FCDE - mov r0, sp - ldr r1, [sp, 0xC] - bl sub_818FEB4 - add sp, 0x1C - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r1} - bx r1 - .pool - thumb_func_end sub_818FCBC - - thumb_func_start sub_818FDB8 -sub_818FDB8: @ 818FDB8 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0x1C - lsls r0, 16 - lsrs r0, 16 - mov r8, r0 - lsls r1, 24 - lsrs r1, 24 - str r1, [sp, 0xC] - movs r0, 0 - mov r9, r0 - mov r1, r8 - lsls r1, 2 - str r1, [sp, 0x18] -_0818FDDA: - mov r2, r9 - lsls r0, r2, 2 - mov r2, sp - adds r1, r2, r0 - movs r0, 0 - str r0, [r1] - movs r7, 0 - mov r0, r9 - adds r0, 0x1 - str r0, [sp, 0x14] - adds r5, r1, 0 - mov r1, r9 - lsls r1, 1 - str r1, [sp, 0x10] -_0818FDF6: - movs r6, 0 - adds r2, r7, 0x1 - mov r10, r2 -_0818FDFC: - ldr r0, =gSaveBlock2Ptr - ldr r1, [r0] - ldr r2, [sp, 0x18] - adds r0, r1, r2 - ldr r2, =0x00000d24 - adds r0, r2 - ldrh r0, [r0] - lsls r0, 22 - lsrs r0, 22 - ldr r2, =0x000003fe - cmp r0, r2 - bne _0818FE38 - mov r1, r9 - lsls r0, r1, 24 - lsls r1, r7, 24 - lsrs r0, 24 - lsrs r1, 24 - bl sub_81A5060 - adds r4, r0, 0 - lsls r4, 16 - lsrs r4, 16 - b _0818FE5C - .pool -_0818FE38: - mov r2, r8 - lsls r0, r2, 1 - add r0, r8 - lsls r0, 1 - ldr r2, [sp, 0x10] - adds r0, r2, r0 - ldr r2, =0x00000d64 - adds r1, r2 - adds r1, r0 - ldrh r0, [r1] - ldr r1, =gUnknown_0203BC8C - ldr r1, [r1] - lsls r0, 4 - adds r0, r1 - lsls r1, r7, 1 - adds r0, 0x2 - adds r0, r1 - ldrh r4, [r0] -_0818FE5C: - movs r0, 0x64 - muls r0, r6 - ldr r1, =gPlayerParty - adds r0, r1 - movs r1, 0xB - movs r2, 0 - bl GetMonData - adds r1, r0, 0 - adds r0, r4, 0 - movs r2, 0x1 - bl sub_818FFC0 - ldr r1, [r5] - adds r1, r0 - str r1, [r5] - adds r6, 0x1 - cmp r6, 0x2 - ble _0818FDFC - mov r7, r10 - cmp r7, 0x3 - ble _0818FDF6 - ldr r0, [sp, 0x14] - mov r9, r0 - cmp r0, 0x2 - ble _0818FDDA - mov r0, sp - ldr r1, [sp, 0xC] - bl sub_818FEB4 - add sp, 0x1C - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r1} - bx r1 - .pool - thumb_func_end sub_818FDB8 - - thumb_func_start sub_818FEB4 -sub_818FEB4: @ 818FEB4 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0x18 - mov r10, r0 - lsls r1, 24 - lsrs r1, 24 - movs r0, 0 - str r0, [sp, 0xC] - movs r3, 0x2 - add r0, sp, 0x8 -_0818FECE: - str r3, [r0] - subs r0, 0x4 - subs r3, 0x1 - cmp r3, 0 - bge _0818FECE - mov r3, r10 - ldr r2, [r3] - ldr r0, [r3, 0x4] - cmp r2, r0 - bne _0818FF20 - ldr r0, [r3, 0x8] - cmp r2, r0 - bne _0818FF20 - cmp r1, 0 - beq _0818FFAA - movs r3, 0 - ldr r4, =gBitTable -_0818FEF0: - str r3, [sp, 0x14] - bl Random - movs r1, 0x3 - ands r1, r0 - ldr r3, [sp, 0x14] - cmp r1, 0x3 - beq _0818FF16 - lsls r0, r1, 2 - adds r0, r4 - ldr r1, [r0] - ldr r0, [sp, 0xC] - ands r0, r1 - cmp r0, 0 - bne _0818FF16 - ldr r0, [sp, 0xC] - orrs r0, r1 - str r0, [sp, 0xC] - adds r3, 0x1 -_0818FF16: - cmp r3, 0x2 - bne _0818FEF0 - b _0818FFAA - .pool -_0818FF20: - movs r3, 0 - mov r9, sp - mov r8, r10 -_0818FF26: - adds r2, r3, 0x1 - cmp r2, 0x2 - bgt _0818FF84 - mov r6, r8 - mov r7, r9 - lsls r0, r2, 2 - mov r1, sp - adds r5, r0, r1 - mov r1, r10 - adds r4, r0, r1 -_0818FF3A: - ldr r0, [r6] - ldr r1, [r4] - cmp r0, r1 - bge _0818FF4E - str r1, [r6] - str r0, [r4] - ldr r1, [r7] - ldr r0, [r5] - str r0, [r7] - str r1, [r5] -_0818FF4E: - ldr r1, [r6] - ldr r0, [r4] - cmp r1, r0 - bne _0818FF7A - str r2, [sp, 0x10] - str r3, [sp, 0x14] - bl Random - movs r1, 0x1 - ands r1, r0 - ldr r2, [sp, 0x10] - ldr r3, [sp, 0x14] - cmp r1, 0 - beq _0818FF7A - ldr r1, [r6] - ldr r0, [r4] - str r0, [r6] - str r1, [r4] - ldr r1, [r7] - ldr r0, [r5] - str r0, [r7] - str r1, [r5] -_0818FF7A: - adds r5, 0x4 - adds r4, 0x4 - adds r2, 0x1 - cmp r2, 0x2 - ble _0818FF3A -_0818FF84: - movs r4, 0x4 - add r9, r4 - add r8, r4 - adds r3, 0x1 - cmp r3, 0x1 - ble _0818FF26 - ldr r2, =gBitTable - mov r1, sp - movs r3, 0x1 -_0818FF96: - ldm r1!, {r0} - lsls r0, 2 - adds r0, r2 - ldr r0, [r0] - ldr r4, [sp, 0xC] - orrs r4, r0 - str r4, [sp, 0xC] - subs r3, 0x1 - cmp r3, 0 - bge _0818FF96 -_0818FFAA: - ldr r0, [sp, 0xC] - add sp, 0x18 - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r1} - bx r1 - .pool - thumb_func_end sub_818FEB4 - - thumb_func_start sub_818FFC0 -sub_818FFC0: @ 818FFC0 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0x8 - adds r3, r0, 0 - adds r4, r1, 0 - str r2, [sp] - movs r6, 0 - movs r2, 0x14 - cmp r3, 0 - beq _0818FFF0 - ldr r0, =0x0000ffff - cmp r3, r0 - beq _0818FFF0 - ldr r0, =gBattleMoves - lsls r1, r3, 1 - adds r1, r3 - lsls r1, 2 - adds r3, r1, r0 - ldrb r0, [r3, 0x1] - cmp r0, 0 - bne _0818FFFC -_0818FFF0: - movs r0, 0 - b _08190156 - .pool -_0818FFFC: - ldr r1, =gBaseStats - lsls r0, r4, 3 - subs r0, r4 - lsls r0, 2 - adds r0, r1 - ldrb r1, [r0, 0x6] - mov r10, r1 - ldrb r1, [r0, 0x7] - mov r9, r1 - ldrb r0, [r0, 0x16] - mov r8, r0 - ldrb r3, [r3, 0x2] - str r3, [sp, 0x4] - cmp r0, 0x1A - bne _0819002C - cmp r3, 0x4 - bne _0819002C - ldr r0, [sp] - cmp r0, 0x1 - bne _081900AA - movs r2, 0x8 - b _081900A4 - .pool -_0819002C: - ldr r0, =gTypeEffectiveness - adds r1, r6, r0 - ldrb r0, [r1] - ldr r7, =gTypeEffectiveness - cmp r0, 0xFF - beq _081900A4 - adds r4, r1, 0 -_0819003A: - ldrb r0, [r4] - cmp r0, 0xFE - beq _08190096 - ldrb r0, [r4] - ldr r1, [sp, 0x4] - cmp r0, r1 - bne _08190096 - ldrb r0, [r4, 0x1] - adds r5, r6, 0x1 - cmp r0, r10 - bne _0819006C - adds r1, r6, 0x2 - mov r0, r8 - cmp r0, 0x19 - bne _0819005E - ldrb r0, [r4, 0x2] - cmp r0, 0x28 - bne _0819006C -_0819005E: - adds r0, r1, r7 - ldrb r0, [r0] - muls r0, r2 - movs r1, 0xA - bl __divsi3 - adds r2, r0, 0 -_0819006C: - adds r0, r5, r7 - ldrb r0, [r0] - cmp r0, r9 - bne _08190096 - cmp r10, r9 - beq _08190096 - adds r1, r6, 0x2 - mov r0, r8 - cmp r0, 0x19 - bne _08190088 - adds r0, r1, r7 - ldrb r0, [r0] - cmp r0, 0x28 - bne _08190096 -_08190088: - adds r0, r1, r7 - ldrb r0, [r0] - muls r0, r2 - movs r1, 0xA - bl __divsi3 - adds r2, r0, 0 -_08190096: - adds r4, 0x3 - adds r6, 0x3 - ldr r1, =gTypeEffectiveness - adds r0, r6, r1 - ldrb r0, [r0] - cmp r0, 0xFF - bne _0819003A -_081900A4: - ldr r0, [sp] - cmp r0, 0x1 - beq _081900E0 -_081900AA: - ldr r1, [sp] - cmp r1, 0x1 - bgt _081900BC - cmp r1, 0 - beq _081900C4 - b _08190154 - .pool -_081900BC: - ldr r0, [sp] - cmp r0, 0x2 - beq _08190114 - b _08190154 -_081900C4: - cmp r2, 0xA - beq _08190146 - cmp r2, 0xA - ble _08190146 - cmp r2, 0x28 - beq _0819014A - cmp r2, 0x28 - bgt _081900DA - cmp r2, 0x14 - beq _08190104 - b _08190146 -_081900DA: - cmp r2, 0x50 - bne _08190146 - b _08190100 -_081900E0: - cmp r2, 0xA - beq _08190104 - cmp r2, 0xA - bgt _081900F2 - cmp r2, 0 - beq _08190100 - cmp r2, 0x5 - beq _0819014A - b _08190146 -_081900F2: - cmp r2, 0x28 - beq _08190108 - cmp r2, 0x28 - ble _08190146 - cmp r2, 0x50 - beq _0819010E - b _08190146 -_08190100: - movs r2, 0x8 - b _08190154 -_08190104: - movs r2, 0x2 - b _08190154 -_08190108: - movs r2, 0x2 - negs r2, r2 - b _08190154 -_0819010E: - movs r2, 0x4 - negs r2, r2 - b _08190154 -_08190114: - cmp r2, 0xA - beq _08190146 - cmp r2, 0xA - bgt _08190126 - cmp r2, 0 - beq _0819013A - cmp r2, 0x5 - beq _08190140 - b _08190146 -_08190126: - cmp r2, 0x28 - beq _0819014E - cmp r2, 0x28 - bgt _08190134 - cmp r2, 0x14 - beq _0819014A - b _08190146 -_08190134: - cmp r2, 0x50 - beq _08190152 - b _08190146 -_0819013A: - movs r2, 0x10 - negs r2, r2 - b _08190154 -_08190140: - movs r2, 0x8 - negs r2, r2 - b _08190154 -_08190146: - movs r2, 0 - b _08190154 -_0819014A: - movs r2, 0x4 - b _08190154 -_0819014E: - movs r2, 0xC - b _08190154 -_08190152: - movs r2, 0x14 -_08190154: - adds r0, r2, 0 -_08190156: - add sp, 0x8 - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r1} - bx r1 - thumb_func_end sub_818FFC0 - - thumb_func_start sub_8190168 -sub_8190168: @ 8190168 + thumb_func_start GetDomeTrainerMonIvs +GetDomeTrainerMonIvs: @ 8190168 push {lr} lsls r0, 16 lsrs r0, 16 @@ -1020,7 +40,7 @@ _0819019A: adds r0, r1, 0 pop {r1} bx r1 - thumb_func_end sub_8190168 + thumb_func_end GetDomeTrainerMonIvs thumb_func_start sub_81901A0 sub_81901A0: @ 81901A0 @@ -1292,7 +312,7 @@ sub_81903B8: @ 81903B8 bl sub_81902AC lsls r0, 16 lsrs r0, 16 - bl sub_8195358 + bl TrainerIdToTournamentId strh r0, [r4, 0xA] strh r5, [r4, 0xC] strh r5, [r4, 0xE] @@ -5282,7 +4302,7 @@ _08192690: adds r0, r3 adds r0, r5 ldrh r1, [r0] - ldr r0, =gUnknown_0203BC8C + ldr r0, =gFacilityTrainerMons ldr r0, [r0] lsls r1, 4 adds r1, r0 @@ -5538,7 +4558,7 @@ _081928E4: adds r1, r2 adds r1, r0 ldrh r1, [r1] - ldr r0, =gUnknown_0203BC8C + ldr r0, =gFacilityTrainerMons ldr r0, [r0] lsls r1, 4 _081928FA: @@ -5683,7 +4703,7 @@ _08192A20: add r1, r12 adds r1, r0 ldrh r0, [r1] - ldr r1, =gUnknown_0203BC8C + ldr r1, =gFacilityTrainerMons ldr r1, [r1] lsls r0, 4 adds r0, r1 @@ -5919,7 +4939,7 @@ _08192C0C: bge _08192C0C b _08192D70 _08192C24: - ldr r4, =gUnknown_0203BC8C + ldr r4, =gFacilityTrainerMons mov r10, r4 ldr r1, [sp, 0x3C] ldr r2, [sp, 0x20] @@ -6965,7 +5985,7 @@ _08193490: adds r2, r1 adds r2, r0 ldrh r1, [r2] - ldr r0, =gUnknown_0203BC8C + ldr r0, =gFacilityTrainerMons ldr r0, [r0] lsls r1, 4 adds r1, r0 @@ -7114,7 +6134,7 @@ _081935D8: adds r2, r1 adds r2, r0 ldrh r1, [r2] - ldr r0, =gUnknown_0203BC8C + ldr r0, =gFacilityTrainerMons ldr r0, [r0] lsls r1, 4 adds r1, r0 @@ -7974,7 +6994,7 @@ sub_8193D7C: @ 8193D7C bne _08193E10 ldr r5, =gTrainerBattleOpponent_A ldrh r0, [r5] - bl sub_8195358 + bl TrainerIdToTournamentId ldr r4, =gSaveBlock2Ptr ldr r2, [r4] lsls r0, 2 @@ -7986,7 +7006,7 @@ sub_8193D7C: @ 8193D7C orrs r0, r1 strb r0, [r2] ldrh r0, [r5] - bl sub_8195358 + bl TrainerIdToTournamentId ldr r1, [r4] lsls r0, 2 adds r0, r1, r0 @@ -8005,7 +7025,7 @@ sub_8193D7C: @ 8193D7C orrs r1, r2 strb r1, [r0] ldrh r0, [r5] - bl sub_8195358 + bl TrainerIdToTournamentId ldr r2, [r4] lsls r0, 1 movs r3, 0xEC @@ -8027,7 +7047,7 @@ sub_8193D7C: @ 8193D7C _08193E10: ldr r5, =0x000003ff adds r0, r5, 0 - bl sub_8195358 + bl TrainerIdToTournamentId ldr r4, =gSaveBlock2Ptr ldr r2, [r4] lsls r0, 2 @@ -8039,7 +7059,7 @@ _08193E10: orrs r0, r1 strb r0, [r2] adds r0, r5, 0 - bl sub_8195358 + bl TrainerIdToTournamentId ldr r1, [r4] lsls r0, 2 adds r0, r1, r0 @@ -8057,7 +7077,7 @@ _08193E10: orrs r1, r2 strb r1, [r0] adds r0, r5, 0 - bl sub_8195358 + bl TrainerIdToTournamentId ldr r1, [r4] lsls r0, 1 movs r3, 0xEC @@ -8076,7 +7096,7 @@ _08193E10: bne _08193E92 _08193E78: adds r0, r5, 0 - bl sub_8195358 + bl TrainerIdToTournamentId ldr r2, [r4] lsls r0, 2 adds r2, r0 @@ -8127,7 +7147,7 @@ sub_8193ED0: @ 8193ED0 str r0, [sp, 0x54] movs r1, 0 str r1, [sp, 0x58] - bl sub_8165C40 + bl GetFrontierEnemyMonLevel movs r2, 0 str r2, [sp, 0x50] add r3, sp, 0x30 @@ -8193,7 +7213,7 @@ _08193F60: adds r1, r3, r5 adds r1, r0 ldrh r0, [r1] - ldr r1, =gUnknown_0203BC8C + ldr r1, =gFacilityTrainerMons ldr r1, [r1] lsls r0, 4 adds r0, r1 @@ -8266,7 +7286,7 @@ _08193FEE: adds r0, r4 add r0, r8 ldrh r4, [r0] - ldr r3, =gUnknown_0203BC8C + ldr r3, =gFacilityTrainerMons ldr r0, [r3] lsls r4, 4 adds r4, r0 @@ -9729,7 +8749,7 @@ sub_8194CE4: @ 8194CE4 thumb_func_start sub_8194D48 sub_8194D48: @ 8194D48 - ldr r1, =gUnknown_0203BC8C + ldr r1, =gFacilityTrainerMons ldr r0, =gBattleFrontierMons str r0, [r1] ldr r1, =gUnknown_0203BC88 @@ -9909,10 +8929,10 @@ sub_8194EC0: @ 8194EC0 push {r4,lr} ldr r0, =gTrainerBattleOpponent_A ldrh r0, [r0] - bl sub_8195358 + bl TrainerIdToTournamentId adds r4, r0, 0 ldr r0, =0x000003ff - bl sub_8195358 + bl TrainerIdToTournamentId cmp r4, r0 ble _08194EE8 ldr r1, =gSpecialVar_Result @@ -10141,7 +9161,7 @@ _0819509E: bge _081950F4 ldr r0, =gSaveBlock2Ptr ldr r0, [r0] - ldr r1, =gUnknown_0203BC8C + ldr r1, =gFacilityTrainerMons mov r9, r1 ldr r2, [sp, 0x8] mov r8, r2 @@ -10189,7 +9209,7 @@ _081950F4: ldr r2, [sp, 0x2C] add r2, sp adds r2, 0x8 - ldr r3, =gUnknown_0203BC8C + ldr r3, =gFacilityTrainerMons ldr r1, [r3] lsls r0, r5, 4 adds r0, r1 @@ -10260,7 +9280,7 @@ _08195182: ldrh r0, [r0] lsls r0, 22 lsrs r0, 22 - bl sub_8190168 + bl GetDomeTrainerMonIvs lsls r0, 24 lsrs r0, 24 mov r8, r0 @@ -10278,7 +9298,7 @@ _081951AA: adds r0, r2 adds r0, r4 ldrh r1, [r0] - ldr r3, =gUnknown_0203BC8C + ldr r3, =gFacilityTrainerMons ldr r0, [r3] lsls r1, 4 adds r1, r0 @@ -10312,7 +9332,7 @@ _081951AA: adds r0, r1 adds r0, r4 ldrh r0, [r0] - ldr r2, =gUnknown_0203BC8C + ldr r2, =gFacilityTrainerMons ldr r1, [r2] lsls r0, 4 adds r0, r1 @@ -10465,8 +9485,8 @@ _0819533E: .pool thumb_func_end sub_8194F58 - thumb_func_start sub_8195358 -sub_8195358: @ 8195358 + thumb_func_start TrainerIdToTournamentId +TrainerIdToTournamentId: @ 8195358 push {r4,r5,lr} lsls r0, 16 lsrs r3, r0, 16 @@ -10501,7 +9521,7 @@ _0819538E: pop {r1} bx r1 .pool - thumb_func_end sub_8195358 + thumb_func_end TrainerIdToTournamentId thumb_func_start sub_81953A0 sub_81953A0: @ 81953A0 @@ -10768,7 +9788,7 @@ _081955B0: ldr r2, [sp, 0x38] adds r0, r1, r2 ldrh r0, [r0] - ldr r3, =gUnknown_0203BC8C + ldr r3, =gFacilityTrainerMons mov r8, r3 ldr r2, [r3] lsls r0, 4 @@ -10873,7 +9893,7 @@ _08195682: mov r2, r8 adds r0, r1, r2 ldrh r0, [r0] - ldr r5, =gUnknown_0203BC8C + ldr r5, =gFacilityTrainerMons mov r9, r5 ldr r2, [r5] lsls r0, 4 @@ -11121,7 +10141,7 @@ sub_8195898: @ 8195898 lsls r1, 16 lsrs r5, r1, 16 movs r4, 0 - bl sub_8165C40 + bl GetFrontierEnemyMonLevel ldr r0, =0x000003fe cmp r5, r0 bne _081958B8 diff --git a/asm/battle_frontier_2.s b/asm/battle_frontier_2.s index 8f2d7b0e01..46204bb647 100644 --- a/asm/battle_frontier_2.s +++ b/asm/battle_frontier_2.s @@ -1867,7 +1867,7 @@ sub_819B484: @ 819B484 lsls r0, 24 lsrs r0, 24 str r0, [sp, 0x18] - ldr r1, =gUnknown_0203BC8C + ldr r1, =gFacilityTrainerMons ldr r0, =gBattleFrontierMons str r0, [r1] ldrb r1, [r4] @@ -1948,7 +1948,7 @@ _0819B572: ldr r0, [r2] adds r0, r4 adds r0, 0x8 - ldr r1, =gUnknown_0203BC8C + ldr r1, =gFacilityTrainerMons ldr r2, [r1] lsls r5, 4 adds r2, r5, r2 @@ -1973,7 +1973,7 @@ _0819B5B8: ldr r0, [r3] adds r0, r4 adds r0, 0x8 - ldr r5, =gUnknown_0203BC8C + ldr r5, =gFacilityTrainerMons ldr r1, [r5] adds r1, r7, r1 lsls r2, r6, 1 @@ -2045,7 +2045,7 @@ sub_819B63C: @ 819B63C add r0, sp, 0xC movs r1, 0 strb r1, [r0] - ldr r2, =gUnknown_0203BC8C + ldr r2, =gFacilityTrainerMons ldr r0, =gSlateportBattleTentMons str r0, [r2] ldr r0, =gSaveBlock2Ptr @@ -2089,7 +2089,7 @@ _0819B678: adds r4, 0xC adds r0, r4 adds r0, 0x8 - ldr r3, =gUnknown_0203BC8C + ldr r3, =gFacilityTrainerMons ldr r2, [r3] mov r7, r8 lsls r5, r7, 4 @@ -2114,7 +2114,7 @@ _0819B6D4: ldr r0, [r1] adds r0, r4 adds r0, 0x8 - ldr r3, =gUnknown_0203BC8C + ldr r3, =gFacilityTrainerMons ldr r2, [r3] mov r3, r8 lsls r1, r3, 4 @@ -2145,7 +2145,7 @@ _0819B6D4: ldr r0, [r2] adds r0, r4 adds r0, 0x8 - ldr r3, =gUnknown_0203BC8C + ldr r3, =gFacilityTrainerMons ldr r1, [r3] adds r1, r5, r1 ldrb r2, [r1, 0xA] @@ -3936,7 +3936,7 @@ sub_819C5D0: @ 819C5D0 sub_819C634: @ 819C634 push {r4-r7,lr} lsls r0, 16 - ldr r2, =gUnknown_0203BC8C + ldr r2, =gFacilityTrainerMons ldr r1, [r2] lsrs r0, 12 adds r0, r1 @@ -20059,7 +20059,7 @@ _081A4E46: bl ZeroEnemyPartyMons movs r1, 0 str r1, [sp, 0x18] - bl sub_8165C40 + bl GetFrontierEnemyMonLevel lsls r0, 24 lsrs r0, 24 str r0, [sp, 0x1C] @@ -22413,7 +22413,7 @@ _081A627A: lsls r0, 16 lsrs r0, 16 mov r9, r0 - ldr r4, =gUnknown_0203BC8C + ldr r4, =gFacilityTrainerMons ldr r2, [r4] lsls r1, r0, 4 adds r0, r1, r2 @@ -22458,7 +22458,7 @@ _081A62D0: cmp r0, r5 beq _081A6302 adds r6, r4, 0 - ldr r3, =gUnknown_0203BC8C + ldr r3, =gFacilityTrainerMons mov r12, r3 mov r5, r8 ldr r3, [sp, 0x14] @@ -22493,7 +22493,7 @@ _081A631C: ldrh r1, [r3] cmp r1, 0 beq _081A6336 - ldr r6, =gUnknown_0203BC8C + ldr r6, =gFacilityTrainerMons ldr r0, [r6] ldr r6, [sp, 0x24] adds r0, r6, r0 @@ -22512,7 +22512,7 @@ _081A633E: cmp r2, r4 bne _081A636E lsls r4, r7, 1 - ldr r0, =gUnknown_0203BC8C + ldr r0, =gFacilityTrainerMons ldr r1, [r0] add r1, r8 ldrh r0, [r1] @@ -22573,12 +22573,12 @@ sub_81A63CC: @ 81A63CC ands r0, r1 cmp r0, 0x2 beq _081A63FC - ldr r1, =gUnknown_0203BC8C + ldr r1, =gFacilityTrainerMons ldr r0, =gBattleFrontierMons b _081A6400 .pool _081A63FC: - ldr r1, =gUnknown_0203BC8C + ldr r1, =gFacilityTrainerMons ldr r0, =gSlateportBattleTentMons _081A6400: str r0, [r1] @@ -22637,7 +22637,7 @@ _081A6408: adds r1, r2 strb r0, [r1] ldrh r1, [r6] - ldr r0, =gUnknown_0203BC8C + ldr r0, =gFacilityTrainerMons ldr r0, [r0] lsls r1, 4 adds r1, r0 @@ -22679,7 +22679,7 @@ sub_81A64C4: @ 81A64C4 ands r0, r1 cmp r0, 0x2 bne _081A6500 - ldr r1, =gUnknown_0203BC8C + ldr r1, =gFacilityTrainerMons ldr r0, =gSlateportBattleTentMons str r0, [r1] movs r2, 0x1E @@ -22687,7 +22687,7 @@ sub_81A64C4: @ 81A64C4 b _081A6518 .pool _081A6500: - ldr r1, =gUnknown_0203BC8C + ldr r1, =gFacilityTrainerMons ldr r0, =gBattleFrontierMons str r0, [r1] ldrb r1, [r2] @@ -22712,7 +22712,7 @@ _081A6522: mov r1, sp adds r1, 0x12 str r1, [sp, 0x1C] - ldr r2, =gUnknown_0203BC8C + ldr r2, =gFacilityTrainerMons mov r9, r2 _081A6534: ldr r4, =gSaveBlock2Ptr @@ -22879,7 +22879,7 @@ _081A666C: _081A667A: movs r2, 0 mov r8, r2 - ldr r4, =gUnknown_0203BC8C + ldr r4, =gFacilityTrainerMons mov r9, r4 _081A6682: ldr r5, =gSaveBlock2Ptr @@ -23113,7 +23113,7 @@ _081A681A: bne _081A6878 movs r2, 0x1 _081A6878: - ldr r1, =gUnknown_0203BC8C + ldr r1, =gFacilityTrainerMons ldr r0, =gBattleFrontierMons str r0, [r1] mov r1, r9 @@ -23166,7 +23166,7 @@ _081A68F2: bl sub_81A6EF0 lsls r0, 16 lsrs r7, r0, 16 - ldr r0, =gUnknown_0203BC8C + ldr r0, =gFacilityTrainerMons ldr r1, [r0] lsls r2, r7, 4 adds r4, r2, r1 @@ -23226,7 +23226,7 @@ _081A6964: ldrh r4, [r5] cmp r4, 0 beq _081A6994 - ldr r1, =gUnknown_0203BC8C + ldr r1, =gFacilityTrainerMons ldr r0, [r1] mov r2, r9 adds r1, r2, r0 @@ -23262,7 +23262,7 @@ _081A699C: lsls r0, 4 adds r1, r0 strh r7, [r1] - ldr r2, =gUnknown_0203BC8C + ldr r2, =gFacilityTrainerMons ldr r1, [r2] add r1, r9 ldrh r0, [r1] @@ -23307,7 +23307,7 @@ sub_81A6A08: @ 81A6A08 mov r7, r8 push {r7} sub sp, 0x18 - ldr r1, =gUnknown_0203BC8C + ldr r1, =gFacilityTrainerMons ldr r0, =gBattleFrontierMons str r0, [r1] movs r4, 0 @@ -23326,7 +23326,7 @@ _081A6A1E: movs r4, 0 ldr r0, =gUnknown_03006298 mov r8, r0 - ldr r0, =gUnknown_0203BC8C + ldr r0, =gFacilityTrainerMons ldr r6, [r0] ldr r1, =gBaseStats mov r12, r1 @@ -23423,7 +23423,7 @@ sub_81A6AEC: @ 81A6AEC push {r4-r7,lr} sub sp, 0x8 movs r7, 0 - ldr r1, =gUnknown_0203BC8C + ldr r1, =gFacilityTrainerMons ldr r0, =gBattleFrontierMons str r0, [r1] movs r4, 0 @@ -23445,7 +23445,7 @@ _081A6B0E: ldrh r6, [r0] movs r5, 0 _081A6B18: - ldr r0, =gUnknown_0203BC8C + ldr r0, =gFacilityTrainerMons ldr r1, [r0] lsls r0, r6, 4 adds r0, r1 @@ -23590,12 +23590,12 @@ sub_81A6C1C: @ 81A6C1C ands r0, r1 cmp r0, 0x2 beq _081A6C48 - ldr r1, =gUnknown_0203BC8C + ldr r1, =gFacilityTrainerMons ldr r0, =gBattleFrontierMons b _081A6C4C .pool _081A6C48: - ldr r1, =gUnknown_0203BC8C + ldr r1, =gFacilityTrainerMons ldr r0, =gSlateportBattleTentMons _081A6C4C: str r0, [r1] @@ -23615,7 +23615,7 @@ _081A6C50: lsls r1, 4 adds r2, r1 ldrh r2, [r2] - ldr r1, =gUnknown_0203BC8C + ldr r1, =gFacilityTrainerMons ldr r1, [r1] lsls r2, 4 adds r2, r1 @@ -23702,7 +23702,7 @@ sub_81A6CD0: @ 81A6CD0 lsls r0, 24 lsrs r0, 24 str r0, [sp, 0x24] - bl sub_8165C40 + bl GetFrontierEnemyMonLevel lsls r0, 24 lsrs r0, 24 str r0, [sp, 0x20] @@ -23727,7 +23727,7 @@ _081A6D4C: bl sub_81A6EF0 lsls r0, 16 lsrs r5, r0, 16 - ldr r7, =gUnknown_0203BC8C + ldr r7, =gFacilityTrainerMons ldr r1, [r7] lsls r0, r5, 4 adds r0, r1 @@ -23775,7 +23775,7 @@ _081A6DA8: cmp r4, r9 bge _081A6DDC add r2, sp, 0xC - ldr r7, =gUnknown_0203BC8C + ldr r7, =gFacilityTrainerMons ldr r0, [r7] lsls r1, r5, 4 adds r0, r1, r0 @@ -23784,7 +23784,7 @@ _081A6DA8: ldrh r0, [r0] cmp r2, r0 beq _081A6DDC - ldr r6, =gUnknown_0203BC8C + ldr r6, =gFacilityTrainerMons adds r3, r7, 0 add r2, sp, 0xC _081A6DC8: @@ -23805,7 +23805,7 @@ _081A6DDC: cmp r4, r9 bge _081A6E0C ldr r7, =gBattleFrontierHeldItems - ldr r6, =gUnknown_0203BC8C + ldr r6, =gFacilityTrainerMons add r2, sp, 0x14 lsls r3, r5, 4 _081A6DEE: @@ -23833,7 +23833,7 @@ _081A6E0C: mov r1, sp adds r1, r2 adds r1, 0xC - ldr r3, =gUnknown_0203BC8C + ldr r3, =gFacilityTrainerMons ldr r4, [r3] lsls r5, 4 mov r8, r5 @@ -23875,7 +23875,7 @@ _081A6E0C: add r0, r9 mov r8, r0 _081A6E6E: - ldr r1, =gUnknown_0203BC8C + ldr r1, =gFacilityTrainerMons ldr r0, [r1] adds r0, r7, r0 lsls r1, r4, 1 @@ -23898,7 +23898,7 @@ _081A6E6E: movs r1, 0x20 mov r2, r10 bl SetMonData - ldr r2, =gUnknown_0203BC8C + ldr r2, =gFacilityTrainerMons ldr r0, [r2] adds r0, r7, r0 ldrb r2, [r0, 0xA] @@ -29517,7 +29517,7 @@ _081A9C56: bl SetMonData cmp r5, 0 beq _081A9CD4 - bl sub_8165C40 + bl GetFrontierEnemyMonLevel lsls r0, 24 lsrs r5, r0, 24 ldr r1, [sp, 0x10] diff --git a/asm/battle_tent.s b/asm/battle_tent.s index c967390d08..d643457300 100644 --- a/asm/battle_tent.s +++ b/asm/battle_tent.s @@ -22,7 +22,7 @@ sub_81B9EC0: @ 81B9EC0 mov r1, sp adds r1, 0x18 str r1, [sp, 0x2C] - ldr r5, =gUnknown_0203BC8C + ldr r5, =gFacilityTrainerMons ldr r4, =gSlateportBattleTentMons movs r2, 0 adds r3, r1, 0 @@ -73,7 +73,7 @@ _081B9F1E: ldrh r0, [r1] cmp r0, r5 beq _081B9F7C - ldr r0, =gUnknown_0203BC8C + ldr r0, =gFacilityTrainerMons ldr r1, [r0] lsls r0, r5, 4 adds r4, r0, r1 @@ -112,7 +112,7 @@ _081B9F7C: bge _081B9FD4 ldr r0, =gBattleFrontierHeldItems mov r12, r0 - ldr r7, =gUnknown_0203BC8C + ldr r7, =gFacilityTrainerMons ldr r1, [sp, 0x24] ldr r0, [sp, 0x2C] adds r4, r1, r0 @@ -155,7 +155,7 @@ _081B9FD4: lsls r6, 4 adds r1, r6 strh r5, [r1] - ldr r0, =gUnknown_0203BC8C + ldr r0, =gFacilityTrainerMons ldr r0, [r0] lsls r1, r5, 4 adds r1, r0 @@ -208,7 +208,7 @@ sub_81BA040: @ 81BA040 ldr r1, =gUnknown_0203BC88 ldr r0, =gSlateportBattleTentTrainers str r0, [r1] - ldr r1, =gUnknown_0203BC8C + ldr r1, =gFacilityTrainerMons ldr r0, =gSlateportBattleTentMons str r0, [r1] ldr r7, =gSaveBlock2Ptr @@ -324,7 +324,7 @@ _081BA13E: strh r0, [r7] movs r2, 0 ldrh r0, [r7] - ldr r4, =gUnknown_0203BC8C + ldr r4, =gFacilityTrainerMons ldr r3, [r4] lsls r0, 4 adds r0, r3 @@ -356,7 +356,7 @@ _081BA180: cmp r0, r6 beq _081BA1B0 ldr r6, =gUnknown_03001298 - ldr r3, =gUnknown_0203BC8C + ldr r3, =gFacilityTrainerMons mov r2, sp _081BA198: adds r2, 0x2 @@ -386,7 +386,7 @@ _081BA1C0: beq _081BA1DE ldr r1, =gUnknown_03001298 ldrh r0, [r1] - ldr r6, =gUnknown_0203BC8C + ldr r6, =gFacilityTrainerMons ldr r1, [r6] lsls r0, 4 adds r0, r1 @@ -406,7 +406,7 @@ _081BA1E6: bne _081BA220 lsls r2, r5, 1 ldrh r0, [r7] - ldr r1, =gUnknown_0203BC8C + ldr r1, =gFacilityTrainerMons ldr r4, [r1] lsls r0, 4 adds r0, r4 diff --git a/asm/battle_tower.s b/asm/battle_tower.s index 7340ea1ce5..43dc9b19bf 100644 --- a/asm/battle_tower.s +++ b/asm/battle_tower.s @@ -551,7 +551,7 @@ _08162414: bl __udivsi3 lsls r0, 16 lsrs r5, r0, 16 - bl sub_8165C40 + bl GetFrontierEnemyMonLevel subs r4, 0x2 cmp r4, 0x1 bhi _08162488 @@ -784,7 +784,7 @@ sub_8162614: @ 8162614 adds r6, r4, 0 lsls r1, 24 lsrs r5, r1, 24 - bl sub_8165C40 + bl GetFrontierEnemyMonLevel movs r0, 0xFA lsls r0, 1 cmp r4, r0 @@ -962,7 +962,7 @@ sub_81627A4: @ 81627A4 lsls r0, 16 lsrs r4, r0, 16 adds r5, r4, 0 - bl sub_8165C40 + bl GetFrontierEnemyMonLevel movs r0, 0xFA lsls r0, 1 cmp r4, r0 @@ -1335,7 +1335,7 @@ GetFrontierTrainerFrontSpriteId: @ 8162AA0 lsls r0, 16 lsrs r4, r0, 16 adds r5, r4, 0 - bl sub_8165C40 + bl GetFrontierEnemyMonLevel movs r0, 0xFA lsls r0, 1 cmp r4, r0 @@ -1462,7 +1462,7 @@ GetFrontierOpponentClass: @ 8162BD8 lsls r0, 16 lsrs r4, r0, 16 adds r5, r4, 0 - bl sub_8165C40 + bl GetFrontierEnemyMonLevel movs r0, 0xFA lsls r0, 1 cmp r4, r0 @@ -1602,7 +1602,7 @@ sub_8162D34: @ 8162D34 lsls r0, 16 lsrs r4, r0, 16 adds r5, r4, 0 - bl sub_8165C40 + bl GetFrontierEnemyMonLevel movs r0, 0xFA lsls r0, 1 cmp r4, r0 @@ -1704,7 +1704,7 @@ GetFrontierTrainerName: @ 8162E20 lsls r1, 16 lsrs r5, r1, 16 movs r4, 0 - bl sub_8165C40 + bl GetFrontierEnemyMonLevel movs r0, 0xFA lsls r0, 1 cmp r5, r0 @@ -1854,7 +1854,7 @@ sub_8162F68: @ 8162F68 lsls r0, 16 lsrs r4, r0, 16 adds r5, r4, 0 - bl sub_8165C40 + bl GetFrontierEnemyMonLevel movs r0, 0xFA lsls r0, 1 cmp r4, r0 @@ -2025,7 +2025,7 @@ sub_81630C4: @ 81630C4 add r4, sp, 0x14 movs r0, 0xFF strb r0, [r4] - bl sub_8165C40 + bl GetFrontierEnemyMonLevel lsls r0, 24 lsrs r0, 24 str r0, [sp, 0x20] @@ -2258,7 +2258,7 @@ _081632D2: movs r1, 0xB movs r2, 0 bl GetMonData - ldr r1, =gUnknown_0203BC8C + ldr r1, =gFacilityTrainerMons ldr r2, [r1] lsls r1, r4, 4 adds r1, r2 @@ -2291,7 +2291,7 @@ _08163308: movs r1, 0xC movs r2, 0 bl GetMonData - ldr r1, =gUnknown_0203BC8C + ldr r1, =gFacilityTrainerMons ldr r2, [r1] lsls r1, r4, 4 adds r1, r2 @@ -2338,7 +2338,7 @@ _08163368: muls r0, r1 ldr r2, =gEnemyParty adds r0, r2 - ldr r5, =gUnknown_0203BC8C + ldr r5, =gFacilityTrainerMons ldr r2, [r5] lsls r4, 4 adds r2, r4, r2 @@ -2405,7 +2405,7 @@ _081633EC: movs r1, 0x20 add r2, sp, 0x14 bl SetMonData - ldr r0, =gUnknown_0203BC8C + ldr r0, =gFacilityTrainerMons ldr r0, [r0] add r0, r9 ldrb r2, [r0, 0xA] @@ -2551,7 +2551,7 @@ sub_8163524: @ 8163524 adds r4, r0, 0 lsls r4, 16 lsrs r4, 16 - bl sub_8165C40 + bl GetFrontierEnemyMonLevel lsls r0, 24 lsrs r6, r0, 24 ldr r0, =gUnknown_0203BC88 @@ -2728,7 +2728,7 @@ _081636A4: movs r0, 0x1F _081636A6: str r0, [sp, 0x18] - bl sub_8165C40 + bl GetFrontierEnemyMonLevel lsls r0, 24 lsrs r0, 24 str r0, [sp, 0x14] @@ -2759,7 +2759,7 @@ _081636CE: muls r6, r0 ldr r1, =gEnemyParty adds r0, r6, r1 - ldr r3, =gUnknown_0203BC8C + ldr r3, =gFacilityTrainerMons ldr r2, [r3] mov r1, r9 lsls r4, r1, 4 @@ -2784,7 +2784,7 @@ _081636CE: mov r10, r7 adds r7, r4, 0 _08163718: - ldr r0, =gUnknown_0203BC8C + ldr r0, =gFacilityTrainerMons ldr r1, [r0] mov r2, r9 lsls r0, r2, 4 @@ -2813,7 +2813,7 @@ _08163718: movs r1, 0x20 add r2, sp, 0xC bl SetMonData - ldr r1, =gUnknown_0203BC8C + ldr r1, =gFacilityTrainerMons ldr r0, [r1] adds r0, r7, r0 ldrb r2, [r0, 0xA] @@ -2881,7 +2881,7 @@ _081637D0: muls r6, r7 ldr r1, =gEnemyParty adds r0, r6, r1 - ldr r7, =gUnknown_0203BC8C + ldr r7, =gFacilityTrainerMons ldr r2, [r7] lsls r4, 4 adds r2, r4, r2 @@ -2905,7 +2905,7 @@ _081637D0: mov r8, r4 mov r5, r8 _08163818: - ldr r1, =gUnknown_0203BC8C + ldr r1, =gFacilityTrainerMons ldr r0, [r1] adds r0, r5, r0 lsls r4, r7, 1 @@ -2916,7 +2916,7 @@ _08163818: adds r0, r6, r2 adds r2, r7, 0 bl sub_81A7024 - ldr r1, =gUnknown_0203BC8C + ldr r1, =gFacilityTrainerMons ldr r0, [r1] adds r0, r5, r0 adds r0, 0x2 @@ -2942,7 +2942,7 @@ _08163846: movs r1, 0x20 add r2, sp, 0xC bl SetMonData - ldr r1, =gUnknown_0203BC8C + ldr r1, =gFacilityTrainerMons ldr r0, [r1] add r0, r8 ldrb r2, [r0, 0xA] @@ -3029,7 +3029,7 @@ _0816390A: thumb_func_start sub_8163914 sub_8163914: @ 8163914 push {lr} - bl sub_8165C40 + bl GetFrontierEnemyMonLevel ldr r0, =gSpecialVar_0x8005 ldrh r0, [r0] cmp r0, 0 @@ -4091,7 +4091,7 @@ sub_81642A0: @ 81642A0 movs r2, 0 bl GetMonData str r0, [sp, 0x20] - bl sub_8165C40 + bl GetFrontierEnemyMonLevel movs r7, 0 ldr r0, [sp, 0x18] lsls r0, 24 @@ -4200,7 +4200,7 @@ _081643C0: ldr r1, [sp, 0x28] adds r0, r1 ldrh r2, [r0] - ldr r0, =gUnknown_0203BC8C + ldr r0, =gFacilityTrainerMons ldr r0, [r0] lsls r2, 4 adds r2, r0 @@ -4216,7 +4216,7 @@ _081643F4: bge _08164430 ldr r2, =gSaveBlock2Ptr ldr r0, [r2] - ldr r1, =gUnknown_0203BC8C + ldr r1, =gFacilityTrainerMons ldr r3, [r1] lsls r1, r6, 4 adds r1, r3 @@ -4556,7 +4556,7 @@ sub_81646BC: @ 81646BC movs r0, 0 mov r9, r0 mov r10, r0 - bl sub_8165C40 + bl GetFrontierEnemyMonLevel movs r0, 0xFA lsls r0, 1 cmp r5, r0 @@ -4564,7 +4564,7 @@ sub_81646BC: @ 81646BC subs r0, 0xC9 cmp r5, r0 bhi _081646FC - ldr r0, =gUnknown_0203BC8C + ldr r0, =gFacilityTrainerMons ldr r1, [r0] lsls r0, r4, 4 adds r0, r1 @@ -4705,7 +4705,7 @@ sub_8164828: @ 8164828 mov r5, r8 push {r5-r7} sub sp, 0x8 - bl sub_8165C40 + bl GetFrontierEnemyMonLevel bl sub_81A39C4 lsls r0, 16 lsrs r0, 16 @@ -6073,7 +6073,7 @@ sub_8165404: @ 8165404 sub sp, 0x70 lsls r0, 16 lsrs r7, r0, 16 - bl sub_8165C40 + bl GetFrontierEnemyMonLevel ldr r0, =0x00000c03 cmp r7, r0 beq _08165420 @@ -6228,7 +6228,7 @@ _08165564: bls _0816556C b _081656E8 _0816556C: - bl sub_8165C40 + bl GetFrontierEnemyMonLevel lsls r0, 24 lsrs r0, 24 str r0, [sp, 0x50] @@ -6272,7 +6272,7 @@ _081655A6: mov r9, r0 mov r0, r8 add r0, r9 - ldr r6, =gUnknown_0203BC8C + ldr r6, =gFacilityTrainerMons ldr r4, [r6] lsls r5, r1, 4 adds r4, r5, r4 @@ -6339,7 +6339,7 @@ _08165634: movs r1, 0x20 ldr r2, [sp, 0x5C] bl SetMonData - ldr r0, =gUnknown_0203BC8C + ldr r0, =gFacilityTrainerMons ldr r1, [r0] ldr r2, [sp, 0x54] lsls r0, r2, 4 @@ -7083,8 +7083,8 @@ _08165C2A: .pool thumb_func_end sub_8165B88 - thumb_func_start sub_8165C40 -sub_8165C40: @ 8165C40 + thumb_func_start GetFrontierEnemyMonLevel +GetFrontierEnemyMonLevel: @ 8165C40 push {lr} ldr r0, =gSaveBlock2Ptr ldr r0, [r0] @@ -7098,7 +7098,7 @@ sub_8165C40: @ 8165C40 ldr r1, =gUnknown_0203BC88 ldr r0, =gBattleFrontierTrainers str r0, [r1] - ldr r1, =gUnknown_0203BC8C + ldr r1, =gFacilityTrainerMons ldr r0, =gBattleFrontierMons str r0, [r1] ldrb r0, [r2] @@ -7114,7 +7114,7 @@ _08165C88: lsrs r0, 24 pop {r1} bx r1 - thumb_func_end sub_8165C40 + thumb_func_end GetFrontierEnemyMonLevel thumb_func_start BattleFrontierGetOpponentLvl BattleFrontierGetOpponentLvl: @ 8165C90 @@ -7258,7 +7258,7 @@ sub_8165D78: @ 8165D78 ldr r1, =gUnknown_0203BC88 ldr r0, =gSlateportBattleTentTrainers str r0, [r1] - ldr r1, =gUnknown_0203BC8C + ldr r1, =gFacilityTrainerMons ldr r0, =gSlateportBattleTentMons b _08165DF2 .pool @@ -7268,7 +7268,7 @@ _08165DA8: ldr r1, =gUnknown_0203BC88 ldr r0, =gVerdanturfBattleTentTrainers str r0, [r1] - ldr r1, =gUnknown_0203BC8C + ldr r1, =gFacilityTrainerMons ldr r0, =gVerdanturfBattleTentMons b _08165DF2 .pool @@ -7278,7 +7278,7 @@ _08165DC8: ldr r1, =gUnknown_0203BC88 ldr r0, =gFallarborBattleTentTrainers str r0, [r1] - ldr r1, =gUnknown_0203BC8C + ldr r1, =gFacilityTrainerMons ldr r0, =gFallarborBattleTentMons b _08165DF2 .pool @@ -7286,7 +7286,7 @@ _08165DE8: ldr r1, =gUnknown_0203BC88 ldr r0, =gBattleFrontierTrainers str r0, [r1] - ldr r1, =gUnknown_0203BC8C + ldr r1, =gFacilityTrainerMons ldr r0, =gBattleFrontierMons _08165DF2: str r0, [r1] @@ -7456,7 +7456,7 @@ _08165F44: movs r1, 0xB movs r2, 0 bl GetMonData - ldr r1, =gUnknown_0203BC8C + ldr r1, =gFacilityTrainerMons ldr r2, [r1] lsls r1, r4, 4 adds r1, r2 @@ -7489,7 +7489,7 @@ _08165F7A: movs r1, 0xC movs r2, 0 bl GetMonData - ldr r1, =gUnknown_0203BC8C + ldr r1, =gFacilityTrainerMons ldr r2, [r1] lsls r1, r4, 4 adds r1, r2 @@ -7537,7 +7537,7 @@ _08165FDA: muls r0, r6 ldr r1, =gEnemyParty adds r0, r1 - ldr r5, =gUnknown_0203BC8C + ldr r5, =gFacilityTrainerMons ldr r2, [r5] lsls r4, 4 adds r2, r4, r2 @@ -7603,7 +7603,7 @@ _0816605E: movs r1, 0x20 add r2, sp, 0x14 bl SetMonData - ldr r0, =gUnknown_0203BC8C + ldr r0, =gFacilityTrainerMons ldr r0, [r0] add r0, r9 ldrb r2, [r0, 0xA] @@ -7756,7 +7756,7 @@ sub_8166188: @ 8166188 ands r0, r1 cmp r0, 0 beq _081661E8 - bl sub_8165C40 + bl GetFrontierEnemyMonLevel lsls r0, 24 movs r5, 0 ldr r7, =gBaseStats diff --git a/include/battle_message.h b/include/battle_message.h index 147bfa501c..c686072469 100644 --- a/include/battle_message.h +++ b/include/battle_message.h @@ -224,6 +224,7 @@ extern const u8* const gStatNamesTable[]; extern const u8* const gPokeblockWasTooXStringTable[]; extern const u8* const gRefereeStringsTable[]; extern const u8* const gStatNamesTable2[]; +extern const u8 *const gRoundsStringTable[]; extern const u8 gText_PkmnIsEvolving[]; extern const u8 gText_CongratsPkmnEvolved[]; diff --git a/include/global.h b/include/global.h index 0d2167c475..5b78fc4c04 100644 --- a/include/global.h +++ b/include/global.h @@ -337,14 +337,16 @@ struct FrontierMonData u8 nature; }; -struct FrontierUnkStruct1 +struct BattleDomeTrainer { - u16 unk0:10; + u16 trainerId:10; u16 unk1:1; u16 unk2:2; u16 unk3:3; }; +#define DOME_TOURNAMENT_TRAINERS_COUNT 16 + struct BattleFrontier { /*0x64C*/ struct EmeraldBattleTowerRecord battleTower; @@ -404,8 +406,8 @@ struct BattleFrontier /*0xD21*/ u8 field_D21; /*0xD22*/ u8 field_D22; /*0xD23*/ u8 field_D23; - /*0xD24*/ struct FrontierUnkStruct1 field_D24[16]; - /*0xD64*/ u16 field_D64[16][3]; + /*0xD24*/ struct BattleDomeTrainer domeTrainers[DOME_TOURNAMENT_TRAINERS_COUNT]; + /*0xD64*/ u16 domeMonId[DOME_TOURNAMENT_TRAINERS_COUNT][3]; /*0xDC8*/ u16 field_DC8[2]; /*0xDCC*/ u8 filler_DCC[4]; /*0xDD0*/ u16 field_DD0[2]; diff --git a/src/battle_frontier_1.c b/src/battle_frontier_1.c index b84e919732..3c97215e39 100644 --- a/src/battle_frontier_1.c +++ b/src/battle_frontier_1.c @@ -2,47 +2,56 @@ #include "battle.h" #include "battle_setup.h" #include "battle_frontier_1.h" +#include "battle_message.h" #include "event_data.h" #include "overworld.h" #include "util.h" #include "malloc.h" +#include "string_util.h" +#include "random.h" #include "constants/species.h" +#include "constants/moves.h" +#include "constants/trainers.h" +#include "constants/abilities.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; + u16 species; + u16 moves[4]; + u8 itemTableId; + u8 evSpread; + u8 nature; }; -extern struct Unknown_0203BC8C_Struct *gUnknown_0203BC8C; +extern struct Unknown_0203BC8C_Struct *gFacilityTrainerMons; 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 GetFrontierEnemyMonLevel(void); +extern void sub_8195898(u8 *dst, u16 trainerId); +extern u16 sub_81A5060(u8, u8); extern u8 gUnknown_0203CEF8[]; +extern u32 gUnknown_0203CD70; +extern u32 gUnknown_0203CD74; extern void (* const gUnknown_0860D090[])(void); extern const u32 gUnknown_0860D0EC[][2]; extern const u32 gUnknown_0860D0FC[][2]; +extern const u16 gBattleFrontierHeldItems[]; // This file's functions. -u8 sub_8190168(u16); +u8 GetDomeTrainerMonIvs(u16 trainerId); void sub_818F720(u16 species, s32 level, s32 ivs, u8 evBits, u8 nature, s32 *stats); +void CreateDomeTrainerMons(u16 tournamentTrainerId); +u16 TrainerIdToTournamentId(u16 trainerId); +s32 sub_818FC78(u16 tournamentTrainerId); +s32 sub_818FCBC(u16 tournamentTrainerId, bool8 arg1); +s32 sub_818FDB8(u16 tournamentTrainerId, bool8 arg1); +s32 sub_818FFC0(s32 move, s32 species, s32 arg2); +s32 sub_818FEB4(s32 *arr, bool8 arg1); // code void sub_818E9AC(void) @@ -219,14 +228,14 @@ void sub_818F02C(void) 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; + gSaveBlock2Ptr->frontier.domeTrainers[0].trainerId = 0x3FF; + gSaveBlock2Ptr->frontier.domeTrainers[0].unk1 = 0; + gSaveBlock2Ptr->frontier.domeTrainers[0].unk2 = 0; + gSaveBlock2Ptr->frontier.domeTrainers[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); + gSaveBlock2Ptr->frontier.domeMonId[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++) @@ -247,12 +256,12 @@ void sub_818F02C(void) val = sub_8162548(sub_81A39C4(), 0); for (k = 1; k < l; k++) { - if (gSaveBlock2Ptr->frontier.field_D24[k].unk0 == val) + if (gSaveBlock2Ptr->frontier.domeTrainers[k].trainerId == val) break; } if (k != l) { - gSaveBlock2Ptr->frontier.field_D24[var_28].unk0 = val; + gSaveBlock2Ptr->frontier.domeTrainers[var_28].trainerId = val; break; } } @@ -264,12 +273,12 @@ void sub_818F02C(void) val = sub_8162548(sub_81A39C4() + 1, 0); for (k = 1; k < l; k++) { - if (gSaveBlock2Ptr->frontier.field_D24[k].unk0 == val) + if (gSaveBlock2Ptr->frontier.domeTrainers[k].trainerId == val) break; } if (k != l) { - gSaveBlock2Ptr->frontier.field_D24[var_28].unk0 = val; + gSaveBlock2Ptr->frontier.domeTrainers[var_28].trainerId = val; break; } } @@ -283,24 +292,24 @@ void sub_818F02C(void) val2 = sub_8163524(val); for (i = 0; i < l; i++) { - if (gSaveBlock2Ptr->frontier.field_D64[i] == val2) + if (gSaveBlock2Ptr->frontier.domeMonId[i] == val2) break; - if (var_54 == gUnknown_0203BC8C[val2].field_0) + if (var_54 == gFacilityTrainerMons[val2].field_0) break; - if (var_50 == gUnknown_0203BC8C[val2].field_0) + if (var_50 == gFacilityTrainerMons[val2].field_0) break; - if (gUnknown_0203BC8C[gSaveBlock2Ptr->frontier.field_D64[i]].field_A == gUnknown_0203BC8C[val2].field_A) + if (gFacilityTrainerMons[gSaveBlock2Ptr->frontier.domeMonId[i]].field_A == gFacilityTrainerMons[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.domeMonId[var_24] = val2; + array[var_38] = gFacilityTrainerMons[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; + gSaveBlock2Ptr->frontier.domeTrainers[var_28].unk1 = 0; + gSaveBlock2Ptr->frontier.domeTrainers[var_28].unk2 = 0; + gSaveBlock2Ptr->frontier.domeTrainers[var_28].unk3 = 0; } for (i = 0; i < 3; i++) @@ -323,7 +332,7 @@ void sub_818F02C(void) monTypesBits >>= 1; } - var_48 = sub_8165C40(); + var_48 = GetFrontierEnemyMonLevel(); var_44[0] += (monTypesCount * var_48) / 20; for (i = 0; i < 16; i++) @@ -331,10 +340,10 @@ void sub_818F02C(void) u8 r8; var_44[i + 1] = 0; - r8 = sub_8190168(gSaveBlock2Ptr->frontier.field_D24[i].unk0); + r8 = GetDomeTrainerMonIvs(gSaveBlock2Ptr->frontier.domeTrainers[i].trainerId); for (j = 0; j < 3; j++) { - sub_818F720(gSaveBlock2Ptr->frontier.field_D64[i]); + sub_818F720(gSaveBlock2Ptr->frontier.domeMonId[i]); } } @@ -659,7 +668,7 @@ _0818F2D4:\n\ ldrh r3, [r4]\n\ cmp r3, r6\n\ beq _0818F300\n\ - ldr r2, =gUnknown_0203BC8C\n\ + ldr r2, =gFacilityTrainerMons\n\ ldr r1, [r2]\n\ lsls r0, r6, 4\n\ adds r2, r0, r1\n\ @@ -692,7 +701,7 @@ _0818F300:\n\ ldr r2, [sp, 0x28]\n\ add r2, sp\n\ adds r2, 0x8\n\ - ldr r0, =gUnknown_0203BC8C\n\ + ldr r0, =gFacilityTrainerMons\n\ ldr r1, [r0]\n\ lsls r0, r6, 4\n\ adds r0, r1\n\ @@ -856,7 +865,7 @@ _0818F462:\n\ subs r5, 0x1\n\ cmp r5, 0\n\ bge _0818F458\n\ - bl sub_8165C40\n\ + bl GetFrontierEnemyMonLevel\n\ lsls r0, 24\n\ lsrs r0, 24\n\ str r0, [sp, 0x14]\n\ @@ -888,7 +897,7 @@ _0818F494:\n\ ldrh r0, [r0]\n\ lsls r0, 22\n\ lsrs r0, 22\n\ - bl sub_8190168\n\ + bl GetDomeTrainerMonIvs\n\ lsls r0, 24\n\ lsrs r0, 24\n\ mov r8, r0\n\ @@ -906,7 +915,7 @@ _0818F4BC:\n\ adds r0, r2\n\ adds r0, r4\n\ ldrh r1, [r0]\n\ - ldr r3, =gUnknown_0203BC8C\n\ + ldr r3, =gFacilityTrainerMons\n\ ldr r0, [r3]\n\ lsls r1, 4\n\ adds r1, r0\n\ @@ -940,7 +949,7 @@ _0818F4BC:\n\ adds r0, r1\n\ adds r0, r4\n\ ldrh r0, [r0]\n\ - ldr r2, =gUnknown_0203BC8C\n\ + ldr r2, =gFacilityTrainerMons\n\ ldr r1, [r2]\n\ lsls r0, 4\n\ adds r0, r1\n\ @@ -1228,8 +1237,347 @@ void sub_818F904(s32 id1, s32 id2, u16 *dst) u16 temp; SWAP_16(dst[id1], dst[id2]); - SWAP_16(gSaveBlock2Ptr->frontier.field_D24[id1].unk0, gSaveBlock2Ptr->frontier.field_D24[id2].unk0); + SWAP_16(gSaveBlock2Ptr->frontier.domeTrainers[id1].trainerId, gSaveBlock2Ptr->frontier.domeTrainers[id2].trainerId); for (i = 0; i < 3; i++) - SWAP_16(gSaveBlock2Ptr->frontier.field_D64[id1][i], gSaveBlock2Ptr->frontier.field_D64[id2][i]); + SWAP_16(gSaveBlock2Ptr->frontier.domeMonId[id1][i], gSaveBlock2Ptr->frontier.domeMonId[id2][i]); } + +void sub_818F9B0(void) +{ + StringCopy(gStringVar1, gRoundsStringTable[gSaveBlock2Ptr->frontier.field_CB2]); +} + +void sub_818F9E0(void) +{ + StringCopy(gStringVar1, gRoundsStringTable[gSaveBlock2Ptr->frontier.field_CB2]); + sub_8195898(gStringVar2, gTrainerBattleOpponent_A); +} + +void sub_818FA20(void) +{ + gUnknown_0203CD70 = 0; + gUnknown_0203CD74 = GetMonData(&gPlayerParty[0], MON_DATA_MAX_HP, NULL); + gUnknown_0203CD74 += GetMonData(&gPlayerParty[1], MON_DATA_MAX_HP, NULL); + CalculatePlayerPartyCount(); + CreateDomeTrainerMons(TrainerIdToTournamentId(gTrainerBattleOpponent_A)); +} + +void CreateDomeMon(u8 monPartyId, u16 tournamentTrainerId, u8 tournamentMonId, u32 otId) +{ + s32 i; + u8 happiness = 0xFF; + u8 fixedIv = GetDomeTrainerMonIvs(tournamentTrainerId); // UB: Should be using trainerId instead of tournamentTrainerId. As a result, all Pokemon have ivs of 3. + u8 level = GetFrontierEnemyMonLevel(); + CreateMonWithEVSpreadPersonalityOTID(&gEnemyParty[monPartyId], + gFacilityTrainerMons[gSaveBlock2Ptr->frontier.domeMonId[tournamentTrainerId][tournamentMonId]].species, + level, + gFacilityTrainerMons[gSaveBlock2Ptr->frontier.domeMonId[tournamentTrainerId][tournamentMonId]].nature, + fixedIv, + gFacilityTrainerMons[gSaveBlock2Ptr->frontier.domeMonId[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) + happiness = 0; + } + + SetMonData(&gEnemyParty[monPartyId], MON_DATA_FRIENDSHIP, &happiness); + SetMonData(&gEnemyParty[monPartyId], MON_DATA_HELD_ITEM, + &gBattleFrontierHeldItems[gFacilityTrainerMons[gSaveBlock2Ptr->frontier.domeMonId[tournamentTrainerId][tournamentMonId]].itemTableId]); +} + +void CreateDomeTrainerMons(u16 tournamentTrainerId) +{ + u8 monsCount = 0; + u32 otId = 0; + s32 i, bits; + + ZeroEnemyPartyMons(); + bits = sub_818FC78(tournamentTrainerId); + otId = Random32(); + if (Random() % 10 > 5) + { + for (i = 0; i < 3; i++) + { + if (bits & 1) + { + CreateDomeMon(monsCount, tournamentTrainerId, i, otId); + monsCount++; + } + bits >>= 1; + } + } + else + { + for (i = 2; i >= 0; i--) + { + if (bits & 4) + { + CreateDomeMon(monsCount, tournamentTrainerId, i, otId); + monsCount++; + } + bits <<= 1; + } + } +} + +s32 sub_818FC78(u16 tournamentTrainerId) +{ + s32 bits; + if (Random() & 1) + { + bits = sub_818FCBC(tournamentTrainerId, FALSE); + if (bits == 0) + bits = sub_818FDB8(tournamentTrainerId, TRUE); + } + else + { + bits = sub_818FDB8(tournamentTrainerId, FALSE); + if (bits == 0) + bits = sub_818FCBC(tournamentTrainerId, TRUE); + } + + return bits; +} + +s32 sub_818FCBC(u16 tournamentTrainerId, bool8 arg1) +{ + s32 i, moveId, playerMonId; + s32 array[3]; + + for (i = 0; i < 3; i++) + { + array[i] = 0; + for (moveId = 0; moveId < 4; moveId++) + { + for (playerMonId = 0; playerMonId < 3; playerMonId++) + { + if (gSaveBlock2Ptr->frontier.domeTrainers[tournamentTrainerId].trainerId == TRAINER_FRONTIER_BRAIN) + { + array[i] += sub_818FFC0(sub_81A5060(i, moveId), + GetMonData(&gPlayerParty[playerMonId], MON_DATA_SPECIES, NULL), 0); + } + else + { + array[i] += sub_818FFC0(gFacilityTrainerMons[gSaveBlock2Ptr->frontier.domeMonId[tournamentTrainerId][i]].moves[moveId], + GetMonData(&gPlayerParty[playerMonId], MON_DATA_SPECIES, NULL), 0); + } + } + } + } + return sub_818FEB4(array, arg1); +} + +s32 sub_818FDB8(u16 tournamentTrainerId, bool8 arg1) +{ + s32 i, moveId, playerMonId; + s32 array[3]; + + for (i = 0; i < 3; i++) + { + array[i] = 0; + for (moveId = 0; moveId < 4; moveId++) + { + for (playerMonId = 0; playerMonId < 3; playerMonId++) + { + if (gSaveBlock2Ptr->frontier.domeTrainers[tournamentTrainerId].trainerId == TRAINER_FRONTIER_BRAIN) + { + array[i] += sub_818FFC0(sub_81A5060(i, moveId), + GetMonData(&gPlayerParty[playerMonId], MON_DATA_SPECIES, NULL), 1); + } + else + { + array[i] += sub_818FFC0(gFacilityTrainerMons[gSaveBlock2Ptr->frontier.domeMonId[tournamentTrainerId][i]].moves[moveId], + GetMonData(&gPlayerParty[playerMonId], MON_DATA_SPECIES, NULL), 1); + } + } + } + } + return sub_818FEB4(array, arg1); +} + +s32 sub_818FEB4(s32 *arr, bool8 arg1) +{ + s32 i, j; + s32 bits = 0; + s32 array[3]; + + for (i = 0; i < 3; i++) + array[i] = i; + + if (arr[0] == arr[1] && arr[0] == arr[2]) + { + if (arg1) + { + i = 0; + while (i != 2) + { + u32 rand = Random() & 3; + if (rand != 3 && !(bits & gBitTable[rand])) + { + bits |= gBitTable[rand]; + i++; + } + } + } + } + else + { + for (i = 0; i < 2; i++) + { + for (j = i + 1; j < 3; j++) + { + s32 temp; + + if (arr[i] < arr[j]) + { + temp = arr[i]; + arr[i] = arr[j]; + arr[j] = temp; + + temp = array[i]; + array[i] = array[j]; + array[j] = temp; + } + + if (arr[i] == arr[j] && (Random() & 1)) + { + temp = arr[i]; + arr[i] = arr[j]; + arr[j] = temp; + + temp = array[i]; + array[i] = array[j]; + array[j] = temp; + } + } + } + + for (i = 0; i < 2; i++) + { + bits |= gBitTable[array[i]]; + } + } + + return bits; +} + +/* +s32 sub_818FFC0(s32 move, s32 species, s32 arg2) +{ + u8 type1, type2, ability, moveType; + s32 i = 0; + s32 typePower = 20; + + if (move == MOVE_NONE || move == 0xFFFF || gBattleMoves[move].power == 0) + return 0; + + type1 = gBaseStats[species].type1; + type2 = gBaseStats[species].type2; + ability = gBaseStats[species].ability1; + moveType = gBattleMoves[move].type; + + if (ability == ABILITY_LEVITATE && moveType == TYPE_GROUND) + { + if (arg2 == 1) + typePower = 8; + } + else + { + while (TYPE_EFFECT_ATK_TYPE(i) != TYPE_ENDTABLE) + { + if (TYPE_EFFECT_ATK_TYPE(i) == TYPE_FORESIGHT) + { + i += 3; + continue; + } + else if (TYPE_EFFECT_ATK_TYPE(i) == moveType) + { + // BUG: * 2 is not necessary and makes the condition always false if the ability is wonder guard. + if (TYPE_EFFECT_DEF_TYPE(i) == type1 && (ability != ABILITY_WONDER_GUARD || TYPE_EFFECT_MULTIPLIER(i) == TYPE_MUL_SUPER_EFFECTIVE * 2)) + typePower = (TYPE_EFFECT_MULTIPLIER(i) * typePower) / 10; + if (TYPE_EFFECT_DEF_TYPE(i) == type2 && type1 != type2 && (ability != ABILITY_WONDER_GUARD || TYPE_EFFECT_MULTIPLIER(i) == TYPE_MUL_SUPER_EFFECTIVE * 2)) + typePower = (TYPE_EFFECT_MULTIPLIER(i) * typePower) / 10; + } + i += 3; + } + } + + switch (arg2) + { + case 0: + switch (typePower) + { + case 10: + case 5: + case 0: + default: + typePower = 0; + break; + case 20: + typePower = 2; + break; + case 40: + typePower = 4; + break; + case 80: + typePower = 8; + break; + } + break; + case 1: + switch (typePower) + { + default: + case 20: + typePower = 0; + break; + case 5: + typePower = 4; + break; + case 0: + typePower = 8; + break; + case 10: + typePower = 2; + break; + case 40: + typePower = -2; + break; + case 80: + typePower = -4; + break; + } + break; + case 2: + switch (typePower) + { + case 0: + typePower = -16; + break; + case 5: + typePower = -8; + break; + case 10: + default: + typePower = 0; + break; + case 20: + typePower = 4; + break; + case 40: + typePower = 12; + break; + case 80: + typePower = 20; + break; + } + break; + } + + return typePower; +}*/ diff --git a/src/battle_message.c b/src/battle_message.c index 13502d6f20..78b9ac53b4 100644 --- a/src/battle_message.c +++ b/src/battle_message.c @@ -1248,7 +1248,7 @@ static const u8 sText_Round2[] = _("Round 2"); static const u8 sText_Semifinal[] = _("Semifinal"); static const u8 sText_Final[] = _("Final"); -const u8 * const gRoundsStringTable[] = +const u8 *const gRoundsStringTable[] = { sText_Round1, sText_Round2, diff --git a/sym_ewram.txt b/sym_ewram.txt index cf1c8b8d7f..cb887bd901 100644 --- a/sym_ewram.txt +++ b/sym_ewram.txt @@ -615,7 +615,7 @@ gUnknown_0203ABB8: @ 203ABB8 gUnknown_0203BC88: @ 203BC88 .space 0x4 -gUnknown_0203BC8C: @ 203BC8C +gFacilityTrainerMons: @ 203BC8C .space 0x4 .include "src/use_pokeblock.o"