Fix from Kent Dickey on the WAI instruction

Fantavision hangs when it starts on KEGS-based emulators (which includes GSport and GSplus) due to a bug in the way KEGS handles the WAI instruction.  Fantavision masks interrupts with SEI, sets a SHR line interrupt, and then does a WAI instruction.  This hangs KEGS since it expects an actual interrupt to end the WAI, but there won't be one since interrupts are masked.  I never realized this was a valid WAI use case.

The fix is easy.  In `instable.h`, change:
```
instcb_SYM              /*  WAI */
        g_wait_pending = 1;
        CYCLES_FINISH
```
(There may be some stale #ifdef ASM code, just ignore that) to:
```
instcb_SYM              /*  WAI */
        if(g_irq_pending) {
                g_wait_pending = 0;
                INC_KPC_1;
        } else {
                g_wait_pending = 1;
        }
```
Kent
This commit is contained in:
David Schmidt 2020-08-19 15:24:31 -04:00 committed by GitHub
parent 3e26fb1ecd
commit d1b556c5c5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 3 deletions

View File

@ -1,6 +1,6 @@
/*
GSport - an Apple //gs Emulator
Copyright (C) 2010 by GSport contributors
Copyright (C) 2010 - 2020 by GSport contributors
Based on the KEGS emulator written by and Copyright (C) 2003 Kent Dickey
@ -2231,8 +2231,12 @@ instcb_SYM /* WAI */
b dispatch
stw scratch2,r%g_wait_pending(scratch1)
#else
g_wait_pending = 1;
CYCLES_FINISH
if(g_irq_pending) {
g_wait_pending = 0;
INC_KPC_1;
} else {
g_wait_pending = 1;
}
#endif
instcc_SYM /* CPY abs */