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 03-Feb-2023 16:21 by Carsten Strotmann  
G’day (anonymous guest) My Prefs
© 2010-2021 AtariWiki
All content in the Wiki is licensed under Creative Commons Share Alike License, unless otherwise noted.
JSPWiki v2.8.3