mirror of
https://github.com/pret/pokeemerald.git
synced 2026-09-12 04:56:34 -05:00
Added updates to make this work with latest pret pokeemerald as of may 2026
@@ -1,3 +1,8 @@
|
||||
May 2026 Edit: [click here for updates to make this compatible again with Pret Pokeemerald](#Updates)
|
||||
|
||||
***
|
||||
|
||||
|
||||
During development it's common for your game to be partially complete; even if it isn't, you probably don't want to spend a whole bunch of time playing through the game to get to the bit you need to test. As such, it's useful to have a **debug menu** with a collection of tools defined in code to do useful things for you which you don't expose to the players. However, `pokeemerald` reproduces the *commercial* release of Pokémon Emerald, so there's no debug functionality at all. Fortunately we're programmers, so we can fix that.
|
||||
|
||||
I assume a reasonable familiarity with C, so I won't be explaining things like preprocessor directives, include guards, what a structure or its fields are, or the like. If you want or need to look these things up, you now know what to search for.
|
||||
@@ -489,4 +494,323 @@ Pyredrid
|
||||
AsparagusEduardo
|
||||
Ghoulslash
|
||||
exposneed
|
||||
```
|
||||
```
|
||||
|
||||
***
|
||||
|
||||
## Updates
|
||||
### May 2026 update to make this compatible with Pret Pokeemerald
|
||||
|
||||
(I'd suggest still pulling from TheXaman's [`tx_debug_system`](https://github.com/TheXaman/pokeemerald/tree/tx_debug_system) first and then making these changes)
|
||||
|
||||
```
|
||||
git remote add xaman https://github.com/TheXaman/pokeemerald/
|
||||
git pull xaman tx_debug_system
|
||||
```
|
||||
***
|
||||
### file location changes:
|
||||
|
||||
* `gflib/string_util.c` is now `src/string_util.c`
|
||||
|
||||
* `gflib/string_util.h` is now `include/string_util.h`
|
||||
***
|
||||
|
||||
### file renamed
|
||||
|
||||
`ld_script.txt` should be `ld_script.ld`
|
||||
|
||||
> -- you may be asked to "commit or stash changes" when pulling this even if you haven't edited this file.
|
||||
|
||||
> -- if your file is unedited, replace with `tx_debug_system` version
|
||||
|
||||
> -- or manually add this to your file so they are in alphabetical order:
|
||||
|
||||
(around lines 112 and 113)
|
||||
```
|
||||
src/debug.o(.text);
|
||||
src/debug_pokemon_creator.o(.text);
|
||||
```
|
||||
(around lines 500 and 501)
|
||||
```
|
||||
src/debug.o(.rodata);
|
||||
src/debug_pokemon_creator.o(.rodata);
|
||||
```
|
||||
***
|
||||
|
||||
### include/pokemon.h
|
||||
change line 446
|
||||
|
||||
```
|
||||
u8 SendMonToPC(struct Pokemon* mon);
|
||||
```
|
||||
|
||||
to
|
||||
|
||||
```
|
||||
u8 CopyMonToPC(struct Pokemon* mon);
|
||||
```
|
||||
|
||||
***
|
||||
|
||||
### src/battle_main.c
|
||||
|
||||
in section `static void CB2_InitBattleInternal(void)`
|
||||
|
||||
(around line 673)
|
||||
|
||||
change
|
||||
```
|
||||
#if TX_DEBUG_SYSTEM_ENABLE == FALSE
|
||||
|
||||
gBattleTerrain = BattleSetup_GetTerrainId();
|
||||
#else
|
||||
if (!gIsDebugBattle)
|
||||
gBattleTerrain = BattleSetup_GetTerrainId();
|
||||
#endif
|
||||
```
|
||||
to
|
||||
```
|
||||
#if TX_DEBUG_SYSTEM_ENABLE == FALSE
|
||||
|
||||
gBattleEnvironment = BattleSetup_GetEnvironmentId();
|
||||
#else
|
||||
if (!gIsDebugBattle)
|
||||
gBattleEnvironment = BattleSetup_GetEnvironmentId();
|
||||
#endif
|
||||
```
|
||||
***
|
||||
|
||||
### src/battle_setup.c
|
||||
|
||||
in section `void DoStandardWildBattle_Debug(void)`
|
||||
|
||||
(around line 456)
|
||||
|
||||
change
|
||||
```
|
||||
if (InBattlePyramid())
|
||||
{
|
||||
VarSet(VAR_TEMP_E, 0);
|
||||
gBattleTypeFlags |= BATTLE_TYPE_PYRAMID;
|
||||
```
|
||||
to
|
||||
```
|
||||
if (CurrentBattlePyramidLocation() != PYRAMID_LOCATION_NONE)
|
||||
{
|
||||
VarSet(VAR_TEMP_PLAYING_PYRAMID_MUSIC, 0);
|
||||
gBattleTypeFlags |= BATTLE_TYPE_PYRAMID;
|
||||
```
|
||||
***
|
||||
|
||||
|
||||
### src/debug.c
|
||||
|
||||
in section `static void DebugAction_Give_Pokemon_ComplexCreateMon(u8 taskId)`
|
||||
|
||||
(around line 3562)
|
||||
|
||||
change
|
||||
```
|
||||
if (i >= PARTY_SIZE)
|
||||
sentToPc = SendMonToPC(&mon);
|
||||
else
|
||||
```
|
||||
to
|
||||
```
|
||||
if (i >= PARTY_SIZE)
|
||||
sentToPc = CopyMonToPC(&mon);
|
||||
else
|
||||
```
|
||||
***
|
||||
|
||||
|
||||
### src/debug_pokemon_creator.c
|
||||
|
||||
in section `static const struct EditPokemonStruct DebugPkmCreator_Options[]`
|
||||
|
||||
(around line 348)
|
||||
|
||||
change
|
||||
```
|
||||
[VAL_RIBBON_FATEFUL] = {Str_Fateful, EDIT_BOOL, 0, 1, 0, MON_DATA_EVENT_LEGAL, 1},
|
||||
```
|
||||
to
|
||||
```
|
||||
[VAL_RIBBON_FATEFUL] = {Str_Fateful, EDIT_BOOL, 0, 1, 0, MON_DATA_MODERN_FATEFUL_ENCOUNTER, 1},
|
||||
```
|
||||
___
|
||||
|
||||
in section `static void DebugPkmCreator_Init_SetNewMonData(bool8 setMoves)`
|
||||
|
||||
in `case VAL_ABILITY:`
|
||||
|
||||
(around line 658)
|
||||
|
||||
change
|
||||
```
|
||||
if (gBaseStats[sDebugPkmCreatorData.data[0]].abilities[1])
|
||||
```
|
||||
to
|
||||
```
|
||||
if (gSpeciesInfo[sDebugPkmCreatorData.data[0]].abilities[1])
|
||||
```
|
||||
___
|
||||
|
||||
in section `static void DebugPkmCreator_EditModeRedraw(u32 digit, u8 editIndex)`
|
||||
|
||||
in `case: VAL_LEVEL:`
|
||||
|
||||
(around line 1314)
|
||||
|
||||
change
|
||||
```
|
||||
//u32 newExp = gExperienceTables[gBaseStats[sDebugPkmCreatorData.data[VAL_SPECIES]].growthRate][DebugPkmCreator_editingVal[editIndex]];
|
||||
```
|
||||
to
|
||||
```
|
||||
//u32 newExp = gExperienceTables[gSpeciesInfo[sDebugPkmCreatorData.data[VAL_SPECIES]].growthRate][DebugPkmCreator_editingVal[editIndex]];
|
||||
```
|
||||
___
|
||||
|
||||
in section `static void DebugPkmCreator_EditModeProcessInput(u8 taskid)`
|
||||
|
||||
in `case: VAL_SPECIES:`
|
||||
|
||||
(around line 1809)
|
||||
|
||||
change
|
||||
```
|
||||
SetMonData(&sDebugPkmCreatorData.mon, MON_DATA_EXP, &gExperienceTables[gBaseStats[DebugPkmCreator_editingVal[i]].growthRate][sDebugPkmCreatorData.data[15]]);
|
||||
```
|
||||
to
|
||||
```
|
||||
SetMonData(&sDebugPkmCreatorData.mon, MON_DATA_EXP, &gExperienceTables[gSpeciesInfo[DebugPkmCreator_editingVal[i]].growthRate][sDebugPkmCreatorData.data[15]]);
|
||||
```
|
||||
___
|
||||
|
||||
a few lines down in the same section
|
||||
in `case VAL_LEVEL:`
|
||||
(around line 1820)
|
||||
|
||||
change
|
||||
```
|
||||
SetMonData(&sDebugPkmCreatorData.mon, MON_DATA_EXP, &gExperienceTables[gBaseStats[sDebugPkmCreatorData.data[VAL_SPECIES]].growthRate][sDebugPkmCreatorData.data[VAL_LEVEL]]);
|
||||
```
|
||||
to
|
||||
```
|
||||
SetMonData(&sDebugPkmCreatorData.mon, MON_DATA_EXP, &gExperienceTables[gSpeciesInfo[sDebugPkmCreatorData.data[VAL_SPECIES]].growthRate][sDebugPkmCreatorData.data[VAL_LEVEL]]);
|
||||
```
|
||||
___
|
||||
|
||||
in section `static u8 DebugPkmCreator_GiveToPlayer(void)`
|
||||
|
||||
(around line 2044)
|
||||
|
||||
change
|
||||
```
|
||||
return SendMonToPC(mon);
|
||||
```
|
||||
to
|
||||
```
|
||||
return CopyMonToPC(mon);
|
||||
```
|
||||
***
|
||||
|
||||
### src/pokemon.c
|
||||
> -- important note: if `CopyMonToPC` has already been changed to `SendMonToPC`, change it back to `CopyMonToPC`.
|
||||
|
||||
in the headers section
|
||||
|
||||
> -- there is no line `static u8 SendMonToPC(struct Pokemon *mon);` anymore so ignore this change
|
||||
|
||||
(around line 73)
|
||||
|
||||
change
|
||||
```
|
||||
static u8 CopyMonToPC(struct Pokemon *mon);
|
||||
```
|
||||
to
|
||||
```
|
||||
u8 CopyMonToPC(struct Pokemon *mon);
|
||||
```
|
||||
___
|
||||
|
||||
around line 4433
|
||||
|
||||
> -- there is no line `static u8 SendMonToPC(struct Pokemon *mon)` anymore so ignore this change
|
||||
|
||||
change
|
||||
```
|
||||
static u8 CopyMonToPC(struct Pokemon *mon)
|
||||
```
|
||||
to
|
||||
```
|
||||
u8 CopyMonToPC(struct Pokemon *mon)
|
||||
```
|
||||
***
|
||||
### tools/mapjson/mapjson.cpp
|
||||
|
||||
in section `string generate_map_constants_text(string groups_filepath, Json groups_data) {`
|
||||
|
||||
(around line 522)
|
||||
|
||||
replace the entire section with:
|
||||
```
|
||||
string file_dir = file_parent(groups_filepath) + sep;
|
||||
|
||||
string guard_name = "CONSTANTS_MAP_GROUPS";
|
||||
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;
|
||||
vector<int> map_count_vec; //DEBUG
|
||||
|
||||
for (auto &group : groups_data["group_order"].array_items()) {
|
||||
vector<string> map_ids;
|
||||
string groupName = json_to_string(group);
|
||||
text << " // " << groupName << "\n";
|
||||
|
||||
size_t max_length = 0; //DEBUG
|
||||
int map_count = 0; //DEBUG
|
||||
|
||||
for (auto &map_name : groups_data[groupName].array_items()) {
|
||||
string map_filepath = file_dir + json_to_string(map_name) + sep + "map.json";
|
||||
string err_str;
|
||||
Json map_data = Json::parse(read_text_file(map_filepath), err_str);
|
||||
if (map_data == Json())
|
||||
FATAL_ERROR("%s: %s\n", map_filepath.c_str(), err_str.c_str());
|
||||
string id = json_to_string(map_data, "id", true);
|
||||
map_ids.push_back(id);
|
||||
if (id.length() > max_length)
|
||||
max_length = id.length();
|
||||
map_count++; //DEBUG
|
||||
}
|
||||
|
||||
int map_id_num = 0;
|
||||
for (string map_id : map_ids) {
|
||||
text << " " << map_id << string(max_length - map_id.length(), ' ')
|
||||
<< " = (" << map_id_num++ << " | (" << group_num << " << 8)),\n";
|
||||
}
|
||||
text << "\n";
|
||||
|
||||
group_num++;
|
||||
map_count_vec.push_back(map_count); //DEBUG
|
||||
}
|
||||
|
||||
text << "};\n\n";
|
||||
|
||||
text << "#define MAP_GROUPS_COUNT " << group_num << "\n\n";
|
||||
|
||||
text << "// static const u8 MAP_GROUP_COUNT[] = {"; //DEBUG
|
||||
for(int i=0; i<group_num; i++){ //DEBUG
|
||||
text << map_count_vec[i] << ", "; //DEBUG
|
||||
} //DEBUG
|
||||
text << "0};\n\n"; //DEBUG
|
||||
|
||||
text << "#endif // GUARD_CONSTANTS_MAP_GROUPS_H\n";
|
||||
|
||||
return text.str();
|
||||
}
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user