Skip to content

Commit

Permalink
Add cart firmware version
Browse files Browse the repository at this point in the history
First attempt
  • Loading branch information
networkfusion committed Dec 26, 2024
1 parent c82f5e0 commit a48a480
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 2 deletions.
10 changes: 10 additions & 0 deletions src/flashcart/64drive/64drive.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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,
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
12 changes: 10 additions & 2 deletions src/menu/views/flashcart_info.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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"
Expand All @@ -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)),
Expand Down

0 comments on commit a48a480

Please sign in to comment.