From a2458d966c19fe837cd459878af28c645a7de2a2 Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Thu, 1 Mar 2018 15:02:44 +0100 Subject: [PATCH] match hidden power calc --- src/battle_script_commands.c | 176 +++-------------------------------- 1 file changed, 15 insertions(+), 161 deletions(-) diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index d1945f5ccd..d1a18e38f0 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -9093,181 +9093,35 @@ static void atkC0_recoverbasedonsunlight(void) } } -#ifdef NONMATCHING static void atkC1_hiddenpowercalc(void) { - u32 powerBits = 0; - u32 typeBits = 0; + u8 powerBits; + u8 typeBits; - powerBits |= ((gBattleMons[gBattlerAttacker].hpIV & 2) >> 1); - powerBits |= ((gBattleMons[gBattlerAttacker].attackIV & 2) << 0); - powerBits |= ((gBattleMons[gBattlerAttacker].defenseIV & 2) << 1); - powerBits |= ((gBattleMons[gBattlerAttacker].speedIV & 2) << 2); - powerBits |= ((gBattleMons[gBattlerAttacker].spAttackIV & 2) << 3); - powerBits |= ((gBattleMons[gBattlerAttacker].spDefenseIV & 2) << 4); + powerBits = ((gBattleMons[gBattlerAttacker].hpIV & 2) >> 1) + | ((gBattleMons[gBattlerAttacker].attackIV & 2) << 0) + | ((gBattleMons[gBattlerAttacker].defenseIV & 2) << 1) + | ((gBattleMons[gBattlerAttacker].speedIV & 2) << 2) + | ((gBattleMons[gBattlerAttacker].spAttackIV & 2) << 3) + | ((gBattleMons[gBattlerAttacker].spDefenseIV & 2) << 4); - typeBits |= ((gBattleMons[gBattlerAttacker].hpIV & 1) << 0); - typeBits |= ((gBattleMons[gBattlerAttacker].attackIV & 1) << 1); - typeBits |= ((gBattleMons[gBattlerAttacker].defenseIV & 1) << 2); - typeBits |= ((gBattleMons[gBattlerAttacker].speedIV & 1) << 3); - typeBits |= ((gBattleMons[gBattlerAttacker].spAttackIV & 1) << 4); - typeBits |= ((gBattleMons[gBattlerAttacker].spDefenseIV & 1) << 5); + typeBits = ((gBattleMons[gBattlerAttacker].hpIV & 1) << 0) + | ((gBattleMons[gBattlerAttacker].attackIV & 1) << 1) + | ((gBattleMons[gBattlerAttacker].defenseIV & 1) << 2) + | ((gBattleMons[gBattlerAttacker].speedIV & 1) << 3) + | ((gBattleMons[gBattlerAttacker].spAttackIV & 1) << 4) + | ((gBattleMons[gBattlerAttacker].spDefenseIV & 1) << 5); gDynamicBasePower = (40 * powerBits) / 63 + 30; gBattleStruct->dynamicMoveType = (15 * typeBits) / 63 + 1; - if (gBattleStruct->dynamicMoveType > 8) + if (gBattleStruct->dynamicMoveType >= TYPE_MYSTERY) gBattleStruct->dynamicMoveType++; gBattleStruct->dynamicMoveType |= 0xC0; gBattlescriptCurrInstr++; } -#else -ASM_DIRECT -static void atkC1_hiddenpowercalc(void) -{ - asm(".syntax unified\n\ - push {r4-r7,lr}\n\ - mov r7, r10\n\ - mov r6, r9\n\ - mov r5, r8\n\ - push {r5-r7}\n\ - ldr r2, =gBattleMons\n\ - ldr r0, =gBattlerAttacker\n\ - ldrb r1, [r0]\n\ - movs r0, 0x58\n\ - adds r4, r1, 0\n\ - muls r4, r0\n\ - adds r4, r2\n\ - ldrb r0, [r4, 0x14]\n\ - mov r10, r0\n\ - mov r7, r10\n\ - lsls r7, 27\n\ - adds r0, r7, 0\n\ - lsrs r0, 27\n\ - mov r10, r0\n\ - movs r1, 0x2\n\ - mov r2, r10\n\ - ands r2, r1\n\ - asrs r2, 1\n\ - ldrh r7, [r4, 0x14]\n\ - mov r9, r7\n\ - mov r0, r9\n\ - lsls r0, 22\n\ - mov r9, r0\n\ - lsrs r3, r0, 27\n\ - adds r0, r1, 0\n\ - ands r0, r3\n\ - orrs r2, r0\n\ - ldrb r7, [r4, 0x15]\n\ - mov r8, r7\n\ - mov r0, r8\n\ - lsls r0, 25\n\ - mov r8, r0\n\ - lsrs r3, r0, 27\n\ - adds r0, r1, 0\n\ - ands r0, r3\n\ - lsls r0, 1\n\ - orrs r2, r0\n\ - ldr r6, [r4, 0x14]\n\ - lsls r6, 12\n\ - lsrs r3, r6, 27\n\ - adds r0, r1, 0\n\ - ands r0, r3\n\ - lsls r0, 2\n\ - orrs r2, r0\n\ - ldrh r5, [r4, 0x16]\n\ - lsls r5, 23\n\ - lsrs r3, r5, 27\n\ - adds r0, r1, 0\n\ - ands r0, r3\n\ - lsls r0, 3\n\ - orrs r2, r0\n\ - ldrb r3, [r4, 0x17]\n\ - lsls r3, 26\n\ - lsrs r0, r3, 27\n\ - ands r1, r0\n\ - lsls r1, 4\n\ - orrs r2, r1\n\ - movs r1, 0x1\n\ - adds r4, r1, 0\n\ - mov r7, r10\n\ - ands r4, r7\n\ - mov r0, r9\n\ - lsrs r0, 27\n\ - mov r9, r0\n\ - adds r0, r1, 0\n\ - mov r7, r9\n\ - ands r0, r7\n\ - lsls r0, 1\n\ - orrs r4, r0\n\ - mov r0, r8\n\ - lsrs r0, 27\n\ - mov r8, r0\n\ - adds r0, r1, 0\n\ - mov r7, r8\n\ - ands r0, r7\n\ - lsls r0, 2\n\ - orrs r4, r0\n\ - lsrs r6, 27\n\ - adds r0, r1, 0\n\ - ands r0, r6\n\ - lsls r0, 3\n\ - orrs r4, r0\n\ - lsrs r5, 27\n\ - adds r0, r1, 0\n\ - ands r0, r5\n\ - lsls r0, 4\n\ - orrs r4, r0\n\ - lsrs r3, 27\n\ - ands r1, r3\n\ - lsls r1, 5\n\ - orrs r4, r1\n\ - ldr r5, =gDynamicBasePower\n\ - lsls r0, r2, 2\n\ - adds r0, r2\n\ - lsls r0, 3\n\ - movs r1, 0x3F\n\ - bl __divsi3\n\ - adds r0, 0x1E\n\ - strh r0, [r5]\n\ - ldr r6, =gBattleStruct\n\ - ldr r5, [r6]\n\ - lsls r0, r4, 4\n\ - subs r0, r4\n\ - movs r1, 0x3F\n\ - bl __divsi3\n\ - adds r0, 0x1\n\ - strb r0, [r5, 0x13]\n\ - ldr r1, [r6]\n\ - ldrb r0, [r1, 0x13]\n\ - cmp r0, 0x8\n\ - bls _080544F0\n\ - adds r0, 0x1\n\ - strb r0, [r1, 0x13]\n\ -_080544F0:\n\ - ldr r2, [r6]\n\ - ldrb r0, [r2, 0x13]\n\ - movs r1, 0xC0\n\ - orrs r0, r1\n\ - strb r0, [r2, 0x13]\n\ - ldr r1, =gBattlescriptCurrInstr\n\ - ldr r0, [r1]\n\ - adds r0, 0x1\n\ - str r0, [r1]\n\ - pop {r3-r5}\n\ - mov r8, r3\n\ - mov r9, r4\n\ - mov r10, r5\n\ - pop {r4-r7}\n\ - pop {r0}\n\ - bx r0\n\ - .pool\n\ - .syntax divided"); -} -#endif // NONMATCHING - static void atkC2_selectfirstvalidtarget(void) { for (gBattlerTarget = 0; gBattlerTarget < gBattlersCount; gBattlerTarget++)