From f3f943c60742d10e71a217986db315d027a2d8fe Mon Sep 17 00:00:00 2001 From: Peter Schorn Date: Sat, 8 Oct 2022 00:25:15 -0700 Subject: [PATCH] AltairZ80: M68K: Fix hang with 'expect' --- AltairZ80/altairz80_sio.c | 4 ++-- AltairZ80/m68ksim.c | 13 +++++++------ 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/AltairZ80/altairz80_sio.c b/AltairZ80/altairz80_sio.c index 71ea0d6f..61a1112b 100644 --- a/AltairZ80/altairz80_sio.c +++ b/AltairZ80/altairz80_sio.c @@ -210,9 +210,9 @@ static int32 markTimeSP = 0; /* stack pointer for timer stack /* default time in milliseconds to sleep for SIMHSleepCmd */ #if defined (__MWERKS__) && defined (macintosh) -static uint32 SIMHSleep = 0; /* no sleep on Macintosh OS9 */ + uint32 SIMHSleep = 0; /* no sleep on Macintosh OS9 */ #else -static uint32 SIMHSleep = 1; /* default value is one millisecond */ + uint32 SIMHSleep = 1; /* default value is one millisecond */ #endif static uint32 sleepAllowedCounter = 0; /* only sleep on no character available when == 0 */ static uint32 sleepAllowedStart = SLEEP_ALLOWED_START_DEFAULT; /* default start for above counter */ diff --git a/AltairZ80/m68ksim.c b/AltairZ80/m68ksim.c index 10d40442..24a57013 100644 --- a/AltairZ80/m68ksim.c +++ b/AltairZ80/m68ksim.c @@ -121,6 +121,7 @@ #define IRQ_MC6850 5 extern uint32 PCX; +extern uint32 SIMHSleep; /* Prototypes */ static void MC6850_reset(void); @@ -268,7 +269,6 @@ static void MC6850_reset(void) { } #define INITIAL_IDLE 100 -#define IDLE_SLEEP 20 static uint32 idleCount = INITIAL_IDLE; static void m68k_input_device_update(void) { @@ -281,8 +281,8 @@ static void m68k_input_device_update(void) { } else if (--idleCount == 0) { const t_stat ch = sim_poll_kbd(); idleCount = INITIAL_IDLE; - if (IDLE_SLEEP) - sim_os_ms_sleep(IDLE_SLEEP); + if (SIMHSleep) + sim_os_ms_sleep(SIMHSleep); if (ch) { characterAvailable = TRUE; keyboardCharacter = ch; @@ -294,15 +294,16 @@ static void m68k_input_device_update(void) { static uint32 MC6850_data_read(void) { t_stat ch; int_controller_clear(IRQ_MC6850); - m68k_MC6850_status &= ~0x81; // clear data ready and interrupt flag + m68k_MC6850_status &= ~0x81; // clear data ready and interrupt flag if (characterAvailable) { ch = keyboardCharacter; characterAvailable = FALSE; } else ch = sim_poll_kbd(); while ((ch <= 0) && (!stop_cpu)) { - if (IDLE_SLEEP) - sim_os_ms_sleep(IDLE_SLEEP); + sim_interval -= KBD_POLL_WAIT; // ensure progress + if (SIMHSleep) + sim_os_ms_sleep(SIMHSleep); ch = sim_poll_kbd(); } if (ch == SCPE_STOP)