From a48a48050d6b3d98ab53a19af03ee4da693ccd7f Mon Sep 17 00:00:00 2001 From: Robin Jones Date: Thu, 26 Dec 2024 15:37:57 +0000 Subject: [PATCH] Add cart firmware version First attempt --- src/flashcart/64drive/64drive.c | 10 ++++++++++ src/flashcart/ed64/ed64_vseries.c | 1 + src/flashcart/flashcart.c | 4 ++++ src/flashcart/flashcart.h | 10 ++++++++++ src/flashcart/sc64/sc64.c | 9 +++++++++ src/menu/views/flashcart_info.c | 12 ++++++++++-- 6 files changed, 44 insertions(+), 2 deletions(-) diff --git a/src/flashcart/64drive/64drive.c b/src/flashcart/64drive/64drive.c index 5b4b5d22..6f8c6a8c 100644 --- a/src/flashcart/64drive/64drive.c +++ b/src/flashcart/64drive/64drive.c @@ -82,6 +82,15 @@ static bool d64_has_feature (flashcart_features_t feature) { } } +// FIXME: show the returned firmware version info. +// static flashcart_firmware_version_t d64_get_firmware_version (void) { +// flashcart_firmware_version_t version_info; + +// d64_ll_get_version(&version_info.major, &version_info.minor, &version_info.revision); + +// return version_info; +// } + static flashcart_err_t d64_load_rom (char *rom_path, flashcart_progress_callback_t *progress) { FIL fil; UINT br; @@ -277,6 +286,7 @@ static flashcart_t flashcart_d64 = { .init = d64_init, .deinit = d64_deinit, .has_feature = d64_has_feature, + .get_firmware_version = NULL, // d64_get_firmware_version, .load_rom = d64_load_rom, .load_file = d64_load_file, .load_save = d64_load_save, diff --git a/src/flashcart/ed64/ed64_vseries.c b/src/flashcart/ed64/ed64_vseries.c index 22b6596d..02ec3f76 100644 --- a/src/flashcart/ed64/ed64_vseries.c +++ b/src/flashcart/ed64/ed64_vseries.c @@ -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, diff --git a/src/flashcart/flashcart.c b/src/flashcart/flashcart.c index 942ebd50..6b634cac 100644 --- a/src/flashcart/flashcart.c +++ b/src/flashcart/flashcart.c @@ -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; diff --git a/src/flashcart/flashcart.h b/src/flashcart/flashcart.h index fcbcf606..4a191290 100644 --- a/src/flashcart/flashcart.h +++ b/src/flashcart/flashcart.h @@ -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 */ @@ -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 */ @@ -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); diff --git a/src/flashcart/sc64/sc64.c b/src/flashcart/sc64/sc64.c index 605ae419..e53c3e27 100644 --- a/src/flashcart/sc64/sc64.c +++ b/src/flashcart/sc64/sc64.c @@ -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; @@ -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, diff --git a/src/menu/views/flashcart_info.c b/src/menu/views/flashcart_info.c index 52799644..ce28a9ba 100644 --- a/src/menu/views/flashcart_info.c +++ b/src/menu/views/flashcart_info.c @@ -26,6 +26,14 @@ static const char *format_cart_type () { } } +static const char *format_cart_version () { + // FIXME: show the returned firmware version info. + // flashcart_firmware_version_t version; + // version = flashcart_get_firmware_version(); + + return "Feature coming soon."; +} + static void process (menu_t *menu) { if (menu->actions.back) { sound_play_effect(SFX_EXIT); @@ -54,7 +62,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" @@ -65,7 +73,7 @@ static void draw (menu_t *menu, surface_t *d) { " Auto F/W Updates: %s.\n" "\n\n", format_cart_type(), - "Feature coming soon.", // 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)),