Re: [stella] Random number generation on 2600?

Subject: Re: [stella] Random number generation on 2600?
From: Chris Wilkson - MCD <cwilkson@xxxxxxxxxxxxx>
Date: Sun, 23 Mar 1997 20:00:12 -0800 (PST)
Erik,

You might try incrementing one of the timers every so often.  Maybe during
vblank.  Hmmm...decrementing would work better.  In case the timer happens
to be zero, it wouldn't always give a value of zero when you read it.  I don't
have any docs here at work, so I don't know if this is feasible.  I don't
think you can actually use the DEC instruction, because the timers are write
only.  Not sure on this.  If so, the code below only costs 12 proc cycles, I
think.

...
...
LDA INTTIM	; get timer value
SBC SEED	; subtact preset seed value.  don't care about carry.
STA (timer)	; store new value in timer of your choice
...
...


> 
> 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!
> 
> --
> Archives available at http://www.biglist.com/lists/stella/archives/
> E-mail UNSUBSCRIBE in the body to stella-request@xxxxxxxxxxx to be removed.
> 


--
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