Subject: Re: [stella] incoming source From: David Galloway <davidgalloway@xxxxxxxxxxxxxx> Date: Sun, 12 Dec 2004 16:18:01 -0800 |
Works just as well in firefox.A couple of things regarding the Linear Feedback Shift Register (LFSR). First of all Lee's example page uses 123 ($7b) as the default constant and that means it repeats after (2^7 -1) or 127 iterations. The example code that Mr. Jentzsch provided used the constant $b2 which repeats after (2^8-1) or 255 iterations
It looks like as soon as the same number comes up, the entire sequence
repeats. And I saw a repetition after only 128 values. So some bytes
must never come up. None of which matters if all you need is a reasonably
random-looking bit or two with a periodicity of at least 128, and I think you definitely have that in the rightmost bits at least. Very
nifty routine for 2600 purposes.
Now a comment about Mr. Jentzsch's code Here is the code again.
2. Random number generation: This code should do the whole job and is *much* shorter: lda random ; initialize to non-zero at start lsr bcs .skipEor eor #$b2 ; various values possible here .skipEor: sta random
Like Thomas mentioned the other 2^8 constants are listed here... http://www.ece.cmu.edu/~koopman/lfsr/8.txt
; TIA HSync LFSR in 6502. Just for the hell of it. Code not tested or optimized ; Kind of clumsy so you can see it's better to use ; the simpler LFSR code above. However, in hardware this method is simpler. Refer to TIA schematic
; The hardware does this: next_bit5 = not(bit0 XOR bit1) ; lfsr cannot be initialized to 63
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [stella] incoming source, Thomas Jentzsch | Thread | RE: [stella] incoming source, Dennis Debro |
Re: [stella] My next Minigame will , Manuel Rotschkar | Date | RE: [stella] incoming source, Dennis Debro |
Month |