Bound late NMI trigger to last half of scanline. Be more careful setting trigger position.

This commit is contained in:
Brandon Wright 2018-05-17 16:24:51 -05:00
parent 7f88063b84
commit 8c47efb89a
2 changed files with 3 additions and 11 deletions

View File

@ -413,7 +413,7 @@ void S9xDoHEventProcessing (void)
}
/* Did we skip over a late NMI Trigger Pos? If so, reschedule it immediately. */
if (CPU.NMIPending && (CPU.Cycles >= Timings.NMITriggerPos))
if (CPU.NMIPending && (CPU.Cycles >= Timings.NMITriggerPos) && (Timings.NMITriggerPos > Timings.H_Max / 2))
Timings.NMITriggerPos = 0;
S9xAPUEndScanline();
@ -421,16 +421,6 @@ void S9xDoHEventProcessing (void)
CPU.PrevCycles -= Timings.H_Max;
S9xAPUSetReferenceTime(CPU.Cycles);
if ((Timings.NMITriggerPos != 0xffff) && (Timings.NMITriggerPos >= Timings.H_Max))
{
Timings.NMITriggerPos -= Timings.H_Max;
#ifdef DEBUGGER
if (Settings.TraceHCEvent)
S9xTraceFormattedMessage ("NMI Trigger pos changed to %d\n", Timings.NMITriggerPos);
#endif
}
CPU.V_Counter++;
if (CPU.V_Counter >= Timings.V_Max) // V ranges from 0 to Timings.V_Max - 1
{

View File

@ -1520,6 +1520,8 @@ void S9xSetCPU (uint8 Byte, uint16 Address)
// then, when to call S9xOpcode_NMI()?
CPU.NMIPending = TRUE;
Timings.NMITriggerPos = CPU.Cycles + 6 + 6;
if (Timings.NMITriggerPOS >= Timings.H_Max)
Timings.NMITriggerPOS -= Timings.H_Max;
#ifdef DEBUGGER
if (Settings.TraceHCEvent)