summaryrefslogtreecommitdiff
path: root/vdp.c
diff options
context:
space:
mode:
authorMichael Pavone <pavone@retrodev.com>2017-06-15 09:45:21 -0700
committerMichael Pavone <pavone@retrodev.com>2017-06-15 09:45:21 -0700
commitdee43c24fbd5f0ee0b81cc325164903c8b25ea1d (patch)
treead8562d7a5d411430122ac75b1e755e571907684 /vdp.c
parentfd0dfe77e0c947e63026c944b94675018834351b (diff)
Properly release and reacquire framebuffer pointer when switching contexts. Hopefully fixes the LOCKRECT issue some people are seeing with the SDL 2 fallback renderer
Diffstat (limited to 'vdp.c')
-rw-r--r--vdp.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/vdp.c b/vdp.c
index 3b8538e..d5bfefa 100644
--- a/vdp.c
+++ b/vdp.c
@@ -1761,6 +1761,25 @@ static void advance_output_line(vdp_context *context)
}
}
+void vdp_release_framebuffer(vdp_context *context)
+{
+ 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));
+ context->output = context->fb = NULL;
+}
+
+void vdp_reacquire_framebuffer(vdp_context *context)
+{
+ context->fb = render_get_framebuffer(context->flags2 & FLAG2_EVEN_FIELD ? FRAMEBUFFER_EVEN : FRAMEBUFFER_ODD, &context->output_pitch);
+ uint16_t lines_max = (context->flags2 & FLAG2_REGION_PAL)
+ ? 240 + BORDER_TOP_V30_PAL + BORDER_BOT_V30_PAL
+ : 224 + BORDER_TOP_V28 + BORDER_BOT_V28;
+ if (context->output_lines <= lines_max && context->output_lines > 0) {
+ context->output = (uint32_t *)(((char *)context->fb) + context->output_pitch * (context->output_lines - 1));
+ } else {
+ context->output = (uint32_t *)(((char *)context->fb) + context->output_pitch * INVALID_LINE);
+ }
+}
+
static void render_border_garbage(vdp_context *context, uint32_t address, uint8_t *buf, uint8_t buf_off, uint16_t col)
{
uint8_t base = col >> 9 & 0x30;