implement border and some more commands

This commit is contained in:
~d6 2023-02-17 23:58:48 -05:00
parent 3199955517
commit ff6b76ba04
1 changed files with 95 additions and 29 deletions

124
term.tal
View File

@ -133,25 +133,49 @@
#0018 .rows STZ2
#0050 .cols STZ2
( set initial cursor )
#0000 .cur-x STZ2
#0000 .cur-y STZ2
( start cursor at origin - including border )
#0010 ( border ) .Screen/x DEO2
#0010 ( border ) .Screen/y DEO2
( confirm no buttons pressed yet )
#00 .lastkey STZ
( set colors )
#07bf .System/r DEO2
#07bf .System/g DEO2
#07bf .System/b DEO2
( set up interrupts )
;redraw .Screen/vect DEO2 ( set up screen )
;on-key .Controller/vect DEO2 ( set up keyboard )
;on-mouse .Mouse/vect DEO2 ( set up mouse )
;on-read .Console/vect DEO2 ( set up stdin )
( load theme to override colors and maybe dimension )
load-theme
( these only work with a patched uxnemu )
( on other emulators they should be no-ops )
;shell .Console/exec DEO2 ( set up bash subprocess )
#80 .Console/mode DEO ( start bash subprocess )
( initialize terminal state and settings )
reset-terminal
( set to 01 to enable debug log )
#00 .debug STZ
.debug LDZ ?&continue BRK &continue
#99 #010e DEO
;debug-log .File1/name DEO2
#01 .File1/append DEO
BRK
@reset-terminal ( -> )
( set initial cursor )
#0000 .cur-x STZ2
#0000 .cur-y STZ2
( confirm no buttons pressed yet )
#00 .lastkey STZ
( calculate derived dimensions from cols/rows )
update-dimensions
@ -168,28 +192,12 @@
( clear screen for initial draw )
clear-screen
( set up interrupts )
;redraw .Screen/vect DEO2 ( set up screen )
;on-key .Controller/vect DEO2 ( set up keyboard )
;on-mouse .Mouse/vect DEO2 ( set up mouse )
;on-read .Console/vect DEO2 ( set up stdin )
( these only work with a patched uxnemu )
( on other emulators they should be no-ops )
;shell .Console/exec DEO2 ( set up bash subprocess )
#80 .Console/mode DEO ( start bash subprocess )
( user defaults )
#01 .visual-bell STZ
( set to 01 to enable debug log )
#00 .debug STZ
.debug LDZ ?&continue BRK &continue
#99 #010e DEO
;debug-log .File1/name DEO2
#01 .File1/append DEO
BRK
( draw border )
draw-border
JMP2r
@update-dimensions ( -> )
( set col-bytes, frequently needed )
@ -265,6 +273,36 @@
#40 .Screen/sprite DEO STH2r ( y* ; s/s<-40 )
.Screen/y DEO2 JMP2r ( ; s/y<-y )
@draw-border ( -> )
#0200 ;cp437 ADD2 .Screen/addr DEO2
#04 .Screen/sprite
#0000 draw-border/row
#0008 draw-border/row
.rows LDZ2 #000c MUL2 #0010 ADD2 draw-border/row
.rows LDZ2 #000c MUL2 #0018 ADD2 draw-border/row
#0000 draw-border/col
#0008 draw-border/col
.cols LDZ2 #0008 MUL2 #0010 ADD2 draw-border/col
.cols LDZ2 #0008 MUL2 #0018 ADD2 draw-border/col
#00 .Screen/auto DEO POP2 !screen-to-cursor
&row ( y* -> )
.Screen/y DEO2
#0000 .Screen/x DEO2
#01 .Screen/auto DEO
#0000 .cols LDZ2 #0004 ADD2 SUB2 STH2
!&loop
&col ( x* -> )
.Screen/x DEO2
#0000 .Screen/y DEO2
#02 .Screen/auto DEO
#0000 .rows LDZ2 #0003 MUL2 INC2 #0002 DIV2 #0004 ADD2 SUB2 STH2
!&loop
&loop ( 04 sprite^ [-count] )
DEOk INC2r STH2kr ORA ?&loop POP2r JMP2r
@redraw ( -> BRK )
.pointer-ttl LDZ #00 EQU ?&pointer-ok ( )
.pointer-ttl LDZk INC DUP ROT STZ ?&pointer-ok
@ -711,6 +749,7 @@
DUP LIT "L EQU ?exec-insert-lines ( insert blank lines )
DUP LIT "M EQU ?exec-delete-lines ( delete n lines )
DUP LIT "P EQU ?exec-delete-chars ( delete n chars )
DUP LIT "Z EQU ?exec-back-tabs ( backward by tab stops )
( ` - horizontal position absolute )
( S - scroll up n lines )
( X - erase n chars )
@ -778,6 +817,7 @@
@exec-delete-chars POP ;delete-n-chars !exec1
@exec-insert-lines POP ;insert-n-lines !exec1
@exec-forward-tabs POP ;forward-n-tabs !exec1
@exec-back-tabs POP ;back-n-tabs !exec1
@exec-erase-line ( c^ -> BRK )
POP #0000 read-arg-1
@ -854,8 +894,14 @@
@on-read-esc ( -> BRK )
.Console/r DEI
DUP debug-esc
DUP LIT "D EQU ?exec-ind
DUP LIT "E EQU ?exec-nel
DUP LIT "H EQU ?exec-hts
DUP LIT "M EQU ?exec-ri
DUP LIT "P EQU ?exec-dcs
DUP LIT "[ EQU ?start-csi
DUP LIT "] EQU ?start-osc
DUP LIT "c EQU ?exec-ris
DUP LIT "( EQU ?start-charset
DUP LIT ") EQU ?start-charset
DUP LIT "7 EQU ?&skip ( save cursor )
@ -865,6 +911,17 @@
!on-read
&skip POP ;on-read .Console/vect DEO2 BRK
@exec-ind ( c^ -> ) POP down BRK
@exec-nel ( c^ -> ) POP cr BRK
@exec-hts ( c^ -> ) POP BRK
@exec-ri ( c^ -> ) POP up BRK
@exec-dcs ( c^ -> ) POP BRK
@exec-st ( c^ -> ) POP BRK
@exec-ris ( c^ -> )
POP first-addr limit-addr erase
reset-terminal BRK
@on-read-skip ( -> BRK )
;on-read .Console/vect DEO2
BRK
@ -937,9 +994,12 @@
INC DUP ?&loop ( i+1^ )
POP BRK ( )
@cr ( -> )
clear-cursor #0000 .cur-x STZ2 !draw-cursor
@read-cr ( 0d -> BRK )
POP .cur-wrap LDZ ?&skip
clear-cursor #0000 .cur-x STZ2 draw-cursor
( clear-cursor #0000 .cur-x STZ2 draw-cursor ) cr
&skip BRK
@at-max-y ( -> true? )
@ -980,13 +1040,14 @@
&zero POP2 POP2 #0000
&done .cur-y STZ2 !draw-cursor
@up ( -> ) #0001 !up-n
@down-n ( n* -> )
clear-cursor
.cur-y LDZ2 ADD2 .max-y LDZ2 min .cur-y STZ2
!draw-cursor
@down ( -> )
#0001 !down-n
@down ( -> ) #0001 !down-n
@maybe-autowrap ( -> )
.cur-wrap LDZ #00 EQU ?&skip
@ -1017,6 +1078,11 @@
#0008 .cur-x LDZ2 #0007 AND2 SUB2 ( i* 8-cur%8* )
ADD2 !forward-n ( )
@back-n-tabs ( n* -> )
dec-floor #30 SFT2 ( i=(n-1)8* )
.cur-x LDZ2 #0007 AND2 ( i* cur%8* )
ADD2 !back-n ( )
@insert-n-lines ( n* -> )
.col-bytes LDZ2 MUL2 STH2 ( [i*] )
bol-addr ( bound* [i*] )