summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--util.c5
-rw-r--r--util.h2
-rw-r--r--vdp.c18
3 files changed, 21 insertions, 4 deletions
diff --git a/util.c b/util.c
index 1c55e09..1617551 100644
--- a/util.c
+++ b/util.c
@@ -534,6 +534,11 @@ void disable_stdout_messages(void)
output_enabled = 0;
}
+uint8_t is_stdout_enabled(void)
+{
+ return output_enabled;
+}
+
#ifdef _WIN32
#define WINVER 0x501
#include <winsock2.h>
diff --git a/util.h b/util.h
index 014789f..956a21a 100644
--- a/util.h
+++ b/util.h
@@ -88,6 +88,8 @@ void warning(char *format, ...);
void debug_message(char *format, ...);
//Disables output of info and debug messages to stdout
void disable_stdout_messages(void);
+//Returns stdout disable status
+uint8_t is_stdout_enabled(void);
//Deletes a file, returns true on success, false on failure
uint8_t delete_file(char *path);
//Initializes the socket library on platforms that need it
diff --git a/vdp.c b/vdp.c
index 18b2eae..5a90e8b 100644
--- a/vdp.c
+++ b/vdp.c
@@ -3809,14 +3809,24 @@ int vdp_control_port_write(vdp_context * context, uint16_t value)
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;
- init_terminal();
- printf("KDEBUG MESSAGE: %s\n", context->kmod_msg_buffer);
+ 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;
}
} else if (reg == REG_KMOD_TIMER) {
if (!(value & 0x80)) {
- init_terminal();
- printf("KDEBUG TIMER: %d\n", (context->cycles - context->timer_start_cycle) / 7);
+ 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;