change IEmulator.DeterministicEmulation to get-only; the old interface implies that a core should be able to take a change to the property at any time, which isn't feasable. most existing cores changed to return true all the time. SNES now takes determinism parameter in Load()

This commit is contained in:
goyuken 2012-10-03 15:31:04 +00:00
parent 0e292d19ca
commit 98d9f13600
12 changed files with 18 additions and 30 deletions

View File

@ -475,7 +475,7 @@ namespace BizHawk.Emulation.Consoles.Calculator
public int LagCount { get { return _lagcount; } set { _lagcount = value; } }
public bool IsLagFrame { get { return islag; } }
public bool DeterministicEmulation { get { return true; } set { } }
public bool DeterministicEmulation { get { return true; } }
public byte[] ReadSaveRam() { return null; }
public void StoreSaveRam(byte[] data) { }

View File

@ -75,7 +75,7 @@ namespace BizHawk.Emulation.Consoles.Coleco
public void ClearSaveRam() { }
public bool SaveRamModified { get; set; }
public bool DeterministicEmulation { get; set; }
public bool DeterministicEmulation { get { return true; } }
public void SaveStateText(TextWriter writer) { SyncState(Serializer.CreateTextWriter(writer)); }
public void LoadStateText(TextReader reader) { SyncState(Serializer.CreateTextReader(reader)); }
public void SaveStateBinary(BinaryWriter bw) { SyncState(Serializer.CreateBinaryWriter(bw)); }

View File

@ -115,7 +115,7 @@ namespace BizHawk.Emulation.Consoles.Intellivision
get { return "INTV"; }
}
public bool DeterministicEmulation { get; set; }
public bool DeterministicEmulation { get { return true; } }
public byte[] ReadSaveRam() { return null; }

View File

@ -219,7 +219,7 @@ namespace BizHawk.Emulation.Consoles.GB
get { return "GB"; }
}
public bool DeterministicEmulation { get; set; }
public bool DeterministicEmulation { get { return true; } }
public byte[] ReadSaveRam()
{

View File

@ -307,7 +307,7 @@ namespace BizHawk.Emulation.Consoles.Nintendo
public int LagCount { get { return _lagcount; } set { _lagcount = value; } }
public bool IsLagFrame { get { return islag; } }
public bool DeterministicEmulation { get { return true; } set { } }
public bool DeterministicEmulation { get { return true; } }

View File

@ -360,7 +360,7 @@ namespace BizHawk.Emulation.Consoles.Nintendo.SNES
{
}
public void Load(GameInfo game, byte[] romData, byte[] sgbRomData)
public void Load(GameInfo game, byte[] romData, byte[] sgbRomData, bool DeterministicEmulation)
{
//attach this core as the current
if (CurrLibsnesCore != null)
@ -434,9 +434,8 @@ namespace BizHawk.Emulation.Consoles.Nintendo.SNES
SetupMemoryDomains(romData);
// disallow any future modifications to the DeterministicEmulation parameter, and set initial deterministic savestate
_DeterministicEmulationProtected = true;
if (DeterministicEmulation)
this.DeterministicEmulation = DeterministicEmulation;
if (DeterministicEmulation) // save frame-0 savestate now
CoreSaveStateInternal(true);
}
@ -634,18 +633,10 @@ namespace BizHawk.Emulation.Consoles.Nintendo.SNES
public bool IsLagFrame { get; private set; }
public string SystemId { get; private set; }
bool _DeterministicEmulation = false;
bool _DeterministicEmulationProtected = false;
public bool DeterministicEmulation
{
get { return _DeterministicEmulation; }
set
{
if (_DeterministicEmulationProtected && value != _DeterministicEmulation)
throw new Exception("snes: DeterministicEmulation must be set before load!");
_DeterministicEmulation = value;
}
get;
private set;
}

View File

@ -277,7 +277,7 @@ namespace BizHawk.Emulation.Consoles.TurboGrafx
public string SystemId { get { return systemid; } }
public string Region { get; set; }
public bool DeterministicEmulation { get; set; }
public bool DeterministicEmulation { get { return true; } }
public byte[] ReadSaveRam()
{

View File

@ -264,7 +264,7 @@ namespace BizHawk.Emulation.Consoles.Sega
public int Frame { get; set; }
public int LagCount { get { return _lagcount; } set { _lagcount = value; } }
public bool IsLagFrame { get { return islag; } }
public bool DeterministicEmulation { get; set; }
public bool DeterministicEmulation { get { return true; } }
public string SystemId { get { return "GEN"; } }

View File

@ -77,7 +77,7 @@ namespace BizHawk.Emulation.Consoles.Sega
byte Port3F = 0xFF;
public DisplayType DisplayType { get; set; }
public bool DeterministicEmulation { get; set; }
public bool DeterministicEmulation { get { return true; } }
public SMS(GameInfo game, byte[] rom)
{

View File

@ -44,7 +44,7 @@ namespace BizHawk
public byte[] ReadSaveRam() { return null; }
public void StoreSaveRam(byte[] data) { }
public void ClearSaveRam() { }
public bool DeterministicEmulation { get; set; }
public bool DeterministicEmulation { get { return true; } }
public bool SaveRamModified { get; set; }
public void SaveStateText(TextWriter writer) { }
public void LoadStateText(TextReader reader) { }

View File

@ -20,7 +20,8 @@ namespace BizHawk
int LagCount { get; set; }
bool IsLagFrame { get; }
string SystemId { get; }
bool DeterministicEmulation { get; set; }
/// <summary>if you want to set this, look in the emulator's constructor or Load() method</summary>
bool DeterministicEmulation { get; }
/// <summary>
/// return a copy of the saveram. editing it won't do you any good unless you later call StoreSaveRam()

View File

@ -1401,10 +1401,9 @@ namespace BizHawk.MultiClient
{
game.System = "SNES";
var snes = new LibsnesCore();
if (deterministicemulation) snes.DeterministicEmulation = true;
nextEmulator = snes;
nextEmulator.CoreInputComm = Global.CoreInputComm;
snes.Load(game, rom.FileData, null);
snes.Load(game, rom.FileData, null, deterministicemulation);
}
break;
case "SMS":
@ -1492,9 +1491,8 @@ namespace BizHawk.MultiClient
game.AddOption("SGB");
game.System = "SGB";
var snes = new LibsnesCore();
if (deterministicemulation) snes.DeterministicEmulation = true;
nextEmulator = snes;
snes.Load(game, rom.FileData, sgbrom);
snes.Load(game, rom.FileData, sgbrom, deterministicemulation);
}
break;
case "COLV":
@ -1530,8 +1528,6 @@ namespace BizHawk.MultiClient
if (nextEmulator == null) throw new Exception();
if (deterministicemulation) nextEmulator.DeterministicEmulation = true;
CloseGame();
Global.Emulator.Dispose();
Global.Emulator = nextEmulator;