diff --git a/projects/examples/demos/hilbert.tal b/projects/examples/demos/hilbert.tal index 0f08a8c..fdb17a7 100644 --- a/projects/examples/demos/hilbert.tal +++ b/projects/examples/demos/hilbert.tal @@ -5,9 +5,9 @@ @on-reset ( -> ) ( | theme ) - #6f0b .System/r DEO2 - #7f0a .System/g DEO2 - #8e0a .System/b DEO2 + #6fff .System/r DEO2 + #7fff .System/g DEO2 + #8fff .System/b DEO2 ( | screen size ) #00c0 ( ) DUP2 .Screen/width DEO2 @@ -24,10 +24,24 @@ [ LIT2 &x1 0020 ] [ LIT2 &y1 0020 ] ( ) [ LIT2 &f $2 ] INC2 DUP2 ,&f STR2 d2xy - ( ) DUP2 ,&y1 STR2 - ( ) OVR2 ,&x1 STR2 - #01 - BRK + ( cache y ) DUP2 ,&y1 STR2 + ( cache x ) OVR2 ,&x1 STR2 + ( | draw line ) + ROT2 SWP2 diff ,&y STR2 + diff ,&x STR2 + #0400 + &l ( -- ) + .Screen/x DEI2k [ LIT2 &x $2 ] ADD2 ROT DEO2 + .Screen/y DEI2k [ LIT2 &y $2 ] ADD2 ROT DEO2 + [ LIT2 01 -Screen/pixel ] DEO + INC GTHk ?&l + POP2 BRK + +@diff ( a* b* -- dir* ) + EQU2k ?{ + GTH2 ?{ #0001 JMP2r } + #ffff JMP2r } + POP2 POP2 #0000 JMP2r @d2xy ( d* -- x* y* ) ,&t STR2 @@ -60,39 +74,3 @@ ( swap ) SWP2 } POP2r JMP2r -@ ( x1* y1* x2* y2* color -- ) - ,&color STR - ,&y STR2 - ,&x STR2 - ,&y2 STR2 - ,&x2 STR2 - ,&x LDR2 ,&x2 LDR2 SUB2 abs2 ,&dx STR2 - #0000 ,&y LDR2 ,&y2 LDR2 SUB2 abs2 SUB2 ,&dy STR2 - #ffff [ LIT2 00 _&x2 ] LDR2 ,&x LDR2 lts2 DUP2 ADD2 ADD2 ,&sx STR2 - #ffff [ LIT2 00 _&y2 ] LDR2 ,&y LDR2 lts2 DUP2 ADD2 ADD2 ,&sy STR2 - [ LIT2 &dx $2 ] [ LIT2 &dy $2 ] ADD2 STH2 - &while ( -- ) - [ LIT2 &x2 $2 ] DUP2 .Screen/x DEO2 - [ LIT2 &x $2 ] EQU2 [ LIT2 &y2 $2 ] DUP2 .Screen/y DEO2 - [ LIT2 &y $2 ] EQU2 [ LIT2 &color $1 -Screen/pixel ] DEO - AND ?&end - STH2kr DUP2 ADD2 DUP2 ,&dy LDR2 lts2 ?&skipy - STH2r ,&dy LDR2 ADD2 STH2 - ,&x2 LDR2 [ LIT2 &sx $2 ] ADD2 ,&x2 STR2 - &skipy ( -- ) - ,&dx LDR2 gts2 ?&while - STH2r ,&dx LDR2 ADD2 STH2 - ,&y2 LDR2 [ LIT2 &sy $2 ] ADD2 ,&y2 STR2 - !&while - &end POP2r JMP2r - -@abs2 ( a* -- f ) - DUP2 #0f SFT2 EQU ?{ #0000 SWP2 SUB2 } - JMP2r - -@lts2 ( a* b* -- f ) - #8000 STH2k ADD2 SWP2 STH2r ADD2 GTH2 JMP2r - -@gts2 ( a* b* -- f ) - #8000 STH2k ADD2 SWP2 STH2r ADD2 LTH2 JMP2r -