Skip to content

Commit

Permalink
Merge branch 'develop' into ed64-xseries
Browse files Browse the repository at this point in the history
  • Loading branch information
networkfusion authored Oct 25, 2024
2 parents 490e624 + f65b345 commit f61c590
Show file tree
Hide file tree
Showing 30 changed files with 197 additions and 99 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
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ jobs:
- uses: actions/checkout@v4

- name: Run Doxygen
uses: mattnotmitt/doxygen-action@1.9.5
uses: mattnotmitt/doxygen-action@v1
with:
doxyfile-path: './Doxyfile'

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
3 changes: 2 additions & 1 deletion src/flashcart/64drive/64drive.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ static bool d64_has_feature (flashcart_features_t feature) {
case FLASHCART_FEATURE_USB: return true;
case FLASHCART_FEATURE_AUTO_CIC: return true;
case FLASHCART_FEATURE_AUTO_REGION: return true;
case FLASHCART_FEATURE_SAVE_WRITEBACK: return true;
default: return false;
}
}
Expand All @@ -101,7 +102,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
3 changes: 3 additions & 0 deletions src/flashcart/flashcart.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ typedef enum {
FLASHCART_FEATURE_USB,
FLASHCART_FEATURE_AUTO_CIC,
FLASHCART_FEATURE_AUTO_REGION,
FLASHCART_FEATURE_DIAGNOSTIC_DATA,
FLASHCART_FEATURE_BIOS_UPDATE_FROM_MENU,
FLASHCART_FEATURE_SAVE_WRITEBACK
} flashcart_features_t;

/** @brief Flashcart save type enumeration */
Expand Down
10 changes: 6 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 All @@ -256,6 +256,8 @@ static bool sc64_has_feature (flashcart_features_t feature) {
case FLASHCART_FEATURE_USB: return true;
case FLASHCART_FEATURE_AUTO_CIC: return true;
case FLASHCART_FEATURE_AUTO_REGION: return true;
case FLASHCART_FEATURE_DIAGNOSTIC_DATA: return true;
case FLASHCART_FEATURE_SAVE_WRITEBACK: return true;
default: return false;
}
}
Expand Down Expand Up @@ -285,7 +287,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 +449,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 +503,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
2 changes: 1 addition & 1 deletion src/libs/miniz
Submodule miniz updated 4 files
+31 −23 CMakeLists.txt
+5 −4 miniz_zip.c
+2 −1 miniz_zip.h
+31 −1 tests/main.cpp
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
4 changes: 2 additions & 2 deletions src/menu/components.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ void component_background_draw (void);
void component_file_list_draw (entry_t *list, int entries, int selected);

typedef struct component_context_menu {
int count;
int selected;
int row_count;
int row_selected;
bool hide_pending;
struct component_context_menu *parent;
struct component_context_menu *submenu;
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
40 changes: 20 additions & 20 deletions src/menu/components/context_menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,22 @@ static component_context_menu_t *get_current_submenu (component_context_menu_t *


void component_context_menu_init (component_context_menu_t *cm) {
cm->selected = -1;
cm->count = 0;
cm->row_selected = -1;
cm->row_count = 0;
cm->hide_pending = false;
cm->parent = NULL;
for (int i = 0; (cm->list[i].text) != NULL; i++) {
cm->count += 1;
cm->row_count += 1;
}
}

void component_context_menu_show (component_context_menu_t *cm) {
cm->selected = 0;
cm->row_selected = 0;
cm->submenu = NULL;
}

bool component_context_menu_process (menu_t *menu, component_context_menu_t *cm) {
if (!cm || (cm->selected < 0)) {
if (!cm || (cm->row_selected < 0)) {
return false;
}

Expand All @@ -44,26 +44,26 @@ bool component_context_menu_process (menu_t *menu, component_context_menu_t *cm)
}
sound_play_effect(SFX_EXIT);
} else if (menu->actions.enter) {
if (cm->list[cm->selected].submenu) {
cm->submenu = cm->list[cm->selected].submenu;
if (cm->list[cm->row_selected].submenu) {
cm->submenu = cm->list[cm->row_selected].submenu;
component_context_menu_init(cm->submenu);
cm->submenu->selected = 0;
cm->submenu->row_selected = 0;
cm->submenu->parent = cm;
} else if (cm->list[cm->selected].action) {
cm->list[cm->selected].action(menu, cm->list[cm->selected].arg);
} else if (cm->list[cm->row_selected].action) {
cm->list[cm->row_selected].action(menu, cm->list[cm->row_selected].arg);
top->hide_pending = true;
}
sound_play_effect(SFX_ENTER);
} else if (menu->actions.go_up) {
cm->selected -= 1;
if (cm->selected < 0) {
cm->selected = 0;
cm->row_selected -= 1;
if (cm->row_selected < 0) {
cm->row_selected = 0;
}
sound_play_effect(SFX_CURSOR);
} else if (menu->actions.go_down) {
cm->selected += 1;
if (cm->selected >= cm->count) {
cm->selected = (cm->count - 1);
cm->row_selected += 1;
if (cm->row_selected >= cm->row_count) {
cm->row_selected = (cm->row_count - 1);
}
sound_play_effect(SFX_CURSOR);
}
Expand All @@ -72,7 +72,7 @@ bool component_context_menu_process (menu_t *menu, component_context_menu_t *cm)
}

void component_context_menu_draw (component_context_menu_t *cm) {
if (!cm || (cm->selected < 0)) {
if (!cm || (cm->row_selected < 0)) {
return;
}

Expand All @@ -92,7 +92,7 @@ void component_context_menu_draw (component_context_menu_t *cm) {
NULL
);

for (int i = 0; i < cm->count; i++) {
for (int i = 0; i < cm->row_count; i++) {
const char *text = cm->list[i].text;
rdpq_paragraph_builder_span(text, strlen(text));
if (cm->list[i + 1].text != NULL) {
Expand All @@ -110,7 +110,7 @@ void component_context_menu_draw (component_context_menu_t *cm) {
int highlight_x0 = DISPLAY_CENTER_X - (width / 2);
int highlight_x1 = DISPLAY_CENTER_X + (width / 2);
int highlight_height = (layout->bbox.y1 - layout->bbox.y0) / layout->nlines;
int highlight_y = VISIBLE_AREA_Y0 + layout->bbox.y0 + ((cm->selected) * highlight_height);
int highlight_y = VISIBLE_AREA_Y0 + layout->bbox.y0 + ((cm->row_selected) * highlight_height);

component_box_draw(
highlight_x0,
Expand All @@ -126,6 +126,6 @@ void component_context_menu_draw (component_context_menu_t *cm) {

if (top->hide_pending) {
top->hide_pending = false;
top->selected = -1;
top->row_selected = -1;
}
}
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
Loading

0 comments on commit f61c590

Please sign in to comment.