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!
Random Noise Generator
Moderator: Moderators
-
- Vic 20 Newbie
- Posts: 4
- Joined: Tue Mar 26, 2019 8:00 am
- Location: Bham, AL
- Kweepa
- Vic 20 Scientist
- Posts: 1316
- Joined: Fri Jan 04, 2008 5:11 pm
- Location: Austin, Texas
- Occupation: Game maker
Re: Random Noise Generator
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
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
-
- Vic 20 Newbie
- Posts: 4
- Joined: Tue Mar 26, 2019 8:00 am
- Location: Bham, AL
Re: Random Noise Generator
Hey thanks! Is there a way to do this without any effect on the screen?
- Stormcrow
- Vic 20 Enthusiast
- Posts: 177
- Joined: Mon Dec 24, 2012 9:46 pm
- Website: http://trimboli.name
- Location: Ronkonkoma, NY
Re: Random Noise Generator
You just want random white noise?
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).
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
36877 is the white noise register (values 128–255), and 36878 is the volume (values 0–15).
- Stormcrow
- Vic 20 Enthusiast
- Posts: 177
- Joined: Mon Dec 24, 2012 9:46 pm
- Website: http://trimboli.name
- Location: Ronkonkoma, NY
Re: Random Noise Generator
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
-
- Vic 20 Newbie
- Posts: 4
- Joined: Tue Mar 26, 2019 8:00 am
- Location: Bham, AL
Re: Random Noise Generator
That second one is exactly what I was looking for! Very cool! Thanks a lot!