[develop] Show F/W version in Flashcart info (#174)

<!--- Provide a general summary of your changes in the Title above -->

## Description
<!--- Describe your changes in detail -->
Add detection for the flashcart firmware version and show it within the
Flashcart Info view.

## Motivation and Context
<!--- What does this sample do? What problem does it solve? -->
<!--- If it fixes/closes/resolves an open issue, please link to the
issue here -->
The feature was incomplete.

## How Has This Been Tested?
<!-- (if applicable) -->
<!--- Please describe in detail how you tested your sample/changes. -->
<!--- Include details of your testing environment, and the tests you ran
to -->
<!--- see how your change affects other areas of the code, etc. -->

## Screenshots
<!-- (if appropriate): -->

## Types of changes
<!--- What types of changes does your code introduce? Put an `x` in all
the boxes that apply: -->
- [x] Improvement (non-breaking change that adds a new feature)
- [ ] Bug fix (fixes an issue)
- [ ] Breaking change (breaking change)
- [ ] Documentation Improvement
- [ ] Config and build (change in the configuration and build system,
has no impact on code or features)

## Checklist:
<!--- Go over all the following points, and put an `x` in all the boxes
that apply. -->
<!--- If you're unsure about any of these, don't hesitate to ask. We're
here to help! -->
- [ ] My code follows the code style of this project.
- [ ] My change requires a change to the documentation.
- [ ] I have updated the documentation accordingly.
- [ ] I have added tests to cover my changes.
- [ ] All new and existing tests passed.

<!--- It would be nice if you could sign off your contribution by
replacing the name with your GitHub user name and GitHub email contact.
-->
Signed-off-by: GITHUB_USER <GITHUB_USER_EMAIL>
This commit is contained in:
Robin Jones 2024-12-26 21:23:52 +00:00 committed by GitHub
parent 27ca0a75d5
commit 21871f6e54
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 59 additions and 2 deletions

View File

@ -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;
@ -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,

View File

@ -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,

View File

@ -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;

View File

@ -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);

View File

@ -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,

View File

@ -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);
@ -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"
@ -65,7 +72,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)),