mirror of
https://github.com/melonDS-emu/melonDS.git
synced 2025-07-25 15:19:53 -06:00
delay savefile flush to the end of the frame
This commit is contained in:
@ -1000,6 +1000,8 @@ u32 RunFrame()
|
|||||||
GPU3D::Timestamp-SysTimestamp);
|
GPU3D::Timestamp-SysTimestamp);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
NDSCart::FlushSRAMFile();
|
||||||
|
|
||||||
NumFrames++;
|
NumFrames++;
|
||||||
|
|
||||||
return GPU::TotalScanlines;
|
return GPU::TotalScanlines;
|
||||||
|
@ -37,6 +37,7 @@ u8* SRAM;
|
|||||||
u32 SRAMLength;
|
u32 SRAMLength;
|
||||||
|
|
||||||
char SRAMPath[1024];
|
char SRAMPath[1024];
|
||||||
|
bool SRAMFileDirty;
|
||||||
|
|
||||||
void (*WriteFunc)(u8 val, bool islast);
|
void (*WriteFunc)(u8 val, bool islast);
|
||||||
|
|
||||||
@ -445,14 +446,21 @@ void Write(u8 val, u32 hold)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (islast && (CurCmd == 0x02 || CurCmd == 0x0A) && (SRAMLength > 0))
|
SRAMFileDirty |= islast && (CurCmd == 0x02 || CurCmd == 0x0A) && (SRAMLength > 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void FlushSRAMFile()
|
||||||
|
{
|
||||||
|
if (!SRAMFileDirty)
|
||||||
|
return;
|
||||||
|
|
||||||
|
SRAMFileDirty = false;
|
||||||
|
|
||||||
|
FILE* f = Platform::OpenFile(SRAMPath, "wb");
|
||||||
|
if (f)
|
||||||
{
|
{
|
||||||
FILE* f = Platform::OpenFile(SRAMPath, "wb");
|
fwrite(SRAM, SRAMLength, 1, f);
|
||||||
if (f)
|
fclose(f);
|
||||||
{
|
|
||||||
fwrite(SRAM, SRAMLength, 1, f);
|
|
||||||
fclose(f);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1034,6 +1042,11 @@ void RelocateSave(const char* path, bool write)
|
|||||||
NDSCart_SRAM::RelocateSave(path, write);
|
NDSCart_SRAM::RelocateSave(path, write);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void FlushSRAMFile()
|
||||||
|
{
|
||||||
|
NDSCart_SRAM::FlushSRAMFile();
|
||||||
|
}
|
||||||
|
|
||||||
int ImportSRAM(const u8* data, u32 length)
|
int ImportSRAM(const u8* data, u32 length)
|
||||||
{
|
{
|
||||||
memcpy(NDSCart_SRAM::SRAM, data, std::min(length, NDSCart_SRAM::SRAMLength));
|
memcpy(NDSCart_SRAM::SRAM, data, std::min(length, NDSCart_SRAM::SRAMLength));
|
||||||
|
@ -46,6 +46,9 @@ void DoSavestate(Savestate* file);
|
|||||||
|
|
||||||
void DecryptSecureArea(u8* out);
|
void DecryptSecureArea(u8* out);
|
||||||
bool LoadROM(const char* path, const char* sram, bool direct);
|
bool LoadROM(const char* path, const char* sram, bool direct);
|
||||||
|
|
||||||
|
void FlushSRAMFile();
|
||||||
|
|
||||||
void RelocateSave(const char* path, bool write);
|
void RelocateSave(const char* path, bool write);
|
||||||
|
|
||||||
int ImportSRAM(const u8* data, u32 length);
|
int ImportSRAM(const u8* data, u32 length);
|
||||||
|
Reference in New Issue
Block a user