From 3c2daf7277c56373327be4b62c0395d7a258f739 Mon Sep 17 00:00:00 2001 From: ariahiro64 Date: Sat, 21 Oct 2023 02:28:26 -0400 Subject: [PATCH] fix large saves --- src/flashcart/ed64/ed64.c | 2 ++ src/flashcart/ed64/ed64_ll.c | 58 ++++++++++++++++++++++++++++++++++-- 2 files changed, 58 insertions(+), 2 deletions(-) diff --git a/src/flashcart/ed64/ed64.c b/src/flashcart/ed64/ed64.c index b3de5823..94006a02 100644 --- a/src/flashcart/ed64/ed64.c +++ b/src/flashcart/ed64/ed64.c @@ -80,6 +80,8 @@ static flashcart_err_t ed64_init (void) { current_state.last_save_path = ""; ed64_state_save(¤t_state); } + //clears rom/save sdram area + memset((void *)(ROM_ADDRESS), 0xFF, MiB(64) + KiB(128)); } return FLASHCART_OK; } diff --git a/src/flashcart/ed64/ed64_ll.c b/src/flashcart/ed64/ed64_ll.c index 5b04eed5..973fca9d 100644 --- a/src/flashcart/ed64/ed64_ll.c +++ b/src/flashcart/ed64/ed64_ll.c @@ -1,5 +1,6 @@ #include #include +#include "utils/utils.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) { @@ -266,7 +294,7 @@ int ed64_ll_get_fram (uint8_t *buffer, int size) { ed64_ll_set_save_type(SAVE_TYPE_SRAM_128K); //2 dma_wait(); - ed64_ll_get_sram(buffer, size); + ed64_ll_get_sram128(buffer, size); data_cache_hit_writeback_invalidate(buffer, size); dma_wait(); @@ -279,6 +307,32 @@ int ed64_ll_get_fram (uint8_t *buffer, int size) { /* 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) { //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); dma_wait(); - ed64_ll_set_sram(buffer, size); + ed64_ll_set_sram128(buffer, size); data_cache_hit_writeback_invalidate(buffer, size); dma_wait();