summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/battle.h21
-rw-r--r--include/battle_main.h5
-rw-r--r--include/battle_tower.h6
-rw-r--r--include/battle_util.h13
-rw-r--r--include/config.h8
-rw-r--r--include/constants/battle_anim.h2
-rw-r--r--include/constants/battle_frontier.h2
-rw-r--r--include/constants/battle_tower.h2
-rw-r--r--include/constants/event_objects.h4
-rw-r--r--include/constants/flags.h46
-rw-r--r--include/constants/item_effects.h5
-rw-r--r--include/constants/items.h4
-rwxr-xr-xinclude/constants/layouts.h14
-rwxr-xr-xinclude/constants/map_groups.h114
-rw-r--r--include/constants/pokemon.h44
-rw-r--r--include/constants/region_map_sections.h12
-rw-r--r--include/constants/rgb.h4
-rw-r--r--include/constants/species.h156
-rw-r--r--include/data.h1
-rw-r--r--include/gba/io_reg.h10
-rw-r--r--include/gba/m4a_internal.h241
-rw-r--r--include/global.fieldmap.h17
-rw-r--r--include/global.h8
-rw-r--r--include/graphics.h125
-rw-r--r--include/menu.h11
-rw-r--r--include/menu_specialized.h12
-rw-r--r--include/metatile_behavior.h8
-rw-r--r--include/mon_markings.h4
-rw-r--r--include/palette.h2
-rw-r--r--include/pokemon.h16
-rw-r--r--include/pokenav.h198
-rw-r--r--include/rayquaza_scene.h13
-rw-r--r--include/recorded_battle.h2
-rw-r--r--include/rom_8011DC0.h4
-rw-r--r--include/trainer_hill.h26
35 files changed, 634 insertions, 526 deletions
diff --git a/include/battle.h b/include/battle.h
index 0ebc9fe01..53a78024a 100644
--- a/include/battle.h
+++ b/include/battle.h
@@ -11,6 +11,7 @@
#include "battle_gfx_sfx_util.h"
#include "battle_util2.h"
#include "battle_bg.h"
+#include "pokeball.h"
#define GET_BATTLER_POSITION(battler) (gBattlerPositions[battler])
#define GET_BATTLER_SIDE(battler) (GetBattlerPosition(battler) & BIT_SIDE)
@@ -124,8 +125,8 @@ struct ProtectStruct
u32 flinchImmobility:1;
u32 notFirstStrike:1;
u32 palaceUnableToUseMove:1;
- s32 physicalDmg;
- s32 specialDmg;
+ u32 physicalDmg;
+ u32 specialDmg;
u8 physicalBattlerId;
u8 specialBattlerId;
};
@@ -254,8 +255,8 @@ struct BattleResults
u16 playerMon2Species; // 0x26
u16 caughtMonSpecies; // 0x28
u8 caughtMonNick[POKEMON_NAME_LENGTH + 1]; // 0x2A
- u8 filler35; // 0x35
- u8 catchAttempts[11]; // 0x36
+ u8 filler35; // 0x35
+ u8 catchAttempts[POKEBALL_COUNT - 1]; // 0x36 Doesn't include Master ball
};
struct BattleTv_Side
@@ -493,7 +494,7 @@ struct BattleScripting
u8 field_20;
u8 reshowMainState;
u8 reshowHelperState;
- u8 field_23;
+ u8 levelUpHP;
u8 windowsType; // 0 - normal, 1 - battle arena
u8 multiplayerId;
u8 specialTrainerBattleType;
@@ -544,8 +545,8 @@ struct BattleHealthboxInfo
u8 statusAnimActive:1; // x10
u8 animFromTableActive:1; // x20
u8 specialAnimActive:1; // x40
- u8 flag_x80:1;
- u8 field_1_x1:1;
+ u8 triedShinyMonAnim:1;
+ u8 finishedShinyMonAnim:1;
u8 field_1_x1E:4;
u8 field_1_x20:1;
u8 field_1_x40:1;
@@ -584,7 +585,11 @@ struct BattleSpriteData
struct MonSpritesGfx
{
void* firstDecompressed; // ptr to the decompressed sprite of the first pokemon
- void* sprites[4];
+ union
+ {
+ void* ptr[4];
+ u8* byte[4];
+ } sprites;
struct SpriteTemplate templates[4];
struct SpriteFrameImage field_74[4][4];
u8 field_F4[0x80];
diff --git a/include/battle_main.h b/include/battle_main.h
index 217b10b39..0176f7f24 100644
--- a/include/battle_main.h
+++ b/include/battle_main.h
@@ -67,14 +67,12 @@ void DoBounceEffect(u8 battlerId, u8 b, s8 c, s8 d);
void EndBounceEffect(u8 battlerId, bool8 b);
void SpriteCb_PlayerMonFromBall(struct Sprite *sprite);
void sub_8039E60(struct Sprite *sprite);
-void sub_8039E84(struct Sprite *sprite);
+void SpriteCB_TrainerThrowObject(struct Sprite *sprite);
void sub_8039E9C(struct Sprite *sprite);
void nullsub_20(void);
void BeginBattleIntro(void);
void SwitchInClearSetData(void);
void FaintClearSetData(void);
-void sub_803B3AC(void); // unused
-void sub_803B598(void); // unused
void BattleTurnPassed(void);
u8 IsRunningFromBattleImpossible(void);
void SwitchPartyOrder(u8 battlerId);
@@ -83,6 +81,7 @@ u8 GetWhoStrikesFirst(u8 battlerId1, u8 battlerId2, bool8 ignoreChosenMoves);
void RunBattleScriptCommands_PopCallbacksStack(void);
void RunBattleScriptCommands(void);
bool8 TryRunFromBattle(u8 battlerId);
+void SpecialStatusesClear(void);
extern struct UnknownPokemonStruct4 gMultiPartnerParty[MULTI_PARTY_SIZE];
diff --git a/include/battle_tower.h b/include/battle_tower.h
index 3bf2f004b..a80314592 100644
--- a/include/battle_tower.h
+++ b/include/battle_tower.h
@@ -43,7 +43,9 @@ extern const struct BattleFrontierTrainer gBattleFrontierTrainers[];
extern const struct FacilityMon gSlateportBattleTentMons[];
extern const struct BattleFrontierTrainer gSlateportBattleTentTrainers[];
-extern u16 gUnknown_03006298[];
+// Temporary storage for monIds of the opponent team
+// during team generation in battle factory and similar facilities.
+extern u16 gFrontierTempParty[];
extern const struct BattleFrontierTrainer *gFacilityTrainers;
extern const struct FacilityMon *gFacilityTrainerMons;
@@ -81,6 +83,6 @@ u8 GetFrontierEnemyMonLevel(u8 lvlMode);
s32 GetHighestLevelInPlayerParty(void);
u8 FacilityClassToGraphicsId(u8 facilityClass);
bool32 ValidateBattleTowerRecord(u8 recordId); // unused
-void sub_8166188(void);
+void TrySetLinkBattleTowerEnemyPartyLevel(void);
#endif //GUARD_BATTLE_TOWER_H
diff --git a/include/battle_util.h b/include/battle_util.h
index 157ba8eb6..81443f463 100644
--- a/include/battle_util.h
+++ b/include/battle_util.h
@@ -41,6 +41,19 @@
#define WEATHER_HAS_EFFECT ((!ABILITY_ON_FIELD(ABILITY_CLOUD_NINE) && !ABILITY_ON_FIELD(ABILITY_AIR_LOCK)))
#define WEATHER_HAS_EFFECT2 ((!ABILITY_ON_FIELD2(ABILITY_CLOUD_NINE) && !ABILITY_ON_FIELD2(ABILITY_AIR_LOCK)))
+void HandleAction_UseMove(void);
+void HandleAction_Switch(void);
+void HandleAction_UseItem(void);
+void HandleAction_Run(void);
+void HandleAction_WatchesCarefully(void);
+void HandleAction_SafariZoneBallThrow(void);
+void HandleAction_ThrowPokeblock(void);
+void HandleAction_GoNear(void);
+void HandleAction_SafariZoneRun(void);
+void HandleAction_WallyBallThrow(void);
+void HandleAction_TryFinish(void);
+void HandleAction_NothingIsFainted(void);
+void HandleAction_ActionFinished(void);
u8 GetBattlerForBattleScript(u8 caseId);
void PressurePPLose(u8 target, u8 attacker, u16 move);
void PressurePPLoseOnUsingPerishSong(u8 attacker);
diff --git a/include/config.h b/include/config.h
index 4f97a12a3..4c231a84d 100644
--- a/include/config.h
+++ b/include/config.h
@@ -15,9 +15,6 @@
// printing system. Use NoCashGBAPrint() and NoCashGBAPrintf() like you
// would normally use AGBPrint() and AGBPrintf().
-// NOTE: Don't try to enable assert right now as many pointers
-// still exist in defines and WILL likely result in a broken ROM.
-
#define ENGLISH
#ifdef ENGLISH
@@ -26,9 +23,12 @@
#define UNITS_METRIC
#endif
+// Uncomment to fix some identified minor bugs
+//#define BUGFIX
+
// Various undefined behavior bugs may or may not prevent compilation with
// newer compilers. So always fix them when using a modern compiler.
-#if MODERN
+#if MODERN || defined(BUGFIX)
#ifndef UBFIX
#define UBFIX
#endif
diff --git a/include/constants/battle_anim.h b/include/constants/battle_anim.h
index dfdd9f912..ebc422b18 100644
--- a/include/constants/battle_anim.h
+++ b/include/constants/battle_anim.h
@@ -376,7 +376,7 @@
#define B_ANIM_SWITCH_OUT_PLAYER_MON 0x1
#define B_ANIM_SWITCH_OUT_OPPONENT_MON 0x2
#define B_ANIM_BALL_THROW 0x3
-#define B_ANIM_SAFARI_BALL_THROW 0x4
+#define B_ANIM_BALL_THROW_WITH_TRAINER 0x4
#define B_ANIM_SUBSTITUTE_TO_MON 0x5
#define B_ANIM_MON_TO_SUBSTITUTE 0x6
diff --git a/include/constants/battle_frontier.h b/include/constants/battle_frontier.h
index 1a60714e8..bbe6db81c 100644
--- a/include/constants/battle_frontier.h
+++ b/include/constants/battle_frontier.h
@@ -51,7 +51,7 @@
#define MAX_BATTLE_FRONTIER_POINTS 9999
#define MAX_STREAK 9999
-// These sets of facility ids would be redunant if the order was consistent
+// These sets of facility ids would be redundant if the order was consistent
// The order is important for this set so that all the non-link records can be continuous
#define RANKING_HALL_BATTLE_TOWER_SINGLES 0
#define RANKING_HALL_BATTLE_TOWER_DOUBLES 1
diff --git a/include/constants/battle_tower.h b/include/constants/battle_tower.h
index b372c3ad5..f661ddc0b 100644
--- a/include/constants/battle_tower.h
+++ b/include/constants/battle_tower.h
@@ -14,7 +14,7 @@
#define BATTLE_TOWER_FUNC_LOAD_PARTNERS 10
#define BATTLE_TOWER_FUNC_PARTNER_MSG 11
#define BATTLE_TOWER_FUNC_LOAD_LINK_OPPONENTS 12
-#define BATTLE_TOWER_FUNC_13 13
+#define BATTLE_TOWER_FUNC_TRY_CLOSE_LINK 13
#define BATTLE_TOWER_FUNC_SET_PARTNER_GFX 14
#define BATTLE_TOWER_FUNC_SET_INTERVIEW_DATA 15
diff --git a/include/constants/event_objects.h b/include/constants/event_objects.h
index ca312e957..8e026ef2d 100644
--- a/include/constants/event_objects.h
+++ b/include/constants/event_objects.h
@@ -205,7 +205,7 @@
#define OBJ_EVENT_GFX_REGICE 201
#define OBJ_EVENT_GFX_REGISTEEL 202
#define OBJ_EVENT_GFX_SKITTY 203
-#define OBJ_EVENT_GFX_KECLEON_1 204
+#define OBJ_EVENT_GFX_KECLEON 204
#define OBJ_EVENT_GFX_KYOGRE_2 205
#define OBJ_EVENT_GFX_GROUDON_2 206
#define OBJ_EVENT_GFX_RAYQUAZA_2 207
@@ -213,7 +213,7 @@
#define OBJ_EVENT_GFX_PIKACHU 209
#define OBJ_EVENT_GFX_AZUMARILL 210
#define OBJ_EVENT_GFX_WINGULL 211
-#define OBJ_EVENT_GFX_KECLEON_2 212
+#define OBJ_EVENT_GFX_KECLEON_BRIDGE_SHADOW 212
#define OBJ_EVENT_GFX_TUBER_M_SWIMMING 213
#define OBJ_EVENT_GFX_AZURILL 214
#define OBJ_EVENT_GFX_MOM 215
diff --git a/include/constants/flags.h b/include/constants/flags.h
index 2490a6244..9be269105 100644
--- a/include/constants/flags.h
+++ b/include/constants/flags.h
@@ -538,27 +538,27 @@
// Hidden Items -- sorted by location
#define FLAG_HIDDEN_ITEMS_START 0x1F4
#define FLAG_HIDDEN_ITEM_TRICK_HOUSE_NUGGET (FLAG_HIDDEN_ITEMS_START + 0x01)
-#define FLAG_HIDDEN_ITEM_UNDERWATER_1_CARBOS (FLAG_HIDDEN_ITEMS_START + 0x08)
-#define FLAG_HIDDEN_ITEM_UNDERWATER_1_GREEN_SHARD (FLAG_HIDDEN_ITEMS_START + 0x09)
-#define FLAG_HIDDEN_ITEM_UNDERWATER_1_PEARL (FLAG_HIDDEN_ITEMS_START + 0x0A)
-#define FLAG_HIDDEN_ITEM_UNDERWATER_1_BIG_PEARL (FLAG_HIDDEN_ITEMS_START + 0x0B)
-#define FLAG_HIDDEN_ITEM_UNDERWATER_1_HEART_SCALE_1 (FLAG_HIDDEN_ITEMS_START + 0x0D)
-#define FLAG_HIDDEN_ITEM_UNDERWATER_1_CALCIUM (FLAG_HIDDEN_ITEMS_START + 0x24)
-#define FLAG_HIDDEN_ITEM_UNDERWATER_1_HEART_SCALE_2 (FLAG_HIDDEN_ITEMS_START + 0x26)
-#define FLAG_HIDDEN_ITEM_UNDERWATER_2_HEART_SCALE (FLAG_HIDDEN_ITEMS_START + 0x0E)
-#define FLAG_HIDDEN_ITEM_UNDERWATER_2_ULTRA_BALL (FLAG_HIDDEN_ITEMS_START + 0x0F)
-#define FLAG_HIDDEN_ITEM_UNDERWATER_2_STARDUST (FLAG_HIDDEN_ITEMS_START + 0x10)
-#define FLAG_HIDDEN_ITEM_UNDERWATER_2_PEARL (FLAG_HIDDEN_ITEMS_START + 0x11)
-#define FLAG_HIDDEN_ITEM_UNDERWATER_2_IRON (FLAG_HIDDEN_ITEMS_START + 0x13)
-#define FLAG_HIDDEN_ITEM_UNDERWATER_2_YELLOW_SHARD (FLAG_HIDDEN_ITEMS_START + 0x12)
-#define FLAG_HIDDEN_ITEM_UNDERWATER_2_BIG_PEARL (FLAG_HIDDEN_ITEMS_START + 0x14)
-#define FLAG_HIDDEN_ITEM_UNDERWATER_2_BLUE_SHARD (FLAG_HIDDEN_ITEMS_START + 0x0C)
-#define FLAG_HIDDEN_ITEM_UNDERWATER_3_STAR_PIECE (FLAG_HIDDEN_ITEMS_START + 0x15)
-#define FLAG_HIDDEN_ITEM_UNDERWATER_3_HP_UP (FLAG_HIDDEN_ITEMS_START + 0x16)
-#define FLAG_HIDDEN_ITEM_UNDERWATER_3_HEART_SCALE (FLAG_HIDDEN_ITEMS_START + 0x17)
-#define FLAG_HIDDEN_ITEM_UNDERWATER_3_RED_SHARD (FLAG_HIDDEN_ITEMS_START + 0x18)
-#define FLAG_HIDDEN_ITEM_UNDERWATER_4_PROTEIN (FLAG_HIDDEN_ITEMS_START + 0x19)
-#define FLAG_HIDDEN_ITEM_UNDERWATER_4_PEARL (FLAG_HIDDEN_ITEMS_START + 0x1A)
+#define FLAG_HIDDEN_ITEM_UNDERWATER_124_CARBOS (FLAG_HIDDEN_ITEMS_START + 0x08)
+#define FLAG_HIDDEN_ITEM_UNDERWATER_124_GREEN_SHARD (FLAG_HIDDEN_ITEMS_START + 0x09)
+#define FLAG_HIDDEN_ITEM_UNDERWATER_124_PEARL (FLAG_HIDDEN_ITEMS_START + 0x0A)
+#define FLAG_HIDDEN_ITEM_UNDERWATER_124_BIG_PEARL (FLAG_HIDDEN_ITEMS_START + 0x0B)
+#define FLAG_HIDDEN_ITEM_UNDERWATER_124_HEART_SCALE_1 (FLAG_HIDDEN_ITEMS_START + 0x0D)
+#define FLAG_HIDDEN_ITEM_UNDERWATER_124_CALCIUM (FLAG_HIDDEN_ITEMS_START + 0x24)
+#define FLAG_HIDDEN_ITEM_UNDERWATER_124_HEART_SCALE_2 (FLAG_HIDDEN_ITEMS_START + 0x26)
+#define FLAG_HIDDEN_ITEM_UNDERWATER_126_HEART_SCALE (FLAG_HIDDEN_ITEMS_START + 0x0E)
+#define FLAG_HIDDEN_ITEM_UNDERWATER_126_ULTRA_BALL (FLAG_HIDDEN_ITEMS_START + 0x0F)
+#define FLAG_HIDDEN_ITEM_UNDERWATER_126_STARDUST (FLAG_HIDDEN_ITEMS_START + 0x10)
+#define FLAG_HIDDEN_ITEM_UNDERWATER_126_PEARL (FLAG_HIDDEN_ITEMS_START + 0x11)
+#define FLAG_HIDDEN_ITEM_UNDERWATER_126_IRON (FLAG_HIDDEN_ITEMS_START + 0x13)
+#define FLAG_HIDDEN_ITEM_UNDERWATER_126_YELLOW_SHARD (FLAG_HIDDEN_ITEMS_START + 0x12)
+#define FLAG_HIDDEN_ITEM_UNDERWATER_126_BIG_PEARL (FLAG_HIDDEN_ITEMS_START + 0x14)
+#define FLAG_HIDDEN_ITEM_UNDERWATER_126_BLUE_SHARD (FLAG_HIDDEN_ITEMS_START + 0x0C)
+#define FLAG_HIDDEN_ITEM_UNDERWATER_127_STAR_PIECE (FLAG_HIDDEN_ITEMS_START + 0x15)
+#define FLAG_HIDDEN_ITEM_UNDERWATER_127_HP_UP (FLAG_HIDDEN_ITEMS_START + 0x16)
+#define FLAG_HIDDEN_ITEM_UNDERWATER_127_HEART_SCALE (FLAG_HIDDEN_ITEMS_START + 0x17)
+#define FLAG_HIDDEN_ITEM_UNDERWATER_127_RED_SHARD (FLAG_HIDDEN_ITEMS_START + 0x18)
+#define FLAG_HIDDEN_ITEM_UNDERWATER_128_PROTEIN (FLAG_HIDDEN_ITEMS_START + 0x19)
+#define FLAG_HIDDEN_ITEM_UNDERWATER_128_PEARL (FLAG_HIDDEN_ITEMS_START + 0x1A)
#define FLAG_HIDDEN_ITEM_FALLARBOR_TOWN_NUGGET (FLAG_HIDDEN_ITEMS_START + 0x1C)
#define FLAG_HIDDEN_ITEM_LAVARIDGE_TOWN_ICE_HEAL (FLAG_HIDDEN_ITEMS_START + 0x00)
#define FLAG_HIDDEN_ITEM_ABANDONED_SHIP_RM_1_KEY (FLAG_HIDDEN_ITEMS_START + 0x1F)
@@ -1012,7 +1012,7 @@
#define FLAG_HIDE_MOSSDEEP_CITY_STEVENS_HOUSE_STEVEN 0x3C7
#define FLAG_HIDE_MOSSDEEP_CITY_STEVENS_HOUSE_BELDUM_POKEBALL 0x3C8
#define FLAG_HIDE_FORTREE_CITY_KECLEON 0x3C9
-#define FLAG_HIDE_ROUTE_120_KECLEON_BRIDGE_INVISIBLE 0x3CA
+#define FLAG_HIDE_ROUTE_120_KECLEON_BRIDGE 0x3CA
#define FLAG_HIDE_LILYCOVE_CITY_RIVAL 0x3CB
#define FLAG_HIDE_ROUTE_120_STEVEN 0x3CC
#define FLAG_HIDE_SOOTOPOLIS_CITY_STEVEN 0x3CD
@@ -1023,7 +1023,7 @@
#define FLAG_HIDE_AQUA_HIDEOUT_B1F_ELECTRODE_2 0x3D2
#define FLAG_HIDE_OLDALE_TOWN_RIVAL 0x3D3
#define FLAG_HIDE_UNDERWATER_SEA_FLOOR_CAVERN_STOLEN_SUBMARINE 0x3D4
-#define FLAG_HIDE_ROUTE_120_KECLEON_BRIDGE_VISIBLE 0x3D5
+#define FLAG_HIDE_ROUTE_120_KECLEON_BRIDGE_SHADOW 0x3D5
#define FLAG_HIDE_ROUTE_120_KECLEON_1 0x3D6
#define FLAG_HIDE_RUSTURF_TUNNEL_WANDA 0x3D7
#define FLAG_HIDE_VERDANTURF_TOWN_WANDAS_HOUSE_WANDA 0x3D8
diff --git a/include/constants/item_effects.h b/include/constants/item_effects.h
index 49fcedc61..6e61c4d7f 100644
--- a/include/constants/item_effects.h
+++ b/include/constants/item_effects.h
@@ -51,6 +51,11 @@
// fields 6 and onwards are item-specific arguments
+// Special HP recovery amounts for ITEM4_HEAL_HP
+#define ITEM6_HEAL_FULL ((u8) -1)
+#define ITEM6_HEAL_HALF ((u8) -2)
+#define ITEM6_HEAL_LVL_UP ((u8) -3)
+
// Used for GetItemEffectType.
#define ITEM_EFFECT_X_ITEM 0
#define ITEM_EFFECT_RAISE_LEVEL 1
diff --git a/include/constants/items.h b/include/constants/items.h
index 9496a4c61..95c6aacfe 100644
--- a/include/constants/items.h
+++ b/include/constants/items.h
@@ -497,6 +497,10 @@
#define MAX_PC_ITEM_CAPACITY 999
#define MAX_BERRY_CAPACITY 999
+#define BAG_ITEM_CAPACITY_DIGITS 2
+#define BERRY_CAPACITY_DIGITS 3
+#define MAX_ITEM_DIGITS BERRY_CAPACITY_DIGITS
+
// Secondary IDs for rods
#define OLD_ROD 0
#define GOOD_ROD 1
diff --git a/include/constants/layouts.h b/include/constants/layouts.h
index 500b82cd4..9d5e877b0 100755
--- a/include/constants/layouts.h
+++ b/include/constants/layouts.h
@@ -55,9 +55,9 @@
#define LAYOUT_ROUTE132 48
#define LAYOUT_ROUTE133 49
#define LAYOUT_ROUTE134 50
-#define LAYOUT_UNDERWATER2 51
-#define LAYOUT_UNDERWATER3 52
-#define LAYOUT_UNDERWATER4 53
+#define LAYOUT_UNDERWATER_ROUTE126 51
+#define LAYOUT_UNDERWATER_ROUTE127 52
+#define LAYOUT_UNDERWATER_ROUTE128 53
#define LAYOUT_LITTLEROOT_TOWN_BRENDANS_HOUSE_1F 54
#define LAYOUT_LITTLEROOT_TOWN_BRENDANS_HOUSE_2F 55
#define LAYOUT_LITTLEROOT_TOWN_MAYS_HOUSE_1F 56
@@ -278,7 +278,7 @@
#define LAYOUT_ROUTE119_WEATHER_INSTITUTE_1F 271
#define LAYOUT_ROUTE119_WEATHER_INSTITUTE_2F 272
#define LAYOUT_LILYCOVE_CITY_DEPARTMENT_STORE_ELEVATOR 273
-#define LAYOUT_UNDERWATER1 274
+#define LAYOUT_UNDERWATER_ROUTE124 274
#define LAYOUT_MOSSDEEP_CITY_SPACE_CENTER_1F 275
#define LAYOUT_MOSSDEEP_CITY_SPACE_CENTER_2F 276
#define LAYOUT_SS_TIDAL_CORRIDOR 277
@@ -414,9 +414,9 @@
#define LAYOUT_MARINE_CAVE_ENTRANCE 407
#define LAYOUT_TERRA_CAVE_ENTRANCE 408
#define LAYOUT_TERRA_CAVE_END 409
-#define LAYOUT_UNDERWATER6 410
-#define LAYOUT_UNDERWATER7 411
-#define LAYOUT_UNDERWATER5 412
+#define LAYOUT_UNDERWATER_ROUTE105 410
+#define LAYOUT_UNDERWATER_ROUTE125 411
+#define LAYOUT_UNDERWATER_ROUTE129 412
#define LAYOUT_MARINE_CAVE_END 413
#define LAYOUT_TRAINER_HILL_ENTRANCE 414
#define LAYOUT_TRAINER_HILL_1F 415
diff --git a/include/constants/map_groups.h b/include/constants/map_groups.h
index aef9924fa..69355635b 100755
--- a/include/constants/map_groups.h
+++ b/include/constants/map_groups.h
@@ -6,63 +6,63 @@
//
// Map Group 0
-#define MAP_PETALBURG_CITY (0 | (0 << 8))
-#define MAP_SLATEPORT_CITY (1 | (0 << 8))
-#define MAP_MAUVILLE_CITY (2 | (0 << 8))
-#define MAP_RUSTBORO_CITY (3 | (0 << 8))
-#define MAP_FORTREE_CITY (4 | (0 << 8))
-#define MAP_LILYCOVE_CITY (5 | (0 << 8))
-#define MAP_MOSSDEEP_CITY (6 | (0 << 8))
-#define MAP_SOOTOPOLIS_CITY (7 | (0 << 8))
-#define MAP_EVER_GRANDE_CITY (8 | (0 << 8))
-#define MAP_LITTLEROOT_TOWN (9 | (0 << 8))
-#define MAP_OLDALE_TOWN (10 | (0 << 8))
-#define MAP_DEWFORD_TOWN (11 | (0 << 8))
-#define MAP_LAVARIDGE_TOWN (12 | (0 << 8))
-#define MAP_FALLARBOR_TOWN (13 | (0 << 8))
-#define MAP_VERDANTURF_TOWN (14 | (0 << 8))
-#define MAP_PACIFIDLOG_TOWN (15 | (0 << 8))
-#define MAP_ROUTE101 (16 | (0 << 8))
-#define MAP_ROUTE102 (17 | (0 << 8))
-#define MAP_ROUTE103 (18 | (0 << 8))
-#define MAP_ROUTE104 (19 | (0 << 8))
-#define MAP_ROUTE105 (20 | (0 << 8))
-#define MAP_ROUTE106 (21 | (0 << 8))
-#define MAP_ROUTE107 (22 | (0 << 8))
-#define MAP_ROUTE108 (23 | (0 << 8))
-#define MAP_ROUTE109 (24 | (0 << 8))
-#define MAP_ROUTE110 (25 | (0 << 8))
-#define MAP_ROUTE111 (26 | (0 << 8))
-#define MAP_ROUTE112 (27 | (0 << 8))
-#define MAP_ROUTE113 (28 | (0 << 8))
-#define MAP_ROUTE114 (29 | (0 << 8))
-#define MAP_ROUTE115 (30 | (0 << 8))
-#define MAP_ROUTE116 (31 | (0 << 8))
-#define MAP_ROUTE117 (32 | (0 << 8))
-#define MAP_ROUTE118 (33 | (0 << 8))
-#define MAP_ROUTE119 (34 | (0 << 8))
-#define MAP_ROUTE120 (35 | (0 << 8))
-#define MAP_ROUTE121 (36 | (0 << 8))
-#define MAP_ROUTE122 (37 | (0 << 8))
-#define MAP_ROUTE123 (38 | (0 << 8))
-#define MAP_ROUTE124 (39 | (0 << 8))
-#define MAP_ROUTE125 (40 | (0 << 8))
-#define MAP_ROUTE126 (41 | (0 << 8))
-#define MAP_ROUTE127 (42 | (0 << 8))
-#define MAP_ROUTE128 (43 | (0 << 8))
-#define MAP_ROUTE129 (44 | (0 << 8))
-#define MAP_ROUTE130 (45 | (0 << 8))
-#define MAP_ROUTE131 (46 | (0 << 8))
-#define MAP_ROUTE132 (47 | (0 << 8))
-#define MAP_ROUTE133 (48 | (0 << 8))
-#define MAP_ROUTE134 (49 | (0 << 8))
-#define MAP_UNDERWATER1 (50 | (0 << 8))
-#define MAP_UNDERWATER2 (51 | (0 << 8))
-#define MAP_UNDERWATER3 (52 | (0 << 8))
-#define MAP_UNDERWATER4 (53 | (0 << 8))
-#define MAP_UNDERWATER5 (54 | (0 << 8))
-#define MAP_UNDERWATER6 (55 | (0 << 8))
-#define MAP_UNDERWATER7 (56 | (0 << 8))
+#define MAP_PETALBURG_CITY (0 | (0 << 8))
+#define MAP_SLATEPORT_CITY (1 | (0 << 8))
+#define MAP_MAUVILLE_CITY (2 | (0 << 8))
+#define MAP_RUSTBORO_CITY (3 | (0 << 8))
+#define MAP_FORTREE_CITY (4 | (0 << 8))
+#define MAP_LILYCOVE_CITY (5 | (0 << 8))
+#define MAP_MOSSDEEP_CITY (6 | (0 << 8))
+#define MAP_SOOTOPOLIS_CITY (7 | (0 << 8))
+#define MAP_EVER_GRANDE_CITY (8 | (0 << 8))
+#define MAP_LITTLEROOT_TOWN (9 | (0 << 8))
+#define MAP_OLDALE_TOWN (10 | (0 << 8))
+#define MAP_DEWFORD_TOWN (11 | (0 << 8))
+#define MAP_LAVARIDGE_TOWN (12 | (0 << 8))
+#define MAP_FALLARBOR_TOWN (13 | (0 << 8))
+#define MAP_VERDANTURF_TOWN (14 | (0 << 8))
+#define MAP_PACIFIDLOG_TOWN (15 | (0 << 8))
+#define MAP_ROUTE101 (16 | (0 << 8))
+#define MAP_ROUTE102 (17 | (0 << 8))
+#define MAP_ROUTE103 (18 | (0 << 8))
+#define MAP_ROUTE104 (19 | (0 << 8))
+#define MAP_ROUTE105 (20 | (0 << 8))
+#define MAP_ROUTE106 (21 | (0 << 8))
+#define MAP_ROUTE107 (22 | (0 << 8))
+#define MAP_ROUTE108 (23 | (0 << 8))
+#define MAP_ROUTE109 (24 | (0 << 8))
+#define MAP_ROUTE110 (25 | (0 << 8))
+#define MAP_ROUTE111 (26 | (0 << 8))
+#define MAP_ROUTE112 (27 | (0 << 8))
+#define MAP_ROUTE113 (28 | (0 << 8))
+#define MAP_ROUTE114 (29 | (0 << 8))
+#define MAP_ROUTE115 (30 | (0 << 8))
+#define MAP_ROUTE116 (31 | (0 << 8))
+#define MAP_ROUTE117 (32 | (0 << 8))
+#define MAP_ROUTE118 (33 | (0 << 8))
+#define MAP_ROUTE119 (34 | (0 << 8))
+#define MAP_ROUTE120 (35 | (0 << 8))
+#define MAP_ROUTE121 (36 | (0 << 8))
+#define MAP_ROUTE122 (37 | (0 << 8))
+#define MAP_ROUTE123 (38 | (0 << 8))
+#define MAP_ROUTE124 (39 | (0 << 8))
+#define MAP_ROUTE125 (40 | (0 << 8))
+#define MAP_ROUTE126 (41 | (0 << 8))
+#define MAP_ROUTE127 (42 | (0 << 8))
+#define MAP_ROUTE128 (43 | (0 << 8))
+#define MAP_ROUTE129 (44 | (0 << 8))
+#define MAP_ROUTE130 (45 | (0 << 8))
+#define MAP_ROUTE131 (46 | (0 << 8))
+#define MAP_ROUTE132 (47 | (0 << 8))
+#define MAP_ROUTE133 (48 | (0 << 8))
+#define MAP_ROUTE134 (49 | (0 << 8))
+#define MAP_UNDERWATER_ROUTE124 (50 | (0 << 8))
+#define MAP_UNDERWATER_ROUTE126 (51 | (0 << 8))
+#define MAP_UNDERWATER_ROUTE127 (52 | (0 << 8))
+#define MAP_UNDERWATER_ROUTE128 (53 | (0 << 8))
+#define MAP_UNDERWATER_ROUTE129 (54 | (0 << 8))
+#define MAP_UNDERWATER_ROUTE105 (55 | (0 << 8))
+#define MAP_UNDERWATER_ROUTE125 (56 | (0 << 8))
// Map Group 1
#define MAP_LITTLEROOT_TOWN_BRENDANS_HOUSE_1F (0 | (1 << 8))
diff --git a/include/constants/pokemon.h b/include/constants/pokemon.h
index 52eabe71b..bac914fec 100644
--- a/include/constants/pokemon.h
+++ b/include/constants/pokemon.h
@@ -239,12 +239,12 @@
#define UNOWN_FORM_COUNT 28
// Battle move flags
-#define FLAG_MAKES_CONTACT 0x1
-#define FLAG_PROTECT_AFFECTED 0x2
-#define FLAG_MAGICCOAT_AFFECTED 0x4
-#define FLAG_SNATCH_AFFECTED 0x8
-#define FLAG_MIRROR_MOVE_AFFECTED 0x10
-#define FLAG_KINGSROCK_AFFECTED 0x20
+#define FLAG_MAKES_CONTACT (1 << 0)
+#define FLAG_PROTECT_AFFECTED (1 << 1)
+#define FLAG_MAGIC_COAT_AFFECTED (1 << 2)
+#define FLAG_SNATCH_AFFECTED (1 << 3)
+#define FLAG_MIRROR_MOVE_AFFECTED (1 << 4)
+#define FLAG_KINGS_ROCK_AFFECTED (1 << 5)
// Growth rates
#define GROWTH_MEDIUM_FAST 0
@@ -268,22 +268,22 @@
#define F_SUMMARY_SCREEN_FLIP_SPRITE 0x80
-// Evolution type flags
-#define EVO_FRIENDSHIP 0x0001 // Pokémon levels up with friendship ≥ 220
-#define EVO_FRIENDSHIP_DAY 0x0002 // Pokémon levels up during the day with friendship ≥ 220
-#define EVO_FRIENDSHIP_NIGHT 0x0003 // Pokémon levels up at night with friendship ≥ 220
-#define EVO_LEVEL 0x0004 // Pokémon reaches the specified level
-#define EVO_TRADE 0x0005 // Pokémon is traded
-#define EVO_TRADE_ITEM 0x0006 // Pokémon is traded while it's holding the specified item
-#define EVO_ITEM 0x0007 // specified item is used on Pokémon
-#define EVO_LEVEL_ATK_GT_DEF 0x0008 // Pokémon reaches the specified level with attack > defense
-#define EVO_LEVEL_ATK_EQ_DEF 0x0009 // Pokémon reaches the specified level with attack = defense
-#define EVO_LEVEL_ATK_LT_DEF 0x000a // Pokémon reaches the specified level with attack < defense
-#define EVO_LEVEL_SILCOON 0x000b // Pokémon reaches the specified level with a Silcoon personality value
-#define EVO_LEVEL_CASCOON 0x000c // Pokémon reaches the specified level with a Cascoon personality value
-#define EVO_LEVEL_NINJASK 0x000d // Pokémon reaches the specified level (special value for Ninjask)
-#define EVO_LEVEL_SHEDINJA 0x000e // Pokémon reaches the specified level (special value for Shedinja)
-#define EVO_BEAUTY 0x000f // Pokémon levels up with beauty ≥ specified value
+// Evolution types
+#define EVO_FRIENDSHIP 1 // Pokémon levels up with friendship ≥ 220
+#define EVO_FRIENDSHIP_DAY 2 // Pokémon levels up during the day with friendship ≥ 220
+#define EVO_FRIENDSHIP_NIGHT 3 // Pokémon levels up at night with friendship ≥ 220
+#define EVO_LEVEL 4 // Pokémon reaches the specified level
+#define EVO_TRADE 5 // Pokémon is traded
+#define EVO_TRADE_ITEM 6 // Pokémon is traded while it's holding the specified item
+#define EVO_ITEM 7 // specified item is used on Pokémon
+#define EVO_LEVEL_ATK_GT_DEF 8 // Pokémon reaches the specified level with attack > defense
+#define EVO_LEVEL_ATK_EQ_DEF 9 // Pokémon reaches the specified level with attack = defense
+#define EVO_LEVEL_ATK_LT_DEF 10 // Pokémon reaches the specified level with attack < defense
+#define EVO_LEVEL_SILCOON 11 // Pokémon reaches the specified level with a Silcoon personality value
+#define EVO_LEVEL_CASCOON 12 // Pokémon reaches the specified level with a Cascoon personality value
+#define EVO_LEVEL_NINJASK 13 // Pokémon reaches the specified level (special value for Ninjask)
+#define EVO_LEVEL_SHEDINJA 14 // Pokémon reaches the specified level (special value for Shedinja)
+#define EVO_BEAUTY 15 // Pokémon levels up with beauty ≥ specified value
#define EVOS_PER_MON 5
diff --git a/include/constants/region_map_sections.h b/include/constants/region_map_sections.h
index 5e64048dd..65aa3e1ca 100644
--- a/include/constants/region_map_sections.h
+++ b/include/constants/region_map_sections.h
@@ -52,9 +52,9 @@
#define MAPSEC_ROUTE_133 0x30
#define MAPSEC_ROUTE_134 0x31
#define MAPSEC_UNDERWATER_124 0x32
-#define MAPSEC_UNDERWATER_125 0x33
-#define MAPSEC_UNDERWATER_126 0x34
-#define MAPSEC_UNDERWATER_127 0x35
+#define MAPSEC_UNDERWATER_126 0x33
+#define MAPSEC_UNDERWATER_127 0x34
+#define MAPSEC_UNDERWATER_128 0x35
#define MAPSEC_UNDERWATER_SOOTOPOLIS 0x36
#define MAPSEC_GRANITE_CAVE 0x37
#define MAPSEC_MT_CHIMNEY 0x38
@@ -70,7 +70,7 @@
#define MAPSEC_AQUA_HIDEOUT_OLD 0x42
#define MAPSEC_SHOAL_CAVE 0x43
#define MAPSEC_SEAFLOOR_CAVERN 0x44
-#define MAPSEC_UNDERWATER_128 0x45
+#define MAPSEC_UNDERWATER_SEAFLOOR_CAVERN 0x45
#define MAPSEC_VICTORY_ROAD 0x46
#define MAPSEC_MIRAGE_ISLAND 0x47
#define MAPSEC_CAVE_OF_ORIGIN 0x48
@@ -207,8 +207,8 @@
#define MAPSEC_MARINE_CAVE 0xCB
#define MAPSEC_UNDERWATER_MARINE_CAVE 0xCC
#define MAPSEC_TERRA_CAVE 0xCD
-#define MAPSEC_UNDERWATER_TERRA_CAVE 0xCE
-#define MAPSEC_UNDERWATER_UNK1 0xCF
+#define MAPSEC_UNDERWATER_105 0xCE
+#define MAPSEC_UNDERWATER_125 0xCF
#define MAPSEC_UNDERWATER_129 0xD0
#define MAPSEC_DESERT_UNDERPASS 0xD1
#define MAPSEC_ALTERING_CAVE 0xD2
diff --git a/include/constants/rgb.h b/include/constants/rgb.h
index 80d951f4b..1896250d2 100644
--- a/include/constants/rgb.h
+++ b/include/constants/rgb.h
@@ -1,6 +1,10 @@
#ifndef GUARD_RGB_H
#define GUARD_RGB_H
+#define GET_R(color) ((color) & 0x1F)
+#define GET_G(color) (((color) >> 5) & 0x1F)
+#define GET_B(color) (((color) >> 10) & 0x1F)
+
#define RGB(r, g, b) ((r) | ((g) << 5) | ((b) << 10))
#define RGB2(r, g, b) (((b) << 10) | ((g) << 5) | (r))
#define _RGB(r, g, b) ((((b) & 0x1F) << 10) + (((g) & 0x1F) << 5) + ((r) & 0x1F))
diff --git a/include/constants/species.h b/include/constants/species.h
index 8fa5cf77b..983e1a796 100644
--- a/include/constants/species.h
+++ b/include/constants/species.h
@@ -417,36 +417,36 @@
#define SPECIES_CHIMECHO 411
#define SPECIES_EGG 412
-#define SPECIES_UNOWN_B 413
-#define SPECIES_UNOWN_C 414
-#define SPECIES_UNOWN_D 415
-#define SPECIES_UNOWN_E 416
-#define SPECIES_UNOWN_F 417
-#define SPECIES_UNOWN_G 418
-#define SPECIES_UNOWN_H 419
-#define SPECIES_UNOWN_I 420
-#define SPECIES_UNOWN_J 421
-#define SPECIES_UNOWN_K 422
-#define SPECIES_UNOWN_L 423
-#define SPECIES_UNOWN_M 424
-#define SPECIES_UNOWN_N 425
-#define SPECIES_UNOWN_O 426
-#define SPECIES_UNOWN_P 427
-#define SPECIES_UNOWN_Q 428
-#define SPECIES_UNOWN_R 429
-#define SPECIES_UNOWN_S 430
-#define SPECIES_UNOWN_T 431
-#define SPECIES_UNOWN_U 432
-#define SPECIES_UNOWN_V 433
-#define SPECIES_UNOWN_W 434
-#define SPECIES_UNOWN_X 435
-#define SPECIES_UNOWN_Y 436
-#define SPECIES_UNOWN_Z 437
-#define SPECIES_UNOWN_EMARK 438
-#define SPECIES_UNOWN_QMARK 439
-
#define NUM_SPECIES SPECIES_EGG
+#define SPECIES_UNOWN_B (NUM_SPECIES + 1)
+#define SPECIES_UNOWN_C (SPECIES_UNOWN_B + 1)
+#define SPECIES_UNOWN_D (SPECIES_UNOWN_B + 2)
+#define SPECIES_UNOWN_E (SPECIES_UNOWN_B + 3)
+#define SPECIES_UNOWN_F (SPECIES_UNOWN_B + 4)
+#define SPECIES_UNOWN_G (SPECIES_UNOWN_B + 5)
+#define SPECIES_UNOWN_H (SPECIES_UNOWN_B + 6)
+#define SPECIES_UNOWN_I (SPECIES_UNOWN_B + 7)
+#define SPECIES_UNOWN_J (SPECIES_UNOWN_B + 8)
+#define SPECIES_UNOWN_K (SPECIES_UNOWN_B + 9)
+#define SPECIES_UNOWN_L (SPECIES_UNOWN_B + 10)
+#define SPECIES_UNOWN_M (SPECIES_UNOWN_B + 11)
+#define SPECIES_UNOWN_N (SPECIES_UNOWN_B + 12)
+#define SPECIES_UNOWN_O (SPECIES_UNOWN_B + 13)
+#define SPECIES_UNOWN_P (SPECIES_UNOWN_B + 14)
+#define SPECIES_UNOWN_Q (SPECIES_UNOWN_B + 15)
+#define SPECIES_UNOWN_R (SPECIES_UNOWN_B + 16)
+#define SPECIES_UNOWN_S (SPECIES_UNOWN_B + 17)
+#define SPECIES_UNOWN_T (SPECIES_UNOWN_B + 18)
+#define SPECIES_UNOWN_U (SPECIES_UNOWN_B + 19)
+#define SPECIES_UNOWN_V (SPECIES_UNOWN_B + 20)
+#define SPECIES_UNOWN_W (SPECIES_UNOWN_B + 21)
+#define SPECIES_UNOWN_X (SPECIES_UNOWN_B + 22)
+#define SPECIES_UNOWN_Y (SPECIES_UNOWN_B + 23)
+#define SPECIES_UNOWN_Z (SPECIES_UNOWN_B + 24)
+#define SPECIES_UNOWN_EMARK (SPECIES_UNOWN_B + 25)
+#define SPECIES_UNOWN_QMARK (SPECIES_UNOWN_B + 26)
+
// National Dex Index Defines
#define NATIONAL_DEX_NONE 0
@@ -845,31 +845,31 @@
#define NATIONAL_DEX_COUNT NATIONAL_DEX_DEOXYS
-#define NATIONAL_DEX_OLD_UNOWN_B 387
-#define NATIONAL_DEX_OLD_UNOWN_C 388
-#define NATIONAL_DEX_OLD_UNOWN_D 389
-#define NATIONAL_DEX_OLD_UNOWN_E 390
-#define NATIONAL_DEX_OLD_UNOWN_F 391
-#define NATIONAL_DEX_OLD_UNOWN_G 392
-#define NATIONAL_DEX_OLD_UNOWN_H 393
-#define NATIONAL_DEX_OLD_UNOWN_I 394
-#define NATIONAL_DEX_OLD_UNOWN_J 395
-#define NATIONAL_DEX_OLD_UNOWN_K 396
-#define NATIONAL_DEX_OLD_UNOWN_L 397
-#define NATIONAL_DEX_OLD_UNOWN_M 398
-#define NATIONAL_DEX_OLD_UNOWN_N 399
-#define NATIONAL_DEX_OLD_UNOWN_O 400
-#define NATIONAL_DEX_OLD_UNOWN_P 401
-#define NATIONAL_DEX_OLD_UNOWN_Q 402
-#define NATIONAL_DEX_OLD_UNOWN_R 403
-#define NATIONAL_DEX_OLD_UNOWN_S 404
-#define NATIONAL_DEX_OLD_UNOWN_T 405
-#define NATIONAL_DEX_OLD_UNOWN_U 406
-#define NATIONAL_DEX_OLD_UNOWN_V 407
-#define NATIONAL_DEX_OLD_UNOWN_W 408
-#define NATIONAL_DEX_OLD_UNOWN_X 409
-#define NATIONAL_DEX_OLD_UNOWN_Y 410
-#define NATIONAL_DEX_OLD_UNOWN_Z 411
+#define NATIONAL_DEX_OLD_UNOWN_B (NATIONAL_DEX_COUNT + 1)
+#define NATIONAL_DEX_OLD_UNOWN_C (NATIONAL_DEX_OLD_UNOWN_B + 1)
+#define NATIONAL_DEX_OLD_UNOWN_D (NATIONAL_DEX_OLD_UNOWN_B + 2)
+#define NATIONAL_DEX_OLD_UNOWN_E (NATIONAL_DEX_OLD_UNOWN_B + 3)
+#define NATIONAL_DEX_OLD_UNOWN_F (NATIONAL_DEX_OLD_UNOWN_B + 4)
+#define NATIONAL_DEX_OLD_UNOWN_G (NATIONAL_DEX_OLD_UNOWN_B + 5)
+#define NATIONAL_DEX_OLD_UNOWN_H (NATIONAL_DEX_OLD_UNOWN_B + 6)
+#define NATIONAL_DEX_OLD_UNOWN_I (NATIONAL_DEX_OLD_UNOWN_B + 7)
+#define NATIONAL_DEX_OLD_UNOWN_J (NATIONAL_DEX_OLD_UNOWN_B + 8)
+#define NATIONAL_DEX_OLD_UNOWN_K (NATIONAL_DEX_OLD_UNOWN_B + 9)
+#define NATIONAL_DEX_OLD_UNOWN_L (NATIONAL_DEX_OLD_UNOWN_B + 10)
+#define NATIONAL_DEX_OLD_UNOWN_M (NATIONAL_DEX_OLD_UNOWN_B + 11)
+#define NATIONAL_DEX_OLD_UNOWN_N (NATIONAL_DEX_OLD_UNOWN_B + 12)
+#define NATIONAL_DEX_OLD_UNOWN_O (NATIONAL_DEX_OLD_UNOWN_B + 13)
+#define NATIONAL_DEX_OLD_UNOWN_P (NATIONAL_DEX_OLD_UNOWN_B + 14)
+#define NATIONAL_DEX_OLD_UNOWN_Q (NATIONAL_DEX_OLD_UNOWN_B + 15)
+#define NATIONAL_DEX_OLD_UNOWN_R (NATIONAL_DEX_OLD_UNOWN_B + 16)
+#define NATIONAL_DEX_OLD_UNOWN_S (NATIONAL_DEX_OLD_UNOWN_B + 17)
+#define NATIONAL_DEX_OLD_UNOWN_T (NATIONAL_DEX_OLD_UNOWN_B + 18)
+#define NATIONAL_DEX_OLD_UNOWN_U (NATIONAL_DEX_OLD_UNOWN_B + 19)
+#define NATIONAL_DEX_OLD_UNOWN_V (NATIONAL_DEX_OLD_UNOWN_B + 20)
+#define NATIONAL_DEX_OLD_UNOWN_W (NATIONAL_DEX_OLD_UNOWN_B + 21)
+#define NATIONAL_DEX_OLD_UNOWN_X (NATIONAL_DEX_OLD_UNOWN_B + 22)
+#define NATIONAL_DEX_OLD_UNOWN_Y (NATIONAL_DEX_OLD_UNOWN_B + 23)
+#define NATIONAL_DEX_OLD_UNOWN_Z (NATIONAL_DEX_OLD_UNOWN_B + 24)
// Hoenn Dex Index Defines
@@ -1264,30 +1264,30 @@
#define HOENN_DEX_HO_OH 385
#define HOENN_DEX_CELEBI 386
-#define HOENN_DEX_OLD_UNOWN_B 387
-#define HOENN_DEX_OLD_UNOWN_C 388
-#define HOENN_DEX_OLD_UNOWN_D 389
-#define HOENN_DEX_OLD_UNOWN_E 390
-#define HOENN_DEX_OLD_UNOWN_F 391
-#define HOENN_DEX_OLD_UNOWN_G 392
-#define HOENN_DEX_OLD_UNOWN_H 393
-#define HOENN_DEX_OLD_UNOWN_I 394
-#define HOENN_DEX_OLD_UNOWN_J 395
-#define HOENN_DEX_OLD_UNOWN_K 396
-#define HOENN_DEX_OLD_UNOWN_L 397
-#define HOENN_DEX_OLD_UNOWN_M 398
-#define HOENN_DEX_OLD_UNOWN_N 399
-#define HOENN_DEX_OLD_UNOWN_O 400
-#define HOENN_DEX_OLD_UNOWN_P 401
-#define HOENN_DEX_OLD_UNOWN_Q 402
-#define HOENN_DEX_OLD_UNOWN_R 403
-#define HOENN_DEX_OLD_UNOWN_S 404
-#define HOENN_DEX_OLD_UNOWN_T 405
-#define HOENN_DEX_OLD_UNOWN_U 406
-#define HOENN_DEX_OLD_UNOWN_V 407
-#define HOENN_DEX_OLD_UNOWN_W 408
-#define HOENN_DEX_OLD_UNOWN_X 409
-#define HOENN_DEX_OLD_UNOWN_Y 410
-#define HOENN_DEX_OLD_UNOWN_Z 411
+#define HOENN_DEX_OLD_UNOWN_B (HOENN_DEX_CELEBI + 1)
+#define HOENN_DEX_OLD_UNOWN_C (HOENN_DEX_OLD_UNOWN_B + 1)
+#define HOENN_DEX_OLD_UNOWN_D (HOENN_DEX_OLD_UNOWN_B + 2)
+#define HOENN_DEX_OLD_UNOWN_E (HOENN_DEX_OLD_UNOWN_B + 3)
+#define HOENN_DEX_OLD_UNOWN_F (HOENN_DEX_OLD_UNOWN_B + 4)
+#define HOENN_DEX_OLD_UNOWN_G (HOENN_DEX_OLD_UNOWN_B + 5)
+#define HOENN_DEX_OLD_UNOWN_H (HOENN_DEX_OLD_UNOWN_B + 6)
+#define HOENN_DEX_OLD_UNOWN_I (HOENN_DEX_OLD_UNOWN_B + 7)
+#define HOENN_DEX_OLD_UNOWN_J (HOENN_DEX_OLD_UNOWN_B + 8)
+#define HOENN_DEX_OLD_UNOWN_K (HOENN_DEX_OLD_UNOWN_B + 9)
+#define HOENN_DEX_OLD_UNOWN_L (HOENN_DEX_OLD_UNOWN_B + 10)
+#define HOENN_DEX_OLD_UNOWN_M (HOENN_DEX_OLD_UNOWN_B + 11)
+#define HOENN_DEX_OLD_UNOWN_N (HOENN_DEX_OLD_UNOWN_B + 12)
+#define HOENN_DEX_OLD_UNOWN_O (HOENN_DEX_OLD_UNOWN_B + 13)
+#define HOENN_DEX_OLD_UNOWN_P (HOENN_DEX_OLD_UNOWN_B + 14)
+#define HOENN_DEX_OLD_UNOWN_Q (HOENN_DEX_OLD_UNOWN_B + 15)
+#define HOENN_DEX_OLD_UNOWN_R (HOENN_DEX_OLD_UNOWN_B + 16)
+#define HOENN_DEX_OLD_UNOWN_S (HOENN_DEX_OLD_UNOWN_B + 17)
+#define HOENN_DEX_OLD_UNOWN_T (HOENN_DEX_OLD_UNOWN_B + 18)
+#define HOENN_DEX_OLD_UNOWN_U (HOENN_DEX_OLD_UNOWN_B + 19)
+#define HOENN_DEX_OLD_UNOWN_V (HOENN_DEX_OLD_UNOWN_B + 20)
+#define HOENN_DEX_OLD_UNOWN_W (HOENN_DEX_OLD_UNOWN_B + 21)
+#define HOENN_DEX_OLD_UNOWN_X (HOENN_DEX_OLD_UNOWN_B + 22)
+#define HOENN_DEX_OLD_UNOWN_Y (HOENN_DEX_OLD_UNOWN_B + 23)
+#define HOENN_DEX_OLD_UNOWN_Z (HOENN_DEX_OLD_UNOWN_B + 24)
#endif // GUARD_CONSTANTS_SPECIES_H
diff --git a/include/data.h b/include/data.h
index 49b98663a..260c18152 100644
--- a/include/data.h
+++ b/include/data.h
@@ -2,7 +2,6 @@
#define GUARD_DATA_H
#include "constants/moves.h"
-#include "constants/species.h"
#define SPECIES_SHINY_TAG 500
diff --git a/include/gba/io_reg.h b/include/gba/io_reg.h
index 071a89bc5..1daa99e1d 100644
--- a/include/gba/io_reg.h
+++ b/include/gba/io_reg.h
@@ -553,6 +553,7 @@
#define WININ_WIN0_BG_ALL (WININ_WIN0_BG0 | WININ_WIN0_BG1 | WININ_WIN0_BG2 | WININ_WIN0_BG3)
#define WININ_WIN0_OBJ (1 << 4)
#define WININ_WIN0_CLR (1 << 5)
+#define WININ_WIN0_ALL (WININ_WIN0_BG_ALL | WININ_WIN0_OBJ | WININ_WIN0_CLR)
#define WININ_WIN1_BG0 (1 << 8)
#define WININ_WIN1_BG1 (1 << 9)
#define WININ_WIN1_BG2 (1 << 10)
@@ -560,6 +561,7 @@
#define WININ_WIN1_BG_ALL (WININ_WIN1_BG0 | WININ_WIN1_BG1 | WININ_WIN1_BG2 | WININ_WIN1_BG3)
#define WININ_WIN1_OBJ (1 << 12)
#define WININ_WIN1_CLR (1 << 13)
+#define WININ_WIN1_ALL (WININ_WIN1_BG_ALL | WININ_WIN1_OBJ | WININ_WIN1_CLR)
#define WINOUT_WIN01_BG0 (1 << 0)
#define WINOUT_WIN01_BG1 (1 << 1)
@@ -568,6 +570,7 @@
#define WINOUT_WIN01_BG_ALL (WINOUT_WIN01_BG0 | WINOUT_WIN01_BG1 | WINOUT_WIN01_BG2 | WINOUT_WIN01_BG3)
#define WINOUT_WIN01_OBJ (1 << 4)
#define WINOUT_WIN01_CLR (1 << 5)
+#define WINOUT_WIN01_ALL (WINOUT_WIN01_BG_ALL | WINOUT_WIN01_OBJ | WINOUT_WIN01_CLR)
#define WINOUT_WINOBJ_BG0 (1 << 8)
#define WINOUT_WINOBJ_BG1 (1 << 9)
#define WINOUT_WINOBJ_BG2 (1 << 10)
@@ -575,6 +578,7 @@
#define WINOUT_WINOBJ_BG_ALL (WINOUT_WINOBJ_BG0 | WINOUT_WINOBJ_BG1 | WINOUT_WINOBJ_BG2 | WINOUT_WINOBJ_BG3)
#define WINOUT_WINOBJ_OBJ (1 << 12)
#define WINOUT_WINOBJ_CLR (1 << 13)
+#define WINOUT_WINOBJ_ALL (WINOUT_WINOBJ_BG_ALL | WINOUT_WINOBJ_OBJ | WINOUT_WINOBJ_CLR)
#define WIN_RANGE(a, b) (((a) << 8) | (b))
#define WIN_RANGE2(a, b) ((b) | ((a) << 8))
@@ -585,9 +589,10 @@
#define BLDCNT_TGT1_BG1 (1 << 1)
#define BLDCNT_TGT1_BG2 (1 << 2)
#define BLDCNT_TGT1_BG3 (1 << 3)
+#define BLDCNT_TGT1_BG_ALL (BLDCNT_TGT1_BG0 | BLDCNT_TGT1_BG1 | BLDCNT_TGT1_BG2 | BLDCNT_TGT1_BG3)
#define BLDCNT_TGT1_OBJ (1 << 4)
#define BLDCNT_TGT1_BD (1 << 5)
-#define BLDCNT_TGT1_ALL (BLDCNT_TGT1_BG0 | BLDCNT_TGT1_BG1 | BLDCNT_TGT1_BG2 | BLDCNT_TGT1_BG3 | BLDCNT_TGT1_OBJ | BLDCNT_TGT1_BD)
+#define BLDCNT_TGT1_ALL (BLDCNT_TGT1_BG_ALL | BLDCNT_TGT1_OBJ | BLDCNT_TGT1_BD)
// Bits 6-7 select the special effect
#define BLDCNT_EFFECT_NONE (0 << 6) // no special effect
#define BLDCNT_EFFECT_BLEND (1 << 6) // 1st+2nd targets mixed (controlled by BLDALPHA)
@@ -598,9 +603,10 @@
#define BLDCNT_TGT2_BG1 (1 << 9)
#define BLDCNT_TGT2_BG2 (1 << 10)
#define BLDCNT_TGT2_BG3 (1 << 11)
+#define BLDCNT_TGT2_BG_ALL (BLDCNT_TGT2_BG0 | BLDCNT_TGT2_BG1 | BLDCNT_TGT2_BG2 | BLDCNT_TGT2_BG3)
#define BLDCNT_TGT2_OBJ (1 << 12)
#define BLDCNT_TGT2_BD (1 << 13)
-#define BLDCNT_TGT2_ALL (BLDCNT_TGT2_BG0 | BLDCNT_TGT2_BG1 | BLDCNT_TGT2_BG2 | BLDCNT_TGT2_BG3 | BLDCNT_TGT2_OBJ | BLDCNT_TGT2_BD)
+#define BLDCNT_TGT2_ALL (BLDCNT_TGT2_BG_ALL | BLDCNT_TGT2_OBJ | BLDCNT_TGT2_BD)
// BLDALPHA
#define BLDALPHA_BLEND(target1, target2) (((target2) << 8) | (target1))
diff --git a/include/gba/m4a_internal.h b/include/gba/m4a_internal.h
index bdff1b865..2d0e1bb1c 100644
--- a/include/gba/m4a_internal.h
+++ b/include/gba/m4a_internal.h
@@ -67,52 +67,69 @@ struct ToneData
u8 release;
};
+#define SOUND_CHANNEL_SF_START 0x80
+#define SOUND_CHANNEL_SF_STOP 0x40
+#define SOUND_CHANNEL_SF_LOOP 0x10
+#define SOUND_CHANNEL_SF_IEC 0x04
+#define SOUND_CHANNEL_SF_ENV 0x03
+#define SOUND_CHANNEL_SF_ENV_ATTACK 0x03
+#define SOUND_CHANNEL_SF_ENV_DECAY 0x02
+#define SOUND_CHANNEL_SF_ENV_SUSTAIN 0x01
+#define SOUND_CHANNEL_SF_ENV_RELEASE 0x00
+#define SOUND_CHANNEL_SF_ON (SOUND_CHANNEL_SF_START | SOUND_CHANNEL_SF_STOP | SOUND_CHANNEL_SF_IEC | SOUND_CHANNEL_SF_ENV)
+
+#define CGB_CHANNEL_MO_PIT 0x02
+#define CGB_CHANNEL_MO_VOL 0x01
+
+#define CGB_NRx2_ENV_DIR_DEC 0x00
+#define CGB_NRx2_ENV_DIR_INC 0x08
+
struct CgbChannel
{
- u8 sf; // 0x0
- u8 ty; // 0x1
- u8 rightVolume; // 0x2
- u8 leftVolume; // 0x3
- u8 at; // 0x4
- u8 de; // 0x5
- u8 su; // 0x6
- u8 re; // 0x7
- u8 ky; // 0x8
- u8 ev; // 0x9
- u8 eg; // 0xA
- u8 ec; // 0xB
- u8 echoVolume; // 0xC
- u8 echoLength; // 0xD
- u8 d1; // 0xE
- u8 d2; // 0xF
- u8 gt; // 0x10
- u8 mk; // 0x11
- u8 ve; // 0x12
- u8 pr; // 0x13
- u8 rp; // 0x14
- u8 d3[3]; // 0x15, 0x16, 0x17
- u8 d5; // 0x18
- u8 sg; // 0x19
- u8 n4; // 0x1A
- u8 pan; // 0x1B
- u8 panMask; // 0x1C
- u8 mo; // 0x1D
- u8 le; // 0x1E
- u8 sw; // 0x1F
- u32 fr; // 0x20
- u32 *wp;
- u32 cp;
- u32 tp;
- u32 pp;
- u32 np;
- u8 d4[8];
+ u8 statusFlags;
+ u8 type;
+ u8 rightVolume;
+ u8 leftVolume;
+ u8 attack;
+ u8 decay;
+ u8 sustain;
+ u8 release;
+ u8 key;
+ u8 envelopeVolume;
+ u8 envelopeGoal;
+ u8 envelopeCounter;
+ u8 pseudoEchoVolume;
+ u8 pseudoEchoLength;
+ u8 dummy1;
+ u8 dummy2;
+ u8 gateTime;
+ u8 midiKey;
+ u8 velocity;
+ u8 priority;
+ u8 rhythmPan;
+ u8 dummy3[3];
+ u8 dummy5;
+ u8 sustainGoal;
+ u8 n4; // NR[1-4]4 register (initial, length bit)
+ u8 pan;
+ u8 panMask;
+ u8 modify;
+ u8 length;
+ u8 sweep;
+ u32 frequency;
+ u32 *wavePointer; // instructs CgbMain to load targeted wave
+ u32 *currentPointer; // stores the currently loaded wave
+ struct MusicPlayerTrack *track;
+ void *prevChannelPointer;
+ void *nextChannelPointer;
+ u8 dummy4[8];
};
struct MusicPlayerTrack;
struct SoundChannel
{
- u8 status;
+ u8 statusFlags;
u8 type;
u8 rightVolume;
u8 leftVolume;
@@ -120,33 +137,85 @@ struct SoundChannel
u8 decay;
u8 sustain;
u8 release;
- u8 ky;
- u8 ev;
- u8 er;
- u8 el;
- u8 echoVolume;
- u8 echoLength;
- u8 d1;
- u8 d2;
- u8 gt;
- u8 mk;
- u8 ve;
- u8 pr;
- u8 rp;
- u8 d3[3];
- u32 ct;
+ u8 key; // midi key as it was translated into final pitch
+ u8 envelopeVolume;
+ u8 envelopeVolumeRight;
+ u8 envelopeVolumeLeft;
+ u8 pseudoEchoVolume;
+ u8 pseudoEchoLength;
+ u8 dummy1;
+ u8 dummy2;
+ u8 gateTime;
+ u8 midiKey; // midi key as it was used in the track data
+ u8 velocity;
+ u8 priority;
+ u8 rhythmPan;
+ u8 dummy3[3];
+ u32 count;
u32 fw;
- u32 freq;
+ u32 frequency;
struct WaveData *wav;
- u32 cp;
+ s8 *currentPointer;
struct MusicPlayerTrack *track;
- void *pp;
- void *np;
- void *d4;
+ void *prevChannelPointer;
+ void *nextChannelPointer;
+ u32 dummy4;
u16 xpi;
u16 xpc;
};
+#define MAX_DIRECTSOUND_CHANNELS 12
+
+#define PCM_DMA_BUF_SIZE 1584 // size of Direct Sound buffer
+
+struct MusicPlayerInfo;
+
+typedef void (*MPlayFunc)();
+typedef void (*PlyNoteFunc)(u32, struct MusicPlayerInfo *, struct MusicPlayerTrack *);
+typedef void (*CgbSoundFunc)(void);
+typedef void (*CgbOscOffFunc)(u8);
+typedef u32 (*MidiKeyToCgbFreqFunc)(u8, u8, u8);
+typedef void (*ExtVolPitFunc)(void);
+typedef void (*MPlayMainFunc)(struct MusicPlayerInfo *);
+
+struct SoundInfo
+{
+ // This field is normally equal to ID_NUMBER but it is set to other
+ // values during sensitive operations for locking purposes.
+ // This field should be volatile but isn't. This could potentially cause
+ // race conditions.
+ u32 ident;
+
+ vu8 pcmDmaCounter;
+
+ // Direct Sound
+ u8 reverb;
+ u8 maxChans;
+ u8 masterVolume;
+ u8 freq;
+
+ u8 mode;
+ u8 c15; // periodically counts from 14 down to 0 (15 states)
+ u8 pcmDmaPeriod; // number of V-blanks per PCM DMA
+ u8 maxLines;
+ u8 gap[3];
+ s32 pcmSamplesPerVBlank;
+ s32 pcmFreq;
+ s32 divFreq;
+ struct CgbChannel *cgbChans;
+ MPlayMainFunc MPlayMainHead;
+ struct MusicPlayerInfo *musicPlayerHead;
+ CgbSoundFunc CgbSound;
+ CgbOscOffFunc CgbOscOff;
+ MidiKeyToCgbFreqFunc MidiKeyToCgbFreq;
+ MPlayFunc *MPlayJumpTable;
+ PlyNoteFunc plynote;
+ ExtVolPitFunc ExtVolPit;
+ u8 gap2[16];
+ struct SoundChannel chans[MAX_DIRECTSOUND_CHANNELS];
+ s8 pcmBuffer[PCM_DMA_BUF_SIZE * 2];
+};
+
struct SongHeader
{
u8 trackCount;
@@ -228,8 +297,8 @@ struct MusicPlayerTrack
u8 lfoDelay;
u8 lfoDelayC;
u8 priority;
- u8 echoVolume;
- u8 echoLength;
+ u8 pseudoEchoVolume;
+ u8 pseudoEchoLength;
struct SoundChannel *chan;
struct ToneData tone;
u8 gap[10];
@@ -270,8 +339,8 @@ struct MusicPlayerInfo
struct MusicPlayerTrack *tracks;
struct ToneData *tone;
u32 ident;
- void (*func)();
- u32 intp;
+ MPlayMainFunc MPlayMainNext;
+ struct MusicPlayerInfo *musicPlayerNext;
};
struct MusicPlayer
@@ -292,47 +361,7 @@ struct Song
extern const struct MusicPlayer gMPlayTable[];
extern const struct Song gSongTable[];
-#define MAX_DIRECTSOUND_CHANNELS 12
-
-#define PCM_DMA_BUF_SIZE 1584 // size of Direct Sound buffer
-
-struct SoundInfo
-{
- // This field is normally equal to ID_NUMBER but it is set to other
- // values during sensitive operations for locking purposes.
- // This field should be volatile but isn't. This could potentially cause
- // race conditions.
- u32 ident;
-
- vu8 pcmDmaCounter;
-
- // Direct Sound
- u8 reverb;
- u8 maxChans;
- u8 masterVolume;
- u8 freq;
- u8 mode;
- u8 c15;
- u8 pcmDmaPeriod; // number of V-blanks per PCM DMA
- u8 maxLines;
- u8 gap[3];
- s32 pcmSamplesPerVBlank;
- s32 pcmFreq;
- s32 divFreq;
- struct CgbChannel *cgbChans;
- void (*func)();
- u32 intp;
- void (*CgbSound)();
- void (*CgbOscOff)(u8);
- u32 (*MidiKeyToCgbFreq)(u8, u8, u8);
- void (**MPlayJumpTable)();
- void (*plynote)(u8, struct MusicPlayerInfo *, struct MusicPlayerTrack *);
- void (*ExtVolPit)(struct MusicPlayerInfo *, struct MusicPlayerTrack *);
- u32 gap2[4];
- struct SoundChannel chans[MAX_DIRECTSOUND_CHANNELS];
- s8 pcmBuffer[PCM_DMA_BUF_SIZE * 2];
-};
extern u8 gMPlayMemAccArea[];
@@ -349,7 +378,7 @@ extern struct MusicPlayerTrack gPokemonCryTracks[];
extern char SoundMainRAM[];
-extern void *gMPlayJumpTable[];
+extern MPlayFunc gMPlayJumpTable[];
typedef void (*XcmdFunc)(struct MusicPlayerInfo *, struct MusicPlayerTrack *);
extern const XcmdFunc gXcmdTable[];
@@ -378,7 +407,7 @@ u32 umul3232H32(u32 multiplier, u32 multiplicand);
void SoundMain(void);
void SoundMainBTM(void);
void TrackStop(struct MusicPlayerInfo *mplayInfo, struct MusicPlayerTrack *track);
-void MPlayMain(void);
+void MPlayMain(struct MusicPlayerInfo *);
void RealClearChain(void *x);
void MPlayContinue(struct MusicPlayerInfo *mplayInfo);
@@ -398,7 +427,7 @@ void CgbOscOff(u8);
void CgbModVol(struct CgbChannel *chan);
u32 MidiKeyToCgbFreq(u8, u8, u8);
void DummyFunc(void);
-void MPlayJumpTableCopy(void **mplayJumpTable);
+void MPlayJumpTableCopy(MPlayFunc *mplayJumpTable);
void SampleFreqSet(u32 freq);
void m4aSoundVSyncOn(void);
void m4aSoundVSyncOff(void);
@@ -446,7 +475,7 @@ void ply_tune(struct MusicPlayerInfo *, struct MusicPlayerTrack *);
void ply_port(struct MusicPlayerInfo *, struct MusicPlayerTrack *);
void ply_xcmd(struct MusicPlayerInfo *, struct MusicPlayerTrack *);
void ply_endtie(struct MusicPlayerInfo *, struct MusicPlayerTrack *);
-void ply_note(u8, struct MusicPlayerInfo *, struct MusicPlayerTrack *);
+void ply_note(u32 note_cmd, struct MusicPlayerInfo *, struct MusicPlayerTrack *);
// extended sound command handler functions
void ply_xxx(struct MusicPlayerInfo *, struct MusicPlayerTrack *);
diff --git a/include/global.fieldmap.h b/include/global.fieldmap.h
index 4598e87fa..c4d7be35d 100644
--- a/include/global.fieldmap.h
+++ b/include/global.fieldmap.h
@@ -195,15 +195,10 @@ struct ObjectEvent
/*0x0C*/ struct Coords16 initialCoords;
/*0x10*/ struct Coords16 currentCoords;
/*0x14*/ struct Coords16 previousCoords;
- /*0x18*/ u8 facingDirection:4; // current direction?
- /*0x18*/ u8 movementDirection:4;
- /*0x19*/ union __attribute__((packed)) {
- u8 as_byte;
- struct __attribute__((packed)) {
- u8 x:4;
- u8 y:4;
- } ALIGNED(1) as_nybbles;
- } ALIGNED(1) range;
+ /*0x18*/ u16 facingDirection:4; // current direction?
+ u16 movementDirection:4;
+ u16 rangeX:4;
+ u16 rangeY:4;
/*0x1A*/ u8 fieldEffectSpriteId;
/*0x1B*/ u8 warpArrowSpriteId;
/*0x1C*/ u8 movementActionId;
@@ -219,8 +214,8 @@ struct ObjectEvent
struct ObjectEventGraphicsInfo
{
/*0x00*/ u16 tileTag;
- /*0x02*/ u16 paletteTag1;
- /*0x04*/ u16 paletteTag2;
+ /*0x02*/ u16 paletteTag;
+ /*0x04*/ u16 reflectionPaletteTag;
/*0x06*/ u16 size;
/*0x08*/ s16 width;
/*0x0A*/ s16 height;
diff --git a/include/global.h b/include/global.h
index 08988eac7..4ccd2be50 100644
--- a/include/global.h
+++ b/include/global.h
@@ -8,6 +8,7 @@
#include "constants/global.h"
#include "constants/flags.h"
#include "constants/vars.h"
+#include "constants/species.h"
// Prevent cross-jump optimization.
#define BLOCK_CROSS_JUMP asm("");
@@ -65,8 +66,6 @@
// Converts a Q24.8 fixed-point format number to a regular integer
#define Q_24_8_TO_INT(n) ((int)((n) >> 8))
-#define POKEMON_SLOTS_NUMBER 412
-
#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) >= (b) ? (a) : (b))
@@ -115,7 +114,7 @@
#define ROUND_BITS_TO_BYTES(numBits)(((numBits) / 8) + (((numBits) % 8) ? 1 : 0))
-#define DEX_FLAGS_NO (ROUND_BITS_TO_BYTES(POKEMON_SLOTS_NUMBER))
+#define DEX_FLAGS_NO (ROUND_BITS_TO_BYTES(NUM_SPECIES))
#define NUM_FLAG_BYTES (ROUND_BITS_TO_BYTES(FLAGS_COUNT))
struct Coords8
@@ -329,11 +328,12 @@ struct BattleDomeTrainer
};
#define DOME_TOURNAMENT_TRAINERS_COUNT 16
+#define BATTLE_TOWER_RECORD_COUNT 5
struct BattleFrontier
{
/*0x64C*/ struct EmeraldBattleTowerRecord towerPlayer;
- /*0x738*/ struct EmeraldBattleTowerRecord towerRecords[5]; // From record mixing.
+ /*0x738*/ struct EmeraldBattleTowerRecord towerRecords[BATTLE_TOWER_RECORD_COUNT]; // From record mixing.
/*0xBEB*/ struct BattleTowerInterview towerInterview;
/*0xBEC*/ struct BattleTowerEReaderTrainer ereaderTrainer;
/*0xCA8*/ u8 challengeStatus;
diff --git a/include/graphics.h b/include/graphics.h
index b5e9396d0..5c15b7a66 100644
--- a/include/graphics.h
+++ b/include/graphics.h
@@ -3180,11 +3180,12 @@ extern const u32 gDecorIconPalette_RegiceDoll[];
extern const u32 gDecorIcon_RegisteelDoll[];
extern const u32 gDecorIconPalette_RegisteelDoll[];
-extern const u32 gWallclock_Gfx[];
-extern const u16 gWallclockMale_Pal[];
-extern const u16 gWallclockFemale_Pal[];
-extern const u32 gUnknown_08DCC648[];
-extern const u32 gUnknown_08DCC908[];
+extern const u32 gWallClock_Gfx[];
+extern const u16 gWallClockMale_Pal[];
+extern const u16 gWallClockFemale_Pal[];
+extern const u32 gWallClockStart_Tilemap[];
+extern const u32 gWallClockView_Tilemap[];
+
extern const u32 gBerryFixGameboy_Gfx[];
extern const u32 gBerryFixGameboy_Tilemap[];
extern const u16 gBerryFixGameboy_Pal[];
@@ -3309,57 +3310,57 @@ extern const u32 gBerryTag_Gfx[];
extern const u32 gBerryTag_Pal[];
// rayquaza scene gfx
-extern const u32 gRaySceneGroudon_Gfx[];
-extern const u32 gRaySceneGroudon2_Gfx[];
-extern const u32 gRaySceneGroudon3_Gfx[];
-extern const u32 gRaySceneKyogre_Gfx[];
-extern const u32 gRaySceneKyogre2_Gfx[];
-extern const u32 gRaySceneKyogre3_Gfx[];
-extern const u32 gRaySceneGroudon_Pal[];
-extern const u32 gRaySceneKyogre_Pal[];
-extern const u32 gRaySceneSmoke_Gfx[];
-extern const u32 gRaySceneSmoke_Pal[];
-extern const u32 gRaySceneRayquaza_Pal[];
-extern const u32 gRaySceneRayquazaFly1_Gfx[];
-extern const u32 gRaySceneRayquazaTail_Gfx[];
-extern const u32 gRaySceneGroudonLeft_Gfx[];
-extern const u32 gRaySceneGroudonTail_Gfx[];
-extern const u32 gRaySceneKyogreRight_Gfx[];
-extern const u32 gRaySceneRayquazaHover_Gfx[];
-extern const u32 gRaySceneRayquazaFlyIn_Gfx[];
-extern const u32 gRaySceneOvercast_Gfx[];
-extern const u32 gRaySceneOvercast_Tilemap[];
-extern const u32 gRaySceneRayquaza_Gfx[];
-extern const u32 gRaySceneRayquaza_Tilemap[];
-extern const u32 gRaySceneSplash_Gfx[];
-extern const u32 gRaySceneGroudonLeft_Pal[];
-extern const u32 gRaySceneKyogreRight_Pal[];
-extern const u32 gRaySceneRayquazaHover_Pal[];
-extern const u32 gRaySceneSplash_Pal[];
-extern const u32 gRaySceneClouds_Gfx[];
-extern const u32 gRaySceneClouds_Pal[];
-extern const u32 gRaySceneClouds2_Tilemap[];
-extern const u32 gRaySceneClouds1_Tilemap[];
-extern const u32 gRaySceneClouds3_Tilemap[];
-extern const u32 gRaySceneRayquazaLight_Gfx[];
-extern const u32 gRaySceneRayquazaLight_Tilemap[];
-extern const u32 gRaySceneOvercast2_Gfx[];
-extern const u32 gRaySceneOvercast2_Tilemap[];
-extern const u32 gRaySceneOvercast2_Pal[];
-extern const u32 gRaySceneRayquazaChase_Gfx[];
-extern const u32 gRaySceneChaseStreaks_Gfx[];
-extern const u32 gRaySceneChaseBg_Gfx[];
-extern const u32 gRayChaseRayquazaChase2_Tilemap[];
-extern const u32 gRayChaseRayquazaChase_Tilemap[];
-extern const u32 gRaySceneChaseStreaks_Tilemap[];
-extern const u32 gRaySceneChaseBg_Tilemap[];
-extern const u32 gRaySceneChase_Pal[];
-extern const u32 gRaySceneHushRing_Tilemap[];
-extern const u32 gRaySceneHushBg_Tilemap[];
-extern const u32 gRaySceneHushRing_Map[];
-extern const u32 gRaySceneHushBg_Pal[];
-extern const u32 gRaySceneHushBg_Gfx[];
-extern const u32 gRaySceneHushRing_Gfx[];
+extern const u32 gRaySceneDuoFight_Groudon_Gfx[];
+extern const u32 gRaySceneDuoFight_GroudonShoulder_Gfx[];
+extern const u32 gRaySceneDuoFight_GroudonClaw_Gfx[];
+extern const u32 gRaySceneDuoFight_Kyogre_Gfx[];
+extern const u32 gRaySceneDuoFight_KyogrePectoralFin_Gfx[];
+extern const u32 gRaySceneDuoFight_KyogreDorsalFin_Gfx[];
+extern const u32 gRaySceneDuoFight_Groudon_Pal[];
+extern const u32 gRaySceneDuoFight_Kyogre_Pal[];
+extern const u32 gRaySceneDuoFight_Clouds_Gfx[];
+extern const u32 gRaySceneDuoFight_Clouds_Pal[];
+extern const u32 gRaySceneDuoFight_Clouds1_Tilemap[];
+extern const u32 gRaySceneDuoFight_Clouds2_Tilemap[];
+extern const u32 gRaySceneDuoFight_Clouds3_Tilemap[];
+extern const u32 gRaySceneTakesFlight_Smoke_Gfx[];
+extern const u32 gRaySceneTakesFlight_Smoke_Pal[];
+extern const u32 gRaySceneTakesFlight_Rayquaza_Pal[];
+extern const u32 gRaySceneTakesFlight_Bg_Gfx[];
+extern const u32 gRaySceneTakesFlight_Bg_Tilemap[];
+extern const u32 gRaySceneTakesFlight_Rayquaza_Gfx[];
+extern const u32 gRaySceneTakesFlight_Rayquaza_Tilemap[];
+extern const u32 gRaySceneDescends_Rayquaza_Gfx[];
+extern const u32 gRaySceneDescends_RayquazaTail_Gfx[];
+extern const u32 gRaySceneDescends_Light_Gfx[];
+extern const u32 gRaySceneDescends_Light_Tilemap[];
+extern const u32 gRaySceneDescends_Bg_Gfx[];
+extern const u32 gRaySceneDescends_Bg_Tilemap[];
+extern const u32 gRaySceneDescends_Bg_Pal[];
+extern const u32 gRaySceneCharges_Rayquaza_Gfx[];
+extern const u32 gRaySceneCharges_Streaks_Gfx[];
+extern const u32 gRaySceneCharges_Bg_Gfx[];
+extern const u32 gRaySceneCharges_Orbs_Tilemap[];
+extern const u32 gRaySceneCharges_Rayquaza_Tilemap[];
+extern const u32 gRaySceneCharges_Streaks_Tilemap[];
+extern const u32 gRaySceneCharges_Bg_Tilemap[];
+extern const u32 gRaySceneCharges_Bg_Pal[];
+extern const u32 gRaySceneChasesAway_Groudon_Gfx[];
+extern const u32 gRaySceneChasesAway_GroudonTail_Gfx[];
+extern const u32 gRaySceneChasesAway_Kyogre_Gfx[];
+extern const u32 gRaySceneChasesAway_Rayquaza_Gfx[];
+extern const u32 gRaySceneChasesAway_RayquazaTail_Gfx[];
+extern const u32 gRaySceneChasesAway_KyogreSplash_Gfx[];
+extern const u32 gRaySceneChasesAway_Groudon_Pal[];
+extern const u32 gRaySceneChasesAway_Kyogre_Pal[];
+extern const u32 gRaySceneChasesAway_Rayquaza_Pal[];
+extern const u32 gRaySceneChasesAway_KyogreSplash_Pal[];
+extern const u32 gRaySceneChasesAway_Bg_Tilemap[];
+extern const u32 gRaySceneChasesAway_Light_Tilemap[];
+extern const u32 gRaySceneChasesAway_Ring_Tilemap[];
+extern const u32 gRaySceneChasesAway_Bg_Pal[];
+extern const u32 gRaySceneChasesAway_Light_Gfx[];
+extern const u32 gRaySceneChasesAway_Ring_Gfx[];
// Pokeballs
extern const u32 gItemIcon_MasterBall[];
@@ -4893,11 +4894,11 @@ extern const u32 gWallpaperTilemap_Horizontal[];
extern const u16 gWallpaperPalettes_Horizontal[][16];
// Cable Car
-extern const u32 gUnknown_08DBA5B8[];
-extern const u16 gUnknown_08DBA518[];
+extern const u32 gCableCarBg_Gfx[];
+extern const u16 gCableCarBg_Pal[];
extern const u32 gCableCar_Gfx[];
extern const u32 gCableCarDoor_Gfx[];
-extern const u32 gCableCarCord_Gfx[];
+extern const u32 gCableCarCable_Gfx[];
extern const u16 gCableCar_Pal[];
// Trade
@@ -5018,4 +5019,10 @@ extern const u8 gFrontierFactorySelectMenu_Gfx[];
extern const u8 gFrontierFactorySelectMenu_Tilemap[];
extern const u16 gFrontierFactorySelectMenu_Pal[];
+// Object event pals
+extern const u16 gObjectEventPal_Brendan[];
+extern const u16 gObjectEventPal_May[];
+extern const u16 gObjectEventPal_RubySapphireBrendan[];
+extern const u16 gObjectEventPal_RubySapphireMay[];
+
#endif //GUARD_GRAPHICS_H
diff --git a/include/menu.h b/include/menu.h
index 1bd800742..c9d8e374d 100644
--- a/include/menu.h
+++ b/include/menu.h
@@ -4,6 +4,7 @@
#include "task.h"
#include "text.h"
#include "window.h"
+#include "constants/pokemon.h"
#define MENU_NOTHING_CHOSEN -2
#define MENU_B_PRESSED -1
@@ -14,6 +15,14 @@
#define MENU_CURSOR_DELTA_LEFT -1
#define MENU_CURSOR_DELTA_RIGHT 1
+#define MENU_INFO_ICON_TYPE (NUMBER_OF_MON_TYPES + 1)
+#define MENU_INFO_ICON_POWER (NUMBER_OF_MON_TYPES + 2)
+#define MENU_INFO_ICON_ACCURACY (NUMBER_OF_MON_TYPES + 3)
+#define MENU_INFO_ICON_PP (NUMBER_OF_MON_TYPES + 4)
+#define MENU_INFO_ICON_EFFECT (NUMBER_OF_MON_TYPES + 5)
+#define MENU_INFO_ICON_BALL_RED (NUMBER_OF_MON_TYPES + 6)
+#define MENU_INFO_ICON_BALL_BLUE (NUMBER_OF_MON_TYPES + 7)
+
enum
{
SAVE_MENU_NAME,
@@ -61,7 +70,7 @@ u8 InitMenuInUpperLeftCornerPlaySoundWhenAPressed(u8 windowId, u8 numItems, u8 i
u8 Menu_GetCursorPos(void);
s8 Menu_ProcessInput(void);
s8 Menu_ProcessInputNoWrap(void);
-void blit_move_info_icon(u8 winId, u8 a2, u16 x, u16 y);
+void BlitMenuInfoIcon(u8 winId, u8 a2, u16 x, u16 y);
void ResetTempTileDataBuffers(void);
void *DecompressAndCopyTileDataToVram(u8 bgId, const void *src, u32 size, u16 offset, u8 mode);
bool8 FreeTempTileDataBuffersIfPossible(void);
diff --git a/include/menu_specialized.h b/include/menu_specialized.h
index 242e1c6b2..987fca9fc 100644
--- a/include/menu_specialized.h
+++ b/include/menu_specialized.h
@@ -23,7 +23,7 @@ struct UnknownSubStruct_81D1ED4
struct ConditionGraph
{
- /*0x000*/ u8 unk0[4][FLAVOR_COUNT];
+ /*0x000*/ u8 stat[4][FLAVOR_COUNT];
/*0x014*/ struct UnknownSubStruct_81D1ED4 unk14[4][FLAVOR_COUNT];
/*0x064*/ struct UnknownSubStruct_81D1ED4 unk64[10][FLAVOR_COUNT];
/*0x12C*/ struct UnknownSubStruct_81D1ED4 unk12C[FLAVOR_COUNT];
@@ -32,7 +32,7 @@ struct ConditionGraph
/*0x350*/ u16 unk350;
/*0x352*/ u16 unk352;
/*0x354*/ u8 unk354;
- /*0x355*/ u8 unk355;
+ /*0x355*/ u8 state;
};
bool8 sub_81D1C44(u8 count);
@@ -41,12 +41,12 @@ u8 sub_81D1DC0(struct PlayerPCItemPageStruct *page);
void sub_81D1E90(struct PlayerPCItemPageStruct *page);
void sub_81D1EC0(void);
void sub_81D1D04(u8 a0);
-void sub_81D1ED4(struct ConditionGraph *graph);
+void InitConditionGraphData(struct ConditionGraph *graph);
void sub_81D2108(struct ConditionGraph *graph);
-void sub_81D21DC(u8 bg);
-void sub_81D20AC(struct ConditionGraph *graph);
+void SetConditionGraphIOWindows(u8 bg);
+void InitConditionGraphState(struct ConditionGraph *graph);
void sub_81D2230(struct ConditionGraph *graph);
-bool8 sub_81D20BC(struct ConditionGraph *graph);
+bool8 SetupConditionGraphScanlineParams(struct ConditionGraph *graph);
bool32 TransitionConditionGraph(struct ConditionGraph *graph);
void sub_81D2754(u8 *arg0, struct UnknownSubStruct_81D1ED4 *arg1);
void sub_81D1F84(struct ConditionGraph *graph, struct UnknownSubStruct_81D1ED4 *arg1, struct UnknownSubStruct_81D1ED4 *arg2);
diff --git a/include/metatile_behavior.h b/include/metatile_behavior.h
index b5dae6de0..d4bd9e683 100644
--- a/include/metatile_behavior.h
+++ b/include/metatile_behavior.h
@@ -99,10 +99,10 @@ bool8 MetatileBehavior_IsShortGrass(u8);
bool8 MetatileBehavior_IsHotSprings(u8);
bool8 MetatileBehavior_IsWaterfall(u8);
bool8 MetatileBehavior_IsFortreeBridge(u8);
-bool8 MetatileBehavior_IsPacifilogVerticalLog1(u8);
-bool8 MetatileBehavior_IsPacifilogVerticalLog2(u8);
-bool8 MetatileBehavior_IsPacifilogHorizontalLog1(u8);
-bool8 MetatileBehavior_IsPacifilogHorizontalLog2(u8);
+bool8 MetatileBehavior_IsPacifidlogVerticalLog1(u8);
+bool8 MetatileBehavior_IsPacifidlogVerticalLog2(u8);
+bool8 MetatileBehavior_IsPacifidlogHorizontalLog1(u8);
+bool8 MetatileBehavior_IsPacifidlogHorizontalLog2(u8);
bool8 MetatileBehavior_IsPacifidlogLog(u8);
bool8 MetatileBehavior_IsTrickHousePuzzleDoor(u8);
bool8 MetatileBehavior_IsRegionMap(u8);
diff --git a/include/mon_markings.h b/include/mon_markings.h
index 241b31e01..3cb04ad48 100644
--- a/include/mon_markings.h
+++ b/include/mon_markings.h
@@ -29,8 +29,8 @@ bool8 sub_811F960(void);
void sub_811FA90(void);
void sub_811FAA4(u8 markings, s16 x, s16 y);
void sub_811FAF8(void);
-bool8 sub_811FBA4(void);
-struct Sprite *sub_811FF94(u16 tileTag, u16 paletteTag, const u16 *palette);
+bool8 MonMarkingsMenuHandleInput(void);
+struct Sprite *CreateMonMarkingsSpriteWithPal(u16 tileTag, u16 paletteTag, const u16 *palette);
struct Sprite *sub_811FFB4(u16 tileTag, u16 paletteTag, const u16 *palette);
void sub_8120084(u8 markings, void *dest);
diff --git a/include/palette.h b/include/palette.h
index 8d16270aa..f874bcd74 100644
--- a/include/palette.h
+++ b/include/palette.h
@@ -70,7 +70,7 @@ void BeginFastPaletteFade(u8);
void BeginHardwarePaletteFade(u8, u8, u8, u8, u8);
void BlendPalettes(u32 selectedPalettes, u8 coeff, u16 color);
void BlendPalettesUnfaded(u32, u8, u16);
-void sub_80A2C44(u32 a1, s8 a2, u8 a3, u8 a4, u16 a5, u8 a6, u8 a7);
+void BlendPalettesGradually(u32 selectedPalettes, s8 delay, u8 coeff, u8 coeffTarget, u16 color, u8 priority, u8 id);
void TintPalette_GrayScale(u16 *palette, u16 count);
void TintPalette_GrayScale2(u16 *palette, u16 count);
void TintPalette_SepiaTone(u16 *palette, u16 count);
diff --git a/include/pokemon.h b/include/pokemon.h
index d75ec94f3..497e8070b 100644
--- a/include/pokemon.h
+++ b/include/pokemon.h
@@ -123,12 +123,12 @@ struct Pokemon
struct Unknown_806F160_Struct
{
- u8 field_0_0:4;
- u8 field_0_1:4;
- u8 field_1;
- u8 magic;
- u8 field_3_0:4;
- u8 field_3_1:4;
+ u32 field_0_0:4;
+ u32 field_0_1:4;
+ u32 field_1:8;
+ u16 magic:8;
+ u32 field_3_0:4;
+ u32 field_3_1:4;
void *bytes;
u8 **byteArrays;
struct SpriteTemplate *templates;
@@ -275,7 +275,7 @@ void CreateBattleTowerMon(struct Pokemon *mon, struct BattleTowerPokemon *src);
void CreateBattleTowerMon2(struct Pokemon *mon, struct BattleTowerPokemon *src, bool8 lvl50);
void CreateApprenticeMon(struct Pokemon *mon, const struct Apprentice *src, u8 monId);
void CreateMonWithEVSpreadNatureOTID(struct Pokemon *mon, u16 species, u8 level, u8 nature, u8 fixedIV, u8 evSpread, u32 otId);
-void sub_80686FC(struct Pokemon *mon, struct BattleTowerPokemon *dest);
+void ConvertPokemonToBattleTowerPokemon(struct Pokemon *mon, struct BattleTowerPokemon *dest);
void CreateObedientMon(struct Pokemon *mon, u16 species, u8 level, u8 fixedIV, u8 hasFixedPersonality, u32 fixedPersonality, u8 otIdType, u32 fixedOtId);
bool8 sub_80688F8(u8 caseId, u8 battlerId);
void SetDeoxysStats(void);
@@ -381,7 +381,7 @@ void ClearBattleMonForms(void);
u16 GetBattleBGM(void);
void PlayBattleBGM(void);
void PlayMapChosenOrBattleBGM(u16 songId);
-void sub_806E694(u16 songId);
+void CreateTask_PlayMapChosenOrBattleBGM(u16 songId);
const u32 *GetMonFrontSpritePal(struct Pokemon *mon);
const u32 *GetMonSpritePalFromSpeciesAndPersonality(u16 species, u32 otId, u32 personality);
const struct CompressedSpritePalette *GetMonSpritePalStruct(struct Pokemon *mon);
diff --git a/include/pokenav.h b/include/pokenav.h
index ac916f3ba..3fc01ede3 100644
--- a/include/pokenav.h
+++ b/include/pokenav.h
@@ -27,17 +27,17 @@ struct PokenavListTemplate
struct PokenavMonList *monList;
struct PokenavMatchCallEntries *matchCallEntries;
} list;
- u16 unk4;
+ u16 count;
u16 unk6;
u8 unk8;
- u8 unk9;
- u8 unkA;
- u8 unkB;
- u8 unkC;
- u8 unkD;
- u8 unkE;
+ u8 item_X;
+ u8 windowWidth;
+ u8 listTop;
+ u8 maxShowed;
+ u8 fillValue;
+ u8 fontId;
union {
- void (*unk10_1)(struct PokenavMonList *, u8 *a1);
+ void (*printMonFunc)(struct PokenavMonList *item, u8 *dest);
void (*unk10_2)(struct PokenavMatchCallEntries *, u8 *a1);
} listFunc;
void (*unk14)(u16 a0, u32 a1, u32 a2);
@@ -45,9 +45,9 @@ struct PokenavListTemplate
struct PokenavSub18
{
- u16 unk0;
- u16 unk2;
- struct PokenavMonList unk4[TOTAL_BOXES_COUNT * IN_BOX_COUNT + PARTY_SIZE];
+ u16 listCount;
+ u16 currIndex;
+ struct PokenavMonList monData[TOTAL_BOXES_COUNT * IN_BOX_COUNT + PARTY_SIZE];
};
// Return values of LoopedTask functions.
@@ -65,6 +65,31 @@ enum
POKENAV_MODE_FORCE_CALL_EXIT, // Pokenav tutorial after calling Mr. Stone
};
+// TODO - refine these names
+enum Substructures
+{
+ POKENAV_SUBSTRUCT_MAIN_MENU,
+ POKENAV_SUBSTRUCT_MAIN_MENU_HANDLER,
+ POKENAV_SUBSTRUCT_MENU_ICONS,
+ POKENAV_SUBSTRUCT_REGION_MAP_STATE,
+ POKENAV_SUBSTRUCT_REGION_MAP_ZOOM,
+ POKENAV_SUBSTRUCT_MATCH_CALL_MAIN,
+ POKENAV_SUBSTRUCT_MATCH_CALL_OPEN,
+ POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULTS,
+ POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULT_LIST,
+ POKENAV_SUBSTRUCT_RIBBONS_MON_LIST,
+ POKENAV_SUBSTRUCT_RIBBONS_MON_MENU,
+ POKENAV_SUBSTRUCT_CONDITION_GRAPH,
+ POKENAV_SUBSTRUCT_MON_MARK_MENU,
+ POKENAV_SUBSTRUCT_RIBBONS_SUMMARY_LIST,
+ POKENAV_SUBSTRUCT_RIBBONS_SUMMARY_MENU,
+ POKENAV_SUBSTRUCT_15, //unused
+ POKENAV_SUBSTRUCT_REGION_MAP,
+ POKENAV_SUBSTRUCT_MATCH_CALL_LIST,
+ POKENAV_SUBSTRUCT_MON_LIST,
+ POKENAV_SUBSTRUCT_COUNT,
+};
+
enum
{
POKENAV_GFX_MAIN_MENU,
@@ -97,12 +122,12 @@ enum
POKENAV_REGION_MAP,
POKENAV_CONDITION_PARTY,
POKENAV_CONDITION_SEARCH_RESULTS,
- POKENAV_MENU_9, // Condition
- POKENAV_MENU_A, // Condition
+ POKENAV_CONDITION_GRAPH_FROM_SEARCH, // opening condition graph from search list
+ POKENAV_RETURN_CONDITION_SEARCH, //return to search list from condition graph
POKENAV_MATCH_CALL,
POKENAV_RIBBONS_MON_LIST,
- POKENAV_MENU_D, // Ribbons
- POKENAV_MENU_E, // Ribbons
+ POKENAV_RIBBONS_SUMMARY_SCREEN,
+ POKENAV_RIBBONS_RETURN_TO_MON_LIST,
};
enum
@@ -207,7 +232,7 @@ enum
// Pokenav Function IDs
// Indices into the LoopedTask tables for each of the main Pokenav features
-enum
+enum RegionMapFuncIds
{
POKENAV_MENU_FUNC_NONE,
POKENAV_MENU_FUNC_MOVE_CURSOR,
@@ -220,6 +245,19 @@ enum
POKENAV_MENU_FUNC_OPEN_FEATURE,
};
+enum PartyConditionFuncIds
+{
+ PARTY_CONDITION_FUNC_NONE,
+ PARTY_CONDITION_FUNC_SLIDE_MON_IN,
+ PARTY_CONDITION_FUNC_RETURN,
+ PARTY_CONDITION_FUNC_NO_TRANSITION,
+ PARTY_CONDITION_FUNC_SLIDE_MON_OUT,
+ PARTY_CONDITION_FUNC_ADD_MARKINGS,
+ PARTY_CONDITION_FUNC_CLOSE_MARKINGS,
+};
+
+#define POKENAV_MENU_FUNC_EXIT -1
+
enum
{
POKENAV_MC_FUNC_NONE,
@@ -268,17 +306,17 @@ void SetPokenavVBlankCallback(void);
void SetVBlankCallback_(IntrCallback callback);
// pokenav_match_call_ui.c
-u32 GetSelectedMatchCall(void);
+u32 GetSelectedPokenavListIndex(void);
bool32 sub_81C8224(void);
int MatchCall_MoveCursorUp(void);
int MatchCall_MoveCursorDown(void);
int MatchCall_PageDown(void);
int MatchCall_PageUp(void);
-bool32 sub_81C8630(void);
+bool32 IsMonListLoopedTaskActive(void);
void ToggleMatchCallVerticalArrows(bool32 shouldHide);
void sub_81C8838(void);
void sub_81C877C(void);
-bool32 sub_81C8820(void);
+bool32 IsMatchCallListTaskActive(void);
void PrintCheckPageInfo(s16 a0);
u32 GetMatchCallListTopIndex(void);
void sub_81C87F0(void);
@@ -300,30 +338,30 @@ void MatchCall_GetNameAndDesc(u32 idx, const u8 **desc, const u8 **name);
// pokenav_main_menu.c
bool32 InitPokenavMainMenu(void);
void CopyPaletteIntoBufferUnfaded(const u16 *palette, u32 bufferOffset, u32 size);
-void sub_81C7850(u32 a0);
-u32 sub_81C786C(void);
+void RunMainMenuLoopedTask(u32 a0);
+u32 IsActiveMenuLoopTaskActive(void);
void LoadLeftHeaderGfxForIndex(u32 arg0);
-void sub_81C7FA0(u32 arg0, bool32 arg1, bool32 arg2);
+void ShowLeftHeaderGfx(u32 menugfxId, bool32 arg1, bool32 isOnRightSide);
void PokenavFadeScreen(s32 fadeType);
-bool32 sub_81C8010(void);
+bool32 AreLeftHeaderSpritesMoving(void);
void InitBgTemplates(const struct BgTemplate *templates, int count);
bool32 IsPaletteFadeActive(void);
void PrintHelpBarText(u32 textId);
bool32 WaitForHelpBar(void);
-void sub_81C78A0(void);
+void SlideMenuHeaderDown(void);
bool32 MainMenuLoopedTaskIsBusy(void);
-void sub_81C7FDC(void);
-void sub_81C79BC(const u16 *a0, const u16 *a1, u32 a2, u32 a3, u32 a4, u16 *a5);
+void SetLeftHeaderSpritesInvisibility(void);
+void PokenavCopyPalette(const u16 *a0, const u16 *a1, int a2, int a3, int a4, u16 *palette);
void sub_81C7B40(void);
struct Sprite *PauseSpinningPokenavSprite(void);
void ResumeSpinningPokenavSprite(void);
-void sub_81C7E14(u32 arg0);
-void sub_81C7FC4(u32 arg0, bool32 arg1);
-void sub_81C7880(void);
-void sub_81C7990(u32 a0, u16 a1);
+void UpdateRegionMapRightHeaderTiles(u32 arg0);
+void HideMainOrSubMenuLeftHeader(u32 id, bool32 onRightSide);
+void SlideMenuHeaderUp(void);
+void PokenavFillPalette(u32 palIndex, u16 fillValue);
u32 PokenavMainMenuLoopedTaskIsActive(void);
bool32 WaitForPokenavShutdownFade(void);
-void sub_81C7834(void *func1, void *func2);
+void SetActiveMenuLoopTasks(void *func1, void *func2);
void ShutdownPokenav(void);
// pokenav_menu_handler_1.c
@@ -345,7 +383,7 @@ bool32 OpenPokenavMenuNotInitial(void);
void CreateMenuHandlerLoopedTask(s32 ltIdx);
bool32 IsMenuHandlerLoopedTaskActive(void);
void FreeMenuHandlerSubstruct2(void);
-void sub_81CAADC(void);
+void ResetBldCnt_(void);
// pokenav_match_call_1.c
bool32 PokenavCallback_Init_MatchCall(void);
@@ -364,7 +402,7 @@ const u8 *GetMatchCallMessageText(int index, u8 *arg1);
u16 GetMatchCallOptionCursorPos(void);
u16 GetMatchCallOptionId(int arg0);
void BufferMatchCallNameAndDesc(struct PokenavMatchCallEntries * arg0, u8 *str);
-u8 sub_81CB0C8(int rematchIndex);
+u8 GetMatchTableMapSectionId(int rematchIndex);
int GetIndexDeltaOfNextCheckPageDown(int index);
int GetIndexDeltaOfNextCheckPageUp(int index);
bool32 IsRematchEntryRegistered(int index);
@@ -385,60 +423,60 @@ void FreeRegionMapSubstruct1(void);
void FreeRegionMapSubstruct2(void);
// pokenav_conditions_1.c
-u32 PokenavCallback_Init_7(void);
-u32 PokenavCallback_Init_9(void);
-u32 sub_81CD070(void);
-void sub_81CD1C0(void);
-bool32 sub_81CD3C4(void);
-bool32 sub_81CDD5C(void);
-struct ConditionGraph *sub_81CDC70(void);
-u16 sub_81CDC60(void);
-u16 sub_81CDC50(void);
-u8 sub_81CDDB0(void);
-bool32 sub_81CD548(u8 arg0);
-u8 sub_81CDD7C(void);
-u8 *sub_81CDD04(u8 id);
-u8 *sub_81CDD24(u8 id);
-u16 sub_81CDD48(void);
-void *sub_81CDCB4(u8 id);
-void *sub_81CDCD4(u8 id);
+u32 PokenavCallback_Init_PartyCondition(void);
+u32 PokenavCallback_Init_ConditionGraphFromSearch(void);
+u32 GetPartyConditionCallback(void);
+void FreePartyConditionSubstruct1(void);
+bool32 LoadPartyConditionMenuGfx(void);
+bool32 IsConditionMenuSearchMode(void);
+struct ConditionGraph *GetConditionGraphDataPtr(void);
+u16 GetConditionGraphCurrentMonIndex(void);
+u16 GetMonListCount(void);
+u8 GetMonSheen(void);
+bool32 SetConditionGraphData(u8 arg0);
+u8 TryGetMonMarkId(void);
+u8 *GetConditionMonNameBuffer(u8 id);
+u8 *GetConditionMonLocationBuffer(u8 id);
+u16 GetConditionMonDataBuffer(void);
+void *GetConditionMonPicGfx(u8 id);
+void *GetConditionMonPal(u8 id);
// pokenav_conditions_2.c
-bool32 sub_81CDDD4(void);
-void sub_81CDE2C(s32);
-u32 sub_81CDE64(void);
-void sub_81CECA0(void);
-u8 sub_81CEF14(void);
+bool32 OpenPartyConditionMenu(void);
+void CreatePartyConditionLoopedTask(s32);
+u32 IsPartyConditionLoopedTaskActive(void);
+void FreePartyConditionSubstruct2(void);
+u8 GetMonMarkingsData(void);
// pokenav_conditions_3.c
-u32 PokenavCallback_Init_8(void);
-u32 PokenavCallback_Init_10(void);
-u32 sub_81CEFDC(void);
-void sub_81CEFF0(void);
-bool32 sub_81CF330(void);
-bool32 sub_81CF368(void);
-void sub_81CF3A0(s32);
-u32 sub_81CF3D0(void);
-void sub_81CF3F8(void);
+u32 PokenavCallback_Init_ConditionSearch(void);
+u32 PokenavCallback_Init_ReturnToMonSearchList(void);
+u32 GetConditionSearchResultsCallback(void);
+void FreeSearchResultSubstruct1(void);
+bool32 OpenConditionSearchResults(void);
+bool32 OpenConditionSearchListFromGraph(void);
+void CreateSearchResultsLoopedTask(s32);
+u32 IsSearchResultLoopedTaskActive(void);
+void FreeSearchResultSubstruct2(void);
// pokenav_ribbons_1.c
-u32 PokenavCallback_Init_12(void);
-u32 PokenavCallback_Init_14(void);
-u32 sub_81CFA34(void);
-void sub_81CFA48(void);
-bool32 sub_81CFDD0(void);
-bool32 sub_81CFE08(void);
-void sub_81CFE40(s32);
-u32 sub_81CFE70(void);
-void sub_81CFE98(void);
+u32 PokenavCallback_Init_MonRibbonList(void);
+u32 PokenavCallback_Init_RibbonsMonListFromSummary(void);
+u32 GetRibbonsMonListCallback(void);
+void FreeRibbonsMonList1(void);
+bool32 OpenRibbonsMonList(void);
+bool32 OpenRibbonsMonListFromRibbonsSummary(void);
+void CreateRibbonsMonListLoopedTask(s32);
+u32 IsRibbonsMonListLoopedTaskActive(void);
+void FreeRibbonsMonList2(void);
// pokenav_ribbons_2.c
-u32 PokenavCallback_Init_13(void);
-u32 sub_81D04A0(void);
-void sub_81D04B8(void);
-bool32 sub_81D0978(void);
-void sub_81D09B0(s32);
-u32 sub_81D09E0(void);
-void sub_81D09F4(void);
+u32 PokenavCallback_Init_RibbonsSummaryMenu(void);
+u32 GetRibbonsSummaryMenuCallback(void);
+void FreeRibbonsSummaryScreen1(void);
+bool32 OpenRibbonsSummaryMenu(void);
+void CreateRibbonsSummaryLoopedTask(s32);
+u32 IsRibbonsSummaryLoopedTaskActive(void);
+void FreeRibbonsSummaryScreen2(void);
#endif // GUARD_POKENAV_H
diff --git a/include/rayquaza_scene.h b/include/rayquaza_scene.h
index fe66b3df0..5aa21981e 100644
--- a/include/rayquaza_scene.h
+++ b/include/rayquaza_scene.h
@@ -1,17 +1,6 @@
#ifndef GUARD_RAYQUAZA_SCENE_H
#define GUARD_RAYQUAZA_SCENE_H
-void DoRayquazaScene(u8 animId, bool8 onlyOneAnim, void (*callback)(void));
-
-enum
-{
- RAY_ANIM_DUO_FIGHT_PRE,
- RAY_ANIM_DUO_FIGHT,
- RAY_ANIM_TAKES_FLIGHT,
- RAY_ANIM_DESCENDS,
- RAY_ANIM_CHARGES,
- RAY_ANIM_CHACES_AWAY,
- RAY_ANIM_END
-};
+void DoRayquazaScene(u8 animId, bool8 endEarly, void (*callback)(void));
#endif // GUARD_RAYQUAZA_SCENE_H
diff --git a/include/recorded_battle.h b/include/recorded_battle.h
index 84c5c2ea2..252b25502 100644
--- a/include/recorded_battle.h
+++ b/include/recorded_battle.h
@@ -30,7 +30,7 @@ void sub_818603C(u8 arg0);
u32 GetAiScriptsInRecordedBattle(void);
void sub_8186444(void);
bool8 sub_8186450(void);
-void sub_8186468(u8 *dst);
+void GetRecordedBattleRecordMixFriendName(u8 *dst);
u8 GetRecordedBattleRecordMixFriendClass(void);
u8 GetRecordedBattleApprenticeId(void);
u8 GetRecordedBattleRecordMixFriendLanguage(void);
diff --git a/include/rom_8011DC0.h b/include/rom_8011DC0.h
deleted file mode 100644
index ee7397320..000000000
--- a/include/rom_8011DC0.h
+++ /dev/null
@@ -1,4 +0,0 @@
-#ifndef GUARD_rom_8011DC0_H
-#define GUARD_rom_8011DC0_H
-
-#endif //GUARD_rom_8011DC0_H
diff --git a/include/trainer_hill.h b/include/trainer_hill.h
index 3f0644248..94d29a7ca 100644
--- a/include/trainer_hill.h
+++ b/include/trainer_hill.h
@@ -8,10 +8,10 @@ struct TrainerHillTrainer
u8 name[HILL_TRAINER_NAME_LENGTH];
u8 facilityClass;
u32 unused;
- u16 speechBefore[6];
- u16 speechWin[6];
- u16 speechLose[6];
- u16 speechAfter[6];
+ u16 speechBefore[EASY_CHAT_BATTLE_WORDS_COUNT];
+ u16 speechWin[EASY_CHAT_BATTLE_WORDS_COUNT];
+ u16 speechLose[EASY_CHAT_BATTLE_WORDS_COUNT];
+ u16 speechAfter[EASY_CHAT_BATTLE_WORDS_COUNT];
struct BattleTowerPokemon mons[PARTY_SIZE];
};
@@ -23,11 +23,19 @@ struct TrHillRoomTrainers
struct TrHillDisplay
{
- u8 data[0x100];
- u16 unk3A0[16];
- u8 coords[2]; // x first 4 bits, y last 4 bits
- u8 direction; // array of 4 bits for each trainer
- u8 range; // array of 4 bits for each trainer
+ // Metatile data. Add 0x200 to the values in this array to get metatiles.
+ // This data then overwrites the metatiles in the map starting at (0,5)
+ u8 metatileData[0x100];
+ // Collision data. One bit for each tile in column-major order,
+ // so every array entry is one row. 1 = impassable, 0 = passable
+ u16 collisionData[16];
+ // Trainer coordinates, starting at (0,6). Format is 0bYYYYXXXX.
+ u8 coords[2];
+ // Trainer facing directions. Same as (DIR_* - 1).
+ // Effectively an array of nibbles, one for each trainer.
+ u8 direction;
+ // Trainer sight ranges. Effectively an array of nibbles, one for each trainer.
+ u8 range;
};
struct TrHillFloor