copying to .snarf works (max 4096 bytes)

This commit is contained in:
~d6 2023-02-09 23:22:16 -05:00
parent 59c6675ff2
commit ef647e4ab9
1 changed files with 70 additions and 19 deletions

View File

@ -16,6 +16,7 @@
( 10. investigate neauoire mosh flicker. theory: tmux running under non-ansi TERM ) ( 10. investigate neauoire mosh flicker. theory: tmux running under non-ansi TERM )
( 11. crawl has screen-clearing issues ) ( 11. crawl has screen-clearing issues )
( 12. cursor hiding for cmatrix ) ( 12. cursor hiding for cmatrix )
( 13. clean up super ugly selection code )
( ANSI sequences ) ( ANSI sequences )
( ) ( )
@ -178,8 +179,8 @@
( set to 01 to enable debug log ) ( set to 01 to enable debug log )
#00 .debug STZ #00 .debug STZ
#99 #010e DEO
.debug LDZ ?&continue BRK &continue .debug LDZ ?&continue BRK &continue
#99 #010e DEO
;debug-log .File1/name DEO2 ;debug-log .File1/name DEO2
#01 .File1/append DEO #01 .File1/append DEO
BRK BRK
@ -224,7 +225,8 @@
LIT2r =cells ( [addr*] ) LIT2r =cells ( [addr*] )
#0000 &yloop ( y* [addr*] y* ) #0000 &yloop ( y* [addr*] y* )
#0000 &xloop ( y* x* [addr*] ) #0000 &xloop ( y* x* [addr*] )
#0220 STH2kr STA2 ( y* x* [addr*] ) ( #0220 STH2kr STA2 ( y* x* [addr*] ) )
#0200 STH2kr STA2 ( y* x* [addr*] )
INC2r INC2r ( y* x* [addr+2*] ) INC2r INC2r ( y* x* [addr+2*] )
INC2 DUP2 .cols LDZ2 ( y* x+1* x+1* cols* [addr+2*] ) INC2 DUP2 .cols LDZ2 ( y* x+1* x+1* cols* [addr+2*] )
LTH2 ?&xloop ( y* x+1* [addr+2*] ) LTH2 ?&xloop ( y* x+1* [addr+2*] )
@ -311,7 +313,7 @@
@paste-snarf ( -> ) @paste-snarf ( -> )
.paste LDZ #00 EQU ?&start LIT "0 ;bracket-paste JSR2 &start .paste LDZ #00 EQU ?&start LIT "0 ;bracket-paste JSR2 &start
;&path .File2/name DEO2 ( ) ;snarf .File2/name DEO2 ( )
#0100 .File2/len DEO2 ( ) #0100 .File2/len DEO2 ( )
&loop ( ) &loop ( )
;paste-buf .File2/r DEO2 ( ) ;paste-buf .File2/r DEO2 ( )
@ -323,7 +325,9 @@
&failed POP2 &failed POP2
&done &done
.paste LDZ #00 EQU ?&end LIT "1 ;bracket-paste JSR2 &end .paste LDZ #00 EQU ?&end LIT "1 ;bracket-paste JSR2 &end
JMP2r [ &path ".snarf 00 ] JMP2r
@snarf ".snarf 00
@lit-first-y @lit-first-y
.is-lit-flip LDZ ?&flip .lit-click-y LDZ2 JMP2r &flip .lit-drag-y LDZ2 JMP2r .is-lit-flip LDZ ?&flip .lit-click-y LDZ2 JMP2r &flip .lit-drag-y LDZ2 JMP2r
@ -374,9 +378,56 @@
.lit-click-y LDZ2 .lit-drag-y LDZ2 EQU2 .lit-click-y LDZ2 .lit-drag-y LDZ2 EQU2
.lit-click-x LDZ2 .lit-drag-x LDZ2 EQU2 AND JMP2r .lit-click-x LDZ2 .lit-drag-x LDZ2 EQU2 AND JMP2r
@find-natural-end ( y* -> xend* )
DUP2 .cols LDZ2 MUL2 ( y* y*cols* )
#0002 MUL2 ;cells ADD2 INC2 ( y* edge* )
DUP2 .max-x LDZ2 #0002 MUL2 ADD2 ( y* edge* start=edge+2cols* )
&loop ( y* edge* addr* )
LDAk ?&done ( y* edge* addr* )
#0002 SUB2 LTH2k ?&loop ( y* edge* addr-2* )
&done ( y* edge* addr* )
SWP2 SUB2 #0002 DIV2 ( y* x* )
NIP2 JMP2r ( x* )
@copy-line ( y* x1* x0* -> y* )
STH2 STH2 DUP2 find-natural-end ( y* xend* [x0* x1*] )
STH2r min ( y* xlim=min(xend,x1)* [x0*] )
OVR2 .cols LDZ2 MUL2 ( y* xlim* y*cols* [x0*] )
STH2kr ADD2 #0002 MUL2 ;cells ADD2 ( y* xlim* addr* [x0*] )
INC2 STH2 SWP2r STH2r ( y* xlim* x0* [addr+1*] )
SUB2 INC2 #0000 SWP2 SUB2 ( y* -count* [addr+1*] )
&loop ( y* -i* [pos*] )
LDAkr STHr copy-char ( y* -i* [pos*] )
INC2 INC2r INC2r ORAk ?&loop ( y* -i+1* [pos+2*] )
POP2 POP2r JMP2r ( y* )
@copy-char ( c^ -> )
DUP ?&ok POP #20 ( replace \0 with space )
&ok STH ;paste-pos LDA2k ( pos* addr* [c^] )
STH2k STAr INC2 SWP2 STA2 JMP2r ( )
@copy-selection ( -> )
;paste-buf ;paste-pos STA2
lit-last-y INC2 lit-first-y ( ylim* y0* )
DUP2 lit-first-x STH2k screen-to-cell ( yn* y0* [x0*] )
&yloop ( yn* y* [x*] )
OVR2 OVR2 INC2 GTH2 STH .max-x LDZ2 ( yn* y* maxx* [x* last^] )
lit-last-x ( yn* y* maxx* xlast* [x* last^] )
STHr JMP SWP2 POP2 STH2r ( yn* y* x1* x* )
copy-line ( yn* y* )
LIT2r 0000 INC2 GTH2k ?&next !&done ( yn* y+1* [0*] )
&next ( )
#0a copy-char !&yloop ( )
&done ( )
POP2 POP2 POP2r ( )
;snarf .File2/name DEO2 ( )
;paste-pos LDA2 ;paste-buf SUB2 ( len* )
.File2/len DEO2 ( )
;paste-buf .File2/w DEO2 ( )
JMP2r ( )
@handle-selection ( -> ) @handle-selection ( -> )
selection-is-empty ?&skip selection-is-empty ?&skip copy-selection &skip !clear-selection
&skip !clear-selection
@clear-selection ( -> ) @clear-selection ( -> )
#00 .is-lit STZ #00 .is-lit STZ
@ -396,9 +447,7 @@
&done .is-lit-flip STZ POP2 POP2 JMP2r ( ) &done .is-lit-flip STZ POP2 POP2 JMP2r ( )
@end-selection ( -> ) @end-selection ( -> )
update-selection ( redraw-selection ( ) ) update-selection draw-cursor !handle-selection ( )
( draw-pointer )
draw-cursor !handle-selection ( )
@on-click-down ( click^ -> ) @on-click-down ( click^ -> )
DUP #01 AND ?&left-click DUP #01 AND ?&left-click
@ -422,8 +471,6 @@
STH2r #0008 ADD2 .Screen/addr DEO2 ( 43 sprite^ ) STH2r #0008 ADD2 .Screen/addr DEO2 ( 43 sprite^ )
DEO JMP2r ( ) DEO JMP2r ( )
( TODO: need to adjust first/last x/y while dragging )
@draw-pointer ( -> ) @draw-pointer ( -> )
.lastmouse-x LDZ2 .lastmouse-y LDZ2 ( x* y* ) .lastmouse-x LDZ2 .lastmouse-y LDZ2 ( x* y* )
#01e0 ;cp437 ADD2 !draw-at ( ) #01e0 ;cp437 ADD2 !draw-at ( )
@ -699,7 +746,8 @@
@erase ( start* end* -> ) @erase ( start* end* -> )
EQU2k ?&skip ( start* end* ) EQU2k ?&skip ( start* end* )
OVR2 SWP2 ( start* start* end* ) OVR2 SWP2 ( start* start* end* )
SUB2 STH2 #0220 SWP2 ( 4220 start* [count*] ) ( SUB2 STH2 #0220 SWP2 ( 4220 start* [count*] ) )
SUB2 STH2 #0200 SWP2 ( 4220 start* [count*] )
&loop ( 4220 addr* [i*] ) &loop ( 4220 addr* [i*] )
STA2k INC2 INC2 INC2r INC2r ( 4220 addr+2* [i+1*] ) STA2k INC2 INC2 INC2r INC2r ( 4220 addr+2* [i+1*] )
ORAkr STHr ?&loop ( 4220 addr+2* [i+2*] ) ORAkr STHr ?&loop ( 4220 addr+2* [i+2*] )
@ -897,7 +945,8 @@
&loop ( bound* pos* [i*] ) &loop ( bound* pos* [i*] )
LDA2k OVR2 STH2kr ADD2 ( bound* pos* x* pos+i* [i*] ) LDA2k OVR2 STH2kr ADD2 ( bound* pos* x* pos+i* [i*] )
STA2 ( bound* pos* [i*] ; pos+i<-x ) STA2 ( bound* pos* [i*] ; pos+i<-x )
#0220 OVR2 STA2 ( bound* pos* [i*] ; pos<-4220 ) ( #0220 OVR2 STA2 ( bound* pos* [i*] ; pos<-4220 ) )
#0200 OVR2 STA2 ( bound* pos* [i*] ; pos<-4220 )
#0002 SUB2 ( bound* pos-2* [i*] ) #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 ( ) POP2 POP2 POP2r ( )
@ -917,7 +966,8 @@
POP2 POP2 POP2r ( [n*] ) POP2 POP2 POP2r ( [n*] )
&replace ( [n*] ) &replace ( [n*] )
LIT2r 0000 SWP2r SUB2r ( [-n*] ) LIT2r 0000 SWP2r SUB2r ( [-n*] )
#0220 cur-addr ( 4220 cur* [-n*] ) ( #0220 cur-addr ( 4220 cur* [-n*] ) )
#0200 cur-addr ( 4220 cur* [-n*] )
&loop2 ( 4220 pos* [-i*] ) &loop2 ( 4220 pos* [-i*] )
STA2k INC2 INC2 INC2r ( 4220 pos+2* [-i+1*] ) STA2k INC2 INC2 INC2r ( 4220 pos+2* [-i+1*] )
ORAkr STHr ?&loop2 ( 4220 pos+2* [-i+1*] ) ORAkr STHr ?&loop2 ( 4220 pos+2* [-i+1*] )
@ -931,7 +981,8 @@
cur-addr ( limit* start* [i*] ) cur-addr ( limit* start* [i*] )
&loop ( limit* pos* [n*] ) &loop ( limit* pos* [n*] )
DUP2 STH2kr ADD2 LDA2k ( limit* pos* pos+i* x* [i*] ) DUP2 STH2kr ADD2 LDA2k ( limit* pos* pos+i* x* [i*] )
#0220 ROT2 STA2 ( limit* pos* x* [i*] ; pos+i<-4220 ) ( #0220 ROT2 STA2 ( limit* pos* x* [i*] ; pos+i<-4220 ) )
#0200 ROT2 STA2 ( limit* pos* x* [i*] ; pos+i<-4220 )
OVR2 STA2 INC2 INC2 ( limit* pos+2* [i*] ; pos<-x ) OVR2 STA2 INC2 INC2 ( limit* pos+2* [i*] ; pos<-x )
GTH2k ?&loop ( limit* pos+2* [i*] ) GTH2k ?&loop ( limit* pos+2* [i*] )
POP2 POP2 POP2r ( ) POP2 POP2 POP2r ( )
@ -948,7 +999,8 @@
limit-addr STH2 limit-addr STH2
;cells .col-bytes LDZ2 ADD2 STH2 ;cells .col-bytes LDZ2 ADD2 STH2
&loop &loop
STH2kr LDA2 #0220 STH2kr STA2 ( STH2kr LDA2 #0220 STH2kr STA2 )
STH2kr LDA2 #0200 STH2kr STA2
STH2kr .col-bytes LDZ2 SUB2 STA2 STH2kr .col-bytes LDZ2 SUB2 STA2
INC2r INC2r GTH2kr STHr ?&loop INC2r INC2r GTH2kr STHr ?&loop
POP2r POP2r POP2r POP2r
@ -1055,7 +1107,8 @@
@args $10 &pos $2 @args $10 &pos $2
( paste buffer ) ( paste buffer )
@paste-buf $100 @paste-buf $1000
@paste-pos $2
( 256 chars x 2 tiles/char x 8 bytes/tile = 4096 bytes ) ( 256 chars x 2 tiles/char x 8 bytes/tile = 4096 bytes )
( second tile only uses top 50% ) ( second tile only uses top 50% )
@ -1070,7 +1123,5 @@
01 01
( device mask ) 41 0d07 ( device mask ) 41 0d07
@lengths $18 ( keep consistent with .cols )
( store tint+char for each screen position ) ( store tint+char for each screen position )
@cells @cells