Controlling the TT sound system.

C and PASCAL (or any other high-level languages) in here please

Moderators: simonsunnyboy, Mug UK, Zorro 2, Moderator Team

Post Reply
susher
Obsessive compulsive Atari behavior
Obsessive compulsive Atari behavior
Posts: 131
Joined: Sat Oct 03, 2015 7:06 pm

Controlling the TT sound system.

Post by susher »

I'm currently writing a game menu program to sit in the AUTO folder which will then list the available games allow a user to select and run them.

I've got the basics working but because it runs before the sound control panel has started the sound defaults to maximum volume with the internal speaker turned on.

What I would like to do is allow the program's configuration file to contain the default volume and whether the internal speaker is enabled.

I think I can probably work out how to use the Microwire interface to control the volume from C but I've found no documentation about how to control the internal speaker. The Atari TT release notes don't mention it and merely say that the DMA sound system is the same as the STe's. I'm guessing that it would be the same on the Mega STe.

Does anyone know?
User avatar
lp
Fuji Shaped Bastard
Fuji Shaped Bastard
Posts: 2517
Joined: Wed Nov 12, 2003 11:09 pm
Location: GFA Headquarters
Contact:

Re: Controlling the TT sound system.

Post by lp »

For the speaker have a look at the source code of XCONTROL.ACC. Specifically file BLOCK2.C.
BLOCK2.C
You do not have the required permissions to view the files attached to this post.
mikro
Hardware Guru
Hardware Guru
Posts: 2231
Joined: Sat Sep 10, 2005 11:11 am
Location: Kosice, Slovakia
Contact:

Re: Controlling the TT sound system.

Post by mikro »

Btw, there's a similar tool for given task: http://paradize.final-memory.org/tools.shtml (Atari ST Harddisk Menu)
susher
Obsessive compulsive Atari behavior
Obsessive compulsive Atari behavior
Posts: 131
Joined: Sat Oct 03, 2015 7:06 pm

Re: Controlling the TT sound system.

Post by susher »

Excellent! Thank-you.

Where can I find the complete source of XCONTROL.ACC?

There's a lot of routines and information in the headers etc.
czietz
Hardware Guru
Hardware Guru
Posts: 1292
Joined: Tue May 24, 2016 6:47 pm

Re: Controlling the TT sound system.

Post by czietz »

susher wrote:Excellent! Thank-you.

Where can I find the complete source of XCONTROL.ACC?

There's a lot of routines and information in the headers etc.
Source code of XCONTROL itself and the CPXes: https://www.dev-docs.org/docs/htm/searc ... ri_src.zip
susher
Obsessive compulsive Atari behavior
Obsessive compulsive Atari behavior
Posts: 131
Joined: Sat Oct 03, 2015 7:06 pm

Re: Controlling the TT sound system.

Post by susher »

Thanks.

The relevant code in BLOCK2.C seems to be:

Code: Select all

void
Set_Speaker( void )
{
   if( IsSpeaker() )
   {
      if( cur_value.TT_Speaker )
            Offgibit( 0xBf );           /* Turn off Speaker */
      else
            Ongibit( 0x40 );            /* Turn on Speaker */

   }
}
However, if I use this in my program it doesn't seems to do anything at all.
susher
Obsessive compulsive Atari behavior
Obsessive compulsive Atari behavior
Posts: 131
Joined: Sat Oct 03, 2015 7:06 pm

Re: Controlling the TT sound system.

Post by susher »

Doh! I've just re-read the TT Release Notes again and found what it says is the speaker on/off:
PROGRAMMABLE SOUND GENERATOR
(also provides bi-directional parallel printer port and miscellaneous output latch)
8800 RO xxxx xxxx ---- ---- PSG Read Data
8800 WO 0000 0000 ---- ---- PSG Register Select
8802 WO xxxx xxxx ---- ---- PSG Write Data
Port A Bit Assignments
7 *LAN Select (0 routes SCC Port A to LAN connector)
6 *Speaker Disable (0 disables internal speaker)
5 Printer Port Strobe
4 *DTR (MFP-ST serial port)
3 *RTS (MFP-ST serial port)
2 *Floppy 1 Select
1 *Floppy 0 Select
0 *Floppy Side 0 Select
I'm guessing that the '*' means TT only, but that doesn't fit with the bits 0-3 definitions.

