optimizations

This commit is contained in:
~d6 2023-02-20 10:51:31 -05:00
parent 83e790a9b2
commit 17d0aea884
2 changed files with 25 additions and 28 deletions

View File

@ -30,6 +30,7 @@
00 00 00 24 66 ff 66 24 00 00 00 00 00 00 00 00 00 00 00 24 66 ff 66 24 00 00 00 00 00 00 00 00
00 00 10 10 38 38 7c 7c fe fe 00 00 00 00 00 00 00 00 10 10 38 38 7c 7c fe fe 00 00 00 00 00 00
00 00 fe fe 7c 7c 38 38 10 10 00 00 00 00 00 00 00 00 fe fe 7c 7c 38 38 10 10 00 00 00 00 00 00
&space
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 30 78 78 78 30 30 00 30 30 00 00 00 00 00 00 00 30 78 78 78 30 30 00 30 30 00 00 00 00 00 00
00 66 66 66 24 00 00 00 00 00 00 00 00 00 00 00 00 66 66 66 24 00 00 00 00 00 00 00 00 00 00 00

View File

@ -197,8 +197,7 @@
#01 .visual-bell STZ #01 .visual-bell STZ
( draw border ) ( draw border )
draw-border !draw-border
JMP2r
@update-dimensions ( -> ) @update-dimensions ( -> )
( set col-bytes, frequently needed ) ( set col-bytes, frequently needed )
@ -219,13 +218,13 @@
;&path .File1/name DEO2 ;&path .File1/name DEO2
#0006 .File1/len DEO2 #0006 .File1/len DEO2
;&r .File1/r DEO2 ;&r .File1/r DEO2
.File1/ok DEI2 ORA #01 JCN JMP2r .File1/ok DEI2 ORA #01 [ JCN JMP2r ]
,&r LDR2 .System/r DEO2 ,&r LDR2 .System/r DEO2
,&g LDR2 .System/g DEO2 ,&g LDR2 .System/g DEO2
,&b LDR2 .System/b DEO2 ,&b LDR2 .System/b DEO2
#0002 .File1/len DEO2 #0002 .File1/len DEO2
;&x .File1/r DEO2 ;&x .File1/r DEO2
.File1/ok DEI2 ORA #01 JCN JMP2r .File1/ok DEI2 ORA #01 [ JCN JMP2r ]
#00 ,&x LDR .cols STZ2 #00 ,&x LDR .cols STZ2
#00 ,&y LDR .rows STZ2 #00 ,&y LDR .rows STZ2
JMP2r [ &path ".theme $1 &r $2 &g $2 &b $2 &x $1 &y $1 ] JMP2r [ &path ".theme $1 &r $2 &g $2 &b $2 &x $1 &y $1 ]
@ -246,10 +245,10 @@
.col-bytes LDZ2 .rows LDZ2 MUL2 ;cells ADD2 JMP2r .col-bytes LDZ2 .rows LDZ2 MUL2 ;cells ADD2 JMP2r
@min ( x* y* -> min* ) @min ( x* y* -> min* )
LTH2k JMP SWP2 POP2 JMP2r LTH2k [ JMP SWP2 ] POP2 JMP2r
@max ( x* y* -> max* ) @max ( x* y* -> max* )
LTH2k JMP SWP2 NIP2 JMP2r LTH2k [ JMP SWP2 ] NIP2 JMP2r
( signed max ) ( signed max )
( #8000 < #8001 < ... < #ffff < #0000 < #0001 < ... < #7fff ) ( #8000 < #8001 < ... < #ffff < #0000 < #0001 < ... < #7fff )
@ -258,8 +257,7 @@
( initialize screen cells and prepare for first draw ) ( initialize screen cells and prepare for first draw )
@init-screen ( -> ) @init-screen ( -> )
first-addr limit-addr #0200 !init first-addr limit-addr #0200 ( fall-through )
@init ( start* limit* cell* -> ) @init ( start* limit* cell* -> )
STH2 EQU2k ?&skip ( start* limit* [cell*] ) STH2 EQU2k ?&skip ( start* limit* [cell*] )
#01 .dirty STZ OVR2 ( start* limit* start* [cell*] ) #01 .dirty STZ OVR2 ( start* limit* start* [cell*] )
@ -280,7 +278,7 @@
.Screen/y DEO2 JMP2r ( ; s/y<-y ) .Screen/y DEO2 JMP2r ( ; s/y<-y )
@draw-border ( -> ) @draw-border ( -> )
#0200 ;cp437 ADD2 .Screen/addr DEO2 ;cp437/space .Screen/addr DEO2
#04 .Screen/sprite #04 .Screen/sprite
#0000 draw-border/row #0000 draw-border/row
#0008 draw-border/row #0008 draw-border/row
@ -288,7 +286,7 @@
.Screen/y DEI2 #0008 ADD2 draw-border/row .Screen/y DEI2 #0008 ADD2 draw-border/row
#0000 draw-border/col #0000 draw-border/col
#0008 draw-border/col #0008 draw-border/col
.cols LDZ2 #0008 MUL2 #0010 ADD2 draw-border/col .cols LDZ2 #30 SFT2 #0010 ADD2 draw-border/col
.Screen/x DEI2 #0008 ADD2 draw-border/col .Screen/x DEI2 #0008 ADD2 draw-border/col
#00 .Screen/auto DEO POP2 !screen-to-cursor #00 .Screen/auto DEO POP2 !screen-to-cursor
@ -303,7 +301,7 @@
.Screen/x DEO2 .Screen/x DEO2
#0000 .Screen/y DEO2 #0000 .Screen/y DEO2
#02 .Screen/auto DEO #02 .Screen/auto DEO
#0000 .rows LDZ2 #0003 MUL2 INC2 #0002 DIV2 #0004 ADD2 SUB2 STH2 #0000 .rows LDZ2 #0003 MUL2 INC2 #01 SFT2 #0004 ADD2 SUB2 STH2
!&loop !&loop
&loop ( 04 sprite^ [-count] ) &loop ( 04 sprite^ [-count] )
@ -423,7 +421,7 @@
&yloop ( yn* y* [addr* x*] ) &yloop ( yn* y* [addr* x*] )
OVR2 OVR2 INC2 GTH2 STH .cols LDZ2 ( yn* y* cols* [addr* x* last^] ) OVR2 OVR2 INC2 GTH2 STH .cols LDZ2 ( yn* y* cols* [addr* x* last^] )
lit-last-x INC2 ( yn* y* cols* xn* [addr* x* last^] ) lit-last-x INC2 ( yn* y* cols* xn* [addr* x* last^] )
STHr JMP SWP2 POP2 STH2r ( yn* y* xlim* x* [addr*] ) STHr [ JMP SWP2 ] POP2 STH2r ( yn* y* xlim* x* [addr*] )
&xloop ( yn* y* xlim* x* [addr*] ) &xloop ( yn* y* xlim* x* [addr*] )
STH2kr LDA2 highlight-cell ( yn* y* xlim* x* [addr*] ) STH2kr LDA2 highlight-cell ( yn* y* xlim* x* [addr*] )
.Screen/x DEI2k #0008 ADD2 ROT DEO2 ( yn* y* xlim* x* [addr*] ) .Screen/x DEI2k #0008 ADD2 ROT DEO2 ( yn* y* xlim* x* [addr*] )
@ -440,7 +438,7 @@
#0010 LTH2k ?&y0 SUB2 #000c DIV2 .max-y LDZ2 !min &y0 POP2 POP2 #0000 JMP2r #0010 LTH2k ?&y0 SUB2 #000c DIV2 .max-y LDZ2 !min &y0 POP2 POP2 #0000 JMP2r
@x-point-to-col ( x* -> col* ) @x-point-to-col ( x* -> col* )
#0010 LTH2k ?&x0 SUB2 #0008 DIV2 .max-x LDZ2 !min &x0 POP2 POP2 #0000 JMP2r #0010 LTH2k ?&x0 SUB2 #03 SFT2 .max-x LDZ2 !min &x0 POP2 POP2 #0000 JMP2r
@point-to-coord ( x* y* -> row* col* ) @point-to-coord ( x* y* -> row* col* )
y-point-to-row SWP2 !x-point-to-col y-point-to-row SWP2 !x-point-to-col
@ -498,7 +496,7 @@
&yloop ( yn* y* [x*] ) &yloop ( yn* y* [x*] )
OVR2 OVR2 INC2 GTH2 STH .max-x LDZ2 ( yn* y* maxx* [x* last^] ) OVR2 OVR2 INC2 GTH2 STH .max-x LDZ2 ( yn* y* maxx* [x* last^] )
lit-last-x ( yn* y* maxx* xlast* [x* last^] ) lit-last-x ( yn* y* maxx* xlast* [x* last^] )
STHr JMP SWP2 POP2 STH2r ( yn* y* x1* x* ) STHr [ JMP SWP2 ] POP2 STH2r ( yn* y* x1* x* )
copy-line ( yn* y* ) copy-line ( yn* y* )
LIT2r 0000 INC2 GTH2k ?&next !&done ( yn* y+1* [0*] ) LIT2r 0000 INC2 GTH2k ?&next !&done ( yn* y+1* [0*] )
&next ( ) &next ( )
@ -568,15 +566,13 @@
JMP2r ( ) JMP2r ( )
&redraw ( ) &redraw ( )
.lastmouse-x LDZ2 .lastmouse-y LDZ2 ( lx* ly* ) .lastmouse-x LDZ2 .lastmouse-y LDZ2 ( lx* ly* )
#0200 ;cp437 ADD2 draw-at ( ) ;cp437/space draw-at ( )
.is-lit LDZ #00 EQU ?&next .is-lit LDZ #00 EQU ?&next ( )
update-selection update-selection #01 .dirty STZ ( )
#01 .dirty STZ &next ( )
&next
.Mouse/x DEI2 .Mouse/y DEI2 ( x* y* ) .Mouse/x DEI2 .Mouse/y DEI2 ( x* y* )
.lastmouse-y STZ2 .lastmouse-x STZ2 ( ) .lastmouse-y STZ2 .lastmouse-x STZ2 ( )
draw-pointer draw-pointer !screen-to-cursor ( )
!screen-to-cursor ( )
@on-mouse ( -> BRK ) @on-mouse ( -> BRK )
.lastmouse-st LDZ ( last ) .lastmouse-st LDZ ( last )
@ -912,8 +908,7 @@
POP2 JMP2r POP2 JMP2r
&erase-full POP2 first-addr limit-addr !erase &erase-full POP2 first-addr limit-addr !erase
&erase-to-end POP2 bol-addr limit-addr !erase &erase-to-end POP2 bol-addr limit-addr !erase
&erase-from-start POP2 first-addr eol-addr !erase &erase-from-start POP2 first-addr eol-addr ( fall-through )
@erase ( start* end* -> ) #0200 !init @erase ( start* end* -> ) #0200 !init
@exec-cup ( c^ -> BRK ) @exec-cup ( c^ -> BRK )
@ -1230,8 +1225,8 @@
#000a MUL2 STH2r ADD2 ( addr* value*10+digit ) #000a MUL2 STH2r ADD2 ( addr* value*10+digit )
SWP2 STA2 BRK SWP2 STA2 BRK
@read-arg-1 ( default* -> n* ) ;args LDA2 !max @read-arg-1 ( default* -> n* ) ;args/arg1 LDA2 !max
@read-arg-2 ( default* -> n* ) ;args INC2 INC2 LDA2 !max @read-arg-2 ( default* -> n* ) ;args/arg2 ( INC2 INC2 ) LDA2 !max
@reset-args ( -> ) @reset-args ( -> )
;args ;args/pos STA2 ;args ;args/pos STA2
@ -1245,11 +1240,11 @@
LITr 00 ( n [0] ) LITr 00 ( n [0] )
&read ( n [k] ) &read ( n [k] )
#000a DIV2k STH2k MUL2 SUB2 STH2r INCr ( n%10 n/10 [k+1] ) #000a DIV2k STH2k MUL2 SUB2 STH2r INCr ( n%10 n/10 [k+1] )
ORAk ,&read JCN ORAk ?&read
POP2 ( top element was 0000 ) POP2 ( top element was 0000 )
&write ( n0 n1 ... nk [k+1] ) &write ( n0 n1 ... nk [k+1] )
NIP #30 ADD .Console/w DEO LITr 01 SUBr ( n0 ... n{k-1} [k] ) NIP #30 ADD .Console/w DEO LITr 01 SUBr ( n0 ... n{k-1} [k] )
STHkr ,&write JCN STHkr ?&write
POPr JMP2r POPr JMP2r
@debug-log "debug_term.log 00 @debug-log "debug_term.log 00
@ -1264,7 +1259,8 @@
;scratch ;scratch/pos STA2 JMP2r ;scratch ;scratch/pos STA2 JMP2r
( store up to 8 arguments for control sequences ) ( store up to 8 arguments for control sequences )
@args $10 &pos $2 ( @args $10 &pos $2 )
@args [ &arg1 $2 &arg2 $2 &rest $c &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% )