Creating Random numbers #

this code is Atari 8bit specific, as its using the POKEY chip as the source for randomness

: RND ( -- n ) \\ Random Number 0-$FF
  $D20A C@ ;

\\ Random Numner 0..n-1
: RANDOM ( n -- 0..n-1 )
  RND $100 * RND + UM* NIP ;

RND will return a random number between 0 - 255 from the Pokey Noise Randomizer. The Word RANDOM will return a 16bit random number between 0-65535.

Add new attachment

Only authorized users are allowed to upload new attachments.
« This page (revision-2) was last changed on 14-Mar-2010 13:55 by Carsten Strotmann