diff --git a/blk/263 b/blk/263 index 370a121..dbaf796 100644 --- a/blk/263 +++ b/blk/263 @@ -4,6 +4,7 @@ VARIABLE XCURRENT : XCOFF 0x02 RAM+ CURRENT* ! ; : (xentry) XCON (entry) XCOFF ; +: XCREATE (xentry) 11 C, ; : XCODE XCON CODE XCOFF ; diff --git a/blk/312 b/blk/312 index 554a599..b2db2ee 100644 --- a/blk/312 +++ b/blk/312 @@ -5,4 +5,11 @@ CODE 2DROP chkPS, ;CODE +( a b -- a b a b ) +CODE 2DUP + HL POPqq, ( b ) DE POPqq, ( a ) + chkPS, + DE PUSHqq, HL PUSHqq, + DE PUSHqq, HL PUSHqq, +;CODE diff --git a/blk/433 b/blk/433 index 27bbd0a..a6690f1 100644 --- a/blk/433 +++ b/blk/433 @@ -7,7 +7,6 @@ SWAP DROP ; -: 2DUP OVER OVER ; : 2OVER 3 PICK 3 PICK ; : 2SWAP 3 ROLL 3 ROLL ; diff --git a/blk/550 b/blk/550 index 1792232..5820af0 100644 --- a/blk/550 +++ b/blk/550 @@ -3,4 +3,4 @@ TI-84+ Recipe Support code for the TI-84+ recipe. Contains drivers for the keyboard and LCD. -551 LCD +551 LCD 564 Keyboard diff --git a/blk/564 b/blk/564 new file mode 100644 index 0000000..477d9db --- /dev/null +++ b/blk/564 @@ -0,0 +1,16 @@ +Keyboard driver + +Low layer range: 566-568 + +Implement a (key) word that interpret keystrokes from the +builtin keyboard. The word waits for a digit to be pressed and +returns the corresponding ASCII value. + +This routine waits for a key to be pressed, but before that, it +waits for all keys to be de-pressed. It does that to ensure +that two calls to _wait only go through after two actual key +presses (otherwise, the user doesn't have enough time to +de-press the button before the next _wait routine registers the +same key press as a second one). + + (cont.) diff --git a/blk/565 b/blk/565 new file mode 100644 index 0000000..7d47d12 --- /dev/null +++ b/blk/565 @@ -0,0 +1,6 @@ +Sending 0xff to the port resets the keyboard, and then we have +to send groups we want to "listen" to, with a 0 in the group +bit. Thus, to know if *any* key is pressed, we send 0xff to +reset the keypad, then 0x00 to select all groups, if the result +isn't 0xff, at least one key is pressed. + diff --git a/blk/566 b/blk/566 new file mode 100644 index 0000000..2ea1d19 --- /dev/null +++ b/blk/566 @@ -0,0 +1,14 @@ +( Requires KBD_MEM, KBD_PORT ) +( gm -- pm, get pressed keys mask for group mask gm ) +CODE _get + HL POPqq, + chkPS, + DI, + A 0xff LDrn, + KBD_PORT OUTnA, + A L LDrr, + KBD_PORT OUTnA, + KBD_PORT INAn, + EI, + L A LDrr, HL PUSHqq, +;CODE diff --git a/blk/567 b/blk/567 new file mode 100644 index 0000000..9010624 --- /dev/null +++ b/blk/567 @@ -0,0 +1,16 @@ +( wait until all keys are de-pressed. To avoid repeat keys, we + require 64 subsequent polls to indicate all depressed keys. + all keys are considered depressed when the 0 group returns + 0xff. ) +: _wait 64 0 DO 0 _get 0xff = UNTIL ; + +( digits table. seach row represents a group. 0 means + unsupported. no group 7 because it has no key. ) +CREATE _dtbl + 0 C, 0 C, 0 C, 0 C, 0 C, 0 C, 0 C, 0 C, + 0xd C, '+' C, '-' C, '*' C, '/' C, '^' C, 0 C, 0 C, + 0 C, '3' C, '6' C, '9' C, ')' C, 0 C, 0 C, 0 C, + '.' C, '2' C, '5' C, '8' C, '(' C, 0 C, 0 C, 0 C, + '0' C, '1' C, '4' C, '7' C, ',' C, 0 C, 0 C, 0 C, + 0 C, 0 C, 0 C, 0 C, 0 C, 0 C, 0 C, 0x80 ( alpha ) C, + 0 C, 0 C, 0 C, 0 C, 0 C, 0x81 ( 2nd ) C, 0 C, 0x7f C, diff --git a/blk/568 b/blk/568 new file mode 100644 index 0000000..919b672 --- /dev/null +++ b/blk/568 @@ -0,0 +1,9 @@ +( alpha table. same as _dtbl, for when we're in alpha mode. ) +CREATE _atbl + 0 C, 0 C, 0 C, 0 C, 0 C, 0 C, 0 C, 0 C, + 0xd C, '"' C, 'w' C, 'r' C, 'm' C, 'h' C, 0 C, 0 C, + '?' C, 0 C, 'v' C, 'q' C, 'l' C, 'g' C, 0 C, 0 C, + ':' C, 'z' C, 'u' C, 'p' C, 'k' C, 'f' C, 'c' C, 0 C, + 0x20 C, 'y' C, 't' C, 'o' C, 'j' C, 'e' C, 'b' C, 0 C, + 0 C, 'x' C, 's' C, 'n' C, 'i' C, 'd' C, 'a' C, 0x80 C, + 0 C, 0 C, 0 C, 0 C, 0 C, 0x81 ( 2nd ) C, 0 C, 0x7f C, diff --git a/blk/569 b/blk/569 new file mode 100644 index 0000000..572fcd7 --- /dev/null +++ b/blk/569 @@ -0,0 +1,13 @@ +: (key) + 0 ( gid ) 0 ( dummy ) + BEGIN ( loop until a digit is pressed ) + DROP + 1+ DUP 7 = IF DROP 0 THEN ( inc gid ) + 1 OVER LSHIFT 0xff -^ ( group dmask ) _get + DUP 0xff = NOT UNTIL + ( gid dmask ) + 0xff XOR ( dpos ) 0 ( dindex ) + BEGIN 2DUP RSHIFT IF 1+ 1 ELSE 0 THEN UNTIL + ( gid dpos dindex ) SWAP DROP + ( gid dindex ) SWAP 8 * + _dtbl + C@ +; diff --git a/emul/forth.bin b/emul/forth.bin index 92c9af8..ec04e62 100644 Binary files a/emul/forth.bin and b/emul/forth.bin differ diff --git a/recipes/ti84/xcomp.fs b/recipes/ti84/xcomp.fs index a8533c5..5e05ec0 100644 --- a/recipes/ti84/xcomp.fs +++ b/recipes/ti84/xcomp.fs @@ -1,27 +1,30 @@ 0x8000 CONSTANT RAMSTART 0xb000 CONSTANT RS_ADDR RAMSTART 0x70 + CONSTANT LCD_MEM +0x01 CONSTANT KBD_PORT 212 LOAD ( z80 assembler ) 262 LOAD ( xcomp ) 522 LOAD ( font compiler ) : CODE XCODE ; : IMMEDIATE XIMM ; : (entry) (xentry) ; +: CREATE XCREATE ; ( for KBD tbls ) : : [ ' X: , ] ; CURRENT @ XCURRENT ! 282 LOAD ( boot.z80 ) 393 LOAD ( icore low ) -555 557 LOADR ( ti low ) +555 557 LOADR ( LCD low ) +566 569 LOADR ( KBD low ) 415 LOAD ( icore high ) (entry) ~FNT CPFNT3x5 (entry) _ ( Update LATEST ) PC ORG @ 8 + ! 422 437 XPACKR ( core ) -558 560 XPACKR ( ti high ) +558 560 XPACKR ( LCD high ) 438 446 XPACKR ( print fmt ) -," : _ LCD$ LIT< Hello (print) LIT< World! (print) BYE ; _ " +," : _ LCD$ LIT< Hello (print) (key) (emit) BYE ; _ " ORG @ 256 /MOD 2 PC! 2 PC! H@ 256 /MOD 2 PC! 2 PC!