Hi!
I have never managed to figure out how to produce sounds with the PSG APIs on the SMS and GameGear.
Bit-banging may not work (no sound is reproduced by KegaFusion even though commercial games do)
and I am not able to compile a simple example with SN PSG (with new APIs such as `psg_channels`).
I have just opened issue #1995 (https://github.com/z88dk/z88dk/issues/1995).
It looks like a bug but maybe I am doing something wrong with the code or the compilation line.
Could someone please provide a simple example that can be compiled and can produce a beep sound on the SMS and/or GameGear?
In particular, as shown in the issue, it seems that `psg_channels` is not found.
If possible I would like to do it with generic code that can be used on several SN PSG targets.
Fabrizio
PSG sounds for SMS and GameGear
Re: PSG sounds for SMS and GameGear
Hello,
is that about AY and YM sound generators?
the ay on zx uses different ports and even 16bit adrsing aginst eg MSX or gameboy which uses 8bit adresing.
in c , i dont know, but i wanted to mention the differences.
is that about AY and YM sound generators?
the ay on zx uses different ports and even 16bit adrsing aginst eg MSX or gameboy which uses 8bit adresing.
in c , i dont know, but i wanted to mention the differences.
Re: PSG sounds for SMS and GameGear
I don't know how to make SMS code (and I don't really care about it much), but after reading some documentation, it's probably simple to make a really simple routine for the SMS SN.
This SN chip is a tone generating chip, it has much less features than an AY chip. That means you can "only" make a tone yourself and then disable it sometime later.
(none of the following is tested, I don't even have an SMS emulator nor do I know how to make a simple program for it.)
(no guarantees at all.)
This SN chip is a tone generating chip, it has much less features than an AY chip. That means you can "only" make a tone yourself and then disable it sometime later.
(none of the following is tested, I don't even have an SMS emulator nor do I know how to make a simple program for it.)
(no guarantees at all.)
Code: Select all
#asm
ld a, 142
out (127), a
ld a, 15
out (127), a
ld a, 144
out (127), a
#endasm
// code for waiting for 30 frames here
// maybe 30 x halt?
#asm
ld a, 159
out (127), a
#endasm
// wait another 30 frames
// then loop this
Re: PSG sounds for SMS and GameGear
Strange, I've tried compiling the example in "examples/sound/psglib", and it didn't made any sound for me in an emulator either.
So I've finished the minimal code in the previous post, and managed to compiled it and it made sound in an emulator.
Can you check if this make any sounds in your emulator? Just to check if your emulator is working.
So I've finished the minimal code in the previous post, and managed to compiled it and it made sound in an emulator.
Code: Select all
/*
* A SMS psg test, april 1st 2022
*
* Compile with:
* zcc +sms -create-app -o sms1.sms sms1.c
*/
void main()
{
char i;
while(1)
{
#asm
ld a, 142
out (127), a
ld a, 15
out (127), a
ld a, 144
out (127), a
#endasm
for (i=0;i<30;i++)
#asm
halt
#endasm
#asm
ld a, 159
out (127), a
#endasm
for (i=0;i<30;i++)
#asm
halt
#endasm
}
}
Re: PSG sounds for SMS and GameGear
One more thing: Strangely, on my emulator (Fusion) if I change the "psg" port into $40, then there is no sound.
But it works if I set the port to $7F then the code above plays a note.
But it works if I set the port to $7F then the code above plays a note.
Re: PSG sounds for SMS and GameGear
this latter case is understandable, in your asm inclusion you are outputting to port 127 (= $7F).
Probably changing the OUT instructions to port 64 it would switch to $40
Probably changing the OUT instructions to port 64 it would switch to $40
Re: PSG sounds for SMS and GameGear
Oops, I meant that if I changed my code above into port $40, there is no sound coming out of my emulator.
Which is strange, since in https://github.com/z88dk/z88dk/blob/mas ... n76489.inc , there is this bit of code:
Why is the default psg port on the sms defined as $40? The default port is $7F. (at least, in the places i looked up on duck.com)
Which is strange, since in https://github.com/z88dk/z88dk/blob/mas ... n76489.inc , there is this bit of code:
Code: Select all
IF FORsms
defc psgport = $40
ENDIF
Re: PSG sounds for SMS and GameGear
It's interesting, because the PSG is meant to be available on port $40 -> $7f (https://www.smspower.org/Development/SN ... opment.PSG)
I'm not sure why $40 was chosen but in theory it should work.
I'm not sure why $40 was chosen but in theory it should work.
Re: PSG sounds for SMS and GameGear
Mmmm in that very same reference It also says that Port 7f was the recommended Port for writing...
Re: PSG sounds for SMS and GameGear
I guess Fabrizio is the only person who can verify whether this is a default port problem or not, by testing the program I wrote above. It's mostly speculations from my side. It could have been something else.