cursor/row refactors: prepare for absolute row addressing

This commit is contained in:
~d6 2022-03-06 15:35:14 -05:00
parent 27e5d42652
commit f48bce6be3
1 changed files with 37 additions and 22 deletions

View File

@ -69,6 +69,7 @@
( startup )
|0100 ;startup JMP2
( code to run on startup )
@startup ;read-filename .Console/vector DEO2 BRK
( ERROR HANDLING )
@ -187,7 +188,7 @@
;draw-statusbar JSR2 ;draw-cursor JSR2
,&skip JMP
&next-line #0000 ;cursor/col STA2
;cursor/row LDA2k INC2 SWP2 STA2
;inc-row JSR2
;ensure-visible-cursor JSR2
;draw-cursor JSR2
&skip BRK
@ -202,8 +203,8 @@
@up ( -> )
;cur-abs-row JSR2 #0000 EQU2 ,&done JCN
;cur-row JSR2 #0001 LTH2 ,&screen-up JCN
;cursor/row LDA2k #0001 SUB2 SWP2 STA2
;cur-rel-row JSR2 #0001 LTH2 ,&screen-up JCN
;dec-row JSR2
;draw-statusbar JSR2
;draw-cursor JSR2 BRK
&screen-up
@ -214,7 +215,7 @@
@down ( -> )
;cur-abs-row JSR2 ;last-abs-row JSR2 EQU2 ,&done JCN
;cursor/row LDA2k INC2 SWP2 STA2
;inc-row JSR2
;ensure-visible-cursor JSR2
;draw-statusbar JSR2
;draw-cursor JSR2 BRK
@ -229,14 +230,12 @@
;buffer/line-offset STA2
;ensure-visible-cursor JSR2
;draw-all JSR2 BRK
&near-bof POP2 POP2 &xyz
;buffer/data ;buffer/offset STA2
#0000 ;buffer/line-offset STA2
#0000 ;cursor/row STA2
&near-bof POP2 POP2
;zero-row JSR2
#0000 ;cursor/col STA2
;draw-all JSR2 BRK
&at-bof
#0000 ;cursor/row STA2
;zero-row JSR2
#0000 ;cursor/col STA2
;draw-cursor JSR2 BRK
@ -250,8 +249,8 @@
;draw-all JSR2 BRK
&near-eof
;buffer/line-count LDA2
;buffer/line-offset LDA2 INC2
SUB2 ;cursor/row STA2
;buffer/line-offset LDA2 INC2 SUB2
;cursor/row STA2
;cur-len JSR2 ;cursor/col STA2
;draw-cursor JSR2 BRK
@ -282,7 +281,7 @@
@newline ( c^ -> )
#0a ;cur-pos JSR2 ;shift-right JSR2
#0000 ;cursor/col STA2
;cursor/row LDA2k INC2 SWP2 STA2
;inc-row JSR2
;buffer/line-count LDA2k INC2 SWP2 STA2
;ensure-visible-cursor JSR2
;draw-all JSR2
@ -344,10 +343,8 @@
;draw-all JSR2 BRK
@goto-start ( -> )
;buffer/data ;buffer/offset STA2
#0000 ;buffer/line-offset STA2
;zero-row JSR2
#0000 ;cursor/col STA2
#0000 ;cursor/row STA2
;draw-all JSR2
BRK
@ -376,7 +373,7 @@
JMP2r
@ensure-visible-cursor
;cur-row JSR2 ;term/rows LDA2 LTH2 ,&noop JCN
;cur-rel-row JSR2 ;term/rows LDA2 LTH2 ,&noop JCN
;cur-abs-row JSR2 ;jump-to-line JSR2
;draw-all JSR2
&noop JMP2r
@ -464,7 +461,7 @@
@draw-cursor ( -> )
;cur-w-col JSR2 ;term/lmargin LDA2 ADD2
;cur-row JSR2
;cur-rel-row JSR2
;term-move-cursor JMP2 ( JSR2 JMP2r )
@draw-statusbar ( -> )
@ -638,13 +635,13 @@
&not-found ;rel-line-error ;error! JMP2
@cur-line ( -> s* )
;cur-row JSR2 ;rel-line JMP2 ( JSR2 JMP2r )
;cur-rel-row JSR2 ;rel-line JMP2 ( JSR2 JMP2r )
@cur-pos ( -> s* )
;cur-line JSR2 ;cur-col JSR2 ADD2 JMP2r
@cur-abs-row ( -> n* )
;cur-row JSR2 ;buffer/line-offset LDA2 ADD2 JMP2r
;cur-rel-row JSR2 ;buffer/line-offset LDA2 ADD2 JMP2r
@last-abs-row ( -> n* )
;buffer/line-count LDA2 #0001 SUB2 JMP2r
@ -688,9 +685,27 @@
&next LDAk #09 EQU ,&tabs JCN INC2 INC2r ,&loop JMP
&tabs INC2 ;config/tab-width LDA2 STH2 ADD2r ,&loop JMP
@cur-row ( -> row* )
@cur-rel-row ( -> row* )
;cursor/row LDA2 JMP2r
@set-abs-row ( n* -> )
;buffer/line-offset LDA2 SUB2 ;cursor/row STA2 JMP2r
@set-rel-row ( n* -> )
;cursor/row STA2 JMP2r
@zero-row ( -> )
;buffer/data ;buffer/offset STA2
#0000 ;buffer/line-offset STA2
#0000 ;cursor/row STA2
JMP2r
@inc-row ( -> )
;cursor/row LDA2k INC2 SWP2 STA2 JMP2r
@dec-row ( -> )
;cursor/row LDA2k #0001 SUB2 SWP2 STA2
@last-pos ( -> addr* )
;buffer/limit LDA2 #0001 SUB2 JMP2r