Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Defines for Expansion version number #3454

Merged
merged 6 commits into from
Nov 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions data/scripts/debug.inc
Original file line number Diff line number Diff line change
Expand Up @@ -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
12 changes: 12 additions & 0 deletions include/constants/expansion.h
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions ld_script.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions ld_script_modern.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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*);
Expand Down
1 change: 1 addition & 0 deletions ld_script_test.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
31 changes: 31 additions & 0 deletions src/debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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"

Expand Down Expand Up @@ -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}");
Expand Down Expand Up @@ -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[] =
Expand Down Expand Up @@ -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) =
Expand Down Expand Up @@ -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)
Expand Down
26 changes: 26 additions & 0 deletions src/rom_header_rhh.c
Original file line number Diff line number Diff line change
@@ -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),
};
Loading