I’ve been having fun playing with 160x160 graphics mode. I have a very rudimentary turtle graphics working for it. The engine itself fits snugly in a single block. It adds the following words for controlling the “turtle”:
c – clear screen (cls doesn’t work in
160x160 graphics mode)
g
– Go to an x y coordinate (0,0 is the center of the screen – y-axis is mirrored
from mathematics)
h
– Set heading (0-60 - 0 is North, 15 East, 30 South, 45 West)
b
– Begin (enters 160x160 graphics mode, clears, resets turtle)
e
– End (waits for key, exits graphics mode)
t
– Turn the turtle (see h above – negative values for counter-clockwise)
n
– Sine function (used internally – see h above – returns scaled by 255)
m
– Move turtle number of pixels along current heading (no drawing)
p
– Plot pixel currently under turtle
f
– Forward number of pixels while plotting
Yes, this all fits in a single block and compiles to just 307 bytes! It uses a table-based sine function with 6 degree (pi/30 radian) increments – think minute marks on a clock. This is still divisible by many things (2, 3, 4, 5, 6, 10, 12, 15, 20, 30), so it works out well enough for Logo and makes the lookup table small.
In a second block are some demos putting it to use. The sine (n) function can be seen to work with:
: sin 160 0 do i i n 4 / 80 + plot loop ;
And we can see that using it to plot lines in each of the 60 available angles works:
: burst 60 0 do 0 0 g i h 110 f loop ;
Other demos show off some of the creative Logo patterns you may have played with as a kid:
: squiral -50 50 g 20 0 do 100 f 21 t loop ;
: circle 60 0 do 4 f 1 t loop ;
: spiral 15 0 do circle 4 t loop ;
: star 5 0 do 80 f 24 t loop ;
: stars 3 0 do star 20 t loop ;
: rose 0 50 0 do 2 + dup f 14 t loop ;
One of my favorites is this flower:
: hp 15 0 do 5 f 1 t loop 15 0 do 2 f -1 t loop ;
: petal hp 30 t hp 30 t ;
: flower 15 0 do petal 4 t loop ;
Source and hex files attached.
Demo video: http://youtu.be/dfKFuOudx3Y
Blog post: http://bit.ly/figlogo
Have fun!
Very impressive work Ashley - well done!P.S. Noticed in the video your FIGnition is resting on an anti-static bag - be aware those bags can be slightly conductive; might be better to use something else :).