Skip to content

Commit

Permalink
Merge branch 'develop' into cpak-management
Browse files Browse the repository at this point in the history
  • Loading branch information
networkfusion authored Dec 27, 2024
2 parents 72c7b45 + fb75890 commit 694cd12
Show file tree
Hide file tree
Showing 11 changed files with 69 additions and 13 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 @@ -99,7 +99,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
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
1 change: 1 addition & 0 deletions src/menu/menu_state.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,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
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

0 comments on commit 694cd12

Please sign in to comment.