Page 1 of 1

Random Noise Generator

Posted: Thu Apr 04, 2019 2:41 pm
by javelinatina
So I tried out a one line random noise generator program based off one I know about for the C64. Goes like so:

10 POKE 36874+RND(1)*25,RND(1)*256 : GOTO 10

But when I run this the VIC-20 (right now just an emulator for experimenting, I should say) the screen explodes into random color madness, and while this is delightful, I would like a certain degree of control over it. How would I prevent this? Also, if I didn't want to prevent this, how would I be able to stop it and get back to programming? When the ball gets rolling on the above program and I hit STOP it leaves the screen as a blob of color and characters.

Thanks!

Re: Random Noise Generator

Posted: Thu Apr 04, 2019 5:35 pm
by Kweepa
Well, geez, you are poking garbage into the vic registers, so it's expected that the vic goes crazy.
To get it back you can copy the original state, and replace it once done.
If you break into the program you should be able to type goto30 to run the recovery code.

10 dimv(26):fori=0to25:v(i)=peek(36874+i):next
20 fori=1to200:poke36874+rnd(1)*25,rnd(1)*256:next
30 fori=0to25:poke36874+i,v(i):next

Re: Random Noise Generator

Posted: Fri Apr 05, 2019 10:03 am
by javelinatina
Hey thanks! Is there a way to do this without any effect on the screen?

Re: Random Noise Generator

Posted: Fri Apr 05, 2019 11:32 am
by Stormcrow
You just want random white noise?

Code: Select all

10 POKE 36878,15
20 POKE 36877,RND(0)*128+128
30 GOTO 20
40 POKE 36878,0
50 POKE 36877,0
When you're done listening, press STOP then RUN 40 to make the noise go away.

36877 is the white noise register (values 128–255), and 36878 is the volume (values 0–15).

Re: Random Noise Generator

Posted: Fri Apr 05, 2019 11:37 am
by Stormcrow
Or even more noise:

Code: Select all

10 POKE 36878,15
20 POKE 36874+RND(0)*4,128+RND(0)*128
30 GOTO 20
40 FOR I=36874 TO 36878
50 POKE I,0
60 NEXT

Re: Random Noise Generator

Posted: Fri Apr 05, 2019 12:46 pm
by javelinatina
That second one is exactly what I was looking for! Very cool! Thanks a lot!