Back to the VGS page

Emulator keyboard setup file explained

The new version 6 of David Keil's emulator (model 1) comes with two keyboard setup files TRS81.KEY and PC81.KEY. These files decide the keyboard layout. Since I am Norwegian and use a Norwegian keyboard neither of them fit very well. So I brought them up in my hex-editor and figured out how they work (Could have asked David but there's no fun in that).

David Keil has now made documentation for the keyboard so for correct information you should look to his documentation. This information is a bit redundant but I decided to keep it anyway. It explaines the file which is here for downloading.

The file contains 512 bytes which you can easily see that are organized in pairs and also that they “start over” from byte 256. The first 128 byte pairs are unshifted keys the last 128 are the same keys shifted. The PC communicates with its keyboard using so-called scancodes and there are several layouts of these. That was a hard part, because the scancode set, on which the layout is based, is the old PC-XT set. Some of these codes are prefixed by 0xE0, and some of these are in the table with an offset of 32, but some seems to be hardcoded. The scancode sets are different for different keyboard layouts, but generally keys which are in the same place have the same code regardless of what's on it.

Here is the Norwegian layout of the keyboard with the emulator key numbers (those I have found):

Example: In the Norwegian keyboard we have a <> key in the lower left part of the keyboard where the US keyboard has a wider shift key. This key is key number 86 in the emulator (I found the number by trial and error) so its code would be at byte number 172 (0xAC) unshifted and 428 (0x1AC) where we find the codes 0x00 0x80 = 0x8000 (=disabled) in both places.

The codes are then used to translate the key into the memorymapped keyboard area of the TRS-80 or to execute emulator functions. The emulator functions should be on the keys where they are designed to be, so we leave these alone. The shift keys have emulator function codes so the tables below doesn't show shift which is in column 0 row 7 (0x**07).

The codes which we concern ourselves with are 0x8000, 0x00** and 0x01**. As stated above 0x8000 means disabled. 0x00** means TRS-80 key pressed without shift and 0x01** that the TRS-80 key is pressed together with shift. You can see from the table below which code each TRS-80 key is assigned to.

Example: You find the code for < is 0x0145 and > is 0x0165.

Caps is an internal function of the operating system on the TRS-80 and affect certain keys. This is different for different DOS'es, below I have shown DOSPLUS' keys that change with gray background. The ROM applies caps to A-Z only. Some applications might run their own keyboard driver and handle Caps differently or not at all.

The [, \, ], ~ and _ keys does not exist on my VGS but would be handled as such if a key would be in the matrix at that point. They would also be affected by Caps so it is a slight inconvenience that the \ key is affected by Caps and turns into |. Likewise with [ and the others.

The F1, F2 and F3 keys don't exist, on the VGS, either and are not decoded by the normal keyboard drivers.

Unshifted

Shifted

I have made PC81.KEY and PC83.KEY files, which fits the Norwegian keyboard layout. Generally moving the signs to their proper place on my keyboard. Also I changed the Delete to be the  (ASCII code 0x7F) key which I will use as delete in an editor.

Originally the keypad key / is using the same setting as key number 53 which is wrong for my keyboard (On the US keyboard they are both /). Jürgen Büssert has made a driver which fixes this. His driver also enables the AltGr to work in the same way as normal. He also made a Norwegian version of the driver.

I have prepared a zip here which you can download, in the zip is my versions of PC81.KEY and PC83.KEY and Jürgen Büssert's TRS-NO.COM driver.

TRS-80NO.zip
Make a backup of the original PC81.KEY and/or PC83.KEY before unpacking the zip!

To use TRS-NO.COM start TRS81.EXE and or TRS80.EXE with it, like this:

TRS-NO.COM TRS81.EXE

You should visit Jürgen Büssert's web pages for more information about the keyboard and his driver, in his German TRS-80 and International Keyboard pages. He has also filled out some of the things I didn't bother with like the codes which triggers emulator functions.

I am giving this file and information away for free so there are no warranties of any kind.

Copyright (c) 2001 Knut Roll-Lund

19/8-00 Created
3/9-00 Corrected mistake; Danish keyboard layout is not exactly same as Norwegian (MS-DOS characterset is).
14/2-01 Corrected a typingmistake and added link to Jürgen's page.
6/4-01 Updated with new zip with TRS-NO driver and correlated info here with other available documentation.

Back to the VGS page