# HG changeset patch # User Michael Pavone # Date 1483672553 28800 # Node ID b519965f6394890e6d221a1d6426388752a48590 # Parent da6a1f156f24f0af8798876deed5d2c128ee0b43 Clear sprite overflow flag when control port read. Fix vcounter progression in Mode 4 diff -r da6a1f156f24 -r b519965f6394 vdp.c --- a/vdp.c Thu Jan 05 00:42:11 2017 -0800 +++ b/vdp.c Thu Jan 05 19:15:53 2017 -0800 @@ -1373,19 +1373,24 @@ { context->vcounter++; context->vcounter &= 0x1FF; - if (context->flags2 & FLAG2_REGION_PAL) { - if (context->latched_mode & BIT_PAL) { - if (context->vcounter == 0x10B) { - context->vcounter = 0x1D2; + uint8_t is_mode_5 = context->regs[REG_MODE_2] & BIT_MODE_5; + if (is_mode_5) { + if (context->flags2 & FLAG2_REGION_PAL) { + if (context->latched_mode & BIT_PAL) { + if (context->vcounter == 0x10B) { + context->vcounter = 0x1D2; + } + } else if (context->vcounter == 0x103){ + context->vcounter = 0x1CA; } - } else if (context->vcounter == 0x103){ - context->vcounter = 0x1CA; + } else if (!(context->latched_mode & BIT_PAL) && context->vcounter == 0xEB) { + context->vcounter = 0x1E5; } - } else if (!(context->latched_mode & BIT_PAL) && context->vcounter == 0xEB) { - context->vcounter = 0x1E5; + } else if (context->vcounter == 0xDB) { + context->vcounter = 0x1D5; } uint32_t inactive_start = (context->latched_mode & BIT_PAL ? PAL_INACTIVE_START : NTSC_INACTIVE_START); - if (!(context->regs[REG_MODE_2] & BIT_MODE_5)) { + if (!is_mode_5) { inactive_start = MODE4_INACTIVE_START; } if (!headless) { @@ -2363,6 +2368,7 @@ } if (context->flags & FLAG_DOT_OFLOW) { value |= 0x40; + context->flags &= ~FLAG_DOT_OFLOW; } if (context->flags2 & FLAG2_SPRITE_COLLIDE) { value |= 0x20;