summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/battle_ai_script_commands.c451
-rw-r--r--src/battle_anim.c55
-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.c1
-rw-r--r--src/battle_controller_player.c1
-rw-r--r--src/battle_controller_player_partner.c1
-rw-r--r--src/battle_controller_recorded_opponent.c1
-rw-r--r--src/battle_controller_recorded_player.c1
-rw-r--r--src/battle_controller_safari.c1
-rw-r--r--src/battle_controller_wally.c1
-rw-r--r--src/battle_gfx_sfx_util.c11
-rw-r--r--src/battle_script_commands.c1
-rw-r--r--src/battle_util.c1
-rw-r--r--src/berry_fix_program.c72
-rw-r--r--src/bike.c1078
-rw-r--r--src/dma3_manager.c430
-rw-r--r--src/egg_hatch.c8
-rw-r--r--src/evolution_scene.c6
-rwxr-xr-xsrc/field_map_obj.c4
-rw-r--r--src/fldeff_teleport.c46
-rw-r--r--src/load_save.c162
-rw-r--r--src/mail.c96
-rw-r--r--src/main.c2
-rw-r--r--src/pokedex.c542
-rw-r--r--src/pokemon_icon.c1014
-rw-r--r--src/pokemon_storage_system.c67
-rwxr-xr-xsrc/pokemon_summary_screen.c22
-rw-r--r--src/rayquaza_scene.c1164
-rw-r--r--src/reset_save_heap.c4
-rw-r--r--src/start_menu.c102
-rw-r--r--src/unk_81BAD84.c36
-rw-r--r--src/wallclock.c10
-rw-r--r--src/window.c736
34 files changed, 4532 insertions, 1597 deletions
diff --git a/src/battle_ai_script_commands.c b/src/battle_ai_script_commands.c
index 44be0a4d9..42cf0595f 100644
--- a/src/battle_ai_script_commands.c
+++ b/src/battle_ai_script_commands.c
@@ -9,6 +9,7 @@
#include "constants/battle_move_effects.h"
#include "constants/moves.h"
#include "util.h"
+#include "constants/battle_ai.h"
#define AIScriptRead32(ptr) ((ptr)[0] | (ptr)[1] << 8 | (ptr)[2] << 16 | (ptr)[3] << 24)
#define AIScriptRead16(ptr) ((ptr)[0] | (ptr)[1] << 8)
@@ -26,14 +27,6 @@
#define AI_THINKING_STRUCT ((struct AI_ThinkingStruct *)(gBattleResources->ai))
#define BATTLE_HISTORY ((struct BattleHistory *)(gBattleResources->battleHistory))
-enum
-{
- AI_TARGET,
- AI_USER,
- AI_TARGET_PARTNER,
- AI_USER_PARTNER
-};
-
// AI states
enum
{
@@ -104,30 +97,30 @@ static void BattleAICmd_if_less_than(void);
static void BattleAICmd_if_more_than(void);
static void BattleAICmd_if_equal(void);
static void BattleAICmd_if_not_equal(void);
-static void BattleAICmd_if_less_than_32(void);
-static void BattleAICmd_if_more_than_32(void);
-static void BattleAICmd_if_equal_32(void);
-static void BattleAICmd_if_not_equal_32(void);
+static void BattleAICmd_if_less_than_ptr(void);
+static void BattleAICmd_if_more_than_ptr(void);
+static void BattleAICmd_if_equal_ptr(void);
+static void BattleAICmd_if_not_equal_ptr(void);
static void BattleAICmd_if_move(void);
static void BattleAICmd_if_not_move(void);
static void BattleAICmd_if_in_bytes(void);
static void BattleAICmd_if_not_in_bytes(void);
static void BattleAICmd_if_in_hwords(void);
static void BattleAICmd_if_not_in_hwords(void);
-static void BattleAICmd_if_user_can_damage(void);
-static void BattleAICmd_if_user_cant_damage(void);
+static void BattleAICmd_if_user_has_attacking_move(void);
+static void BattleAICmd_if_user_has_no_attacking_moves(void);
static void BattleAICmd_get_turn_count(void);
static void BattleAICmd_get_type(void);
-static void BattleAICmd_get_last_used_bank_move_power(void);
-static void BattleAICmd_is_most_powerful_move(void);
+static void BattleAICmd_get_considered_move_power(void);
+static void BattleAICmd_get_how_powerful_move_is(void);
static void BattleAICmd_get_last_used_bank_move(void);
-static void BattleAICmd_if_arg_equal(void);
-static void BattleAICmd_if_arg_not_equal(void);
-static void BattleAICmd_if_would_go_first(void);
-static void BattleAICmd_if_would_not_go_first(void);
+static void BattleAICmd_if_equal_(void);
+static void BattleAICmd_if_not_equal_(void);
+static void BattleAICmd_if_user_goes(void);
+static void BattleAICmd_if_user_doesnt_go(void);
static void BattleAICmd_nullsub_2A(void);
static void BattleAICmd_nullsub_2B(void);
-static void BattleAICmd_count_alive_pokemon(void);
+static void BattleAICmd_count_usable_party_mons(void);
static void BattleAICmd_get_considered_move(void);
static void BattleAICmd_get_considered_move_effect(void);
static void BattleAICmd_get_ability(void);
@@ -147,17 +140,17 @@ static void BattleAICmd_if_stat_level_not_equal(void);
static void BattleAICmd_if_can_faint(void);
static void BattleAICmd_if_cant_faint(void);
static void BattleAICmd_if_has_move(void);
-static void BattleAICmd_if_dont_have_move(void);
-static void BattleAICmd_if_move_effect(void);
-static void BattleAICmd_if_not_move_effect(void);
+static void BattleAICmd_if_doesnt_have_move(void);
+static void BattleAICmd_if_has_move_with_effect(void);
+static void BattleAICmd_if_doesnt_have_move_with_effect(void);
static void BattleAICmd_if_any_move_disabled_or_encored(void);
static void BattleAICmd_if_curr_move_disabled_or_encored(void);
static void BattleAICmd_flee(void);
-static void BattleAICmd_if_random_100(void);
+static void BattleAICmd_if_random_safari_flee(void);
static void BattleAICmd_watch(void);
static void BattleAICmd_get_hold_effect(void);
static void BattleAICmd_get_gender(void);
-static void BattleAICmd_is_first_turn(void);
+static void BattleAICmd_is_first_turn_for(void);
static void BattleAICmd_get_stockpile_count(void);
static void BattleAICmd_is_double_battle(void);
static void BattleAICmd_get_used_held_item(void);
@@ -172,7 +165,7 @@ static void BattleAICmd_nullsub_55(void);
static void BattleAICmd_nullsub_56(void);
static void BattleAICmd_nullsub_57(void);
static void BattleAICmd_call(void);
-static void BattleAICmd_jump(void);
+static void BattleAICmd_goto(void);
static void BattleAICmd_end(void);
static void BattleAICmd_if_level_cond(void);
static void BattleAICmd_if_target_taunted(void);
@@ -215,30 +208,30 @@ static const BattleAICmdFunc sBattleAICmdTable[] =
BattleAICmd_if_more_than, // 0x12
BattleAICmd_if_equal, // 0x13
BattleAICmd_if_not_equal, // 0x14
- BattleAICmd_if_less_than_32, // 0x15
- BattleAICmd_if_more_than_32, // 0x16
- BattleAICmd_if_equal_32, // 0x17
- BattleAICmd_if_not_equal_32, // 0x18
+ BattleAICmd_if_less_than_ptr, // 0x15
+ BattleAICmd_if_more_than_ptr, // 0x16
+ BattleAICmd_if_equal_ptr, // 0x17
+ BattleAICmd_if_not_equal_ptr, // 0x18
BattleAICmd_if_move, // 0x19
BattleAICmd_if_not_move, // 0x1A
BattleAICmd_if_in_bytes, // 0x1B
BattleAICmd_if_not_in_bytes, // 0x1C
BattleAICmd_if_in_hwords, // 0x1D
BattleAICmd_if_not_in_hwords, // 0x1E
- BattleAICmd_if_user_can_damage, // 0x1F
- BattleAICmd_if_user_cant_damage, // 0x20
+ BattleAICmd_if_user_has_attacking_move, // 0x1F
+ BattleAICmd_if_user_has_no_attacking_moves, // 0x20
BattleAICmd_get_turn_count, // 0x21
BattleAICmd_get_type, // 0x22
- BattleAICmd_get_last_used_bank_move_power, // 0x23
- BattleAICmd_is_most_powerful_move, // 0x24
+ BattleAICmd_get_considered_move_power, // 0x23
+ BattleAICmd_get_how_powerful_move_is, // 0x24
BattleAICmd_get_last_used_bank_move, // 0x25
- BattleAICmd_if_arg_equal, // 0x26
- BattleAICmd_if_arg_not_equal, // 0x27
- BattleAICmd_if_would_go_first, // 0x28
- BattleAICmd_if_would_not_go_first, // 0x29
+ BattleAICmd_if_equal_, // 0x26
+ BattleAICmd_if_not_equal_, // 0x27
+ BattleAICmd_if_user_goes, // 0x28
+ BattleAICmd_if_user_doesnt_go, // 0x29
BattleAICmd_nullsub_2A, // 0x2A
BattleAICmd_nullsub_2B, // 0x2B
- BattleAICmd_count_alive_pokemon, // 0x2C
+ BattleAICmd_count_usable_party_mons, // 0x2C
BattleAICmd_get_considered_move, // 0x2D
BattleAICmd_get_considered_move_effect, // 0x2E
BattleAICmd_get_ability, // 0x2F
@@ -258,17 +251,17 @@ static const BattleAICmdFunc sBattleAICmdTable[] =
BattleAICmd_if_can_faint, // 0x3D
BattleAICmd_if_cant_faint, // 0x3E
BattleAICmd_if_has_move, // 0x3F
- BattleAICmd_if_dont_have_move, // 0x40
- BattleAICmd_if_move_effect, // 0x41
- BattleAICmd_if_not_move_effect, // 0x42
+ BattleAICmd_if_doesnt_have_move, // 0x40
+ BattleAICmd_if_has_move_with_effect, // 0x41
+ BattleAICmd_if_doesnt_have_move_with_effect, // 0x42
BattleAICmd_if_any_move_disabled_or_encored, // 0x43
BattleAICmd_if_curr_move_disabled_or_encored, // 0x44
BattleAICmd_flee, // 0x45
- BattleAICmd_if_random_100, // 0x46
+ BattleAICmd_if_random_safari_flee, // 0x46
BattleAICmd_watch, // 0x47
BattleAICmd_get_hold_effect, // 0x48
BattleAICmd_get_gender, // 0x49
- BattleAICmd_is_first_turn, // 0x4A
+ BattleAICmd_is_first_turn_for, // 0x4A
BattleAICmd_get_stockpile_count, // 0x4B
BattleAICmd_is_double_battle, // 0x4C
BattleAICmd_get_used_held_item, // 0x4D
@@ -283,7 +276,7 @@ static const BattleAICmdFunc sBattleAICmdTable[] =
BattleAICmd_nullsub_56, // 0x56
BattleAICmd_nullsub_57, // 0x57
BattleAICmd_call, // 0x58
- BattleAICmd_jump, // 0x59
+ BattleAICmd_goto, // 0x59
BattleAICmd_end, // 0x5A
BattleAICmd_if_level_cond, // 0x5B
BattleAICmd_if_target_taunted, // 0x5C
@@ -374,32 +367,34 @@ void BattleAI_SetupAIData(u8 defaultScoreMoves)
// decide a random target bank in doubles
if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE)
{
- gBankTarget = (Random() & 2) + (GetBankSide(gActiveBank) ^ 1);
+ gBankTarget = (Random() & BIT_MON) + (GetBankSide(gActiveBank) ^ BIT_SIDE);
if (gAbsentBankFlags & gBitTable[gBankTarget])
- gBankTarget ^= 2;
+ gBankTarget ^= BIT_MON;
}
// in singles there's only one choice
else
- gBankTarget = sBank_AI ^ 1;
+ {
+ gBankTarget = sBank_AI ^ BIT_SIDE;
+ }
if (gBattleTypeFlags & BATTLE_TYPE_RECORDED)
AI_THINKING_STRUCT->aiFlags = GetAiScriptsInRecordedBattle();
else if (gBattleTypeFlags & BATTLE_TYPE_SAFARI)
- AI_THINKING_STRUCT->aiFlags = 0x40000000;
+ AI_THINKING_STRUCT->aiFlags = AI_SCRIPT_SAFARI;
else if (gBattleTypeFlags & BATTLE_TYPE_ROAMER)
- AI_THINKING_STRUCT->aiFlags = 0x20000000;
+ AI_THINKING_STRUCT->aiFlags = AI_SCRIPT_ROAMING;
else if (gBattleTypeFlags & BATTLE_TYPE_FIRST_BATTLE)
- AI_THINKING_STRUCT->aiFlags = 0x80000000;
+ AI_THINKING_STRUCT->aiFlags = AI_SCRIPT_FIRST_BATTLE;
else if (gBattleTypeFlags & BATTLE_TYPE_FACTORY)
AI_THINKING_STRUCT->aiFlags = GetAiScriptsInBattleFactory();
else if (gBattleTypeFlags & (BATTLE_TYPE_FRONTIER | BATTLE_TYPE_EREADER_TRAINER | BATTLE_TYPE_x4000000 | BATTLE_TYPE_SECRET_BASE))
- AI_THINKING_STRUCT->aiFlags = 7; // the smartest possible set
+ AI_THINKING_STRUCT->aiFlags = AI_SCRIPT_CHECK_BAD_MOVE | AI_SCRIPT_CHECK_VIABILITY | AI_SCRIPT_TRY_TO_FAINT;
else if (gBattleTypeFlags & BATTLE_TYPE_TWO_OPPONENTS)
AI_THINKING_STRUCT->aiFlags = gTrainers[gTrainerBattleOpponent_A].aiFlags | gTrainers[gTrainerBattleOpponent_B].aiFlags;
else
AI_THINKING_STRUCT->aiFlags = gTrainers[gTrainerBattleOpponent_A].aiFlags;
if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE)
- AI_THINKING_STRUCT->aiFlags |= 0x80; // act smart in doubles and don't attack your partner
+ AI_THINKING_STRUCT->aiFlags |= AI_SCRIPT_DOUBLE_BATTLE; // act smart in doubles and don't attack your partner
}
u8 BattleAI_ChooseMoveOrAction(void)
@@ -723,14 +718,14 @@ static void BattleAICmd_score(void)
static void BattleAICmd_if_hp_less_than(void)
{
- u16 index;
+ u16 bank;
if (gAIScriptPtr[1] == AI_USER)
- index = sBank_AI;
+ bank = sBank_AI;
else
- index = gBankTarget;
+ bank = gBankTarget;
- if ((u32)(100 * gBattleMons[index].hp / gBattleMons[index].maxHP) < gAIScriptPtr[2])
+ if ((u32)(100 * gBattleMons[bank].hp / gBattleMons[bank].maxHP) < gAIScriptPtr[2])
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 3);
else
gAIScriptPtr += 7;
@@ -738,14 +733,14 @@ static void BattleAICmd_if_hp_less_than(void)
static void BattleAICmd_if_hp_more_than(void)
{
- u16 index;
+ u16 bank;
if (gAIScriptPtr[1] == AI_USER)
- index = sBank_AI;
+ bank = sBank_AI;
else
- index = gBankTarget;
+ bank = gBankTarget;
- if ((u32)(100 * gBattleMons[index].hp / gBattleMons[index].maxHP) > gAIScriptPtr[2])
+ if ((u32)(100 * gBattleMons[bank].hp / gBattleMons[bank].maxHP) > gAIScriptPtr[2])
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 3);
else
gAIScriptPtr += 7;
@@ -753,14 +748,14 @@ static void BattleAICmd_if_hp_more_than(void)
static void BattleAICmd_if_hp_equal(void)
{
- u16 index;
+ u16 bank;
if (gAIScriptPtr[1] == AI_USER)
- index = sBank_AI;
+ bank = sBank_AI;
else
- index = gBankTarget;
+ bank = gBankTarget;
- if ((u32)(100 * gBattleMons[index].hp / gBattleMons[index].maxHP) == gAIScriptPtr[2])
+ if ((u32)(100 * gBattleMons[bank].hp / gBattleMons[bank].maxHP) == gAIScriptPtr[2])
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 3);
else
gAIScriptPtr += 7;
@@ -768,14 +763,14 @@ static void BattleAICmd_if_hp_equal(void)
static void BattleAICmd_if_hp_not_equal(void)
{
- u16 index;
+ u16 bank;
if (gAIScriptPtr[1] == AI_USER)
- index = sBank_AI;
+ bank = sBank_AI;
else
- index = gBankTarget;
+ bank = gBankTarget;
- if ((u32)(100 * gBattleMons[index].hp / gBattleMons[index].maxHP) != gAIScriptPtr[2])
+ if ((u32)(100 * gBattleMons[bank].hp / gBattleMons[bank].maxHP) != gAIScriptPtr[2])
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 3);
else
gAIScriptPtr += 7;
@@ -783,17 +778,17 @@ static void BattleAICmd_if_hp_not_equal(void)
static void BattleAICmd_if_status(void)
{
- u16 index;
- u32 arg;
+ u16 bank;
+ u32 status;
if (gAIScriptPtr[1] == AI_USER)
- index = sBank_AI;
+ bank = sBank_AI;
else
- index = gBankTarget;
+ bank = gBankTarget;
- arg = AIScriptRead32(gAIScriptPtr + 2);
+ status = AIScriptRead32(gAIScriptPtr + 2);
- if ((gBattleMons[index].status1 & arg) != 0)
+ if ((gBattleMons[bank].status1 & status) != 0)
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 6);
else
gAIScriptPtr += 10;
@@ -801,17 +796,17 @@ static void BattleAICmd_if_status(void)
static void BattleAICmd_if_not_status(void)
{
- u16 index;
- u32 arg;
+ u16 bank;
+ u32 status;
if (gAIScriptPtr[1] == AI_USER)
- index = sBank_AI;
+ bank = sBank_AI;
else
- index = gBankTarget;
+ bank = gBankTarget;
- arg = AIScriptRead32(gAIScriptPtr + 2);
+ status = AIScriptRead32(gAIScriptPtr + 2);
- if ((gBattleMons[index].status1 & arg) == 0)
+ if ((gBattleMons[bank].status1 & status) == 0)
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 6);
else
gAIScriptPtr += 10;
@@ -819,17 +814,17 @@ static void BattleAICmd_if_not_status(void)
static void BattleAICmd_if_status2(void)
{
- u16 index;
- u32 arg;
+ u16 bank;
+ u32 status;
if (gAIScriptPtr[1] == AI_USER)
- index = sBank_AI;
+ bank = sBank_AI;
else
- index = gBankTarget;
+ bank = gBankTarget;
- arg = AIScriptRead32(gAIScriptPtr + 2);
+ status = AIScriptRead32(gAIScriptPtr + 2);
- if ((gBattleMons[index].status2 & arg) != 0)
+ if ((gBattleMons[bank].status2 & status) != 0)
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 6);
else
gAIScriptPtr += 10;
@@ -837,17 +832,17 @@ static void BattleAICmd_if_status2(void)
static void BattleAICmd_if_not_status2(void)
{
- u16 index;
- u32 arg;
+ u16 bank;
+ u32 status;
if (gAIScriptPtr[1] == AI_USER)
- index = sBank_AI;
+ bank = sBank_AI;
else
- index = gBankTarget;
+ bank = gBankTarget;
- arg = AIScriptRead32(gAIScriptPtr + 2);
+ status = AIScriptRead32(gAIScriptPtr + 2);
- if ((gBattleMons[index].status2 & arg) == 0)
+ if ((gBattleMons[bank].status2 & status) == 0)
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 6);
else
gAIScriptPtr += 10;
@@ -855,17 +850,17 @@ static void BattleAICmd_if_not_status2(void)
static void BattleAICmd_if_status3(void)
{
- u16 index;
- u32 arg;
+ u16 bank;
+ u32 status;
if (gAIScriptPtr[1] == AI_USER)
- index = sBank_AI;
+ bank = sBank_AI;
else
- index = gBankTarget;
+ bank = gBankTarget;
- arg = AIScriptRead32(gAIScriptPtr + 2);
+ status = AIScriptRead32(gAIScriptPtr + 2);
- if ((gStatuses3[index] & arg) != 0)
+ if ((gStatuses3[bank] & status) != 0)
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 6);
else
gAIScriptPtr += 10;
@@ -873,17 +868,17 @@ static void BattleAICmd_if_status3(void)
static void BattleAICmd_if_not_status3(void)
{
- u16 index;
- u32 arg;
+ u16 bank;
+ u32 status;
if (gAIScriptPtr[1] == AI_USER)
- index = sBank_AI;
+ bank = sBank_AI;
else
- index = gBankTarget;
+ bank = gBankTarget;
- arg = AIScriptRead32(gAIScriptPtr + 2);
+ status = AIScriptRead32(gAIScriptPtr + 2);
- if ((gStatuses3[index] & arg) == 0)
+ if ((gStatuses3[bank] & status) == 0)
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 6);
else
gAIScriptPtr += 10;
@@ -891,18 +886,18 @@ static void BattleAICmd_if_not_status3(void)
static void BattleAICmd_if_side_affecting(void)
{
- u16 index;
- u32 arg1, arg2;
+ u16 bank;
+ u32 side, status;
if (gAIScriptPtr[1] == AI_USER)
- index = sBank_AI;
+ bank = sBank_AI;
else
- index = gBankTarget;
+ bank = gBankTarget;
- arg1 = GetBankIdentity(index) & 1;
- arg2 = AIScriptRead32(gAIScriptPtr + 2);
+ side = GET_BANK_SIDE(bank);
+ status = AIScriptRead32(gAIScriptPtr + 2);
- if ((gSideAffecting[arg1] & arg2) != 0)
+ if ((gSideAffecting[side] & status) != 0)
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 6);
else
gAIScriptPtr += 10;
@@ -910,18 +905,18 @@ static void BattleAICmd_if_side_affecting(void)
static void BattleAICmd_if_not_side_affecting(void)
{
- u16 index;
- u32 arg1, arg2;
+ u16 bank;
+ u32 side, status;
if (gAIScriptPtr[1] == AI_USER)
- index = sBank_AI;
+ bank = sBank_AI;
else
- index = gBankTarget;
+ bank = gBankTarget;
- arg1 = GetBankIdentity(index) & 1;
- arg2 = AIScriptRead32(gAIScriptPtr + 2);
+ side = GET_BANK_SIDE(bank);
+ status = AIScriptRead32(gAIScriptPtr + 2);
- if ((gSideAffecting[arg1] & arg2) == 0)
+ if ((gSideAffecting[side] & status) == 0)
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 6);
else
gAIScriptPtr += 10;
@@ -959,41 +954,41 @@ static void BattleAICmd_if_not_equal(void)
gAIScriptPtr += 6;
}
-static void BattleAICmd_if_less_than_32(void)
+static void BattleAICmd_if_less_than_ptr(void)
{
- const u8 *temp = AIScriptReadPtr(gAIScriptPtr + 1);
+ const u8 *value = AIScriptReadPtr(gAIScriptPtr + 1);
- if (AI_THINKING_STRUCT->funcResult < *temp)
+ if (AI_THINKING_STRUCT->funcResult < *value)
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 5);
else
gAIScriptPtr += 9;
}
-static void BattleAICmd_if_more_than_32(void)
+static void BattleAICmd_if_more_than_ptr(void)
{
- const u8 *temp = AIScriptReadPtr(gAIScriptPtr + 1);
+ const u8 *value = AIScriptReadPtr(gAIScriptPtr + 1);
- if (AI_THINKING_STRUCT->funcResult > *temp)
+ if (AI_THINKING_STRUCT->funcResult > *value)
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 5);
else
gAIScriptPtr += 9;
}
-static void BattleAICmd_if_equal_32(void)
+static void BattleAICmd_if_equal_ptr(void)
{
- const u8 *temp = AIScriptReadPtr(gAIScriptPtr + 1);
+ const u8 *value = AIScriptReadPtr(gAIScriptPtr + 1);
- if (AI_THINKING_STRUCT->funcResult == *temp)
+ if (AI_THINKING_STRUCT->funcResult == *value)
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 5);
else
gAIScriptPtr += 9;
}
-static void BattleAICmd_if_not_equal_32(void)
+static void BattleAICmd_if_not_equal_ptr(void)
{
- const u8 *temp = AIScriptReadPtr(gAIScriptPtr + 1);
+ const u8 *value = AIScriptReadPtr(gAIScriptPtr + 1);
- if (AI_THINKING_STRUCT->funcResult != *temp)
+ if (AI_THINKING_STRUCT->funcResult != *value)
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 5);
else
gAIScriptPtr += 9;
@@ -1083,7 +1078,7 @@ static void BattleAICmd_if_not_in_hwords(void)
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 5);
}
-static void BattleAICmd_if_user_can_damage(void)
+static void BattleAICmd_if_user_has_attacking_move(void)
{
s32 i;
@@ -1099,7 +1094,7 @@ static void BattleAICmd_if_user_can_damage(void)
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 1);
}
-static void BattleAICmd_if_user_cant_damage(void)
+static void BattleAICmd_if_user_has_no_attacking_moves(void)
{
s32 i;
@@ -1127,28 +1122,28 @@ static void BattleAICmd_get_type(void)
switch (typeVar)
{
- case 1: // player primary type
+ case AI_TYPE1_USER: // AI user primary type
AI_THINKING_STRUCT->funcResult = gBattleMons[sBank_AI].type1;
break;
- case 0: // enemy primary type
+ case AI_TYPE1_TARGET: // target primary type
AI_THINKING_STRUCT->funcResult = gBattleMons[gBankTarget].type1;
break;
- case 3: // player secondary type
+ case AI_TYPE2_USER: // AI user secondary type
AI_THINKING_STRUCT->funcResult = gBattleMons[sBank_AI].type2;
break;
- case 2: // enemy secondary type
+ case AI_TYPE2_TARGET: // target secondary type
AI_THINKING_STRUCT->funcResult = gBattleMons[gBankTarget].type2;
break;
- case 4: // type of move being pointed to
+ case AI_TYPE_MOVE: // type of move being pointed to
AI_THINKING_STRUCT->funcResult = gBattleMoves[AI_THINKING_STRUCT->moveConsidered].type;
break;
}
gAIScriptPtr += 2;
}
-static u8 BattleAI_GetWantedBank(u8 index)
+static u8 BattleAI_GetWantedBank(u8 bank)
{
- switch (index)
+ switch (bank)
{
case AI_USER:
return sBank_AI;
@@ -1168,23 +1163,23 @@ static void BattleAICmd_is_of_type(void)
if(gBattleMons[bank].type1 == gAIScriptPtr[2] || gBattleMons[bank].type2 == gAIScriptPtr[2])
{
- AI_THINKING_STRUCT->funcResult = 1;
+ AI_THINKING_STRUCT->funcResult = TRUE;
}
else
{
- AI_THINKING_STRUCT->funcResult = 0;
+ AI_THINKING_STRUCT->funcResult = FALSE;
}
gAIScriptPtr += 3;
}
-static void BattleAICmd_get_last_used_bank_move_power(void)
+static void BattleAICmd_get_considered_move_power(void)
{
AI_THINKING_STRUCT->funcResult = gBattleMoves[AI_THINKING_STRUCT->moveConsidered].power;
gAIScriptPtr += 1;
}
-static void BattleAICmd_is_most_powerful_move(void)
+static void BattleAICmd_get_how_powerful_move_is(void)
{
s32 i, checkedMove;
s32 moveDmgs[4];
@@ -1236,13 +1231,13 @@ static void BattleAICmd_is_most_powerful_move(void)
}
if (checkedMove == 4)
- AI_THINKING_STRUCT->funcResult = 2; // is the most powerful
+ AI_THINKING_STRUCT->funcResult = MOVE_MOST_POWERFUL; // is the most powerful
else
- AI_THINKING_STRUCT->funcResult = 1; // not most powerful
+ AI_THINKING_STRUCT->funcResult = MOVE_NOT_MOST_POWERFUL; // not most powerful
}
else
{
- AI_THINKING_STRUCT->funcResult = 0; // highly discouraged in terms of power
+ AI_THINKING_STRUCT->funcResult = MOVE_POWER_DISCOURAGED; // highly discouraged in terms of power
}
gAIScriptPtr++;
@@ -1258,7 +1253,7 @@ static void BattleAICmd_get_last_used_bank_move(void)
gAIScriptPtr += 2;
}
-static void BattleAICmd_if_arg_equal(void)
+static void BattleAICmd_if_equal_(void) // same as if_equal
{
if (gAIScriptPtr[1] == AI_THINKING_STRUCT->funcResult)
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 2);
@@ -1266,7 +1261,7 @@ static void BattleAICmd_if_arg_equal(void)
gAIScriptPtr += 6;
}
-static void BattleAICmd_if_arg_not_equal(void)
+static void BattleAICmd_if_not_equal_(void) // same as if_not_equal
{
if (gAIScriptPtr[1] != AI_THINKING_STRUCT->funcResult)
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 2);
@@ -1274,7 +1269,7 @@ static void BattleAICmd_if_arg_not_equal(void)
gAIScriptPtr += 6;
}
-static void BattleAICmd_if_would_go_first(void)
+static void BattleAICmd_if_user_goes(void)
{
if (GetWhoStrikesFirst(sBank_AI, gBankTarget, TRUE) == gAIScriptPtr[1])
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 2);
@@ -1282,7 +1277,7 @@ static void BattleAICmd_if_would_go_first(void)
gAIScriptPtr += 6;
}
-static void BattleAICmd_if_would_not_go_first(void)
+static void BattleAICmd_if_user_doesnt_go(void)
{
if (GetWhoStrikesFirst(sBank_AI, gBankTarget, TRUE) != gAIScriptPtr[1])
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 2);
@@ -1298,9 +1293,9 @@ static void BattleAICmd_nullsub_2B(void)
{
}
-static void BattleAICmd_count_alive_pokemon(void)
+static void BattleAICmd_count_usable_party_mons(void)
{
- u8 index;
+ u8 bank;
u8 bankOnField1, bankOnField2;
struct Pokemon *party;
int i;
@@ -1308,29 +1303,29 @@ static void BattleAICmd_count_alive_pokemon(void)
AI_THINKING_STRUCT->funcResult = 0;
if (gAIScriptPtr[1] == AI_USER)
- index = sBank_AI;
+ bank = sBank_AI;
else
- index = gBankTarget;
+ bank = gBankTarget;
- if (GetBankSide(index) == SIDE_PLAYER)
+ if (GetBankSide(bank) == SIDE_PLAYER)
party = gPlayerParty;
else
party = gEnemyParty;
if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE)
{
- u32 status;
- bankOnField1 = gBattlePartyID[index];
- status = GetBankIdentity(index) ^ 2;
- bankOnField2 = gBattlePartyID[GetBankByIdentity(status)];
+ u32 identity;
+ bankOnField1 = gBattlePartyID[bank];
+ identity = GetBankIdentity(bank) ^ BIT_MON;
+ bankOnField2 = gBattlePartyID[GetBankByIdentity(identity)];
}
else // in singles there's only one bank by side
{
- bankOnField1 = gBattlePartyID[index];
- bankOnField2 = gBattlePartyID[index];
+ bankOnField1 = gBattlePartyID[bank];
+ bankOnField2 = gBattlePartyID[bank];
}
- for (i = 0; i < 6; i++)
+ for (i = 0; i < PARTY_SIZE; i++)
{
if (i != bankOnField1 && i != bankOnField2
&& GetMonData(&party[i], MON_DATA_HP) != 0
@@ -1358,60 +1353,60 @@ static void BattleAICmd_get_considered_move_effect(void)
static void BattleAICmd_get_ability(void)
{
- u8 index;
+ u8 bank;
if (gAIScriptPtr[1] == AI_USER)
- index = sBank_AI;
+ bank = sBank_AI;
else
- index = gBankTarget;
+ bank = gBankTarget;
- if(gActiveBank != index)
+ if (gActiveBank != bank)
{
- if(BATTLE_HISTORY->abilities[index] != 0)
+ if (BATTLE_HISTORY->abilities[bank] != 0)
{
- AI_THINKING_STRUCT->funcResult = BATTLE_HISTORY->abilities[index];
+ AI_THINKING_STRUCT->funcResult = BATTLE_HISTORY->abilities[bank];
gAIScriptPtr += 2;
return;
}
// abilities that prevent fleeing.
- if (gBattleMons[index].ability == ABILITY_SHADOW_TAG
- || gBattleMons[index].ability == ABILITY_MAGNET_PULL
- || gBattleMons[index].ability == ABILITY_ARENA_TRAP)
+ if (gBattleMons[bank].ability == ABILITY_SHADOW_TAG
+ || gBattleMons[bank].ability == ABILITY_MAGNET_PULL
+ || gBattleMons[bank].ability == ABILITY_ARENA_TRAP)
{
- AI_THINKING_STRUCT->funcResult = gBattleMons[index].ability;
+ AI_THINKING_STRUCT->funcResult = gBattleMons[bank].ability;
gAIScriptPtr += 2;
return;
}
- if (gBaseStats[gBattleMons[index].species].ability1 != ABILITY_NONE)
+ if (gBaseStats[gBattleMons[bank].species].ability1 != ABILITY_NONE)
{
- if (gBaseStats[gBattleMons[index].species].ability2 != ABILITY_NONE)
+ if (gBaseStats[gBattleMons[bank].species].ability2 != ABILITY_NONE)
{
// AI has no knowledge of opponent, so it guesses which ability.
if (Random() & 1)
{
- AI_THINKING_STRUCT->funcResult = gBaseStats[gBattleMons[index].species].ability1;
+ AI_THINKING_STRUCT->funcResult = gBaseStats[gBattleMons[bank].species].ability1;
}
else
{
- AI_THINKING_STRUCT->funcResult = gBaseStats[gBattleMons[index].species].ability2;
+ AI_THINKING_STRUCT->funcResult = gBaseStats[gBattleMons[bank].species].ability2;
}
}
else
{
- AI_THINKING_STRUCT->funcResult = gBaseStats[gBattleMons[index].species].ability1; // it's definitely ability 1.
+ AI_THINKING_STRUCT->funcResult = gBaseStats[gBattleMons[bank].species].ability1; // it's definitely ability 1.
}
}
else
{
- AI_THINKING_STRUCT->funcResult = gBaseStats[gBattleMons[index].species].ability2; // AI cant actually reach this part since every mon has at least 1 ability.
+ AI_THINKING_STRUCT->funcResult = gBaseStats[gBattleMons[bank].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[index].ability;
+ AI_THINKING_STRUCT->funcResult = gBattleMons[bank].ability;
}
gAIScriptPtr += 2;
}
@@ -1493,7 +1488,7 @@ static void BattleAICmd_get_highest_type_effectiveness(void)
for (i = 0; i < 4; i++)
{
- gBattleMoveDamage = 40;
+ gBattleMoveDamage = AI_EFFECTIVENESS_x1;
gCurrentMove = gBattleMons[sBank_AI].moves[i];
if (gCurrentMove)
@@ -1502,16 +1497,16 @@ static void BattleAICmd_get_highest_type_effectiveness(void)
// reduce by 1/3.
if (gBattleMoveDamage == 120)
- gBattleMoveDamage = 80;
+ gBattleMoveDamage = AI_EFFECTIVENESS_x2;
if (gBattleMoveDamage == 240)
- gBattleMoveDamage = 160;
+ gBattleMoveDamage = AI_EFFECTIVENESS_x4;
if (gBattleMoveDamage == 30)
- gBattleMoveDamage = 20;
+ gBattleMoveDamage = AI_EFFECTIVENESS_x0_5;
if (gBattleMoveDamage == 15)
- gBattleMoveDamage = 10;
+ gBattleMoveDamage = AI_EFFECTIVENESS_x0_25;
if (gBattleMoveFlags & MOVESTATUS_NOTAFFECTED)
- gBattleMoveDamage = 0;
+ gBattleMoveDamage = AI_EFFECTIVENESS_x0;
if (AI_THINKING_STRUCT->funcResult < gBattleMoveDamage)
AI_THINKING_STRUCT->funcResult = gBattleMoveDamage;
@@ -1530,22 +1525,22 @@ static void BattleAICmd_if_type_effectiveness(void)
gBattleMoveFlags = 0;
gCritMultiplier = 1;
- gBattleMoveDamage = 40;
+ gBattleMoveDamage = AI_EFFECTIVENESS_x1;
gCurrentMove = AI_THINKING_STRUCT->moveConsidered;
TypeCalc(gCurrentMove, sBank_AI, gBankTarget);
if (gBattleMoveDamage == 120)
- gBattleMoveDamage = 80;
+ gBattleMoveDamage = AI_EFFECTIVENESS_x2;
if (gBattleMoveDamage == 240)
- gBattleMoveDamage = 160;
+ gBattleMoveDamage = AI_EFFECTIVENESS_x4;
if (gBattleMoveDamage == 30)
- gBattleMoveDamage = 20;
+ gBattleMoveDamage = AI_EFFECTIVENESS_x0_5;
if (gBattleMoveDamage == 15)
- gBattleMoveDamage = 10;
+ gBattleMoveDamage = AI_EFFECTIVENESS_x0_25;
if (gBattleMoveFlags & MOVESTATUS_NOTAFFECTED)
- gBattleMoveDamage = 0;
+ gBattleMoveDamage = AI_EFFECTIVENESS_x0;
// store gBattleMoveDamage in a u8 variable because gAIScriptPtr[1] is a u8.
damageVar = gBattleMoveDamage;
@@ -1569,23 +1564,23 @@ static void BattleAICmd_if_status_in_party(void)
struct Pokemon *party;
int i;
u32 statusToCompareTo;
- u8 index;
+ u8 bank;
switch(gAIScriptPtr[1])
{
case AI_USER:
- index = sBank_AI;
+ bank = sBank_AI;
break;
default:
- index = gBankTarget;
+ bank = gBankTarget;
break;
}
- party = (GetBankSide(index) == 0) ? gPlayerParty : gEnemyParty;
+ party = (GetBankSide(bank) == SIDE_PLAYER) ? gPlayerParty : gEnemyParty;
statusToCompareTo = AIScriptRead32(gAIScriptPtr + 2);
- for (i = 0; i < 6; i++)
+ for (i = 0; i < PARTY_SIZE; i++)
{
u16 species = GetMonData(&party[i], MON_DATA_SPECIES);
u16 hp = GetMonData(&party[i], MON_DATA_HP);
@@ -1606,23 +1601,23 @@ static void BattleAICmd_if_status_not_in_party(void)
struct Pokemon *party;
int i;
u32 statusToCompareTo;
- u8 index;
+ u8 bank;
switch(gAIScriptPtr[1])
{
case 1:
- index = sBank_AI;
+ bank = sBank_AI;
break;
default:
- index = gBankTarget;
+ bank = gBankTarget;
break;
}
- party = (GetBankSide(index) == 0) ? gPlayerParty : gEnemyParty;
+ party = (GetBankSide(bank) == SIDE_PLAYER) ? gPlayerParty : gEnemyParty;
statusToCompareTo = AIScriptRead32(gAIScriptPtr + 2);
- for (i = 0; i < 6; i++)
+ for (i = 0; i < PARTY_SIZE; i++)
{
u16 species = GetMonData(&party[i], MON_DATA_SPECIES);
u16 hp = GetMonData(&party[i], MON_DATA_HP);
@@ -1640,13 +1635,13 @@ static void BattleAICmd_if_status_not_in_party(void)
static void BattleAICmd_get_weather(void)
{
if (gBattleWeather & WEATHER_RAIN_ANY)
- AI_THINKING_STRUCT->funcResult = 1;
+ AI_THINKING_STRUCT->funcResult = AI_WEATHER_RAIN;
if (gBattleWeather & WEATHER_SANDSTORM_ANY)
- AI_THINKING_STRUCT->funcResult = 2;
+ AI_THINKING_STRUCT->funcResult = AI_WEATHER_SANDSTORM;
if (gBattleWeather & WEATHER_SUN_ANY)
- AI_THINKING_STRUCT->funcResult = 0;
+ AI_THINKING_STRUCT->funcResult = AI_WEATHER_SUN;
if (gBattleWeather & WEATHER_HAIL_ANY)
- AI_THINKING_STRUCT->funcResult = 3;
+ AI_THINKING_STRUCT->funcResult = AI_WEATHER_HAIL;
gAIScriptPtr += 1;
}
@@ -1786,14 +1781,14 @@ static void BattleAICmd_if_cant_faint(void)
static void BattleAICmd_if_has_move(void)
{
int i;
- const u16 *temp_ptr = (u16 *)(gAIScriptPtr + 2);
+ const u16 *movePtr = (u16 *)(gAIScriptPtr + 2);
- switch(gAIScriptPtr[1])
+ switch (gAIScriptPtr[1])
{
case AI_USER:
for (i = 0; i < 4; i++)
{
- if (gBattleMons[sBank_AI].moves[i] == *temp_ptr)
+ if (gBattleMons[sBank_AI].moves[i] == *movePtr)
break;
}
if (i == 4)
@@ -1807,7 +1802,7 @@ static void BattleAICmd_if_has_move(void)
return;
}
case AI_USER_PARTNER:
- if (gBattleMons[sBank_AI ^ 2].hp == 0)
+ if (gBattleMons[sBank_AI ^ BIT_MON].hp == 0)
{
gAIScriptPtr += 8;
return;
@@ -1816,7 +1811,7 @@ static void BattleAICmd_if_has_move(void)
{
for (i = 0; i < 4; i++)
{
- if (gBattleMons[sBank_AI ^ 2].moves[i] == *temp_ptr)
+ if (gBattleMons[sBank_AI ^ BIT_MON].moves[i] == *movePtr)
break;
}
}
@@ -1834,7 +1829,7 @@ static void BattleAICmd_if_has_move(void)
case AI_TARGET_PARTNER:
for (i = 0; i < 4; i++)
{
- if (BATTLE_HISTORY->usedMoves[gBankTarget].moves[i] == *temp_ptr)
+ if (BATTLE_HISTORY->usedMoves[gBankTarget].moves[i] == *movePtr)
break;
}
if (i == 4)
@@ -1850,10 +1845,10 @@ static void BattleAICmd_if_has_move(void)
}
}
-static void BattleAICmd_if_dont_have_move(void)
+static void BattleAICmd_if_doesnt_have_move(void)
{
int i;
- const u16 *temp_ptr = (u16 *)(gAIScriptPtr + 2);
+ const u16 *movePtr = (u16 *)(gAIScriptPtr + 2);
switch(gAIScriptPtr[1])
{
@@ -1861,7 +1856,7 @@ static void BattleAICmd_if_dont_have_move(void)
case AI_USER_PARTNER: // UB: no separate check for user partner
for (i = 0; i < 4; i++)
{
- if (gBattleMons[sBank_AI].moves[i] == *temp_ptr)
+ if (gBattleMons[sBank_AI].moves[i] == *movePtr)
break;
}
if (i != 4)
@@ -1878,7 +1873,7 @@ static void BattleAICmd_if_dont_have_move(void)
case AI_TARGET_PARTNER:
for (i = 0; i < 4; i++)
{
- if (BATTLE_HISTORY->usedMoves[gBankTarget].moves[i] == *temp_ptr)
+ if (BATTLE_HISTORY->usedMoves[gBankTarget].moves[i] == *movePtr)
break;
}
if (i != 4)
@@ -1894,7 +1889,7 @@ static void BattleAICmd_if_dont_have_move(void)
}
}
-static void BattleAICmd_if_move_effect(void)
+static void BattleAICmd_if_has_move_with_effect(void)
{
int i;
@@ -1904,7 +1899,7 @@ static void BattleAICmd_if_move_effect(void)
case AI_USER_PARTNER:
for (i = 0; i < 4; i++)
{
- if(gBattleMons[sBank_AI].moves[i] != 0 && gBattleMoves[gBattleMons[sBank_AI].moves[i]].effect == gAIScriptPtr[2])
+ if (gBattleMons[sBank_AI].moves[i] != 0 && gBattleMoves[gBattleMons[sBank_AI].moves[i]].effect == gAIScriptPtr[2])
break;
}
if (i == 4)
@@ -1916,6 +1911,7 @@ static void BattleAICmd_if_move_effect(void)
case AI_TARGET_PARTNER:
for (i = 0; i < 4; i++)
{
+ // UB: checks sBank_AI instead of gBankTarget
if (gBattleMons[sBank_AI].moves[i] != 0 && gBattleMoves[BATTLE_HISTORY->usedMoves[gBankTarget].moves[i]].effect == gAIScriptPtr[2])
break;
}
@@ -1927,7 +1923,7 @@ static void BattleAICmd_if_move_effect(void)
}
}
-static void BattleAICmd_if_not_move_effect(void)
+static void BattleAICmd_if_doesnt_have_move_with_effect(void)
{
int i;
@@ -2023,7 +2019,7 @@ static void BattleAICmd_flee(void)
AI_THINKING_STRUCT->aiAction |= (AI_ACTION_DONE | AI_ACTION_FLEE | AI_ACTION_DO_NOT_ATTACK);
}
-static void BattleAICmd_if_random_100(void)
+static void BattleAICmd_if_random_safari_flee(void)
{
u8 safariFleeRate = gBattleStruct->field_7B * 5; // safari flee rate, from 0-20
@@ -2041,7 +2037,6 @@ static void BattleAICmd_watch(void)
static void BattleAICmd_get_hold_effect(void)
{
u8 bank;
- u16 status;
if (gAIScriptPtr[1] == AI_USER)
bank = sBank_AI;
@@ -2049,9 +2044,7 @@ static void BattleAICmd_get_hold_effect(void)
bank = gBankTarget;
if (gActiveBank != bank)
- {
AI_THINKING_STRUCT->funcResult = ItemId_GetHoldEffect(BATTLE_HISTORY->itemEffects[bank]);
- }
else
AI_THINKING_STRUCT->funcResult = ItemId_GetHoldEffect(gBattleMons[bank].item);
@@ -2093,7 +2086,7 @@ static void BattleAICmd_get_gender(void)
gAIScriptPtr += 2;
}
-static void BattleAICmd_is_first_turn(void)
+static void BattleAICmd_is_first_turn_for(void)
{
u8 bank;
@@ -2212,7 +2205,7 @@ static void BattleAICmd_call(void)
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 1);
}
-static void BattleAICmd_jump(void)
+static void BattleAICmd_goto(void)
{
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 1);
}
@@ -2272,7 +2265,7 @@ static void BattleAICmd_if_target_not_taunted(void)
static void BattleAICmd_if_target_is_ally(void)
{
- if((sBank_AI & 1) == (gBankTarget & 1))
+ if ((sBank_AI & BIT_SIDE) == (gBankTarget & BIT_SIDE))
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 1);
else
gAIScriptPtr += 5;
@@ -2280,9 +2273,9 @@ static void BattleAICmd_if_target_is_ally(void)
static void BattleAICmd_if_flash_fired(void)
{
- u8 index = BattleAI_GetWantedBank(gAIScriptPtr[1]);
+ u8 bank = BattleAI_GetWantedBank(gAIScriptPtr[1]);
- if(gBattleResources->flags->flags[index] & UNKNOWN_FLAG_FLASH_FIRE)
+ if (gBattleResources->flags->flags[bank] & UNKNOWN_FLAG_FLASH_FIRE)
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 2);
else
gAIScriptPtr += 6;
diff --git a/src/battle_anim.c b/src/battle_anim.c
index 2eec0bed5..fa4dfb48f 100644
--- a/src/battle_anim.c
+++ b/src/battle_anim.c
@@ -1,6 +1,7 @@
#include "global.h"
#include "battle.h"
#include "battle_anim.h"
+#include "constants/battle_anim.h"
#include "sprite.h"
#include "contest.h"
#include "m4a.h"
@@ -67,7 +68,7 @@ static void ScriptCmd_return(void);
static void ScriptCmd_setarg(void);
static void ScriptCmd_choosetwoturnanim(void);
static void ScriptCmd_jumpifmoveturn(void);
-static void ScriptCmd_jump(void);
+static void ScriptCmd_goto(void);
static void ScriptCmd_fadetobg(void);
static void ScriptCmd_restorebg(void);
static void ScriptCmd_waitbgfadeout(void);
@@ -156,7 +157,7 @@ static void (* const sScriptCmdTable[])(void) =
ScriptCmd_setarg,
ScriptCmd_choosetwoturnanim,
ScriptCmd_jumpifmoveturn,
- ScriptCmd_jump,
+ ScriptCmd_goto,
ScriptCmd_fadetobg,
ScriptCmd_restorebg,
ScriptCmd_waitbgfadeout,
@@ -605,7 +606,7 @@ static void ScriptCmd_monbg(void)
sBattleAnimScriptPtr++;
animBank = sBattleAnimScriptPtr[0];
- if (animBank & ANIM_BANK_TARGET)
+ if (animBank & ANIM_TARGET)
bank = gAnimBankTarget;
else
bank = gAnimBankAttacker;
@@ -862,12 +863,12 @@ static void ScriptCmd_clearmonbg(void)
sBattleAnimScriptPtr++;
animBankId = sBattleAnimScriptPtr[0];
- if (animBankId == ANIM_BANK_ATTACKER)
- animBankId = ANIM_BANK_ATK_PARTNER;
- else if (animBankId == ANIM_BANK_TARGET)
- animBankId = ANIM_BANK_DEF_PARTNER;
+ if (animBankId == ANIM_ATTACKER)
+ animBankId = ANIM_ATK_PARTNER;
+ else if (animBankId == ANIM_TARGET)
+ animBankId = ANIM_DEF_PARTNER;
- if (animBankId == ANIM_BANK_ATTACKER || animBankId == ANIM_BANK_ATK_PARTNER)
+ if (animBankId == ANIM_ATTACKER || animBankId == ANIM_ATK_PARTNER)
bank = gAnimBankAttacker;
else
bank = gAnimBankTarget;
@@ -924,12 +925,12 @@ static void ScriptCmd_monbg_22(void)
animBankId = sBattleAnimScriptPtr[0];
- if (animBankId == ANIM_BANK_ATTACKER)
- animBankId = ANIM_BANK_ATK_PARTNER;
- else if (animBankId == ANIM_BANK_TARGET)
- animBankId = ANIM_BANK_DEF_PARTNER;
+ if (animBankId == ANIM_ATTACKER)
+ animBankId = ANIM_ATK_PARTNER;
+ else if (animBankId == ANIM_TARGET)
+ animBankId = ANIM_DEF_PARTNER;
- if (animBankId == ANIM_BANK_ATTACKER || animBankId == ANIM_BANK_ATK_PARTNER)
+ if (animBankId == ANIM_ATTACKER || animBankId == ANIM_ATK_PARTNER)
bank = gAnimBankAttacker;
else
bank = gAnimBankTarget;
@@ -969,12 +970,12 @@ static void ScriptCmd_clearmonbg_23(void)
sBattleAnimScriptPtr++;
animBankId = sBattleAnimScriptPtr[0];
- if (animBankId == ANIM_BANK_ATTACKER)
- animBankId = ANIM_BANK_ATK_PARTNER;
- else if (animBankId == ANIM_BANK_TARGET)
- animBankId = ANIM_BANK_DEF_PARTNER;
+ if (animBankId == ANIM_ATTACKER)
+ animBankId = ANIM_ATK_PARTNER;
+ else if (animBankId == ANIM_TARGET)
+ animBankId = ANIM_DEF_PARTNER;
- if (animBankId == ANIM_BANK_ATTACKER || animBankId == ANIM_BANK_ATK_PARTNER)
+ if (animBankId == ANIM_ATTACKER || animBankId == ANIM_ATK_PARTNER)
bank = gAnimBankAttacker;
else
bank = gAnimBankTarget;
@@ -1099,7 +1100,7 @@ static void ScriptCmd_jumpifmoveturn(void)
sBattleAnimScriptPtr += 4;
}
-static void ScriptCmd_jump(void)
+static void ScriptCmd_goto(void)
{
sBattleAnimScriptPtr++;
sBattleAnimScriptPtr = SCRIPT_READ_PTR(sBattleAnimScriptPtr);
@@ -1699,7 +1700,7 @@ static void ScriptCmd_monbgprio_28(void)
wantedBank = sBattleAnimScriptPtr[1];
sBattleAnimScriptPtr += 2;
- if (wantedBank != ANIM_BANK_ATTACKER)
+ if (wantedBank != ANIM_ATTACKER)
bank = gAnimBankTarget;
else
bank = gAnimBankAttacker;
@@ -1732,7 +1733,7 @@ static void ScriptCmd_monbgprio_2A(void)
sBattleAnimScriptPtr += 2;
if (GetBankSide(gAnimBankAttacker) != GetBankSide(gAnimBankTarget))
{
- if (wantedBank != ANIM_BANK_ATTACKER)
+ if (wantedBank != ANIM_ATTACKER)
bank = gAnimBankTarget;
else
bank = gAnimBankAttacker;
@@ -1779,15 +1780,15 @@ static void ScriptCmd_doublebattle_2D(void)
if (!IsContest() && IsDoubleBattle()
&& GetBankSide(gAnimBankAttacker) == GetBankSide(gAnimBankTarget))
{
- if (wantedBank == ANIM_BANK_ATTACKER)
+ if (wantedBank == ANIM_ATTACKER)
{
r4 = sub_80A8364(gAnimBankAttacker);
- spriteId = GetAnimBankSpriteId(0);
+ spriteId = GetAnimBankSpriteId(ANIM_ATTACKER);
}
else
{
r4 = sub_80A8364(gAnimBankTarget);
- spriteId = GetAnimBankSpriteId(1);
+ spriteId = GetAnimBankSpriteId(ANIM_TARGET);
}
if (spriteId != 0xFF)
{
@@ -1814,15 +1815,15 @@ static void ScriptCmd_doublebattle_2E(void)
if (!IsContest() && IsDoubleBattle()
&& GetBankSide(gAnimBankAttacker) == GetBankSide(gAnimBankTarget))
{
- if (wantedBank == ANIM_BANK_ATTACKER)
+ if (wantedBank == ANIM_ATTACKER)
{
r4 = sub_80A8364(gAnimBankAttacker);
- spriteId = GetAnimBankSpriteId(0);
+ spriteId = GetAnimBankSpriteId(ANIM_ATTACKER);
}
else
{
r4 = sub_80A8364(gAnimBankTarget);
- spriteId = GetAnimBankSpriteId(1);
+ spriteId = GetAnimBankSpriteId(ANIM_TARGET);
}
if (spriteId != 0xFF && r4 == 2)
diff --git a/src/battle_controller_link_opponent.c b/src/battle_controller_link_opponent.c
index dd8582618..58360b9a1 100644
--- a/src/battle_controller_link_opponent.c
+++ b/src/battle_controller_link_opponent.c
@@ -4,6 +4,7 @@
#include "battle_message.h"
#include "battle_interface.h"
#include "battle_anim.h"
+#include "constants/battle_anim.h"
#include "battle_ai_script_commands.h"
#include "battle_link_817C95C.h"
#include "pokemon.h"
diff --git a/src/battle_controller_link_partner.c b/src/battle_controller_link_partner.c
index 9da468761..082b134b4 100644
--- a/src/battle_controller_link_partner.c
+++ b/src/battle_controller_link_partner.c
@@ -4,6 +4,7 @@
#include "battle_message.h"
#include "battle_interface.h"
#include "battle_anim.h"
+#include "constants/battle_anim.h"
#include "battle_ai_script_commands.h"
#include "battle_link_817C95C.h"
#include "pokemon.h"
diff --git a/src/battle_controller_opponent.c b/src/battle_controller_opponent.c
index 0862e72a7..8aeab6a55 100644
--- a/src/battle_controller_opponent.c
+++ b/src/battle_controller_opponent.c
@@ -4,6 +4,7 @@
#include "battle_message.h"
#include "battle_interface.h"
#include "battle_anim.h"
+#include "constants/battle_anim.h"
#include "battle_link_817C95C.h"
#include "battle_ai_script_commands.h"
#include "pokemon.h"
diff --git a/src/battle_controller_player.c b/src/battle_controller_player.c
index 08c666d11..6023552c3 100644
--- a/src/battle_controller_player.c
+++ b/src/battle_controller_player.c
@@ -4,6 +4,7 @@
#include "battle_message.h"
#include "battle_interface.h"
#include "battle_anim.h"
+#include "constants/battle_anim.h"
#include "battle_link_817C95C.h"
#include "pokemon.h"
#include "link.h"
diff --git a/src/battle_controller_player_partner.c b/src/battle_controller_player_partner.c
index dc4a213cc..6b5211ceb 100644
--- a/src/battle_controller_player_partner.c
+++ b/src/battle_controller_player_partner.c
@@ -4,6 +4,7 @@
#include "battle_message.h"
#include "battle_interface.h"
#include "battle_anim.h"
+#include "constants/battle_anim.h"
#include "battle_ai_script_commands.h"
#include "pokemon.h"
#include "link.h"
diff --git a/src/battle_controller_recorded_opponent.c b/src/battle_controller_recorded_opponent.c
index 8e2f31879..64dea0200 100644
--- a/src/battle_controller_recorded_opponent.c
+++ b/src/battle_controller_recorded_opponent.c
@@ -4,6 +4,7 @@
#include "battle_message.h"
#include "battle_interface.h"
#include "battle_anim.h"
+#include "constants/battle_anim.h"
#include "battle_ai_script_commands.h"
#include "battle_link_817C95C.h"
#include "recorded_battle.h"
diff --git a/src/battle_controller_recorded_player.c b/src/battle_controller_recorded_player.c
index f558fde87..52fd803e1 100644
--- a/src/battle_controller_recorded_player.c
+++ b/src/battle_controller_recorded_player.c
@@ -4,6 +4,7 @@
#include "battle_message.h"
#include "battle_interface.h"
#include "battle_anim.h"
+#include "constants/battle_anim.h"
#include "battle_ai_script_commands.h"
#include "recorded_battle.h"
#include "pokemon.h"
diff --git a/src/battle_controller_safari.c b/src/battle_controller_safari.c
index 64e6a0bc3..682e8333d 100644
--- a/src/battle_controller_safari.c
+++ b/src/battle_controller_safari.c
@@ -4,6 +4,7 @@
#include "battle_message.h"
#include "battle_interface.h"
#include "battle_anim.h"
+#include "constants/battle_anim.h"
#include "pokemon.h"
#include "link.h"
#include "util.h"
diff --git a/src/battle_controller_wally.c b/src/battle_controller_wally.c
index 446027944..eeb0b596d 100644
--- a/src/battle_controller_wally.c
+++ b/src/battle_controller_wally.c
@@ -4,6 +4,7 @@
#include "battle_message.h"
#include "battle_interface.h"
#include "battle_anim.h"
+#include "constants/battle_anim.h"
#include "battle_link_817C95C.h"
#include "pokemon.h"
#include "link.h"
diff --git a/src/battle_gfx_sfx_util.c b/src/battle_gfx_sfx_util.c
index 70b4d7d31..4f444b8bf 100644
--- a/src/battle_gfx_sfx_util.c
+++ b/src/battle_gfx_sfx_util.c
@@ -3,6 +3,7 @@
#include "battle_controllers.h"
#include "battle_ai_script_commands.h"
#include "battle_anim.h"
+#include "constants/battle_anim.h"
#include "battle_interface.h"
#include "main.h"
#include "malloc.h"
@@ -39,8 +40,8 @@ extern struct MusicPlayerInfo gMPlay_BGM;
extern const struct BattleMove gBattleMoves[];
extern const u8 gUnknown_0831C604[];
-extern const u8 * const gUnknown_082C9320[];
-extern const u8 * const gUnknown_082C937C[];
+extern const u8 * const gBattleAnims_VariousTable[];
+extern const u8 * const gBattleAnims_Special[];
extern const struct CompressedSpriteSheet gMonFrontPicTable[];
extern const struct CompressedSpriteSheet gMonBackPicTable[];
extern const struct CompressedSpriteSheet gTrainerFrontPicTable[];
@@ -414,7 +415,7 @@ void InitAndLaunchChosenStatusAnimation(bool8 isStatus2, u32 status)
else if (status & STATUS2_NIGHTMARE)
LaunchStatusAnimation(gActiveBank, B_ANIM_STATUS_NIGHTMARE);
else if (status & STATUS2_WRAPPED)
- LaunchStatusAnimation(gActiveBank, B_ANIM_STATUS_WRAPPED);
+ LaunchStatusAnimation(gActiveBank, B_ANIM_STATUS_WRAPPED); // this animation doesn't actually exist
else // no animation
gBattleSpritesDataPtr->healthBoxesData[gActiveBank].statusAnimActive = 0;
}
@@ -448,7 +449,7 @@ bool8 TryHandleLaunchBattleTableAnimation(u8 activeBank, u8 atkBank, u8 defBank,
gAnimBankAttacker = atkBank;
gAnimBankTarget = defBank;
gBattleSpritesDataPtr->animationData->animArg = argument;
- LaunchBattleAnimation(gUnknown_082C9320, tableId, FALSE);
+ LaunchBattleAnimation(gBattleAnims_VariousTable, tableId, FALSE);
taskId = CreateTask(Task_ClearBitWhenBattleTableAnimDone, 10);
gTasks[taskId].tBank = activeBank;
gBattleSpritesDataPtr->healthBoxesData[gTasks[taskId].tBank].animFromTableActive = 1;
@@ -492,7 +493,7 @@ void InitAndLaunchSpecialAnimation(u8 activeBank, u8 atkBank, u8 defBank, u8 tab
gAnimBankAttacker = atkBank;
gAnimBankTarget = defBank;
- LaunchBattleAnimation(gUnknown_082C937C, tableId, FALSE);
+ LaunchBattleAnimation(gBattleAnims_Special, tableId, FALSE);
taskId = CreateTask(Task_ClearBitWhenSpecialAnimDone, 10);
gTasks[taskId].tBank = activeBank;
gBattleSpritesDataPtr->healthBoxesData[gTasks[taskId].tBank].specialAnimActive = 1;
diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c
index 43b802d0b..4ddf2472e 100644
--- a/src/battle_script_commands.c
+++ b/src/battle_script_commands.c
@@ -18,6 +18,7 @@
#include "constants/species.h"
#include "constants/songs.h"
#include "constants/trainers.h"
+#include "constants/battle_anim.h"
#include "text.h"
#include "sound.h"
#include "pokedex.h"
diff --git a/src/battle_util.c b/src/battle_util.c
index 1a624641d..2ce37cfbd 100644
--- a/src/battle_util.c
+++ b/src/battle_util.c
@@ -3,6 +3,7 @@
#include "constants/abilities.h"
#include "constants/moves.h"
#include "constants/hold_effects.h"
+#include "constants/battle_anim.h"
#include "pokemon.h"
#include "constants/species.h"
#include "item.h"
diff --git a/src/berry_fix_program.c b/src/berry_fix_program.c
index 195490543..3b2bfb5f7 100644
--- a/src/berry_fix_program.c
+++ b/src/berry_fix_program.c
@@ -81,50 +81,50 @@ static const u8 *const gUnknown_08618160[] = {
Unknown_08617EA3
};
-extern const u8 gUnknown_08DD87C0[];
-extern const u8 gUnknown_08DD8EE0[];
-extern const u8 gUnknown_08DD8780[];
-extern const u8 gUnknown_08DD90E0[];
-extern const u8 gUnknown_08DD9718[];
-extern const u8 gUnknown_08DD9080[];
-extern const u8 gUnknown_08DD98B4[];
-extern const u8 gUnknown_08DD9E58[];
-extern const u8 gUnknown_08DD9874[];
-extern const u8 gUnknown_08DDA02C[];
-extern const u8 gUnknown_08DDA63C[];
-extern const u8 gUnknown_08DD9FEC[];
-extern const u8 gUnknown_08DDA840[];
-extern const u8 gUnknown_08DDAE40[];
-extern const u8 gUnknown_08DDA800[];
-extern const u8 gUnknown_08DDB020[];
-extern const u8 gUnknown_08DDB2C4[];
-extern const u8 gUnknown_08DDAFE0[];
+extern const u8 gBerryFixGameboy_Gfx[];
+extern const u8 gBerryFixGameboy_Tilemap[];
+extern const u8 gBerryFixGameboy_Pal[];
+extern const u8 gBerryFixGameboyLogo_Gfx[];
+extern const u8 gBerryFixGameboyLogo_Tilemap[];
+extern const u8 gBerryFixGameboyLogo_Pal[];
+extern const u8 gBerryFixGbaTransfer_Gfx[];
+extern const u8 gBerryFixGbaTransfer_Tilemap[];
+extern const u8 gBerryFixGbaTransfer_Pal[];
+extern const u8 gBerryFixGbaTransferHighlight_Gfx[];
+extern const u8 gBerryFixGbaTransferHighlight_Tilemap[];
+extern const u8 gBerryFixGbaTransferHighlight_Pal[];
+extern const u8 gBerryFixGbaTransferError_Gfx[];
+extern const u8 gBerryFixGbaTransferError_Tilemap[];
+extern const u8 gBerryFixGbaTransferError_Pal[];
+extern const u8 gBerryFixWindow_Gfx[];
+extern const u8 gBerryFixWindow_Tilemap[];
+extern const u8 gBerryFixWindow_Pal[];
static const u8 *const gUnknown_08618178[][3] = {
{
- gUnknown_08DD87C0,
- gUnknown_08DD8EE0,
- gUnknown_08DD8780
+ gBerryFixGameboy_Gfx,
+ gBerryFixGameboy_Tilemap,
+ gBerryFixGameboy_Pal
}, {
- gUnknown_08DD90E0,
- gUnknown_08DD9718,
- gUnknown_08DD9080
+ gBerryFixGameboyLogo_Gfx,
+ gBerryFixGameboyLogo_Tilemap,
+ gBerryFixGameboyLogo_Pal
}, {
- gUnknown_08DD98B4,
- gUnknown_08DD9E58,
- gUnknown_08DD9874
+ gBerryFixGbaTransfer_Gfx,
+ gBerryFixGbaTransfer_Tilemap,
+ gBerryFixGbaTransfer_Pal
}, {
- gUnknown_08DDA02C,
- gUnknown_08DDA63C,
- gUnknown_08DD9FEC
+ gBerryFixGbaTransferHighlight_Gfx,
+ gBerryFixGbaTransferHighlight_Tilemap,
+ gBerryFixGbaTransferHighlight_Pal
}, {
- gUnknown_08DDA840,
- gUnknown_08DDAE40,
- gUnknown_08DDA800
+ gBerryFixGbaTransferError_Gfx,
+ gBerryFixGbaTransferError_Tilemap,
+ gBerryFixGbaTransferError_Pal
}, {
- gUnknown_08DDB020,
- gUnknown_08DDB2C4,
- gUnknown_08DDAFE0
+ gBerryFixWindow_Gfx,
+ gBerryFixWindow_Tilemap,
+ gBerryFixWindow_Pal
},
};
diff --git a/src/bike.c b/src/bike.c
new file mode 100644
index 000000000..64af7c711
--- /dev/null
+++ b/src/bike.c
@@ -0,0 +1,1078 @@
+#include "global.h"
+#include "bike.h"
+#include "field_map_obj.h"
+#include "field_player_avatar.h"
+#include "fieldmap.h"
+#include "constants/flags.h"
+#include "global.fieldmap.h"
+#include "metatile_behavior.h"
+#include "overworld.h"
+#include "constants/songs.h"
+#include "sound.h"
+
+extern bool8 gBikeCyclingChallenge;
+extern u8 gBikeCollisions;
+extern bool8 gUnknown_02037348;
+
+extern u8 sub_8093514(u8 direction);
+extern u8 sub_808B980(u8 direction);
+extern u8 sub_808B9BC(u8 direction);
+extern u8 sub_808B9A4(u8 direction);
+extern u8 sub_808C1B4(u8 direction);
+extern u8 npc_use_some_d2s(u8 direction);
+extern void Overworld_ClearSavedMusic(void);
+extern void Overworld_PlaySpecialMapMusic(void);
+
+// this file's functions
+static void MovePlayerOnMachBike(u8, u16, u16);
+static u8 GetMachBikeTransition(u8 *);
+static void MachBikeTransition_FaceDirection(u8);
+static void MachBikeTransition_TurnDirection(u8);
+static void MachBikeTransition_TrySpeedUp(u8);
+static void MachBikeTransition_TrySlowDown(u8);
+static void MovePlayerOnAcroBike(u8, u16, u16);
+static u8 CheckMovementInputAcroBike(u8 *, u16, u16);
+static u8 AcroBikeHandleInputNormal(u8 *, u16, u16);
+static u8 AcroBikeHandleInputTurning(u8 *, u16, u16);
+static u8 AcroBikeHandleInputWheelieStanding(u8 *, u16, u16);
+static u8 AcroBikeHandleInputBunnyHop(u8 *, u16, u16);
+static u8 AcroBikeHandleInputWheelieMoving(u8 *, u16, u16);
+static u8 AcroBikeHandleInputSidewaysJump(u8 *, u16, u16);
+static u8 AcroBikeHandleInputTurnJump(u8 *, u16, u16);
+static void AcroBikeTransition_FaceDirection(u8);
+static void AcroBikeTransition_TurnDirection(u8);
+static void AcroBikeTransition_Moving(u8);
+static void AcroBikeTransition_NormalToWheelie(u8);
+static void AcroBikeTransition_WheelieToNormal(u8);
+static void AcroBikeTransition_WheelieIdle(u8);
+static void AcroBikeTransition_WheelieHoppingStanding(u8);
+static void AcroBikeTransition_WheelieHoppingMoving(u8);
+static void AcroBikeTransition_SideJump(u8);
+static void AcroBikeTransition_TurnJump(u8);
+static void AcroBikeTransition_WheelieMoving(u8);
+static void AcroBikeTransition_WheelieRisingMoving(u8);
+static void AcroBikeTransition_WheelieLoweringMoving(u8);
+static void AcroBike_TryHistoryUpdate(u16, u16);
+static u8 AcroBike_GetJumpDirection(void);
+static void Bike_UpdateDirTimerHistory(u8);
+static void Bike_UpdateABStartSelectHistory(u8);
+static u8 Bike_DPadToDirection(u16);
+static u8 get_some_collision(u8);
+static u8 Bike_CheckCollisionTryAdvanceCollisionCount(struct MapObject *, s16, s16, u8, u8);
+static bool8 IsRunningDisallowedByMetatile(u8);
+static void Bike_TryAdvanceCyclingRoadCollisions();
+static u8 CanBikeFaceDirOnMetatile(u8, u8);
+static bool8 WillPlayerCollideWithCollision(u8, u8);
+static void Bike_SetBikeStill(void);
+
+// const rom data
+
+/*
+ A bike transition is a type of callback for the bike that actually
+ modifies the bicycle's direction or momentum or otherwise movement.
+ Alternatively, a bike may also have input handlers which process the
+ bike transition to call: the acro bike has input handlers while the mach
+ bike does not. This is because the Acro needs to know the button inputs
+ for its complex tricks and actions.
+*/
+
+static void (*const sMachBikeTransitions[])(u8) =
+{
+ MachBikeTransition_FaceDirection, // Face vs Turn: Face has no anim while Turn does. Turn checks for collision because if you turn right as opposed to face right, if there is a wall there, turn will make a bonk sound effect while face will not.
+ MachBikeTransition_TurnDirection,
+ MachBikeTransition_TrySpeedUp,
+ MachBikeTransition_TrySlowDown,
+};
+
+// bikeFrameCounter is input which is represented by sMachBikeSpeeds in order: 0 is normal speed (1 speed), 1 is fast speed (2 speed), 2 is fastest speed (4 speed)
+static void (*const sMachBikeSpeedCallbacks[])(u8) =
+{
+ PlayerGoSpeed1, // normal speed (1 speed)
+ PlayerGoSpeed2, // fast speed (2 speed)
+ PlayerGoSpeed4, // fastest speed (4 speed)
+};
+
+static void (*const sAcroBikeTransitions[])(u8) =
+{
+ AcroBikeTransition_FaceDirection,
+ AcroBikeTransition_TurnDirection,
+ AcroBikeTransition_Moving,
+ AcroBikeTransition_NormalToWheelie,
+ AcroBikeTransition_WheelieToNormal,
+ AcroBikeTransition_WheelieIdle,
+ AcroBikeTransition_WheelieHoppingStanding,
+ AcroBikeTransition_WheelieHoppingMoving,
+ AcroBikeTransition_SideJump,
+ AcroBikeTransition_TurnJump,
+ AcroBikeTransition_WheelieMoving,
+ AcroBikeTransition_WheelieRisingMoving,
+ AcroBikeTransition_WheelieLoweringMoving,
+};
+
+static u8 (*const sAcroBikeInputHandlers[])(u8 *, u16, u16) =
+{
+ AcroBikeHandleInputNormal,
+ AcroBikeHandleInputTurning,
+ AcroBikeHandleInputWheelieStanding,
+ AcroBikeHandleInputBunnyHop,
+ AcroBikeHandleInputWheelieMoving,
+ AcroBikeHandleInputSidewaysJump,
+ AcroBikeHandleInputTurnJump,
+};
+
+// used with bikeFrameCounter from mach bike
+static const u16 sMachBikeSpeeds[] = {SPEED_NORMAL, SPEED_FAST, SPEED_FASTEST};
+
+// this is a list of timers to compare against later, terminated with 0. the only timer being compared against is 4 frames in this list.
+static const u8 sAcroBikeJumpTimerList[] = {4, 0};
+
+// this is a list of history inputs to do in order to do the check to retrieve a jump direction for acro bike. it seems to be an extensible list, so its possible that Game Freak may have intended for the Acro Bike to have more complex tricks at some point. The final list only has the acro jump.
+static const struct BikeHistoryInputInfo sAcroBikeTricksList[] =
+{
+ // the 0xF is a mask performed with each byte of the array in order to perform the check on only the last entry of the history list, otherwise the check wouldn't work as there can be 0xF0 as opposed to 0x0F.
+ {DIR_SOUTH, B_BUTTON, 0xF, 0xF, sAcroBikeJumpTimerList, sAcroBikeJumpTimerList, DIR_SOUTH},
+ {DIR_NORTH, B_BUTTON, 0xF, 0xF, sAcroBikeJumpTimerList, sAcroBikeJumpTimerList, DIR_NORTH},
+ {DIR_WEST, B_BUTTON, 0xF, 0xF, sAcroBikeJumpTimerList, sAcroBikeJumpTimerList, DIR_WEST},
+ {DIR_EAST, B_BUTTON, 0xF, 0xF, sAcroBikeJumpTimerList, sAcroBikeJumpTimerList, DIR_EAST},
+};
+
+// code
+void MovePlayerOnBike(u8 direction, u16 newKeys, u16 heldKeys)
+{
+ if (gPlayerAvatar.flags & PLAYER_AVATAR_FLAG_MACH_BIKE)
+ MovePlayerOnMachBike(direction, newKeys, heldKeys);
+ else
+ MovePlayerOnAcroBike(direction, newKeys, heldKeys);
+}
+
+static void MovePlayerOnMachBike(u8 direction, u16 newKeys, u16 heldKeys)
+{
+ sMachBikeTransitions[GetMachBikeTransition(&direction)](direction);
+}
+
+// dirTraveling is a variable that is 0 when the player is standing still.
+static u8 GetMachBikeTransition(u8 *dirTraveling)
+{
+ // if the dir updated before this function, get the relevent new direction to check later.
+ u8 direction = player_get_direction_upper_nybble();
+
+ // is the player standing still?
+ if (*dirTraveling == 0)
+ {
+ *dirTraveling = direction; // update the direction, since below we either faced a direction or we started moving.
+ if (gPlayerAvatar.bikeSpeed == SPEED_STANDING)
+ {
+ gPlayerAvatar.runningState = NOT_MOVING;
+ return MACH_TRANS_FACE_DIRECTION;
+ }
+ gPlayerAvatar.runningState = MOVING;
+ return MACH_TRANS_START_MOVING;
+ }
+
+ // we need to check if the last traveled direction changed from the new direction as well as ensuring that we dont update the state while the player is moving: see the else check.
+ if (*dirTraveling != direction && gPlayerAvatar.runningState != MOVING)
+ {
+ if (gPlayerAvatar.bikeSpeed != SPEED_STANDING)
+ {
+ *dirTraveling = direction; // implement the new direction
+ gPlayerAvatar.runningState = MOVING;
+ return MACH_TRANS_START_MOVING;
+ }
+ // if you didnt start moving but your dir was different, do a turn direction instead.
+ gPlayerAvatar.runningState = TURN_DIRECTION;
+ return MACH_TRANS_TURN_DIRECTION;
+ }
+ else // the player is either going in the current direction and hasnt changed or their state is currently moving.
+ {
+ gPlayerAvatar.runningState = MOVING;
+ return MACH_TRANS_KEEP_MOVING;
+ }
+}
+
+// the difference between face direction and turn direction is that one changes direction while the other does the animation of turning as well as changing direction.
+static void MachBikeTransition_FaceDirection(u8 direction)
+{
+ PlayerFaceDirection(direction);
+ Bike_SetBikeStill();
+}
+
+static void MachBikeTransition_TurnDirection(u8 direction)
+{
+ struct MapObject *playerMapObj = &gMapObjects[gPlayerAvatar.mapObjectId];
+
+ if (CanBikeFaceDirOnMetatile(direction, playerMapObj->mapobj_unk_1E))
+ {
+ PlayerTurnInPlace(direction);
+ Bike_SetBikeStill();
+ }
+ else
+ {
+ MachBikeTransition_FaceDirection(playerMapObj->mapobj_unk_18);
+ }
+}
+
+static void MachBikeTransition_TrySpeedUp(u8 direction)
+{
+ struct MapObject *playerMapObj = &gMapObjects[gPlayerAvatar.mapObjectId];
+ u8 collision;
+
+ if (CanBikeFaceDirOnMetatile(direction, playerMapObj->mapobj_unk_1E) == FALSE)
+ {
+ // we cannot go forward, so either slow down or, if we are stopped, idle face direction.
+ if (gPlayerAvatar.bikeSpeed)
+ MachBikeTransition_TrySlowDown(playerMapObj->placeholder18);
+ else
+ MachBikeTransition_FaceDirection(playerMapObj->placeholder18);
+ }
+ else
+ {
+ collision = get_some_collision(direction);
+ if (collision > 0 && collision < 12)
+ {
+ // we hit a solid object, but check to see if its a ledge and then jump.
+ if (collision == COLLISION_LEDGE_JUMP)
+ {
+ PlayerJumpLedge(direction);
+ }
+ else
+ {
+ // we hit a solid object that is not a ledge, so perform the collision.
+ Bike_SetBikeStill();
+ if (collision == 4 && IsPlayerCollidingWithFarawayIslandMew(direction))
+ PlayerOnBikeCollideWithFarawayIslandMew(direction);
+ else if (collision < 5 || collision > 8)
+ PlayerOnBikeCollide(direction);
+ }
+ }
+ else
+ {
+ // we did not hit anything that can slow us down, so perform the advancement callback depending on the bikeFrameCounter and try to increase the mach bike's speed.
+ sMachBikeSpeedCallbacks[gPlayerAvatar.bikeFrameCounter](direction);
+ gPlayerAvatar.bikeSpeed = gPlayerAvatar.bikeFrameCounter + (gPlayerAvatar.bikeFrameCounter >> 1); // same as dividing by 2, but compiler is insistent on >> 1
+ if (gPlayerAvatar.bikeFrameCounter < 2) // do not go faster than the last element in the mach bike array
+ gPlayerAvatar.bikeFrameCounter++;
+ }
+ }
+}
+
+static void MachBikeTransition_TrySlowDown(u8 direction)
+{
+ u8 collision;
+
+ if (gPlayerAvatar.bikeSpeed != SPEED_STANDING)
+ gPlayerAvatar.bikeFrameCounter = --gPlayerAvatar.bikeSpeed;
+
+ collision = get_some_collision(direction);
+
+ if (collision > 0 && collision < 12)
+ {
+ if (collision == COLLISION_LEDGE_JUMP)
+ {
+ PlayerJumpLedge(direction);
+ }
+ else
+ {
+ Bike_SetBikeStill();
+ if (collision == 4 && IsPlayerCollidingWithFarawayIslandMew(direction))
+ PlayerOnBikeCollideWithFarawayIslandMew(direction);
+ else if (collision < 5 || collision > 8)
+ PlayerOnBikeCollide(direction);
+ }
+ }
+ else
+ {
+ sMachBikeSpeedCallbacks[gPlayerAvatar.bikeFrameCounter](direction);
+ }
+}
+
+// the acro bike requires the input handler to be executed before the transition can.
+static void MovePlayerOnAcroBike(u8 newDirection, u16 newKeys, u16 heldKeys)
+{
+ sAcroBikeTransitions[CheckMovementInputAcroBike(&newDirection, newKeys, heldKeys)](newDirection);
+}
+
+static u8 CheckMovementInputAcroBike(u8 *newDirection, u16 newKeys, u16 heldKeys)
+{
+ return sAcroBikeInputHandlers[gPlayerAvatar.acroBikeState](newDirection, newKeys, heldKeys);
+}
+
+static u8 AcroBikeHandleInputNormal(u8 *newDirection, u16 newKeys, u16 heldKeys)
+{
+ u8 direction = player_get_direction_upper_nybble();
+
+ gPlayerAvatar.bikeFrameCounter = 0;
+ if (*newDirection == DIR_NONE)
+ {
+ if (newKeys & B_BUTTON)
+ {
+ //We're standing still with the B button held.
+ //Do a wheelie.
+ *newDirection = direction;
+ gPlayerAvatar.runningState = NOT_MOVING;
+ gPlayerAvatar.acroBikeState = ACRO_STATE_WHEELIE_STANDING;
+ return ACRO_TRANS_NORMAL_TO_WHEELIE;
+ }
+ else
+ {
+ *newDirection = direction;
+ gPlayerAvatar.runningState = NOT_MOVING;
+ return ACRO_TRANS_FACE_DIRECTION;
+ }
+ }
+ if (*newDirection == direction && (heldKeys & B_BUTTON) && gPlayerAvatar.bikeSpeed == SPEED_STANDING)
+ {
+ gPlayerAvatar.bikeSpeed++;
+ gPlayerAvatar.acroBikeState = ACRO_STATE_WHEELIE_MOVING;
+ return ACRO_TRANS_WHEELIE_RISING_MOVING;
+ }
+ if (*newDirection != direction && gPlayerAvatar.runningState != MOVING)
+ {
+ gPlayerAvatar.acroBikeState = ACRO_STATE_TURNING;
+ gPlayerAvatar.newDirBackup = *newDirection;
+ gPlayerAvatar.runningState = NOT_MOVING;
+ return CheckMovementInputAcroBike(newDirection, newKeys, heldKeys);
+ }
+ gPlayerAvatar.runningState = MOVING;
+ return ACRO_TRANS_MOVING;
+}
+
+static u8 AcroBikeHandleInputTurning(u8 *newDirection, u16 newKeys, u16 heldKeys)
+{
+ u8 direction;
+
+ *newDirection = gPlayerAvatar.newDirBackup;
+ gPlayerAvatar.bikeFrameCounter++;
+
+ // Wait 6 frames before actually changing direction
+ if (gPlayerAvatar.bikeFrameCounter > 6) // ... because it takes 6 frames to advance 1 tile.
+ {
+ gPlayerAvatar.runningState = TURN_DIRECTION;
+ gPlayerAvatar.acroBikeState = ACRO_STATE_NORMAL;
+ Bike_SetBikeStill();
+ return ACRO_TRANS_TURN_DIRECTION;
+ }
+ direction = player_get_direction_upper_nybble();
+ if (*newDirection == AcroBike_GetJumpDirection())
+ {
+ Bike_SetBikeStill(); // Bike_SetBikeStill sets speed to standing, but the next line immediately overrides it. could have just reset acroBikeState to 0 here instead of wasting a jump.
+ gPlayerAvatar.bikeSpeed = SPEED_NORMAL;
+ if (*newDirection == GetOppositeDirection(direction))
+ {
+ // do a turn jump.
+ // no need to update runningState, didnt move.
+ gPlayerAvatar.acroBikeState = ACRO_STATE_TURN_JUMP;
+ return ACRO_TRANS_TURN_JUMP;
+ }
+ else
+ {
+ // do a sideways jump.
+ gPlayerAvatar.runningState = MOVING; // we need to move, set state to moving.
+ gPlayerAvatar.acroBikeState = ACRO_STATE_SIDE_JUMP;
+ return ACRO_TRANS_SIDE_JUMP;
+ }
+ }
+ *newDirection = direction;
+ return ACRO_TRANS_FACE_DIRECTION;
+}
+
+static u8 AcroBikeHandleInputWheelieStanding(u8 *newDirection, u16 newKeys, u16 heldKeys)
+{
+ u8 direction;
+ struct MapObject *playerMapObj;
+
+ direction = player_get_direction_upper_nybble();
+ playerMapObj = &gMapObjects[gPlayerAvatar.mapObjectId];
+ gPlayerAvatar.runningState = NOT_MOVING;
+
+ if (heldKeys & B_BUTTON)
+ gPlayerAvatar.bikeFrameCounter++;
+ else
+ {
+ // B button was released.
+ gPlayerAvatar.bikeFrameCounter = 0;
+ if (!MetatileBehavior_IsBumpySlope(playerMapObj->mapobj_unk_1E))
+ {
+ // Go back to normal on flat ground
+ *newDirection = direction;
+ gPlayerAvatar.acroBikeState = ACRO_STATE_NORMAL;
+ Bike_SetBikeStill();
+ return ACRO_TRANS_WHEELIE_TO_NORMAL;
+ }
+ }
+ if (gPlayerAvatar.bikeFrameCounter >= 40)
+ {
+ *newDirection = direction;
+ gPlayerAvatar.acroBikeState = ACRO_STATE_BUNNY_HOP;
+ Bike_SetBikeStill();
+ return ACRO_TRANS_WHEELIE_HOPPING_STANDING;
+ }
+ if (*newDirection == direction)
+ {
+ gPlayerAvatar.runningState = MOVING;
+ gPlayerAvatar.acroBikeState = ACRO_STATE_WHEELIE_MOVING;
+ Bike_SetBikeStill();
+ return ACRO_TRANS_WHEELIE_MOVING;
+ }
+ if (*newDirection == 0)
+ {
+ *newDirection = direction;
+ return ACRO_TRANS_WHEELIE_IDLE;
+ }
+ gPlayerAvatar.runningState = TURN_DIRECTION;
+ return ACRO_TRANS_WHEELIE_IDLE;
+}
+
+static u8 AcroBikeHandleInputBunnyHop(u8 *newDirection, u16 newKeys, u16 heldKeys)
+{
+ u8 direction;
+ struct MapObject *playerMapObj;
+
+ direction = player_get_direction_upper_nybble();
+ playerMapObj = &gMapObjects[gPlayerAvatar.mapObjectId];
+ if (!(heldKeys & B_BUTTON))
+ {
+ // B button was released
+ Bike_SetBikeStill();
+ if (MetatileBehavior_IsBumpySlope(playerMapObj->mapobj_unk_1E))
+ {
+ // even though B was released, dont undo the wheelie on the bumpy slope.
+ gPlayerAvatar.acroBikeState = ACRO_STATE_WHEELIE_STANDING;
+ return CheckMovementInputAcroBike(newDirection, newKeys, heldKeys);
+ }
+ else
+ {
+ // .. otherwise, go back to normal on flat ground
+ *newDirection = direction;
+ gPlayerAvatar.runningState = NOT_MOVING;
+ gPlayerAvatar.acroBikeState = ACRO_STATE_NORMAL;
+ return ACRO_TRANS_WHEELIE_TO_NORMAL;
+ }
+ }
+
+ // B Button is still held
+
+ if (*newDirection == DIR_NONE)
+ {
+ // we did not move, so keep hopping in place without moving.
+ *newDirection = direction;
+ gPlayerAvatar.runningState = NOT_MOVING;
+ return ACRO_TRANS_WHEELIE_HOPPING_STANDING;
+ }
+ if (*newDirection != direction && gPlayerAvatar.runningState != MOVING)
+ {
+ // we changed direction, so turn but do not move hop.
+ gPlayerAvatar.runningState = TURN_DIRECTION;
+ return ACRO_TRANS_WHEELIE_HOPPING_STANDING;
+ }
+ // otherwise, we started moving while hopping
+ gPlayerAvatar.runningState = MOVING;
+ return ACRO_TRANS_WHEELIE_HOPPING_MOVING;
+}
+
+static u8 AcroBikeHandleInputWheelieMoving(u8 *newDirection, u16 newKeys, u16 heldKeys)
+{
+ u8 direction;
+ struct MapObject *playerMapObj;
+
+ direction = player_get_direction_lower_nybble();
+ playerMapObj = &gMapObjects[gPlayerAvatar.mapObjectId];
+ if (!(heldKeys & B_BUTTON))
+ {
+ // we were moving on a wheelie, but we let go while moving. reset bike still status
+ Bike_SetBikeStill();
+ if (!MetatileBehavior_IsBumpySlope(playerMapObj->mapobj_unk_1E))
+ {
+ // we let go of B and arent on a bumpy slope, set state to normal because now we need to handle this
+ gPlayerAvatar.acroBikeState = ACRO_STATE_NORMAL;
+ if (*newDirection == DIR_NONE)
+ {
+ // we stopped moving but are turning, still try to lower the wheelie in place.
+ *newDirection = direction;
+ gPlayerAvatar.runningState = NOT_MOVING;
+ return ACRO_TRANS_WHEELIE_TO_NORMAL;
+ }
+ if (*newDirection != direction && gPlayerAvatar.runningState != MOVING)
+ {
+ // we did not turn while lowering wheelie, so do so without turning.
+ gPlayerAvatar.runningState = NOT_MOVING;
+ return ACRO_TRANS_WHEELIE_TO_NORMAL;
+ }
+ // if we are moving while lowering wheelie, put the acro into a lowering state while moving.
+ gPlayerAvatar.runningState = MOVING;
+ return ACRO_TRANS_WHEELIE_LOWERING_MOVING;
+ }
+ // please do not undo the wheelie on a bumpy slope
+ gPlayerAvatar.acroBikeState = ACRO_STATE_WHEELIE_STANDING;
+ return CheckMovementInputAcroBike(newDirection, newKeys, heldKeys);
+ }
+ // we are still holding B.
+ if (*newDirection == DIR_NONE)
+ {
+ // idle the wheelie in place because we're holding B without moving.
+ *newDirection = direction;
+ gPlayerAvatar.acroBikeState = ACRO_STATE_WHEELIE_STANDING;
+ gPlayerAvatar.runningState = NOT_MOVING;
+ Bike_SetBikeStill();
+ return ACRO_TRANS_WHEELIE_IDLE;
+ }
+ if (direction != *newDirection && gPlayerAvatar.runningState != MOVING)
+ {
+ gPlayerAvatar.runningState = NOT_MOVING;
+ return ACRO_TRANS_WHEELIE_IDLE;
+ }
+ gPlayerAvatar.runningState = MOVING;
+ return ACRO_TRANS_WHEELIE_MOVING;
+}
+
+static u8 AcroBikeHandleInputSidewaysJump(u8 *ptr, u16 newKeys, u16 heldKeys)
+{
+ struct MapObject *playerMapObj = &gMapObjects[gPlayerAvatar.mapObjectId];
+
+ playerMapObj->mapobj_bit_9 = 0;
+ FieldObjectSetDirection(playerMapObj, playerMapObj->mapobj_unk_18);
+ gPlayerAvatar.acroBikeState = ACRO_STATE_NORMAL;
+ return CheckMovementInputAcroBike(ptr, newKeys, heldKeys);
+}
+
+static u8 AcroBikeHandleInputTurnJump(u8 *ptr, u16 newKeys, u16 heldKeys)
+{
+ gPlayerAvatar.acroBikeState = ACRO_STATE_NORMAL;
+ return CheckMovementInputAcroBike(ptr, newKeys, heldKeys);
+}
+
+static void AcroBikeTransition_FaceDirection(u8 direction)
+{
+ PlayerFaceDirection(direction);
+}
+
+static void AcroBikeTransition_TurnDirection(u8 direction)
+{
+ struct MapObject *playerMapObj = &gMapObjects[gPlayerAvatar.mapObjectId];
+
+ if (CanBikeFaceDirOnMetatile(direction, playerMapObj->mapobj_unk_1E) == 0)
+ direction = playerMapObj->placeholder18;
+ PlayerFaceDirection(direction);
+}
+
+static void AcroBikeTransition_Moving(u8 direction)
+{
+ u8 collision;
+ struct MapObject *playerMapObj = &gMapObjects[gPlayerAvatar.mapObjectId];
+
+ if (CanBikeFaceDirOnMetatile(direction, playerMapObj->mapobj_unk_1E) == 0)
+ {
+ AcroBikeTransition_FaceDirection(playerMapObj->placeholder18);
+ return;
+ }
+ collision = get_some_collision(direction);
+ if (collision > 0 && collision < 12)
+ {
+ if (collision == COLLISION_LEDGE_JUMP)
+ PlayerJumpLedge(direction);
+ else if (collision == 4 && IsPlayerCollidingWithFarawayIslandMew(direction))
+ PlayerOnBikeCollideWithFarawayIslandMew(direction);
+ else if (collision < 5 || collision > 8)
+ PlayerOnBikeCollide(direction);
+ }
+ else
+ {
+ PlayerGoSpeed3(direction);
+ }
+}
+
+static void AcroBikeTransition_NormalToWheelie(u8 direction)
+{
+ struct MapObject *playerMapObj = &gMapObjects[gPlayerAvatar.mapObjectId];
+
+ if (CanBikeFaceDirOnMetatile(direction, playerMapObj->mapobj_unk_1E) == 0)
+ direction = playerMapObj->placeholder18;
+ PlayerStartWheelie(direction);
+}
+
+static void AcroBikeTransition_WheelieToNormal(u8 direction)
+{
+ struct MapObject *playerMapObj = &gMapObjects[gPlayerAvatar.mapObjectId];
+
+ if (CanBikeFaceDirOnMetatile(direction, playerMapObj->mapobj_unk_1E) == 0)
+ direction = playerMapObj->placeholder18;
+ PlayerEndWheelie(direction);
+}
+
+static void AcroBikeTransition_WheelieIdle(u8 direction)
+{
+ struct MapObject *playerMapObj = &gMapObjects[gPlayerAvatar.mapObjectId];
+
+ if (CanBikeFaceDirOnMetatile(direction, playerMapObj->mapobj_unk_1E) == 0)
+ direction = playerMapObj->placeholder18;
+ PlayerIdleWheelie(direction);
+}
+
+static void AcroBikeTransition_WheelieHoppingStanding(u8 direction)
+{
+ struct MapObject *playerMapObj = &gMapObjects[gPlayerAvatar.mapObjectId];
+
+ if (CanBikeFaceDirOnMetatile(direction, playerMapObj->mapobj_unk_1E) == 0)
+ direction = playerMapObj->placeholder18;
+ PlayerStandingHoppingWheelie(direction);
+}
+
+static void AcroBikeTransition_WheelieHoppingMoving(u8 direction)
+{
+ u8 collision;
+ struct MapObject *playerMapObj = &gMapObjects[gPlayerAvatar.mapObjectId];
+
+ if (CanBikeFaceDirOnMetatile(direction, playerMapObj->mapobj_unk_1E) == 0)
+ {
+ AcroBikeTransition_WheelieHoppingStanding(playerMapObj->placeholder18);
+ return;
+ }
+ collision = get_some_collision(direction);
+ // TODO: Try to get rid of this goto
+ if (collision == 0 || collision == 9)
+ {
+ goto derp;
+ }
+ else if (collision == 6)
+ {
+ PlayerLedgeHoppingWheelie(direction);
+ }
+ else if (collision < 5 || collision > 8)
+ {
+ if (collision <= 11)
+ {
+ AcroBikeTransition_WheelieHoppingStanding(direction);
+ }
+ else
+ {
+ derp:
+ PlayerMovingHoppingWheelie(direction);
+ }
+ }
+}
+
+static void AcroBikeTransition_SideJump(u8 direction)
+{
+ u8 collision;
+ struct MapObject *playerMapObj;
+
+ collision = get_some_collision(direction);
+ if (collision != 0)
+ {
+ if (collision == 7)
+ return;
+ if (collision < 10)
+ {
+ AcroBikeTransition_TurnDirection(direction);
+ return;
+ }
+ if (WillPlayerCollideWithCollision(collision, direction) == FALSE)
+ {
+ AcroBikeTransition_TurnDirection(direction);
+ return;
+ }
+ }
+ playerMapObj = &gMapObjects[gPlayerAvatar.mapObjectId];
+ PlaySE(SE_JITE_PYOKO);
+ playerMapObj->mapobj_bit_9 = 1;
+ PlayerSetAnimId(sub_8093514(direction), 2);
+}
+
+static void AcroBikeTransition_TurnJump(u8 direction)
+{
+ PlayerAcroTurnJump(direction);
+}
+
+static void AcroBikeTransition_WheelieMoving(u8 direction)
+{
+ u8 collision;
+ struct MapObject *playerMapObj = &gMapObjects[gPlayerAvatar.mapObjectId];
+
+ if (CanBikeFaceDirOnMetatile(direction, playerMapObj->mapobj_unk_1E) == 0)
+ {
+ PlayerIdleWheelie(playerMapObj->placeholder18);
+ return;
+ }
+ collision = get_some_collision(direction);
+ if (collision > 0 && collision < 12)
+ {
+ if (collision == 6)
+ {
+ PlayerLedgeHoppingWheelie(direction);
+ }
+ else if (collision == 9)
+ {
+ PlayerIdleWheelie(direction);
+ }
+ else if (collision <= 4)
+ {
+ if (MetatileBehavior_IsBumpySlope(playerMapObj->mapobj_unk_1E))
+ PlayerIdleWheelie(direction);
+ else
+ sub_808B980(direction); //hit wall?
+ }
+ return;
+ }
+ sub_808B9BC(direction);
+ gPlayerAvatar.runningState = MOVING;
+}
+
+static void AcroBikeTransition_WheelieRisingMoving(u8 direction)
+{
+ u8 collision;
+ struct MapObject *playerMapObj = &gMapObjects[gPlayerAvatar.mapObjectId];
+
+ if (CanBikeFaceDirOnMetatile(direction, playerMapObj->mapobj_unk_1E) == 0)
+ {
+ PlayerStartWheelie(playerMapObj->placeholder18);
+ return;
+ }
+ collision = get_some_collision(direction);
+ if (collision > 0 && collision < 12)
+ {
+ if (collision == 6)
+ {
+ PlayerLedgeHoppingWheelie(direction);
+ }
+ else if (collision == 9)
+ {
+ PlayerIdleWheelie(direction);
+ }
+ else if (collision <= 4)
+ {
+ if (MetatileBehavior_IsBumpySlope(playerMapObj->mapobj_unk_1E))
+ PlayerIdleWheelie(direction);
+ else
+ sub_808B980(direction); //hit wall?
+ }
+ return;
+ }
+ sub_808B9A4(direction);
+ gPlayerAvatar.runningState = MOVING;
+}
+
+static void AcroBikeTransition_WheelieLoweringMoving(u8 direction)
+{
+ u8 collision;
+ struct MapObject *playerMapObj = &gMapObjects[gPlayerAvatar.mapObjectId];
+
+ if (CanBikeFaceDirOnMetatile(direction, playerMapObj->mapobj_unk_1E) == 0)
+ {
+ PlayerEndWheelie(playerMapObj->placeholder18);
+ return;
+ }
+ collision = get_some_collision(direction);
+ if (collision > 0 && collision < 12)
+ {
+ if (collision == 6)
+ PlayerJumpLedge(direction);
+ else if (collision < 5 || collision > 8)
+ PlayerEndWheelie(direction);
+ return;
+ }
+ npc_use_some_d2s(direction);
+}
+
+void Bike_TryAcroBikeHistoryUpdate(u16 newKeys, u16 heldKeys)
+{
+ if (gPlayerAvatar.flags & PLAYER_AVATAR_FLAG_ACRO_BIKE)
+ AcroBike_TryHistoryUpdate(newKeys, heldKeys);
+}
+
+static void AcroBike_TryHistoryUpdate(u16 newKeys, u16 heldKeys) // newKeys is unused
+{
+ u8 direction = Bike_DPadToDirection(heldKeys);
+
+ if (direction == (gPlayerAvatar.directionHistory & 0xF))
+ {
+ // increment the timer for direction history since last input.
+ if (gPlayerAvatar.dirTimerHistory[0] < 0xFF)
+ gPlayerAvatar.dirTimerHistory[0]++;
+ }
+ else
+ {
+ Bike_UpdateDirTimerHistory(direction);
+ gPlayerAvatar.bikeSpeed = SPEED_STANDING;
+ }
+
+ direction = heldKeys & (A_BUTTON | B_BUTTON | SELECT_BUTTON | START_BUTTON); // directions is reused for some reason.
+ if (direction == (gPlayerAvatar.abStartSelectHistory & 0xF))
+ {
+ if (gPlayerAvatar.abStartSelectTimerHistory[0] < 0xFF)
+ gPlayerAvatar.abStartSelectTimerHistory[0]++;
+ }
+ else
+ {
+ Bike_UpdateABStartSelectHistory(direction);
+ gPlayerAvatar.bikeSpeed = SPEED_STANDING;
+ }
+}
+
+static bool8 HasPlayerInputTakenLongerThanList(const u8 *dirTimerList, const u8 *abStartSelectTimerList)
+{
+ u8 i;
+
+ for (i = 0; dirTimerList[i] != 0; i++)
+ {
+ if (gPlayerAvatar.dirTimerHistory[i] > dirTimerList[i])
+ return FALSE;
+ }
+ for (i = 0; abStartSelectTimerList[i] != 0; i++)
+ {
+ if (gPlayerAvatar.abStartSelectTimerHistory[i] > abStartSelectTimerList[i])
+ return FALSE;
+ }
+ return TRUE;
+}
+
+static u8 AcroBike_GetJumpDirection(void)
+{
+ u32 i;
+
+ for (i = 0; i < ARRAY_COUNT(sAcroBikeTricksList); i++)
+ {
+ const struct BikeHistoryInputInfo *historyInputInfo = &sAcroBikeTricksList[i];
+ u32 dirHistory = gPlayerAvatar.directionHistory;
+ u32 abStartSelectHistory = gPlayerAvatar.abStartSelectHistory;
+
+ dirHistory &= historyInputInfo->dirHistoryMask;
+ abStartSelectHistory &= historyInputInfo->abStartSelectHistoryMask;
+ if (dirHistory == historyInputInfo->dirHistoryMatch && abStartSelectHistory == historyInputInfo->abStartSelectHistoryMatch && HasPlayerInputTakenLongerThanList(historyInputInfo->dirTimerHistoryList, historyInputInfo->abStartSelectHistoryList))
+ return historyInputInfo->direction;
+ }
+ return 0;
+}
+
+static void Bike_UpdateDirTimerHistory(u8 dir)
+{
+ u8 i;
+
+ gPlayerAvatar.directionHistory = (gPlayerAvatar.directionHistory << 4) | (dir & 0xF);
+
+ for (i = 7; i != 0; i--)
+ gPlayerAvatar.dirTimerHistory[i] = gPlayerAvatar.dirTimerHistory[i - 1];
+ gPlayerAvatar.dirTimerHistory[0] = 1;
+}
+
+static void Bike_UpdateABStartSelectHistory(u8 input)
+{
+ u8 i;
+
+ gPlayerAvatar.abStartSelectHistory = (gPlayerAvatar.abStartSelectHistory << 4) | (input & 0xF);
+
+ for (i = 7; i != 0; i--)
+ gPlayerAvatar.abStartSelectTimerHistory[i] = gPlayerAvatar.abStartSelectTimerHistory[i - 1];
+ gPlayerAvatar.abStartSelectTimerHistory[0] = 1;
+}
+
+static u8 Bike_DPadToDirection(u16 heldKeys)
+{
+ if (heldKeys & DPAD_UP)
+ return DIR_NORTH;
+ if (heldKeys & DPAD_DOWN)
+ return DIR_SOUTH;
+ if (heldKeys & DPAD_LEFT)
+ return DIR_WEST;
+ if (heldKeys & DPAD_RIGHT)
+ return DIR_EAST;
+ return DIR_NONE;
+}
+
+static u8 get_some_collision(u8 direction)
+{
+ s16 x;
+ s16 y;
+ u8 metatitleBehavior;
+ struct MapObject *playerMapObj = &gMapObjects[gPlayerAvatar.mapObjectId];
+
+ x = playerMapObj->coords2.x;
+ y = playerMapObj->coords2.y;
+ MoveCoords(direction, &x, &y);
+ metatitleBehavior = MapGridGetMetatileBehaviorAt(x, y);
+ return Bike_CheckCollisionTryAdvanceCollisionCount(playerMapObj, x, y, direction, metatitleBehavior);
+}
+
+static u8 Bike_CheckCollisionTryAdvanceCollisionCount(struct MapObject *mapObject, s16 x, s16 y, u8 direction, u8 metatitleBehavior)
+{
+ u8 collision = CheckForFieldObjectCollision(mapObject, x, y, direction, metatitleBehavior);
+
+ if (collision > 4)
+ return collision;
+
+ if (collision == 0 && IsRunningDisallowedByMetatile(metatitleBehavior))
+ collision = 2;
+
+ if (collision)
+ Bike_TryAdvanceCyclingRoadCollisions();
+
+ return collision;
+}
+
+bool8 RS_IsRunningDisallowed(u8 tile)
+{
+ if (IsRunningDisallowedByMetatile(tile) != FALSE || gMapHeader.mapType == MAP_TYPE_INDOOR)
+ return TRUE;
+ else
+ return FALSE;
+}
+
+static bool8 IsRunningDisallowedByMetatile(u8 tile)
+{
+ if (MetatileBehavior_IsRunningDisallowed(tile))
+ return TRUE;
+ if (MetatileBehavior_IsFortreeBridge(tile) && (PlayerGetZCoord() & 1) == 0)
+ return TRUE;
+ return FALSE;
+}
+
+static void Bike_TryAdvanceCyclingRoadCollisions(void)
+{
+ if (gBikeCyclingChallenge != FALSE && gBikeCollisions < 100)
+ gBikeCollisions++;
+}
+
+static bool8 CanBikeFaceDirOnMetatile(u8 direction, u8 tile)
+{
+ if (direction == DIR_EAST || direction == DIR_WEST)
+ {
+ // Bike cannot face east or west on a vertical rail
+ if (MetatileBehavior_IsIsolatedVerticalRail(tile)
+ || MetatileBehavior_IsVerticalRail(tile))
+ return FALSE;
+ }
+ else
+ {
+ // Bike cannot face north or south on a horizontal rail
+ if (MetatileBehavior_IsIsolatedHorizontalRail(tile)
+ || MetatileBehavior_IsHorizontalRail(tile))
+ return FALSE;
+ }
+ return TRUE;
+}
+
+static bool8 WillPlayerCollideWithCollision(u8 newTileCollision, u8 direction)
+{
+ if (direction == DIR_NORTH || direction == DIR_SOUTH)
+ {
+ if (newTileCollision == 10 || newTileCollision == 12)
+ return FALSE;
+ }
+ else if (newTileCollision == 11 || newTileCollision == 13)
+ {
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+bool8 IsBikingDisallowedByPlayer(void)
+{
+ s16 x, y;
+ u8 tileBehavior;
+
+ if (!(gPlayerAvatar.flags & (PLAYER_AVATAR_FLAG_SURFING | PLAYER_AVATAR_FLAG_4)))
+ {
+ PlayerGetDestCoords(&x, &y);
+ tileBehavior = MapGridGetMetatileBehaviorAt(x, y);
+ if (!IsRunningDisallowedByMetatile(tileBehavior))
+ return FALSE;
+ }
+ return TRUE;
+}
+
+bool8 player_should_look_direction_be_enforced_upon_movement(void)
+{
+ if (TestPlayerAvatarFlags(PLAYER_AVATAR_FLAG_ACRO_BIKE) != FALSE && MetatileBehavior_IsBumpySlope(gMapObjects[gPlayerAvatar.mapObjectId].mapobj_unk_1E) != FALSE)
+ return FALSE;
+ else
+ return TRUE;
+}
+
+void GetOnOffBike(u8 transitionFlags)
+{
+ gUnknown_02037348 = FALSE;
+
+ if (gPlayerAvatar.flags & (PLAYER_AVATAR_FLAG_MACH_BIKE | PLAYER_AVATAR_FLAG_ACRO_BIKE))
+ {
+ SetPlayerAvatarTransitionFlags(PLAYER_AVATAR_FLAG_ON_FOOT);
+ Overworld_ClearSavedMusic();
+ Overworld_PlaySpecialMapMusic();
+ }
+ else
+ {
+ SetPlayerAvatarTransitionFlags(transitionFlags);
+ Overworld_SetSavedMusic(MUS_CYCLING);
+ Overworld_ChangeMusicTo(MUS_CYCLING);
+ }
+}
+
+void BikeClearState(int newDirHistory, int newAbStartHistory)
+{
+ u8 i;
+
+ gPlayerAvatar.acroBikeState = ACRO_STATE_NORMAL;
+ gPlayerAvatar.newDirBackup = DIR_NONE;
+ gPlayerAvatar.bikeFrameCounter = 0;
+ gPlayerAvatar.bikeSpeed = SPEED_STANDING;
+ gPlayerAvatar.directionHistory = newDirHistory;
+ gPlayerAvatar.abStartSelectHistory = newAbStartHistory;
+
+ for (i = 0; i < 8; i++)
+ gPlayerAvatar.dirTimerHistory[i] = 0;
+
+ for (i = 0; i < 8; i++)
+ gPlayerAvatar.abStartSelectTimerHistory[i] = 0;
+}
+
+void Bike_UpdateBikeCounterSpeed(u8 counter)
+{
+ gPlayerAvatar.bikeFrameCounter = counter;
+ gPlayerAvatar.bikeSpeed = gPlayerAvatar.bikeFrameCounter + (gPlayerAvatar.bikeFrameCounter >> 1); // lazy way of multiplying by 1.5.
+}
+
+static void Bike_SetBikeStill(void)
+{
+ gPlayerAvatar.bikeFrameCounter = 0;
+ gPlayerAvatar.bikeSpeed = SPEED_STANDING;
+}
+
+s16 GetPlayerSpeed(void)
+{
+ // because the player pressed a direction, it won't ever return a speed of 0 since this function returns the player's current speed.
+ s16 machSpeeds[3];
+
+ memcpy(machSpeeds, sMachBikeSpeeds, sizeof(machSpeeds));
+
+ if (gPlayerAvatar.flags & PLAYER_AVATAR_FLAG_MACH_BIKE)
+ return machSpeeds[gPlayerAvatar.bikeFrameCounter];
+ else if (gPlayerAvatar.flags & PLAYER_AVATAR_FLAG_ACRO_BIKE)
+ return SPEED_FASTER;
+ else if (gPlayerAvatar.flags & (PLAYER_AVATAR_FLAG_SURFING | PLAYER_AVATAR_FLAG_DASH))
+ return SPEED_FAST;
+ else
+ return SPEED_NORMAL;
+}
+
+void Bike_HandleBumpySlopeJump(void)
+{
+ s16 x, y;
+ u8 tileBehavior;
+
+ if (gPlayerAvatar.flags & PLAYER_AVATAR_FLAG_ACRO_BIKE)
+ {
+ PlayerGetDestCoords(&x, &y);
+ tileBehavior = MapGridGetMetatileBehaviorAt(x, y);
+ if (MetatileBehavior_IsBumpySlope(tileBehavior))
+ {
+ gPlayerAvatar.acroBikeState = ACRO_STATE_WHEELIE_STANDING;
+ sub_808C1B4(player_get_direction_upper_nybble());
+ }
+ }
+}
+
+bool32 IsRunningDisallowed(u8 metatile)
+{
+ if (!(gMapHeader.flags & 4) || IsRunningDisallowedByMetatile(metatile) == TRUE)
+ return TRUE;
+ else
+ return FALSE;
+}
diff --git a/src/dma3_manager.c b/src/dma3_manager.c
index bb015c5cf..725bfb0e7 100644
--- a/src/dma3_manager.c
+++ b/src/dma3_manager.c
@@ -29,76 +29,92 @@ void ClearDma3Requests(void)
gDma3ManagerLocked = FALSE;
}
-#ifdef NONMATCHING
+// Maximum amount of data will will transfer in one operation
+#define DMA_MAX_BLOCK_SIZE 0x1000
+
+#define Dma3CopyLarge_(src, dest, size, bit) \
+{ \
+ const void *_src = src; \
+ void *_dest = dest; \
+ u32 _size = size; \
+ while (1) \
+ { \
+ if (_size <= DMA_MAX_BLOCK_SIZE) \
+ { \
+ DmaCopy##bit(3, _src, _dest, _size); \
+ break; \
+ } \
+ DmaCopy##bit(3, _src, _dest, DMA_MAX_BLOCK_SIZE); \
+ _src += DMA_MAX_BLOCK_SIZE; \
+ _dest += DMA_MAX_BLOCK_SIZE; \
+ _size -= DMA_MAX_BLOCK_SIZE; \
+ } \
+}
+
+#define Dma3CopyLarge16_(src, dest, size) Dma3CopyLarge_(src, dest, size, 16)
+#define Dma3CopyLarge32_(src, dest, size) Dma3CopyLarge_(src, dest, size, 32)
+
+#define Dma3FillLarge_(value, dest, size, bit) \
+{ \
+ void *_dest = dest; \
+ u32 _size = size; \
+ while (1) \
+ { \
+ if (_size <= DMA_MAX_BLOCK_SIZE) \
+ { \
+ DmaFill##bit(3, value, _dest, _size); \
+ break; \
+ } \
+ DmaFill##bit(3, value, _dest, DMA_MAX_BLOCK_SIZE); \
+ _dest += DMA_MAX_BLOCK_SIZE; \
+ _size -= DMA_MAX_BLOCK_SIZE; \
+ } \
+}
+
+#define Dma3FillLarge16_(value, dest, size) Dma3FillLarge_(value, dest, size, 16)
+#define Dma3FillLarge32_(value, dest, size) Dma3FillLarge_(value, dest, size, 32)
+
+
void ProcessDma3Requests(void)
{
- // NOTE: the fillerA member of the DMA struct is actually u32 value;
- u16 total_size;
+ u16 totalSize;
if (gDma3ManagerLocked)
return;
- total_size = 0;
+ totalSize = 0;
// as long as there are DMA requests to process (unless size or vblank is an issue), do not exit
- while (gDma3Requests[gDma3RequestCursor].size)
+ while (gDma3Requests[gDma3RequestCursor].size != 0)
{
- total_size += gDma3Requests[gDma3RequestCursor].size;
+ totalSize += gDma3Requests[gDma3RequestCursor].size;
- if (total_size > 0xA000)
+ if (totalSize > 0xA000)
return; // don't do too much at once
-
- if (REG_VCOUNT > 224)
- return;// we're about to leave vblank, stop
+ if (*(u8 *)REG_ADDR_VCOUNT > 224)
+ return; // we're about to leave vblank, stop
switch (gDma3Requests[gDma3RequestCursor].mode)
{
case 1: // regular 32-bit copy
- // _08000C8C
- if(gDma3Requests[gDma3RequestCursor].size <= 0x1000)
- {
- DmaCopy32(3, gDma3Requests[gDma3RequestCursor].src, gDma3Requests[gDma3RequestCursor].dest, gDma3Requests[gDma3RequestCursor].size);
- break;
- }
- while (gDma3Requests[gDma3RequestCursor].size > 0x1000)
- {
- DmaCopy32(3, gDma3Requests[gDma3RequestCursor].src, gDma3Requests[gDma3RequestCursor].dest, 0x1000);
- gDma3Requests[gDma3RequestCursor].src += 0x1000;
- gDma3Requests[gDma3RequestCursor].dest += 0x1000;
- gDma3Requests[gDma3RequestCursor].size -= 0x1000;
- }
- DmaCopy32(3, gDma3Requests[gDma3RequestCursor].src, gDma3Requests[gDma3RequestCursor].dest, gDma3Requests[gDma3RequestCursor].size);
+ Dma3CopyLarge32_(gDma3Requests[gDma3RequestCursor].src,
+ gDma3Requests[gDma3RequestCursor].dest,
+ gDma3Requests[gDma3RequestCursor].size);
break;
case 2: // repeat a single 32-bit value across RAM
- // _08000CD0
- while (gDma3Requests[gDma3RequestCursor].size > 0x1000)
- {
- DmaFill32(3, gDma3Requests[gDma3RequestCursor].value, gDma3Requests[gDma3RequestCursor].dest, 0x1000);
- gDma3Requests[gDma3RequestCursor].dest += 0x1000;
- gDma3Requests[gDma3RequestCursor].size -= 0x1000;
- }
- DmaFill32(3, gDma3Requests[gDma3RequestCursor].value, gDma3Requests[gDma3RequestCursor].dest, gDma3Requests[gDma3RequestCursor].size);
+ Dma3FillLarge32_(gDma3Requests[gDma3RequestCursor].value,
+ gDma3Requests[gDma3RequestCursor].dest,
+ gDma3Requests[gDma3RequestCursor].size);
break;
case 3: // regular 16-bit copy
- // _08000D3C
- while (gDma3Requests[gDma3RequestCursor].size > 0x1000)
- {
- DmaCopy16(3, gDma3Requests[gDma3RequestCursor].src, gDma3Requests[gDma3RequestCursor].dest, 0x1000);
- gDma3Requests[gDma3RequestCursor].src += 0x1000;
- gDma3Requests[gDma3RequestCursor].dest += 0x1000;
- gDma3Requests[gDma3RequestCursor].size -= 0x1000;
- }
- DmaCopy16(3, gDma3Requests[gDma3RequestCursor].src, gDma3Requests[gDma3RequestCursor].dest, gDma3Requests[gDma3RequestCursor].size);
+ Dma3CopyLarge16_(gDma3Requests[gDma3RequestCursor].src,
+ gDma3Requests[gDma3RequestCursor].dest,
+ gDma3Requests[gDma3RequestCursor].size);
break;
case 4: // repeat a single 16-bit value across RAM
- // _08000D88
- while (gDma3Requests[gDma3RequestCursor].size > 0x1000)
- {
- DmaFill16(3, gDma3Requests[gDma3RequestCursor].value, gDma3Requests[gDma3RequestCursor].dest, 0x1000);
- gDma3Requests[gDma3RequestCursor].dest += 0x1000;
- gDma3Requests[gDma3RequestCursor].size -= 0x1000;
- }
- DmaFill16(3, gDma3Requests[gDma3RequestCursor].value, gDma3Requests[gDma3RequestCursor].dest, gDma3Requests[gDma3RequestCursor].size);
+ Dma3FillLarge16_(gDma3Requests[gDma3RequestCursor].value,
+ gDma3Requests[gDma3RequestCursor].dest,
+ gDma3Requests[gDma3RequestCursor].size);
break;
}
gDma3Requests[gDma3RequestCursor].src = NULL;
@@ -112,322 +128,6 @@ void ProcessDma3Requests(void)
gDma3RequestCursor = 0;
}
}
-#else
-__attribute__((naked))
-void ProcessDma3Requests(void)
-{
- asm(".syntax unified\n\
- push {r4-r7,lr}\n\
- mov r7, r10\n\
- mov r6, r9\n\
- mov r5, r8\n\
- push {r5-r7}\n\
- sub sp, 0xC\n\
- ldr r0, =gDma3ManagerLocked\n\
- ldrb r0, [r0]\n\
- cmp r0, 0\n\
- beq _08000C06\n\
- b _08000E46\n\
-_08000C06:\n\
- movs r0, 0\n\
- str r0, [sp, 0x8]\n\
- ldr r1, =gDma3Requests\n\
- ldr r2, =gDma3RequestCursor\n\
- ldrb r0, [r2]\n\
- lsls r0, 4\n\
- adds r0, r1\n\
- ldrh r0, [r0, 0x8]\n\
- mov r12, r2\n\
- cmp r0, 0\n\
- bne _08000C1E\n\
- b _08000E46\n\
-_08000C1E:\n\
- mov r8, r1\n\
- adds r1, 0x4\n\
- mov r10, r1\n\
- movs r6, 0x80\n\
- lsls r6, 5\n\
- ldr r7, =0x040000D4 @REG_DMA3\n\
- movs r2, 0\n\
- mov r9, r2\n\
-_08000C2E:\n\
- mov r3, r12 @ gDma3RequestCursor\n\
- ldrb r0, [r3]\n\
- lsls r5, r0, 4\n\
- mov r0, r8 @ gDma3Requests\n\
- adds r1, r5, r0 @ gDma3Requests[gDma3RequestCursor]\n\
- ldrh r0, [r1, 0x8] @ gDma3Requests[gDma3RequestCursor].size\n\
- ldr r2, [sp, 0x8]\n\
- adds r0, r2, r0\n\
- lsls r0, 16\n\
- lsrs r0, 16\n\
- str r0, [sp, 0x8]\n\
- movs r0, 0xA0\n\
- lsls r0, 8\n\
- ldr r3, [sp, 0x8]\n\
- cmp r3, r0\n\
- bls _08000C50\n\
- b _08000E46\n\
-_08000C50:\n\
- ldr r0, =0x04000006 @REG_VCOUNT\n\
- ldrb r0, [r0]\n\
- cmp r0, 0xE0\n\
- bls _08000C5A\n\
- b _08000E46\n\
-_08000C5A:\n\
- ldrh r0, [r1, 0xA]\n\
- cmp r0, 0x2\n\
- beq _08000CD0\n\
- cmp r0, 0x2\n\
- bgt _08000C80\n\
- cmp r0, 0x1\n\
- beq _08000C8C\n\
- b _08000DF0\n\
- .pool\n\
-_08000C80:\n\
- cmp r0, 0x3\n\
- beq _08000D3C\n\
- cmp r0, 0x4\n\
- bne _08000C8A\n\
- b _08000D88\n\
-_08000C8A:\n\
- b _08000DF0\n\
-_08000C8C:\n\
- ldr r3, [r1]\n\
- mov r2, r10\n\
- adds r0, r5, r2\n\
- ldr r2, [r0]\n\
- ldrh r1, [r1, 0x8]\n\
- cmp r1, r6\n\
- bhi _08000CA6\n\
- str r3, [r7]\n\
- str r2, [r7, 0x4]\n\
- lsrs r0, r1, 2\n\
- movs r1, 0x84\n\
- lsls r1, 24\n\
- b _08000DAA\n\
-_08000CA6:\n\
- ldr r4, =0x040000D4 @REG_DMA3\n\
- str r3, [r4]\n\
- str r2, [r4, 0x4]\n\
- ldr r0, =0x84000400\n\
- str r0, [r4, 0x8]\n\
- ldr r0, [r4, 0x8]\n\
- adds r3, r6\n\
- adds r2, r6\n\
- subs r1, r6\n\
- cmp r1, r6\n\
- bhi _08000CA6\n\
- str r3, [r4]\n\
- str r2, [r4, 0x4]\n\
- lsrs r0, r1, 2\n\
- movs r1, 0x84\n\
- lsls r1, 24\n\
- b _08000D76\n\
- .pool\n\
-_08000CD0:\n\
- mov r3, r10\n\
- adds r0, r5, r3\n\
- ldr r4, [r0]\n\
- ldrh r1, [r1, 0x8]\n\
- cmp r1, r6\n\
- bhi _08000CF4\n\
- mov r0, r8\n\
- adds r0, 0xC\n\
- adds r0, r5, r0\n\
- ldr r0, [r0]\n\
- str r0, [sp]\n\
- mov r5, sp\n\
- str r5, [r7]\n\
- str r4, [r7, 0x4]\n\
- lsrs r0, r1, 2\n\
- movs r1, 0x85\n\
- lsls r1, 24\n\
- b _08000DAA\n\
-_08000CF4:\n\
- mov r2, r12\n\
- ldrb r0, [r2]\n\
- lsls r0, 4\n\
- mov r5, r8\n\
- adds r5, 0xC\n\
- adds r0, r5\n\
- ldr r0, [r0]\n\
- str r0, [sp]\n\
- ldr r3, =0x040000D4 @REG_DMA3\n\
- mov r0, sp\n\
- str r0, [r3]\n\
- str r4, [r3, 0x4]\n\
- ldr r0, =0x85000400\n\
- str r0, [r3, 0x8]\n\
- ldr r0, [r3, 0x8]\n\
- adds r4, r6\n\
- subs r1, r6\n\
- cmp r1, r6\n\
- bhi _08000CF4\n\
- ldrb r0, [r2]\n\
- lsls r0, 4\n\
- adds r0, r5\n\
- ldr r0, [r0]\n\
- str r0, [sp]\n\
- mov r2, sp\n\
- str r2, [r3]\n\
- str r4, [r3, 0x4]\n\
- lsrs r0, r1, 2\n\
- movs r1, 0x85\n\
- lsls r1, 24\n\
- b _08000DEA\n\
- .pool\n\
-_08000D3C:\n\
- ldr r3, [r1]\n\
- mov r2, r10\n\
- adds r0, r5, r2\n\
- ldr r2, [r0]\n\
- ldrh r1, [r1, 0x8]\n\
- cmp r1, r6\n\
- bhi _08000D56\n\
- str r3, [r7]\n\
- str r2, [r7, 0x4]\n\
- lsrs r0, r1, 1\n\
- movs r1, 0x80\n\
- lsls r1, 24\n\
- b _08000DAA\n\
-_08000D56:\n\
- ldr r4, =0x040000D4 @REG_DMA3\n\
- str r3, [r4]\n\
- str r2, [r4, 0x4]\n\
- ldr r0, =0x80000800\n\
- str r0, [r4, 0x8]\n\
- ldr r0, [r4, 0x8]\n\
- adds r3, r6\n\
- adds r2, r6\n\
- subs r1, r6\n\
- cmp r1, r6\n\
- bhi _08000D56\n\
- str r3, [r4]\n\
- str r2, [r4, 0x4]\n\
- lsrs r0, r1, 1\n\
- movs r1, 0x80\n\
- lsls r1, 24\n\
-_08000D76:\n\
- orrs r0, r1\n\
- str r0, [r4, 0x8]\n\
- ldr r0, [r4, 0x8]\n\
- b _08000DF0\n\
- .pool\n\
-_08000D88:\n\
- mov r3, r10\n\
- adds r0, r5, r3\n\
- ldr r2, [r0]\n\
- ldrh r4, [r1, 0x8]\n\
- add r1, sp, 0x4\n\
- cmp r4, r6\n\
- bhi _08000DB2\n\
- mov r0, r8\n\
- adds r0, 0xC\n\
- adds r0, r5, r0\n\
- ldr r0, [r0]\n\
- strh r0, [r1]\n\
- str r1, [r7]\n\
- str r2, [r7, 0x4]\n\
- lsrs r0, r4, 1\n\
- movs r1, 0x81\n\
- lsls r1, 24\n\
-_08000DAA:\n\
- orrs r0, r1\n\
- str r0, [r7, 0x8]\n\
- ldr r0, [r7, 0x8]\n\
- b _08000DF0\n\
-_08000DB2:\n\
- mov r5, r12\n\
- ldrb r0, [r5]\n\
- lsls r0, 4\n\
- ldr r3, =gDma3Requests + 0x0C\n\
- adds r0, r3\n\
- ldr r0, [r0]\n\
- strh r0, [r1]\n\
- ldr r3, =0x040000D4 @REG_DMA3\n\
- str r1, [r3]\n\
- str r2, [r3, 0x4]\n\
- ldr r0, =0x81000800\n\
- str r0, [r3, 0x8]\n\
- ldr r0, [r3, 0x8]\n\
- adds r2, r6\n\
- subs r4, r6\n\
- cmp r4, r6\n\
- bhi _08000DB2\n\
- ldrb r0, [r5]\n\
- lsls r0, 4\n\
- ldr r5, =gDma3Requests + 0x0C\n\
- adds r0, r5\n\
- ldr r0, [r0]\n\
- strh r0, [r1]\n\
- str r1, [r3]\n\
- str r2, [r3, 0x4]\n\
- lsrs r0, r4, 1\n\
- movs r1, 0x81\n\
- lsls r1, 24\n\
-_08000DEA:\n\
- orrs r0, r1\n\
- str r0, [r3, 0x8]\n\
- ldr r0, [r3, 0x8]\n\
-_08000DF0:\n\
- ldr r1, =gDma3Requests\n\
- mov r3, r12\n\
- ldrb r0, [r3]\n\
- lsls r0, 4\n\
- adds r0, r1\n\
- mov r2, r9\n\
- str r2, [r0]\n\
- ldrb r0, [r3]\n\
- lsls r0, 4\n\
- add r0, r10\n\
- str r2, [r0]\n\
- ldrb r0, [r3]\n\
- lsls r0, 4\n\
- adds r0, r1\n\
- movs r4, 0\n\
- strh r2, [r0, 0x8]\n\
- ldrb r0, [r3]\n\
- lsls r0, 4\n\
- adds r0, r1\n\
- mov r5, r9\n\
- strh r5, [r0, 0xA]\n\
- ldrb r0, [r3]\n\
- lsls r0, 4\n\
- adds r1, 0xC\n\
- adds r0, r1\n\
- mov r1, r9\n\
- str r1, [r0]\n\
- ldrb r0, [r3]\n\
- adds r0, 0x1\n\
- strb r0, [r3]\n\
- lsls r0, 24\n\
- cmp r0, 0\n\
- bge _08000E34\n\
- strb r4, [r3]\n\
-_08000E34:\n\
- mov r2, r12\n\
- ldrb r0, [r2]\n\
- lsls r0, 4\n\
- ldr r3, =gDma3Requests\n\
- adds r0, r3\n\
- ldrh r0, [r0, 0x8]\n\
- cmp r0, 0\n\
- beq _08000E46\n\
- b _08000C2E\n\
-_08000E46:\n\
- add sp, 0xC\n\
- pop {r3-r5}\n\
- mov r8, r3\n\
- mov r9, r4\n\
- mov r10, r5\n\
- pop {r4-r7}\n\
- pop {r0}\n\
- bx r0\n\
- .pool\n\
- .syntax divided");
-}
-#endif
int RequestDma3Copy(const void *src, void *dest, u16 size, u8 mode)
{
diff --git a/src/egg_hatch.c b/src/egg_hatch.c
index 721ba4a4f..1aff894b9 100644
--- a/src/egg_hatch.c
+++ b/src/egg_hatch.c
@@ -51,8 +51,8 @@ extern const struct CompressedSpriteSheet gMonFrontPicTable[];
extern const u8 gBattleTextboxTiles[];
extern const u8 gBattleTextboxTilemap[];
extern const u8 gBattleTextboxPalette[];
-extern const u16 gUnknown_08DD7300[]; // palette, gameboy advance
-extern const u32 gUnknown_08DD7360[]; // tileset gameboy advance
+extern const u16 gTradeGba2_Pal[]; // palette, gameboy advance
+extern const u32 gTradeGba_Gfx[]; // tileset gameboy advance
extern const u32 gUnknown_08331F60[]; // tilemap gameboy circle
extern const u8 gText_HatchedFromEgg[];
extern const u8 gText_NickHatchPrompt[];
@@ -548,8 +548,8 @@ static void CB2_EggHatch_0(void)
break;
case 7:
SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_OBJ_ON | DISPCNT_OBJ_1D_MAP);
- LoadPalette(gUnknown_08DD7300, 0x10, 0xA0);
- LoadBgTiles(1, gUnknown_08DD7360, 0x1420, 0);
+ LoadPalette(gTradeGba2_Pal, 0x10, 0xA0);
+ LoadBgTiles(1, gTradeGba_Gfx, 0x1420, 0);
CopyToBgTilemapBuffer(1, gUnknown_08331F60, 0x1000, 0);
CopyBgTilemapBufferToVram(1);
gMain.state++;
diff --git a/src/evolution_scene.c b/src/evolution_scene.c
index 580e88ad7..4b59147ff 100644
--- a/src/evolution_scene.c
+++ b/src/evolution_scene.c
@@ -78,7 +78,7 @@ extern void sub_806A068(u16, u8);
extern void sub_807F19C(void);
extern void sub_807B140(void);
extern void EvolutionRenameMon(struct Pokemon *mon, u16 oldSpecies, u16 newSpecies);
-extern void sub_8085784(void);
+extern void Overworld_PlaySpecialMapMusic(void);
extern void sub_81BFA38(struct Pokemon *party, u8 monId, u8 partyCount, void *CB2_ptr, u16 move);
extern u8 sub_81C1B94(void);
extern void sub_807F1A8(u8 arg0, const u8 *arg1, u8 arg2);
@@ -764,7 +764,7 @@ static void Task_EvolutionScene(u8 taskID)
if (!(gTasks[taskID].tBits & TASK_BIT_LEARN_MOVE))
{
StopMapMusic();
- sub_8085784();
+ Overworld_PlaySpecialMapMusic();
}
gTasks[taskID].tBits |= TASK_BIT_LEARN_MOVE;
@@ -793,7 +793,7 @@ static void Task_EvolutionScene(u8 taskID)
if (!(gTasks[taskID].tBits & TASK_BIT_LEARN_MOVE))
{
StopMapMusic();
- sub_8085784();
+ Overworld_PlaySpecialMapMusic();
}
if (!gTasks[taskID].tEvoWasStopped)
CreateShedinja(gTasks[taskID].tPreEvoSpecies, mon);
diff --git a/src/field_map_obj.c b/src/field_map_obj.c
index fc23a6e37..df80494b3 100755
--- a/src/field_map_obj.c
+++ b/src/field_map_obj.c
@@ -3231,7 +3231,7 @@ bool8 mss_npc_reset_oampriv3_1_unk2_unk3(struct MapObject *mapObject, struct Spr
bool8 sub_8091EC0(struct MapObject *mapObject, struct Sprite *sprite)
{
- if (gMapObjects[gPlayerAvatar.mapObjectId].mapobj_unk_1C == 0xFF || gPlayerAvatar.running1 == 2)
+ if (gMapObjects[gPlayerAvatar.mapObjectId].mapobj_unk_1C == 0xFF || gPlayerAvatar.tileTransitionState == 2)
{
return FALSE;
}
@@ -3410,7 +3410,7 @@ field_object_step(CopyPlayer2, gUnknown_0850DA90)
bool8 mss_08062EA4(struct MapObject *mapObject, struct Sprite *sprite)
{
- if (gMapObjects[gPlayerAvatar.mapObjectId].mapobj_unk_1C == 0xFF || gPlayerAvatar.running1 == 2)
+ if (gMapObjects[gPlayerAvatar.mapObjectId].mapobj_unk_1C == 0xFF || gPlayerAvatar.tileTransitionState == 2)
{
return FALSE;
}
diff --git a/src/fldeff_teleport.c b/src/fldeff_teleport.c
new file mode 100644
index 000000000..5b3492db0
--- /dev/null
+++ b/src/fldeff_teleport.c
@@ -0,0 +1,46 @@
+#include "global.h"
+#include "fldeff_teleport.h"
+#include "field_effect.h"
+#include "field_player_avatar.h"
+#include "party_menu.h"
+#include "overworld.h"
+#include "rom6.h"
+#include "task.h"
+
+extern bool8 (*gUnknown_03005DB0)(void);
+extern void (*gUnknown_0203CEEC)(void);
+
+bool8 SetUpFieldMove_Teleport(void)
+{
+ if (Overworld_MapTypeAllowsTeleportAndFly(gMapHeader.mapType) == TRUE)
+ {
+ gUnknown_03005DB0 = FieldCallback_Teleport;
+ gUnknown_0203CEEC = hm_teleport_run_dp02scr;
+ return TRUE;
+ }
+ return FALSE;
+}
+
+void hm_teleport_run_dp02scr(void)
+{
+ Overworld_ResetStateAfterTeleport();
+ FieldEffectStart(FLDEFF_USE_TELEPORT);
+ gFieldEffectArguments[0] = (u32)GetCursorSelectionMonId();
+}
+
+bool8 FldEff_UseTeleport(void)
+{
+ u8 taskId = oei_task_add();
+ gTasks[taskId].data[8] = (u32)sub_817C94C >> 16;
+ gTasks[taskId].data[9] = (u32)sub_817C94C;
+ SetPlayerAvatarTransitionFlags(1);
+ return FALSE;
+}
+
+void sub_817C94C(void)
+{
+ FieldEffectActiveListRemove(FLDEFF_USE_TELEPORT);
+ sub_80B7FC8();
+}
+
+
diff --git a/src/load_save.c b/src/load_save.c
index e0106c0a8..a516c08c2 100644
--- a/src/load_save.c
+++ b/src/load_save.c
@@ -80,45 +80,15 @@ void SetSaveBlocksPointers(u16 offset)
SetDecorationInventoriesPointers();
}
-// stuff i used to try and match MoveSaveBlocks_ResetHeap
-struct SaveBlocksInOne
-{
- struct SaveBlock2 sav2;
- struct SaveBlock1 sav1;
- struct PokemonStorage sav3;
-};
+extern u8 gHeap[];
-extern struct SaveBlocksInOne gHeap;
-
-#define ewram_addr 0x02000000 // oh no...
-#define ewram_addr2 0x02000f2c
-#define ewram_addr3 0x02004cb4
-
-#define eSaveBlockCopy (*(struct SaveBlocksInOne *)(ewram_addr + 0x0))
-#define eSaveBlock2Copy (*(struct SaveBlock2 *)((void*)(ewram_addr + 0x0)))
-#define eSaveBlock1Copy (*(struct SaveBlock1 *)((void*)(ewram_addr + sizeof(struct SaveBlock2))))
-#define eSaveBlock3Copy (*(struct PokemonStorage *)((void*)(ewram_addr + sizeof(struct SaveBlock2) + sizeof(struct SaveBlock1))))
-
-#ifdef NONMATCHING // this is one devil of a motherfucker
-/*
- The reason MoveSaveBlocks_ResetHeap mismatches is due to incorrect memcpys. Various
- things have been tried, such as: direct struct copys, ewram casts, use of defining
- the addresses manually, using memcpy anyway, delayed allocation of pointers at
- the start of function, as seen above and below. Scope declaration has been used to try and
- reproduce the correct macro thought to be used, but nothing has worked. It is worth
- noting that at this point that the compiler will delay the allocation of the save block
- pointers at the beginningto be allocated later: which might matter for matching this.
- Due to loading shared ewram heap areas directly, it is very likely emerald used ewram
- defines for this function, but there is no known example of a matching define.
- In addition, dead code might be present in the form of a runtime variable used
- to fix the address of the save blocks. This has been tested and is shown to affect
- the registers as well.
-*/
void MoveSaveBlocks_ResetHeap(void)
{
void *vblankCB, *hblankCB;
u32 encryptionKey;
- struct SaveBlock1 **sav1Copy = &gSaveBlock1Ptr; // r10;
+ struct SaveBlock2 *saveBlock2Copy;
+ struct SaveBlock1 *saveBlock1Copy;
+ struct PokemonStorage *pokemonStorageCopy;
// save interrupt functions and turn them off
vblankCB = gMain.vblankCallback;
@@ -127,22 +97,30 @@ void MoveSaveBlocks_ResetHeap(void)
gMain.hblankCallback = NULL;
gUnknown_0203CF5C = NULL;
+ saveBlock2Copy = (struct SaveBlock2 *)(gHeap);
+ saveBlock1Copy = (struct SaveBlock1 *)(gHeap + sizeof(struct SaveBlock2));
+ pokemonStorageCopy = (struct PokemonStorage *)(gHeap + sizeof(struct SaveBlock2) + sizeof(struct SaveBlock1));
+
// backup the saves.
- eSaveBlock1Copy = **sav1Copy;
- eSaveBlock2Copy = *gSaveBlock2Ptr;
- eSaveBlock3Copy = *gPokemonStoragePtr;
+ *saveBlock2Copy = *gSaveBlock2Ptr;
+ *saveBlock1Copy = *gSaveBlock1Ptr;
+ *pokemonStorageCopy = *gPokemonStoragePtr;
// change saveblocks' pointers
// argument is a sum of the individual trainerId bytes
- SetSaveBlocksPointers(eSaveBlock2Copy.playerTrainerId[0] + eSaveBlock2Copy.playerTrainerId[1] + eSaveBlock2Copy.playerTrainerId[2] + eSaveBlock2Copy.playerTrainerId[3]);
+ SetSaveBlocksPointers(
+ saveBlock2Copy->playerTrainerId[0] +
+ saveBlock2Copy->playerTrainerId[1] +
+ saveBlock2Copy->playerTrainerId[2] +
+ saveBlock2Copy->playerTrainerId[3]);
// restore saveblock data since the pointers changed
- **sav1Copy = eSaveBlock1Copy;
- *gSaveBlock2Ptr = eSaveBlock2Copy;
- *gPokemonStoragePtr = eSaveBlock3Copy;
+ *gSaveBlock2Ptr = *saveBlock2Copy;
+ *gSaveBlock1Ptr = *saveBlock1Copy;
+ *gPokemonStoragePtr = *pokemonStorageCopy;
// heap was destroyed in the copying process, so reset it
- InitHeap((void*)(0x02000000), 0x1C000);
+ InitHeap(gHeap, HEAP_SIZE);
// restore interrupt functions
gMain.hblankCallback = hblankCB;
@@ -153,105 +131,7 @@ void MoveSaveBlocks_ResetHeap(void)
ApplyNewEncryptionKeyToAllEncryptedData(encryptionKey);
gSaveBlock2Ptr->encryptionKey = encryptionKey;
}
-#else
-__attribute__((naked))
-void MoveSaveBlocks_ResetHeap(void)
-{
- asm(".syntax unified\n\
- push {r4-r7,lr}\n\
- mov r7, r10\n\
- mov r6, r9\n\
- mov r5, r8\n\
- push {r5-r7}\n\
- sub sp, 0x8\n\
- ldr r5, =gMain\n\
- ldr r0, [r5, 0xC]\n\
- str r0, [sp]\n\
- ldr r1, [r5, 0x10]\n\
- str r1, [sp, 0x4]\n\
- movs r0, 0\n\
- str r0, [r5, 0xC]\n\
- str r0, [r5, 0x10]\n\
- ldr r1, =gUnknown_0203CF5C\n\
- str r0, [r1]\n\
- ldr r4, =0x02000000\n\
- ldr r0, =gSaveBlock2Ptr\n\
- ldr r1, [r0]\n\
- ldr r6, =0x00000f2c\n\
- adds r0, r4, 0\n\
- adds r2, r6, 0\n\
- bl memcpy\n\
- ldr r1, =gSaveBlock1Ptr\n\
- mov r10, r1\n\
- ldr r1, [r1]\n\
- ldr r7, =0x00003d88\n\
- ldr r0, =0x02000f2c\n\
- adds r2, r7, 0\n\
- bl memcpy\n\
- ldr r0, =gPokemonStoragePtr\n\
- mov r8, r0\n\
- ldr r1, [r0]\n\
- ldr r0, =0x000083d0\n\
- mov r9, r0\n\
- ldr r0, =0x02004cb4\n\
- mov r2, r9\n\
- bl memcpy\n\
- ldrb r1, [r4, 0xA]\n\
- ldrb r0, [r4, 0xB]\n\
- adds r1, r0\n\
- ldrb r0, [r4, 0xC]\n\
- adds r1, r0\n\
- ldrb r0, [r4, 0xD]\n\
- adds r0, r1\n\
- bl SetSaveBlocksPointers\n\
- ldr r1, =gSaveBlock2Ptr\n\
- ldr r0, [r1]\n\
- adds r1, r4, 0\n\
- adds r2, r6, 0\n\
- bl memcpy\n\
- mov r1, r10\n\
- ldr r0, [r1]\n\
- ldr r1, =0x02000f2c\n\
- adds r2, r7, 0\n\
- bl memcpy\n\
- mov r1, r8\n\
- ldr r0, [r1]\n\
- ldr r1, =0x02004cb4\n\
- mov r2, r9\n\
- bl memcpy\n\
- movs r1, 0xE0\n\
- lsls r1, 9\n\
- adds r0, r4, 0\n\
- bl InitHeap\n\
- ldr r0, [sp, 0x4]\n\
- str r0, [r5, 0x10]\n\
- ldr r1, [sp]\n\
- str r1, [r5, 0xC]\n\
- bl Random\n\
- adds r4, r0, 0\n\
- bl Random\n\
- lsls r4, 16\n\
- lsls r0, 16\n\
- lsrs r0, 16\n\
- adds r4, r0\n\
- adds r0, r4, 0\n\
- bl ApplyNewEncryptionKeyToAllEncryptedData\n\
- ldr r1, =gSaveBlock2Ptr\n\
- ldr r0, [r1]\n\
- adds r0, 0xAC\n\
- str r4, [r0]\n\
- add sp, 0x8\n\
- pop {r3-r5}\n\
- mov r8, r3\n\
- mov r9, r4\n\
- mov r10, r5\n\
- pop {r4-r7}\n\
- pop {r0}\n\
- bx r0\n\
- .pool\n\
- .syntax divided\n");
-}
-#endif
+
u8 sav2_x1_query_bit1(void)
{
diff --git a/src/mail.c b/src/mail.c
index ec7ff2ce2..68a55e242 100644
--- a/src/mail.c
+++ b/src/mail.c
@@ -20,42 +20,42 @@
#include "malloc.h"
#include "easy_chat.h"
-extern const u16 gUnknown_08DBE818[];
-extern const u16 gUnknown_08DBE838[];
-extern const u16 gUnknown_08DBE858[];
-extern const u16 gUnknown_08DBE878[];
-extern const u16 gUnknown_08DBE898[];
-extern const u16 gUnknown_08DBE8B8[];
-extern const u16 gUnknown_08DBE8D8[];
-extern const u16 gUnknown_08DBE8F8[];
-extern const u16 gUnknown_08DBE918[];
-extern const u16 gUnknown_08DBE938[];
-extern const u16 gUnknown_08DBE958[];
-extern const u16 gUnknown_08DBE978[];
-extern const u8 gUnknown_08DBE998[];
-extern const u8 gUnknown_08DBFBA4[];
-extern const u8 gUnknown_08DBEB38[];
-extern const u8 gUnknown_08DBFC7C[];
-extern const u8 gUnknown_08DBEC74[];
-extern const u8 gUnknown_08DBFD5C[];
-extern const u8 gUnknown_08DBEE84[];
-extern const u8 gUnknown_08DBFE68[];
-extern const u8 gUnknown_08DBEF5C[];
-extern const u8 gUnknown_08DBFF44[];
-extern const u8 gUnknown_08DBF154[];
-extern const u8 gUnknown_08DC0034[];
-extern const u8 gUnknown_08DBF2D4[];
-extern const u8 gUnknown_08DC0114[];
-extern const u8 gUnknown_08DBF37C[];
-extern const u8 gUnknown_08DC01F4[];
-extern const u8 gUnknown_08DBF50C[];
-extern const u8 gUnknown_08DC0300[];
-extern const u8 gUnknown_08DBF64C[];
-extern const u8 gUnknown_08DC03F0[];
-extern const u8 gUnknown_08DBF7B4[];
-extern const u8 gUnknown_08DC04E8[];
-extern const u8 gUnknown_08DBF904[];
-extern const u8 gUnknown_08DC0600[];
+extern const u16 gMailPalette_Orange[];
+extern const u16 gMailPalette_Harbor[];
+extern const u16 gMailPalette_Glitter[];
+extern const u16 gMailPalette_Mech[];
+extern const u16 gMailPalette_Wood[];
+extern const u16 gMailPalette_Wave[];
+extern const u16 gMailPalette_Bead[];
+extern const u16 gMailPalette_Shadow[];
+extern const u16 gMailPalette_Tropic[];
+extern const u16 gMailPalette_Dream[];
+extern const u16 gMailPalette_Fab[];
+extern const u16 gMailPalette_Retro[];
+extern const u8 gMailTiles_Orange[];
+extern const u8 gMailTilemap_Orange[];
+extern const u8 gMailTiles_Harbor[];
+extern const u8 gMailTilemap_Harbor[];
+extern const u8 gMailTiles_Glitter[];
+extern const u8 gMailTilemap_Glitter[];
+extern const u8 gMailTiles_Mech[];
+extern const u8 gMailTilemap_Mech[];
+extern const u8 gMailTiles_Wood[];
+extern const u8 gMailTilemap_Wood[];
+extern const u8 gMailTiles_Wave[];
+extern const u8 gMailTilemap_Wave[];
+extern const u8 gMailTiles_Bead[];
+extern const u8 gMailTilemap_Bead[];
+extern const u8 gMailTiles_Shadow[];
+extern const u8 gMailTilemap_Shadow[];
+extern const u8 gMailTiles_Tropic[];
+extern const u8 gMailTilemap_Tropic[];
+extern const u8 gMailTiles_Dream[];
+extern const u8 gMailTilemap_Dream[];
+extern const u8 gMailTiles_Fab[];
+extern const u8 gMailTilemap_Fab[];
+extern const u8 gMailTiles_Retro[];
+extern const u8 gMailTilemap_Retro[];
// Static type declarations
@@ -170,29 +170,29 @@ static const u16 sUnknown_0859F2B0[][2] = {
static const struct MailGraphics sUnknown_0859F2B8[] = {
{
- gUnknown_08DBE818, gUnknown_08DBE998, gUnknown_08DBFBA4, 0x02c0, 0x0000, 0x294a, 0x6739
+ gMailPalette_Orange, gMailTiles_Orange, gMailTilemap_Orange, 0x02c0, 0x0000, 0x294a, 0x6739
}, {
- gUnknown_08DBE838, gUnknown_08DBEB38, gUnknown_08DBFC7C, 0x02e0, 0x0000, 0x7fff, 0x4631
+ gMailPalette_Harbor, gMailTiles_Harbor, gMailTilemap_Harbor, 0x02e0, 0x0000, 0x7fff, 0x4631
}, {
- gUnknown_08DBE858, gUnknown_08DBEC74, gUnknown_08DBFD5C, 0x0400, 0x0000, 0x294a, 0x6739
+ gMailPalette_Glitter, gMailTiles_Glitter, gMailTilemap_Glitter, 0x0400, 0x0000, 0x294a, 0x6739
}, {
- gUnknown_08DBE878, gUnknown_08DBEE84, gUnknown_08DBFE68, 0x01e0, 0x0000, 0x7fff, 0x4631
+ gMailPalette_Mech, gMailTiles_Mech, gMailTilemap_Mech, 0x01e0, 0x0000, 0x7fff, 0x4631
}, {
- gUnknown_08DBE898, gUnknown_08DBEF5C, gUnknown_08DBFF44, 0x02e0, 0x0000, 0x7fff, 0x4631
+ gMailPalette_Wood, gMailTiles_Wood, gMailTilemap_Wood, 0x02e0, 0x0000, 0x7fff, 0x4631
}, {
- gUnknown_08DBE8B8, gUnknown_08DBF154, gUnknown_08DC0034, 0x0300, 0x0000, 0x294a, 0x6739
+ gMailPalette_Wave, gMailTiles_Wave, gMailTilemap_Wave, 0x0300, 0x0000, 0x294a, 0x6739
}, {
- gUnknown_08DBE8D8, gUnknown_08DBF2D4, gUnknown_08DC0114, 0x0140, 0x0000, 0x7fff, 0x4631
+ gMailPalette_Bead, gMailTiles_Bead, gMailTilemap_Bead, 0x0140, 0x0000, 0x7fff, 0x4631
}, {
- gUnknown_08DBE8F8, gUnknown_08DBF37C, gUnknown_08DC01F4, 0x0300, 0x0000, 0x7fff, 0x4631
+ gMailPalette_Shadow, gMailTiles_Shadow, gMailTilemap_Shadow, 0x0300, 0x0000, 0x7fff, 0x4631
}, {
- gUnknown_08DBE918, gUnknown_08DBF50C, gUnknown_08DC0300, 0x0220, 0x0000, 0x294a, 0x6739
+ gMailPalette_Tropic, gMailTiles_Tropic, gMailTilemap_Tropic, 0x0220, 0x0000, 0x294a, 0x6739
}, {
- gUnknown_08DBE938, gUnknown_08DBF64C, gUnknown_08DC03F0, 0x0340, 0x0000, 0x294a, 0x6739
+ gMailPalette_Dream, gMailTiles_Dream, gMailTilemap_Dream, 0x0340, 0x0000, 0x294a, 0x6739
}, {
- gUnknown_08DBE958, gUnknown_08DBF7B4, gUnknown_08DC04E8, 0x02a0, 0x0000, 0x294a, 0x6739
+ gMailPalette_Fab, gMailTiles_Fab, gMailTilemap_Fab, 0x02a0, 0x0000, 0x294a, 0x6739
}, {
- gUnknown_08DBE978, gUnknown_08DBF904, gUnknown_08DC0600, 0x0520, 0x0000, 0x294a, 0x6739
+ gMailPalette_Retro, gMailTiles_Retro, gMailTilemap_Retro, 0x0520, 0x0000, 0x294a, 0x6739
}
};
diff --git a/src/main.c b/src/main.c
index 07ce07f1c..18d1abdc2 100644
--- a/src/main.c
+++ b/src/main.c
@@ -122,7 +122,7 @@ void AgbMain()
ClearDma3Requests();
ResetBgs();
SetDefaultFontsPointer();
- InitHeap(gHeap, 0x1C000);
+ InitHeap(gHeap, HEAP_SIZE);
gSoftResetDisabled = FALSE;
diff --git a/src/pokedex.c b/src/pokedex.c
new file mode 100644
index 000000000..a74594865
--- /dev/null
+++ b/src/pokedex.c
@@ -0,0 +1,542 @@
+#include "global.h"
+#include "gba/m4a_internal.h"
+#include "pokedex.h"
+#include "sprite.h"
+#include "graphics.h"
+#include "decompress.h"
+#include "bg.h"
+#include "window.h"
+
+// this file's functions
+void sub_80BE604(struct Sprite *sprite);
+void sub_80BE658(struct Sprite *sprite);
+void sub_80BE758(struct Sprite *sprite);
+void sub_80BE780(struct Sprite *sprite);
+void sub_80BE44C(struct Sprite *sprite);
+void sub_80BE834(struct Sprite *sprite);
+
+// const rom data
+#include "data/pokedex_orders.h"
+
+static const struct OamData sOamData_855CFE4 =
+{
+ .y = 160,
+ .affineMode = 0,
+ .objMode = 0,
+ .mosaic = 0,
+ .bpp = 0,
+ .shape = 0,
+ .x = 0,
+ .matrixNum = 0,
+ .size = 0,
+ .tileNum = 0,
+ .priority = 1,
+ .paletteNum = 0,
+ .affineParam = 0
+};
+
+static const struct OamData sOamData_855CFEC =
+{
+ .y = 160,
+ .affineMode = 0,
+ .objMode = 0,
+ .mosaic = 0,
+ .bpp = 0,
+ .shape = 1,
+ .x = 0,
+ .matrixNum = 0,
+ .size = 0,
+ .tileNum = 0,
+ .priority = 0,
+ .paletteNum = 0,
+ .affineParam = 0
+};
+
+static const struct OamData sOamData_855CFF4 =
+{
+ .y = 160,
+ .affineMode = 0,
+ .objMode = 0,
+ .mosaic = 0,
+ .bpp = 0,
+ .shape = 1,
+ .x = 0,
+ .matrixNum = 0,
+ .size = 2,
+ .tileNum = 0,
+ .priority = 0,
+ .paletteNum = 0,
+ .affineParam = 0
+};
+
+static const struct OamData sOamData_855CFFC =
+{
+ .y = 160,
+ .affineMode = 0,
+ .objMode = 2,
+ .mosaic = 0,
+ .bpp = 0,
+ .shape = 0,
+ .x = 0,
+ .matrixNum = 0,
+ .size = 2,
+ .tileNum = 0,
+ .priority = 1,
+ .paletteNum = 0,
+ .affineParam = 0
+};
+
+static const struct OamData sOamData_855D004 =
+{
+ .y = 160,
+ .affineMode = 0,
+ .objMode = 0,
+ .mosaic = 0,
+ .bpp = 0,
+ .shape = 1,
+ .x = 0,
+ .matrixNum = 0,
+ .size = 3,
+ .tileNum = 0,
+ .priority = 0,
+ .paletteNum = 0,
+ .affineParam = 0
+};
+
+static const struct OamData sOamData_855D00C =
+{
+ .y = 160,
+ .affineMode = 0,
+ .objMode = 0,
+ .mosaic = 0,
+ .bpp = 0,
+ .shape = 2,
+ .x = 0,
+ .matrixNum = 0,
+ .size = 0,
+ .tileNum = 0,
+ .priority = 0,
+ .paletteNum = 0,
+ .affineParam = 0
+};
+
+static const union AnimCmd sSpriteAnim_855D014[] =
+{
+ ANIMCMD_FRAME(3, 30),
+ ANIMCMD_END
+};
+
+static const union AnimCmd sSpriteAnim_855D01C[] =
+{
+ ANIMCMD_FRAME(1, 30),
+ ANIMCMD_END
+};
+
+static const union AnimCmd sSpriteAnim_855D024[] =
+{
+ ANIMCMD_FRAME(16, 30),
+ ANIMCMD_END
+};
+
+static const union AnimCmd sSpriteAnim_855D02C[] =
+{
+ ANIMCMD_FRAME(48, 30),
+ ANIMCMD_END
+};
+
+static const union AnimCmd sSpriteAnim_855D034[] =
+{
+ ANIMCMD_FRAME(40, 30),
+ ANIMCMD_END
+};
+
+static const union AnimCmd sSpriteAnim_855D03C[] =
+{
+ ANIMCMD_FRAME(32, 30),
+ ANIMCMD_END
+};
+
+static const union AnimCmd sSpriteAnim_855D044[] =
+{
+ ANIMCMD_FRAME(56, 30),
+ ANIMCMD_END
+};
+
+static const union AnimCmd sSpriteAnim_855D04C[] =
+{
+ ANIMCMD_FRAME(64, 30),
+ ANIMCMD_END
+};
+
+static const union AnimCmd sSpriteAnim_855D054[] =
+{
+ ANIMCMD_FRAME(96, 30),
+ ANIMCMD_END
+};
+
+static const union AnimCmd sSpriteAnim_855D05C[] =
+{
+ ANIMCMD_FRAME(160, 30),
+ ANIMCMD_END
+};
+
+static const union AnimCmd sSpriteAnim_855D064[] =
+{
+ ANIMCMD_FRAME(168, 30),
+ ANIMCMD_END
+};
+
+static const union AnimCmd sSpriteAnim_855D06C[] =
+{
+ ANIMCMD_FRAME(128, 30),
+ ANIMCMD_END
+};
+
+static const union AnimCmd sSpriteAnim_855D074[] =
+{
+ ANIMCMD_FRAME(130, 30),
+ ANIMCMD_END
+};
+
+static const union AnimCmd sSpriteAnim_855D07C[] =
+{
+ ANIMCMD_FRAME(132, 30),
+ ANIMCMD_END
+};
+
+static const union AnimCmd sSpriteAnim_855D084[] =
+{
+ ANIMCMD_FRAME(134, 30),
+ ANIMCMD_END
+};
+
+static const union AnimCmd sSpriteAnim_855D08C[] =
+{
+ ANIMCMD_FRAME(136, 30),
+ ANIMCMD_END
+};
+
+static const union AnimCmd sSpriteAnim_855D094[] =
+{
+ ANIMCMD_FRAME(138, 30),
+ ANIMCMD_END
+};
+
+static const union AnimCmd sSpriteAnim_855D09C[] =
+{
+ ANIMCMD_FRAME(140, 30),
+ ANIMCMD_END
+};
+
+static const union AnimCmd sSpriteAnim_855D0A4[] =
+{
+ ANIMCMD_FRAME(142, 30),
+ ANIMCMD_END
+};
+
+static const union AnimCmd sSpriteAnim_855D0AC[] =
+{
+ ANIMCMD_FRAME(144, 30),
+ ANIMCMD_END
+};
+
+static const union AnimCmd sSpriteAnim_855D0B4[] =
+{
+ ANIMCMD_FRAME(146, 30),
+ ANIMCMD_END
+};
+
+static const union AnimCmd sSpriteAnim_855D0BC[] =
+{
+ ANIMCMD_FRAME(176, 30),
+ ANIMCMD_END
+};
+
+static const union AnimCmd sSpriteAnim_855D0C4[] =
+{
+ ANIMCMD_FRAME(178, 30),
+ ANIMCMD_END
+};
+
+static const union AnimCmd sSpriteAnim_855D0CC[] =
+{
+ ANIMCMD_FRAME(180, 30),
+ ANIMCMD_END
+};
+
+static const union AnimCmd sSpriteAnim_855D0D4[] =
+{
+ ANIMCMD_FRAME(182, 30),
+ ANIMCMD_END
+};
+
+static const union AnimCmd sSpriteAnim_855D0DC[] =
+{
+ ANIMCMD_FRAME(184, 30),
+ ANIMCMD_END
+};
+
+static const union AnimCmd sSpriteAnim_855D0E4[] =
+{
+ ANIMCMD_FRAME(186, 30),
+ ANIMCMD_END
+};
+
+static const union AnimCmd sSpriteAnim_855D0EC[] =
+{
+ ANIMCMD_FRAME(188, 30),
+ ANIMCMD_END
+};
+
+static const union AnimCmd sSpriteAnim_855D0F4[] =
+{
+ ANIMCMD_FRAME(190, 30),
+ ANIMCMD_END
+};
+
+static const union AnimCmd sSpriteAnim_855D0FC[] =
+{
+ ANIMCMD_FRAME(192, 30),
+ ANIMCMD_END
+};
+
+static const union AnimCmd sSpriteAnim_855D104[] =
+{
+ ANIMCMD_FRAME(194, 30),
+ ANIMCMD_END
+};
+
+static const union AnimCmd sSpriteAnim_855D10C[] =
+{
+ ANIMCMD_FRAME(4, 30),
+ ANIMCMD_END
+};
+
+static const union AnimCmd *const sSpriteAnimTable_855D114[] =
+{
+ sSpriteAnim_855D014
+};
+
+static const union AnimCmd *const sSpriteAnimTable_855D118[] =
+{
+ sSpriteAnim_855D01C
+};
+
+static const union AnimCmd *const sSpriteAnimTable_855D11C[] =
+{
+ sSpriteAnim_855D024
+};
+
+static const union AnimCmd *const sSpriteAnimTable_855D120[] =
+{
+ sSpriteAnim_855D02C,
+ sSpriteAnim_855D034,
+ sSpriteAnim_855D03C,
+ sSpriteAnim_855D044
+};
+
+static const union AnimCmd *const sSpriteAnimTable_855D130[] =
+{
+ sSpriteAnim_855D04C,
+ sSpriteAnim_855D054
+};
+
+static const union AnimCmd *const sSpriteAnimTable_855D138[] =
+{
+ sSpriteAnim_855D05C,
+ sSpriteAnim_855D064
+};
+
+static const union AnimCmd *const sSpriteAnimTable_855D140[] =
+{
+ sSpriteAnim_855D06C,
+ sSpriteAnim_855D074,
+ sSpriteAnim_855D07C,
+ sSpriteAnim_855D084,
+ sSpriteAnim_855D08C,
+ sSpriteAnim_855D094,
+ sSpriteAnim_855D09C,
+ sSpriteAnim_855D0A4,
+ sSpriteAnim_855D0AC,
+ sSpriteAnim_855D0B4
+};
+
+static const union AnimCmd *const sSpriteAnimTable_855D168[] =
+{
+ sSpriteAnim_855D0BC,
+ sSpriteAnim_855D0C4,
+ sSpriteAnim_855D0CC,
+ sSpriteAnim_855D0D4,
+ sSpriteAnim_855D0DC,
+ sSpriteAnim_855D0E4,
+ sSpriteAnim_855D0EC,
+ sSpriteAnim_855D0F4,
+ sSpriteAnim_855D0FC,
+ sSpriteAnim_855D104
+};
+
+static const union AnimCmd *const sSpriteAnimTable_855D190[] =
+{
+ sSpriteAnim_855D10C
+};
+
+const struct SpriteTemplate gUnknown_0855D194 =
+{
+ .tileTag = 4096,
+ .paletteTag = 4096,
+ .oam = &sOamData_855CFE4,
+ .anims = sSpriteAnimTable_855D114,
+ .images = NULL,
+ .affineAnims = gDummySpriteAffineAnimTable,
+ .callback = sub_80BE604,
+};
+
+const struct SpriteTemplate gUnknown_0855D1AC =
+{
+ .tileTag = 4096,
+ .paletteTag = 4096,
+ .oam = &sOamData_855CFEC,
+ .anims = sSpriteAnimTable_855D118,
+ .images = NULL,
+ .affineAnims = gDummySpriteAffineAnimTable,
+ .callback = sub_80BE658,
+};
+
+const struct SpriteTemplate gUnknown_0855D1C4 =
+{
+ .tileTag = 4096,
+ .paletteTag = 4096,
+ .oam = &sOamData_855CFF4,
+ .anims = sSpriteAnimTable_855D120,
+ .images = NULL,
+ .affineAnims = gDummySpriteAffineAnimTable,
+ .callback = sub_80BE758,
+};
+
+const struct SpriteTemplate gUnknown_0855D1DC =
+{
+ .tileTag = 4096,
+ .paletteTag = 4096,
+ .oam = &sOamData_855CFFC,
+ .anims = sSpriteAnimTable_855D11C,
+ .images = NULL,
+ .affineAnims = gDummySpriteAffineAnimTable,
+ .callback = sub_80BE780,
+};
+
+const struct SpriteTemplate gUnknown_0855D1F4 =
+{
+ .tileTag = 4096,
+ .paletteTag = 4096,
+ .oam = &sOamData_855D004,
+ .anims = sSpriteAnimTable_855D130,
+ .images = NULL,
+ .affineAnims = gDummySpriteAffineAnimTable,
+ .callback = sub_80BE44C,
+};
+
+const struct SpriteTemplate gUnknown_0855D20C =
+{
+ .tileTag = 4096,
+ .paletteTag = 4096,
+ .oam = &sOamData_855CFF4,
+ .anims = sSpriteAnimTable_855D138,
+ .images = NULL,
+ .affineAnims = gDummySpriteAffineAnimTable,
+ .callback = sub_80BE44C,
+};
+
+const struct SpriteTemplate gUnknown_0855D224 =
+{
+ .tileTag = 4096,
+ .paletteTag = 4096,
+ .oam = &sOamData_855D00C,
+ .anims = sSpriteAnimTable_855D140,
+ .images = NULL,
+ .affineAnims = gDummySpriteAffineAnimTable,
+ .callback = sub_80BE44C,
+};
+
+const struct SpriteTemplate gUnknown_0855D23C =
+{
+ .tileTag = 4096,
+ .paletteTag = 4096,
+ .oam = &sOamData_855D00C,
+ .anims = sSpriteAnimTable_855D168,
+ .images = NULL,
+ .affineAnims = gDummySpriteAffineAnimTable,
+ .callback = sub_80BE44C,
+};
+
+const struct SpriteTemplate gUnknown_0855D254 =
+{
+ .tileTag = 4096,
+ .paletteTag = 4096,
+ .oam = &sOamData_855D00C,
+ .anims = sSpriteAnimTable_855D190,
+ .images = NULL,
+ .affineAnims = gDummySpriteAffineAnimTable,
+ .callback = sub_80BE834,
+};
+
+const struct CompressedSpriteSheet gSpriteSheets_0855D26C[] =
+{
+ {gPokedexMenu2_Gfx, 0x2000, 4096},
+ {0}
+};
+
+const struct CompressedSpritePalette gSpritePalettes_0855D26C[] =
+{
+ {gPokedexText_Pal, 4096},
+ {0}
+};
+
+const u8 gUnknown_0855D28C[] = {0x4, 0x8, 0x10, 0x20, 0x20};
+const u8 gUnknown_0855D291[] = {0x8, 0x4, 0x2, 0x1, 0x1};
+
+const struct BgTemplate gBgTemplates_0855D298[] =
+{
+ {
+ .bg = 0,
+ .charBaseIndex = 0,
+ .mapBaseIndex = 12,
+ .screenSize = 0,
+ .paletteMode = 0,
+ .priority = 0,
+ .baseTile = 0
+ },
+ {
+ .bg = 1,
+ .charBaseIndex = 0,
+ .mapBaseIndex = 13,
+ .screenSize = 0,
+ .paletteMode = 0,
+ .priority = 1,
+ .baseTile = 0
+ },
+ {
+ .bg = 2,
+ .charBaseIndex = 2,
+ .mapBaseIndex = 14,
+ .screenSize = 0,
+ .paletteMode = 0,
+ .priority = 2,
+ .baseTile = 0
+ },
+ {
+ .bg = 3,
+ .charBaseIndex = 0,
+ .mapBaseIndex = 15,
+ .screenSize = 0,
+ .paletteMode = 0,
+ .priority = 3,
+ .baseTile = 0
+ }
+};
+
+const struct WindowTemplate sWindowTemplates_0855D2A8[] =
+{
+ {2, 0, 0, 0x20, 0x20, 0, 1},
+ DUMMY_WIN_TEMPLATE
+};
+
diff --git a/src/pokemon_icon.c b/src/pokemon_icon.c
new file mode 100644
index 000000000..4d1cc51c5
--- /dev/null
+++ b/src/pokemon_icon.c
@@ -0,0 +1,1014 @@
+#include "global.h"
+#include "sprite.h"
+#include "graphics.h"
+
+#define POKE_ICON_BASE_PAL_TAG 56000
+
+const u8 * const gMonIconTable[] =
+{
+ gMonIcon_Bulbasaur,
+ gMonIcon_Bulbasaur,
+ gMonIcon_Ivysaur,
+ gMonIcon_Venusaur,
+ gMonIcon_Charmander,
+ gMonIcon_Charmeleon,
+ gMonIcon_Charizard,
+ gMonIcon_Squirtle,
+ gMonIcon_Wartortle,
+ gMonIcon_Blastoise,
+ gMonIcon_Caterpie,
+ gMonIcon_Metapod,
+ gMonIcon_Butterfree,
+ gMonIcon_Weedle,
+ gMonIcon_Kakuna,
+ gMonIcon_Beedrill,
+ gMonIcon_Pidgey,
+ gMonIcon_Pidgeotto,
+ gMonIcon_Pidgeot,
+ gMonIcon_Rattata,
+ gMonIcon_Raticate,
+ gMonIcon_Spearow,
+ gMonIcon_Fearow,
+ gMonIcon_Ekans,
+ gMonIcon_Arbok,
+ gMonIcon_Pikachu,
+ gMonIcon_Raichu,
+ gMonIcon_Sandshrew,
+ gMonIcon_Sandslash,
+ gMonIcon_NidoranF,
+ gMonIcon_Nidorina,
+ gMonIcon_Nidoqueen,
+ gMonIcon_NidoranM,
+ gMonIcon_Nidorino,
+ gMonIcon_Nidoking,
+ gMonIcon_Clefairy,
+ gMonIcon_Clefable,
+ gMonIcon_Vulpix,
+ gMonIcon_Ninetales,
+ gMonIcon_Jigglypuff,
+ gMonIcon_Wigglytuff,
+ gMonIcon_Zubat,
+ gMonIcon_Golbat,
+ gMonIcon_Oddish,
+ gMonIcon_Gloom,
+ gMonIcon_Vileplume,
+ gMonIcon_Paras,
+ gMonIcon_Parasect,
+ gMonIcon_Venonat,
+ gMonIcon_Venomoth,
+ gMonIcon_Diglett,
+ gMonIcon_Dugtrio,
+ gMonIcon_Meowth,
+ gMonIcon_Persian,
+ gMonIcon_Psyduck,
+ gMonIcon_Golduck,
+ gMonIcon_Mankey,
+ gMonIcon_Primeape,
+ gMonIcon_Growlithe,
+ gMonIcon_Arcanine,
+ gMonIcon_Poliwag,
+ gMonIcon_Poliwhirl,
+ gMonIcon_Poliwrath,
+ gMonIcon_Abra,
+ gMonIcon_Kadabra,
+ gMonIcon_Alakazam,
+ gMonIcon_Machop,
+ gMonIcon_Machoke,
+ gMonIcon_Machamp,
+ gMonIcon_Bellsprout,
+ gMonIcon_Weepinbell,
+ gMonIcon_Victreebel,
+ gMonIcon_Tentacool,
+ gMonIcon_Tentacruel,
+ gMonIcon_Geodude,
+ gMonIcon_Graveler,
+ gMonIcon_Golem,
+ gMonIcon_Ponyta,
+ gMonIcon_Rapidash,
+ gMonIcon_Slowpoke,
+ gMonIcon_Slowbro,
+ gMonIcon_Magnemite,
+ gMonIcon_Magneton,
+ gMonIcon_Farfetchd,
+ gMonIcon_Doduo,
+ gMonIcon_Dodrio,
+ gMonIcon_Seel,
+ gMonIcon_Dewgong,
+ gMonIcon_Grimer,
+ gMonIcon_Muk,
+ gMonIcon_Shellder,
+ gMonIcon_Cloyster,
+ gMonIcon_Gastly,
+ gMonIcon_Haunter,
+ gMonIcon_Gengar,
+ gMonIcon_Onix,
+ gMonIcon_Drowzee,
+ gMonIcon_Hypno,
+ gMonIcon_Krabby,
+ gMonIcon_Kingler,
+ gMonIcon_Voltorb,
+ gMonIcon_Electrode,
+ gMonIcon_Exeggcute,
+ gMonIcon_Exeggutor,
+ gMonIcon_Cubone,
+ gMonIcon_Marowak,
+ gMonIcon_Hitmonlee,
+ gMonIcon_Hitmonchan,
+ gMonIcon_Lickitung,
+ gMonIcon_Koffing,
+ gMonIcon_Weezing,
+ gMonIcon_Rhyhorn,
+ gMonIcon_Rhydon,
+ gMonIcon_Chansey,
+ gMonIcon_Tangela,
+ gMonIcon_Kangaskhan,
+ gMonIcon_Horsea,
+ gMonIcon_Seadra,
+ gMonIcon_Goldeen,
+ gMonIcon_Seaking,
+ gMonIcon_Staryu,
+ gMonIcon_Starmie,
+ gMonIcon_Mrmime,
+ gMonIcon_Scyther,
+ gMonIcon_Jynx,
+ gMonIcon_Electabuzz,
+ gMonIcon_Magmar,
+ gMonIcon_Pinsir,
+ gMonIcon_Tauros,
+ gMonIcon_Magikarp,
+ gMonIcon_Gyarados,
+ gMonIcon_Lapras,
+ gMonIcon_Ditto,
+ gMonIcon_Eevee,
+ gMonIcon_Vaporeon,
+ gMonIcon_Jolteon,
+ gMonIcon_Flareon,
+ gMonIcon_Porygon,
+ gMonIcon_Omanyte,
+ gMonIcon_Omastar,
+ gMonIcon_Kabuto,
+ gMonIcon_Kabutops,
+ gMonIcon_Aerodactyl,
+ gMonIcon_Snorlax,
+ gMonIcon_Articuno,
+ gMonIcon_Zapdos,
+ gMonIcon_Moltres,
+ gMonIcon_Dratini,
+ gMonIcon_Dragonair,
+ gMonIcon_Dragonite,
+ gMonIcon_Mewtwo,
+ gMonIcon_Mew,
+ gMonIcon_Chikorita,
+ gMonIcon_Bayleef,
+ gMonIcon_Meganium,
+ gMonIcon_Cyndaquil,
+ gMonIcon_Quilava,
+ gMonIcon_Typhlosion,
+ gMonIcon_Totodile,
+ gMonIcon_Croconaw,
+ gMonIcon_Feraligatr,
+ gMonIcon_Sentret,
+ gMonIcon_Furret,
+ gMonIcon_Hoothoot,
+ gMonIcon_Noctowl,
+ gMonIcon_Ledyba,
+ gMonIcon_Ledian,
+ gMonIcon_Spinarak,
+ gMonIcon_Ariados,
+ gMonIcon_Crobat,
+ gMonIcon_Chinchou,
+ gMonIcon_Lanturn,
+ gMonIcon_Pichu,
+ gMonIcon_Cleffa,
+ gMonIcon_Igglybuff,
+ gMonIcon_Togepi,
+ gMonIcon_Togetic,
+ gMonIcon_Natu,
+ gMonIcon_Xatu,
+ gMonIcon_Mareep,
+ gMonIcon_Flaaffy,
+ gMonIcon_Ampharos,
+ gMonIcon_Bellossom,
+ gMonIcon_Marill,
+ gMonIcon_Azumarill,
+ gMonIcon_Sudowoodo,
+ gMonIcon_Politoed,
+ gMonIcon_Hoppip,
+ gMonIcon_Skiploom,
+ gMonIcon_Jumpluff,
+ gMonIcon_Aipom,
+ gMonIcon_Sunkern,
+ gMonIcon_Sunflora,
+ gMonIcon_Yanma,
+ gMonIcon_Wooper,
+ gMonIcon_Quagsire,
+ gMonIcon_Espeon,
+ gMonIcon_Umbreon,
+ gMonIcon_Murkrow,
+ gMonIcon_Slowking,
+ gMonIcon_Misdreavus,
+ gMonIcon_UnownA,
+ gMonIcon_Wobbuffet,
+ gMonIcon_Girafarig,
+ gMonIcon_Pineco,
+ gMonIcon_Forretress,
+ gMonIcon_Dunsparce,
+ gMonIcon_Gligar,
+ gMonIcon_Steelix,
+ gMonIcon_Snubbull,
+ gMonIcon_Granbull,
+ gMonIcon_Qwilfish,
+ gMonIcon_Scizor,
+ gMonIcon_Shuckle,
+ gMonIcon_Heracross,
+ gMonIcon_Sneasel,
+ gMonIcon_Teddiursa,
+ gMonIcon_Ursaring,
+ gMonIcon_Slugma,
+ gMonIcon_Magcargo,
+ gMonIcon_Swinub,
+ gMonIcon_Piloswine,
+ gMonIcon_Corsola,
+ gMonIcon_Remoraid,
+ gMonIcon_Octillery,
+ gMonIcon_Delibird,
+ gMonIcon_Mantine,
+ gMonIcon_Skarmory,
+ gMonIcon_Houndour,
+ gMonIcon_Houndoom,
+ gMonIcon_Kingdra,
+ gMonIcon_Phanpy,
+ gMonIcon_Donphan,
+ gMonIcon_Porygon2,
+ gMonIcon_Stantler,
+ gMonIcon_Smeargle,
+ gMonIcon_Tyrogue,
+ gMonIcon_Hitmontop,
+ gMonIcon_Smoochum,
+ gMonIcon_Elekid,
+ gMonIcon_Magby,
+ gMonIcon_Miltank,
+ gMonIcon_Blissey,
+ gMonIcon_Raikou,
+ gMonIcon_Entei,
+ gMonIcon_Suicune,
+ gMonIcon_Larvitar,
+ gMonIcon_Pupitar,
+ gMonIcon_Tyranitar,
+ gMonIcon_Lugia,
+ gMonIcon_HoOh,
+ gMonIcon_Celebi,
+ gMonIcon_QuestionMark,
+ gMonIcon_QuestionMark,
+ gMonIcon_QuestionMark,
+ gMonIcon_QuestionMark,
+ gMonIcon_QuestionMark,
+ gMonIcon_QuestionMark,
+ gMonIcon_QuestionMark,
+ gMonIcon_QuestionMark,
+ gMonIcon_QuestionMark,
+ gMonIcon_QuestionMark,
+ gMonIcon_QuestionMark,
+ gMonIcon_QuestionMark,
+ gMonIcon_QuestionMark,
+ gMonIcon_QuestionMark,
+ gMonIcon_QuestionMark,
+ gMonIcon_QuestionMark,
+ gMonIcon_QuestionMark,
+ gMonIcon_QuestionMark,
+ gMonIcon_QuestionMark,
+ gMonIcon_QuestionMark,
+ gMonIcon_QuestionMark,
+ gMonIcon_QuestionMark,
+ gMonIcon_QuestionMark,
+ gMonIcon_QuestionMark,
+ gMonIcon_QuestionMark,
+ gMonIcon_Treecko,
+ gMonIcon_Grovyle,
+ gMonIcon_Sceptile,
+ gMonIcon_Torchic,
+ gMonIcon_Combusken,
+ gMonIcon_Blaziken,
+ gMonIcon_Mudkip,
+ gMonIcon_Marshtomp,
+ gMonIcon_Swampert,
+ gMonIcon_Poochyena,
+ gMonIcon_Mightyena,
+ gMonIcon_Zigzagoon,
+ gMonIcon_Linoone,
+ gMonIcon_Wurmple,
+ gMonIcon_Silcoon,
+ gMonIcon_Beautifly,
+ gMonIcon_Cascoon,
+ gMonIcon_Dustox,
+ gMonIcon_Lotad,
+ gMonIcon_Lombre,
+ gMonIcon_Ludicolo,
+ gMonIcon_Seedot,
+ gMonIcon_Nuzleaf,
+ gMonIcon_Shiftry,
+ gMonIcon_Nincada,
+ gMonIcon_Ninjask,
+ gMonIcon_Shedinja,
+ gMonIcon_Taillow,
+ gMonIcon_Swellow,
+ gMonIcon_Shroomish,
+ gMonIcon_Breloom,
+ gMonIcon_Spinda,
+ gMonIcon_Wingull,
+ gMonIcon_Pelipper,
+ gMonIcon_Surskit,
+ gMonIcon_Masquerain,
+ gMonIcon_Wailmer,
+ gMonIcon_Wailord,
+ gMonIcon_Skitty,
+ gMonIcon_Delcatty,
+ gMonIcon_Kecleon,
+ gMonIcon_Baltoy,
+ gMonIcon_Claydol,
+ gMonIcon_Nosepass,
+ gMonIcon_Torkoal,
+ gMonIcon_Sableye,
+ gMonIcon_Barboach,
+ gMonIcon_Whiscash,
+ gMonIcon_Luvdisc,
+ gMonIcon_Corphish,
+ gMonIcon_Crawdaunt,
+ gMonIcon_Feebas,
+ gMonIcon_Milotic,
+ gMonIcon_Carvanha,
+ gMonIcon_Sharpedo,
+ gMonIcon_Trapinch,
+ gMonIcon_Vibrava,
+ gMonIcon_Flygon,
+ gMonIcon_Makuhita,
+ gMonIcon_Hariyama,
+ gMonIcon_Electrike,
+ gMonIcon_Manectric,
+ gMonIcon_Numel,
+ gMonIcon_Camerupt,
+ gMonIcon_Spheal,
+ gMonIcon_Sealeo,
+ gMonIcon_Walrein,
+ gMonIcon_Cacnea,
+ gMonIcon_Cacturne,
+ gMonIcon_Snorunt,
+ gMonIcon_Glalie,
+ gMonIcon_Lunatone,
+ gMonIcon_Solrock,
+ gMonIcon_Azurill,
+ gMonIcon_Spoink,
+ gMonIcon_Grumpig,
+ gMonIcon_Plusle,
+ gMonIcon_Minun,
+ gMonIcon_Mawile,
+ gMonIcon_Meditite,
+ gMonIcon_Medicham,
+ gMonIcon_Swablu,
+ gMonIcon_Altaria,
+ gMonIcon_Wynaut,
+ gMonIcon_Duskull,
+ gMonIcon_Dusclops,
+ gMonIcon_Roselia,
+ gMonIcon_Slakoth,
+ gMonIcon_Vigoroth,
+ gMonIcon_Slaking,
+ gMonIcon_Gulpin,
+ gMonIcon_Swalot,
+ gMonIcon_Tropius,
+ gMonIcon_Whismur,
+ gMonIcon_Loudred,
+ gMonIcon_Exploud,
+ gMonIcon_Clamperl,
+ gMonIcon_Huntail,
+ gMonIcon_Gorebyss,
+ gMonIcon_Absol,
+ gMonIcon_Shuppet,
+ gMonIcon_Banette,
+ gMonIcon_Seviper,
+ gMonIcon_Zangoose,
+ gMonIcon_Relicanth,
+ gMonIcon_Aron,
+ gMonIcon_Lairon,
+ gMonIcon_Aggron,
+ gMonIcon_Castform,
+ gMonIcon_Volbeat,
+ gMonIcon_Illumise,
+ gMonIcon_Lileep,
+ gMonIcon_Cradily,
+ gMonIcon_Anorith,
+ gMonIcon_Armaldo,
+ gMonIcon_Ralts,
+ gMonIcon_Kirlia,
+ gMonIcon_Gardevoir,
+ gMonIcon_Bagon,
+ gMonIcon_Shelgon,
+ gMonIcon_Salamence,
+ gMonIcon_Beldum,
+ gMonIcon_Metang,
+ gMonIcon_Metagross,
+ gMonIcon_Regirock,
+ gMonIcon_Regice,
+ gMonIcon_Registeel,
+ gMonIcon_Kyogre,
+ gMonIcon_Groudon,
+ gMonIcon_Rayquaza,
+ gMonIcon_Latias,
+ gMonIcon_Latios,
+ gMonIcon_Jirachi,
+ gMonIcon_Deoxys,
+ gMonIcon_Chimecho,
+ gMonIcon_Egg,
+ gMonIcon_UnownB,
+ gMonIcon_UnownC,
+ gMonIcon_UnownD,
+ gMonIcon_UnownE,
+ gMonIcon_UnownF,
+ gMonIcon_UnownG,
+ gMonIcon_UnownH,
+ gMonIcon_UnownI,
+ gMonIcon_UnownJ,
+ gMonIcon_UnownK,
+ gMonIcon_UnownL,
+ gMonIcon_UnownM,
+ gMonIcon_UnownN,
+ gMonIcon_UnownO,
+ gMonIcon_UnownP,
+ gMonIcon_UnownQ,
+ gMonIcon_UnownR,
+ gMonIcon_UnownS,
+ gMonIcon_UnownT,
+ gMonIcon_UnownU,
+ gMonIcon_UnownV,
+ gMonIcon_UnownW,
+ gMonIcon_UnownX,
+ gMonIcon_UnownY,
+ gMonIcon_UnownZ,
+ gMonIcon_UnownExclamationMark,
+ gMonIcon_UnownQuestionMark,
+};
+
+const u8 gMonIconPaletteIndices[] =
+{
+ 0, // ??????????
+ 1, // Bulbasaur
+ 1, // Ivysaur
+ 1, // Venusaur
+ 0, // Charmander
+ 0, // Charmeleon
+ 0, // Charizard
+ 0, // Squirtle
+ 2, // Wartortle
+ 2, // Blastoise
+ 1, // Caterpie
+ 1, // Metapod
+ 0, // Butterfree
+ 1, // Weedle
+ 2, // Kakuna
+ 2, // Beedrill
+ 0, // Pidgey
+ 0, // Pidgeotto
+ 0, // Pidgeot
+ 2, // Rattata
+ 1, // Raticate
+ 0, // Spearow
+ 0, // Fearow
+ 2, // Ekans
+ 2, // Arbok
+ 2, // Pikachu
+ 0, // Raichu
+ 2, // Sandshrew
+ 2, // Sandslash
+ 2, // Nidoran♀
+ 2, // Nidorina
+ 2, // Nidoqueen
+ 2, // Nidoran♂
+ 2, // Nidorino
+ 2, // Nidoking
+ 0, // Clefairy
+ 0, // Clefable
+ 2, // Vulpix
+ 1, // Ninetales
+ 0, // Jigglypuff
+ 0, // Wigglytuff
+ 2, // Zubat
+ 2, // Golbat
+ 1, // Oddish
+ 0, // Gloom
+ 0, // Vileplume
+ 0, // Paras
+ 0, // Parasect
+ 0, // Venonat
+ 2, // Venomoth
+ 2, // Diglett
+ 2, // Dugtrio
+ 1, // Meowth
+ 1, // Persian
+ 1, // Psyduck
+ 2, // Golduck
+ 1, // Mankey
+ 2, // Primeape
+ 0, // Growlithe
+ 0, // Arcanine
+ 0, // Poliwag
+ 0, // Poliwhirl
+ 0, // Poliwrath
+ 2, // Abra
+ 2, // Kadabra
+ 2, // Alakazam
+ 0, // Machop
+ 2, // Machoke
+ 0, // Machamp
+ 1, // Bellsprout
+ 1, // Weepinbell
+ 1, // Victreebel
+ 2, // Tentacool
+ 2, // Tentacruel
+ 1, // Geodude
+ 1, // Graveler
+ 1, // Golem
+ 0, // Ponyta
+ 0, // Rapidash
+ 0, // Slowpoke
+ 0, // Slowbro
+ 0, // Magnemite
+ 0, // Magneton
+ 1, // Farfetch'd
+ 2, // Doduo
+ 2, // Dodrio
+ 2, // Seel
+ 2, // Dewgong
+ 2, // Grimer
+ 2, // Muk
+ 2, // Shellder
+ 2, // Cloyster
+ 2, // Gastly
+ 2, // Haunter
+ 2, // Gengar
+ 2, // Onix
+ 2, // Drowzee
+ 1, // Hypno
+ 2, // Krabby
+ 2, // Kingler
+ 0, // Voltorb
+ 0, // Electrode
+ 0, // Exeggcute
+ 1, // Exeggutor
+ 1, // Cubone
+ 1, // Marowak
+ 2, // Hitmonlee
+ 2, // Hitmonchan
+ 1, // Lickitung
+ 2, // Koffing
+ 2, // Weezing
+ 1, // Rhyhorn
+ 1, // Rhydon
+ 0, // Chansey
+ 0, // Tangela
+ 1, // Kangaskhan
+ 0, // Horsea
+ 0, // Seadra
+ 0, // Goldeen
+ 0, // Seaking
+ 2, // Staryu
+ 2, // Starmie
+ 0, // Mr. mime
+ 1, // Scyther
+ 2, // Jynx
+ 1, // Electabuzz
+ 0, // Magmar
+ 2, // Pinsir
+ 2, // Tauros
+ 0, // Magikarp
+ 0, // Gyarados
+ 2, // Lapras
+ 2, // Ditto
+ 2, // Eevee
+ 0, // Vaporeon
+ 0, // Jolteon
+ 0, // Flareon
+ 0, // Porygon
+ 0, // Omanyte
+ 0, // Omastar
+ 2, // Kabuto
+ 2, // Kabutops
+ 0, // Aerodactyl
+ 1, // Snorlax
+ 0, // Articuno
+ 0, // Zapdos
+ 0, // Moltres
+ 0, // Dratini
+ 0, // Dragonair
+ 2, // Dragonite
+ 2, // Mewtwo
+ 0, // Mew
+ 1, // Chikorita
+ 1, // Bayleef
+ 1, // Meganium
+ 1, // Cyndaquil
+ 1, // Quilava
+ 1, // Typhlosion
+ 2, // Totodile
+ 2, // Croconaw
+ 2, // Feraligatr
+ 2, // Sentret
+ 2, // Furret
+ 2, // Hoothoot
+ 2, // Noctowl
+ 0, // Ledyba
+ 0, // Ledian
+ 1, // Spinarak
+ 0, // Ariados
+ 2, // Crobat
+ 2, // Chinchou
+ 0, // Lanturn
+ 0, // Pichu
+ 0, // Cleffa
+ 1, // Igglybuff
+ 2, // Togepi
+ 2, // Togetic
+ 0, // Natu
+ 0, // Xatu
+ 2, // Mareep
+ 0, // Flaaffy
+ 0, // Ampharos
+ 1, // Bellossom
+ 2, // Marill
+ 2, // Azumarill
+ 1, // Sudowoodo
+ 1, // Politoed
+ 1, // Hoppip
+ 1, // Skiploom
+ 2, // Jumpluff
+ 2, // Aipom
+ 1, // Sunkern
+ 1, // Sunflora
+ 1, // Yanma
+ 0, // Wooper
+ 0, // Quagsire
+ 2, // Espeon
+ 2, // Umbreon
+ 2, // Murkrow
+ 0, // Slowking
+ 0, // Misdreavus
+ 0, // Unown A
+ 0, // Wobbuffet
+ 1, // Girafarig
+ 0, // Pineco
+ 2, // Forretress
+ 2, // Dunsparce
+ 2, // Gligar
+ 0, // Steelix
+ 0, // Snubbull
+ 2, // Granbull
+ 0, // Qwilfish
+ 0, // Scizor
+ 1, // Shuckle
+ 2, // Heracross
+ 0, // Sneasel
+ 0, // Teddiursa
+ 2, // Ursaring
+ 0, // Slugma
+ 0, // Magcargo
+ 2, // Swinub
+ 2, // Piloswine
+ 0, // Corsola
+ 0, // Remoraid
+ 0, // Octillery
+ 0, // Delibird
+ 2, // Mantine
+ 0, // Skarmory
+ 0, // Houndour
+ 0, // Houndoom
+ 0, // Kingdra
+ 0, // Phanpy
+ 0, // Donphan
+ 0, // Porygon2
+ 2, // Stantler
+ 1, // Smeargle
+ 2, // Tyrogue
+ 2, // Hitmontop
+ 1, // Smoochum
+ 1, // Elekid
+ 1, // Magby
+ 1, // Miltank
+ 1, // Blissey
+ 0, // Raikou
+ 2, // Entei
+ 0, // Suicune
+ 1, // Larvitar
+ 0, // Pupitar
+ 1, // Tyranitar
+ 0, // Lugia
+ 1, // Ho-Oh
+ 1, // Celebi
+ 0, // ?
+ 0, // ?
+ 0, // ?
+ 0, // ?
+ 0, // ?
+ 0, // ?
+ 0, // ?
+ 0, // ?
+ 0, // ?
+ 0, // ?
+ 0, // ?
+ 0, // ?
+ 0, // ?
+ 0, // ?
+ 0, // ?
+ 0, // ?
+ 0, // ?
+ 0, // ?
+ 0, // ?
+ 0, // ?
+ 0, // ?
+ 0, // ?
+ 0, // ?
+ 0, // ?
+ 0, // ?
+ 1, // Treecko
+ 0, // Grovyle
+ 1, // Sceptile
+ 0, // Torchic
+ 0, // Combusken
+ 0, // Blaziken
+ 0, // Mudkip
+ 0, // Marshtomp
+ 0, // Swampert
+ 2, // Poochyena
+ 2, // Mightyena
+ 2, // Zigzagoon
+ 2, // Linoone
+ 0, // Wurmple
+ 2, // Silcoon
+ 0, // Beautifly
+ 2, // Cascoon
+ 1, // Dustox
+ 1, // Lotad
+ 1, // Lombre
+ 1, // Ludicolo
+ 1, // Seedot
+ 1, // Nuzleaf
+ 0, // Shiftry
+ 1, // Nincada
+ 1, // Ninjask
+ 1, // Shedinja
+ 2, // Taillow
+ 2, // Swellow
+ 1, // Shroomish
+ 1, // Breloom
+ 1, // Spinda
+ 0, // Wingull
+ 0, // Pelipper
+ 2, // Surskit
+ 0, // Masquerain
+ 2, // Wailmer
+ 0, // Wailord
+ 0, // Skitty
+ 2, // Delcatty
+ 1, // Kecleon
+ 1, // Baltoy
+ 0, // Claydol
+ 0, // Nosepass
+ 1, // Torkoal
+ 2, // Sableye
+ 0, // Barboach
+ 0, // Whiscash
+ 0, // Luvdisc
+ 0, // Corphish
+ 0, // Crawdaunt
+ 2, // Feebas
+ 0, // Milotic
+ 0, // Carvanha
+ 0, // Sharpedo
+ 1, // Trapinch
+ 1, // Vibrava
+ 1, // Flygon
+ 2, // Makuhita
+ 1, // Hariyama
+ 1, // Electrike
+ 0, // Manectric
+ 1, // Numel
+ 0, // Camerupt
+ 2, // Spheal
+ 2, // Sealeo
+ 0, // Walrein
+ 1, // Cacnea
+ 1, // Cacturne
+ 2, // Snorunt
+ 0, // Glalie
+ 1, // Lunatone
+ 0, // Solrock
+ 2, // Azurill
+ 0, // Spoink
+ 2, // Grumpig
+ 0, // Plusle
+ 0, // Minun
+ 2, // Mawile
+ 0, // Meditite
+ 0, // Medicham
+ 0, // Swablu
+ 0, // Altaria
+ 0, // Wynaut
+ 0, // Duskull
+ 0, // Dusclops
+ 0, // Roselia
+ 2, // Slakoth
+ 2, // Vigoroth
+ 1, // Slaking
+ 1, // Gulpin
+ 2, // Swalot
+ 1, // Tropius
+ 0, // Whismur
+ 2, // Loudred
+ 2, // Exploud
+ 0, // Clamperl
+ 0, // Huntail
+ 0, // Gorebyss
+ 0, // Absol
+ 0, // Shuppet
+ 0, // Banette
+ 2, // Seviper
+ 0, // Zangoose
+ 1, // Relicanth
+ 2, // Aron
+ 2, // Lairon
+ 2, // Aggron
+ 0, // Castform
+ 0, // Volbeat
+ 2, // Illumise
+ 2, // Lileep
+ 0, // Cradily
+ 0, // Anorith
+ 0, // Armaldo
+ 1, // Ralts
+ 1, // Kirlia
+ 1, // Gardevoir
+ 2, // Bagon
+ 2, // Shelgon
+ 0, // Salamence
+ 0, // Beldum
+ 0, // Metang
+ 0, // Metagross
+ 2, // Regirock
+ 2, // Regice
+ 2, // Registeel
+ 2, // Kyogre
+ 0, // Groudon
+ 1, // Rayquaza
+ 0, // Latias
+ 2, // Latios
+ 0, // Jirachi
+ 0, // Deoxys
+ 0, // Chimecho
+ 1, // Egg
+ 0, // Unown B
+ 0, // Unown C
+ 0, // Unown D
+ 0, // Unown E
+ 0, // Unown F
+ 0, // Unown G
+ 0, // Unown H
+ 0, // Unown I
+ 0, // Unown J
+ 0, // Unown K
+ 0, // Unown L
+ 0, // Unown M
+ 0, // Unown N
+ 0, // Unown O
+ 0, // Unown P
+ 0, // Unown Q
+ 0, // Unown R
+ 0, // Unown S
+ 0, // Unown T
+ 0, // Unown U
+ 0, // Unown V
+ 0, // Unown W
+ 0, // Unown X
+ 0, // Unown Y
+ 0, // Unown Z
+ 0, // Unown Exclamation Mark
+ 0, // Unown Question Mark
+};
+
+const struct SpritePalette gMonIconPaletteTable[] =
+{
+ { gMonIconPalettes[0], POKE_ICON_BASE_PAL_TAG + 0 },
+ { gMonIconPalettes[1], POKE_ICON_BASE_PAL_TAG + 1 },
+ { gMonIconPalettes[2], POKE_ICON_BASE_PAL_TAG + 2 },
+
+// There are only 3 actual palettes. The following are unused
+// and don't point to valid data.
+ { gMonIconPalettes[3], POKE_ICON_BASE_PAL_TAG + 3 },
+ { gMonIconPalettes[4], POKE_ICON_BASE_PAL_TAG + 4 },
+ { gMonIconPalettes[5], POKE_ICON_BASE_PAL_TAG + 5 },
+};
+
+const struct OamData sMonIconOamData =
+{
+ .y = 0,
+ .affineMode = 0,
+ .objMode = 0,
+ .mosaic = 0,
+ .bpp = 0,
+ .shape = 0,
+ .x = 0,
+ .matrixNum = 0,
+ .size = 2,
+ .tileNum = 0,
+ .priority = 1,
+ .paletteNum = 0,
+ .affineParam = 0
+};
+
+// fastest to slowest
+
+static const union AnimCmd sAnim_0[] =
+{
+ ANIMCMD_FRAME(0, 6),
+ ANIMCMD_FRAME(1, 6),
+ ANIMCMD_JUMP(0),
+};
+
+static const union AnimCmd sAnim_1[] =
+{
+ ANIMCMD_FRAME(0, 8),
+ ANIMCMD_FRAME(1, 8),
+ ANIMCMD_JUMP(0),
+};
+
+static const union AnimCmd sAnim_2[] =
+{
+ ANIMCMD_FRAME(0, 14),
+ ANIMCMD_FRAME(1, 14),
+ ANIMCMD_JUMP(0),
+};
+
+static const union AnimCmd sAnim_3[] =
+{
+ ANIMCMD_FRAME(0, 22),
+ ANIMCMD_FRAME(1, 22),
+ ANIMCMD_JUMP(0),
+};
+
+static const union AnimCmd sAnim_4[] =
+{
+ ANIMCMD_FRAME(0, 29),
+ ANIMCMD_FRAME(0, 29), // frame 0 is repeated
+ ANIMCMD_JUMP(0),
+};
+
+const union AnimCmd *const sMonIconAnims[] =
+{
+ sAnim_0,
+ sAnim_1,
+ sAnim_2,
+ sAnim_3,
+ sAnim_4,
+};
+
+static const union AffineAnimCmd sAffineAnim_0[] =
+{
+ AFFINEANIMCMD_FRAME(0, 0, 0, 10),
+ AFFINEANIMCMD_END,
+};
+
+static const union AffineAnimCmd sAffineAnim_1[] =
+{
+ AFFINEANIMCMD_FRAME(-2, -2, 0, 122),
+ AFFINEANIMCMD_END,
+};
+
+const union AffineAnimCmd *const sMonIconAffineAnims[] =
+{
+ sAffineAnim_0,
+ sAffineAnim_1,
+};
+
+const u16 sSpriteImageSizes[3][4] =
+{
+ // square
+ {
+ 0x20, // 1×1
+ 0x80, // 2×2
+ 0x200, // 4×4
+ 0x800, // 8×8
+ },
+
+ // horizontal rectangle
+ {
+ 0x40, // 2×1
+ 0x80, // 4×1
+ 0x100, // 4×2
+ 0x400, // 8×4
+ },
+
+ // vertical rectangle
+ {
+ 0x40, // 1×2
+ 0x80, // 1×4
+ 0x100, // 2×4
+ 0x400, // 4×8
+ },
+};
diff --git a/src/pokemon_storage_system.c b/src/pokemon_storage_system.c
index bdf4427c7..bb196dd27 100644
--- a/src/pokemon_storage_system.c
+++ b/src/pokemon_storage_system.c
@@ -5,9 +5,76 @@
#include "event_data.h"
#include "string_util.h"
#include "text.h"
+#include "strings.h"
+#include "window.h"
IWRAM_DATA u8 gUnknown_03000F78[0x188];
+struct OptionAndDescription
+{
+ const u8 *optionTxt;
+ const u8 *descriptionTxt;
+};
+
+// const rom data
+const struct OptionAndDescription gUnknown_085716C0[] =
+{
+ {gText_WithdrawPokemon, gText_WithdrawMonDescription},
+ {gText_DepositPokemon, gText_DepositMonDescription},
+ {gText_MovePokemon, gText_MoveMonDescription},
+ {gText_MoveItems, gText_MoveItemsDescription},
+ {gText_SeeYa, gText_SeeYaDescription}
+};
+
+const struct WindowTemplate gUnknown_085716E8 = {0, 1, 1, 0x11, 0xA, 0xF, 1};
+
+static const union AnimCmd sSpriteAnim_85716F0[] =
+{
+ ANIMCMD_FRAME(0, 5),
+ ANIMCMD_END
+};
+
+static const union AnimCmd sSpriteAnim_85716F8[] =
+{
+ ANIMCMD_FRAME(4, 5),
+ ANIMCMD_END
+};
+
+static const union AnimCmd sSpriteAnim_8571700[] =
+{
+ ANIMCMD_FRAME(6, 5),
+ ANIMCMD_END
+};
+
+static const union AnimCmd sSpriteAnim_8571708[] =
+{
+ ANIMCMD_FRAME(10, 5),
+ ANIMCMD_END
+};
+
+const union AnimCmd *const sSpriteAnimTable_8571710[] =
+{
+ sSpriteAnim_85716F0,
+ sSpriteAnim_85716F8,
+ sSpriteAnim_8571700,
+ sSpriteAnim_8571708
+};
+
+static const union AffineAnimCmd sSpriteAffineAnim_8571720[] =
+{
+ AFFINEANIMCMD_FRAME(0xE0, 0xE0, 0, 0),
+ AFFINEANIMCMD_END
+};
+
+static const union AffineAnimCmd *const sSpriteAffineAnimTable_8571730[] =
+{
+ sSpriteAffineAnim_8571720
+};
+
+const struct TextColor gUnknown_08571734[] = {4, 0xF, 0xE};
+const u8 gUnknown_08571737[] = _("/30");
+
+// code
u8 CountMonsInBox(u8 boxId)
{
u16 i, count;
diff --git a/src/pokemon_summary_screen.c b/src/pokemon_summary_screen.c
index ba0c4dde7..d659b2a02 100755
--- a/src/pokemon_summary_screen.c
+++ b/src/pokemon_summary_screen.c
@@ -50,7 +50,7 @@ extern struct UnkStruct_61CC04 gUnknown_0861CC04;
extern struct UnkStruct_61CC04 gUnknown_0861CC10;
extern struct UnkStruct_61CC04 gUnknown_0861CBEC;
extern struct UnkStruct_61CC04 gUnknown_0861CBF8;
-extern u16 gUnknown_08DC3CD4[];
+extern u16 gSummaryScreenWindow_Tilemap[];
extern struct ContestMove gContestMoves[];
extern struct ContestEffect gContestEffects[];
extern struct WindowTemplate gUnknown_0861CC24;
@@ -93,7 +93,7 @@ extern struct CompressedSpriteSheet gUnknown_0861D074;
extern struct CompressedSpriteSheet gUnknown_0861D0F8;
extern struct CompressedSpritePalette gUnknown_0861D100;
extern struct CompressedSpritePalette gUnknown_0861D07C;
-extern u8 gUnknown_08D97B84;
+extern u8 gMoveTypes_Pal;
extern u8 gUnknown_08D97D0C;
extern void reset_temp_tile_data_buffers();
extern void decompress_and_copy_tile_data_to_vram(u8 a, void* tiledata, u8 b, u8 c, u8 d);
@@ -648,7 +648,7 @@ u8 sub_81BFEB0()
gUnknown_0203CF1C->unk40F0++;
break;
case 12:
- LoadCompressedPalette(&gUnknown_08D97B84, 0x1D0, 0x60);
+ LoadCompressedPalette(&gMoveTypes_Pal, 0x1D0, 0x60);
gUnknown_0203CF1C->unk40F0 = 0;
return 1;
}
@@ -2343,18 +2343,18 @@ void sub_81C2194(u16 *a, u16 b, u8 c)
{
for (i = 0; i < 20; i++)
{
- a[(i + var) << 1] = gUnknown_08DC3CD4[i] + b;
- a[((i + var) << 1) + 0x40] = gUnknown_08DC3CD4[i] + b;
- a[((i + var) << 1) + 0x80] = gUnknown_08DC3CD4[i + 20] + b;
+ a[(i + var) << 1] = gSummaryScreenWindow_Tilemap[i] + b;
+ a[((i + var) << 1) + 0x40] = gSummaryScreenWindow_Tilemap[i] + b;
+ a[((i + var) << 1) + 0x80] = gSummaryScreenWindow_Tilemap[i + 20] + b;
}
}
else
{
for (i = 0; i < 20; i++)
{
- a[(i + var)] = gUnknown_08DC3CD4[i + 20] + b;
- a[((i + var)) + 0x40] = gUnknown_08DC3CD4[i + 40] + b;
- a[((i + var)) + 0x80] = gUnknown_08DC3CD4[i + 40] + b;
+ a[(i + var)] = gSummaryScreenWindow_Tilemap[i + 20] + b;
+ a[((i + var)) + 0x40] = gSummaryScreenWindow_Tilemap[i + 40] + b;
+ a[((i + var)) + 0x80] = gSummaryScreenWindow_Tilemap[i + 40] + b;
}
}
}
@@ -2372,7 +2372,7 @@ void sub_81C2194(u16 *a, u16 b, u8 c)
cmp r2, 0\n\
bne _081C21E4\n\
movs r3, 0\n\
- ldr r5, =gUnknown_08DC3CD4\n\
+ ldr r5, =gSummaryScreenWindow_Tilemap\n\
_081C21A8:\n\
adds r2, r7, r3\n\
lsls r2, 1\n\
@@ -2402,7 +2402,7 @@ _081C21A8:\n\
.pool\n\
_081C21E4:\n\
movs r3, 0\n\
- ldr r5, =gUnknown_08DC3CD4\n\
+ ldr r5, =gSummaryScreenWindow_Tilemap\n\
_081C21E8:\n\
adds r1, r7, r3\n\
lsls r1, 1\n\
diff --git a/src/rayquaza_scene.c b/src/rayquaza_scene.c
new file mode 100644
index 000000000..ce8747395
--- /dev/null
+++ b/src/rayquaza_scene.c
@@ -0,0 +1,1164 @@
+#include "global.h"
+#include "sprite.h"
+#include "task.h"
+#include "graphics.h"
+#include "bg.h"
+
+struct UnkRayquazaStruct
+{
+ u32 field_0;
+ u32 field_4;
+ u32 field_8;
+};
+
+// this file's functions
+void sub_81D7134(u8 taskId);
+void sub_81D7F4C(u8 taskId);
+void sub_81D84EC(u8 taskId);
+void sub_81D8980(u8 taskId);
+void sub_81D8DB4(u8 taskId);
+void sub_81D6800(u8 taskId);
+
+void sub_81D8260(struct Sprite *sprite);
+void sub_81D961C(struct Sprite *sprite);
+
+// const rom data
+const TaskFunc gUnknown_0862A6A0[] =
+{
+ sub_81D7134,
+ sub_81D7134,
+ sub_81D7F4C,
+ sub_81D84EC,
+ sub_81D8980,
+ sub_81D8DB4,
+ sub_81D6800
+};
+
+static const struct OamData sOamData_862A6BC =
+{
+ .y = 0,
+ .affineMode = 0,
+ .objMode = 0,
+ .mosaic = 0,
+ .bpp = 0,
+ .shape = 0,
+ .x = 0,
+ .matrixNum = 0,
+ .size = 3,
+ .tileNum = 0,
+ .priority = 2,
+ .paletteNum = 0,
+ .affineParam = 0
+};
+
+static const struct OamData sOamData_862A6C4 =
+{
+ .y = 0,
+ .affineMode = 0,
+ .objMode = 0,
+ .mosaic = 0,
+ .bpp = 0,
+ .shape = 0,
+ .x = 0,
+ .matrixNum = 0,
+ .size = 2,
+ .tileNum = 0,
+ .priority = 2,
+ .paletteNum = 0,
+ .affineParam = 0
+};
+
+static const struct OamData sOamData_862A6CC =
+{
+ .y = 0,
+ .affineMode = 0,
+ .objMode = 0,
+ .mosaic = 0,
+ .bpp = 0,
+ .shape = 1,
+ .x = 0,
+ .matrixNum = 0,
+ .size = 3,
+ .tileNum = 0,
+ .priority = 2,
+ .paletteNum = 0,
+ .affineParam = 0
+};
+
+static const struct OamData sOamData_862A6D4 =
+{
+ .y = 0,
+ .affineMode = 0,
+ .objMode = 0,
+ .mosaic = 0,
+ .bpp = 0,
+ .shape = 1,
+ .x = 0,
+ .matrixNum = 0,
+ .size = 2,
+ .tileNum = 0,
+ .priority = 2,
+ .paletteNum = 0,
+ .affineParam = 0
+};
+
+static const struct OamData sOamData_862A6DC =
+{
+ .y = 0,
+ .affineMode = 0,
+ .objMode = 0,
+ .mosaic = 0,
+ .bpp = 0,
+ .shape = 1,
+ .x = 0,
+ .matrixNum = 0,
+ .size = 0,
+ .tileNum = 0,
+ .priority = 2,
+ .paletteNum = 0,
+ .affineParam = 0
+};
+
+static const struct OamData sOamData_862A6E4 =
+{
+ .y = 0,
+ .affineMode = 0,
+ .objMode = 0,
+ .mosaic = 0,
+ .bpp = 0,
+ .shape = 2,
+ .x = 0,
+ .matrixNum = 0,
+ .size = 2,
+ .tileNum = 0,
+ .priority = 2,
+ .paletteNum = 0,
+ .affineParam = 0
+};
+
+static const struct OamData sOamData_862A6EC =
+{
+ .y = 0,
+ .affineMode = 0,
+ .objMode = 0,
+ .mosaic = 0,
+ .bpp = 0,
+ .shape = 0,
+ .x = 0,
+ .matrixNum = 0,
+ .size = 1,
+ .tileNum = 0,
+ .priority = 2,
+ .paletteNum = 0,
+ .affineParam = 0
+};
+
+static const struct OamData sOamData_862A6F4 =
+{
+ .y = 0,
+ .affineMode = 0,
+ .objMode = 0,
+ .mosaic = 0,
+ .bpp = 0,
+ .shape = 1,
+ .x = 0,
+ .matrixNum = 0,
+ .size = 1,
+ .tileNum = 0,
+ .priority = 2,
+ .paletteNum = 0,
+ .affineParam = 0
+};
+
+static const union AnimCmd sSpriteAnim_862A6FC[] =
+{
+ ANIMCMD_FRAME(0, 30),
+ ANIMCMD_FRAME(64, 30),
+ ANIMCMD_FRAME(128, 30),
+ ANIMCMD_FRAME(64, 30),
+ ANIMCMD_JUMP(0),
+};
+
+static const union AnimCmd sSpriteAnim_862A710[] =
+{
+ ANIMCMD_FRAME(192, 30),
+ ANIMCMD_FRAME(256, 30),
+ ANIMCMD_FRAME(320, 30),
+ ANIMCMD_FRAME(256, 30),
+ ANIMCMD_JUMP(0),
+};
+
+static const union AnimCmd *const sSpriteAnimTable_862A724[] =
+{
+ sSpriteAnim_862A6FC,
+ sSpriteAnim_862A710
+};
+
+const struct SpriteTemplate gUnknown_0862A72C =
+{
+ .tileTag = 30505,
+ .paletteTag = 30505,
+ .oam = &sOamData_862A6BC,
+ .anims = sSpriteAnimTable_862A724,
+ .images = NULL,
+ .affineAnims = gDummySpriteAffineAnimTable,
+ .callback = SpriteCallbackDummy,
+};
+
+static const union AnimCmd sSpriteAnim_862A744[] =
+{
+ ANIMCMD_FRAME(0, 1),
+ ANIMCMD_END
+};
+
+static const union AnimCmd *const sSpriteAnimTable_862A74C[] =
+{
+ sSpriteAnim_862A744
+};
+
+const struct SpriteTemplate gUnknown_0862A750 =
+{
+ .tileTag = 30506,
+ .paletteTag = 30505,
+ .oam = &sOamData_862A6C4,
+ .anims = sSpriteAnimTable_862A74C,
+ .images = NULL,
+ .affineAnims = gDummySpriteAffineAnimTable,
+ .callback = SpriteCallbackDummy,
+};
+
+static const union AnimCmd sSpriteAnim_862A768[] =
+{
+ ANIMCMD_FRAME(0, 1),
+ ANIMCMD_END
+};
+
+static const union AnimCmd *const sSpriteAnimTable_862A770[] =
+{
+ sSpriteAnim_862A768
+};
+
+const struct SpriteTemplate gUnknown_0862A774 =
+{
+ .tileTag = 30507,
+ .paletteTag = 30505,
+ .oam = &sOamData_862A6CC,
+ .anims = sSpriteAnimTable_862A770,
+ .images = NULL,
+ .affineAnims = gDummySpriteAffineAnimTable,
+ .callback = SpriteCallbackDummy,
+};
+
+static const union AnimCmd sSpriteAnim_862A78C[] =
+{
+ ANIMCMD_FRAME(0, 1),
+ ANIMCMD_END
+};
+
+static const union AnimCmd sSpriteAnim_862A794[] =
+{
+ ANIMCMD_FRAME(8, 1),
+ ANIMCMD_END
+};
+
+static const union AnimCmd sSpriteAnim_862A79C[] =
+{
+ ANIMCMD_FRAME(16, 1),
+ ANIMCMD_END
+};
+
+static const union AnimCmd sSpriteAnim_862A7A4[] =
+{
+ ANIMCMD_FRAME(24, 1),
+ ANIMCMD_END
+};
+
+static const union AnimCmd sSpriteAnim_862A7AC[] =
+{
+ ANIMCMD_FRAME(32, 1),
+ ANIMCMD_END
+};
+
+static const union AnimCmd sSpriteAnim_862A7B4[] =
+{
+ ANIMCMD_FRAME(40, 1),
+ ANIMCMD_END
+};
+
+static const union AnimCmd sSpriteAnim_862A7BC[] =
+{
+ ANIMCMD_FRAME(48, 36),
+ ANIMCMD_FRAME(64, 36),
+ ANIMCMD_FRAME(80, 36),
+ ANIMCMD_FRAME(64, 36),
+ ANIMCMD_JUMP(0),
+};
+
+static const union AnimCmd sSpriteAnim_862A7D0[] =
+{
+ ANIMCMD_FRAME(56, 36),
+ ANIMCMD_FRAME(72, 36),
+ ANIMCMD_FRAME(88, 36),
+ ANIMCMD_FRAME(72, 36),
+ ANIMCMD_JUMP(0),
+};
+
+static const union AnimCmd sSpriteAnim_862A7E4[] =
+{
+ ANIMCMD_FRAME(96, 36),
+ ANIMCMD_FRAME(104, 36),
+ ANIMCMD_FRAME(112, 36),
+ ANIMCMD_FRAME(104, 36),
+ ANIMCMD_JUMP(0),
+};
+
+static const union AnimCmd *const sSpriteAnimTable_862A7F8[] =
+{
+ sSpriteAnim_862A78C,
+ sSpriteAnim_862A794,
+ sSpriteAnim_862A79C,
+ sSpriteAnim_862A7A4,
+ sSpriteAnim_862A7AC,
+ sSpriteAnim_862A7B4,
+ sSpriteAnim_862A7BC,
+ sSpriteAnim_862A7D0,
+ sSpriteAnim_862A7E4
+};
+
+const struct SpriteTemplate gUnknown_0862A81C =
+{
+ .tileTag = 30508,
+ .paletteTag = 30508,
+ .oam = &sOamData_862A6D4,
+ .anims = sSpriteAnimTable_862A7F8,
+ .images = NULL,
+ .affineAnims = gDummySpriteAffineAnimTable,
+ .callback = SpriteCallbackDummy,
+};
+
+static const union AnimCmd sSpriteAnim_862A834[] =
+{
+ ANIMCMD_FRAME(0, 36),
+ ANIMCMD_FRAME(2, 36),
+ ANIMCMD_FRAME(4, 36),
+ ANIMCMD_FRAME(2, 36),
+ ANIMCMD_JUMP(0),
+};
+
+static const union AnimCmd *const sSpriteAnimTable_862A848[] =
+{
+ sSpriteAnim_862A834
+};
+
+const struct SpriteTemplate gUnknown_0862A84C =
+{
+ .tileTag = 30509,
+ .paletteTag = 30508,
+ .oam = &sOamData_862A6DC,
+ .anims = sSpriteAnimTable_862A848,
+ .images = NULL,
+ .affineAnims = gDummySpriteAffineAnimTable,
+ .callback = SpriteCallbackDummy,
+};
+
+const struct SpriteTemplate gUnknown_0862A864 =
+{
+ .tileTag = 30510,
+ .paletteTag = 30508,
+ .oam = &sOamData_862A6C4,
+ .anims = sSpriteAnimTable_862A74C,
+ .images = NULL,
+ .affineAnims = gDummySpriteAffineAnimTable,
+ .callback = SpriteCallbackDummy,
+};
+
+const struct UnkRayquazaStruct gUnknown_0862A87C = {0x4000014, 0xA2600001, 1};
+
+const struct BgTemplate gUnknown_0862A888[] =
+{
+ {
+ .bg = 0,
+ .charBaseIndex = 0,
+ .mapBaseIndex = 31,
+ .screenSize = 0,
+ .paletteMode = 0,
+ .priority = 0,
+ .baseTile = 0
+ },
+ {
+ .bg = 1,
+ .charBaseIndex = 0,
+ .mapBaseIndex = 30,
+ .screenSize = 0,
+ .paletteMode = 0,
+ .priority = 2,
+ .baseTile = 0
+ },
+ {
+ .bg = 2,
+ .charBaseIndex = 0,
+ .mapBaseIndex = 29,
+ .screenSize = 0,
+ .paletteMode = 0,
+ .priority = 1,
+ .baseTile = 0
+ },
+};
+
+static const union AnimCmd sSpriteAnim_862A894[] =
+{
+ ANIMCMD_FRAME(0, 20),
+ ANIMCMD_FRAME(64, 20),
+ ANIMCMD_FRAME(128, 20),
+ ANIMCMD_FRAME(64, 20),
+ ANIMCMD_JUMP(0),
+};
+
+static const union AnimCmd sSpriteAnim_862A8A8[] =
+{
+ ANIMCMD_FRAME(192, 20),
+ ANIMCMD_FRAME(256, 20),
+ ANIMCMD_FRAME(320, 20),
+ ANIMCMD_FRAME(256, 20),
+ ANIMCMD_JUMP(0),
+};
+
+static const union AnimCmd *const sSpriteAnimTable_862A8BC[] =
+{
+ sSpriteAnim_862A894,
+ sSpriteAnim_862A8A8
+};
+
+const struct CompressedSpriteSheet gUnknown_0862A8C4 =
+{
+ gRaySceneGroudon_Gfx, 0x3000, 30505
+};
+
+const struct CompressedSpritePalette gUnknown_0862A8CC =
+{
+ gRaySceneGroudon_Pal, 30505
+};
+
+const struct SpriteTemplate gUnknown_0862A8D4 =
+{
+ .tileTag = 30505,
+ .paletteTag = 30505,
+ .oam = &sOamData_862A6BC,
+ .anims = sSpriteAnimTable_862A8BC,
+ .images = NULL,
+ .affineAnims = gDummySpriteAffineAnimTable,
+ .callback = SpriteCallbackDummy,
+};
+
+static const union AnimCmd sSpriteAnim_862A8EC[] =
+{
+ ANIMCMD_FRAME(0, 1),
+ ANIMCMD_END
+};
+
+static const union AnimCmd *const sSpriteAnimTable_862A8F4[] =
+{
+ sSpriteAnim_862A8EC
+};
+
+const struct CompressedSpriteSheet gUnknown_0862A8F8 =
+{
+ gRaySceneGroudon2_Gfx, 0x200, 30506
+};
+
+const struct SpriteTemplate gUnknown_0862A900 =
+{
+ .tileTag = 30506,
+ .paletteTag = 30505,
+ .oam = &sOamData_862A6C4,
+ .anims = sSpriteAnimTable_862A8F4,
+ .images = NULL,
+ .affineAnims = gDummySpriteAffineAnimTable,
+ .callback = SpriteCallbackDummy,
+};
+
+static const union AnimCmd sSpriteAnim_862A918[] =
+{
+ ANIMCMD_FRAME(0, 1),
+ ANIMCMD_END
+};
+
+static const union AnimCmd *const sSpriteAnimTable_862A920[] =
+{
+ sSpriteAnim_862A918
+};
+
+const struct CompressedSpriteSheet gUnknown_0862A924 =
+{
+ gRaySceneGroudon3_Gfx, 0x400, 30507
+};
+
+const struct SpriteTemplate gUnknown_0862A92C =
+{
+ .tileTag = 30507,
+ .paletteTag = 30505,
+ .oam = &sOamData_862A6CC,
+ .anims = sSpriteAnimTable_862A920,
+ .images = NULL,
+ .affineAnims = gDummySpriteAffineAnimTable,
+ .callback = SpriteCallbackDummy,
+};
+
+static const union AnimCmd sSpriteAnim_862A944[] =
+{
+ ANIMCMD_FRAME(0, 1),
+ ANIMCMD_END
+};
+
+static const union AnimCmd sSpriteAnim_862A94C[] =
+{
+ ANIMCMD_FRAME(8, 1),
+ ANIMCMD_END
+};
+
+static const union AnimCmd sSpriteAnim_862A954[] =
+{
+ ANIMCMD_FRAME(16, 1),
+ ANIMCMD_END
+};
+
+static const union AnimCmd sSpriteAnim_862A95C[] =
+{
+ ANIMCMD_FRAME(24, 1),
+ ANIMCMD_END
+};
+
+static const union AnimCmd sSpriteAnim_862A964[] =
+{
+ ANIMCMD_FRAME(32, 1),
+ ANIMCMD_END
+};
+
+static const union AnimCmd sSpriteAnim_862A96C[] =
+{
+ ANIMCMD_FRAME(40, 1),
+ ANIMCMD_END
+};
+
+static const union AnimCmd sSpriteAnim_862A974[] =
+{
+ ANIMCMD_FRAME(48, 24),
+ ANIMCMD_FRAME(64, 24),
+ ANIMCMD_FRAME(80, 24),
+ ANIMCMD_FRAME(64, 24),
+ ANIMCMD_JUMP(0),
+};
+
+static const union AnimCmd sSpriteAnim_862A988[] =
+{
+ ANIMCMD_FRAME(56, 24),
+ ANIMCMD_FRAME(72, 24),
+ ANIMCMD_FRAME(88, 24),
+ ANIMCMD_FRAME(72, 24),
+ ANIMCMD_JUMP(0),
+};
+
+static const union AnimCmd sSpriteAnim_862A99C[] =
+{
+ ANIMCMD_FRAME(96, 24),
+ ANIMCMD_FRAME(104, 24),
+ ANIMCMD_FRAME(112, 24),
+ ANIMCMD_FRAME(104, 24),
+ ANIMCMD_JUMP(0),
+};
+
+static const union AnimCmd *const sSpriteAnimTable_862A9B0[] =
+{
+ sSpriteAnim_862A944,
+ sSpriteAnim_862A94C,
+ sSpriteAnim_862A954,
+ sSpriteAnim_862A95C,
+ sSpriteAnim_862A964,
+ sSpriteAnim_862A96C,
+ sSpriteAnim_862A974,
+ sSpriteAnim_862A988,
+ sSpriteAnim_862A99C
+};
+
+const struct CompressedSpriteSheet gUnknown_0862A9D4 =
+{
+ gRaySceneKyogre_Gfx, 0xF00, 30508
+};
+
+const struct CompressedSpritePalette gUnknown_0862A9DC =
+{
+ gRaySceneKyogre_Pal, 30508
+};
+
+const struct SpriteTemplate gUnknown_0862A9E4 =
+{
+ .tileTag = 30508,
+ .paletteTag = 30508,
+ .oam = &sOamData_862A6D4,
+ .anims = sSpriteAnimTable_862A9B0,
+ .images = NULL,
+ .affineAnims = gDummySpriteAffineAnimTable,
+ .callback = SpriteCallbackDummy,
+};
+
+static const union AnimCmd sSpriteAnim_862A9FC[] =
+{
+ ANIMCMD_FRAME(0, 24),
+ ANIMCMD_FRAME(2, 24),
+ ANIMCMD_FRAME(4, 24),
+ ANIMCMD_FRAME(2, 24),
+ ANIMCMD_JUMP(0),
+};
+
+static const union AnimCmd *const sSpriteAnimTable_862AA10[] =
+{
+ sSpriteAnim_862A9FC
+};
+
+const struct CompressedSpriteSheet gUnknown_0862AA14 =
+{
+ gRaySceneKyogre2_Gfx, 0xC0, 30509
+};
+
+const struct SpriteTemplate gUnknown_0862AA1C =
+{
+ .tileTag = 30509,
+ .paletteTag = 30508,
+ .oam = &sOamData_862A6DC,
+ .anims = sSpriteAnimTable_862AA10,
+ .images = NULL,
+ .affineAnims = gDummySpriteAffineAnimTable,
+ .callback = SpriteCallbackDummy,
+};
+
+const struct CompressedSpriteSheet gUnknown_0862AA34 =
+{
+ gRaySceneKyogre3_Gfx, 0x200, 30510
+};
+
+const struct SpriteTemplate gUnknown_0862AA3C =
+{
+ .tileTag = 30510,
+ .paletteTag = 30508,
+ .oam = &sOamData_862A6C4,
+ .anims = sSpriteAnimTable_862A8F4,
+ .images = NULL,
+ .affineAnims = gDummySpriteAffineAnimTable,
+ .callback = SpriteCallbackDummy,
+};
+
+const struct BgTemplate gUnknown_0862AA54[] =
+{
+ {
+ .bg = 0,
+ .charBaseIndex = 2,
+ .mapBaseIndex = 31,
+ .screenSize = 0,
+ .paletteMode = 0,
+ .priority = 0,
+ .baseTile = 0
+ },
+ {
+ .bg = 1,
+ .charBaseIndex = 0,
+ .mapBaseIndex = 30,
+ .screenSize = 0,
+ .paletteMode = 0,
+ .priority = 2,
+ .baseTile = 0
+ },
+ {
+ .bg = 2,
+ .charBaseIndex = 1,
+ .mapBaseIndex = 29,
+ .screenSize = 1,
+ .paletteMode = 0,
+ .priority = 1,
+ .baseTile = 0
+ }
+};
+
+static const union AnimCmd sSpriteAnim_862AA60[] =
+{
+ ANIMCMD_FRAME(0, 1),
+ ANIMCMD_END
+};
+
+static const union AnimCmd *const sSpriteAnimTable_862AA68[] =
+{
+ sSpriteAnim_862AA60
+};
+
+static const union AffineAnimCmd sSpriteAffineAnim_862AA6C[] =
+{
+ AFFINEANIMCMD_FRAME(-64, -64, 0, 1),
+ AFFINEANIMCMD_FRAME(32, 32, 0, 14),
+ AFFINEANIMCMD_FRAME(256, 256, 0, 0),
+ AFFINEANIMCMD_JUMP(0)
+};
+
+static const union AffineAnimCmd *const sSpriteAffineAnimTable_862AA8C[] =
+{
+ sSpriteAffineAnim_862AA6C
+};
+
+const struct CompressedSpriteSheet gUnknown_0862AA90 =
+{
+ gRaySceneSmoke_Gfx, 0x100, 30555
+};
+
+const struct CompressedSpritePalette gUnknown_0862AA98 =
+{
+ gRaySceneSmoke_Pal, 30555
+};
+
+const struct SpriteTemplate gUnknown_0862AAA0 =
+{
+ .tileTag = 30555,
+ .paletteTag = 30555,
+ .oam = &sOamData_862A6D4,
+ .anims = sSpriteAnimTable_862AA68,
+ .images = NULL,
+ .affineAnims = sSpriteAffineAnimTable_862AA8C,
+ .callback = sub_81D8260,
+};
+
+const s8 gUnknown_0862AAB8[][2] =
+{
+ {-1, 5},
+ {-3, -4},
+ {5, -3},
+ {-7, 2},
+ {-9, -1},
+ {1, -5},
+ {3, 4},
+ {-5, 3},
+ {7, -2},
+ {9, 1}
+};
+
+const struct BgTemplate gUnknown_0862AACC[] =
+{
+ {
+ .bg = 0,
+ .charBaseIndex = 0,
+ .mapBaseIndex = 31,
+ .screenSize = 0,
+ .paletteMode = 0,
+ .priority = 0,
+ .baseTile = 0
+ },
+ {
+ .bg = 1,
+ .charBaseIndex = 1,
+ .mapBaseIndex = 30,
+ .screenSize = 0,
+ .paletteMode = 0,
+ .priority = 1,
+ .baseTile = 0
+ },
+ {
+ .bg = 2,
+ .charBaseIndex = 2,
+ .mapBaseIndex = 29,
+ .screenSize = 0,
+ .paletteMode = 0,
+ .priority = 2,
+ .baseTile = 0
+ },
+ {
+ .bg = 3,
+ .charBaseIndex = 1,
+ .mapBaseIndex = 28,
+ .screenSize = 0,
+ .paletteMode = 0,
+ .priority = 3,
+ .baseTile = 0
+ }
+};
+
+static const union AnimCmd sSpriteAnim_862AADC[] =
+{
+ ANIMCMD_FRAME(0, 32),
+ ANIMCMD_FRAME(64, 32),
+ ANIMCMD_JUMP(0),
+};
+
+static const union AnimCmd *const sSpriteAnimTable_862AAE8[] =
+{
+ sSpriteAnim_862AADC
+};
+
+static const union AnimCmd sSpriteAnim_862AAEC[] =
+{
+ ANIMCMD_FRAME(0, 32),
+ ANIMCMD_FRAME(8, 32),
+ ANIMCMD_JUMP(0),
+};
+
+static const union AnimCmd *const sSpriteAnimTable_862AAF8[] =
+{
+ sSpriteAnim_862AAEC
+};
+
+const struct CompressedSpriteSheet gUnknown_0862AAFC =
+{
+ gRaySceneRayquazaFly1_Gfx, 0x1000, 30556
+};
+
+const struct CompressedSpriteSheet gUnknown_0862AB04 =
+{
+ gRaySceneRayquazaTail_Gfx, 0x200, 30557
+};
+
+const struct CompressedSpritePalette gUnknown_0862AB0C =
+{
+ gRaySceneRayquaza_Pal, 30556
+};
+
+const struct SpriteTemplate gUnknown_0862AB14 =
+{
+ .tileTag = 30556,
+ .paletteTag = 30556,
+ .oam = &sOamData_862A6BC,
+ .anims = sSpriteAnimTable_862AAE8,
+ .images = NULL,
+ .affineAnims = gDummySpriteAffineAnimTable,
+ .callback = SpriteCallbackDummy,
+};
+
+const struct SpriteTemplate gUnknown_0862AB2C =
+{
+ .tileTag = 30557,
+ .paletteTag = 30556,
+ .oam = &sOamData_862A6E4,
+ .anims = sSpriteAnimTable_862AAF8,
+ .images = NULL,
+ .affineAnims = gDummySpriteAffineAnimTable,
+ .callback = SpriteCallbackDummy,
+};
+
+const struct BgTemplate gUnknown_0862AB44[] =
+{
+ {
+ .bg = 0,
+ .charBaseIndex = 2,
+ .mapBaseIndex = 31,
+ .screenSize = 0,
+ .paletteMode = 0,
+ .priority = 0,
+ .baseTile = 0
+ },
+ {
+ .bg = 1,
+ .charBaseIndex = 1,
+ .mapBaseIndex = 30,
+ .screenSize = 0,
+ .paletteMode = 0,
+ .priority = 1,
+ .baseTile = 0
+ },
+ {
+ .bg = 2,
+ .charBaseIndex = 2,
+ .mapBaseIndex = 29,
+ .screenSize = 0,
+ .paletteMode = 0,
+ .priority = 2,
+ .baseTile = 0
+ },
+ {
+ .bg = 3,
+ .charBaseIndex = 3,
+ .mapBaseIndex = 28,
+ .screenSize = 0,
+ .paletteMode = 0,
+ .priority = 3,
+ .baseTile = 0
+ }
+};
+
+static const union AnimCmd sSpriteAnim_862AB54[] =
+{
+ ANIMCMD_FRAME(0, 1),
+ ANIMCMD_END
+};
+
+static const union AnimCmd sSpriteAnim_862AB5C[] =
+{
+ ANIMCMD_FRAME(0, 48),
+ ANIMCMD_FRAME(64, 32),
+ ANIMCMD_FRAME(0, 48),
+ ANIMCMD_FRAME(128, 32),
+ ANIMCMD_JUMP(0)
+};
+
+static const union AnimCmd *const sSpriteAnimTable_862AB70[] =
+{
+ sSpriteAnim_862AB54,
+ sSpriteAnim_862AB5C
+};
+
+static const union AnimCmd sSpriteAnim_862AB78[] =
+{
+ ANIMCMD_FRAME(0, 1),
+ ANIMCMD_END
+};
+
+static const union AnimCmd *const sSpriteAnimTable_862AB80[] =
+{
+ sSpriteAnim_862AB78,
+};
+
+static const union AnimCmd sSpriteAnim_862AB84[] =
+{
+ ANIMCMD_FRAME(0, 1),
+ ANIMCMD_END
+};
+
+static const union AnimCmd sSpriteAnim_862AB8C[] =
+{
+ ANIMCMD_FRAME(16, 1),
+ ANIMCMD_END
+};
+
+static const union AnimCmd sSpriteAnim_862AB94[] =
+{
+ ANIMCMD_FRAME(32, 1),
+ ANIMCMD_END
+};
+
+static const union AnimCmd *const sSpriteAnimTable_862AB9C[] =
+{
+ sSpriteAnim_862AB84,
+ sSpriteAnim_862AB8C,
+ sSpriteAnim_862AB94
+};
+
+static const union AnimCmd sSpriteAnim_862ABA8[] =
+{
+ ANIMCMD_FRAME(0, 1),
+ ANIMCMD_END
+};
+
+static const union AnimCmd sSpriteAnim_862ABB0[] =
+{
+ ANIMCMD_FRAME(64, 1),
+ ANIMCMD_END
+};
+
+static const union AnimCmd sSpriteAnim_862ABB8[] =
+{
+ ANIMCMD_FRAME(128, 1),
+ ANIMCMD_END
+};
+
+static const union AnimCmd sSpriteAnim_862ABC0[] =
+{
+ ANIMCMD_FRAME(192, 1),
+ ANIMCMD_END
+};
+
+static const union AnimCmd *const sSpriteAnimTable_862ABC8[] =
+{
+ sSpriteAnim_862ABA8,
+ sSpriteAnim_862ABB0,
+ sSpriteAnim_862ABB8,
+ sSpriteAnim_862ABC0
+};
+
+static const union AnimCmd sSpriteAnim_862ABD8[] =
+{
+ ANIMCMD_FRAME(0, 1),
+ ANIMCMD_END
+};
+
+static const union AnimCmd sSpriteAnim_862ABE0[] =
+{
+ ANIMCMD_FRAME(16, 1),
+ ANIMCMD_END
+};
+
+static const union AnimCmd sSpriteAnim_862ABE8[] =
+{
+ ANIMCMD_FRAME(32, 1),
+ ANIMCMD_END
+};
+
+static const union AnimCmd sSpriteAnim_862ABF0[] =
+{
+ ANIMCMD_FRAME(48, 1),
+ ANIMCMD_END
+};
+
+static const union AnimCmd *const sSpriteAnimTable_862ABF8[] =
+{
+ sSpriteAnim_862ABD8,
+ sSpriteAnim_862ABE0,
+ sSpriteAnim_862ABE8,
+ sSpriteAnim_862ABF0
+};
+
+static const union AnimCmd sSpriteAnim_862AC08[] =
+{
+ ANIMCMD_FRAME(0, 8),
+ ANIMCMD_FRAME(4, 8),
+ ANIMCMD_FRAME(8, 8),
+ ANIMCMD_FRAME(12, 8),
+ ANIMCMD_FRAME(16, 8),
+ ANIMCMD_FRAME(20, 8),
+ ANIMCMD_JUMP(0)
+};
+
+static const union AnimCmd *const sSpriteAnimTable_862AC24[] =
+{
+ sSpriteAnim_862AC08
+};
+
+const struct CompressedSpriteSheet gUnknown_0862AC28 =
+{
+ gRaySceneGroudonLeft_Gfx, 0x1800, 30565
+};
+
+const struct CompressedSpriteSheet gUnknown_0862AC30 =
+{
+ gRaySceneGroudonTail_Gfx, 0x80, 30566
+};
+
+const struct CompressedSpriteSheet gUnknown_0862AC38 =
+{
+ gRaySceneKyogreRight_Gfx, 0x600, 30568
+};
+
+const struct CompressedSpriteSheet gUnknown_0862AC40 =
+{
+ gRaySceneRayquazaHover_Gfx, 0x2000, 30569
+};
+
+const struct CompressedSpriteSheet gUnknown_0862AC48 =
+{
+ gRaySceneRayquazaFlyIn_Gfx, 0x800, 30570
+};
+
+const struct CompressedSpriteSheet gUnknown_0862AC50 =
+{
+ gRaySceneSplash_Gfx, 0x300, 30571
+};
+
+const struct CompressedSpritePalette gUnknown_0862AC58 =
+{
+ gRaySceneGroudonLeft_Pal, 30565
+};
+
+const struct CompressedSpritePalette gUnknown_0862AC60 =
+{
+ gRaySceneKyogreRight_Pal, 30568
+};
+
+const struct CompressedSpritePalette gUnknown_0862AC68 =
+{
+ gRaySceneRayquazaHover_Pal, 30569
+};
+
+const struct CompressedSpritePalette gUnknown_0862AC70 =
+{
+ gRaySceneSplash_Pal, 30571
+};
+
+const struct SpriteTemplate gUnknown_0862AC78 =
+{
+ .tileTag = 30565,
+ .paletteTag = 30565,
+ .oam = &sOamData_862A6BC,
+ .anims = sSpriteAnimTable_862AB70,
+ .images = NULL,
+ .affineAnims = gDummySpriteAffineAnimTable,
+ .callback = SpriteCallbackDummy,
+};
+
+const struct SpriteTemplate gUnknown_0862AC90 =
+{
+ .tileTag = 30566,
+ .paletteTag = 30565,
+ .oam = &sOamData_862A6EC,
+ .anims = sSpriteAnimTable_862AB80,
+ .images = NULL,
+ .affineAnims = gDummySpriteAffineAnimTable,
+ .callback = SpriteCallbackDummy,
+};
+
+const struct SpriteTemplate gUnknown_0862ACA8 =
+{
+ .tileTag = 30568,
+ .paletteTag = 30568,
+ .oam = &sOamData_862A6C4,
+ .anims = sSpriteAnimTable_862AB9C,
+ .images = NULL,
+ .affineAnims = gDummySpriteAffineAnimTable,
+ .callback = SpriteCallbackDummy,
+};
+
+const struct SpriteTemplate gUnknown_0862ACC0 =
+{
+ .tileTag = 30569,
+ .paletteTag = 30569,
+ .oam = &sOamData_862A6BC,
+ .anims = sSpriteAnimTable_862ABC8,
+ .images = NULL,
+ .affineAnims = gDummySpriteAffineAnimTable,
+ .callback = sub_81D961C,
+};
+
+const struct SpriteTemplate gUnknown_0862ACD8 =
+{
+ .tileTag = 30570,
+ .paletteTag = 30569,
+ .oam = &sOamData_862A6C4,
+ .anims = sSpriteAnimTable_862ABF8,
+ .images = NULL,
+ .affineAnims = gDummySpriteAffineAnimTable,
+ .callback = SpriteCallbackDummy,
+};
+
+const struct SpriteTemplate gUnknown_0862ACF0 =
+{
+ .tileTag = 30571,
+ .paletteTag = 30571,
+ .oam = &sOamData_862A6F4,
+ .anims = sSpriteAnimTable_862AC24,
+ .images = NULL,
+ .affineAnims = gDummySpriteAffineAnimTable,
+ .callback = SpriteCallbackDummy,
+};
+
+const struct BgTemplate gUnknown_0862AD08[] =
+{
+ {
+ .bg = 0,
+ .charBaseIndex = 1,
+ .mapBaseIndex = 31,
+ .screenSize = 0,
+ .paletteMode = 0,
+ .priority = 1,
+ .baseTile = 0
+ },
+ {
+ .bg = 1,
+ .charBaseIndex = 1,
+ .mapBaseIndex = 30,
+ .screenSize = 0,
+ .paletteMode = 0,
+ .priority = 2,
+ .baseTile = 0
+ },
+ {
+ .bg = 2,
+ .charBaseIndex = 0,
+ .mapBaseIndex = 29,
+ .screenSize = 0,
+ .paletteMode = 0,
+ .priority = 0,
+ .baseTile = 0
+ }
+};
+
diff --git a/src/reset_save_heap.c b/src/reset_save_heap.c
index d4dbc5f42..099edce49 100644
--- a/src/reset_save_heap.c
+++ b/src/reset_save_heap.c
@@ -23,10 +23,8 @@ void sub_81700F8(void)
ResetSaveCounters();
sub_81534D0(0);
if (gSaveFileStatus == 0 || gSaveFileStatus == 2)
- {
Sav2_ClearSetDefault();
- }
SetPokemonCryStereo(gSaveBlock2Ptr->optionsSound);
- InitHeap(gHeap, 0x1c000);
+ InitHeap(gHeap, HEAP_SIZE);
SetMainCallback2(sub_8086230);
}
diff --git a/src/start_menu.c b/src/start_menu.c
index f45fd8626..a820cd992 100644
--- a/src/start_menu.c
+++ b/src/start_menu.c
@@ -6,6 +6,8 @@
#include "window.h"
#include "string_util.h"
#include "text.h"
+#include "strings.h"
+#include "bg.h"
// Menu actions
enum
@@ -25,15 +27,6 @@ enum
MENU_ACTION_PYRAMID_BAG
};
-static void BuildStartMenuActions_LinkMode(void);
-static void BuildStartMenuActions_UnionRoom(void);
-static void BuildStartMenuActions_SafariZone(void);
-static void BuildStartMenuActions_BattlePike(void);
-static void BuildStartMenuActions_BattlePyramid(void);
-static void BuildStartMenuActions_MultiBattleRoom(void);
-static void BuildStartMenuActions_Normal(void);
-u8 StartMenu_PlayerName(void);
-
extern bool32 is_c1_link_related_active(void);
extern bool32 InUnionRoom(void);
extern bool8 InBattlePike(void);
@@ -42,12 +35,91 @@ extern bool8 InMultiBattleRoom(void);
extern void sub_81973FC(u8 windowId, u8 a1);
extern void sub_8198070(u8 windowId, u8 a1);
+// this file's functions
+static void BuildStartMenuActions_LinkMode(void);
+static void BuildStartMenuActions_UnionRoom(void);
+static void BuildStartMenuActions_SafariZone(void);
+static void BuildStartMenuActions_BattlePike(void);
+static void BuildStartMenuActions_BattlePyramid(void);
+static void BuildStartMenuActions_MultiBattleRoom(void);
+static void BuildStartMenuActions_Normal(void);
+bool8 StartMenu_Pokedex(void);
+bool8 StartMenu_Pokemon(void);
+bool8 StartMenu_Bag(void);
+bool8 StartMenu_PokeNav(void);
+bool8 StartMenu_PlayerName(void);
+bool8 StartMenu_Save(void);
+bool8 StartMenu_Option(void);
+bool8 StartMenu_Exit(void);
+bool8 StartMenu_SafariZoneRetire(void);
+bool8 StartMenu_LinkModePlayerName(void);
+bool8 StartMenu_BattlePyramidRetire(void);
+bool8 StartMenu_BattlePyramidBag(void);
+
+// EWRAM vars
EWRAM_DATA u8 sSafariBallsWindowId = 0;
EWRAM_DATA u8 sBattlePyramidFloorWindowId = 0;
EWRAM_DATA u8 sStartMenuCursorPos = 0;
EWRAM_DATA u8 sNumStartMenuActions = 0;
EWRAM_DATA u8 sCurrentStartMenuActions[9] = {0};
+// const rom data
+static const struct WindowTemplate gSafariBallsWindowTemplate = {0, 1, 1, 9, 4, 0xF, 8};
+
+static const u8* const sPyramindFloorNames[] =
+{
+ gText_Floor1,
+ gText_Floor2,
+ gText_Floor3,
+ gText_Floor4,
+ gText_Floor5,
+ gText_Floor6,
+ gText_Floor7,
+ gText_Peak
+};
+
+static const struct WindowTemplate gPyramidFloorWindowTemplate_2 = {0, 1, 1, 0xA, 4, 0xF, 8};
+static const struct WindowTemplate gPyramidFloorWindowTemplate_1 = {0, 1, 1, 0xC, 4, 0xF, 8};
+
+const struct MenuAction sStartMenuItems[] =
+{
+ {gText_MenuPokedex, {.u8_void = StartMenu_Pokedex}},
+ {gText_MenuPokemon, {.u8_void = StartMenu_Pokemon}},
+ {gText_MenuBag, {.u8_void = StartMenu_Bag}},
+ {gText_MenuPokenav, {.u8_void = StartMenu_PokeNav}},
+ {gText_MenuPlayer, {.u8_void = StartMenu_PlayerName}},
+ {gText_MenuSave, {.u8_void = StartMenu_Save}},
+ {gText_MenuOption, {.u8_void = StartMenu_Option}},
+ {gText_MenuExit, {.u8_void = StartMenu_Exit}},
+ {gText_MenuRetire, {.u8_void = StartMenu_SafariZoneRetire}},
+ {gText_MenuPlayer, {.u8_void = StartMenu_LinkModePlayerName}},
+ {gText_MenuRest, {.u8_void = StartMenu_Save}},
+ {gText_MenuRetire, {.u8_void = StartMenu_BattlePyramidRetire}},
+ {gText_MenuBag, {.u8_void = StartMenu_BattlePyramidBag}}
+};
+
+const struct BgTemplate gUnknown_085105A8[] =
+{
+ {
+ .bg = 0,
+ .charBaseIndex = 2,
+ .mapBaseIndex = 31,
+ .screenSize = 0,
+ .paletteMode = 0,
+ .priority = 0,
+ .baseTile = 0
+ }
+};
+
+const struct WindowTemplate gUnknown_085105AC[] =
+{
+ {0, 2, 0xF, 0x1A, 4, 0xF, 0x194},
+ DUMMY_WIN_TEMPLATE
+};
+
+const struct WindowTemplate gUnknown_085105BC = {0, 1, 1, 0xE, 0xA, 0xF, 8};
+
+// code
void BuildStartMenuActions(void)
{
sNumStartMenuActions = 0;
@@ -148,11 +220,6 @@ static void BuildStartMenuActions_MultiBattleRoom(void)
AddStartMenuAction(MENU_ACTION_EXIT);
}
-extern const struct WindowTemplate gSafariBallsWindowTemplate;
-extern const struct WindowTemplate gPyramidFloorWindowTemplate_1;
-extern const struct WindowTemplate gPyramidFloorWindowTemplate_2;
-extern const u8 gText_SafariBallStock[];
-
void DisplaySafariBallsWindow(void)
{
sSafariBallsWindowId = AddWindow(&gSafariBallsWindowTemplate);
@@ -164,9 +231,6 @@ void DisplaySafariBallsWindow(void)
CopyWindowToVram(sSafariBallsWindowId, 2);
}
-extern const u8* const gUnknown_08510510[];
-extern const u8 gText_BattlePyramidFloor[];
-
void DisplayPyramidFloorWindow(void)
{
// TODO: fix location
@@ -176,7 +240,7 @@ void DisplayPyramidFloorWindow(void)
sBattlePyramidFloorWindowId = AddWindow(&gPyramidFloorWindowTemplate_2);
PutWindowTilemap(sBattlePyramidFloorWindowId);
sub_81973FC(sBattlePyramidFloorWindowId, 0);
- StringCopy(gStringVar1, gUnknown_08510510[gSaveBlock2Ptr->field_CAA[4]]);
+ StringCopy(gStringVar1, sPyramindFloorNames[gSaveBlock2Ptr->field_CAA[4]]);
StringExpandPlaceholders(gStringVar4, gText_BattlePyramidFloor);
PrintTextOnWindow(sBattlePyramidFloorWindowId, 1, gStringVar4, 0, 1, 0xFF, NULL);
CopyWindowToVram(sBattlePyramidFloorWindowId, 2);
@@ -197,8 +261,6 @@ void RemoveExtraStartMenuWindows(void)
}
}
-extern const struct MenuAction sStartMenuItems[];
-
/*
// Prints n menu items starting at *index
static bool32 PrintStartMenuItemsMultistep(s16 *index, u32 n)
diff --git a/src/unk_81BAD84.c b/src/unk_81BAD84.c
index 9ba98dd87..c0d891c12 100644
--- a/src/unk_81BAD84.c
+++ b/src/unk_81BAD84.c
@@ -7,29 +7,29 @@ const struct {
const u16 *pltt;
} gUnknown_08617128[] = {
{
- gUnknown_08DD87C0,
- gUnknown_08DD8EE0,
- gUnknown_08DD8780
+ gBerryFixGameboy_Gfx,
+ gBerryFixGameboy_Tilemap,
+ gBerryFixGameboy_Pal
}, {
- gUnknown_08DD90E0,
- gUnknown_08DD9718,
- gUnknown_08DD9080
+ gBerryFixGameboyLogo_Gfx,
+ gBerryFixGameboyLogo_Tilemap,
+ gBerryFixGameboyLogo_Pal
}, {
- gUnknown_08DD98B4,
- gUnknown_08DD9E58,
- gUnknown_08DD9874
+ gBerryFixGbaTransfer_Gfx,
+ gBerryFixGbaTransfer_Tilemap,
+ gBerryFixGbaTransfer_Pal
}, {
- gUnknown_08DDA02C,
- gUnknown_08DDA63C,
- gUnknown_08DD9FEC
+ gBerryFixGbaTransferHighlight_Gfx,
+ gBerryFixGbaTransferHighlight_Tilemap,
+ gBerryFixGbaTransferHighlight_Pal
}, {
- gUnknown_08DDA840,
- gUnknown_08DDAE40,
- gUnknown_08DDA800
+ gBerryFixGbaTransferError_Gfx,
+ gBerryFixGbaTransferError_Tilemap,
+ gBerryFixGbaTransferError_Pal
}, {
- gUnknown_08DDB020,
- gUnknown_08DDB2C4,
- gUnknown_08DDAFE0
+ gBerryFixWindow_Gfx,
+ gBerryFixWindow_Tilemap,
+ gBerryFixWindow_Pal
}
};
diff --git a/src/wallclock.c b/src/wallclock.c
index 897576719..ea6137c5d 100644
--- a/src/wallclock.c
+++ b/src/wallclock.c
@@ -92,8 +92,8 @@ static const struct CompressedSpriteSheet gUnknown_085B2208 = {
};
static const u32 filler_85B2210[2] = {};
static const struct SpritePalette gUnknown_085B2218[] = {
- { gUnknown_08DCC01C, TAG_PAL_WALL_CLOCK_HAND },
- { gUnknown_08DCC03C, 0x1001 },
+ { gWallclockMale_Pal, TAG_PAL_WALL_CLOCK_HAND },
+ { gWallclockFemale_Pal, 0x1001 },
{}
};
static const struct OamData Unknown_085B2230 = {
@@ -561,14 +561,14 @@ static void LoadWallClockGraphics(void)
DmaFillLarge16(3, 0, (void *)VRAM, VRAM_SIZE, 0x1000);
DmaClear32(3, (void *)OAM, OAM_SIZE);
DmaClear16(3, (void *)PLTT, PLTT_SIZE);
- LZ77UnCompVram(gUnknown_08DCC05C, (void *)VRAM);
+ LZ77UnCompVram(gWallclock_Gfx, (void *)VRAM);
if (gSpecialVar_0x8004 == 0)
{
- LoadPalette(gUnknown_08DCC01C, 0x00, 0x20);
+ LoadPalette(gWallclockMale_Pal, 0x00, 0x20);
}
else
{
- LoadPalette(gUnknown_08DCC03C, 0x00, 0x20);
+ LoadPalette(gWallclockFemale_Pal, 0x00, 0x20);
}
LoadPalette(GetOverworldTextboxPalettePtr(), 0xe0, 0x20);
LoadPalette(sUnknown_085B21D4, 0xc0, 0x08);
diff --git a/src/window.c b/src/window.c
index f4cb48ec0..3913b5800 100644
--- a/src/window.c
+++ b/src/window.c
@@ -465,696 +465,74 @@ void FillWindowPixelBuffer(u8 windowId, u8 fillValue)
CpuFastFill8(fillValue, gWindows[windowId].tileData, 0x20 * fillSize);
}
-// functionally equivalent, its fucking hard to match
-#ifdef NONMATCHING
+#define MOVE_TILES_DOWN(a) \
+{ \
+ destOffset = i + (a); \
+ srcOffset = i + (((width * (distanceLoop & ~7)) | (distanceLoop & 7)) * 4); \
+ if (srcOffset < size) \
+ *(u32*)(tileData + destOffset) = *(u32*)(tileData + srcOffset); \
+ else \
+ *(u32*)(tileData + destOffset) = fillValue32; \
+ distanceLoop++; \
+}
+
+#define MOVE_TILES_UP(a) \
+{ \
+ destOffset = i + (a); \
+ srcOffset = i + (((width * (distanceLoop & ~7)) | (distanceLoop & 7)) * 4); \
+ if (srcOffset < size) \
+ *(u32*)(tileData - destOffset) = *(u32*)(tileData - srcOffset); \
+ else \
+ *(u32*)(tileData - destOffset) = fillValue32; \
+ distanceLoop++; \
+}
+
void ScrollWindow(u8 windowId, u8 direction, u8 distance, u8 fillValue)
{
- s32 i, id1, id2, size;
- u32 distanceLoop, toFill, width;
- u8 *tileData;
- struct WindowTemplate window;
-
- tileData = gWindows[windowId].tileData;
- toFill = (fillValue << 0x18) | (fillValue << 0x10) | (fillValue << 8) | fillValue;
- window = gWindows[windowId].window;
- size = 0x20 * (window.height * window.width);
- width = window.width;
- if (direction != 1)
+ struct WindowTemplate window = gWindows[windowId].window;
+ u8 *tileData = gWindows[windowId].tileData;
+ u32 fillValue32 = (fillValue << 24) | (fillValue << 16) | (fillValue << 8) | fillValue;
+ s32 size = window.height * window.width * 32;
+ u32 width = window.width;
+ s32 i;
+ s32 srcOffset, destOffset;
+ u32 distanceLoop;
+
+ switch (direction)
{
- s32 signedDirection = direction;
- if (signedDirection <= 1)
+ case 0:
+ for (i = 0; i < size; i += 32)
{
- if (signedDirection == 0)
- {
- for (i = 0; i < size; i += 0x20)
- {
- distanceLoop = distance;
- id1 = i + 0;
- id2 = i + (((width * ((distanceLoop) & ~(7))) | ((distanceLoop) & 7)) * 4);
- if (id2 < size)
- *(u32*)(tileData + id1) = *(u32*)(tileData + id2);
- else
- *(u32*)(tileData + id1) = toFill;
-
- distanceLoop++;
- id1 = i + 4;
- id2 = i + (((width * ((distanceLoop) & ~(7))) | ((distanceLoop) & 7)) * 4);
- if (id2 < size)
- *(u32*)(tileData + id1) = *(u32*)(tileData + id2);
- else
- *(u32*)(tileData + id1) = toFill;
-
- distanceLoop++;
- id1 = i + 8;
- id2 = i + (((width * ((distanceLoop) & ~(7))) | ((distanceLoop) & 7)) * 4);
- if (id2 < size)
- *(u32*)(tileData + id1) = *(u32*)(tileData + id2);
- else
- *(u32*)(tileData + id1) = toFill;
-
- distanceLoop++;
- id1 = i + 12;
- id2 = i + (((width * ((distanceLoop) & ~(7))) | ((distanceLoop) & 7)) * 4);
- if (id2 < size)
- *(u32*)(tileData + id1) = *(u32*)(tileData + id2);
- else
- *(u32*)(tileData + id1) = toFill;
-
- distanceLoop++;
- id1 = i + 16;
- id2 = i + (((width * ((distanceLoop) & ~(7))) | ((distanceLoop) & 7)) * 4);
- if (id2 < size)
- *(u32*)(tileData + id1) = *(u32*)(tileData + id2);
- else
- *(u32*)(tileData + id1) = toFill;
-
- distanceLoop++;
- id1 = i + 20;
- id2 = i + (((width * ((distanceLoop) & ~(7))) | ((distanceLoop) & 7)) * 4);
- if (id2 < size)
- *(u32*)(tileData + id1) = *(u32*)(tileData + id2);
- else
- *(u32*)(tileData + id1) = toFill;
-
- distanceLoop++;
- id1 = i + 24;
- id2 = i + (((width * ((distanceLoop) & ~(7))) | ((distanceLoop) & 7)) * 4);
- if (id2 < size)
- *(u32*)(tileData + id1) = *(u32*)(tileData + id2);
- else
- *(u32*)(tileData + id1) = toFill;
-
- distanceLoop++;
- id1 = i + 28;
- id2 = i + (((width * ((distanceLoop) & ~(7))) | ((distanceLoop) & 7)) * 4);
- if (id2 < size)
- *(u32*)(tileData + id1) = *(u32*)(tileData + id2);
- else
- *(u32*)(tileData + id1) = toFill;
- }
- }
+ distanceLoop = distance;
+ MOVE_TILES_DOWN(0)
+ MOVE_TILES_DOWN(4)
+ MOVE_TILES_DOWN(8)
+ MOVE_TILES_DOWN(12)
+ MOVE_TILES_DOWN(16)
+ MOVE_TILES_DOWN(20)
+ MOVE_TILES_DOWN(24)
+ MOVE_TILES_DOWN(28)
}
- }
- else
- {
+ break;
+ case 1:
tileData += size - 4;
- for (i = 0; i < size; i += 0x20)
+ for (i = 0; i < size; i += 32)
{
distanceLoop = distance;
- id1 = i + 0;
- id2 = i + (((width * ((distanceLoop) & ~(7))) | ((distanceLoop) & 7)) * 4);
- if (id2 < size)
- *(u32*)(tileData - id1) = *(u32*)(tileData - id2);
- else
- *(u32*)(tileData - id1) = toFill;
-
- distanceLoop++;
- id1 = i + 4;
- id2 = i + (((width * ((distanceLoop) & ~(7))) | ((distanceLoop) & 7)) * 4);
- if (id2 < size)
- *(u32*)(tileData - id1) = *(u32*)(tileData - id2);
- else
- *(u32*)(tileData - id1) = toFill;
-
- distanceLoop++;
- id1 = i + 8;
- id2 = i + (((width * ((distanceLoop) & ~(7))) | ((distanceLoop) & 7)) * 4);
- if (id2 < size)
- *(u32*)(tileData - id1) = *(u32*)(tileData - id2);
- else
- *(u32*)(tileData - id1) = toFill;
-
- distanceLoop++;
- id1 = i + 12;
- id2 = i + (((width * ((distanceLoop) & ~(7))) | ((distanceLoop) & 7)) * 4);
- if (id2 < size)
- *(u32*)(tileData - id1) = *(u32*)(tileData - id2);
- else
- *(u32*)(tileData - id1) = toFill;
-
- distanceLoop++;
- id1 = i + 16;
- id2 = i + (((width * ((distanceLoop) & ~(7))) | ((distanceLoop) & 7)) * 4);
- if (id2 < size)
- *(u32*)(tileData - id1) = *(u32*)(tileData - id2);
- else
- *(u32*)(tileData - id1) = toFill;
-
- distanceLoop++;
- id1 = i + 20;
- id2 = i + (((width * ((distanceLoop) & ~(7))) | ((distanceLoop) & 7)) * 4);
- if (id2 < size)
- *(u32*)(tileData - id1) = *(u32*)(tileData - id2);
- else
- *(u32*)(tileData - id1) = toFill;
-
- distanceLoop++;
- id1 = i + 24;
- id2 = i + (((width * ((distanceLoop) & ~(7))) | ((distanceLoop) & 7)) * 4);
- if (id2 < size)
- *(u32*)(tileData - id1) = *(u32*)(tileData - id2);
- else
- *(u32*)(tileData - id1) = toFill;
-
- distanceLoop++;
- id1 = i + 28;
- id2 = i + (((width * ((distanceLoop) & ~(7))) | ((distanceLoop) & 7)) * 4);
- if (id2 < size)
- *(u32*)(tileData - id1) = *(u32*)(tileData - id2);
- else
- *(u32*)(tileData - id1) = toFill;
+ MOVE_TILES_UP(0)
+ MOVE_TILES_UP(4)
+ MOVE_TILES_UP(8)
+ MOVE_TILES_UP(12)
+ MOVE_TILES_UP(16)
+ MOVE_TILES_UP(20)
+ MOVE_TILES_UP(24)
+ MOVE_TILES_UP(28)
}
+ break;
+ case 2:
+ break;
}
}
-#else
-__attribute__((naked))
-void ScrollWindow(u8 windowId, u8 direction, u8 distance, u8 fillValue)
-{
- asm(".syntax unified\n\
- push {r4-r7,lr}\n\
- mov r7, r10\n\
- mov r6, r9\n\
- mov r5, r8\n\
- push {r5-r7}\n\
- sub sp, 0x8\n\
- lsls r0, 24\n\
- lsrs r0, 24\n\
- lsls r1, 24\n\
- lsrs r1, 24\n\
- mov r8, r1\n\
- lsls r2, 24\n\
- lsrs r2, 24\n\
- str r2, [sp]\n\
- lsls r3, 24\n\
- lsrs r3, 24\n\
- ldr r2, =gWindows\n\
- lsls r1, r0, 1\n\
- adds r1, r0\n\
- lsls r1, 2\n\
- adds r4, r1, r2\n\
- adds r2, 0x8\n\
- adds r1, r2\n\
- ldr r5, [r1]\n\
- lsls r7, r3, 24\n\
- lsls r0, r3, 16\n\
- orrs r7, r0\n\
- lsls r0, r3, 8\n\
- orrs r7, r0\n\
- orrs r7, r3\n\
- ldr r1, [r4]\n\
- ldr r2, [r4, 0x4]\n\
- ldrb r3, [r4, 0x4]\n\
- lsrs r0, r1, 24\n\
- muls r0, r3\n\
- lsls r6, r0, 5\n\
- lsrs r1, 24\n\
- mov r12, r1\n\
- mov r0, r8\n\
- cmp r0, 0x1\n\
- bne _08003CE8\n\
- b _08003E9E\n\
-_08003CE8:\n\
- cmp r0, 0x1\n\
- ble _08003CEE\n\
- b _08004046\n\
-_08003CEE:\n\
- cmp r0, 0\n\
- beq _08003CF4\n\
- b _08004046\n\
-_08003CF4:\n\
- movs r4, 0\n\
- cmp r4, r6\n\
- blt _08003CFC\n\
- b _08004046\n\
-_08003CFC:\n\
- movs r1, 0x8\n\
- negs r1, r1\n\
- mov r9, r1\n\
- movs r2, 0x7\n\
- mov r8, r2\n\
- mov r10, r5\n\
-_08003D08:\n\
- ldr r3, [sp]\n\
- adds r0, r3, 0\n\
- mov r1, r9\n\
- ands r0, r1\n\
- mov r1, r12\n\
- muls r1, r0\n\
- adds r0, r3, 0\n\
- mov r2, r8\n\
- ands r0, r2\n\
- orrs r1, r0\n\
- lsls r1, 2\n\
- adds r1, r4, r1\n\
- cmp r1, r6\n\
- bge _08003D34\n\
- adds r0, r5, r1\n\
- ldr r0, [r0]\n\
- mov r1, r10\n\
- str r0, [r1]\n\
- b _08003D38\n\
- .pool\n\
-_08003D34:\n\
- mov r2, r10\n\
- str r7, [r2]\n\
-_08003D38:\n\
- adds r3, 0x1\n\
- adds r2, r4, 0x4\n\
- adds r0, r3, 0\n\
- mov r1, r9\n\
- ands r0, r1\n\
- mov r1, r12\n\
- muls r1, r0\n\
- str r1, [sp, 0x4]\n\
- adds r0, r3, 0\n\
- mov r1, r8\n\
- ands r0, r1\n\
- ldr r1, [sp, 0x4]\n\
- orrs r1, r0\n\
- lsls r1, 2\n\
- adds r1, r4, r1\n\
- cmp r1, r6\n\
- bge _08003D64\n\
- adds r0, r5, r2\n\
- adds r1, r5, r1\n\
- ldr r1, [r1]\n\
- str r1, [r0]\n\
- b _08003D68\n\
-_08003D64:\n\
- adds r0, r5, r2\n\
- str r7, [r0]\n\
-_08003D68:\n\
- adds r3, 0x1\n\
- adds r2, r4, 0\n\
- adds r2, 0x8\n\
- adds r0, r3, 0\n\
- mov r1, r9\n\
- ands r0, r1\n\
- mov r1, r12\n\
- muls r1, r0\n\
- str r1, [sp, 0x4]\n\
- adds r0, r3, 0\n\
- mov r1, r8\n\
- ands r0, r1\n\
- ldr r1, [sp, 0x4]\n\
- orrs r1, r0\n\
- lsls r1, 2\n\
- adds r1, r4, r1\n\
- cmp r1, r6\n\
- bge _08003D96\n\
- adds r0, r5, r2\n\
- adds r1, r5, r1\n\
- ldr r1, [r1]\n\
- str r1, [r0]\n\
- b _08003D9A\n\
-_08003D96:\n\
- adds r0, r5, r2\n\
- str r7, [r0]\n\
-_08003D9A:\n\
- adds r3, 0x1\n\
- adds r2, r4, 0\n\
- adds r2, 0xC\n\
- adds r0, r3, 0\n\
- mov r1, r9\n\
- ands r0, r1\n\
- mov r1, r12\n\
- muls r1, r0\n\
- str r1, [sp, 0x4]\n\
- adds r0, r3, 0\n\
- mov r1, r8\n\
- ands r0, r1\n\
- ldr r1, [sp, 0x4]\n\
- orrs r1, r0\n\
- lsls r1, 2\n\
- adds r1, r4, r1\n\
- cmp r1, r6\n\
- bge _08003DC8\n\
- adds r0, r5, r2\n\
- adds r1, r5, r1\n\
- ldr r1, [r1]\n\
- str r1, [r0]\n\
- b _08003DCC\n\
-_08003DC8:\n\
- adds r0, r5, r2\n\
- str r7, [r0]\n\
-_08003DCC:\n\
- adds r3, 0x1\n\
- adds r2, r4, 0\n\
- adds r2, 0x10\n\
- adds r0, r3, 0\n\
- mov r1, r9\n\
- ands r0, r1\n\
- mov r1, r12\n\
- muls r1, r0\n\
- str r1, [sp, 0x4]\n\
- adds r0, r3, 0\n\
- mov r1, r8\n\
- ands r0, r1\n\
- ldr r1, [sp, 0x4]\n\
- orrs r1, r0\n\
- lsls r1, 2\n\
- adds r1, r4, r1\n\
- cmp r1, r6\n\
- bge _08003DFA\n\
- adds r0, r5, r2\n\
- adds r1, r5, r1\n\
- ldr r1, [r1]\n\
- str r1, [r0]\n\
- b _08003DFE\n\
-_08003DFA:\n\
- adds r0, r5, r2\n\
- str r7, [r0]\n\
-_08003DFE:\n\
- adds r3, 0x1\n\
- adds r2, r4, 0\n\
- adds r2, 0x14\n\
- adds r0, r3, 0\n\
- mov r1, r9\n\
- ands r0, r1\n\
- mov r1, r12\n\
- muls r1, r0\n\
- str r1, [sp, 0x4]\n\
- adds r0, r3, 0\n\
- mov r1, r8\n\
- ands r0, r1\n\
- ldr r1, [sp, 0x4]\n\
- orrs r1, r0\n\
- lsls r1, 2\n\
- adds r1, r4, r1\n\
- cmp r1, r6\n\
- bge _08003E2C\n\
- adds r0, r5, r2\n\
- adds r1, r5, r1\n\
- ldr r1, [r1]\n\
- str r1, [r0]\n\
- b _08003E30\n\
-_08003E2C:\n\
- adds r0, r5, r2\n\
- str r7, [r0]\n\
-_08003E30:\n\
- adds r3, 0x1\n\
- adds r2, r4, 0\n\
- adds r2, 0x18\n\
- adds r0, r3, 0\n\
- mov r1, r9\n\
- ands r0, r1\n\
- mov r1, r12\n\
- muls r1, r0\n\
- str r1, [sp, 0x4]\n\
- adds r0, r3, 0\n\
- mov r1, r8\n\
- ands r0, r1\n\
- ldr r1, [sp, 0x4]\n\
- orrs r1, r0\n\
- lsls r1, 2\n\
- adds r1, r4, r1\n\
- cmp r1, r6\n\
- bge _08003E5E\n\
- adds r0, r5, r2\n\
- adds r1, r5, r1\n\
- ldr r1, [r1]\n\
- str r1, [r0]\n\
- b _08003E62\n\
-_08003E5E:\n\
- adds r0, r5, r2\n\
- str r7, [r0]\n\
-_08003E62:\n\
- adds r3, 0x1\n\
- adds r2, r4, 0\n\
- adds r2, 0x1C\n\
- adds r0, r3, 0\n\
- mov r1, r9\n\
- ands r0, r1\n\
- mov r1, r12\n\
- muls r1, r0\n\
- adds r0, r1, 0\n\
- mov r1, r8\n\
- ands r3, r1\n\
- orrs r0, r3\n\
- lsls r0, 2\n\
- adds r1, r4, r0\n\
- cmp r1, r6\n\
- bge _08003E8C\n\
- adds r0, r5, r2\n\
- adds r1, r5, r1\n\
- ldr r1, [r1]\n\
- str r1, [r0]\n\
- b _08003E90\n\
-_08003E8C:\n\
- adds r0, r5, r2\n\
- str r7, [r0]\n\
-_08003E90:\n\
- movs r2, 0x20\n\
- add r10, r2\n\
- adds r4, 0x20\n\
- cmp r4, r6\n\
- bge _08003E9C\n\
- b _08003D08\n\
-_08003E9C:\n\
- b _08004046\n\
-_08003E9E:\n\
- subs r0, r6, 0x4\n\
- adds r5, r0\n\
- movs r4, 0\n\
- cmp r4, r6\n\
- blt _08003EAA\n\
- b _08004046\n\
-_08003EAA:\n\
- movs r0, 0x8\n\
- negs r0, r0\n\
- mov r9, r0\n\
- movs r1, 0x7\n\
- mov r8, r1\n\
- mov r10, r5\n\
-_08003EB6:\n\
- ldr r3, [sp]\n\
- adds r0, r3, 0\n\
- mov r2, r9\n\
- ands r0, r2\n\
- mov r1, r12\n\
- muls r1, r0\n\
- adds r0, r3, 0\n\
- mov r2, r8\n\
- ands r0, r2\n\
- orrs r1, r0\n\
- lsls r1, 2\n\
- adds r1, r4, r1\n\
- cmp r1, r6\n\
- bge _08003EDC\n\
- subs r0, r5, r1\n\
- ldr r0, [r0]\n\
- mov r1, r10\n\
- str r0, [r1]\n\
- b _08003EE0\n\
-_08003EDC:\n\
- mov r2, r10\n\
- str r7, [r2]\n\
-_08003EE0:\n\
- adds r3, 0x1\n\
- adds r2, r4, 0x4\n\
- adds r0, r3, 0\n\
- mov r1, r9\n\
- ands r0, r1\n\
- mov r1, r12\n\
- muls r1, r0\n\
- str r1, [sp, 0x4]\n\
- adds r0, r3, 0\n\
- mov r1, r8\n\
- ands r0, r1\n\
- ldr r1, [sp, 0x4]\n\
- orrs r1, r0\n\
- lsls r1, 2\n\
- adds r1, r4, r1\n\
- cmp r1, r6\n\
- bge _08003F0C\n\
- subs r0, r5, r2\n\
- subs r1, r5, r1\n\
- ldr r1, [r1]\n\
- str r1, [r0]\n\
- b _08003F10\n\
-_08003F0C:\n\
- subs r0, r5, r2\n\
- str r7, [r0]\n\
-_08003F10:\n\
- adds r3, 0x1\n\
- adds r2, r4, 0\n\
- adds r2, 0x8\n\
- adds r0, r3, 0\n\
- mov r1, r9\n\
- ands r0, r1\n\
- mov r1, r12\n\
- muls r1, r0\n\
- str r1, [sp, 0x4]\n\
- adds r0, r3, 0\n\
- mov r1, r8\n\
- ands r0, r1\n\
- ldr r1, [sp, 0x4]\n\
- orrs r1, r0\n\
- lsls r1, 2\n\
- adds r1, r4, r1\n\
- cmp r1, r6\n\
- bge _08003F3E\n\
- subs r0, r5, r2\n\
- subs r1, r5, r1\n\
- ldr r1, [r1]\n\
- str r1, [r0]\n\
- b _08003F42\n\
-_08003F3E:\n\
- subs r0, r5, r2\n\
- str r7, [r0]\n\
-_08003F42:\n\
- adds r3, 0x1\n\
- adds r2, r4, 0\n\
- adds r2, 0xC\n\
- adds r0, r3, 0\n\
- mov r1, r9\n\
- ands r0, r1\n\
- mov r1, r12\n\
- muls r1, r0\n\
- str r1, [sp, 0x4]\n\
- adds r0, r3, 0\n\
- mov r1, r8\n\
- ands r0, r1\n\
- ldr r1, [sp, 0x4]\n\
- orrs r1, r0\n\
- lsls r1, 2\n\
- adds r1, r4, r1\n\
- cmp r1, r6\n\
- bge _08003F70\n\
- subs r0, r5, r2\n\
- subs r1, r5, r1\n\
- ldr r1, [r1]\n\
- str r1, [r0]\n\
- b _08003F74\n\
-_08003F70:\n\
- subs r0, r5, r2\n\
- str r7, [r0]\n\
-_08003F74:\n\
- adds r3, 0x1\n\
- adds r2, r4, 0\n\
- adds r2, 0x10\n\
- adds r0, r3, 0\n\
- mov r1, r9\n\
- ands r0, r1\n\
- mov r1, r12\n\
- muls r1, r0\n\
- str r1, [sp, 0x4]\n\
- adds r0, r3, 0\n\
- mov r1, r8\n\
- ands r0, r1\n\
- ldr r1, [sp, 0x4]\n\
- orrs r1, r0\n\
- lsls r1, 2\n\
- adds r1, r4, r1\n\
- cmp r1, r6\n\
- bge _08003FA2\n\
- subs r0, r5, r2\n\
- subs r1, r5, r1\n\
- ldr r1, [r1]\n\
- str r1, [r0]\n\
- b _08003FA6\n\
-_08003FA2:\n\
- subs r0, r5, r2\n\
- str r7, [r0]\n\
-_08003FA6:\n\
- adds r3, 0x1\n\
- adds r2, r4, 0\n\
- adds r2, 0x14\n\
- adds r0, r3, 0\n\
- mov r1, r9\n\
- ands r0, r1\n\
- mov r1, r12\n\
- muls r1, r0\n\
- str r1, [sp, 0x4]\n\
- adds r0, r3, 0\n\
- mov r1, r8\n\
- ands r0, r1\n\
- ldr r1, [sp, 0x4]\n\
- orrs r1, r0\n\
- lsls r1, 2\n\
- adds r1, r4, r1\n\
- cmp r1, r6\n\
- bge _08003FD4\n\
- subs r0, r5, r2\n\
- subs r1, r5, r1\n\
- ldr r1, [r1]\n\
- str r1, [r0]\n\
- b _08003FD8\n\
-_08003FD4:\n\
- subs r0, r5, r2\n\
- str r7, [r0]\n\
-_08003FD8:\n\
- adds r3, 0x1\n\
- adds r2, r4, 0\n\
- adds r2, 0x18\n\
- adds r0, r3, 0\n\
- mov r1, r9\n\
- ands r0, r1\n\
- mov r1, r12\n\
- muls r1, r0\n\
- str r1, [sp, 0x4]\n\
- adds r0, r3, 0\n\
- mov r1, r8\n\
- ands r0, r1\n\
- ldr r1, [sp, 0x4]\n\
- orrs r1, r0\n\
- lsls r1, 2\n\
- adds r1, r4, r1\n\
- cmp r1, r6\n\
- bge _08004006\n\
- subs r0, r5, r2\n\
- subs r1, r5, r1\n\
- ldr r1, [r1]\n\
- str r1, [r0]\n\
- b _0800400A\n\
-_08004006:\n\
- subs r0, r5, r2\n\
- str r7, [r0]\n\
-_0800400A:\n\
- adds r3, 0x1\n\
- adds r2, r4, 0\n\
- adds r2, 0x1C\n\
- adds r0, r3, 0\n\
- mov r1, r9\n\
- ands r0, r1\n\
- mov r1, r12\n\
- muls r1, r0\n\
- adds r0, r1, 0\n\
- mov r1, r8\n\
- ands r3, r1\n\
- orrs r0, r3\n\
- lsls r0, 2\n\
- adds r1, r4, r0\n\
- cmp r1, r6\n\
- bge _08004034\n\
- subs r0, r5, r2\n\
- subs r1, r5, r1\n\
- ldr r1, [r1]\n\
- str r1, [r0]\n\
- b _08004038\n\
-_08004034:\n\
- subs r0, r5, r2\n\
- str r7, [r0]\n\
-_08004038:\n\
- movs r2, 0x20\n\
- negs r2, r2\n\
- add r10, r2\n\
- adds r4, 0x20\n\
- cmp r4, r6\n\
- bge _08004046\n\
- b _08003EB6\n\
-_08004046:\n\
- add sp, 0x8\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
void CallWindowFunction(u8 windowId, void ( *func)(u8, u8, u8, u8, u8, u8))
{