Out of Order comes Chaos

So. My 512b Intro for Chaos Constructions is almost complete. I have routines, I have effects, and now I’m searching for random numbers. Or rather, semi-random numbers.
Or rather, semi-random sequences of numbers. Or rather, semi-random, predictable sequences of numbers.
The theory is simple (this is the techie bit) – use the R register to provide a pseudo-random number to a routine. If the R register is incremented per instruction in a Z80 processor, and if we run an exact amount of code between accesses to this register, we can predict the value of the pseudo-random number. For this to work we can simply initialise the R register to a “known value”, and it will generate our predictable number sequence from this seed. See, told you it was simple.
I worked out a few sequences that, in the way I’m generating the effect, looks quite nice. But I didn’t account for the contended RAM of a “traditional” ZX Spectrum. The Chaos Constructions party machine will likely be a Pentagon or Scorpion, a “Russian Clone” with no contended RAM. The lack of contention means that the R register is incremented differently (tho’ still predictably) to what I was expecting. This means that I need to find a set of “seeds” that look pretty on both machines.

Crap.

3 Comments

  1. Posted July 13, 2006 at 10:26 am | Permalink

    Have you considered borrowing the random number generator from Baze’s Z80 Bits page? (Or perhaps that’s just too many bytes…)

  2. Posted July 13, 2006 at 12:29 pm | Permalink

    I did consider another random number generator, but for the moment the R-register works ok. I don’t think it’ll be a problem actually, I’m just working on finding a collection of seeds that work well.

    More of an issue may be that, going by the babelfish’d rules on the CC6 website, the intro should exit with a clear screen and restored stack. Clear screen I could do, but the stack is pretty much destroyed. And there’s not really a definitive “exit” point – it runs until you get bored and hit reset. Hmm, I’ll try to get someone to clarify the rules for me.

  3. Posted July 13, 2006 at 12:31 pm | Permalink

    As for the size of the random number generator, it’s fine – I think I actually have about 12b spare. But as I say, I can probably work without it.

Post a Comment

Your email is never shared. Required fields are marked *

*
*