From f01fb77db347694e3e7ecdb7f31ed99d1178ff9d Mon Sep 17 00:00:00 2001 From: Robin Jones Date: Wed, 23 Oct 2024 12:58:21 +0100 Subject: [PATCH 1/3] Minor comment improvements --- docs/99_developer_guide.md | 2 ++ src/menu/actions.h | 4 +++- src/menu/sound.h | 17 +++++++++++++++++ 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/docs/99_developer_guide.md b/docs/99_developer_guide.md index ab148140..1734b8d9 100644 --- a/docs/99_developer_guide.md +++ b/docs/99_developer_guide.md @@ -57,6 +57,8 @@ Generated documentation is located in the `output/docs` folder and auto-publishe Once merged, they can be viewed [here](https://polprzewodnikowy.github.io/N64FlashcartMenu/) ### Test generated docs in the dev-container +Testing the documentation locally allows you to preview changes and ensure everything renders correctly before submitting your changes. + Install Prerequisites: ```bash apt-get install ruby-full build-essential zlib1g-dev diff --git a/src/menu/actions.h b/src/menu/actions.h index e02e35af..f10a83ce 100644 --- a/src/menu/actions.h +++ b/src/menu/actions.h @@ -10,7 +10,9 @@ #include "menu_state.h" - +/** + * @brief Initialize the actions module + */ void actions_init (void); void actions_update (menu_t *menu); diff --git a/src/menu/sound.h b/src/menu/sound.h index 8752a9b9..e086a362 100644 --- a/src/menu/sound.h +++ b/src/menu/sound.h @@ -12,6 +12,9 @@ #define SOUND_MP3_PLAYER_CHANNEL (0) #define SOUND_SFX_CHANNEL (2) +/** + * @brief Enumeration of available sound effects for menu interactions. + */ typedef enum { SFX_CURSOR, SFX_ERROR, @@ -23,8 +26,22 @@ typedef enum { void sound_init_default (void); void sound_init_mp3_playback (void); + +/** + * @brief Initialize sound effects system. + */ void sound_init_sfx (void); + +/** + * @brief Enable or disable sound effects. + * @param enable True to enable sound effects, false to disable. + */ void sound_use_sfx(bool); + +/** + * @brief Play a specified sound effect. + * @param sfx The sound effect to play, as defined in sound_effect_t. + */ void sound_play_effect(sound_effect_t sfx); void sound_deinit (void); void sound_poll (void); From 9020445c17ac2b25c8ac691f734f495b717d8ca4 Mon Sep 17 00:00:00 2001 From: Robin Jones Date: Wed, 23 Oct 2024 13:46:29 +0100 Subject: [PATCH 2/3] Improve boxart Minor fixes for: * menu error SFX * RTC text --- src/menu/components/boxart.c | 25 ++++++++++++++++--------- src/menu/views/error.c | 2 +- src/menu/views/load_disk.c | 4 +++- src/menu/views/load_rom.c | 5 ++++- src/menu/views/rtc.c | 2 +- 5 files changed, 25 insertions(+), 13 deletions(-) diff --git a/src/menu/components/boxart.c b/src/menu/components/boxart.c index 2535068c..d663230a 100644 --- a/src/menu/components/boxart.c +++ b/src/menu/components/boxart.c @@ -40,20 +40,28 @@ component_boxart_t *component_boxart_init (const char *storage_prefix, char *gam switch (current_image_view) { case IMAGE_GAMEPAK_FRONT: path_push(path, "gamepak_front.png"); + break; case IMAGE_GAMEPAK_BACK: path_push(path, "gamepak_back.png"); + break; case IMAGE_BOXART_BACK: path_push(path, "boxart_back.png"); + break; case IMAGE_BOXART_LEFT: path_push(path, "boxart_left.png"); + break; case IMAGE_BOXART_RIGHT: path_push(path, "boxart_right.png"); + break; case IMAGE_BOXART_BOTTOM: path_push(path, "boxart_bottom.png"); + break; case IMAGE_BOXART_TOP: path_push(path, "boxart_top.png"); + break; default: path_push(path, "boxart_front.png"); + break; } if (file_exists(path_get(path))) { @@ -65,12 +73,13 @@ component_boxart_t *component_boxart_init (const char *storage_prefix, char *gam } else { // compatibility mode - char file_name[8]; + char file_name[9]; // reset the directory path used for boxart. + path_free(path); path = path_init(storage_prefix, BOXART_DIRECTORY); - sprintf(file_name, "%c%c%c%c.png", game_code[0], game_code[1], game_code[2], game_code[3]); + snprintf(file_name, sizeof(file_name), "%c%c%c%c.png", game_code[0], game_code[1], game_code[2], game_code[3]); path_push(path, file_name); if (file_exists(path_get(path))) { @@ -81,21 +90,19 @@ component_boxart_t *component_boxart_init (const char *storage_prefix, char *gam } path_pop(path); - sprintf(file_name, "%c%c%c.png", game_code[0], game_code[1], game_code[2]); + snprintf(file_name, sizeof(file_name), "%c%c%c.png", game_code[0], game_code[1], game_code[2]); path_push(path, file_name); if (file_exists(path_get(path))) { - if (file_exists(path_get(path))) { - if (png_decoder_start(path_get(path), BOXART_WIDTH_MAX, BOXART_HEIGHT_MAX, png_decoder_callback, b) == PNG_OK) { - path_free(path); - return b; - } + if (png_decoder_start(path_get(path), BOXART_WIDTH_MAX, BOXART_HEIGHT_MAX, png_decoder_callback, b) == PNG_OK) { + path_free(path); + return b; } } else { path_pop(path); - sprintf(file_name, "%c%c.png", game_code[1], game_code[2]); + snprintf(file_name, sizeof(file_name), "%c%c.png", game_code[1], game_code[2]); path_push(path, file_name); if (file_exists(path_get(path))) { if (png_decoder_start(path_get(path), BOXART_WIDTH_MAX, BOXART_HEIGHT_MAX, png_decoder_callback, b) == PNG_OK) { diff --git a/src/menu/views/error.c b/src/menu/views/error.c index 07eb70d4..7cb4f7d2 100644 --- a/src/menu/views/error.c +++ b/src/menu/views/error.c @@ -4,8 +4,8 @@ static void process (menu_t *menu) { if (menu->actions.back) { - menu->next_mode = MENU_MODE_BROWSER; sound_play_effect(SFX_EXIT); + menu->next_mode = MENU_MODE_BROWSER; } } diff --git a/src/menu/views/load_disk.c b/src/menu/views/load_disk.c index 39957fcf..f4140781 100644 --- a/src/menu/views/load_disk.c +++ b/src/menu/views/load_disk.c @@ -94,7 +94,9 @@ static void draw (menu_t *menu, surface_t *d) { ); } - component_boxart_draw(boxart); + if (boxart != NULL) { + component_boxart_draw(boxart); + } } rdpq_detach_show(); diff --git a/src/menu/views/load_rom.c b/src/menu/views/load_rom.c index 36933b92..4fb9d710 100644 --- a/src/menu/views/load_rom.c +++ b/src/menu/views/load_rom.c @@ -262,7 +262,9 @@ static void draw (menu_t *menu, surface_t *d) { "R: Options" ); - component_boxart_draw(boxart); + if (boxart != NULL) { + component_boxart_draw(boxart); + } if (show_extra_info_message) { component_messagebox_draw( @@ -335,6 +337,7 @@ static void load (menu_t *menu) { static void deinit (void) { component_boxart_free(boxart); + boxart = NULL; } diff --git a/src/menu/views/rtc.c b/src/menu/views/rtc.c index ae56fd8b..da595f6f 100644 --- a/src/menu/views/rtc.c +++ b/src/menu/views/rtc.c @@ -36,7 +36,7 @@ static void draw (menu_t *menu, surface_t *d) { "\n" "\n" "To set the date and time, please use the PC terminal\n" - "application and set via USB or a game that uses it.\n\n" + "application and set via USB,\n or a N64 game with RTC support.\n\n" "Current date & time: %s\n", menu->current_time >= 0 ? ctime(&menu->current_time) : "Unknown\n" ); From 4732981f88f8916a92b9e4dcfaf2785c39d75748 Mon Sep 17 00:00:00 2001 From: Robin Jones Date: Wed, 23 Oct 2024 14:19:59 +0100 Subject: [PATCH 3/3] Correctly init joypay vars Correctly free overrides path --- src/menu/actions.c | 6 +++--- src/menu/rom_info.c | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/menu/actions.c b/src/menu/actions.c index 00317168..4cafbce7 100644 --- a/src/menu/actions.c +++ b/src/menu/actions.c @@ -25,8 +25,8 @@ static void actions_clear (menu_t *menu) { } static void actions_update_direction (menu_t *menu) { - joypad_8way_t held_dir; - joypad_8way_t fast_dir; + joypad_8way_t held_dir = JOYPAD_8WAY_NONE; + joypad_8way_t fast_dir = JOYPAD_8WAY_NONE; JOYPAD_PORT_FOREACH (i) { held_dir = joypad_get_direction(i, JOYPAD_2D_DPAD | JOYPAD_2D_STICK); @@ -90,7 +90,7 @@ static void actions_update_direction (menu_t *menu) { } static void actions_update_buttons (menu_t *menu) { - joypad_buttons_t pressed; + joypad_buttons_t pressed = {0}; JOYPAD_PORT_FOREACH (i) { pressed = joypad_get_buttons_pressed(i); diff --git a/src/menu/rom_info.c b/src/menu/rom_info.c index e5b750ce..b313950c 100644 --- a/src/menu/rom_info.c +++ b/src/menu/rom_info.c @@ -835,6 +835,7 @@ static rom_err_t save_override (path_t *path, const char *id, int value, int def mini_t *ini = mini_try_load(path_get(overrides_path)); if (!ini) { + path_free(overrides_path); return ROM_ERR_SAVE_IO; }