GYM File Format

From vgmrips

GYM is a sound format for the Sega Mega Drive/Genesis. It is the YM2612's precursor to VGM, which included YM2612 support in version 1.10.

The name stands for Genesis YM2612 because the file contains the data stream sent to the console's Yamaha YM2612 sound chip. The data is logged to a file through the use of emulators running a ROM image.

Logging to the GYM format first appeared in the emulator Genecyst and was originally a simple raw YM2612 data log. The last update to the format before its obsolescence included a file header detailing simple information like game name, song title, what region the game in question was found (NTSC or PAL), and eventually where the file would loop (if at all) and how large the loop data was. Given that raw YM2612 was logged, large GYM files were often expected if a song contained many writes to the YM2612's DAC register.

GYM was eventually made obsolete when VGM added support for YM2612 events and eventually optimized storage of data intended to be sent to the DAC register.

Specification

Header

The most popular GYM player, the YMAMP plugin for WinAMP, allowed addition of a header to a GYM file. If this header was present, subsequent playbacks of the file would attempt to respect the data in the header.

A GYM header, if it exists, is 428 bytes, arranged as follows:

GYMX 428 byte header
Data Size Usage
tag char[4] A four-byte ID denoting the string GYMX. If this is present, GYM loaders should consider the next 424 bytes of the file as the remainder of the header.
song char[32] The title of the song
game char[32] The name of the game that features this song
publisher char[32] Publisher of the game/song
emulator char[32] The emulator that was used to dump this file
dumper char[32] The name of the person who dumped this file
comment char[256] Any comments the dumper would like to add about this file
loop_start uint32 A 32-bit unsigned integer in little-endian format denoting how many frames into the song the beginning of the loop takes place, with the loop ending at the file's end; if the song does not loop this value is 0.
packed_size uint32 A 32-bit unsigned integer in little-endian format denoting how large the remainder of the data is if it's zlib compressed; if the non-header GYM data is uncompressed this value is 0.

Data

The GYM file format contains only four different instructions, each represented by one byte with 0 to 2 bytes of arguments:

0x00
Do nothing for one frame (1/60th of a second if NTSC, 1/50th of a second if PAL)
0x01 rr vv
Write data vv to register rr on YM port 0
0x02 rr vv
Write data vv to register rr on YM port 1
0x03 vv
Write data vv to the PSG port

See also