improvements

This commit is contained in:
~d6 2022-02-09 01:05:11 -05:00
parent b734ca5eab
commit b1c383477a
1 changed files with 58 additions and 31 deletions

View File

@ -16,25 +16,12 @@
%ansi { #1b18 DEO #5b18 DEO } %ansi { #1b18 DEO #5b18 DEO }
( %WIDTH { #50 }
%LAST-COL { #4f }
%PEN-COL { #4e }
%HEIGHT { #18 }
%LAST-LINE { #17 }
%PEN-LINE { #16 } )
%PEN-COL { ;term/cols LDA2 #0002 SUB2 NIP } %PEN-COL { ;term/cols LDA2 #0002 SUB2 NIP }
%HEIGHT { ;term/rows LDA2 NIP } %HEIGHT { ;term/rows LDA2 NIP }
%LAST-LINE { ;term/rows LDA2 #0001 SUB2 NIP } %LAST-LINE { ;term/rows LDA2 #0001 SUB2 NIP }
%PEN-LINE { ;term/rows LDA2 #0002 SUB2 NIP } %PEN-LINE { ;term/rows LDA2 #0002 SUB2 NIP }
( useful ASCII )
( - ESC 1b )
( - '[' 5b )
( - )
( ANSI sequences ) ( ANSI sequences )
( goto $row,$col ESC [ $row ; $col H ) ( goto $row,$col ESC [ $row ; $col H )
( goto home ESC [ H ) ( goto home ESC [ H )
@ -43,6 +30,8 @@
( go right ESC [ C ) ( go right ESC [ C )
( go left ESC [ D ) ( go left ESC [ D )
( ) ( )
( query cursor ESC [ 6 n )
( )
( all scroll on ESC [ r ) ( all scroll on ESC [ r )
( region scroll on ESC [ $y0 ; $y1 r ) ( region scroll on ESC [ $y0 ; $y1 r )
( scroll down ESC D ) ( scroll down ESC D )
@ -77,9 +66,15 @@
&ok &ok
( save how many bytes were read ) ( save how many bytes were read )
.File/success DEI2 ;buffer/data ADD2 ;buffer/limit STA2 .File/success DEI2 ;buffer/data ADD2 ;buffer/limit STA2
( ;on-key .Console/vector DEO2 )
( ;draw-all JSR2 ) ( use this if hardcoding to 80x24 )
;query-terminal-size JSR2 #0050 ;term/cols STA2
#0014 ;term/rows STA2
;on-key .Console/vector DEO2
;draw-all JSR2
( use this to detect terminal size )
( ;query-terminal-size JSR2 )
BRK BRK
@ -180,7 +175,6 @@
&skip BRK &skip BRK
@escape ( -> ) @escape ( -> )
#00 #00 DIV
#01 ;saw-esc STA BRK #01 ;saw-esc STA BRK
@goto-end ( FIXME ) @goto-end ( FIXME )
@ -191,11 +185,11 @@
;draw-all JSR2 ;draw-all JSR2
BRK BRK
( TODO: 8-bit meta/alt? )
( TODO: tab? ) ( TODO: tab? )
@on-key @on-key
;saw-esc LDA ,&escaped JCN ,&unmodified JMP ;saw-esc LDA ,&escaped JCN ,&unmodified JMP
&escaped &escaped
#00 #00 DIV
#00 ;saw-esc STA #00 ;saw-esc STA
.Console/read DEI LIT '< EQU ( M-< ) ;goto-start JCN2 .Console/read DEI LIT '< EQU ( M-< ) ;goto-start JCN2
.Console/read DEI LIT '> EQU ( M-> ) ;goto-end JCN2 .Console/read DEI LIT '> EQU ( M-> ) ;goto-end JCN2
@ -221,9 +215,8 @@
LTHk JMP SWP POP JMP2r LTHk JMP SWP POP JMP2r
@query-terminal-size @query-terminal-size
ansi #ff ;emit-dec JSR2 LIT '; emit #fe #fe ;term-move-cursor JSR2
#ff ;emit-dec JSR2 LIT 'H emit ;term-get-cursor-position JSR2
ansi LIT '6 emit LIT 'n emit
;tmp/data ;tmp/pos STA2 ;tmp/data ;tmp/pos STA2
;receive-terminal-size .Console/vector DEO2 ;receive-terminal-size .Console/vector DEO2
JMP2r JMP2r
@ -240,7 +233,6 @@
LDAk LIT '[ NEQ ,&parse-error JCN ( i ) INC2 LDAk LIT '[ NEQ ,&parse-error JCN ( i ) INC2
&loop &loop
LDAk LIT '; EQU ,&parse-col JCN LDAk LIT '; EQU ,&parse-col JCN
( #00 #00 DIV )
LIT2r 000a MUL2r LIT2r 000a MUL2r
LDAk LIT '0 SUB #00 SWP STH2 ADD2r LDAk LIT '0 SUB #00 SWP STH2 ADD2r
INC2 ,&loop JMP INC2 ,&loop JMP
@ -258,14 +250,36 @@
BRK BRK
&parse-error LDAk #00 #00 DIV &parse-error LDAk #00 #00 DIV
@draw-cursor @term-move-cursor ( col^ row^ -> )
ansi ;get-row JSR2 INC ;emit-dec JSR2 ansi INC ( row+1 ) ;emit-dec JSR2
LIT '; emit ;get-col JSR2 INC ;emit-dec JSR2 LIT '; emit INC ( col+1 ) ;emit-dec JSR2
LIT 'H emit JMP2r LIT 'H emit JMP2r
@term-get-cursor-position
ansi LIT '6 emit LIT 'n emit JMP2r
@term-erase-all
ansi LIT '2 emit LIT 'J emit JMP2r
@draw-cursor
;get-col JSR2 ;get-row JSR2
;term-move-cursor JSR2 JMP2r
@draw-statusbar
#00 #17 ;term-move-cursor JSR2
ansi LIT '7 emit LIT 'm emit
LIT2r 2018
;term/cols LDA2 #0000
&loop GTH2k ,&continue JCN ,&done JMP
&continue DEOkr INC2 ,&loop JMP
&done POP2 POP2 POP2r
ansi LIT '0 emit LIT 'm emit
JMP2r
@draw-all @draw-all
ansi LIT '2 emit LIT 'J emit ;term-erase-all JSR2
ansi LIT 'H emit ;draw-statusbar JSR2
#00 #00 ;term-move-cursor JSR2
#00 STH #00 STH
;buffer/offset LDA2 ;buffer/offset LDA2
&loop &loop
@ -363,8 +377,10 @@
@line-last ( -> s* ) ;cursor/row LDA INC ;rel-line JSR2 #0001 SUB2 JMP2r @line-last ( -> s* ) ;cursor/row LDA INC ;rel-line JSR2 #0001 SUB2 JMP2r
@mod-div ( x^ y^ -> x%d x/y ) @mod-div ( x^ y^ -> x%d x/y )
DIVk ( x y x/y ) STHk ( x y x/y [x/y] ) MUL ( x y*x/y [x/y] ) DIVk STHk MUL SUB STHr JMP2r
SUB ( x%y [x/y] ) STHr ( x%y x/y ) JMP2r
@mod-div2 ( x^ y^ -> x%d x/y )
DIV2k STH2k MUL2 SUB2 STH2r JMP2r
@emit-digit ( n^ -> ) @emit-digit ( n^ -> )
LIT '0 ADD emit JMP2r LIT '0 ADD emit JMP2r
@ -377,9 +393,20 @@
&do2 #0a ;mod-div JSR2 ;emit-digit JSR2 &do2 #0a ;mod-div JSR2 ;emit-digit JSR2
&do1 ;emit-digit JSR2 JMP2r &do1 ;emit-digit JSR2 JMP2r
@emit-dec2 ( n* -> )
DUP2 #270f GTH2 ,&do5 JCN
DUP2 #03e7 GTH2 ,&do4 JCN
DUP2 #0063 GTH2 ,&do3 JCN
DUP2 #0009 GTH2 ,&do2 JCN
,&do1 JMP
&do5 #2710 ;mod-div2 JSR2 NIP ;emit-digit JSR2
&do4 #03e7 ;mod-div2 JSR2 NIP ;emit-digit JSR2
&do3 #0064 ;mod-div2 JSR2 NIP ;emit-digit JSR2
&do2 #000a ;mod-div2 JSR2 NIP ;emit-digit JSR2
&do1 NIP ;emit-digit JSR2 JMP2r
@tmp [ &pos :buffer/data &data $100 ] @tmp [ &pos :buffer/data &data $100 ]
( @term [ &cols $2 &rows $2 ] ) @term [ &cols 0050 &rows 0018 ] ( 80x24 )
@term [ &cols 0050 &rows 0018 ]
@input-error "input 20 "error 00 @input-error "input 20 "error 00
@demo-path "math32.tal 00 @demo-path "math32.tal 00