From 9ca5c650d080a89dfe882e921af6ecb62ff1ce96 Mon Sep 17 00:00:00 2001 From: The Gears of Progress Date: Wed, 3 Dec 2025 22:08:35 -0500 Subject: [PATCH] Working on debugging --- Makefile | 2 +- include/debug_mode.h | 14 +++++++----- source/gameboy_colour.cpp | 5 ++++- source/mystery_gift_injector.cpp | 15 ------------- source/pokemon_party.cpp | 22 +++++++++++++++++-- source/script_array.cpp | 2 +- .../src/payloads/payload_builder.cpp | 2 +- 7 files changed, 35 insertions(+), 27 deletions(-) diff --git a/Makefile b/Makefile index 22047ab..f3f3e73 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ # Build configuration (set to either 'debug' or 'release') -BUILD_TYPE := release +BUILD_TYPE := debug #--------------------------------------------------------------------------------- .SUFFIXES: diff --git a/include/debug_mode.h b/include/debug_mode.h index 1ed3aa0..6386e3a 100644 --- a/include/debug_mode.h +++ b/include/debug_mode.h @@ -1,16 +1,16 @@ #ifndef DEBUG_MODE_H #define DEBUG_MODE_H -#define VERSION "v1.2.0" +#define VERSION "v1.3.0b" #define PTGB_BUILD_LANGUAGE 2 -#define DEBUG_MODE false +#define DEBUG_MODE true -#define PRINT_LINK_DATA (true && DEBUG_MODE) +#define PRINT_LINK_DATA (false && DEBUG_MODE) #define INSTANT_TEXT_SPEED (false && DEBUG_MODE) -#define IGNORE_GAME_PAK (false && DEBUG_MODE) -#define IGNORE_GAME_PAK_SPRITES (true && DEBUG_MODE) -#define IGNORE_LINK_CABLE (true && DEBUG_MODE) +#define IGNORE_GAME_PAK (true && DEBUG_MODE) +#define IGNORE_GAME_PAK_SPRITES (false && DEBUG_MODE) +#define IGNORE_LINK_CABLE (false && DEBUG_MODE) #define IGNORE_MG_E4_FLAGS (true && DEBUG_MODE) #define IGNORE_UNRECEIVED_PKMN (true && DEBUG_MODE) #define FORCE_TUTORIAL (false && DEBUG_MODE) @@ -22,6 +22,8 @@ #define SHOW_DATA_PACKETS (false && DEBUG_MODE) #define DISPLAY_CONTROL_CHAR (false && DEBUG_MODE) #define PAYLOAD_EXPORT_TEST (false && DEBUG_MODE) +#define DONT_TRANSFER_POKEMON_AT_INDEX_X (false && DEBUG_MODE) +#define POKEMON_INDEX_TO_SKIP 5 #define DEBUG_GAME EMERALD_ID #define DEBUG_VERS VERS_1_0 diff --git a/source/gameboy_colour.cpp b/source/gameboy_colour.cpp index b267026..22d1b17 100644 --- a/source/gameboy_colour.cpp +++ b/source/gameboy_colour.cpp @@ -598,7 +598,10 @@ byte exchange_remove_array(byte curr_in, PokeBox *box, bool cancel_connection) if (box->getGen3Pokemon(i)->isValid && !cancel_connection) { box->removePokemon(i); - return i; + if (!(DONT_TRANSFER_POKEMON_AT_INDEX_X && i == POKEMON_INDEX_TO_SKIP)) + { + return i; + } } } return 0xFF; diff --git a/source/mystery_gift_injector.cpp b/source/mystery_gift_injector.cpp index 8eb0e6b..40565a1 100644 --- a/source/mystery_gift_injector.cpp +++ b/source/mystery_gift_injector.cpp @@ -78,21 +78,6 @@ bool inject_mystery(PokeBox* box) erase_sector(memory_section_array[4]); copy_ram_to_save(&global_memory_buffer[0], memory_section_array[4], 0x1000); - if (WRITE_CABLE_DATA_TO_SAVE) - { - for (int i = 0; i < 1122; i++) - { - // global_memory_buffer[i] = incoming_box_data.box_data_array[i]; - while(true){} - // This is currently not possible(?) - } - for (int i = 0; i < 0x1000 - 1122; i++) - { - global_memory_buffer[i + 1122] = 0xAA; - } - copy_ram_to_save(&global_memory_buffer[0], 0x0000, 0x1000); - } - // Set flags int memory_section = 1 + ((curr_GBA_rom.offset_flags + (curr_GBA_rom.unused_flag_start / 8)) / 0xF80); // This sets the correct memory section, since flags stretch between section 1 and 2. copy_save_to_ram(memory_section_array[memory_section], &global_memory_buffer[0], 0x1000); diff --git a/source/pokemon_party.cpp b/source/pokemon_party.cpp index 809f67f..bf06c6e 100644 --- a/source/pokemon_party.cpp +++ b/source/pokemon_party.cpp @@ -13,8 +13,9 @@ #include "gb_gen1_payloads_Y_lz10_bin.h" #include "gb_gen2_payloads_lz10_bin.h" #include "save_data_manager.h" +#include "libraries/Pokemon-Gen3-to-Gen-X/include/save.h" -static byte gen1_rb_debug_box_data[0x462] = { +static byte gen1_rb_debug_box_dataz[0x462] = { // Num of Pokemon 0x14, // Pokemon 1-20 @@ -83,6 +84,9 @@ static byte gen1_rb_debug_box_data[0x462] = { 0x91, 0x80, 0x93, 0x93, 0x80, 0x93, 0x80, 0x50, 0x50, 0x50, 0x50, 0x8F, 0x88, 0x83, 0x86, 0x84, 0x98, 0x50, 0x50, 0x50, 0x50, 0x50}; +static byte gen1_rb_debug_box_data[0x462] = { + 0x02, 0x8F, 0xB1, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x8F, 0x00, 0xBB, 0x64, 0x00, 0x03, 0x03, 0x3C, 0x21, 0x99, 0x7C, 0x6C, 0x97, 0x03, 0x0F, 0x42, 0x40, 0x00, 0xAA, 0x00, 0xBE, 0x00, 0xBE, 0x00, 0xAC, 0x0A, 0xDC, 0xE7, 0x32, 0x1F, 0x05, 0x14, 0x14, 0xB1, 0x00, 0x18, 0x07, 0x00, 0x15, 0x15, 0x2D, 0x21, 0x27, 0x24, 0x00, 0x97, 0x03, 0x00, 0x00, 0xEC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 0x81, 0x23, 0x1E, 0x14, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 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; -Pokemon_Party::Pokemon_Party() { +Pokemon_Party::Pokemon_Party() +{ box.setTable(&table); }; @@ -183,6 +188,19 @@ void Pokemon_Party::start_link() last_error = loop(&box_data_array[0], current_payload, &curr_gb_rom, &box, debug_charset, false); box.loadData(curr_gb_rom.generation, (Language)curr_gb_rom.language, box_data_array); + + if (WRITE_CABLE_DATA_TO_SAVE) + { + for (int i = 0; i < 1122; i++) + { + global_memory_buffer[i] = box_data_array[i]; + } + for (int i = 0; i < 0x1000 - 1122; i++) + { + global_memory_buffer[i + 1122] = 0xAA; + } + copy_ram_to_save(&global_memory_buffer[0], 0x0000, 0x1000); + } } } diff --git a/source/script_array.cpp b/source/script_array.cpp index 0fbc0ce..f6ddcb6 100644 --- a/source/script_array.cpp +++ b/source/script_array.cpp @@ -904,7 +904,7 @@ bool run_conditional(int index) return true; case CMD_IS_A_VALID_PKMN: - return party_data.box.getNumValid() > 0; + return party_data.box.getNumValid() > 0 || DONT_HIDE_INVALID_PKMN; case CMD_CANCEL_LINK: party_data.continue_link(true); diff --git a/tools/data-generator/src/payloads/payload_builder.cpp b/tools/data-generator/src/payloads/payload_builder.cpp index 8341d3d..4fbe2cf 100644 --- a/tools/data-generator/src/payloads/payload_builder.cpp +++ b/tools/data-generator/src/payloads/payload_builder.cpp @@ -963,7 +963,7 @@ void init_payload(byte *payload_buffer, const GB_ROM &curr_rom, int type, bool d #if PAYLOAD_EXPORT_TEST #include #include "gb_rom_values/gb_rom_values.h" -int main() // Rename to "main" to send the payload to test_payload.txt +int main() { byte buffer[672] = {0}; freopen("test_payload.txt", "w", stdout);