diff --git a/term.tal b/term.tal index d3796ac..7ed66da 100644 --- a/term.tal +++ b/term.tal @@ -561,22 +561,25 @@ @exec-move-row ( c^ -> ) POP - #0001 read-arg-1 #0001 SUB2 ( row ) - .cur-x LDZ2 ( col ) + #0001 read-arg-1 dec-floor ( row ) + .cur-x LDZ2 ( col ) goto BRK @exec-move-col ( c^ -> ) POP - .cur-y LDZ2 ( row ) - #0001 read-arg-2 #0001 SUB2 ( col ) + .cur-y LDZ2 ( row ) + #0001 read-arg-2 dec-floor ( col ) goto BRK @exec-move ( c^ -> ) POP - #0001 read-arg-1 #0001 SUB2 ( row ) - #0001 read-arg-2 #0001 SUB2 ( col ) + #0001 read-arg-1 dec-floor ( row ) + #0001 read-arg-2 dec-floor ( col ) goto BRK +@dec-floor ( x* -> x==0 ? 0* : x-1* ) + ORAk ?&sub JMP2r &sub #0001 SUB2 JMP2r + @debug-esc ( c^ -> ) .debug LDZ ?&continue POP JMP2r &continue ;scratch STH2 @@ -667,7 +670,7 @@ POP BRK ( ) @read-cr ( 0d -> ) - POP clear-cursor #0000 .cur-x STZ2 BRK + POP clear-cursor #0000 .cur-x STZ2 draw-cursor BRK @at-max-y ( -> true? ) .cur-y LDZ2 .max-y LDZ2 EQU2 JMP2r @@ -677,7 +680,6 @@ at-max-y ?scroll down BRK @read-printable ( c -> ) -( DUP debug-read ) .tint LDZ SWP DUP2 cur-addr STA2 draw-cell forward BRK @@ -723,31 +725,31 @@ @insert-cell ( cell* -> ) .irm LDZ #00 EQU ?&replace ( cell* ) - eol-addr #0001 SUB2 ( cell* last=eol-1* ) - cur-addr ( cell* last* cur* ) - &loop ( cell* last* pos* ) - LDA2k OVR2 INC2 STA2 ( cell* last* pos* ; pos+1<-pos ) + eol-addr #0001 SUB2 ( cell* last=eol-1* ) + cur-addr ( cell* last* cur* ) + &loop ( cell* last* pos* ) + LDA2k OVR2 INC2 STA2 ( cell* last* pos* ; pos+1<-pos ) INC2 LTH2k ?&loop ( cell* last pos+1* ) - POP2 POP2 ( cell* ) - &replace ( cell* ) - cur-addr STA2 JMP2r ( ) + POP2 POP2 ( cell* ) + &replace ( cell* ) + cur-addr STA2 JMP2r ( ) @forward-n-tabs ( n* -> ) - #0001 SUB2 #0008 MUL2 ( i=(n-1)8* ) + dec-floor #0008 MUL2 ( i=(n-1)8* ) #0008 .cur-x LDZ2 #0007 AND2 SUB2 ( i* 8-cur%8* ) - ADD2 !forward-n ( ) + ADD2 !forward-n ( ) @insert-n-lines ( n* -> ) .col-bytes LDZ2 MUL2 STH2 ( [i*] ) - bol-addr ( bound* [i*] ) - limit-addr STH2kr ( bound* limit* i* [i*] ) + bol-addr ( bound* [i*] ) + limit-addr STH2kr ( bound* limit* i* [i*] ) 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 ) #0220 OVR2 STA2 ( bound* pos* [i*] ; pos<-4220 ) #0002 SUB2 ( bound* pos-2* [i*] ) - GTH2k #00 EQU ?&loop ( bound* pos-2* [i*] ) + GTH2k #00 EQU ?&loop ( bound* pos-2* [i*] ) POP2 POP2 POP2r ( ) #01 .dirty? STZ JMP2r ( )