diff --git a/asm/battle_2.s b/asm/battle_2.s index 2ff446dd0..5f970d766 100644 --- a/asm/battle_2.s +++ b/asm/battle_2.s @@ -4,1721 +4,6 @@ .syntax unified .text - - - thumb_func_start sub_803BDA0 -sub_803BDA0: @ 803BDA0 - push {r4-r7,lr} - mov r7, r8 - push {r7} - lsls r0, 24 - lsrs r5, r0, 24 - movs r3, 0 - ldr r0, =gBattlePartyID - mov r8, r0 - ldr r1, =gUnknown_0203CF00 - mov r12, r1 - ldr r7, =gBattleStruct - lsls r0, r5, 1 - adds r4, r0, r5 - adds r6, r0, 0 -_0803BDBC: - mov r0, r12 - adds r2, r3, r0 - ldr r1, [r7] - adds r0, r4, r3 - adds r0, r1 - adds r0, 0x60 - ldrb r0, [r0] - strb r0, [r2] - adds r3, 0x1 - cmp r3, 0x2 - ble _0803BDBC - mov r1, r8 - adds r0, r6, r1 - ldrb r0, [r0] - bl pokemon_order_func - adds r4, r0, 0 - lsls r4, 24 - lsrs r4, 24 - ldr r7, =gBattleStruct - ldr r0, [r7] - adds r0, r5, r0 - adds r0, 0x5C - ldrb r0, [r0] - bl pokemon_order_func - adds r1, r0, 0 - lsls r1, 24 - lsrs r1, 24 - adds r0, r4, 0 - bl sub_81B8FB0 - ldr r0, =gBattleTypeFlags - ldr r0, [r0] - movs r1, 0x1 - ands r0, r1 - cmp r0, 0 - beq _0803BE4C - movs r3, 0 - adds r4, r7, 0 - adds r6, r5 - movs r0, 0x2 - adds r1, r5, 0 - eors r1, r0 - ldr r7, =gUnknown_0203CF00 - lsls r0, r1, 1 - adds r5, r0, r1 -_0803BE1A: - ldr r0, [r4] - adds r1, r6, r3 - adds r1, r0 - adds r1, 0x60 - adds r2, r3, r7 - ldrb r0, [r2] - strb r0, [r1] - ldr r1, [r4] - adds r0, r5, r3 - adds r0, r1 - adds r0, 0x60 - ldrb r1, [r2] - strb r1, [r0] - adds r3, 0x1 - cmp r3, 0x2 - ble _0803BE1A - b _0803BE66 - .pool -_0803BE4C: - movs r3, 0 - adds r2, r6, r5 - ldr r4, =gUnknown_0203CF00 -_0803BE52: - ldr r0, [r7] - adds r1, r2, r3 - adds r1, r0 - adds r1, 0x60 - adds r0, r3, r4 - ldrb r0, [r0] - strb r0, [r1] - adds r3, 0x1 - cmp r3, 0x2 - ble _0803BE52 -_0803BE66: - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_803BDA0 - - thumb_func_start sub_803BE74 -sub_803BE74: @ 803BE74 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0x1C - ldr r0, =gBattleCommunication - movs r1, 0 - strb r1, [r0, 0x4] - ldr r0, =gActiveBank - strb r1, [r0] - ldr r0, =gNoOfAllBanks - bl _0803CD12 - .pool -_0803BE9C: - ldr r4, =gActiveBank - ldrb r0, [r4] - bl GetBankIdentity - lsls r0, 24 - lsrs r5, r0, 24 - ldr r1, =gBattleCommunication - ldrb r0, [r4] - adds r0, r1 - ldrb r0, [r0] - cmp r0, 0x8 - bls _0803BEB8 - bl _0803CD04 -_0803BEB8: - lsls r0, 2 - ldr r1, =_0803BED0 - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .pool - .align 2, 0 -_0803BED0: - .4byte _0803BEF4 - .4byte _0803BF0C - .4byte _0803C02C - .4byte _0803C7D8 - .4byte _0803CAD0 - .4byte _0803CB84 - .4byte _0803CBC8 - .4byte _0803CBF4 - .4byte _0803CC38 -_0803BEF4: - bl sub_8185FD0 - ldr r1, =gBattleCommunication - ldr r0, =gActiveBank - ldrb r0, [r0] - adds r0, r1 - bl _0803CC20 - .pool -_0803BF0C: - ldr r0, =gActiveBank - ldrb r1, [r0] - ldr r4, =gBattleStruct - ldr r0, [r4] - adds r1, r0 - adds r1, 0x5C - movs r0, 0x6 - strb r0, [r1] - ldr r0, =gBattleTypeFlags - ldr r0, [r0] - movs r1, 0x40 - ands r0, r1 - cmp r0, 0 - bne _0803BF68 - movs r1, 0x2 - movs r0, 0x2 - ands r0, r5 - cmp r0, 0 - beq _0803BF68 - eors r5, r1 - adds r0, r5, 0 - bl GetBankByIdentity - ldr r1, [r4] - adds r1, 0x91 - ldrb r1, [r1] - ldr r2, =gBitTable - lsls r0, 24 - lsrs r0, 22 - adds r0, r2 - ldr r0, [r0] - ands r1, r0 - cmp r1, 0 - bne _0803BF68 - ldr r4, =gBattleCommunication - adds r0, r5, 0 - bl GetBankByIdentity - lsls r0, 24 - lsrs r0, 24 - adds r0, r4 - ldrb r0, [r0] - cmp r0, 0x5 - beq _0803BF68 - bl _0803CD04 -_0803BF68: - ldr r0, =gBattleStruct - ldr r0, [r0] - adds r0, 0x91 - ldrb r3, [r0] - ldr r1, =gBitTable - ldr r4, =gActiveBank - ldrb r2, [r4] - lsls r0, r2, 2 - adds r0, r1 - ldr r0, [r0] - ands r3, r0 - cmp r3, 0 - beq _0803BFD0 - ldr r0, =gActionForBanks - adds r0, r2, r0 - movs r1, 0xD - strb r1, [r0] - ldr r0, =gBattleTypeFlags - ldr r0, [r0] - movs r1, 0x40 - ands r0, r1 - cmp r0, 0 - bne _0803BFBC - ldr r0, =gBattleCommunication - ldrb r1, [r4] - adds r1, r0 - movs r0, 0x5 - strb r0, [r1] - bl _0803CD04 - .pool -_0803BFBC: - ldr r0, =gBattleCommunication - ldrb r1, [r4] - adds r1, r0 - movs r0, 0x4 - strb r0, [r1] - bl _0803CD04 - .pool -_0803BFD0: - ldr r1, =gBattleMons - movs r0, 0x58 - muls r0, r2 - adds r1, 0x50 - adds r0, r1 - ldr r1, [r0] - movs r0, 0x80 - lsls r0, 5 - ands r0, r1 - cmp r0, 0 - bne _0803BFF0 - movs r0, 0x80 - lsls r0, 15 - ands r1, r0 - cmp r1, 0 - beq _0803C00C -_0803BFF0: - ldr r0, =gActionForBanks - adds r0, r2, r0 - strb r3, [r0] - ldr r1, =gBattleCommunication - ldrb r0, [r4] - bl _0803CC72 - .pool -_0803C00C: - ldr r0, =gActionForBanks - ldrb r1, [r0] - ldr r0, =gBattleBufferB - ldrb r2, [r0, 0x1] - ldrb r0, [r0, 0x2] - lsls r0, 8 - orrs r2, r0 - movs r0, 0 - bl dp01_build_cmdbuf_x12_a_bb - bl _0803CB68 - .pool -_0803C02C: - ldr r3, =gBattleExecBuffer - ldr r1, =gBitTable - ldr r6, =gActiveBank - ldrb r5, [r6] - lsls r0, r5, 2 - adds r0, r1 - ldr r2, [r0] - lsls r1, r2, 4 - movs r0, 0xF0 - lsls r0, 24 - orrs r1, r0 - orrs r1, r2 - lsls r0, r2, 8 - orrs r1, r0 - lsls r2, 12 - orrs r1, r2 - ldr r0, [r3] - ands r0, r1 - cmp r0, 0 - beq _0803C058 - bl _0803CD04 -_0803C058: - ldr r4, =gBattleBufferB - lsls r0, r5, 9 - adds r4, 0x1 - adds r0, r4 - ldrb r1, [r0] - adds r0, r5, 0 - bl RecordedBattle_SetBankAction - ldr r1, =gActionForBanks - ldrb r0, [r6] - adds r1, r0, r1 - lsls r0, 9 - adds r0, r4 - ldrb r0, [r0] - strb r0, [r1] - ldrb r0, [r6] - lsls r0, 9 - adds r0, r4 - ldrb r0, [r0] - cmp r0, 0xC - bls _0803C084 - b _0803C6C4 -_0803C084: - lsls r0, 2 - ldr r1, =_0803C0A8 - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .pool - .align 2, 0 -_0803C0A8: - .4byte _0803C0DC - .4byte _0803C230 - .4byte _0803C268 - .4byte _0803C6C4 - .4byte _0803C6C4 - .4byte _0803C440 - .4byte _0803C48C - .4byte _0803C6C4 - .4byte _0803C6C4 - .4byte _0803C6C4 - .4byte _0803C6C4 - .4byte _0803C6C4 - .4byte _0803C4B4 -_0803C0DC: - bl AreAllMovesUnusable - lsls r0, 24 - cmp r0, 0 - beq _0803C134 - ldr r0, =gBattleCommunication - ldr r3, =gActiveBank - ldrb r1, [r3] - adds r1, r0 - movs r4, 0 - movs r0, 0x6 - strb r0, [r1] - ldrb r1, [r3] - ldr r2, =gBattleStruct - ldr r0, [r2] - adds r1, r0 - adds r1, 0x54 - strb r4, [r1] - ldrb r1, [r3] - ldr r0, [r2] - adds r1, r0 - adds r1, 0x84 - movs r0, 0x4 - strb r0, [r1] - ldrb r1, [r3] - ldr r2, [r2] - adds r2, r1, r2 - ldr r0, =gBattleBufferB - lsls r1, 9 - adds r0, 0x3 - adds r1, r0 - ldrb r0, [r1] - strb r0, [r2, 0xC] - bl _0803CD70 - .pool -_0803C134: - ldr r3, =gDisableStructs - ldr r5, =gActiveBank - ldrb r4, [r5] - lsls r0, r4, 3 - subs r0, r4 - lsls r0, 2 - adds r0, r3 - ldrh r2, [r0, 0x6] - cmp r2, 0 - beq _0803C188 - ldr r1, =gChosenMovesByBanks - lsls r0, r4, 1 - adds r0, r1 - strh r2, [r0] - ldrb r2, [r5] - ldr r0, =gBattleStruct - ldr r1, [r0] - adds r1, r2, r1 - adds r1, 0x80 - lsls r0, r2, 3 - subs r0, r2 - lsls r0, 2 - adds r0, r3 - ldrb r0, [r0, 0xC] - strb r0, [r1] - ldr r1, =gBattleCommunication - ldrb r0, [r5] - adds r0, r1 - movs r1, 0x4 - strb r1, [r0] - bl _0803CD70 - .pool -_0803C188: - add r2, sp, 0x4 - ldr r3, =gBattleMons - movs r1, 0x58 - adds r0, r4, 0 - muls r0, r1 - adds r0, r3 - ldrh r0, [r0] - strh r0, [r2, 0x10] - ldrb r0, [r5] - muls r0, r1 - adds r0, r3 - adds r0, 0x21 - ldrb r0, [r0] - strb r0, [r2, 0x12] - ldrb r0, [r5] - muls r0, r1 - adds r0, r3 - adds r0, 0x22 - ldrb r0, [r0] - strb r0, [r2, 0x13] - movs r4, 0 - mov r1, sp - adds r1, 0xC - str r1, [sp, 0x18] - add r2, sp, 0x10 - mov r10, r2 - mov r8, r3 - adds r7, r5, 0 - movs r6, 0x58 - movs r0, 0xC - add r0, r8 - mov r9, r0 - add r5, sp, 0x4 -_0803C1CA: - lsls r2, r4, 1 - ldrb r0, [r7] - muls r0, r6 - adds r0, r2, r0 - add r0, r9 - ldrh r0, [r0] - strh r0, [r5] - ldr r1, [sp, 0x18] - adds r3, r1, r4 - ldrb r0, [r7] - muls r0, r6 - adds r0, r4, r0 - mov r1, r8 - adds r1, 0x24 - adds r0, r1 - ldrb r0, [r0] - strb r0, [r3] - ldrb r0, [r7] - adds r1, r0, 0 - muls r1, r6 - adds r2, r1 - add r2, r9 - ldrh r0, [r2] - add r1, r8 - adds r1, 0x3B - ldrb r1, [r1] - lsls r2, r4, 24 - lsrs r2, 24 - bl CalculatePPWithBonus - mov r2, r10 - adds r1, r2, r4 - strb r0, [r1] - adds r5, 0x2 - adds r4, 0x1 - cmp r4, 0x3 - ble _0803C1CA - ldr r0, =gBattleTypeFlags - ldr r1, [r0] - movs r0, 0x1 - ands r1, r0 - movs r0, 0 - movs r2, 0 - add r3, sp, 0x4 - bl sub_8033E30 - b _0803C42E - .pool -_0803C230: - ldr r0, =gBattleTypeFlags - ldr r0, [r0] - ldr r1, =0x021f0902 - ands r0, r1 - cmp r0, 0 - bne _0803C23E - b _0803C48C -_0803C23E: - ldr r4, =gActiveBank - ldrb r0, [r4] - movs r1, 0x1 - bl sub_8185008 - ldr r1, =gUnknown_02024220 - ldrb r0, [r4] - lsls r0, 2 - adds r0, r1 - ldr r1, =gUnknown_082DB879 - b _0803C784 - .pool -_0803C268: - ldr r5, =gActiveBank - ldrb r0, [r5] - ldr r3, =gBattleStruct - ldr r1, [r3] - adds r1, r0, r1 - adds r1, 0x58 - ldr r2, =gBattlePartyID - lsls r0, 1 - adds r0, r2 - ldrh r0, [r0] - strb r0, [r1] - ldr r7, =gBattleMons - ldrb r2, [r5] - movs r6, 0x58 - adds r0, r2, 0 - muls r0, r6 - adds r1, r7, 0 - adds r1, 0x50 - adds r0, r1 - ldr r1, [r0] - ldr r0, =0x0400e000 - ands r1, r0 - cmp r1, 0 - bne _0803C2B8 - ldr r0, =gBattleTypeFlags - ldr r0, [r0] - movs r1, 0x80 - lsls r1, 11 - ands r0, r1 - cmp r0, 0 - bne _0803C2B8 - ldr r0, =gStatuses3 - lsls r1, r2, 2 - adds r1, r0 - ldr r1, [r1] - movs r0, 0x80 - lsls r0, 3 - ands r1, r0 - cmp r1, 0 - beq _0803C2EC -_0803C2B8: - ldr r0, =gActiveBank - ldrb r0, [r0] - lsls r1, r0, 1 - adds r1, r0 - adds r1, 0x60 - ldr r0, [r3] - adds r0, r1 - str r0, [sp] - movs r0, 0 - movs r1, 0x2 - movs r2, 0x6 - b _0803C400 - .pool -_0803C2EC: - str r1, [sp] - movs r0, 0xC - adds r1, r2, 0 - movs r2, 0x17 - movs r3, 0 - bl AbilityBattleEffects - lsls r0, 24 - lsrs r4, r0, 24 - cmp r4, 0 - bne _0803C374 - ldrb r1, [r5] - str r4, [sp] - movs r0, 0xC - movs r2, 0x47 - movs r3, 0 - bl AbilityBattleEffects - lsls r0, 24 - lsrs r4, r0, 24 - cmp r4, 0 - beq _0803C33C - ldrb r0, [r5] - muls r0, r6 - adds r1, r0, r7 - adds r0, r1, 0 - adds r0, 0x21 - ldrb r0, [r0] - cmp r0, 0x2 - beq _0803C33C - adds r0, r1, 0 - adds r0, 0x22 - ldrb r0, [r0] - cmp r0, 0x2 - beq _0803C33C - adds r0, r1, 0 - adds r0, 0x20 - ldrb r0, [r0] - cmp r0, 0x1A - bne _0803C374 -_0803C33C: - ldr r5, =gActiveBank - ldrb r1, [r5] - movs r0, 0 - str r0, [sp] - movs r0, 0xF - movs r2, 0x2A - movs r3, 0 - bl AbilityBattleEffects - lsls r0, 24 - lsrs r4, r0, 24 - cmp r4, 0 - beq _0803C3B0 - ldr r2, =gBattleMons - ldrb r1, [r5] - movs r0, 0x58 - muls r0, r1 - adds r1, r0, r2 - adds r0, r1, 0 - adds r0, 0x21 - ldrb r0, [r0] - cmp r0, 0x8 - beq _0803C374 - adds r0, r1, 0 - adds r0, 0x22 - ldrb r0, [r0] - cmp r0, 0x8 - bne _0803C3B0 -_0803C374: - subs r1, r4, 0x1 - lsls r1, 4 - movs r0, 0x4 - orrs r1, r0 - lsls r1, 24 - lsrs r1, 24 - ldr r0, =gLastUsedAbility - ldrb r3, [r0] - ldr r4, =gBattleStruct - ldr r0, =gActiveBank - ldrb r0, [r0] - lsls r2, r0, 1 - adds r2, r0 - adds r2, 0x60 - ldr r0, [r4] - adds r0, r2 - str r0, [sp] - movs r0, 0 - movs r2, 0x6 - bl EmitChoosePokemon - b _0803C42E - .pool -_0803C3B0: - ldr r0, =gActiveBank - ldrb r1, [r0] - adds r4, r0, 0 - cmp r1, 0x2 - bne _0803C3D8 - ldr r0, =gActionForBanks - ldrb r0, [r0] - cmp r0, 0x2 - bne _0803C3D8 - ldr r0, =gBattleStruct - ldr r3, [r0] - adds r0, r3, 0 - adds r0, 0x5C - b _0803C3EE - .pool -_0803C3D8: - ldrb r0, [r4] - cmp r0, 0x3 - bne _0803C410 - ldr r0, =gActionForBanks - ldrb r0, [r0, 0x1] - cmp r0, 0x2 - bne _0803C410 - ldr r0, =gBattleStruct - ldr r3, [r0] - adds r0, r3, 0 - adds r0, 0x5D -_0803C3EE: - ldrb r2, [r0] - ldrb r1, [r4] - lsls r0, r1, 1 - adds r0, r1 - adds r0, 0x60 - adds r3, r0 - str r3, [sp] - movs r0, 0 - movs r1, 0 -_0803C400: - movs r3, 0 - bl EmitChoosePokemon - b _0803C42E - .pool -_0803C410: - ldr r2, =gBattleStruct - ldr r0, =gActiveBank - ldrb r0, [r0] - lsls r1, r0, 1 - adds r1, r0 - adds r1, 0x60 - ldr r0, [r2] - adds r0, r1 - str r0, [sp] - movs r0, 0 - movs r1, 0 - movs r2, 0x6 - movs r3, 0 - bl EmitChoosePokemon -_0803C42E: - ldr r0, =gActiveBank - ldrb r0, [r0] - bl MarkBufferBankForExecution - b _0803C6C4 - .pool -_0803C440: - bl IsPlayerPartyAndPokemonStorageFull - lsls r0, 24 - cmp r0, 0 - bne _0803C44C - b _0803C6C4 -_0803C44C: - ldr r1, =gUnknown_02024220 - ldr r3, =gActiveBank - ldrb r0, [r3] - lsls r0, 2 - adds r0, r1 - ldr r1, =gUnknown_082DAB11 - str r1, [r0] - ldr r0, =gBattleCommunication - ldrb r1, [r3] - adds r1, r0 - movs r4, 0 - movs r0, 0x6 - strb r0, [r1] - ldrb r1, [r3] - ldr r2, =gBattleStruct - ldr r0, [r2] - adds r1, r0 - adds r1, 0x54 - strb r4, [r1] - ldrb r1, [r3] - b _0803C7A0 - .pool -_0803C48C: - ldr r2, =gBattleStruct - ldr r4, =gActiveBank - ldrb r1, [r4] - lsls r0, r1, 1 - adds r0, r1 - adds r0, 0x60 - ldr r1, [r2] - adds r1, r0 - movs r0, 0 - bl sub_8033E6C - ldrb r0, [r4] - bl MarkBufferBankForExecution - b _0803C6C4 - .pool -_0803C4B4: - ldr r4, =gBattleCommunication - ldr r5, =gActiveBank - ldrb r0, [r5] - adds r0, r4 - movs r1, 0x7 - strb r1, [r0] - ldrb r0, [r5] - bl GetBankIdentity - movs r6, 0x2 - eors r0, r6 - lsls r0, 24 - lsrs r0, 24 - bl GetBankByIdentity - lsls r0, 24 - lsrs r0, 24 - adds r0, r4 - movs r1, 0x1 - strb r1, [r0] - ldrb r0, [r5] - bl sub_8185008 - ldrb r0, [r5] - bl GetBankIdentity - eors r0, r6 - lsls r0, 24 - lsrs r0, 24 - bl GetBankByIdentity - ldr r1, =gBattleMons - lsls r0, 24 - lsrs r0, 24 - movs r7, 0x58 - muls r0, r7 - adds r4, r1, 0 - adds r4, 0x50 - adds r0, r4 - ldr r0, [r0] - movs r1, 0x80 - lsls r1, 5 - ands r0, r1 - cmp r0, 0 - bne _0803C532 - ldrb r0, [r5] - bl GetBankIdentity - eors r0, r6 - lsls r0, 24 - lsrs r0, 24 - bl GetBankByIdentity - lsls r0, 24 - lsrs r0, 24 - muls r0, r7 - adds r0, r4 - ldr r0, [r0] - movs r1, 0x80 - lsls r1, 15 - ands r0, r1 - cmp r0, 0 - beq _0803C550 -_0803C532: - movs r0, 0 - bl dp01_build_cmdbuf_x32_32_32_32 - ldrb r0, [r5] - bl MarkBufferBankForExecution - bl _0803CD70 - .pool -_0803C550: - ldr r4, =gActionForBanks - ldrb r0, [r5] - bl GetBankIdentity - eors r0, r6 - lsls r0, 24 - lsrs r0, 24 - bl GetBankByIdentity - lsls r0, 24 - lsrs r0, 24 - adds r0, r4 - ldrb r0, [r0] - cmp r0, 0x2 - bne _0803C590 - ldrb r0, [r5] - bl GetBankIdentity - eors r0, r6 - lsls r0, 24 - lsrs r0, 24 - bl GetBankByIdentity - lsls r0, 24 - lsrs r0, 24 - movs r1, 0x2 - bl sub_8185008 - b _0803C6AE - .pool -_0803C590: - ldrb r0, [r5] - bl GetBankIdentity - eors r0, r6 - lsls r0, 24 - lsrs r0, 24 - bl GetBankByIdentity - lsls r0, 24 - lsrs r0, 24 - adds r0, r4 - ldrb r0, [r0] - cmp r0, 0x3 - bne _0803C5B6 - ldrb r0, [r5] - bl GetBankIdentity - eors r0, r6 - b _0803C668 -_0803C5B6: - ldrb r0, [r5] - bl GetBankIdentity - eors r0, r6 - lsls r0, 24 - lsrs r0, 24 - bl GetBankByIdentity - lsls r0, 24 - lsrs r0, 24 - adds r0, r4 - ldrb r0, [r0] - cmp r0, 0 - bne _0803C628 - ldr r4, =gProtectStructs - ldrb r0, [r5] - bl GetBankIdentity - eors r0, r6 - lsls r0, 24 - lsrs r0, 24 - bl GetBankByIdentity - lsls r0, 24 - lsrs r0, 20 - adds r0, r4 - ldrb r0, [r0] - lsls r0, 29 - cmp r0, 0 - blt _0803C616 - ldr r4, =gDisableStructs - ldrb r0, [r5] - bl GetBankIdentity - eors r0, r6 - lsls r0, 24 - lsrs r0, 24 - bl GetBankByIdentity - lsls r0, 24 - lsrs r0, 24 - lsls r1, r0, 3 - subs r1, r0 - lsls r1, 2 - adds r1, r4 - ldrh r0, [r1, 0x6] - cmp r0, 0 - beq _0803C628 -_0803C616: - ldrb r0, [r5] - bl GetBankIdentity - eors r0, r6 - b _0803C668 - .pool -_0803C628: - ldr r0, =gBattleTypeFlags - ldr r0, [r0] - movs r1, 0x80 - lsls r1, 10 - ands r0, r1 - cmp r0, 0 - beq _0803C690 - ldr r4, =gActionForBanks - ldr r6, =gActiveBank - ldrb r0, [r6] - bl GetBankIdentity - movs r5, 0x2 - eors r0, r5 - lsls r0, 24 - lsrs r0, 24 - bl GetBankByIdentity - lsls r0, 24 - lsrs r0, 24 - adds r0, r4 - ldrb r0, [r0] - cmp r0, 0 - bne _0803C690 - ldr r1, =gRngValue - ldr r0, =gUnknown_0203BD30 - ldr r0, [r0] - str r0, [r1] - ldrb r0, [r6] - bl GetBankIdentity - eors r0, r5 -_0803C668: - lsls r0, 24 - lsrs r0, 24 - bl GetBankByIdentity - lsls r0, 24 - lsrs r0, 24 - movs r1, 0x1 - bl sub_8185008 - b _0803C6AE - .pool -_0803C690: - ldr r0, =gActiveBank - ldrb r0, [r0] - bl GetBankIdentity - movs r1, 0x2 - eors r0, r1 - lsls r0, 24 - lsrs r0, 24 - bl GetBankByIdentity - lsls r0, 24 - lsrs r0, 24 - movs r1, 0x3 - bl sub_8185008 -_0803C6AE: - movs r0, 0 - bl dp01_build_cmdbuf_x32_32_32_32 - ldr r0, =gActiveBank - ldrb r0, [r0] - bl MarkBufferBankForExecution - b _0803CD70 - .pool -_0803C6C4: - ldr r1, =gBattleTypeFlags - ldr r2, [r1] - movs r5, 0x8 - adds r0, r2, 0 - ands r0, r5 - adds r3, r1, 0 - cmp r0, 0 - beq _0803C720 - ldr r0, =0x043f0100 - ands r2, r0 - cmp r2, 0 - beq _0803C720 - ldr r0, =gBattleBufferB - ldr r4, =gActiveBank - ldrb r2, [r4] - lsls r1, r2, 9 - adds r0, 0x1 - adds r1, r0 - ldrb r0, [r1] - cmp r0, 0x3 - bne _0803C720 - ldr r1, =gUnknown_02024220 - lsls r0, r2, 2 - adds r0, r1 - ldr r1, =gUnknown_082DB9BA - str r1, [r0] - ldr r1, =gBattleCommunication - ldrb r0, [r4] - adds r0, r1 - movs r3, 0 - strb r5, [r0] - b _0803C792 - .pool -_0803C720: - ldr r0, [r3] - ldr r1, =0x0200000a - ands r0, r1 - cmp r0, 0x8 - bne _0803C760 - ldr r0, =gBattleBufferB - ldr r4, =gActiveBank - ldrb r1, [r4] - lsls r1, 9 - adds r0, 0x1 - adds r1, r0 - ldrb r0, [r1] - cmp r0, 0x3 - bne _0803C760 - ldr r0, =gUnknown_082DAAFE - bl BattleScriptExecute - ldr r1, =gBattleCommunication - ldrb r0, [r4] - adds r0, r1 - b _0803CC20 - .pool -_0803C760: - bl IsRunningFromBattleImpossible - lsls r0, 24 - cmp r0, 0 - beq _0803C7C4 - ldr r0, =gBattleBufferB - ldr r4, =gActiveBank - ldrb r2, [r4] - lsls r1, r2, 9 - adds r0, 0x1 - adds r1, r0 - ldrb r0, [r1] - cmp r0, 0x3 - bne _0803C7C4 - ldr r1, =gUnknown_02024220 - lsls r0, r2, 2 - adds r0, r1 - ldr r1, =gUnknown_082DAB0B -_0803C784: - str r1, [r0] - ldr r0, =gBattleCommunication - ldrb r1, [r4] - adds r1, r0 - movs r3, 0 - movs r0, 0x6 - strb r0, [r1] -_0803C792: - ldrb r1, [r4] - ldr r2, =gBattleStruct - ldr r0, [r2] - adds r1, r0 - adds r1, 0x54 - strb r3, [r1] - ldrb r1, [r4] -_0803C7A0: - ldr r0, [r2] - adds r1, r0 - adds r1, 0x84 - movs r0, 0x1 - strb r0, [r1] - b _0803CD70 - .pool -_0803C7C4: - ldr r2, =gBattleCommunication - ldr r0, =gActiveBank - ldrb r1, [r0] - adds r1, r2 - b _0803CB74 - .pool -_0803C7D8: - ldr r4, =gBattleExecBuffer - ldr r1, =gBitTable - ldr r3, =gActiveBank - ldrb r5, [r3] - lsls r0, r5, 2 - adds r0, r1 - ldr r2, [r0] - lsls r0, r2, 4 - movs r1, 0xF0 - lsls r1, 24 - orrs r0, r1 - orrs r0, r2 - lsls r1, r2, 8 - orrs r0, r1 - lsls r2, 12 - orrs r0, r2 - ldr r1, [r4] - ands r1, r0 - adds r4, r3, 0 - cmp r1, 0 - beq _0803C804 - b _0803CD04 -_0803C804: - ldr r1, =gActionForBanks - adds r0, r5, r1 - ldrb r0, [r0] - adds r2, r1, 0 - cmp r0, 0x9 - bls _0803C812 - b _0803CD04 -_0803C812: - lsls r0, 2 - ldr r1, =_0803C830 - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .pool - .align 2, 0 -_0803C830: - .4byte _0803C858 - .4byte _0803C99C - .4byte _0803C9D4 - .4byte _0803CA0A - .4byte _0803CA2C - .4byte _0803CA40 - .4byte _0803CA54 - .4byte _0803CA84 - .4byte _0803CA98 - .4byte _0803CABC -_0803C858: - ldr r1, =gBattleBufferB - ldrb r3, [r4] - lsls r0, r3, 9 - adds r1, 0x1 - adds r0, r1 - ldrb r1, [r0] - cmp r1, 0x3 - blt _0803C88A - cmp r1, 0x9 - ble _0803C878 - cmp r1, 0xF - beq _0803C87E - b _0803C88A - .pool -_0803C878: - adds r0, r3, r2 - strb r1, [r0] - b _0803CD70 -_0803C87E: - adds r1, r3, r2 - movs r0, 0x2 - strb r0, [r1] - bl sub_803CDF8 - b _0803CD70 -_0803C88A: - movs r0, 0x2 - bl sub_818603C - ldr r4, =gBattleBufferB - ldr r6, =gActiveBank - ldrb r3, [r6] - lsls r1, r3, 9 - adds r5, r4, 0x2 - adds r0, r1, r5 - ldrb r2, [r0] - adds r7, r4, 0x3 - adds r1, r7 - ldrb r0, [r1] - lsls r0, 8 - orrs r2, r0 - ldr r0, =0x0000ffff - cmp r2, r0 - bne _0803C8D0 - ldr r0, =gBattleCommunication - adds r0, r3, r0 - movs r1, 0x1 - strb r1, [r0] - ldrb r0, [r6] - bl sub_8185008 - b _0803CD04 - .pool -_0803C8D0: - bl sub_803FB4C - lsls r0, 24 - cmp r0, 0 - beq _0803C91C - ldrb r0, [r6] - movs r1, 0x1 - bl sub_8185008 - ldr r0, =gBattleCommunication - ldrb r1, [r6] - adds r1, r0 - movs r3, 0 - movs r0, 0x6 - strb r0, [r1] - ldrb r1, [r6] - ldr r2, =gBattleStruct - ldr r0, [r2] - adds r1, r0 - adds r1, 0x54 - strb r3, [r1] - ldrb r0, [r6] - lsls r0, 9 - adds r1, r4, 0x1 - adds r0, r1 - strb r3, [r0] - ldrb r1, [r6] - ldr r0, [r2] - adds r1, r0 - adds r1, 0x84 - movs r0, 0x2 - strb r0, [r1] - b _0803CD70 - .pool -_0803C91C: - ldr r0, =gBattleTypeFlags - ldr r0, [r0] - movs r1, 0x80 - lsls r1, 10 - ands r0, r1 - cmp r0, 0 - bne _0803C942 - ldrb r0, [r6] - lsls r1, r0, 9 - adds r1, r5 - ldrb r1, [r1] - bl RecordedBattle_SetBankAction - ldrb r0, [r6] - lsls r1, r0, 9 - adds r1, r7 - ldrb r1, [r1] - bl RecordedBattle_SetBankAction -_0803C942: - ldrb r0, [r6] - ldr r4, =gBattleStruct - ldr r1, [r4] - adds r1, r0, r1 - adds r1, 0x80 - lsls r0, 9 - adds r0, r5 - ldrb r0, [r0] - strb r0, [r1] - ldr r0, =gChosenMovesByBanks - ldrb r2, [r6] - lsls r5, r2, 1 - adds r5, r0 - ldr r3, =gBattleMons - ldr r4, [r4] - adds r0, r2, r4 - adds r0, 0x80 - ldrb r0, [r0] - lsls r0, 1 - movs r1, 0x58 - muls r1, r2 - adds r0, r1 - adds r3, 0xC - adds r0, r3 - ldrh r0, [r0] - strh r0, [r5] - ldrb r0, [r6] - adds r4, r0, r4 - lsls r0, 9 - adds r0, r7 - ldrb r0, [r0] - strb r0, [r4, 0xC] - ldr r0, =gBattleCommunication - ldrb r1, [r6] - b _0803CB72 - .pool -_0803C99C: - ldr r2, =gBattleBufferB - ldr r5, =gActiveBank - ldrb r4, [r5] - lsls r1, r4, 9 - adds r0, r2, 0x1 - adds r0, r1, r0 - ldrb r3, [r0] - adds r2, 0x2 - adds r1, r2 - ldrb r0, [r1] - lsls r0, 8 - orrs r3, r0 - cmp r3, 0 - bne _0803C9BA - b _0803CC1C -_0803C9BA: - ldr r0, =gLastUsedItem - strh r3, [r0] - ldr r0, =gBattleCommunication - ldrb r1, [r5] - b _0803CB72 - .pool -_0803C9D4: - ldr r0, =gBattleBufferB - ldr r4, =gActiveBank - ldrb r2, [r4] - lsls r1, r2, 9 - adds r0, 0x1 - adds r1, r0 - ldrb r0, [r1] - cmp r0, 0x6 - bne _0803CA04 - ldr r0, =gBattleCommunication - adds r0, r2, r0 - movs r1, 0x1 - strb r1, [r0] - ldrb r0, [r4] - bl sub_8185008 - b _0803CD04 - .pool -_0803CA04: - bl sub_803CDF8 - b _0803CB6E -_0803CA0A: - ldr r2, =gHitMarker - ldr r0, [r2] - movs r1, 0x80 - lsls r1, 8 - orrs r0, r1 - str r0, [r2] - ldr r2, =gBattleCommunication - ldr r0, =gActiveBank - ldrb r1, [r0] - adds r1, r2 - b _0803CB74 - .pool -_0803CA2C: - ldr r2, =gBattleCommunication - ldr r0, =gActiveBank - ldrb r1, [r0] - adds r1, r2 - b _0803CB74 - .pool -_0803CA40: - ldr r2, =gBattleCommunication - ldr r0, =gActiveBank - ldrb r1, [r0] - adds r1, r2 - b _0803CB74 - .pool -_0803CA54: - ldr r3, =gBattleBufferB - ldr r0, =gActiveBank - ldrb r4, [r0] - lsls r1, r4, 9 - adds r0, r3, 0x1 - adds r0, r1, r0 - ldrb r2, [r0] - adds r3, 0x2 - adds r1, r3 - ldrb r0, [r1] - lsls r0, 8 - orrs r2, r0 - cmp r2, 0 - bne _0803CA72 - b _0803CC1C -_0803CA72: - ldr r1, =gBattleCommunication - adds r1, r4, r1 - b _0803CB74 - .pool -_0803CA84: - ldr r2, =gBattleCommunication - ldr r0, =gActiveBank - ldrb r1, [r0] - adds r1, r2 - b _0803CB74 - .pool -_0803CA98: - ldr r2, =gHitMarker - ldr r0, [r2] - movs r1, 0x80 - lsls r1, 8 - orrs r0, r1 - str r0, [r2] - ldr r2, =gBattleCommunication - ldr r0, =gActiveBank - ldrb r1, [r0] - adds r1, r2 - b _0803CB74 - .pool -_0803CABC: - ldr r2, =gBattleCommunication - ldr r0, =gActiveBank - ldrb r1, [r0] - adds r1, r2 - b _0803CB74 - .pool -_0803CAD0: - ldr r3, =gBattleExecBuffer - ldr r6, =gBitTable - ldr r0, =gActiveBank - ldrb r0, [r0] - lsls r0, 2 - adds r0, r6 - ldr r2, [r0] - lsls r1, r2, 4 - movs r0, 0xF0 - lsls r0, 24 - orrs r1, r0 - orrs r1, r2 - lsls r0, r2, 8 - orrs r1, r0 - lsls r2, 12 - orrs r1, r2 - ldr r0, [r3] - ands r0, r1 - cmp r0, 0 - beq _0803CAFA - b _0803CD04 -_0803CAFA: - bl sub_803CDB8 - lsls r0, 24 - lsrs r0, 24 - negs r1, r0 - orrs r1, r0 - lsrs r4, r1, 31 - ldr r0, =gBattleTypeFlags - ldr r0, [r0] - movs r1, 0x41 - ands r0, r1 - cmp r0, 0x1 - bne _0803CB3C - movs r1, 0x2 - movs r0, 0x2 - ands r0, r5 - cmp r0, 0 - bne _0803CB3C - adds r0, r5, 0 - eors r0, r1 - bl GetBankByIdentity - ldr r1, =gBattleStruct - ldr r1, [r1] - adds r1, 0x91 - ldrb r1, [r1] - lsls r0, 24 - lsrs r0, 22 - adds r0, r6 - ldr r0, [r0] - ands r1, r0 - cmp r1, 0 - beq _0803CB5C -_0803CB3C: - movs r0, 0 - movs r1, 0 - adds r2, r4, 0 - bl EmitLinkStandbyMsg - b _0803CB66 - .pool -_0803CB5C: - movs r0, 0 - movs r1, 0x1 - adds r2, r4, 0 - bl EmitLinkStandbyMsg -_0803CB66: - ldr r4, =gActiveBank -_0803CB68: - ldrb r0, [r4] - bl MarkBufferBankForExecution -_0803CB6E: - ldr r0, =gBattleCommunication - ldrb r1, [r4] -_0803CB72: - adds r1, r0 -_0803CB74: - ldrb r0, [r1] - adds r0, 0x1 - strb r0, [r1] - b _0803CD04 - .pool -_0803CB84: - ldr r3, =gBattleExecBuffer - ldr r1, =gBitTable - ldr r0, =gActiveBank - ldrb r0, [r0] - lsls r0, 2 - adds r0, r1 - ldr r2, [r0] - lsls r1, r2, 4 - movs r0, 0xF0 - lsls r0, 24 - orrs r1, r0 - orrs r1, r2 - lsls r0, r2, 8 - orrs r1, r0 - lsls r2, 12 - orrs r1, r2 - ldr r0, [r3] - ands r0, r1 - cmp r0, 0 - beq _0803CBAE - b _0803CD04 -_0803CBAE: - ldr r1, =gBattleCommunication - ldrb r0, [r1, 0x4] - adds r0, 0x1 - strb r0, [r1, 0x4] - b _0803CD04 - .pool -_0803CBC8: - ldr r5, =gActiveBank - ldrb r2, [r5] - ldr r0, =gBattleStruct - ldr r0, [r0] - adds r1, r2, r0 - adds r0, r1, 0 - adds r0, 0x54 - ldrb r0, [r0] - cmp r0, 0 - beq _0803CCB4 - ldr r0, =gBattleCommunication - adds r0, r2, r0 - adds r1, 0x84 - ldrb r1, [r1] - strb r1, [r0] - b _0803CD04 - .pool -_0803CBF4: - ldr r3, =gBattleExecBuffer - ldr r1, =gBitTable - ldr r0, =gActiveBank - ldrb r4, [r0] - lsls r0, r4, 2 - adds r0, r1 - ldr r2, [r0] - lsls r1, r2, 4 - movs r0, 0xF0 - lsls r0, 24 - orrs r1, r0 - orrs r1, r2 - lsls r0, r2, 8 - orrs r1, r0 - lsls r2, 12 - orrs r1, r2 - ldr r0, [r3] - ands r0, r1 - cmp r0, 0 - bne _0803CD04 -_0803CC1C: - ldr r0, =gBattleCommunication - adds r0, r4, r0 -_0803CC20: - movs r1, 0x1 - strb r1, [r0] - b _0803CD04 - .pool -_0803CC38: - ldr r5, =gActiveBank - ldrb r2, [r5] - ldr r4, =gBattleStruct - ldr r0, [r4] - adds r0, r2, r0 - adds r0, 0x54 - ldrb r0, [r0] - cmp r0, 0 - beq _0803CCB4 - ldr r0, =gBattleBufferB - lsls r1, r2, 9 - adds r0, 0x1 - adds r1, r0 - ldrb r0, [r1] - cmp r0, 0xD - bne _0803CC94 - ldr r2, =gHitMarker - ldr r0, [r2] - movs r1, 0x80 - lsls r1, 8 - orrs r0, r1 - str r0, [r2] - ldr r1, =gActionForBanks - ldrb r0, [r5] - adds r0, r1 - movs r1, 0x3 - strb r1, [r0] - ldr r1, =gBattleCommunication - ldrb r0, [r5] -_0803CC72: - adds r0, r1 - movs r1, 0x4 - strb r1, [r0] - b _0803CD04 - .pool -_0803CC94: - adds r0, r2, 0 - movs r1, 0x1 - bl sub_8185008 - ldr r2, =gBattleCommunication - ldrb r0, [r5] - adds r2, r0, r2 - ldr r1, [r4] - adds r0, r1 - adds r0, 0x84 - ldrb r0, [r0] - strb r0, [r2] - b _0803CD04 - .pool -_0803CCB4: - ldr r0, =gBankAttacker - strb r2, [r0] - ldr r7, =gBattlescriptCurrInstr - ldr r6, =gUnknown_02024220 - ldrb r0, [r5] - lsls r0, 2 - adds r0, r6 - ldr r4, [r0] - str r4, [r7] - ldr r3, =gBattleExecBuffer - ldr r1, =gBitTable - ldrb r0, [r5] - lsls r0, 2 - adds r0, r1 - ldr r2, [r0] - lsls r1, r2, 4 - movs r0, 0xF0 - lsls r0, 24 - orrs r1, r0 - orrs r1, r2 - lsls r0, r2, 8 - orrs r1, r0 - lsls r2, 12 - orrs r1, r2 - ldr r0, [r3] - ands r0, r1 - cmp r0, 0 - bne _0803CCFA - ldr r0, =gBattleScriptingCommandsTable - ldrb r1, [r4] - lsls r1, 2 - adds r1, r0 - ldr r0, [r1] - bl _call_via_r0 -_0803CCFA: - ldrb r0, [r5] - lsls r0, 2 - adds r0, r6 - ldr r1, [r7] - str r1, [r0] -_0803CD04: - ldr r0, =gActiveBank - ldrb r1, [r0] - adds r1, 0x1 - strb r1, [r0] - ldr r0, =gNoOfAllBanks - lsls r1, 24 - lsrs r1, 24 -_0803CD12: - adds r5, r0, 0 - ldrb r0, [r5] - cmp r1, r0 - bcs _0803CD1E - bl _0803BE9C -_0803CD1E: - ldr r0, =gBattleCommunication - ldrb r0, [r0, 0x4] - ldrb r1, [r5] - cmp r0, r1 - bne _0803CD70 - movs r0, 0x1 - bl sub_818603C - ldr r1, =gBattleMainFunc - ldr r0, =sub_803D2E8 - str r0, [r1] - ldr r0, =gBattleTypeFlags - ldr r0, [r0] - movs r1, 0x80 - lsls r1, 15 - ands r0, r1 - cmp r0, 0 - beq _0803CD70 - movs r4, 0 - ldrb r5, [r5] - cmp r4, r5 - bge _0803CD70 -_0803CD4A: - ldr r0, =gActionForBanks - adds r0, r4, r0 - ldrb r0, [r0] - cmp r0, 0x2 - bne _0803CD66 - lsls r0, r4, 24 - lsrs r0, 24 - ldr r1, =gBattleStruct - ldr r1, [r1] - adds r1, r4, r1 - adds r1, 0x5C - ldrb r1, [r1] - bl sub_80571DC -_0803CD66: - adds r4, 0x1 - ldr r0, =gNoOfAllBanks - ldrb r0, [r0] - cmp r4, r0 - blt _0803CD4A -_0803CD70: - 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_803BE74 thumb_func_start sub_803CDB8 sub_803CDB8: @ 803CDB8 diff --git a/asm/battle_controller_player.s b/asm/battle_controller_player.s index 78236f1d7..1ea1bb5f2 100644 --- a/asm/battle_controller_player.s +++ b/asm/battle_controller_player.s @@ -8648,7 +8648,7 @@ sub_805C158: @ 805C158 lsls r0, 24 cmp r0, 0 bne _0805C194 - ldr r1, =gUnknown_0203BD30 + ldr r1, =gBattlePalaceMoveSelectionRngValue ldr r0, =gRngValue ldr r0, [r0] str r0, [r1] diff --git a/asm/recorded_battle.s b/asm/recorded_battle.s index f733033ff..e742cbe7d 100644 --- a/asm/recorded_battle.s +++ b/asm/recorded_battle.s @@ -271,8 +271,8 @@ _08184FF0: .pool thumb_func_end RecordedBattle_SetBankAction - thumb_func_start sub_8185008 -sub_8185008: @ 8185008 + thumb_func_start RecordedBattle_ClearBankAction +RecordedBattle_ClearBankAction: @ 8185008 push {r4-r7,lr} lsls r0, 24 lsrs r5, r0, 24 @@ -310,7 +310,7 @@ _08185046: pop {r0} bx r0 .pool - thumb_func_end sub_8185008 + thumb_func_end RecordedBattle_ClearBankAction thumb_func_start sub_8185054 sub_8185054: @ 8185054 diff --git a/asm/rom3.s b/asm/rom3.s index 2e040ff0f..6a3e7e299 100644 --- a/asm/rom3.s +++ b/asm/rom3.s @@ -2786,8 +2786,8 @@ _08033D7C: .pool thumb_func_end EmitPrintStringPlayerOnly - thumb_func_start dp01_build_cmdbuf_x12_a_bb -dp01_build_cmdbuf_x12_a_bb: @ 8033DE4 + thumb_func_start EmitChooseAction +EmitChooseAction: @ 8033DE4 push {r4,lr} adds r4, r1, 0 lsls r0, 24 @@ -2807,7 +2807,7 @@ dp01_build_cmdbuf_x12_a_bb: @ 8033DE4 pop {r0} bx r0 .pool - thumb_func_end dp01_build_cmdbuf_x12_a_bb + thumb_func_end EmitChooseAction thumb_func_start EmitCmd13 EmitCmd13: @ 8033E10 @@ -2827,8 +2827,8 @@ EmitCmd13: @ 8033E10 .pool thumb_func_end EmitCmd13 - thumb_func_start sub_8033E30 -sub_8033E30: @ 8033E30 + thumb_func_start EmitChooseMove +EmitChooseMove: @ 8033E30 push {r4-r6,lr} adds r5, r3, 0 lsls r0, 24 @@ -2858,10 +2858,10 @@ _08033E4C: pop {r0} bx r0 .pool - thumb_func_end sub_8033E30 + thumb_func_end EmitChooseMove - thumb_func_start sub_8033E6C -sub_8033E6C: @ 8033E6C + thumb_func_start EmitOpenBag +EmitOpenBag: @ 8033E6C push {r4,r5,lr} adds r4, r1, 0 lsls r0, 24 @@ -2886,7 +2886,7 @@ _08033E7E: pop {r0} bx r0 .pool - thumb_func_end sub_8033E6C + thumb_func_end EmitOpenBag thumb_func_start EmitChoosePokemon EmitChoosePokemon: @ 8033EA0 @@ -3624,8 +3624,8 @@ EmitCmd49: @ 80343D4 .pool thumb_func_end EmitCmd49 - thumb_func_start dp01_build_cmdbuf_x32_32_32_32 -dp01_build_cmdbuf_x32_32_32_32: @ 80343F4 + thumb_func_start Emit_x32 +Emit_x32: @ 80343F4 push {lr} lsls r0, 24 lsrs r0, 24 @@ -3640,7 +3640,7 @@ dp01_build_cmdbuf_x32_32_32_32: @ 80343F4 pop {r0} bx r0 .pool - thumb_func_end dp01_build_cmdbuf_x32_32_32_32 + thumb_func_end Emit_x32 thumb_func_start EmitSpriteInvisibility EmitSpriteInvisibility: @ 8034414 diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index 206519f40..0b797feef 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -561,7 +561,7 @@ BattleScript_BerryStatRaiseEnd2:: @ 82DB84E BattleScript_BerryFocusEnergyEnd2:: @ 82DB869 .incbin "baserom.gba", 0x2db869, 0x10 -gUnknown_082DB879:: @ 82DB879 +BattleScript_ActionSelectionItemsCantBeUsed:: @ 82DB879 .incbin "baserom.gba", 0x2db879, 0x4 gUnknown_082DB87D:: @ 82DB87D diff --git a/include/battle.h b/include/battle.h index e5e5a94d1..50d2389ac 100644 --- a/include/battle.h +++ b/include/battle.h @@ -61,7 +61,8 @@ #define STEVEN_PARTNER_ID 0xC03 #define SECRET_BASE_OPPONENT 0x400 -#define BATTLE_TYPE_FRONTIER (BATTLE_TYPE_BATTLE_TOWER | BATTLE_TYPE_DOME | BATTLE_TYPE_PALACE | BATTLE_TYPE_ARENA | BATTLE_TYPE_FACTORY | BATTLE_TYPE_x100000 | BATTLE_TYPE_PYRAMID) +#define BATTLE_TYPE_FRONTIER (BATTLE_TYPE_BATTLE_TOWER | BATTLE_TYPE_DOME | BATTLE_TYPE_PALACE | BATTLE_TYPE_ARENA | BATTLE_TYPE_FACTORY | BATTLE_TYPE_x100000 | BATTLE_TYPE_PYRAMID) +#define BATTLE_TYPE_FRONTIER_NO_PYRAMID (BATTLE_TYPE_BATTLE_TOWER | BATTLE_TYPE_DOME | BATTLE_TYPE_PALACE | BATTLE_TYPE_ARENA | BATTLE_TYPE_FACTORY | BATTLE_TYPE_x100000) #define BATTLE_WON 0x1 #define BATTLE_LOST 0x2 @@ -136,6 +137,7 @@ #define HITMARKER_PURSUIT_TRAP 0x00001000 #define HITMARKER_IGNORE_SAFEGUARD 0x00002000 #define HITMARKER_SYNCHRONISE_EFFECT 0x00004000 +#define HITMARKER_x8000 0x00008000 #define HITMARKER_IGNORE_ON_AIR 0x00010000 #define HITMARKER_IGNORE_UNDERGROUND 0x00020000 #define HITMARKER_IGNORE_UNDERWATER 0x00040000 @@ -614,10 +616,7 @@ struct BattleStruct u8 field_7E; u8 formToChangeInto; u8 chosenMovesIds[4]; - u8 field_84; - u8 field_85; - u8 field_86; - u8 field_87; + u8 field_84[4]; u8 field_88; u8 field_89; u8 field_8A; @@ -906,7 +905,7 @@ void BattleTurnPassed(void); void BattleScriptPush(const u8* bsPtr); void BattleScriptPushCursor(void); void BattleScriptPop(void); -u8 sub_803FB4C(void); // msg, can't select a move +u8 TrySetCantSelectMoveBattleScript(void); u8 CheckMoveLimitations(u8 bank, u8 unusableMoves, u8 check); bool8 AreAllMovesUnusable(void); u8 GetImprisonedMovesCount(u8 bank, u16 move); diff --git a/include/battle_controllers.h b/include/battle_controllers.h index 61e8bec29..9a7f947fa 100644 --- a/include/battle_controllers.h +++ b/include/battle_controllers.h @@ -14,6 +14,16 @@ struct MovePpInfo u8 ppBonuses; }; +struct ChooseMoveStruct +{ + u16 moves[4]; + u8 ppNumbers[4]; + u8 ppWithBonusNumbers[4]; + u16 species; + u8 monType1; + u8 monType2; +}; + #define REQUEST_ALL_BATTLE 0x0 #define REQUEST_SPECIES_BATTLE 0x1 #define REQUEST_HELDITEM_BATTLE 0x2 @@ -40,8 +50,8 @@ void EmitSpriteInvisibility(u8 bufferId, bool8 isInvisible); void EmitReturnPokeToBall(u8 bufferId, u8 arg1); void EmitGetMonData(u8 bufferId, u8 arg1, u8 arg2); void EmitSwitchInAnim(u8 bufferId, u8 partyId, bool8 dontClearSubstituteBit); -void EmitChoosePokemon(u8 bufferId, u8 caseId, u8 arg2, u8 abilityId, const u8* arg4); -void EmitLinkStandbyMsg(u8 bufferId, u8 arg1, u8 arg2); +void EmitChoosePokemon(u8 bufferId, u8 caseId, u8 arg2, u8 abilityId, u8* arg4); +void EmitLinkStandbyMsg(u8 bufferId, u8 arg1, bool32 arg2); void EmitTrainerSlide(u8 bufferId); void EmitTrainerSlideBack(u8 bufferId); void EmitFaintingCry(u8 bufferId); @@ -56,6 +66,10 @@ void EmitIntroSlide(u8 bufferId, u8 terrainId); void EmitDrawTrainerPic(u8 bufferId); void EmitLoadMonSprite(u8 bufferId); void EmitIntroTrainerBallThrow(u8 bufferId); +void EmitChooseAction(u8 bufferId, u8 arg1, u16 arg2); +void EmitChooseMove(u8 bufferId, bool8 isDoubleBattle, bool8 NoPpNumber, struct ChooseMoveStruct* movePpData); +void EmitOpenBag(u8 bufferId, u8* arg1); +void Emit_x32(u8 bufferId); #define RESET_ACTION_MOVE_SELECTION 0 #define RESET_ACTION_SELECTION 1 diff --git a/include/recorded_battle.h b/include/recorded_battle.h index 2040f2b8a..2df1620e4 100644 --- a/include/recorded_battle.h +++ b/include/recorded_battle.h @@ -6,10 +6,13 @@ extern u32 gRecordedBattleRngSeed; void sub_8185F84(void); void sub_8184E58(void); void RecordedBattle_SetBankAction(u8 bank, u8 action); +void RecordedBattle_ClearBankAction(u8 bank, u8 bytesToClear); void sub_8185F90(u16 arg0); bool8 sub_8186450(void); u8 sub_8185FAC(void); u8 sub_8185FB8(void); u8 MoveRecordedBattleToSaveData(void); +void sub_818603C(u8); +void sub_8185FD0(void); #endif // GUARD_RECORDED_BATTLE_H diff --git a/src/battle_2.c b/src/battle_2.c index 769723c24..a18e1c698 100644 --- a/src/battle_2.c +++ b/src/battle_2.c @@ -132,6 +132,7 @@ extern u8 gActionForBanks[BATTLE_BANKS_COUNT]; extern u16 gChosenMovesByBanks[BATTLE_BANKS_COUNT]; extern u8 gFightStateTracker; extern u8 gLastUsedAbility; +extern u16 gLastUsedItem; extern const u8 gSpeciesNames[][POKEMON_NAME_LENGTH + 1]; extern const struct BattleMove gBattleMoves[]; @@ -168,6 +169,8 @@ extern void sub_80B3AF8(u8 taskId); // cable club extern void sub_8076918(u8 bank); extern void sub_80729D0(u8 healthoxSpriteId); extern void sub_81A56B4(void); // battle frontier 2 +extern void sub_81B8FB0(u8, u8); // party menu +extern u8 pokemon_order_func(u8); // party menu // this file's functions static void CB2_InitBattleInternal(void); @@ -214,6 +217,9 @@ static void BattleIntroPlayer1SendsOutMonAnimation(void); static void TryDoEventsBeforeFirstTurn(void); void sub_803BE74(void); void bc_bs_exec(void); +void sub_803D2E8(void); +void sub_803CDF8(void); +bool8 sub_803CDB8(void); void CB2_InitBattle(void) { @@ -3736,3 +3742,475 @@ u8 IsRunningFromBattleImpossible(void) } return 0; } + +extern u8 gUnknown_0203CF00[]; + +void sub_803BDA0(u8 bank) +{ + s32 i; + u8 r4; + u8 r1; + + // gBattleStruct->field_60[bank][i] + + for (i = 0; i < 3; i++) + gUnknown_0203CF00[i] = *(bank * 3 + i + (u8*)(gBattleStruct->field_60)); + + r4 = pokemon_order_func(gBattlePartyID[bank]); + r1 = pokemon_order_func(*(gBattleStruct->field_5C + bank)); + sub_81B8FB0(r4, r1); + + if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE) + { + for (i = 0; i < 3; i++) + { + *(bank * 3 + i + (u8*)(gBattleStruct->field_60)) = gUnknown_0203CF00[i]; + *((bank ^ BIT_MON) * 3 + i + (u8*)(gBattleStruct->field_60)) = gUnknown_0203CF00[i]; + } + } + else + { + for (i = 0; i < 3; i++) + { + *(bank * 3 + i + (u8*)(gBattleStruct->field_60)) = gUnknown_0203CF00[i]; + } + } +} + +extern const u8* gBattlescriptPtrsForSelection[BATTLE_BANKS_COUNT]; +extern const u8* gBattlescriptCurrInstr; + +extern const u8 BattleScript_ActionSelectionItemsCantBeUsed[]; +extern const u8 gUnknown_082DAB11[]; +extern const u8 gUnknown_082DB9BA[]; +extern const u8 gUnknown_082DAAFE[]; +extern const u8 gUnknown_082DAB0B[]; + +extern u32 gBattlePalaceMoveSelectionRngValue; + +void sub_803BE74(void) +{ + s32 i; + + gBattleCommunication[4] = 0; + for (gActiveBank = 0; gActiveBank < gNoOfAllBanks; gActiveBank++) + { + u8 identity = GetBankIdentity(gActiveBank); + switch (gBattleCommunication[gActiveBank]) + { + case 0: + sub_8185FD0(); + gBattleCommunication[gActiveBank] = 1; + break; + case 1: + *(gBattleStruct->field_5C + gActiveBank) = 6; + if (gBattleTypeFlags & BATTLE_TYPE_MULTI + || !(identity & BIT_MON) + || gBattleStruct->field_91 & gBitTable[GetBankByIdentity(identity ^ BIT_MON)] + || gBattleCommunication[GetBankByIdentity(identity ^ BIT_MON)] == 5) + { + if (gBattleStruct->field_91 & gBitTable[gActiveBank]) + { + gActionForBanks[gActiveBank] = 13; + if (!(gBattleTypeFlags & BATTLE_TYPE_MULTI)) + gBattleCommunication[gActiveBank] = 5; + else + gBattleCommunication[gActiveBank] = 4; + } + else + { + if (gBattleMons[gActiveBank].status2 & STATUS2_MULTIPLETURNS + || gBattleMons[gActiveBank].status2 & STATUS2_RECHARGE) + { + gActionForBanks[gActiveBank] = 0; + gBattleCommunication[gActiveBank] = 4; + } + else + { + EmitChooseAction(0, gActionForBanks[0], gBattleBufferB[0][1] | (gBattleBufferB[0][2] << 8)); + MarkBufferBankForExecution(gActiveBank); + gBattleCommunication[gActiveBank]++; + } + } + } + break; + case 2: + if (!(gBattleExecBuffer & ((gBitTable[gActiveBank]) | (0xF0000000) | (gBitTable[gActiveBank] << 4) | (gBitTable[gActiveBank] << 8) | (gBitTable[gActiveBank] << 0xC)))) + { + RecordedBattle_SetBankAction(gActiveBank, gBattleBufferB[gActiveBank][1]); + gActionForBanks[gActiveBank] = gBattleBufferB[gActiveBank][1]; + + switch (gBattleBufferB[gActiveBank][1]) + { + case 0: + if (AreAllMovesUnusable()) + { + gBattleCommunication[gActiveBank] = 6; + *(gBattleStruct->field_54 + gActiveBank) = 0; + *(gBattleStruct->field_84 + gActiveBank) = 4; + *(gBattleStruct->moveTarget + gActiveBank) = gBattleBufferB[gActiveBank][3]; + return; + } + else if (gDisableStructs[gActiveBank].encoredMove != 0) + { + gChosenMovesByBanks[gActiveBank] = gDisableStructs[gActiveBank].encoredMove; + *(gBattleStruct->chosenMovesIds + gActiveBank) = gDisableStructs[gActiveBank].encoredMovePos; + gBattleCommunication[gActiveBank] = 4; + return; + } + else + { + struct ChooseMoveStruct moveInfo; + + moveInfo.species = gBattleMons[gActiveBank].species; + moveInfo.monType1 = gBattleMons[gActiveBank].type1; + moveInfo.monType2 = gBattleMons[gActiveBank].type2; + + for (i = 0; i < 4; i++) + { + moveInfo.moves[i] = gBattleMons[gActiveBank].moves[i]; + moveInfo.ppNumbers[i] = gBattleMons[gActiveBank].pp[i]; + moveInfo.ppWithBonusNumbers[i] = CalculatePPWithBonus( + gBattleMons[gActiveBank].moves[i], + gBattleMons[gActiveBank].ppBonuses, + i); + } + + EmitChooseMove(0, (gBattleTypeFlags & BATTLE_TYPE_DOUBLE) != 0, FALSE, &moveInfo); + MarkBufferBankForExecution(gActiveBank); + } + break; + case 1: + if (gBattleTypeFlags & (BATTLE_TYPE_LINK + | BATTLE_TYPE_FRONTIER_NO_PYRAMID + | BATTLE_TYPE_EREADER_TRAINER + | BATTLE_TYPE_x2000000)) + { + RecordedBattle_ClearBankAction(gActiveBank, 1); + gBattlescriptPtrsForSelection[gActiveBank] = BattleScript_ActionSelectionItemsCantBeUsed; + gBattleCommunication[gActiveBank] = 6; + *(gBattleStruct->field_54 + gActiveBank) = 0; + *(gBattleStruct->field_84 + gActiveBank) = 1; + return; + } + else + { + EmitOpenBag(0, gBattleStruct->field_60[gActiveBank]); + MarkBufferBankForExecution(gActiveBank); + } + break; + case 2: + *(gBattleStruct->field_58 + gActiveBank) = gBattlePartyID[gActiveBank]; + if (gBattleMons[gActiveBank].status2 & (STATUS2_WRAPPED | STATUS2_ESCAPE_PREVENTION) + || gBattleTypeFlags & BATTLE_TYPE_ARENA + || gStatuses3[gActiveBank] & STATUS3_ROOTED) + { + EmitChoosePokemon(0, 2, 6, ABILITY_NONE, gBattleStruct->field_60[gActiveBank]); + } + else if ((i = AbilityBattleEffects(ABILITYEFFECT_CHECK_OTHER_SIDE, gActiveBank, ABILITY_SHADOW_TAG, 0, 0)) + || ((i = AbilityBattleEffects(ABILITYEFFECT_CHECK_OTHER_SIDE, gActiveBank, ABILITY_ARENA_TRAP, 0, 0)) + && gBattleMons[gActiveBank].type1 != TYPE_FLYING + && gBattleMons[gActiveBank].type2 != TYPE_FLYING + && gBattleMons[gActiveBank].ability != ABILITY_LEVITATE) + || ((i = AbilityBattleEffects(ABILITYEFFECT_CHECK_FIELD_EXCEPT_BANK, gActiveBank, ABILITY_MAGNET_PULL, 0, 0)) + && (gBattleMons[gActiveBank].type1 == TYPE_STEEL + || gBattleMons[gActiveBank].type2 == TYPE_STEEL))) + { + EmitChoosePokemon(0, ((i - 1) << 4) | 4, 6, gLastUsedAbility, gBattleStruct->field_60[gActiveBank]); + } + else + { + if (gActiveBank == 2 && gActionForBanks[0] == 2) + EmitChoosePokemon(0, 0, *(gBattleStruct->field_5C + 0), ABILITY_NONE, gBattleStruct->field_60[gActiveBank]); + else if (gActiveBank == 3 && gActionForBanks[1] == 2) + EmitChoosePokemon(0, 0, *(gBattleStruct->field_5C + 1), ABILITY_NONE, gBattleStruct->field_60[gActiveBank]); + else + EmitChoosePokemon(0, 0, 6, ABILITY_NONE, gBattleStruct->field_60[gActiveBank]); + } + MarkBufferBankForExecution(gActiveBank); + break; + case 5: + if (IsPlayerPartyAndPokemonStorageFull()) + { + gBattlescriptPtrsForSelection[gActiveBank] = gUnknown_082DAB11; + gBattleCommunication[gActiveBank] = 6; + *(gBattleStruct->field_54 + gActiveBank) = 0; + *(gBattleStruct->field_84 + gActiveBank) = 1; + return; + } + break; + case 6: + EmitOpenBag(0, gBattleStruct->field_60[gActiveBank]); + MarkBufferBankForExecution(gActiveBank); + break; + case 12: + gBattleCommunication[gActiveBank] = 7; + gBattleCommunication[GetBankByIdentity(GetBankIdentity(gActiveBank) ^ BIT_MON)] = 1; + RecordedBattle_ClearBankAction(gActiveBank, 1); + if (gBattleMons[GetBankByIdentity(GetBankIdentity(gActiveBank) ^ BIT_MON)].status2 & STATUS2_MULTIPLETURNS + || gBattleMons[GetBankByIdentity(GetBankIdentity(gActiveBank) ^ BIT_MON)].status2 & STATUS2_RECHARGE) + { + Emit_x32(0); + MarkBufferBankForExecution(gActiveBank); + return; + } + else if (gActionForBanks[GetBankByIdentity(GetBankIdentity(gActiveBank) ^ BIT_MON)] == 2) + { + RecordedBattle_ClearBankAction(GetBankByIdentity(GetBankIdentity(gActiveBank) ^ BIT_MON), 2); + } + else if (gActionForBanks[GetBankByIdentity(GetBankIdentity(gActiveBank) ^ BIT_MON)] == 3) + { + RecordedBattle_ClearBankAction(GetBankByIdentity(GetBankIdentity(gActiveBank) ^ BIT_MON), 1); + } + else if (gActionForBanks[GetBankByIdentity(GetBankIdentity(gActiveBank) ^ BIT_MON)] == 0 + && (gProtectStructs[GetBankByIdentity(GetBankIdentity(gActiveBank) ^ BIT_MON)].onlyStruggle + || gDisableStructs[GetBankByIdentity(GetBankIdentity(gActiveBank) ^ BIT_MON)].encoredMove)) + { + RecordedBattle_ClearBankAction(GetBankByIdentity(GetBankIdentity(gActiveBank) ^ BIT_MON), 1); + } + else if (gBattleTypeFlags & BATTLE_TYPE_PALACE + && gActionForBanks[GetBankByIdentity(GetBankIdentity(gActiveBank) ^ BIT_MON)] == 0) + { + gRngValue = gBattlePalaceMoveSelectionRngValue; + RecordedBattle_ClearBankAction(GetBankByIdentity(GetBankIdentity(gActiveBank) ^ BIT_MON), 1); + } + else + { + RecordedBattle_ClearBankAction(GetBankByIdentity(GetBankIdentity(gActiveBank) ^ BIT_MON), 3); + } + Emit_x32(0); + MarkBufferBankForExecution(gActiveBank); + return; + } + + if (gBattleTypeFlags & BATTLE_TYPE_TRAINER + && gBattleTypeFlags & (BATTLE_TYPE_FRONTIER | BATTLE_TYPE_x4000000) + && gBattleBufferB[gActiveBank][1] == 3) + { + gBattlescriptPtrsForSelection[gActiveBank] = gUnknown_082DB9BA; + gBattleCommunication[gActiveBank] = 8; + *(gBattleStruct->field_54 + gActiveBank) = 0; + *(gBattleStruct->field_84 + gActiveBank) = 1; + return; + } + else if (gBattleTypeFlags & BATTLE_TYPE_TRAINER + && !(gBattleTypeFlags & (BATTLE_TYPE_LINK | BATTLE_TYPE_x2000000)) + && gBattleBufferB[gActiveBank][1] == 3) + { + BattleScriptExecute(gUnknown_082DAAFE); + gBattleCommunication[gActiveBank] = 1; + } + else if (IsRunningFromBattleImpossible() != 0 + && gBattleBufferB[gActiveBank][1] == 3) + { + gBattlescriptPtrsForSelection[gActiveBank] = gUnknown_082DAB0B; + gBattleCommunication[gActiveBank] = 6; + *(gBattleStruct->field_54 + gActiveBank) = 0; + *(gBattleStruct->field_84 + gActiveBank) = 1; + return; + } + else + { + gBattleCommunication[gActiveBank]++; + } + } + break; + case 3: + if (!(gBattleExecBuffer & ((gBitTable[gActiveBank]) | (0xF0000000) | (gBitTable[gActiveBank] << 4) | (gBitTable[gActiveBank] << 8) | (gBitTable[gActiveBank] << 0xC)))) + { + switch (gActionForBanks[gActiveBank]) + { + case 0: + switch (gBattleBufferB[gActiveBank][1]) + { + case 3: + case 4: + case 5: + case 6: + case 7: + case 8: + case 9: + gActionForBanks[gActiveBank] = gBattleBufferB[gActiveBank][1]; + return; + case 15: + gActionForBanks[gActiveBank] = 2; + sub_803CDF8(); + return; + default: + sub_818603C(2); + if ((gBattleBufferB[gActiveBank][2] | (gBattleBufferB[gActiveBank][3] << 8)) == 0xFFFF) + { + gBattleCommunication[gActiveBank] = 1; + RecordedBattle_ClearBankAction(gActiveBank, 1); + } + else if (TrySetCantSelectMoveBattleScript()) + { + RecordedBattle_ClearBankAction(gActiveBank, 1); + gBattleCommunication[gActiveBank] = 6; + *(gBattleStruct->field_54 + gActiveBank) = 0; + gBattleBufferB[gActiveBank][1] = 0; + *(gBattleStruct->field_84 + gActiveBank) = 2; + return; + } + else + { + if (!(gBattleTypeFlags & BATTLE_TYPE_PALACE)) + { + RecordedBattle_SetBankAction(gActiveBank, gBattleBufferB[gActiveBank][2]); + RecordedBattle_SetBankAction(gActiveBank, gBattleBufferB[gActiveBank][3]); + } + *(gBattleStruct->chosenMovesIds + gActiveBank) = gBattleBufferB[gActiveBank][2]; + gChosenMovesByBanks[gActiveBank] = gBattleMons[gActiveBank].moves[*(gBattleStruct->chosenMovesIds + gActiveBank)]; + *(gBattleStruct->moveTarget + gActiveBank) = gBattleBufferB[gActiveBank][3]; + gBattleCommunication[gActiveBank]++; + } + break; + } + break; + case 1: + if ((gBattleBufferB[gActiveBank][1] | (gBattleBufferB[gActiveBank][2] << 8)) == 0) + { + gBattleCommunication[gActiveBank] = 1; + } + else + { + gLastUsedItem = (gBattleBufferB[gActiveBank][1] | (gBattleBufferB[gActiveBank][2] << 8)); + gBattleCommunication[gActiveBank]++; + } + break; + case 2: + if (gBattleBufferB[gActiveBank][1] == 6) + { + gBattleCommunication[gActiveBank] = 1; + RecordedBattle_ClearBankAction(gActiveBank, 1); + } + else + { + sub_803CDF8(); + gBattleCommunication[gActiveBank]++; + } + break; + case 3: + gHitMarker |= HITMARKER_x8000; + gBattleCommunication[gActiveBank]++; + break; + case 4: + gBattleCommunication[gActiveBank]++; + break; + case 5: + gBattleCommunication[gActiveBank]++; + break; + case 6: + if ((gBattleBufferB[gActiveBank][1] | (gBattleBufferB[gActiveBank][2] << 8)) != 0) + { + gBattleCommunication[gActiveBank]++; + } + else + { + gBattleCommunication[gActiveBank] = 1; + } + break; + case 7: + gBattleCommunication[gActiveBank]++; + break; + case 8: + gHitMarker |= HITMARKER_x8000; + gBattleCommunication[gActiveBank]++; + break; + case 9: + gBattleCommunication[gActiveBank]++; + break; + } + } + break; + case 4: + if (!(gBattleExecBuffer & ((gBitTable[gActiveBank]) | (0xF0000000) | (gBitTable[gActiveBank] << 4) | (gBitTable[gActiveBank] << 8) | (gBitTable[gActiveBank] << 0xC)))) + { + i = (sub_803CDB8() != 0); + + if (((gBattleTypeFlags & (BATTLE_TYPE_MULTI | BATTLE_TYPE_DOUBLE)) != BATTLE_TYPE_DOUBLE) + || (identity & BIT_MON) + || (*(&gBattleStruct->field_91) & gBitTable[GetBankByIdentity(identity ^ BIT_MON)])) + { + EmitLinkStandbyMsg(0, 0, i); + } + else + { + EmitLinkStandbyMsg(0, 1, i); + } + MarkBufferBankForExecution(gActiveBank); + gBattleCommunication[gActiveBank]++; + } + break; + case 5: + if (!(gBattleExecBuffer & ((gBitTable[gActiveBank]) | (0xF0000000) | (gBitTable[gActiveBank] << 4) | (gBitTable[gActiveBank] << 8) | (gBitTable[gActiveBank] << 0xC)))) + { + gBattleCommunication[4]++; + } + break; + case 6: + if (*(gBattleStruct->field_54 + gActiveBank) != 0) + { + gBattleCommunication[gActiveBank] = *(gBattleStruct->field_84 + gActiveBank); + } + else + { + gBankAttacker = gActiveBank; + gBattlescriptCurrInstr = gBattlescriptPtrsForSelection[gActiveBank]; + if (!(gBattleExecBuffer & ((gBitTable[gActiveBank]) | (0xF0000000) | (gBitTable[gActiveBank] << 4) | (gBitTable[gActiveBank] << 8) | (gBitTable[gActiveBank] << 0xC)))) + { + gBattleScriptingCommandsTable[gBattlescriptCurrInstr[0]](); + } + gBattlescriptPtrsForSelection[gActiveBank] = gBattlescriptCurrInstr; + } + break; + case 7: + if (!(gBattleExecBuffer & ((gBitTable[gActiveBank]) | (0xF0000000) | (gBitTable[gActiveBank] << 4) | (gBitTable[gActiveBank] << 8) | (gBitTable[gActiveBank] << 0xC)))) + { + gBattleCommunication[gActiveBank] = 1; + } + break; + case 8: + if (*(gBattleStruct->field_54 + gActiveBank) != 0) + { + if (gBattleBufferB[gActiveBank][1] == 13) + { + gHitMarker |= HITMARKER_x8000; + gActionForBanks[gActiveBank] = 3; + gBattleCommunication[gActiveBank] = 4; + } + else + { + RecordedBattle_ClearBankAction(gActiveBank, 1); + gBattleCommunication[gActiveBank] = *(gBattleStruct->field_84 + gActiveBank); + } + } + else + { + gBankAttacker = gActiveBank; + gBattlescriptCurrInstr = gBattlescriptPtrsForSelection[gActiveBank]; + if (!(gBattleExecBuffer & ((gBitTable[gActiveBank]) | (0xF0000000) | (gBitTable[gActiveBank] << 4) | (gBitTable[gActiveBank] << 8) | (gBitTable[gActiveBank] << 0xC)))) + { + gBattleScriptingCommandsTable[gBattlescriptCurrInstr[0]](); + } + gBattlescriptPtrsForSelection[gActiveBank] = gBattlescriptCurrInstr; + } + break; + } + } + + if (gBattleCommunication[4] == gNoOfAllBanks) + { + sub_818603C(1); + gBattleMainFunc = sub_803D2E8; + + if (gBattleTypeFlags & BATTLE_TYPE_INGAME_PARTNER) + { + for (i = 0; i < gNoOfAllBanks; i++) + { + if (gActionForBanks[i] == 2) + sub_80571DC(i, *(gBattleStruct->field_5C + i)); + } + } + } +} diff --git a/src/battle_3.c b/src/battle_3.c index 071e4d59d..59028410d 100644 --- a/src/battle_3.c +++ b/src/battle_3.c @@ -19,7 +19,7 @@ #include "calculate_base_damage.h" extern const u8* gBattlescriptCurrInstr; -extern const u8* gUnknown_02024220[BATTLE_BANKS_COUNT]; +extern const u8* gBattlescriptPtrsForSelection[BATTLE_BANKS_COUNT]; extern const u8* gUnknown_02024230[BATTLE_BANKS_COUNT]; extern struct BattlePokemon gBattleMons[BATTLE_BANKS_COUNT]; extern u8 gActiveBank; @@ -200,7 +200,7 @@ void BattleScriptPop(void) gBattlescriptCurrInstr = BATTLESCRIPTS_STACK->ptr[--BATTLESCRIPTS_STACK->size]; } -u8 sub_803FB4C(void) // msg, can't select a move +u8 TrySetCantSelectMoveBattleScript(void) { u8 limitations = 0; u16 move = gBattleMons[gActiveBank].moves[gBattleBufferB[gActiveBank][2]]; @@ -218,7 +218,7 @@ u8 sub_803FB4C(void) // msg, can't select a move } else { - gUnknown_02024220[gActiveBank] = gUnknown_082DAE1F; + gBattlescriptPtrsForSelection[gActiveBank] = gUnknown_082DAE1F; limitations = 1; } } @@ -233,7 +233,7 @@ u8 sub_803FB4C(void) // msg, can't select a move } else { - gUnknown_02024220[gActiveBank] = gUnknown_082DB089; + gBattlescriptPtrsForSelection[gActiveBank] = gUnknown_082DB089; limitations++; } } @@ -248,7 +248,7 @@ u8 sub_803FB4C(void) // msg, can't select a move } else { - gUnknown_02024220[gActiveBank] = gUnknown_082DB0A0; + gBattlescriptPtrsForSelection[gActiveBank] = gUnknown_082DB0A0; limitations++; } } @@ -263,7 +263,7 @@ u8 sub_803FB4C(void) // msg, can't select a move } else { - gUnknown_02024220[gActiveBank] = gUnknown_082DB181; + gBattlescriptPtrsForSelection[gActiveBank] = gUnknown_082DB181; limitations++; } } @@ -285,7 +285,7 @@ u8 sub_803FB4C(void) // msg, can't select a move } else { - gUnknown_02024220[gActiveBank] = gUnknown_082DB812; + gBattlescriptPtrsForSelection[gActiveBank] = gUnknown_082DB812; limitations++; } } @@ -298,7 +298,7 @@ u8 sub_803FB4C(void) // msg, can't select a move } else { - gUnknown_02024220[gActiveBank] = gUnknown_082DB076; + gBattlescriptPtrsForSelection[gActiveBank] = gUnknown_082DB076; limitations++; } } @@ -349,7 +349,7 @@ bool8 AreAllMovesUnusable(void) if (unusable == 0xF) // all moves are unusable { gProtectStructs[gActiveBank].onlyStruggle = 1; - gUnknown_02024220[gActiveBank] = BattleScript_NoMovesLeft; + gBattlescriptPtrsForSelection[gActiveBank] = BattleScript_NoMovesLeft; } else { diff --git a/sym_ewram.txt b/sym_ewram.txt index 287bc4a5d..aa069b325 100644 --- a/sym_ewram.txt +++ b/sym_ewram.txt @@ -382,7 +382,7 @@ gBattlescriptCurrInstr: @ 2024214 gActionForBanks: @ 202421C .space 0x4 -gUnknown_02024220: @ 2024220 +gBattlescriptPtrsForSelection: @ 2024220 .space 0x10 gUnknown_02024230: @ 2024230 @@ -1671,7 +1671,7 @@ gUnknown_0203BD28: @ 203BD28 gRecordedBattleRngSeed: @ 203BD2C .space 0x4 -gUnknown_0203BD30: @ 203BD30 +gBattlePalaceMoveSelectionRngValue: @ 203BD30 .space 0x4 gUnknown_0203BD34: @ 203BD34