ZXHawk: added CPUMonitor syncstate
This commit is contained in:
parent
7f8084d410
commit
c80f873adf
|
@ -1,4 +1,5 @@
|
||||||
using BizHawk.Emulation.Cores.Components.Z80A;
|
using BizHawk.Common;
|
||||||
|
using BizHawk.Emulation.Cores.Components.Z80A;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
@ -19,19 +20,17 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
|
||||||
|
|
||||||
#region Lookups
|
#region Lookups
|
||||||
|
|
||||||
public ushort[] cur_instr => _cpu.cur_instr;
|
/// <summary>
|
||||||
public int instr_pntr => _cpu.instr_pntr;
|
/// CPU total executes t-states
|
||||||
public ushort RegPC => _cpu.RegPC;
|
/// </summary>
|
||||||
public long TotalExecutedCycles => _cpu.TotalExecutedCycles;
|
public long TotalExecutedCycles => _cpu.TotalExecutedCycles;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Current BUSRQ line array
|
||||||
|
/// </summary>
|
||||||
public ushort BUSRQ
|
public ushort BUSRQ
|
||||||
{
|
{
|
||||||
get
|
get { return _cpu.BUSRQ[_cpu.bus_pntr]; }
|
||||||
{
|
|
||||||
//if (_cpu.bus_pntr < _cpu.BUSRQ.Length - 1)
|
|
||||||
return _cpu.BUSRQ[_cpu.bus_pntr];
|
|
||||||
|
|
||||||
//return 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
@ -48,13 +47,10 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
|
||||||
|
|
||||||
#region State
|
#region State
|
||||||
|
|
||||||
public bool IsContending = false;
|
/// <summary>
|
||||||
public int ContCounter = -1;
|
/// The last 16-bit port address that was detected
|
||||||
public int portContCounter = 0;
|
/// </summary>
|
||||||
public int portContTotalLen = 0;
|
|
||||||
public bool portContending = false;
|
|
||||||
public ushort lastPortAddr;
|
public ushort lastPortAddr;
|
||||||
public int[] portContArr = new int[4];
|
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
@ -89,7 +85,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Looks up the BUSRQ address that is about to be signalled
|
/// Looks up the current BUSRQ address that is about to be signalled on the upcoming cycle
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
private ushort AscertainBUSRQAddress()
|
private ushort AscertainBUSRQAddress()
|
||||||
|
@ -156,6 +152,79 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
|
||||||
return addr;
|
return addr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Running every cycle, this determines whether the upcoming BUSRQ is for an IO operation
|
||||||
|
/// Also processes any contention
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
private bool CheckIO()
|
||||||
|
{
|
||||||
|
bool isIO = false;
|
||||||
|
|
||||||
|
switch (BUSRQ)
|
||||||
|
{
|
||||||
|
// BC: T1
|
||||||
|
case Z80A.BIO1:
|
||||||
|
lastPortAddr = AscertainBUSRQAddress();
|
||||||
|
isIO = true;
|
||||||
|
if (IsIOCycleContended(1))
|
||||||
|
_cpu.TotalExecutedCycles += _machine.ULADevice.GetPortContentionValue((int)_machine.CurrentFrameCycle);
|
||||||
|
break;
|
||||||
|
// BC: T2
|
||||||
|
case Z80A.BIO2:
|
||||||
|
lastPortAddr = AscertainBUSRQAddress();
|
||||||
|
isIO = true;
|
||||||
|
if (IsIOCycleContended(2))
|
||||||
|
_cpu.TotalExecutedCycles += _machine.ULADevice.GetPortContentionValue((int)_machine.CurrentFrameCycle);
|
||||||
|
break;
|
||||||
|
// BC: T3
|
||||||
|
case Z80A.BIO3:
|
||||||
|
lastPortAddr = AscertainBUSRQAddress();
|
||||||
|
isIO = true;
|
||||||
|
if (IsIOCycleContended(3))
|
||||||
|
_cpu.TotalExecutedCycles += _machine.ULADevice.GetPortContentionValue((int)_machine.CurrentFrameCycle);
|
||||||
|
break;
|
||||||
|
// BC: T4
|
||||||
|
case Z80A.BIO4:
|
||||||
|
lastPortAddr = AscertainBUSRQAddress();
|
||||||
|
isIO = true;
|
||||||
|
if (IsIOCycleContended(4))
|
||||||
|
_cpu.TotalExecutedCycles += _machine.ULADevice.GetPortContentionValue((int)_machine.CurrentFrameCycle);
|
||||||
|
break;
|
||||||
|
|
||||||
|
// WZ: T1
|
||||||
|
case Z80A.WIO1:
|
||||||
|
lastPortAddr = AscertainBUSRQAddress();
|
||||||
|
isIO = true;
|
||||||
|
if (IsIOCycleContended(1))
|
||||||
|
_cpu.TotalExecutedCycles += _machine.ULADevice.GetPortContentionValue((int)_machine.CurrentFrameCycle);
|
||||||
|
break;
|
||||||
|
// WZ: T2
|
||||||
|
case Z80A.WIO2:
|
||||||
|
lastPortAddr = AscertainBUSRQAddress();
|
||||||
|
isIO = true;
|
||||||
|
if (IsIOCycleContended(2))
|
||||||
|
_cpu.TotalExecutedCycles += _machine.ULADevice.GetPortContentionValue((int)_machine.CurrentFrameCycle);
|
||||||
|
break;
|
||||||
|
// WZ: T3
|
||||||
|
case Z80A.WIO3:
|
||||||
|
lastPortAddr = AscertainBUSRQAddress();
|
||||||
|
isIO = true;
|
||||||
|
if (IsIOCycleContended(3))
|
||||||
|
_cpu.TotalExecutedCycles += _machine.ULADevice.GetPortContentionValue((int)_machine.CurrentFrameCycle);
|
||||||
|
break;
|
||||||
|
// WZ: T4
|
||||||
|
case Z80A.WIO4:
|
||||||
|
lastPortAddr = AscertainBUSRQAddress();
|
||||||
|
isIO = true;
|
||||||
|
if (IsIOCycleContended(4))
|
||||||
|
_cpu.TotalExecutedCycles += _machine.ULADevice.GetPortContentionValue((int)_machine.CurrentFrameCycle);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return isIO;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns TRUE if the supplied T-cycle within an IO operation has the possibility of being contended
|
/// Returns TRUE if the supplied T-cycle within an IO operation has the possibility of being contended
|
||||||
/// This can be different based on the emulated ZX Spectrum model
|
/// This can be different based on the emulated ZX Spectrum model
|
||||||
|
@ -238,79 +307,6 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Running every cycle, this determines whether the upcoming BUSRQ is for an IO operation
|
|
||||||
/// Also processes any contention
|
|
||||||
/// </summary>
|
|
||||||
/// <returns></returns>
|
|
||||||
private bool CheckIO()
|
|
||||||
{
|
|
||||||
bool isIO = false;
|
|
||||||
|
|
||||||
switch (BUSRQ)
|
|
||||||
{
|
|
||||||
// BC: T1
|
|
||||||
case Z80A.BIO1:
|
|
||||||
lastPortAddr = AscertainBUSRQAddress();
|
|
||||||
isIO = true;
|
|
||||||
if (IsIOCycleContended(1))
|
|
||||||
_cpu.TotalExecutedCycles += _machine.ULADevice.GetPortContentionValue((int)_machine.CurrentFrameCycle);
|
|
||||||
break;
|
|
||||||
// BC: T2
|
|
||||||
case Z80A.BIO2:
|
|
||||||
lastPortAddr = AscertainBUSRQAddress();
|
|
||||||
isIO = true;
|
|
||||||
if (IsIOCycleContended(2))
|
|
||||||
_cpu.TotalExecutedCycles += _machine.ULADevice.GetPortContentionValue((int)_machine.CurrentFrameCycle);
|
|
||||||
break;
|
|
||||||
// BC: T3
|
|
||||||
case Z80A.BIO3:
|
|
||||||
lastPortAddr = AscertainBUSRQAddress();
|
|
||||||
isIO = true;
|
|
||||||
if (IsIOCycleContended(3))
|
|
||||||
_cpu.TotalExecutedCycles += _machine.ULADevice.GetPortContentionValue((int)_machine.CurrentFrameCycle);
|
|
||||||
break;
|
|
||||||
// BC: T4
|
|
||||||
case Z80A.BIO4:
|
|
||||||
lastPortAddr = AscertainBUSRQAddress();
|
|
||||||
isIO = true;
|
|
||||||
if (IsIOCycleContended(4))
|
|
||||||
_cpu.TotalExecutedCycles += _machine.ULADevice.GetPortContentionValue((int)_machine.CurrentFrameCycle);
|
|
||||||
break;
|
|
||||||
|
|
||||||
// WZ: T1
|
|
||||||
case Z80A.WIO1:
|
|
||||||
lastPortAddr = AscertainBUSRQAddress();
|
|
||||||
isIO = true;
|
|
||||||
if (IsIOCycleContended(1))
|
|
||||||
_cpu.TotalExecutedCycles += _machine.ULADevice.GetPortContentionValue((int)_machine.CurrentFrameCycle);
|
|
||||||
break;
|
|
||||||
// WZ: T2
|
|
||||||
case Z80A.WIO2:
|
|
||||||
lastPortAddr = AscertainBUSRQAddress();
|
|
||||||
isIO = true;
|
|
||||||
if (IsIOCycleContended(2))
|
|
||||||
_cpu.TotalExecutedCycles += _machine.ULADevice.GetPortContentionValue((int)_machine.CurrentFrameCycle);
|
|
||||||
break;
|
|
||||||
// WZ: T3
|
|
||||||
case Z80A.WIO3:
|
|
||||||
lastPortAddr = AscertainBUSRQAddress();
|
|
||||||
isIO = true;
|
|
||||||
if (IsIOCycleContended(3))
|
|
||||||
_cpu.TotalExecutedCycles += _machine.ULADevice.GetPortContentionValue((int)_machine.CurrentFrameCycle);
|
|
||||||
break;
|
|
||||||
// WZ: T4
|
|
||||||
case Z80A.WIO4:
|
|
||||||
lastPortAddr = AscertainBUSRQAddress();
|
|
||||||
isIO = true;
|
|
||||||
if (IsIOCycleContended(4))
|
|
||||||
_cpu.TotalExecutedCycles += _machine.ULADevice.GetPortContentionValue((int)_machine.CurrentFrameCycle);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return isIO;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Called when the first byte of an instruction is fetched
|
/// Called when the first byte of an instruction is fetched
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -323,5 +319,15 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#region Serialization
|
||||||
|
|
||||||
|
public void SyncState(Serializer ser)
|
||||||
|
{
|
||||||
|
ser.BeginSection("CPUMonitor");
|
||||||
|
ser.Sync("", ref lastPortAddr);
|
||||||
|
ser.EndSection();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue