diff --git a/data/scripts/debug.inc b/data/scripts/debug.inc index 72ace2512ab3..3e482c839104 100644 --- a/data/scripts/debug.inc +++ b/data/scripts/debug.inc @@ -206,4 +206,13 @@ DebugText_DaycareOnePokemon: DebugText_DaycarePokemonNotCompatible: .string "Your Pokémon at Daycare can't\nhave babies together!$" +Debug_ShowExpansionVersion:: + callnative BufferExpansionVersion + msgbox Debug_ExpansionVersion, MSGBOX_DEFAULT + release + end + +Debug_ExpansionVersion: + .string "pokeemerald-expansion {STR_VAR_1}$" + .endif diff --git a/include/constants/expansion.h b/include/constants/expansion.h new file mode 100644 index 000000000000..872e5bbd3414 --- /dev/null +++ b/include/constants/expansion.h @@ -0,0 +1,12 @@ +#ifndef GUARD_CONSTANTS_EXPANSION_H +#define GUARD_CONSTANTS_EXPANSION_H + +#define EXPANSION_VERSION_MAJOR 1 +#define EXPANSION_VERSION_MINOR 7 +#define EXPANSION_VERSION_PATCH 0 + +// FALSE if this this version of Expansion is not a tagged commit, i.e. +// it contains unreleased changes. +#define EXPANSION_TAGGED_RELEASE FALSE + +#endif diff --git a/ld_script.txt b/ld_script.txt index 27b340f49099..6b7d115b2295 100644 --- a/ld_script.txt +++ b/ld_script.txt @@ -52,6 +52,7 @@ SECTIONS { { src/rom_header.o(.text); src/rom_header_gf.o(.text.*); + src/rom_header_rhh.o(.text.*); src/crt0.o(.text); src/main.o(.text); gflib/malloc.o(.text); diff --git a/ld_script_modern.txt b/ld_script_modern.txt index ab68976661b1..7a14cfa52c3f 100644 --- a/ld_script_modern.txt +++ b/ld_script_modern.txt @@ -51,6 +51,7 @@ SECTIONS { { src/rom_header.o(.text*); src/rom_header_gf.o(.text.*); + src/rom_header_rhh.o(.text.*); src/crt0.o(.text); src/main.o(.text); gflib/*.o(.text*); diff --git a/ld_script_test.txt b/ld_script_test.txt index c7e19d7189d9..447d7a2b877a 100644 --- a/ld_script_test.txt +++ b/ld_script_test.txt @@ -62,6 +62,7 @@ SECTIONS { { src/rom_header.o(.text); src/rom_header_gf.o(.text.*); + src/rom_header_rhh.o(.text.*); src/*.o(.text); gflib/*.o(.text); } =0 diff --git a/src/debug.c b/src/debug.c index 822d1bb4723a..8489a265c027 100644 --- a/src/debug.c +++ b/src/debug.c @@ -55,6 +55,7 @@ #include "constants/battle_ai.h" #include "constants/battle_frontier.h" #include "constants/coins.h" +#include "constants/expansion.h" #include "constants/flags.h" #include "constants/items.h" #include "constants/map_groups.h" @@ -97,6 +98,7 @@ enum UtilMenu DEBUG_UTIL_MENU_ITEM_CLEAR_BOXES, DEBUG_UTIL_MENU_ITEM_CHEAT, DEBUG_UTIL_MENU_ITEM_HATCH_AN_EGG, + DEBUG_UTIL_MENU_ITEM_EXPANSION_VER, }; enum ScriptMenu @@ -339,6 +341,7 @@ static void DebugAction_Util_Player_Id(u8 taskId); static void DebugAction_Util_Clear_Boxes(u8 taskId); static void DebugAction_Util_CheatStart(u8 taskId); static void DebugAction_Util_HatchAnEgg(u8 taskId); +static void DebugAction_Util_ExpansionVersion(u8 taskId); static void DebugAction_FlagsVars_Flags(u8 taskId); static void DebugAction_FlagsVars_FlagsSelect(u8 taskId); @@ -418,6 +421,7 @@ extern const u8 PlayersHouse_2F_EventScript_CheckWallClock[]; extern const u8 Debug_CheckSaveBlock[]; extern const u8 Debug_CheckROMSpace[]; extern const u8 Debug_BoxFilledMessage[]; +extern const u8 Debug_ShowExpansionVersion[]; #include "data/map_group_count.h" @@ -471,6 +475,7 @@ static const u8 sDebugText_Util_Player_Id[] = _("New Trainer Id") static const u8 sDebugText_Util_Clear_Boxes[] = _("Clear Storage Boxes"); static const u8 sDebugText_Util_CheatStart[] = _("CHEAT Start"); static const u8 sDebugText_Util_HatchAnEgg[] = _("Hatch an Egg"); +static const u8 sDebugText_Util_ExpansionVersion[] = _("Expansion Version"); // Flags/Vars Menu static const u8 sDebugText_FlagsVars_Flags[] = _("Set Flag XYZ…{CLEAR_TO 110}{RIGHT_ARROW}"); static const u8 sDebugText_FlagsVars_Flag[] = _("Flag: {STR_VAR_1}{CLEAR_TO 90}\n{STR_VAR_2}{CLEAR_TO 90}\n{STR_VAR_3}"); @@ -637,6 +642,7 @@ static const struct ListMenuItem sDebugMenu_Items_Utilities[] = [DEBUG_UTIL_MENU_ITEM_CLEAR_BOXES] = {sDebugText_Util_Clear_Boxes, DEBUG_UTIL_MENU_ITEM_CLEAR_BOXES}, [DEBUG_UTIL_MENU_ITEM_CHEAT] = {sDebugText_Util_CheatStart, DEBUG_UTIL_MENU_ITEM_CHEAT}, [DEBUG_UTIL_MENU_ITEM_HATCH_AN_EGG] = {sDebugText_Util_HatchAnEgg, DEBUG_UTIL_MENU_ITEM_HATCH_AN_EGG}, + [DEBUG_UTIL_MENU_ITEM_EXPANSION_VER] = {sDebugText_Util_ExpansionVersion,DEBUG_UTIL_MENU_ITEM_EXPANSION_VER}, }; static const struct ListMenuItem sDebugMenu_Items_Scripts[] = @@ -780,6 +786,7 @@ static void (*const sDebugMenu_Actions_Utilities[])(u8) = [DEBUG_UTIL_MENU_ITEM_CLEAR_BOXES] = DebugAction_Util_Clear_Boxes, [DEBUG_UTIL_MENU_ITEM_CHEAT] = DebugAction_Util_CheatStart, [DEBUG_UTIL_MENU_ITEM_HATCH_AN_EGG] = DebugAction_Util_HatchAnEgg, + [DEBUG_UTIL_MENU_ITEM_EXPANSION_VER] = DebugAction_Util_ExpansionVersion, }; static void (*const sDebugMenu_Actions_Scripts[])(u8) = @@ -2122,6 +2129,30 @@ static void DebugAction_Util_HatchAnEgg(u8 taskId) Debug_DestroyMenu_Full_Script(taskId, Debug_HatchAnEgg); } +static void DebugAction_Util_ExpansionVersion(u8 taskId) +{ + Debug_DestroyMenu_Full(taskId); + LockPlayerFieldControls(); + ScriptContext_SetupScript(Debug_ShowExpansionVersion); +} + +void BufferExpansionVersion(struct ScriptContext *ctx) +{ + static const u8 sText_Released[] = _("\nRelease Build"); + static const u8 sText_Unreleased[] = _("\nDevelopment Build"); + u8 *string = gStringVar1; + *string++ = CHAR_v; + string = ConvertIntToDecimalStringN(string, EXPANSION_VERSION_MAJOR, STR_CONV_MODE_LEFT_ALIGN, 3); + *string++ = CHAR_PERIOD; + string = ConvertIntToDecimalStringN(string, EXPANSION_VERSION_MINOR, STR_CONV_MODE_LEFT_ALIGN, 3); + *string++ = CHAR_PERIOD; + string = ConvertIntToDecimalStringN(string, EXPANSION_VERSION_PATCH, STR_CONV_MODE_LEFT_ALIGN, 3); + if (EXPANSION_TAGGED_RELEASE) + string = StringCopy(string, sText_Released); + else + string = StringCopy(string, sText_Unreleased); +} + // ******************************* // Actions Scripts static void DebugAction_Util_Script_1(u8 taskId) diff --git a/src/rom_header_rhh.c b/src/rom_header_rhh.c new file mode 100644 index 000000000000..2e141670a744 --- /dev/null +++ b/src/rom_header_rhh.c @@ -0,0 +1,26 @@ +#include "global.h" +#include "constants/expansion.h" + +// Similar to the GF ROM header, this struct allows external programs to +// detect details about Expansion. +// For this structure to be useful we have to maintain backwards binary +// compatibility. This means that we should only ever append data to the +// end. If there are any structs as members then those structs should +// not be modified after being introduced. +struct RHHRomHeader +{ + /*0x00*/ char rhh_magic[6]; // 'RHHEXP'. Useful to locate the header if it shifts. + /*0x06*/ u8 expansionVersionMajor; + /*0x07*/ u8 expansionVersionMinor; + /*0x08*/ u8 expansionVersionPatch; + /*0x09*/ u8 expansionVersionFlags; +}; + +static const struct RHHRomHeader sRHHRomHeader = +{ + .rhh_magic = { 'R', 'H', 'H', 'E', 'X', 'P' }, + .expansionVersionMajor = EXPANSION_VERSION_MAJOR, + .expansionVersionMinor = EXPANSION_VERSION_MINOR, + .expansionVersionPatch = EXPANSION_VERSION_PATCH, + .expansionVersionFlags = (EXPANSION_TAGGED_RELEASE << 0), +};