Jump to content
  • 0
K4TFJ

Need help with BASIC/ASM access to VERA sound

Question

I have succeeded in setting up sound from BASIC using the following:

300 REM =========================================== SOUND SETUP
310 VPOKE 1,$F9C0,255
320 VPOKE 1,$F9C1,5
330 VPOKE 1,$F9C3,%10000000

Then later in the program, I turn it on and off:

4300 SP=TI+DU
4310 VPOKE 1,$F9C2,255
4320 IF TI<SP THEN GOTO 4320
4330 VPOKE 1,$F9C2,0

This all works fine. I will be honest I do not know exactly what each VPOKE is doing other than the $F9C2. Any help in understanding what is doing would be grateful.

Secondly, I do not know how to increase the volume. I can hear the tone, but it is not as loud as I think it could be. Help!

And last but certainly not least... how do I do the same thing in ASM? I know there is banking involved and could use some help.

I have created a BASIC program to iron out the details of my program prior to attempting the ASM version. I have attached a copy for those interested. It is by no means finished, nor pretty.

 

 

MORSE6.PRG

Share this post


Link to post
Share on other sites

6 answers to this question

Recommended Posts

  • 0

If you look in x16.inc I define the following constant:

VRAM_psg       = $1F9C0

I use that as the basis of all PSG operations, using a fixed offset for the parameter being changed (e.g. volume is in the third byte of each channel, so I use an offset of 2) and then taking the channel number and shifting it left twice (to do a quick x4) to index into the channel's 4-byte section of VRAM (e.g. channel 2 starts at 8 bytes into the PSG registers, so 2 << 2 also gets added to the address).

So, say you want to max the volume of channel X of the PSG, the VRAM address you need to modify is $1F9C0 + 4X + 2. You need to read that in, then OR it with the maximum value (63 or $3F) and store it back to VRAM. The OR will prevent you from modifying the L/R channel bits in the same byte.

Share this post


Link to post
Share on other sites
  • 0

My program MakeWave is an example of using assembly, and acts as a tool to discover how the different parameters in the PSG work:

 

Edited by SlithyMatt

Share this post


Link to post
Share on other sites
  • 0

 

Quote

My program MakeWave is an example of using assembly, and acts as a tool to discover how the different parameters in the PSG work:

I cant seem to locate any address references in your ASM file that correspond to the ones i am using. Am I doing something totally different with a different "sound generator"?

 

Share this post


Link to post
Share on other sites
  • 0
4 minutes ago, K4TFJ said:

 

I cant seem to locate any address references in your ASM file that correspond to the ones i am using. Am I doing something totally different with a different "sound generator"?

 

The PSG registers aren't exposed to the CPU. They must be accessed through the VERA's ports.

Share this post


Link to post
Share on other sites
  • 0

Are the channel names zero indexed? (start with 0)

VPOKE 1,$F9C0,255    // low frequency byte?
VPOKE 1,$F9C1,5        // high frequency byte?
VPOKE 1,$F9C2,255   // L-R-Volume

VPOKE 1,$F9C3,%10000000   // Waveform and pulse width?

So with my example above: this must be channel 0, with frequency set to $05ff (will have to look at the calcs and see what that is)

The 1,$F9C2,255 being this:
255 = 1111 1111, so 11xx xxxx means Left and Right are turned on?
and xx11 1111 means the Volume is maxed?

Am I getting there?

 

Edited by K4TFJ

Share this post


Link to post
Share on other sites
  • 0

That's correct. The frequency value is calculated by multiplying the integer value by (48828.125 / (2^17))  so $05FF is equivalent to 571.832 Hz.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...

Important Information

Please review our Terms of Use