Detection of FM sound chips
Tuesday, August 9, 2011, 11:47
Introduction
MSX has some sound chips based on FM synthesis. In this article only the detection of MSX-AUDIO, MSX-MUSIC and MoonSound will be described. These are most used and are based on the same type of FM synthesis, which means they all can be used to produce the same sound with the same data up to a point.
MSX-AUDIO
MSX-AUDIO is built around the Y8950 chip. It's an OPL1 chip with ADPCM record and play capabilities. It's used in the Philips NMS-1205 Music Module, Toshiba HX-MU900 Synthesizer Unit and Panasonic FS-CA1 MSX-AUDIO Module.
On MSX the Y8950 chip can be accessed through one of 2 port ranges: $C0-$C1 or $C2-$C3. The Philips and Toshiba ones can only be accessed through port range $C0-$C1. The Panasonic one can be accessed through either port range. This is because it's capable of selecting the range it should use. If it hasn't detected an MSX-AUDIO yet, it'll set itself up on port range $C0-$C1. Otherwise it'll set itself up on port range $C2-$C3. This way up to 2 MSX-AUDIOs can be used and only if there's at least 1 Panasonic used. It's possible for the Philips and Toshiba ones to be adapted to run on port range $C2-$C3.
Detecting the availability of MSX-AUDIO, read I/O port $C0. If it returns $06, it's MSX-AUDIO. If it returns $00, it's actually MoonSound with port range $C0-$C3 enabled. For information about MoonSound continue reading this article.
MSX-MUSIC
MSX-MUSIC is built around the YM2413 chip. It's an OPLL (a simplified OPL2) chip. Several external variants appeared: FM-PAK (released in Korea and by some Dutch MSX clubs), FM-Stereo-PAK (released by Checkmark, splitting up the MSX-MUSIC melody and rhythm outputs and mixing the latter optionally with the PSG using a seperate input) and the Panasonic SW-M004 FM-PAC (FM Pana Amusement Cartridge). Many MSX2+ and all MSXturboR machines have MSX-MUSIC internally.
On MSX the YM2413 chip can be accessed through port range $7C-$7D. Apart from the FM-PAC it's immediately accessible. When using the FM-PAC, it should be set up first.
Detecting the availability of MSX-MUSIC an identification string should be found. Internal MSX-MUSIC have the string "APRLOPLL" from $4018. External MSX-MUSIC may have different identification strings. However, from $401C the string "OPLL" is required for correct detection. As external MSX-MUSIC may require setting up first (like FM-PAC) a detection method is required.
To successfully detect and set up MSX-MUSIC, parse through all available slots: first check for the "APRLOPLL" string. If this is found, MSX-MUSIC is available and nothing special is required and exit the detection system. Then check for the "OPLL" string. If this is found, set bit 0 of address $7FF6 of the detected slot and exit the detection system.
Emulated MSX-MUSIC
Something that may become more and more of an issue, is MSX-MUSIC emulated by MSX-AUDIO expansions using recent ROM updates. There are 3 identification strings, all from $4018: "AUD1OPLL" for MSX-AUDIO implementation, "AUD3OPLL" for OPL3 cartridge implementation (Brazilian prototype) and "AUD4OPLL" for MoonSound implementation.
These implementations require the FM-BIOS calls to be used to have the sound played through them, which additionally requires knowledge of that system and unnecessary overhead due to interslot calling. If you only want to have real MSX-MUSIC play (simply by using the MSX-MUSIC I/O ports) you'll need to do specific tests for those identification strings. If you don't add them, MSX-MUSIC will be falsely detected and data will be sent to the MSX-MUSIC I/O ports regardless of the chip itself is actually available to produce the sound.
MoonSound
MoonSound is built around the YMF278B chip. It's an OPL4 chip. It's 100% compatible with OPL1, OPL2 and OPL3. It's designed by Henrik Gilvad and released under this name by Stichting Sunrise.
On MSX the YMF278B can be accessed through port range $C4-$C7. On MoonSound v2 it's also possible to have it emulating MSX-AUDIO without the ADPCM, by adjusting JP1 on the MoonSound PCB.
Detecting the availability of MoonSound, read I/O port $C4. If it returns $00 it's MoonSound, regardless the state of JP1.
Final words
Of course it's highly advisable to set a bit or byte for each of the detected sound chips so the program can determine which chip to use. This way it's possible to have a preferred order of use for the program.