diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/mupen64plusApi.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/mupen64plusApi.cs index 8b211a9826..a37d88fb91 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]; + return new byte[0x800 + 4 * 0x8000 + 0x20000]; } } else { - byte[] dest = new byte[0x800 + 4 * 0x8000]; + byte[] dest = new byte[0x800 + 4 * 0x8000 + 0x20000]; m64psave_saveram(dest); return dest; } diff --git a/libmupen64plus/mupen64plus-core/src/memory/flashram.c b/libmupen64plus/mupen64plus-core/src/memory/flashram.c index 7993030960..164650aca4 100644 --- a/libmupen64plus/mupen64plus-core/src/memory/flashram.c +++ b/libmupen64plus/mupen64plus-core/src/memory/flashram.c @@ -45,19 +45,19 @@ typedef enum flashram_mode STATUS_MODE } Flashram_mode; -static unsigned char flashram[0x20000]; +unsigned char flashram[0x20000]; -static char *get_flashram_path(void) +/*static char *get_flashram_path(void) { return formatstr("%s%s.fla", get_savesrampath(), ROM_SETTINGS.goodname); -} +}*/ -static void flashram_format(void) +void flashram_format(void) { memset(flashram, 0xff, sizeof(flashram)); } -static void flashram_read_file(void) +/*static void flashram_read_file(void) { char *filename = get_flashram_path(); @@ -75,11 +75,11 @@ static void flashram_read_file(void) } free(filename); -} +}*/ static void flashram_write_file(void) { - char *filename = get_flashram_path(); + /*char *filename = get_flashram_path(); switch (write_to_file(filename, flashram, sizeof(flashram))) { @@ -92,7 +92,7 @@ static void flashram_write_file(void) default: break; } - free(filename); + free(filename);*/ } void init_flashram(void) @@ -132,7 +132,6 @@ void flashram_command(unsigned int command) case ERASE_MODE: { unsigned int i; - flashram_read_file(); for (i=flashram_info.erase_offset; i<(flashram_info.erase_offset+128); i++) { flashram[i^S8] = 0xff; @@ -143,7 +142,6 @@ void flashram_command(unsigned int command) case WRITE_MODE: { int i; - flashram_read_file(); for (i=0; i<128; i++) { flashram[(flashram_info.erase_offset+i)^S8]= @@ -186,7 +184,6 @@ void dma_read_flashram(void) rdram[pi_register.pi_dram_addr_reg/4+1] = (unsigned int)(flashram_info.status); break; case READ_MODE: - flashram_read_file(); for (i=0; i<(pi_register.pi_wr_len_reg & 0x0FFFFFF)+1; i++) { ((unsigned char*)rdram)[(pi_register.pi_dram_addr_reg+i)^S8]= diff --git a/libmupen64plus/mupen64plus-core/src/memory/flashram.h b/libmupen64plus/mupen64plus-core/src/memory/flashram.h index b2c6987d82..e07e9d4d2a 100644 --- a/libmupen64plus/mupen64plus-core/src/memory/flashram.h +++ b/libmupen64plus/mupen64plus-core/src/memory/flashram.h @@ -34,3 +34,4 @@ void flashram_command(unsigned int command); unsigned int flashram_status(void); void dma_read_flashram(void); void dma_write_flashram(void); +void flashram_format(void); \ No newline at end of file diff --git a/libmupen64plus/mupen64plus-core/src/memory/pif.c b/libmupen64plus/mupen64plus-core/src/memory/pif.c index d31902f3a0..02a624210a 100644 --- a/libmupen64plus/mupen64plus-core/src/memory/pif.c +++ b/libmupen64plus/mupen64plus-core/src/memory/pif.c @@ -26,6 +26,7 @@ #include "memory.h" #include "pif.h" +#include "flashram.h" #include "n64_cic_nus_6105.h" #include "r4300/r4300.h" @@ -602,16 +603,20 @@ EXPORT void CALL init_saveram(void) eeprom_format(); mempack_format(); saveramModified = 0; + + flashram_format(); } 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); } 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); } \ 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 8306e7652c..a09af7526c 100644 --- a/libmupen64plus/mupen64plus-core/src/memory/pif.h +++ b/libmupen64plus/mupen64plus-core/src/memory/pif.h @@ -25,5 +25,7 @@ void update_pif_write(void); void update_pif_read(void); +extern unsigned char flashram[]; + #endif diff --git a/output/dll/mupen64plus.dll b/output/dll/mupen64plus.dll index fa789940aa..fc8923eabe 100644 Binary files a/output/dll/mupen64plus.dll and b/output/dll/mupen64plus.dll differ