Skip to content

Commit

Permalink
Merge branch 'develop' into improve-rom-info
Browse files Browse the repository at this point in the history
  • Loading branch information
networkfusion authored Dec 30, 2024
2 parents 4b24ccc + f2cff4c commit f08e900
Show file tree
Hide file tree
Showing 22 changed files with 117 additions and 49 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.20.0
ARG SC64_DEPLOYER_VERSION=v2.20.2
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 Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ FILESYSTEM = \

$(MINIZ_OBJS): N64_CFLAGS+=-DMINIZ_NO_TIME -fcompare-debug-second
$(SPNG_OBJS): N64_CFLAGS+=-isystem $(SOURCE_DIR)/libs/miniz -DSPNG_USE_MINIZ -fcompare-debug-second
$(FILESYSTEM_DIR)/FiraMonoBold.font64: MKFONT_FLAGS+=-c 1 --size 16 -r 20-7F -r 80-1FF -r 2026-2026 --ellipsis 2026,1
$(FILESYSTEM_DIR)/FiraMonoBold.font64: MKFONT_FLAGS+=--compress 1 --outline 1 --size 16 --range 20-7F --range 80-1FF --range 2026-2026 --ellipsis 2026,1
$(FILESYSTEM_DIR)/%.wav64: AUDIOCONV_FLAGS=--wav-compress 1

$(@info $(shell mkdir -p ./$(FILESYSTEM_DIR) &> /dev/null))
Expand Down
25 changes: 17 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ An open source menu for N64 flashcarts.
## Documentation
* [Getting started guide](./docs/00_getting_started_sd.md)
* [Menu controls](./docs/01_menu_controls.md)
* [Menu customizations](./docs/07_menu_customizations.md)
* [Menu customization](./docs/07_menu_customization.md)
* [Developer guide](./docs/99_developer_guide.md)

## Video showcase (as of Oct 12 2023)
Expand All @@ -53,27 +53,36 @@ These features are subject to change:

### N64 ROM autoload
To use the autoload function, while on the `N64 ROM information` display, press the `R` button on your joypad and select the `Set ROM to autoload` option. When you restart the console, it will now only load the selected ROM rather than the menu.
NOTE: to return to the menu, hold joypad `start` button whilst powering on the console.
The autoload setting is stored in `config.ini` and persists until changed. This feature may slightly increase boot time as the menu needs to check for the Start button state.
NOTE: To return to the menu, hold the joypad `Start` button while powering on the console.

### GamePak sprites
To use N64 `GamePak` sprites, place `PNG` files within the `sd:/menu/boxart/` folder.

To use N64 GamePak sprites, place PNG files within the `sd:/menu/boxart/` folder.

#### Supported sprites
These must be `PNG` files that use the following dimensions:
* Standard N64 GamePak boxart sprites: 158x112
* Japanese N64 GamePak boxart sprites: 112x158
* 64DD boxart sprites: 129x112

Supported PNG formats:
* RGB/RGBA color formats
* 8-bit color depth

They will be loaded by directories using each character (case-sensitive) of the full 4 character Game Code (as identified in the menu ROM information).
i.e. for GoldenEye NTSC USA (NGEE), this would be `sd:/menu/boxart/N/G/E/E/boxart_front.png`.
i.e. for GoldenEye PAL (NGEP), this would be `sd:/menu/boxart/N/G/E/P/boxart_front.png`.

To improve compatibility between regions (as a fallback), you may exclude the region ID (last matched directory) for GamePaks to match with 3 letter IDs instead:
i.e. for GoldenEye, this would be `sd:/menu/boxart/N/G/E/boxart_front.png`.

**Note1:** Excluding the region ID may show the wrong boxart.
**Note2:** For future support, boxart sprites should also include: `boxart_back.png`, `boxart_top.png`, `boxart_bottom.png`, `boxart_left.png`, `boxart_right.png`.
**Warning**: Excluding the region ID may show the wrong boxart.
**Note**: For future support, boxart sprites should also include:
* `boxart_back.png`
* `boxart_top.png`
* `boxart_bottom.png`
* `boxart_left.png`
* `boxart_right.png`

