Thursday, November 28, 2019

OutRun's Music Macro Language & Tooling

My recent post, which covered Sega's audio creation process in the 1980s, inspired fellow coder cmonkey to create a nifty tool to facilitate composing new music for OutRun.

The music in OutRun is, at the most basic level, a simple stream of MIDI note values and durations. The tunes were originally transcribed from sheet music into MML (Macro Music Language). Presumably, after transcription, Sega had tooling to compile the MML data into the format used by the game's audio engine. Cmonkey's tool, SiMMpLified, essentially recreates this tooling.

The format used by OutRun is compact and efficient. Tunes are comprised of up-to 8 FM tracks, played by the Yamaha YM2151 sound chip and up-to 5 PCM tracks, played by the custom Sega 315-5218 PCM sample playback chip. Technically, it's possible to have a tune that's purely 16 channels of PCM samples, but practically sample space is limited. In addition, some PCM channels are reserved for the game's sound effects including engine revs, tire screeches and voice samples. In some respects, the format can be considered a more advanced version of the MOD format, popularised by the Amiga home computers.

The power of Sega's MML format is a result of a relatively advanced looping and nested sub-routine structure. This enables the data for a tune like Passing Breeze to be squeezed into under 5K of EPROM space, excluding the percussion samples! If you're interested in the technical structure and command format of MML, it's worth reading the SiMMpLified documentation.

The SiMMpLified tooling inspired me to consider what could be achieved with OutRun's audio in the forthcoming Enhanced Edition, currently slated for release in 2020. Ideally, I'd love to include additional music, as per AfterBurner: Enhanced Edition. There are already candidates for the tracks. M2's 3DS version of OutRun introduced two new tunes, Camino and Crusing Line. The later Switch version introduced Step on Beat, which first premiered on the Megadrive and Hiro's Radiation. The rest of the music in the Switch version is streamed audio and doesn't use MML format.


However, whilst extracting the new music reveals it to be in the correct format, it's bulky in terms of file-size. Each new song is as large as all four of the original OutRun compositions combined! There was an impressive project to get the music running on original hardware, but it required a custom manufactured PCB. This allowed the Z80 audio processor to access the additional address space.


I'd like to achieve this without the need for custom hardware. The existing OutRun audio EPROM is 32K. The maximum size supported by the PCB is 64K, with a jumper swap. However, part of the 64K memory map is mapped to RAM. Therefore, there's only 60K of accessible EPROM space. Any new music would need to fit into ~28K of free space.

At this point I realised the new music would require analysis and optimization. Reversing the music by hand would be error-prone and time consuming. Instead, I coded a tool that would read a binary and output an MML file, compatible with the SiMMpLified tooling. The end result is that we can instantly produce a formatted MML file containing the notes and commands for any OutRun tune. This file can be recompiled with a Z80 assembler and inserted back into the audio EPROM.

For the sake of completeness, you can think of the flow through these tools as follows, although clearly this example is an extremity:

OutRun Z80 EPROM -> MML Reassembler -> ASM file + siMMpLified Libs -> Z80 Assembler -> MML Injector -> OutRun Z80 EPROM

The MML Reassembler suggests that the original music is hand-crafted, whereas the new tracks appear to have been produced using some kind of tooling developed by M2. M2 did not need to be concerned about file size, and as such the output is bulky and contains repeated data.

I started work hand-optimizing Camino last night and shaved 2.5K off the filesize within a few hours (or closer to 9K if you take into account the unused data which my MML Reassembler automatically strips out). I don't know whether this project will be possible, but it's certainly worth a serious attempt!

Why not write a tool to optimize the tracks automatically? At this stage, I don't think it would achieve the results of a manual analysis where every single byte counts. Why not ZLIB compress the tunes in EPROM? The Z80 only has access to 2K of Work RAM, much of which is already in use by the program code.

Bear in mind that this is a work in process, and I'm unsure whether this will be of use to anyone right now. Nevertheless, the tooling can be found here.

Tuesday, October 01, 2019

Raiding Hiro's Sega Audio Archives

In recent years, Sega consolidated its scattered Tokyo offices to a centralised building in Ousaki. One office that closed at the start of 2019 was the Otorii office. This office had been the key development hub since September 1985, shortly after Hang-On development concluded. As such, intriguing development materials were unearthed in the process.

Sega Otorii Office Building

Hiro posted a vast collection of audio planning documents and media from 1985 through to the early 1990s. When Hiro joined Sega in 1984, music was composed on hand-written sheets.


Space Harrier Sheet Music. Note that game was called 'Heli' at this stage, as the fantasy theme had not yet been adopted.

