very basic autowrap

This commit is contained in:
~d6 2023-02-15 11:04:09 -05:00
parent 3c471499c9
commit d711a6106e
1 changed files with 28 additions and 13 deletions

View File

@ -98,6 +98,7 @@
@cols $2 ( width in characters )
@cur-x $2 ( cursor x: 0 <= cur-x < cols )
@cur-y $2 ( cursor y: 0 <= cur-y < rows )
@cur-wrap $1 ( did cursor just wrap? )
@max-x $2 ( cols-1 )
@max-y $2 ( rows-1 )
@col-bytes $2 ( 2*cols )
@ -130,7 +131,7 @@
( 80 cols x 24 rows + 1 col for padding )
#0018 .rows STZ2
#0051 .cols STZ2
#0050 .cols STZ2
( set initial cursor )
#0000 .cur-x STZ2
@ -881,9 +882,12 @@
&ok
DUP #20 LTH ?read-ctrl
DUP #7f EQU ?read-del
( read printable )
.tint LDZ SWP DUP2 insert-cell
draw-cell forward BRK
.tint LDZ SWP DUP2 insert-cell draw-cell
forward
( TODO: all cursor movement should potentially set/unset this flag )
( so this should move into forward and everything else )
.cur-x LDZ2 .max-x LDZ2 EQU2 .cur-wrap STZ
BRK
@read-ctrl ( c^ -> BRK )
DUP #07 EQU ?read-bel
@ -930,7 +934,9 @@
.cur-y LDZ2 .max-y LDZ2 EQU2 JMP2r
@read-nl ( 0a -> BRK )
POP clear-cursor at-max-y ?scroll down BRK
POP clear-cursor at-max-y ?&scrolling
down BRK
&scrolling scroll BRK
@goto ( y* x* -> )
clear-cursor
@ -968,7 +974,16 @@
@down ( -> )
#0001 !down-n
@maybe-autowrap ( -> )
.cur-wrap LDZ #00 EQU ?&skip
clear-cursor #0000 .cur-x STZ2
at-max-y ?&scrolling
.cur-y LDZ2k INC2 ROT STZ2
&skip JMP2r
&scrolling #010e DEO !scroll
@insert-cell ( cell* -> )
maybe-autowrap ( cell* )
.irm LDZ #00 EQU ?&replace ( cell* )
cur-addr ( cell* lim* )
eol-addr #0002 SUB2 ( cell* lim* last=eol-2* )
@ -1037,16 +1052,16 @@
eol-addr ( limit* start* [n*] )
!delete-n-chars/loop
@scroll ( -> BRK )
limit-addr STH2
;cells .col-bytes LDZ2 ADD2 STH2
&loop
STH2kr LDA2 #0200 STH2kr STA2
STH2kr .col-bytes LDZ2 SUB2 STA2
INC2r INC2r GTH2kr STHr ?&loop
@scroll ( -> )
limit-addr STH2 ( [lim*] )
;cells .col-bytes LDZ2 ADD2 STH2 ( [lim* addr*] )
&loop ( [lim* pos*] )
STH2kr LDA2 #0200 STH2kr STA2 ( cell* [lim* pos* cell*] ; pos<-0200 )
STH2kr .col-bytes LDZ2 SUB2 STA2 ( [lim* pos*] ; pos-cb<-cell )
INC2r INC2r GTH2kr STHr ?&loop ( [lim* pos+2*] )
POP2r POP2r
#01 .dirty STZ
draw-cursor BRK
!draw-cursor
( bits: Rx xx FF BB )
( - R: reversed [0=normal, 1=reversed] )