# HG changeset patch # User Michael Pavone # Date 1542649927 28800 # Node ID bc9bb4e5856f4c7f5ef88c4d392e4ccf214e5b4b # Parent 3602f3b2007212b7f370417a965e68abd89bd352 Basic version of layer compositing debug view in a separate window diff -r 3602f3b20072 -r bc9bb4e5856f bindings.c --- a/bindings.c Fri Nov 16 19:56:24 2018 -0800 +++ b/bindings.c Mon Nov 19 09:52:07 2018 -0800 @@ -40,6 +40,7 @@ UI_PLANE_DEBUG, UI_VRAM_DEBUG, UI_CRAM_DEBUG, + UI_COMPOSITE_DEBUG } ui_action; typedef struct { @@ -378,7 +379,8 @@ break; case UI_PLANE_DEBUG: case UI_VRAM_DEBUG: - case UI_CRAM_DEBUG: { + case UI_CRAM_DEBUG: + case UI_COMPOSITE_DEBUG: { vdp_context *vdp = NULL; if (current_system->type == SYSTEM_GENESIS) { genesis_context *gen = (genesis_context *)current_system; @@ -394,6 +396,7 @@ case UI_PLANE_DEBUG: debug_type = VDP_DEBUG_PLANE; break; case UI_VRAM_DEBUG: debug_type = VDP_DEBUG_VRAM; break; case UI_CRAM_DEBUG: debug_type = VDP_DEBUG_CRAM; break; + case UI_COMPOSITE_DEBUG: debug_type = VDP_DEBUG_COMPOSITE; break; default: return; } vdp_toggle_debug_view(vdp, debug_type); @@ -609,6 +612,8 @@ *subtype_a = UI_VRAM_DEBUG; } else if (!strcmp(target + 3, "cram_debug")) { *subtype_a = UI_CRAM_DEBUG; + } else if (!strcmp(target + 3, "compositing_debug")) { + *subtype_a = UI_COMPOSITE_DEBUG; } else { warning("Unreconized UI binding type %s\n", target); return 0; diff -r 3602f3b20072 -r bc9bb4e5856f default.cfg --- a/default.cfg Fri Nov 16 19:56:24 2018 -0800 +++ b/default.cfg Mon Nov 19 09:52:07 2018 -0800 @@ -22,6 +22,7 @@ b ui.plane_debug v ui.vram_debug c ui.cram_debug + n ui.compositing_debug esc ui.exit ` ui.save_state 0 ui.set_speed.0 diff -r 3602f3b20072 -r bc9bb4e5856f vdp.c --- a/vdp.c Fri Nov 16 19:56:24 2018 -0800 +++ b/vdp.c Mon Nov 19 09:52:07 2018 -0800 @@ -1267,6 +1267,7 @@ static void render_map_output(uint32_t line, int32_t col, vdp_context * context) { uint32_t *dst; + uint8_t *debug_dst; uint8_t output_disabled = (context->test_port & TEST_BIT_DISABLE) != 0; uint8_t test_layer = context->test_port >> 7 & 3; if (context->state == PREPARING && !test_layer) { @@ -1299,6 +1300,8 @@ { col-=2; dst = context->output + BORDER_LEFT + col * 8; + debug_dst = context->layer_debug_buf + BORDER_LEFT + col * 8; + if (context->debug < 2) { sprite_buf = context->linebuf + col * 8; uint8_t a_src, src; @@ -1380,14 +1383,8 @@ } break; } - - uint32_t outpixel; - if (context->debug) { - outpixel = context->debugcolors[src]; - } else { - outpixel = colors[pixel & 0x3F]; - } - *(dst++) = outpixel; + *(debug_dst++) = src; + *(dst++) = colors[pixel & 0x3F]; } } else { for (int i = 0; i < 16; ++plane_a_off, ++plane_b_off, ++sprite_buf, ++i) { @@ -1435,13 +1432,8 @@ } break; } - uint32_t outpixel; - if (context->debug) { - outpixel = context->debugcolors[src]; - } else { - outpixel = context->colors[pixel & 0x3F]; - } - *(dst++) = outpixel; + *(dst++) = context->colors[pixel & 0x3F]; + *(debug_dst++) = src; } } } else if (context->debug == 2) { @@ -1490,6 +1482,7 @@ } } else { dst = context->output; + debug_dst = context->layer_debug_buf; uint8_t pixel = context->regs[REG_BG_COLOR] & 0x3F; if (output_disabled) { pixel = 0x3F; @@ -1500,9 +1493,11 @@ { case 1: bg_color = context->colors[0]; - for (int i = 0; i < BORDER_LEFT; i++, dst++) + for (int i = 0; i < BORDER_LEFT; i++, dst++, debug_dst++) { *dst = bg_color; + *debug_dst = DBG_SRC_BG; + } break; case 2: { @@ -1512,9 +1507,10 @@ i = 0; uint8_t buf_off = context->buf_a_off - (context->hscroll_a & 0xF) + (16 - BORDER_LEFT); //uint8_t *src = context->tmp_buf_a + ((context->buf_a_off + (i ? 0 : (16 - BORDER_LEFT) - (context->hscroll_a & 0xF))) & SCROLL_BUFFER_MASK); - for (; i < BORDER_LEFT; buf_off++, i++, dst++) + for (; i < BORDER_LEFT; buf_off++, i++, dst++, debug_dst++) { *dst = context->colors[context->tmp_buf_a[buf_off & SCROLL_BUFFER_MASK]]; + *debug_dst = DBG_SRC_A; } break; } @@ -1524,17 +1520,19 @@ i = 0; uint8_t buf_off = context->buf_b_off - (context->hscroll_b & 0xF) + (16 - BORDER_LEFT); //uint8_t *src = context->tmp_buf_b + ((context->buf_b_off + (i ? 0 : (16 - BORDER_LEFT) - (context->hscroll_b & 0xF))) & SCROLL_BUFFER_MASK); - for (; i < BORDER_LEFT; buf_off++, i++, dst++) + for (; i < BORDER_LEFT; buf_off++, i++, dst++, debug_dst++) { *dst = context->colors[context->tmp_buf_b[buf_off & SCROLL_BUFFER_MASK]]; + *debug_dst = DBG_SRC_B; } break; } } } else { - for (int i = 0; i < BORDER_LEFT; i++, dst++) + for (int i = 0; i < BORDER_LEFT; i++, dst++, debug_dst++) { *dst = bg_color; + *debug_dst = DBG_SRC_BG; } } } @@ -1694,7 +1692,7 @@ jump_end = 0x1D5; } - if (context->enabled_debuggers & (1 << VDP_DEBUG_CRAM)) { + if (context->enabled_debuggers & (1 << VDP_DEBUG_CRAM | 1 << VDP_DEBUG_COMPOSITE)) { uint32_t line = context->vcounter; if (line >= jump_end) { line -= jump_end - jump_start; @@ -1706,15 +1704,28 @@ } else { line += context->border_top; } - uint32_t *fb = context->debug_fbs[VDP_DEBUG_CRAM] + context->debug_fb_pitch[VDP_DEBUG_CRAM] * line / sizeof(uint32_t); - for (int i = 0; i < 64; i++) - { - for (int x = 0; x < 8; x++) + if (context->enabled_debuggers & (1 << VDP_DEBUG_CRAM)) { + uint32_t *fb = context->debug_fbs[VDP_DEBUG_CRAM] + context->debug_fb_pitch[VDP_DEBUG_CRAM] * line / sizeof(uint32_t); + for (int i = 0; i < 64; i++) { - *(fb++) = context->colors[i]; + for (int x = 0; x < 8; x++) + { + *(fb++) = context->colors[i]; + } + } + } + if ( + context->enabled_debuggers & (1 << VDP_DEBUG_COMPOSITE) + && line < (context->inactive_start + context->border_bot + context->border_top) + ) { + uint32_t *fb = context->debug_fbs[VDP_DEBUG_COMPOSITE] + context->debug_fb_pitch[VDP_DEBUG_COMPOSITE] * line / sizeof(uint32_t); + for (int i = 0; i < LINEBUF_SIZE; i++) + { + *(fb++) = context->debugcolors[context->layer_debug_buf[i]]; } } } + context->vcounter++; if (context->vcounter == jump_start) { context->vcounter = jump_end; @@ -1900,6 +1911,10 @@ render_framebuffer_updated(context->debug_fb_indices[VDP_DEBUG_CRAM], 512); context->debug_fbs[VDP_DEBUG_CRAM] = render_get_framebuffer(context->debug_fb_indices[VDP_DEBUG_CRAM], &context->debug_fb_pitch[VDP_DEBUG_CRAM]); } + if (context->enabled_debuggers & (1 << VDP_DEBUG_COMPOSITE)) { + render_framebuffer_updated(context->debug_fb_indices[VDP_DEBUG_COMPOSITE], LINEBUF_SIZE); + context->debug_fbs[VDP_DEBUG_COMPOSITE] = render_get_framebuffer(context->debug_fb_indices[VDP_DEBUG_COMPOSITE], &context->debug_fb_pitch[VDP_DEBUG_COMPOSITE]); + } } void vdp_force_update_framebuffer(vdp_context *context) @@ -3950,6 +3965,12 @@ height = 512; fetch_immediately = 1; break; + case VDP_DEBUG_COMPOSITE: + caption = "BlastEm - VDP Plane Composition Debugger"; + width = LINEBUF_SIZE; + height = context->inactive_start + context->border_top + context->border_bot; + fetch_immediately = 1; + break; default: return; } diff -r 3602f3b20072 -r bc9bb4e5856f vdp.h --- a/vdp.h Fri Nov 16 19:56:24 2018 -0800 +++ b/vdp.h Mon Nov 19 09:52:07 2018 -0800 @@ -202,6 +202,7 @@ uint16_t test_port; //stores 2-bit palette + 4-bit palette index + priority for current sprite line uint8_t linebuf[LINEBUF_SIZE]; + uint8_t layer_debug_buf[LINEBUF_SIZE]; uint8_t hslot; //hcounter/2 uint8_t sprite_index; uint8_t sprite_draws;