Controlling the TT sound system.

News,announcements,programming,fixes,game patches & discussions.

Moderator: Petari

stephen_usher
Posts: 134
Joined: Mon Nov 13, 2017 7:19 pm
Location: Oxford, UK.
Contact:

Controlling the TT sound system.

Post by stephen_usher » Sat May 26, 2018 6:19 pm

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?
Intro retro computers since before they were retro...
ZX81->Spectrum->Memotech MTX->Sinclair QL->520STM->BBC Micro->TT030->PCs & Sun Workstations.
Added code to the MiNT kernel (still there the last time I checked) + put together MiNTOS.
Collection now with added Macs, Amigas, Suns and Acorns.

Petari
Posts: 536
Joined: Tue Nov 28, 2017 1:32 pm

Re: Controlling the TT sound system.

Post by Petari » Sun May 27, 2018 8:00 am

Audio DMA system is same in STE, Mega STE and TT - except internal speaker in TT . So, you can use docs about Microwire for STE . It should be in Atari Compendium what port , which bit controls internal speaker on/off . It may be same as in case of Falcon - PSG port A, bit 6. I'm not sure, you should try with search online, probably was mentioned in some forums. The funny thing is that I had here 2 TTs for some time (got them for SW testing purpose), and never heard any internal speaker sound. They were probably removed, as simplest and most effective solution :lol:
There is 2 kind of people: one thinking about moving to Mars after here becomes too bad, the others thinking about how to keep this planet habitable.

stephen_usher
Posts: 134
Joined: Mon Nov 13, 2017 7:19 pm
Location: Oxford, UK.
Contact:

Re: Controlling the TT sound system.

Post by stephen_usher » Sun May 27, 2018 9:01 am

Your TT speakers probably just stopped working. I had to replace mine as the internal coil died whilst the machine was in storage.
Intro retro computers since before they were retro...
ZX81->Spectrum->Memotech MTX->Sinclair QL->520STM->BBC Micro->TT030->PCs & Sun Workstations.
Added code to the MiNT kernel (still there the last time I checked) + put together MiNTOS.
Collection now with added Macs, Amigas, Suns and Acorns.

Petari
Posts: 536
Joined: Tue Nov 28, 2017 1:32 pm

Re: Controlling the TT sound system.

Post by Petari » Sun May 27, 2018 10:50 am

It were not mine TTs - as said, I got them "for testing", "for some time".
There is 2 kind of people: one thinking about moving to Mars after here becomes too bad, the others thinking about how to keep this planet habitable.

stephen_usher
Posts: 134
Joined: Mon Nov 13, 2017 7:19 pm
Location: Oxford, UK.
Contact:

Re: Controlling the TT sound system.

Post by stephen_usher » Sun May 27, 2018 11:35 am

Someone on the Atari Forum pointed me at the XCONTROL.ACC source file 'block2.c' which uses the following to control the TT speaker:
void
Set_Speaker( void )
{
if( IsSpeaker() )
{
if( cur_value.TT_Speaker )
Offgibit( 0xBf ); /* Turn off Speaker */
else
Ongibit( 0x40 ); /* Turn on Speaker */

}
}
Now, I've put this in my code and it makes not a darned bit of difference, as you can see here with my broken for some reason volume setting code...
#include <osbind.h>
#include <string.h>

#define MICROWIRE_DATA_ADDR 0xff8922
#define MICROWIRE_MASK_ADDR 0xff8924

unsigned short *mw_mask = MICROWIRE_MASK_ADDR;
unsigned short *mw_data = MICROWIRE_DATA_ADDR;

unsigned short value;

void do_microwire();

void set_volume(int volume)
{
value = 0x0400 + volume;

Supexec(do_microwire);

return;
}

void do_microwire()
{
int i;
unsigned short mask = 0x07ff;

*mw_mask = mask;

while(*mw_mask != mask) i++;

*mw_data = value;
}

void set_speaker(int onoff)
{
if (onoff == 0)
Offgibit(0x8f);
else
Ongibit(0x40);

return;
}
What fun the STe/TT sound system is, not!