Still Ongibit(6) and Offgibit(6) still don't do anything for the speaker.
czietz
Hardware Guru
Hardware Guru
Posts: 1292
Joined: Tue May 24, 2016 6:47 pm

Re: Controlling the TT sound system.

Post by czietz »

susher wrote:Still Ongibit(6) and Offgibit(6) still don't do anything for the speaker.
Of course not, because the original syntax was right. You don't give the bit number to Ongibit and Offgibit, but a bit mask, like Atari did in the GENERAL.CPX source code.

As for why the correct code doesn't work for you: The speaker isn't broken, is it? Also of course if you have muted the sound via the LMC1992, the speaker won't be able to output anything.
susher
Obsessive compulsive Atari behavior
Obsessive compulsive Atari behavior
Posts: 131
Joined: Sat Oct 03, 2015 7:06 pm

Re: Controlling the TT sound system.

Post by susher »

Well, the original didn't work to turn off the speaker (it continues to operate).

I changed the value to 6 after reading the definition of the function calls in "Atari ST Internals" which says give the bit number and gives examples in assembler.
czietz
Hardware Guru
Hardware Guru
Posts: 1292
Joined: Tue May 24, 2016 6:47 pm

Re: Controlling the TT sound system.

Post by czietz »

Atari ST Internals is wrong here, I recommend using other documentation.

But back to the original question: Can you turn the speaker on and off using Atari's control panel?
susher
Obsessive compulsive Atari behavior
Obsessive compulsive Atari behavior
Posts: 131
Joined: Sat Oct 03, 2015 7:06 pm

Re: Controlling the TT sound system.

Post by susher »

Yes, the control panel operates correctly.
czietz
Hardware Guru
Hardware Guru
Posts: 1292
Joined: Tue May 24, 2016 6:47 pm

Re: Controlling the TT sound system.

Post by czietz »

I can confirm that on my TT Ongibit( 0x40 ) turns the speaker off while Offgibit( 0xBF ) turns it on. So the commands are correct, just the comments in the source code are wrong.
susher
Obsessive compulsive Atari behavior
Obsessive compulsive Atari behavior
Posts: 131
Joined: Sat Oct 03, 2015 7:06 pm

Re: Controlling the TT sound system.

Post by susher »

Well, I'm blowed if I can get it to work either way.

Here's my code:

Code: Select all

void set_speaker(int onoff)
{
#ifdef DEBUG2
        printf("set_speaker: onoff = %d\n", onoff);
#endif
        if (onoff == 0)
        {
#ifdef DEBUG2
        printf("set_speaker: Offgibit(0xbf)\n");
#endif
                Offgibit(0xbf);
        }
        else
        {
#ifdef DEBUG2
        printf("set_speaker: Ongibit(0x40)\n");
#endif
                Ongibit(0x40);
        }
#ifdef DEBUG2
        sleep(5);
#endif
        return;
}
I wonder if I need to cast the values passed to Ongibit() and Offgibit() to unsigned char?
joska
Hardware Guru
Hardware Guru
Posts: 4749
Joined: Tue Oct 30, 2007 2:55 pm
Location: Florø, Norway
Contact:

Re: Controlling the TT sound system.

Post by joska »

Which compiler? Does this code work?

Code: Select all

#include <tos.h>

void main(void)
{
	Cconws("Speaker off\n\rPress a key\n\r");
	Ongibit(0x40);
	Cconin();
}
SPEAKOFF.zip
You do not have the required permissions to view the files attached to this post.
Jo Even

