Re: [cc65] Possible bug in cc65

From: Joseph Rose <rose.joseph121yahoo.com>
Date: 2012-03-26 19:50:42
I looked in the source code of rand() today.  The seed assigner (word check requested) writes only the LSW of the seed DWORD, and the random number generator uses the middle word to return the number and clears the sign bit.  Von Bassewitz: I once created a random number generator for a game that died.  I first retrieved a word from the caller.  Then, I added then XORed the same constant to the word, such that the number is unmodified or, if desired, tweaked.  Then, I XORed the seed word to the number.  Then, I ADDed another constant and XORed another.  Then, I wrote the seed and repeated the previous state.  Depending on the constants used, it should make $10000 hits before repeating.  It seems to work okay with some randomness.  I tried shifting and lost some hits.  Try rotating the value one way before the first ADD/XOR and the other way after.  This might help.  It might also only require a word-size seed.  I request feedback.  :)
----------------
Joseph Rose, a.k.a. Harry Potter
Working magic in the computer community
----------------------------------------------------------------------
To unsubscribe from the list send mail to majordomo@musoftware.de with
the string "unsubscribe cc65" in the body(!) of the mail.
Received on Mon Mar 26 19:50:51 2012

This archive was generated by hypermail 2.1.8 : 2012-03-26 19:50:54 CEST