summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Pavone <pavone@retrodev.com>2018-11-19 19:26:57 -0800
committerMichael Pavone <pavone@retrodev.com>2018-11-19 19:26:57 -0800
commit4525890432924cfee316c5235653d1dc6b22d106 (patch)
tree1be9fee62d187dd68a27810ff2adb52159a109c5
parent9316f533ab20aa79cf0a5863452efdadfad91f6f (diff)
Removed old VDP debug functionality
-rw-r--r--bindings.c10
-rw-r--r--genesis.c10
-rw-r--r--sms.c15
-rw-r--r--system.h1
-rw-r--r--vdp.c353
-rw-r--r--vdp.h2
6 files changed, 138 insertions, 253 deletions
diff --git a/bindings.c b/bindings.c
index c4f3530..98e4d4b 100644
--- a/bindings.c
+++ b/bindings.c
@@ -23,7 +23,6 @@ enum {
typedef enum {
UI_DEBUG_MODE_INC,
- UI_DEBUG_PAL_INC,
UI_ENTER_DEBUGGER,
UI_SAVE_STATE,
UI_SET_SPEED,
@@ -242,9 +241,6 @@ void handle_mousedown(int mouse, int button)
handle_binding_down(binding);
}
-static uint8_t ui_debug_mode = 0;
-static uint8_t ui_debug_pal = 0;
-
static int current_speed = 0;
static int num_speeds = 1;
static uint32_t * speeds = NULL;
@@ -275,9 +271,6 @@ void handle_binding_up(keybinding * binding)
case UI_DEBUG_MODE_INC:
current_system->inc_debug_mode(current_system);
break;
- case UI_DEBUG_PAL_INC:
- current_system->inc_debug_pal(current_system);
- break;
case UI_ENTER_DEBUGGER:
current_system->enter_debugger = 1;
break;
@@ -578,7 +571,8 @@ int parse_binding_target(int device_num, char * target, tern_node * padbuttons,
if (!strcmp(target + 3, "vdp_debug_mode")) {
*subtype_a = UI_DEBUG_MODE_INC;
} else if(!strcmp(target + 3, "vdp_debug_pal")) {
- *subtype_a = UI_DEBUG_PAL_INC;
+ //legacy binding, ignore
+ return 0;
} else if(!strcmp(target + 3, "enter_debugger")) {
*subtype_a = UI_ENTER_DEBUGGER;
} else if(!strcmp(target + 3, "save_state")) {
diff --git a/genesis.c b/genesis.c
index 70664ce..0196191 100644
--- a/genesis.c
+++ b/genesis.c
@@ -1131,15 +1131,6 @@ static void inc_debug_mode(system_header *system)
vdp_inc_debug_mode(gen->vdp);
}
-static void inc_debug_pal(system_header *system)
-{
- genesis_context *gen = (genesis_context *)system;
- gen->vdp->debug_pal++;
- if (gen->vdp->debug_pal == 4) {
- gen->vdp->debug_pal = 0;
- }
-}
-
static void request_exit(system_header *system)
{
genesis_context *gen = (genesis_context *)system;
@@ -1288,7 +1279,6 @@ genesis_context *alloc_init_genesis(rom_info *rom, void *main_rom, void *lock_on
gen->header.get_open_bus_value = get_open_bus_value;
gen->header.request_exit = request_exit;
gen->header.inc_debug_mode = inc_debug_mode;
- gen->header.inc_debug_pal = inc_debug_pal;
gen->header.gamepad_down = gamepad_down;
gen->header.gamepad_up = gamepad_up;
gen->header.mouse_down = mouse_down;
diff --git a/sms.c b/sms.c
index 2751c72..6f1c85b 100644
--- a/sms.c
+++ b/sms.c
@@ -451,19 +451,7 @@ static void request_exit(system_header *system)
static void inc_debug_mode(system_header *system)
{
sms_context *sms = (sms_context *)system;
- sms->vdp->debug++;
- if (sms->vdp->debug == 7) {
- sms->vdp->debug = 0;
- }
-}
-
-static void inc_debug_pal(system_header *system)
-{
- sms_context *sms = (sms_context *)system;
- sms->vdp->debug_pal++;
- if (sms->vdp->debug_pal == 4) {
- sms->vdp->debug_pal = 0;
- }
+ vdp_inc_debug_mode(sms->vdp);
}
static void load_save(system_header *system)
@@ -601,7 +589,6 @@ sms_context *alloc_configure_sms(system_media *media, uint32_t opts, uint8_t for
sms->header.request_exit = request_exit;
sms->header.soft_reset = soft_reset;
sms->header.inc_debug_mode = inc_debug_mode;
- sms->header.inc_debug_pal = inc_debug_pal;
sms->header.gamepad_down = gamepad_down;
sms->header.gamepad_up = gamepad_up;
sms->header.mouse_down = mouse_down;
diff --git a/system.h b/system.h
index 0ba25e2..0402684 100644
--- a/system.h
+++ b/system.h
@@ -44,7 +44,6 @@ struct system_header {
system_fun_r16 get_open_bus_value;
system_u32_fun set_speed_percent;
system_fun inc_debug_mode;
- system_fun inc_debug_pal;
system_u8_u8_fun gamepad_down;
system_u8_u8_fun gamepad_up;
system_u8_u8_fun mouse_down;
diff --git a/vdp.c b/vdp.c
index 8932b75..b6f605c 100644
--- a/vdp.c
+++ b/vdp.c
@@ -1302,182 +1302,137 @@ static void render_map_output(uint32_t line, int32_t col, vdp_context * context)
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;
- if (context->flags & FLAG_WINDOW) {
- plane_a_off = context->buf_a_off;
- a_src = DBG_SRC_W;
- } else {
- plane_a_off = context->buf_a_off - (context->hscroll_a & 0xF);
- a_src = DBG_SRC_A;
- }
- plane_b_off = context->buf_b_off - (context->hscroll_b & 0xF);
- //printf("A | tmp_buf offset: %d\n", 8 - (context->hscroll_a & 0x7));
-
- if (context->regs[REG_MODE_4] & BIT_HILIGHT) {
- for (int i = 0; i < 16; ++plane_a_off, ++plane_b_off, ++sprite_buf, ++i) {
- plane_a = context->tmp_buf_a + (plane_a_off & SCROLL_BUFFER_MASK);
- plane_b = context->tmp_buf_b + (plane_b_off & SCROLL_BUFFER_MASK);
- uint8_t pixel = context->regs[REG_BG_COLOR];
- uint32_t *colors = context->colors;
- src = DBG_SRC_BG;
- uint8_t intensity = 0;
+ sprite_buf = context->linebuf + col * 8;
+ uint8_t a_src, src;
+ if (context->flags & FLAG_WINDOW) {
+ plane_a_off = context->buf_a_off;
+ a_src = DBG_SRC_W;
+ } else {
+ plane_a_off = context->buf_a_off - (context->hscroll_a & 0xF);
+ a_src = DBG_SRC_A;
+ }
+ plane_b_off = context->buf_b_off - (context->hscroll_b & 0xF);
+ //printf("A | tmp_buf offset: %d\n", 8 - (context->hscroll_a & 0x7));
+
+ if (context->regs[REG_MODE_4] & BIT_HILIGHT) {
+ for (int i = 0; i < 16; ++plane_a_off, ++plane_b_off, ++sprite_buf, ++i) {
+ plane_a = context->tmp_buf_a + (plane_a_off & SCROLL_BUFFER_MASK);
+ plane_b = context->tmp_buf_b + (plane_b_off & SCROLL_BUFFER_MASK);
+ uint8_t pixel = context->regs[REG_BG_COLOR];
+ uint32_t *colors = context->colors;
+ src = DBG_SRC_BG;
+ uint8_t intensity = 0;
+ if (col || !(context->regs[REG_MODE_1] & BIT_COL0_MASK) || i >= 8) {
+ if (*plane_b & 0xF) {
+ pixel = *plane_b;
+ src = DBG_SRC_B;
+ }
+ intensity = *plane_b & BUF_BIT_PRIORITY;
+ if (*plane_a & 0xF && (*plane_a & BUF_BIT_PRIORITY) >= (pixel & BUF_BIT_PRIORITY)) {
+ pixel = *plane_a;
+ src = a_src;
+ }
+ intensity |= *plane_a & BUF_BIT_PRIORITY;
+ if (*sprite_buf & 0xF && (*sprite_buf & BUF_BIT_PRIORITY) >= (pixel & BUF_BIT_PRIORITY)) {
+ if ((*sprite_buf & 0x3F) == 0x3E) {
+ intensity += BUF_BIT_PRIORITY;
+ } else if ((*sprite_buf & 0x3F) == 0x3F) {
+ intensity = 0;
+ } else {
+ pixel = *sprite_buf;
+ src = DBG_SRC_S;
+ if ((pixel & 0xF) == 0xE) {
+ intensity = BUF_BIT_PRIORITY;
+ } else {
+ intensity |= pixel & BUF_BIT_PRIORITY;
+ }
+ }
+ }
+ }
+ if (output_disabled) {
+ pixel = 0x3F;
+ }
+ if (!intensity) {
+ src |= DBG_SHADOW;
+ colors += CRAM_SIZE;
+ } else if (intensity == BUF_BIT_PRIORITY*2) {
+ src |= DBG_HILIGHT;
+ colors += CRAM_SIZE*2;
+ }
+ //TODO: Verify how test register stuff interacts with shadow/highlight
+ //TODO: Simulate CRAM corruption from bus fight
+ switch (test_layer)
+ {
+ case 1:
+ pixel &= *sprite_buf;
+ if (output_disabled && pixel) {
+ src = DBG_SRC_S;
+ }
+ break;
+ case 2:
+ pixel &= *plane_a;
+ if (output_disabled && pixel) {
+ src = DBG_SRC_A;
+ }
+ break;
+ case 3:
+ pixel &= *plane_b;
+ if (output_disabled && pixel) {
+ src = DBG_SRC_B;
+ }
+ break;
+ }
+ *(debug_dst++) = src;
+ *(dst++) = colors[pixel & 0x3F];
+ }
+ } else {
+ for (int i = 0; i < 16; ++plane_a_off, ++plane_b_off, ++sprite_buf, ++i) {
+ plane_a = context->tmp_buf_a + (plane_a_off & SCROLL_BUFFER_MASK);
+ plane_b = context->tmp_buf_b + (plane_b_off & SCROLL_BUFFER_MASK);
+ uint8_t pixel = context->regs[REG_BG_COLOR];
+ src = DBG_SRC_BG;
+ if (output_disabled) {
+ pixel = 0x3F;
+ } else {
if (col || !(context->regs[REG_MODE_1] & BIT_COL0_MASK) || i >= 8) {
if (*plane_b & 0xF) {
pixel = *plane_b;
src = DBG_SRC_B;
}
- intensity = *plane_b & BUF_BIT_PRIORITY;
if (*plane_a & 0xF && (*plane_a & BUF_BIT_PRIORITY) >= (pixel & BUF_BIT_PRIORITY)) {
pixel = *plane_a;
src = a_src;
}
- intensity |= *plane_a & BUF_BIT_PRIORITY;
if (*sprite_buf & 0xF && (*sprite_buf & BUF_BIT_PRIORITY) >= (pixel & BUF_BIT_PRIORITY)) {
- if ((*sprite_buf & 0x3F) == 0x3E) {
- intensity += BUF_BIT_PRIORITY;
- } else if ((*sprite_buf & 0x3F) == 0x3F) {
- intensity = 0;
- } else {
- pixel = *sprite_buf;
- src = DBG_SRC_S;
- if ((pixel & 0xF) == 0xE) {
- intensity = BUF_BIT_PRIORITY;
- } else {
- intensity |= pixel & BUF_BIT_PRIORITY;
- }
- }
- }
- }
- if (output_disabled) {
- pixel = 0x3F;
- }
- if (!intensity) {
- src |= DBG_SHADOW;
- colors += CRAM_SIZE;
- } else if (intensity == BUF_BIT_PRIORITY*2) {
- src |= DBG_HILIGHT;
- colors += CRAM_SIZE*2;
- }
- //TODO: Verify how test register stuff interacts with shadow/highlight
- //TODO: Simulate CRAM corruption from bus fight
- switch (test_layer)
- {
- case 1:
- pixel &= *sprite_buf;
- if (output_disabled && pixel) {
+ pixel = *sprite_buf;
src = DBG_SRC_S;
}
- break;
- case 2:
- pixel &= *plane_a;
- if (output_disabled && pixel) {
- src = DBG_SRC_A;
- }
- break;
- case 3:
- pixel &= *plane_b;
- if (output_disabled && pixel) {
- src = DBG_SRC_B;
- }
- break;
}
- *(debug_dst++) = src;
- *(dst++) = colors[pixel & 0x3F];
}
- } else {
- for (int i = 0; i < 16; ++plane_a_off, ++plane_b_off, ++sprite_buf, ++i) {
- plane_a = context->tmp_buf_a + (plane_a_off & SCROLL_BUFFER_MASK);
- plane_b = context->tmp_buf_b + (plane_b_off & SCROLL_BUFFER_MASK);
- uint8_t pixel = context->regs[REG_BG_COLOR];
- src = DBG_SRC_BG;
- if (output_disabled) {
- pixel = 0x3F;
- } else {
- if (col || !(context->regs[REG_MODE_1] & BIT_COL0_MASK) || i >= 8) {
- if (*plane_b & 0xF) {
- pixel = *plane_b;
- src = DBG_SRC_B;
- }
- if (*plane_a & 0xF && (*plane_a & BUF_BIT_PRIORITY) >= (pixel & BUF_BIT_PRIORITY)) {
- pixel = *plane_a;
- src = a_src;
- }
- if (*sprite_buf & 0xF && (*sprite_buf & BUF_BIT_PRIORITY) >= (pixel & BUF_BIT_PRIORITY)) {
- pixel = *sprite_buf;
- src = DBG_SRC_S;
- }
- }
+ //TODO: Simulate CRAM corruption from bus fight
+ switch (test_layer)
+ {
+ case 1:
+ pixel &= *sprite_buf;
+ if (output_disabled && pixel) {
+ src = DBG_SRC_S;
}
- //TODO: Simulate CRAM corruption from bus fight
- switch (test_layer)
- {
- case 1:
- pixel &= *sprite_buf;
- if (output_disabled && pixel) {
- src = DBG_SRC_S;
- }
- break;
- case 2:
- pixel &= *plane_a;
- if (output_disabled && pixel) {
- src = DBG_SRC_A;
- }
- break;
- case 3:
- pixel &= *plane_b;
- if (output_disabled && pixel) {
- src = DBG_SRC_B;
- }
- break;
+ break;
+ case 2:
+ pixel &= *plane_a;
+ if (output_disabled && pixel) {
+ src = DBG_SRC_A;
}
- *(dst++) = context->colors[pixel & 0x3F];
- *(debug_dst++) = src;
- }
- }
- } else if (context->debug == 2) {
- if (col < 32) {
- *(dst++) = context->colors[col * 2];
- *(dst++) = context->colors[col * 2];
- *(dst++) = context->colors[col * 2];
- *(dst++) = context->colors[col * 2];
- *(dst++) = context->colors[col * 2 + 1];
- *(dst++) = context->colors[col * 2 + 1];
- *(dst++) = context->colors[col * 2 + 1];
- *(dst++) = context->colors[col * 2 + 1];
- *(dst++) = context->colors[col * 2 + 2];
- *(dst++) = context->colors[col * 2 + 2];
- *(dst++) = context->colors[col * 2 + 2];
- *(dst++) = context->colors[col * 2 + 2];
- *(dst++) = context->colors[col * 2 + 3];
- *(dst++) = context->colors[col * 2 + 3];
- *(dst++) = context->colors[col * 2 + 3];
- *(dst++) = context->colors[col * 2 + 3];
- } else if (col == 32 || line >= 192) {
- for (int32_t i = 0; i < 16; i ++) {
- *(dst++) = 0;
- }
- } else {
- for (int32_t i = 0; i < 16; i ++) {
- *(dst++) = context->colors[line / 3 + (col - 34) * 0x20];
+ break;
+ case 3:
+ pixel &= *plane_b;
+ if (output_disabled && pixel) {
+ src = DBG_SRC_B;
+ }
+ break;
}
- }
- } else {
- uint32_t base = (context->debug - 3) * 0x200;
- uint32_t cell = base + (line / 8) * (context->regs[REG_MODE_4] & BIT_H40 ? 40 : 32) + col;
- uint32_t address = (cell * 32 + (line % 8) * 4) & 0xFFFF;
- for (int32_t i = 0; i < 4; i ++) {
- *(dst++) = context->colors[(context->debug_pal << 4) | (context->vdpmem[address] >> 4)];
- *(dst++) = context->colors[(context->debug_pal << 4) | (context->vdpmem[address] & 0xF)];
- address++;
- }
- cell++;
- address = (cell * 32 + (line % 8) * 4) & 0xFFFF;
- for (int32_t i = 0; i < 4; i ++) {
- *(dst++) = context->colors[(context->debug_pal << 4) | (context->vdpmem[address] >> 4)];
- *(dst++) = context->colors[(context->debug_pal << 4) | (context->vdpmem[address] & 0xF)];
- address++;
+ *(dst++) = context->colors[pixel & 0x3F];
+ *(debug_dst++) = src;
}
}
} else {
@@ -1583,6 +1538,7 @@ static void render_map_mode4(uint32_t line, int32_t col, vdp_context * context)
uint8_t bgcolor = 0x10 | (context->regs[REG_BG_COLOR] & 0xF) + CRAM_SIZE*3;
uint32_t *dst = context->output + col * 8 + BORDER_LEFT;
+ uint8_t *debug_dst = context->layer_debug_buf + col * 8 + BORDER_LEFT;
if (context->state == PREPARING) {
for (int i = 0; i < 16; i++)
{
@@ -1591,65 +1547,30 @@ static void render_map_mode4(uint32_t line, int32_t col, vdp_context * context)
context->done_output = dst;
return;
}
- if (context->debug < 2) {
- if (col || !(context->regs[REG_MODE_1] & BIT_COL0_MASK)) {
- uint8_t *sprite_src = context->linebuf + col * 8;
- if (context->regs[REG_MODE_1] & BIT_SPRITE_8PX) {
- sprite_src += 8;
- }
- for (int i = 0; i < 8; i++, sprite_src++)
- {
- uint8_t *bg_src = context->tmp_buf_a + ((8 + i + col * 8 - (context->hscroll_a & 0x7)) & 15);
- if ((*bg_src & 0x4F) > 0x40 || !*sprite_src) {
- //background plane has priority and is opaque or sprite layer is transparent
- if (context->debug) {
- *(dst++) = context->debugcolors[DBG_SRC_A];
- } else {
- *(dst++) = context->colors[(*bg_src & 0x1F) + CRAM_SIZE*3];
- }
- } else {
- //sprite layer is opaque and not covered by high priority BG pixels
- if (context->debug) {
- *(dst++) = context->debugcolors[DBG_SRC_S];
- } else {
- *(dst++) = context->colors[*sprite_src | 0x10 + CRAM_SIZE*3];
- }
- }
- }
- } else {
- for (int i = 0; i < 8; i++)
- {
- *(dst++) = context->colors[bgcolor];
- }
+
+ if (col || !(context->regs[REG_MODE_1] & BIT_COL0_MASK)) {
+ uint8_t *sprite_src = context->linebuf + col * 8;
+ if (context->regs[REG_MODE_1] & BIT_SPRITE_8PX) {
+ sprite_src += 8;
}
- } else if (context->debug == 2) {
- for (int i = 0; i < 8; i++)
+ for (int i = 0; i < 8; i++, sprite_src++)
{
- *(dst++) = context->colors[CRAM_SIZE*3 + col];
+ uint8_t *bg_src = context->tmp_buf_a + ((8 + i + col * 8 - (context->hscroll_a & 0x7)) & 15);
+ if ((*bg_src & 0x4F) > 0x40 || !*sprite_src) {
+ //background plane has priority and is opaque or sprite layer is transparent
+ *(dst++) = context->colors[(*bg_src & 0x1F) + CRAM_SIZE*3];
+ *(debug_dst++) = DBG_SRC_A;
+ } else {
+ //sprite layer is opaque and not covered by high priority BG pixels
+ *(dst++) = context->colors[*sprite_src | 0x10 + CRAM_SIZE*3];
+ *(debug_dst++) = DBG_SRC_S;
+ }
}
} else {
- uint32_t cell = (line / 8) * 32 + col;
- uint32_t address = cell * 32 + (line % 8) * 4;
- uint32_t m4_address = mode4_address_map[address & 0x3FFF];
- uint32_t pixel = planar_to_chunky[context->vdpmem[m4_address]] << 1;
- pixel |= planar_to_chunky[context->vdpmem[m4_address + 1]];
- m4_address = mode4_address_map[(address + 2) & 0x3FFF];
- pixel |= planar_to_chunky[context->vdpmem[m4_address]] << 3;
- pixel |= planar_to_chunky[context->vdpmem[m4_address + 1]] << 2;
- if (context->debug_pal < 2) {
- for (int i = 28; i >= 0; i -= 4)
- {
- *(dst++) = context->colors[CRAM_SIZE*3 | (context->debug_pal << 4) | (pixel >> i & 0xF)];
- }
- } else {
- for (int i = 28; i >= 0; i -= 4)
- {
- uint8_t value = (pixel >> i & 0xF) * 17;
- if (context->debug_pal == 3) {
- value = 255 - value;
- }
- *(dst++) = render_map_color(value, value, value);
- }
+ for (int i = 0; i < 8; i++)
+ {
+ *(dst++) = context->colors[bgcolor];
+ *(debug_dst++) = DBG_SRC_BG;
}
}
context->done_output = dst;
@@ -3989,10 +3910,6 @@ void vdp_inc_debug_mode(vdp_context *context)
{
uint8_t active = render_get_active_framebuffer();
if (active < FRAMEBUFFER_USER_START) {
- context->debug++;
- if (context->debug == 7) {
- context->debug = 0;
- }
return;
}
for (int i = 0; i < VDP_NUM_DEBUG_TYPES; i++)
diff --git a/vdp.h b/vdp.h
index 8da30a8..fec1c35 100644
--- a/vdp.h
+++ b/vdp.h
@@ -217,8 +217,6 @@ typedef struct {
uint8_t double_res;
uint8_t buf_a_off;
uint8_t buf_b_off;
- uint8_t debug;
- uint8_t debug_pal;
uint8_t pending_byte;
uint8_t state;
uint8_t cur_buffer;