summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bindings.c21
-rw-r--r--default.cfg1
-rw-r--r--vdp.c38
3 files changed, 57 insertions, 3 deletions
diff --git a/bindings.c b/bindings.c
index 8ab1b61..00019d2 100644
--- a/bindings.c
+++ b/bindings.c
@@ -37,7 +37,8 @@ typedef enum {
UI_SMS_PAUSE,
UI_SCREENSHOT,
UI_EXIT,
- UI_PLANE_DEBUG
+ UI_PLANE_DEBUG,
+ UI_VRAM_DEBUG
} ui_action;
typedef struct {
@@ -388,6 +389,20 @@ void handle_binding_up(keybinding * binding)
}
break;
}
+ case UI_VRAM_DEBUG: {
+ vdp_context *vdp = NULL;
+ if (current_system->type == SYSTEM_GENESIS) {
+ genesis_context *gen = (genesis_context *)current_system;
+ vdp = gen->vdp;
+ } else if (current_system->type == SYSTEM_SMS) {
+ sms_context *sms = (sms_context *)current_system;
+ vdp = sms->vdp;
+ }
+ if (vdp) {
+ vdp_toggle_debug_view(vdp, VDP_DEBUG_VRAM);
+ }
+ break;
+ }
}
break;
}
@@ -593,7 +608,9 @@ int parse_binding_target(int device_num, char * target, tern_node * padbuttons,
*subtype_a = UI_EXIT;
} else if (!strcmp(target + 3, "plane_debug")) {
*subtype_a = UI_PLANE_DEBUG;
- } else {
+ } else if (!strcmp(target + 3, "vram_debug")) {
+ *subtype_a = UI_VRAM_DEBUG;
+ } else {
warning("Unreconized UI binding type %s\n", target);
return 0;
}
diff --git a/default.cfg b/default.cfg
index d20d4df..fec512d 100644
--- a/default.cfg
+++ b/default.cfg
@@ -20,6 +20,7 @@ bindings {
u ui.enter_debugger
p ui.screenshot
b ui.plane_debug
+ v ui.vram_debug
esc ui.exit
` ui.save_state
0 ui.set_speed.0
diff --git a/vdp.c b/vdp.c
index 115f26c..7b2359a 100644
--- a/vdp.c
+++ b/vdp.c
@@ -1824,6 +1824,35 @@ static void vdp_update_per_frame_debug(vdp_context *context)
}
render_framebuffer_updated(context->debug_fb_indices[VDP_DEBUG_PLANE], 1024);
}
+
+ if (context->enabled_debuggers & (1 << VDP_DEBUG_VRAM)) {
+ uint32_t pitch;
+ uint32_t *fb = render_get_framebuffer(context->debug_fb_indices[VDP_DEBUG_VRAM], &pitch);
+
+ uint8_t pal = (context->debug_modes[VDP_DEBUG_VRAM] % 4) << 4;
+ for (int y = 0; y < 512; y++)
+ {
+ uint32_t *line = fb + y * pitch / sizeof(uint32_t);
+ int row = y >> 4;
+ int yoff = y >> 1 & 7;
+ for (int col = 0; col < 64; col++)
+ {
+ uint16_t address = (row * 64 + col) * 32 + yoff * 4;
+ for (int x = 0; x < 4; x++)
+ {
+ uint8_t byte = context->vdpmem[address++];
+ uint8_t left = byte >> 4 | pal;
+ uint8_t right = byte & 0xF | pal;
+ *(line++) = context->colors[left];
+ *(line++) = context->colors[left];
+ *(line++) = context->colors[right];
+ *(line++) = context->colors[right];
+ }
+ }
+ }
+
+ render_framebuffer_updated(context->debug_fb_indices[VDP_DEBUG_VRAM], 1024);
+ }
}
void vdp_force_update_framebuffer(vdp_context *context)
@@ -3854,16 +3883,23 @@ void vdp_toggle_debug_view(vdp_context *context, uint8_t debug_type)
if (context->enabled_debuggers & 1 << debug_type) {
//TODO: implement me
} else {
+ uint32_t width,height;
char *caption;
switch(debug_type)
{
case VDP_DEBUG_PLANE:
caption = "BlastEm - VDP Plane Debugger";
+ width = height = 1024;
+ break;
+ case VDP_DEBUG_VRAM:
+ caption = "BlastEm - VDP VRAM Debugger";
+ width = 1024;
+ height = 512;
break;
default:
return;
}
- context->debug_fb_indices[debug_type] = render_create_window(caption, 1024, 1024);
+ context->debug_fb_indices[debug_type] = render_create_window(caption, width, height);
if (context->debug_fb_indices[debug_type]) {
context->enabled_debuggers |= 1 << debug_type;
}