2023-01-23 23:16:46 -05:00
|
|
|
( TODO: )
|
|
|
|
( 1. investigate femto/nano bugs )
|
|
|
|
( 2. support attributes (inverse, bold, dim) )
|
|
|
|
( 3. add more ansi control seqs )
|
|
|
|
( 4. log ESC [ ? x ; ... $c )
|
2023-01-25 23:37:56 -05:00
|
|
|
( 5. need draw-line word, and need to use it more )
|
|
|
|
( a. on delete, CSI-P )
|
|
|
|
( b. on insert )
|
2023-01-23 23:16:46 -05:00
|
|
|
|
2023-01-22 21:07:10 -05:00
|
|
|
( ANSI sequences )
|
|
|
|
( )
|
2023-01-30 14:25:03 -05:00
|
|
|
( set attributes: ESC [ x ; ... m -> 0:reset 1:bright 2:dim 7:reverse )
|
|
|
|
( get cursor position: ESC [ 6 n -> ESC [ $row ; $col R )
|
|
|
|
( set insert: ESC [ 4 h )
|
|
|
|
( set replace (def): ESC [ 4 l )
|
|
|
|
( enable line wrap: ESC [ 7 h )
|
|
|
|
( disable line wrap: ESC [ 7 l )
|
2023-01-22 21:07:10 -05:00
|
|
|
( )
|
2023-01-30 14:25:03 -05:00
|
|
|
( move cursor home: ESC [ H )
|
|
|
|
( move cursor: ESC [ $row ; $col H )
|
|
|
|
( move to column: ESC [ $n G )
|
|
|
|
( move to row: ESC [ $n d )
|
|
|
|
( move up: ESC [ $n A )
|
|
|
|
( move down: ESC [ $n B )
|
|
|
|
( move forward: ESC [ $n C )
|
|
|
|
( move back: ESC [ $n D )
|
|
|
|
( move forward n tabs ESC [ $n I )
|
2023-01-22 21:07:10 -05:00
|
|
|
( )
|
|
|
|
( erase from cursor to end of line: ESC [ K )
|
|
|
|
( erase from start of line to cursor: ESC [ 1 K )
|
|
|
|
( erase line: ESC [ 2 K )
|
|
|
|
( erase from current line to bottom: ESC [ J )
|
|
|
|
( erase from current line to top: ESC [ 1 J )
|
|
|
|
( erase screen: ESC [ 2 J )
|
2023-01-23 21:00:00 -05:00
|
|
|
( )
|
2023-01-30 10:59:52 -05:00
|
|
|
( insert lines: ESC [ $n L )
|
|
|
|
( delete n characters: ESC [ $n P )
|
|
|
|
( insert n blank characters: ESC [ $n @ )
|
2023-01-24 11:59:01 -05:00
|
|
|
( )
|
2023-01-30 10:59:52 -05:00
|
|
|
( show cursor: ESC [ ? 25 h )
|
|
|
|
( hide cursor: ESC [ ? 25 l )
|
|
|
|
( set bracketed paste mode (xterm): ESC [ ? 2004 h )
|
|
|
|
( reset bracketed paste mode (xterm): ESC [ ? 2004 l )
|
2023-01-30 14:25:03 -05:00
|
|
|
( )
|
|
|
|
( NOT SUPPORTED YET: )
|
|
|
|
( ??? ESC lpar )
|
|
|
|
( ??? ESC 7 )
|
2023-01-30 10:59:52 -05:00
|
|
|
( end alt charset ESC [ 10 m )
|
|
|
|
( end alt charset ESC [ 11 m )
|
2023-01-22 21:07:10 -05:00
|
|
|
|
2023-01-30 23:01:34 -05:00
|
|
|
|00 @System [ &vect $2 &expansion $2 &title $2 &metadata $2 &r $2 &g $2 &b $2 ]
|
2022-11-06 21:49:02 -05:00
|
|
|
|10 @Console [ &vect $2 &r $1 &pad $5 &w $1 ]
|
2023-01-31 15:37:14 -05:00
|
|
|
|20 @Screen [ &vect $2 &w $2 &h $2 &auto $1 &pad $1 &x $2 &y $2 &addr $2 &px $1 &sprite $1 ]
|
2023-01-23 20:22:59 -05:00
|
|
|
|80 @Controller [ &vect $2 &button $1 &key $1 &fn $1 ]
|
2023-01-31 15:37:14 -05:00
|
|
|
|90 @Mouse [ &vect $2 &x $2 &y $2 &state $1 &pad $3 &scrollx $2 &scrolly $2 ]
|
|
|
|
|a0 @File1 [ &vect $2 &ok $2 &stat $2 &del $1 &append $1 &name $2 &len $2 &r $2 &w $2 ]
|
|
|
|
|b0 @File2 [ &vect $2 &ok $2 &stat $2 &del $1 &append $1 &name $2 &len $2 &r $2 &w $2 ]
|
2022-11-06 21:49:02 -05:00
|
|
|
|
|
|
|
|0000
|
2023-01-30 10:59:52 -05:00
|
|
|
@tint $1 ( draw mode. 01=regular, 04=inverted )
|
|
|
|
@attr $1 ( 5 bits: RxxxBBFF )
|
|
|
|
@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 )
|
|
|
|
@col-bytes $2 ( 2*cols )
|
|
|
|
@debug $1 ( use debug log? )
|
2023-01-31 22:28:41 -05:00
|
|
|
@lastmouse-x $2 ( last mouse x )
|
|
|
|
@lastmouse-y $2 ( last mouse y )
|
|
|
|
@lastmouse-st $1 ( last mouse press )
|
2022-11-06 21:49:02 -05:00
|
|
|
|
2023-01-28 10:40:47 -05:00
|
|
|
( terminal settings )
|
|
|
|
@irm $1 ( 01: insert and move right, 00: replace and overwrite )
|
|
|
|
@awm $1 ( 01: wrap chars at margin, 00: overwrite at margin )
|
2023-01-30 14:25:03 -05:00
|
|
|
@tcem $1 ( 01: cursor is visible, 00: cursor is invisible )
|
|
|
|
@paste $1 ( 01: bracketed paste is on, 00: is off )
|
|
|
|
|
|
|
|
( TODO: detect when pasting text from varvara if possible )
|
|
|
|
( to send CSI 200 ~ on start of paste, and CSI 201 ~ at end of paste )
|
2023-01-28 10:40:47 -05:00
|
|
|
|
2022-11-06 21:49:02 -05:00
|
|
|
|0100
|
2023-01-30 23:01:34 -05:00
|
|
|
( metadata )
|
|
|
|
;meta .System/metadata DEO2
|
|
|
|
;meta/name .System/title DEO2
|
|
|
|
|
2023-01-21 22:54:20 -05:00
|
|
|
( 80 cols x 24 rows )
|
|
|
|
#0028 .rows STZ2
|
|
|
|
#0050 .cols STZ2
|
2022-11-06 21:49:02 -05:00
|
|
|
|
2023-01-29 23:07:03 -05:00
|
|
|
( set col-bytes, frequently needed )
|
|
|
|
.cols LDZ2 DUP2 ADD2 .col-bytes STZ2
|
|
|
|
|
2023-01-22 21:07:10 -05:00
|
|
|
( set max row/col )
|
|
|
|
.rows LDZ2 #0001 SUB2 .max-y STZ2
|
|
|
|
.cols LDZ2 #0001 SUB2 .max-x STZ2
|
|
|
|
|
|
|
|
( set initial cursor )
|
|
|
|
#0000 .cur-x STZ2
|
|
|
|
#0000 .cur-y STZ2
|
2023-01-28 10:40:47 -05:00
|
|
|
|
2023-01-23 20:22:59 -05:00
|
|
|
( confirm no buttons pressed yet )
|
|
|
|
#00 .lastkey STZ
|
2023-01-22 21:07:10 -05:00
|
|
|
|
2022-11-06 21:49:02 -05:00
|
|
|
( set screen height/width based on rows/cols )
|
|
|
|
.rows LDZ2 #30 SFT2 .Screen/h DEO2
|
|
|
|
.cols LDZ2 #30 SFT2 .Screen/w DEO2
|
|
|
|
|
|
|
|
( set colors )
|
2023-01-25 12:11:16 -05:00
|
|
|
#07bf .System/r DEO2
|
|
|
|
#07bf .System/g DEO2
|
|
|
|
#07bf .System/b DEO2
|
2023-01-30 22:05:47 -05:00
|
|
|
load-theme
|
2023-01-25 12:11:16 -05:00
|
|
|
|
|
|
|
( set starting tint: reverse=0, bg=0, fg=2 )
|
|
|
|
#02 .attr STZ
|
2023-01-30 22:05:47 -05:00
|
|
|
update-tint
|
2023-01-21 15:41:27 -05:00
|
|
|
|
2023-01-28 10:40:47 -05:00
|
|
|
( set initial modes )
|
2023-01-30 14:25:03 -05:00
|
|
|
#01 .irm STZ ( insert and move right )
|
|
|
|
#01 .awm STZ ( wrap at margin )
|
|
|
|
#01 .tcem STZ ( show cursor )
|
|
|
|
#00 .paste STZ ( bracketed paste is off )
|
2023-01-28 10:40:47 -05:00
|
|
|
|
2022-11-06 21:49:02 -05:00
|
|
|
( clear screen for initial draw )
|
2023-01-30 22:05:47 -05:00
|
|
|
clear-screen
|
2022-11-06 21:49:02 -05:00
|
|
|
|
|
|
|
( set up interrupts )
|
|
|
|
;redraw .Screen/vect DEO2 ( set up screen )
|
|
|
|
;on-key .Controller/vect DEO2 ( set up keyboard )
|
2023-01-31 22:28:41 -05:00
|
|
|
;on-mouse .Mouse/vect DEO2 ( set up mouse )
|
2023-01-22 21:07:10 -05:00
|
|
|
;on-read .Console/vect DEO2 ( set up stdin )
|
2022-11-06 21:49:02 -05:00
|
|
|
|
2023-01-29 23:07:03 -05:00
|
|
|
( set to 01 to enable debug log )
|
2023-01-30 16:47:44 -05:00
|
|
|
#00 .debug STZ
|
2023-01-25 12:11:16 -05:00
|
|
|
|
2023-01-30 22:05:47 -05:00
|
|
|
.debug LDZ ?&continue BRK &continue
|
2023-01-29 23:07:03 -05:00
|
|
|
#99 #010e DEO
|
2023-01-31 15:37:14 -05:00
|
|
|
;debug-log .File1/name DEO2
|
|
|
|
#01 .File1/append DEO
|
2022-11-06 21:49:02 -05:00
|
|
|
BRK
|
|
|
|
|
2023-01-25 12:51:25 -05:00
|
|
|
@load-theme ( -> )
|
2023-01-31 15:37:14 -05:00
|
|
|
;&path .File1/name DEO2
|
|
|
|
#0002 .File1/len DEO2
|
|
|
|
;&r .File1/r DEO2
|
|
|
|
;&g .File1/r DEO2
|
|
|
|
;&b .File1/r DEO2
|
|
|
|
.File1/ok DEI2 ORA #01 JCN JMP2r
|
2023-01-25 12:51:25 -05:00
|
|
|
LIT2 &r $2 .System/r DEO2
|
|
|
|
LIT2 &g $2 .System/g DEO2
|
|
|
|
LIT2 &b $2 .System/b DEO2
|
|
|
|
JMP2r [ &path ".theme $1 ]
|
|
|
|
|
2023-01-23 16:26:08 -05:00
|
|
|
@first-addr ( -> )
|
2023-01-25 12:11:16 -05:00
|
|
|
;cells JMP2r
|
2023-01-23 16:26:08 -05:00
|
|
|
|
2023-01-23 11:14:45 -05:00
|
|
|
@bol-addr ( -> addr* )
|
2023-01-29 23:07:03 -05:00
|
|
|
.col-bytes LDZ2 .cur-y LDZ2 MUL2 ;cells ADD2 JMP2r
|
2023-01-23 11:14:45 -05:00
|
|
|
|
|
|
|
@cur-addr ( -> addr* )
|
2023-01-29 23:07:03 -05:00
|
|
|
.col-bytes LDZ2 .cur-y LDZ2 MUL2 .cur-x LDZ2 DUP2 ADD2 ADD2 ;cells ADD2 JMP2r
|
2023-01-23 11:14:45 -05:00
|
|
|
|
|
|
|
@eol-addr ( -> addr* )
|
2023-01-29 23:07:03 -05:00
|
|
|
.col-bytes LDZ2 .cur-y LDZ2 INC2 MUL2 ;cells ADD2 JMP2r
|
2023-01-23 16:26:08 -05:00
|
|
|
|
2023-01-25 12:11:16 -05:00
|
|
|
@limit-addr ( -> )
|
2023-01-29 23:07:03 -05:00
|
|
|
.col-bytes LDZ2 .rows LDZ2 MUL2 ;cells ADD2 JMP2r
|
2023-01-23 11:14:45 -05:00
|
|
|
|
2023-01-22 21:07:10 -05:00
|
|
|
@min ( x* y* -> min* )
|
|
|
|
LTH2k JMP SWP2 POP2 JMP2r
|
|
|
|
|
2023-01-22 23:44:00 -05:00
|
|
|
@max ( x* y* -> max* )
|
|
|
|
LTH2k JMP SWP2 NIP2 JMP2r
|
2023-01-22 21:07:10 -05:00
|
|
|
|
2022-11-06 21:49:02 -05:00
|
|
|
@clear-screen
|
2023-01-22 15:21:57 -05:00
|
|
|
#01 .dirty? STZ
|
2023-01-25 12:11:16 -05:00
|
|
|
;cells STH2 ( [addr*] )
|
|
|
|
#0000 &yloop ( y* [addr*] y* )
|
|
|
|
#0000 &xloop ( y* x* [addr*] )
|
2023-01-31 22:30:13 -05:00
|
|
|
#0220 STH2kr STA2 ( y* x* [addr*] )
|
2023-01-25 12:11:16 -05:00
|
|
|
INC2r INC2r ( y* x* [addr+2*] )
|
|
|
|
INC2 DUP2 .cols LDZ2 ( y* x+1* x+1* cols* [addr+2*] )
|
2023-01-30 22:05:47 -05:00
|
|
|
LTH2 ?&xloop ( y* x+1* [addr+2*] )
|
2023-01-25 12:11:16 -05:00
|
|
|
POP2 ( y* [addr*] )
|
|
|
|
INC2 DUP2 .rows LDZ2 ( y+1* y+1* rows* [addr*] )
|
2023-01-30 22:05:47 -05:00
|
|
|
LTH2 ?&yloop ( y+1* [addr*] )
|
2023-01-25 12:11:16 -05:00
|
|
|
POP2 POP2r JMP2r ( )
|
2022-11-06 21:49:02 -05:00
|
|
|
|
|
|
|
@redraw
|
2023-01-30 22:05:47 -05:00
|
|
|
.dirty? LDZ #00 EQU ?&done
|
2023-01-25 12:11:16 -05:00
|
|
|
;cells STH2 ( [addr*] )
|
2023-01-30 23:01:34 -05:00
|
|
|
.rows LDZ2 #0000 DUP2 .Screen/y DEO2
|
2022-11-06 21:49:02 -05:00
|
|
|
&yloop
|
2023-01-30 23:01:34 -05:00
|
|
|
.cols LDZ2 #0000 DUP2 .Screen/x DEO2
|
2022-11-06 21:49:02 -05:00
|
|
|
&xloop
|
2023-01-30 22:05:47 -05:00
|
|
|
STH2kr LDA2 draw-cell
|
2023-01-25 12:11:16 -05:00
|
|
|
.Screen/x DEI2k #0008 ADD2 ROT DEO2
|
|
|
|
INC2 INC2r INC2r
|
2023-01-30 23:01:34 -05:00
|
|
|
GTH2k ?&xloop
|
|
|
|
POP2 POP2
|
2023-01-25 12:11:16 -05:00
|
|
|
.Screen/y DEI2k #0008 ADD2 ROT DEO2
|
2022-11-06 21:49:02 -05:00
|
|
|
INC2
|
2023-01-30 23:01:34 -05:00
|
|
|
GTH2k ?&yloop
|
|
|
|
POP2 POP2 POP2r
|
|
|
|
draw-cursor #00 .dirty? STZ &done BRK
|
2022-11-06 21:49:02 -05:00
|
|
|
|
2023-01-25 12:11:16 -05:00
|
|
|
@clear-cursor
|
|
|
|
.cur-x LDZ2 #30 SFT2 .Screen/x DEO2
|
|
|
|
.cur-y LDZ2 #30 SFT2 .Screen/y DEO2
|
2023-01-30 22:05:47 -05:00
|
|
|
cur-addr LDA2
|
|
|
|
!draw-cell
|
2022-11-06 21:49:02 -05:00
|
|
|
|
|
|
|
@draw-cursor
|
|
|
|
.cur-x LDZ2 #30 SFT2 .Screen/x DEO2
|
|
|
|
.cur-y LDZ2 #30 SFT2 .Screen/y DEO2
|
2023-01-30 22:05:47 -05:00
|
|
|
cur-addr LDA2
|
|
|
|
.tcem LDZ #00 EQU ?&skip
|
|
|
|
SWP reverse-tint SWP
|
2023-01-30 14:25:03 -05:00
|
|
|
&skip
|
2023-01-30 22:05:47 -05:00
|
|
|
!draw-cell
|
2022-11-06 21:49:02 -05:00
|
|
|
|
2023-01-23 20:22:59 -05:00
|
|
|
@on-button ( -> )
|
2023-01-25 12:11:16 -05:00
|
|
|
.lastkey LDZ ( last^ )
|
|
|
|
.Controller/button DEI ( last^ button^ )
|
|
|
|
STHk EOR ( last-xor-button^ [button^] )
|
|
|
|
STHr AND ( last-xor-button&button^ )
|
2023-01-30 22:05:47 -05:00
|
|
|
DUP #10 AND #00 EQU ?&no-n LIT "A arrow
|
|
|
|
&no-n DUP #20 AND #00 EQU ?&no-s LIT "B arrow
|
|
|
|
&no-s DUP #40 AND #00 EQU ?&no-w LIT "D arrow
|
|
|
|
&no-w DUP #80 AND #00 EQU ?&no-e LIT "C arrow
|
2023-01-25 12:11:16 -05:00
|
|
|
&no-e POP .Controller/button DEI .lastkey STZ BRK
|
2023-01-23 20:22:59 -05:00
|
|
|
|
|
|
|
( send ESC [ $c )
|
|
|
|
@arrow ( c^ -> )
|
|
|
|
.Console/w STH
|
|
|
|
#1b STHkr DEO LIT "[ STHkr DEO STHr DEO
|
|
|
|
JMP2r
|
|
|
|
|
2023-01-31 22:28:41 -05:00
|
|
|
@paste-from-buf ( size* -> )
|
|
|
|
;paste-buf SWP2 OVR2 ADD2 SWP2 ( limit* start* )
|
|
|
|
&loop ( limit* pos* )
|
|
|
|
LDAk .Console/w DEO INC2 ( limit* pos+1* )
|
|
|
|
GTH2k ?&loop POP2 POP2 JMP2r
|
|
|
|
|
|
|
|
@paste-snarf ( -> )
|
|
|
|
;&path .File2/name DEO2 ( )
|
|
|
|
#0100 .File2/len DEO2 ( )
|
|
|
|
&loop ( )
|
|
|
|
;paste-buf .File2/r DEO2 ( )
|
|
|
|
.File2/ok DEI2 ( size* )
|
|
|
|
DUP2 #0000 EQU2 ?&failed ( size* )
|
|
|
|
DUP2 paste-from-buf ( size* )
|
|
|
|
#0100 LTH2 ?&done ( )
|
|
|
|
!&loop ( )
|
|
|
|
&failed POP2
|
|
|
|
&done JMP2r [ &path ".snarf 00 ]
|
|
|
|
|
|
|
|
@on-click-down ( click^ -> )
|
|
|
|
#02 AND ?&middle-click !&done
|
|
|
|
&middle-click paste-snarf
|
|
|
|
&done JMP2r
|
|
|
|
|
|
|
|
@on-click-up ( unclick^ -> )
|
|
|
|
POP JMP2r
|
|
|
|
|
|
|
|
@on-move
|
|
|
|
.Mouse/x DEI2 .lastmouse-x LDZ2 NEQ2 ?&redraw
|
|
|
|
.Mouse/y DEI2 .lastmouse-y LDZ2 NEQ2 ?&redraw
|
|
|
|
JMP2r
|
|
|
|
&redraw
|
|
|
|
.Mouse/x DEI2 .Screen/x DEO2
|
|
|
|
.Mouse/y DEI2 .Screen/y DEO2
|
|
|
|
#02f0 ;ascii ADD2 .Screen/addr DEO2
|
|
|
|
#43 .Screen/sprite DEO
|
|
|
|
.Mouse/x DEI2 .lastmouse-x STZ2
|
|
|
|
.Mouse/y DEI2 .lastmouse-y STZ2
|
|
|
|
JMP2r
|
|
|
|
|
|
|
|
@on-mouse ( -> )
|
|
|
|
.lastmouse-st LDZ ( last )
|
|
|
|
.Mouse/state DEI ( last st )
|
|
|
|
STHk OVR EOR STHkr AND ( last (last^st)&st [st] )
|
|
|
|
on-click-down ( last [st] )
|
|
|
|
DUP STHkr EOR AND ( last&(last^st) [st] )
|
|
|
|
on-click-up ( [st] )
|
|
|
|
STHr .lastmouse-st STZ ( )
|
|
|
|
( on-move ) BRK ( )
|
|
|
|
|
2023-01-22 15:55:52 -05:00
|
|
|
@on-key ( -> )
|
2023-01-30 22:05:47 -05:00
|
|
|
.Controller/key DEI ?&ok !on-button
|
|
|
|
&ok alt ?on-alt-key
|
|
|
|
ctrl ?on-ctrl-key
|
2023-01-30 15:09:07 -05:00
|
|
|
.Controller/key DEI
|
2023-01-30 22:05:47 -05:00
|
|
|
DUP #08 NEQ ?&done
|
2023-01-30 15:09:07 -05:00
|
|
|
POP #7f ( send DEL instead of BS )
|
|
|
|
&done .Console/w DEO BRK
|
2023-01-22 15:55:52 -05:00
|
|
|
|
2023-01-30 22:05:47 -05:00
|
|
|
@ctrl ( -> is-down? ) .Controller/button DEI #01 AND JMP2r
|
|
|
|
@alt ( -> is-down? ) .Controller/button DEI #02 AND JMP2r
|
2023-01-22 15:55:52 -05:00
|
|
|
|
|
|
|
( alt-XYZ emits ESC and then emits XYZ )
|
|
|
|
@on-alt-key ( -> )
|
|
|
|
#1b .Console/w DEO
|
2023-01-30 22:05:47 -05:00
|
|
|
ctrl ?on-ctrl-key
|
2023-01-22 15:55:52 -05:00
|
|
|
.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
|
2023-01-30 22:05:47 -05:00
|
|
|
DUP LIT "@ LTH ?&done
|
|
|
|
DUP LIT "` LTH ?&c1
|
|
|
|
LIT "` SUB !&done
|
2023-01-22 15:55:52 -05:00
|
|
|
&c1 LIT "@ SUB
|
|
|
|
&done .Console/w DEO BRK
|
2023-01-22 15:21:57 -05:00
|
|
|
|
2023-01-24 11:59:01 -05:00
|
|
|
@on-read-priv
|
2023-01-22 23:44:00 -05:00
|
|
|
.Console/r DEI
|
2023-01-30 22:05:47 -05:00
|
|
|
DUP LIT "; EQU ?next-arg
|
|
|
|
DUP LIT "0 LTH ?end-arg-priv
|
|
|
|
DUP LIT "9 GTH ?end-arg-priv
|
|
|
|
!add-to-arg
|
2023-01-24 11:59:01 -05:00
|
|
|
|
|
|
|
@start-priv
|
2023-01-30 14:25:03 -05:00
|
|
|
POP ;on-read-priv .Console/vect DEO2 BRK
|
2023-01-24 11:59:01 -05:00
|
|
|
|
|
|
|
@on-read-csi ( -> )
|
|
|
|
.Console/r DEI
|
2023-01-30 22:05:47 -05:00
|
|
|
DUP LIT "? EQU ?start-priv
|
|
|
|
DUP LIT "; EQU ?next-arg
|
|
|
|
DUP LIT "0 LTH ?end-arg
|
|
|
|
DUP LIT "9 GTH ?end-arg
|
|
|
|
!add-to-arg
|
2023-01-22 23:44:00 -05:00
|
|
|
|
2023-01-25 23:37:56 -05:00
|
|
|
|
|
|
|
@debug-arg ( n* -> )
|
2023-01-30 22:05:47 -05:00
|
|
|
&short SWP debug-arg/byte
|
|
|
|
&byte DUP #04 SFT debug-arg/char
|
|
|
|
&char #0f AND DUP #09 GTH #27 MUL ADD #30 ADD scratch-write
|
2023-01-25 23:37:56 -05:00
|
|
|
JMP2r
|
|
|
|
|
|
|
|
@debug-args ( -> )
|
|
|
|
;args/pos LDA2 ;args
|
|
|
|
&loop
|
2023-01-30 22:05:47 -05:00
|
|
|
#20 scratch-write
|
|
|
|
LDA2k debug-arg/short INC2 INC2
|
|
|
|
LTH2k ?&done !&loop
|
2023-01-25 23:37:56 -05:00
|
|
|
&done POP2 POP2 JMP2r
|
|
|
|
|
2023-01-24 11:59:01 -05:00
|
|
|
@debug-priv ( c^ -> )
|
2023-01-30 22:05:47 -05:00
|
|
|
.debug LDZ ?&continue POP JMP2r &continue
|
|
|
|
reset-scratch
|
2023-01-25 23:37:56 -05:00
|
|
|
;scratch-write STH2
|
|
|
|
LIT "1 STH2kr JSR2
|
|
|
|
LIT "b STH2kr JSR2
|
|
|
|
#20 STH2kr JSR2
|
|
|
|
LIT "[ STH2kr JSR2
|
|
|
|
#20 STH2kr JSR2
|
|
|
|
LIT "? STH2kr JSR2
|
2023-01-30 22:05:47 -05:00
|
|
|
debug-args
|
2023-01-25 23:37:56 -05:00
|
|
|
#20 STH2kr JSR2
|
|
|
|
STH2kr JSR2
|
|
|
|
#0a STH2r JSR2
|
2023-01-31 15:37:14 -05:00
|
|
|
scratch-len .File1/len DEO2
|
|
|
|
;scratch .File1/w DEO2
|
2023-01-25 23:37:56 -05:00
|
|
|
JMP2r
|
|
|
|
|
2023-01-24 11:59:01 -05:00
|
|
|
@end-arg-priv ( c^ -> )
|
|
|
|
;on-read .Console/vect DEO2
|
2023-01-30 22:05:47 -05:00
|
|
|
DUP LIT "h EQU ?exec-priv-set-or-unset
|
|
|
|
DUP LIT "l EQU ?exec-priv-set-or-unset
|
|
|
|
DUP debug-priv
|
2023-01-24 11:59:01 -05:00
|
|
|
( TODO: handle these )
|
|
|
|
POP BRK
|
|
|
|
|
2023-01-30 14:25:03 -05:00
|
|
|
@exec-priv-set-or-unset ( c^ -> )
|
2023-01-30 22:05:47 -05:00
|
|
|
#0001 read-arg-1 ( c^ n* )
|
|
|
|
DUP2 #0019 NEQ2 ?&!25 POP2 .tcem !&change
|
|
|
|
&!25 DUP2 #07d4 NEQ2 ?&!2004 POP2 .paste !&change
|
|
|
|
&!2004 POP2 debug-priv BRK
|
2023-01-30 14:25:03 -05:00
|
|
|
&change SWP LIT "h EQU SWP STZ BRK ( h is set, l is unset )
|
|
|
|
|
2023-01-24 11:59:01 -05:00
|
|
|
@debug-csi ( c^ -> )
|
2023-01-30 22:05:47 -05:00
|
|
|
.debug LDZ ?&continue POP JMP2r &continue
|
|
|
|
reset-scratch
|
2023-01-25 23:37:56 -05:00
|
|
|
;scratch-write STH2
|
|
|
|
LIT "1 STH2kr JSR2
|
|
|
|
LIT "b STH2kr JSR2
|
|
|
|
#20 STH2kr JSR2
|
|
|
|
LIT "[ STH2kr JSR2
|
2023-01-30 22:05:47 -05:00
|
|
|
debug-args
|
2023-01-25 23:37:56 -05:00
|
|
|
#20 STH2kr JSR2
|
|
|
|
STH2kr JSR2
|
|
|
|
#0a STH2r JSR2
|
2023-01-31 15:37:14 -05:00
|
|
|
scratch-len .File1/len DEO2
|
|
|
|
;scratch .File1/w DEO2
|
2023-01-25 23:37:56 -05:00
|
|
|
JMP2r
|
2023-01-23 20:54:52 -05:00
|
|
|
|
2023-01-22 23:44:00 -05:00
|
|
|
@end-arg ( c^ -> )
|
|
|
|
;on-read .Console/vect DEO2
|
2023-01-30 22:05:47 -05:00
|
|
|
( DUP debug-csi )
|
|
|
|
DUP LIT "d EQU ?exec-move-row ( move cursor to row )
|
|
|
|
DUP LIT "h EQU ?exec-set-mode ( enable line wrap )
|
|
|
|
DUP LIT "l EQU ?exec-reset-mode ( disable line wrap )
|
|
|
|
DUP LIT "m EQU ?exec-set-attr ( set attr )
|
|
|
|
DUP LIT "n EQU ?exec-status ( get status )
|
|
|
|
DUP LIT "@ EQU ?exec-insert-blanks ( insert blank characters )
|
|
|
|
DUP LIT "A EQU ?exec-up ( up )
|
|
|
|
DUP LIT "B EQU ?exec-down ( down )
|
|
|
|
DUP LIT "C EQU ?exec-forward ( forward )
|
|
|
|
DUP LIT "D EQU ?exec-back ( back )
|
|
|
|
DUP LIT "G EQU ?exec-move-col ( move cursor to col )
|
|
|
|
DUP LIT "H EQU ?exec-move ( move cursor )
|
|
|
|
DUP LIT "I EQU ?exec-forward-tabs ( forward by tab stops )
|
|
|
|
DUP LIT "J EQU ?exec-erase-screen ( erase screen )
|
|
|
|
DUP LIT "K EQU ?exec-erase-line ( erase line )
|
|
|
|
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 )
|
|
|
|
debug-csi BRK
|
2023-01-22 23:44:00 -05:00
|
|
|
|
|
|
|
@exec-noop ( c^ -> )
|
|
|
|
POP BRK
|
|
|
|
|
2023-01-25 23:37:56 -05:00
|
|
|
( set mode )
|
|
|
|
( TODO: insert/replace, line wrap, etc. )
|
|
|
|
@exec-set-mode ( c^ -> )
|
2023-01-30 22:05:47 -05:00
|
|
|
POP #0001 read-arg-1
|
|
|
|
DUP2 #0004 NEQ2 ?&!irm POP2 .irm !&set
|
|
|
|
&!irm DUP2 #0007 NEQ2 ?&!awm POP2 .awm !&set
|
2023-01-28 10:40:47 -05:00
|
|
|
&!awm POP2 BRK
|
|
|
|
&set #01 SWP STZ BRK
|
|
|
|
|
2023-01-25 23:37:56 -05:00
|
|
|
@exec-reset-mode ( c^ -> )
|
2023-01-30 22:05:47 -05:00
|
|
|
POP #0001 read-arg-1
|
|
|
|
DUP2 #0004 NEQ2 ?&!irm POP2 .irm !&reset
|
|
|
|
&!irm DUP2 #0007 NEQ2 ?&!awm POP2 .awm !&reset
|
2023-01-28 10:40:47 -05:00
|
|
|
&!awm POP2 BRK
|
|
|
|
&reset #00 SWP STZ BRK
|
2023-01-25 23:37:56 -05:00
|
|
|
|
2023-01-25 12:11:16 -05:00
|
|
|
@read-attr ( attr* -> )
|
2023-01-30 22:05:47 -05:00
|
|
|
DUP2 #0000 NEQ2 ?&!0 #02 .attr STZ !&done ( reset )
|
|
|
|
&!0 DUP2 #0001 NEQ2 ?&!1 #03 !&set-fg ( bright )
|
|
|
|
&!1 DUP2 #0002 NEQ2 ?&!2 #01 !&set-fg ( dim )
|
|
|
|
&!2 DUP2 #0007 NEQ2 ?&!7 .attr LDZk #80 ORA SWP STZ !&done ( reverse )
|
|
|
|
&!7 !&ignored
|
2023-01-25 12:11:16 -05:00
|
|
|
|
|
|
|
&set-fg .attr LDZ #fc AND ORA .attr STZ
|
2023-01-30 22:05:47 -05:00
|
|
|
&done update-tint
|
2023-01-25 12:11:16 -05:00
|
|
|
&ignored POP2 JMP2r
|
|
|
|
|
|
|
|
@exec-set-attr ( c^ -> )
|
|
|
|
POP
|
|
|
|
;args/pos LDA2 ;args
|
|
|
|
&loop
|
2023-01-30 22:05:47 -05:00
|
|
|
LDA2k read-attr
|
2023-01-25 12:11:16 -05:00
|
|
|
INC2 INC2
|
2023-01-30 22:05:47 -05:00
|
|
|
LTH2k ?&done !&loop
|
2023-01-25 12:11:16 -05:00
|
|
|
&done
|
2023-01-28 10:40:47 -05:00
|
|
|
POP2 POP2 BRK
|
2023-01-25 12:11:16 -05:00
|
|
|
|
2023-01-22 23:44:00 -05:00
|
|
|
@exec1 ( addr* -> )
|
2023-01-30 22:05:47 -05:00
|
|
|
STH2 #0001 read-arg-1 STH2r JSR2 BRK
|
2023-01-22 23:44:00 -05:00
|
|
|
|
2023-01-23 11:14:45 -05:00
|
|
|
@exec-status
|
2023-01-30 22:05:47 -05:00
|
|
|
POP #0000 read-arg-1 #0006 NEQ2 ,&done
|
2023-01-23 11:14:45 -05:00
|
|
|
#1b .Console/w DEO
|
|
|
|
LIT "[ .Console/w DEO
|
|
|
|
LIT "4 .Console/w DEO
|
|
|
|
LIT "0 .Console/w DEO
|
|
|
|
LIT "; .Console/w DEO
|
|
|
|
LIT "7 .Console/w DEO
|
|
|
|
LIT "9 .Console/w DEO
|
|
|
|
LIT "R .Console/w DEO
|
|
|
|
&done BRK
|
|
|
|
|
2023-01-30 22:05:47 -05:00
|
|
|
@exec-up POP ;up-n !exec1
|
|
|
|
@exec-down POP ;down-n !exec1
|
|
|
|
@exec-forward POP ;forward-n !exec1
|
|
|
|
@exec-back POP ;back-n !exec1
|
|
|
|
@exec-insert-blanks POP ;insert-n-spaces !exec1
|
|
|
|
@exec-delete-lines POP ;delete-n-lines !exec1
|
|
|
|
@exec-delete-chars POP ;delete-n-chars !exec1
|
|
|
|
@exec-insert-lines POP ;insert-n-lines !exec1
|
|
|
|
@exec-forward-tabs POP ;forward-n-tabs !exec1
|
2023-01-22 23:44:00 -05:00
|
|
|
|
2023-01-23 11:14:45 -05:00
|
|
|
@exec-erase-line
|
2023-01-30 22:05:47 -05:00
|
|
|
POP #0000 read-arg-1
|
|
|
|
DUP2 #0000 EQU2 ?&erase-to-end
|
|
|
|
DUP2 #0001 EQU2 ?&erase-from-start
|
|
|
|
DUP2 #0002 EQU2 ?&erase-full
|
2023-01-23 14:48:29 -05:00
|
|
|
POP2 BRK
|
|
|
|
&erase-full
|
2023-01-30 22:05:47 -05:00
|
|
|
POP2 bol-addr eol-addr erase BRK
|
2023-01-23 11:14:45 -05:00
|
|
|
&erase-to-end
|
2023-01-30 22:05:47 -05:00
|
|
|
POP2 cur-addr eol-addr erase BRK
|
2023-01-23 11:14:45 -05:00
|
|
|
&erase-from-start
|
2023-01-30 22:05:47 -05:00
|
|
|
POP2 bol-addr cur-addr erase BRK
|
2023-01-23 11:14:45 -05:00
|
|
|
|
2023-01-23 16:26:08 -05:00
|
|
|
@exec-erase-screen
|
2023-01-30 22:05:47 -05:00
|
|
|
POP #0000 read-arg-1
|
|
|
|
DUP2 #0000 EQU2 ?&erase-to-end
|
|
|
|
DUP2 #0001 EQU2 ?&erase-from-start
|
|
|
|
DUP2 #0002 EQU2 ?&erase-full
|
2023-01-23 16:26:08 -05:00
|
|
|
POP2 BRK
|
|
|
|
&erase-full
|
2023-01-30 22:05:47 -05:00
|
|
|
POP2 first-addr limit-addr erase BRK
|
2023-01-23 16:26:08 -05:00
|
|
|
&erase-to-end
|
2023-01-30 22:05:47 -05:00
|
|
|
POP2 bol-addr limit-addr erase BRK
|
2023-01-23 16:26:08 -05:00
|
|
|
&erase-from-start
|
2023-01-30 22:05:47 -05:00
|
|
|
POP2 first-addr eol-addr erase BRK
|
2023-01-23 11:14:45 -05:00
|
|
|
|
2023-01-23 16:26:08 -05:00
|
|
|
( TODO: needs to be smarter -- need to redraw tiles and keep x/y coords )
|
2023-01-23 11:14:45 -05:00
|
|
|
@erase ( start* end* -> )
|
2023-01-30 22:05:47 -05:00
|
|
|
EQU2k ?&skip ( start* end* )
|
2023-01-25 12:11:16 -05:00
|
|
|
OVR2 SWP2 ( start* start* end* )
|
2023-01-31 22:30:13 -05:00
|
|
|
SUB2 STH2 #0220 SWP2 ( 4220 start* [count*] )
|
2023-01-25 12:11:16 -05:00
|
|
|
&loop ( 4220 addr* [i*] )
|
|
|
|
STA2k INC2 INC2 INC2r INC2r ( 4220 addr+2* [i+1*] )
|
2023-01-30 22:05:47 -05:00
|
|
|
ORAkr STHr ?&loop ( 4220 addr+2* [i+2*] )
|
2023-01-25 12:11:16 -05:00
|
|
|
POP2r POP2 POP2 ( )
|
2023-01-23 16:26:08 -05:00
|
|
|
#01 .dirty? STZ ( ; FIXME just redraw affected tiles )
|
|
|
|
JMP2r ( )
|
2023-01-25 12:11:16 -05:00
|
|
|
&skip POP2 POP2 JMP2r ( )
|
2023-01-23 11:14:45 -05:00
|
|
|
|
2023-01-23 21:18:50 -05:00
|
|
|
@exec-move-row ( c^ -> )
|
|
|
|
POP
|
2023-01-30 22:05:47 -05:00
|
|
|
#0001 read-arg-1 #0001 SUB2 ( row )
|
2023-01-23 21:18:50 -05:00
|
|
|
.cur-x LDZ2 ( col )
|
2023-01-30 22:05:47 -05:00
|
|
|
goto BRK
|
2023-01-23 21:18:50 -05:00
|
|
|
|
|
|
|
@exec-move-col ( c^ -> )
|
|
|
|
POP
|
|
|
|
.cur-y LDZ2 ( row )
|
2023-01-30 22:05:47 -05:00
|
|
|
#0001 read-arg-2 #0001 SUB2 ( col )
|
|
|
|
goto BRK
|
2023-01-23 21:18:50 -05:00
|
|
|
|
2023-01-22 23:44:00 -05:00
|
|
|
@exec-move ( c^ -> )
|
2023-01-23 16:26:08 -05:00
|
|
|
POP
|
2023-01-30 22:05:47 -05:00
|
|
|
#0001 read-arg-1 #0001 SUB2 ( row )
|
|
|
|
#0001 read-arg-2 #0001 SUB2 ( col )
|
|
|
|
goto BRK
|
2023-01-22 23:44:00 -05:00
|
|
|
|
2023-01-23 20:54:52 -05:00
|
|
|
@debug-esc ( c^ -> )
|
2023-01-30 22:05:47 -05:00
|
|
|
.debug LDZ ?&continue POP JMP2r &continue
|
2023-01-23 20:54:52 -05:00
|
|
|
;scratch STH2
|
|
|
|
LIT "1 STH2kr STA INC2r
|
|
|
|
LIT "b STH2kr STA INC2r
|
|
|
|
#20 STH2kr STA INC2r
|
|
|
|
STH2kr STA INC2r
|
|
|
|
#0a STH2r STA
|
2023-01-31 15:37:14 -05:00
|
|
|
#0005 .File1/len DEO2
|
|
|
|
;scratch .File1/w DEO2
|
2023-01-23 20:54:52 -05:00
|
|
|
JMP2r
|
|
|
|
|
2023-01-22 23:44:00 -05:00
|
|
|
@on-read-esc ( -> )
|
2023-01-30 22:05:47 -05:00
|
|
|
.Console/r DEI LIT "[ EQU ?start-csi
|
|
|
|
.Console/r DEI debug-esc
|
2023-01-22 23:44:00 -05:00
|
|
|
;on-read .Console/vect DEO2
|
2023-01-30 22:05:47 -05:00
|
|
|
!on-read
|
2023-01-22 23:44:00 -05:00
|
|
|
|
2023-01-24 11:59:01 -05:00
|
|
|
@start-csi ( -> )
|
2023-01-30 22:05:47 -05:00
|
|
|
reset-args
|
2023-01-24 11:59:01 -05:00
|
|
|
;on-read-csi .Console/vect DEO2
|
2023-01-22 23:44:00 -05:00
|
|
|
BRK
|
|
|
|
|
2023-01-22 21:07:10 -05:00
|
|
|
@on-read
|
2023-01-22 15:55:52 -05:00
|
|
|
.Console/r DEI
|
2023-01-30 22:05:47 -05:00
|
|
|
DUP ?&ok POP BRK
|
2023-01-25 12:11:16 -05:00
|
|
|
&ok ( #42 .tint STZ )
|
2023-01-30 22:05:47 -05:00
|
|
|
!read
|
2023-01-21 15:41:27 -05:00
|
|
|
|
2023-01-22 21:07:10 -05:00
|
|
|
@read ( c^ -> )
|
2023-01-30 22:05:47 -05:00
|
|
|
DUP #20 LTH ?read-ctrl
|
|
|
|
DUP #7f EQU ?read-del
|
|
|
|
!read-printable
|
2023-01-22 21:07:10 -05:00
|
|
|
|
|
|
|
@read-ctrl ( c^ -> )
|
2023-01-30 22:05:47 -05:00
|
|
|
DUP #07 EQU ?read-bel
|
|
|
|
DUP #08 EQU ?read-bs
|
|
|
|
DUP #09 EQU ?read-tab
|
|
|
|
DUP #0a EQU ?read-nl
|
|
|
|
DUP #0d EQU ?read-cr
|
|
|
|
DUP #1b EQU ?read-esc
|
2022-11-06 21:49:02 -05:00
|
|
|
|
2023-01-22 23:44:00 -05:00
|
|
|
@read-bel ( 07 -> )
|
2023-01-23 20:54:52 -05:00
|
|
|
POP BRK ( TODO: flash terminal )
|
2023-01-22 23:44:00 -05:00
|
|
|
|
|
|
|
@read-bs ( 08 -> )
|
2023-01-23 16:26:08 -05:00
|
|
|
POP
|
2023-01-30 22:05:47 -05:00
|
|
|
clear-cursor
|
|
|
|
#0001 back-n
|
|
|
|
draw-cursor
|
2023-01-23 16:26:08 -05:00
|
|
|
JMP2r
|
2023-01-22 23:44:00 -05:00
|
|
|
|
|
|
|
@read-esc ( 1b -> )
|
|
|
|
POP ;on-read-esc .Console/vect DEO2 BRK
|
|
|
|
|
|
|
|
@read-del ( 7f -> )
|
2023-01-23 20:54:52 -05:00
|
|
|
POP BRK
|
2022-11-06 21:49:02 -05:00
|
|
|
|
2023-01-21 22:54:20 -05:00
|
|
|
( @read-tab POP JMP2r )
|
|
|
|
@read-tab
|
|
|
|
POP
|
2023-01-29 23:07:03 -05:00
|
|
|
.cur-x LDZ2 ( x* )
|
|
|
|
NIP #07 AND #08 SUB ( i=(xlo&7)-8^ )
|
|
|
|
&loop ( i^ )
|
|
|
|
.tint LDZ #20 DUP2 ( i^ cell* cell* )
|
2023-01-30 22:05:47 -05:00
|
|
|
cur-addr STA2 ( i^ cell* ; addr<-cell )
|
|
|
|
draw-cell ( i^ )
|
|
|
|
forward ( i^ )
|
|
|
|
INC DUP ?&loop ( i+1^ )
|
2023-01-29 23:07:03 -05:00
|
|
|
POP BRK ( )
|
2023-01-21 22:54:20 -05:00
|
|
|
|
2022-11-06 21:49:02 -05:00
|
|
|
@read-cr ( 0d -> )
|
2023-01-30 22:05:47 -05:00
|
|
|
POP clear-cursor #0000 .cur-x STZ2 BRK
|
2022-11-06 21:49:02 -05:00
|
|
|
|
2023-01-22 21:07:10 -05:00
|
|
|
@at-max-y ( -> true? )
|
|
|
|
.cur-y LDZ2 .max-y LDZ2 EQU2 JMP2r
|
|
|
|
|
2022-11-06 21:49:02 -05:00
|
|
|
@read-nl ( 0a -> )
|
2023-01-30 22:05:47 -05:00
|
|
|
POP clear-cursor
|
|
|
|
at-max-y ?scroll down BRK
|
2023-01-22 15:21:57 -05:00
|
|
|
|
|
|
|
@read-printable ( c -> )
|
2023-01-30 22:05:47 -05:00
|
|
|
.tint LDZ SWP DUP2 cur-addr STA2
|
|
|
|
draw-cell
|
|
|
|
forward BRK
|
2022-11-06 21:49:02 -05:00
|
|
|
|
2023-01-22 23:44:00 -05:00
|
|
|
@goto ( y* x* -> )
|
2023-01-30 22:05:47 -05:00
|
|
|
clear-cursor
|
|
|
|
.max-x LDZ2 min .cur-x STZ2
|
|
|
|
.max-y LDZ2 min .cur-y STZ2
|
|
|
|
!draw-cursor
|
2023-01-22 23:44:00 -05:00
|
|
|
|
2023-01-22 21:07:10 -05:00
|
|
|
@forward-n ( n* -> )
|
2023-01-30 22:05:47 -05:00
|
|
|
clear-cursor
|
|
|
|
.cur-x LDZ2 ADD2 .max-x LDZ2 min .cur-x STZ2
|
|
|
|
!draw-cursor
|
2022-11-06 21:49:02 -05:00
|
|
|
|
2023-01-22 21:07:10 -05:00
|
|
|
@forward ( -> )
|
2023-01-30 22:05:47 -05:00
|
|
|
#0001 !forward-n
|
2023-01-22 21:07:10 -05:00
|
|
|
|
|
|
|
@back-n ( n* -> )
|
2023-01-30 22:05:47 -05:00
|
|
|
clear-cursor
|
|
|
|
.cur-x LDZ2 GTH2k ?&zero
|
|
|
|
SWP2 SUB2 !&done
|
2023-01-22 21:07:10 -05:00
|
|
|
&zero POP2 POP2 #0000
|
2023-01-30 22:05:47 -05:00
|
|
|
&done .cur-x STZ2 !draw-cursor
|
2023-01-22 21:07:10 -05:00
|
|
|
|
|
|
|
@up-n ( n* -> )
|
2023-01-30 22:05:47 -05:00
|
|
|
clear-cursor
|
|
|
|
.cur-y LDZ2 GTH2k ?&zero
|
|
|
|
SWP2 SUB2 !&done
|
2023-01-22 21:07:10 -05:00
|
|
|
&zero POP2 POP2 #0000
|
2023-01-30 22:05:47 -05:00
|
|
|
&done .cur-y STZ2 !draw-cursor
|
2023-01-22 21:07:10 -05:00
|
|
|
|
|
|
|
@down-n ( n* -> )
|
2023-01-30 22:05:47 -05:00
|
|
|
clear-cursor
|
|
|
|
.cur-y LDZ2 ADD2 .max-y LDZ2 min .cur-y STZ2
|
|
|
|
!draw-cursor
|
2023-01-22 15:21:57 -05:00
|
|
|
|
2022-11-06 21:49:02 -05:00
|
|
|
@down ( -> )
|
2023-01-30 22:05:47 -05:00
|
|
|
#0001 !down-n
|
2022-11-06 21:49:02 -05:00
|
|
|
|
2023-01-31 22:28:41 -05:00
|
|
|
@insert ( c^ -> )
|
2023-01-30 22:05:47 -05:00
|
|
|
.attr LDZ SWP !insert-cell
|
2023-01-28 10:40:47 -05:00
|
|
|
|
|
|
|
@insert-cell ( cell* -> )
|
2023-01-30 22:05:47 -05:00
|
|
|
.irm LDZ #00 EQU ?&replace ( cell* )
|
|
|
|
eol-addr #0001 SUB2 ( cell* last=eol-1* )
|
|
|
|
cur-addr ( cell* last* cur* )
|
2023-01-28 10:40:47 -05:00
|
|
|
&loop ( cell* last* pos* )
|
|
|
|
LDA2k OVR2 INC2 STA2 ( cell* last* pos* ; pos+1<-pos )
|
2023-01-30 22:05:47 -05:00
|
|
|
INC2 LTH2k ?&loop ( cell* last pos+1* )
|
2023-01-28 10:40:47 -05:00
|
|
|
POP2 POP2 ( cell* )
|
|
|
|
&replace ( cell* )
|
2023-01-31 22:28:41 -05:00
|
|
|
cur-addr STA2 JMP2r ( )
|
2023-01-28 10:40:47 -05:00
|
|
|
|
2023-01-30 10:59:52 -05:00
|
|
|
@forward-n-tabs ( n* -> )
|
|
|
|
#0001 SUB2 #0008 MUL2 ( i=(n-1)8* )
|
|
|
|
#0008 .cur-x LDZ2 #0007 AND2 SUB2 ( i* 8-cur%8* )
|
2023-01-30 22:05:47 -05:00
|
|
|
ADD2 !forward-n ( )
|
2023-01-30 10:59:52 -05:00
|
|
|
|
|
|
|
@insert-n-lines ( n* -> )
|
|
|
|
.col-bytes LDZ2 MUL2 STH2 ( [i*] )
|
2023-01-30 22:05:47 -05:00
|
|
|
bol-addr ( bound* [i*] )
|
|
|
|
limit-addr STH2kr ( bound* limit* i* [i*] )
|
2023-01-30 10:59:52 -05:00
|
|
|
INC2 INC2 SUB2 ( bound* start=limit-i-2* [i*] )
|
|
|
|
&loop ( bound* pos* [i*] )
|
|
|
|
LDA2k OVR2 STH2kr ADD2 ( bound* pos* x* pos+i* [i*] )
|
|
|
|
STA2 ( bound* pos* [i*] ; pos+i<-x )
|
2023-01-31 22:30:13 -05:00
|
|
|
#0220 OVR2 STA2 ( bound* pos* [i*] ; pos<-4220 )
|
2023-01-30 10:59:52 -05:00
|
|
|
#0002 SUB2 ( bound* pos-2* [i*] )
|
2023-01-30 22:05:47 -05:00
|
|
|
GTH2k #00 EQU ?&loop ( bound* pos-2* [i*] )
|
2023-01-30 10:59:52 -05:00
|
|
|
POP2 POP2 POP2r ( )
|
|
|
|
#01 .dirty? STZ JMP2r ( )
|
|
|
|
|
2023-01-28 10:40:47 -05:00
|
|
|
@insert-n-spaces ( n* -> )
|
|
|
|
STH2 ( [n*] )
|
2023-01-30 22:05:47 -05:00
|
|
|
.irm LDZ #00 EQU ?&replace ( [n*] )
|
|
|
|
eol-addr #0001 SUB2 ( last* [n*] )
|
2023-01-28 10:40:47 -05:00
|
|
|
STH2kr DUP2 ADD2 SUB2 ( start=last-2n* [n*] )
|
2023-01-30 22:05:47 -05:00
|
|
|
cur-addr SWP2 ( end* start* [n*] )
|
2023-01-28 10:40:47 -05:00
|
|
|
DUP2kr ADD2r ( end* start* [n* 2n*] )
|
|
|
|
&loop ( end* pos* [n* 2n*] )
|
|
|
|
LDA2k OVR2 STH2kr ADD2 ( end* pos* x* pos+2n* )
|
|
|
|
STA2 #0002 SUB2 ( end* pos-2* [n* 2n*] )
|
2023-01-30 22:05:47 -05:00
|
|
|
GTH2k #00 EQU ?&loop ( end* pos-2* [n* 2n*] )
|
2023-01-28 10:40:47 -05:00
|
|
|
POP2 POP2 POP2r ( [n*] )
|
|
|
|
&replace ( [n*] )
|
|
|
|
LIT2r 0000 SWP2r SUB2r ( [-n*] )
|
2023-01-31 22:30:13 -05:00
|
|
|
#0220 cur-addr ( 4220 cur* [-n*] )
|
2023-01-28 10:40:47 -05:00
|
|
|
&loop2 ( 4220 pos* [-i*] )
|
|
|
|
STA2k INC2 INC2 INC2r ( 4220 pos+2* [-i+1*] )
|
2023-01-30 22:05:47 -05:00
|
|
|
ORAkr STHr ?&loop2 ( 4220 pos+2* [-i+1*] )
|
2023-01-30 14:25:03 -05:00
|
|
|
POP2 POP2 POP2r ( )
|
|
|
|
#01 .dirty? STZ JMP2r ( )
|
2023-01-28 10:40:47 -05:00
|
|
|
|
2023-01-29 23:07:03 -05:00
|
|
|
( starts with cursor pos )
|
|
|
|
@delete-n-chars ( n* -> )
|
|
|
|
DUP2 ADD2 STH2 ( [i=2n*] )
|
2023-01-30 22:05:47 -05:00
|
|
|
eol-addr STH2kr SUB2 ( limit=eol-i* [i*] )
|
|
|
|
cur-addr ( limit* start* [i*] )
|
2023-01-29 23:07:03 -05:00
|
|
|
&loop ( limit* pos* [n*] )
|
|
|
|
DUP2 STH2kr ADD2 LDA2k ( limit* pos* pos+i* x* [i*] )
|
2023-01-31 22:30:13 -05:00
|
|
|
#0220 ROT2 STA2 ( limit* pos* x* [i*] ; pos+i<-4220 )
|
2023-01-29 23:07:03 -05:00
|
|
|
OVR2 STA2 INC2 INC2 ( limit* pos+2* [i*] ; pos<-x )
|
2023-01-30 22:05:47 -05:00
|
|
|
GTH2k ?&loop ( limit* pos+2* [i*] )
|
2023-01-29 23:07:03 -05:00
|
|
|
POP2 POP2 POP2r ( )
|
|
|
|
#01 .dirty? STZ JMP2r ( )
|
|
|
|
|
|
|
|
( starts below current line )
|
|
|
|
@delete-n-lines ( n* -> )
|
2023-01-30 10:59:52 -05:00
|
|
|
.col-bytes LDZ2 MUL2 STH2 ( [n*] )
|
2023-01-30 22:05:47 -05:00
|
|
|
limit-addr STH2kr SUB2 ( limit* [n*] )
|
|
|
|
eol-addr ( limit* start* [n*] )
|
|
|
|
!delete-n-chars/loop
|
2023-01-29 23:07:03 -05:00
|
|
|
|
2022-11-06 21:49:02 -05:00
|
|
|
@scroll
|
2023-01-30 22:05:47 -05:00
|
|
|
limit-addr STH2
|
2023-01-29 23:07:03 -05:00
|
|
|
;cells .col-bytes LDZ2 ADD2 STH2
|
2022-11-06 21:49:02 -05:00
|
|
|
&loop
|
2023-01-31 22:30:13 -05:00
|
|
|
STH2kr LDA2 #0220 STH2kr STA2
|
2023-01-29 23:07:03 -05:00
|
|
|
STH2kr .col-bytes LDZ2 SUB2 STA2
|
2023-01-30 22:05:47 -05:00
|
|
|
INC2r INC2r GTH2kr STHr ?&loop
|
2022-11-06 21:49:02 -05:00
|
|
|
POP2r POP2r
|
2023-01-22 15:21:57 -05:00
|
|
|
#01 .dirty? STZ
|
2023-01-30 22:05:47 -05:00
|
|
|
draw-cursor BRK
|
2022-11-06 21:49:02 -05:00
|
|
|
|
|
|
|
( 0 <= index < 128 )
|
|
|
|
@load-tile ( index^ -> )
|
|
|
|
#00 SWP #30 SFT2
|
|
|
|
;ascii ADD2 .Screen/addr DEO2
|
|
|
|
JMP2r
|
|
|
|
|
2023-01-25 12:11:16 -05:00
|
|
|
( bits: Rx xx FF BB )
|
|
|
|
( - R: reversed [0=normal, 1=reversed] )
|
|
|
|
( - F: foreground [0:black, 1:dim, 2:normal, 3:bright] )
|
|
|
|
( - B: background [0:black, 1:dim, 2:normal, 3:bright] )
|
|
|
|
@update-tint ( -> )
|
|
|
|
.attr LDZ
|
2023-01-30 22:05:47 -05:00
|
|
|
DUP #80 LTH ?&ok
|
2023-01-25 12:11:16 -05:00
|
|
|
#80 EOR DUP #02 SFT SWP #20 SFT #0c AND ORA
|
2023-01-31 22:30:13 -05:00
|
|
|
&ok .tint STZ JMP2r
|
2022-11-06 21:49:02 -05:00
|
|
|
|
2023-01-25 12:11:16 -05:00
|
|
|
@reverse-tint ( tint^ -> tint^ )
|
|
|
|
#0f AND ( x=tint&0f )
|
|
|
|
DUP #02 SFT SWP ( x>>2 x )
|
|
|
|
#03 AND #20 SFT ( x>>2 (x&3)<<2 )
|
2023-01-31 22:30:13 -05:00
|
|
|
ORA ( res=40|x>>2|(x&3)<<2 )
|
2023-01-25 12:11:16 -05:00
|
|
|
JMP2r ( res^ )
|
|
|
|
|
|
|
|
( cell* = tint^ c^ )
|
|
|
|
@draw-cell ( cell* -> )
|
|
|
|
SWP STH ( c^ [tint^] )
|
2023-01-30 22:05:47 -05:00
|
|
|
DUP #80 LTH ?&draw ( c^ [tint^] )
|
2023-01-25 12:11:16 -05:00
|
|
|
#80 SUB ( c-80^ [tint^] )
|
2023-01-30 22:05:47 -05:00
|
|
|
&draw load-tile ( [tint^] )
|
2023-01-25 12:11:16 -05:00
|
|
|
STHr .Screen/sprite DEO ( )
|
|
|
|
JMP2r ( )
|
2022-11-06 21:49:02 -05:00
|
|
|
|
2023-01-22 23:44:00 -05:00
|
|
|
@next-arg ( c^ -> )
|
|
|
|
POP
|
|
|
|
( TODO: check if we already have max args )
|
2023-01-25 12:40:46 -05:00
|
|
|
;args/pos LDA2k INC2 INC2 SWP2 STA2 BRK
|
2023-01-22 23:44:00 -05:00
|
|
|
|
|
|
|
@add-to-arg ( c^ -> )
|
|
|
|
LIT "0 SUB LITr 00 STH ( [digit*] )
|
|
|
|
;args/pos LDA2 LDA2k ( addr* value* [digit*] )
|
|
|
|
#000a MUL2 STH2r ADD2 ( addr* value*10+digit )
|
|
|
|
SWP2 STA2 BRK
|
|
|
|
|
|
|
|
@read-arg-1 ( default* -> n* )
|
2023-01-30 22:05:47 -05:00
|
|
|
;args LDA2 !max
|
2023-01-22 23:44:00 -05:00
|
|
|
@read-arg-2 ( default* -> n* )
|
2023-01-30 22:05:47 -05:00
|
|
|
;args INC2 INC2 LDA2 !max
|
2023-01-22 23:44:00 -05:00
|
|
|
|
|
|
|
@reset-args ( -> )
|
|
|
|
;args ;args/pos STA2
|
|
|
|
#0000 ;args LITr f8
|
|
|
|
&loop STA2k INC2 INC2
|
2023-01-30 22:05:47 -05:00
|
|
|
INCr STHkr ?&loop
|
2023-01-22 23:44:00 -05:00
|
|
|
POPr POP2 POP2 JMP2r
|
|
|
|
|
2023-01-29 23:07:03 -05:00
|
|
|
@debug-log "debug_term.log 00
|
2023-01-25 23:37:56 -05:00
|
|
|
@scratch $40 &pos $2
|
|
|
|
|
|
|
|
@scratch-write ( c^ -> )
|
|
|
|
;scratch/pos LDA2 STA
|
|
|
|
;scratch/pos LDA2k INC2 SWP2 STA2 JMP2r
|
|
|
|
@scratch-len ( -> n* )
|
|
|
|
;scratch/pos LDA2 ;scratch SUB2 JMP2r
|
|
|
|
@reset-scratch
|
|
|
|
;scratch ;scratch/pos STA2 JMP2r
|
2023-01-23 20:54:52 -05:00
|
|
|
|
2023-01-22 23:44:00 -05:00
|
|
|
( store up to 8 arguments for control sequences )
|
|
|
|
@args $10 &pos $2
|
|
|
|
|
2023-01-31 22:28:41 -05:00
|
|
|
( paste buffer )
|
|
|
|
@paste-buf $100
|
|
|
|
|
2023-01-25 12:11:16 -05:00
|
|
|
( 128 1-bit 8x8 tiles for ASCII 7-bit characters )
|
|
|
|
@ascii
|
|
|
|
~chr/ascii.tal
|
2023-01-22 15:21:57 -05:00
|
|
|
|
2023-01-30 23:01:34 -05:00
|
|
|
@meta 00
|
|
|
|
&name "determ 0a
|
|
|
|
&details "ansi 20 "terminal 20 "emulator 0a
|
|
|
|
&author "by 20 "d_m 0a
|
|
|
|
&date "3 20 "jan 20 2023 00
|
2023-01-31 15:37:14 -05:00
|
|
|
01
|
|
|
|
( device mask ) 41 0d07
|
2023-01-30 23:01:34 -05:00
|
|
|
|
2023-01-25 12:11:16 -05:00
|
|
|
( store tint+char for each screen position )
|
|
|
|
@cells $1900 ( 80 x 40 x 2 )
|