etherforth_logo

Node 012

This node processes numeric keys 1-0, punctuation keys, and function keys F1-F10. Shift key bits are used here.

Source code

usb node 011 node 013 node 012
012 chars
chrs 00 3F009 0 , 27040 !1 , 26081 @2 , 2C0C2 hash3 , 3F103 4 ,
3F144 5 , 3F185 6 , 3F1C6 7 , 24207 *8 , 3F248 9 , 3FB4F - ,
2FFD0 + , 3FA95 ; , 3FAD6 ' , 3FA58 , , 3FA19 . , 2E95A ?/ ,

!? 11 n io a! @ 1000 lr and if ; then drop !b ;
mask 17 cm-cmf over over 3F and or ;
chr? 1A scm-sc mask if drop drop ;
then drop push drop 22 and if pop 11 else pop 5 then
for 2/ unext 3F and dup 3F or if drop !? then ahead *
seek 2C dup dup or 'chrs a! 16 for @+ chr? next
fn 31 -28 . + -if else 30000 or !? then then *
go 38 right a! @ @ dup 8000 and if or seek ;
then drop !? go ; 40

init right a! left b! go ; 44

6 d 3 r 0 ether

Definitions

chrs
Table of printable keys. Lowest six bits are used as table index, corresponding to scan code. Middle six bits are non-shifted key, and top six bits are shifted key etherforth character codes. Empty bits in character codes are set to one (3F).
!?
One symbol buffer. If node 011 reads LEFT port, send symbol n. Otherwise ignore it and return.
mask
Expect keyboard scan code in S and a mask from chrs table in T. Keep the stack and return flag in T. If scan code not found return true, else zero.
chr?
Expect control byte, key scan code, and mask on stack. Call mask to check if we have the right one. If not, drop flag and mask and return. Else, keep key code in R, test for SHIFT keys, and right-shift key code and mask low six bits to get etherforth character code. If the result is 3F then no valid symbol found, drop the result and return. If a valid symbol code found, send it with !? out and jump ahead to go.
seek
Start with the address of the chrs table (zero) and scan all items in table with chr?. If we find a valid symbol corresponding to the combination of control byte and key scan code we send it out (from chr?) and jump ahead to go. Else we fall through to
fn
Adjust the key scan code by subtracting 27. If the result is negative or zero, discard this data and fall through to go. Else set bit 17 to indicate a function key and send the result out with !?.
go
Check if the two words received from node 013 are to be processed here (the second word has bit 15 high) or not. If so, jump to seek, else send the first word (a valid symbol) to node 011 with !?.
init
Set A and B, and jump to go.

Description

This node processes key scan codes not recognized by node 013. It takes care of numeric keys 1-0, punctuation keys, and function keys F1-F10. To this end this node also considers SHIFT key bits. Character codes are looked for in chrs table.

This node also implements a one-character buffer. If node 011 is not ready to read a character when the buffer is full and another character has been decoded, the buffer is flushed and filled with the latest character. It assures that USB controller can run independently of the rest of the system.