[vcf-midatlantic] Random numbers

Dan Roganti ragooman at gmail.com
Sun Apr 9 22:21:03 EDT 2017

On Sun, Apr 9, 2017 at 6:54 AM, David Riley via vcf-midatlantic <
vcf-midatlantic at lists.vintagecomputerfederation.org> wrote:

> On Apr 8, 2017, at 13:06, Dave McGuire via vcf-midatlantic <
> vcf-midatlantic at lists.vintagecomputerfederation.org> wrote:
> >
> > On 04/08/2017 12:10 PM, Dan Roganti via vcf-midatlantic wrote:
> >>> ​Remember,
> >>> that step to seed the rnd generator is not perfect either​
> >>> ​
> >>> ​, eg. RND(-32768) or whichever value​
> >>> ​if you use the same seed, guess what,
> >>> you get the same random numbers :)
> >>
> >> ​This is why you like to use something "random" to seed the rnd
> generator​
> >> Usually every computer has a free running counter,
> >> meaning it's constantly being updated in the background
> >
> >  If some of my dustiest neurons are working, in the Atari at least
> there's a scan line counter from the video subsystem available for
> reading.  At least I think it was something like that.  That was great for
> seeding random number generators.  The Apple ][ must have something like
> that.
> Hahaha, NOPE. The Apple II is EXTREMELY Spartan hardware. There's not even
> a timer in there. The only hardware you can count on is RAM, some ROM, the
> (0 or 1 valued) cassette interface, and some miscellaneous stuff (speaker
> output, paddle connector, etc.).
> Getting good entropy to seed is hard on an Apple II.
> - Dave

​I think we can safely deduce that none of the home computers had perfect
random numbers,
it was just good enough for their Basic games
I'm not sure if my post came thru entirely the other day,
as I'm having some issues with rcv'ing posts on time with this List, but
all my other Lists work fine
this was where I posted the method to use the "free-running counter" on the
Apple ][ to seed the RND generator
This isn't a timer, just a counter inc by the Kernal Rom
in this one,
On Sat, Apr 8, 2017 at 1:14 PM, Dan Roganti <ragooman at gmail.com> wrote:

> ​ok found it, I dug up some old reference,​
> Apple ][ has a free running counter at $4E,$4F
> This is a 16bit counter, so that's why it's stored in 2 memory locations
> ,eg. 2 bytes
> where $4E holds the lower byte half of the number, and $4F hold the upper
> byte half of the number
> This is used for the Keyboard Input routine in the Kernal Rom
> But there's one slight glitch to work around, [on live hardware - some
> emulators don't replicate this entirely]
> I know you like to use RUN "filename" most of the times
> But for some reason that counter is frozen at a fixed value, basically
> from the time you Power On the computer.
> So just this first, LOAD "filename", then RUN
> And so the counter will be free running for as long as the computer is On
> Then you just Peek those values at the beginning of your code to seed the
> And this is how you convert the Hex values into Decimal values, same as on
> any computer
> ​S =RND ( -1 * ( PEEK(78) + 256 * PEEK(79) ) )​
> http://paperity.org/p/18923593/cautions-regarding-
> random-number-generation-on-the-apple-ii
> Dan

More information about the vcf-midatlantic mailing list