Hi,

  Following the recent thread about the PSG, I found these interesting
emails in my mailbox from one year ago about playing 4 bit PCM samples
via the PSG. It might be educating and interesting to reread it.

  Bye, /\/\ark


On Mon, 22 Jun 1998, Laurens Holst wrote:

> === How to replay samples via the PSG??? ===
> 

        You have to use an undocumented feature of the PSG. When you
select a period of 0 in the register 6, the noise produced is just like
the noise when you select 1 in this same register. 

        But this does not apply to the square wave generators. When you
write a 0 to registers 0 and 1, what's happening is that you TURN OFF THE
OSCILLATORS. Since the PSG uses active low logic, the signal on the output
is set to "1" and don't change with time.

        Now comes the trick. This "1" is affected by the register 8
(volume register). This way, if you change very quickly the value of
register 8, you can modulate the output and generate a nice 4-bit PCM.
This method is used in the game "Aleste 2". 

        I made a program to test this feature, it's called "readwav" and
it can play .WAV files of 11 kHz. It can be found at 
http://www.lsi.usp.br/~ricardo/msx.htm. The maximum wave size is about
50kb but Walter "Marujo" made a new version that play files up to 100kb,
I'll try to add it to the home page as soon as possible.

        There is no source code included, but my original source doesn't
have any comment, the best you can do is disassemble it by hand (it has
only 512 bytes anyway).  Oh, this 11kHz is arbitrary: by removing a
void-loop in the middle of the code you can reach up to 35 kHz. 

        Please note this is not the only way to generate samples in MSX-1.
You can also use the keyclick to generate 1-bit PCM (used in the game
"Super Laydock", for example). 

        Another undocumented feature of the PSG permits a variation on the
first method. Most people thinks the lower bits of register 7 are used to
send the volume of a channel to zero. This is not true. This bit actually
controls the oscillator. So, by disabling a channel in register 7, you can
write any values you want in registers 1 and 0 and still use the
initial method (btw, this is used in "Oh Shit").

        A last method is to select a sound with very low frequency, and
change the volume faster this frequency. This method is not used in any
MSX game that I know, since it is very unaccurate. But it's used a lot in
the Sega Master System, in games like "Afterburner". The Sega Master
System, for those who don't know, is a videogame heavily based in the MSX.
It uses a Z80 and a sound chip with the same characteristics as the
AY-3-8910 (but it doesn't have envelopes).

------------------------------------------------------------
Ricardo Bittencourt           http://www.lsi.usp.br/~ricardo
[EMAIL PROTECTED]    "Save the trees: eat more woodpeckers"

****
MSX Mailinglist. To unsubscribe, send an email to [EMAIL PROTECTED] and put
in the body (not subject) "unsubscribe msx [EMAIL PROTECTED]" (without the
quotes :-) Problems? contact [EMAIL PROTECTED] (www.stack.nl/~wiebe/mailinglist/)
****






On Mon, 22 Jun 1998, Alex Wulms wrote:

> Are there any more undocumented features in the PSG, the MSX1 VDP and any 
> other chips used in the MSX which all programmers and other MSX fans should 
> be aware of?
>

        Sean Young's page (www.msxnet.org) has a description of a
undocumented MSX1 VDP feature, when you set the address for reading. You
should read that.

        But one thing I ever wanted to do and never had the chance is to
transform your MSX1 into an AM radio.

        The idea is simple: remember that fourth PCM method, when you set
the PSG to a very low frequency and send bytes faster than that? Now think
of it backwards, setting the PSG in a very high frequency and sending the
data slowly.

        Let's take some values: if you write 0001 to the first pair of PSG
registers, the oscillator will generate a square wave of ~ 110 kHz. And
now you modulate the output at audio values, like 8 kHz or 11 kHz. Notice
the word here: "modulate". What you're doing is an AM modulation of the
initial square wave.

        Since the carrier is a square wave, your spectrum will have
signals at 110 kHz, 330 kHz, 550 kHz, and if the signal is strong enough,
this 550 kHz signal can be detected by a common AM-DSB radio (at least in
theory, I never tried it). 

        If anyone wants to try it, don't forget to wire the antenna
directly to the PSG pins. The MSX has an amplifier with a low-pass filter
that cut signals higher than audio.

------------------------------------------------------------
Ricardo Bittencourt           http://www.lsi.usp.br/~ricardo
[EMAIL PROTECTED]    "Save the trees: eat more woodpeckers"

****
MSX Mailinglist. To unsubscribe, send an email to [EMAIL PROTECTED] and put
in the body (not subject) "unsubscribe msx [EMAIL PROTECTED]" (without the
quotes :-) Problems? contact [EMAIL PROTECTED] (www.stack.nl/~wiebe/mailinglist/)
****




Reply via email to