^10 - The Keyboard (Button) Port

This port is a read only value of the last button action on a user interface.
It only reports the last change as either a press or release.
The value is a bitfield with the MSB (bit 8) as the state and the first 7 bits as the button number.
MSB cleared indicates the button is pressed. MSB set indicates the button is released. Therefore button 1 release is 0x81, button 11 release is 0x8b etc.

This only reports the last button action. Unlike the DIP Switch Port it does not report the current state of all buttons.

Syntax

LDA ^10,x
Where x is the bank of up to 16 buttons you want the status of.
LDA ^10,0 will give the last transition of buttons 1-16.
LDA ^10,1 will give the last transition of buttons 17-32.

^10 Keyboard port responses

Button Number

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

Press Value

0x01

0x02

0x03

0x04

0x05

0x06

0x07

0x08

0x09

0x0a

0x0b

0x0c

0x0d

0x0e

0x0f

0x10

Release Value

0x81

0x82

0x83

0x84

0x85

0x86

0x87

0x88

0x89

0x8a

0x8b

0x8c

0x8d

0x8e

0x8f

0x90

This port will not record a two button press. It will only report the latest button action. You would need to rapidly check the port twice and have your task recognize that there were two back to back press events without a release event.

Examples

Example showing one task managing multiple buttons.

Task1()
{
// One Task can handle many buttons:
LDA ^10,0      // Get the keyboard port
CMP #0x01      // Was it a button 1 push?
BRZ B1PRESS    // Yes, go do button 1 press stuff
CMP #0x81      // Was it a button 1 release?
BRZ B1RELEASE  // Yes, go do button 1 release stuff
CMP #0x02      // Was it a button 2 push?
BRZ B2PRESS    // Yes, go do button 2 press stuff
NULL           // Not a combination we are interested in, so end Task
...
}