"ABOUT GAPCM"

About GAPCM

Some information about this project.

GAPCM is a collection of programs that transcode (convert) PCM files found in the original releases of Lunar: Eternal Blue by [GAME ARTS] and [Working Designs]. Those files were designed for the Ricoh RF5C164 in the Mega-CD, and thus are not conventionally usable outside the game. While there are existing solutions, ours is standalone with openly accessible source code, and has no GUI constraints.

The project consists of three applications and one library. Binaries for Debian and Windows are provided, but the source code should compile in any modern POSIX-compliant environment with [GNU Make].

Specifications

Prose description of the file format in question.

A game PCM file is divided into 2048-byte sectors.

The first sector is the header. 2 bytes for format, 4 bytes for loop start position (mark), 4 bytes for length, 11 bytes for echo parameters, one byte for pregap, and the rest should be zeroes. Following the m68k, multibyte integers are stored in big-endian order.

The remaining sectors make up the PCM stream. Each 8-bit sample is preceded by eight zero-padding bits, totaling to 1024 samples per sector. For stereo streams, an even-numbered[1] sector has samples for the left, then the next one for the right. Therefore, two sectors are required to reconstruct 1024 stereo samples.

Each sample is a sign-magnitude representation of the range [−128, 127]. [0x00, 0x7f] maps to [−1, −128], and [0x80, 0xff] maps to [0, 127], in which 0xff or 127 is used as the loop stop control. They are played back at 16276 Hz or one-768th of ~12.5 MHz--at least on original hardware. Emulators and alike running at 60 Hz framerate play them at 16297 Hz.[2]

More details can be found in [this VGM Preservation Foundation wiki], though we must correct that the length header field measures in frames, not samples.

  1. Counting from and including the header.
  2. 16276 × (60 / (53693175 / (3420 × 262))), following Genesis-Plus-GX/core/system.c:

    The original console would run exactly 53693175 M-cycles per sec (53203424 for PAL) 3420 M-cycles per line and 262 (313 for PAL) lines per frame.