LagFrame implementation
This commit is contained in:
parent
36485bba8a
commit
198008a573
|
@ -204,6 +204,11 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
|
|||
{
|
||||
return JoystickCollection.Where(a => a.JoyType == type).FirstOrDefault();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Signs whether input read has been requested
|
||||
/// </summary>
|
||||
protected bool InputRead { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -140,6 +140,8 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
|
|||
/// </summary>
|
||||
public virtual void ExecuteFrame()
|
||||
{
|
||||
InputRead = false;
|
||||
|
||||
FrameCompleted = false;
|
||||
BuzzerDevice.StartFrame();
|
||||
if (AYDevice != null)
|
||||
|
@ -179,6 +181,9 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
|
|||
TapeDevice.EndFrame();
|
||||
|
||||
FrameCompleted = true;
|
||||
|
||||
// is this a lag frame?
|
||||
Spectrum.IsLagFrame = !InputRead;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -15,6 +15,8 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
|
|||
/// <returns></returns>
|
||||
public override byte ReadPort(ushort port)
|
||||
{
|
||||
InputRead = true;
|
||||
|
||||
int result = 0xFF;
|
||||
|
||||
// Check whether the low bit is reset
|
||||
|
@ -29,6 +31,8 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
|
|||
{
|
||||
if (LocateUniqueJoystick(JoystickType.Kempston) != null)
|
||||
return (byte)((KempstonJoystick)LocateUniqueJoystick(JoystickType.Kempston) as KempstonJoystick).JoyLine;
|
||||
|
||||
InputRead = true;
|
||||
}
|
||||
else if (lowBitReset)
|
||||
{
|
||||
|
@ -43,28 +47,45 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
|
|||
*/
|
||||
|
||||
if ((port & 0x8000) == 0)
|
||||
{
|
||||
result &= KeyboardDevice.KeyLine[7];
|
||||
}
|
||||
|
||||
if ((port & 0x4000) == 0)
|
||||
{
|
||||
result &= KeyboardDevice.KeyLine[6];
|
||||
}
|
||||
|
||||
if ((port & 0x2000) == 0)
|
||||
{
|
||||
result &= KeyboardDevice.KeyLine[5];
|
||||
}
|
||||
|
||||
if ((port & 0x1000) == 0)
|
||||
{
|
||||
result &= KeyboardDevice.KeyLine[4];
|
||||
|
||||
}
|
||||
|
||||
if ((port & 0x800) == 0)
|
||||
{
|
||||
result &= KeyboardDevice.KeyLine[3];
|
||||
}
|
||||
|
||||
if ((port & 0x400) == 0)
|
||||
{
|
||||
result &= KeyboardDevice.KeyLine[2];
|
||||
}
|
||||
|
||||
if ((port & 0x200) == 0)
|
||||
{
|
||||
result &= KeyboardDevice.KeyLine[1];
|
||||
}
|
||||
|
||||
if ((port & 0x100) == 0)
|
||||
{
|
||||
result &= KeyboardDevice.KeyLine[0];
|
||||
}
|
||||
|
||||
|
||||
result = result & 0x1f; //mask out lower 4 bits
|
||||
result = result | 0xa0; //set bit 5 & 7 to 1
|
||||
|
|
|
@ -15,6 +15,8 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
|
|||
/// <returns></returns>
|
||||
public override byte ReadPort(ushort port)
|
||||
{
|
||||
InputRead = true;
|
||||
|
||||
int result = 0xFF;
|
||||
|
||||
// Check whether the low bit is reset
|
||||
|
@ -28,6 +30,8 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
|
|||
{
|
||||
if (LocateUniqueJoystick(JoystickType.Kempston) != null)
|
||||
return (byte)((KempstonJoystick)LocateUniqueJoystick(JoystickType.Kempston) as KempstonJoystick).JoyLine;
|
||||
|
||||
InputRead = true;
|
||||
}
|
||||
else if (lowBitReset)
|
||||
{
|
||||
|
@ -42,28 +46,44 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
|
|||
*/
|
||||
|
||||
if ((port & 0x8000) == 0)
|
||||
{
|
||||
result &= KeyboardDevice.KeyLine[7];
|
||||
}
|
||||
|
||||
if ((port & 0x4000) == 0)
|
||||
{
|
||||
result &= KeyboardDevice.KeyLine[6];
|
||||
}
|
||||
|
||||
if ((port & 0x2000) == 0)
|
||||
{
|
||||
result &= KeyboardDevice.KeyLine[5];
|
||||
}
|
||||
|
||||
if ((port & 0x1000) == 0)
|
||||
{
|
||||
result &= KeyboardDevice.KeyLine[4];
|
||||
}
|
||||
|
||||
if ((port & 0x800) == 0)
|
||||
{
|
||||
result &= KeyboardDevice.KeyLine[3];
|
||||
}
|
||||
|
||||
if ((port & 0x400) == 0)
|
||||
{
|
||||
result &= KeyboardDevice.KeyLine[2];
|
||||
}
|
||||
|
||||
if ((port & 0x200) == 0)
|
||||
{
|
||||
result &= KeyboardDevice.KeyLine[1];
|
||||
}
|
||||
|
||||
if ((port & 0x100) == 0)
|
||||
{
|
||||
result &= KeyboardDevice.KeyLine[0];
|
||||
}
|
||||
|
||||
result = result & 0x1f; //mask out lower 4 bits
|
||||
result = result | 0xa0; //set bit 5 & 7 to 1
|
||||
|
|
|
@ -15,6 +15,8 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
|
|||
/// <returns></returns>
|
||||
public override byte ReadPort(ushort port)
|
||||
{
|
||||
InputRead = true;
|
||||
|
||||
int result = 0xFF;
|
||||
|
||||
// Check whether the low bit is reset
|
||||
|
@ -28,6 +30,8 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
|
|||
{
|
||||
if (LocateUniqueJoystick(JoystickType.Kempston) != null)
|
||||
return (byte)((KempstonJoystick)LocateUniqueJoystick(JoystickType.Kempston) as KempstonJoystick).JoyLine;
|
||||
|
||||
InputRead = true;
|
||||
}
|
||||
else if (lowBitReset)
|
||||
{
|
||||
|
@ -44,28 +48,44 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
|
|||
*/
|
||||
|
||||
if ((port & 0x8000) == 0)
|
||||
{
|
||||
result &= KeyboardDevice.KeyLine[7];
|
||||
}
|
||||
|
||||
if ((port & 0x4000) == 0)
|
||||
{
|
||||
result &= KeyboardDevice.KeyLine[6];
|
||||
}
|
||||
|
||||
if ((port & 0x2000) == 0)
|
||||
{
|
||||
result &= KeyboardDevice.KeyLine[5];
|
||||
}
|
||||
|
||||
if ((port & 0x1000) == 0)
|
||||
{
|
||||
result &= KeyboardDevice.KeyLine[4];
|
||||
}
|
||||
|
||||
if ((port & 0x800) == 0)
|
||||
{
|
||||
result &= KeyboardDevice.KeyLine[3];
|
||||
}
|
||||
|
||||
if ((port & 0x400) == 0)
|
||||
{
|
||||
result &= KeyboardDevice.KeyLine[2];
|
||||
}
|
||||
|
||||
if ((port & 0x200) == 0)
|
||||
{
|
||||
result &= KeyboardDevice.KeyLine[1];
|
||||
}
|
||||
|
||||
if ((port & 0x100) == 0)
|
||||
{
|
||||
result &= KeyboardDevice.KeyLine[0];
|
||||
}
|
||||
|
||||
result = result & 0x1f; //mask out lower 4 bits
|
||||
result = result | 0xa0; //set bit 5 & 7 to 1
|
||||
|
|
|
@ -13,6 +13,8 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
|
|||
{
|
||||
_controller = controller;
|
||||
|
||||
_isLag = true;
|
||||
|
||||
if (_tracer.Enabled)
|
||||
{
|
||||
_cpu.TraceCallback = s => _tracer.Put(s);
|
||||
|
@ -23,6 +25,11 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
|
|||
}
|
||||
|
||||
_machine.ExecuteFrame();
|
||||
|
||||
if (_isLag)
|
||||
{
|
||||
_lagCount++;
|
||||
}
|
||||
}
|
||||
|
||||
public int Frame => _machine.FrameCount;
|
||||
|
|
|
@ -21,6 +21,6 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
|
|||
public IInputCallbackSystem InputCallbacks { get; }
|
||||
|
||||
private int _lagCount = 0;
|
||||
private bool _isLag = true;
|
||||
private bool _isLag = false;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue