From a58b0f1133b2f1bb01312a3358df169a0f79041f Mon Sep 17 00:00:00 2001 From: d6 Date: Mon, 23 Jan 2023 20:22:59 -0500 Subject: [PATCH] arrow keys --- term.tal | 38 ++++++++++++++++++++++++++++---------- 1 file changed, 28 insertions(+), 10 deletions(-) diff --git a/term.tal b/term.tal index 1577e9d..50c0cff 100644 --- a/term.tal +++ b/term.tal @@ -22,17 +22,18 @@ |00 @System [ &vect $2 &pad $6 &r $2 &g $2 &b $2 ] |10 @Console [ &vect $2 &r $1 &pad $5 &w $1 ] |20 @Screen [ &vect $2 &w $2 &h $2 &auto $1 &pad $1 &x $2 &y $2 &addr $2 &pixel $1 &sprite $1 ] -|80 @Controller [ &vect $2 &button $1 &key $1 ] +|80 @Controller [ &vect $2 &button $1 &key $1 &fn $1 ] |0000 - @tint $1 ( draw mode. 01=regular, 04=inverted ) - @dirty? $1 ( screen needs redraw? ) - @rows $2 ( height in characters ) - @cols $2 ( width in characters ) - @cur-x $2 ( cursor x: 0 <= cur-x < cols ) - @cur-y $2 ( cursor y: 0 <= cur-y < rows ) - @max-x $2 ( cols-1 ) - @max-y $2 ( rows-1 ) + @tint $1 ( draw mode. 01=regular, 04=inverted ) + @dirty? $1 ( screen needs redraw? ) + @lastkey $1 ( last button press ) + @rows $2 ( height in characters ) + @cols $2 ( width in characters ) + @cur-x $2 ( cursor x: 0 <= cur-x < cols ) + @cur-y $2 ( cursor y: 0 <= cur-y < rows ) + @max-x $2 ( cols-1 ) + @max-y $2 ( rows-1 ) |0100 ( 80 cols x 24 rows ) @@ -46,6 +47,9 @@ ( set initial cursor ) #0000 .cur-x STZ2 #0000 .cur-y STZ2 + + ( confirm no buttons pressed yet ) + #00 .lastkey STZ ( set screen height/width based on rows/cols ) .rows LDZ2 #30 SFT2 .Screen/h DEO2 @@ -140,8 +144,22 @@ .cur-y LDZ2 .cols LDZ2 MUL2 .cur-x LDZ2 ADD2 ;screen ADD2 LDA ;draw-tile JMP2 +@on-button ( -> ) + .lastkey LDZ .Controller/button DEI STHk EOR STHr AND ( new-buttons ) + DUP #10 AND #00 EQU ,&no-n JCN LIT "A ,arrow JSR + &no-n DUP #20 AND #00 EQU ,&no-s JCN LIT "B ,arrow JSR + &no-s DUP #40 AND #00 EQU ,&no-w JCN LIT "D ,arrow JSR + &no-w DUP #80 AND #00 EQU ,&no-e JCN LIT "C ,arrow JSR + &no-e .Controller/button DEI .lastkey STZ BRK + +( send ESC [ $c ) +@arrow ( c^ -> ) + .Console/w STH + #1b STHkr DEO LIT "[ STHkr DEO STHr DEO + JMP2r + @on-key ( -> ) - .Controller/key DEI ,&ok JCN BRK + .Controller/key DEI ,&ok JCN ,on-button JMP &ok ,alt? JSR ,on-alt-key JCN ,ctrl? JSR ,on-ctrl-key JCN .Controller/key DEI .Console/w DEO BRK