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