home *** CD-ROM | disk | FTP | other *** search
- KEYPAD.TXT - THE CARE AND FEEDING OF THE CP/M KAYPRO PROGRAMMABLE KEYPAD
-
- Copyright 1989 by Dale H. Cook
-
- This document may be freely distributed provided that it is distributed in
- whole with no alteration or modification in form or content, that all
- copyright notices remain intact, and that no charge is made other than a
- nominal distribution fee. All commercial distribution of this program in part
- or in whole without the express written consent of the author is strictly
- prohibited. The author may be reached at: CompuServe 71370,2635.
-
-
- NOTE: This document involves the use of a number of public domain and/or
- freeware programs such as PROBE and SuperZap. At the end of this text
- is a list of these programs with suggestions on where to find them.
- All are widely and easily available. The only other programs you need
- are on your Kaypro CP/M system disk (like CONFIG and DDT).
-
-
- One of my favorite features on the CP/M Kaypro computers is that the
- numeric keypad and cursor keys are fully programmable. The keypad can be
- customized for a particular application to become a set of fourteen function
- keys. This document explains how the keypad and cursor keys work and how you
- can customize them for your own needs.
-
- For simplicity, let's refer to the main keyboard as the "normal" keys,
- and to the cursor (arrow) keys and numeric keypad as the "special" keys. When
- a normal key is pressed, the key board sends the ASCII value of the key (in
- the range 00h to 7Fh) to the BIOS, which passes the value to the calling
- program. So when you type an upper case "C", the keyboard and BIOS hand the
- calling program the ASCII value 43h. When you type a special key, however,
- the keyboard generates a value with the upper bit set (in the range 80h to
- FFh) and the BIOS, flagged by the high bit, handles the value differently.
- The BIOS passes the value to the monitor ROM which uses the value to enter
- a table and look up a new value. This new value, with high bit still set,
- is returned to the BIOS. The BIOS uses the new value as an entry into another
- table in the BIOS RAM that we will refer to as the "small key table".
-
- Let's take a look at the small key table on your machine. First, you'll
- need to know the starting address of your BIOS. Run PROBE.COM and note the
- address where your BIOS jump table begins. For example, on my Kaypro 4-84,
- it is F600h. (The examples here all use the addresses for my system - just
- substitute the addresses you find for your system and follow allong.) Fire up
- DDT and instruct it:
-
- -dF600 <CR> (to display memory contents starting at F600h)
-
- You'll get a display similar to this:
-
- -dF600
- F600 C3 A9 F6 C3 1E F7 C3 85 F7 C3 AA F7 C3 06 F8 C3 ................
- F610 1F F8 C3 1A F8 C3 15 F8 C3 64 F8 C3 68 F8 C3 6C .........d..h..l
- F620 F8 C3 70 F8 C3 74 F8 C3 78 F8 C3 82 F8 C3 3A F8 ..p..t..x.....:.
- F630 C3 94 F8 81 00>0B 0A 08 0C 30 31 32 33 34 35 36 .........0123456
- F640 37 38 39 2D 2C 0D 2E<05 05 2C 09 0E 18 04 44 03 789-,....,....D.
- F650 E1 05 E8 01 00 09 06 18 04 44 03 E1 05 E8 01 00 .........D......
- F660 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
- F670 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
- F680 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
- F690 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
- F6A0 00 00 00 00 00 00 00 00 00 CD 60 F8 AF 32 04 00 ..........'..2..
- F6B0 3A 33 F6 32 03 00 21 4A F6 46 23 4E 23 ED B3 7E :3.2..!J.F#N#..~
- -
-
- The ASCII display to the right shows a string of 18 bytes (their hex
- values are between the > and < symbols) "....0123456789-,.." which
- constitute the small key table. The first four - 0Bh, 0Ah, 08h and 0Ch -
- are the up, down, left and right cursor key values. The next ten are the
- keypad number keys. The last four are the remaining four keys - "-" (2Dh),
- "," (2Ch), "ENTER" (0Dh) and "." (2Eh). On some Kaypros the last two keys
- seem to have the hex value 00h. (probably due to a BIOS source code error)
- If your keypad "ENTER" key doesn't do anything, that's why! Just use CONFIG to
- set those keys to their correct values.
-
- Now that we've seen the small key table, what can we do with it? We
- could use DDT to change the keys, but Kaypro has provided a seperate program
- to make the process easier - CONFIG.COM. If you've never used CONFIG, fire
- it up now and play with it. The documentation for this program is pretty
- skimpy, but the screens pretty much explain themselves. Try changing the
- "ENTER" key to "C" (43h). After you exit CONFIG, the "ENTER" key will print a
- "C" on the screen. Changes to the keys made with CONFIG are only good after
- the system is cold booted. Since the changes are made on disk, the system
- must be rebooted to load the new key values into RAM.
-
- You'll notice that CONFIG lets you program each key with a string of up
- to four characters, but the small key table entries are only one byte long.
- Let's take a look at that DDT display again:
-
- -dF600
- F600 C3 A9 F6 C3 1E F7 C3 85 F7 C3 AA F7 C3 06 F8 C3 ................
- F610 1F F8 C3 1A F8 C3 15 F8 C3 64 F8 C3 68 F8 C3 6C .........d..h..l
- F620 F8 C3 70 F8 C3 74 F8 C3 78 F8 C3 82 F8 C3 3A F8 ..p..t..x.....:.
- F630 C3 94 F8 81 00>0B 0A 08 0C 30 31 32 33 34 35 36 .........0123456
- F640 37 38 39 2D 2C 0D 2E<05 05*2C*09 0E 18 04 44 03 789-,....,....D.
- F650 E1 05 E8 01 00 09 06 18 04 44 03 E1 05 E8 01 00 .........D......
- F660 00}00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
- F670 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
- F680 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
- F690 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
- F6A0 00 00 00 00 00 00 00 00 00{CD 60 F8 AF 32 04 00 ..........'..2..
- F6B0 3A 33 F6 32 03 00 21 4A F6 46 23 4E 23 ED B3 7E :3.2..!J.F#N#..~
- -
-
- Once again, the hex values of the small key table are indicated between
- > and <. I have also marked a string of 72 nuls (00h) between the } and {
- symbols. This is the "large key table". Also note the third byte after the
- end of the small key table (indicated by the asterisks) - 2Ch on my machine.
- This is an offset from the small table to the large table used by the BIOS.
- The first byte of the small table is at F635h, and the first byte of the
- large table is at F661h. F635h + 2Ch = F661h.
-
- If a byte in the small key table nold a nul (00h) the BIOS will look at
- the large key table to find a string of up to four bytes, and pass those
- values to the calling program. Try using CONFIG to change the "ENTER" key to
- the four characters "C", "a", "t" and "s". Use DDT to examine the changes to
- the key tables:
-
- -dF600
- F600 C3 A9 F6 C3 1E F7 C3 85 F7 C3 AA F7 C3 06 F8 C3 ................
- F610 1F F8 C3 1A F8 C3 15 F8 C3 64 F8 C3 68 F8 C3 6C .........d..h..l
- F620 F8 C3 70 F8 C3 74 F8 C3 78 F8 C3 82 F8 C3 3A F8 ..p..t..x.....:.
- F630 C3 94 F8 81 00 0B 0A 08 0C 30 31 32 33 34 35 36 .........0123456
- F640 37 38 39 2D 2C>00<2E 05 05 2C 09 0E 18 04 44 03 789-,....,....D.
- F650 E1 05 E8 01 00 09 06 18 04 44 03 E1 05 E8 01 00 .........D......
- F660 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
- F670 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
- F680 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
- F690 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
- F6A0 00}43 61 74 73{00 00 00 00 CD 60 F8 AF 32 04 00 .Cats.....'..2..
- F6B0 3A 33 F6 32 03 00 21 4A F6 46 23 4E 23 ED B3 7E :3.2..!J.F#N#..~
- -
-
- Byte F645, formerly 0Dh (carriage return) is now a nul, (00h) and
- bytes F6A1 through F6A4 hold the ASCII value of "Cats". Now when you hit
- the "ENTER" key, "Cats" will be sent to the screen. To find the four large
- key table bytes corresponding to any key, use the table below to perform
- a calculation:
-
- Offset Key Offset Key Offset Key Offset Key
- ------ --- ------ --- ------ --- ------ ---
- 00h Up 14h 1 28h 6 3Ch ,
- 04h Down 18h 2 2Ch 7 40h ENTER
- 08h Left 1Ch 3 30h 8 44h .
- 0Ch Right 20h 4 34h 9
- 10h 0 24h 5 38h -
-
- Here's the calculation:
-
- F635h < First byte of small key table
- + 2Ch < Offset from small table to large table mentioned earlier
- -----
- F661h < First byte of large key table
- + 40h < Offset for "ENTER" key
- -----
- F6A1h < First of the four large table bytes for the "ENTER" key
-
- Now you know how to find your way around the key tables in your Kaypro,
- and should understand how CONFIG changes the key table values to customize
- your cursor and keypad keys. Let's see how these changes are stored on the
- system tracks of a disk.
-
- The Kaypro-distributed version of WordStar 3.3 had a patch that set the
- cursor keys "on the fly" to the WordStar cursor commands. (^E, ^X, ^S, ^D)
- I wanted to program the keypad for fourteen other common WordStar commands,
- so I made a permanent change to the system tracks on my WordStar working
- disk. I used CONFIG to make the changes, but we'll use a disk editor. Usually
- I use SuperZap, but PATCH18 can do the same thing. (DDT can't do disk
- editing easily. Get one of these free programs and save yourself a lot of
- work.) Read the documentation for the disk editor of your choice to find out
- how to view and change a system track sector. (SuperZap - "Absolute Sector",
- PATCH18 - "Record")
-
- Fire up your disk editor, and look at the keytables. (For SuperZap you
- want absolute sectors 61 and 62, for PATCH it's track 1, physical sector 21)
- Here's what you'll see with SuperZap on two seperate screens: (PROBE puts
- both sectors on one screen)
-
- Sector 00061 of 03200 A: Trk=001 Sct=021
- TPA Load = 0000
-
- 0 1 2 3 4 5 6 7 8 9 A B C D E F
- 0000 C3 A9 F6 C3 1E F7 C3 85 F7 C3 AA F7 C3 06 F8 C3 ................
- 0010 1F F8 C3 1A F8 C3 15 F8 C3 64 F8 C3 68 F8 C3 6C .........d..h..l
- 0020 F8 C3 70 F8 C3 74 F8 C3 78 F8 C3 82 F8 C3 3A F8 ..p..t..x.....:.
- 0030 C3 94 F8 81 00 0B 0A 08 0C 30 31 32 33 34 35 36 .........0123456
- 0040 37 38 39 2D 2C 2E 00 05 05 2C 09 0E 18 04 44 03 789-,....,....D.
- 0050 E1 05 E8 01 00 09 06 18 04 44 03 E1 05 E8 01 00 .........D......
- 0060 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
- 0070 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
-
-
- Sector 00061 of 03200 A: Trk=001 Sct=021
- TPA Load = 0000
-
- 0 1 2 3 4 5 6 7 8 9 A B C D E F
- 0000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
- 0010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
- 0020 00 43 61 74 73 00 00 00 00 CD 60 F8 AF 32 04 00 .Cats.....'..2..
- 0030 3A 33 F6 32 03 00 21 4A F6 46 23 4E 23 ED B3 7E :3.2..!J.F#N#..~
- 0040 B7 20 F6 3A 47 F6 D3 00 3A 48 F6 D3 08 CD BB F8 . .:G...:H......
- 0050 1A 0D 0A 4B 41 59 50 52 4F 20 36 33 4B 20 43 50 ...KAYPRO 63K CP
- 0060 2F 4D 20 56 65 72 73 69 6F 6E 20 32 2E 32 46 0D /M Version 2.2F.
- 0070 0A 00 21 00 80 22 4B F9 3E C3 21 03 F6 32 00 00 ..!.."K.>.!..2..
-
- Looks familiar, doesn't it? The "Cats" patch to the "ENTER" key is the
- same as the image we saw in the BIOS.
-
- Since the keypad values are in RAM, a program can alter them for a
- particular application. For an example of this, see WSKEYPAD.ASM (for 8080)
- and WSKEYPAD.AZM (for Z80). These overlays patch the WordStar 4.0 .COM file
- to redefine the keypad when WS4 is run, and restore them to their original
- value when exiting WS4.
-
- I hope this little discussion has answered your questions on the Kaypro
- keypad. If you have further questions, I can be reached on CompuServe in the
- CP/M and Computer Club Forums at User I.D. 71370,2635.
-
-
- NOTES ON UTILITIES - These programs can be found on most RCP/M systems
- and information systems with CP/M SIGs. Letters in parentheses show where
- they can be found on CompuServe. (C - CP/M Forum Lib 2, K - Computer Club
- Forum Lib 15)
-
- PROBE - Shows the addresses of important locations in your installation
- of CP/M. Look for PROBE.LBR (C) or PROB12.BIN & PROB12.DOC (K).
-
- SuperZap - Commercial disk editor, now freeware. Look for SPZ35.COM
- & SPZ25.DOC (K).
-
- PATCH - Versatile disk and memory editor. Look for PATC18.LBR (C) or
- PAT18A.BIN & PAT18A.DOC (K).
-
-
- - Dale H. Cook
- July 3, 1989