uxn

Varvara Ordinator, written in ANSI C(SDL2)
git clone https://git.eamoncaddigan.net/uxn.git
Log | Files | Refs | README | LICENSE

hilbert.tal (1624B)


      1 |00 @System &vector $2 &wst $1 &rst $1 &eaddr $2 &ecode $1 &pad $1 &r $2 &g $2 &b $2 &debug $1 &halt $1
      2 |20 @Screen &vector $2 &width $2 &height $2 &auto $1 &pad $1 &x $2 &y $2 &addr $2 &pixel $1 &sprite $1
      3 
      4 |0100
      5 
      6 @on-reset ( -> )
      7 	( | theme )
      8 	#6f04 .System/r DEO2
      9 	#7f00 .System/g DEO2
     10 	#8f00 .System/b DEO2
     11 	( | screen size )
     12 	#00c0
     13 	( ) DUP2 .Screen/width DEO2
     14 	( ) .Screen/height DEO2
     15 	( | pen )
     16 	#0020
     17 	( ) DUP2 .Screen/x DEO2
     18 	( ) .Screen/y DEO2
     19 	( | vector )
     20 	;on-frame .Screen/vector DEO2
     21 	BRK
     22 
     23 @on-frame ( -> )
     24 	[ LIT2 &f $2 ] INC2 DUP2 ,&f STR2
     25 	( | end )
     26 	DUP2 #0400 LTH2 ?{
     27 		POP2 #0000 .Screen/vector DEO2
     28 		BRK }
     29 	d2xy
     30 	( | draw line )
     31 	.Screen/y DEI2 diff ,&y STR2
     32 	.Screen/x DEI2 diff ,&x STR2
     33 	#0400
     34 	&l ( -- )
     35 		.Screen/x DEI2k [ LIT2 &x $2 ] ADD2 ROT DEO2
     36 		.Screen/y DEI2k [ LIT2 &y $2 ] ADD2 ROT DEO2
     37 		[ LIT2 01 -Screen/pixel ] DEO
     38 		INC GTHk ?&l
     39 	POP2 BRK
     40 
     41 @diff ( a* b* -- dir* )
     42 	EQU2k ?{
     43 		LTH2 ?{ #0001 JMP2r }
     44 		#ffff JMP2r }
     45 	POP2 POP2 #0000 JMP2r
     46 
     47 @d2xy ( d* -- x* y* )
     48 	,&t STR2
     49 	#0000
     50 	( ) DUP2 ,&x STR2
     51 	( ) ,&y STR2
     52 	#2001
     53 	&l ( -- )
     54 		#00 OVR STH2
     55 		[ LIT2 &t $2 ] DUP2 #02 SFT2 ,&t STR2
     56 		( ) DUP2 #01 SFT2 #0001 AND2 DUP2 ,&rx STR2
     57 		( ) EOR2 #0001 AND2 ,&ry STR2
     58 		[ LIT2 &x $2 ] [ LIT2 &y $2 ] [ LIT2 &ry $2 ]
     59 		( ) DUP2r [ LIT2r 0001 ] SUB2r
     60 		( | rot )
     61 		ORA ?{
     62 			[ LIT2 &rx $2 ] #0001 NEQ2 ?{
     63 				( rx-n-1 ) SWP2 STH2kr SWP2 SUB2
     64 				( ry-n-1 ) SWP2 STH2kr SWP2 SUB2 }
     65 			( swap ) SWP2 }
     66 		POP2r
     67 		( ) STH2kr ,&ry LDR2 MUL2 ADD2 ,&y STR2
     68 		( ) STH2r ,&rx LDR2 MUL2 ADD2 ,&x STR2
     69 		DUP ADD GTHk ?&l
     70 	POP2
     71 	( ) ,&x LDR2 #20 SFT2 #0020 ADD2
     72 	( ) ,&y LDR2 #20 SFT2 #0020 ADD2 JMP2r
     73