Forums

Sega Master System / Mark III / Game Gear
SG-1000 / SC-3000 / SF-7000 / OMV
Home - Forums - Games - Scans - Maps - Cheats - Credits
Music - Videos - Development - Hacks - Translations - Homebrew

View topic - Sega/BO/SMPS “SOUND-SORCE” music engine: documentation and tools

Reply to topic
Author Message
  • Site Admin
  • Joined: 19 Oct 1999
  • Posts: 14745
  • Location: London
Reply with quote
Sega/BO/SMPS “SOUND-SORCE” music engine: documentation and tools
Post Posted: Sat Oct 07, 2023 12:55 pm
It’s well known that many Sega games have almost identical music engines, with a characteristic RAM based trigger using values from $80 to start new songs. This engine seems to have a heritage dating back to the earliest Master System/Mark III games, as well as arcade games, but undoubtedly had some variations and evolution across time.

I think sometimes it has been referred to as “pre-SMPS”, where SMPS is as per https://segaretro.org/SMPS . Elsewhere I think I saw references to it being written by Tokuhiko Uwabo, at least at first. See https://hiddenpalace.org/News/Sega_of_Japan_Sound_Documents_and_Source_Code for example.

Recently I’ve been looking at the (dual-chip FM and PSG) version in Phantasy Star. I’ve also looked at the disassembly of the Snail Maze BIOS at https://github.com/maxim-zhao/smsbioses/blob/master/1.3/Bios13.asm which seems to be extremely similar, as is the (incomplete) description of SMPS linked above. I aim to write up some documentation on the wiki to cover what I find.

Are there existing projects covering this that I might make use of? It seems like it might be useful or even desirable for people to make use of the engine, but is there a way to make it easy to arrange music for it? Maybe the Mega Drive scene has done something already?

The engine seems to be common, but not always identical, and the data seems to be mixed into the code in a way that makes it hard to write a tool to extract song/SFX data from ROMs.
  View user's profile Send private message Visit poster's website
  • Joined: 16 May 2002
  • Posts: 1356
  • Location: italy
Reply with quote
Post Posted: Sat Oct 07, 2023 6:31 pm
A few people (including ValleyBell and myself) made converters which target the SMPS driver used in the 16-bit Sonic games, yes. My one converts from XM, his one from MIDI. Also, mine is a terrible piece of software by any standard, in retrospect I'm ashamed of how I coded it, I would completely overhaul it nowadays.

Aside from the converter, ValleyBell made extensive research and disassemblies of various SMPS drivers, though I'm not sure if this link is publicly viewable: https://forums.sonicretro.org/index.php?threads/valley-bells-smps-research.32473/

I might have been a precursor when it came to Sonic music hacking, but ValleyBell is definitely THE go-to person when it comes to SMPS, now and forever. He helped me in the blink of an eye when I asked him a second opinion about the music in Rainbow Islands, I wouldn't have succeeded without him.
  View user's profile Send private message Visit poster's website
  • Joined: 16 Dec 2008
  • Posts: 38
  • Location: UK
Reply with quote
Post Posted: Sun Oct 08, 2023 10:44 am
Not sure if this is of any use for your research - it might be going in the wrong direction, chronologically - but there's also the annotated disassembly of the SMPS driver from Sonic 2.
Plus the data structure & format notes page, which was also enhanced by ValleyBell: https://info.sonicretro.org/SCHG:Sonic_the_Hedgehog_2_(Master_System)/Music_Hack...
  View user's profile Send private message
  • Joined: 16 May 2002
  • Posts: 1356
  • Location: italy
Reply with quote
Post Posted: Sun Oct 08, 2023 11:20 am
Right, I didn't mention it, because I ignorantly assumed that ValleyBell superseded it in his gigantic pack, but I didn't mean to be disrespectful. I apologise if that was the case. My comment from back then still stands. Interestingly enough, it was October 8th even at that time, so happy anniversary, I guess 😁
  View user's profile Send private message Visit poster's website
  • Joined: 16 Dec 2008
  • Posts: 38
  • Location: UK
Reply with quote
Post Posted: Sun Oct 08, 2023 12:25 pm
Quote
I didn't mean to be disrespectful.

That thought didn't even enter my head. I didn't meant to imply anything and no offence was taken. I rememer most of ValleyBell's pack being MegaDrive stuff so I thought this might have been useful, for an additional SMS perspective.

Quote
it was October 8th even at that time,

Oh, wow. 14 years ago!? That's depressing :)
  View user's profile Send private message
  • Site Admin
  • Joined: 19 Oct 1999
  • Posts: 14745
  • Location: London
