MSX-MUSIC programming
This page was last modified 09:47, 17 August 2018 by Gdx. Based on work by Mars2000you.

MSX-MUSIC is YM2413 aka OPLL implementation standard for MSX. This implementation can be found inside most MSX2+ computers and all MSX tR computers. It is also very popular as external cartridge among MSX2 users. There exists only few software that supports MSX-MUSIC on MSX1.

You may also want to check out music replayer routines

Contents

Detecting

There is text "APRLOPLL" in the Rom an internal device at 4018h ~ 401Fh
There is text "PAC2OPLL" in the Rom an external device at 4018h ~ 401Fh

Direct usage for internal device

I/O Port R/W Usage Wait (in μsec) Wait (as clock cycles)
#7C W Register Index 3.36 12
#7D W Register data 23.52 84

Direct usage for external device

I/O Port Address* R/W Usage Wait (in μsec) Wait (as clock cycles)
#7C 7FF4H W Register Index 3.36 12
#7D 7FF5H W Register data 23.52 84

(*) Access by memory addressing should be on all external MSX-MUSIC but all clones do not have this feature.

Note: If you want to activate the I/O ports, you need to set bit 0 of address #7FF6 in FM-PAC slot else OPLL chip will be available for use only trough memory I/O. To prevent two devices on same I/O ports it is not recommended to activate FM-PAC when there is internal MSX-MUSIC present.

PLEASE NOTE: Do not set the bit0 of #7FF6 if there is no "PAC2OPLL" string. This will break compatibility with Panasonic MSX2+ computers! In Panasonic A1WX and A1WSX seting bit 0 in any address between #7FF0 and #7FFF will disable the MSX-MUSIC ROM completely.

If you use MSX-BASIC or FM-BIOS then no extra attention is needed because CALL MUSIC command and OPLINI routine will both automatically activate OPLL when needed. These routines will always search first for internal MSX-MUSIC (APRLOPLL) and then external (PAC2OPLL) and activate the external only if internal is not found.

YM2413 Application Manual

FM-BIOS

Address Name Meaning Usage
#4110 WRTOPL Write to OPLL registers IN: A=Register, E=Data
#4113 INIOPL Initialize OPLL IN: HL=Work area (needs to be even address)
#4116 MSTART Start music IN: A=Repeat count 0-254 (0=infinite repeat) HL=Music address
#4119 MSTOP Stop music
#411C RDDATA Read instrument data IN: A=Instrument number (0-63), HL=8 byte buffer to output.
#411F OPLDRV Handle music data. Put in H.TIMI hook
#4122 TESTBGM LD A,(Workarea + #3A) Output: A=Playing status 0=Not playing
#5000 Statement handler CALL-command handler
#5003 Interrupt handler
#5006 Stop background music
#5009 Enable & reset OPLL


For BIOS music format, please look MSX Datapack chapter 3.3.4