mirror of
https://github.com/Polprzewodnikowy/N64FlashcartMenu.git
synced 2024-11-25 03:56:54 +01:00
Add required changes before merge
This commit is contained in:
parent
d3c5eabd17
commit
fbe387eafc
@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
extern int ed_exit(void);
|
extern int ed_exit(void);
|
||||||
|
|
||||||
static flashcart_error_t ed64_init (void) {
|
static flashcart_err_t ed64_init (void) {
|
||||||
|
|
||||||
// TODO: partly already done, see https://github.com/DragonMinded/libdragon/blob/4ec469d26b6dc4e308caf3d5b86c2b340b708bbd/src/libcart/cart.c#L1064
|
// TODO: partly already done, see https://github.com/DragonMinded/libdragon/blob/4ec469d26b6dc4e308caf3d5b86c2b340b708bbd/src/libcart/cart.c#L1064
|
||||||
|
|
||||||
@ -26,7 +26,7 @@ static flashcart_error_t ed64_init (void) {
|
|||||||
return FLASHCART_OK;
|
return FLASHCART_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static flashcart_error_t ed64_deinit (void) {
|
static flashcart_err_t ed64_deinit (void) {
|
||||||
|
|
||||||
// For the moment, just use libCart exit.
|
// For the moment, just use libCart exit.
|
||||||
ed_exit();
|
ed_exit();
|
||||||
@ -34,12 +34,19 @@ static flashcart_error_t ed64_deinit (void) {
|
|||||||
return FLASHCART_OK;
|
return FLASHCART_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static flashcart_error_t ed64_load_rom (char *rom_path, flashcart_progress_callback_t *progress) {
|
static bool ed64_has_feature (flashcart_features_t feature) {
|
||||||
|
switch (feature) {
|
||||||
|
case FLASHCART_FEATURE_64DD: return false;
|
||||||
|
default: return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static flashcart_err_t ed64_load_rom (char *rom_path, flashcart_progress_callback_t *progress) {
|
||||||
FIL fil;
|
FIL fil;
|
||||||
UINT br;
|
UINT br;
|
||||||
|
|
||||||
if (f_open(&fil, strip_sd_prefix(rom_path), FA_READ) != FR_OK) {
|
if (f_open(&fil, strip_sd_prefix(rom_path), FA_READ) != FR_OK) {
|
||||||
return FLASHCART_ERROR_LOAD;
|
return FLASHCART_ERR_LOAD;
|
||||||
}
|
}
|
||||||
|
|
||||||
fix_file_size(&fil);
|
fix_file_size(&fil);
|
||||||
@ -49,7 +56,7 @@ static flashcart_error_t ed64_load_rom (char *rom_path, flashcart_progress_callb
|
|||||||
// FIXME: if the cart is not V3 or X5 or X7, we need to - 128KiB
|
// FIXME: if the cart is not V3 or X5 or X7, we need to - 128KiB
|
||||||
if (rom_size > MiB(64) - KiB(128)) {
|
if (rom_size > MiB(64) - KiB(128)) {
|
||||||
f_close(&fil);
|
f_close(&fil);
|
||||||
return FLASHCART_ERROR_LOAD;
|
return FLASHCART_ERR_LOAD;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -60,7 +67,7 @@ static flashcart_error_t ed64_load_rom (char *rom_path, flashcart_progress_callb
|
|||||||
size_t block_size = MIN(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) {
|
if (f_read(&fil, (void *) (ROM_ADDRESS + offset), block_size, &br) != FR_OK) {
|
||||||
f_close(&fil);
|
f_close(&fil);
|
||||||
return FLASHCART_ERROR_LOAD;
|
return FLASHCART_ERR_LOAD;
|
||||||
}
|
}
|
||||||
if (progress) {
|
if (progress) {
|
||||||
progress(f_tell(&fil) / (float) (f_size(&fil)));
|
progress(f_tell(&fil) / (float) (f_size(&fil)));
|
||||||
@ -68,23 +75,23 @@ static flashcart_error_t ed64_load_rom (char *rom_path, flashcart_progress_callb
|
|||||||
}
|
}
|
||||||
if (f_tell(&fil) != sdram_size) {
|
if (f_tell(&fil) != sdram_size) {
|
||||||
f_close(&fil);
|
f_close(&fil);
|
||||||
return FLASHCART_ERROR_LOAD;
|
return FLASHCART_ERR_LOAD;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (f_close(&fil) != FR_OK) {
|
if (f_close(&fil) != FR_OK) {
|
||||||
return FLASHCART_ERROR_LOAD;
|
return FLASHCART_ERR_LOAD;
|
||||||
}
|
}
|
||||||
|
|
||||||
return FLASHCART_OK;
|
return FLASHCART_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static flashcart_error_t ed64_load_file (char *file_path, uint32_t rom_offset, uint32_t file_offset) {
|
static flashcart_err_t ed64_load_file (char *file_path, uint32_t rom_offset, uint32_t file_offset) {
|
||||||
FIL fil;
|
FIL fil;
|
||||||
UINT br;
|
UINT br;
|
||||||
|
|
||||||
if (f_open(&fil, strip_sd_prefix(file_path), FA_READ) != FR_OK) {
|
if (f_open(&fil, strip_sd_prefix(file_path), FA_READ) != FR_OK) {
|
||||||
return FLASHCART_ERROR_LOAD;
|
return FLASHCART_ERR_LOAD;
|
||||||
}
|
}
|
||||||
|
|
||||||
fix_file_size(&fil);
|
fix_file_size(&fil);
|
||||||
@ -94,31 +101,31 @@ static flashcart_error_t ed64_load_file (char *file_path, uint32_t rom_offset, u
|
|||||||
// FIXME: if the cart is not V3 or X5 or X7, we need to - 128KiB
|
// FIXME: if the cart is not V3 or X5 or X7, we need to - 128KiB
|
||||||
if (file_size > (MiB(64) - KiB(128) - rom_offset)) {
|
if (file_size > (MiB(64) - KiB(128) - rom_offset)) {
|
||||||
f_close(&fil);
|
f_close(&fil);
|
||||||
return FLASHCART_ERROR_ARGS;
|
return FLASHCART_ERR_ARGS;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (f_lseek(&fil, file_offset) != FR_OK) {
|
if (f_lseek(&fil, file_offset) != FR_OK) {
|
||||||
f_close(&fil);
|
f_close(&fil);
|
||||||
return FLASHCART_ERROR_LOAD;
|
return FLASHCART_ERR_LOAD;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (f_read(&fil, (void *) (ROM_ADDRESS + rom_offset), file_size, &br) != FR_OK) {
|
if (f_read(&fil, (void *) (ROM_ADDRESS + rom_offset), file_size, &br) != FR_OK) {
|
||||||
f_close(&fil);
|
f_close(&fil);
|
||||||
return FLASHCART_ERROR_LOAD;
|
return FLASHCART_ERR_LOAD;
|
||||||
}
|
}
|
||||||
if (br != file_size) {
|
if (br != file_size) {
|
||||||
f_close(&fil);
|
f_close(&fil);
|
||||||
return FLASHCART_ERROR_LOAD;
|
return FLASHCART_ERR_LOAD;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (f_close(&fil) != FR_OK) {
|
if (f_close(&fil) != FR_OK) {
|
||||||
return FLASHCART_ERROR_LOAD;
|
return FLASHCART_ERR_LOAD;
|
||||||
}
|
}
|
||||||
|
|
||||||
return FLASHCART_OK;
|
return FLASHCART_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static flashcart_error_t ed64_load_save (char *save_path) {
|
static flashcart_err_t ed64_load_save (char *save_path) {
|
||||||
void *address = NULL;
|
void *address = NULL;
|
||||||
ed64_save_type_t type = ed64_ll_get_save_type();
|
ed64_save_type_t type = ed64_ll_get_save_type();
|
||||||
|
|
||||||
@ -134,35 +141,35 @@ static flashcart_error_t ed64_load_save (char *save_path) {
|
|||||||
break;
|
break;
|
||||||
case SAVE_TYPE_NONE:
|
case SAVE_TYPE_NONE:
|
||||||
default:
|
default:
|
||||||
return FLASHCART_ERROR_ARGS;
|
return FLASHCART_ERR_ARGS;
|
||||||
}
|
}
|
||||||
|
|
||||||
FIL fil;
|
FIL fil;
|
||||||
UINT br;
|
UINT br;
|
||||||
|
|
||||||
if (f_open(&fil, strip_sd_prefix(save_path), FA_READ) != FR_OK) {
|
if (f_open(&fil, strip_sd_prefix(save_path), FA_READ) != FR_OK) {
|
||||||
return FLASHCART_ERROR_LOAD;
|
return FLASHCART_ERR_LOAD;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t save_size = f_size(&fil);
|
size_t save_size = f_size(&fil);
|
||||||
|
|
||||||
if (f_read(&fil, address, save_size, &br) != FR_OK) {
|
if (f_read(&fil, address, save_size, &br) != FR_OK) {
|
||||||
f_close(&fil);
|
f_close(&fil);
|
||||||
return FLASHCART_ERROR_LOAD;
|
return FLASHCART_ERR_LOAD;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (f_close(&fil) != FR_OK) {
|
if (f_close(&fil) != FR_OK) {
|
||||||
return FLASHCART_ERROR_LOAD;
|
return FLASHCART_ERR_LOAD;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (br != save_size) {
|
if (br != save_size) {
|
||||||
return FLASHCART_ERROR_LOAD;
|
return FLASHCART_ERR_LOAD;
|
||||||
}
|
}
|
||||||
|
|
||||||
return FLASHCART_OK;
|
return FLASHCART_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static flashcart_error_t ed64_set_save_type (flashcart_save_type_t save_type) {
|
static flashcart_err_t ed64_set_save_type (flashcart_save_type_t save_type) {
|
||||||
ed64_save_type_t type;
|
ed64_save_type_t type;
|
||||||
|
|
||||||
switch (save_type) {
|
switch (save_type) {
|
||||||
@ -187,7 +194,7 @@ static flashcart_error_t ed64_set_save_type (flashcart_save_type_t save_type) {
|
|||||||
type = SAVE_TYPE_FLASHRAM;
|
type = SAVE_TYPE_FLASHRAM;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return FLASHCART_ERROR_ARGS;
|
return FLASHCART_ERR_ARGS;
|
||||||
}
|
}
|
||||||
|
|
||||||
ed64_ll_set_save_type(type);
|
ed64_ll_set_save_type(type);
|
||||||
@ -199,9 +206,12 @@ static flashcart_error_t ed64_set_save_type (flashcart_save_type_t save_type) {
|
|||||||
static flashcart_t flashcart_ed64 = {
|
static flashcart_t flashcart_ed64 = {
|
||||||
.init = ed64_init,
|
.init = ed64_init,
|
||||||
.deinit = ed64_deinit,
|
.deinit = ed64_deinit,
|
||||||
|
.has_feature = ed64_has_feature,
|
||||||
.load_rom = ed64_load_rom,
|
.load_rom = ed64_load_rom,
|
||||||
.load_file = ed64_load_file,
|
.load_file = ed64_load_file,
|
||||||
.load_save = ed64_load_save,
|
.load_save = ed64_load_save,
|
||||||
|
.load_64dd_ipl = NULL,
|
||||||
|
.load_64dd_disk = NULL,
|
||||||
.set_save_type = ed64_set_save_type,
|
.set_save_type = ed64_set_save_type,
|
||||||
.set_save_writeback = NULL,
|
.set_save_writeback = NULL,
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user