early version of goto-line working

This commit is contained in:
~d6 2022-02-10 01:40:48 -05:00
parent df971a1fc8
commit f64806dbd4
1 changed files with 47 additions and 8 deletions

View File

@ -58,8 +58,6 @@
|0100
;read-filename .Console/vector DEO2
( ;demo-path ;open-file JSR2 )
( use this if hardcoding to 80x24 )
( ;setup-80x24 JSR2 )
@ -244,6 +242,29 @@
;draw-all JSR2
BRK
@goto-line ( -> )
#0060 ;jump-to-line JSR2
;draw-all JSR2 BRK
@jump-to-line ( n* -> )
;term/rows LDA2 #0002 DIV2 LTH2k ( n rows/2 n<rows/2? ) ,&early JCN
OVR2 SWP2 SUB2 ( n n-rows/2 )
;buffer/line-count LDA2 ( n n-rows/2 lines )
;term/rows LDA2 SUB2 ( n n-rows/2 lines-rows )
GTH2k ( n n-rows/2 lines-rows n-rows/2>lines-rows? )
,&late JCN ( n n-rows/2 lines-rows )
POP2 ,&finish JMP
&early ( n rows/2 )
POP2 ,&finish JCN
&late ( n n-rows/2 lines-rows )
NIP2 ,&finish JCN
&finish ( n o )
SUB2k STH2
;abs-line JSR2 ;buffer/offset STA2
#00 ;cursor/col STA
POP2 STH2r NIP ;cursor/row STA
JMP2r
( TODO: M-v for page up and M-> for goto end )
( M-f and M-b for next/previous word )
( M-n and M-p for next/previous paragraph )
@ -252,6 +273,7 @@
#00 ;saw-esc STA
.Console/read DEI LIT '< EQU ( M-< ) ;goto-start JCN2
.Console/read DEI LIT '> EQU ( M-> ) ;goto-end JCN2
.Console/read DEI LIT 'g EQU ( M-g ) ;goto-line JCN2
BRK
( TODO: C-g or C-h for help )
@ -337,6 +359,19 @@
INC2 INC2r ,&loop JMP
&end POP2 STH2r JMP2r
@abs-line ( y* -> s* )
#0000 SWP2 SUB2 STH2 ( [-y] )
;buffer/data LDA2 ( addr )
&newline ( addr [-y] )
STH2kr ORA ,&loop JCN ,&done JMP
&loop ( addr [-y] )
LDAk #00 EQU ,&not-found JCN ( addr [-y] )
LDAk #0a EQU ,&found JCN ( addr [-y] )
INC2 ,&loop JMP ( addr+1 [-y] )
&found INC2 INC2r ( addr+1 [-y+1] ) ,&newline JMP
&done POP2r JMP2r
&not-found POP2 POP2r #0000 JMP2r
( line number relative to the offset, starting at 0 )
@rel-line ( y^ -> s* )
#00 SWP SUB STH ( [-y] )
@ -435,13 +470,14 @@
&do2 #000a ;mod-div2 JSR2 NIP ;emit-digit JSR2
&do1 NIP ;emit-digit JSR2 JMP2r
@tmp [ &pos :tmp/data &data $100 ]
@term [ &cols 0050 &rows 0018 ] ( 80x24 )
@input-error "input 20 "error 00
@demo-path "math32.tal 00
( col is 0-79, row is 0-23 )
@tmp [ &pos :tmp/data
&data $100 ]
@term [ &cols 0050
&rows 0018 ]
@cursor [ &col 00 &row 00 ]
( did we just see ESC? )
@ -450,4 +486,7 @@
( |1ffc )
( offset is address of the first visible line )
( size is total size of data in bytes )
@buffer [ &limit 0000 &offset :buffer/data &data $8000 ]
@buffer [ &limit 0000
&offset :buffer/data
&line-count 0000
&data $8000 ]