diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/mupen64plusApi.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/mupen64plusApi.cs index a37d88fb91..355580cf00 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/mupen64plusApi.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/mupen64plusApi.cs @@ -757,12 +757,12 @@ namespace BizHawk.Emulation.Cores.Nintendo.N64 else { // This shouldn't happen!! - return new byte[0x800 + 4 * 0x8000 + 0x20000]; + return new byte[0x800 + 4 * 0x8000 + 0x20000 + 0x8000]; } } else { - byte[] dest = new byte[0x800 + 4 * 0x8000 + 0x20000]; + byte[] dest = new byte[0x800 + 4 * 0x8000 + 0x20000 + 0x8000]; m64psave_saveram(dest); return dest; } diff --git a/libmupen64plus/mupen64plus-core/src/memory/dma.c b/libmupen64plus/mupen64plus-core/src/memory/dma.c index 8d606d40e4..f98e7fe436 100644 --- a/libmupen64plus/mupen64plus-core/src/memory/dma.c +++ b/libmupen64plus/mupen64plus-core/src/memory/dma.c @@ -44,19 +44,19 @@ #include "main/rom.h" #include "main/util.h" -static unsigned char sram[0x8000]; +unsigned char sram[0x8000]; -static char *get_sram_path(void) +/*static char *get_sram_path(void) { return formatstr("%s%s.sra", get_savesrampath(), ROM_SETTINGS.goodname); -} +}*/ -static void sram_format(void) +void sram_format(void) { memset(sram, 0, sizeof(sram)); } -static void sram_read_file(void) +/*static void sram_read_file(void) { char *filename = get_sram_path(); @@ -75,11 +75,11 @@ static void sram_read_file(void) } free(filename); -} +}*/ static void sram_write_file(void) { - char *filename = get_sram_path(); + /*char *filename = get_sram_path(); switch (write_to_file(filename, sram, sizeof(sram))) { @@ -92,7 +92,7 @@ static void sram_write_file(void) default: break; } - free(filename); + free(filename);*/ } void dma_pi_read(void) @@ -104,8 +104,6 @@ void dma_pi_read(void) { if (flashram_info.use_flashram != 1) { - sram_read_file(); - for (i=0; i < (pi_register.pi_rd_len_reg & 0xFFFFFF)+1; i++) { sram[((pi_register.pi_cart_addr_reg-0x08000000)+i)^S8] = @@ -145,8 +143,6 @@ void dma_pi_write(void) { int i; - sram_read_file(); - for (i=0; i<(int)(pi_register.pi_wr_len_reg & 0xFFFFFF)+1; i++) { ((unsigned char*)rdram)[(pi_register.pi_dram_addr_reg+i)^S8]= diff --git a/libmupen64plus/mupen64plus-core/src/memory/dma.h b/libmupen64plus/mupen64plus-core/src/memory/dma.h index 8319f299cf..7bb3ac48b9 100644 --- a/libmupen64plus/mupen64plus-core/src/memory/dma.h +++ b/libmupen64plus/mupen64plus-core/src/memory/dma.h @@ -29,5 +29,7 @@ void dma_si_read(void); void dma_sp_write(void); void dma_sp_read(void); +void sram_format(void); + #endif diff --git a/libmupen64plus/mupen64plus-core/src/memory/pif.c b/libmupen64plus/mupen64plus-core/src/memory/pif.c index 02a624210a..75badd677b 100644 --- a/libmupen64plus/mupen64plus-core/src/memory/pif.c +++ b/libmupen64plus/mupen64plus-core/src/memory/pif.c @@ -27,6 +27,7 @@ #include "memory.h" #include "pif.h" #include "flashram.h" +#include "dma.h" #include "n64_cic_nus_6105.h" #include "r4300/r4300.h" @@ -605,6 +606,8 @@ EXPORT void CALL init_saveram(void) saveramModified = 0; flashram_format(); + + sram_format(); } EXPORT void CALL save_saveram(unsigned char * dest) @@ -612,6 +615,7 @@ EXPORT void CALL save_saveram(unsigned char * dest) memcpy(dest, eeprom, 0x800); memcpy(dest + 0x800, mempack, 4 * 0x8000); memcpy(dest + (0x800 + 4 * 0x8000), flashram, 0x20000); + memcpy(dest + (0x800 + 4 * 0x8000 + 0x20000), sram, 0x8000); } EXPORT void CALL load_saveram(unsigned char * src) @@ -619,4 +623,5 @@ EXPORT void CALL load_saveram(unsigned char * src) memcpy(eeprom, src, 0x800); memcpy(mempack, src + 0x800, 4 * 0x8000); memcpy(flashram, src + (0x800 + 4 * 0x8000), 0x20000); + memcpy(sram, src + (0x800 + 4 * 0x8000 + 0x20000), 0x8000); } \ No newline at end of file diff --git a/libmupen64plus/mupen64plus-core/src/memory/pif.h b/libmupen64plus/mupen64plus-core/src/memory/pif.h index a09af7526c..ccccffef3a 100644 --- a/libmupen64plus/mupen64plus-core/src/memory/pif.h +++ b/libmupen64plus/mupen64plus-core/src/memory/pif.h @@ -26,6 +26,6 @@ void update_pif_write(void); void update_pif_read(void); extern unsigned char flashram[]; - +extern unsigned char sram[]; #endif diff --git a/output/dll/mupen64plus.dll b/output/dll/mupen64plus.dll index fc8923eabe..737b953f60 100644 Binary files a/output/dll/mupen64plus.dll and b/output/dll/mupen64plus.dll differ