comparison vdp.c @ 1362:83bdd358f3a7

Fix regression in games that disable the display early like F1 World Championship. Remove debug printf
author Michael Pavone <pavone@retrodev.com>
date Sun, 14 May 2017 12:07:39 -0700
parents 1679ea04c449
children 6dd2c3edd0b5
comparison
equal deleted inserted replaced
1361:1679ea04c449 1362:83bdd358f3a7
2581 } 2581 }
2582 context->buf_a_off = (context->buf_a_off + SCROLL_BUFFER_DRAW) & SCROLL_BUFFER_DRAW; 2582 context->buf_a_off = (context->buf_a_off + SCROLL_BUFFER_DRAW) & SCROLL_BUFFER_DRAW;
2583 context->buf_b_off = (context->buf_b_off + SCROLL_BUFFER_DRAW) & SCROLL_BUFFER_DRAW; 2583 context->buf_b_off = (context->buf_b_off + SCROLL_BUFFER_DRAW) & SCROLL_BUFFER_DRAW;
2584 } 2584 }
2585 2585
2586 static void check_switch_inactive(vdp_context *context, uint8_t is_h40)
2587 {
2588 //technically the second hcounter check should be different for H40, but this is probably close enough for now
2589 if (context->state == ACTIVE && context->vcounter == context->inactive_start && (context->hslot >= (is_h40 ? 167 : 135) || context->hslot < 133)) {
2590 context->state = INACTIVE;
2591 }
2592 }
2593
2586 static void vdp_inactive(vdp_context *context, uint32_t target_cycles, uint8_t is_h40, uint8_t mode_5) 2594 static void vdp_inactive(vdp_context *context, uint32_t target_cycles, uint8_t is_h40, uint8_t mode_5)
2587 { 2595 {
2588 uint8_t buf_clear_slot, index_reset_slot, bg_end_slot, vint_slot, line_change, jump_start, jump_dest; 2596 uint8_t buf_clear_slot, index_reset_slot, bg_end_slot, vint_slot, line_change, jump_start, jump_dest;
2589 uint8_t index_reset_value, max_draws, max_sprites; 2597 uint8_t index_reset_value, max_draws, max_sprites;
2590 uint16_t vint_line, active_line; 2598 uint16_t vint_line, active_line;
2659 dst = NULL; 2667 dst = NULL;
2660 } 2668 }
2661 2669
2662 while(context->cycles < target_cycles) 2670 while(context->cycles < target_cycles)
2663 { 2671 {
2672 check_switch_inactive(context, is_h40);
2664 if (context->hslot == BG_START_SLOT && !test_layer && ( 2673 if (context->hslot == BG_START_SLOT && !test_layer && (
2665 context->vcounter < context->inactive_start + context->border_bot 2674 context->vcounter < context->inactive_start + context->border_bot
2666 || context->vcounter >= 0x200 - context->border_top 2675 || context->vcounter >= 0x200 - context->border_top
2667 )) { 2676 )) {
2668 dst = context->output + (context->hslot - BG_START_SLOT) * 2; 2677 dst = context->output + (context->hslot - BG_START_SLOT) * 2;
2766 { 2775 {
2767 uint8_t is_h40 = context->regs[REG_MODE_4] & BIT_H40; 2776 uint8_t is_h40 = context->regs[REG_MODE_4] & BIT_H40;
2768 uint8_t mode_5 = context->regs[REG_MODE_2] & BIT_MODE_5; 2777 uint8_t mode_5 = context->regs[REG_MODE_2] & BIT_MODE_5;
2769 while(context->cycles < target_cycles) 2778 while(context->cycles < target_cycles)
2770 { 2779 {
2771 //technically the second hcounter check should be different for H40, but this is probably close enough for now 2780 check_switch_inactive(context, is_h40);
2772 if (context->state == ACTIVE && context->vcounter == context->inactive_start && (context->hslot >= (is_h40 ? 167 : 135) || context->hslot < 133)) {
2773 context->state = INACTIVE;
2774 }
2775 2781
2776 if (is_active(context)) { 2782 if (is_active(context)) {
2777 if (mode_5) { 2783 if (mode_5) {
2778 if (is_h40) { 2784 if (is_h40) {
2779 vdp_h40(context, target_cycles); 2785 vdp_h40(context, target_cycles);
2913 vdp_latch_hv(context); 2919 vdp_latch_hv(context);
2914 } 2920 }
2915 if (reg == REG_BG_COLOR) { 2921 if (reg == REG_BG_COLOR) {
2916 value &= 0x3F; 2922 value &= 0x3F;
2917 } 2923 }
2918 if (reg == REG_MODE_2 && ((value ^ context->regs[reg]) & BIT_DISP_EN)) {
2919 printf("Display %s at %d, %d, %d\n", value & BIT_DISP_EN ? "enabled" : "disabled", context->frame, context->vcounter, context->hslot);
2920 }
2921 /*if (reg == REG_MODE_4 && ((value ^ context->regs[reg]) & BIT_H40)) { 2924 /*if (reg == REG_MODE_4 && ((value ^ context->regs[reg]) & BIT_H40)) {
2922 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); 2925 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);
2923 }*/ 2926 }*/
2924 context->regs[reg] = value; 2927 context->regs[reg] = value;
2925 if (reg == REG_MODE_4) { 2928 if (reg == REG_MODE_4) {