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