home *** CD-ROM | disk | FTP | other *** search
/ Carousel Volume 2 #1 / carousel.iso / comdore / 64apps / flicker.arc / FASTRAND.ASM < prev    next >
Assembly Source File  |  1985-11-20  |  317b  |  15 lines

  1.  
  2.     public    _FastRand
  3. _FastRand:
  4.     move.w    randseed,d0
  5.     add.w    d0,d0        ; shift seed left (add dn,dn is faster)
  6.     bhi.s    L5        ; carry? (using bhi instead of bcc unlocks 0s)
  7.     eor.w    #$2B41,d0    ; magic number for 16 bit seed
  8. L5:
  9.     move.w    d0,randseed
  10.     and.w    #$3ff,d0    ; mask down to 0 to 1023
  11.     rts
  12.  
  13.     dseg
  14. randseed dc.w    0
  15.