Difference between revisions of "83Plus:Ports:01"

From WikiTI
Jump to: navigation, search
 
Line 1: Line 1:
wooot... new page new page new page
+
== Synopsis ==
SHOUT OUT TO CALCKING!!!!!
+
'''Port Number:''' 01h
  
0x40 to the rescue!!!!
+
'''Function:''' Keyboard Port
 +
 
 +
This port controls the on-calc keypad. The keypad is divided into a series of groups.
 +
 
 +
=== Read Values ===
 +
* Bits are set according whether corresponding keys from selected groups are pressed. Groups are selected through writing to the port. A pressed key reads a 0 bit. An unpressed key reads a 1 bit. The port reads FF after a reset (write FF).
 +
 
 +
=== Write Values ===
 +
* $FF : Reset the keypad. This unselects all groups and resets the keypad state.
 +
* Anything else : Any 0 bit adds the corresponding group to the list of monitored groups. When a key in a monitored group is pressed, the corresponding key bit reads 1.
 +
 
 +
== Comments ==
 +
The key map is laid out as follows:
 +
 
 +
<nowiki>    Group Bit ->    0    1    2    3    4    5    6    7
 +
              Group Mask ->  FE    FD    FB    F7    EF    DF    BF    7F
 +
Key Bit (Mask)
 +
0 (FE)                    | DOWN|ENTER| (-) |  .  |  0  |    |GRAPH|    |
 +
1 (FD)                    | LEFT|  +  |  3  |  2  |  1  | STO |TRACE|    |
 +
2 (FB)                    |RIGHT|  -  |  6  |  5  |  4  | LN  |ZOOM |    |
 +
3 (F7)                    | UP  |  *  |  9  |  8  |  7  | LOG |WIND |    |
 +
4 (EF)                    |    |  /  |  )  |  (  |  ,  | x^2 | Y=  |    |
 +
5 (DF)                    |    |  ^  | TAN | COS | SIN |x^-1 | 2nd |    |
 +
6 (BF)                    |    |CLEAR|VARS |PRGM |APPS |MATH |MODE |    |
 +
7 (7F)                    |    |    |    |STAT |X,T..|ALPHA| DEL |    |
 +
 
 +
NOTE: Group FB Key FE is NEGATE, not to be confused SUBTRACT.
 +
NOTE: Group DF Key FE could be ON, but the ON key is tested elsewhere (a "special case" key - after all, it is the ON key).
 +
 
 +
== Example ==
 +
<nowiki>ld a, 0FFh ;Reset the keypad.
 +
out (1), a
 +
ld a, 0FEh ;Select group 0.
 +
out (1), a
 +
in a, (1) ;Test for keys.
 +
and 0FDh ;Test for Left Arrow key. Basically set all other bits to 0. This means A becomes 0 if left was pressed.
 +
call z, LeftArrowPressed ;If A==0 then Left Arrow bit was reset, meaning it was pressed.
 +
ld a, 0FFh ;Reset the keypad.
 +
out (1), a</nowiki>
 +
 
 +
== Credits and Contributions ==
 +
* '''/dev/console:''' For letting me type all this.

Revision as of 21:52, 26 March 2005

Synopsis

Port Number: 01h

Function: Keyboard Port

This port controls the on-calc keypad. The keypad is divided into a series of groups.

Read Values

  • Bits are set according whether corresponding keys from selected groups are pressed. Groups are selected through writing to the port. A pressed key reads a 0 bit. An unpressed key reads a 1 bit. The port reads FF after a reset (write FF).

Write Values

  • $FF : Reset the keypad. This unselects all groups and resets the keypad state.
  • Anything else : Any 0 bit adds the corresponding group to the list of monitored groups. When a key in a monitored group is pressed, the corresponding key bit reads 1.

Comments

The key map is laid out as follows:

     Group Bit ->     0     1     2     3     4     5     6     7
              Group Mask ->   FE    FD    FB    F7    EF    DF    BF    7F
Key Bit (Mask)
0 (FE)                    | DOWN|ENTER| (-) |  .  |  0  |     |GRAPH|     |
1 (FD)                    | LEFT|  +  |  3  |  2  |  1  | STO |TRACE|     |
2 (FB)                    |RIGHT|  -  |  6  |  5  |  4  | LN  |ZOOM |     |
3 (F7)                    | UP  |  *  |  9  |  8  |  7  | LOG |WIND |     |
4 (EF)                    |     |  /  |  )  |  (  |  ,  | x^2 | Y=  |     |
5 (DF)                    |     |  ^  | TAN | COS | SIN |x^-1 | 2nd |     |
6 (BF)                    |     |CLEAR|VARS |PRGM |APPS |MATH |MODE |     |
7 (7F)                    |     |     |     |STAT |X,T..|ALPHA| DEL |     |

NOTE: Group FB Key FE is NEGATE, not to be confused SUBTRACT.
NOTE: Group DF Key FE could be ON, but the ON key is tested elsewhere (a "special case" key - after all, it is the ON key).

== Example ==
 <nowiki>ld a, 0FFh ;Reset the keypad.
out (1), a
ld a, 0FEh ;Select group 0.
out (1), a
in a, (1) ;Test for keys.
and 0FDh ;Test for Left Arrow key. Basically set all other bits to 0. This means A becomes 0 if left was pressed.
call z, LeftArrowPressed ;If A==0 then Left Arrow bit was reset, meaning it was pressed.
ld a, 0FFh ;Reset the keypad.
out (1), a

Credits and Contributions

  • /dev/console: For letting me type all this.