Re: [stella] Random number generation on 2600?

Subject: Re: [stella] Random number generation on 2600?
From: Nick S Bensema <nickb@xxxxxxxxxxxx>
Date: Sun, 23 Mar 1997 21:21:45 -0700 (MST)
>
>Any hints on how to go about creating a pseudo-random number generator on
>the 2600?  True random numbers seem pretty difficult if not impossible (as
>with most assembly languages), but one can get a seed and plug it into an
>algorithm to get pseudo-random numbers.  On the PC, it's easy to use the
>current time for the seed (all BASIC programmers know RANDOMIZE TIMER), but
>that's not there on the 2600.. anyone have a good method for getting a seed
>and/or a good algorithm that works well on the 6502?  thanks!

The 2600 powers up in a completely random state, as you can tell when
you start it up without a cartridge.  That is probably how Stellar Track
gets completely random numbers every time you turn it on.

At the start of the program, after the SEI and CLD, make sure your memory 
clear routine clears all memory except one byte.  That byte will be your
seed.  If your algorithm would utilize two, then save two bytes.

This does not work on emulators, I believe.  Many of them give the same
numbers each time you start up Stellar Track, though subsequent presses
of the SELECT or START keys will prove to yield better results.



--
Archives available at http://www.biglist.com/lists/stella/archives/
E-mail UNSUBSCRIBE in the body to stella-request@xxxxxxxxxxx to be removed.

Current Thread