Updated Z80 CPU to fix interrupts etc...
This commit is contained in:
@@ -17,6 +17,7 @@ namespace Core
|
||||
public SmsVdp VideoProcessor { get; private set; }
|
||||
public SmsApu AudioProcessor { get; private set; }
|
||||
public ushort? Breakpoint { get; set; } = null;
|
||||
private int _tStateCarryover = 0;
|
||||
|
||||
// NTSC SMS T-States per frame
|
||||
public const int TStatesPerFrame = 59736; //NTSC
|
||||
@@ -40,13 +41,15 @@ namespace Core
|
||||
public void Reset()
|
||||
{
|
||||
MemoryBus.CleanRAMData();
|
||||
VideoProcessor.Reset();
|
||||
Cpu.Reset();
|
||||
_tStateCarryover = 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void RunFrame()
|
||||
{
|
||||
int tStatesThisFrame = 0;
|
||||
int tStatesThisFrame = _tStateCarryover;
|
||||
while (tStatesThisFrame < TStatesPerFrame) // Standard NTSC frame time
|
||||
{
|
||||
// 1. Run one CPU instruction
|
||||
@@ -58,12 +61,16 @@ namespace Core
|
||||
AudioProcessor.Update(cycles);
|
||||
|
||||
// 3. Check if the VDP is begging for attention!
|
||||
if (VideoProcessor.InterruptPending && Cpu.IFF1)
|
||||
//if (VideoProcessor.InterruptPending && Cpu.IFF1)
|
||||
if (VideoProcessor.InterruptPending)
|
||||
{
|
||||
int intCycles = Cpu.RequestInterrupt();
|
||||
tStatesThisFrame += intCycles;
|
||||
VideoProcessor.Update(intCycles);
|
||||
AudioProcessor.Update(intCycles);
|
||||
if (intCycles > 0)
|
||||
{
|
||||
tStatesThisFrame += intCycles;
|
||||
VideoProcessor.Update(intCycles);
|
||||
AudioProcessor.Update(intCycles);
|
||||
}
|
||||
}
|
||||
|
||||
// 4. THE RESTORED BREAKPOINT TRAP
|
||||
|
||||
Reference in New Issue
Block a user