P.S. I think I've seen why my volume setting might be broken, I should use 0x04c0 rather than 0x0400 to add to the volume level (0 -> 40).
Intro retro computers since before they were retro...
ZX81->Spectrum->Memotech MTX->Sinclair QL->520STM->BBC Micro->TT030->PCs & Sun Workstations.
Added code to the MiNT kernel (still there the last time I checked) + put together MiNTOS.
Collection now with added Macs, Amigas, Suns and Acorns.

stephen_usher
Posts: 134
Joined: Mon Nov 13, 2017 7:19 pm
Location: Oxford, UK.
Contact:

Re: Controlling the TT sound system.

Post by stephen_usher » Sun May 27, 2018 12:30 pm

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.
Intro retro computers since before they were retro...
ZX81->Spectrum->Memotech MTX->Sinclair QL->520STM->BBC Micro->TT030->PCs & Sun Workstations.
Added code to the MiNT kernel (still there the last time I checked) + put together MiNTOS.
Collection now with added Macs, Amigas, Suns and Acorns.

stephen_usher
Posts: 134
Joined: Mon Nov 13, 2017 7:19 pm
Location: Oxford, UK.
Contact:

Re: Controlling the TT sound system.

Post by stephen_usher » Mon May 28, 2018 4:07 pm

Oh well, it turns out Ongibit(0x40) was working to turn off the speaker but the game I was testing all the time, "Bubble Bobble" (or the hard disk loader) seems to reset the PSG Port A for some unknown reason.

I only found this out after trying many things including upgrading mintlibs to patchlevel 46 from 44, making sure that the argument passed was an unsigned short etc.

I'd given up and moved onto the machine detection part. Then I tried "Chaos Engine" and amazingly there was no sound from the speaker!

So, the final job will be turning off the CPU caches if the machine is a TT.
Intro retro computers since before they were retro...
ZX81->Spectrum->Memotech MTX->Sinclair QL->520STM->BBC Micro->TT030->PCs & Sun Workstations.
Added code to the MiNT kernel (still there the last time I checked) + put together MiNTOS.
Collection now with added Macs, Amigas, Suns and Acorns.

Petari
Posts: 536
Joined: Tue Nov 28, 2017 1:32 pm

Re: Controlling the TT sound system.

Post by Petari » Mon May 28, 2018 4:54 pm

You will encounter many other games turning TT speaker back on. Simply because programmers were not aware that PSG port A will be used for such function. Same problems appear with floppy code on Mega STE - there is bit on that port what controls VME bus - if some SW changes it's state machine usually crashes. In case of Falcon SW may switch off IDE port, so hard disk. Shared ports were never good idea. Hard disk loader certainly deals not with PSG port. (well, unless is written by nut :D ) .
There is 2 kind of people: one thinking about moving to Mars after here becomes too bad, the others thinking about how to keep this planet habitable.

stephen_usher
Posts: 134
Joined: Mon Nov 13, 2017 7:19 pm
Location: Oxford, UK.
Contact:

Re: Controlling the TT sound system.

Post by stephen_usher » Mon May 28, 2018 10:50 pm

Just in case you're interested I've finished my game menu program and you can download it here:

http://www.lingula.org.uk/~steve/downlo ... enu.tar.gz
Intro retro computers since before they were retro...
ZX81->Spectrum->Memotech MTX->Sinclair QL->520STM->BBC Micro->TT030->PCs & Sun Workstations.
Added code to the MiNT kernel (still there the last time I checked) + put together MiNTOS.
Collection now with added Macs, Amigas, Suns and Acorns.

Petari
Posts: 536
Joined: Tue Nov 28, 2017 1:32 pm

Re: Controlling the TT sound system.

Post by Petari » Tue May 29, 2018 7:22 am

Would be good to put there resulting Atari PRG file, don't you think ? Or everyone should self compile it ?
There is 2 kind of people: one thinking about moving to Mars after here becomes too bad, the others thinking about how to keep this planet habitable.

Post Reply