Mercurial > repos > blastem
changeset 2559:e534423bd20d
Disable KMOD debug registers when not emulating an MD VDP
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Sun, 19 Jan 2025 22:28:32 -0800 |
parents | 3f58fec775df |
children | 6404643aca38 |
files | vdp.c |
diffstat | 1 files changed, 37 insertions(+), 33 deletions(-) [+] |
line wrap: on
line diff
--- a/vdp.c Sun Jan 19 00:31:16 2025 -0800 +++ b/vdp.c Sun Jan 19 22:28:32 2025 -0800 @@ -4748,42 +4748,46 @@ if (reg == REG_MODE_1 || reg == REG_MODE_2 || reg == REG_MODE_4) { update_video_params(context); } - } else if (reg == REG_KMOD_CTRL) { - if (!(value & 0xFF)) { - context->system->enter_debugger = 1; - } - } else if (reg == REG_KMOD_MSG) { - char c = value; - if (c) { - context->kmod_buffer_length++; - if ((context->kmod_buffer_length + 1) > context->kmod_buffer_storage) { - context->kmod_buffer_storage = context->kmod_buffer_storage ? context->kmod_buffer_storage * 2 : 128; - context->kmod_msg_buffer = realloc(context->kmod_msg_buffer, context->kmod_buffer_storage); + } else if (context->type == VDP_GENESIS) { + // Apparently Bart vs. the Space Mutants for SMS/GG writes to the timer KMOD timer register + // Probably need to add some sort of config toggle for KMOD registers generally, but this is a quick fix + if (reg == REG_KMOD_CTRL) { + if (!(value & 0xFF)) { + context->system->enter_debugger = 1; } - context->kmod_msg_buffer[context->kmod_buffer_length - 1] = c; - } else if (context->kmod_buffer_length) { - context->kmod_msg_buffer[context->kmod_buffer_length] = 0; - if (is_stdout_enabled()) { - init_terminal(); - printf("KDEBUG MESSAGE: %s\n", context->kmod_msg_buffer); - } else { - // GDB remote debugging is enabled, use stderr instead - fprintf(stderr, "KDEBUG MESSAGE: %s\n", context->kmod_msg_buffer); + } else if (reg == REG_KMOD_MSG) { + char c = value; + if (c) { + context->kmod_buffer_length++; + if ((context->kmod_buffer_length + 1) > context->kmod_buffer_storage) { + context->kmod_buffer_storage = context->kmod_buffer_storage ? context->kmod_buffer_storage * 2 : 128; + context->kmod_msg_buffer = realloc(context->kmod_msg_buffer, context->kmod_buffer_storage); + } + context->kmod_msg_buffer[context->kmod_buffer_length - 1] = c; + } else if (context->kmod_buffer_length) { + context->kmod_msg_buffer[context->kmod_buffer_length] = 0; + if (is_stdout_enabled()) { + init_terminal(); + printf("KDEBUG MESSAGE: %s\n", context->kmod_msg_buffer); + } else { + // GDB remote debugging is enabled, use stderr instead + fprintf(stderr, "KDEBUG MESSAGE: %s\n", context->kmod_msg_buffer); + } + context->kmod_buffer_length = 0; } - context->kmod_buffer_length = 0; - } - } else if (reg == REG_KMOD_TIMER) { - if (!(value & 0x80)) { - if (is_stdout_enabled()) { - init_terminal(); - printf("KDEBUG TIMER: %d\n", (context->cycles - context->timer_start_cycle) / 7); - } else { - // GDB remote debugging is enabled, use stderr instead - fprintf(stderr, "KDEBUG TIMER: %d\n", (context->cycles - context->timer_start_cycle) / 7); + } else if (reg == REG_KMOD_TIMER) { + if (!(value & 0x80)) { + if (is_stdout_enabled()) { + init_terminal(); + printf("KDEBUG TIMER: %d\n", (context->cycles - context->timer_start_cycle) / 7); + } else { + // GDB remote debugging is enabled, use stderr instead + fprintf(stderr, "KDEBUG TIMER: %d\n", (context->cycles - context->timer_start_cycle) / 7); + } } - } - if (value & 0xC0) { - context->timer_start_cycle = context->cycles; + if (value & 0xC0) { + context->timer_start_cycle = context->cycles; + } } } }