INT 16h - Zoomer keypad interface

The Zoomer's directional keypad and A/B buttons are accessed by the BIOS interrupt number 16 (22 decimal), which corresponds to the keyboard interface in desktop PCs.

The "keyboard" state may be checked by means of polling or by installing a routine (similar to an interrupt handler) to be called whenever a button is pushed or the keypad is moved in a different direction.

Please note: Except where specified otherwise, all numeric values are given in hexadecimal.

Int 16 Functions
AX BH Description
5001 00 Purpose unknown (Initialization?)
5001 01 Purpose unknown
5002 Read keypad state
5003 00 Get keyboard handler address
5003 01 Set keyboard handler address

Click on a specific function description in the above table to jump to its detailed description immediately. Other information available on this subject:

Other information
Keypad Flags Byte
Example program (assembly language)



Function 5001H, BH=00 -- Purpose unknown

Parameters
Register Contents
AX 5001
BH 00
Returns
BX 0001

The purpose of this call is not yet known. It seems to be the first call made to the keyboard interface, prior to reading and setting the keyboard interrupt handler address.

It may be an initialization call, similar to the INT 33/AX=0 call to the mouse driver in desktop PCs.





Function 5001H, BH=01 -- Purpose unknown

Parameters
Register Contents
AX 5001
BH 01
Returns
BX ????

The purpose of this call is not yet known. It seems to be the final call made to the keyboard interface, prior to reading and setting the keyboard interrupt handler address. Before calling INT 16, BL is set to 01 as well.





Function 5002H -- Read keypad state

Parameters
Register Contents
AX 5002
Returns
AL Keypad flags byte (see below)

This function returns the state of the directional keypad and the A/B buttons, and returns a bitmapped flag byte in the AL register. AH is always set to 01.

Due to the physical construction of the directional keypad, diametrically opposing bits cannot be set (e.g., the UP flag will not be set at the same time as the DOWN flag).


Keypad flags byte

Bit Numbers Description
7 6 5 4 3 2 1 0
X X               C0 - Unused
    X             20 - Keypad Right
      X           10 - Keypad Down
        X         08 - Keypad Left
          X       04 - Keypad Up
            X     02 - "A" Button
              X   01 - "B" Button




Function 5003, BH=00 -- Get keyboard handler address

Parameters
Register Contents
AX 5003
BH 00
Returns
CX Offset of current handler
DX Segment of current handler

This function returns the address of the current keyboard handler. This handler is called whenever a button is pressed or released, or whenever the directional keypad is moved in a different direction (or returned to its center position).

See the next section for information about the keyboard handler.




Function 5003, BH=01 -- Set keyboard handler address

Parameters
Register Contents
AX 5003
BH 00
CX Offset of new handler
DX Segment of new handler
Returns
Nothing

This function installs a new keyboard handler. This handler is called whenever a button is pressed or released, or whenever the directional keypad is moved in a different direction (or returned to its center position).

Upon entry, the routine receives the new value of the keypad state in the AL register, and the previous state in the AH register. (See the table named "Keypad Flags Byte" for an explanation of the key flags.)

When the routine is called, the value of the Data and Extra segments is undefined. The handler routine should save the values of these registers, as well as any other registers which it uses, and restore them before exiting.

The routine must be a FAR procedure, and exit with a far return.


Send questions, comments, suggestions, more information, or errors to Jeff Lee at <godfrey@shipbrook.net>.