Re: [cc65] offtopic: random numbers in c64

Date view Thread view Subject view

From: Adam Dunkels (adam_at_sics.se)
Date: 2003-06-26 13:34:40


Hi!

On Thu, 2003-06-26 at 12:43, Piotr Fusik wrote:
> My question is not cc65-related, but please help me. I need a good and
> fast random number generator in c64. On Atari it's lda $d20a (8 bits of
> 17-bit LFSR shifted every cycle). I found something about $d41b, but
> doesn't it interfere with the music?

Yes, it is possible to get good pseudo-random numbers by turning on the
noise waveform on SID voice 3 (and setting the volume of voice 3 to 0)
and reading the output the oscillator at $d41b. And yes, this will
interfere with the music, unless the music plays noise on voice #3.

One technique that I have used to solve this problem is to sample, say,
256 bytes of noise from oscillator #3 before starting to play the music,
and then use these numbers later in the program. If the music stops
sometime during the program, another 256 bytes can be sampled in the
silcence period.

/adam
-- 
Adam Dunkels <adam_at_sics.se>
http://www.sics.se/~adam/

----------------------------------------------------------------------
To unsubscribe from the list send mail to majordomo_at_musoftware.de with
the string "unsubscribe cc65" in the body(!) of the mail.


Date view Thread view Subject view

This archive was generated by hypermail 2.1.3 : 2003-06-26 13:34:55 CEST