summaryrefslogtreecommitdiff
path: root/vdp.c
diff options
context:
space:
mode:
authorMichael Pavone <pavone@retrodev.com>2018-11-14 22:16:35 -0800
committerMichael Pavone <pavone@retrodev.com>2018-11-14 22:16:35 -0800
commitc4d4fb343ea0c125febe578585b79cf0d3c09a7f (patch)
tree7cad2ed81248df898a0f4286d28451e84a754ec4 /vdp.c
parente1a275cbd9a8b620040cf06f24879926dbaf2065 (diff)
Initial stab at CRAM debug in a detached window
Diffstat (limited to 'vdp.c')
-rw-r--r--vdp.c98
1 files changed, 82 insertions, 16 deletions
diff --git a/vdp.c b/vdp.c
index 4c15149..80af2ac 100644
--- a/vdp.c
+++ b/vdp.c
@@ -1676,31 +1676,56 @@ static void vdp_advance_line(vdp_context *context)
}
last_line = context->cycles;
#endif
- context->vcounter++;
-
+ uint16_t jump_start, jump_end;
uint8_t is_mode_5 = context->regs[REG_MODE_2] & BIT_MODE_5;
if (is_mode_5) {
if (context->flags2 & FLAG2_REGION_PAL) {
if (context->regs[REG_MODE_2] & BIT_PAL) {
- if (context->vcounter == 0x10B) {
- context->vcounter = 0x1D2;
- }
- } else if (context->vcounter == 0x103){
- context->vcounter = 0x1CA;
+ jump_start = 0x10B;
+ jump_end = 0x1D2;
+ } else {
+ jump_start = 0x103;
+ jump_end = 0x1CA;
}
+ } else if (context->regs[REG_MODE_2] & BIT_PAL) {
+ jump_start = 0x100;
+ jump_end = 0x1FA;
} else {
- if (context->regs[REG_MODE_2] & BIT_PAL) {
- if (context->vcounter == 0x100) {
- context->vcounter = 0x1FA;
- }
- } else if (context->vcounter == 0xEB) {
- context->vcounter = 0x1E5;
+ jump_start = 0xEB;
+ jump_end = 0x1E5;
+ }
+ } else {
+ jump_start = 0xDB;
+ jump_end = 0x1D5;
+ }
+
+ if (context->enabled_debuggers & (1 << VDP_DEBUG_CRAM)) {
+ uint32_t line = context->vcounter;
+ if (line >= jump_end) {
+ line -= jump_end - jump_start;
+ }
+ uint32_t total_lines = (context->flags2 & FLAG2_REGION_PAL) ? 313 : 262;
+
+ if (total_lines - line <= context->border_top) {
+ line -= total_lines - context->border_top;
+ } 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++)
+ {
+ *(fb++) = context->colors[i];
}
}
- } else if (context->vcounter == 0xDB) {
- context->vcounter = 0x1D5;
}
- context->vcounter &= 0x1FF;
+ context->vcounter++;
+ if (context->vcounter == jump_start) {
+ context->vcounter = jump_end;
+ } else {
+ context->vcounter &= 0x1FF;
+ }
if (context->state == PREPARING) {
context->state = ACTIVE;
}
@@ -1849,6 +1874,37 @@ static void vdp_update_per_frame_debug(vdp_context *context)
render_framebuffer_updated(context->debug_fb_indices[VDP_DEBUG_VRAM], 1024);
}
+
+ if (context->enabled_debuggers & (1 << VDP_DEBUG_CRAM)) {
+ uint32_t starting_line = 512 - 32*4;
+ uint32_t *line = context->debug_fbs[VDP_DEBUG_CRAM]
+ + context->debug_fb_pitch[VDP_DEBUG_CRAM] * starting_line / sizeof(uint32_t);
+ for (int pal = 0; pal < 4; pal ++)
+ {
+ uint32_t *cur;
+ for (int y = 0; y < 31; y++)
+ {
+ cur = line;
+ for (int offset = 0; offset < 16; offset++)
+ {
+ for (int x = 0; x < 31; x++)
+ {
+ *(cur++) = context->colors[pal * 16 + offset];
+ }
+ *(cur++) = 0xFF000000;
+ }
+ line += context->debug_fb_pitch[VDP_DEBUG_CRAM] / sizeof(uint32_t);
+ }
+ cur = line;
+ for (int x = 0; x < 512; x++)
+ {
+ *(cur++) = 0xFF000000;
+ }
+ line += context->debug_fb_pitch[VDP_DEBUG_CRAM] / sizeof(uint32_t);
+ }
+ 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]);
+ }
}
void vdp_force_update_framebuffer(vdp_context *context)
@@ -3880,6 +3936,7 @@ void vdp_toggle_debug_view(vdp_context *context, uint8_t debug_type)
//TODO: implement me
} else {
uint32_t width,height;
+ uint8_t fetch_immediately = 0;
char *caption;
switch(debug_type)
{
@@ -3892,6 +3949,12 @@ void vdp_toggle_debug_view(vdp_context *context, uint8_t debug_type)
width = 1024;
height = 512;
break;
+ case VDP_DEBUG_CRAM:
+ caption = "BlastEm - VDP CRAM Debugger";
+ width = 512;
+ height = 512;
+ fetch_immediately = 1;
+ break;
default:
return;
}
@@ -3899,6 +3962,9 @@ void vdp_toggle_debug_view(vdp_context *context, uint8_t debug_type)
if (context->debug_fb_indices[debug_type]) {
context->enabled_debuggers |= 1 << debug_type;
}
+ if (fetch_immediately) {
+ context->debug_fbs[debug_type] = render_get_framebuffer(context->debug_fb_indices[debug_type], &context->debug_fb_pitch[debug_type]);
+ }
}
}