summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Pavone <pavone@retrodev.com>2018-11-19 09:52:07 -0800
committerMichael Pavone <pavone@retrodev.com>2018-11-19 09:52:07 -0800
commit654b9b962025cd4bb404eeccfb3ef1fcfd40ece7 (patch)
tree0cf1240b89b181c4b9472cb52886bac0446e87d1
parent909f6628edf5b5446586321c0a4df5045f2955c8 (diff)
Basic version of layer compositing debug view in a separate window
-rw-r--r--bindings.c7
-rw-r--r--default.cfg1
-rw-r--r--vdp.c71
-rw-r--r--vdp.h1
4 files changed, 54 insertions, 26 deletions
diff --git a/bindings.c b/bindings.c
index fc3d13a..c4f3530 100644
--- a/bindings.c
+++ b/bindings.c
@@ -40,6 +40,7 @@ typedef enum {
UI_PLANE_DEBUG,
UI_VRAM_DEBUG,
UI_CRAM_DEBUG,
+ UI_COMPOSITE_DEBUG
} ui_action;
typedef struct {
@@ -378,7 +379,8 @@ void handle_binding_up(keybinding * binding)
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 @@ void handle_binding_up(keybinding * binding)
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 @@ int parse_binding_target(int device_num, char * target, tern_node * padbuttons,
*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 --git a/default.cfg b/default.cfg
index 723445a..9236732 100644
--- a/default.cfg
+++ b/default.cfg
@@ -22,6 +22,7 @@ bindings {
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 --git a/vdp.c b/vdp.c
index c52ac51..69d304d 100644
--- a/vdp.c
+++ b/vdp.c
@@ -1267,6 +1267,7 @@ static void fetch_map_mode4(uint16_t col, uint32_t line, vdp_context *context)
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 @@ static void render_map_output(uint32_t line, int32_t col, vdp_context * context)
{
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 @@ static void render_map_output(uint32_t line, int32_t col, vdp_context * context)
}
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 @@ static void render_map_output(uint32_t line, int32_t col, vdp_context * context)
}
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 @@ static void render_map_output(uint32_t line, int32_t col, vdp_context * context)
}
} 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 @@ static void render_map_output(uint32_t line, int32_t col, vdp_context * context)
{
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 @@ static void render_map_output(uint32_t line, int32_t col, vdp_context * context)
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 @@ static void render_map_output(uint32_t line, int32_t col, vdp_context * context)
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 @@ static void vdp_advance_line(vdp_context *context)
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 @@ static void vdp_advance_line(vdp_context *context)
} 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 @@ static void vdp_update_per_frame_debug(vdp_context *context)
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 @@ void vdp_toggle_debug_view(vdp_context *context, uint8_t debug_type)
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 --git a/vdp.h b/vdp.h
index d0dc15d..8da30a8 100644
--- a/vdp.h
+++ b/vdp.h
@@ -202,6 +202,7 @@ typedef struct {
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;