joncampbell123 / dosbox-x

DOSBox-X fork of the DOSBox project
GNU General Public License v2.0
2.65k stars 376 forks source link

PCjr keyboard handling is not correct #850

Open joncampbell123 opened 6 years ago

joncampbell123 commented 6 years ago

Describe the bug Keyboard handling on the PCjr is said to follow the following pattern:

To Reproduce Steps to reproduce the behavior:

  1. Run the "Pitfall2" cartridge image in PCjr mode
  2. Start a game, hit 'K'
  3. Notice that controls do not work, except spacebar

Notes: The game installs it's own IRQ 1 handler, which may be related to the issue.

See also:

http://www.brutman.com/PCjr/pcjr_keyboard_handling.html

joncampbell123 commented 6 years ago

Recent commits bring the PCjr keyboard emulation closer to actual hardware, including the NMI interrupt and passage of the scan code to IRQ1, but it's not 100% correct yet.

On real hardware, the PCjr keyboard has it's own proprietary scan code set, which is decoded by the NMI (which according to sources, eats 1ms of CPU time), then fed to an interrupt (somewhere in the 40-4Fh range, need to check), to translate the code to IBM PC/XT compatible scan codes before passing it in AL to the IRQ1 handler.

Note that according to PCjr source code listings, IRQ1 on the PCjr does NOT read port 60h, it accepts whatever was given to it in AL on entry to the interrupt handler (!) which is very different from any other IBM platform.