# HG changeset patch # User Michael Pavone # Date 1431401435 25200 # Node ID d8a1fdec68fc621733c5223072e5c12a18aefd48 # Parent 0a86e81fa87de66d0687bb21eec0090fbccb0414 Fix frame counter increment and VINT cycle time calculation diff -r 0a86e81fa87d -r d8a1fdec68fc vdp.c --- a/vdp.c Mon May 11 20:30:13 2015 -0700 +++ b/vdp.c Mon May 11 20:30:35 2015 -0700 @@ -1456,9 +1456,6 @@ } if (is_h40 && slot == LINE_CHANGE_H40 || !is_h40 && slot == LINE_CHANGE_H32) { if (line >= inactive_start) { - if (line == (inactive_start + 8)) { - context->frame++; - } context->hint_counter = context->regs[REG_HINT]; } else if (context->hint_counter) { context->hint_counter--; @@ -1524,12 +1521,18 @@ if (is_h40) { if (context->hslot == LINE_CHANGE_H40) { context->vcounter++; + if (context->vcounter == (inactive_start + 8)) { + context->frame++; + } } else if (context->hslot == 183) { context->hslot = 229; } } else { if (context->hslot == LINE_CHANGE_H32) { context->vcounter++; + if (context->vcounter == (inactive_start + 8)) { + context->frame++; + } } else if (context->hslot == 148) { context->hslot = 233; } @@ -1957,7 +1960,7 @@ uint32_t inactive_start = context->latched_mode & BIT_PAL ? PAL_INACTIVE_START : NTSC_INACTIVE_START; if (context->vcounter == inactive_start) { if (context->regs[REG_MODE_4] & BIT_H40) { - if (context->hslot >= HBLANK_START_H40) { + if (context->hslot >= LINE_CHANGE_H40) { if (context->hslot < 183) { return context->cycles + (VINT_SLOT_H40 + 183 - context->hslot + 256 - 229) * MCLKS_SLOT_H40; } else { @@ -1967,7 +1970,7 @@ return context->cycles + (VINT_SLOT_H40 - context->hslot) * MCLKS_SLOT_H40; } } else { - if (context->hslot >= HBLANK_START_H32) { + if (context->hslot >= LINE_CHANGE_H32) { if (context->hslot < 148) { return context->cycles + (VINT_SLOT_H32 + 148 - context->hslot + 256 - 233) * MCLKS_SLOT_H32; } else { @@ -1980,9 +1983,9 @@ } int32_t cycles_to_vint = vdp_cycles_to_line(context, inactive_start); if (context->regs[REG_MODE_4] & BIT_H40) { - cycles_to_vint += (VINT_SLOT_H40 + 183 - HBLANK_START_H40 + 256 - 229) * MCLKS_SLOT_H40; + cycles_to_vint += (VINT_SLOT_H40 + 183 - LINE_CHANGE_H40 + 256 - 229) * MCLKS_SLOT_H40; } else { - cycles_to_vint += (VINT_SLOT_H32 + 148 - HBLANK_START_H32 + 256 - 233) * MCLKS_SLOT_H32; + cycles_to_vint += (VINT_SLOT_H32 + 148 - LINE_CHANGE_H32 + 256 - 233) * MCLKS_SLOT_H32; } return context->cycles + cycles_to_vint; }