home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: alt.sys.amiga.demos
- Path: sparky!uunet!comp.vuw.ac.nz!lundman
- From: lundman@kauri.vuw.ac.nz (L Lundman)
- Subject: Re: pseudo random numbers
- Nntp-Posting-Host: kauri.vuw.ac.nz
- Message-ID: <LUNDMAN.93Jan27074907@kauri.kauri.vuw.ac.nz>
- In-Reply-To: larshaug@ifi.uio.no's message of Tue, 26 Jan 1993 09:09:49 GMT
- Organization: Disorganised.
- Sender: news@comp.vuw.ac.nz (News Admin)
- Date: Tue, 26 Jan 1993 19:49:07 GMT
- References: <1k19ioINN7l8@darkstar.UCSC.EDU> <1993Jan26.090949.4643@ifi.uio.no>
- Lines: 45
-
- In article <1993Jan26.090949.4643@ifi.uio.no> larshaug@ifi.uio.no (Lars Haugseth) writes:
-
- > Here's how I do it, and I get pretty good results :
- >
- > GETRND: moveq #0,d0
- > moveq #0,d1
- > move.b $DFF007,d0
- > move.b $BFD800,d1
- > eor.b d1,d0
- > rts
- >
- > This following is better, but takes more cycles :
- >
- > GETRND: moveq #0,d0
- > move.b $DFF007,d0
- > move.b $BFD800,d1
- > eor.b d1,d0
- > move.b d0,d1
- > and.w #15,d1
- > GRND1: dbf d1,GRND1
- > rts
- >
- > The loop is done so that the time between my bsr GETRND 's will
- > wary slightly to produce 'more random' numbers.
- >
- > Lars
- >
-
- Another way you could add some randomness is to have a table of 256 bytes
- (That is each byte only occuring once but in a random place. No repeats)
-
- So when you get a random byte with one of the routine above you can index
- into this array and get a new unique value, and using that index in again.
-
- About three time makes it look fairly random. I used this to do a fade/morph
- routine between two pictures.
-
- Kef
- --
- -------------------------------------------------------------------------------
- Jorgen Lundman eMail: lundman@kauri.vuw.ac.nz, lundman@rata.vuw.ac.nz.
- 8 Atua Street My thoughts are my own and not VUW's..
- Johnsonville,wgtn "Research indicate that only 21 percent of what goes
- New Zealand wrong here is actually my fault."
- Phone: +64 4 478 2724 (GMT+11 hrs) Amiga Archive Admin on ftphost.vuw.ac.nz
-