Fix case when vtimer and htimer are enabled and the timer would have triggered earlier on the current line.

This commit is contained in:
Brandon Wright 2018-05-27 12:43:16 -05:00
parent c932d4e37a
commit d33c9eaad5
2 changed files with 10 additions and 3 deletions

View File

@ -889,7 +889,7 @@ static uint8 debug_cpu_op_print (char *Line, uint8 Bank, uint16 Address)
break;
}
sprintf(Line, "%-44s A:%04X X:%04X Y:%04X D:%04X DB:%02X S:%04X P:%c%c%c%c%c%c%c%c%c HC:%04ld VC:%03ld FC:%02d %03x %c",
sprintf(Line, "%-44s A:%04X X:%04X Y:%04X D:%04X DB:%02X S:%04X P:%c%c%c%c%c%c%c%c%c HC:%04ld VC:%03ld FC:%02d %03x %c %c%c",
Line, Registers.A.W, Registers.X.W, Registers.Y.W,
Registers.D.W, Registers.DB, Registers.S.W,
CheckEmulation() ? 'E' : 'e',
@ -905,7 +905,9 @@ static uint8 debug_cpu_op_print (char *Line, uint8 Bank, uint16 Address)
(long) CPU.V_Counter,
IPPU.FrameCount,
(CPU.IRQExternal ? 0x100 : 0) | (PPU.HTimerEnabled ? 0x10 : 0) | (PPU.VTimerEnabled ? 0x01 : 0),
CPU.NMIPending ? 'N' : '.');
CPU.NMIPending ? 'N' : '.',
CPU.IRQTransition ? 'T' : ' ',
CPU.IRQLine ? 'L' : ' ');
return (Size);
}

View File

@ -274,7 +274,7 @@ static int CyclesUntilNext (int hc, int vc)
int32 total = 0;
int vpos = CPU.V_Counter;
if (vc - vpos >= 0)
if (vc - vpos > 0)
{
// It's still in this frame */
// Add number of lines
@ -285,6 +285,11 @@ static int CyclesUntilNext (int hc, int vc)
}
else
{
if (vc == vpos && hc > CPU.Cycles)
{
return hc;
}
total += (Timings.V_Max - vpos) * Timings.H_Max;
if (vpos <= 240 && Timings.InterlaceField && !IPPU.Interlace)
total -= ONE_DOT_CYCLE;