changeset 723:7178d750efbd

Process events while waiting for 68K debugger input. This prevents "not responsive" dialogs when sitting in the debugger
author Michael Pavone <pavone@retrodev.com>
date Thu, 21 May 2015 18:37:41 -0700
parents 8f5339961903
children 2174f92c5f9b
files debug.c render.h
diffstat 2 files changed, 21 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/debug.c	Thu May 21 00:55:46 2015 -0700
+++ b/debug.c	Thu May 21 18:37:41 2015 -0700
@@ -3,6 +3,8 @@
 #include "68kinst.h"
 #include <stdlib.h>
 #include <string.h>
+#include <sys/select.h>
+#include "render.h"
 
 static bp_def * breakpoints = NULL;
 static bp_def * zbreakpoints = NULL;
@@ -508,8 +510,25 @@
 	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;
--- a/render.h	Thu May 21 00:55:46 2015 -0700
+++ b/render.h	Thu May 21 18:37:41 2015 -0700
@@ -33,6 +33,7 @@
 int render_joystick_num_buttons(int joystick);
 int render_joystick_num_hats(int joystick);
 int render_num_joysticks();
+void process_events();
 
 //TODO: Throw an ifdef in here once there's more than one renderer
 #include <SDL.h>