Add comments, optimize rom space slightly and fix issue in debug_menu_entries.cpp

This commit is contained in:
Philippe Symons
2026-03-10 11:58:43 +01:00
parent 343d4eb83e
commit 07e522fd62
8 changed files with 250 additions and 74 deletions

View File

@@ -21,7 +21,7 @@ static const option_data toggle_options[2] = {
/**
* @brief This helper function makes it easy to define a multiple choice debug row.
*/
static debug_menu_row_widget __attribute__((noinline)) define_debug_choice_row(const u16 *charset, const char *labelText, on_execute_callback option_activate_callback, const option_data *options_metadata, u8 num_options, bool should_delete_options, u8 default_option_index, void *context)
static debug_menu_row_widget* __attribute__((noinline)) define_debug_choice_row(const u16 *charset, const char *labelText, on_execute_callback option_activate_callback, const option_data *options_metadata, u8 num_options, bool should_delete_options, u8 default_option_index, void *context)
{
const debug_menu_row_data row_data = {
.charset = charset,
@@ -37,18 +37,21 @@ static debug_menu_row_widget __attribute__((noinline)) define_debug_choice_row(c
.context = context,
.user_param = 0
};
return debug_menu_row_widget(row_data);
return new debug_menu_row_widget(row_data);
}
/**
* @brief This helper function makes it easy to define a toggle row.
*/
static debug_menu_row_widget define_toggle_row(const u16 *charset, const char* labelText, on_execute_callback on_toggle_callback, bool default_value, void *context)
static debug_menu_row_widget* define_toggle_row(const u16 *charset, const char* labelText, on_execute_callback on_toggle_callback, bool default_value, void *context)
{
return define_debug_choice_row(charset, labelText, on_toggle_callback, toggle_options, 2, false, default_value ? 1 : 0, context);
}
static debug_menu_row_widget __attribute__((noinline)) define_song_row(const u16 *charset, const char* labelText)
/**
* @brief This helper function will define the song row, which will let you toggle between any available maxmod song or None at all.
*/
static debug_menu_row_widget* __attribute__((noinline)) define_song_row(const u16 *charset, const char* labelText)
{
option_data *song_options = (option_data*)malloc(sizeof(option_data) * (MSL_NSONGS + 1));
song_options[0] = {
@@ -70,7 +73,7 @@ static debug_menu_row_widget __attribute__((noinline)) define_song_row(const u16
/**
* @brief This helper function makes it easy to define a row that executes a function when you select it and press A.
*/
static debug_menu_row_widget __attribute__((noinline)) define_executable_row(const u16 *charset, const char* labelText, on_execute_callback on_execute, unsigned user_param, void *context)
static debug_menu_row_widget* __attribute__((noinline)) define_executable_row(const u16 *charset, const char* labelText, on_execute_callback on_execute, unsigned user_param, void *context)
{
const debug_menu_row_data row_data = {
.charset = charset,
@@ -86,49 +89,31 @@ static debug_menu_row_widget __attribute__((noinline)) define_executable_row(con
.context = context,
.user_param = user_param
};
return debug_menu_row_widget(row_data);
return new debug_menu_row_widget(row_data);
}
// Here we define the actual entries of the debug menu, using the helper functions defined above.
void fill_debug_menu_with_entries(vertical_menu &menu, u16 *charset)
{
#if ENABLE_TEXT_DEBUG_SCREEN
debug_menu_row_widget txt_dbg_screen = define_executable_row(charset, "Text Debug", show_text_debug_screen, 0, nullptr);
#endif
debug_menu_row_widget dbg_info_screen = define_executable_row(charset, "Info", show_debug_info_screen, 0, nullptr);
debug_menu_row_widget row_play_song = define_song_row(charset, "Song");
debug_menu_row_widget row_print_link_data = define_toggle_row(charset, "Print Link", dbg_set_boolean_flag, g_debug_options.print_link_data, &g_debug_options.print_link_data);
debug_menu_row_widget row_instant_text_speed = define_toggle_row(charset, "Instant Text", dbg_set_boolean_flag, g_debug_options.instant_text_speed, &g_debug_options.instant_text_speed);
debug_menu_row_widget row_ignore_game_pak = define_toggle_row(charset, "Ign Cart", dbg_set_boolean_flag, g_debug_options.ignore_game_pak, &g_debug_options.ignore_game_pak);
debug_menu_row_widget row_ignore_game_pak_sprites = define_toggle_row(charset, "Ign Sprites", dbg_set_boolean_flag, g_debug_options.ignore_game_pak_sprites, &g_debug_options.ignore_game_pak_sprites);
debug_menu_row_widget row_ignore_link_cable = define_toggle_row(charset, "Ign Link", dbg_set_boolean_flag, g_debug_options.ignore_link_cable, &g_debug_options.ignore_link_cable);
debug_menu_row_widget row_ignore_mg_e4_flags = define_toggle_row(charset, "Ign MG/E4", dbg_set_boolean_flag, g_debug_options.ignore_mg_e4_flags, &g_debug_options.ignore_mg_e4_flags);
debug_menu_row_widget row_ignore_unreceived_pkmn = define_toggle_row(charset, "Ign Unrec PKMN", dbg_set_boolean_flag, g_debug_options.ignore_unreceived_pkmn, &g_debug_options.ignore_unreceived_pkmn);
debug_menu_row_widget row_force_tutorial = define_toggle_row(charset, "Force Tut", dbg_set_boolean_flag, g_debug_options.force_tutorial, &g_debug_options.force_tutorial);
debug_menu_row_widget row_dont_hide_invalid_pkmn = define_toggle_row(charset, "Show Invalid", dbg_set_boolean_flag, g_debug_options.dont_hide_invalid_pkmn, &g_debug_options.dont_hide_invalid_pkmn);
debug_menu_row_widget row_ignore_dex_completion = define_toggle_row(charset, "Ign Dex Compl", dbg_set_boolean_flag, g_debug_options.ignore_dex_completion, &g_debug_options.ignore_dex_completion);
debug_menu_row_widget row_force_all_caught = define_toggle_row(charset, "Force Caught", dbg_set_boolean_flag, g_debug_options.force_all_caught, &g_debug_options.force_all_caught);
debug_menu_row_widget row_write_cable_data_to_save = define_toggle_row(charset, "Write Cbl Data", dbg_set_boolean_flag, g_debug_options.write_cable_data_to_save, &g_debug_options.write_cable_data_to_save);
debug_menu_row_widget row_display_control_char = define_toggle_row(charset, "Disp CtrlChr", dbg_set_boolean_flag, g_debug_options.display_control_char, &g_debug_options.display_control_char);
i_item_widget* item_widgets[] = {
#if ENABLE_TEXT_DEBUG_SCREEN
&txt_dbg_screen,
define_executable_row(charset, "Text Debug", show_text_debug_screen, 0, nullptr),
#endif
&dbg_info_screen,
&row_play_song,
&row_print_link_data,
&row_instant_text_speed,
&row_ignore_game_pak,
&row_ignore_game_pak_sprites,
&row_ignore_link_cable,
&row_ignore_mg_e4_flags,
&row_ignore_unreceived_pkmn,
&row_force_tutorial,
&row_dont_hide_invalid_pkmn,
&row_ignore_dex_completion,
&row_force_all_caught,
&row_write_cable_data_to_save,
&row_display_control_char
define_executable_row(charset, "Info", show_debug_info_screen, 0, nullptr),
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),
define_toggle_row(charset, "Instant Text", dbg_set_boolean_flag, g_debug_options.instant_text_speed, &g_debug_options.instant_text_speed),
define_toggle_row(charset, "Ign Cart", dbg_set_boolean_flag, g_debug_options.ignore_game_pak, &g_debug_options.ignore_game_pak),
define_toggle_row(charset, "Ign Sprites", dbg_set_boolean_flag, g_debug_options.ignore_game_pak_sprites, &g_debug_options.ignore_game_pak_sprites),
define_toggle_row(charset, "Ign Link", dbg_set_boolean_flag, g_debug_options.ignore_link_cable, &g_debug_options.ignore_link_cable),
define_toggle_row(charset, "Ign MG/E4", dbg_set_boolean_flag, g_debug_options.ignore_mg_e4_flags, &g_debug_options.ignore_mg_e4_flags),
define_toggle_row(charset, "Ign Unrec PKMN", dbg_set_boolean_flag, g_debug_options.ignore_unreceived_pkmn, &g_debug_options.ignore_unreceived_pkmn),
define_toggle_row(charset, "Force Tut", dbg_set_boolean_flag, g_debug_options.force_tutorial, &g_debug_options.force_tutorial),
define_toggle_row(charset, "Show Invalid", dbg_set_boolean_flag, g_debug_options.dont_hide_invalid_pkmn, &g_debug_options.dont_hide_invalid_pkmn),
define_toggle_row(charset, "Ign Dex Compl", dbg_set_boolean_flag, g_debug_options.ignore_dex_completion, &g_debug_options.ignore_dex_completion),
define_toggle_row(charset, "Force Caught", dbg_set_boolean_flag, g_debug_options.force_all_caught, &g_debug_options.force_all_caught),
define_toggle_row(charset, "Write Cbl Data", dbg_set_boolean_flag, g_debug_options.write_cable_data_to_save, &g_debug_options.write_cable_data_to_save),
define_toggle_row(charset, "Disp CtrlChr", dbg_set_boolean_flag, g_debug_options.display_control_char, &g_debug_options.display_control_char)
};
menu.add_item_widgets(item_widgets, sizeof(item_widgets) / sizeof(item_widgets[0]));