From 5a9ce8dabc0e7de5f92436c7a4a082cd019caa28 Mon Sep 17 00:00:00 2001 From: Philippe Symons Date: Wed, 15 Apr 2026 21:20:41 +0200 Subject: [PATCH] Add entries to debug menu to unlock Mystery Gift and Mystery Events NOTE: to test this with ignore_game_pak, you need to make sure DEBUG_GAME is set correctly to the game that matches --- PCCS | 2 +- include/dbg/debug_menu_functions.h | 2 ++ include/dbg/debug_mode.h | 1 + source/dbg/debug_menu_entries.cpp | 4 ++++ source/dbg/debug_menu_functions.cpp | 31 +++++++++++++++++++++++++++++ 5 files changed, 39 insertions(+), 1 deletion(-) diff --git a/PCCS b/PCCS index fb1ffff..ffdfb24 160000 --- a/PCCS +++ b/PCCS @@ -1 +1 @@ -Subproject commit fb1ffffb5df748d0859f1a082d2d3a12802686bd +Subproject commit ffdfb243e21328f4e5c979fd24b6082670cc422e diff --git a/include/dbg/debug_menu_functions.h b/include/dbg/debug_menu_functions.h index 54b04fe..7332fe9 100644 --- a/include/dbg/debug_menu_functions.h +++ b/include/dbg/debug_menu_functions.h @@ -33,4 +33,6 @@ void dbg_play_song(void *context, unsigned user_param); */ void dbg_inject_pkmn(void *context, unsigned user_param); +void dbg_unlock_mystery(void *context, unsigned user_param); + #endif \ No newline at end of file diff --git a/include/dbg/debug_mode.h b/include/dbg/debug_mode.h index dcbb07f..b7eb639 100644 --- a/include/dbg/debug_mode.h +++ b/include/dbg/debug_mode.h @@ -117,6 +117,7 @@ extern debug_options g_debug_options; #define ENABLE_DEBUG_MENU true #define ENABLE_TEXT_DEBUG_SCREEN true #define ENABLE_DEBUG_PKMN_INJECTION true +#define ENABLE_MYSTERY_GIFT true #define USE_CUSTOM_MALLOC 1 // needs to be a value divisible by 4 #define CUSTOM_MALLOC_POOL_SIZE 8192 diff --git a/source/dbg/debug_menu_entries.cpp b/source/dbg/debug_menu_entries.cpp index ead3040..d44de61 100644 --- a/source/dbg/debug_menu_entries.cpp +++ b/source/dbg/debug_menu_entries.cpp @@ -102,6 +102,10 @@ void fill_debug_menu_with_entries(vertical_menu &menu, u16 *charset) define_executable_row(charset, "Info", show_debug_info_screen, 0, nullptr), #if ENABLE_DEBUG_PKMN_INJECTION define_executable_row(charset, "Inject Celebi", dbg_inject_pkmn, 0, nullptr), +#endif +#if ENABLE_MYSTERY_GIFT + define_executable_row(charset, "Unlock MystE", dbg_unlock_mystery, 0, nullptr), + define_executable_row(charset, "Unlock MystG", dbg_unlock_mystery, 1, nullptr), #endif define_song_row(charset, "Song"), define_toggle_row(charset, "Print Link", dbg_set_boolean_flag, g_debug_options.print_link_data, &g_debug_options.print_link_data), diff --git a/source/dbg/debug_menu_functions.cpp b/source/dbg/debug_menu_functions.cpp index 46a649e..ffa23c8 100644 --- a/source/dbg/debug_menu_functions.cpp +++ b/source/dbg/debug_menu_functions.cpp @@ -279,4 +279,35 @@ void dbg_inject_pkmn(void *context, unsigned user_param) hide_textbox(); tte_erase_rect(LEFT, TOP, RIGHT, BOTTOM); +} + +void dbg_unlock_mystery(void *context, unsigned user_param) +{ + const Game game_type = convert_rom_game_id_to_ptgb_game(curr_GBA_rom.gamecode); + const Language game_lang = convert_rom_lang_to_ptgb_lang(curr_GBA_rom.language); + Gen3CartridgeSaveReader reader(global_memory_buffer); + Gen3SaveManager save_manager(game_type, game_lang, reader); + + if(user_param == 0) + { + // mystery event not supported by fire red or leaf green + if(game_type == FIRERED || game_type == LEAFGREEN) + { + return; + } + } + else + { + // mystery gift not supported by ruby or sapphire + if(game_type == RUBY || game_type == SAPPHIRE) + { + return; + } + } + + save_manager.setMysteryEventUnlocked(user_param == 0); + save_manager.setMysteryGiftUnlocked(user_param != 0); + + save_manager.finishSave(); + reader.flush(); } \ No newline at end of file