# HG changeset patch # User Michael Pavone # Date 1494788859 25200 # Node ID 83bdd358f3a70ab1dc7273d6804cb855e05db7ce # Parent 1679ea04c44941614f540b4560cc0142307f6acb Fix regression in games that disable the display early like F1 World Championship. Remove debug printf diff -r 1679ea04c449 -r 83bdd358f3a7 vdp.c --- a/vdp.c Sun May 14 11:15:56 2017 -0700 +++ b/vdp.c Sun May 14 12:07:39 2017 -0700 @@ -2583,6 +2583,14 @@ context->buf_b_off = (context->buf_b_off + SCROLL_BUFFER_DRAW) & SCROLL_BUFFER_DRAW; } +static void check_switch_inactive(vdp_context *context, uint8_t is_h40) +{ + //technically the second hcounter check should be different for H40, but this is probably close enough for now + if (context->state == ACTIVE && context->vcounter == context->inactive_start && (context->hslot >= (is_h40 ? 167 : 135) || context->hslot < 133)) { + context->state = INACTIVE; + } +} + static void vdp_inactive(vdp_context *context, uint32_t target_cycles, uint8_t is_h40, uint8_t mode_5) { uint8_t buf_clear_slot, index_reset_slot, bg_end_slot, vint_slot, line_change, jump_start, jump_dest; @@ -2661,6 +2669,7 @@ while(context->cycles < target_cycles) { + check_switch_inactive(context, is_h40); if (context->hslot == BG_START_SLOT && !test_layer && ( context->vcounter < context->inactive_start + context->border_bot || context->vcounter >= 0x200 - context->border_top @@ -2768,10 +2777,7 @@ uint8_t mode_5 = context->regs[REG_MODE_2] & BIT_MODE_5; while(context->cycles < target_cycles) { - //technically the second hcounter check should be different for H40, but this is probably close enough for now - if (context->state == ACTIVE && context->vcounter == context->inactive_start && (context->hslot >= (is_h40 ? 167 : 135) || context->hslot < 133)) { - context->state = INACTIVE; - } + check_switch_inactive(context, is_h40); if (is_active(context)) { if (mode_5) { @@ -2915,9 +2921,6 @@ if (reg == REG_BG_COLOR) { value &= 0x3F; } - if (reg == REG_MODE_2 && ((value ^ context->regs[reg]) & BIT_DISP_EN)) { - printf("Display %s at %d, %d, %d\n", value & BIT_DISP_EN ? "enabled" : "disabled", context->frame, context->vcounter, context->hslot); - } /*if (reg == REG_MODE_4 && ((value ^ context->regs[reg]) & BIT_H40)) { printf("Mode changed from H%d to H%d @ %d, frame: %d\n", context->regs[reg] & BIT_H40 ? 40 : 32, value & BIT_H40 ? 40 : 32, context->cycles, context->frame); }*/