From 6cd595a305c71f0540a3ecf4c4038891a7eba762 Mon Sep 17 00:00:00 2001 From: Michael Pavone Date: Tue, 17 Jun 2014 19:01:01 -0700 Subject: Partially working switch to having a vcounter and hslot counter in the context rather than trying to derive them from the cycle count. This should allow for more accurate handling of mid screen mode switches. Interrupt timing is broken currently though --- debug.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'debug.c') diff --git a/debug.c b/debug.c index aa0cb7f..c9f9293 100644 --- a/debug.c +++ b/debug.c @@ -598,9 +598,14 @@ m68k_context * debugger(m68k_context * context, uint32_t address) } } else if(param[0] == 'c') { value = context->current_cycle; - } else if (param[0] == '0' && param[1] == 'x') { - uint32_t p_addr = strtol(param+2, NULL, 16); - value = read_dma_value(p_addr/2); + } else if ((param[0] == '0' && param[1] == 'x') || param[0] == '$') { + uint32_t p_addr = strtol(param+(param[0] == '0' ? 2 : 1), NULL, 16); + if ((p_addr & 0xFFFFFF) == 0xC00004) { + genesis_context * gen = context->system; + value = vdp_hv_counter_read(gen->vdp); + } else { + value = read_dma_value(p_addr/2); + } } else { fprintf(stderr, "Unrecognized parameter to p: %s\n", param); break; -- cgit v1.2.3 From b88dc02ba056c2b5891b1bb062a2ad44df5df544 Mon Sep 17 00:00:00 2001 From: Michael Pavone Date: Thu, 14 May 2015 00:04:22 -0700 Subject: Sync machine state before entering debugger --- debug.c | 1 + 1 file changed, 1 insertion(+) (limited to 'debug.c') diff --git a/debug.c b/debug.c index fa0e26e..11ec9ad 100644 --- a/debug.c +++ b/debug.c @@ -471,6 +471,7 @@ m68k_context * debugger(m68k_context * context, uint32_t address) static uint32_t branch_t; static uint32_t branch_f; m68kinst inst; + sync_components(context, 0); //probably not necessary, but let's play it safe address &= 0xFFFFFF; if (address == branch_t) { -- cgit v1.2.3 From 68f82c7735196d65a2d57ce8d36cac01a402c3a2 Mon Sep 17 00:00:00 2001 From: Michael Pavone Date: Thu, 21 May 2015 18:37:41 -0700 Subject: Process events while waiting for 68K debugger input. This prevents "not responsive" dialogs when sitting in the debugger --- debug.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'debug.c') diff --git a/debug.c b/debug.c index 11ec9ad..ac5c34d 100644 --- a/debug.c +++ b/debug.c @@ -3,6 +3,8 @@ #include "68kinst.h" #include #include +#include +#include "render.h" static bp_def * breakpoints = NULL; static bp_def * zbreakpoints = NULL; @@ -508,8 +510,25 @@ m68k_context * debugger(m68k_context * context, uint32_t address) printf("%X: %s\n", address, input_buf); uint32_t after = address + (after_pc-pc)*2; int debugging = 1; + int prompt = 1; + fd_set read_fds; + FD_ZERO(&read_fds); + struct timeval timeout; while (debugging) { - fputs(">", stdout); + if (prompt) { + fputs(">", stdout); + fflush(stdout); + } + process_events(); + timeout.tv_sec = 0; + timeout.tv_usec = 16667; + FD_SET(fileno(stdin), &read_fds); + if(select(fileno(stdin) + 1, &read_fds, NULL, NULL, &timeout) < 1) { + prompt = 0; + continue; + } else { + prompt = 1; + } if (!fgets(input_buf, sizeof(input_buf), stdin)) { fputs("fgets failed", stderr); break; -- cgit v1.2.3 From 38d85c1c95d0a4152a480baff4974622977dcfce Mon Sep 17 00:00:00 2001 From: Michael Pavone Date: Wed, 27 May 2015 20:53:21 -0700 Subject: Add a basic YM-2612 command to the debugger. Fix negative detune values and get the correct precision for the multiplication step of phase inc calculation --- debug.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'debug.c') diff --git a/debug.c b/debug.c index ac5c34d..e121277 100644 --- a/debug.c +++ b/debug.c @@ -760,6 +760,23 @@ m68k_context * debugger(m68k_context * context, uint32_t address) } break; } + case 'y': { + genesis_context * gen = context->system; + //YM-2612 debug commands + switch(input_buf[1]) + { + case 'c': + if (input_buf[2] == ' ') { + int channel = atoi(input_buf+3)-1; + ym_print_channel_info(gen->ym, channel); + } else { + for (int i = 0; i < 6; i++) { + ym_print_channel_info(gen->ym, i); + } + } + } + break; + } #ifndef NO_Z80 case 'z': { genesis_context * gen = context->system; -- cgit v1.2.3 From 93a29403d334c8dd1253221fd4588209a706f500 Mon Sep 17 00:00:00 2001 From: Michael Pavone Date: Thu, 28 May 2015 22:31:21 -0700 Subject: Get windows build compiling again post-merge --- debug.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'debug.c') diff --git a/debug.c b/debug.c index ac5c34d..6ff8917 100644 --- a/debug.c +++ b/debug.c @@ -3,7 +3,9 @@ #include "68kinst.h" #include #include +#ifndef _WIN32 #include +#endif #include "render.h" static bp_def * breakpoints = NULL; @@ -510,16 +512,21 @@ m68k_context * debugger(m68k_context * context, uint32_t address) printf("%X: %s\n", address, input_buf); uint32_t after = address + (after_pc-pc)*2; int debugging = 1; +#ifdef _WIN32 +#define prompt 1 +#else int prompt = 1; fd_set read_fds; FD_ZERO(&read_fds); struct timeval timeout; +#endif while (debugging) { if (prompt) { fputs(">", stdout); fflush(stdout); } process_events(); +#ifndef _WIN32 timeout.tv_sec = 0; timeout.tv_usec = 16667; FD_SET(fileno(stdin), &read_fds); @@ -529,6 +536,7 @@ m68k_context * debugger(m68k_context * context, uint32_t address) } else { prompt = 1; } +#endif if (!fgets(input_buf, sizeof(input_buf), stdin)) { fputs("fgets failed", stderr); break; -- cgit v1.2.3 From 80ff833dd8ad011b579bff26ac654819e6735bce Mon Sep 17 00:00:00 2001 From: Michael Pavone Date: Sat, 25 Jul 2015 18:22:07 -0700 Subject: Use a new fatal_error function instead of calling fprintf and exit for fatal errors. This new function more gracefully handles the case in which BlastEm was not started from a terminal or disconnected from ther terminal (Windows). --- debug.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'debug.c') diff --git a/debug.c b/debug.c index 74e076b..a70f790 100644 --- a/debug.c +++ b/debug.c @@ -7,6 +7,7 @@ #include #endif #include "render.h" +#include "util.h" static bp_def * breakpoints = NULL; static bp_def * zbreakpoints = NULL; @@ -298,15 +299,12 @@ z80_context * zdebugger(z80_context * context, uint16_t address) pc = z80_ram + (address & 0x1FFF); } else if (address >= 0x8000) { if (context->bank_reg < (0x400000 >> 15)) { - fprintf(stderr, "Entered Z80 debugger in banked memory address %X, which is not yet supported\n", address); - exit(1); + fatal_error("Entered Z80 debugger in banked memory address %X, which is not yet supported\n", address); } else { - fprintf(stderr, "Entered Z80 debugger in banked memory address %X, but the bank is not pointed to a cartridge address\n", address); - exit(1); + fatal_error("Entered Z80 debugger in banked memory address %X, but the bank is not pointed to a cartridge address\n", address); } } else { - fprintf(stderr, "Entered Z80 debugger at address %X\n", address); - exit(1); + fatal_error("Entered Z80 debugger at address %X\n", address); } for (disp_def * cur = zdisplays; cur; cur = cur->next) { zdebugger_print(context, cur->format_char, cur->param); @@ -504,8 +502,7 @@ m68k_context * debugger(m68k_context * context, uint32_t address) } else if(address > 0xE00000) { pc = ram + (address & 0xFFFF)/2; } else { - fprintf(stderr, "Entered 68K debugger at address %X\n", address); - exit(1); + fatal_error("Entered 68K debugger at address %X\n", address); } uint16_t * after_pc = m68k_decode(pc, &inst, address); m68k_disasm(&inst, input_buf); -- cgit v1.2.3 From bee8b42029900ca034675c54d98813a61ca4407a Mon Sep 17 00:00:00 2001 From: Michael Pavone Date: Sun, 26 Jul 2015 01:11:04 -0700 Subject: Spawn a terminal for the debugger when needed if we are not already attached to one --- debug.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'debug.c') diff --git a/debug.c b/debug.c index a70f790..5fedb73 100644 --- a/debug.c +++ b/debug.c @@ -8,6 +8,7 @@ #endif #include "render.h" #include "util.h" +#include "terminal.h" static bp_def * breakpoints = NULL; static bp_def * zbreakpoints = NULL; @@ -287,6 +288,7 @@ z80_context * zdebugger(z80_context * context, uint16_t address) static uint16_t branch_t; static uint16_t branch_f; z80inst inst; + init_terminal(); //Check if this is a user set breakpoint, or just a temporary one bp_def ** this_bp = find_breakpoint(&zbreakpoints, address); if (*this_bp) { @@ -473,6 +475,9 @@ m68k_context * debugger(m68k_context * context, uint32_t address) static uint32_t branch_t; static uint32_t branch_f; m68kinst inst; + + init_terminal(); + sync_components(context, 0); //probably not necessary, but let's play it safe address &= 0xFFFFFF; -- cgit v1.2.3