summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/battle_ai_script_commands.c333
-rw-r--r--src/battle_ai_switch_items.c2
-rw-r--r--src/battle_controller_link_opponent.c1
-rw-r--r--src/battle_controller_link_partner.c1
-rw-r--r--src/battle_controller_opponent.c5
-rw-r--r--src/battle_controller_player.c18
-rw-r--r--src/battle_controller_player_partner.c3
-rw-r--r--src/battle_controller_recorded_player.c1
-rw-r--r--src/battle_controllers.c1
-rw-r--r--src/battle_gfx_sfx_util.c9
-rw-r--r--src/battle_main.c211
-rw-r--r--src/battle_message.c2
-rw-r--r--src/battle_script_commands.c409
-rw-r--r--src/battle_setup.c162
-rw-r--r--src/battle_util.c3
-rw-r--r--src/blit.c209
-rw-r--r--src/gym_leader_rematch.c106
-rwxr-xr-xsrc/item_menu.c1
-rw-r--r--src/lilycove_lady.c84
-rw-r--r--src/pokemon.c4
-rw-r--r--src/pokemon_summary_screen.c5
-rw-r--r--src/text.c12
-rw-r--r--src/window.c23
23 files changed, 881 insertions, 724 deletions
diff --git a/src/battle_ai_script_commands.c b/src/battle_ai_script_commands.c
index d6ccf9305..46fe7a89c 100644
--- a/src/battle_ai_script_commands.c
+++ b/src/battle_ai_script_commands.c
@@ -45,7 +45,6 @@ in order to read the next command correctly. refer to battle_ai_scripts.s for th
AI scripts.
*/
-extern const struct BattleMove gBattleMoves[];
extern const u8 * const gBattleAI_ScriptsTable[];
extern u32 GetAiScriptsInRecordedBattle();
@@ -346,7 +345,7 @@ void BattleAI_SetupAIData(u8 defaultScoreMoves)
}
gBattleResources->AI_ScriptsStack->size = 0;
sBattler_AI = gActiveBattler;
- // decide a random target bank in doubles
+ // decide a random target battlerId in doubles
if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE)
{
gBattlerTarget = (Random() & BIT_FLANK) + (GetBattlerSide(gActiveBattler) ^ BIT_SIDE);
@@ -620,32 +619,32 @@ static void RecordLastUsedMoveByTarget(void)
}
}
-void ClearBattlerMoveHistory(u8 bank)
+void ClearBattlerMoveHistory(u8 battlerId)
{
s32 i;
for (i = 0; i < 4; i++)
- gBattleResources->battleHistory->usedMoves[bank].moves[i] = 0;
+ gBattleResources->battleHistory->usedMoves[battlerId].moves[i] = 0;
}
-void RecordAbilityBattle(u8 bank, u8 abilityId)
+void RecordAbilityBattle(u8 battlerId, u8 abilityId)
{
- gBattleResources->battleHistory->abilities[bank] = abilityId;
+ gBattleResources->battleHistory->abilities[battlerId] = abilityId;
}
-void ClearBattlerAbilityHistory(u8 bank)
+void ClearBattlerAbilityHistory(u8 battlerId)
{
- gBattleResources->battleHistory->abilities[bank] = 0;
+ gBattleResources->battleHistory->abilities[battlerId] = 0;
}
-void RecordItemEffectBattle(u8 bank, u8 itemEffect)
+void RecordItemEffectBattle(u8 battlerId, u8 itemEffect)
{
- gBattleResources->battleHistory->itemEffects[bank] = itemEffect;
+ gBattleResources->battleHistory->itemEffects[battlerId] = itemEffect;
}
-void ClearBankItemEffectHistory(u8 bank)
+void ClearBankItemEffectHistory(u8 battlerId)
{
- gBattleResources->battleHistory->itemEffects[bank] = 0;
+ gBattleResources->battleHistory->itemEffects[battlerId] = 0;
}
static void BattleAICmd_if_random_less_than(void)
@@ -700,14 +699,14 @@ static void BattleAICmd_score(void)
static void BattleAICmd_if_hp_less_than(void)
{
- u16 bank;
+ u16 battlerId;
if (gAIScriptPtr[1] == AI_USER)
- bank = sBattler_AI;
+ battlerId = sBattler_AI;
else
- bank = gBattlerTarget;
+ battlerId = gBattlerTarget;
- if ((u32)(100 * gBattleMons[bank].hp / gBattleMons[bank].maxHP) < gAIScriptPtr[2])
+ if ((u32)(100 * gBattleMons[battlerId].hp / gBattleMons[battlerId].maxHP) < gAIScriptPtr[2])
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 3);
else
gAIScriptPtr += 7;
@@ -715,14 +714,14 @@ static void BattleAICmd_if_hp_less_than(void)
static void BattleAICmd_if_hp_more_than(void)
{
- u16 bank;
+ u16 battlerId;
if (gAIScriptPtr[1] == AI_USER)
- bank = sBattler_AI;
+ battlerId = sBattler_AI;
else
- bank = gBattlerTarget;
+ battlerId = gBattlerTarget;
- if ((u32)(100 * gBattleMons[bank].hp / gBattleMons[bank].maxHP) > gAIScriptPtr[2])
+ if ((u32)(100 * gBattleMons[battlerId].hp / gBattleMons[battlerId].maxHP) > gAIScriptPtr[2])
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 3);
else
gAIScriptPtr += 7;
@@ -730,14 +729,14 @@ static void BattleAICmd_if_hp_more_than(void)
static void BattleAICmd_if_hp_equal(void)
{
- u16 bank;
+ u16 battlerId;
if (gAIScriptPtr[1] == AI_USER)
- bank = sBattler_AI;
+ battlerId = sBattler_AI;
else
- bank = gBattlerTarget;
+ battlerId = gBattlerTarget;
- if ((u32)(100 * gBattleMons[bank].hp / gBattleMons[bank].maxHP) == gAIScriptPtr[2])
+ if ((u32)(100 * gBattleMons[battlerId].hp / gBattleMons[battlerId].maxHP) == gAIScriptPtr[2])
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 3);
else
gAIScriptPtr += 7;
@@ -745,14 +744,14 @@ static void BattleAICmd_if_hp_equal(void)
static void BattleAICmd_if_hp_not_equal(void)
{
- u16 bank;
+ u16 battlerId;
if (gAIScriptPtr[1] == AI_USER)
- bank = sBattler_AI;
+ battlerId = sBattler_AI;
else
- bank = gBattlerTarget;
+ battlerId = gBattlerTarget;
- if ((u32)(100 * gBattleMons[bank].hp / gBattleMons[bank].maxHP) != gAIScriptPtr[2])
+ if ((u32)(100 * gBattleMons[battlerId].hp / gBattleMons[battlerId].maxHP) != gAIScriptPtr[2])
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 3);
else
gAIScriptPtr += 7;
@@ -760,17 +759,17 @@ static void BattleAICmd_if_hp_not_equal(void)
static void BattleAICmd_if_status(void)
{
- u16 bank;
+ u16 battlerId;
u32 status;
if (gAIScriptPtr[1] == AI_USER)
- bank = sBattler_AI;
+ battlerId = sBattler_AI;
else
- bank = gBattlerTarget;
+ battlerId = gBattlerTarget;
status = AIScriptRead32(gAIScriptPtr + 2);
- if ((gBattleMons[bank].status1 & status) != 0)
+ if ((gBattleMons[battlerId].status1 & status) != 0)
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 6);
else
gAIScriptPtr += 10;
@@ -778,17 +777,17 @@ static void BattleAICmd_if_status(void)
static void BattleAICmd_if_not_status(void)
{
- u16 bank;
+ u16 battlerId;
u32 status;
if (gAIScriptPtr[1] == AI_USER)
- bank = sBattler_AI;
+ battlerId = sBattler_AI;
else
- bank = gBattlerTarget;
+ battlerId = gBattlerTarget;
status = AIScriptRead32(gAIScriptPtr + 2);
- if ((gBattleMons[bank].status1 & status) == 0)
+ if ((gBattleMons[battlerId].status1 & status) == 0)
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 6);
else
gAIScriptPtr += 10;
@@ -796,17 +795,17 @@ static void BattleAICmd_if_not_status(void)
static void BattleAICmd_if_status2(void)
{
- u16 bank;
+ u16 battlerId;
u32 status;
if (gAIScriptPtr[1] == AI_USER)
- bank = sBattler_AI;
+ battlerId = sBattler_AI;
else
- bank = gBattlerTarget;
+ battlerId = gBattlerTarget;
status = AIScriptRead32(gAIScriptPtr + 2);
- if ((gBattleMons[bank].status2 & status) != 0)
+ if ((gBattleMons[battlerId].status2 & status) != 0)
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 6);
else
gAIScriptPtr += 10;
@@ -814,17 +813,17 @@ static void BattleAICmd_if_status2(void)
static void BattleAICmd_if_not_status2(void)
{
- u16 bank;
+ u16 battlerId;
u32 status;
if (gAIScriptPtr[1] == AI_USER)
- bank = sBattler_AI;
+ battlerId = sBattler_AI;
else
- bank = gBattlerTarget;
+ battlerId = gBattlerTarget;
status = AIScriptRead32(gAIScriptPtr + 2);
- if ((gBattleMons[bank].status2 & status) == 0)
+ if ((gBattleMons[battlerId].status2 & status) == 0)
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 6);
else
gAIScriptPtr += 10;
@@ -832,17 +831,17 @@ static void BattleAICmd_if_not_status2(void)
static void BattleAICmd_if_status3(void)
{
- u16 bank;
+ u16 battlerId;
u32 status;
if (gAIScriptPtr[1] == AI_USER)
- bank = sBattler_AI;
+ battlerId = sBattler_AI;
else
- bank = gBattlerTarget;
+ battlerId = gBattlerTarget;
status = AIScriptRead32(gAIScriptPtr + 2);
- if ((gStatuses3[bank] & status) != 0)
+ if ((gStatuses3[battlerId] & status) != 0)
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 6);
else
gAIScriptPtr += 10;
@@ -850,17 +849,17 @@ static void BattleAICmd_if_status3(void)
static void BattleAICmd_if_not_status3(void)
{
- u16 bank;
+ u16 battlerId;
u32 status;
if (gAIScriptPtr[1] == AI_USER)
- bank = sBattler_AI;
+ battlerId = sBattler_AI;
else
- bank = gBattlerTarget;
+ battlerId = gBattlerTarget;
status = AIScriptRead32(gAIScriptPtr + 2);
- if ((gStatuses3[bank] & status) == 0)
+ if ((gStatuses3[battlerId] & status) == 0)
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 6);
else
gAIScriptPtr += 10;
@@ -868,15 +867,15 @@ static void BattleAICmd_if_not_status3(void)
static void BattleAICmd_if_side_affecting(void)
{
- u16 bank;
+ u16 battlerId;
u32 side, status;
if (gAIScriptPtr[1] == AI_USER)
- bank = sBattler_AI;
+ battlerId = sBattler_AI;
else
- bank = gBattlerTarget;
+ battlerId = gBattlerTarget;
- side = GET_BATTLER_SIDE(bank);
+ side = GET_BATTLER_SIDE(battlerId);
status = AIScriptRead32(gAIScriptPtr + 2);
if ((gSideStatuses[side] & status) != 0)
@@ -887,15 +886,15 @@ static void BattleAICmd_if_side_affecting(void)
static void BattleAICmd_if_not_side_affecting(void)
{
- u16 bank;
+ u16 battlerId;
u32 side, status;
if (gAIScriptPtr[1] == AI_USER)
- bank = sBattler_AI;
+ battlerId = sBattler_AI;
else
- bank = gBattlerTarget;
+ battlerId = gBattlerTarget;
- side = GET_BATTLER_SIDE(bank);
+ side = GET_BATTLER_SIDE(battlerId);
status = AIScriptRead32(gAIScriptPtr + 2);
if ((gSideStatuses[side] & status) == 0)
@@ -1123,9 +1122,9 @@ static void BattleAICmd_get_type(void)
gAIScriptPtr += 2;
}
-static u8 BattleAI_GetWantedBank(u8 bank)
+static u8 BattleAI_GetWantedBank(u8 battlerId)
{
- switch (bank)
+ switch (battlerId)
{
case AI_USER:
return sBattler_AI;
@@ -1141,9 +1140,9 @@ static u8 BattleAI_GetWantedBank(u8 bank)
static void BattleAICmd_is_of_type(void)
{
- u8 bank = BattleAI_GetWantedBank(gAIScriptPtr[1]);
+ u8 battlerId = BattleAI_GetWantedBank(gAIScriptPtr[1]);
- if(gBattleMons[bank].type1 == gAIScriptPtr[2] || gBattleMons[bank].type2 == gAIScriptPtr[2])
+ if(gBattleMons[battlerId].type1 == gAIScriptPtr[2] || gBattleMons[battlerId].type2 == gAIScriptPtr[2])
{
AI_THINKING_STRUCT->funcResult = TRUE;
}
@@ -1277,7 +1276,7 @@ static void BattleAICmd_nullsub_2B(void)
static void BattleAICmd_count_usable_party_mons(void)
{
- u8 bank;
+ u8 battlerId;
u8 bankOnField1, bankOnField2;
struct Pokemon *party;
int i;
@@ -1285,11 +1284,11 @@ static void BattleAICmd_count_usable_party_mons(void)
AI_THINKING_STRUCT->funcResult = 0;
if (gAIScriptPtr[1] == AI_USER)
- bank = sBattler_AI;
+ battlerId = sBattler_AI;
else
- bank = gBattlerTarget;
+ battlerId = gBattlerTarget;
- if (GetBattlerSide(bank) == B_SIDE_PLAYER)
+ if (GetBattlerSide(battlerId) == B_SIDE_PLAYER)
party = gPlayerParty;
else
party = gEnemyParty;
@@ -1297,14 +1296,14 @@ static void BattleAICmd_count_usable_party_mons(void)
if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE)
{
u32 position;
- bankOnField1 = gBattlerPartyIndexes[bank];
- position = GetBattlerPosition(bank) ^ BIT_FLANK;
+ bankOnField1 = gBattlerPartyIndexes[battlerId];
+ position = GetBattlerPosition(battlerId) ^ BIT_FLANK;
bankOnField2 = gBattlerPartyIndexes[GetBattlerAtPosition(position)];
}
- else // in singles there's only one bank by side
+ else // in singles there's only one battlerId by side
{
- bankOnField1 = gBattlerPartyIndexes[bank];
- bankOnField2 = gBattlerPartyIndexes[bank];
+ bankOnField1 = gBattlerPartyIndexes[battlerId];
+ bankOnField2 = gBattlerPartyIndexes[battlerId];
}
for (i = 0; i < PARTY_SIZE; i++)
@@ -1335,110 +1334,110 @@ static void BattleAICmd_get_considered_move_effect(void)
static void BattleAICmd_get_ability(void)
{
- u8 bank;
+ u8 battlerId;
if (gAIScriptPtr[1] == AI_USER)
- bank = sBattler_AI;
+ battlerId = sBattler_AI;
else
- bank = gBattlerTarget;
+ battlerId = gBattlerTarget;
- if (gActiveBattler != bank)
+ if (gActiveBattler != battlerId)
{
- if (BATTLE_HISTORY->abilities[bank] != 0)
+ if (BATTLE_HISTORY->abilities[battlerId] != 0)
{
- AI_THINKING_STRUCT->funcResult = BATTLE_HISTORY->abilities[bank];
+ AI_THINKING_STRUCT->funcResult = BATTLE_HISTORY->abilities[battlerId];
gAIScriptPtr += 2;
return;
}
// abilities that prevent fleeing.
- if (gBattleMons[bank].ability == ABILITY_SHADOW_TAG
- || gBattleMons[bank].ability == ABILITY_MAGNET_PULL
- || gBattleMons[bank].ability == ABILITY_ARENA_TRAP)
+ if (gBattleMons[battlerId].ability == ABILITY_SHADOW_TAG
+ || gBattleMons[battlerId].ability == ABILITY_MAGNET_PULL
+ || gBattleMons[battlerId].ability == ABILITY_ARENA_TRAP)
{
- AI_THINKING_STRUCT->funcResult = gBattleMons[bank].ability;
+ AI_THINKING_STRUCT->funcResult = gBattleMons[battlerId].ability;
gAIScriptPtr += 2;
return;
}
- if (gBaseStats[gBattleMons[bank].species].ability1 != ABILITY_NONE)
+ if (gBaseStats[gBattleMons[battlerId].species].ability1 != ABILITY_NONE)
{
- if (gBaseStats[gBattleMons[bank].species].ability2 != ABILITY_NONE)
+ if (gBaseStats[gBattleMons[battlerId].species].ability2 != ABILITY_NONE)
{
// AI has no knowledge of opponent, so it guesses which ability.
if (Random() & 1)
{
- AI_THINKING_STRUCT->funcResult = gBaseStats[gBattleMons[bank].species].ability1;
+ AI_THINKING_STRUCT->funcResult = gBaseStats[gBattleMons[battlerId].species].ability1;
}
else
{
- AI_THINKING_STRUCT->funcResult = gBaseStats[gBattleMons[bank].species].ability2;
+ AI_THINKING_STRUCT->funcResult = gBaseStats[gBattleMons[battlerId].species].ability2;
}
}
else
{
- AI_THINKING_STRUCT->funcResult = gBaseStats[gBattleMons[bank].species].ability1; // it's definitely ability 1.
+ AI_THINKING_STRUCT->funcResult = gBaseStats[gBattleMons[battlerId].species].ability1; // it's definitely ability 1.
}
}
else
{
- AI_THINKING_STRUCT->funcResult = gBaseStats[gBattleMons[bank].species].ability2; // AI cant actually reach this part since every mon has at least 1 ability.
+ AI_THINKING_STRUCT->funcResult = gBaseStats[gBattleMons[battlerId].species].ability2; // AI cant actually reach this part since every mon has at least 1 ability.
}
}
else
{
// The AI knows its own ability.
- AI_THINKING_STRUCT->funcResult = gBattleMons[bank].ability;
+ AI_THINKING_STRUCT->funcResult = gBattleMons[battlerId].ability;
}
gAIScriptPtr += 2;
}
static void BattleAICmd_check_ability(void)
{
- u32 bank = BattleAI_GetWantedBank(gAIScriptPtr[1]);
+ u32 battlerId = BattleAI_GetWantedBank(gAIScriptPtr[1]);
u32 ability = gAIScriptPtr[2];
if (gAIScriptPtr[1] == AI_TARGET || gAIScriptPtr[1] == AI_TARGET_PARTNER)
{
- if (BATTLE_HISTORY->abilities[bank] != 0)
+ if (BATTLE_HISTORY->abilities[battlerId] != 0)
{
- ability = BATTLE_HISTORY->abilities[bank];
+ ability = BATTLE_HISTORY->abilities[battlerId];
AI_THINKING_STRUCT->funcResult = ability;
}
// abilities that prevent fleeing.
- else if (gBattleMons[bank].ability == ABILITY_SHADOW_TAG
- || gBattleMons[bank].ability == ABILITY_MAGNET_PULL
- || gBattleMons[bank].ability == ABILITY_ARENA_TRAP)
+ else if (gBattleMons[battlerId].ability == ABILITY_SHADOW_TAG
+ || gBattleMons[battlerId].ability == ABILITY_MAGNET_PULL
+ || gBattleMons[battlerId].ability == ABILITY_ARENA_TRAP)
{
- ability = gBattleMons[bank].ability;
+ ability = gBattleMons[battlerId].ability;
}
- else if (gBaseStats[gBattleMons[bank].species].ability1 != ABILITY_NONE)
+ else if (gBaseStats[gBattleMons[battlerId].species].ability1 != ABILITY_NONE)
{
- if (gBaseStats[gBattleMons[bank].species].ability2 != ABILITY_NONE)
+ if (gBaseStats[gBattleMons[battlerId].species].ability2 != ABILITY_NONE)
{
u8 abilityDummyVariable = ability; // needed to match
- if (gBaseStats[gBattleMons[bank].species].ability1 != abilityDummyVariable
- && gBaseStats[gBattleMons[bank].species].ability2 != abilityDummyVariable)
+ if (gBaseStats[gBattleMons[battlerId].species].ability1 != abilityDummyVariable
+ && gBaseStats[gBattleMons[battlerId].species].ability2 != abilityDummyVariable)
{
- ability = gBaseStats[gBattleMons[bank].species].ability1;
+ ability = gBaseStats[gBattleMons[battlerId].species].ability1;
}
else
ability = 0;
}
else
{
- ability = gBaseStats[gBattleMons[bank].species].ability1;
+ ability = gBaseStats[gBattleMons[battlerId].species].ability1;
}
}
else
{
- ability = gBaseStats[gBattleMons[bank].species].ability2; // AI cant actually reach this part since every mon has at least 1 ability.
+ ability = gBaseStats[gBattleMons[battlerId].species].ability2; // AI cant actually reach this part since every mon has at least 1 ability.
}
}
else
{
// The AI knows its own or partner's ability.
- ability = gBattleMons[bank].ability;
+ ability = gBattleMons[battlerId].ability;
}
if (ability == 0)
{
@@ -1546,19 +1545,19 @@ static void BattleAICmd_if_status_in_party(void)
struct Pokemon *party;
int i;
u32 statusToCompareTo;
- u8 bank;
+ u8 battlerId;
switch(gAIScriptPtr[1])
{
case AI_USER:
- bank = sBattler_AI;
+ battlerId = sBattler_AI;
break;
default:
- bank = gBattlerTarget;
+ battlerId = gBattlerTarget;
break;
}
- party = (GetBattlerSide(bank) == B_SIDE_PLAYER) ? gPlayerParty : gEnemyParty;
+ party = (GetBattlerSide(battlerId) == B_SIDE_PLAYER) ? gPlayerParty : gEnemyParty;
statusToCompareTo = AIScriptRead32(gAIScriptPtr + 2);
@@ -1583,19 +1582,19 @@ static void BattleAICmd_if_status_not_in_party(void)
struct Pokemon *party;
int i;
u32 statusToCompareTo;
- u8 bank;
+ u8 battlerId;
switch(gAIScriptPtr[1])
{
case 1:
- bank = sBattler_AI;
+ battlerId = sBattler_AI;
break;
default:
- bank = gBattlerTarget;
+ battlerId = gBattlerTarget;
break;
}
- party = (GetBattlerSide(bank) == B_SIDE_PLAYER) ? gPlayerParty : gEnemyParty;
+ party = (GetBattlerSide(battlerId) == B_SIDE_PLAYER) ? gPlayerParty : gEnemyParty;
statusToCompareTo = AIScriptRead32(gAIScriptPtr + 2);
@@ -1646,14 +1645,14 @@ static void BattleAICmd_if_not_effect(void)
static void BattleAICmd_if_stat_level_less_than(void)
{
- u32 bank;
+ u32 battlerId;
if (gAIScriptPtr[1] == AI_USER)
- bank = sBattler_AI;
+ battlerId = sBattler_AI;
else
- bank = gBattlerTarget;
+ battlerId = gBattlerTarget;
- if (gBattleMons[bank].statStages[gAIScriptPtr[2]] < gAIScriptPtr[3])
+ if (gBattleMons[battlerId].statStages[gAIScriptPtr[2]] < gAIScriptPtr[3])
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 4);
else
gAIScriptPtr += 8;
@@ -1661,14 +1660,14 @@ static void BattleAICmd_if_stat_level_less_than(void)
static void BattleAICmd_if_stat_level_more_than(void)
{
- u32 bank;
+ u32 battlerId;
if (gAIScriptPtr[1] == AI_USER)
- bank = sBattler_AI;
+ battlerId = sBattler_AI;
else
- bank = gBattlerTarget;
+ battlerId = gBattlerTarget;
- if (gBattleMons[bank].statStages[gAIScriptPtr[2]] > gAIScriptPtr[3])
+ if (gBattleMons[battlerId].statStages[gAIScriptPtr[2]] > gAIScriptPtr[3])
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 4);
else
gAIScriptPtr += 8;
@@ -1676,14 +1675,14 @@ static void BattleAICmd_if_stat_level_more_than(void)
static void BattleAICmd_if_stat_level_equal(void)
{
- u32 bank;
+ u32 battlerId;
if (gAIScriptPtr[1] == AI_USER)
- bank = sBattler_AI;
+ battlerId = sBattler_AI;
else
- bank = gBattlerTarget;
+ battlerId = gBattlerTarget;
- if (gBattleMons[bank].statStages[gAIScriptPtr[2]] == gAIScriptPtr[3])
+ if (gBattleMons[battlerId].statStages[gAIScriptPtr[2]] == gAIScriptPtr[3])
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 4);
else
gAIScriptPtr += 8;
@@ -1691,14 +1690,14 @@ static void BattleAICmd_if_stat_level_equal(void)
static void BattleAICmd_if_stat_level_not_equal(void)
{
- u32 bank;
+ u32 battlerId;
if (gAIScriptPtr[1] == AI_USER)
- bank = sBattler_AI;
+ battlerId = sBattler_AI;
else
- bank = gBattlerTarget;
+ battlerId = gBattlerTarget;
- if (gBattleMons[bank].statStages[gAIScriptPtr[2]] != gAIScriptPtr[3])
+ if (gBattleMons[battlerId].statStages[gAIScriptPtr[2]] != gAIScriptPtr[3])
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 4);
else
gAIScriptPtr += 8;
@@ -1940,16 +1939,16 @@ static void BattleAICmd_if_doesnt_have_move_with_effect(void)
static void BattleAICmd_if_any_move_disabled_or_encored(void)
{
- u8 bank;
+ u8 battlerId;
if (gAIScriptPtr[1] == AI_USER)
- bank = sBattler_AI;
+ battlerId = sBattler_AI;
else
- bank = gBattlerTarget;
+ battlerId = gBattlerTarget;
if (gAIScriptPtr[2] == 0)
{
- if (gDisableStructs[bank].disabledMove == 0)
+ if (gDisableStructs[battlerId].disabledMove == 0)
{
gAIScriptPtr += 7;
return;
@@ -1962,7 +1961,7 @@ static void BattleAICmd_if_any_move_disabled_or_encored(void)
gAIScriptPtr += 7;
return;
}
- else if (gDisableStructs[bank].encoredMove != 0)
+ else if (gDisableStructs[battlerId].encoredMove != 0)
{
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 3);
return;
@@ -2018,31 +2017,31 @@ static void BattleAICmd_watch(void)
static void BattleAICmd_get_hold_effect(void)
{
- u8 bank;
+ u8 battlerId;
if (gAIScriptPtr[1] == AI_USER)
- bank = sBattler_AI;
+ battlerId = sBattler_AI;
else
- bank = gBattlerTarget;
+ battlerId = gBattlerTarget;
- if (gActiveBattler != bank)
- AI_THINKING_STRUCT->funcResult = ItemId_GetHoldEffect(BATTLE_HISTORY->itemEffects[bank]);
+ if (gActiveBattler != battlerId)
+ AI_THINKING_STRUCT->funcResult = ItemId_GetHoldEffect(BATTLE_HISTORY->itemEffects[battlerId]);
else
- AI_THINKING_STRUCT->funcResult = ItemId_GetHoldEffect(gBattleMons[bank].item);
+ AI_THINKING_STRUCT->funcResult = ItemId_GetHoldEffect(gBattleMons[battlerId].item);
gAIScriptPtr += 2;
}
static void BattleAICmd_if_holds_item(void)
{
- u8 bank = BattleAI_GetWantedBank(gAIScriptPtr[1]);
+ u8 battlerId = BattleAI_GetWantedBank(gAIScriptPtr[1]);
u16 item;
u8 var1, var2;
- if ((bank & BIT_SIDE) == (sBattler_AI & BIT_SIDE))
- item = gBattleMons[bank].item;
+ if ((battlerId & BIT_SIDE) == (sBattler_AI & BIT_SIDE))
+ item = gBattleMons[battlerId].item;
else
- item = BATTLE_HISTORY->itemEffects[bank];
+ item = BATTLE_HISTORY->itemEffects[battlerId];
// UB: doesn't properly read an unaligned u16
var2 = gAIScriptPtr[2];
@@ -2056,42 +2055,42 @@ static void BattleAICmd_if_holds_item(void)
static void BattleAICmd_get_gender(void)
{
- u8 bank;
+ u8 battlerId;
if (gAIScriptPtr[1] == AI_USER)
- bank = sBattler_AI;
+ battlerId = sBattler_AI;
else
- bank = gBattlerTarget;
+ battlerId = gBattlerTarget;
- AI_THINKING_STRUCT->funcResult = GetGenderFromSpeciesAndPersonality(gBattleMons[bank].species, gBattleMons[bank].personality);
+ AI_THINKING_STRUCT->funcResult = GetGenderFromSpeciesAndPersonality(gBattleMons[battlerId].species, gBattleMons[battlerId].personality);
gAIScriptPtr += 2;
}
static void BattleAICmd_is_first_turn_for(void)
{
- u8 bank;
+ u8 battlerId;
if (gAIScriptPtr[1] == AI_USER)
- bank = sBattler_AI;
+ battlerId = sBattler_AI;
else
- bank = gBattlerTarget;
+ battlerId = gBattlerTarget;
- AI_THINKING_STRUCT->funcResult = gDisableStructs[bank].isFirstTurn;
+ AI_THINKING_STRUCT->funcResult = gDisableStructs[battlerId].isFirstTurn;
gAIScriptPtr += 2;
}
static void BattleAICmd_get_stockpile_count(void)
{
- u8 bank;
+ u8 battlerId;
if (gAIScriptPtr[1] == AI_USER)
- bank = sBattler_AI;
+ battlerId = sBattler_AI;
else
- bank = gBattlerTarget;
+ battlerId = gBattlerTarget;
- AI_THINKING_STRUCT->funcResult = gDisableStructs[bank].stockpileCounter;
+ AI_THINKING_STRUCT->funcResult = gDisableStructs[battlerId].stockpileCounter;
gAIScriptPtr += 2;
}
@@ -2105,18 +2104,18 @@ static void BattleAICmd_is_double_battle(void)
static void BattleAICmd_get_used_held_item(void)
{
- u8 bank;
+ u8 battlerId;
if (gAIScriptPtr[1] == AI_USER)
- bank = sBattler_AI;
+ battlerId = sBattler_AI;
else
- bank = gBattlerTarget;
+ battlerId = gBattlerTarget;
// This is likely a leftover from Ruby's code and its ugly ewram access
#ifdef NONMATCHING
- AI_THINKING_STRUCT->funcResult = gBattleStruct->usedHeldItems[bank];
+ AI_THINKING_STRUCT->funcResult = gBattleStruct->usedHeldItems[battlerId];
#else
- AI_THINKING_STRUCT->funcResult = *(u8*)((u8*)(gBattleStruct) + offsetof(struct BattleStruct, usedHeldItems) + (bank * 2));
+ AI_THINKING_STRUCT->funcResult = *(u8*)((u8*)(gBattleStruct) + offsetof(struct BattleStruct, usedHeldItems) + (battlerId * 2));
#endif // NONMATCHING
gAIScriptPtr += 2;
@@ -2145,14 +2144,14 @@ static void BattleAICmd_get_move_effect_from_result(void)
static void BattleAICmd_get_protect_count(void)
{
- u8 bank;
+ u8 battlerId;
if (gAIScriptPtr[1] == AI_USER)
- bank = sBattler_AI;
+ battlerId = sBattler_AI;
else
- bank = gBattlerTarget;
+ battlerId = gBattlerTarget;
- AI_THINKING_STRUCT->funcResult = gDisableStructs[bank].protectUses;
+ AI_THINKING_STRUCT->funcResult = gDisableStructs[battlerId].protectUses;
gAIScriptPtr += 2;
}
@@ -2255,9 +2254,9 @@ static void BattleAICmd_if_target_is_ally(void)
static void BattleAICmd_if_flash_fired(void)
{
- u8 bank = BattleAI_GetWantedBank(gAIScriptPtr[1]);
+ u8 battlerId = BattleAI_GetWantedBank(gAIScriptPtr[1]);
- if (gBattleResources->flags->flags[bank] & UNKNOWN_FLAG_FLASH_FIRE)
+ if (gBattleResources->flags->flags[battlerId] & UNKNOWN_FLAG_FLASH_FIRE)
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 2);
else
gAIScriptPtr += 6;
diff --git a/src/battle_ai_switch_items.c b/src/battle_ai_switch_items.c
index c3bb0d422..5426cc774 100644
--- a/src/battle_ai_switch_items.c
+++ b/src/battle_ai_switch_items.c
@@ -9,8 +9,6 @@
#include "util.h"
#include "constants/items.h"
-extern const struct BattleMove gBattleMoves[];
-extern const u8 gTypeEffectiveness[];
extern const u8 * const gItemEffectTable[]; // todo: fix once struct is declared
// this file's functions
diff --git a/src/battle_controller_link_opponent.c b/src/battle_controller_link_opponent.c
index 6e6968786..cc6528f5f 100644
--- a/src/battle_controller_link_opponent.c
+++ b/src/battle_controller_link_opponent.c
@@ -32,7 +32,6 @@ extern struct MusicPlayerInfo gMPlayInfo_BGM;
extern struct UnusedControllerStruct gUnknown_02022D0C;
extern const struct CompressedSpritePalette gTrainerFrontPicPaletteTable[];
-extern const struct BattleMove gBattleMoves[];
extern void sub_8172EF0(u8 bank, struct Pokemon *mon);
extern void sub_806A068(u16, u8);
diff --git a/src/battle_controller_link_partner.c b/src/battle_controller_link_partner.c
index 476a95ad1..6ca50dc5c 100644
--- a/src/battle_controller_link_partner.c
+++ b/src/battle_controller_link_partner.c
@@ -31,7 +31,6 @@ extern struct UnusedControllerStruct gUnknown_02022D0C;
extern const struct CompressedSpritePalette gTrainerFrontPicPaletteTable[];
extern const struct CompressedSpritePalette gTrainerBackPicPaletteTable[];
-extern const struct BattleMove gBattleMoves[];
extern void sub_8172EF0(u8 bank, struct Pokemon *mon);
extern void sub_806A068(u16, u8);
diff --git a/src/battle_controller_opponent.c b/src/battle_controller_opponent.c
index 54d6434a3..e88b586b1 100644
--- a/src/battle_controller_opponent.c
+++ b/src/battle_controller_opponent.c
@@ -35,7 +35,6 @@ extern struct MusicPlayerInfo gMPlayInfo_BGM;
extern struct UnusedControllerStruct gUnknown_02022D0C;
extern const struct CompressedSpritePalette gTrainerFrontPicPaletteTable[];
-extern const struct BattleMove gBattleMoves[];
extern void sub_8172EF0(u8 bank, struct Pokemon *mon);
extern void sub_806A068(u16, u8);
@@ -1563,7 +1562,7 @@ static void OpponentHandleChooseMove(void)
BtlController_EmitTwoReturnValues(1, 15, gBattlerTarget);
break;
default:
- if (gBattleMoves[moveInfo->moves[chosenMoveId]].target & (MOVE_TARGET_USER | MOVE_TARGET_x10))
+ if (gBattleMoves[moveInfo->moves[chosenMoveId]].target & (MOVE_TARGET_USER_OR_SELECTED | MOVE_TARGET_USER))
gBattlerTarget = gActiveBattler;
if (gBattleMoves[moveInfo->moves[chosenMoveId]].target & MOVE_TARGET_BOTH)
{
@@ -1585,7 +1584,7 @@ static void OpponentHandleChooseMove(void)
move = moveInfo->moves[chosenMoveId];
} while (move == MOVE_NONE);
- if (gBattleMoves[move].target & (MOVE_TARGET_USER | MOVE_TARGET_x10))
+ if (gBattleMoves[move].target & (MOVE_TARGET_USER_OR_SELECTED | MOVE_TARGET_USER))
BtlController_EmitTwoReturnValues(1, 10, (chosenMoveId) | (gActiveBattler << 8));
else if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE)
BtlController_EmitTwoReturnValues(1, 10, (chosenMoveId) | (GetBattlerAtPosition(Random() & 2) << 8));
diff --git a/src/battle_controller_player.c b/src/battle_controller_player.c
index f25566dd5..3a6aa4a6e 100644
--- a/src/battle_controller_player.c
+++ b/src/battle_controller_player.c
@@ -42,8 +42,6 @@ extern struct SpriteTemplate gUnknown_0202499C;
extern const struct CompressedSpritePalette gTrainerFrontPicPaletteTable[];
extern const struct CompressedSpritePalette gTrainerBackPicPaletteTable[];
-extern const u8 gTypeNames[][7];
-extern const struct BattleMove gBattleMoves[];
extern const u8 gText_BattleSwitchWhich[];
extern const u8 gText_MoveInterfacePP[];
@@ -432,7 +430,7 @@ static void HandleInputChooseTarget(void)
case B_POSITION_PLAYER_RIGHT:
if (gActiveBattler != gMultiUsePlayerCursor)
i++;
- else if (gBattleMoves[GetMonData(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_MOVE1 + gMoveSelectionCursor[gActiveBattler])].target & MOVE_TARGET_USER)
+ else if (gBattleMoves[GetMonData(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_MOVE1 + gMoveSelectionCursor[gActiveBattler])].target & MOVE_TARGET_USER_OR_SELECTED)
i++;
break;
case B_POSITION_OPPONENT_LEFT:
@@ -474,7 +472,7 @@ static void HandleInputChooseTarget(void)
case B_POSITION_PLAYER_RIGHT:
if (gActiveBattler != gMultiUsePlayerCursor)
i++;
- else if (gBattleMoves[GetMonData(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_MOVE1 + gMoveSelectionCursor[gActiveBattler])].target & MOVE_TARGET_USER)
+ else if (gBattleMoves[GetMonData(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_MOVE1 + gMoveSelectionCursor[gActiveBattler])].target & MOVE_TARGET_USER_OR_SELECTED)
i++;
break;
case B_POSITION_OPPONENT_LEFT:
@@ -508,7 +506,7 @@ static void HandleInputChooseMove(void)
if (moveInfo->moves[gMoveSelectionCursor[gActiveBattler]] == MOVE_CURSE)
{
if (moveInfo->monType1 != TYPE_GHOST && moveInfo->monType2 != TYPE_GHOST)
- moveTarget = MOVE_TARGET_x10;
+ moveTarget = MOVE_TARGET_USER;
else
moveTarget = MOVE_TARGET_SELECTED;
}
@@ -517,26 +515,26 @@ static void HandleInputChooseMove(void)
moveTarget = gBattleMoves[moveInfo->moves[gMoveSelectionCursor[gActiveBattler]]].target;
}
- if (moveTarget & MOVE_TARGET_x10)
+ if (moveTarget & MOVE_TARGET_USER)
gMultiUsePlayerCursor = gActiveBattler;
else
gMultiUsePlayerCursor = GetBattlerAtPosition((GetBattlerPosition(gActiveBattler) & BIT_SIDE) ^ BIT_SIDE);
if (!gBattleBufferA[gActiveBattler][1]) // not a double battle
{
- if (moveTarget & MOVE_TARGET_USER && !gBattleBufferA[gActiveBattler][2])
+ if (moveTarget & MOVE_TARGET_USER_OR_SELECTED && !gBattleBufferA[gActiveBattler][2])
canSelectTarget++;
}
else // double battle
{
- if (!(moveTarget & (MOVE_TARGET_RANDOM | MOVE_TARGET_BOTH | MOVE_TARGET_DEPENDS | MOVE_TARGET_FOES_AND_ALLY | MOVE_TARGET_OPPONENTS_FIELD | MOVE_TARGET_x10)))
+ if (!(moveTarget & (MOVE_TARGET_RANDOM | MOVE_TARGET_BOTH | MOVE_TARGET_DEPENDS | MOVE_TARGET_FOES_AND_ALLY | MOVE_TARGET_OPPONENTS_FIELD | MOVE_TARGET_USER)))
canSelectTarget++; // either selected or user
if (moveInfo->currentPp[gMoveSelectionCursor[gActiveBattler]] == 0)
{
canSelectTarget = FALSE;
}
- else if (!(moveTarget & (MOVE_TARGET_x10 | MOVE_TARGET_USER)) && CountAliveMonsInBattle(BATTLE_ALIVE_EXCEPT_ACTIVE) <= 1)
+ else if (!(moveTarget & (MOVE_TARGET_USER | MOVE_TARGET_USER_OR_SELECTED)) && CountAliveMonsInBattle(BATTLE_ALIVE_EXCEPT_ACTIVE) <= 1)
{
gMultiUsePlayerCursor = GetDefaultMoveTarget(gActiveBattler);
canSelectTarget = FALSE;
@@ -552,7 +550,7 @@ static void HandleInputChooseMove(void)
{
gBattlerControllerFuncs[gActiveBattler] = HandleInputChooseTarget;
- if (moveTarget & (MOVE_TARGET_x10 | MOVE_TARGET_USER))
+ if (moveTarget & (MOVE_TARGET_USER | MOVE_TARGET_USER_OR_SELECTED))
gMultiUsePlayerCursor = gActiveBattler;
else if (gAbsentBattlerFlags & gBitTable[GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT)])
gMultiUsePlayerCursor = GetBattlerAtPosition(B_POSITION_OPPONENT_RIGHT);
diff --git a/src/battle_controller_player_partner.c b/src/battle_controller_player_partner.c
index d2f85f85e..7569604d8 100644
--- a/src/battle_controller_player_partner.c
+++ b/src/battle_controller_player_partner.c
@@ -31,7 +31,6 @@ extern struct UnusedControllerStruct gUnknown_02022D0C;
extern const struct CompressedSpritePalette gTrainerFrontPicPaletteTable[];
extern const struct CompressedSpritePalette gTrainerBackPicPaletteTable[];
-extern const struct BattleMove gBattleMoves[];
extern void sub_81358F4(void);
extern void sub_8172EF0(u8 bank, struct Pokemon *mon);
@@ -1521,7 +1520,7 @@ static void PlayerPartnerHandleChooseMove(void)
BattleAI_SetupAIData(0xF);
chosenMoveId = BattleAI_ChooseMoveOrAction();
- if (gBattleMoves[moveInfo->moves[chosenMoveId]].target & (MOVE_TARGET_x10 | MOVE_TARGET_USER))
+ if (gBattleMoves[moveInfo->moves[chosenMoveId]].target & (MOVE_TARGET_USER | MOVE_TARGET_USER_OR_SELECTED))
gBattlerTarget = gActiveBattler;
if (gBattleMoves[moveInfo->moves[chosenMoveId]].target & MOVE_TARGET_BOTH)
{
diff --git a/src/battle_controller_recorded_player.c b/src/battle_controller_recorded_player.c
index 0d06e26eb..c1e5447a4 100644
--- a/src/battle_controller_recorded_player.c
+++ b/src/battle_controller_recorded_player.c
@@ -34,7 +34,6 @@ extern struct UnusedControllerStruct gUnknown_02022D0C;
extern const struct CompressedSpritePalette gTrainerFrontPicPaletteTable[];
extern const struct CompressedSpritePalette gTrainerBackPicPaletteTable[];
-extern const struct BattleMove gBattleMoves[];
extern void sub_8172EF0(u8 bank, struct Pokemon *mon);
extern void sub_806A068(u16, u8);
diff --git a/src/battle_controllers.c b/src/battle_controllers.c
index 97f82ed0c..8bd654c29 100644
--- a/src/battle_controllers.c
+++ b/src/battle_controllers.c
@@ -36,7 +36,6 @@ extern u8 gBattleBuffersTransferData[0x100];
static EWRAM_DATA u8 sBattleBuffersTransferData[0x100] = {};
-extern const struct BattleMove gBattleMoves[];
extern void task00_08081A90(u8 taskId); // cable_club
extern void sub_81B8D64(u8 bank, u8 arg1); // party_menu
diff --git a/src/battle_gfx_sfx_util.c b/src/battle_gfx_sfx_util.c
index 4dc88ab6a..d2c242553 100644
--- a/src/battle_gfx_sfx_util.c
+++ b/src/battle_gfx_sfx_util.c
@@ -28,7 +28,6 @@ extern struct MusicPlayerInfo gMPlayInfo_SE1;
extern struct MusicPlayerInfo gMPlayInfo_SE2;
extern struct MusicPlayerInfo gMPlayInfo_BGM;
-extern const struct BattleMove gBattleMoves[];
extern const u8 gUnknown_0831C604[];
extern const u8 * const gBattleAnims_VariousTable[];
extern const u8 * const gBattleAnims_Special[];
@@ -237,7 +236,7 @@ u16 ChooseMoveAndTargetInBattlePalace(void)
if (moveInfo->moves[chosenMoveId] == MOVE_CURSE)
{
if (moveInfo->monType1 != TYPE_GHOST && moveInfo->monType2 != TYPE_GHOST)
- var1 = MOVE_TARGET_x10;
+ var1 = MOVE_TARGET_USER;
else
var1 = MOVE_TARGET_SELECTED;
}
@@ -246,7 +245,7 @@ u16 ChooseMoveAndTargetInBattlePalace(void)
var1 = gBattleMoves[moveInfo->moves[chosenMoveId]].target;
}
- if (var1 & MOVE_TARGET_x10)
+ if (var1 & MOVE_TARGET_USER)
chosenMoveId |= (gActiveBattler << 8);
else if (var1 == MOVE_TARGET_SELECTED)
chosenMoveId |= (BattlePalaceGetTargetRetValue());
@@ -261,7 +260,7 @@ static u8 sub_805D4A8(u16 move)
switch (gBattleMoves[move].target)
{
case MOVE_TARGET_SELECTED:
- case MOVE_TARGET_USER:
+ case MOVE_TARGET_USER_OR_SELECTED:
case MOVE_TARGET_RANDOM:
case MOVE_TARGET_BOTH:
case MOVE_TARGET_FOES_AND_ALLY:
@@ -273,7 +272,7 @@ static u8 sub_805D4A8(u16 move)
case MOVE_TARGET_DEPENDS:
case MOVE_TARGET_OPPONENTS_FIELD:
return 2;
- case MOVE_TARGET_x10:
+ case MOVE_TARGET_USER:
return 1;
default:
return 0;
diff --git a/src/battle_main.c b/src/battle_main.c
index 78b69212d..9715221ba 100644
--- a/src/battle_main.c
+++ b/src/battle_main.c
@@ -81,7 +81,6 @@ extern struct MusicPlayerInfo gMPlayInfo_SE1;
extern struct MusicPlayerInfo gMPlayInfo_SE2;
extern u8 gUnknown_0203CF00[];
-extern const struct BattleMove gBattleMoves[];
extern const u16 gBattleTextboxPalette[]; // battle textbox palette
extern const struct BgTemplate gUnknown_0831AA08[];
extern const struct WindowTemplate * const gUnknown_0831ABA0[];
@@ -301,6 +300,214 @@ u8 gNumberOfMovesToChoose;
u8 gUnknown_03005D7C[MAX_BATTLERS_COUNT];
// rom const data
+
+// format: attacking type, defending type, damage multiplier
+// the multiplier is a (decimal) fixed-point number:
+// 20 is ×2.0 TYPE_MUL_SUPER_EFFECTIVE
+// 10 is ×1.0 TYPE_MUL_NORMAL
+// 05 is ×0.5 TYPE_MUL_NOT_EFFECTIVE
+// 00 is ×0.0 TYPE_MUL_NO_EFFECT
+const u8 gTypeEffectiveness[336] =
+{
+ TYPE_NORMAL, TYPE_ROCK, TYPE_MUL_NOT_EFFECTIVE,
+ TYPE_NORMAL, TYPE_STEEL, TYPE_MUL_NOT_EFFECTIVE,
+ TYPE_FIRE, TYPE_FIRE, TYPE_MUL_NOT_EFFECTIVE,
+ TYPE_FIRE, TYPE_WATER, TYPE_MUL_NOT_EFFECTIVE,
+ TYPE_FIRE, TYPE_GRASS, TYPE_MUL_SUPER_EFFECTIVE,
+ TYPE_FIRE, TYPE_ICE, TYPE_MUL_SUPER_EFFECTIVE,
+ TYPE_FIRE, TYPE_BUG, TYPE_MUL_SUPER_EFFECTIVE,
+ TYPE_FIRE, TYPE_ROCK, TYPE_MUL_NOT_EFFECTIVE,
+ TYPE_FIRE, TYPE_DRAGON, TYPE_MUL_NOT_EFFECTIVE,
+ TYPE_FIRE, TYPE_STEEL, TYPE_MUL_SUPER_EFFECTIVE,
+ TYPE_WATER, TYPE_FIRE, TYPE_MUL_SUPER_EFFECTIVE,
+ TYPE_WATER, TYPE_WATER, TYPE_MUL_NOT_EFFECTIVE,
+ TYPE_WATER, TYPE_GRASS, TYPE_MUL_NOT_EFFECTIVE,
+ TYPE_WATER, TYPE_GROUND, TYPE_MUL_SUPER_EFFECTIVE,
+ TYPE_WATER, TYPE_ROCK, TYPE_MUL_SUPER_EFFECTIVE,
+ TYPE_WATER, TYPE_DRAGON, TYPE_MUL_NOT_EFFECTIVE,
+ TYPE_ELECTRIC, TYPE_WATER, TYPE_MUL_SUPER_EFFECTIVE,
+ TYPE_ELECTRIC, TYPE_ELECTRIC, TYPE_MUL_NOT_EFFECTIVE,
+ TYPE_ELECTRIC, TYPE_GRASS, TYPE_MUL_NOT_EFFECTIVE,
+ TYPE_ELECTRIC, TYPE_GROUND, TYPE_MUL_NO_EFFECT,
+ TYPE_ELECTRIC, TYPE_FLYING, TYPE_MUL_SUPER_EFFECTIVE,
+ TYPE_ELECTRIC, TYPE_DRAGON, TYPE_MUL_NOT_EFFECTIVE,
+ TYPE_GRASS, TYPE_FIRE, TYPE_MUL_NOT_EFFECTIVE,
+ TYPE_GRASS, TYPE_WATER, TYPE_MUL_SUPER_EFFECTIVE,
+ TYPE_GRASS, TYPE_GRASS, TYPE_MUL_NOT_EFFECTIVE,
+ TYPE_GRASS, TYPE_POISON, TYPE_MUL_NOT_EFFECTIVE,
+ TYPE_GRASS, TYPE_GROUND, TYPE_MUL_SUPER_EFFECTIVE,
+ TYPE_GRASS, TYPE_FLYING, TYPE_MUL_NOT_EFFECTIVE,
+ TYPE_GRASS, TYPE_BUG, TYPE_MUL_NOT_EFFECTIVE,
+ TYPE_GRASS, TYPE_ROCK, TYPE_MUL_SUPER_EFFECTIVE,
+ TYPE_GRASS, TYPE_DRAGON, TYPE_MUL_NOT_EFFECTIVE,
+ TYPE_GRASS, TYPE_STEEL, TYPE_MUL_NOT_EFFECTIVE,
+ TYPE_ICE, TYPE_WATER, TYPE_MUL_NOT_EFFECTIVE,
+ TYPE_ICE, TYPE_GRASS, TYPE_MUL_SUPER_EFFECTIVE,
+ TYPE_ICE, TYPE_ICE, TYPE_MUL_NOT_EFFECTIVE,
+ TYPE_ICE, TYPE_GROUND, TYPE_MUL_SUPER_EFFECTIVE,
+ TYPE_ICE, TYPE_FLYING, TYPE_MUL_SUPER_EFFECTIVE,
+ TYPE_ICE, TYPE_DRAGON, TYPE_MUL_SUPER_EFFECTIVE,
+ TYPE_ICE, TYPE_STEEL, TYPE_MUL_NOT_EFFECTIVE,
+ TYPE_ICE, TYPE_FIRE, TYPE_MUL_NOT_EFFECTIVE,
+ TYPE_FIGHTING, TYPE_NORMAL, TYPE_MUL_SUPER_EFFECTIVE,
+ TYPE_FIGHTING, TYPE_ICE, TYPE_MUL_SUPER_EFFECTIVE,
+ TYPE_FIGHTING, TYPE_POISON, TYPE_MUL_NOT_EFFECTIVE,
+ TYPE_FIGHTING, TYPE_FLYING, TYPE_MUL_NOT_EFFECTIVE,
+ TYPE_FIGHTING, TYPE_PSYCHIC, TYPE_MUL_NOT_EFFECTIVE,
+ TYPE_FIGHTING, TYPE_BUG, TYPE_MUL_NOT_EFFECTIVE,
+ TYPE_FIGHTING, TYPE_ROCK, TYPE_MUL_SUPER_EFFECTIVE,
+ TYPE_FIGHTING, TYPE_DARK, TYPE_MUL_SUPER_EFFECTIVE,
+ TYPE_FIGHTING, TYPE_STEEL, TYPE_MUL_SUPER_EFFECTIVE,
+ TYPE_POISON, TYPE_GRASS, TYPE_MUL_SUPER_EFFECTIVE,
+ TYPE_POISON, TYPE_POISON, TYPE_MUL_NOT_EFFECTIVE,
+ TYPE_POISON, TYPE_GROUND, TYPE_MUL_NOT_EFFECTIVE,
+ TYPE_POISON, TYPE_ROCK, TYPE_MUL_NOT_EFFECTIVE,
+ TYPE_POISON, TYPE_GHOST, TYPE_MUL_NOT_EFFECTIVE,
+ TYPE_POISON, TYPE_STEEL, TYPE_MUL_NO_EFFECT,
+ TYPE_GROUND, TYPE_FIRE, TYPE_MUL_SUPER_EFFECTIVE,
+ TYPE_GROUND, TYPE_ELECTRIC, TYPE_MUL_SUPER_EFFECTIVE,
+ TYPE_GROUND, TYPE_GRASS, TYPE_MUL_NOT_EFFECTIVE,
+ TYPE_GROUND, TYPE_POISON, TYPE_MUL_SUPER_EFFECTIVE,
+ TYPE_GROUND, TYPE_FLYING, TYPE_MUL_NO_EFFECT,
+ TYPE_GROUND, TYPE_BUG, TYPE_MUL_NOT_EFFECTIVE,
+ TYPE_GROUND, TYPE_ROCK, TYPE_MUL_SUPER_EFFECTIVE,
+ TYPE_GROUND, TYPE_STEEL, TYPE_MUL_SUPER_EFFECTIVE,
+ TYPE_FLYING, TYPE_ELECTRIC, TYPE_MUL_NOT_EFFECTIVE,
+ TYPE_FLYING, TYPE_GRASS, TYPE_MUL_SUPER_EFFECTIVE,
+ TYPE_FLYING, TYPE_FIGHTING, TYPE_MUL_SUPER_EFFECTIVE,
+ TYPE_FLYING, TYPE_BUG, TYPE_MUL_SUPER_EFFECTIVE,
+ TYPE_FLYING, TYPE_ROCK, TYPE_MUL_NOT_EFFECTIVE,
+ TYPE_FLYING, TYPE_STEEL, TYPE_MUL_NOT_EFFECTIVE,
+ TYPE_PSYCHIC, TYPE_FIGHTING, TYPE_MUL_SUPER_EFFECTIVE,
+ TYPE_PSYCHIC, TYPE_POISON, TYPE_MUL_SUPER_EFFECTIVE,
+ TYPE_PSYCHIC, TYPE_PSYCHIC, TYPE_MUL_NOT_EFFECTIVE,
+ TYPE_PSYCHIC, TYPE_DARK, TYPE_MUL_NO_EFFECT,
+ TYPE_PSYCHIC, TYPE_STEEL, TYPE_MUL_NOT_EFFECTIVE,
+ TYPE_BUG, TYPE_FIRE, TYPE_MUL_NOT_EFFECTIVE,
+ TYPE_BUG, TYPE_GRASS, TYPE_MUL_SUPER_EFFECTIVE,
+ TYPE_BUG, TYPE_FIGHTING, TYPE_MUL_NOT_EFFECTIVE,
+ TYPE_BUG, TYPE_POISON, TYPE_MUL_NOT_EFFECTIVE,
+ TYPE_BUG, TYPE_FLYING, TYPE_MUL_NOT_EFFECTIVE,
+ TYPE_BUG, TYPE_PSYCHIC, TYPE_MUL_SUPER_EFFECTIVE,
+ TYPE_BUG, TYPE_GHOST, TYPE_MUL_NOT_EFFECTIVE,
+ TYPE_BUG, TYPE_DARK, TYPE_MUL_SUPER_EFFECTIVE,
+ TYPE_BUG, TYPE_STEEL, TYPE_MUL_NOT_EFFECTIVE,
+ TYPE_ROCK, TYPE_FIRE, TYPE_MUL_SUPER_EFFECTIVE,
+ TYPE_ROCK, TYPE_ICE, TYPE_MUL_SUPER_EFFECTIVE,
+ TYPE_ROCK, TYPE_FIGHTING, TYPE_MUL_NOT_EFFECTIVE,
+ TYPE_ROCK, TYPE_GROUND, TYPE_MUL_NOT_EFFECTIVE,
+ TYPE_ROCK, TYPE_FLYING, TYPE_MUL_SUPER_EFFECTIVE,
+ TYPE_ROCK, TYPE_BUG, TYPE_MUL_SUPER_EFFECTIVE,
+ TYPE_ROCK, TYPE_STEEL, TYPE_MUL_NOT_EFFECTIVE,
+ TYPE_GHOST, TYPE_NORMAL, TYPE_MUL_NO_EFFECT,
+ TYPE_GHOST, TYPE_PSYCHIC, TYPE_MUL_SUPER_EFFECTIVE,
+ TYPE_GHOST, TYPE_DARK, TYPE_MUL_NOT_EFFECTIVE,
+ TYPE_GHOST, TYPE_STEEL, TYPE_MUL_NOT_EFFECTIVE,
+ TYPE_GHOST, TYPE_GHOST, TYPE_MUL_SUPER_EFFECTIVE,
+ TYPE_DRAGON, TYPE_DRAGON, TYPE_MUL_SUPER_EFFECTIVE,
+ TYPE_DRAGON, TYPE_STEEL, TYPE_MUL_NOT_EFFECTIVE,
+ TYPE_DARK, TYPE_FIGHTING, TYPE_MUL_NOT_EFFECTIVE,
+ TYPE_DARK, TYPE_PSYCHIC, TYPE_MUL_SUPER_EFFECTIVE,
+ TYPE_DARK, TYPE_GHOST, TYPE_MUL_SUPER_EFFECTIVE,
+ TYPE_DARK, TYPE_DARK, TYPE_MUL_NOT_EFFECTIVE,
+ TYPE_DARK, TYPE_STEEL, TYPE_MUL_NOT_EFFECTIVE,
+ TYPE_STEEL, TYPE_FIRE, TYPE_MUL_NOT_EFFECTIVE,
+ TYPE_STEEL, TYPE_WATER, TYPE_MUL_NOT_EFFECTIVE,
+ TYPE_STEEL, TYPE_ELECTRIC, TYPE_MUL_NOT_EFFECTIVE,
+ TYPE_STEEL, TYPE_ICE, TYPE_MUL_SUPER_EFFECTIVE,
+ TYPE_STEEL, TYPE_ROCK, TYPE_MUL_SUPER_EFFECTIVE,
+ TYPE_STEEL, TYPE_STEEL, TYPE_MUL_NOT_EFFECTIVE,
+ TYPE_FORESIGHT, TYPE_FORESIGHT, TYPE_MUL_NO_EFFECT,
+ TYPE_NORMAL, TYPE_GHOST, TYPE_MUL_NO_EFFECT,
+ TYPE_FIGHTING, TYPE_GHOST, TYPE_MUL_NO_EFFECT,
+ TYPE_ENDTABLE, TYPE_ENDTABLE, TYPE_MUL_NO_EFFECT
+};
+
+const u8 gTypeNames[][TYPE_NAME_LENGTH + 1] =
+{
+ _("NORMAL"),
+ _("FIGHT"),
+ _("FLYING"),
+ _("POISON"),
+ _("GROUND"),
+ _("ROCK"),
+ _("BUG"),
+ _("GHOST"),
+ _("STEEL"),
+ _("???"),
+ _("FIRE"),
+ _("WATER"),
+ _("GRASS"),
+ _("ELECTR"),
+ _("PSYCHC"),
+ _("ICE"),
+ _("DRAGON"),
+ _("DARK"),
+};
+
+// This is a factor in how much money you get for beating a trainer.
+const struct TrainerMoney gTrainerMoneyTable[] =
+{
+ {TRAINER_CLASS_TEAM_AQUA, 5},
+ {TRAINER_CLASS_AQUA_ADMIN, 10},
+ {TRAINER_CLASS_AQUA_LEADER, 20},
+ {TRAINER_CLASS_AROMA_LADY, 10},
+ {TRAINER_CLASS_RUIN_MANIAC, 15},
+ {TRAINER_CLASS_INTERVIEWER, 12},
+ {TRAINER_CLASS_TUBER_1, 1},
+ {TRAINER_CLASS_TUBER_2, 1},
+ {TRAINER_CLASS_SIS_AND_BRO, 3},
+ {TRAINER_CLASS_COOLTRAINER_1, 12},
+ {TRAINER_CLASS_HEX_MANIAC, 6},
+ {TRAINER_CLASS_LADY, 50},
+ {TRAINER_CLASS_BEAUTY, 20},
+ {TRAINER_CLASS_RICH_BOY, 50},
+ {TRAINER_CLASS_POKEMANIAC, 15},
+ {TRAINER_CLASS_SWIMMER_M, 2},
+ {TRAINER_CLASS_BLACK_BELT, 8},
+ {TRAINER_CLASS_GUITARIST, 8},
+ {TRAINER_CLASS_KINDLER, 8},
+ {TRAINER_CLASS_CAMPER, 4},
+ {TRAINER_CLASS_OLD_COUPLE, 10},
+ {TRAINER_CLASS_BUG_MANIAC, 15},
+ {TRAINER_CLASS_PSYCHIC, 6},
+ {TRAINER_CLASS_GENTLEMAN, 20},
+ {TRAINER_CLASS_ELITE_FOUR, 25},
+ {TRAINER_CLASS_LEADER, 25},
+ {TRAINER_CLASS_SCHOOL_KID, 5},
+ {TRAINER_CLASS_SR_AND_JR, 4},
+ {TRAINER_CLASS_POKEFAN, 20},
+ {TRAINER_CLASS_EXPERT, 10},
+ {TRAINER_CLASS_YOUNGSTER, 4},
+ {TRAINER_CLASS_CHAMPION, 50},
+ {TRAINER_CLASS_FISHERMAN, 10},
+ {TRAINER_CLASS_TRIATHLETE, 10},
+ {TRAINER_CLASS_DRAGON_TAMER, 12},
+ {TRAINER_CLASS_BIRD_KEEPER, 8},
+ {TRAINER_CLASS_NINJA_BOY, 3},
+ {TRAINER_CLASS_BATTLE_GIRL, 6},
+ {TRAINER_CLASS_PARASOL_LADY, 10},
+ {TRAINER_CLASS_SWIMMER_F, 2},
+ {TRAINER_CLASS_PICNICKER, 4},
+ {TRAINER_CLASS_TWINS, 3},
+ {TRAINER_CLASS_SAILOR, 8},
+ {TRAINER_CLASS_COLLECTOR, 15},
+ {TRAINER_CLASS_PKMN_TRAINER_3, 15},
+ {TRAINER_CLASS_PKMN_BREEDER, 10},
+ {TRAINER_CLASS_PKMN_RANGER, 12},
+ {TRAINER_CLASS_TEAM_MAGMA, 5},
+ {TRAINER_CLASS_MAGMA_ADMIN, 10},
+ {TRAINER_CLASS_MAGMA_LEADER, 20},
+ {TRAINER_CLASS_LASS, 4},
+ {TRAINER_CLASS_BUG_CATCHER, 4},
+ {TRAINER_CLASS_HIKER, 10},
+ {TRAINER_CLASS_YOUNG_COUPLE, 8},
+ {TRAINER_CLASS_WINSTRATE, 10},
+ {0xFF, 5},
+};
+
+#include "data/text/abilities.h"
+
static void (* const sTurnActionsFuncsTable[])(void) =
{
HandleAction_UseMove, // B_ACTION_USE_MOVE
@@ -5133,7 +5340,7 @@ static void HandleAction_UseMove(void)
else if ((gBattleTypeFlags & BATTLE_TYPE_DOUBLE)
&& gSideTimers[side].followmeTimer == 0
&& (gBattleMoves[gCurrentMove].power != 0
- || gBattleMoves[gCurrentMove].target != MOVE_TARGET_x10)
+ || gBattleMoves[gCurrentMove].target != MOVE_TARGET_USER)
&& gBattleMons[*(gBattleStruct->moveTarget + gBattlerAttacker)].ability != ABILITY_LIGHTNING_ROD
&& gBattleMoves[gCurrentMove].type == TYPE_ELECTRIC)
{
diff --git a/src/battle_message.c b/src/battle_message.c
index 0358c0956..8351b84d8 100644
--- a/src/battle_message.c
+++ b/src/battle_message.c
@@ -22,9 +22,7 @@ extern u8 gUnknown_0203C7B4;
extern struct StringInfoBattle *gStringInfo;
extern const u8 gMoveNames[LAST_MOVE_INDEX + 1][13];
-extern const u8 gAbilityNames[][13];
extern const u8 gTrainerClassNames[][13];
-extern const u8 gTypeNames[][7];
extern const u16 gUnknown_08D85620[];
// strings
diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c
index 2da48de49..b588970b7 100644
--- a/src/battle_script_commands.c
+++ b/src/battle_script_commands.c
@@ -48,15 +48,6 @@ extern u16 gBattle_BG2_Y;
extern u16 gBattle_BG3_X;
extern struct MusicPlayerInfo gMPlayInfo_BGM;
-struct TrainerMoney
-{
- u8 classId;
- u8 value;
-};
-
-extern const struct BattleMove gBattleMoves[];
-extern const u8 gTypeEffectiveness[336];
-extern const struct TrainerMoney gTrainerMoneyTable[];
extern const u8* const gBattleScriptsForMoveEffects[];
// functions
@@ -4436,31 +4427,34 @@ static void atk47_setgraphicalstatchangevalues(void)
gBattlescriptCurrInstr++;
}
-#ifdef NONMATCHING
static void atk48_playstatchangeanimation(void)
{
u32 currStat = 0;
- s16 statAnimId = 0;
- s16 checkingStatAnimId = 0;
- s32 changeableStats = 0;
- u32 statsToCheck = 0;
+ u16 statAnimId = 0;
+ s32 changeableStatsCount = 0;
+ u8 statsToCheck = 0;
gActiveBattler = GetBattlerForBattleScript(gBattlescriptCurrInstr[1]);
statsToCheck = gBattlescriptCurrInstr[2];
if (gBattlescriptCurrInstr[3] & ATK48_STAT_NEGATIVE) // goes down
{
- checkingStatAnimId = (gBattlescriptCurrInstr[3] & ATK48_STAT_BY_TWO) ? 0x2D : 0x15;
+ s16 startingStatAnimId;
+ if (gBattlescriptCurrInstr[3] & ATK48_STAT_BY_TWO)
+ startingStatAnimId = 0x2D;
+ else
+ startingStatAnimId = 0x15;
+
while (statsToCheck != 0)
{
if (statsToCheck & 1)
{
- if (!(gBattlescriptCurrInstr[3] & ATK48_LOWER_FAIL_CHECK))
+ if (gBattlescriptCurrInstr[3] & ATK48_DONT_CHECK_LOWER)
{
if (gBattleMons[gActiveBattler].statStages[currStat] > 0)
{
- statAnimId = checkingStatAnimId;
- changeableStats++;
+ statAnimId = startingStatAnimId + currStat;
+ changeableStatsCount++;
}
}
else if (!gSideTimers[GET_BATTLER_SIDE(gActiveBattler)].mistTimer
@@ -4471,15 +4465,15 @@ static void atk48_playstatchangeanimation(void)
{
if (gBattleMons[gActiveBattler].statStages[currStat] > 0)
{
- statAnimId = checkingStatAnimId;
- changeableStats++;
+ statAnimId = startingStatAnimId + currStat;
+ changeableStatsCount++;
}
}
}
- statsToCheck >>= 1, checkingStatAnimId++, currStat++;
+ statsToCheck >>= 1, currStat++;
}
- if (changeableStats > 1) // more than one stat, so the color is gray
+ if (changeableStatsCount > 1) // more than one stat, so the color is gray
{
if (gBattlescriptCurrInstr[3] & ATK48_STAT_BY_TWO)
statAnimId = 0x3A;
@@ -4489,18 +4483,23 @@ static void atk48_playstatchangeanimation(void)
}
else // goes up
{
- checkingStatAnimId = (gBattlescriptCurrInstr[3] & ATK48_STAT_BY_TWO) ? 0x26 : 0xE;
+ s16 startingStatAnimId;
+ if (gBattlescriptCurrInstr[3] & ATK48_STAT_BY_TWO)
+ startingStatAnimId = 0x26;
+ else
+ startingStatAnimId = 0xE;
+
while (statsToCheck != 0)
{
if (statsToCheck & 1 && gBattleMons[gActiveBattler].statStages[currStat] < 0xC)
{
- statAnimId = checkingStatAnimId;
- changeableStats++;
+ statAnimId = startingStatAnimId + currStat;
+ changeableStatsCount++;
}
- statsToCheck >>= 1, checkingStatAnimId += 1, currStat++;
+ statsToCheck >>= 1, currStat++;
}
- if (changeableStats > 1) // more than one stat, so the color is gray
+ if (changeableStatsCount > 1) // more than one stat, so the color is gray
{
if (gBattlescriptCurrInstr[3] & ATK48_STAT_BY_TWO)
statAnimId = 0x38;
@@ -4509,15 +4508,15 @@ static void atk48_playstatchangeanimation(void)
}
}
- if (gBattlescriptCurrInstr[3] & ATK48_BIT_x4 && changeableStats < 2)
+ if (gBattlescriptCurrInstr[3] & ATK48_BIT_x4 && changeableStatsCount < 2)
{
gBattlescriptCurrInstr += 4;
}
- else if (changeableStats != 0 && gBattleScripting.field_1B == 0)
+ else if (changeableStatsCount != 0 && gBattleScripting.field_1B == 0)
{
BtlController_EmitBattleAnimation(0, B_ANIM_STATS_CHANGE, statAnimId);
MarkBattlerForControllerExec(gActiveBattler);
- if (gBattlescriptCurrInstr[3] & ATK48_BIT_x4 && changeableStats > 1)
+ if (gBattlescriptCurrInstr[3] & ATK48_BIT_x4 && changeableStatsCount > 1)
gBattleScripting.field_1B = 1;
gBattlescriptCurrInstr += 4;
}
@@ -4526,261 +4525,6 @@ static void atk48_playstatchangeanimation(void)
gBattlescriptCurrInstr += 4;
}
}
-#else
-ASM_DIRECT
-static void atk48_playstatchangeanimation(void)
-{
- asm("\n\
- .syntax unified\n\
- push {r4-r7,lr}\n\
- mov r7, r10\n\
- mov r6, r9\n\
- mov r5, r8\n\
- push {r5-r7}\n\
- sub sp, 0x4\n\
- movs r7, 0\n\
- movs r0, 0\n\
- mov r8, r0\n\
- movs r3, 0\n\
- ldr r5, =gBattlescriptCurrInstr\n\
- ldr r0, [r5]\n\
- ldrb r0, [r0, 0x1]\n\
- str r3, [sp]\n\
- bl GetBattlerForBattleScript\n\
- ldr r2, =gActiveBattler\n\
- strb r0, [r2]\n\
- ldr r0, [r5]\n\
- ldrb r4, [r0, 0x2]\n\
- ldrb r1, [r0, 0x3]\n\
- movs r0, 0x1\n\
- ands r0, r1\n\
- ldr r3, [sp]\n\
- cmp r0, 0\n\
- beq _0804BAEC\n\
- movs r0, 0x2\n\
- ands r0, r1\n\
- movs r1, 0x15\n\
- cmp r0, 0\n\
- beq _0804BA18\n\
- movs r1, 0x2D\n\
-_0804BA18:\n\
- cmp r4, 0\n\
- beq _0804BAC0\n\
- movs r0, 0x1\n\
- mov r10, r0\n\
- ldr r0, =gBattleMons + 0x18\n\
- mov r9, r0\n\
- lsls r5, r1, 16\n\
-_0804BA26:\n\
- adds r0, r4, 0\n\
- mov r1, r10\n\
- ands r0, r1\n\
- cmp r0, 0\n\
- beq _0804BAB2\n\
- ldr r0, =gBattlescriptCurrInstr\n\
- ldr r0, [r0]\n\
- ldrb r1, [r0, 0x3]\n\
- movs r0, 0x8\n\
- ands r0, r1\n\
- cmp r0, 0\n\
- beq _0804BA58\n\
- ldr r0, =gActiveBattler\n\
- ldrb r1, [r0]\n\
- movs r0, 0x58\n\
- muls r0, r1\n\
- adds r0, r7, r0\n\
- b _0804BAA0\n\
- .pool\n\
-_0804BA58:\n\
- ldr r6, =gActiveBattler\n\
- ldrb r0, [r6]\n\
- str r3, [sp]\n\
- bl GetBattlerPosition\n\
- mov r1, r10\n\
- ands r1, r0\n\
- lsls r0, r1, 1\n\
- adds r0, r1\n\
- lsls r0, 2\n\
- ldr r1, =gSideTimers\n\
- adds r0, r1\n\
- ldrb r0, [r0, 0x4]\n\
- ldr r3, [sp]\n\
- cmp r0, 0\n\
- bne _0804BAB2\n\
- ldr r0, =gBattleMons\n\
- ldrb r2, [r6]\n\
- movs r1, 0x58\n\
- muls r2, r1\n\
- adds r0, r2, r0\n\
- adds r0, 0x20\n\
- ldrb r0, [r0]\n\
- cmp r0, 0x1D\n\
- beq _0804BAB2\n\
- cmp r0, 0x49\n\
- beq _0804BAB2\n\
- cmp r0, 0x33\n\
- bne _0804BA96\n\
- cmp r7, 0x6\n\
- beq _0804BAB2\n\
-_0804BA96:\n\
- cmp r0, 0x34\n\
- bne _0804BA9E\n\
- cmp r7, 0x1\n\
- beq _0804BAB2\n\
-_0804BA9E:\n\
- adds r0, r7, r2\n\
-_0804BAA0:\n\
- add r0, r9\n\
- ldrb r0, [r0]\n\
- lsls r0, 24\n\
- asrs r0, 24\n\
- cmp r0, 0\n\
- ble _0804BAB2\n\
- lsrs r0, r5, 16\n\
- mov r8, r0\n\
- adds r3, 0x1\n\
-_0804BAB2:\n\
- lsrs r4, 1\n\
- movs r1, 0x80\n\
- lsls r1, 9\n\
- adds r5, r1\n\
- adds r7, 0x1\n\
- cmp r4, 0\n\
- bne _0804BA26\n\
-_0804BAC0:\n\
- ldr r0, =gBattlescriptCurrInstr\n\
- mov r9, r0\n\
- cmp r3, 0x1\n\
- ble _0804BB4E\n\
- ldr r0, [r0]\n\
- ldrb r1, [r0, 0x3]\n\
- movs r0, 0x2\n\
- ands r0, r1\n\
- movs r1, 0x39\n\
- mov r8, r1\n\
- cmp r0, 0\n\
- beq _0804BB4E\n\
- movs r0, 0x3A\n\
- b _0804BB4C\n\
- .pool\n\
-_0804BAEC:\n\
- movs r0, 0x2\n\
- ands r0, r1\n\
- movs r1, 0xE\n\
- cmp r0, 0\n\
- beq _0804BAF8\n\
- movs r1, 0x26\n\
-_0804BAF8:\n\
- mov r9, r5\n\
- cmp r4, 0\n\
- beq _0804BB34\n\
- ldr r6, =gBattleMons + 0x18\n\
- adds r5, r2, 0\n\
- lsls r2, r1, 16\n\
-_0804BB04:\n\
- movs r0, 0x1\n\
- ands r0, r4\n\
- cmp r0, 0\n\
- beq _0804BB26\n\
- ldrb r1, [r5]\n\
- movs r0, 0x58\n\
- muls r0, r1\n\
- adds r0, r7, r0\n\
- adds r0, r6\n\
- ldrb r0, [r0]\n\
- lsls r0, 24\n\
- asrs r0, 24\n\
- cmp r0, 0xB\n\
- bgt _0804BB26\n\
- lsrs r1, r2, 16\n\
- mov r8, r1\n\
- adds r3, 0x1\n\
-_0804BB26:\n\
- lsrs r4, 1\n\
- movs r0, 0x80\n\
- lsls r0, 9\n\
- adds r2, r0\n\
- adds r7, 0x1\n\
- cmp r4, 0\n\
- bne _0804BB04\n\
-_0804BB34:\n\
- cmp r3, 0x1\n\
- ble _0804BB4E\n\
- mov r1, r9\n\
- ldr r0, [r1]\n\
- ldrb r1, [r0, 0x3]\n\
- movs r0, 0x2\n\
- ands r0, r1\n\
- movs r1, 0x37\n\
- mov r8, r1\n\
- cmp r0, 0\n\
- beq _0804BB4E\n\
- movs r0, 0x38\n\
-_0804BB4C:\n\
- mov r8, r0\n\
-_0804BB4E:\n\
- mov r1, r9\n\
- ldr r2, [r1]\n\
- ldrb r1, [r2, 0x3]\n\
- movs r0, 0x4\n\
- ands r0, r1\n\
- cmp r0, 0\n\
- beq _0804BB6C\n\
- cmp r3, 0x1\n\
- bgt _0804BB6C\n\
- adds r0, r2, 0x4\n\
- mov r1, r9\n\
- b _0804BBBA\n\
- .pool\n\
-_0804BB6C:\n\
- cmp r3, 0\n\
- beq _0804BBB4\n\
- ldr r4, =gBattleScripting\n\
- ldrb r0, [r4, 0x1B]\n\
- cmp r0, 0\n\
- bne _0804BBB4\n\
- movs r0, 0\n\
- movs r1, 0x1\n\
- mov r2, r8\n\
- str r3, [sp]\n\
- bl BtlController_EmitBattleAnimation\n\
- ldr r0, =gActiveBattler\n\
- ldrb r0, [r0]\n\
- bl MarkBattlerForControllerExec\n\
- ldr r0, =gBattlescriptCurrInstr\n\
- ldr r0, [r0]\n\
- ldrb r1, [r0, 0x3]\n\
- movs r0, 0x4\n\
- ands r0, r1\n\
- ldr r3, [sp]\n\
- cmp r0, 0\n\
- beq _0804BBA4\n\
- cmp r3, 0x1\n\
- ble _0804BBA4\n\
- movs r0, 0x1\n\
- strb r0, [r4, 0x1B]\n\
-_0804BBA4:\n\
- ldr r1, =gBattlescriptCurrInstr\n\
- b _0804BBB6\n\
- .pool\n\
-_0804BBB4:\n\
- mov r1, r9\n\
-_0804BBB6:\n\
- ldr r0, [r1]\n\
- adds r0, 0x4\n\
-_0804BBBA:\n\
- str r0, [r1]\n\
- add sp, 0x4\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\
- .syntax divided");
-}
-#endif // NONMATCHING
#define ATK49_LAST_CASE 17
@@ -5271,10 +5015,9 @@ static void atk4E_switchinanim(void)
static void atk4F_jumpifcantswitch(void)
{
- s32 val = 0;
- s32 compareVar = 0;
- struct Pokemon *party = NULL;
- s32 r7 = 0;
+ s32 i;
+ s32 lastMonId;
+ struct Pokemon *party;
gActiveBattler = GetBattlerForBattleScript(gBattlescriptCurrInstr[1] & ~(ATK4F_DONT_CHECK_STATUSES));
@@ -5294,20 +5037,20 @@ static void atk4F_jumpifcantswitch(void)
else
party = gPlayerParty;
- val = 0;
- if (2 & gActiveBattler)
- val = 3;
+ i = 0;
+ if (gActiveBattler & 2)
+ i = 3;
- for (compareVar = val + 3; val < compareVar; val++)
+ for (lastMonId = i + 3; i < lastMonId; i++)
{
- if (GetMonData(&party[val], MON_DATA_SPECIES) != SPECIES_NONE
- && !GetMonData(&party[val], MON_DATA_IS_EGG)
- && GetMonData(&party[val], MON_DATA_HP) != 0
- && gBattlerPartyIndexes[gActiveBattler] != val)
+ if (GetMonData(&party[i], MON_DATA_SPECIES) != SPECIES_NONE
+ && !GetMonData(&party[i], MON_DATA_IS_EGG)
+ && GetMonData(&party[i], MON_DATA_HP) != 0
+ && gBattlerPartyIndexes[gActiveBattler] != i)
break;
}
- if (val == compareVar)
+ if (i == lastMonId)
gBattlescriptCurrInstr = BSScriptReadPtr(gBattlescriptCurrInstr + 2);
else
gBattlescriptCurrInstr += 6;
@@ -5320,18 +5063,18 @@ static void atk4F_jumpifcantswitch(void)
{
party = gPlayerParty;
- val = 0;
+ i = 0;
if (sub_806D82C(GetBattlerMultiplayerId(gActiveBattler)) == TRUE)
- val = 3;
+ i = 3;
}
else
{
party = gEnemyParty;
if (gActiveBattler == 1)
- val = 0;
+ i = 0;
else
- val = 3;
+ i = 3;
}
}
else
@@ -5341,22 +5084,21 @@ static void atk4F_jumpifcantswitch(void)
else
party = gPlayerParty;
-
- val = 0;
+ i = 0;
if (sub_806D82C(GetBattlerMultiplayerId(gActiveBattler)) == TRUE)
- val = 3;
+ i = 3;
}
- for (compareVar = val + 3; val < compareVar; val++)
+ for (lastMonId = i + 3; i < lastMonId; i++)
{
- if (GetMonData(&party[val], MON_DATA_SPECIES) != SPECIES_NONE
- && !GetMonData(&party[val], MON_DATA_IS_EGG)
- && GetMonData(&party[val], MON_DATA_HP) != 0
- && gBattlerPartyIndexes[gActiveBattler] != val)
+ if (GetMonData(&party[i], MON_DATA_SPECIES) != SPECIES_NONE
+ && !GetMonData(&party[i], MON_DATA_IS_EGG)
+ && GetMonData(&party[i], MON_DATA_HP) != 0
+ && gBattlerPartyIndexes[gActiveBattler] != i)
break;
}
- if (val == compareVar)
+ if (i == lastMonId)
gBattlescriptCurrInstr = BSScriptReadPtr(gBattlescriptCurrInstr + 2);
else
gBattlescriptCurrInstr += 6;
@@ -5365,58 +5107,61 @@ static void atk4F_jumpifcantswitch(void)
{
party = gEnemyParty;
- val = 0;
- if (gActiveBattler == 3)
- val = 3;
+ i = 0;
+ if (gActiveBattler == B_POSITION_OPPONENT_RIGHT)
+ i = 3;
- for (compareVar = val + 3; val < compareVar; val++)
+ for (lastMonId = i + 3; i < lastMonId; i++)
{
- if (GetMonData(&party[val], MON_DATA_SPECIES) != SPECIES_NONE
- && !GetMonData(&party[val], MON_DATA_IS_EGG)
- && GetMonData(&party[val], MON_DATA_HP) != 0
- && gBattlerPartyIndexes[gActiveBattler] != val)
+ if (GetMonData(&party[i], MON_DATA_SPECIES) != SPECIES_NONE
+ && !GetMonData(&party[i], MON_DATA_IS_EGG)
+ && GetMonData(&party[i], MON_DATA_HP) != 0
+ && gBattlerPartyIndexes[gActiveBattler] != i)
break;
}
- if (val == compareVar)
+ if (i == lastMonId)
gBattlescriptCurrInstr = BSScriptReadPtr(gBattlescriptCurrInstr + 2);
else
gBattlescriptCurrInstr += 6;
}
else
{
+ u8 battlerIn1, battlerIn2;
+
if (GetBattlerSide(gActiveBattler) == B_SIDE_OPPONENT)
{
- r7 = GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT);
+ battlerIn1 = GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT);
if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE)
- compareVar = GetBattlerAtPosition(B_POSITION_OPPONENT_RIGHT);
+ battlerIn2 = GetBattlerAtPosition(B_POSITION_OPPONENT_RIGHT);
else
- compareVar = r7;
+ battlerIn2 = battlerIn1;
party = gEnemyParty;
}
else
{
- r7 = GetBattlerAtPosition(B_POSITION_PLAYER_LEFT);
+ battlerIn1 = GetBattlerAtPosition(B_POSITION_PLAYER_LEFT);
if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE)
- compareVar = GetBattlerAtPosition(B_POSITION_PLAYER_RIGHT);
+ battlerIn2 = GetBattlerAtPosition(B_POSITION_PLAYER_RIGHT);
else
- compareVar = r7;
+ battlerIn2 = battlerIn1;
party = gPlayerParty;
}
- for (val = 0; val < 6; val++)
+
+ for (i = 0; i < PARTY_SIZE; i++)
{
- if (GetMonData(&party[val], MON_DATA_HP) != 0
- && GetMonData(&party[val], MON_DATA_SPECIES) != SPECIES_NONE
- && !GetMonData(&party[val], MON_DATA_IS_EGG)
- && val != gBattlerPartyIndexes[r7] && val != gBattlerPartyIndexes[compareVar])
+ if (GetMonData(&party[i], MON_DATA_HP) != 0
+ && GetMonData(&party[i], MON_DATA_SPECIES) != SPECIES_NONE
+ && !GetMonData(&party[i], MON_DATA_IS_EGG)
+ && i != gBattlerPartyIndexes[battlerIn1] && i != gBattlerPartyIndexes[battlerIn2])
break;
}
- if (val == 6)
+ if (i == 6)
gBattlescriptCurrInstr = BSScriptReadPtr(gBattlescriptCurrInstr + 2);
else
gBattlescriptCurrInstr += 6;
diff --git a/src/battle_setup.c b/src/battle_setup.c
index 5b2bf4d98..fa1eb7edc 100644
--- a/src/battle_setup.c
+++ b/src/battle_setup.c
@@ -31,6 +31,7 @@
#include "string_util.h"
#include "overworld.h"
#include "field_weather.h"
+#include "gym_leader_rematch.h"
enum
{
@@ -66,7 +67,6 @@ extern void Overworld_ClearSavedMusic(void);
extern void CB2_WhiteOut(void);
extern void sub_80AF6F0(void);
extern void PlayBattleBGM(void);
-extern void sub_81DA57C(void);
extern u8 Overworld_GetFlashLevel(void);
extern u16 sub_81A9AA8(u8 localId);
extern u16 sub_81D6180(u8 localId);
@@ -252,84 +252,84 @@ static const struct TrainerBattleParameter sTrainerBContinueScriptBattleParams[]
const struct RematchTrainer gRematchTable[REMATCH_TABLE_ENTRIES] =
{
- {{0x0025, 0x0028, 0x0029, 0x002a, 0x002b}, 0x0000, 0x0021},
- {{0x02e1, 0x032c, 0x032d, 0x032e, 0x032f}, 0x0000, 0x0014},
- {{0x002c, 0x002f, 0x0030, 0x0031, 0x0032}, 0x0000, 0x001a},
- {{0x0039, 0x003c, 0x003d, 0x003e, 0x003f}, 0x0000, 0x0018},
- {{0x0040, 0x0043, 0x0044, 0x0045, 0x0046}, 0x0000, 0x0018},
- {{0x02af, 0x02b0, 0x02b1, 0x02b2, 0x02b3}, 0x0000, 0x0027},
- {{0x02ff, 0x033c, 0x033d, 0x033e, 0x033f}, 0x0000, 0x0024},
- {{0x005e, 0x0065, 0x0066, 0x0067, 0x0068}, 0x0000, 0x001a},
- {{0x004e, 0x0054, 0x0055, 0x0056, 0x0057}, 0x0000, 0x001a},
- {{0x006c, 0x006e, 0x006f, 0x0070, 0x0071}, 0x0018, 0x0014},
- {{0x0072, 0x0078, 0x0079, 0x007a, 0x007b}, 0x0000, 0x0013},
- {{0x0090, 0x034c, 0x034d, 0x034e, 0x034f}, 0x0018, 0x0038},
- {{0x007f, 0x0084, 0x0085, 0x0086, 0x0087}, 0x0000, 0x0024},
- {{0x0088, 0x008b, 0x008c, 0x008d, 0x008e}, 0x0000, 0x0013},
- {{0x008f, 0x0093, 0x0094, 0x0095, 0x0096}, 0x0000, 0x001d},
- {{0x009b, 0x00af, 0x00b0, 0x00b1, 0x00b2}, 0x0000, 0x0016},
- {{0x00b7, 0x00b8, 0x00b9, 0x00ba, 0x00bb}, 0x0000, 0x001e},
- {{0x02a0, 0x0338, 0x0339, 0x033a, 0x033b}, 0x0000, 0x002a},
- {{0x00c3, 0x0340, 0x0341, 0x0342, 0x0343}, 0x0000, 0x0026},
- {{0x00c4, 0x00c5, 0x00c6, 0x00c7, 0x00c8}, 0x0000, 0x0021},
- {{0x00ce, 0x00cf, 0x00d0, 0x00d1, 0x00d2}, 0x0000, 0x001d},
- {{0x00d8, 0x00db, 0x00dc, 0x00dd, 0x00de}, 0x0018, 0x000d},
- {{0x02a9, 0x02aa, 0x02ab, 0x02ac, 0x02ad}, 0x0018, 0x0001},
- {{0x00e2, 0x00e4, 0x00e5, 0x00e6, 0x00e7}, 0x0000, 0x0023},
- {{0x00ee, 0x00ef, 0x00f0, 0x00f1, 0x00f2}, 0x0000, 0x0026},
- {{0x00f9, 0x00fa, 0x00fb, 0x00fc, 0x00fd}, 0x0000, 0x0026},
- {{0x00fe, 0x0101, 0x0102, 0x0103, 0x0104}, 0x0000, 0x0024},
- {{0x0118, 0x011a, 0x011b, 0x011c, 0x011d}, 0x0000, 0x001f},
- {{0x0111, 0x0114, 0x0115, 0x0116, 0x0117}, 0x0000, 0x001f},
- {{0x011f, 0x0120, 0x0121, 0x0122, 0x0123}, 0x0000, 0x0020},
- {{0x012e, 0x012f, 0x0130, 0x0131, 0x0132}, 0x0000, 0x0019},
- {{0x0125, 0x0127, 0x0128, 0x0129, 0x012a}, 0x0000, 0x0012},
- {{0x0133, 0x0134, 0x0135, 0x0136, 0x0137}, 0x0000, 0x001e},
- {{0x0139, 0x013a, 0x013b, 0x013c, 0x013d}, 0x0018, 0x000c},
- {{0x013e, 0x0148, 0x0149, 0x014a, 0x014b}, 0x0000, 0x0011},
- {{0x0153, 0x015a, 0x015b, 0x015c, 0x015d}, 0x0000, 0x0015},
- {{0x0178, 0x017b, 0x017c, 0x017d, 0x017e}, 0x0000, 0x002b},
- {{0x0171, 0x0172, 0x0173, 0x0174, 0x0175}, 0x0000, 0x0020},
- {{0x0166, 0x0168, 0x0169, 0x016a, 0x016b}, 0x0000, 0x0019},
- {{0x016c, 0x016d, 0x016e, 0x016f, 0x0170}, 0x0000, 0x0020},
- {{0x0182, 0x0184, 0x0185, 0x0186, 0x0187}, 0x0000, 0x002b},
- {{0x0161, 0x0162, 0x0163, 0x0164, 0x0165}, 0x0000, 0x0019},
- {{0x0179, 0x0334, 0x0335, 0x0336, 0x0337}, 0x0000, 0x0029},
- {{0x0188, 0x0189, 0x018a, 0x018b, 0x018c}, 0x0018, 0x0001},
- {{0x0196, 0x0199, 0x019a, 0x019b, 0x019c}, 0x0000, 0x0023},
- {{0x01a3, 0x01a5, 0x01a6, 0x01a7, 0x01a8}, 0x0000, 0x001c},
- {{0x01ab, 0x01ae, 0x01af, 0x01b0, 0x01b1}, 0x0000, 0x001e},
- {{0x01b2, 0x01b5, 0x01b6, 0x01b7, 0x01b8}, 0x0000, 0x001c},
- {{0x01c1, 0x01d1, 0x01d2, 0x01d3, 0x01d4}, 0x0000, 0x0027},
- {{0x01da, 0x01dd, 0x01de, 0x01df, 0x01e0}, 0x0018, 0x000d},
- {{0x01e1, 0x01e2, 0x01e7, 0x01e8, 0x01e9}, 0x0000, 0x0012},
- {{0x01ec, 0x01f1, 0x01f2, 0x01f3, 0x01f4}, 0x0000, 0x0028},
- {{0x02e4, 0x0330, 0x0331, 0x0332, 0x0333}, 0x0000, 0x0017},
- {{0x0200, 0x0203, 0x0204, 0x0205, 0x0206}, 0x0000, 0x0019},
- {{0x0221, 0x0224, 0x0225, 0x0226, 0x0227}, 0x0000, 0x0020},
- {{0x021a, 0x021d, 0x021e, 0x021f, 0x0220}, 0x0000, 0x0020},
- {{0x0009, 0x0348, 0x0349, 0x034a, 0x034b}, 0x0018, 0x0011},
- {{0x022f, 0x0232, 0x0233, 0x0234, 0x0235}, 0x0000, 0x0022},
- {{0x0228, 0x022b, 0x022c, 0x022d, 0x022e}, 0x0000, 0x0022},
- {{0x025c, 0x025f, 0x0260, 0x0261, 0x0262}, 0x0000, 0x0013},
- {{0x026d, 0x026e, 0x026f, 0x0270, 0x0271}, 0x0018, 0x000b},
- {{0x0273, 0x027c, 0x027d, 0x027e, 0x027f}, 0x0000, 0x001b},
- {{0x0001, 0x0344, 0x0345, 0x0346, 0x0347}, 0x0018, 0x000c},
- {{0x0282, 0x0283, 0x0284, 0x0285, 0x0286}, 0x0018, 0x003e},
- {{0x0291, 0x0292, 0x0293, 0x0294, 0x0294}, 0x0018, 0x002b},
- {{0x0109, 0x0302, 0x0303, 0x0304, 0x0305}, 0x0000, 0x0003},
- {{0x010a, 0x0306, 0x0307, 0x0308, 0x0309}, 0x0000, 0x000b},
- {{0x010b, 0x030a, 0x030b, 0x030c, 0x030d}, 0x0000, 0x0002},
- {{0x010c, 0x030e, 0x030f, 0x0310, 0x0311}, 0x0000, 0x000c},
- {{0x010d, 0x0312, 0x0313, 0x0314, 0x0315}, 0x0000, 0x0000},
- {{0x010e, 0x0316, 0x0317, 0x0318, 0x0319}, 0x0000, 0x0004},
- {{0x010f, 0x031a, 0x031b, 0x031c, 0x031d}, 0x0000, 0x0006},
- {{0x0110, 0x031e, 0x031f, 0x0320, 0x0321}, 0x0000, 0x0007},
- {{0x0105, 0x0105, 0x0105, 0x0105, 0x0105}, 0x0000, 0x0008},
- {{0x0106, 0x0106, 0x0106, 0x0106, 0x0106}, 0x0000, 0x0008},
- {{0x0107, 0x0107, 0x0107, 0x0107, 0x0107}, 0x0000, 0x0008},
- {{0x0108, 0x0108, 0x0108, 0x0108, 0x0108}, 0x0000, 0x0008},
- {{0x014f, 0x014f, 0x014f, 0x014f, 0x014f}, 0x0000, 0x0008},
+ {{TRAINER_ROSE_1, TRAINER_ROSE_2, TRAINER_ROSE_3, TRAINER_ROSE_4, TRAINER_ROSE_5}, 0x0, 0x21},
+ {{TRAINER_ANDRES_1, TRAINER_ANDRES_2, TRAINER_ANDRES_3, TRAINER_ANDRES_4, TRAINER_ANDRES_5}, 0x0, 0x14},
+ {{TRAINER_DUSTY_1, TRAINER_DUSTY_2, TRAINER_DUSTY_3, TRAINER_DUSTY_4, TRAINER_DUSTY_5}, 0x0, 0x1a},
+ {{TRAINER_LOLA_1, TRAINER_LOLA_2, TRAINER_LOLA_3, TRAINER_LOLA_4, TRAINER_LOLA_5}, 0x0, 0x18},
+ {{TRAINER_RICKY_1, TRAINER_RICKY_2, TRAINER_RICKY_3, TRAINER_RICKY_4, TRAINER_RICKY_5}, 0x0, 0x18},
+ {{TRAINER_LILA_AND_ROY_1, TRAINER_LILA_AND_ROY_2, TRAINER_LILA_AND_ROY_3, TRAINER_LILA_AND_ROY_4, TRAINER_LILA_AND_ROY_5}, 0x0, 0x27},
+ {{TRAINER_CRISTIN_1, TRAINER_CRISTIN_2, TRAINER_CRISTIN_3, TRAINER_CRISTIN_4, TRAINER_CRISTIN_5}, 0x0, 0x24},
+ {{TRAINER_BROOKE_1, TRAINER_BROOKE_2, TRAINER_BROOKE_3, TRAINER_BROOKE_4, TRAINER_BROOKE_5}, 0x0, 0x1a},
+ {{TRAINER_WILTON_1, TRAINER_WILTON_2, TRAINER_WILTON_3, TRAINER_WILTON_4, TRAINER_WILTON_5}, 0x0, 0x1a},
+ {{TRAINER_VALERIE_1, TRAINER_VALERIE_2, TRAINER_VALERIE_3, TRAINER_VALERIE_4, TRAINER_VALERIE_5}, 0x18, 0x14},
+ {{TRAINER_CINDY_1, TRAINER_CINDY_3, TRAINER_CINDY_4, TRAINER_CINDY_5, TRAINER_CINDY_6}, 0x0, 0x13},
+ {{TRAINER_THALIA_1, TRAINER_THALIA_2, TRAINER_THALIA_3, TRAINER_THALIA_4, TRAINER_THALIA_5}, 0x18, 0x38},
+ {{TRAINER_JESSICA_1, TRAINER_JESSICA_2, TRAINER_JESSICA_3, TRAINER_JESSICA_4, TRAINER_JESSICA_5}, 0x0, 0x24},
+ {{TRAINER_WINSTON_1, TRAINER_WINSTON_2, TRAINER_WINSTON_3, TRAINER_WINSTON_4, TRAINER_WINSTON_5}, 0x0, 0x13},
+ {{TRAINER_STEVE_1, TRAINER_STEVE_2, TRAINER_STEVE_3, TRAINER_STEVE_4, TRAINER_STEVE_5}, 0x0, 0x1d},
+ {{TRAINER_TONY_1, TRAINER_TONY_2, TRAINER_TONY_3, TRAINER_TONY_4, TRAINER_TONY_5}, 0x0, 0x16},
+ {{TRAINER_NOB_1, TRAINER_NOB_2, TRAINER_NOB_3, TRAINER_NOB_4, TRAINER_NOB_5}, 0x0, 0x1e},
+ {{TRAINER_KOJI_1, TRAINER_KOJI_2, TRAINER_KOJI_3, TRAINER_KOJI_4, TRAINER_KOJI_5}, 0x0, 0x2a},
+ {{TRAINER_FERNANDO_1, TRAINER_FERNANDO_2, TRAINER_FERNANDO_3, TRAINER_FERNANDO_4, TRAINER_FERNANDO_5}, 0x0, 0x26},
+ {{TRAINER_DALTON_1, TRAINER_DALTON_2, TRAINER_DALTON_3, TRAINER_DALTON_4, TRAINER_DALTON_5}, 0x0, 0x21},
+ {{TRAINER_BERNIE_1, TRAINER_BERNIE_2, TRAINER_BERNIE_3, TRAINER_BERNIE_4, TRAINER_BERNIE_5}, 0x0, 0x1d},
+ {{TRAINER_ETHAN_1, TRAINER_ETHAN_2, TRAINER_ETHAN_3, TRAINER_ETHAN_4, TRAINER_ETHAN_5}, 0x18, 0xd},
+ {{TRAINER_JOHN_AND_JAY_1, TRAINER_JOHN_AND_JAY_2, TRAINER_JOHN_AND_JAY_3, TRAINER_JOHN_AND_JAY_4, TRAINER_JOHN_AND_JAY_5}, 0x18, 0x1},
+ {{TRAINER_JEFFREY_1, TRAINER_JEFFREY_2, TRAINER_JEFFREY_3, TRAINER_JEFFREY_4, TRAINER_JEFFREY_5}, 0x0, 0x23},
+ {{TRAINER_CAMERON_1, TRAINER_CAMERON_2, TRAINER_CAMERON_3, TRAINER_CAMERON_4, TRAINER_CAMERON_5}, 0x0, 0x26},
+ {{TRAINER_JACKI_1, TRAINER_JACKI_2, TRAINER_JACKI_3, TRAINER_JACKI_4, TRAINER_JACKI_5}, 0x0, 0x26},
+ {{TRAINER_WALTER_1, TRAINER_WALTER_2, TRAINER_WALTER_3, TRAINER_WALTER_4, TRAINER_WALTER_5}, 0x0, 0x24},
+ {{TRAINER_KAREN_1, TRAINER_KAREN_2, TRAINER_KAREN_3, TRAINER_KAREN_4, TRAINER_KAREN_5}, 0x0, 0x1f},
+ {{TRAINER_JERRY_1, TRAINER_JERRY_2, TRAINER_JERRY_3, TRAINER_JERRY_4, TRAINER_JERRY_5}, 0x0, 0x1f},
+ {{TRAINER_ANNA_AND_MEG_1, TRAINER_ANNA_AND_MEG_2, TRAINER_ANNA_AND_MEG_3, TRAINER_ANNA_AND_MEG_4, TRAINER_ANNA_AND_MEG_5}, 0x0, 0x20},
+ {{TRAINER_ISABEL_1, TRAINER_ISABEL_2, TRAINER_ISABEL_3, TRAINER_ISABEL_4, TRAINER_ISABEL_5}, 0x0, 0x19},
+ {{TRAINER_MIGUEL_1, TRAINER_MIGUEL_2, TRAINER_MIGUEL_3, TRAINER_MIGUEL_4, TRAINER_MIGUEL_5}, 0x0, 0x12},
+ {{TRAINER_TIMOTHY_1, TRAINER_TIMOTHY_2, TRAINER_TIMOTHY_3, TRAINER_TIMOTHY_4, TRAINER_TIMOTHY_5}, 0x0, 0x1e},
+ {{TRAINER_SHELBY_1, TRAINER_SHELBY_2, TRAINER_SHELBY_3, TRAINER_SHELBY_4, TRAINER_SHELBY_5}, 0x18, 0xc},
+ {{TRAINER_CALVIN_1, TRAINER_CALVIN_2, TRAINER_CALVIN_3, TRAINER_CALVIN_4, TRAINER_CALVIN_5}, 0x0, 0x11},
+ {{TRAINER_ELLIOT_1, TRAINER_ELLIOT_2, TRAINER_ELLIOT_3, TRAINER_ELLIOT_4, TRAINER_ELLIOT_5}, 0x0, 0x15},
+ {{TRAINER_ISAIAH_1, TRAINER_ISAIAH_2, TRAINER_ISAIAH_3, TRAINER_ISAIAH_4, TRAINER_ISAIAH_5}, 0x0, 0x2b},
+ {{TRAINER_MARIA_1, TRAINER_MARIA_2, TRAINER_MARIA_3, TRAINER_MARIA_4, TRAINER_MARIA_5}, 0x0, 0x20},
+ {{TRAINER_ABIGAIL_1, TRAINER_ABIGAIL_2, TRAINER_ABIGAIL_3, TRAINER_ABIGAIL_4, TRAINER_ABIGAIL_5}, 0x0, 0x19},
+ {{TRAINER_DYLAN_1, TRAINER_DYLAN_2, TRAINER_DYLAN_3, TRAINER_DYLAN_4, TRAINER_DYLAN_5}, 0x0, 0x20},
+ {{TRAINER_KATELYN_1, TRAINER_KATELYN_2, TRAINER_KATELYN_3, TRAINER_KATELYN_4, TRAINER_KATELYN_5}, 0x0, 0x2b},
+ {{TRAINER_BENJAMIN_1, TRAINER_BENJAMIN_2, TRAINER_BENJAMIN_3, TRAINER_BENJAMIN_4, TRAINER_BENJAMIN_5}, 0x0, 0x19},
+ {{TRAINER_PABLO_1, TRAINER_PABLO_2, TRAINER_PABLO_3, TRAINER_PABLO_4, TRAINER_PABLO_5}, 0x0, 0x29},
+ {{TRAINER_NICOLAS_1, TRAINER_NICOLAS_2, TRAINER_NICOLAS_3, TRAINER_NICOLAS_4, TRAINER_NICOLAS_5}, 0x18, 0x1},
+ {{TRAINER_ROBERT_1, TRAINER_ROBERT_2, TRAINER_ROBERT_3, TRAINER_ROBERT_4, TRAINER_ROBERT_5}, 0x0, 0x23},
+ {{TRAINER_LAO_1, TRAINER_LAO_2, TRAINER_LAO_3, TRAINER_LAO_4, TRAINER_LAO_5}, 0x0, 0x1c},
+ {{TRAINER_CYNDY_1, TRAINER_CYNDY_2, TRAINER_CYNDY_3, TRAINER_CYNDY_4, TRAINER_CYNDY_5}, 0x0, 0x1e},
+ {{TRAINER_MADELINE_1, TRAINER_MADELINE_2, TRAINER_MADELINE_3, TRAINER_MADELINE_4, TRAINER_MADELINE_5}, 0x0, 0x1c},
+ {{TRAINER_JENNY_1, TRAINER_JENNY_2, TRAINER_JENNY_3, TRAINER_JENNY_4, TRAINER_JENNY_5}, 0x0, 0x27},
+ {{TRAINER_DIANA_1, TRAINER_DIANA_2, TRAINER_DIANA_3, TRAINER_DIANA_4, TRAINER_DIANA_5}, 0x18, 0xd},
+ {{TRAINER_AMY_AND_LIV_1, TRAINER_AMY_AND_LIV_2, TRAINER_AMY_AND_LIV_4, TRAINER_AMY_AND_LIV_5, TRAINER_AMY_AND_LIV_6}, 0x0, 0x12},
+ {{TRAINER_ERNEST_1, TRAINER_ERNEST_2, TRAINER_ERNEST_3, TRAINER_ERNEST_4, TRAINER_ERNEST_5}, 0x0, 0x28},
+ {{TRAINER_CORY_1, TRAINER_CORY_2, TRAINER_CORY_3, TRAINER_CORY_4, TRAINER_CORY_5}, 0x0, 0x17},
+ {{TRAINER_EDWIN_1, TRAINER_EDWIN_2, TRAINER_EDWIN_3, TRAINER_EDWIN_4, TRAINER_EDWIN_5}, 0x0, 0x19},
+ {{TRAINER_LYDIA_1, TRAINER_LYDIA_2, TRAINER_LYDIA_3, TRAINER_LYDIA_4, TRAINER_LYDIA_5}, 0x0, 0x20},
+ {{TRAINER_ISAAC_1, TRAINER_ISAAC_2, TRAINER_ISAAC_3, TRAINER_ISAAC_4, TRAINER_ISAAC_5}, 0x0, 0x20},
+ {{TRAINER_GABRIELLE_1, TRAINER_GABRIELLE_2, TRAINER_GABRIELLE_3, TRAINER_GABRIELLE_4, TRAINER_GABRIELLE_5}, 0x18, 0x11},
+ {{TRAINER_CATHERINE_1, TRAINER_CATHERINE_2, TRAINER_CATHERINE_3, TRAINER_CATHERINE_4, TRAINER_CATHERINE_5}, 0x0, 0x22},
+ {{TRAINER_JACKSON_1, TRAINER_JACKSON_2, TRAINER_JACKSON_3, TRAINER_JACKSON_4, TRAINER_JACKSON_5}, 0x0, 0x22},
+ {{TRAINER_HALEY_1, TRAINER_HALEY_2, TRAINER_HALEY_3, TRAINER_HALEY_4, TRAINER_HALEY_5}, 0x0, 0x13},
+ {{TRAINER_JAMES_1, TRAINER_JAMES_2, TRAINER_JAMES_3, TRAINER_JAMES_4, TRAINER_JAMES_5}, 0x18, 0xb},
+ {{TRAINER_TRENT_1, TRAINER_TRENT_2, TRAINER_TRENT_3, TRAINER_TRENT_4, TRAINER_TRENT_5}, 0x0, 0x1b},
+ {{TRAINER_SAWYER_1, TRAINER_SAWYER_2, TRAINER_SAWYER_3, TRAINER_SAWYER_4, TRAINER_SAWYER_5}, 0x18, 0xc},
+ {{TRAINER_KIRA_AND_DAN_1, TRAINER_KIRA_AND_DAN_2, TRAINER_KIRA_AND_DAN_3, TRAINER_KIRA_AND_DAN_4, TRAINER_KIRA_AND_DAN_5}, 0x18, 0x3e},
+ {{TRAINER_WALLY_3, 0x292, 0x293, 0x294, 0x294}, 0x18, 0x2b},
+ {{TRAINER_ROXANNE_1, TRAINER_ROXANNE_2, TRAINER_ROXANNE_3, TRAINER_ROXANNE_4, TRAINER_ROXANNE_5}, 0x0, 0x3},
+ {{TRAINER_BRAWLY_1, TRAINER_BRAWLY_2, TRAINER_BRAWLY_3, TRAINER_BRAWLY_4, TRAINER_BRAWLY_5}, 0x0, 0xb},
+ {{TRAINER_WATTSON_1, TRAINER_WATTSON_2, TRAINER_WATTSON_3, TRAINER_WATTSON_4, TRAINER_WATTSON_5}, 0x0, 0x2},
+ {{TRAINER_FLANNERY_1, TRAINER_FLANNERY_2, TRAINER_FLANNERY_3, TRAINER_FLANNERY_4, TRAINER_FLANNERY_5}, 0x0, 0xc},
+ {{TRAINER_NORMAN_1, TRAINER_NORMAN_2, TRAINER_NORMAN_3, TRAINER_NORMAN_4, TRAINER_NORMAN_5}, 0x0, 0x0},
+ {{TRAINER_WINONA_1, TRAINER_WINONA_2, TRAINER_WINONA_3, TRAINER_WINONA_4, TRAINER_WINONA_5}, 0x0, 0x4},
+ {{TRAINER_TATE_AND_LIZA_1, TRAINER_TATE_AND_LIZA_2, TRAINER_TATE_AND_LIZA_3, TRAINER_TATE_AND_LIZA_4, TRAINER_TATE_AND_LIZA_5}, 0x0, 0x6},
+ {{TRAINER_JUAN_1, TRAINER_JUAN_2, TRAINER_JUAN_3, TRAINER_JUAN_4, TRAINER_JUAN_5}, 0x0, 0x7},
+ {{TRAINER_SIDNEY, TRAINER_SIDNEY, TRAINER_SIDNEY, TRAINER_SIDNEY, TRAINER_SIDNEY}, 0x0, 0x8},
+ {{TRAINER_PHOEBE, TRAINER_PHOEBE, TRAINER_PHOEBE, TRAINER_PHOEBE, TRAINER_PHOEBE}, 0x0, 0x8},
+ {{TRAINER_GLACIA, TRAINER_GLACIA, TRAINER_GLACIA, TRAINER_GLACIA, TRAINER_GLACIA}, 0x0, 0x8},
+ {{TRAINER_DRAKE, TRAINER_DRAKE, TRAINER_DRAKE, TRAINER_DRAKE, TRAINER_DRAKE}, 0x0, 0x8},
+ {{TRAINER_WALLACE, TRAINER_WALLACE, TRAINER_WALLACE, TRAINER_WALLACE, TRAINER_WALLACE}, 0x0, 0x8},
};
static const u16 sBadgeFlags[8] =
@@ -945,13 +945,13 @@ static void CB2_EndFirstBattle(void)
static void sub_80B1218(void)
{
if (GetGameStat(GAME_STAT_WILD_BATTLES) % 60 == 0)
- sub_81DA57C();
+ UpdateGymLeaderRematch();
}
static void sub_80B1234(void)
{
if (GetGameStat(GAME_STAT_TRAINER_BATTLES) % 20 == 0)
- sub_81DA57C();
+ UpdateGymLeaderRematch();
}
// why not just use the macros? maybe its because they didnt want to uncast const every time?
diff --git a/src/battle_util.c b/src/battle_util.c
index a457ce15d..662e5b2a6 100644
--- a/src/battle_util.c
+++ b/src/battle_util.c
@@ -23,7 +23,6 @@
#include "link.h"
#include "berry.h"
-extern const struct BattleMove gBattleMoves[];
extern u8 weather_get_current(void);
@@ -3255,8 +3254,8 @@ u8 GetMoveTarget(u16 move, u8 useMoveTarget)
else
targetBank = GetBattlerAtPosition((GetBattlerPosition(gBattlerAttacker) & BIT_SIDE) ^ BIT_SIDE);
break;
+ case MOVE_TARGET_USER_OR_SELECTED:
case MOVE_TARGET_USER:
- case MOVE_TARGET_x10:
targetBank = gBattlerAttacker;
break;
}
diff --git a/src/blit.c b/src/blit.c
new file mode 100644
index 000000000..b4d5f7de5
--- /dev/null
+++ b/src/blit.c
@@ -0,0 +1,209 @@
+#include "global.h"
+#include "blit.h"
+
+void BlitBitmapRect4BitWithoutColorKey(struct Bitmap *src, struct Bitmap *dst, u16 srcX, u16 srcY, u16 dstX, u16 dstY, u16 width, u16 height)
+{
+ BlitBitmapRect4Bit(src, dst, srcX, srcY, dstX, dstY, width, height, 0xFF);
+}
+
+void BlitBitmapRect4Bit(struct Bitmap *src, struct Bitmap *dst, u16 srcX, u16 srcY, u16 dstX, u16 dstY, u16 width, u16 height, u8 colorKey)
+{
+ s32 xEnd;
+ s32 yEnd;
+ s32 multiplierSrcY;
+ s32 multiplierDstY;
+ s32 loopSrcY, loopDstY;
+ s32 loopSrcX, loopDstX;
+ u8 *pixelsSrc;
+ u8 *pixelsDst;
+ s32 toOrr;
+ s32 toAnd;
+ s32 toShift;
+
+ if (dst->width - dstX < width)
+ xEnd = (dst->width - dstX) + srcX;
+ else
+ xEnd = srcX + width;
+
+ if (dst->height - dstY < height)
+ yEnd = (dst->height - dstY) + srcY;
+ else
+ yEnd = height + srcY;
+
+ multiplierSrcY = (src->width + (src->width & 7)) >> 3;
+ multiplierDstY = (dst->width + (dst->width & 7)) >> 3;
+
+ if (colorKey == 0xFF)
+ {
+ for (loopSrcY = srcY, loopDstY = dstY; loopSrcY < yEnd; loopSrcY++, loopDstY++)
+ {
+ for (loopSrcX = srcX, loopDstX = dstX; loopSrcX < xEnd; loopSrcX++, loopDstX++)
+ {
+ pixelsSrc = src->pixels + ((loopSrcX >> 1) & 3) + ((loopSrcX >> 3) << 5) + (((loopSrcY >> 3) * multiplierSrcY) << 5) + ((u32)(loopSrcY << 0x1d) >> 0x1B);
+ pixelsDst = dst->pixels + ((loopDstX >> 1) & 3) + ((loopDstX >> 3) << 5) + (((loopDstY >> 3) * multiplierDstY) << 5) + ((u32)(loopDstY << 0x1d) >> 0x1B);
+ toOrr = ((*pixelsSrc >> ((loopSrcX & 1) << 2)) & 0xF);
+ toShift = ((loopDstX & 1) << 2);
+ toOrr <<= toShift;
+ toAnd = 0xF0 >> (toShift);
+ *pixelsDst = toOrr | (*pixelsDst & toAnd);
+ }
+ }
+ }
+ else
+ {
+ for (loopSrcY = srcY, loopDstY = dstY; loopSrcY < yEnd; loopSrcY++, loopDstY++)
+ {
+ for (loopSrcX = srcX, loopDstX = dstX; loopSrcX < xEnd; loopSrcX++, loopDstX++)
+ {
+ pixelsSrc = src->pixels + ((loopSrcX >> 1) & 3) + ((loopSrcX >> 3) << 5) + (((loopSrcY >> 3) * multiplierSrcY) << 5) + ((u32)(loopSrcY << 0x1d) >> 0x1B);
+ pixelsDst = dst->pixels + ((loopDstX >> 1) & 3) + ((loopDstX >> 3) << 5) + (((loopDstY >> 3) * multiplierDstY) << 5) + ((u32)(loopDstY << 0x1d) >> 0x1B);
+ toOrr = ((*pixelsSrc >> ((loopSrcX & 1) << 2)) & 0xF);
+ if (toOrr != colorKey)
+ {
+ toShift = ((loopDstX & 1) << 2);
+ toOrr <<= toShift;
+ toAnd = 0xF0 >> (toShift);
+ *pixelsDst = toOrr | (*pixelsDst & toAnd);
+ }
+ }
+ }
+ }
+}
+
+void FillBitmapRect4Bit(struct Bitmap *surface, u16 x, u16 y, u16 width, u16 height, u8 fillValue)
+{
+ s32 xEnd;
+ s32 yEnd;
+ s32 multiplierY;
+ s32 loopX, loopY;
+ s32 toOrr1, toOrr2;
+
+ xEnd = x + width;
+ if (xEnd > surface->width)
+ xEnd = surface->width;
+
+ yEnd = y + height;
+ if (yEnd > surface->height)
+ yEnd = surface->height;
+
+ multiplierY = (surface->width + (surface->width & 7)) >> 3;
+ toOrr1 = (u32)(fillValue << 0x1C) >> 0x18;
+ toOrr2 = (fillValue & 0xF);
+
+ for (loopY = y; loopY < yEnd; loopY++)
+ {
+ for (loopX = x; loopX < xEnd; loopX++)
+ {
+ u8 *pixels = surface->pixels + ((loopX >> 1) & 3) + ((loopX >> 3) << 5) + (((loopY >> 3) * multiplierY) << 5) + ((u32)(loopY << 0x1d) >> 0x1B);
+ if ((loopX << 0x1F) != 0)
+ *pixels = toOrr1 | (*pixels & 0xF);
+ else
+ *pixels = toOrr2 | (*pixels & 0xF0);
+ }
+ }
+}
+
+void BlitBitmapRect4BitTo8Bit(struct Bitmap *src, struct Bitmap *dst, u16 srcX, u16 srcY, u16 dstX, u16 dstY, u16 width, u16 height, u8 colorKey, u8 paletteOffset)
+{
+ s32 palOffsetBits;
+ s32 xEnd;
+ s32 yEnd;
+ s32 multiplierSrcY;
+ s32 multiplierDstY;
+ s32 loopSrcY, loopDstY;
+ s32 loopSrcX, loopDstX;
+ u8 *pixelsSrc;
+ u8 *pixelsDst;
+ s32 colorKeyBits;
+
+ palOffsetBits = (u32)(paletteOffset << 0x1C) >> 0x18;
+ colorKeyBits = (u32)(colorKey << 0x1C) >> 0x18;
+
+ if (dst->width - dstX < width)
+ xEnd = (dst->width - dstX) + srcX;
+ else
+ xEnd = width + srcX;
+
+ if (dst->height - dstY < height)
+ yEnd = (srcY + dst->height) - dstY;
+ else
+ yEnd = srcY + height;
+
+ multiplierSrcY = (src->width + (src->width & 7)) >> 3;
+ multiplierDstY = (dst->width + (dst->width & 7)) >> 3;
+
+ if (colorKey == 0xFF)
+ {
+ for (loopSrcY = srcY, loopDstY = dstY; loopSrcY < yEnd; loopSrcY++, loopDstY++)
+ {
+ pixelsSrc = src->pixels + ((srcX >> 1) & 3) + ((srcX >> 3) << 5) + (((loopSrcY >> 3) * multiplierSrcY) << 5) + ((u32)(loopSrcY << 0x1d) >> 0x1b);
+ for (loopSrcX = srcX, loopDstX = dstX; loopSrcX < xEnd; loopSrcX++, loopDstX++)
+ {
+ pixelsDst = dst->pixels + (loopDstX & 7) + ((loopDstX >> 3) << 6) + (((loopDstY >> 3) * multiplierDstY) << 6) + ((u32)(loopDstY << 0x1d) >> 0x1a);
+ if (loopSrcX & 1)
+ {
+ *pixelsDst = palOffsetBits + (*pixelsSrc >> 4);
+ }
+ else
+ {
+ pixelsSrc = src->pixels + ((loopSrcX >> 1) & 3) + ((loopSrcX >> 3) << 5) + (((loopSrcY >> 3) * multiplierSrcY) << 5) + ((u32)(loopSrcY << 0x1d) >> 0x1b);
+ *pixelsDst = palOffsetBits + (*pixelsSrc & 0xF);
+ }
+ }
+ }
+ }
+ else
+ {
+ for (loopSrcY = srcY, loopDstY = dstY; loopSrcY < yEnd; loopSrcY++, loopDstY++)
+ {
+ pixelsSrc = src->pixels + ((srcX >> 1) & 3) + ((srcX >> 3) << 5) + (((loopSrcY >> 3) * multiplierSrcY) << 5) + ((u32)(loopSrcY << 0x1d) >> 0x1b);
+ for (loopSrcX = srcX, loopDstX = dstX; loopSrcX < xEnd; loopSrcX++, loopDstX++)
+ {
+ if (loopSrcX & 1)
+ {
+ if ((*pixelsSrc & 0xF0) != colorKeyBits)
+ {
+ pixelsDst = dst->pixels + (loopDstX & 7) + ((loopDstX >> 3) << 6) + (((loopDstY >> 3) * multiplierDstY) << 6) + ((u32)(loopDstY << 0x1d) >> 0x1a);
+ *pixelsDst = palOffsetBits + (*pixelsSrc >> 4);
+ }
+ }
+ else
+ {
+ pixelsSrc = src->pixels + ((loopSrcX >> 1) & 3) + ((loopSrcX >> 3) << 5) + (((loopSrcY >> 3) * multiplierSrcY) << 5) + ((u32)(loopSrcY << 0x1d) >> 0x1b);
+ if ((*pixelsSrc & 0xF) != colorKey)
+ {
+ pixelsDst = dst->pixels + (loopDstX & 7) + ((loopDstX >> 3) << 6) + (((loopDstY >> 3) * multiplierDstY) << 6) + ((u32)(loopDstY << 0x1d) >> 0x1a);
+ *pixelsDst = palOffsetBits + (*pixelsSrc & 0xF);
+ }
+ }
+ }
+ }
+ }
+}
+
+void FillBitmapRect8Bit(struct Bitmap *surface, u16 x, u16 y, u16 width, u16 height, u8 fillValue)
+{
+ s32 xEnd;
+ s32 yEnd;
+ s32 multiplierY;
+ s32 loopX, loopY;
+
+ xEnd = x + width;
+ if (xEnd > surface->width)
+ xEnd = surface->width;
+
+ yEnd = y + height;
+ if (yEnd > surface->height)
+ yEnd = surface->height;
+
+ multiplierY = (surface->width + (surface->width & 7)) >> 3;
+
+ for (loopY = y; loopY < yEnd; loopY++)
+ {
+ for (loopX = x; loopX < xEnd; loopX++)
+ {
+ u8 *pixels = surface->pixels + (loopX & 7) + ((loopX >> 3) << 6) + (((loopY >> 3) * multiplierY) << 6) + ((u32)(loopY << 0x1d) >> 0x1a);
+ *pixels = fillValue;
+ }
+ }
+}
diff --git a/src/gym_leader_rematch.c b/src/gym_leader_rematch.c
new file mode 100644
index 000000000..355ae5534
--- /dev/null
+++ b/src/gym_leader_rematch.c
@@ -0,0 +1,106 @@
+#include "global.h"
+#include "constants/flags.h"
+#include "random.h"
+#include "event_data.h"
+#include "battle_setup.h"
+#include "gym_leader_rematch.h"
+
+static void UpdateGymLeaderRematchFromArray(const u16 *data, size_t size, u32 maxRematch);
+static s32 GetRematchIndex(u32 trainerIdx);
+
+static const u16 GymLeaderRematches_AfterNewMauville[] = {
+ REMATCH_ROXANNE,
+ REMATCH_BRAWLY,
+ REMATCH_WATTSON,
+ REMATCH_FLANNERY,
+ REMATCH_NORMAN,
+ REMATCH_WINONA,
+ REMATCH_TATE_AND_LIZA,
+ REMATCH_JUAN
+};
+
+static const u16 GymLeaderRematches_BeforeNewMauville[] = {
+ REMATCH_ROXANNE,
+ REMATCH_BRAWLY,
+ // Wattson isn't available at this time
+ REMATCH_FLANNERY,
+ REMATCH_NORMAN,
+ REMATCH_WINONA,
+ REMATCH_TATE_AND_LIZA,
+ REMATCH_JUAN
+};
+
+void UpdateGymLeaderRematch(void)
+{
+ if (FlagGet(FLAG_SYS_GAME_CLEAR) && (Random() % 100) <= 30)
+ {
+ if (FlagGet(FLAG_WATTSON_REMATCH_AVAILABLE))
+ UpdateGymLeaderRematchFromArray(GymLeaderRematches_AfterNewMauville, ARRAY_COUNT(GymLeaderRematches_AfterNewMauville), 5);
+ else
+ UpdateGymLeaderRematchFromArray(GymLeaderRematches_BeforeNewMauville, ARRAY_COUNT(GymLeaderRematches_BeforeNewMauville), 1);
+ }
+}
+
+static void UpdateGymLeaderRematchFromArray(const u16 *data, size_t size, u32 maxRematch)
+{
+ s32 whichLeader = 0;
+ s32 lowestRematchIndex = 5;
+ u32 i;
+ s32 rematchIndex;
+ for (i = 0; i < size; i++)
+ {
+ if (!gSaveBlock1Ptr->trainerRematches[data[i]])
+ {
+ rematchIndex = GetRematchIndex(data[i]);
+ if (lowestRematchIndex > rematchIndex)
+ lowestRematchIndex = rematchIndex;
+ whichLeader++;
+ }
+ }
+ if (whichLeader != 0 && lowestRematchIndex <= maxRematch)
+ {
+ whichLeader = 0;
+ for (i = 0; i < size; i++)
+ {
+ if (!gSaveBlock1Ptr->trainerRematches[data[i]])
+ {
+ rematchIndex = GetRematchIndex(data[i]);
+ if (rematchIndex == lowestRematchIndex)
+ whichLeader++;
+ }
+ }
+ if (whichLeader != 0)
+ {
+ whichLeader = Random() % whichLeader;
+ for (i = 0; i < size; i++)
+ {
+ if (!gSaveBlock1Ptr->trainerRematches[data[i]])
+ {
+ rematchIndex = GetRematchIndex(data[i]);
+ if (rematchIndex == lowestRematchIndex)
+ {
+ if (whichLeader == 0)
+ {
+ gSaveBlock1Ptr->trainerRematches[data[i]] = lowestRematchIndex;
+ break;
+ }
+ whichLeader--;
+ }
+ }
+ }
+ }
+ }
+}
+
+static s32 GetRematchIndex(u32 trainerIdx)
+{
+ s32 i;
+ for (i = 0; i < 5; i++)
+ {
+ if (!HasTrainerBeenFought(gRematchTable[trainerIdx].trainerIds[i]))
+ {
+ return i;
+ }
+ }
+ return 5;
+}
diff --git a/src/item_menu.c b/src/item_menu.c
index e88d1c2d3..9090a39c5 100755
--- a/src/item_menu.c
+++ b/src/item_menu.c
@@ -328,7 +328,6 @@ extern u8* gReturnToXStringsTable[];
extern u32 gUnknown_0203CE5E[];
extern u8 EventScript_2736B3[];
extern const u16 gUnknown_0860F074[];
-extern struct BattleMove gBattleMoves[];
void ResetBagScrollPositions(void)
{
diff --git a/src/lilycove_lady.c b/src/lilycove_lady.c
index 81a10f8a4..812f1f975 100644
--- a/src/lilycove_lady.c
+++ b/src/lilycove_lady.c
@@ -606,7 +606,6 @@ u8 sub_818E06C(void)
}
}
-#ifdef NONMATCHING
static u8 sub_818E13C(void)
{
u8 retval;
@@ -627,9 +626,11 @@ static u8 sub_818E13C(void)
len = sub_818E258(gUnknown_0203CD68->playerName);
if (len == sub_818E258(gSaveBlock2Ptr->playerName))
{
+ u8 *name = gUnknown_0203CD68->playerName;
for (i = 0; i < len; i ++)
{
- if (gUnknown_0203CD68->playerName[i] != gSaveBlock2Ptr->playerName[i])
+ name = gUnknown_0203CD68->playerName;
+ if (name[i] != gSaveBlock2Ptr->playerName[i])
{
retval = 2;
break;
@@ -640,85 +641,6 @@ static u8 sub_818E13C(void)
}
return retval;
}
-#else
-ASM_DIRECT static u8 sub_818E13C(void)
-{
- asm_unified("\tpush {r4-r7,lr}\n"
- "\tmovs r7, 0x1\n"
- "\tldr r5, =gUnknown_0203CD68\n"
- "\tldr r0, =gSaveBlock1Ptr\n"
- "\tldr r1, [r0]\n"
- "\tldr r2, =0x00003b58\n"
- "\tadds r0, r1, r2\n"
- "\tstr r0, [r5]\n"
- "\tldrb r0, [r0, 0x18]\n"
- "\tcmp r0, 0xFF\n"
- "\tbne _0818E174\n"
- "\tldr r0, =gStringVar1\n"
- "\tldr r1, =gText_Lady2\n"
- "\tbl StringCopy7\n"
- "\tmovs r7, 0\n"
- "\tb _0818E1DC\n"
- "\t.pool\n"
- "_0818E174:\n"
- "\tldr r4, =gStringVar1\n"
- "\tldr r0, =0x00003b70\n"
- "\tadds r1, r0\n"
- "\tadds r0, r4, 0\n"
- "\tbl StringCopy7\n"
- "\tldr r0, [r5]\n"
- "\tadds r0, 0x2D\n"
- "\tldrb r1, [r0]\n"
- "\tadds r0, r4, 0\n"
- "\tbl ConvertInternationalString\n"
- "\tldr r0, [r5]\n"
- "\tadds r0, 0x18\n"
- "\tbl sub_818E258\n"
- "\tlsls r0, 24\n"
- "\tlsrs r4, r0, 24\n"
- "\tldr r6, =gSaveBlock2Ptr\n"
- "\tldr r0, [r6]\n"
- "\tbl sub_818E258\n"
- "\tlsls r0, 24\n"
- "\tlsrs r0, 24\n"
- "\tcmp r4, r0\n"
- "\tbne _0818E1DC\n"
- "\tldr r0, [r5]\n"
- "\tmovs r2, 0\n"
- "\tcmp r2, r4\n"
- "\tbcs _0818E1DC\n"
- "\tldr r1, [r6]\n"
- "\tldrb r0, [r0, 0x18]\n"
- "\tldrb r1, [r1]\n"
- "\tcmp r0, r1\n"
- "\tbne _0818E1DA\n"
- "_0818E1BA:\n"
- "\tadds r0, r2, 0x1\n"
- "\tlsls r0, 24\n"
- "\tlsrs r2, r0, 24\n"
- "\tcmp r2, r4\n"
- "\tbcs _0818E1DC\n"
- "\tldr r0, =gUnknown_0203CD68\n"
- "\tldr r1, [r0]\n"
- "\tadds r1, 0x18\n"
- "\tadds r1, r2\n"
- "\tldr r0, =gSaveBlock2Ptr\n"
- "\tldr r0, [r0]\n"
- "\tadds r0, r2\n"
- "\tldrb r1, [r1]\n"
- "\tldrb r0, [r0]\n"
- "\tcmp r1, r0\n"
- "\tbeq _0818E1BA\n"
- "_0818E1DA:\n"
- "\tmovs r7, 0x2\n"
- "_0818E1DC:\n"
- "\tadds r0, r7, 0\n"
- "\tpop {r4-r7}\n"
- "\tpop {r1}\n"
- "\tbx r1\n"
- "\t.pool");
-}
-#endif
static u8 sub_818E1F4(void)
{
diff --git a/src/pokemon.c b/src/pokemon.c
index 9c55fb84d..800b7c0cd 100644
--- a/src/pokemon.c
+++ b/src/pokemon.c
@@ -67,7 +67,6 @@ extern const union AnimCmd *gUnknown_082FF70C[];
extern const union AnimCmd *const *const gMonAnimationsSpriteAnimsPtrTable[];
extern const union AnimCmd *const *const gUnknown_08305D0C[];
extern const union AnimCmd *const *const gUnknown_0830536C[];
-extern const struct BattleMove gBattleMoves[];
extern const u8 gSpeciesNames[][POKEMON_NAME_LENGTH + 1];
extern const struct UnknownPokemonStruct3 gUnknown_08610970[];
extern const struct CompressedSpritePalette gMonPaletteTable[];
@@ -110,6 +109,9 @@ EWRAM_DATA struct SpriteTemplate gUnknown_0202499C = {0};
EWRAM_DATA struct Unknown_806F160_Struct *gUnknown_020249B4[2] = {NULL};
// const rom data
+#include "data/battle_moves.h"
+static const u8 sUnreferencedData[] = {0x34, 0x00, 0x10, 0x00, 0x01, 0x01, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00};
+
const u16 gSpeciesToHoennPokedexNum[] = {203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 156, 157, 112, 113, 227, 228, 229, 230, 231, 232, 233, 234, 153, 154, 138, 139, 63, 64, 88, 89, 90, 235, 236, 237, 238, 239, 240, 241, 242, 158, 159, 243, 244, 245, 246, 247, 248, 249, 39, 40, 41, 73, 74, 75, 250, 251, 252, 66, 67, 57, 58, 59, 253, 254, 255, 256, 82, 83, 257, 92, 93, 258, 259, 106, 107, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 84, 85, 270, 271, 272, 273, 274, 275, 276, 108, 109, 169, 170, 277, 278, 279, 184, 185, 50, 51, 143, 144, 280, 281, 282, 283, 284, 167, 285, 52, 53, 286, 287, 288, 289, 290, 291, 292, 293, 294, 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, 305, 306, 307, 308, 309, 310, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, 323, 65, 181, 182, 155, 324, 137, 325, 326, 162, 163, 327, 328, 329, 91, 55, 56, 330, 331, 332, 333, 334, 335, 336, 337, 338, 339, 340, 341, 342, 343, 344, 345, 346, 161, 164, 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, 168, 357, 358, 359, 103, 104, 360, 361, 180, 362, 363, 364, 365, 115, 366, 367, 186, 165, 166, 368, 369, 370, 371, 372, 373, 374, 375, 376, 377, 378, 379, 380, 381, 382, 383, 384, 385, 386, 387, 388, 389, 390, 391, 392, 393, 394, 395, 396, 397, 398, 399, 400, 401, 402, 403, 404, 405, 406, 407, 408, 409, 410, 411, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 42, 43, 44, 25, 26, 34, 35, 114, 27, 28, 32, 33, 99, 100, 61, 62, 145, 131, 132, 60, 105, 68, 127, 128, 183, 129, 130, 140, 141, 97, 98, 116, 117, 118, 48, 49, 78, 79, 101, 102, 173, 174, 175, 119, 120, 171, 172, 125, 126, 54, 110, 111, 80, 81, 69, 76, 77, 121, 122, 160, 148, 149, 94, 36, 37, 38, 95, 96, 150, 45, 46, 47, 176, 177, 178, 152, 146, 147, 124, 123, 179, 70, 71, 72, 142, 86, 87, 133, 134, 135, 136, 29, 30, 31, 187, 188, 189, 190, 191, 192, 193, 194, 195, 198, 199, 200, 196, 197, 201, 202, 151};
const u16 gSpeciesToNationalPokedexNum[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 387, 388, 389, 390, 391, 392, 393, 394, 395, 396, 397, 398, 399, 400, 401, 402, 403, 404, 405, 406, 407, 408, 409, 410, 411, 252, 253, 254, 255, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 290, 291, 292, 276, 277, 285, 286, 327, 278, 279, 283, 284, 320, 321, 300, 301, 352, 343, 344, 299, 324, 302, 339, 340, 370, 341, 342, 349, 350, 318, 319, 328, 329, 330, 296, 297, 309, 310, 322, 323, 363, 364, 365, 331, 332, 361, 362, 337, 338, 298, 325, 326, 311, 312, 303, 307, 308, 333, 334, 360, 355, 356, 315, 287, 288, 289, 316, 317, 357, 293, 294, 295, 366, 367, 368, 359, 353, 354, 336, 335, 369, 304, 305, 306, 351, 313, 314, 345, 346, 347, 348, 280, 281, 282, 371, 372, 373, 374, 375, 376, 377, 378, 379, 382, 383, 384, 380, 381, 385, 386, 358};
const u16 gHoennToNationalOrder[] = {252, 253, 254, 255, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, 286, 287, 288, 289, 63, 64, 65, 290, 291, 292, 293, 294, 295, 296, 297, 118, 119, 129, 130, 298, 183, 184, 74, 75, 76, 299, 300, 301, 41, 42, 169, 72, 73, 302, 303, 304, 305, 306, 66, 67, 68, 307, 308, 309, 310, 311, 312, 81, 82, 100, 101, 313, 314, 43, 44, 45, 182, 84, 85, 315, 316, 317, 318, 319, 320, 321, 322, 323, 218, 219, 324, 88, 89, 109, 110, 325, 326, 27, 28, 327, 227, 328, 329, 330, 331, 332, 333, 334, 335, 336, 337, 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, 348, 174, 39, 40, 349, 350, 351, 120, 121, 352, 353, 354, 355, 356, 357, 358, 359, 37, 38, 172, 25, 26, 54, 55, 360, 202, 177, 178, 203, 231, 232, 127, 214, 111, 112, 361, 362, 363, 364, 365, 366, 367, 368, 369, 222, 170, 171, 370, 116, 117, 230, 371, 372, 373, 374, 375, 376, 377, 378, 379, 380, 381, 382, 383, 384, 385, 386, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 29, 30, 31, 32, 33, 34, 35, 36, 46, 47, 48, 49, 50, 51, 52, 53, 56, 57, 58, 59, 60, 61, 62, 69, 70, 71, 77, 78, 79, 80, 83, 86, 87, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 102, 103, 104, 105, 106, 107, 108, 113, 114, 115, 122, 123, 124, 125, 126, 128, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 173, 175, 176, 179, 180, 181, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 215, 216, 217, 220, 221, 223, 224, 225, 226, 228, 229, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 387, 388, 389, 390, 391, 392, 393, 394, 395, 396, 397, 398, 399, 400, 401, 402, 403, 404, 405, 406, 407, 408, 409, 410, 411};
diff --git a/src/pokemon_summary_screen.c b/src/pokemon_summary_screen.c
index 1e5245d70..3ebdc3d6d 100644
--- a/src/pokemon_summary_screen.c
+++ b/src/pokemon_summary_screen.c
@@ -115,8 +115,6 @@ extern u8 gText_Appeal[];
extern u8 gText_Jam[];
extern u8 gText_OTSlash[];
extern u8 gText_UnkCtrlF907F908[];
-extern u8 gAbilityNames[][13];
-extern u8 *gAbilityDescriptionPointers[];
extern u8 gText_XNature[];
extern u8 gText_XNatureHatchedAtYZ[];
extern u8 gText_XNatureHatchedSomewhereAt[];
@@ -146,7 +144,6 @@ extern u8 gText_OneDash[];
extern u8 gText_TwoDashes[];
extern u8 gText_ThreeDashes[];
extern u8 gUnknown_0861CE97[];
-extern struct BattleMove gBattleMoves[];
extern void sub_8199C30(u8 a, u8 b, u8 c, u8 d, u8 e, u8 f);
extern bool8 sub_81A6BF4();
@@ -2539,7 +2536,7 @@ void sub_81C2554()
gUnknown_0203CF1C->unk40CB[i] |= 0xFF;
}
-void sub_81C25A4(u8 a, u8 *b, u8 c, u8 d, u8 e, u8 f)
+void sub_81C25A4(u8 a, const u8 *b, u8 c, u8 d, u8 e, u8 f)
{
AddTextPrinterParameterized2(a, 1, c, d, 0, e, gUnknown_0861CD2C[f], 0, b);
}
diff --git a/src/text.c b/src/text.c
index a2495d068..eacfd2a1f 100644
--- a/src/text.c
+++ b/src/text.c
@@ -4,18 +4,15 @@
#include "m4a.h"
#include "palette.h"
#include "sound.h"
+#include "constants/songs.h"
#include "string_util.h"
#include "window.h"
#include "text.h"
+#include "blit.h"
-extern void FillBitmapRect4Bit(struct Bitmap *surface, u16 x, u16 y, u16 width, u16 height, u8 fillValue);
-extern void FillWindowPixelRect(u8 windowId, u8 fillValue, u16 x, u16 y, u16 width, u16 height);
-extern void BlitBitmapRectToWindow(u8 windowId, const u8 *pixels, u16 srcX, u16 srcY, u16 srcWidth, int srcHeight, u16 destX, u16 destY, u16 rectWidth, u16 rectHeight);
extern u8 GetKeypadIconWidth(u8 keypadIconId);
-extern void CopyWindowToVram(u8 windowId, u8 mode);
extern u16 Font6Func(struct TextPrinter *textPrinter);
extern u32 GetGlyphWidthFont6(u16 glyphId, bool32 isJapanese);
-extern void PlaySE(u16 songNum);
extern u8* UnkTextUtil_GetPtrI(u8 a1);
extern int sub_8197964();
@@ -27,7 +24,6 @@ static u16 gLastTextBgColor;
static u16 gLastTextFgColor;
static u16 gLastTextShadowColor;
-extern struct Main gMain;
extern struct MusicPlayerInfo gMPlayInfo_BGM;
const struct FontInfo *gFonts;
@@ -1986,7 +1982,7 @@ bool16 TextPrinterWaitWithDownArrow(struct TextPrinter *textPrinter)
if (gMain.newKeys & (A_BUTTON | B_BUTTON))
{
result = TRUE;
- PlaySE(5);
+ PlaySE(SE_SELECT);
}
}
return result;
@@ -2004,7 +2000,7 @@ bool16 TextPrinterWait(struct TextPrinter *textPrinter)
if (gMain.newKeys & (A_BUTTON | B_BUTTON))
{
result = TRUE;
- PlaySE(5);
+ PlaySE(SE_SELECT);
}
}
return result;
diff --git a/src/window.c b/src/window.c
index 589557d43..9a52a5a20 100644
--- a/src/window.c
+++ b/src/window.c
@@ -1,6 +1,8 @@
#include "global.h"
#include "window.h"
#include "malloc.h"
+#include "bg.h"
+#include "blit.h"
u32 filler_03002F58;
u32 filler_03002F5C;
@@ -15,19 +17,6 @@ EWRAM_DATA struct Window gWindows[WINDOWS_MAX] = {0};
EWRAM_DATA static struct Window* sWindowPtr = NULL;
EWRAM_DATA static u16 sWindowSize = 0;
-extern void* GetBgTilemapBuffer(u8 bg);
-extern int DummiedOutFireRedLeafGreenTileAllocFunc(int, int, int, int);
-extern u16 GetBgAttribute(u8 bg, u8 attributeId);
-extern void SetBgTilemapBuffer(u8 bg, void *tilemap);
-extern void CopyBgTilemapBufferToVram(u8 bg);
-extern u8 LoadBgTiles(u8 bg, void *src, u16 size, u16 destOffset);
-extern void WriteSequenceToBgTilemapBuffer(u8 bg, u16 firstTileNum, u8 x, u8 y, u8 width, u8 height, u8 paletteSlot, u16 tileNumDelta);
-extern void FillBgTilemapBufferRect(u8 bg, u16 tileNum, u8 x, u8 y, u8 width, u8 height, u8 palette);
-extern void BlitBitmapRect4Bit(struct Bitmap *src, struct Bitmap *dest, u16 srcX, u16 srcY, u16 destX, u16 destY, u16 width, u16 height, u8 colorKey);
-extern void BlitBitmapRect4BitTo8Bit(struct Bitmap *src, struct Bitmap *dest, u16 srcX, u16 srcY, u16 destX, u16 destY, u16 width, u16 height, u8 colorKey, u8 paletteNum);
-extern void FillBitmapRect4Bit(struct Bitmap *surface, u16 x, u16 y, u16 width, u16 height, u8 fillValue);
-extern void FillBitmapRect8Bit(struct Bitmap *surface, u16 x, u16 y, u16 width, u16 height, u8 fillValue);
-
static u8 GetNumActiveWindowsOnBg(u8 bgId);
static u8 GetNumActiveWindowsOnBg8Bit(u8 bgId);
@@ -130,13 +119,13 @@ u16 AddWindow(const struct WindowTemplate *template)
u8 *allocatedTilemapBuffer;
int i;
- for (win = 0; win < 0x20; ++win)
+ for (win = 0; win < WINDOWS_MAX; ++win)
{
if ((bgLayer = gWindows[win].window.priority) == 0xFF)
break;
}
- if (win == 0x20)
+ if (win == WINDOWS_MAX)
return 0xFF;
bgLayer = template->priority;
@@ -199,13 +188,13 @@ int AddWindowWithoutTileMap(const struct WindowTemplate *template)
u8 bgLayer;
int allocatedBaseBlock;
- for (win = 0; win < 0x20; ++win)
+ for (win = 0; win < WINDOWS_MAX; ++win)
{
if (gWindows[win].window.priority == 0xFF)
break;
}
- if (win == 0x20)
+ if (win == WINDOWS_MAX)
return 0xFF;
bgLayer = template->priority;