Merge branch 'develop' into add-rom-patcher

This commit is contained in:
Robin Jones 2024-11-08 01:00:45 +00:00 committed by GitHub
commit 5116725746
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 266 additions and 25 deletions

View File

@ -29,6 +29,7 @@ SRCS = \
flashcart/64drive/64drive_ll.c \
flashcart/64drive/64drive.c \
flashcart/flashcart_utils.c \
flashcart/ed64/ed64_vseries.c \
flashcart/flashcart.c \
flashcart/sc64/sc64_ll.c \
flashcart/sc64/sc64.c \

View File

@ -114,10 +114,20 @@ If required, you can manually adjust the file on the SD card using your computer
* Download the latest `menu.bin` file from the [releases](https://github.com/Polprzewodnikowy/N64FlashcartMenu/releases/) page, then put it in the root directory of your SD card.
### ED64 & ED64P
### 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..
The aim is to replace [Altra64](https://github.com/networkfusion/altra64) and [ED64-UnofficialOS](https://github.com/n64-tools/ED64-UnofficialOS-binaries).
#### 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.
#### ED64 (P clone)
Download the `OS64P.v64` ROM from the latest [action run - assets] and place it in the `/ED64P` folder.
The aim is to reach feature parity with [Altra64](https://github.com/networkfusion/altra64)
# Open source software and licenses used

View File

@ -0,0 +1,155 @@
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <fatfs/ff.h>
#include <libdragon.h>
#include "utils/fs.h"
#include "utils/utils.h"
#include "../flashcart_utils.h"
#include "ed64_vseries.h"
typedef enum {
ED64_V1_0 = 110,
ED64_V2_0 = 320,
ED64_V2_5 = 325,
ED64_V3_0 = 330,
} ed64_vseries_device_variant_t;
/* ED64 save location base address */
#define SRAM_ADDRESS (0xA8000000)
/* ED64 ROM location base address */
#define ROM_ADDRESS (0xB0000000)
static flashcart_err_t ed64_vseries_init (void) {
return FLASHCART_OK;
}
static flashcart_err_t ed64_vseries_deinit (void) {
return FLASHCART_OK;
}
static ed64_vseries_device_variant_t get_cart_model() {
ed64_vseries_device_variant_t variant = ED64_V1_0; // FIXME: check cart model from ll for better feature handling.
return variant;
}
static bool ed64_vseries_has_feature (flashcart_features_t feature) {
bool is_model_v3 = (get_cart_model() == ED64_V3_0);
switch (feature) {
case FLASHCART_FEATURE_RTC: return is_model_v3 ? true : false;
case FLASHCART_FEATURE_USB: return is_model_v3 ? true : false;
case FLASHCART_FEATURE_AUTO_CIC: return is_model_v3 ? true : false;
default: return false;
}
}
static flashcart_err_t ed64_vseries_load_rom (char *rom_path, flashcart_progress_callback_t *progress) {
FIL fil;
UINT br;
if (f_open(&fil, strip_fs_prefix(rom_path), FA_READ) != FR_OK) {
return FLASHCART_ERR_LOAD;
}
fatfs_fix_file_size(&fil);
size_t rom_size = f_size(&fil);
if (rom_size > MiB(64)) {
f_close(&fil);
return FLASHCART_ERR_LOAD;
}
size_t sdram_size = MiB(64);
size_t chunk_size = KiB(128);
for (int offset = 0; offset < sdram_size; offset += chunk_size) {
size_t block_size = MIN(sdram_size - offset, chunk_size);
if (f_read(&fil, (void *) (ROM_ADDRESS + offset), block_size, &br) != FR_OK) {
f_close(&fil);
return FLASHCART_ERR_LOAD;
}
if (progress) {
progress(f_tell(&fil) / (float) (f_size(&fil)));
}
}
if (f_tell(&fil) != rom_size) {
f_close(&fil);
return FLASHCART_ERR_LOAD;
}
if (f_close(&fil) != FR_OK) {
return FLASHCART_ERR_LOAD;
}
return FLASHCART_OK;
}
static flashcart_err_t ed64_vseries_load_file (char *file_path, uint32_t rom_offset, uint32_t file_offset) {
FIL fil;
UINT br;
if (f_open(&fil, strip_fs_prefix(file_path), FA_READ) != FR_OK) {
return FLASHCART_ERR_LOAD;
}
fatfs_fix_file_size(&fil);
size_t file_size = f_size(&fil) - file_offset;
if (file_size > (MiB(64) - rom_offset)) {
f_close(&fil);
return FLASHCART_ERR_ARGS;
}
if (f_lseek(&fil, file_offset) != FR_OK) {
f_close(&fil);
return FLASHCART_ERR_LOAD;
}
if (f_read(&fil, (void *) (ROM_ADDRESS + rom_offset), file_size, &br) != FR_OK) {
f_close(&fil);
return FLASHCART_ERR_LOAD;
}
if (br != file_size) {
f_close(&fil);
return FLASHCART_ERR_LOAD;
}
if (f_close(&fil) != FR_OK) {
return FLASHCART_ERR_LOAD;
}
return FLASHCART_OK;
}
static flashcart_err_t ed64_vseries_load_save (char *save_path) {
// FIXME: the savetype will be none.
return FLASHCART_OK;
}
static flashcart_err_t ed64_vseries_set_save_type (flashcart_save_type_t save_type) {
// FIXME: the savetype will be none.
return FLASHCART_OK;
}
static flashcart_t flashcart_ed64_vseries = {
.init = ed64_vseries_init,
.deinit = ed64_vseries_deinit,
.has_feature = ed64_vseries_has_feature,
.load_rom = ed64_vseries_load_rom,
.load_file = ed64_vseries_load_file,
.load_save = ed64_vseries_load_save,
.load_64dd_ipl = NULL,
.load_64dd_disk = NULL,
.set_save_type = ed64_vseries_set_save_type,
.set_save_writeback = NULL,
};
flashcart_t *ed64_vseries_get_flashcart (void) {
return &flashcart_ed64_vseries;
}

View File

@ -0,0 +1,24 @@
/**
* @file ed64_vseries.h
* @brief ED64 Vseries flashcart support
* @ingroup flashcart
*/
#ifndef FLASHCART_ED64_VSERIES_H__
#define FLASHCART_ED64_VSERIES_H__
#include "../flashcart.h"
/**
* @addtogroup ED64_Vseries
* @{
*/
flashcart_t *ed64_vseries_get_flashcart (void);
/** @} */ /* ED64_Vseries */
#endif

View File

@ -0,0 +1,24 @@
/**
* @file ed64xseries.h
* @brief ED64 Xseries flashcart support
* @ingroup flashcart
*/
#ifndef FLASHCART_ED64XSERIES_H__
#define FLASHCART_ED64XSERIES_H__
#include "../flashcart.h"
/**
* @addtogroup ED64_Xseries
* @{
*/
flashcart_t *ed64xseries_get_flashcart (void);
/** @} */ /* ED64_Xseries */
#endif

View File

@ -10,6 +10,7 @@
#include "flashcart.h"
#include "flashcart_utils.h"
#include "ed64/ed64_vseries.h"
#include "64drive/64drive.h"
#include "sc64/sc64.h"
@ -108,10 +109,13 @@ flashcart_err_t flashcart_init (const char **storage_prefix) {
flashcart = d64_get_flashcart();
break;
case CART_EDX: // Series X EverDrive-64
break;
// FIXME: this is commented out awaiting a fix from libcart.
// case CART_EDX: // Series X EverDrive-64
// flashcart = ed64_xseries_get_flashcart();
// break;
case CART_ED: // Original EverDrive-64
case CART_ED: // Series V EverDrive-64 or clone
flashcart = ed64_vseries_get_flashcart();
break;
case CART_SC: // SummerCart64

View File

@ -119,7 +119,7 @@ static void process (menu_t *menu) {
sound_play_effect(SFX_EXIT);
menu->next_mode = MENU_MODE_BROWSER;
}
else if (menu->actions.enter && !is_editing_mode) {
else if (menu->actions.enter && !is_editing_mode && menu->current_time >= 0) {
rtc_tm = *gmtime(&menu->current_time);
is_editing_mode = true;
}
@ -169,6 +169,9 @@ static void draw (menu_t *menu, surface_t *d) {
component_layout_draw();
if (!is_editing_mode) {
if( menu->current_time >= 0 ) {
component_main_text_draw(
ALIGN_CENTER, VALIGN_TOP,
"ADJUST REAL TIME CLOCK\n"
@ -183,13 +186,33 @@ static void draw (menu_t *menu, surface_t *d) {
menu->current_time >= 0 ? ctime(&menu->current_time) : "Unknown"
);
if (!is_editing_mode) {
component_actions_bar_text_draw(
ALIGN_LEFT, VALIGN_TOP,
"A: Change\n"
"B: Back"
);
}
else {
component_main_text_draw(
ALIGN_CENTER, VALIGN_TOP,
"ADJUST REAL TIME CLOCK\n"
"\n"
"\n"
"This cart does not support a real time clock."
"\n"
"Current date & time: %s\n"
"\n",
menu->current_time >= 0 ? ctime(&menu->current_time) : "Unknown"
);
component_actions_bar_text_draw(
ALIGN_LEFT, VALIGN_TOP,
"\n"
"B: Back"
);
}
}
else {
component_actions_bar_text_draw(
ALIGN_RIGHT, VALIGN_TOP,