Synthesizers used to compose the melodies included the Yamaha DX-7 for Space Harrier and the Yamaha PSR-70 for AfterBurner. The sheet music was manually transcribed into Macro Music Language for the audio engine to process. This took the format of the note, followed by its length (e.g. C-4, L4, A#4, L8). Once assembled, the actual audio could be tested on hardware. Needless to say this would have been a time consuming process.

Hiro's ROM cartridges for the Yamaha DX-7 Synthesizer

For the arcade games of this era, sound comprised lo-fi 8-bit samples used for voices, drums and sound effects. The samples were paired with a YM sound source (typically a Yamaha YM2203 or YM2151 chip), mostly used for melodies. YM sounds could be created and edited with an audio editor, which ensured each game had its own style, despite sharing audio hardware. For example, AfterBurner's 'Final Take Off' uses the YM to drive the melodies, but the overlaid guitars are in fact samples.

Data was saved to 8 inch floppy disks.

The following labels read 'OutRun 2' in reference to the revision of the music, as opposed to being anything to do with OutRun's sequel. I wonder if the earlier revisions of the OutRun music still exist?



OutRun's 'Passing Breeze' was initially named 'Passing Wind', until someone pointed out the flatulence reference. So the disk below must date from the end of the development process!


AfterBurner was aptly referred to as 'Top Gun' during development, and the final audio program code appears to have been named TG.HEX. Some of the disks are dated 9th September 1987. 





It appears that data was transferred over the years between 8 inch floppy, through to 5.25 and 3.5 inch floppy for preservation. 




Here we can see the list of commands Power Drift's main 68k program code needed to send to the Z80 Sub program in order to trigger the relevant sound. 





The final Power Drift master. Later on Digital Audio Tapes (DAT) replaced reel-to-reel recordings. 




Friday, July 12, 2019

AfterBurner City Cabinet

This popped up on Yahoo auctions and I thought it was worth preserving here. In Japan, Sega appear to have released an official conversion kit to turn a generic Sega City cabinet into AfterBurner.

City cabinets are relatively small (580 x 715 x 1000 mm) and at only 60kg, less than half the weight of a normal upright AfterBurner.








Here is a low-resolution promotional image of this cabinet, including the header, from Yu Suzuki GameWorks Vol. 1.


Sunday, February 10, 2019

Sega Game Cards

Western arcade gamers were accustomed to overflowing pockets of loose change, but Japanese arcade centres had a more elegant solution: Game Cards. These were magnetic cards, similar to Japanese phonecards of the era, pre-loaded with credits and read by a card reader attached to the arcade cabinet. As the card was used, the reader punched holes to denote the number of credits used.


The system was introduced in October 1986 at Hi-Tech Land, Kanada. Two types of card were common: 500 cards provided 12 credits and 1000 cards 24 credits. Most games were set to 2 credits per play, although this was variable. For ¥500 you therefore gained credits and a collectible card to keep.

Game Card Creation & Vending System

Cards were branded by game, but could be used with any compatible machine. It was common for game centres to add their personal branding to the cards and many variants exist. The system was reportedly not successful in the long-term (source: Sega Arcade History).

Card vender & cabinets with card readers

Trade Show Image: Everything you need to manufacture your own game cards!

The Sega cards were numbered as follows. I'll complete missing entries as I find out more information.

1 SPACE HARRIER (Number not shown on card)
2 FANTASY ZONE (Number not shown on card)
3 OUTRUN
4 ALEX KIDD
5 SUPER HANG-ON (1000 version)
6 DUNK SHOT
SUPER HANG-ON (500 version)
8 AFTERBURNER
9 SUPER LEAGUE
10 HEAVYWEIGHT CHAMP
11 THUNDER BLADE
12 HOT ROD
13 GALAXY FORCE II
14 POWER DRIFT
15 UNKNOWN

16 UNKNOWN

17 TURBO OUTRUN

18 SUPER MONACO GP

19 G-LOC (1000 Version)

20 G-LOC (500 Version)

21 R-360

Cards were also available exclusively at the AM and AOU trade shows from Sega booths. Some example follow.

24th AM SHOW (OUTRUN & HOTROD)


25TH AM SHOW (HEAVYWEIGHT CHAMP & THUNDER BLADE)

87 AOU SHOW (SUPER HANG-ON, then HANG-ON II)

88 HAPPY NEW HARRIER
SEGA ATTRACTIONS

OTHER GAMES



Special thanks to Sean Tagg for helping me with images and information for this post. Don't let this man spend any more money on game cards. Or at least donate him some for free!

Game Machine Article - December 1986