more progress

This commit is contained in:
~d6 2023-01-22 15:21:57 -05:00
parent 4900ec17f0
commit 74ee535179
1 changed files with 78 additions and 50 deletions

128
term.tal
View File

@ -4,18 +4,17 @@
|80 @Controller [ &vect $2 &button $1 &key $1 ]
|0000
@dirty $1 ( screen needs redraw? )
@tint $1 ( draw mode. 01=regular, 04=inverted )
@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 )
@cols $2 ( width in characters )
@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 )
@cur-x $2 ( cursor x: 0 <= cur-x < cols )
@cur-y $2 ( cursor y: 0 <= cur-y < rows )
@buffer $c8 ( input buffer, 200 bytes )
@pos $1 ( buffer position )
@subinput $1 ( reading from subprocess? )
@buffer $c8 ( input buffer, 200 bytes )
|0100
( 80 cols x 24 rows )
@ -31,9 +30,9 @@
#0c88 .System/g DEO2
#0c0f .System/b DEO2
( set pos, subinput flag )
( set pos )
.buffer .pos STZ
#00 .subinput STZ
.buffer .max STZ
( clear screen for initial draw )
;clear-screen JSR2
@ -47,7 +46,7 @@
BRK
@clear-screen
#01 .dirty STZ
#01 .dirty? STZ
;screen STH2
#0000 &yloop
#0000 &xloop
@ -60,7 +59,7 @@
@redraw
#41 .tint STZ
.dirty LDZ #00 EQU ,&done JCN
.dirty? LDZ #00 EQU ,&done JCN
;screen STH2
#0000 DUP2 .Screen/y DEO2
&yloop
@ -77,7 +76,7 @@
POP2 POP2r
;show-cursor JSR2
#00 .dirty STZ
#00 .dirty? STZ
&done BRK
@hide-cursor
@ -99,14 +98,51 @@
;draw-tile JMP2
@on-key
#00 .subinput STZ
.Controller/key DEI #00 EQU ,&skip JCN
#41 .tint STZ
.Controller/key DEI ;read JSR2
.Controller/key DEI ;send JSR2
&skip BRK
@send ( byte^ -> )
DUP #20 LTH ;send-ctrl JCN2
DUP #7f GTH ;send-8bit JCN2
DUP #7f EQU ;send-del JCN2
;send-printable JMP2
@send-ctrl ( byte^ -> )
DUP #08 EQU ;send-bs JCN2
( DUP #09 EQU ;send-tab JCN2
DUP #0a EQU ;send-nl JCN2
DUP #1b EQU ;send-esc JCN2 )
DUP #0d EQU ;send-cr JCN2
POP JMP2r
@send-8bit ( byte^ -> )
POP JMP2r
@send-del ( 7f -> )
POP JMP2r
@send-bs ( 08 -> )
POP ;back JSR2
( #20 ;cursor-addr JSR2 STA ) JMP2r
@send-cr ( 0d -> )
POP
;emit-line JSR2
;read-cr JSR2 ;read-nl JMP2
@send-printable ( c -> )
.pos LDZ STZk INC .pos STZ
;read-printable JMP2
@emit-line ( -> )
.pos LDZ .buffer
&loop GTHk ,&next JCN ,&done JMP
&next LDZk .Console/w DEO INC ,&loop JMP
&done #0a .Console/w DEO .buffer .pos STZ JMP2r
@on-input
#01 .subinput STZ
.Console/r DEI #00 EQU ,&skip JCN
#41 .tint STZ
.Console/r DEI ;read JSR2
@ -120,7 +156,7 @@
DUP #0d EQU ;read-cr JCN2
DUP #1b EQU ;read-esc JCN2
DUP #7f EQU ;read-del JCN2
;read-normal JMP2
;read-printable JMP2
( TODO: we need line-editing! )
@read-bel POP JMP2r
@ -128,18 +164,9 @@
@read-esc POP JMP2r
@read-del POP JMP2r
@write-line ( -> )
.pos LDZ .buffer
&loop GTHk ,&next JCN ,&done JMP
&next LDZk .Console/w DEO INC ,&loop JMP
&done #0a .Console/w DEO .buffer .pos STZ JMP2r
( @read-tab POP JMP2r )
@read-tab
POP
.subinput LDZ ,&display JCN
#01 #0e DEO JMP2r ( POP POP2r #0000 DIV )
&display
.cur-x LDZ2 NIP #07 AND #08 SUB
&loop
#20 DUP ;cursor-addr JSR2 STA
@ -149,18 +176,15 @@
POP JMP2r
@read-cr ( 0d -> )
POP
.subinput LDZ ,&display JCN
;write-line JSR2
&display
;hide-cursor JSR2
#0000 .cur-x STZ2
;down JMP2
POP ;hide-cursor JSR2 #0000 .cur-x STZ2 JMP2r
@read-nl ( 0a -> )
POP
JMP2r
( ,read-cr JMP )
POP ;hide-cursor JSR2 ;down JMP2
@read-printable ( c -> )
DUP ;cursor-addr JSR2 STA
;draw-tile JSR2
;forward JMP2
@forward ( -> )
.cur-x LDZ2 INC2 DUP2 .cols LDZ2 LTH2 ,&ok JCN
@ -168,6 +192,15 @@
&ok .cur-x STZ2
;show-cursor JMP2
@back ( -> )
.cur-x LDZ2 #0000 GTH2 ,&continue JCN
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
@down ( -> )
.cur-y LDZ2 INC2 DUP2 .rows LDZ2 LTH2 ,&ok JCN
POP2 ;scroll JMP2
@ -182,7 +215,7 @@
STH2kr .cols LDZ2 SUB2 STA
INC2r GTH2kr STHr ,&loop JCN
POP2r POP2r
#01 .dirty STZ
#01 .dirty? STZ
;show-cursor JMP2
@cursor-addr ( -> addr* )
@ -190,14 +223,6 @@
.cur-x LDZ2 ADD2 ;screen ADD2
JMP2r
@read-normal ( c -> )
.subinput LDZ ,&display JCN
.pos LDZ STZk INC .pos STZ
&display
DUP ;cursor-addr JSR2 STA
;draw-tile JSR2
;forward JMP2
( 0 <= c < 256 )
@draw-tile ( c^ -> )
DUP #80 LTH
@ -226,7 +251,10 @@
@ascii
~chr/ascii.tal
( screen to store characters for redraw, etc. )
( @screen $0800 ( 64 x 32 ) )
@screen $0c80 ( 64 x 32 )
( store characters for redraw, etc. )
@screen $0c80 ( 80 x 40 )
@end-screen
( store attributes for redraw, etc. )
@attrs $0c80 ( 80 x 40 )
@end-attrs