summaryrefslogtreecommitdiff
path: root/src/battle_script_commands.c
diff options
context:
space:
mode:
authorKaz <kazbloxmc@gmail.com>2020-05-24 15:25:02 -0400
committerKaz <kazbloxmc@gmail.com>2020-05-24 15:25:02 -0400
commitdc27a171ee9b486424ee0e74a84fb9e3ffc7a40e (patch)
tree0fbb977fe8844a5c592f69a96fc550d2cf65592b /src/battle_script_commands.c
parent52d3cc8dac65153442d3ceed724a53546681afcf (diff)
battle_script_commands.c: WIP fix for atk24
Diffstat (limited to 'src/battle_script_commands.c')
-rw-r--r--src/battle_script_commands.c91
1 files changed, 46 insertions, 45 deletions
diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c
index 32887efc1..2e992e027 100644
--- a/src/battle_script_commands.c
+++ b/src/battle_script_commands.c
@@ -5576,64 +5576,65 @@ static void atk23_getexp(void)
static void atk24(void)
{
u16 HP_count = 0;
- int i;
- if (gBattleControllerExecFlags) {return;}
-
- for (i = 0; i < 6; i++)
- {
- if (GetMonData(&gPlayerParty[i], MON_DATA_SPECIES) && !GetMonData(&gPlayerParty[i], MON_DATA_IS_EGG))
- HP_count += GetMonData(&gPlayerParty[i], MON_DATA_HP);
- }
-
- if (HP_count == 0)
- gBattleOutcome |= B_OUTCOME_LOST;
-
- for (HP_count = 0, i = 0; i < 6; i++)
- {
- if (GetMonData(&gEnemyParty[i], MON_DATA_SPECIES) && !GetMonData(&gEnemyParty[i], MON_DATA_IS_EGG))
- HP_count += GetMonData(&gEnemyParty[i], MON_DATA_HP);
- }
-
- if (!HP_count)
- gBattleOutcome |= B_OUTCOME_WON;
-
- if (!gBattleOutcome && (gBattleTypeFlags & BATTLE_TYPE_LINK))
- {
- register int found1 asm("r2");
- register int found2 asm("r4");
-
- //I can't for the love of god decompile that part
+ s32 i;
+ s32 found1;
+ s32 found2;
- for (found1 = 0, i = 0; i < gBattlersCount; i += 2)
+ // maybe it should be like this, plethora of other atk routines do it too
+ if (gBattleControllerExecFlags == 0) // cmp r0, 0
+ { // beq 0x80209C6
+ for (i = 0; i < 6; i++)
{
- if ((gHitMarker & HITMARKER_UNK(i)) && !gSpecialStatuses[i].flag40)
- found1++;
+ if (GetMonData(&gPlayerParty[i], MON_DATA_SPECIES) && !GetMonData(&gPlayerParty[i], MON_DATA_IS_EGG))
+ HP_count += GetMonData(&gPlayerParty[i], MON_DATA_HP);
}
- for (found2 = 0, i = 1; i < gBattlersCount; i += 2)
+ if (HP_count == 0)
+ gBattleOutcome |= B_OUTCOME_LOST;
+
+ for (HP_count = 0, i = 0; i < 6; i++)
{
- if ((gHitMarker & HITMARKER_UNK(i)) && !gSpecialStatuses[i].flag40)
- found2++;
+ if (GetMonData(&gEnemyParty[i], MON_DATA_SPECIES) && !GetMonData(&gEnemyParty[i], MON_DATA_IS_EGG))
+ HP_count += GetMonData(&gEnemyParty[i], MON_DATA_HP);
}
- if (gBattleTypeFlags & BATTLE_TYPE_MULTI)
+ if (!HP_count)
+ gBattleOutcome |= B_OUTCOME_WON;
+
+ if (!gBattleOutcome && (gBattleTypeFlags & BATTLE_TYPE_LINK))
{
- if (found2 + found1 > 1)
- gBattlescriptCurrInstr = T2_READ_PTR(gBattlescriptCurrInstr + 1);
+ for (found1 = 0, i = 0; i < gBattlersCount; i += 2)
+ {
+ if ((gHitMarker & HITMARKER_UNK(i)) && !gSpecialStatuses[i].flag40)
+ found1++;
+ }
+
+ for (found2 = 0, i = 1; i < gBattlersCount; i += 2)
+ {
+ if ((gHitMarker & HITMARKER_UNK(i)) && !gSpecialStatuses[i].flag40)
+ found2++;
+ }
+
+ if (gBattleTypeFlags & BATTLE_TYPE_MULTI)
+ {
+ if (found2 + found1 > 1)
+ gBattlescriptCurrInstr = T2_READ_PTR(gBattlescriptCurrInstr + 1);
+ else
+ gBattlescriptCurrInstr += 5;
+ }
else
- gBattlescriptCurrInstr += 5;
+ {
+ if (found2 != 0 && found1 != 0)
+ gBattlescriptCurrInstr = T2_READ_PTR(gBattlescriptCurrInstr + 1);
+ else
+ gBattlescriptCurrInstr += 5;
+ }
}
- else
+ else // b 0x8020B46
{
- if (found2 != 0 && found1 != 0)
- gBattlescriptCurrInstr = T2_READ_PTR(gBattlescriptCurrInstr + 1);
- else
- gBattlescriptCurrInstr += 5;
+ gBattlescriptCurrInstr += 5;
}
}
- else
- gBattlescriptCurrInstr += 5;
-
}
#else
NAKED