comparison vdp.c @ 1401:b56c8c51ca5d

Properly release and reacquire framebuffer pointer when switching contexts. Hopefully fixes the LOCKRECT issue some people are seeing with the SDL 2 fallback renderer
author Michael Pavone <pavone@retrodev.com>
date Thu, 15 Jun 2017 09:45:21 -0700
parents 1eded4f19910
children 2b34469e3f81
comparison
equal deleted inserted replaced
1400:6a0e3bb6981f 1401:b56c8c51ca5d
1759 context->h40_lines++; 1759 context->h40_lines++;
1760 } 1760 }
1761 } 1761 }
1762 } 1762 }
1763 1763
1764 void vdp_release_framebuffer(vdp_context *context)
1765 {
1766 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));
1767 context->output = context->fb = NULL;
1768 }
1769
1770 void vdp_reacquire_framebuffer(vdp_context *context)
1771 {
1772 context->fb = render_get_framebuffer(context->flags2 & FLAG2_EVEN_FIELD ? FRAMEBUFFER_EVEN : FRAMEBUFFER_ODD, &context->output_pitch);
1773 uint16_t lines_max = (context->flags2 & FLAG2_REGION_PAL)
1774 ? 240 + BORDER_TOP_V30_PAL + BORDER_BOT_V30_PAL
1775 : 224 + BORDER_TOP_V28 + BORDER_BOT_V28;
1776 if (context->output_lines <= lines_max && context->output_lines > 0) {
1777 context->output = (uint32_t *)(((char *)context->fb) + context->output_pitch * (context->output_lines - 1));
1778 } else {
1779 context->output = (uint32_t *)(((char *)context->fb) + context->output_pitch * INVALID_LINE);
1780 }
1781 }
1782
1764 static void render_border_garbage(vdp_context *context, uint32_t address, uint8_t *buf, uint8_t buf_off, uint16_t col) 1783 static void render_border_garbage(vdp_context *context, uint32_t address, uint8_t *buf, uint8_t buf_off, uint16_t col)
1765 { 1784 {
1766 uint8_t base = col >> 9 & 0x30; 1785 uint8_t base = col >> 9 & 0x30;
1767 for (int i = 0; i < 4; i++, address++) 1786 for (int i = 0; i < 4; i++, address++)
1768 { 1787 {