From 13756a9dd9c6d158bba6b77952da306182adf4b5 Mon Sep 17 00:00:00 2001 From: Robin Jones Date: Tue, 10 Oct 2023 22:46:56 +0100 Subject: [PATCH 1/3] Further improve ROM loading ability. Add fixme for why it might be broken. --- src/flashcart/ed64/ed64.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/flashcart/ed64/ed64.c b/src/flashcart/ed64/ed64.c index a6fa75ae..0f5801c3 100644 --- a/src/flashcart/ed64/ed64.c +++ b/src/flashcart/ed64/ed64.c @@ -53,7 +53,8 @@ static flashcart_err_t ed64_load_rom (char *rom_path, flashcart_progress_callbac size_t rom_size = f_size(&fil); - // FIXME: if the cart is not V3 or X5 or X7, we need probably need to - 128KiB + // FIXME: if the cart is not V3 or X5 or X7, we need probably need to - 128KiB for save compatibility. + // Or somehow warn that certain ROM's will have corruption due to the address space being used for saves. if (rom_size > MiB(64)) { f_close(&fil); return FLASHCART_ERR_LOAD; @@ -97,8 +98,9 @@ static flashcart_err_t ed64_load_file (char *file_path, uint32_t rom_offset, uin size_t file_size = f_size(&fil) - file_offset; - // FIXME: if the cart is not V3 or X5 or X7, we need to - 128KiB - if (file_size > (MiB(64) - KiB(128) - rom_offset)) { + // FIXME: if the cart is not V3 or X5 or X7, we need probably need to - 128KiB for save compatibility. + // Or somehow warn that certain ROM's will have corruption due to the address space being used for saves. + if (file_size > (MiB(64) - rom_offset)) { f_close(&fil); return FLASHCART_ERR_ARGS; } From 034233547ed30e2fbd32751a79c4e47c47f0adf2 Mon Sep 17 00:00:00 2001 From: ariahiro64 <45049787+ariahiro64@users.noreply.github.com> Date: Tue, 10 Oct 2023 17:54:55 -0400 Subject: [PATCH 2/3] Fix saves on ED64 (#7) --- src/flashcart/ed64/ed64.c | 3 --- src/flashcart/ed64/ed64_ll.h | 2 +- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/src/flashcart/ed64/ed64.c b/src/flashcart/ed64/ed64.c index 0f5801c3..83b735f4 100644 --- a/src/flashcart/ed64/ed64.c +++ b/src/flashcart/ed64/ed64.c @@ -12,7 +12,6 @@ #include "ed64_ll.h" #include "ed64.h" -#define EEPROM_ADDRESS (0x1FFE2000) extern int ed_exit(void); @@ -133,8 +132,6 @@ static flashcart_err_t ed64_load_save (char *save_path) { switch (type) { case SAVE_TYPE_EEPROM_4K: case SAVE_TYPE_EEPROM_16K: - address = (void *) (EEPROM_ADDRESS); - break; case SAVE_TYPE_SRAM: case SAVE_TYPE_SRAM_128K: case SAVE_TYPE_FLASHRAM: diff --git a/src/flashcart/ed64/ed64_ll.h b/src/flashcart/ed64/ed64_ll.h index 0faa635d..1e8f3cf0 100644 --- a/src/flashcart/ed64/ed64_ll.h +++ b/src/flashcart/ed64/ed64_ll.h @@ -30,7 +30,7 @@ typedef enum { } ed64_save_type_t; -#define SRAM_ADDRESS (0xA8000000) +#define SRAM_ADDRESS (0x1FFE2000) #define ROM_ADDRESS (0xB0000000) /* Save functions */ From 8b3d092ac6a448797d36a2323ffac5a20c42c5e7 Mon Sep 17 00:00:00 2001 From: Robin Jones Date: Tue, 10 Oct 2023 23:41:24 +0100 Subject: [PATCH 3/3] Add fixme notes for save restore --- src/flashcart/ed64/ed64.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/flashcart/ed64/ed64.c b/src/flashcart/ed64/ed64.c index 83b735f4..313722ab 100644 --- a/src/flashcart/ed64/ed64.c +++ b/src/flashcart/ed64/ed64.c @@ -21,6 +21,10 @@ static flashcart_err_t ed64_init (void) { // FIXME: Update firmware if needed. // FIXME: Enable RTC if available. + + // FIXME: retrive a config file from (probably SRAM) that might have been set. + // This should include the location of the ROM and its save type. + // Then, if it is valid, perform a save. return FLASHCART_OK; } @@ -48,6 +52,10 @@ static flashcart_err_t ed64_load_rom (char *rom_path, flashcart_progress_callbac return FLASHCART_ERR_LOAD; } + // FIXME: set the required actions for retriving the save file later (probably SRAM). + // This would involve creating some content in an area of RAM that would include + // the ROM location and its save type. This information will be used on init to perform a "save writeback". + fix_file_size(&fil); size_t rom_size = f_size(&fil);