diff options
author | Michael Pavone <pavone@retrodev.com> | 2017-01-05 19:15:53 -0800 |
---|---|---|
committer | Michael Pavone <pavone@retrodev.com> | 2017-01-05 19:15:53 -0800 |
commit | d87edd8607664bbd62d9da2026e305c5d85a8f75 (patch) | |
tree | 70dc61123de4111d685310b4eb81fb1dbe949048 | |
parent | 952542d189ed3b0f9c19a1a90485fdfde39cd2f2 (diff) |
Clear sprite overflow flag when control port read. Fix vcounter progression in Mode 4
-rw-r--r-- | vdp.c | 24 |
1 files changed, 15 insertions, 9 deletions
@@ -1373,19 +1373,24 @@ static void vdp_advance_line(vdp_context *context) { 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 @@ uint16_t vdp_control_port_read(vdp_context * context) } if (context->flags & FLAG_DOT_OFLOW) { value |= 0x40; + context->flags &= ~FLAG_DOT_OFLOW; } if (context->flags2 & FLAG2_SPRITE_COLLIDE) { value |= 0x20; |