fully working

This commit is contained in:
ariahiro64 2023-10-15 19:25:51 -04:00
parent df3baa3110
commit 01b802ea41

View File

@ -30,8 +30,10 @@ static flashcart_err_t ed64_init (void) {
FIL lrp_fil; FIL lrp_fil;
UINT lrp_br; UINT lrp_br;
TCHAR lrp_path[1024]; TCHAR lrp_path[255*32];
// FIXME: use max supported length-
// FIXME: use max supported length
if (f_open(&lrp_fil, LAST_SAVE_FILE_PATH, FA_READ) != FR_OK) { if (f_open(&lrp_fil, LAST_SAVE_FILE_PATH, FA_READ) != FR_OK) {
return FLASHCART_ERR_LOAD; return FLASHCART_ERR_LOAD;
} }
@ -55,6 +57,7 @@ static flashcart_err_t ed64_init (void) {
// Older everdrives cant save during gameplay so we need to the reset method. // Older everdrives cant save during gameplay so we need to the reset method.
// find the path to last save // find the path to last save
if (file_exists(strip_sd_prefix(lrp_path))) {
int save_size = file_get_size(strip_sd_prefix(lrp_path)); int save_size = file_get_size(strip_sd_prefix(lrp_path));
@ -66,7 +69,7 @@ static flashcart_err_t ed64_init (void) {
// so we can just check the size // so we can just check the size
if (save_size > KiB(2)) { if (save_size > KiB(2)) {
getSRAM(cartsave_data, save_size); getSRAM(cartsave_data, save_size);
} else if (save_size > 0){ } else {
getEeprom(cartsave_data, save_size); getEeprom(cartsave_data, save_size);
} }
@ -77,6 +80,7 @@ static flashcart_err_t ed64_init (void) {
if (f_close(&fil) != FR_OK) { if (f_close(&fil) != FR_OK) {
return FLASHCART_ERR_LOAD; return FLASHCART_ERR_LOAD;
} }
}
} }
return FLASHCART_OK; return FLASHCART_OK;
} }
@ -139,26 +143,6 @@ static flashcart_err_t ed64_load_rom (char *rom_path, flashcart_progress_callbac
return FLASHCART_ERR_LOAD; return FLASHCART_ERR_LOAD;
} }
// Set the required actions for retriving the save file later.
// Given there is no good place in RAM...
// This would involve creating some content to a file on the SD card that includes:
// the ROM name and location and possibly its save type. This information will be used on init to perform a "save writeback".
// Actually, we should be using the settings API, so this is just a trial hack.
// FIL lrp_fil;
// UINT lrp_bw;
// if (f_open(&lrp_fil, LAST_ROM_FILE_PATH, FA_CREATE_ALWAYS) != FR_OK) {
// return FLASHCART_ERR_LOAD;
// }
// if (f_write(&lrp_fil, rom_path, strlen(rom_path) + 1, &lrp_bw) != FR_OK) {
// f_close(&lrp_fil);
// return FLASHCART_ERR_LOAD;
// }
// if (f_close(&lrp_fil) != FR_OK) {
// return FLASHCART_ERR_LOAD;
// }
return FLASHCART_OK; return FLASHCART_OK;
} }