Continuing with bad IKBD coding examples:
Sensible Software made some really good games, starting at 1990, if I see it correct. But I had lot of troubles with their International 3D Tennis. It just wont read joystick properly, or at all when game menu appears. On some STE, Falcon certainly not. Someone asked me at YouTube to say more about bad coding in it, so I will do it here.
But need to say few words before: you can not read keyboard, or joystick, mouse state directly in ST, because it is done by IKBD chip, which normally generates an interrupt whenever something changes -some key pressed or released, mouse moved. There are codes for every action. It seems that some coders had troubles with that - I guess mostly those programming on 8-bit machines like Sinclair Spectrum, where is direct access to keyboard matrix.
Serial communication is used, with relative slow speed, and small sized buffer. If CPU not reads all sent data whole system freezes, and further action are not readable. Then you need to flush ACIA first. Such data overflow happens mostly when some longer code with disabled interrupts is executed. Usual and efficient cure against is to disable IKBD chip's code sending, and reenabling after SW is again ready to receive IKBD input. Normal way of reading IKBD chip is via MFP interrupts - at every IKBD code sending an interrupt is generated, and then CPU can read it in service routine, after what IKBD chip can send next one - there are multi-byte sequences, which start with specific header byte.
And this is where main problem in International 3D Tennis lies. During intro they use wrong method: ACIA interrupt is disabled, and ACIA is readen by SW periodically. But that may confuse IKBD chip, and putting it in some bad state. Interesting thing, what I did not notice before is that giving command $14 - enable joysticks instead $12 - disable mouse is not good in such bad IKBD reading way. Mouse will be still readen, and that code for joystick read goes confused. In normal work, giving $14 or $12 has same effect - mouse goes disabled, and can read 2 joysticks. There are some other bad codings in International 3D Tennis, like enabling Timer-D, while it is not used at all - what made Steem working bad.
Their later game Cannon Fodder has better IKBD code, but still made me troubles in version with STE DMA music loaded from mass storage during intro. It again used method with disabled ACIA interrupt during intro, what worked with PSG music, but not with STE audio DMA and constant loading from disk with rate of 50 KB/sec . There is code what should detect absolute mouse position package from IKBD chip - but it fails under mentioned music playback way (I guess that there were traces of it on bus, instead ACIA data when code tried to read it) - user needs to press mouse button multiple times and longer to abort intro. Stupid thing is that they used same, absolute mouse pos. reading way in intro, where even no mouse cursor
I fixed both cases, but it took too much time - it is not easy to fix badly concepted code.
Famous Schrodinger's cat hypothetical experiment says that cat is dead or alive until we open box and see condition of poor animal, which deserved better logic. Cat is always in some certain state - regardless from is observer able or not to see what the state is.