Automaton Revisited 2 | Everygamegoing


Automaton Revisited 2

Published in EUG #62

Welcome back to this short series on creating a really impressive, yet regulated, "pattern" effect via machine code. Last issue I presented a generator which filled the whole screen in one go. This disc's article and utility combines the idea with the Fibonacci method of generating graphics.

2. AUTOFIB - Automaton-Fibonacci Backgrounds

The Fibonacci sequence evolves from adding previous numbers to obtain the next in a series, normally starting with 1 and 1:


Reducing each term to its digit sum gives a sequence which repeats itself after 24 terms:

1,1,2,3,5,8,4,3,7,1,8,9,8,8,7,6,4,1,5,6,2,8,1,9, 1,1,2,3,...

and they can be used as a basis repeating for patterns.

The sequence in its reduced form is generated by GEN, filling a 24-byte table called TABLE. The digit summing is done by DIGSUM - those of you who have seen my previous articles on the subject can compare it with the Basic version.

ENCODE picks up a term, uses it as an index into RULES (which, like before, is filled with random values in Basic in line 90), and makes up a four-pixel byte to put into the screen Ram. There are 24 terms but 160 pixels across the screen, so once 24 pixels (or 6 bytes) have been plotted, the routine wraps around to the start of TABLE.

Of course, 160 isn't exactly divisible by 24, but that creates a staggered effect. The next row of pixels is slightly displaced from the row above. This produces interesting patterns that might give you ideas for bricks and other scenic sprites in a game.

Chris Dewhurst