home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / alt / sys / amiga / demos / 2352 < prev    next >
Encoding:
Text File  |  1993-01-26  |  1.5 KB  |  60 lines

  1. Nntp-Posting-Host: yrsa.ifi.uio.no
  2. Newsgroups: alt.sys.amiga.demos
  3. Path: sparky!uunet!mcsun!sunic!aun.uninett.no!nuug!ifi.uio.no!larshaug
  4. From: larshaug@ifi.uio.no (Lars Haugseth)
  5. Subject: Re: pseudo random numbers
  6. Message-ID: <1993Jan26.090949.4643@ifi.uio.no>
  7. Sender: larshaug@ifi.uio.no (Lars Haugseth)
  8. Organization: Dept. of Informatics, University of Oslo, Norway
  9. References:  <1k19ioINN7l8@darkstar.UCSC.EDU>
  10. Date: Tue, 26 Jan 1993 09:09:49 GMT
  11. Lines: 46
  12. Originator: larshaug@yrsa.ifi.uio.no
  13.  
  14.  
  15. In article <1k19ioINN7l8@darkstar.UCSC.EDU>, moria@ucscb.UCSC.EDU (Moria Beledain) writes:
  16. > pfibl.
  17. > i am looking for a Good pseudo random number generator. 
  18. > the one i am using now was by Leo Schwabb many years ago, and
  19. > i have modified it to now and then EOR in some clock counter
  20. > etc..  But i am still not satisfied!
  21. >  
  22. > so who knows some good ideas ?
  23. > .. Maybe a routine to use the HPos..  It has periods of
  24. > very fast fluctuation which if polled slow enough could seem
  25. > quite random..
  26. > .. hmm
  27. > rnd
  28. >     move.w    seed,d0
  29. >      lsl.w    #4,d0
  30. >     eor.b    HPOS,d0
  31. >     move.w    d0,seed
  32. >     rts
  33. >  
  34.  
  35. Here's how I do it, and I get pretty good results :
  36.  
  37. GETRND:    moveq    #0,d0
  38.     moveq    #0,d1
  39.     move.b    $DFF007,d0
  40.     move.b    $BFD800,d1
  41.     eor.b    d1,d0
  42.     rts
  43.  
  44. This following is better, but takes more cycles :
  45.  
  46. GETRND:    moveq    #0,d0
  47.     move.b    $DFF007,d0
  48.     move.b    $BFD800,d1
  49.     eor.b    d1,d0
  50.     move.b    d0,d1
  51.     and.w    #15,d1
  52. GRND1:    dbf    d1,GRND1
  53.     rts
  54.  
  55. The loop is done so that the time between my bsr GETRND 's will
  56. wary slightly to produce 'more random' numbers.
  57.  
  58. Lars
  59.