[Coco] OS-9 Level1 Version 02.00.00 FYI

William Astle lost at l-w.ca
Fri Apr 17 11:30:29 EDT 2020


On 2020-04-17 9:10 a.m., Dave Philipsen wrote:
> Actually keyboard interrupts are not used in OS9. The keyboard is scanned at a regular interval determined by the interrupt routine but it’s actually the video system which is generating the interrupts which OS9 also uses for multitasking.

As an interesting side note, I did some experimentation a while back 
with using the GIME keyboard interrupt. I discovered that it making it 
reliable actually takes a lot more code and as much or more time just 
doing a quick scan of the PIA to determine if any keys are pressed.

Detecting if any keys are down requires just a handful of instructions 
that don't take very long.

But with the keyboard interrupt, you have to 1) detect the keyboard 
interrupt, 2) if it fires, disable the keyboard interrupt and enable 
periodic scanning of the keyboard, and 3) after scanning the keyboard, 
you have to check if any keys are pressed at all and if not, turn off 
regular scanning and re-enable the interrupt. Also, 4) You also need to 
check a flag in the VSYNC interrupt handler to decide if you need to 
scan the keyboard, though some form of this might be required anyway to 
make things more efficient.

1), 2), and 4) combined take more time than just scanning the PIA, 
partly due to the write-only nature of the interrupt enable flags. 
Reading them gives the the state of the interrupt source, not the enable 
flags so you have to maintain a mirror somewhere. Also, you have an 
extra flag test in every VSYNC interrupt. 3) just makes the periodic 
keyboard scan slightly slower.

The practical upshot is that the GIME keyboard interrupt is useless 
except possibly in some *very* limited cases. Even if someone smarter 
than me could work out how to make the rather convoluted code needed to 
make this reliable run faster than checking the PIA for a key being 
down, it's almost certainly not going to save enough to be worth the 
extra complexity and code size.


More information about the Coco mailing list