gsplus
gsplus copied to clipboard
Fix for WAI behavior (Fantavision)
From https://groups.google.com/forum/#!topic/comp.sys.apple2/NWjJ1_ytewQ (Thanks fatdog)
Kent Dickey writes: 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;
}