KR9600 Tester
The KR9600-PRO keyboard encoder has a bug of sorts.
So does the AY-5-3600-PRO keyboard encoder, according to page 7-12 of Understanding the Apple IIe by James Sather.
But despite being a drop-in replacement for the KR9600-PRO and AY-5-3600-PRO, the JCM-1 does not exhibit the aforementioned bug. Well done!
James Sather identified the bug in the timing diagram illustrated below: when all keys have been released, the AKD signal goes high immediately when a new key has been pressed, but the key is not decoded until 0.01 second later. If a game like Prince of Persia uses AKD to detect keypresses during that interval, it will incorrectly read a stale ASCII value because the keypress has not been decoded yet.
The binary program KR9600 TESTER.OBJ0
enables you to test your keyboard encoder.
Run the program with the command: BRUN KR9600 TESTER.OBJ0
Then try pressing and releasing a few keys. At regular intervals, the tester captures the values from the KDB and AKD ports, and then reports on any unexpected or illegal transitions. If a faulty transition occurs, the affected port is highlighted and a message appears to describe the fault condition.
In the test below, a fault occurred on the first keypress: I pressed the letter J (code $CA), but the AKD port immediately reported that the RETURN key had been pressed (code $8D). And the KBD port still contained the ASCII code for the RETURN key from earlier. Shortly afterward, both ports indicated that the J key had been pressed...but there was an instant where both were wrong.
After replacing the KR9600-PRO with a JCM-1 keyboard encoder, the errors stopped happening. Except just once when it detected an AKD fault followed immediately by a KBD fault -- this was probably just freak timing, where a keypress was registered exactly while my program was reading KDB and AKD.
It didn't detect any errors under the Apple //jse emulator. No surprise, really. It's unlikely that anyone would try to emulate this faulty behavior, even if they know about it.
The KR9600 TESTER program and its source code are included in PoPABol, my Prince Of Persia pre-boot disk, which is attached below.
The original purpose of this disk was to apply a runtime patch to avoid this bug in Prince Of Persia when booted from its original floppy disk. To run the KR9600 TESTER instead of the Prince Of Persia patch, press CTRL-RESET and then type BRUN KR9600 TESTER.OBJ0
Attachment | Size |
---|---|
Prince of Persia pre-boot disk, with KR9600 TESTER.OBJ0 | 140 KB |
- S.Elliott's blog
- Log in or register to post comments