From b874a1c175385153278e556f85bd7172b1d42b01 Mon Sep 17 00:00:00 2001 From: Virgil Dupras Date: Wed, 20 May 2020 18:56:18 -0400 Subject: [PATCH] ps2: wip --- blk/001 | 1 + blk/410 | 11 +++++++++++ blk/411 | 14 ++++++++++++++ blk/412 | 11 +++++++++++ blk/413 | 12 ++++++++++++ 5 files changed, 49 insertions(+) create mode 100644 blk/410 create mode 100644 blk/411 create mode 100644 blk/412 create mode 100644 blk/413 diff --git a/blk/001 b/blk/001 index a3fa89b..8075f1d 100644 --- a/blk/001 +++ b/blk/001 @@ -6,6 +6,7 @@ MASTER INDEX 150 Extra words 200 Z80 assembler 260 Cross compilation 280 Z80 boot code 350 Core words +410 PS/2 keyboard subsystem 490 TRS-80 Recipe 520 Fonts 550 TI-84+ Recipe 580 RC2014 Recipe 620 Sega Master System Recipe diff --git a/blk/410 b/blk/410 new file mode 100644 index 0000000..0496601 --- /dev/null +++ b/blk/410 @@ -0,0 +1,11 @@ +PS/2 keyboard subsystem + +Provides (key) from a driver providing (ps2kc). That is, for a +driver taking care of providing all key codes emanating from a +PS/2 keyboard, this subsystem takes care of mapping those key- +strokes to ASCII characters. This code is designed to be cross- +compiled and loaded with drivers. + +Requires PS2_MEM to be defined. + +Load range: 411-414 diff --git a/blk/411 b/blk/411 new file mode 100644 index 0000000..fc73841 --- /dev/null +++ b/blk/411 @@ -0,0 +1,14 @@ +: PS2_SHIFT [ PS2_MEM LITN ] ; +: PS2$ 0 PS2_SHIFT C! ; + +( A list of the values associated with the 0x80 possible scan +codes of the set 2 of the PS/2 keyboard specs. 0 means no +value. That value is a character that can be read in (key) +No make code in the PS/2 set 2 reaches 0x80. ) +CREATE PS2_CODES +( 00 ) 0 C, 0 C, 0 C, 0 C, 0 C, 0 C, 0 C, 0 C, +( 08 ) 0 C, 0 C, 0 C, 0 C, 0 C, 9 C, '`' C, 0 C, +( 10 ) 0 C, 0 C, 0 C, 0 C, 0 C, 'q' C, '1' C, 0 C, +( 18 ) 0 C, 0 C, 'z' C, 's' C, 'a' C, 'w' C, '2' C, 0 C, +( 20 ) 0 C, 'c' C, 'x' C, 'd' C, 'e' C, '4' C, '3' C, 0 C, +( 28 ) 0 C, 32 C, 'v' C, 'f' C, 't' C, 'r' C, '5' C, 0 C, diff --git a/blk/412 b/blk/412 new file mode 100644 index 0000000..a728e7a --- /dev/null +++ b/blk/412 @@ -0,0 +1,11 @@ +( 30 ) 0 C, 'n' C, 'b' C, 'h' C, 'g' C, 'y' C, '6' C, 0 C, +( 38 ) 0 C, 0 C, 'm' C, 'j' C, 'u' C, '7' C, '8' C, 0 C, +( 40 ) 0 C, ',' C, 'k' C, 'i' C, 'o' C, '0' C, '9' C, 0 C, +( 48 ) 0 C, '.' C, '/' C, 'l' C, ';' C, 'p' C, '-' C, 0 C, +( 50 ) 0 C, 0 C, ''' C, 0 C, '[' C, '=' C, 0 C, 0 C, +( 58 ) 0 C, 0 C, 13 C, ']' C, 0 C, '\' C, 0 C, 0 C, +( 60 ) 0 C, 0 C, 0 C, 0 C, 0 C, 0 C, 8 C, 0 C, +( 68 ) 0 C, '1' C, 0 C, '4' C, '7' C, 0 C, 0 C, 0 C, +( 70 ) '0' C, '.' C, '2' C, '5' C, '6' C, '8' C, 27 C, 0 C, +( 78 ) 0 C, 0 C, '3' C, 0 C, 0 C, '9' C, 0 C, 0 C, +: _shift? ( kc -- f ) DUP 0x12 = SWAP 0x59 = OR ; diff --git a/blk/413 b/blk/413 new file mode 100644 index 0000000..d695bf5 --- /dev/null +++ b/blk/413 @@ -0,0 +1,12 @@ +: (key) 0 ( dummy ) BEGIN DROP (ps2kc) DUP UNTIL ( kc ) + DUP 0xe0 ( extended ) = IF ( ignore ) DROP (key) EXIT THEN + DUP 0xf0 ( break ) = IF DROP ( ) + ( get next key and see if it's a shift ) + (key) _shift? IF ( drop shift ) 0 PS2_SHIFT ! THEN + ( whether we had a shift or not, we return the next ) + (key) EXIT THEN + DUP 0x7f > IF DROP (key) EXIT THEN + DUP _shift? IF DROP 1 PS2_SHIFT ! (key) EXIT THEN + ( ah, finally, we have a gentle run-of-the-mill KC ) + PS2_CODES + C@ DUP NOT IF DROP (key) EXIT THEN ; +