In Sega Genesis emulation history, YM2612 sound chip has always been one of the hardest part to emulate and more over when you are going the accurate way, since no technical documentation really exists to describe how the FM synthesiser chip internally works.

During a long time, the only documentation we had was the official Sega Developers Sound Manual that describes the interface with the YM2612 OPN chip and his internal registers.

As a result, the number of available YM2612 core, written by emulator authors, is rather limited:

  • The “MAME” core, written by Tatsuyuki Satoh & Jarek Burczynski, courtesy of the M.A.M.E emulator. This is an open-source emulator with a rather high level of accuracy thanks to lot of low-level tests made on real Yamaha OPN chips from the same family.

  • The “GENS” core, written by Stéphane Dallongeville, author of the GENS emulator. This is also an open source emulator, inspirated by the MAME core regarding internal YM2612 constants. It has been several times updated to improve sound rendering in some Sega Genesis games. For example, Stef added an interpolation method to emulate the YM2612 at his original frequency (quite but not completely similar as the Kega SuperHQ option). He also made many (but probably only at high level) tests on a real Sega Megadrive to adjust emulation parameters. The result is that his core is sometime considered as being more accurate than the MAME core regarding to some specific games.

  • Kega’s core, written by Steve Snake, one of the Sega Genesis emulation’s pioneer (author of Kgen & Kega). Not much is known about this core since it is closed-source but it is considered as the “most accurate” YM2612 emulator and Steve Snake admitted he spent MANY hours testing all possible features of the real chip. This even includes undocumented & unofficial features (see below) used by some games. The result is that, effectively, the accuracy level is quite HIGH and Kega was considered as the only emulator being able to render the sound of some games quite exactly as on real hardware. Sadly, Steve Snake always remained very discrete about his findings and, for whatever reasons, never publically shared them.

As you can now guess, excepted Kega, quite all (open-source or not) Sega Genesis/Megadrive emulators use the M.A.M.E core as a reference and, logically, share the same emulation flaws, resulting in some sound emulation inaccuracy.

Hopefully, a new document was recently discovered & translated, that covers the YM2608 FM chip. This chip is part of the same Yamaha OPN chip family as the YM2612 and obviously share a lot common internal behaviour. This document covers pretty everything about the chip registers & internal tables and even fixes some mistakes from the original Sega YM2612 document. However, it appeared quickly that the M.A.M.E core was already emulating all described features correctly so this document, even if being a great resource for emulator authors, could not help in fixing undocumented behaviour on his own.

But Nemesis, who is writing his own Sega Genesis emulator (not yet released) took this opportunity to start intensive tests on a real YM2612 chip, trying to fully understand how it internally works and most important, documenting it & sharing his notes.

Among other things (you can read the full thread here), he made priceless discoveries about two undocumented features that caused some games to sound incorrect before (one of this “bug” being discussed in a previous entry of this blog by the way, affecting some of the games using GEMS sound driver)

And now ?

I implemented these findings in the M.A.M.E ym612 core that I’m using for Genesis Plus and also, implemented sample interpolation to emulate the chip as it original frequency, which is required by some games to sound more correctly (the best example is known to be Sonic the Hedgehog’s end of level sign spinning). Finally, I fixed some inaccuracies regarding the Envelope Generator and Phase updates in CH3 special mode.

The result is a pretty accurate sound emulation, way better than before, and probably close (if not better) to Kega level of accuracy.

The modified source code is freely available on the Genesis Plus SVN repository (fm.c) for anyone interested. It seems that the M.A.M.E team, through Richard Belmont, got their hand on this and updated the original core: good stuff happen when people are sharing code & informations !

Obviously, Genesis Plus for Gamecube/Wii has been updated to reflect current modification, the last version can as usual be found on his thread on Tehskeen.

Here is the full changelog:

[Genesis]
- adjusted (again) HINT timings: fix Double Dragon 2 (game freezed), hopefully does not break anything else
- fixed broken EEPROM support for Codemaster games
- modified input update timings: fix Dungeons & Dragons – Warriors of the Eternal Sun (thanks to Notaz)
- added support for “Ultimate Mortal Kombat Trilogy” hack (max. size supported is 10MBytes)
- added (VERY) preliminar support for PICO roms (credits to Notaz for his documentation)
- improved YM2612 emulation (credits to Nemesis for his tests on real hardware):
.implemented phase overflow emulation: improved fix for special music instrument used in Comix Zone, Flashback, Ariel, Shaq Fu…
.improved SSG-EG emulation in MAME core (also based on additional code from Alone Coder)
.improved Timers emulation accuracy
.improved Enveloppe Generator accuracy
.fixed Channel 3 CSM mode emulation
.implemented sample interpolation in MAME core to emulate the chip at original frequency (HQ YM2612 mode, from gens)

[NGC/Wii]
- added automatic alphabetical filesorting (Marty Disibio)
- added ROM History for faster ROM access (Marty Disibio)
- fixed a silly input bug in “ROM Infos” & “Game Genie” menus
- modified “Hard Reset” option
- improved display sharpness in original rendering mode (H40 cell mode only), filtering is now completely disabled
- enabled overscan emulation in “STRETCH” aspect mode also
- added support for horizontal wiimote handling in Menu (automatically used when the wiimote is not pointed towards the screen)
- improved Controller options
.prevented keys reconfiguration if device is not detected
.added support for up to 8 players (ISS Pro Deluxe, …)
.each player can be affected to a custom device (GAMECUBE Pad, WIIMOTE/NUNCHUK or CLASSIC)
.added the ability to use classic controller & wiimote pad from the same port separately
.modified “soft-reset” key on the Wiimote to avoid “accidental” resets (now press Buttons + & – simultaneously)
.added MODE button mapping: use “START+Z” on gamepad or “Button Minus” on wiimote/classic (not reconfigurable)
.added automatic configuration save for controller options

Side notes

I didn’t post before but since a few months, thanks to the hard work of para (author of the wiiuse library) & shagkur (libogc main developper), we now got easy-to-use & stable support for wiimote and expansion controllers in Wii homebrew. Obviously, Genesis Plus GX takes full benefit of this and now even support up to 8 players.

I also worked on Sms Plus GX to add accurate Sega LightPhaser emulation and to use the Wiimote IR pointing ability for a full nostalgic experience. Sega Menacer & Konami Justifier emulation should come along soon for Genesis Plus, more to come in a later post.

About these ads