Skip to content

Commit

Permalink
Merge branch 'develop' into rtc-adjust
Browse files Browse the repository at this point in the history
  • Loading branch information
networkfusion authored Oct 25, 2024
2 parents fa96f56 + 004f182 commit 1f02177
Show file tree
Hide file tree
Showing 19 changed files with 129 additions and 60 deletions.
2 changes: 1 addition & 1 deletion .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM debian:bookworm-slim

ARG SC64_DEPLOYER_VERSION=v2.18.0
ARG SC64_DEPLOYER_VERSION=v2.20.0
RUN apt-get update && \
apt-get upgrade -y && \
apt-get install build-essential doxygen git python3 wget -y && \
Expand Down
10 changes: 9 additions & 1 deletion docs/00_getting_started_sd.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
## First time setup of SD card

Using your PC, insert the SD card and ensure it is formatted for compatibility with your flashcart (*FAT32 and EXFAT are fully supported on the SC64*).
Using your PC, insert the SD card and ensure it is formatted for compatibility with your flashcart
#### SC64
- FAT32 and EXFAT are fully supported.
- An SD formatted with 128 kiB cluster size is recommended.

- Download the latest `sc64menu.n64` (assuming you are using an *sc64*) file from the [releases](https://github.com/Polprzewodnikowy/N64FlashcartMenu/releases/) page, then put it in the root directory of your SD card.
- Create a folder in the root of your SD card called `menu`.
- Place your ROMs on the SD Card, in any folder (**except for `menu`**).

#### Other supported flashcarts
- FAT32 recommended.
- An SD formatted with default cluster size is recommended.



### Emulator support
Emulators should be added to the `/menu/emulators` directory on the SD card.
Expand Down
15 changes: 10 additions & 5 deletions docs/99_developer_guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ You can use a dev container in VSCode to ease development.

### To deploy:
#### SC64
* Download the deployer [here](https://github.com/Polprzewodnikowy/SummerCart64/releases/download/v2.18.0/sc64-deployer-windows-v2.18.0.zip)
* Download the deployer [here](https://github.com/Polprzewodnikowy/SummerCart64/releases/download/v2.20.0/sc64-deployer-windows-v2.20.0.zip)
* Extract and place `sc64deployer.exe` in the `tools/sc64` directory.

Make sure that your firmware is compatible (currently v2.18.0+)
See: [here](https://github.com/Polprzewodnikowy/SummerCart64/blob/v2.18.0/docs/00_quick_startup_guide.md#firmware-backupupdate)
Make sure that your firmware is compatible (currently v2.20.0+)
See: [here](https://github.com/Polprzewodnikowy/SummerCart64/blob/v2.20.0/docs/00_quick_startup_guide.md#firmware-backupupdate)

##### From the devcontainer
It is not currently possible to directly communicate with USB devices.
Expand Down Expand Up @@ -45,10 +45,13 @@ For ease of development and debugging, the menu ROM can run in the [Ares emulato
* Add the required file to the correct folder on your SD card.


## Update Libdragon submodule
This repo currently uses the `preview` branch as a submodule at a specific commit.
## Update submodules
To update to the latest version, use `git submodule update --remote` from the terminal.

### libdragon
This repo currently uses the `preview` branch as a submodule at a specific commit.
* To ensure your local instance is building against it, use `cd ./libdragon && make clobber -j && make libdragon tools -j && make install tools-install -j && cd ..`

## Generate documentation
Run `doxygen` from the dev container terminal.
Make sure you fix the warnings before creating a PR!
Expand All @@ -57,6 +60,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
Expand Down
2 changes: 1 addition & 1 deletion src/boot/boot.c
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ void boot (boot_params_t *params) {
io32_t *reboot_dst = SP_MEM->IMEM;
size_t reboot_instructions = (size_t) (&reboot_size) / sizeof(uint32_t);

for (int i = 0; i < reboot_instructions; i++) {
for (unsigned int i = 0; i < reboot_instructions; i++) {
cpu_io_write(&reboot_dst[i], reboot_src[i]);
}

Expand Down
2 changes: 1 addition & 1 deletion src/flashcart/64drive/64drive.c
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ static flashcart_err_t d64_load_rom (char *rom_path, flashcart_progress_callback
size_t sdram_size = MiB(64);

size_t chunk_size = KiB(128);
for (int offset = 0; offset < sdram_size; offset += chunk_size) {
for (unsigned int offset = 0; offset < sdram_size; offset += chunk_size) {
size_t block_size = MIN(sdram_size - offset, chunk_size);
if (f_read(&fil, (void *) (ROM_ADDRESS + offset), block_size, &br) != FR_OK) {
f_close(&fil);
Expand Down
8 changes: 4 additions & 4 deletions src/flashcart/sc64/sc64.c
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ static flashcart_err_t sc64_init (void) {
{ CFG_ID_ROM_EXTENDED_ENABLE, false },
};

for (int i = 0; i < sizeof(default_config) / sizeof(default_config[0]); i++) {
for (unsigned int i = 0; i < sizeof(default_config) / sizeof(default_config[0]); i++) {
if (sc64_ll_set_config(default_config[i].id, default_config[i].value) != SC64_OK) {
return FLASHCART_ERR_INT;
}
Expand Down Expand Up @@ -285,7 +285,7 @@ static flashcart_err_t sc64_load_rom (char *rom_path, flashcart_progress_callbac
size_t extended_size = extended_enabled ? rom_size - MiB(64) : 0;

size_t chunk_size = KiB(128);
for (int offset = 0; offset < sdram_size; offset += chunk_size) {
for (unsigned int offset = 0; offset < sdram_size; offset += chunk_size) {
size_t block_size = MIN(sdram_size - offset, chunk_size);
if (f_read(&fil, (void *) (ROM_ADDRESS + offset), block_size, &br) != FR_OK) {
f_close(&fil);
Expand Down Expand Up @@ -447,7 +447,7 @@ static flashcart_err_t sc64_load_64dd_ipl (char *ipl_path, flashcart_progress_ca
}

size_t chunk_size = KiB(128);
for (int offset = 0; offset < ipl_size; offset += chunk_size) {
for (unsigned int offset = 0; offset < ipl_size; offset += chunk_size) {
size_t block_size = MIN(ipl_size - offset, chunk_size);
if (f_read(&fil, (void *) (IPL_ADDRESS + offset), block_size, &br) != FR_OK) {
f_close(&fil);
Expand Down Expand Up @@ -501,7 +501,7 @@ static flashcart_err_t sc64_load_64dd_disk (char *disk_path, flashcart_disk_para
{ CFG_ID_BUTTON_MODE, BUTTON_MODE_DD_DISK_SWAP },
};

for (int i = 0; i < sizeof(config) / sizeof(config[0]); i++) {
for (unsigned int i = 0; i < sizeof(config) / sizeof(config[0]); i++) {
if (sc64_ll_set_config(config[i].id, config[i].value) != SC64_OK) {
return FLASHCART_ERR_INT;
}
Expand Down
6 changes: 3 additions & 3 deletions src/menu/actions.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
4 changes: 3 additions & 1 deletion src/menu/actions.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@

#include "menu_state.h"


/**
* @brief Initialize the actions module
*/
void actions_init (void);
void actions_update (menu_t *menu);

Expand Down
25 changes: 16 additions & 9 deletions src/menu/components/boxart.c
Original file line number Diff line number Diff line change
Expand Up @@ -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))) {
Expand All @@ -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))) {
Expand All @@ -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) {
Expand Down
1 change: 1 addition & 0 deletions src/menu/rom_info.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
12 changes: 8 additions & 4 deletions src/menu/sound.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,7 @@ static bool sfx_enabled = false;

static void sound_reconfigure (int frequency) {
if ((frequency > 0) && (audio_get_frequency() != frequency)) {
if (sound_initialized) {
mixer_close();
audio_close();
}
sound_deinit();
audio_init(frequency, NUM_BUFFERS);
mixer_init(NUM_CHANNELS);
mp3player_mixer_init();
Expand Down Expand Up @@ -86,6 +83,13 @@ void sound_play_effect(sound_effect_t sfx) {

void sound_deinit (void) {
if (sound_initialized) {
if (sfx_enabled) {
wav64_close(&sfx_cursor);
wav64_close(&sfx_exit);
wav64_close(&sfx_setting);
wav64_close(&sfx_enter);
wav64_close(&sfx_error);
}
mixer_close();
audio_close();
sound_initialized = false;
Expand Down
17 changes: 17 additions & 0 deletions src/menu/sound.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/menu/views/error.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/menu/views/fault.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ static void draw (menu_t *menu, surface_t *d) {
rdpq_clear(RGBA32(0x7F, 0x00, 0x00, 0xFF));

const char *firmware_message = (
"Supported firmware versions:\n"
"Minimum supported firmware versions:\n"
"64drive: 2.05+\n"
"EverDrive-64: ???+\n"
"SummerCart64: 2.17.0+"
Expand Down
36 changes: 28 additions & 8 deletions src/menu/views/flashcart_info.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
#include "../sound.h"


static inline const char *format_boolean_type (bool bool_value) {
return bool_value ? "Supported" : "Unsupported";
}

static void process (menu_t *menu) {
if (menu->actions.back) {
menu->next_mode = MENU_MODE_BROWSER;
Expand All @@ -18,24 +22,40 @@ static void draw (menu_t *menu, surface_t *d) {

component_main_text_draw(
ALIGN_CENTER, VALIGN_TOP,
"FLASHCART INFORMATION\n"
"FLASHCART INFORMATION"
"\n"
"\n"
"This feature is not yet supported.\n\n"
);

// FIXME: Display:
// * cart_type
// * Firmware version
// * supported features (flashcart_features_t)


component_main_text_draw(
ALIGN_LEFT, VALIGN_TOP,
"\n"
"\n"
"Type:\n"
" %s\n\n"
"Firmware:\n"
" %s\n\n"
"Features:\n"
" Virtual 64DD: %s.\n"
" Real Time Clock: %s.\n"
" USB Debugging: %s.\n"
" CIC Detection: %s.\n"
" Region Detection: %s.\n"
"\n\n",
"SummerCart64",
"V?.?.?",
format_boolean_type(true),
format_boolean_type(true),
format_boolean_type(true),
format_boolean_type(true),
format_boolean_type(true)
);

// FIXME: Display:
// * cart_type
// * Firmware version
// * supported features (flashcart_features_t)


component_actions_bar_text_draw(
ALIGN_LEFT, VALIGN_TOP,
Expand Down
4 changes: 3 additions & 1 deletion src/menu/views/load_disk.c
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Loading

0 comments on commit 1f02177

Please sign in to comment.