Mercurial > repos > blastem
comparison vdp.c @ 1436:40c3be9f1af7
Fix timing of VDP ODD flag toggle
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Mon, 21 Aug 2017 23:08:36 -0700 |
parents | 5e7e6d9b79ff |
children | da72344af3ff |
comparison
equal
deleted
inserted
replaced
1435:178de1432291 | 1436:40c3be9f1af7 |
---|---|
147 */ | 147 */ |
148 if (headless) { | 148 if (headless) { |
149 context->output = malloc(LINEBUF_SIZE * sizeof(uint32_t)); | 149 context->output = malloc(LINEBUF_SIZE * sizeof(uint32_t)); |
150 context->output_pitch = 0; | 150 context->output_pitch = 0; |
151 } else { | 151 } else { |
152 context->cur_buffer = FRAMEBUFFER_ODD; | |
152 context->fb = render_get_framebuffer(FRAMEBUFFER_ODD, &context->output_pitch); | 153 context->fb = render_get_framebuffer(FRAMEBUFFER_ODD, &context->output_pitch); |
153 } | 154 } |
154 context->linebuf = malloc(LINEBUF_SIZE + SCROLL_BUFFER_SIZE*2); | 155 context->linebuf = malloc(LINEBUF_SIZE + SCROLL_BUFFER_SIZE*2); |
155 memset(context->linebuf, 0, LINEBUF_SIZE + SCROLL_BUFFER_SIZE*2); | 156 memset(context->linebuf, 0, LINEBUF_SIZE + SCROLL_BUFFER_SIZE*2); |
156 context->tmp_buf_a = context->linebuf + LINEBUF_SIZE; | 157 context->tmp_buf_a = context->linebuf + LINEBUF_SIZE; |
1727 uint16_t lines_max = (context->flags2 & FLAG2_REGION_PAL) | 1728 uint16_t lines_max = (context->flags2 & FLAG2_REGION_PAL) |
1728 ? 240 + BORDER_TOP_V30_PAL + BORDER_BOT_V30_PAL | 1729 ? 240 + BORDER_TOP_V30_PAL + BORDER_BOT_V30_PAL |
1729 : 224 + BORDER_TOP_V28 + BORDER_BOT_V28; | 1730 : 224 + BORDER_TOP_V28 + BORDER_BOT_V28; |
1730 | 1731 |
1731 if (context->output_lines == lines_max) { | 1732 if (context->output_lines == lines_max) { |
1732 render_framebuffer_updated(context->flags2 & FLAG2_EVEN_FIELD ? FRAMEBUFFER_EVEN: FRAMEBUFFER_ODD, context->h40_lines > (context->inactive_start + context->border_top) / 2 ? LINEBUF_SIZE : (256+HORIZ_BORDER)); | 1733 render_framebuffer_updated(context->cur_buffer, context->h40_lines > (context->inactive_start + context->border_top) / 2 ? LINEBUF_SIZE : (256+HORIZ_BORDER)); |
1733 if (context->double_res) { | 1734 context->cur_buffer = context->flags2 & FLAG2_EVEN_FIELD ? FRAMEBUFFER_EVEN : FRAMEBUFFER_ODD; |
1734 context->flags2 ^= FLAG2_EVEN_FIELD; | 1735 context->fb = render_get_framebuffer(context->cur_buffer, &context->output_pitch); |
1735 } | |
1736 context->fb = render_get_framebuffer(context->flags2 & FLAG2_EVEN_FIELD ? FRAMEBUFFER_EVEN : FRAMEBUFFER_ODD, &context->output_pitch); | |
1737 context->h40_lines = 0; | 1736 context->h40_lines = 0; |
1738 context->frame++; | 1737 context->frame++; |
1739 context->output_lines = 0; | 1738 context->output_lines = 0; |
1740 } | 1739 } |
1741 uint32_t output_line = context->vcounter; | 1740 uint32_t output_line = context->vcounter; |
1769 } | 1768 } |
1770 } | 1769 } |
1771 | 1770 |
1772 void vdp_release_framebuffer(vdp_context *context) | 1771 void vdp_release_framebuffer(vdp_context *context) |
1773 { | 1772 { |
1774 render_framebuffer_updated(context->flags2 & FLAG2_EVEN_FIELD ? FRAMEBUFFER_EVEN: FRAMEBUFFER_ODD, context->h40_lines > (context->inactive_start + context->border_top) / 2 ? LINEBUF_SIZE : (256+HORIZ_BORDER)); | 1773 render_framebuffer_updated(context->cur_buffer, context->h40_lines > (context->inactive_start + context->border_top) / 2 ? LINEBUF_SIZE : (256+HORIZ_BORDER)); |
1775 context->output = context->fb = NULL; | 1774 context->output = context->fb = NULL; |
1776 } | 1775 } |
1777 | 1776 |
1778 void vdp_reacquire_framebuffer(vdp_context *context) | 1777 void vdp_reacquire_framebuffer(vdp_context *context) |
1779 { | 1778 { |
1780 context->fb = render_get_framebuffer(context->flags2 & FLAG2_EVEN_FIELD ? FRAMEBUFFER_EVEN : FRAMEBUFFER_ODD, &context->output_pitch); | 1779 context->fb = render_get_framebuffer(context->cur_buffer, &context->output_pitch); |
1781 uint16_t lines_max = (context->flags2 & FLAG2_REGION_PAL) | 1780 uint16_t lines_max = (context->flags2 & FLAG2_REGION_PAL) |
1782 ? 240 + BORDER_TOP_V30_PAL + BORDER_BOT_V30_PAL | 1781 ? 240 + BORDER_TOP_V30_PAL + BORDER_BOT_V30_PAL |
1783 : 224 + BORDER_TOP_V28 + BORDER_BOT_V28; | 1782 : 224 + BORDER_TOP_V28 + BORDER_BOT_V28; |
1784 if (context->output_lines <= lines_max && context->output_lines > 0) { | 1783 if (context->output_lines <= lines_max && context->output_lines > 0) { |
1785 context->output = (uint32_t *)(((char *)context->fb) + context->output_pitch * (context->output_lines - 1)); | 1784 context->output = (uint32_t *)(((char *)context->fb) + context->output_pitch * (context->output_lines - 1)); |
2823 context->sprite_index = index_reset_value; | 2822 context->sprite_index = index_reset_value; |
2824 context->slot_counter = mode_5 ? 0 : max_sprites; | 2823 context->slot_counter = mode_5 ? 0 : max_sprites; |
2825 } else if (context->vcounter == vint_line && context->hslot == vint_slot) { | 2824 } else if (context->vcounter == vint_line && context->hslot == vint_slot) { |
2826 context->flags2 |= FLAG2_VINT_PENDING; | 2825 context->flags2 |= FLAG2_VINT_PENDING; |
2827 context->pending_vint_start = context->cycles; | 2826 context->pending_vint_start = context->cycles; |
2827 } else if (context->vcounter == context->inactive_start && context->hslot == 1 && (context->regs[REG_MODE_4] & BIT_INTERLACE)) { | |
2828 context->flags2 ^= FLAG2_EVEN_FIELD; | |
2828 } | 2829 } |
2829 | 2830 |
2830 if (dst) { | 2831 if (dst) { |
2831 if (mode_5) { | 2832 if (mode_5) { |
2832 bg_color = context->colors[context->regs[REG_BG_COLOR] & 0x3F]; | 2833 bg_color = context->colors[context->regs[REG_BG_COLOR] & 0x3F]; |