sourcelibs/Hex1000/demos/keys.xtl

1⍝!/usr/bin/env xetal 2⍝ HEX1000 reading keys: a program that waits for a key on K, stores it 3⍝ in the next RAM word, and waits for the key to be released. The keys 4⍝ C, A, F, E (K 12, 10, 15, 14) are pressed in turn, each held for 8 5⍝ instructions with 9 instructions of no key (K 0) between, and RAM 6⍝ file 0 ends up holding 12 10 15 14. K 0 means no key, so a key whose 7⍝ code is 0 cannot be read this way; the calculator's keyboard is a 8⍝ matrix scanned through the R latches (docs/machine.md, Keys). 9⍝ Run with "just demo-lib Hex1000 keys". 10ʰˣ⁼u̲se< "Hex1000" 11scan ← ʰˣa̲ssemble "wait: KNEZ ; S: a key is down\nBR got\nBR wait\ngot: TKA ; the key into A\nTAMIY ; into RAM, Y + 1\nup: KNEZ ; wait for the release\nBR up\nBR wait" 120 ʰˣl̲isting scan 13presses ← 8 2 r̲eshape 12 8 0 9 10 8 0 9 15 8 0 9 14 8 0 9 14"K held" ʰˣt̲able presses 15after ← scan ʰˣr̲unKeys (ʰˣReset, presses) 16ʰˣRegNames ʰˣt̲able ʰˣr̲egs after 17"w0 w1 w2 w3 w4 w5 w6 w7" ʰˣt̲able 8 t̲ake f̲irst ʰˣr̲am after