separate SRAM setting coded, I guess
This commit is contained in:
parent
1edf2aed3b
commit
8b4ba2d8b9
|
@ -53,6 +53,8 @@ int Threaded3D;
|
|||
|
||||
int SocketBindAnyAddr;
|
||||
|
||||
int SavestateRelocSRAM;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
char Name[16];
|
||||
|
@ -107,6 +109,8 @@ ConfigEntry ConfigFile[] =
|
|||
|
||||
{"SockBindAnyAddr", 0, &SocketBindAnyAddr, 0, NULL, 0},
|
||||
|
||||
{"SavStaRelocSRAM", 0, &SavestateRelocSRAM, 1, NULL, 0},
|
||||
|
||||
{"", -1, NULL, 0, NULL, 0}
|
||||
};
|
||||
|
||||
|
|
|
@ -46,6 +46,8 @@ extern int Threaded3D;
|
|||
|
||||
extern int SocketBindAnyAddr;
|
||||
|
||||
extern int SavestateRelocSRAM;
|
||||
|
||||
}
|
||||
|
||||
#endif // CONFIG_H
|
||||
|
|
|
@ -562,6 +562,12 @@ void LoadBIOS()
|
|||
Running = true;
|
||||
}
|
||||
|
||||
void RelocateSave(const char* path, bool write)
|
||||
{
|
||||
printf("SRAM: relocating to %s (write=%s)\n", path, write?"true":"false");
|
||||
NDSCart::RelocateSave(path, write);
|
||||
}
|
||||
|
||||
|
||||
void CalcIterationCycles()
|
||||
{
|
||||
|
|
|
@ -114,6 +114,7 @@ bool DoSavestate(Savestate* file);
|
|||
bool LoadROM(const char* path, const char* sram, bool direct);
|
||||
void LoadBIOS();
|
||||
void SetupDirectBoot();
|
||||
void RelocateSave(const char* path, bool write);
|
||||
|
||||
u32 RunFrame();
|
||||
|
||||
|
|
|
@ -196,8 +196,14 @@ void LoadSave(const char* path)
|
|||
StatusReg = 0x00;
|
||||
}
|
||||
|
||||
void RelocateSave(const char* path)
|
||||
void RelocateSave(const char* path, bool write)
|
||||
{
|
||||
if (!write)
|
||||
{
|
||||
LoadSave(path); // lazy
|
||||
return;
|
||||
}
|
||||
|
||||
strncpy(SRAMPath, path, 1023);
|
||||
SRAMPath[1023] = '\0';
|
||||
|
||||
|
@ -1143,10 +1149,10 @@ bool LoadROM(const char* path, const char* sram, bool direct)
|
|||
return true;
|
||||
}
|
||||
|
||||
void RelocateSave(const char* path)
|
||||
void RelocateSave(const char* path, bool write)
|
||||
{
|
||||
// herp derp
|
||||
NDSCart_SRAM::RelocateSave(path);
|
||||
NDSCart_SRAM::RelocateSave(path, write);
|
||||
}
|
||||
|
||||
void ReadROM(u32 addr, u32 len, u32 offset)
|
||||
|
|
|
@ -45,7 +45,7 @@ void Reset();
|
|||
void DoSavestate(Savestate* file);
|
||||
|
||||
bool LoadROM(const char* path, const char* sram, bool direct);
|
||||
void RelocateSave(const char* path);
|
||||
void RelocateSave(const char* path, bool write);
|
||||
|
||||
void WriteROMCnt(u32 val);
|
||||
u32 ReadROMData();
|
||||
|
|
|
@ -65,6 +65,8 @@ uiMenuItem* MenuItem_Pause;
|
|||
uiMenuItem* MenuItem_Reset;
|
||||
uiMenuItem* MenuItem_Stop;
|
||||
|
||||
uiMenuItem* MenuItem_SavestateSRAMReloc;
|
||||
|
||||
uiMenuItem* MenuItem_ScreenRot[4];
|
||||
uiMenuItem* MenuItem_ScreenGap[6];
|
||||
uiMenuItem* MenuItem_ScreenLayout[3];
|
||||
|
@ -818,7 +820,10 @@ void TryLoadROM(char* file, int prevstatus)
|
|||
SetupSRAMPath();
|
||||
|
||||
if (NDS::LoadROM(ROMPath, SRAMPath, Config::DirectBoot))
|
||||
{
|
||||
strncpy(PrevSRAMPath, SRAMPath, 1024); // safety
|
||||
Run();
|
||||
}
|
||||
else
|
||||
{
|
||||
uiMsgBoxError(MainWindow,
|
||||
|
@ -846,11 +851,10 @@ void GetSavestateName(int slot, char* filename, int len)
|
|||
}
|
||||
else
|
||||
{
|
||||
int len = strlen(ROMPath);
|
||||
pos = len;
|
||||
int l = strlen(ROMPath);
|
||||
pos = l;
|
||||
while (ROMPath[pos] != '.' && pos > 0) pos--;
|
||||
if (pos == 0) pos = len;
|
||||
else pos++;
|
||||
if (pos == 0) pos = l;
|
||||
|
||||
// avoid buffer overflow. shoddy
|
||||
if (pos > len-5) pos = len-5;
|
||||
|
@ -913,6 +917,18 @@ void LoadState(int slot)
|
|||
NDS::DoSavestate(state);
|
||||
delete state;
|
||||
|
||||
if (Config::SavestateRelocSRAM && ROMPath[0]!='\0')
|
||||
{
|
||||
strncpy(PrevSRAMPath, SRAMPath, 1024);
|
||||
|
||||
strncpy(SRAMPath, filename, 1019);
|
||||
int len = strlen(SRAMPath);
|
||||
strcpy(&SRAMPath[len], ".sav");
|
||||
SRAMPath[len+4] = '\0';
|
||||
|
||||
NDS::RelocateSave(SRAMPath, false);
|
||||
}
|
||||
|
||||
EmuRunning = prevstatus;
|
||||
}
|
||||
|
||||
|
@ -956,6 +972,16 @@ void SaveState(int slot)
|
|||
|
||||
if (slot > 0)
|
||||
uiMenuItemEnable(MenuItem_LoadStateSlot[slot-1]);
|
||||
|
||||
if (Config::SavestateRelocSRAM && ROMPath[0]!='\0')
|
||||
{
|
||||
strncpy(SRAMPath, filename, 1019);
|
||||
int len = strlen(SRAMPath);
|
||||
strcpy(&SRAMPath[len], ".sav");
|
||||
SRAMPath[len+4] = '\0';
|
||||
|
||||
NDS::RelocateSave(SRAMPath, true);
|
||||
}
|
||||
}
|
||||
|
||||
EmuRunning = prevstatus;
|
||||
|
@ -974,6 +1000,12 @@ void UndoStateLoad()
|
|||
NDS::DoSavestate(backup);
|
||||
delete backup;
|
||||
|
||||
if (ROMPath[0]!='\0')
|
||||
{
|
||||
strncpy(SRAMPath, PrevSRAMPath, 1024);
|
||||
NDS::RelocateSave(SRAMPath, false);
|
||||
}
|
||||
|
||||
EmuRunning = prevstatus;
|
||||
}
|
||||
|
||||
|
@ -1096,7 +1128,10 @@ void OnReset(uiMenuItem* item, uiWindow* window, void* blarg)
|
|||
if (ROMPath[0] == '\0')
|
||||
NDS::LoadBIOS();
|
||||
else
|
||||
{
|
||||
SetupSRAMPath();
|
||||
NDS::LoadROM(ROMPath, SRAMPath, Config::DirectBoot);
|
||||
}
|
||||
|
||||
Run();
|
||||
}
|
||||
|
@ -1119,6 +1154,12 @@ void OnOpenInputConfig(uiMenuItem* item, uiWindow* window, void* blarg)
|
|||
}
|
||||
|
||||
|
||||
void OnSetSavestateSRAMReloc(uiMenuItem* item, uiWindow* window, void* param)
|
||||
{
|
||||
Config::SavestateRelocSRAM = uiMenuItemChecked(item) ? 1:0;
|
||||
}
|
||||
|
||||
|
||||
void EnsureProperMinSize()
|
||||
{
|
||||
bool isHori = (ScreenRotation == 1 || ScreenRotation == 3);
|
||||
|
@ -1367,6 +1408,15 @@ int main(int argc, char** argv)
|
|||
menuitem = uiMenuAppendItem(menu, "Input config");
|
||||
uiMenuItemOnClicked(menuitem, OnOpenInputConfig, NULL);
|
||||
uiMenuAppendSeparator(menu);
|
||||
{
|
||||
uiMenu* submenu = uiNewMenu("Savestate settings");
|
||||
|
||||
MenuItem_SavestateSRAMReloc = uiMenuAppendCheckItem(submenu, "Separate savefiles");
|
||||
uiMenuItemOnClicked(MenuItem_SavestateSRAMReloc, OnSetSavestateSRAMReloc, NULL);
|
||||
|
||||
uiMenuAppendSubmenu(menu, submenu);
|
||||
}
|
||||
uiMenuAppendSeparator(menu);
|
||||
{
|
||||
uiMenu* submenu = uiNewMenu("Screen rotation");
|
||||
|
||||
|
@ -1471,6 +1521,8 @@ int main(int argc, char** argv)
|
|||
SANITIZE(ScreenSizing, 0, 3);
|
||||
#undef SANITIZE
|
||||
|
||||
uiMenuItemSetChecked(MenuItem_SavestateSRAMReloc, Config::SavestateRelocSRAM?1:0);
|
||||
|
||||
uiMenuItemSetChecked(MenuItem_ScreenRot[ScreenRotation], 1);
|
||||
uiMenuItemSetChecked(MenuItem_ScreenLayout[ScreenLayout], 1);
|
||||
uiMenuItemSetChecked(MenuItem_ScreenSizing[ScreenSizing], 1);
|
||||
|
|
Loading…
Reference in New Issue