~rabbits/oekaki

e4707bd2395e0d616e781e5340f66d9681a82304 — neauoire 6 months ago 5fb5505
Faster inc pixel
1 files changed, 16 insertions(+), 15 deletions(-)

M src/oekaki.tal
M src/oekaki.tal => src/oekaki.tal +16 -15
@@ 214,7 214,7 @@
@get-tile-addr ( x* y* -- x* y* addr* )
	( x ) OVR2 #03 SFT2
	( y ) OVR2 #03 SFT2 .canvas/width LDZ2 #03 SFT2 MUL2 ADD2
	( )  #40 SFT2 ;pict ADD2 JMP2r
	( ) #40 SFT2 ;pict ADD2 JMP2r

@get-pixel ( x* y* -- x* y* color )
	( get tile addr ) get-tile-addr STH2


@@ 332,28 332,29 @@
(
@|filters )

@patt-pixel ( x* y* -- x* y* f )
	( y* ) DUP2 #0007 AND2 get-brush-patt ADD2 LDA STH
	( ) OVR2 NIP #80 SWP #07 AND SFT STHr AND JMP2r

@dec-pixel ( x* y* -- )
	patt-pixel ?{ POP2 POP2 JMP2r }
	get-pixel DUP #01 SUB !blend-pixel

@inc-pixel ( x* y* -- )
	patt-pixel ?{ POP2 POP2 JMP2r }
	.brush/blend LDZ ?{
		.brush/color LDZ <set-pixel>
		!<redraw-tile> }
	get-pixel INCk blend-pixel <set-pixel>
	!<redraw-tile>

@dec-pixel ( x* y* -- )
	patt-pixel ?{ POP2 POP2 JMP2r }
	get-pixel DUP #01 SUB blend-pixel <set-pixel>
	!<redraw-tile>

@patt-pixel ( x* y* -- x* y* f )
	( y* ) DUP2 #0007 AND2 get-brush-patt ADD2 LDA STH
	( ) OVR2 NIP #80 SWP #07 AND SFT STHr AND JMP2r
	get-pixel INCk
	( >> )

@blend-pixel ( a b -- color )
@blend-pixel ( x* y* a b -- color )
	DUP #04 NEQ ?{ POP #03 }
	DUP INC ?{ POP #00 }
	NEQk ?{ POP JMP2r }
	.brush/color LDZ LTHk [ JMP SWP ] POP NIP JMP2r
	NEQk ?{
		POP2 POP2 POP2 JMP2r }
	.brush/color LDZ LTHk [ JMP SWP ] POP NIP <set-pixel>
	!<redraw-tile>

@<do-line> ( x1* y1* x2* y2* fn* -- )
	,&fn STR2