As a starting point, here is a link to a boxart pack following the new structure, including `boxart_front.png` and failback images:
* [Link](https://drive.google.com/file/d/1IpCmFqmGgGwKKmlRBxYObfFR9XywaC6n/view?usp=drive_link)
Expand Down Expand Up @@ -117,14 +126,14 @@ If required, you can manually adjust the file on the SD card using your computer

### ED64 - WIP - UNTESTED AND UNSUPPORTED - USE AT OWN RISK
Currently not supported, but work is in progress (See [PR's](https://github.com/Polprzewodnikowy/N64FlashcartMenu/pulls)).
NOTE: The menu may be able to load ROM's but not perform saves and may break existing ones..
**Warning**: The menu may be able to load ROMs but cannot guarantee save functionality. Existing saves may be corrupted.

#### ED64 (Vseries)
The aim is to reach feature parity with [ED64-UnofficialOS](https://github.com/n64-tools/ED64-UnofficialOS-binaries) / [ED64-OfficialOS](https://krikzz.com/pub/support/everdrive-64/v2x-v3x/os-bin/).
Download the `OS64.v64` ROM from the latest [action run - assets] and place it in the `/ED64` folder.

#### ED64 (X series)
X Series support is currently awaiting fixes, in the meantime use the official [OS](https://krikzz.com/pub/support/everdrive-64/x-series/OS/) instead.
X Series support is currently awaiting fixes. Please use the official [OS](https://krikzz.com/pub/support/everdrive-64/x-series/OS/) for now.

#### ED64 (P clone)
Download the `OS64P.v64` ROM from the latest [action run - assets] and place it in the `/ED64P` folder.
Expand Down
5 changes: 4 additions & 1 deletion docs/00_getting_started_sd.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
## First time setup of SD card

Using your PC, insert the SD card and ensure it is formatted for compatibility with your flashcart
### Flashcarts
Using your PC, insert the SD card and ensure it is formatted for compatibility with your flashcart.
**warning** Filenames are expected to be part of the ASCII character set. Unicode characters are not fully supported and may cause a crash screen.

#### SC64
- FAT32 and EXFAT are fully supported.
- An SD formatted with 128 kiB cluster size is recommended.
Expand Down
2 changes: 1 addition & 1 deletion docs/01_menu_controls.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Use the C-Up and C-Down buttons
### DD ROMs

#### Expansion Disks
To load an expansion disk (e.g. F-Zero X) browse to the N64 ROM and load it (but not start it) and then browse to the DD expansion file and press the `R` button.
To load an expansion disk (e.g. F-Zero X) browse to the N64 ROM and load it (but not start it) and then browse to the DD expansion file and press the `L` or `Z` button.

#### Disk swapping
This feature is not currently available in the menu.
Expand Down
26 changes: 26 additions & 0 deletions src/flashcart/64drive/64drive.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,31 @@ static bool d64_has_feature (flashcart_features_t feature) {
}
}

/**
* @brief Retrieves the firmware version of the 64drive device.
*
* The firmware version is returned as a flashcart_firmware_version_t structure, with each field
* including the major, minor, and revision numbers.
* The major version is set to 1 for 64drive variant A, and 2 for 64drive variant B.
*
* @return A flashcart_firmware_version_t structure containing the firmware version information.
*/
static flashcart_firmware_version_t d64_get_firmware_version (void) {
flashcart_firmware_version_t version_info;

d64_ll_get_version(&device_variant, &version_info.minor, &version_info.revision);

if (device_variant == DEVICE_VARIANT_A) {
version_info.major = 1;
} else if (device_variant == DEVICE_VARIANT_B) {
version_info.major = 2;
} else {
version_info.major = 0;
}

return version_info;
}

static flashcart_err_t d64_load_rom (char *rom_path, flashcart_progress_callback_t *progress) {
FIL fil;
UINT br;
Expand Down Expand Up @@ -277,6 +302,7 @@ static flashcart_t flashcart_d64 = {
.init = d64_init,
.deinit = d64_deinit,
.has_feature = d64_has_feature,
.get_firmware_version = d64_get_firmware_version,
.load_rom = d64_load_rom,
.load_file = d64_load_file,
.load_save = d64_load_save,
Expand Down
1 change: 1 addition & 0 deletions src/flashcart/ed64/ed64_vseries.c
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ static flashcart_t flashcart_ed64_vseries = {
.init = ed64_vseries_init,
.deinit = ed64_vseries_deinit,
.has_feature = ed64_vseries_has_feature,
.get_firmware_version = NULL, // FIXME: show the returned firmware version info.
.load_rom = ed64_vseries_load_rom,
.load_file = ed64_vseries_load_file,
.load_save = ed64_vseries_load_save,
Expand Down
4 changes: 4 additions & 0 deletions src/flashcart/flashcart.c
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,10 @@ bool flashcart_has_feature (flashcart_features_t feature) {
return flashcart->has_feature(feature);
}

flashcart_firmware_version_t flashcart_get_firmware_version (void) {
return flashcart->get_firmware_version();
}

flashcart_err_t flashcart_load_rom (char *rom_path, bool byte_swap, flashcart_progress_callback_t *progress) {
flashcart_err_t err;

Expand Down
10 changes: 10 additions & 0 deletions src/flashcart/flashcart.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,13 @@ typedef struct {
uint8_t defect_tracks[16][12];
} flashcart_disk_parameters_t;

/** @brief Flashcart Firmware version Structure. */
typedef struct {
uint16_t major;
uint16_t minor;
uint32_t revision;
} flashcart_firmware_version_t;

typedef void flashcart_progress_callback_t (float progress);

/** @brief Flashcart Structure */
Expand All @@ -67,6 +74,8 @@ typedef struct {
flashcart_err_t (*deinit) (void);
/** @brief The flashcart feature function */
bool (*has_feature) (flashcart_features_t feature);
/** @brief The flashcart firmware version function */
flashcart_firmware_version_t (*get_firmware_version) (void);
/** @brief The flashcart ROM load function */
flashcart_err_t (*load_rom) (char *rom_path, flashcart_progress_callback_t *progress);
/** @brief The flashcart file load function */
Expand All @@ -88,6 +97,7 @@ char *flashcart_convert_error_message (flashcart_err_t err);
flashcart_err_t flashcart_init (const char **storage_prefix);
flashcart_err_t flashcart_deinit (void);
bool flashcart_has_feature (flashcart_features_t feature);
flashcart_firmware_version_t flashcart_get_firmware_version (void);
flashcart_err_t flashcart_load_rom (char *rom_path, bool byte_swap, flashcart_progress_callback_t *progress);
flashcart_err_t flashcart_load_file (char *file_path, uint32_t rom_offset, uint32_t file_offset);
flashcart_err_t flashcart_load_save (char *save_path, flashcart_save_type_t save_type);
Expand Down
9 changes: 9 additions & 0 deletions src/flashcart/sc64/sc64.c
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,14 @@ static bool disk_load_sector_table (char *path, uint32_t *sector_table_offset, u
return false;
}

static flashcart_firmware_version_t sc64_get_firmware_version (void) {
flashcart_firmware_version_t version_info;

sc64_ll_get_version(&version_info.major, &version_info.minor, &version_info.revision);

return version_info;
}


static flashcart_err_t sc64_init (void) {
uint16_t major;
Expand Down Expand Up @@ -572,6 +580,7 @@ static flashcart_t flashcart_sc64 = {
.init = sc64_init,
.deinit = sc64_deinit,
.has_feature = sc64_has_feature,
.get_firmware_version = sc64_get_firmware_version,
.load_rom = sc64_load_rom,
.load_file = sc64_load_file,
.load_save = sc64_load_save,
Expand Down
2 changes: 1 addition & 1 deletion src/menu/menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ static void menu_init (boot_params_t *boot_params) {

path_free(path);

sound_use_sfx(menu->settings.sound_enabled);
sound_use_sfx(menu->settings.soundfx_enabled);

menu->browser.directory = path_init(menu->storage_prefix, menu->settings.default_directory);
if (!directory_exists(path_get(menu->browser.directory))) {
Expand Down
1 change: 1 addition & 0 deletions src/menu/menu_state.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ typedef struct {
rom_info_t rom_info;
path_t *disk_path;
disk_info_t disk_info;
bool combined_disk_rom;
} load;

struct {
Expand Down
6 changes: 3 additions & 3 deletions src/menu/settings.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ static settings_t init = {
.show_protected_entries = false,
.default_directory = "/",
.use_saves_folder = true,
.sound_enabled = true,
.soundfx_enabled = false,
.rom_autoload_enabled = false,
.rom_autoload_path = "",
.rom_autoload_filename = "",
Expand Down Expand Up @@ -42,7 +42,7 @@ void settings_load (settings_t *settings) {
settings->show_protected_entries = mini_get_bool(ini, "menu", "show_protected_entries", init.show_protected_entries);
settings->default_directory = strdup(mini_get_string(ini, "menu", "default_directory", init.default_directory));
settings->use_saves_folder = mini_get_bool(ini, "menu", "use_saves_folder", init.use_saves_folder);
settings->sound_enabled = mini_get_bool(ini, "menu", "sound_enabled", init.sound_enabled);
settings->soundfx_enabled = mini_get_bool(ini, "menu", "soundfx_enabled", init.soundfx_enabled);

settings->rom_autoload_enabled = mini_get_bool(ini, "menu", "autoload_rom_enabled", init.rom_autoload_enabled);
settings->rom_autoload_path = strdup(mini_get_string(ini, "autoload", "rom_path", init.rom_autoload_path));
Expand All @@ -62,7 +62,7 @@ void settings_save (settings_t *settings) {
mini_set_bool(ini, "menu", "show_protected_entries", settings->show_protected_entries);
mini_set_string(ini, "menu", "default_directory", settings->default_directory);
mini_set_bool(ini, "menu", "use_saves_folder", settings->use_saves_folder);
mini_set_bool(ini, "menu", "sound_enabled", settings->sound_enabled);
mini_set_bool(ini, "menu", "soundfx_enabled", settings->soundfx_enabled);
mini_set_bool(ini, "menu", "autoload_rom_enabled", settings->rom_autoload_enabled);
mini_set_string(ini, "autoload", "rom_path", settings->rom_autoload_path);
mini_set_string(ini, "autoload", "rom_filename", settings->rom_autoload_filename);
Expand Down
2 changes: 1 addition & 1 deletion src/menu/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ typedef struct {
bool bgm_enabled;

/** @brief Enable Sounds */
bool sound_enabled;
bool soundfx_enabled;

/** @brief Enable rumble feedback */
bool rumble_enabled;
Expand Down
10 changes: 5 additions & 5 deletions src/menu/views/browser.c
Original file line number Diff line number Diff line change
Expand Up @@ -278,11 +278,11 @@ static void set_menu_next_mode (menu_t *menu, void *arg) {

static component_context_menu_t settings_context_menu = {
.list = {
{ .text = "Edit settings", .action = set_menu_next_mode, .arg = (void *) (MENU_MODE_SETTINGS_EDITOR) },
{ .text = "Show system info", .action = set_menu_next_mode, .arg = (void *) (MENU_MODE_SYSTEM_INFO) },
{ .text = "Show credits", .action = set_menu_next_mode, .arg = (void *) (MENU_MODE_CREDITS) },
{ .text = "Adjust RTC", .action = set_menu_next_mode, .arg = (void *) (MENU_MODE_RTC) },
{ .text = "Show cart info", .action = set_menu_next_mode, .arg = (void *) (MENU_MODE_FLASHCART) },
{ .text = "Menu settings", .action = set_menu_next_mode, .arg = (void *) (MENU_MODE_SETTINGS_EDITOR) },
{ .text = "Time (RTC) settings", .action = set_menu_next_mode, .arg = (void *) (MENU_MODE_RTC) },
{ .text = "Menu information", .action = set_menu_next_mode, .arg = (void *) (MENU_MODE_CREDITS) },
{ .text = "Flashcart information", .action = set_menu_next_mode, .arg = (void *) (MENU_MODE_FLASHCART) },
{ .text = "N64 information", .action = set_menu_next_mode, .arg = (void *) (MENU_MODE_SYSTEM_INFO) },
COMPONENT_CONTEXT_MENU_LIST_END,
}
};
Expand Down
2 changes: 1 addition & 1 deletion src/menu/views/credits.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ static void draw (menu_t *menu, surface_t *d) {
" Robin Jones / NetworkFusion\n"
" Mateusz Faderewski / Polprzewodnikowy\n"
"Credits:\n"
" N64Brew / libdragon contributors\n"
" N64Brew / libDragon contributors\n"
"\n"
"OSS software used:\n"
" libdragon (UNLICENSE License)\n"
Expand Down
11 changes: 9 additions & 2 deletions src/menu/views/flashcart_info.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,13 @@ static const char *format_cart_type () {
}
}

static const char *format_cart_version () {
flashcart_firmware_version_t version = flashcart_get_firmware_version();
static char buffer[16];
sprintf(buffer, "%u.%u.%lu", version.major, version.minor, version.revision);
return buffer;
}

static void process (menu_t *menu) {
if (menu->actions.back) {
sound_play_effect(SFX_EXIT);
Expand Down Expand Up @@ -54,7 +61,7 @@ static void draw (menu_t *menu, surface_t *d) {
"Type:\n"
" %s\n\n"
"Firmware:\n"
" %s\n\n"
" Version: %s\n\n"
"Features:\n"
" Virtual 64DD: %s.\n"
" Real Time Clock: %s.\n"
Expand All @@ -65,7 +72,7 @@ static void draw (menu_t *menu, surface_t *d) {
" Auto F/W Updates: %s.\n"
"\n\n",
format_cart_type(),
"Not Available", // TODO get cart firmware version(s).
format_cart_version(),
format_boolean_type(flashcart_has_feature(FLASHCART_FEATURE_64DD)),
format_boolean_type(flashcart_has_feature(FLASHCART_FEATURE_RTC)),
format_boolean_type(flashcart_has_feature(FLASHCART_FEATURE_USB)),
Expand Down
14 changes: 6 additions & 8 deletions src/menu/views/load_disk.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
#include "../sound.h"
#include "views.h"


static bool load_disk_with_rom;
static component_boxart_t *boxart;


Expand All @@ -31,10 +29,10 @@ static char *format_disk_region (disk_region_t region) {
static void process (menu_t *menu) {
if (menu->actions.enter) {
menu->boot_pending.disk_file = true;
load_disk_with_rom = false;
} else if (menu->actions.options && menu->load.rom_path) {
menu->load.combined_disk_rom = false;
} else if (menu->actions.lz_context && menu->load.rom_path) {
menu->boot_pending.disk_file = true;
load_disk_with_rom = true;
menu->load.combined_disk_rom = true;
sound_play_effect(SFX_SETTING);
} else if (menu->actions.back) {
sound_play_effect(SFX_EXIT);
Expand Down Expand Up @@ -89,7 +87,7 @@ static void draw (menu_t *menu, surface_t *d) {
if (menu->load.rom_path) {
ui_components_actions_bar_text_draw(
ALIGN_RIGHT, VALIGN_TOP,
"R: Load with ROM"
"L|Z: Load with ROM\n"
);
}

Expand Down Expand Up @@ -118,7 +116,7 @@ static void draw_progress (float progress) {
static void load (menu_t *menu) {
cart_load_err_t err;

if (menu->load.rom_path && load_disk_with_rom) {
if (menu->load.rom_path && menu->load.combined_disk_rom) {
err = cart_load_n64_rom_and_save(menu, draw_progress);
if (err != CART_LOAD_OK) {
menu_show_error(menu, cart_load_convert_error_message(err));
Expand All @@ -134,7 +132,7 @@ static void load (menu_t *menu) {

menu->next_mode = MENU_MODE_BOOT;

if (load_disk_with_rom) {
if (menu->load.combined_disk_rom) {
menu->boot_params->device_type = BOOT_DEVICE_TYPE_ROM;
menu->boot_params->detect_cic_seed = rom_info_get_cic_seed(&menu->load.rom_info, &menu->boot_params->cic_seed);
switch (rom_info_get_tv_type(&menu->load.rom_info)) {
Expand Down
2 changes: 1 addition & 1 deletion src/menu/views/rtc.c
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ static void draw (menu_t *menu, surface_t *d) {

ui_components_actions_bar_text_draw(
ALIGN_LEFT, VALIGN_TOP,
"A: Change\n"
"A: Adjust time\n"
"B: Back"
);
}
Expand Down
Loading

0 comments on commit f08e900

Please sign in to comment.