VanillaMiNT - Firebee - Falcon060 - Milan060 - Falcon040 - MIST - Mega ST - STM - STE - Amiga 600 - Sharp MZ700 - MSX - Amstrad CPC - C64
susher
Obsessive compulsive Atari behavior
Obsessive compulsive Atari behavior
Posts: 131
Joined: Sat Oct 03, 2015 7:06 pm

Re: Controlling the TT sound system.

Post by susher »

Which compiler/libraries are you using?

I'm using an ancient GCC and mintlibs44 at the moment.
joska
Hardware Guru
Hardware Guru
Posts: 4749
Joined: Tue Oct 30, 2007 2:55 pm
Location: Florø, Norway
Contact:

Re: Controlling the TT sound system.

Post by joska »

I'm using PureC.
Jo Even

VanillaMiNT - Firebee - Falcon060 - Milan060 - Falcon040 - MIST - Mega ST - STM - STE - Amiga 600 - Sharp MZ700 - MSX - Amstrad CPC - C64
susher
Obsessive compulsive Atari behavior
Obsessive compulsive Atari behavior
Posts: 131
Joined: Sat Oct 03, 2015 7:06 pm

Re: Controlling the TT sound system.

Post by susher »

Upgraded to mintlibs Pl.46 (still gcc 2.5.8 PL 1). Tried passing an unsigned short as the mask and no difference. I even tried setting the high byte rather than the low one in case that was the issue, but no.
joska
Hardware Guru
Hardware Guru
Posts: 4749
Joined: Tue Oct 30, 2007 2:55 pm
Location: Florø, Norway
Contact:

Re: Controlling the TT sound system.

Post by joska »

Did my program (binary) work?
Jo Even

VanillaMiNT - Firebee - Falcon060 - Milan060 - Falcon040 - MIST - Mega ST - STM - STE - Amiga 600 - Sharp MZ700 - MSX - Amstrad CPC - C64
ThorstenOtto
Atari God
Atari God
Posts: 1212
Joined: Sun Aug 03, 2014 5:54 pm

Re: Controlling the TT sound system.

Post by ThorstenOtto »

susher wrote:Upgraded to mintlibs Pl.46 (still gcc 2.5.8 PL 1)
Is there a specific reason for using such an old compiler? Might as well be that he is just generating wrong code.
susher
Obsessive compulsive Atari behavior
Obsessive compulsive Atari behavior
Posts: 131
Joined: Sat Oct 03, 2015 7:06 pm

Re: Controlling the TT sound system.

Post by susher »

joska wrote:Did my program (binary) work?
Yes, it did.
susher
Obsessive compulsive Atari behavior
Obsessive compulsive Atari behavior
Posts: 131
Joined: Sat Oct 03, 2015 7:06 pm

Re: Controlling the TT sound system.

Post by susher »

ThorstenOtto wrote:
susher wrote:Upgraded to mintlibs Pl.46 (still gcc 2.5.8 PL 1)
Is there a specific reason for using such an old compiler? Might as well be that he is just generating wrong code.
2.5.8p1 was one of the good versions. 2.7.2 was the classic high-point for GCC and probably the last you'd want to run natively on an Atari.

The reason? Well, I'm running under MiNT 1.12 and looking at updating my old MiNTOS distribution incrementally.
susher
Obsessive compulsive Atari behavior
Obsessive compulsive Atari behavior
Posts: 131
Joined: Sat Oct 03, 2015 7:06 pm

Re: Controlling the TT sound system.

Post by susher »

As it happens, once I made sure that the mask being passed to Ongibit was an unsigned short it did work. However, I didn't realise that it did as it seems the game I was testing this with seems to reset the PSG Port A for some unknown reason, which meant that my work was undone by it.

It was only after working on another part of the code and decided to try a different game that I found that it was in fact working!
susher
Obsessive compulsive Atari behavior
Obsessive compulsive Atari behavior
Posts: 131
Joined: Sat Oct 03, 2015 7:06 pm

Re: Controlling the TT sound system.

Post by susher »

In case anyone's interested, I've finished the game launcher menu program, at least for this iteration.

You can find it here:

Image
Post Reply

Return to “C / PASCAL etc.”