Actions

SonMP3

From Sonic Retro

SonMP3

SonMP3 is an MDP plugin for Gens/GS created by Cinossu that serves to replace and exceed Sonic 2 MP3 Tool by allowing MP3 music to be played instead of the regular in-game music. Currently in early alpha, and only configured for a single ROM hack, Sonic the Hedgehog 1 @ SAGE 2010, future releases will include the configuration files for other Sonic games.

Features

  • Supports any ROM (provided a valid configuration file).
  • Supports looping and non-looping files, with loop positions editable in a future release.
  • Effects such as speed up, slow down, fading in and out, and more in future releases as requested.
  • Code replacement in configuration files so clean ROMs can be used.
  • More features in the future as requested or found to be useful/relevant.

Known Bugs/Problems

  • Does not get enabled/disabled by Gens/GS's internal sound enable/disable. Has to be disabled/enabled individually in from the Plugins menu. This is not solvable until the correct hooks are added to the MDP plugin system.
  • Crashes Gens/GS on section count failure. Needs to be fixed to just unload itself/report plugin error.
  • Game code replacements do not alter the in-game checksum, so in-game checksum checks will fail unless replaced in the same way.

Configuration Files

There are two types of configuration file for SonMP3, the SonMP3 Main Configuration File, and each individual Game Configuration File. Please make sure to add an extra new line to the end of all configuration files, or else they may not load correctly into SonMP3.

SonMP3 Main Configuration File

The main configuration file (filename _sonmp3.cfg) consists of a Main section and a section for each individual game.

The Main section has two variables:

Enabled - Used by Gens/GS to turn the plugin's support on and off.

Total - The total number of games SonMP3 is set up to support.

Each individual game has the section title GameXX, where XX is a two-character hexadecimal number starting from 00 up to the total number of games - 1, allowing up to 256 supported games. Please be sure to give at least as many individual game sections as there are specified in the Main section's Total, otherwise the plugin will currently crash Gens/GS. Each game section consists of three variables:

Game - The name of the game being supported.

Serial - The internal ROM serial number (at address 0x180 in ROM and used by SonMP3 to determine whether to enable support for the currently loaded ROM or not).

Config - The filename (minus extension) of the individual Game Configuration File.

Game Configuration Files

Each individual game's configuration files consist of two neccessary sections, Main and Audio, and several optional sections depending on what level of manipulation is needed to get SonMP3 to work with the game being supported.

The Main section has 4 neccessary variables and 5 optional variables, although for the alpha release all 9 are required to work correctly. They are as follows:

RAMAddress - Two bytes of free RAM in the game used by SonMP3.

PauseAddress - Address in RAM of the byte used to indicate when the game is Paused (to pause/resume music correctly).

MusicAddress - Address in RAM to watch for when music is played.

Replace - The amount of sections of code in-ROM required to be replaced/altered when SonMP3 is enabled (more on this later in this section).

Stop - Value reported to MusicAddress when music should be stopped.

Fade - Value reported to MusicAddress when music should be faded out.

SpeedFast - Value reported to MusicAddress when music should be sped up.

SpeedNormal - Value reported to MusicAddress when music should be returned to a normal speed.

ExtraLife - Specifically for Sonic games, value reported to MusicAddress for when an Extra Life is played. Used to add the additional previous music pause and fade back in once finished.

The Audio section contains the filenames to all the MP3s to be played by SonMP3. Please note, editing this file on the fly will not cause changes if a ROM is already loaded. You will have to reopen the ROM if you want to hear any changes.

Each music uses the variable name of the value reported for it to MusicAddress in the Main section, with the filename for the music file as its value. For example, if the value reported to MusicAddress is 81, and the MP3 we wish to play on this music is greenHillZone.mp3, then in the configuration file under the Audio section we would have the line 81=greenHillZone.mp3.

In addition to this, SonMP3 assumes all music is to be looped. To disable looping and have a track only play once, use the variable name of the value reported to MusicAddress from the Main section plus the word loop added to the end, with a value of 0 for the variable. For example, if the value reported to MusicAddress is 8A, the MP3 we wish to play on this music is titleScreen.mp3 and we only want this music to play once, then in the configuration file under the Audio section we would have the lines 8A=titleScreen.mp3 followed by 8Aloop=0.

In addition to these two neccessary sections, there is also support for replacing code directly in-ROM when SonMP3 is enabled, allowing support for clean ROMs without having to patch them externally. You can have up to 256 replacements in a ROM. Please note that this does not currently replace the loaded ROM's checksum accordingly, so any in-game checksum checks need to be replaced using this method as well. This will be fixed in a future release.

To use this, you need to set the Replace variable in the Main section to the amount of code replacements you wish to use. Each replacement has its own section in the configuration file, with the title ReplaceXX, where XX is a two-character hexadecimal number starting from 00 up to the total number of replacements - 1. Just as with games, in the SonMP3 Main Configuration File, please be sure to give at least as many individual replace sections as there are specified in the Main section's Replace, otherwise the plugin will crash Gens/GS.

In each replace section, there are five variables:

Comment - A comment about what the replacement is doing, for internal use and organisation.

Address - Starting address in-ROM of where the code replacement is going to be. Formatted as 0xHEXADDRESS.

CodeOn - The replacement code to be used at this address when SonMP3 is enabled. Formatted as hexadecimal bytes.

CodeOff - Code to be used at this address when SonMP3 is disabled. Used to give SonMP3-specific support in-ROM even when disabled to show support is there. Formatted as hexadecimal bytes.

Length - The length in bytes of the replacement of code. Please make sure CodeOn and CodeOff are the same length, or else the plugin may act in an unknown manner.

While this method of replacement can be long-winded, the use of RAMAddress in the Main section for ROM hacks can make support for SonMP3 a lot easier. It is best to keep replacements for clean ROMs or already-built ROM hacks only.

Folder Structure

Inside of your Gens/GS plugins folder, there should be a folder called sonmp3 containing the files bass.dll, bass_fx.dll, _sonmp3.cfg and any Game Configuration Files that you have. For each game configuration, there should be a folder named the same (minus the extension) containing the MP3 music to be used by the game configuration.

Future Plans

  • Full support for any and all Sonic games:
    • Sonic 1 - 90% complete.
    • Sonic 2 - 45% complete.
    • Sonic 3/Sonic & Knuckles - 0% complete.
    • Sonic 3D - 0% complete.
  • Support for multiple filetypes (WAV, OGG, M4A, etc).
  • Support for Sound Effects.
  • Custom effects on Music/SFX.

If you have any other ideas for future releases, please add them to the discussion on this article.

Further Links