control characters work now

This commit is contained in:
~d6 2023-01-22 15:55:52 -05:00
parent 7757e71409
commit 927aece263
1 changed files with 30 additions and 16 deletions

View File

@ -5,8 +5,6 @@
|0000
@tint $1 ( draw mode. 01=regular, 04=inverted )
@pos $1 ( cur buffer position )
@max $1 ( max buffer position )
@dirty? $1 ( screen needs redraw? )
@rows $2 ( height in characters )
@ -14,8 +12,6 @@
@cur-x $2 ( cursor x: 0 <= cur-x < cols )
@cur-y $2 ( cursor y: 0 <= cur-y < rows )
@buffer $c8 ( input buffer, 200 bytes )
|0100
( 80 cols x 24 rows )
#0028 .rows STZ2
@ -30,10 +26,6 @@
#0c88 .System/g DEO2
#0c0f .System/b DEO2
( set pos )
.buffer .pos STZ
.buffer .max STZ
( clear screen for initial draw )
;clear-screen JSR2
@ -97,15 +89,38 @@
.cur-y LDZ2 .cols LDZ2 MUL2 .cur-x LDZ2 ADD2 ;screen ADD2 LDA
;draw-tile JMP2
@on-key
.Controller/key DEI #00 EQU ,&skip JCN
.Controller/key DEI .Console/w DEO &skip BRK
@on-key ( -> )
.Controller/key DEI ,&ok JCN BRK
&ok ,alt? JSR ,on-alt-key JCN
,ctrl? JSR ,on-ctrl-key JCN
.Controller/key DEI .Console/w DEO BRK
@ctrl? ( -> down? ) .Controller/button DEI #01 AND JMP2r
@alt? ( -> down? ) .Controller/button DEI #02 AND JMP2r
( alt-XYZ emits ESC and then emits XYZ )
@on-alt-key ( -> )
#1b .Console/w DEO
,ctrl? JSR ,on-ctrl-key JCN
.Controller/key DEI .Console/w DEO BRK
( ctrl-$n emits: )
( 0 <= $n < @ -> $n )
( @ <= $n < ` -> $n #40 SUB )
( ` <= $n <= #ff -> $n #60 SUB )
@on-ctrl-key ( -> )
.Controller/key DEI
DUP LIT "@ LTH ,&done JCN
DUP LIT "` LTH ,&c1 JCN
LIT "` SUB ,&done JMP
&c1 LIT "@ SUB
&done .Console/w DEO BRK
@on-input
.Console/r DEI #00 EQU ,&skip JCN
#41 .tint STZ
.Console/r DEI ;read JSR2
&skip BRK
.Console/r DEI
DUP ,&ok JCN POP BRK
&ok #41 .tint STZ
;read JSR2 BRK
@read ( byte^ -> )
DUP #07 EQU ;read-bel JCN2
@ -156,7 +171,6 @@
POP2 POP JMP2r
&continue ( addr^ value* )
;hide-cursor JSR2
.pos LDZ #01 SUB .pos STZ
.cur-x LDZ2 #0001 SUB2 .cur-x STZ2
;show-cursor JMP2