From 80ec69fc5d6eb5d392124e902c67ad68164192c5 Mon Sep 17 00:00:00 2001 From: Jan Helbling Date: Tue, 14 Oct 2025 10:35:53 +0200 Subject: [PATCH 01/16] switched from head -c 12 to dd bs=1 count=12, to successful compiling with OpenBSD (#2091) Co-authored-by: Jan Helbling --- graphics_file_rules.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/graphics_file_rules.mk b/graphics_file_rules.mk index 05dfe5a2d5..e309ba25a7 100644 --- a/graphics_file_rules.mk +++ b/graphics_file_rules.mk @@ -431,7 +431,7 @@ $(RAYQUAZAGFXDIR)/scene_3/rayquaza.4bpp: %.4bpp: %.png $(RAYQUAZAGFXDIR)/scene_3/rayquaza_tail_fix.4bpp: $(RAYQUAZAGFXDIR)/scene_3/rayquaza_tail.4bpp cp $< $@ - head -c 12 /dev/zero >> $@ + dd if=/dev/zero bs=1 count=12 >> $@ $(RAYQUAZAGFXDIR)/scene_4/streaks.4bpp: %.4bpp: %.png $(GFX) $< $@ -num_tiles 19 -Wnum_tiles From d05742ca05e840b98a5629c03cc369a8a80086f6 Mon Sep 17 00:00:00 2001 From: FosterProgramming Date: Tue, 14 Oct 2025 10:36:32 +0200 Subject: [PATCH 02/16] Fix include order in wild_encounter.c (#2185) --- src/wild_encounter.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/wild_encounter.c b/src/wild_encounter.c index 7ac9ae0e8f..0656b19853 100644 --- a/src/wild_encounter.c +++ b/src/wild_encounter.c @@ -1,21 +1,21 @@ #include "global.h" -#include "wild_encounter.h" -#include "pokemon.h" -#include "metatile_behavior.h" -#include "fieldmap.h" -#include "random.h" -#include "field_player_avatar.h" -#include "event_data.h" -#include "safari_zone.h" -#include "overworld.h" -#include "pokeblock.h" #include "battle_setup.h" -#include "roamer.h" -#include "tv.h" -#include "link.h" -#include "script.h" #include "battle_pike.h" #include "battle_pyramid.h" +#include "event_data.h" +#include "fieldmap.h" +#include "field_player_avatar.h" +#include "link.h" +#include "metatile_behavior.h" +#include "overworld.h" +#include "pokeblock.h" +#include "pokemon.h" +#include "random.h" +#include "roamer.h" +#include "safari_zone.h" +#include "script.h" +#include "tv.h" +#include "wild_encounter.h" #include "constants/abilities.h" #include "constants/game_stat.h" #include "constants/items.h" From f4f7c38255c0bc29667af99badb9d98cc5407345 Mon Sep 17 00:00:00 2001 From: Estellar <137097857+estellarc@users.noreply.github.com> Date: Tue, 14 Oct 2025 05:41:27 -0300 Subject: [PATCH 03/16] Use MainCallback wherever posible (#2184) --- include/battle.h | 3 ++- include/battle_pyramid_bag.h | 7 ++++--- include/dodrio_berry_picking.h | 4 +++- include/item_menu.h | 9 +++++---- include/mail.h | 4 +++- include/rayquaza_scene.h | 4 +++- include/save.h | 4 +++- src/battle_main.c | 2 +- src/battle_pyramid_bag.c | 3 +-- src/dodrio_berry_picking.c | 5 ++--- src/frontier_pass.c | 14 +++++++------- src/item_menu.c | 5 ++--- src/mail.c | 3 +-- src/pokeblock.c | 4 ++-- src/rayquaza_scene.c | 3 +-- src/save.c | 5 ++--- src/save_failed_screen.c | 2 +- src/shop.c | 2 +- src/trainer_card.c | 2 +- src/use_pokeblock.c | 4 ++-- 20 files changed, 47 insertions(+), 42 deletions(-) diff --git a/include/battle.h b/include/battle.h index 855f085de0..4bd8aaaf35 100644 --- a/include/battle.h +++ b/include/battle.h @@ -12,6 +12,7 @@ #include "battle_util2.h" #include "battle_bg.h" #include "pokeball.h" +#include "main.h" #define GET_BATTLER_SIDE(battler) (GetBattlerPosition(battler) & BIT_SIDE) #define GET_BATTLER_SIDE2(battler) (gBattlerPositions[battler] & BIT_SIDE) @@ -716,7 +717,7 @@ extern u16 gBattleMovePower; extern u16 gMoveToLearn; extern u8 gBattleMonForms[MAX_BATTLERS_COUNT]; -extern void (*gPreBattleCallback1)(void); +extern MainCallback gPreBattleCallback1; extern void (*gBattleMainFunc)(void); extern struct BattleResults gBattleResults; extern u8 gLeveledUpInBattle; diff --git a/include/battle_pyramid_bag.h b/include/battle_pyramid_bag.h index 258ca56b21..0caf8d302c 100644 --- a/include/battle_pyramid_bag.h +++ b/include/battle_pyramid_bag.h @@ -2,6 +2,7 @@ #define GUARD_BATTLE_PYRAMID_BAG_H #include "list_menu.h" +#include "main.h" enum { PYRAMIDBAG_LOC_FIELD, @@ -29,7 +30,7 @@ enum { struct PyramidBagMenu { - void (*newScreenCallback)(void); + MainCallback newScreenCallback; u8 tilemapBuffer[BG_SCREEN_SIZE]; u8 spriteIds[PBAG_SPRITE_COUNT]; u8 windowIds[5]; @@ -49,7 +50,7 @@ struct PyramidBagMenu struct PyramidBagMenuState { - void (*exitCallback)(void); + MainCallback exitCallback; u8 location; u16 cursorPosition; u16 scrollPosition; @@ -63,7 +64,7 @@ void CB2_PyramidBagMenuFromStartMenu(void); void CB2_ReturnToPyramidBagMenu(void); void UpdatePyramidBagList(void); void UpdatePyramidBagCursorPos(void); -void GoToBattlePyramidBagMenu(u8 location, void (*exitCallback)(void)); +void GoToBattlePyramidBagMenu(u8 location, MainCallback exitCallback); void Task_CloseBattlePyramidBagMessage(u8 taskId); void TryStoreHeldItemsInPyramidBag(void); void ChooseItemsToTossFromPyramidBag(void); diff --git a/include/dodrio_berry_picking.h b/include/dodrio_berry_picking.h index a93fb27cd1..ec62e51947 100644 --- a/include/dodrio_berry_picking.h +++ b/include/dodrio_berry_picking.h @@ -1,7 +1,9 @@ #ifndef GUARD_DODRIO_BERRY_PICKING_H #define GUARD_DODRIO_BERRY_PICKING_H -void StartDodrioBerryPicking(u16 partyId, void (*exitCallback)(void)); +#include "main.h" + +void StartDodrioBerryPicking(u16 partyId, MainCallback exitCallback); void IsDodrioInParty(void); void ShowDodrioBerryPickingRecords(void); diff --git a/include/item_menu.h b/include/item_menu.h index dc7b44a0d6..2f7f3f3825 100644 --- a/include/item_menu.h +++ b/include/item_menu.h @@ -2,6 +2,7 @@ #define GUARD_ITEM_MENU_H #include "item.h" +#include "main.h" #include "menu_helpers.h" enum { @@ -47,7 +48,7 @@ enum { struct BagPosition { - void (*exitCallback)(void); + MainCallback exitCallback; u8 location; u8 pocket; u16 pocketSwitchArrowPos; @@ -59,7 +60,7 @@ extern struct BagPosition gBagPosition; struct BagMenu { - void (*newScreenCallback)(void); + MainCallback newScreenCallback; u8 tilemapBuffer[BG_SCREEN_SIZE]; u8 spriteIds[ITEMMENUSPRITE_COUNT]; u8 windowIds[ITEMWIN_COUNT]; @@ -96,10 +97,10 @@ void CB2_BagMenuFromStartMenu(void); u8 GetItemListPosition(u8 pocketId); bool8 UseRegisteredKeyItemOnField(void); void CB2_GoToSellMenu(void); -void GoToBagMenu(u8 location, u8 pocket, void ( *exitCallback)()); +void GoToBagMenu(u8 location, u8 pocket, MainCallback exitCallback); void DoWallyTutorialBagMenu(void); void ResetBagScrollPositions(void); -void ChooseBerryForMachine(void (*exitCallback)(void)); +void ChooseBerryForMachine(MainCallback exitCallback); void CB2_ChooseBerry(void); void Task_FadeAndCloseBagMenu(u8 taskId); void BagMenu_YesNo(u8 taskId, u8 windowType, const struct YesNoFuncTable *funcTable); diff --git a/include/mail.h b/include/mail.h index 403078f097..de29b21d42 100644 --- a/include/mail.h +++ b/include/mail.h @@ -1,6 +1,8 @@ #ifndef GUARD_MAIL_H #define GUARD_MAIL_H +#include "main.h" + #define IS_ITEM_MAIL(itemId) ((itemId == ITEM_ORANGE_MAIL \ || itemId == ITEM_HARBOR_MAIL \ || itemId == ITEM_GLITTER_MAIL \ @@ -15,7 +17,7 @@ || itemId == ITEM_RETRO_MAIL)) // mail.h -void ReadMail(struct Mail *mail, void (*exitCallback)(void), bool8 hasText); +void ReadMail(struct Mail *mail, MainCallback exitCallback, bool8 hasText); // mail_data.h void ClearAllMail(void); diff --git a/include/rayquaza_scene.h b/include/rayquaza_scene.h index 422b591273..6a51b9a45f 100644 --- a/include/rayquaza_scene.h +++ b/include/rayquaza_scene.h @@ -1,6 +1,8 @@ #ifndef GUARD_RAYQUAZA_SCENE_H #define GUARD_RAYQUAZA_SCENE_H -void DoRayquazaScene(u8 animId, bool8 endEarly, void (*exitCallback)(void)); +#include "main.h" + +void DoRayquazaScene(u8 animId, bool8 endEarly, MainCallback exitCallback); #endif // GUARD_RAYQUAZA_SCENE_H diff --git a/include/save.h b/include/save.h index 41913d1df4..923c672f50 100644 --- a/include/save.h +++ b/include/save.h @@ -1,6 +1,8 @@ #ifndef GUARD_SAVE_H #define GUARD_SAVE_H +#include "main.h" + // Each 4 KiB flash sector contains 3968 bytes of actual data followed by a 128 byte footer. // Only 12 bytes of the footer are used. #define SECTOR_DATA_SIZE 3968 @@ -87,7 +89,7 @@ extern u32 gSaveCounter; extern struct SaveSector *gFastSaveSector; extern u16 gIncrementalSectorId; extern u16 gSaveFileStatus; -extern void (*gGameContinueCallback)(void); +extern MainCallback gGameContinueCallback; extern struct SaveSectorLocation gRamSaveSectorLocations[]; extern struct SaveSector gSaveDataBuffer; diff --git a/src/battle_main.c b/src/battle_main.c index d6cbad4727..ed50332bb8 100644 --- a/src/battle_main.c +++ b/src/battle_main.c @@ -237,7 +237,7 @@ EWRAM_DATA u16 gBattleMovePower = 0; EWRAM_DATA u16 gMoveToLearn = 0; EWRAM_DATA u8 gBattleMonForms[MAX_BATTLERS_COUNT] = {0}; -COMMON_DATA void (*gPreBattleCallback1)(void) = NULL; +COMMON_DATA MainCallback gPreBattleCallback1 = NULL; COMMON_DATA void (*gBattleMainFunc)(void) = NULL; COMMON_DATA struct BattleResults gBattleResults = {0}; COMMON_DATA u8 gLeveledUpInBattle = 0; diff --git a/src/battle_pyramid_bag.c b/src/battle_pyramid_bag.c index e131508928..5354fc46fa 100644 --- a/src/battle_pyramid_bag.c +++ b/src/battle_pyramid_bag.c @@ -16,7 +16,6 @@ #include "item_use.h" #include "list_menu.h" #include "mail.h" -#include "main.h" #include "malloc.h" #include "menu.h" #include "menu_helpers.h" @@ -414,7 +413,7 @@ void CB2_ReturnToPyramidBagMenu(void) GoToBattlePyramidBagMenu(PYRAMIDBAG_LOC_PREV, gPyramidBagMenuState.exitCallback); } -void GoToBattlePyramidBagMenu(u8 location, void (*exitCallback)(void)) +void GoToBattlePyramidBagMenu(u8 location, MainCallback exitCallback) { gPyramidBagMenu = AllocZeroed(sizeof(*gPyramidBagMenu)); diff --git a/src/dodrio_berry_picking.c b/src/dodrio_berry_picking.c index 16ea035c7c..456cead41e 100644 --- a/src/dodrio_berry_picking.c +++ b/src/dodrio_berry_picking.c @@ -10,7 +10,6 @@ #include "link.h" #include "link_rfu.h" #include "m4a.h" -#include "main.h" #include "palette.h" #include "minigame_countdown.h" #include "random.h" @@ -223,7 +222,7 @@ struct DodrioGame_ScoreResults struct DodrioGame { - /*0x0000*/ void (*exitCallback)(void); + /*0x0000*/ MainCallback exitCallback; /*0x0004*/ u8 ALIGNED(4) taskId; /*0x0008*/ u8 ALIGNED(4) playersReceived; /*0x000C*/ u8 ALIGNED(4) startState; @@ -661,7 +660,7 @@ static void (*const sMemberFuncs[])(void) = [FUNC_WAIT_END_GAME] = WaitEndGame_Member }; -void StartDodrioBerryPicking(u16 partyId, void (*exitCallback)(void)) +void StartDodrioBerryPicking(u16 partyId, MainCallback exitCallback) { sExitingGame = FALSE; diff --git a/src/frontier_pass.c b/src/frontier_pass.c index 54d25a11e0..a053badc62 100644 --- a/src/frontier_pass.c +++ b/src/frontier_pass.c @@ -106,7 +106,7 @@ enum { struct FrontierPassData { - void (*callback)(void); + MainCallback callback; u16 state; u16 battlePoints; s16 cursorX; @@ -137,14 +137,14 @@ struct FrontierPassGfx struct FrontierPassSaved { - void (*callback)(void); + MainCallback callback; s16 cursorX; s16 cursorY; }; struct FrontierMapData { - void (*callback)(void); + MainCallback callback; struct Sprite *cursorSprite; struct Sprite *playerHeadSprite; struct Sprite *mapIndicatorSprite; @@ -160,8 +160,8 @@ static EWRAM_DATA struct FrontierPassGfx *sPassGfx = NULL; static EWRAM_DATA struct FrontierMapData *sMapData = NULL; static EWRAM_DATA struct FrontierPassSaved sSavedPassData = {0}; -static u32 AllocateFrontierPassData(void (*callback)(void)); -static void ShowFrontierMap(void (*callback)(void)); +static u32 AllocateFrontierPassData(MainCallback callback); +static void ShowFrontierMap(MainCallback callback); static void CB2_InitFrontierPass(void); static void DrawFrontierPassBg(void); static void FreeCursorAndSymbolSprites(void); @@ -604,7 +604,7 @@ static void LeaveFrontierPass(void) FreeFrontierPassData(); } -static u32 AllocateFrontierPassData(void (*callback)(void)) +static u32 AllocateFrontierPassData(MainCallback callback) { u8 i; @@ -1363,7 +1363,7 @@ static void PrintOnFrontierMap(void); static void InitFrontierMapSprites(void); static void HandleFrontierMapCursorMove(u8 direction); -static void ShowFrontierMap(void (*callback)(void)) +static void ShowFrontierMap(MainCallback callback) { if (sMapData != NULL) SetMainCallback2(callback); // This line doesn't make sense at all, since it gets overwritten later anyway. diff --git a/src/item_menu.c b/src/item_menu.c index e5e3e88f4e..8fe3b692d5 100755 --- a/src/item_menu.c +++ b/src/item_menu.c @@ -24,7 +24,6 @@ #include "list_menu.h" #include "link.h" #include "mail.h" -#include "main.h" #include "malloc.h" #include "map_name_popup.h" #include "menu.h" @@ -578,7 +577,7 @@ void CB2_ChooseBerry(void) } // Choosing berry for Berry Blender or Berry Crush -void ChooseBerryForMachine(void (*exitCallback)(void)) +void ChooseBerryForMachine(MainCallback exitCallback) { GoToBagMenu(ITEMMENULOCATION_BERRY_BLENDER_CRUSH, BERRIES_POCKET, exitCallback); } @@ -612,7 +611,7 @@ void QuizLadyOpenBagMenu(void) gSpecialVar_Result = FALSE; } -void GoToBagMenu(u8 location, u8 pocket, void ( *exitCallback)()) +void GoToBagMenu(u8 location, u8 pocket, MainCallback exitCallback) { gBagMenu = AllocZeroed(sizeof(*gBagMenu)); if (gBagMenu == NULL) diff --git a/src/mail.c b/src/mail.c index e1aaa66873..a2f1c44065 100644 --- a/src/mail.c +++ b/src/mail.c @@ -1,7 +1,6 @@ #include "global.h" #include "mail.h" #include "constants/items.h" -#include "main.h" #include "overworld.h" #include "task.h" #include "scanline_effect.h" @@ -443,7 +442,7 @@ static const struct MailLayout sMailLayouts_Tall[] = { }, }; -void ReadMail(struct Mail *mail, void (*exitCallback)(void), bool8 hasText) +void ReadMail(struct Mail *mail, MainCallback exitCallback, bool8 hasText) { u16 buffer[2]; u16 species; diff --git a/src/pokeblock.c b/src/pokeblock.c index f3d1fa446e..8ecf7f6e1d 100644 --- a/src/pokeblock.c +++ b/src/pokeblock.c @@ -62,7 +62,7 @@ enum { struct PokeblockMenuStruct { u8 tilemap[BG_SCREEN_SIZE]; - void (*callbackOnUse)(void); + MainCallback callbackOnUse; const u8 *pokeblockActionIds; u8 numActions; u8 caseId; @@ -80,7 +80,7 @@ struct PokeblockMenuStruct struct PokeblockSavedData { - void (*callback)(void); + MainCallback callback; u16 selectedRow; u16 scrollOffset; }; diff --git a/src/rayquaza_scene.c b/src/rayquaza_scene.c index 3264b22bdf..d97d463135 100644 --- a/src/rayquaza_scene.c +++ b/src/rayquaza_scene.c @@ -4,7 +4,6 @@ #include "task.h" #include "graphics.h" #include "bg.h" -#include "main.h" #include "malloc.h" #include "palette.h" #include "scanline_effect.h" @@ -1285,7 +1284,7 @@ static const struct BgTemplate sBgTemplates_ChasesAway[] = } }; -void DoRayquazaScene(u8 animId, bool8 endEarly, void (*exitCallback)(void)) +void DoRayquazaScene(u8 animId, bool8 endEarly, MainCallback exitCallback) { sRayScene = AllocZeroed(sizeof(*sRayScene)); sRayScene->animId = animId; diff --git a/src/save.c b/src/save.c index bff1384c52..5c5d7b1b8b 100644 --- a/src/save.c +++ b/src/save.c @@ -8,7 +8,6 @@ #include "load_save.h" #include "overworld.h" #include "pokemon_storage_system.h" -#include "main.h" #include "trainer_hill.h" #include "link.h" #include "constants/game_stat.h" @@ -88,7 +87,7 @@ COMMON_DATA struct SaveSector *gReadWriteSector = NULL; // Pointer to a buffer f COMMON_DATA u16 gIncrementalSectorId = 0; COMMON_DATA u16 gSaveUnusedVar = 0; COMMON_DATA u16 gSaveFileStatus = 0; -COMMON_DATA void (*gGameContinueCallback)(void) = NULL; +COMMON_DATA MainCallback gGameContinueCallback = NULL; COMMON_DATA struct SaveSectorLocation gRamSaveSectorLocations[NUM_SECTORS_PER_SLOT] = {0}; COMMON_DATA u16 gSaveUnusedVar2 = 0; COMMON_DATA u16 gSaveAttemptStatus = 0; @@ -887,7 +886,7 @@ u8 LoadGameSave(u8 saveType) status = TryLoadSaveSlot(FULL_SAVE_SLOT, gRamSaveSectorLocations); CopyPartyAndObjectsFromSave(); gSaveFileStatus = status; - gGameContinueCallback = 0; + gGameContinueCallback = NULL; break; case SAVE_HALL_OF_FAME: status = TryLoadSaveSector(SECTOR_ID_HOF_1, gDecompressionBuffer, SECTOR_DATA_SIZE); diff --git a/src/save_failed_screen.c b/src/save_failed_screen.c index f7f0162ff4..8b0a766d70 100644 --- a/src/save_failed_screen.c +++ b/src/save_failed_screen.c @@ -326,7 +326,7 @@ static void CB2_ReturnToTitleScreen(void) } else { - SetMainCallback2((MainCallback)gGameContinueCallback); + SetMainCallback2(gGameContinueCallback); gGameContinueCallback = NULL; } } diff --git a/src/shop.c b/src/shop.c index 338e067938..c6e78817eb 100644 --- a/src/shop.c +++ b/src/shop.c @@ -455,7 +455,7 @@ static void Task_GoToBuyOrSellMenu(u8 taskId) if (!gPaletteFade.active) { DestroyTask(taskId); - SetMainCallback2((void *)((u16)tCallbackHi << 16 | (u16)tCallbackLo)); + SetMainCallback2((MainCallback)((u16)tCallbackHi << 16 | (u16)tCallbackLo)); } } diff --git a/src/trainer_card.c b/src/trainer_card.c index 1535c3d997..78a4bb56fe 100755 --- a/src/trainer_card.c +++ b/src/trainer_card.c @@ -77,7 +77,7 @@ struct TrainerCardData u8 cardType; bool8 isHoenn; u16 blendColor; - void (*callback2)(void); + MainCallback callback2; struct TrainerCard trainerCard; u16 frontTilemap[600]; u16 backTilemap[600]; diff --git a/src/use_pokeblock.c b/src/use_pokeblock.c index c9d5c56e5c..769e5a3465 100644 --- a/src/use_pokeblock.c +++ b/src/use_pokeblock.c @@ -50,7 +50,7 @@ enum { struct UsePokeblockSession { void (*callback)(void); - void (*exitCallback)(void); + MainCallback exitCallback; struct Pokeblock *pokeblock; struct Pokemon *mon; u8 stringBuffer[64]; @@ -162,7 +162,7 @@ extern const u16 gConditionText_Pal[]; // The below 3 are saved for returning to the screen after feeding a pokeblock to a mon // so that the rest of the data can be freed static EWRAM_DATA struct UsePokeblockSession *sInfo = NULL; -static EWRAM_DATA void (*sExitCallback)(void) = NULL; +static EWRAM_DATA MainCallback sExitCallback = NULL; static EWRAM_DATA struct Pokeblock *sPokeblock = NULL; EWRAM_DATA u8 gPokeblockMonId = 0; EWRAM_DATA s16 gPokeblockGain = 0; From f2cf20ce9bdf4a9f6cd0300a005ca3ec6ae89e3c Mon Sep 17 00:00:00 2001 From: Jan Helbling Date: Tue, 14 Oct 2025 13:30:26 +0200 Subject: [PATCH 04/16] INSTALL.MD updated for OpenBSD (#2186) Co-authored-by: Jan Helbling --- INSTALL.md | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/INSTALL.md b/INSTALL.md index 03b28ba464..1cca7f8ae6 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -357,6 +357,26 @@ nix-shell -p pkgsCross.arm-embedded.stdenv.cc git pkg-config libpng ``` Then proceed to [Choosing where to store pokeemerald (Linux)](#choosing-where-to-store-pokeemerald-linux). +### OpenBSD +Install requirements: +```bash +pkg_add gmake bash arm-none-eabi-binutils clang git +``` + +Clone pokeemerald & agbcc, and Build agbcc +```bash +git clone https://github.com/pret/pokeemerald +git clone https://github.com/pret/agbcc +cd agbcc && ./build.sh +./install.sh ../pokeemerald +``` + +Build the ROM: +```bash +cd ../pokeemerald +gmake +``` + ### Other distributions _(Specific instructions for other distributions would be greatly appreciated!)_ From 0965dffe70bb7d4bc229e24e4bc0266a6be6b8c8 Mon Sep 17 00:00:00 2001 From: Estellar <137097857+estellarc@users.noreply.github.com> Date: Sat, 18 Oct 2025 13:53:50 -0300 Subject: [PATCH 05/16] Use TaskFunc wherever posible (#2188) --- include/battle_pyramid_bag.h | 3 ++- include/item_menu.h | 2 +- src/battle_factory_screen.c | 6 +++--- src/battle_pyramid_bag.c | 2 +- src/fldeff_misc.c | 4 ++-- src/item_menu.c | 2 +- src/item_use.c | 2 +- src/palette.c | 2 +- src/pokemon_summary_screen.c | 2 +- 9 files changed, 13 insertions(+), 12 deletions(-) diff --git a/include/battle_pyramid_bag.h b/include/battle_pyramid_bag.h index 0caf8d302c..4d8b87506e 100644 --- a/include/battle_pyramid_bag.h +++ b/include/battle_pyramid_bag.h @@ -3,6 +3,7 @@ #include "list_menu.h" #include "main.h" +#include "task.h" enum { PYRAMIDBAG_LOC_FIELD, @@ -69,6 +70,6 @@ void Task_CloseBattlePyramidBagMessage(u8 taskId); void TryStoreHeldItemsInPyramidBag(void); void ChooseItemsToTossFromPyramidBag(void); void CloseBattlePyramidBag(u8 taskId); -void DisplayItemMessageInBattlePyramid(u8 taskId, const u8 *str, void (*callback)(u8 taskId)); +void DisplayItemMessageInBattlePyramid(u8 taskId, const u8 *str, TaskFunc callback); #endif // GUARD_BATTLE_PYRAMID_BAG_H diff --git a/include/item_menu.h b/include/item_menu.h index 2f7f3f3825..e63eb3b6c2 100644 --- a/include/item_menu.h +++ b/include/item_menu.h @@ -105,7 +105,7 @@ void CB2_ChooseBerry(void); void Task_FadeAndCloseBagMenu(u8 taskId); void BagMenu_YesNo(u8 taskId, u8 windowType, const struct YesNoFuncTable *funcTable); void UpdatePocketItemList(u8 pocketId); -void DisplayItemMessage(u8 taskId, u8 fontId, const u8 *str, void (*callback)(u8 taskId)); +void DisplayItemMessage(u8 taskId, u8 fontId, const u8 *str, TaskFunc callback); void DisplayItemMessageOnField(u8 taskId, const u8 *string, TaskFunc callback); void CloseItemMessage(u8 taskId); diff --git a/src/battle_factory_screen.c b/src/battle_factory_screen.c index eea04b99d3..8726770f18 100644 --- a/src/battle_factory_screen.c +++ b/src/battle_factory_screen.c @@ -125,7 +125,7 @@ struct FactorySelectScreen struct SwapScreenAction { u8 id; - void (*func)(u8 taskId); + TaskFunc func; }; struct FactorySwapScreen @@ -253,7 +253,7 @@ static EWRAM_DATA u8 *sSwapMenuTilemapBuffer = NULL; static EWRAM_DATA u8 *sSwapMonPicBgTilemapBuffer = NULL; static struct FactorySelectScreen *sFactorySelectScreen; -static void (*sSwap_CurrentOptionFunc)(u8 taskId); +static TaskFunc sSwap_CurrentOptionFunc; static struct FactorySwapScreen *sFactorySwapScreen; COMMON_DATA u8 (*gFactorySelect_CurrentOptionFunc)(void) = NULL; @@ -886,7 +886,7 @@ static const struct SpriteTemplate sSpriteTemplate_Swap_MonPicBgAnim = .callback = SpriteCallbackDummy }; -void static (*const sSwap_MenuOptionFuncs[])(u8 taskId) = +static const TaskFunc sSwap_MenuOptionFuncs[] = { Swap_OptionSummary, Swap_OptionSwap, diff --git a/src/battle_pyramid_bag.c b/src/battle_pyramid_bag.c index 5354fc46fa..805b4df905 100644 --- a/src/battle_pyramid_bag.c +++ b/src/battle_pyramid_bag.c @@ -1502,7 +1502,7 @@ static void CreatePyramidBagYesNo(u8 taskId, const struct YesNoFuncTable *yesNoT CreateYesNoMenuWithCallbacks(taskId, &sWindowTemplates_MenuActions[MENU_WIN_YESNO], 1, 0, 2, 1, 0xE, yesNoTable); } -void DisplayItemMessageInBattlePyramid(u8 taskId, const u8 *str, void (*callback)(u8 taskId)) +void DisplayItemMessageInBattlePyramid(u8 taskId, const u8 *str, TaskFunc callback) { FillWindowPixelBuffer(WIN_MSG, PIXEL_FILL(1)); DisplayMessageAndContinueTask(taskId, WIN_MSG, 0xA, 0xD, FONT_NORMAL, GetPlayerTextSpeedDelay(), str, callback); diff --git a/src/fldeff_misc.c b/src/fldeff_misc.c index 1c361fb6f0..3adff9c81c 100644 --- a/src/fldeff_misc.c +++ b/src/fldeff_misc.c @@ -339,9 +339,9 @@ bool8 IsComputerScreenCloseEffectActive(void) #define tBlendCnt data[7] #define tBlendY data[8] -static void CreateComputerScreenEffectTask(void (*taskfunc) (u8), u16 increment, u16 unused, u8 priority) +static void CreateComputerScreenEffectTask(TaskFunc func, u16 increment, u16 unused, u8 priority) { - u8 taskId = CreateTask(taskfunc, priority); + u8 taskId = CreateTask(func, priority); gTasks[taskId].tState = 0; gTasks[taskId].tHorzIncrement = increment == 0 ? 16 : increment; diff --git a/src/item_menu.c b/src/item_menu.c index 8fe3b692d5..09bc25c90b 100755 --- a/src/item_menu.c +++ b/src/item_menu.c @@ -1159,7 +1159,7 @@ u8 GetItemListPosition(u8 pocketId) return gBagPosition.scrollPosition[pocketId] + gBagPosition.cursorPosition[pocketId]; } -void DisplayItemMessage(u8 taskId, u8 fontId, const u8 *str, void (*callback)(u8 taskId)) +void DisplayItemMessage(u8 taskId, u8 fontId, const u8 *str, TaskFunc callback) { s16 *data = gTasks[taskId].data; diff --git a/src/item_use.c b/src/item_use.c index 6ae235675a..b7bf458a99 100755 --- a/src/item_use.c +++ b/src/item_use.c @@ -72,7 +72,7 @@ static void SetDistanceOfClosestHiddenItem(u8, s16, s16); static void CB2_OpenPokeblockFromBag(void); // EWRAM variables -EWRAM_DATA static void(*sItemUseOnFieldCB)(u8 taskId) = NULL; +EWRAM_DATA static TaskFunc sItemUseOnFieldCB = NULL; // Below is set TRUE by UseRegisteredKeyItemOnField #define tUsingRegisteredKeyItem data[3] diff --git a/src/palette.c b/src/palette.c index f19ac07cf6..09a4b91ebd 100644 --- a/src/palette.c +++ b/src/palette.c @@ -956,7 +956,7 @@ void BlendPalettesGradually(u32 selectedPalettes, s8 delay, u8 coeff, u8 coeffTa { u8 taskId; - taskId = CreateTask((void *)Task_BlendPalettesGradually, priority); + taskId = CreateTask(Task_BlendPalettesGradually, priority); gTasks[taskId].tCoeff = coeff; gTasks[taskId].tCoeffTarget = coeffTarget; diff --git a/src/pokemon_summary_screen.c b/src/pokemon_summary_screen.c index a5886fd6a9..a77df48327 100644 --- a/src/pokemon_summary_screen.c +++ b/src/pokemon_summary_screen.c @@ -715,7 +715,7 @@ static void (*const sTextPrinterFunctions[])(void) = [PSS_PAGE_CONTEST_MOVES] = PrintContestMoves }; -static void (*const sTextPrinterTasks[])(u8 taskId) = +static const TaskFunc sTextPrinterTasks[] = { [PSS_PAGE_INFO] = Task_PrintInfoPage, [PSS_PAGE_SKILLS] = Task_PrintSkillsPage, From 7fd0029ed7b9a245f866b6a7467f6d0bd7c0f717 Mon Sep 17 00:00:00 2001 From: DavidJCobb <831497+DavidJCobb@users.noreply.github.com> Date: Sun, 19 Oct 2025 18:37:13 +0200 Subject: [PATCH 06/16] Add typedefs for MAPSEC and METLOC values (#2183) Added typedefs: mapsec_t, metloc_t, and variants for MAPSEC and METLOC values. There are some rough edges that could do with smoothing out, but for now, this gets us close to ideal with a ROM that compares equal. Per feedback, all typedefs to mention the underlying type within the typedef name. The documentation comments reflect and explain the naming convention. Updated comments to reflect the fact that we're no longer using SET8 for a Pokemon's met locations, in favor of a new macro (added by this PR) that adjusts to match the width of whatever is being set. --- include/gametypes.h | 67 +++++++++++++++++++++++++ include/global.fieldmap.h | 2 +- include/global.h | 1 + include/global.tv.h | 14 +++--- include/landmark.h | 2 +- include/overworld.h | 4 +- include/pokemon.h | 2 +- include/pokenav.h | 6 +-- include/region_map.h | 14 +++--- src/data/region_map/region_map_layout.h | 2 +- src/daycare.c | 2 +- src/egg_hatch.c | 2 +- src/frontier_pass.c | 4 +- src/landmark.c | 8 +-- src/map_name_popup.c | 2 +- src/match_call.c | 4 +- src/overworld.c | 6 +-- src/pokedex_area_screen.c | 16 +++--- src/pokemon.c | 15 +++++- src/pokemon_summary_screen.c | 2 +- src/pokenav_match_call_data.c | 36 ++++++------- src/pokenav_match_call_gfx.c | 2 +- src/pokenav_match_call_list.c | 4 +- src/pokenav_region_map.c | 10 ++-- src/region_map.c | 58 ++++++++++----------- src/trade.c | 2 +- 26 files changed, 185 insertions(+), 102 deletions(-) create mode 100644 include/gametypes.h diff --git a/include/gametypes.h b/include/gametypes.h new file mode 100644 index 0000000000..242fc9d9db --- /dev/null +++ b/include/gametypes.h @@ -0,0 +1,67 @@ +#ifndef GUARD_GAMETYPES_H +#define GUARD_GAMETYPES_H + +#include "gba/types.h" + +// +// This header includes typedefs for fields that commonly appear throughout +// the codebase, and which ROM hacks might benefit from being able to widen. +// +// These typedefs include the underlying type in their name for two reasons: +// +// - Game Freak wasn't fully consistent about field widths throughout +// their codebase. For example, when Region Map Sections are persistently +// stored in savedata, they're stored as 8-bit values; but much of the +// codebase handles them as 16-bit values. +// +// - Although Pokemon Emerald doesn't come close to maxing out RAM, it *does* +// use nearly all of its EEPROM. That is: the vanilla game uses 96% of the +// flash memory available for storing players' save files, leaving 2172 +// bytes to spare within each of the game's two save files (primary and +// backup). These spare bytes are not contiguous: SaveBlock1 can only grow +// by 84 bytes, and SaveBlock2 can only grow by 120 bytes, with the rest +// of the free space located after the player's PC-boxed Pokemon. +// +// With so little flash memory to spare, keeping track of how much space +// you're using is vital -- and so is arranging struct members to minimize +// compiler-inserted padding. It's easier to deal with this when you can +// see these types' widths at a glance. +// +// Accordingly, this file generally doesn't contain just single types, but +// rather families of types. For example, Region Map Sections are saved as +// u8s within the player's save file, but are sometimes handled as u16s or +// even s16s and ints; and so there are multiple typedefs for Map Sections +// corresponding to each of these underlying types, and each typedef has a +// name which indicates the underlying type. +// +// For a given family of typedefs, the smallest one should be considered +// the "real" or "canonical" type. Continuing with Map Sections as our +// example, the smallest type is an 8-bit integer, and so any values that +// can't fit in an 8-bit integer will be truncated and lost at some point +// within the codebase. Therefore mapsec_u8_t is the "canonical" type for +// Map Sections, and the larger typedefs just exist to describe situations +// where the game handles Map Sections inconsistently with that "canon." +// + +// Map Sections are named areas that can appear in the region map. Each +// individual map can be assigned to a Map Section as appropriate. The +// possible values are in constants/region_map_sections.h. +// +// If you choose to widen Map Sections, be aware that Met Locations (below) +// are based on Map Sections and will also be widened. +typedef u8 mapsec_u8_t; +typedef u16 mapsec_u16_t; +typedef s16 mapsec_s16_t; +typedef s32 mapsec_s32_t; + +// Met Locations for caught Pokemon use the same values as Map Sections, +// except that 0xFD, 0xFE, and 0xFF have special meanings. +// +// Because this value appears inside every Pokemon's data, widening it will +// consume a lot more space within flash memory. The space usage will be +// greater than you expect due to how Pokemon substructs are laid out; you +// would have to rearrange the substructs' contents in order to minimize +// how much more space a wider Met Location would consume. +typedef mapsec_u8_t metloc_u8_t; + +#endif //GUARD_GAMETYPES_H diff --git a/include/global.fieldmap.h b/include/global.fieldmap.h index 1207bd80ea..90f2080d71 100644 --- a/include/global.fieldmap.h +++ b/include/global.fieldmap.h @@ -167,7 +167,7 @@ struct MapHeader /* 0x0C */ const struct MapConnections *connections; /* 0x10 */ u16 music; /* 0x12 */ u16 mapLayoutId; - /* 0x14 */ u8 regionMapSectionId; + /* 0x14 */ mapsec_u8_t regionMapSectionId; /* 0x15 */ u8 cave; /* 0x16 */ u8 weather; /* 0x17 */ u8 mapType; diff --git a/include/global.h b/include/global.h index f0882710e5..bdfc426fb9 100644 --- a/include/global.h +++ b/include/global.h @@ -5,6 +5,7 @@ #include #include "config.h" // we need to define config before gba headers as print stuff needs the functions nulled before defines. #include "gba/gba.h" +#include "gametypes.h" #include "constants/global.h" #include "constants/flags.h" #include "constants/vars.h" diff --git a/include/global.tv.h b/include/global.tv.h index 9c3902e7cc..a2721b06b4 100644 --- a/include/global.tv.h +++ b/include/global.tv.h @@ -226,7 +226,7 @@ typedef union // size = 0x24 /*0x04*/ u8 filler_04[2]; /*0x06*/ u16 itemIds[SMARTSHOPPER_NUM_ITEMS]; /*0x0C*/ u16 itemAmounts[SMARTSHOPPER_NUM_ITEMS]; - /*0x12*/ u8 shopLocation; + /*0x12*/ mapsec_u8_t shopLocation; /*0x13*/ u8 playerName[PLAYER_NAME_LENGTH + 1]; /*0x1B*/ //u8 padding; } smartshopperShow; @@ -241,7 +241,7 @@ typedef union // size = 0x24 /*0x0E*/ u16 species2; /*0x10*/ u8 nBallsUsed; /*0x11*/ u8 outcome; - /*0x12*/ u8 location; + /*0x12*/ mapsec_u8_t location; /*0x13*/ u8 playerName[PLAYER_NAME_LENGTH + 1]; /*0x1B*/ //u8 padding; } pokemonTodayFailed; @@ -267,7 +267,7 @@ typedef union // size = 0x24 /*0x04*/ u16 caughtPoke; /*0x06*/ u16 steps; /*0x08*/ u16 species; - /*0x0A*/ u8 location; + /*0x0A*/ mapsec_u8_t location; /*0x0B*/ u8 language; /*0x0C*/ u8 filler_0C[7]; /*0x13*/ u8 playerName[PLAYER_NAME_LENGTH + 1]; @@ -282,7 +282,7 @@ typedef union // size = 0x24 /*0x04*/ u8 badgeCount; /*0x05*/ u8 nSilverSymbols; /*0x06*/ u8 nGoldSymbols; - /*0x07*/ u8 location; + /*0x07*/ mapsec_u8_t location; /*0x08*/ u16 battlePoints; /*0x0A*/ u16 mapLayoutId; /*0x0C*/ u8 language; @@ -309,7 +309,7 @@ typedef union // size = 0x24 /*0x00*/ u8 kind; /*0x01*/ bool8 active; /*0x02*/ u16 item; - /*0x04*/ u8 location; + /*0x04*/ mapsec_u8_t location; /*0x05*/ u8 language; /*0x06*/ u16 mapLayoutId; /*0x08*/ u8 filler_08[11]; @@ -336,7 +336,7 @@ typedef union // size = 0x24 /*0x00*/ u8 kind; /*0x01*/ bool8 active; /*0x02*/ u16 lastOpponentSpecies; - /*0x04*/ u8 location; + /*0x04*/ mapsec_u8_t location; /*0x05*/ u8 outcome; /*0x06*/ u16 caughtMonBall; /*0x08*/ u16 balls; @@ -505,7 +505,7 @@ struct GabbyAndTyData /*2BA6*/ u16 mon2; /*2BA8*/ u16 lastMove; /*2BAA*/ u16 quote[1]; - /*2BAC*/ u8 mapnum; + /*2BAC*/ mapsec_u8_t mapnum; /*2BAD*/ u8 battleNum; /*2BAE*/ u8 battleTookMoreThanOneTurn:1; u8 playerLostAMon:1; diff --git a/include/landmark.h b/include/landmark.h index 395905033a..f5feb407bc 100644 --- a/include/landmark.h +++ b/include/landmark.h @@ -1,6 +1,6 @@ #ifndef GUARD_LANDMARK_H #define GUARD_LANDMARK_H -const u8 *GetLandmarkName(u8 mapSection, u8 id, u8 count); +const u8 *GetLandmarkName(mapsec_u8_t mapSection, u8 id, u8 count); #endif // GUARD_LANDMARK_H diff --git a/include/overworld.h b/include/overworld.h index bde6896569..8ac0ddc81e 100644 --- a/include/overworld.h +++ b/include/overworld.h @@ -121,8 +121,8 @@ u8 GetLastUsedWarpMapType(void); bool8 IsMapTypeOutdoors(u8 mapType); bool8 Overworld_MapTypeAllowsTeleportAndFly(u8 mapType); bool8 IsMapTypeIndoors(u8 mapType); -u8 GetSavedWarpRegionMapSectionId(void); -u8 GetCurrentRegionMapSectionId(void); +mapsec_u8_t GetSavedWarpRegionMapSectionId(void); +mapsec_u8_t GetCurrentRegionMapSectionId(void); u8 GetCurrentMapBattleScene(void); void CleanupOverworldWindowsAndTilemaps(void); bool32 IsOverworldLinkActive(void); diff --git a/include/pokemon.h b/include/pokemon.h index 53f7f02fd0..3d75157f91 100644 --- a/include/pokemon.h +++ b/include/pokemon.h @@ -131,7 +131,7 @@ struct PokemonSubstruct2 struct PokemonSubstruct3 { /* 0x00 */ u8 pokerus; - /* 0x01 */ u8 metLocation; + /* 0x01 */ metloc_u8_t metLocation; /* 0x02 */ u16 metLevel:7; /* 0x02 */ u16 metGame:4; diff --git a/include/pokenav.h b/include/pokenav.h index 553d2ad0f6..b548824234 100644 --- a/include/pokenav.h +++ b/include/pokenav.h @@ -17,7 +17,7 @@ struct PokenavMonListItem struct PokenavMatchCallEntry { bool8 isSpecialTrainer; - u8 mapSec; + mapsec_u8_t mapSec; u16 headerId; }; @@ -410,7 +410,7 @@ void FreeMatchCallSubstruct1(void); int IsMatchCallListInitFinished(void); int GetNumberRegistered(void); struct PokenavMatchCallEntry *GetMatchCallList(void); -u16 GetMatchCallMapSec(int index); +mapsec_u16_t GetMatchCallMapSec(int index); bool32 ShouldDrawRematchPokeballIcon(int index); void ClearRematchPokeballIcon(u16 windowId, u32 tileOffset); int GetMatchCallTrainerPic(int index); @@ -419,7 +419,7 @@ const u8 *GetMatchCallMessageText(int index, bool8 *newRematchRequest); u16 GetMatchCallOptionCursorPos(void); u16 GetMatchCallOptionId(int optionId); void BufferMatchCallNameAndDesc(struct PokenavMatchCallEntry *matchCallEntry, u8 *str); -u8 GetMatchTableMapSectionId(int rematchIndex); +mapsec_u8_t GetMatchTableMapSectionId(int rematchIndex); int GetIndexDeltaOfNextCheckPageDown(int index); int GetIndexDeltaOfNextCheckPageUp(int index); bool32 IsRematchEntryRegistered(int rematchIndex); diff --git a/include/region_map.h b/include/region_map.h index 2bca9e7f7d..abdb44b16c 100644 --- a/include/region_map.h +++ b/include/region_map.h @@ -26,7 +26,7 @@ enum { }; struct RegionMap { - /*0x000*/ u16 mapSecId; + /*0x000*/ mapsec_u16_t mapSecId; /*0x002*/ u8 mapSecType; /*0x003*/ u8 posWithinMapSec; /*0x004*/ u8 mapSecName[20]; @@ -99,14 +99,14 @@ void InitRegionMap(struct RegionMap *regionMap, bool8 zoomed); u8 DoRegionMapInputCallback(void); bool8 UpdateRegionMapZoom(void); void FreeRegionMapIconResources(void); -u16 GetRegionMapSecIdAt(u16 x, u16 y); +mapsec_u16_t GetRegionMapSecIdAt(u16 x, u16 y); void CreateRegionMapPlayerIcon(u16 tileTag, u16 paletteTag); void CreateRegionMapCursor(u16 tileTag, u16 paletteTag); -bool32 IsEventIslandMapSecId(u8 mapSecId); -u8 *GetMapName(u8 *dest, u16 regionMapId, u16 padLength); -u8 *GetMapNameGeneric(u8 *dest, u16 mapSecId); -u8 *GetMapNameHandleAquaHideout(u8 *dest, u16 mapSecId); -u16 CorrectSpecialMapSecId(u16 mapSecId); +bool32 IsEventIslandMapSecId(mapsec_u8_t mapSecId); +u8 *GetMapName(u8 *dest, mapsec_u16_t regionMapId, u16 padLength); +u8 *GetMapNameGeneric(u8 *dest, mapsec_u16_t mapSecId); +u8 *GetMapNameHandleAquaHideout(u8 *dest, mapsec_u16_t mapSecId); +mapsec_u16_t CorrectSpecialMapSecId(mapsec_u16_t mapSecId); void ShowRegionMapForPokedexAreaScreen(struct RegionMap *regionMap); void PokedexAreaScreen_UpdateRegionMapVariablesAndVideoRegs(s16 x, s16 y); void CB2_OpenFlyMap(void); diff --git a/src/data/region_map/region_map_layout.h b/src/data/region_map/region_map_layout.h index 95a4e94f31..32ce91724d 100644 --- a/src/data/region_map/region_map_layout.h +++ b/src/data/region_map/region_map_layout.h @@ -1,4 +1,4 @@ -static const u8 sRegionMap_MapSectionLayout[MAP_HEIGHT][MAP_WIDTH] = { +static const mapsec_u8_t sRegionMap_MapSectionLayout[MAP_HEIGHT][MAP_WIDTH] = { {MAPSEC_NONE, MAPSEC_ROUTE_114, MAPSEC_ROUTE_114, MAPSEC_FALLARBOR_TOWN, MAPSEC_ROUTE_113, MAPSEC_ROUTE_113, MAPSEC_ROUTE_113, MAPSEC_ROUTE_113, MAPSEC_ROUTE_111, MAPSEC_NONE, MAPSEC_NONE, MAPSEC_ROUTE_119, MAPSEC_FORTREE_CITY, MAPSEC_ROUTE_120, MAPSEC_NONE, MAPSEC_NONE, MAPSEC_NONE, MAPSEC_NONE, MAPSEC_NONE, MAPSEC_NONE, MAPSEC_NONE, MAPSEC_NONE, MAPSEC_NONE, MAPSEC_NONE, MAPSEC_NONE, MAPSEC_NONE, MAPSEC_NONE, MAPSEC_NONE}, {MAPSEC_NONE, MAPSEC_ROUTE_114, MAPSEC_NONE, MAPSEC_NONE, MAPSEC_NONE, MAPSEC_NONE, MAPSEC_MT_CHIMNEY, MAPSEC_MT_CHIMNEY, MAPSEC_ROUTE_111, MAPSEC_NONE, MAPSEC_NONE, MAPSEC_ROUTE_119, MAPSEC_NONE, MAPSEC_ROUTE_120, MAPSEC_NONE, MAPSEC_NONE, MAPSEC_NONE, MAPSEC_NONE, MAPSEC_NONE, MAPSEC_NONE, MAPSEC_NONE, MAPSEC_NONE, MAPSEC_NONE, MAPSEC_NONE, MAPSEC_NONE, MAPSEC_NONE, MAPSEC_NONE, MAPSEC_NONE}, {MAPSEC_ROUTE_115, MAPSEC_ROUTE_114, MAPSEC_NONE, MAPSEC_NONE, MAPSEC_NONE, MAPSEC_NONE, MAPSEC_MT_CHIMNEY, MAPSEC_MT_CHIMNEY, MAPSEC_ROUTE_111, MAPSEC_NONE, MAPSEC_NONE, MAPSEC_ROUTE_119, MAPSEC_NONE, MAPSEC_ROUTE_120, MAPSEC_NONE, MAPSEC_NONE, MAPSEC_SAFARI_ZONE, MAPSEC_NONE, MAPSEC_NONE, MAPSEC_NONE, MAPSEC_NONE, MAPSEC_NONE, MAPSEC_NONE, MAPSEC_NONE, MAPSEC_NONE, MAPSEC_NONE, MAPSEC_NONE, MAPSEC_NONE}, diff --git a/src/daycare.c b/src/daycare.c index 5ebe255b39..eb9a5fdeb0 100644 --- a/src/daycare.c +++ b/src/daycare.c @@ -830,7 +830,7 @@ void CreateEgg(struct Pokemon *mon, u16 species, bool8 setHotSpringsLocation) u8 metLevel; u16 ball; u8 language; - u8 metLocation; + metloc_u8_t metLocation; u8 isEgg; CreateMon(mon, species, EGG_HATCH_LEVEL, USE_RANDOM_IVS, FALSE, 0, OT_ID_PLAYER_ID, 0); diff --git a/src/egg_hatch.c b/src/egg_hatch.c index 5aa955d7e9..00a194ea70 100644 --- a/src/egg_hatch.c +++ b/src/egg_hatch.c @@ -362,7 +362,7 @@ static void AddHatchedMonToParty(u8 id) u8 name[POKEMON_NAME_LENGTH + 1]; u16 ball; u16 metLevel; - u8 metLocation; + metloc_u8_t metLocation; struct Pokemon *mon = &gPlayerParty[id]; CreateHatchedMon(mon, &gEnemyParty[0]); diff --git a/src/frontier_pass.c b/src/frontier_pass.c index a053badc62..fb6920e3cc 100644 --- a/src/frontier_pass.c +++ b/src/frontier_pass.c @@ -606,7 +606,9 @@ static void LeaveFrontierPass(void) static u32 AllocateFrontierPassData(MainCallback callback) { - u8 i; + // This variable is a MAPSEC initially, but is recycled as a + // bare integer near the end of the function. + mapsec_u8_t i; if (sPassData != NULL) return ERR_ALREADY_DONE; diff --git a/src/landmark.c b/src/landmark.c index d2bb3c4105..a8cf6c1233 100644 --- a/src/landmark.c +++ b/src/landmark.c @@ -10,7 +10,7 @@ struct Landmark struct LandmarkList { - u8 mapSection; + mapsec_u8_t mapSection; u8 id; const struct Landmark *const *landmarks; }; @@ -392,9 +392,9 @@ static const struct LandmarkList sLandmarkLists[] = {MAPSEC_NONE, 0, NULL}, }; -static const struct Landmark *const *GetLandmarks(u8 mapSection, u8 id); +static const struct Landmark *const *GetLandmarks(mapsec_u8_t mapSection, u8 id); -const u8 *GetLandmarkName(u8 mapSection, u8 id, u8 count) +const u8 *GetLandmarkName(mapsec_u8_t mapSection, u8 id, u8 count) { const struct Landmark *const *landmarks = GetLandmarks(mapSection, id); @@ -421,7 +421,7 @@ const u8 *GetLandmarkName(u8 mapSection, u8 id, u8 count) return (*landmarks)->name; } -static const struct Landmark *const *GetLandmarks(u8 mapSection, u8 id) +static const struct Landmark *const *GetLandmarks(mapsec_u8_t mapSection, u8 id) { u16 i = 0; diff --git a/src/map_name_popup.c b/src/map_name_popup.c index 4b30068f3c..665cccec3c 100644 --- a/src/map_name_popup.c +++ b/src/map_name_popup.c @@ -404,7 +404,7 @@ static void LoadMapNamePopUpWindowBg(void) { u8 popUpThemeId; u8 popupWindowId = GetMapNamePopUpWindowId(); - u16 regionMapSectionId = gMapHeader.regionMapSectionId; + mapsec_u16_t regionMapSectionId = gMapHeader.regionMapSectionId; if (regionMapSectionId >= KANTO_MAPSEC_START) { diff --git a/src/match_call.c b/src/match_call.c index e6a141a1bc..41188f51bb 100644 --- a/src/match_call.c +++ b/src/match_call.c @@ -134,7 +134,7 @@ static u32 GetCurrentTotalMinutes(struct Time *); static u32 GetNumRegisteredTrainers(void); static u32 GetActiveMatchCallTrainerId(u32); static int GetTrainerMatchCallId(int); -static u16 GetRematchTrainerLocation(int); +static mapsec_u16_t GetRematchTrainerLocation(int); static bool32 TrainerIsEligibleForRematch(int); static void StartMatchCall(void); static void ExecuteMatchCall(u8); @@ -1463,7 +1463,7 @@ static bool32 TrainerIsEligibleForRematch(int matchCallId) return gSaveBlock1Ptr->trainerRematches[matchCallId] > 0; } -static u16 GetRematchTrainerLocation(int matchCallId) +static mapsec_u16_t GetRematchTrainerLocation(int matchCallId) { const struct MapHeader *mapHeader = Overworld_GetMapHeaderByGroupAndId(gRematchTable[matchCallId].mapGroup, gRematchTable[matchCallId].mapNum); return mapHeader->regionMapSectionId; diff --git a/src/overworld.c b/src/overworld.c index 32c5eb0678..d1d3ddcd37 100644 --- a/src/overworld.c +++ b/src/overworld.c @@ -194,7 +194,7 @@ EWRAM_DATA struct WarpData gLastUsedWarp = {0}; EWRAM_DATA static struct WarpData sWarpDestination = {0}; // new warp position EWRAM_DATA static struct WarpData sFixedDiveWarp = {0}; EWRAM_DATA static struct WarpData sFixedHoleWarp = {0}; -EWRAM_DATA static u16 sLastMapSectionId = 0; +EWRAM_DATA static mapsec_u16_t sLastMapSectionId = 0; EWRAM_DATA static struct InitialPlayerAvatarState sInitialPlayerAvatarState = {0}; EWRAM_DATA static u16 sAmbientCrySpecies = 0; EWRAM_DATA static bool8 sIsAmbientCryWaterMon = FALSE; @@ -1383,12 +1383,12 @@ bool8 IsMapTypeIndoors(u8 mapType) return FALSE; } -u8 GetSavedWarpRegionMapSectionId(void) +mapsec_u8_t GetSavedWarpRegionMapSectionId(void) { return Overworld_GetMapHeaderByGroupAndId(gSaveBlock1Ptr->dynamicWarp.mapGroup, gSaveBlock1Ptr->dynamicWarp.mapNum)->regionMapSectionId; } -u8 GetCurrentRegionMapSectionId(void) +mapsec_u8_t GetCurrentRegionMapSectionId(void) { return Overworld_GetMapHeaderByGroupAndId(gSaveBlock1Ptr->location.mapGroup, gSaveBlock1Ptr->location.mapNum)->regionMapSectionId; } diff --git a/src/pokedex_area_screen.c b/src/pokedex_area_screen.c index 8b0a845102..c3211ed454 100755 --- a/src/pokedex_area_screen.c +++ b/src/pokedex_area_screen.c @@ -58,7 +58,7 @@ struct OverworldArea { u8 mapGroup; u8 mapNum; - u16 regionMapSectionId; + mapsec_u16_t regionMapSectionId; }; struct @@ -79,7 +79,7 @@ struct /*0x61C*/ u16 areaShadeBldArgHi; /*0x61E*/ bool8 showingMarkers; /*0x61F*/ u8 markerFlashCounter; - /*0x620*/ u16 specialAreaRegionMapSectionIds[MAX_AREA_MARKERS]; + /*0x620*/ mapsec_u16_t specialAreaRegionMapSectionIds[MAX_AREA_MARKERS]; /*0x660*/ struct Sprite *areaMarkerSprites[MAX_AREA_MARKERS]; /*0x6E0*/ u16 numAreaMarkerSprites; /*0x6E2*/ u16 alteringCaveCounter; @@ -95,7 +95,7 @@ static void FindMapsWithMon(u16); static void BuildAreaGlowTilemap(void); static void SetAreaHasMon(u16, u16); static void SetSpecialMapHasMon(u16, u16); -static u16 GetRegionMapSectionId(u8, u8); +static mapsec_u16_t GetRegionMapSectionId(u8, u8); static bool8 MapHasSpecies(const struct WildPokemonHeader *, u16); static bool8 MonListHasSpecies(const struct WildPokemonInfo *, u16, u16); static void DoAreaGlow(void); @@ -112,7 +112,7 @@ static const u32 sAreaGlow_Gfx[] = INCBIN_U32("graphics/pokedex/area_glow.4bpp.l static const u16 sSpeciesHiddenFromAreaScreen[] = { SPECIES_WYNAUT }; -static const u16 sMovingRegionMapSections[3] = +static const mapsec_u16_t sMovingRegionMapSections[3] = { MAPSEC_MARINE_CAVE, MAPSEC_UNDERWATER_MARINE_CAVE, @@ -125,7 +125,7 @@ static const u16 sFeebasData[][3] = {NUM_SPECIES} }; -static const u16 sLandmarkData[][2] = +static const mapsec_u16_t sLandmarkData[][2] = { {MAPSEC_SKY_PILLAR, FLAG_LANDMARK_SKY_PILLAR}, {MAPSEC_SEAFLOOR_CAVERN, FLAG_LANDMARK_SEAFLOOR_CAVERN}, @@ -336,7 +336,7 @@ static void SetSpecialMapHasMon(u16 mapGroup, u16 mapNum) if (sPokedexAreaScreen->numSpecialAreas < MAX_AREA_MARKERS) { - u16 regionMapSectionId = GetRegionMapSectionId(mapGroup, mapNum); + mapsec_u16_t regionMapSectionId = GetRegionMapSectionId(mapGroup, mapNum); if (regionMapSectionId < MAPSEC_NONE) { // Don't highlight the area if it's a moving area (Marine/Terra Cave) @@ -370,7 +370,7 @@ static void SetSpecialMapHasMon(u16 mapGroup, u16 mapNum) } } -static u16 GetRegionMapSectionId(u8 mapGroup, u8 mapNum) +static mapsec_u16_t GetRegionMapSectionId(u8 mapGroup, u8 mapNum) { return Overworld_GetMapHeaderByGroupAndId(mapGroup, mapNum)->regionMapSectionId; } @@ -710,7 +710,7 @@ static void CreateAreaMarkerSprites(void) static s16 x; static s16 y; static s16 i; - static s16 mapSecId; + static mapsec_s16_t mapSecId; static s16 numSprites; LoadSpriteSheet(&sAreaMarkerSpriteSheet); diff --git a/src/pokemon.c b/src/pokemon.c index a06693dc8a..7283e0e456 100644 --- a/src/pokemon.c +++ b/src/pokemon.c @@ -4074,6 +4074,19 @@ u32 GetBoxMonData2(struct BoxPokemon *boxMon, s32 field) __attribute__((alias("G #define SET8(lhs) (lhs) = *data #define SET16(lhs) (lhs) = data[0] + (data[1] << 8) #define SET32(lhs) (lhs) = data[0] + (data[1] << 8) + (data[2] << 16) + (data[3] << 24) +// +// Prefer SET_BY_WIDTH for fields whose types might be extended (e.g. +// anything whose typedef is in gametypes.h). +// +#define SET_BY_WIDTH(lhs) \ + do { \ + if (sizeof(lhs) == 1) \ + SET8(lhs); \ + else if (sizeof(lhs) == 2) \ + SET16(lhs); \ + else if (sizeof(lhs) == 4) \ + SET32(lhs); \ + } while (0) void SetMonData(struct Pokemon *mon, s32 field, const void *dataArg) { @@ -4263,7 +4276,7 @@ void SetBoxMonData(struct BoxPokemon *boxMon, s32 field, const void *dataArg) SET8(substruct3->pokerus); break; case MON_DATA_MET_LOCATION: - SET8(substruct3->metLocation); + SET_BY_WIDTH(substruct3->metLocation); break; case MON_DATA_MET_LEVEL: { diff --git a/src/pokemon_summary_screen.c b/src/pokemon_summary_screen.c index a77df48327..734d925358 100644 --- a/src/pokemon_summary_screen.c +++ b/src/pokemon_summary_screen.c @@ -143,7 +143,7 @@ static EWRAM_DATA struct PokemonSummaryScreenData u8 ribbonCount; // 0x6 u8 ailment; // 0x7 u8 abilityNum; // 0x8 - u8 metLocation; // 0x9 + metloc_u8_t metLocation; // 0x9 u8 metLevel; // 0xA u8 metGame; // 0xB u32 pid; // 0xC diff --git a/src/pokenav_match_call_data.c b/src/pokenav_match_call_data.c index 1c3cf9aeeb..3f47550f17 100644 --- a/src/pokenav_match_call_data.c +++ b/src/pokenav_match_call_data.c @@ -34,13 +34,13 @@ typedef struct MatchCallTextDataStruct { struct MatchCallStructCommon { u8 type; - u8 mapSec; + mapsec_u8_t mapSec; u16 flag; }; struct MatchCallStructNPC { u8 type; - u8 mapSec; + mapsec_u8_t mapSec; u16 flag; const u8 *desc; const u8 *name; @@ -50,7 +50,7 @@ struct MatchCallStructNPC { // Shared by MC_TYPE_TRAINER and MC_TYPE_LEADER struct MatchCallStructTrainer { u8 type; - u8 mapSec; + mapsec_u8_t mapSec; u16 flag; u16 rematchTableIdx; const u8 *desc; @@ -60,12 +60,12 @@ struct MatchCallStructTrainer { struct MatchCallLocationOverride { u16 flag; - u8 mapSec; + mapsec_u8_t mapSec; }; struct MatchCallWally { u8 type; - u8 mapSec; + mapsec_u8_t mapSec; u16 flag; u16 rematchTableIdx; const u8 *desc; @@ -75,7 +75,7 @@ struct MatchCallWally { struct MatchCallBirch { u8 type; - u8 mapSec; + mapsec_u8_t mapSec; u16 flag; const u8 *desc; const u8 *name; @@ -117,11 +117,11 @@ static bool32 MatchCall_GetEnabled_Wally(match_call_t); static bool32 MatchCall_GetEnabled_Birch(match_call_t); static bool32 MatchCall_GetEnabled_Rival(match_call_t); -static u8 MatchCall_GetMapSec_NPC(match_call_t); -static u8 MatchCall_GetMapSec_Trainer(match_call_t); -static u8 MatchCall_GetMapSec_Wally(match_call_t); -static u8 MatchCall_GetMapSec_Birch(match_call_t); -static u8 MatchCall_GetMapSec_Rival(match_call_t); +static mapsec_u8_t MatchCall_GetMapSec_NPC(match_call_t); +static mapsec_u8_t MatchCall_GetMapSec_Trainer(match_call_t); +static mapsec_u8_t MatchCall_GetMapSec_Wally(match_call_t); +static mapsec_u8_t MatchCall_GetMapSec_Birch(match_call_t); +static mapsec_u8_t MatchCall_GetMapSec_Rival(match_call_t); static bool32 MatchCall_IsRematchable_NPC(match_call_t); static bool32 MatchCall_IsRematchable_Trainer(match_call_t); @@ -609,7 +609,7 @@ static bool32 (*const sMatchCallGetEnabledFuncs[])(match_call_t) = { MatchCall_GetEnabled_Birch }; -static u8 (*const sMatchCallGetMapSecFuncs[])(match_call_t) = { +static mapsec_u8_t (*const sMatchCallGetMapSecFuncs[])(match_call_t) = { MatchCall_GetMapSec_NPC, MatchCall_GetMapSec_Trainer, MatchCall_GetMapSec_Wally, @@ -779,7 +779,7 @@ static bool32 MatchCall_GetEnabled_Birch(match_call_t matchCall) return FlagGet(matchCall.birch->flag); } -u8 MatchCall_GetMapSec(u32 idx) +mapsec_u8_t MatchCall_GetMapSec(u32 idx) { match_call_t matchCall; u32 i; @@ -791,17 +791,17 @@ u8 MatchCall_GetMapSec(u32 idx) return sMatchCallGetMapSecFuncs[i](matchCall); } -static u8 MatchCall_GetMapSec_NPC(match_call_t matchCall) +static mapsec_u8_t MatchCall_GetMapSec_NPC(match_call_t matchCall) { return matchCall.npc->mapSec; } -static u8 MatchCall_GetMapSec_Trainer(match_call_t matchCall) +static mapsec_u8_t MatchCall_GetMapSec_Trainer(match_call_t matchCall) { return matchCall.trainer->mapSec; } -static u8 MatchCall_GetMapSec_Wally(match_call_t matchCall) +static mapsec_u8_t MatchCall_GetMapSec_Wally(match_call_t matchCall) { s32 i; @@ -813,12 +813,12 @@ static u8 MatchCall_GetMapSec_Wally(match_call_t matchCall) return matchCall.wally->locationData[i].mapSec; } -static u8 MatchCall_GetMapSec_Rival(match_call_t matchCall) +static mapsec_u8_t MatchCall_GetMapSec_Rival(match_call_t matchCall) { return MAPSEC_NONE; } -static u8 MatchCall_GetMapSec_Birch(match_call_t matchCall) +static mapsec_u8_t MatchCall_GetMapSec_Birch(match_call_t matchCall) { return MAPSEC_NONE; } diff --git a/src/pokenav_match_call_gfx.c b/src/pokenav_match_call_gfx.c index 4271e2ff23..dde725d8bd 100755 --- a/src/pokenav_match_call_gfx.c +++ b/src/pokenav_match_call_gfx.c @@ -1022,7 +1022,7 @@ static void PrintMatchCallLocation(struct Pokenav_MatchCallGfx *gfx, int delta) u8 mapName[32]; int x; int index = PokenavList_GetSelectedIndex() + delta; - int mapSec = GetMatchCallMapSec(index); + mapsec_s32_t mapSec = GetMatchCallMapSec(index); if (mapSec != MAPSEC_NONE) GetMapName(mapName, mapSec, 0); else diff --git a/src/pokenav_match_call_list.c b/src/pokenav_match_call_list.c index fb89e33e0b..8f8fc6b4c2 100755 --- a/src/pokenav_match_call_list.c +++ b/src/pokenav_match_call_list.c @@ -306,7 +306,7 @@ struct PokenavMatchCallEntry *GetMatchCallList(void) return state->matchCallEntries; } -u16 GetMatchCallMapSec(int index) +mapsec_u16_t GetMatchCallMapSec(int index) { struct Pokenav_MatchCallMenu *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_MAIN); return state->matchCallEntries[index].mapSec; @@ -424,7 +424,7 @@ void BufferMatchCallNameAndDesc(struct PokenavMatchCallEntry *matchCallEntry, u8 } } -u8 GetMatchTableMapSectionId(int rematchIndex) +mapsec_u8_t GetMatchTableMapSectionId(int rematchIndex) { int mapGroup = gRematchTable[rematchIndex].mapGroup; int mapNum = gRematchTable[rematchIndex].mapNum; diff --git a/src/pokenav_region_map.c b/src/pokenav_region_map.c index f81ff42966..8475bbacb8 100755 --- a/src/pokenav_region_map.c +++ b/src/pokenav_region_map.c @@ -41,7 +41,7 @@ struct Pokenav_RegionMapGfx struct CityMapEntry { - u16 mapSecId; + mapsec_u16_t mapSecId; u16 index; const u32 *tilemap; }; @@ -63,8 +63,8 @@ static bool32 IsDma3ManagerBusyWithBgCopy_(struct Pokenav_RegionMapGfx *); static void ChangeBgYForZoom(bool32); static bool32 IsChangeBgYForZoomActive(void); static void CreateCityZoomTextSprites(void); -static void DrawCityMap(struct Pokenav_RegionMapGfx *, int, int); -static void PrintLandmarkNames(struct Pokenav_RegionMapGfx *, int, int); +static void DrawCityMap(struct Pokenav_RegionMapGfx *, mapsec_s32_t, int); +static void PrintLandmarkNames(struct Pokenav_RegionMapGfx *, mapsec_s32_t, int); static void SetCityZoomTextInvisibility(bool32); static void Task_ChangeBgYForZoom(u8 taskId); static void UpdateCityZoomTextPosition(void); @@ -634,7 +634,7 @@ static u32 LoopedTask_DecompressCityMaps(s32 taskState) return LT_FINISH; } -static void DrawCityMap(struct Pokenav_RegionMapGfx *state, int mapSecId, int pos) +static void DrawCityMap(struct Pokenav_RegionMapGfx *state, mapsec_s32_t mapSecId, int pos) { int i; for (i = 0; i < NUM_CITY_MAPS && (sPokenavCityMaps[i].mapSecId != mapSecId || sPokenavCityMaps[i].index != pos); i++) @@ -647,7 +647,7 @@ static void DrawCityMap(struct Pokenav_RegionMapGfx *state, int mapSecId, int po CopyToBgTilemapBufferRect(1, state->cityZoomPics[i], 18, 6, 10, 10); } -static void PrintLandmarkNames(struct Pokenav_RegionMapGfx *state, int mapSecId, int pos) +static void PrintLandmarkNames(struct Pokenav_RegionMapGfx *state, mapsec_s32_t mapSecId, int pos) { int i = 0; while (1) diff --git a/src/region_map.c b/src/region_map.c index 22a3f567b4..a418b7fe4f 100644 --- a/src/region_map.c +++ b/src/region_map.c @@ -63,7 +63,7 @@ enum { struct MultiNameFlyDest { const u8 *const *name; - u16 mapSecId; + mapsec_u16_t mapSecId; u16 flag; }; @@ -72,7 +72,7 @@ static EWRAM_DATA struct RegionMap *sRegionMap = NULL; static EWRAM_DATA struct { void (*callback)(void); u16 state; - u16 mapSecId; + mapsec_u16_t mapSecId; struct RegionMap regionMap; u8 tileBuffer[0x1c0]; u8 nameBuffer[0x26]; // never read @@ -86,15 +86,15 @@ static u8 MoveRegionMapCursor_Full(void); static u8 ProcessRegionMapInput_Zoomed(void); static u8 MoveRegionMapCursor_Zoomed(void); static void CalcZoomScrollParams(s16 scrollX, s16 scrollY, s16 c, s16 d, u16 e, u16 f, u8 rotation); -static u16 GetMapSecIdAt(u16 x, u16 y); +static mapsec_u16_t GetMapSecIdAt(u16 x, u16 y); static void RegionMap_SetBG2XAndBG2Y(s16 x, s16 y); static void InitMapBasedOnPlayerLocation(void); static void RegionMap_InitializeStateBasedOnSSTidalLocation(void); -static u8 GetMapsecType(u16 mapSecId); -static u16 CorrectSpecialMapSecId_Internal(u16 mapSecId); -static u16 GetTerraOrMarineCaveMapSecId(void); +static u8 GetMapsecType(mapsec_u16_t mapSecId); +static mapsec_u16_t CorrectSpecialMapSecId_Internal(mapsec_u16_t mapSecId); +static mapsec_u16_t GetTerraOrMarineCaveMapSecId(void); static void GetMarineCaveCoords(u16 *x, u16 *y); -static bool32 IsPlayerInAquaHideout(u8 mapSecId); +static bool32 IsPlayerInAquaHideout(mapsec_u8_t mapSecId); static void GetPositionOfCursorWithinMapSec(void); static bool8 RegionMap_IsMapSecIdInNextRow(u16 y); static void SpriteCB_CursorMapFull(struct Sprite *sprite); @@ -130,7 +130,7 @@ static const u8 sRegionMapPlayerIcon_MayGfx[] = INCBIN_U8("graphics/pokenav/regi #include "data/region_map/region_map_layout.h" #include "data/region_map/region_map_entries.h" -static const u16 sRegionMap_SpecialPlaceLocations[][2] = +static const mapsec_u16_t sRegionMap_SpecialPlaceLocations[][2] = { {MAPSEC_UNDERWATER_105, MAPSEC_ROUTE_105}, {MAPSEC_UNDERWATER_124, MAPSEC_ROUTE_124}, @@ -162,14 +162,14 @@ static const u16 sRegionMap_SpecialPlaceLocations[][2] = {MAPSEC_NONE, MAPSEC_NONE} }; -static const u16 sMarineCaveMapSecIds[] = +static const mapsec_u16_t sMarineCaveMapSecIds[] = { MAPSEC_MARINE_CAVE, MAPSEC_UNDERWATER_MARINE_CAVE, MAPSEC_UNDERWATER_MARINE_CAVE }; -static const u16 sTerraOrMarineCaveMapSecIds[ABNORMAL_WEATHER_LOCATIONS] = +static const mapsec_u16_t sTerraOrMarineCaveMapSecIds[ABNORMAL_WEATHER_LOCATIONS] = { [ABNORMAL_WEATHER_ROUTE_114_NORTH - 1] = MAPSEC_ROUTE_114, [ABNORMAL_WEATHER_ROUTE_114_SOUTH - 1] = MAPSEC_ROUTE_114, @@ -203,7 +203,7 @@ static const struct UCoords16 sMarineCaveLocationCoords[MARINE_CAVE_LOCATIONS] = [MARINE_CAVE_COORD(ROUTE_129_EAST)] = {24, 10} }; -static const u8 sMapSecAquaHideoutOld[] = +static const mapsec_u8_t sMapSecAquaHideoutOld[] = { MAPSEC_AQUA_HIDEOUT_OLD }; @@ -273,7 +273,7 @@ static const union AnimCmd *const sRegionMapPlayerIconAnimTable[] = }; // Event islands that don't appear on map. (Southern Island does) -static const u8 sMapSecIdsOffMap[] = +static const mapsec_u8_t sMapSecIdsOffMap[] = { MAPSEC_BIRTH_ISLAND, MAPSEC_FARAWAY_ISLAND, @@ -421,7 +421,7 @@ static const struct SpritePalette sFlyTargetIconsSpritePalette = .tag = TAG_FLY_ICON }; -static const u16 sRedOutlineFlyDestinations[][2] = +static const mapsec_u16_t sRedOutlineFlyDestinations[][2] = { { FLAG_LANDMARK_BATTLE_FRONTIER, @@ -690,7 +690,7 @@ static u8 ProcessRegionMapInput_Full(void) static u8 MoveRegionMapCursor_Full(void) { - u16 mapSecId; + mapsec_u16_t mapSecId; if (sRegionMap->cursorMovementFrameCounter != 0) return MAP_INPUT_MOVE_CONT; @@ -771,7 +771,7 @@ static u8 MoveRegionMapCursor_Zoomed(void) { u16 x; u16 y; - u16 mapSecId; + mapsec_u16_t mapSecId; sRegionMap->scrollY += sRegionMap->zoomedCursorDeltaY; sRegionMap->scrollX += sRegionMap->zoomedCursorDeltaX; @@ -954,7 +954,7 @@ void PokedexAreaScreen_UpdateRegionMapVariablesAndVideoRegs(s16 x, s16 y) } } -static u16 GetMapSecIdAt(u16 x, u16 y) +static mapsec_u16_t GetMapSecIdAt(u16 x, u16 y) { if (y < MAPCURSOR_Y_MIN || y > MAPCURSOR_Y_MAX || x < MAPCURSOR_X_MIN || x > MAPCURSOR_X_MAX) { @@ -1172,7 +1172,7 @@ static void RegionMap_InitializeStateBasedOnSSTidalLocation(void) sRegionMap->cursorPosY = gRegionMapEntries[sRegionMap->mapSecId].y + y + MAPCURSOR_Y_MIN; } -static u8 GetMapsecType(u16 mapSecId) +static u8 GetMapsecType(mapsec_u16_t mapSecId) { switch (mapSecId) { @@ -1219,12 +1219,12 @@ static u8 GetMapsecType(u16 mapSecId) } } -u16 GetRegionMapSecIdAt(u16 x, u16 y) +mapsec_u16_t GetRegionMapSecIdAt(u16 x, u16 y) { return GetMapSecIdAt(x, y); } -static u16 CorrectSpecialMapSecId_Internal(u16 mapSecId) +static mapsec_u16_t CorrectSpecialMapSecId_Internal(mapsec_u16_t mapSecId) { u32 i; @@ -1245,7 +1245,7 @@ static u16 CorrectSpecialMapSecId_Internal(u16 mapSecId) return mapSecId; } -static u16 GetTerraOrMarineCaveMapSecId(void) +static mapsec_u16_t GetTerraOrMarineCaveMapSecId(void) { s16 idx; @@ -1274,7 +1274,7 @@ static void GetMarineCaveCoords(u16 *x, u16 *y) // Probably meant to be an "IsPlayerInIndoorDungeon" function, but in practice it only has the one mapsec // Additionally, because the mapsec doesnt exist in Emerald, this function always returns FALSE -static bool32 IsPlayerInAquaHideout(u8 mapSecId) +static bool32 IsPlayerInAquaHideout(mapsec_u8_t mapSecId) { u32 i; @@ -1286,7 +1286,7 @@ static bool32 IsPlayerInAquaHideout(u8 mapSecId) return FALSE; } -u16 CorrectSpecialMapSecId(u16 mapSecId) +mapsec_u16_t CorrectSpecialMapSecId(mapsec_u16_t mapSecId) { return CorrectSpecialMapSecId_Internal(mapSecId); } @@ -1565,7 +1565,7 @@ void TrySetPlayerIconBlink(void) #undef sVisible #undef sTimer -u8 *GetMapName(u8 *dest, u16 regionMapId, u16 padLength) +u8 *GetMapName(u8 *dest, mapsec_u16_t regionMapId, u16 padLength) { u8 *str; u16 i; @@ -1598,7 +1598,7 @@ u8 *GetMapName(u8 *dest, u16 regionMapId, u16 padLength) } // TODO: probably needs a better name -u8 *GetMapNameGeneric(u8 *dest, u16 mapSecId) +u8 *GetMapNameGeneric(u8 *dest, mapsec_u16_t mapSecId) { switch (mapSecId) { @@ -1611,7 +1611,7 @@ u8 *GetMapNameGeneric(u8 *dest, u16 mapSecId) } } -u8 *GetMapNameHandleAquaHideout(u8 *dest, u16 mapSecId) +u8 *GetMapNameHandleAquaHideout(u8 *dest, mapsec_u16_t mapSecId) { if (mapSecId == MAPSEC_AQUA_HIDEOUT_OLD) return StringCopy(dest, gText_Hideout); @@ -1619,7 +1619,7 @@ u8 *GetMapNameHandleAquaHideout(u8 *dest, u16 mapSecId) return GetMapNameGeneric(dest, mapSecId); } -static void GetMapSecDimensions(u16 mapSecId, u16 *x, u16 *y, u16 *width, u16 *height) +static void GetMapSecDimensions(mapsec_u16_t mapSecId, u16 *x, u16 *y, u16 *width, u16 *height) { *x = gRegionMapEntries[mapSecId].x; *y = gRegionMapEntries[mapSecId].y; @@ -1632,7 +1632,7 @@ bool8 IsRegionMapZoomed(void) return sRegionMap->zoomed; } -bool32 IsEventIslandMapSecId(u8 mapSecId) +bool32 IsEventIslandMapSecId(mapsec_u8_t mapSecId) { u32 i; @@ -1839,7 +1839,7 @@ static void LoadFlyDestIcons(void) static void CreateFlyDestIcons(void) { u16 canFlyFlag; - u16 mapSecId; + mapsec_u16_t mapSecId; u16 x; u16 y; u16 width; @@ -1887,7 +1887,7 @@ static void TryCreateRedOutlineFlyDestIcons(void) u16 y; u16 width; u16 height; - u16 mapSecId; + mapsec_u16_t mapSecId; u8 spriteId; for (i = 0; sRedOutlineFlyDestinations[i][1] != MAPSEC_NONE; i++) diff --git a/src/trade.c b/src/trade.c index e07e418d1a..e9c2984087 100644 --- a/src/trade.c +++ b/src/trade.c @@ -4552,7 +4552,7 @@ static void CreateInGameTradePokemonInternal(u8 whichPlayerMon, u8 whichInGameTr u8 level = GetMonData(&gPlayerParty[whichPlayerMon], MON_DATA_LEVEL); struct Mail mail; - u8 metLocation = METLOC_IN_GAME_TRADE; + metloc_u8_t metLocation = METLOC_IN_GAME_TRADE; u8 mailNum; struct Pokemon *pokemon = &gEnemyParty[0]; From fa5ca10b17ee602f8f078e6ff597e990125aef66 Mon Sep 17 00:00:00 2001 From: Josh <32826900+ShinyDragonHunter@users.noreply.github.com> Date: Sun, 19 Oct 2025 18:32:19 +0100 Subject: [PATCH 07/16] Add spritesheet rules for healthbox graphics (#2180) --- .../healthbox_doubles_opponent.png | Bin 284 -> 277 bytes .../healthbox_doubles_player.png | Bin 293 -> 282 bytes graphics/battle_interface/healthbox_safari.png | Bin 297 -> 284 bytes .../healthbox_singles_opponent.png | Bin 296 -> 278 bytes .../healthbox_singles_player.png | Bin 336 -> 328 bytes spritesheet_rules.mk | 16 ++++++++++++++++ 6 files changed, 16 insertions(+) diff --git a/graphics/battle_interface/healthbox_doubles_opponent.png b/graphics/battle_interface/healthbox_doubles_opponent.png index def9d07af0000520355bbd783c6ba2f27ff1fc67..28fdbbbeb984bf600c0053c14c26901ac57248fc 100644 GIT binary patch delta 224 zcmbQkG?huQGr-TCmrII^fq{Y7)59eQNH+kn0t+*c)Zob#o2Y1C&spFRSBnm?xchdFtB#ul~-b5Dr#)J|zFja@)%@%3Y$azBnpm;hJivpBjYYV_sfE?~79SN8UP@>MAkOK2j1$0ti zWR4}ikrgzXr(wo7vH}frEJ+4UJprZ>C|0;*Np&cW>`22j0$G7d8J2{LoFv=Z(lCu6 hl&Dei1vdF10RWZr=~ntpgyR4J002ovPDHLkV1oFvRq6l$ diff --git a/graphics/battle_interface/healthbox_doubles_player.png b/graphics/battle_interface/healthbox_doubles_player.png index f843c664b19abef8d15df4fe13f3ef0fc88ac5d2..c3587ec3fd14505ac511b1fb72f3bd07c097846c 100644 GIT binary patch delta 229 zcmZ3=G>b{GGr-TCmrII^fq{Y7)59eQNH+kn0t+*c)Zob#o2Y1C&spFRS_uuxI87O=k1ZL)y*l7|L=$f*q$3TvBxC~e#;YAhKLr_sFEQRTp@dXWG& Zh7(yY-**0X*aLJNgQu&X%Q~loCIF&;Mk)XR delta 240 zcmbQmw3JD)Gr-TCmrII^fq{Y7)59eQNIQTq3p0?6aL;)=QPIABgQtsQh(~8~!UCZL z-@~j6K1n{^!QkTP(z@A@k0EfvyCp5$4mmFlXz~Xh2y^mq{J4T?kw}YRz=2tA4vrFx ztOu^N#DnMsPddUGFEp6cykwj+&$>X(Guf$AYSya51!>(Tt5S9=G8ov*>srR3{Nff< zfarquy`Jt&tC)IT6uYS}IZzYAI9EhMFzAAhM1vCGr-TCmrII^fq{Y7)59eQNH+kn0}C^dRQQqPGf~mLp0mIsvY3H^?+6Gp zPSxg<21-uyba4!cXnlLlkk7$Epf&NVRmTp-&UsF&HwI?$*dFA(kvv%=y=!L9;)?qH z@yjOIcz&8JvvT&4@23~Od&QDqG21Cp(v5M(YoAzc2E7;e)2A{liPqV`#K3TXPk@m@ zfPV|q16_v)4a$f0p4eKm+pzvMxhH=6dHF5f$7k5@z5dU;&#kOsqu!?m%})*UYFRlH dTQ2lhG5isYTU9F^(*blIgQu&X%Q~loCIHg@Q~Lk_ delta 244 zcmVf3!(N zK~z|U?Uk_(f=~=a-+~`P`~ytfVPIvEII>vXCBhfr`)m`-LTg_c)PdZy_N1NeZ3tf? zBa3-{8!T8jk5ys7!nMpT_(C-2EbMwuxI=)jHKBEcjGSDw6wPQB9DO_7!+SxBRCmlm zdI5P0XjOv&0RE3k>qQ8vQl@4pO2|$+#BM35TB|+b2w_WtcmWU$q4tF62>XW+WHg_X u$hQi&EPxOHyz_*{5k$qP`6&PZe$ES1FkY(iS^ePv0000u8IGr-TCmrII^fq{Y7)59eQNH+kn0t+*c)Zob#o2Y1C&spFRS>UlAce97O%YE`{*Y6b z47gpl@jdE3^36=g{Hc*=tI>v(<0VcKAFndKTh%BcydjiVWhc{WVF@SA(nAbP3|x9L V;bJ$}r2!qr;OXk;vd$@?2>_8wMX&$> delta 243 zcmbQnw1P>oGr-TCmrII^fq{Y7)59eQNIQTq3p0?6aL;)=QPIABv!{z=h(~8~!UCoQ z-^1(;pCq6DU|@E3Y29onci_N;cS~CM4K|cLm>Qmxpsl!MK}E#V;{oSG654UZOu=x_xzt<_}+W-Qtsw*u6{1-oD!M<%Bxr+ diff --git a/graphics/battle_interface/healthbox_singles_player.png b/graphics/battle_interface/healthbox_singles_player.png index 0862ca399d54ce6f77b94432f6189a8eed4e386a..cf65e676129334422cf47eccbc013ed8ec6c8967 100644 GIT binary patch delta 275 zcmcb>bb?8-Gr-TCmrII^fq{Y7)59eQNH+kn0}C^dRQQqPGf~mLp0mIsvY3H^?+6Gp zPSxg<21@Spba4!cXnlKaBiA7Vfny)_J~}ov7e^OdpR_KPr!ThZ)tVK%FFfOH*_Yeg zSN@=t`DDTWoj)f!J0-$f_WKBLCrhuw9*%x54LQ66UAiESbr~%Gof@c zQ#h;0590u@#_1wAPGmANJk;iB4C0DlEnprNrPHsZeF1H})^3#BgF9nbWa zOt<;)Z};!s;&p{{>|5kwA6(`UpK(9nzlPn-iQ*mY$p;wNelfk_d!c>7#P{-+o+yT` XY{3tXHZyMldWFH$)z4*}Q$iB}uRCsd delta 283 zcmV+$0p$M30?+~>iBL{Q4GJ0x0000DNk~Le0000$0001h1Oos707f7?k! zK~z|U?Uu0)f+sci6e_uXN|a<;5~r}Z|j9qBP~rAHHP$C`{g?Q ze=i6=Lh!uq^S7`(7uL>zvDW#?X)93|nPf(m03N Date: Tue, 28 Oct 2025 06:19:12 -0300 Subject: [PATCH 08/16] Remove magic numbers in slot_machine.c (#2195) --- src/slot_machine.c | 59 +++++++++++++++++++++++++--------------------- 1 file changed, 32 insertions(+), 27 deletions(-) diff --git a/src/slot_machine.c b/src/slot_machine.c index 217767fc9e..da8b3613b3 100644 --- a/src/slot_machine.c +++ b/src/slot_machine.c @@ -314,6 +314,11 @@ enum { DIG_DISPLAY_BONUS_BIG }; +// IDs for the text windows +enum { + WIN_MSG, + WIN_INFO, +}; // How ReelTime works // ================== @@ -1249,7 +1254,7 @@ static void SlotMachineSetup_LoadGfxAndTilemaps(void) LoadSlotMachineGfx(); LoadMessageBoxGfx(0, 0x200, BG_PLTT_ID(15)); LoadUserWindowBorderGfx(0, 0x214, BG_PLTT_ID(14)); - PutWindowTilemap(0); + PutWindowTilemap(WIN_MSG); } static void CreateSlotMachineSprites(void) @@ -1390,9 +1395,9 @@ static bool8 SlotTask_HandleBetInput(struct Task *task) // SLOTTASK_MSG_NEED_3_COINS static bool8 SlotTask_PrintMsg_Need3Coins(struct Task *task) { - DrawDialogueFrame(0, FALSE); - AddTextPrinterParameterized(0, FONT_NORMAL, gText_YouDontHaveThreeCoins, 0, 1, 0, 0); - CopyWindowToVram(0, COPYWIN_FULL); + DrawDialogueFrame(WIN_MSG, FALSE); + AddTextPrinterParameterized(WIN_MSG, FONT_NORMAL, gText_YouDontHaveThreeCoins, 0, 1, 0, 0); + CopyWindowToVram(WIN_MSG, COPYWIN_FULL); sSlotMachine->state = SLOTTASK_WAIT_MSG_NEED_3_COINS; return FALSE; } @@ -1402,7 +1407,7 @@ static bool8 SlotTask_WaitMsg_Need3Coins(struct Task *task) { if (JOY_NEW(A_BUTTON | B_BUTTON)) { - ClearDialogWindowAndFrame(0, TRUE); + ClearDialogWindowAndFrame(WIN_MSG, TRUE); sSlotMachine->state = SLOTTASK_BET_INPUT; } return FALSE; @@ -1655,9 +1660,9 @@ static bool8 SlotTask_NoMatches(struct Task *task) // SLOTTASK_ASK_QUIT static bool8 SlotTask_AskQuit(struct Task *task) { - DrawDialogueFrame(0, FALSE); - AddTextPrinterParameterized(0, FONT_NORMAL, gText_QuitTheGame, 0, 1, 0, 0); - CopyWindowToVram(0, COPYWIN_FULL); + DrawDialogueFrame(WIN_MSG, FALSE); + AddTextPrinterParameterized(WIN_MSG, FONT_NORMAL, gText_QuitTheGame, 0, 1, 0, 0); + CopyWindowToVram(WIN_MSG, COPYWIN_FULL); CreateYesNoMenuParameterized(0x15, 7, 0x214, 0x180, 0xE, 0xF); sSlotMachine->state = SLOTTASK_HANDLE_QUIT_INPUT; return FALSE; @@ -1669,16 +1674,16 @@ static bool8 SlotTask_HandleQuitInput(struct Task *task) s8 input = Menu_ProcessInputNoWrapClearOnChoose(); if (input == 0) // Chose to quit { - ClearDialogWindowAndFrame(0, TRUE); + ClearDialogWindowAndFrame(WIN_MSG, TRUE); DarkenBetTiles(0); DarkenBetTiles(1); DarkenBetTiles(2); sSlotMachine->coins += sSlotMachine->bet; sSlotMachine->state = SLOTTASK_END; } - else if (input == 1 || input == -1) // Chose not to quit + else if (input == 1 || input == MENU_B_PRESSED) // Chose not to quit { - ClearDialogWindowAndFrame(0, TRUE); + ClearDialogWindowAndFrame(WIN_MSG, TRUE); sSlotMachine->state = SLOTTASK_BET_INPUT; } return FALSE; @@ -1687,9 +1692,9 @@ static bool8 SlotTask_HandleQuitInput(struct Task *task) // SLOTTASK_MSG_MAX_COINS static bool8 SlotTask_PrintMsg_MaxCoins(struct Task *task) { - DrawDialogueFrame(0, FALSE); - AddTextPrinterParameterized(0, FONT_NORMAL, gText_YouveGot9999Coins, 0, 1, 0, 0); - CopyWindowToVram(0, COPYWIN_FULL); + DrawDialogueFrame(WIN_MSG, FALSE); + AddTextPrinterParameterized(WIN_MSG, FONT_NORMAL, gText_YouveGot9999Coins, 0, 1, 0, 0); + CopyWindowToVram(WIN_MSG, COPYWIN_FULL); sSlotMachine->state = SLOTTASK_WAIT_MSG_MAX_COINS; return FALSE; } @@ -1699,7 +1704,7 @@ static bool8 SlotTask_WaitMsg_MaxCoins(struct Task *task) { if (JOY_NEW(A_BUTTON | B_BUTTON)) { - ClearDialogWindowAndFrame(0, TRUE); + ClearDialogWindowAndFrame(WIN_MSG, TRUE); sSlotMachine->state = SLOTTASK_BET_INPUT; } return FALSE; @@ -1708,9 +1713,9 @@ static bool8 SlotTask_WaitMsg_MaxCoins(struct Task *task) // SLOTTASK_MSG_NO_MORE_COINS static bool8 SlotTask_PrintMsg_NoMoreCoins(struct Task *task) { - DrawDialogueFrame(0, FALSE); - AddTextPrinterParameterized(0, FONT_NORMAL, gText_YouveRunOutOfCoins, 0, 1, 0, 0); - CopyWindowToVram(0, COPYWIN_FULL); + DrawDialogueFrame(WIN_MSG, FALSE); + AddTextPrinterParameterized(WIN_MSG, FONT_NORMAL, gText_YouveRunOutOfCoins, 0, 1, 0, 0); + CopyWindowToVram(WIN_MSG, COPYWIN_FULL); sSlotMachine->state = SLOTTASK_WAIT_MSG_NO_MORE_COINS; return FALSE; } @@ -1720,7 +1725,7 @@ static bool8 SlotTask_WaitMsg_NoMoreCoins(struct Task *task) { if (JOY_NEW(A_BUTTON | B_BUTTON)) { - ClearDialogWindowAndFrame(0, TRUE); + ClearDialogWindowAndFrame(WIN_MSG, TRUE); sSlotMachine->state = SLOTTASK_END; } return FALSE; @@ -3922,15 +3927,15 @@ static void InfoBox_DrawWindow(struct Task *task) DestroyDigitalDisplayScene(); LoadInfoBoxTilemap(); AddWindow(&sWindowTemplate_InfoBox); - PutWindowTilemap(1); - FillWindowPixelBuffer(1, PIXEL_FILL(0)); + PutWindowTilemap(WIN_INFO); + FillWindowPixelBuffer(WIN_INFO, PIXEL_FILL(0)); task->tState++; } static void InfoBox_AddText(struct Task *task) { - AddTextPrinterParameterized3(1, FONT_NORMAL, 2, 5, sColors_ReeltimeHelp, 0, gText_ReelTimeHelp); - CopyWindowToVram(1, COPYWIN_FULL); + AddTextPrinterParameterized3(WIN_INFO, FONT_NORMAL, 2, 5, sColors_ReeltimeHelp, 0, gText_ReelTimeHelp); + CopyWindowToVram(WIN_INFO, COPYWIN_FULL); BeginNormalPaletteFade(PALETTES_ALL, 0, 16, 0, RGB_BLACK); task->tState++; } @@ -3939,10 +3944,10 @@ static void InfoBox_WaitInput(struct Task *task) { if (JOY_NEW(B_BUTTON | SELECT_BUTTON)) { - FillWindowPixelBuffer(1, PIXEL_FILL(0)); - ClearWindowTilemap(1); - CopyWindowToVram(1, COPYWIN_MAP); - RemoveWindow(1); + FillWindowPixelBuffer(WIN_INFO, PIXEL_FILL(0)); + ClearWindowTilemap(WIN_INFO); + CopyWindowToVram(WIN_INFO, COPYWIN_MAP); + RemoveWindow(WIN_INFO); BeginNormalPaletteFade(PALETTES_ALL, 0, 0, 16, RGB_BLACK); task->tState++; } From d1d543548772cbdf087c5ccc1e0b19980aa9ad87 Mon Sep 17 00:00:00 2001 From: Martin Griffin Date: Thu, 30 Oct 2025 01:34:03 +0000 Subject: [PATCH 09/16] Improve undefined map assembler messages (#2196) --- asm/macros/event.inc | 16 ++++++++++++++++ asm/macros/map.inc | 4 ++++ data/event_scripts.s | 4 ++-- data/maps/LilycoveCity_Harbor/scripts.inc | 4 ++-- data/maps/LittlerootTown/scripts.inc | 2 +- data/maps/SlateportCity_Harbor/scripts.inc | 2 +- data/scripts/cable_club.inc | 12 ++++++------ include/constants/maps.h | 11 +++++++---- tools/mapjson/mapjson.cpp | 10 +++++++--- 9 files changed, 46 insertions(+), 19 deletions(-) diff --git a/asm/macros/event.inc b/asm/macros/event.inc index 797d549dc9..7075481750 100644 --- a/asm/macros/event.inc +++ b/asm/macros/event.inc @@ -667,6 +667,14 @@ map \map .endm + @ Set the player object's invisibility to FALSE. + .macro showplayer + .byte SCR_OP_SHOWOBJECTAT + .2byte LOCALID_PLAYER + .byte 0 @ map group + .byte 0 @ map num + .endm + @ Sets the specified object's invisibility to TRUE. .macro hideobjectat localId:req, map:req .byte SCR_OP_HIDEOBJECTAT @@ -674,6 +682,14 @@ map \map .endm + @ Set the player object's invisibility to TRUE. + .macro hideplayer + .byte SCR_OP_HIDEOBJECTAT + .2byte LOCALID_PLAYER + .byte 0 @ map group + .byte 0 @ map num + .endm + @ Turns the currently selected object (if there is one) to face the player. .macro faceplayer .byte SCR_OP_FACEPLAYER diff --git a/asm/macros/map.inc b/asm/macros/map.inc index 21445138de..acbcd532dd 100644 --- a/asm/macros/map.inc +++ b/asm/macros/map.inc @@ -2,8 +2,12 @@ @ Takes a MAP constant and outputs the map group and map number as separate bytes .macro map map_id:req + .ifdef \map_id .byte \map_id >> 8 @ map group .byte \map_id & 0xFF @ map num + .else + .error "undefined map (check for typos)" + .endif .endm @ Defines a map script. 'type' is any MAP_SCRIPT_* constant (see include/constants/map_scripts.h) diff --git a/data/event_scripts.s b/data/event_scripts.s index 0cc95940f8..33fc318957 100644 --- a/data/event_scripts.s +++ b/data/event_scripts.s @@ -787,7 +787,7 @@ EventScript_UnusedBoardFerry:: delay 30 applymovement LOCALID_PLAYER, Common_Movement_WalkInPlaceFasterUp waitmovement 0 - showobjectat LOCALID_PLAYER, 0 + showplayer delay 30 applymovement LOCALID_PLAYER, Movement_UnusedBoardFerry waitmovement 0 @@ -802,7 +802,7 @@ Common_EventScript_FerryDepartIsland:: call_if_eq VAR_FACING, DIR_SOUTH, Ferry_EventScript_DepartIslandSouth call_if_eq VAR_FACING, DIR_WEST, Ferry_EventScript_DepartIslandWest delay 30 - hideobjectat LOCALID_PLAYER, 0 + hideplayer call Common_EventScript_FerryDepart return diff --git a/data/maps/LilycoveCity_Harbor/scripts.inc b/data/maps/LilycoveCity_Harbor/scripts.inc index 9388609ab5..89bbb0714c 100644 --- a/data/maps/LilycoveCity_Harbor/scripts.inc +++ b/data/maps/LilycoveCity_Harbor/scripts.inc @@ -333,7 +333,7 @@ LilycoveCity_Harbor_EventScript_BoardFerryWithSailor:: call_if_eq VAR_FACING, DIR_NORTH, LilycoveCity_Harbor_EventScript_PlayerBoardFerryNorth call_if_eq VAR_FACING, DIR_EAST, LilycoveCity_Harbor_EventScript_PlayerBoardFerryEast delay 30 - hideobjectat LOCALID_PLAYER, 0 + hideplayer setvar VAR_0x8004, LOCALID_LILYCOVE_HARBOR_SS_TIDAL call Common_EventScript_FerryDepart return @@ -393,7 +393,7 @@ LilycoveCity_Harbor_EventScript_BoardFerry:: call_if_eq VAR_FACING, DIR_NORTH, LilycoveCity_Harbor_EventScript_PlayerBoardFerryNorth call_if_eq VAR_FACING, DIR_EAST, LilycoveCity_Harbor_EventScript_PlayerBoardFerryEast delay 30 - hideobjectat LOCALID_PLAYER, 0 + hideplayer setvar VAR_0x8004, LOCALID_LILYCOVE_HARBOR_SS_TIDAL call Common_EventScript_FerryDepart return diff --git a/data/maps/LittlerootTown/scripts.inc b/data/maps/LittlerootTown/scripts.inc index fd1d970b13..6a2c6af41b 100644 --- a/data/maps/LittlerootTown/scripts.inc +++ b/data/maps/LittlerootTown/scripts.inc @@ -156,7 +156,7 @@ LittlerootTown_EventScript_GoInsideWithMom:: waitmovement 0 setflag FLAG_HIDE_LITTLEROOT_TOWN_MOM_OUTSIDE setvar VAR_LITTLEROOT_INTRO_STATE, 3 - hideobjectat LOCALID_PLAYER, 0 + hideplayer closedoor VAR_0x8004, VAR_0x8005 waitdooranim clearflag FLAG_HIDE_LITTLEROOT_TOWN_FAT_MAN diff --git a/data/maps/SlateportCity_Harbor/scripts.inc b/data/maps/SlateportCity_Harbor/scripts.inc index ebcd40ab0c..52fd04ec65 100644 --- a/data/maps/SlateportCity_Harbor/scripts.inc +++ b/data/maps/SlateportCity_Harbor/scripts.inc @@ -228,7 +228,7 @@ SlateportCity_Harbor_EventScript_BoardFerry:: call_if_eq VAR_FACING, DIR_NORTH, SlateportCity_Harbor_EventScript_BoardFerryNorth call_if_eq VAR_FACING, DIR_EAST, SlateportCity_Harbor_EventScript_BoardFerryEast delay 30 - hideobjectat LOCALID_PLAYER, 0 + hideplayer setvar VAR_0x8004, LOCALID_SLATEPORT_HARBOR_SS_TIDAL call Common_EventScript_FerryDepart return diff --git a/data/scripts/cable_club.inc b/data/scripts/cable_club.inc index 68d619097f..a6a13fe940 100644 --- a/data/scripts/cable_club.inc +++ b/data/scripts/cable_club.inc @@ -356,7 +356,7 @@ CableClub_EventScript_EnterColosseum:: waitdooranim applymovement LOCALID_PLAYER, Movement_PlayerEnterLinkRoom waitmovement 0 - hideobjectat LOCALID_PLAYER, 0 + hideplayer closedoor 9, 1 waitdooranim release @@ -450,7 +450,7 @@ CableClub_EventScript_EnterTradeCenter:: waitdooranim applymovement LOCALID_PLAYER, Movement_PlayerEnterLinkRoom waitmovement 0 - hideobjectat LOCALID_PLAYER, 0 + hideplayer closedoor 9, 1 waitdooranim release @@ -515,7 +515,7 @@ CableClub_EventScript_EnterRecordCorner:: waitdooranim applymovement LOCALID_PLAYER, Movement_PlayerEnterLinkRoom waitmovement 0 - hideobjectat LOCALID_PLAYER, 0 + hideplayer closedoor 9, 1 waitdooranim release @@ -902,7 +902,7 @@ CableClub_EventScript_EnterUnionRoom:: waitdooranim applymovement LOCALID_PLAYER, Movement_PlayerEnterLinkRoom waitmovement 0 - hideobjectat LOCALID_PLAYER, 0 + hideplayer closedoor 5, 1 waitdooranim special Script_ResetUnionRoomTrade @@ -1202,7 +1202,7 @@ CableClub_EventScript_EnterWirelessLinkRoom:: waitdooranim applymovement LOCALID_PLAYER, Movement_PlayerEnterLinkRoom waitmovement 0 - hideobjectat LOCALID_PLAYER, 0 + hideplayer closedoor 9, 1 waitdooranim release @@ -1380,7 +1380,7 @@ MossdeepCity_GameCorner_1F_EventScript_EnterMinigameRoom:: closemessage applymovement LOCALID_PLAYER, Movement_PlayerEnterMinigameRoom waitmovement 0 - hideobjectat LOCALID_PLAYER, 0 + hideplayer release waitstate end diff --git a/include/constants/maps.h b/include/constants/maps.h index d41f03c683..36e27d78b7 100644 --- a/include/constants/maps.h +++ b/include/constants/maps.h @@ -3,11 +3,14 @@ #include "map_groups.h" -// Warps using this map will instead use the warp data stored in gSaveBlock1Ptr->dynamicWarp. -// Used for warps that need to change destinations, e.g. when stepping off an elevator. -#define MAP_DYNAMIC (0x7F | (0x7F << 8)) +enum +{ + // Warps using this map will instead use the warp data stored in gSaveBlock1Ptr->dynamicWarp. + // Used for warps that need to change destinations, e.g. when stepping off an elevator. + MAP_DYNAMIC = (0x7F | (0x7F << 8)), -#define MAP_UNDEFINED (0xFF | (0xFF << 8)) + MAP_UNDEFINED = (0xFF | (0xFF << 8)), +}; #define MAP_GROUP(map) (map >> 8) #define MAP_NUM(map) (map & 0xFF) diff --git a/tools/mapjson/mapjson.cpp b/tools/mapjson/mapjson.cpp index 8d8ec4e4e6..5ceac10393 100644 --- a/tools/mapjson/mapjson.cpp +++ b/tools/mapjson/mapjson.cpp @@ -526,11 +526,13 @@ string generate_map_constants_text(string groups_filepath, Json groups_data) { ostringstream text; text << get_include_guard_start(guard_name) << get_generated_warning("data/maps/map_groups.json", false); + text << "enum\n{\n"; + int group_num = 0; for (auto &group : groups_data["group_order"].array_items()) { string groupName = json_to_string(group); - text << "// " << groupName << "\n"; + text << " // " << groupName << "\n"; vector map_ids; size_t max_length = 0; @@ -548,14 +550,16 @@ string generate_map_constants_text(string groups_filepath, Json groups_data) { int map_id_num = 0; for (string map_id : map_ids) { - text << "#define " << map_id << string((max_length - map_id.length() + 1), ' ') - << "(" << map_id_num++ << " | (" << group_num << " << 8))\n"; + text << " " << map_id << string(max_length - map_id.length(), ' ') + << " = (" << map_id_num++ << " | (" << group_num << " << 8)),\n"; } text << "\n"; group_num++; } + text << "};\n\n"; + text << "#define MAP_GROUPS_COUNT " << group_num << "\n\n"; text << get_include_guard_end(guard_name); From a10a824081a8040a8b776dd968c2f6234c8793c0 Mon Sep 17 00:00:00 2001 From: Zimmermann Gyula Date: Sat, 1 Nov 2025 13:06:49 +0100 Subject: [PATCH 10/16] Change magic number to constant in dexnav. (#8102) --- src/dexnav.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/dexnav.c b/src/dexnav.c index fe4b267a70..581178e940 100644 --- a/src/dexnav.c +++ b/src/dexnav.c @@ -1517,7 +1517,7 @@ static u8 GetEncounterLevelFromMapData(u16 species, enum EncounterType environme { u32 headerId = GetCurrentMapWildMonHeaderId(); enum TimeOfDay timeOfDay; - u8 min = 100; + u8 min = MAX_LEVEL; u8 max = 0; u8 i; From dba50c91eacddf7bfc856c8aaf70344c868f4b11 Mon Sep 17 00:00:00 2001 From: grintoul <166724814+grintoul1@users.noreply.github.com> Date: Sat, 1 Nov 2025 12:43:31 +0000 Subject: [PATCH 11/16] Aura Break tests (#8099) --- test/battle/ability/aura_break.c | 115 ++++++++++++++++++++++++++++++- 1 file changed, 112 insertions(+), 3 deletions(-) diff --git a/test/battle/ability/aura_break.c b/test/battle/ability/aura_break.c index 93b21421e4..389ab327b1 100644 --- a/test/battle/ability/aura_break.c +++ b/test/battle/ability/aura_break.c @@ -1,6 +1,115 @@ #include "global.h" #include "test/battle.h" -TO_DO_BATTLE_TEST("Aura Break inverts Fairy Aura's effect"); -TO_DO_BATTLE_TEST("Aura Break inverts Dark Aura's effect"); -TO_DO_BATTLE_TEST("Aura Break ignores Mold Breaker abilities"); +DOUBLE_BATTLE_TEST("Aura Break inverts Fairy Aura's effect") +{ + s16 damage[3]; + + GIVEN { + PLAYER(SPECIES_WOBBUFFET); + PLAYER(SPECIES_WOBBUFFET); + PLAYER(SPECIES_XERNEAS) { Ability(ABILITY_FAIRY_AURA); } + OPPONENT(SPECIES_WOBBUFFET); + OPPONENT(SPECIES_WOBBUFFET); + OPPONENT(SPECIES_ZYGARDE_50) { Ability(ABILITY_AURA_BREAK); } + } WHEN { + TURN { MOVE(playerLeft, MOVE_PLAY_ROUGH, target:opponentLeft); } + TURN { MOVE(playerLeft, MOVE_PLAY_ROUGH, target:opponentLeft); SWITCH(playerRight, 2); } + TURN { MOVE(playerLeft, MOVE_PLAY_ROUGH, target:opponentLeft); SWITCH(opponentRight, 2); } + } SCENE { + ANIMATION(ANIM_TYPE_MOVE, MOVE_PLAY_ROUGH, playerLeft); + HP_BAR(opponentLeft, captureDamage: &damage[0]); + + ANIMATION(ANIM_TYPE_MOVE, MOVE_PLAY_ROUGH, playerLeft); + HP_BAR(opponentLeft, captureDamage: &damage[1]); + + ANIMATION(ANIM_TYPE_MOVE, MOVE_PLAY_ROUGH, playerLeft); + HP_BAR(opponentLeft, captureDamage: &damage[2]); + + } THEN { + EXPECT_MUL_EQ(damage[0], UQ_4_12(1.33), damage[1]); + EXPECT_MUL_EQ(damage[0], UQ_4_12(0.75), damage[2]); + } +} + +DOUBLE_BATTLE_TEST("Aura Break inverts Dark Aura's effect") +{ + s16 damage[3]; + + GIVEN { + PLAYER(SPECIES_WOBBUFFET); + PLAYER(SPECIES_WOBBUFFET); + PLAYER(SPECIES_YVELTAL) { Ability(ABILITY_DARK_AURA); } + OPPONENT(SPECIES_WOBBUFFET); + OPPONENT(SPECIES_WOBBUFFET); + OPPONENT(SPECIES_ZYGARDE_50) { Ability(ABILITY_AURA_BREAK); } + } WHEN { + TURN { MOVE(playerLeft, MOVE_BITE, target:opponentLeft); } + TURN { MOVE(playerLeft, MOVE_BITE, target:opponentLeft); SWITCH(playerRight, 2); } + TURN { MOVE(playerLeft, MOVE_BITE, target:opponentLeft); SWITCH(opponentRight, 2); } + } SCENE { + ANIMATION(ANIM_TYPE_MOVE, MOVE_BITE, playerLeft); + HP_BAR(opponentLeft, captureDamage: &damage[0]); + + ANIMATION(ANIM_TYPE_MOVE, MOVE_BITE, playerLeft); + HP_BAR(opponentLeft, captureDamage: &damage[1]); + + ANIMATION(ANIM_TYPE_MOVE, MOVE_BITE, playerLeft); + HP_BAR(opponentLeft, captureDamage: &damage[2]); + + } THEN { + EXPECT_MUL_EQ(damage[0], UQ_4_12(1.33), damage[1]); + EXPECT_MUL_EQ(damage[0], UQ_4_12(0.75), damage[2]); + } +} + +DOUBLE_BATTLE_TEST("Aura Break ignores Mold Breaker abilities") +{ + s16 damage[6]; + u32 species = SPECIES_WOBBUFFET, ability = ABILITY_NONE; + + PARAMETRIZE { species = SPECIES_WOBBUFFET, ability = ABILITY_SHADOW_TAG; } + PARAMETRIZE { species = SPECIES_CRANIDOS, ability = ABILITY_MOLD_BREAKER; } + PARAMETRIZE { species = SPECIES_ZEKROM, ability = ABILITY_TERAVOLT; } + PARAMETRIZE { species = SPECIES_RESHIRAM, ability = ABILITY_TURBOBLAZE; } + + GIVEN { + PLAYER(species) { Ability(ability); Level(50); } + PLAYER(SPECIES_WOBBUFFET); + PLAYER(SPECIES_YVELTAL) { Ability(ABILITY_DARK_AURA); } + PLAYER(SPECIES_XERNEAS) { Ability(ABILITY_FAIRY_AURA); } + OPPONENT(SPECIES_WOBBUFFET); + OPPONENT(SPECIES_WOBBUFFET); + OPPONENT(SPECIES_ZYGARDE_50) { Ability(ABILITY_AURA_BREAK); } + } WHEN { + TURN { MOVE(playerLeft, MOVE_BITE, target: opponentLeft); } + TURN { MOVE(playerLeft, MOVE_PLAY_ROUGH, target: opponentLeft); } + TURN { MOVE(playerLeft, MOVE_BITE, target: opponentLeft); SWITCH(playerRight, 2); } + TURN { MOVE(playerLeft, MOVE_PLAY_ROUGH, target: opponentLeft); SWITCH(playerRight, 3); } + TURN { MOVE(playerLeft, MOVE_BITE, target: opponentLeft); SWITCH(playerRight, 2); SWITCH(opponentRight, 2); } + TURN { MOVE(playerLeft, MOVE_PLAY_ROUGH, target: opponentLeft); SWITCH(playerRight, 3); } + } SCENE { + ANIMATION(ANIM_TYPE_MOVE, MOVE_BITE, playerLeft); + HP_BAR(opponentLeft, captureDamage: &damage[0]); + + ANIMATION(ANIM_TYPE_MOVE, MOVE_PLAY_ROUGH, playerLeft); + HP_BAR(opponentLeft, captureDamage: &damage[1]); + + ANIMATION(ANIM_TYPE_MOVE, MOVE_BITE, playerLeft); + HP_BAR(opponentLeft, captureDamage: &damage[2]); + + ANIMATION(ANIM_TYPE_MOVE, MOVE_PLAY_ROUGH, playerLeft); + HP_BAR(opponentLeft, captureDamage: &damage[3]); + + ANIMATION(ANIM_TYPE_MOVE, MOVE_BITE, playerLeft); + HP_BAR(opponentLeft, captureDamage: &damage[4]); + + ANIMATION(ANIM_TYPE_MOVE, MOVE_PLAY_ROUGH, playerLeft); + HP_BAR(opponentLeft, captureDamage: &damage[5]); + } THEN { + EXPECT_MUL_EQ(damage[0], UQ_4_12(1.33), damage[2]); + EXPECT_MUL_EQ(damage[0], UQ_4_12(0.75), damage[4]); + EXPECT_MUL_EQ(damage[1], UQ_4_12(1.33), damage[3]); + EXPECT_MUL_EQ(damage[1], UQ_4_12(0.75), damage[5]); + } +} From 47a1704391ccd5b953c9bfdd2bd30df94c57e236 Mon Sep 17 00:00:00 2001 From: Alex <93446519+AlexOn1ine@users.noreply.github.com> Date: Sat, 1 Nov 2025 15:48:56 +0100 Subject: [PATCH 12/16] Fix docs compile issue (#8101) --- docs/book.toml | 1 - 1 file changed, 1 deletion(-) diff --git a/docs/book.toml b/docs/book.toml index 3282d8c8e7..a1e994eff3 100644 --- a/docs/book.toml +++ b/docs/book.toml @@ -1,6 +1,5 @@ [book] language = "en" -multilingual = false src = "." title = "pokeemerald-expansion" From 3fb472777baa4a4c8d89153b8130223d7bb2805d Mon Sep 17 00:00:00 2001 From: Alex <93446519+AlexOn1ine@users.noreply.github.com> Date: Sat, 1 Nov 2025 16:51:37 +0100 Subject: [PATCH 13/16] Reverts wrongly applies fix to book.toml (#8105) --- docs/book.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/book.toml b/docs/book.toml index a1e994eff3..3282d8c8e7 100644 --- a/docs/book.toml +++ b/docs/book.toml @@ -1,5 +1,6 @@ [book] language = "en" +multilingual = false src = "." title = "pokeemerald-expansion" From dd1b0b306743296e3f0d46749a3bbb3a64763fdb Mon Sep 17 00:00:00 2001 From: Alex <93446519+AlexOn1ine@users.noreply.github.com> Date: Sat, 1 Nov 2025 19:39:28 +0100 Subject: [PATCH 14/16] Initialize DamageContext struct with zero values Also forgot to initialize the struct in `Cmd_damagecalc` --- src/battle_script_commands.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 353d0e16e7..bc4e8d6551 100755 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -1806,7 +1806,7 @@ static void Cmd_damagecalc(void) u32 moveTarget = GetBattlerMoveTargetType(gBattlerAttacker, gCurrentMove); - struct DamageContext ctx; + struct DamageContext ctx = {0}; ctx.battlerAtk = gBattlerAttacker; ctx.move = gCurrentMove; ctx.moveType = GetBattleMoveType(gCurrentMove); From f969c126b1f74a799f98f0bb9551b737abe812eb Mon Sep 17 00:00:00 2001 From: Hedara Date: Sat, 1 Nov 2025 21:51:06 +0100 Subject: [PATCH 15/16] 1.13.3 release version --- .../ISSUE_TEMPLATE/01_battle_engine_bugs.yaml | 3 +- .../ISSUE_TEMPLATE/02_battle_ai_issues.yaml | 3 +- .github/ISSUE_TEMPLATE/04_other_errors.yaml | 3 +- README.md | 2 +- docs/SUMMARY.md | 1 + docs/changelogs/1.13.x/1.13.3.md | 193 ++++++++++++++++++ include/constants/expansion.h | 4 +- 7 files changed, 203 insertions(+), 6 deletions(-) create mode 100644 docs/changelogs/1.13.x/1.13.3.md diff --git a/.github/ISSUE_TEMPLATE/01_battle_engine_bugs.yaml b/.github/ISSUE_TEMPLATE/01_battle_engine_bugs.yaml index 56368ef27c..4564bad007 100644 --- a/.github/ISSUE_TEMPLATE/01_battle_engine_bugs.yaml +++ b/.github/ISSUE_TEMPLATE/01_battle_engine_bugs.yaml @@ -43,9 +43,10 @@ body: label: Version description: What version of pokeemerald-expansion are you using? options: - - 1.13.2 (Latest release) + - 1.13.3 (Latest release) - master (default, unreleased bugfixes) - upcoming (Edge) + - 1.13.2 - 1.13.1 - 1.13.0 - 1.12.3 diff --git a/.github/ISSUE_TEMPLATE/02_battle_ai_issues.yaml b/.github/ISSUE_TEMPLATE/02_battle_ai_issues.yaml index 06c55598d6..8ee1d1cc17 100644 --- a/.github/ISSUE_TEMPLATE/02_battle_ai_issues.yaml +++ b/.github/ISSUE_TEMPLATE/02_battle_ai_issues.yaml @@ -43,9 +43,10 @@ body: label: Version description: What version of pokeemerald-expansion are you using? options: - - 1.13.2 (Latest release) + - 1.13.3 (Latest release) - master (default, unreleased bugfixes) - upcoming (Edge) + - 1.13.2 - 1.13.1 - 1.13.0 - 1.12.3 diff --git a/.github/ISSUE_TEMPLATE/04_other_errors.yaml b/.github/ISSUE_TEMPLATE/04_other_errors.yaml index 56cfecf33a..5791967807 100644 --- a/.github/ISSUE_TEMPLATE/04_other_errors.yaml +++ b/.github/ISSUE_TEMPLATE/04_other_errors.yaml @@ -43,9 +43,10 @@ body: label: Version description: What version of pokeemerald-expansion are you using? options: - - 1.13.2 (Latest release) + - 1.13.3 (Latest release) - master (default, unreleased bugfixes) - upcoming (Edge) + - 1.13.2 - 1.13.1 - 1.13.0 - 1.12.3 diff --git a/README.md b/README.md index 8f9088a6e8..2389dfe26a 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ If you use **`pokeemerald-expansion`**, please credit **RHH (Rom Hacking Hideout)**. Optionally, include the version number for clarity. ``` -Based off RHH's pokeemerald-expansion 1.13.2 https://github.com/rh-hideout/pokeemerald-expansion/ +Based off RHH's pokeemerald-expansion 1.13.3 https://github.com/rh-hideout/pokeemerald-expansion/ ``` Please consider [crediting all contributors](CREDITS.md) involved in the project! diff --git a/docs/SUMMARY.md b/docs/SUMMARY.md index 7f20718f30..8d1e4e9cdb 100644 --- a/docs/SUMMARY.md +++ b/docs/SUMMARY.md @@ -39,6 +39,7 @@ - [How to use Trainer Party Pools](tutorials/how_to_trainer_party_pool.md) - [Changelog](./CHANGELOG.md) - [1.13.x]() + - [Version 1.13.3](changelogs/1.13.x/1.13.3.md) - [Version 1.13.2](changelogs/1.13.x/1.13.2.md) - [Version 1.13.1](changelogs/1.13.x/1.13.1.md) - [Version 1.13.0](changelogs/1.13.x/1.13.0.md) diff --git a/docs/changelogs/1.13.x/1.13.3.md b/docs/changelogs/1.13.x/1.13.3.md new file mode 100644 index 0000000000..70e1830ff4 --- /dev/null +++ b/docs/changelogs/1.13.x/1.13.3.md @@ -0,0 +1,193 @@ +```md +## How to update +- If you haven't set up a remote, run the command `git remote add RHH https://github.com/rh-hideout/pokeemerald-expansion`. +- Once you have your remote set up, run the command `git pull RHH expansion/1.13.3 +`. +``` + + +## 🧬 General 🧬 +### Added +* Add test to detect save file shifting by @Bassoonian in [#8030](https://github.com/rh-hideout/pokeemerald-expansion/pull/8030) + +### Changed +* 1.13.2 release by @hedara90 in [#7831](https://github.com/rh-hideout/pokeemerald-expansion/pull/7831) +* Remove unnecessary EWRAM and IWRAM variables from the Window code by @estellarc in [#7897](https://github.com/rh-hideout/pokeemerald-expansion/pull/7897) +* Replace magic numbers with define'd values in field_player_avatar.c by @FosterProgramming in [#7910](https://github.com/rh-hideout/pokeemerald-expansion/pull/7910) +* Pret merge (1st of November, 2025) by @hedara90 in [#8103](https://github.com/rh-hideout/pokeemerald-expansion/pull/8103) + +### Fixed +* Fixes `EVO_BATTLE_END` evolutions not removing item with additional conditions by @PhallenTree in [#7841](https://github.com/rh-hideout/pokeemerald-expansion/pull/7841) +* Fix EV display in debug menu by @cawtds in [#7848](https://github.com/rh-hideout/pokeemerald-expansion/pull/7848) +* Fix right player position battle partner target display by @ravepossum in [#7878](https://github.com/rh-hideout/pokeemerald-expansion/pull/7878) +* Ensure last used ball and move description window sprites don't free palette too early by @ravepossum in [#7875](https://github.com/rh-hideout/pokeemerald-expansion/pull/7875) +* Fix fusion pokemon aquiring illegal movesets by @FosterProgramming in [#7896](https://github.com/rh-hideout/pokeemerald-expansion/pull/7896) + - Calyrex will now delete moves if they are not part of its learnset when unfusing + - Kyurem will now properly swap the moves Glaciate and Scary Face to its signature moves when fusing/unfusing +* Fix bug causing hgss dex to freeze by @FosterProgramming in [#7936](https://github.com/rh-hideout/pokeemerald-expansion/pull/7936) + - Fix a bug when checking evolutions info screen while search mode is active in the hgss dex +* Show convergent evolution to Gholdengo in HGSS dex by @FosterProgramming in [#7934](https://github.com/rh-hideout/pokeemerald-expansion/pull/7934) +* Fix HGSS dex sprites for gen9+ by @FosterProgramming in [#7922](https://github.com/rh-hideout/pokeemerald-expansion/pull/7922) +* Fix nicknames containing many / overflowing the party screen textbox by @hedara90 in [#7970](https://github.com/rh-hideout/pokeemerald-expansion/pull/7970) +* Fix ruination and nature's madness damage percentage by @FosterProgramming in [#7983](https://github.com/rh-hideout/pokeemerald-expansion/pull/7983) +* Fix ribbon colours by @hedara90 in [#7971](https://github.com/rh-hideout/pokeemerald-expansion/pull/7971) +* Fix long pokemon name in partner party not appearing properly by @FosterProgramming in [#8009](https://github.com/rh-hideout/pokeemerald-expansion/pull/8009) +* Fix battle dome bug (again) by @FosterProgramming in [#8007](https://github.com/rh-hideout/pokeemerald-expansion/pull/8007) +* Fix battle arena counting all judges loss for the opponent by @FosterProgramming in [#8046](https://github.com/rh-hideout/pokeemerald-expansion/pull/8046) + - Fix battle arena referees giving undeserved wins to the player +* Fix wrong gimmick spite showing when inputting too fast by @FosterProgramming in [#8066](https://github.com/rh-hideout/pokeemerald-expansion/pull/8066) + +## 🗺️ Overworld 🗺️ +### Fixed +* Fix LTO breaking with FREE_MYSTERY_GIFT set to TRUE by @DizzyEggg in [#7844](https://github.com/rh-hideout/pokeemerald-expansion/pull/7844) +* Fix dns palette weight by @FosterProgramming in [#7855](https://github.com/rh-hideout/pokeemerald-expansion/pull/7855) +* Bug Fix: NPC follower not inheriting facing direction upon creation by @Bivurnum in [#7895](https://github.com/rh-hideout/pokeemerald-expansion/pull/7895) +* Fix follower pokemon not playing animation when colliding by @FosterProgramming in [#7908](https://github.com/rh-hideout/pokeemerald-expansion/pull/7908) +* Fix incorrect font width in Dexnav search window hiding some elements by @FosterProgramming in [#7949](https://github.com/rh-hideout/pokeemerald-expansion/pull/7949) +* Fix dns color transition not applying weather blending by @FosterProgramming in [#7883](https://github.com/rh-hideout/pokeemerald-expansion/pull/7883) +* Fix follower NPC sidewaystair movement by @FosterProgramming in [#7909](https://github.com/rh-hideout/pokeemerald-expansion/pull/7909) +* Fix battle dome pre round 1 waiting room by @FosterProgramming in [#7976](https://github.com/rh-hideout/pokeemerald-expansion/pull/7976) +* Fix no_effect script command overwriting trainer data in trainer script by @FosterProgramming in [#7978](https://github.com/rh-hideout/pokeemerald-expansion/pull/7978) +* Setting wallclock time now properly sets fakeRTC by @FosterProgramming in [#7860](https://github.com/rh-hideout/pokeemerald-expansion/pull/7860) + - Fix time bug when setting wallclock in fakeRTC mode + - When setting the wall clock, it will start on current time instead of 10AM + - If FakeRTC is active, new game will start at 10AM +* Bugfix hidefollower not waiting properly by @FosterProgramming in [#7768](https://github.com/rh-hideout/pokeemerald-expansion/pull/7768) +* Bugfix Emotes not loading their palette by @estellarc in [#7843](https://github.com/rh-hideout/pokeemerald-expansion/pull/7843) +* Fix OW Pokémon VObjects by @HashtagMarky in [#7991](https://github.com/rh-hideout/pokeemerald-expansion/pull/7991) +* fix: hypertraining a stat now optionally reflects in the summary screen by @khbsd in [#8035](https://github.com/rh-hideout/pokeemerald-expansion/pull/8035) +* Fix pc turning on/off animation not working in battle frontier by @FosterProgramming in [#8048](https://github.com/rh-hideout/pokeemerald-expansion/pull/8048) +* Fix non-battle trainer script not running properly by @FosterProgramming in [#8056](https://github.com/rh-hideout/pokeemerald-expansion/pull/8056) + +## 🐉 Pokémon 🐉 +### Fixed +* Fixes shininess for givemon by @cawtds in [#7847](https://github.com/rh-hideout/pokeemerald-expansion/pull/7847) +* Fix Minior start of battle form by @hedara90 in [#7972](https://github.com/rh-hideout/pokeemerald-expansion/pull/7972) +* Add error messages for trying to send an illegal mon to the PC and fixes index in double wild battles by @hedara90 in [#7982](https://github.com/rh-hideout/pokeemerald-expansion/pull/7982) +* fix: hypertraining a stat now optionally reflects in the summary screen by @khbsd in [#8035](https://github.com/rh-hideout/pokeemerald-expansion/pull/8035) +* Add camera-facing right-walking Krabby and Kingler follower sprites by @rayrobdod in [#7881](https://github.com/rh-hideout/pokeemerald-expansion/pull/7881) + +## ⚔️ Battle General ⚔️ +### Changed +* Tests for Battery ability by @grintoul1 in [#7846](https://github.com/rh-hideout/pokeemerald-expansion/pull/7846) +* Aura Break tests by @grintoul1 in [#8099](https://github.com/rh-hideout/pokeemerald-expansion/pull/8099) + +### Fixed +* Fixes Endure lasting forever by @AlexOn1ine in [#7838](https://github.com/rh-hideout/pokeemerald-expansion/pull/7838) +* Fix for uncaught mon with terrain active by @DizzyEggg in [#7868](https://github.com/rh-hideout/pokeemerald-expansion/pull/7868) +* Fixes Steadfast not activating + tests by @PhallenTree in [#7886](https://github.com/rh-hideout/pokeemerald-expansion/pull/7886) +* Fix hgss pokedex when catching mon with terrain by @DizzyEggg in [#7884](https://github.com/rh-hideout/pokeemerald-expansion/pull/7884) +* Fix SmartStrike crashing the game in double battles by @DizzyEggg in [#7902](https://github.com/rh-hideout/pokeemerald-expansion/pull/7902) +* Fix palaceUnableToUseMove falling through to change battle script by @ghoulslash in [#7912](https://github.com/rh-hideout/pokeemerald-expansion/pull/7912) +* Add new Move target types to GetBattlePalaceMoveGroup by @ghoulslash in [#7913](https://github.com/rh-hideout/pokeemerald-expansion/pull/7913) +* Fixes 2 instances of global usage in the `Cmd_adjustdamage` loop by @AlexOn1ine in [#7918](https://github.com/rh-hideout/pokeemerald-expansion/pull/7918) +* Fix Battle Anim monbg calls Part 1 by @ghoulslash in [#7906](https://github.com/rh-hideout/pokeemerald-expansion/pull/7906) +* Adds missing breakable flag for Bulletproof by @AlexOn1ine in [#7928](https://github.com/rh-hideout/pokeemerald-expansion/pull/7928) +* Fix multiple battle arena bugs by @FosterProgramming in [#7941](https://github.com/rh-hideout/pokeemerald-expansion/pull/7941) +* Fixes Cursed Body failing to disable moves on the last PP by @PhallenTree in [#7940](https://github.com/rh-hideout/pokeemerald-expansion/pull/7940) +* Fixed an issue related to Pokemon animation bleeding into attack anim… by @LinathanZel in [#7924](https://github.com/rh-hideout/pokeemerald-expansion/pull/7924) +* Fixes terrain not failing on duplicate by @AlexOn1ine in [#7939](https://github.com/rh-hideout/pokeemerald-expansion/pull/7939) +* Fix volt tackle not inflicting recoil by @FosterProgramming in [#7944](https://github.com/rh-hideout/pokeemerald-expansion/pull/7944) +* Fix Knock Off not being restored and Wild Battles by @ghoulslash in [#7952](https://github.com/rh-hideout/pokeemerald-expansion/pull/7952) +* Fix Anticipation type effectiveness check by @spindrift64 in [#7840](https://github.com/rh-hideout/pokeemerald-expansion/pull/7840) +* Fix Cherim and Castfrom not reverting to baseform when Teraform Zero is triggered by @FosterProgramming in [#7961](https://github.com/rh-hideout/pokeemerald-expansion/pull/7961) +* Fix Focus Energy boosting crit by the wrong amount with gen1 crit chance by @FosterProgramming in [#7956](https://github.com/rh-hideout/pokeemerald-expansion/pull/7956) +* Fix bug where transformed pokemon lose copied stats on levelup by @FosterProgramming in [#7969](https://github.com/rh-hideout/pokeemerald-expansion/pull/7969) +* Fixes Shields Down incorrectly preventing status on Minior Core form by @PhallenTree in [#7968](https://github.com/rh-hideout/pokeemerald-expansion/pull/7968) +* SetShellSideArmCategory avoid div by zero by @DizzyEggg in [#7980](https://github.com/rh-hideout/pokeemerald-expansion/pull/7980) +* CalcBarFilledPixels Safe Div by @DizzyEggg in [#7979](https://github.com/rh-hideout/pokeemerald-expansion/pull/7979) +* Fix psychic terrain affecting semi-invulnerable mons by @FosterProgramming in [#7986](https://github.com/rh-hideout/pokeemerald-expansion/pull/7986) +* Fixes Terrain Extender timer by @AlexOn1ine in [#7995](https://github.com/rh-hideout/pokeemerald-expansion/pull/7995) +* Fixed Max Move in-battle descriptions by @AsparagusEduardo in [#8004](https://github.com/rh-hideout/pokeemerald-expansion/pull/8004) +* Fixes Echoed Voice base power increase depending on attacker's use of the move by @PhallenTree in [#7997](https://github.com/rh-hideout/pokeemerald-expansion/pull/7997) +* Fixed Stomping Tantrum not doubling in damage if the user failed Protect by @AsparagusEduardo in [#8008](https://github.com/rh-hideout/pokeemerald-expansion/pull/8008) +* Fix badge boost not applying in gen1 and 2 by @FosterProgramming in [#8013](https://github.com/rh-hideout/pokeemerald-expansion/pull/8013) +* Fix toxic debris setting hazards on the wrong side when hit by an ally by @FosterProgramming in [#8026](https://github.com/rh-hideout/pokeemerald-expansion/pull/8026) +* Adds missing alive check for Rapid Spin by @AlexOn1ine in [#8024](https://github.com/rh-hideout/pokeemerald-expansion/pull/8024) +* Fixes visual glitch after Misty Explosion by @AlexOn1ine in [#8022](https://github.com/rh-hideout/pokeemerald-expansion/pull/8022) +* Fixes Protosynthesis not activating after weather was reset by @AlexOn1ine in [#8021](https://github.com/rh-hideout/pokeemerald-expansion/pull/8021) +* Fix Salt Cure script by @AlexOn1ine in [#8005](https://github.com/rh-hideout/pokeemerald-expansion/pull/8005) +* Fix emergency exit not triggering properly during wild battles by @FosterProgramming in [#8037](https://github.com/rh-hideout/pokeemerald-expansion/pull/8037) +* Fix target cancelling not working properly with z-move by @FosterProgramming in [#8067](https://github.com/rh-hideout/pokeemerald-expansion/pull/8067) +* Corrects battler partner identification in battle_ai_switch_items.c by @grintoul1 in [#8071](https://github.com/rh-hideout/pokeemerald-expansion/pull/8071) +* Fix Ally Switch being useable in Frontier Link Multi battles by @grintoul1 in [#8059](https://github.com/rh-hideout/pokeemerald-expansion/pull/8059) +* Fixes hazards and switch-in items not being reset when switching in by @PhallenTree in [#8074](https://github.com/rh-hideout/pokeemerald-expansion/pull/8074) +* Fixes Liquid Ooze dmg not blocked by Magic Guard by @AlexOn1ine in [#8036](https://github.com/rh-hideout/pokeemerald-expansion/pull/8036) +* Fix move description prompt window not appear when choosing a move after canceling target selection by @FosterProgramming in [#8055](https://github.com/rh-hideout/pokeemerald-expansion/pull/8055) +* Initialize DamageContext on declaration to zero by @AlexOn1ine in [#8076](https://github.com/rh-hideout/pokeemerald-expansion/pull/8076) +* Fixed Hunger Switch changing forms on switch out while Tera'd by @AsparagusEduardo in [#8080](https://github.com/rh-hideout/pokeemerald-expansion/pull/8080) +* Fixes Gooey/Tangling Hair ability pop up triggering on Clear Body by @AlexOn1ine in [#8083](https://github.com/rh-hideout/pokeemerald-expansion/pull/8083) +* Fixes intimidate activating on empty field by @AlexOn1ine in [#8058](https://github.com/rh-hideout/pokeemerald-expansion/pull/8058) +* Fix bug where mon selection doesn't properly account for party order by @FosterProgramming in [#8088](https://github.com/rh-hideout/pokeemerald-expansion/pull/8088) +* Fix bug when a captured pokemon replaces a party member who changed forms by @FosterProgramming in [#8091](https://github.com/rh-hideout/pokeemerald-expansion/pull/8091) +* Fixed Zygarde Complete disappearing upon catch by @AsparagusEduardo in [#8089](https://github.com/rh-hideout/pokeemerald-expansion/pull/8089) +* Initialize DamageContext struct with zero values by @AlexOn1ine in [#8107](https://github.com/rh-hideout/pokeemerald-expansion/pull/8107) + +## 🤹 Moves 🤹 +### Fixed +* Updated Mountain Gale's PP for Gen 9 by @fdeblasio in [#7856](https://github.com/rh-hideout/pokeemerald-expansion/pull/7856) +* Fix Brine move anim and document Water Spout anim by @ravepossum in [#7865](https://github.com/rh-hideout/pokeemerald-expansion/pull/7865) +* Add Struggle tests, weakness berry tests and prevent Struggle from activating Silk Scarf and Chilan Berry by @rayrobdod in [#7880](https://github.com/rh-hideout/pokeemerald-expansion/pull/7880) +* Fix Battle Anim monbg calls Part 1 by @ghoulslash in [#7906](https://github.com/rh-hideout/pokeemerald-expansion/pull/7906) +* Add missing end signal for AnimTask_SetAttackerInvisibleWaitForSignal by @hedara90 in [#7950](https://github.com/rh-hideout/pokeemerald-expansion/pull/7950) +* Fix Ally Switch being useable in Frontier Link Multi battles by @grintoul1 in [#8059](https://github.com/rh-hideout/pokeemerald-expansion/pull/8059) +* Fixed Belly Drum/Contrary interaction at max Attack by @AsparagusEduardo in [#8078](https://github.com/rh-hideout/pokeemerald-expansion/pull/8078) + +## 🎭 Abilities 🎭 +### Changed +* Tests for Battery ability by @grintoul1 in [#7846](https://github.com/rh-hideout/pokeemerald-expansion/pull/7846) +* Aura Break tests by @grintoul1 in [#8099](https://github.com/rh-hideout/pokeemerald-expansion/pull/8099) + +## 🧶 Items 🧶 +### Fixed +* Add gBallItemIds Array by @HashtagMarky in [#7905](https://github.com/rh-hideout/pokeemerald-expansion/pull/7905) +* Fix Persim Berry battle usage by @hedara90 in [#7963](https://github.com/rh-hideout/pokeemerald-expansion/pull/7963) + +## 🤖 Battle AI 🤖 +### Fixed +* Add failsafe to AI_DecideHoldEffectForTurn by @AlexOn1ine in [#7849](https://github.com/rh-hideout/pokeemerald-expansion/pull/7849) +* Fix some ai action check happening before the logic was computed by @FosterProgramming in [#7867](https://github.com/rh-hideout/pokeemerald-expansion/pull/7867) + - Roamers will now flee in the first turn of battle +* Fix ShouldPivot overwriting random memory by @DizzyEggg in [#7882](https://github.com/rh-hideout/pokeemerald-expansion/pull/7882) +* Fix AI seeing priority wrong for players choice lock by @MaximeGr00 in [#7899](https://github.com/rh-hideout/pokeemerald-expansion/pull/7899) +* fix (post-KO switch): force AI data recalc to see abilities on field correctly when pivot moves used by player by @ghostyboyy97 in [#7900](https://github.com/rh-hideout/pokeemerald-expansion/pull/7900) +* Add missing break to Power Split AI case by @ghoulslash in [#7959](https://github.com/rh-hideout/pokeemerald-expansion/pull/7959) + +## 🧹 Other Cleanup 🧹 +* Fix some failed and assume fail tests with `GEN_LATEST` = `GEN_5` by @AsparagusEduardo in [#7735](https://github.com/rh-hideout/pokeemerald-expansion/pull/7735) +* Update INSTALL.md by @RubyRaven6 in [#7852](https://github.com/rh-hideout/pokeemerald-expansion/pull/7852) +* Remove unnecessary EWRAM and IWRAM variables from the Window code by @estellarc in [#7897](https://github.com/rh-hideout/pokeemerald-expansion/pull/7897) +* Replace magic numbers with define'd values in field_player_avatar.c by @FosterProgramming in [#7910](https://github.com/rh-hideout/pokeemerald-expansion/pull/7910) +* Reverts wrongly applies fix to book.toml by @AlexOn1ine in [#8105](https://github.com/rh-hideout/pokeemerald-expansion/pull/8105) + +## 🧪 Test Runner 🧪 +### Changed +* Fix some failed and assume fail tests with `GEN_LATEST` = `GEN_5` by @AsparagusEduardo in [#7735](https://github.com/rh-hideout/pokeemerald-expansion/pull/7735) +* Tests for Battery ability by @grintoul1 in [#7846](https://github.com/rh-hideout/pokeemerald-expansion/pull/7846) +* Fixed fainting form change tests by @AsparagusEduardo in [#8079](https://github.com/rh-hideout/pokeemerald-expansion/pull/8079) +* Aura Break tests by @grintoul1 in [#8099](https://github.com/rh-hideout/pokeemerald-expansion/pull/8099) + +### Fixed +* Fix Knock Off not being restored and Wild Battles by @ghoulslash in [#7952](https://github.com/rh-hideout/pokeemerald-expansion/pull/7952) +* Fixes Shields Down incorrectly preventing status on Minior Core form by @PhallenTree in [#7968](https://github.com/rh-hideout/pokeemerald-expansion/pull/7968) +* Fixed Stomping Tantrum not doubling in damage if the user failed Protect by @AsparagusEduardo in [#8008](https://github.com/rh-hideout/pokeemerald-expansion/pull/8008) +* Fix stats defined in tests being overwritteng by stat change by @FosterProgramming in [#8018](https://github.com/rh-hideout/pokeemerald-expansion/pull/8018) + +## 📚 Documentation 📚 +* Update INSTALL.md by @RubyRaven6 in [#7852](https://github.com/rh-hideout/pokeemerald-expansion/pull/7852) +* Updated PR template to make existing credit policy clearer by @pkmnsnfrn in [#7864](https://github.com/rh-hideout/pokeemerald-expansion/pull/7864) +* Fix image links in doc site by @rayrobdod in [#7948](https://github.com/rh-hideout/pokeemerald-expansion/pull/7948) +* Add all pages in `docs` to doc website by @rayrobdod in [#7907](https://github.com/rh-hideout/pokeemerald-expansion/pull/7907) +* Relativize doc links, to fix links in docs site by @rayrobdod in [#7964](https://github.com/rh-hideout/pokeemerald-expansion/pull/7964) +* Fix docs compile issue by @AlexOn1ine in [#8101](https://github.com/rh-hideout/pokeemerald-expansion/pull/8101) +* Reverts wrongly applies fix to book.toml by @AlexOn1ine in [#8105](https://github.com/rh-hideout/pokeemerald-expansion/pull/8105) + +## New Contributors +* @HashtagMarky made their first contribution in [#7905](https://github.com/rh-hideout/pokeemerald-expansion/pull/7905) +* @MaximeGr00 made their first contribution in [#7899](https://github.com/rh-hideout/pokeemerald-expansion/pull/7899) + +**Full Changelog**: https://github.com/rh-hideout/pokeemerald-expansion/compare/expansion/1.13.2...expansion/1.13.3 + + + + diff --git a/include/constants/expansion.h b/include/constants/expansion.h index 92973512b2..52f97f7c31 100644 --- a/include/constants/expansion.h +++ b/include/constants/expansion.h @@ -1,13 +1,13 @@ #ifndef GUARD_CONSTANTS_EXPANSION_H #define GUARD_CONSTANTS_EXPANSION_H -// Last version: 1.13.2 +// Last version: 1.13.3 #define EXPANSION_VERSION_MAJOR 1 #define EXPANSION_VERSION_MINOR 13 #define EXPANSION_VERSION_PATCH 3 // FALSE if this this version of Expansion is not a tagged commit, i.e. // it contains unreleased changes. -#define EXPANSION_TAGGED_RELEASE FALSE +#define EXPANSION_TAGGED_RELEASE TRUE #endif From cfdbd19ea89593eace0432940a48a9b0273da7bd Mon Sep 17 00:00:00 2001 From: Hedara Date: Sat, 1 Nov 2025 21:51:24 +0100 Subject: [PATCH 16/16] Start of 1.13.4 cycle --- include/constants/expansion.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/constants/expansion.h b/include/constants/expansion.h index 52f97f7c31..1b9fba88a1 100644 --- a/include/constants/expansion.h +++ b/include/constants/expansion.h @@ -4,10 +4,10 @@ // Last version: 1.13.3 #define EXPANSION_VERSION_MAJOR 1 #define EXPANSION_VERSION_MINOR 13 -#define EXPANSION_VERSION_PATCH 3 +#define EXPANSION_VERSION_PATCH 4 // FALSE if this this version of Expansion is not a tagged commit, i.e. // it contains unreleased changes. -#define EXPANSION_TAGGED_RELEASE TRUE +#define EXPANSION_TAGGED_RELEASE FALSE #endif