commit f3d86c5384e3a50636417383cb1b0d2dde92e0c7
parent 2560216ed098265413270e47569b2ee07e963160
Author: Devine Lu Linvega <aliceffekt@gmail.com>
Date: Sun, 21 Jan 2024 08:58:34 -0800
(hilbert) Cache last pos
Diffstat:
1 file changed, 22 insertions(+), 12 deletions(-)
diff --git a/projects/examples/demos/hilbert.tal b/projects/examples/demos/hilbert.tal
@@ -12,13 +12,21 @@
#00c0
( ) DUP2 .Screen/width DEO2
( ) .Screen/height DEO2
+ ( | pen )
+ #0020
+ ( ) DUP2 .Screen/x DEO2
+ .Screen/y DEO2
( | vector )
;on-frame .Screen/vector DEO2
BRK
@on-frame ( -> )
- [ LIT2 &f $2 ] STH2k INC2 DUP2 ,&f STR2
- d2xy STH2r d2xy #01 <draw-line>
+ [ LIT2 &x1 0020 ] [ LIT2 &y1 0020 ]
+ ( ) [ LIT2 &f $2 ] INC2 DUP2 ,&f STR2
+ d2xy
+ ( ) DUP2 ,&y1 STR2
+ ( ) OVR2 ,&x1 STR2
+ #01 <draw-line>
BRK
@d2xy ( d* -- x* y* )
@@ -26,16 +34,18 @@
#0000
( ) DUP2 ,&x STR2
( ) ,&y STR2
- #2001 &l #00 OVR STH2
- [ LIT2 &t $2 ]
- ( ) DUP2 DUP2 #01 SFT2 #0001 AND2 DUP2 ,&rx STR2
- ( ) EOR2 #0001 AND2 ,&ry STR2
- ( ) #02 SFT2 ,&t STR2
- [ LIT2 &x $2 ] [ LIT2 &y $2 ] [ LIT2 &rx $2 ] [ LIT2 &ry $2 ]
- ( ) STH2kr rot
- ( ) STH2kr ,&ry LDR2 MUL2 ADD2 ,&y STR2
- ( ) STH2r ,&rx LDR2 MUL2 ADD2 ,&x STR2
- DUP ADD GTHk ?&l
+ #2001
+ &l ( -- )
+ #00 OVR STH2
+ [ LIT2 &t $2 ]
+ ( ) DUP2 DUP2 #01 SFT2 #0001 AND2 DUP2 ,&rx STR2
+ ( ) EOR2 #0001 AND2 ,&ry STR2
+ ( ) #02 SFT2 ,&t STR2
+ [ LIT2 &x $2 ] [ LIT2 &y $2 ] [ LIT2 &rx $2 ] [ LIT2 &ry $2 ]
+ ( ) STH2kr rot
+ ( ) STH2kr ,&ry LDR2 MUL2 ADD2 ,&y STR2
+ ( ) STH2r ,&rx LDR2 MUL2 ADD2 ,&x STR2
+ DUP ADD GTHk ?&l
POP2
( ) ,&x LDR2 #20 SFT2 #0020 ADD2
( ) ,&y LDR2 #20 SFT2 #0020 ADD2 JMP2r