Faster draw-line

This commit is contained in:
Devine Lu Linvega 2024-06-04 20:59:26 -08:00
parent 4edea23083
commit 094d01d149
1 changed files with 10 additions and 8 deletions

View File

@ -250,17 +250,19 @@
,&x2 STR2
STH2
STH2
( dx ) #0001 #ffff ,&x2 LDR2 STH2kr SUB2k abs2 ,&dx STR2
( sx ) SWP2 lts2 [ JMP SWP2 POP2 ] ,&sx STR2
( y x -> x y ) SWP2r
( dy ) #0001 #ffff ,&y2 LDR2 STH2kr SUB2k abs2 #0000 SWP2 SUB2 ,&dy STR2
( sy ) SWP2 lts2 [ JMP SWP2 POP2 ] ,&sy STR2
( | x )
#0001 #ffff ,&x2 LDR2 STH2kr SUB2k abs2 ,&dx STR2
SWP2 lts2 [ JMP SWP2 POP2 ] ,&sx STR2
SWP2r
( | y )
#0001 #ffff ,&y2 LDR2 STH2kr SUB2k abs2 #0000 SWP2 SUB2 ,&dy STR2
SWP2 lts2 [ JMP SWP2 POP2 ] ,&sy STR2
,&dx LDR2 ,&dy LDR2 ADD2
&>while ( -- )
( draw ) OVR2r STH2r STH2kr [ LIT &color $1 ] <set-pixel>
( x ) OVR2r STH2r [ LIT2 &x2 $2 ] EQU2
( y ) STH2kr [ LIT2 &y2 $2 ] EQU2 AND ?&end
DUP2k ADD2 DUP2
( y ) STH2kr [ LIT2 &y2 $2 ] NEQ2 ?{
( x ) OVR2r STH2r [ LIT2 &x2 $2 ] EQU2 ?&end }
( e -> e2 ) DUP2k ADD2 DUP2
( y ) [ LIT2 &dy $2 ] lts2 ?{
( e+dy ) SWP2 ,&dy LDR2 ADD2 SWP2
( x1+sx ) SWP2r [ LIT2r &sx $2 ] ADD2r SWP2r }