Handling loadstate issues for different machine configurations

This commit is contained in:
Asnivor 2018-03-13 22:09:46 +00:00
parent 6d66eee459
commit 7739c0dee1
5 changed files with 82 additions and 8 deletions

View File

@ -19,6 +19,9 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
string PrevBlock = "Prev Tape Block";
string TapeStatus = "Get Tape Status";
string HardResetStr = "Hard Reset";
string SoftResetStr = "Soft Reset";
bool pressed_Play = false;
bool pressed_Stop = false;
bool pressed_RTZ = false;
@ -27,6 +30,8 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
bool pressed_NextBlock = false;
bool pressed_PrevBlock = false;
bool pressed_TapeStatus = false;
bool pressed_HardReset = false;
bool pressed_SoftReset = false;
/// <summary>
/// Cycles through all the input callbacks
@ -191,6 +196,28 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
}
else
pressed_TapeStatus = false;
if (Spectrum._controller.IsPressed(HardResetStr))
{
if (!pressed_HardReset)
{
HardReset();
pressed_HardReset = true;
}
}
else
pressed_HardReset = false;
if (Spectrum._controller.IsPressed(SoftResetStr))
{
if (!pressed_SoftReset)
{
SoftReset();
pressed_SoftReset = true;
}
}
else
pressed_SoftReset = false;
}
/// <summary>

View File

@ -207,6 +207,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
{
//ResetBorder();
ULADevice.ResetInterrupt();
CPU.RegPC = 0;
}
#endregion

View File

@ -82,6 +82,19 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
definition.CategoryLabels[s] = "Keyboard";
}
// Datacorder (tape device)
List<string> power = new List<string>
{
// Tape functions
"Soft Reset", "Hard Reset"
};
foreach (var s in power)
{
definition.BoolButtons.Add(s);
definition.CategoryLabels[s] = "Power";
}
// Datacorder (tape device)
List<string> tape = new List<string>
{

View File

@ -50,19 +50,49 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
ms.Close();
core = ms.ToArray();
}
_cpu.SyncState(ser);
ser.BeginSection("ZXSpectrum");
_machine.SyncState(ser);
ser.Sync("Frame", ref _machine.FrameCount);
ser.Sync("LagCount", ref _lagCount);
ser.Sync("IsLag", ref _isLag);
ser.EndSection();
if (ser.IsWriter)
{
ser.SyncEnum("_machineType", ref _machineType);
_cpu.SyncState(ser);
ser.BeginSection("ZXSpectrum");
_machine.SyncState(ser);
ser.Sync("Frame", ref _machine.FrameCount);
ser.Sync("LagCount", ref _lagCount);
ser.Sync("IsLag", ref _isLag);
ser.EndSection();
}
if (ser.IsReader)
{
SyncAllByteArrayDomains();
var tmpM = _machineType;
ser.SyncEnum("_machineType", ref _machineType);
if (tmpM != _machineType)
{
string msg = "SAVESTATE FAILED TO LOAD!!\n\n";
msg += "Current Configuration: " + _machineType.ToString();
msg += "\n";
msg += "Saved Configuration: " + tmpM.ToString();
msg += "\n\n";
msg += "If you with to load this SaveState ensure that you have to correct machine configuration selected, reboot the core, then try again.";
CoreComm.ShowMessage(msg);
_machineType = tmpM;
}
else
{
_cpu.SyncState(ser);
ser.BeginSection("ZXSpectrum");
_machine.SyncState(ser);
ser.Sync("Frame", ref _machine.FrameCount);
ser.Sync("LagCount", ref _lagCount);
ser.Sync("IsLag", ref _isLag);
ser.EndSection();
SyncAllByteArrayDomains();
}
}
}
}

View File

@ -185,9 +185,12 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
return result;
}
private MachineType _machineType;
private void Init(MachineType machineType, BorderType borderType, TapeLoadSpeed tapeLoadSpeed, List<byte[]> files, List<JoystickType> joys)
{
_machineType = machineType;
// setup the emulated model based on the MachineType
switch (machineType)
{