fix large saves

This commit is contained in:
ariahiro64 2023-10-21 02:28:26 -04:00
parent 9bcfface78
commit 3c2daf7277
2 changed files with 58 additions and 2 deletions

View File

@ -80,6 +80,8 @@ static flashcart_err_t ed64_init (void) {
current_state.last_save_path = ""; current_state.last_save_path = "";
ed64_state_save(&current_state); ed64_state_save(&current_state);
} }
//clears rom/save sdram area
memset((void *)(ROM_ADDRESS), 0xFF, MiB(64) + KiB(128));
} }
return FLASHCART_OK; return FLASHCART_OK;
} }

View File

@ -1,5 +1,6 @@
#include <malloc.h> #include <malloc.h>
#include <libdragon.h> #include <libdragon.h>
#include "utils/utils.h"
#include "ed64_ll.h" #include "ed64_ll.h"
@ -220,6 +221,33 @@ void pi_dma_from_cart_safe (void *dest, void *src, unsigned long size) {
} }
int ed64_ll_get_sram128 (uint8_t *buffer, int size) {
dma_wait();
io_write(PI_BSD_DOM2_LAT_REG, 0x05);
io_write(PI_BSD_DOM2_PWD_REG, 0x0C);
io_write(PI_BSD_DOM2_PGS_REG, 0x0D);
io_write(PI_BSD_DOM2_RLS_REG, 0x02);
dma_wait();
pi_initialize();
dma_wait();
pi_dma_from_sram(buffer, 0 - (KiB(128) - KiB(32)), size) ;
dma_wait();
io_write(PI_BSD_DOM2_LAT_REG, 0x40);
io_write(PI_BSD_DOM2_PWD_REG, 0x12);
io_write(PI_BSD_DOM2_PGS_REG, 0x07);
io_write(PI_BSD_DOM2_RLS_REG, 0x03);
return 1;
}
int ed64_ll_get_sram (uint8_t *buffer, int size) { int ed64_ll_get_sram (uint8_t *buffer, int size) {
@ -266,7 +294,7 @@ int ed64_ll_get_fram (uint8_t *buffer, int size) {
ed64_ll_set_save_type(SAVE_TYPE_SRAM_128K); //2 ed64_ll_set_save_type(SAVE_TYPE_SRAM_128K); //2
dma_wait(); dma_wait();
ed64_ll_get_sram(buffer, size); ed64_ll_get_sram128(buffer, size);
data_cache_hit_writeback_invalidate(buffer, size); data_cache_hit_writeback_invalidate(buffer, size);
dma_wait(); dma_wait();
@ -279,6 +307,32 @@ int ed64_ll_get_fram (uint8_t *buffer, int size) {
/* /*
sram upload sram upload
*/ */
int ed64_ll_set_sram128 (uint8_t *buffer, int size) {
//half working
dma_wait();
//Timing
pi_initialize_sram();
//Readmode
pi_initialize();
data_cache_hit_writeback_invalidate(buffer,size);
dma_wait();
pi_dma_to_sram(buffer, 0 - (KiB(128) - KiB(32)), size);
data_cache_hit_writeback_invalidate(buffer,size);
//Wait
dma_wait();
//Restore evd Timing
ed64_ll_set_sdcard_timing();
return 1;
}
int ed64_ll_set_sram (uint8_t *buffer, int size) { int ed64_ll_set_sram (uint8_t *buffer, int size) {
//half working //half working
@ -321,7 +375,7 @@ int ed64_ll_set_fram (uint8_t *buffer, int size) {
ed64_ll_set_save_type(SAVE_TYPE_SRAM_128K); ed64_ll_set_save_type(SAVE_TYPE_SRAM_128K);
dma_wait(); dma_wait();
ed64_ll_set_sram(buffer, size); ed64_ll_set_sram128(buffer, size);
data_cache_hit_writeback_invalidate(buffer, size); data_cache_hit_writeback_invalidate(buffer, size);
dma_wait(); dma_wait();