The 90s were the golden age of personal computer music… and if you owned a PC compatible computer, the Sound Blaster card was a must as it was capable of producing both FM synthesis and digital music.
The YM3812 (also known as the “OPL2”) chip was responsible for the FM synthesis music in the Sound Blaster... let’s recreate a YM3812/OPL2 in an FPGA.
You will need
We are going to program the FPGA with a RS232 receiver, an OPL2 core named JTOPL and a PWM generator.
Here we use a Pluto-IIx XC3S200A board but most FPGA boards should work.
How does this work? VGM files contain the exact list of commands to send to a sound chip to play a specific tune.
Let's look at a YM3812 VGM file with an HEX editor.
Starting at address 0x60, we can see all the YM3812 write commands.0x5A means "write to YM3812" and is followed by the YM3812 address and data bytes... so here we have "write 0x20 to the YM3812 address 0x01", then "write 0x00 at address 0x08", etc... lots of writes. The VGM2COM player reads all the YM3812 address and data bytes from a VGM file and sends them over the RS232 port. There are also delay commands, so VGM2COM simply stalls for whatever delay is specified by the delay command before resuming sending data.
You can find a lot of VGM files on the OPL archive site. The music files are playable right on the site and are also available for download. You might get a VGZ file but it is simply a compressed VGM: open the VGZ file in WinRar (or your favorite compression software) to un-compress it to a VGM.
Note that not all the files on OPL archive are targeted for the YM3812... but about half of the files are (they are marked "OPL2"). Another site with a lot of VGM files is VGMRIPS and if you want only the files targeting the YM3812, go here.