From ef661db3c8b807200f6b33d2d77b6ad6de971fa9 Mon Sep 17 00:00:00 2001 From: Philippe Symons Date: Tue, 28 Apr 2026 23:53:10 +0200 Subject: [PATCH] Set up menu entry to inject old sea map --- PCCS | 2 +- include/dbg/debug_menu_functions.h | 2 + include/dbg/old_sea_map.h | 95 +++++++++++++++++++++++++++++ source/dbg/debug_menu_entries.cpp | 6 ++ source/dbg/debug_menu_functions.cpp | 26 ++++++++ 5 files changed, 130 insertions(+), 1 deletion(-) create mode 100644 include/dbg/old_sea_map.h diff --git a/PCCS b/PCCS index 6285fc7..1bb8572 160000 --- a/PCCS +++ b/PCCS @@ -1 +1 @@ -Subproject commit 6285fc7e8422bf880ce0d2f2326df55ca7ba815d +Subproject commit 1bb8572dfdd2213b60b262a6cc3227360fde97bf diff --git a/include/dbg/debug_menu_functions.h b/include/dbg/debug_menu_functions.h index f0b0f19..d7a1b58 100644 --- a/include/dbg/debug_menu_functions.h +++ b/include/dbg/debug_menu_functions.h @@ -42,4 +42,6 @@ void dbg_inject_pkmn(void *context, unsigned user_param); void dbg_unlock_mystery(void *context, unsigned user_param); +void dbg_inject_wc3(void *context, unsigned user_param); + #endif \ No newline at end of file diff --git a/include/dbg/old_sea_map.h b/include/dbg/old_sea_map.h new file mode 100644 index 0000000..1339a78 --- /dev/null +++ b/include/dbg/old_sea_map.h @@ -0,0 +1,95 @@ +#include "typeDefs.h" + +// array size is 1420 +// Taken from WC3Tool 0.1f: https://github.com/projectpokemon/Gen3-WCTool/releases/tag/0.1f +static const u8 OldSeaMap_E_custom[] = { + 0xcf, 0xa6, 0x00, 0x00, 0xba, 0xb4, 0xbe, 0xb9, 0x00, 0x00, 0x00, 0x00, 0x8c, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xb1, 0xc9, 0xc6, 0xbe, 0x00, 0xcd, 0xbf, 0xbb, 0x00, 0xc7, 0xbb, + 0xca, 0xb2, 0x00, 0xbd, 0xe9, 0xe7, 0xe8, 0xe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7, 0xd5, 0xea, 0xd9, 0x00, + 0xe8, 0xdc, 0xd9, 0x00, 0xdb, 0xd5, 0xe1, 0xd9, 0xab, 0xab, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xbe, 0xe3, + 0x00, 0xe2, 0xe3, 0xe8, 0x00, 0xe8, 0xe3, 0xe7, 0xe7, 0x00, 0xe8, 0xdc, 0xdd, 0xe7, 0x00, 0xbf, + 0xec, 0xd7, 0xdc, 0xd5, 0xe2, 0xdb, 0xd9, 0x00, 0xbd, 0xd5, 0xe6, 0xd8, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xd6, 0xd9, 0xda, 0xe3, 0xe6, 0xd9, 0x00, 0xe6, 0xd9, 0xd7, + 0xd9, 0xdd, 0xea, 0xdd, 0xe2, 0xdb, 0x00, 0xe8, 0xdc, 0xd9, 0x00, 0xc9, 0xc6, 0xbe, 0x00, 0xcd, + 0xbf, 0xbb, 0x00, 0xc7, 0xbb, 0xca, 0xab, 0xab, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x88, 0x37, 0x00, 0x00, 0x33, 0xff, 0xff, 0xff, 0xb8, 0xf4, 0x57, 0x67, 0x08, 0x6a, 0x5a, 0x2b, + 0x3c, 0x01, 0xbb, 0x01, 0x58, 0x58, 0x67, 0x08, 0x2b, 0xca, 0x01, 0xbb, 0x01, 0x58, 0x58, 0x67, + 0x08, 0x47, 0x78, 0x01, 0x01, 0x00, 0x21, 0x0d, 0x80, 0x01, 0x00, 0xbb, 0x01, 0x58, 0x58, 0x67, + 0x08, 0xbd, 0x61, 0x58, 0x67, 0x08, 0x66, 0x6d, 0x46, 0x78, 0x01, 0x01, 0x00, 0x21, 0x0d, 0x80, + 0x00, 0x00, 0xbb, 0x01, 0x4f, 0x58, 0x67, 0x08, 0x1a, 0x00, 0x80, 0x78, 0x01, 0x1a, 0x01, 0x80, + 0x01, 0x00, 0x09, 0x00, 0x29, 0xd6, 0x08, 0x29, 0x3c, 0x01, 0xbd, 0xd9, 0x58, 0x67, 0x08, 0x66, + 0x6d, 0x6c, 0x02, 0xbd, 0x6a, 0x59, 0x67, 0x08, 0x66, 0x6d, 0x6c, 0x02, 0xbd, 0x3d, 0x59, 0x67, + 0x08, 0x66, 0x6d, 0x6c, 0x02, 0xce, 0xdc, 0xd5, 0xe2, 0xdf, 0x00, 0xed, 0xe3, 0xe9, 0x00, 0xda, + 0xe3, 0xe6, 0x00, 0xe9, 0xe7, 0xdd, 0xe2, 0xdb, 0x00, 0xe8, 0xdc, 0xd9, 0x00, 0xc7, 0xd3, 0xcd, + 0xce, 0xbf, 0xcc, 0xd3, 0xfe, 0xc1, 0xc3, 0xc0, 0xce, 0x00, 0xcd, 0xed, 0xe7, 0xe8, 0xd9, 0xe1, + 0xad, 0xfb, 0xc6, 0xd9, 0xe8, 0x00, 0xe1, 0xd9, 0x00, 0xd7, 0xe3, 0xe2, 0xda, 0xdd, 0xe6, 0xe1, + 0xae, 0xae, 0xed, 0xe3, 0xe9, 0x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0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 +}; \ No newline at end of file diff --git a/source/dbg/debug_menu_entries.cpp b/source/dbg/debug_menu_entries.cpp index 6bcfd5d..491a68f 100644 --- a/source/dbg/debug_menu_entries.cpp +++ b/source/dbg/debug_menu_entries.cpp @@ -7,6 +7,10 @@ #include +#if ENABLE_MYSTERY_GIFT +#include "dbg/old_sea_map.h" +#endif + static const option_data toggle_options[2] = { { .text = "Off", @@ -144,6 +148,8 @@ static void fill_debug_menu_with_injection_entries(vertical_menu &menu, u16 *cha #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), + define_executable_row(charset, "Inj OldSeaMap", dbg_inject_wc3, sizeof(OldSeaMap_E_custom), const_cast(OldSeaMap_E_custom)), + #endif }; menu.add_item_widgets(item_widgets, sizeof(item_widgets) / sizeof(item_widgets[0])); diff --git a/source/dbg/debug_menu_functions.cpp b/source/dbg/debug_menu_functions.cpp index a0b9350..8e71f15 100644 --- a/source/dbg/debug_menu_functions.cpp +++ b/source/dbg/debug_menu_functions.cpp @@ -316,6 +316,32 @@ void dbg_unlock_mystery(void *context, unsigned user_param) save_manager.setMysteryEventUnlocked(user_param == 0); save_manager.setMysteryGiftUnlocked(user_param != 0); + save_manager.finishSave(); + reader.flush(); +} + +void dbg_inject_wc3(void *context, unsigned user_param) +{ + const u8* wc3_data_ptr = reinterpret_cast(context); + size_t wc3_data_size = user_param; + if(wc3_data_ptr == nullptr) + { + return; + } + + const Game game_type = convert_rom_game_id_to_ptgb_game(curr_GBA_rom.gamecode); + if(game_type != EMERALD) + { + return; + } + + 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); + + save_manager.setMysteryGiftUnlocked(user_param != 0); + save_manager.injectMysteryGift(wc3_data_ptr, wc3_data_size); + save_manager.finishSave(); reader.flush(); } \ No newline at end of file