Saturday, October 11, 2014

Directional Difficulties - The Early Keyboards and Cursor Keys

When IBM introduced the PC, it came with an 83-key keyboard keyboard that a number row and a numeric keypad.  There were no status LEDs on this keyboard, so the only way you could tell whether the Num Lock key had been pressed was by observing the behavior of the numeric keypad.  If a number was typed, then the Num Lock was on.  The general layout was as follows :


All layouts taken from here : http://www.quadibloc.com/comp/kyb03.htm.  There were also separate + and - keys and a PrtSc * key.  Not every game used the numberpad for directional controls.  

For the IBM PCjr., IBM severely cut down the keyboard size, build quality and number of keys.  There was no numeric keypad.  Instead, the keyboard only had six discrete cursor keys.  Here is the new layout :

The cursor keys pull double and even triple duty, as their function changes  if the Shift or Fn key is held down.  There is no Num Lock key on this keyboard.

The Num Lock key can be "pressed" by hitting Alt, Fn and N.  When the Num Lock function is activated in this manner or the Shift key is pressed, then Up becomes 8, Left becomes 4, Right becomes 6, Down becomes 2, Ins becomes 0 and Del becomes .  If the Fn key is held, then you get Home, Pg Up, Pg Dn and End for Up, Left, Right and Down, respectively.   Press Fn and Shift, and you get 7, 9, 3 and 1.  Numberpad key 5 cannot be directly generated by the PCjr. keyboard.

The next major keyboard innovation came from Tandy.  Tandy 2000 and more importantly 1000 keyboards have separate cursor control keys in the now familiar inverted-T layout.  In addition, there is a numeric keypad, but several functions have been changed.  There are individual keys for Home, Insert and Delete. Here is the layout :


There are more differences between an IBM and a Tandy keyboard as well.  However, the differences do not always make a difference to programs.  There are two general methods with PCs to determine which key was pressed.  The first was to call Int 16h.  The result would give you a translated scan code and an ASCII character.  The second was to read the raw scancode directly from the hardware.  Some programmers used the second method with their own keyboard interrupt handlers.  This tends to be the cause of keyboard incompatibilities.

Because some keys, like the numberpad keys, can give results identical to other keys on the keyboard, even the BIOS allows you to distinguish between the 1 key on the number row and the 1 key on the number paid.  You can tell the difference between the Left and Right Shift keys, even though their function is totally identical.

A Tandy has a Num Lock key and even a status LED, but when the Tandy boots up, the Num Lock defaults to off, just like the PCjr.  An IBM PC defaults the Num Lock function to on.  Many games require you to turn the Num Lock on when running on a Tandy 1000.  This is because the characters given by the Tandy keyboard are often not the same as on an IBM PC keyboard.  However, for numbers they will always be the same.  

The Tandy inverted T cursor keys are another issue.  A well-behaved program doesn't care which key is pressed so long as it reads the scancode it expects.  However, not every DOS game is well-behaved.  In DOS, the separate cursor keys function as they would on an IBM Model M keyboard.  However, some games rely on the numeric keypad to give eight movement directions.  Tandy's inverted-T cursor keys give different raw scancodes and may not always be recognized.  

Later Keyboards :

The 83-key keyboard layout was followed for the PC AT keyboard with a few differences to key placement and size.  IBM included status LEDs and an 84th key for Sys Req.  The raw scancodes are completely different from an 83-key keyboard, only the BIOS allows for compatibility with PC and XT software.  However, despite the fewer number of keys compared to more modern keyboards, it is still usable in any system with a PS/2 port.  

Finally, IBM released the Model M 101-key keyboard which essentially defined the minimum number of keys and the basic layout that we use today.  Its provided fully separate cursor keys in addition to the numeric keypad.  Most of the time, the cursor keys can be used as directionals, but because they have different raw scancodes than the numeric keypad cursor keys, some games will not recognize them.  The Model M supports three sets of raw scancodes, Set 1 is the PC/XT scancodes and it sends those scancodes when it is plugged into a PC or XT or Tandy 1000 TL/SL/RL or the 8086 based IBM PS/2s (but compatibility with anything other than the PC/XT's 2nd or 3rd BIOS is dicey).  Set 2 is when it is plugged into an IBM PC AT, PC/XT Model 286 and just about every other computer, including modern machines. Set 3 was intended as the native PS/2 scancode set and is similar to Set 2 but was rarely used. 

No comments: