back to lofibucket.com

A while ago I had an urgent need to write a song with the Mario Paint music composer, namely for the Battle of the Bits Summer Chip II competition. The “official” way to make such songs would be the original Mario Paint SNES cartridge, and nowadays that usually means running a dumped ROM in an emulator. But there was a giant flaw with this approach: it requires you to use your mouse. There are also some weird simulators available, but as far as I know these don’t respect the original limitations of the format.

A semi-official way to redistribute Mario Paint songs is the SHO format. It’s used by the infamous ShroomTool, which converts ZSNES V143 savestates (from Mario Paint, obviously) to it’s own adorable format that happens to have its dedicated player! And you can inject the SHO song back to the savestate to play it with the original ROM. Just perfect. So I went ahead and poked around the ShroomTool source code, and deduced that the SHO specs go like this:

Offset  Length (bytes)  Description
0       4               File format identifier, should be the string 'shro'
4       1               Format version, should be 2
5       1               Compression flag, should be 0
6       32              The song name, a null terminated string in ASCII
38      32              Author name, a null terminated string in ASCII
70      32              The filename of preferred SHI instrument file 
                        (ShroomPlay supports custom sample packs),
                        also a null terminated string in ASCII

102     576             Raw song data dumped straight from the ZSNES savestate
678     1               Song tempo

There are few things to note here:

If you don’t have a life, and happen to be interested in inventing a better format for Mario Paint songs, you might find these fascinating facts about the savestate (as of ZSNES V143 and V151) useful:

Song data format

What is this mysterious song data blob then? Well you could probably figure it out with a hex editor in a reasonable time frame, but let me help you out. The song consists of 96 rows, and each row is made of three notes. Each note is two bytes long:

Offset  Length (bytes)  Description
0       1               Pitch, valid values are from B3 (0x01) to B4 (0x0D)
1       1               Instrument, valid values lie between 0x02 and 0x0E

An empty note has a pitch of 0xFF and instrument 0xDF. It’s also worth noting that instrument 13 (0x0C) has two different samples: from 0x02 to 0x07 it’s conga and from 0x07 to 0x0E it’s an open hihat. Talk about compression man!

So to get back to the point, let me introduce you to modshroom, a mod to sho converter! Yes that’s right, you can now write your Mario Paint songs with any of your favourite Amiga or MS-DOS tracker. I chose the Protracker module as the source format mainly because of its lack of any compression, so it was easy parse. And also because I just love endianess issues and silly nibble shifting. See the Protracker 2.3A module format description if you just became interested (I pity you).

The converter takes in a specially formatted Protracker module, and spits out a legit SHO file. To help with the process I prepared a special template.mod file with authentic samples (thanks Dennis!) and correct channel layout on which to base your future masterpieces on.

If you want to give it a whirl, go ahead: modshroom.zip, 566KB

The source code is available at GitHub. It’s not for the faint of heart though :)

After all this work one might ask, how did the competition go then? Well, I almost won: the song placed 100th of 108 entrants. Those unthankful rascals!


For feedback email to pekka.vaananen@iki.fi