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

  1. Newsgroups: alt.sys.amiga.demos
  2. Path: sparky!uunet!comp.vuw.ac.nz!lundman
  3. From: lundman@kauri.vuw.ac.nz (L Lundman)
  4. Subject: Re: pseudo random numbers
  5. Nntp-Posting-Host: kauri.vuw.ac.nz
  6. Message-ID: <LUNDMAN.93Jan27074907@kauri.kauri.vuw.ac.nz>
  7. In-Reply-To: larshaug@ifi.uio.no's message of Tue, 26 Jan 1993 09:09:49 GMT
  8. Organization: Disorganised.
  9. Sender: news@comp.vuw.ac.nz (News Admin)
  10. Date: Tue, 26 Jan 1993 19:49:07 GMT
  11. References: <1k19ioINN7l8@darkstar.UCSC.EDU> <1993Jan26.090949.4643@ifi.uio.no>
  12. Lines: 45
  13.  
  14. In article <1993Jan26.090949.4643@ifi.uio.no> larshaug@ifi.uio.no (Lars Haugseth) writes:
  15.  
  16. >   Here's how I do it, and I get pretty good results :
  17. >
  18. >   GETRND:    moveq    #0,d0
  19. >       moveq    #0,d1
  20. >       move.b    $DFF007,d0
  21. >       move.b    $BFD800,d1
  22. >       eor.b    d1,d0
  23. >       rts
  24. >
  25. >   This following is better, but takes more cycles :
  26. >
  27. >   GETRND:    moveq    #0,d0
  28. >       move.b    $DFF007,d0
  29. >       move.b    $BFD800,d1
  30. >       eor.b    d1,d0
  31. >       move.b    d0,d1
  32. >       and.w    #15,d1
  33. >   GRND1:    dbf    d1,GRND1
  34. >       rts
  35. >
  36. >   The loop is done so that the time between my bsr GETRND 's will
  37. >   wary slightly to produce 'more random' numbers.
  38. >
  39. >   Lars
  40. >
  41.  
  42. Another way you could add some randomness is to have a table of 256 bytes
  43. (That is each byte only occuring once but in a random place. No repeats)
  44.  
  45. So when you get a random byte with one of the routine above you can index
  46. into this array and get a new unique value, and using that index in again.
  47.  
  48. About three time makes it look fairly random. I used this to do a fade/morph
  49. routine between two pictures.
  50.  
  51. Kef
  52. --
  53. -------------------------------------------------------------------------------
  54. Jorgen Lundman         eMail: lundman@kauri.vuw.ac.nz, lundman@rata.vuw.ac.nz.
  55. 8 Atua Street          My thoughts are my own and not VUW's..
  56. Johnsonville,wgtn      "Research indicate that only 21 percent of what goes
  57. New Zealand            wrong here is actually my fault."
  58. Phone: +64 4 478 2724 (GMT+11 hrs) Amiga Archive Admin on ftphost.vuw.ac.nz
  59.