Sound Effects

Basic and Machine Language

Moderator: Moderators

User avatar
Jeff-20
Denial Founder
Posts: 5759
Joined: Wed Dec 31, 1969 6:00 pm

Post by Jeff-20 »

Very good! Why is V set to 36864 instead of something like 36874 so you only have to add a single digit? :) :?
High Scores, Links, and Jeff's Basic Games page.
User avatar
Mike
Herr VC
Posts: 4842
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Post by Mike »

Here I use V=36864 as the base address of the VIC chip. In my programs I either write out the addresses in full, i.e. 36878, or 36879, or I use this convention. Also, in ML the VIC registers are addressed as $900x, with x=0..F.

Using another VIC register as "base" (say, S=36875) implies a more arbitrary choice, and one might well end up with negative offsets, like POKES-6,255 to activate custom chars.
User avatar
Jeff-20
Denial Founder
Posts: 5759
Joined: Wed Dec 31, 1969 6:00 pm

Post by Jeff-20 »

Mike wrote:Using another VIC register as "base" (say, S=36875) implies a more arbitrary choice, and one might well end up with negative offsets, like POKES-6,255 to activate custom chars.
That's how I do it. I try to keep all offsets to single digits, saving a byte or two in longer programs.
High Scores, Links, and Jeff's Basic Games page.
User avatar
Mike
Herr VC
Posts: 4842
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Post by Mike »

Of course. That depends on what priorities one has regarding function, clarity, speed, and length of program code. ;)
Commander#1
Vic 20 Drifter
Posts: 38
Joined: Wed Feb 25, 2009 1:48 am

Sound effects

Post by Commander#1 »

Can someone check this out? My VIC is down. It's suppose to sound like R2D2.

10 for L=1 to int(20*rnd(1))
20 poke 36878, int(14*rnd(1))
30 poke 36874, 240 + int(16*rnd(1))
40 for T=1 to int(150*rnd(1)): next
50 poke 36878, 0: next
60 getA$: if A$="" then 60
70 goto 10

Phil.
The earth is - oh my gosh - ROUND ! !
User avatar
Jeff-20
Denial Founder
Posts: 5759
Joined: Wed Dec 31, 1969 6:00 pm

Post by Jeff-20 »

I love fun type-ins like this. It sounds lovely! I would change the loop in like 10 to

10 for l = 10 to int(20*rnd(1))

It sounds better when it is longer.
High Scores, Links, and Jeff's Basic Games page.
carlsson
Class of '6502
Posts: 5516
Joined: Wed Mar 10, 2004 1:41 am

Re: Sound effects

Post by carlsson »

Commander#1 wrote:30 poke 36874, 240 + int(16*rnd(1))
I would either change the offset to 239 or the random range to 15. This is because POKE 36874,255 generates the lowest note the VIC-20 can play, not the highest in the register as you might expect. On the other hand, perhaps this is exactly what you want, a very low beep now and then. If so, leave everything as it is.

The range of the oscillators is 255, 128-254.
Anders Carlsson

Image Image Image Image Image
Post Reply