|
|||
1. Introduction | |||
2. What is MML? | |||
3. Neo-Geo sound hardware | |||
4. ADK's MML format | |||
Alpha Denshi (ADK) NEO-GEO MML Music Driver
|
a. general commands | ||
b. note length commands | |||
c. FM-specific commands | |||
d. ADPCM & SSG commands | |||
5. Conversion tools & downloads | |||
6. Example videos | |||
Among the earliest Neo-Geo releases, the most graphically- and musically-impressive ones to me were by Alpha Denshi Corporation (ADK). ADK games often had large, rainbow-hued, lushly-shaded graphics (some were, yes, a bit too garish), while SNK-developed ones were still at a smaller scale, and had at times comedic art styles and forgettable music. True, 'Nam-1975 (by SNK) had an excellent musical score, but SNK's other first efforts on the Neo-Geo showed they had yet to come to grips with the hardware. Meanwhile, ADK's first effort on the system, Magician Lord, was so impressive that one wondered what SNK had been smoking; and, um, what ADK's guys had been smoking instead.
Well, the truth is that the Neo-Geo hardware was largely ADK's baby, developed within ADK and manufactured by SNK, similar to the Hudson-NEC arrangement for the PC-Engine. While much of the early Neo-Geo library has music and sound that is oh-so-'90s (like Fatal Fury or Super Spy), ADK's music -- with some exceptions -- can't really date itself, each production bettering the one previous. Magician Lord has synthy fantasy themes; Blue's Journey, steel-drum calypso themes; Crossed Swords, swords-and-sorcery orchestral hits paired with tribal drums; and Thrash Rally, some decent imitations of SEGA racing rock tunes.
The above-mentioned games have some of my favourite music on the entire system, so I wasn't all that surprised to see that the best ADK compositions tended to have a person named Yuka (or "Yuuka") Watanabe as sole (or co-) composer. Hideki Yamamoto, Hiroaki Shimizu are two other names featured in "lesser" ADK productions, save for the fabulous Thrash Rally. (Ninja Combat's music is rather shitty, so you can see what I mean about the latter two guys.)
ANYHOW. One day, I was looking around the games' sound ROMs in a hex editor when I was intrigued to discover that ADK's games had mostly unencoded MML data for music.
Well, it's rather unknown in the West, but MML is a musical notation language for home computers that was pretty well-supported by Japanese companies in the '80s. It was also a major method of musical composition in the Japanese videogame world, kind of how .MODs / trackers were huge in the PC/Amiga music world.
So, finding MML notation in a Z80 ROM is almost like finding BASIC statements in a game ROM: you can read it rather easily and understand it with a bit of effort. So that's what I did: I disassembled the Z80 music ROM to Magician Lord and tried to figure out how the special MML statements used by the ADK interpreter mapped to "modern" MML (though MML seems to be lacking in standardization and clear explanation these days as well...)
Here's some meta-data about ADK's early music driver for the Neo-Geo:
Name | Driver Ver. | Driver Date | Note Data Add. | New Commands | Composer | etc. |
Magician Lord | 1.2 | 02/18/1990 | $0200 | Yuka Watanabe, Hideki Yamamoto, Hiroaki Shimizu | ||
Sun Shine | ?? | |||||
Ninja Combat | 2.2 | 06/18/1990 | $0200 | g, o, q, t, u | Hideki Yamamoto, Hiroaki Shimizu | "Special Thanks" Y.Watanabe |
Blue's Journey | 3.5 | 11/01/1990 | $0200 | Yuka Watanabe | ||
Crossed Swords | 6.1 | 03/14/1991 | $2C00 | Yuka Watanabe | ||
Thrash Rally | 6.5 | 07/05/1991 | $2C00 | Hideki Yamamoto, Hiroaki Shimizu | ||
Ninja Commando | 7.3 | 12/03/1991 | $2E00 | Yuka Watanabe | final boss tune is an EL&P ripoff... |
As you can see, the ADK MML driver has gone through several revisions, though when I compared version 1.2 with 7.3, it didn't seem drastically different or have that much more code. Perhaps someone else can pitch in and clear up what has changed through all these driver versions.
ADK developed their sound driver beyond those listed above: World Heroes and later had 128K of data with more bankswitching, but I may deal with those games some other day. It's also interesting to note that many of Alpha's pre-Neo-Geo games also have similarly unencoded MML data just sitting in the Z80 ROMs, waiting to be extracted and interpreted. I wouldn't be at all surprised if many other videogames, either for home consoles or in the arcade, had MML interpreters running the sound driver-- probably the note data would be uncompressed but encoded into gibberish somehow. Anyhow, it's an interesting avenue for someone to research.
A quick description of the Neo-Geo's sound hardware |
The Neo-Geo uses a YM2610 FM/ADPCM/SSG audio chip to produce all of its sound effects and music. This chip has 15 sound channels, separated into 4 FM, 3 PSG, 1 noise, 6 ADPCM-A, and 1 ADPCM-B channel. Each type of ADPCM sampling uses its own bus on the YM2610. The ADPCM-A sample channels produce a fixed 18.5 Khz sample rate at 12 bits from 4-bit data, and the ADPCM-B channel can produce a wide range of sample rates with 16-bit output and with sample looping.
The Neo-Geo can thus produce, with effort, sounds ranging from the simplest PSG beeps of Sega Master System-style square waves, all the way up to streamed minutes-long sampled soundtracks. Obviously, due to the cost of mask ROMs in the early 1990s, most games stuck to FM music tracks, with samples used for percussion, some instruments, voices, and sound effects. Starting in the mid-late-1990s, many Neo-Geo game soundtracks became simply long monophonic samples -- kinda losing the distinct character of the YM2610 hardware.
A Z80 CPU inside the Neo-Geo handles all of the YM2610 management, port writing, and music driver software. Although all 15 channels can be used simultaneously, the SSG (3 PSG, 1 noise) portion of the YM chip was mostly neglected & used sparingly in SNK's own driver. The ADK sound driver perhaps cannot even use SSG voices as part of the main music data (though as sound effects overlaid on top of the music, it is possible). And since Westerners tend to run away screaming from FM sound generation in general, homebrew Neo-Geo drivers gloss over the subject of FM, sticking to PSG and PCM for everything. So perhaps this page will help put the FM channels back into future music & homebrew creations on Neo-Geo hardware.
ADK's MML Format |
Since this music driver has to deal with various sound hardware channels (FM, PCM, SSG) and allow the composer to alter their parameters, instruments, and effects, the commands in ADK's MML driver are expanded compared to modern MML. The ADK driver basically contains 4 separate MML interpreters/engines each processing one of the FM, ADPCM-A, ADPCM-B, and SSG sound units. In the main chunk of note data, the interpreter works its way through 4 tracks of FM, 6 tracks of ADPCM, and then the final ADPCM-B track. It looks like the SSG tracks are handled separately by the sound effect portion of the Z80 code.
Some ADK MML commands have nothing to compare to in the modern version. While modern MML may be case-insensitive for notes and other commands, ADK's driver is very much CASE-SENSITIVE. Many extra commands use up the range of available lowercase and uppercase letters. Watch out!
In cases where MML commands take an extra parameter "n", the ADK MML version is always a HEX byte, whereas the modern MML parameter is written in decimal in ASCII.
I want to note that this information is INCOMPLETE, so if anyone else with technical knowledge wants to figure it out in more detail, please do!!!
General MML commands | |||
HEX | syntax | modern MML equivalent | meaning |
43-47,41,42 | C D E F G A B | c d e f g a b | plays the specified note |
52 | R | r | rest |
54 | Tn | tn | set tempo |
4F | On | on+1 | set octave number * |
3C | < | < ( or > ) | octave UP* |
3E | > | > ( or < ) | octave DOWN* |
51 | Qn | qn | quantize (quick/long keyoff) |
56 | Vn | vn | volume (can be 00-$7F for FM) |
2E | . | . | extend note |
23 | # | + | (after note) sharp |
62 | b | - | " " flat |
2B | + | " quarter(?)-tone up | |
2D | - | " quarter(?)-tone down | |
6F | o | " eighth(?)-tone up | |
71 | q | " eighth(?)-tone down | |
74 | t | " 3/8 (?)-tone up | |
75 | u | " 3/8 (?)-tone down | |
5F | _n | ^n (??) | no change for duration ("NOP") |
Looping Commands | |||
5B | [n | [n | outer loop start + counter |
5D | ] | ] | outer loop end |
7B | {n | [n | inner / single note loop start + counter |
7D | } | ] | inner / single note loop end |
28 | ( | looping track start | |
29 | ) | looping track end | |
24 | $ | $ (??) | sequence loop start |
25 | % | ; (??) | sequence loop end |
2F | / | restart track | |
7C | |n | (??) | another loop start/break? pitch bend? non-functional? |
2A | *n | (??) | yet another? |
FF | ; | track end |
Setting Note Lengths |
The ADK MML player seems to ignore local note lengths (eg "A16"), thus lengths are set (globally) prior to the note.
Note Length Commands | |||
HEX | modern MML equivalent | HEX | modern MML equivalent |
01 | l1 | 03 | l3 |
02 | l2 | 06 | l6 |
04 | l4 | 0C | l12 |
08 | l8 | 18 | l24 |
10 | l16 | 30 | l48 |
20 | l32 | 60 | l96 |
40 | l64 | C0 | l192 |
HEX | syntax | modern MML equivalent | meaning |
57 | Wn | change / reset timers? | |
70 | pn | tpn (??) | pitch bend / envelope |
64 | dhl | bypass "notes" and write 16-bit frequency value | |
65 | enn | change note length or timers? | |
3F | ?n | FM Instrument no. (resets settings such as panning & volume) | |
66 | fn | LFO frequency | |
76 | vn | Vibrato ("PM Sense") | |
61 | an | Tremolo ("AM Sense") | |
5A | Zn | FM Release Rate (RR) | |
53 | Sn | PM sense (PMS) direct write | |
67 | gn | ?? Writes some YM reg.setting. | |
6C | l | left channel only | |
73 | s | centre channel | |
72 | r | right channel only | |
3D | =n | Z80 music engine command # |
ADPCM(A) TRACK COMMANDS | |||
HEX | syntax | modern MML equivalent | meaning |
3F | ?n | ADPCM Instrument / Sample no. | |
55 | Un | vn | ADPCM master volume (can be $00-$3F) |
56 | Vn | vn | sample volume (can be 00-$1F) |
58 | X | cdefgab | start sample playing |
e,l,s,r,R,Q, {}()[]/|*$%, etc. seem the same as for FM channels. | |||
ADPCM(B) TRACK COMMANDS | |||
4B | Kn | ?? Turns on/off some YM reg.setting. | |
56 | Vn | vn | sample volume (can be 00-$FF) |
SSG PSG special commands | |||
6E | nn | set SSG Noise frequency | |
4E | N | stop SSG Noise??? | |
6D | mn (?) | set SSG (noise?) note | |
4D | M | stop SSG Note??? | |
50 | Pn | set PSG note | |
Tool Downloads & Links |
ADK <-> MML Converters & Z80 Project Example | <- The Useful Stuff is Here! <- A couple conversion tools with (poor) C source, and a Z80 project file for WLA DX that injects MML-converted music back into Magician Lord's Z80 ROM (sold separately). You can test your own composition in M1 ((or in MAME) if you can edit CRC32/SHA expectations) as the 1st stage music. |
Disassembly of Magician Lord sound driver | I try to figure out what the Z80 code is even doing. Hopefully this will get you started on your own disassembly or reverse-engineering effort. |
link: Visual MML Player | Something that will help you quickly get MML note data playing. Somewhat idiosyncratic, but is there anything better out there? |
link: YM2610 Reference Page | This is quite a good page with descriptions of most/all the YM registers and ports, etc. |
Example Videos |
All FM instruments | I play all the instrument numbers in Magician Lord's music driver in 3 notes each: C4,G3,C3. A text file with my vague naming of these instruments is HERE. | |
All ADPCM-A samples | I play all the samples in Magician Lord's ADPCM-A format. ADPCM-A samples are 12-bit but have a fixed pitch / sampling rate. | |
All ADPCM-B samples | I play all the samples in Magician Lord's ADPCM-B format. ADPCM-B samples are 16-bit and can be played at a variable pitch, so again it's the 3 notes of C4,G3,C3. | |
Example of extracted MML note data | Once you use ADKtoMML on a Neo-Geo sound ROM, it'll create dozens of MML text files. You can then copy & paste the notes in these files into any MML editor. For ease of use, I use the online Visual MML Player. This player generates only square waves, but it does the job of previewing the songs. Anyway, here are some example recordings from the VMML player. | |
Example of an original(..?) song in MML running on the ADK driver | Playing around with the original soundtracks from ADK games is fine, but the ultimate goal is probably putting your own compositions into a Neo-Geo sound driver! So, here's an example of an arrangement that I made. I took a friend's PC-Engine arrangement of Big Blue from F-Zero, and converted it to run in Magician Lord's sound driver -- trying to preserve the same early 1990 feeling of the instruments in Magician Lord. |