diff --git a/Ibm1130/ibm1130_cpu.c b/Ibm1130/ibm1130_cpu.c index b667851a..186e8422 100644 --- a/Ibm1130/ibm1130_cpu.c +++ b/Ibm1130/ibm1130_cpu.c @@ -1941,7 +1941,6 @@ static t_stat view_cmd (int32 flag, CONST char *cptr) sprintf(cmdline, "notepad %s", cptr); WinExec(cmdline, SW_SHOWNORMAL); - Sleep(1000); /* wait a bit to allow notepad to open the file */ #endif return SCPE_OK; } diff --git a/Ibm1130/ibm1130_defs.h b/Ibm1130/ibm1130_defs.h index d6dbf06a..699d751c 100644 --- a/Ibm1130/ibm1130_defs.h +++ b/Ibm1130/ibm1130_defs.h @@ -281,7 +281,7 @@ void break_simulation (t_stat reason); /* let a device halt the sim char hollerith_to_ascii (uint16 hol); /* for debugging use only */ t_bool gdu_active (void); void remark_cmd (char *remark); -void stuff_cmd (char *cmd); +LONG stuff_cmd (char *cmd); t_bool stuff_and_wait (char *cmd, int timeout, int delay); void update_gui (t_bool force); void sim_init (void); diff --git a/Ibm1130/ibm1130_gui.c b/Ibm1130/ibm1130_gui.c index 9dccf159..180af0f1 100644 --- a/Ibm1130/ibm1130_gui.c +++ b/Ibm1130/ibm1130_gui.c @@ -1475,7 +1475,7 @@ static void tear_printer (void) return; sprintf(cmd, "view \"%s\"", filename); /* spawn notepad to view it */ - if (! stuff_and_wait(cmd, 3000, 500)) + if (! stuff_and_wait(cmd, 3000, 2000)) return; remove(filename); /* delete the file */ @@ -1522,9 +1522,13 @@ static DWORD iCmdThreadID = 0; static HANDLE hCmdReadEvent = NULL; static HANDLE hCmdReadyEvent = NULL; static BOOL scp_reading = FALSE; +static LONG scp_command = 0; static char cmdbuffer[256]; static BOOL read_exiting = FALSE; +#define SCP_COMMAND InterlockedExchangeAdd(&scp_command, 0L) +#define NEXT_SCP_COMMAND InterlockedIncrement(&scp_command) + /* CmdThread - separate thread to read commands from stdin upon request */ static DWORD WINAPI CmdThread (LPVOID arg) @@ -1537,14 +1541,17 @@ static DWORD WINAPI CmdThread (LPVOID arg) continue; /* put breakpoint here to debug */ if (read_exiting) break; - scp_reading = TRUE; + scp_reading = FALSE; if (ReadFile(hStdIn, cmdbuffer, sizeof(cmdbuffer)-1, &dwBytesRead, NULL)) { cmdbuffer[dwBytesRead] = '\0'; scp_reading = FALSE; + NEXT_SCP_COMMAND; SetEvent(hCmdReadyEvent); /* notify main thread a line is ready */ } else { DWORD dwError = GetLastError(); + scp_reading = FALSE; + NEXT_SCP_COMMAND; } } return 0; @@ -1598,10 +1605,12 @@ char *read_cmdline (char *ptr, int size, FILE *stream) /* stuff_cmd - force a command into the read_cmdline output buffer. Called asynchronously by GUI */ -void stuff_cmd (char *cmd) +LONG stuff_cmd (char *cmd) { INPUT_RECORD *ip; size_t i, j, cmdsize = strlen(cmd); + DWORD dwEventsWritten; + LONG scp_cmd = SCP_COMMAND; ip = (INPUT_RECORD *)calloc(2+2*cmdsize, sizeof(*ip)); for (i=j=0; i