Reply with quote
Post Posted: Sun Oct 08, 2023 1:07 pm
Thanks, this is all super helpful. Valleybell’s pack seems to be Mega Drive oriented, but I suspect Phantasy Star will be somewhere between the BIOS engine (which is PSG only and relatively basic) and Sonic 2 (which is quite a few years later, but still PSG only). Doing a dual-chip engine might be fun and maybe a way to make some retconned FM soundtracks later?
  View user's profile Send private message Visit poster's website
  • Joined: 15 Sep 2009
  • Posts: 377
Reply with quote
Post Posted: Mon Oct 16, 2023 8:04 am
I disassembled and labelled a number of Master System SMPS drivers.
They are in SMPS_Research_Pack_v5_DriverDisasm.7z, in the folder Drivers/SMPS_Z80/SMS.

They include:

  • Snail-Maze SMS BIOS ("bios13fx")
  • JP Master System BIOS (MRP11124)
  • Alex Kidd in Miracle World
  • Dragon Crystal
  • Phantasy Star (J)
  • Sonic 2 Auto Demo Prototype
  • Sonic 2 v1.0
  • Sonic Triple Trouble


I didn't do a lot of research on the SMS variant, but there is limited support for the "later" sound driver variant used by e.g. by Sonic 2/Chaos/Triple Trouble that has a song header similar to MegaDrive SMPS.

SMPSPlay v2 can play such Master System SMPS songs - if you provide correct format specification files. (I have some for Sonic 2 and STT.)
SMPSExtract may be able to extract songs, but it currently assumes MegaDrive Z80 banking. (pointers in the range $8000 .. $FFFF)


I remember Phantasy Star's PSG/FM driver being interesting, because songs generally share the same note data for FM and PSG versions and just have different headers. The "set instrument" command has 2 parameters - one for a PSG instrument and another one for the FM instrument.


The main difference for "pre-SMPS" vs. (later) "SMPS" is the song header:

  • pre-SMPS song headers begin with a 1-byte track count.
    It is followed by N track headers that are copied 1:1 into the sound driver's work RAM and include flags, pointer and initial transposition/volume settings.
    preSMPS track headers are usually 9 bytes.
    The song tempo is stored in a separate byte array somewhere else.
  • SMPS song headers start with a 6-byte header that includes an instrument pointer (for MegaDrive FM instruments), FM/PSG track counts and tempo information.
    Track headers are 4 bytes (FM) / 6 bytes (PSG) and contain only "important" information. (pointer, transposition, volume)



btw: The origins of the sound driver can be traced back to Arcade games like Space Harrier and OutRun.
Those games use the same system for frequency and volume envelopes. I think looping worked similar as well?

The pre-SMPS driver used in the Snail Maze SMS BIOS driver resembles the Arcade drivers more closely than later variants, as it supports pitch slides between two specific notes (with frequency interpolation!). That feature was later cut. (It was CPU-heavy anyway.)

I think the sound driver made a transition this way:

  • starting in the Arcade
  • ported to Master System (Snail Maze, Alex Kidd in Miracle World)
  • modified and speed-optimized for better use with games (JP SMS BIOS, Phantasy Star) -> 8-bit pre-SMPS (supports FM/PSG)
  • ported to the MegaDrive (early MD titles like Space Harrier 2, Altered Beast) -> 16-bit pre-SMPS Z80
  • on the MegaDrive, develop format further (simplification of the song header, additional vibrato effects) -> 16-bit SMPS Z80
  • 16-bit SMPS Z80 ported back to the Master System (e.g. Sonic 2 and later) -> 8-bit SMPS (PSG only, kept 16-bit header format)


MegaDrive SMPS 68k is a different branch (originated from 16-bit pre-SMPS Z80) with its own story.
  View user's profile Send private message Visit poster's website
  • Site Admin
  • Joined: 19 Oct 1999
  • Posts: 14745
  • Location: London
Reply with quote
Post Posted: Mon Oct 16, 2023 5:00 pm
Well, maybe I wasted a few hours annotating the PS disassembly then :) indeed it does share channel data between PSG and FM, but sometimes has extra channels for FM or (more often) prepends an extra wait to make an “echo” channel to fill out the sound with pseudo reverb.

My reason for getting into it is to fix a bug in the original game. One of the “special effects” allows it to fade out one song, then start another (e.g. battle or shop music) on an alternate set of data structures. Then when that music ends (battles ends, leave the shop) the previous music fades back in without restarting. This can sometimes fail to fade back in and instead the game is left silent. So I’m understanding that secondary channel set and how it handles this sequence.

The music data itself is secondary - but it would be great to have a way to edit or compose data for a given engine, maybe a superset of the various features seen in games.
  View user's profile Send private message Visit poster's website
Reply to topic



Back to the top of this page

Back to SMS Power!