Mega PCM 2 is a DAC sound driver for Sega Mega-Drive / Genesis. It offers the highest quality playback possible on the hardware, high sample rate (up to 32 kHz), pitch/volume effects and supports several sample formats (WAVE, raw PCM, DPCM-HQ and DPCM).
Unlike the majority of DAC drivers on the Mega-Drive with the infamous "scratchy" playback many games are known for, Mega PCM 2 outputs cleanest sounding samples on the hardware thanks to its buffering / DMA protection system.
You may also see this demo of crystal-clear PCM playback @ 32 kHz recorded on real hardware.
-
High quality crystal-clear playback:
- Battle-tested on real hardware and emulators alike;
- DMA protection / buffering system allows for ideal non-interrupted playback;
- Games usually DMA 6-8 Kb of data at most; Mega PCM 2 can survive up to 24 Kb (!) of DMA transfers;
-
Supports several compressed and uncompressed formats:
- .WAV files in 8-bit unsigned PCM format;
- Raw PCM - 8-bit unsigned PCM format (headless);
- DPCM-HQ (compressed) - new Mega PCM exclusive format, higher quality version of DPCM;
- DPCM (compressed) - classic 4-bit DPCM format (headless) found in some Sega titles.
-
High playback rates:
- WAVE/PCM: up to 25.1 kHz (supporting effects) or 32 kHz (turbo mode);
- DPCM-HQ/DPCM: up to 20.5 kHz (supporting effects) or 25.8 kHz (turbo mode);
-
Support for volume and pitch effects:
- 16 volume levels;
- 256 pitch levels;
-
Playback control, priority levels and SFX support:
- Pause, Stop and Loop supported for all sample types;
- Differentiates between "normal" (usually BGM drums) and SFX samples;
- 8 total priority levels: 4 for "normal" and 4 for SFX samples (latter always have higher priority);
- Separate volume and panning settings for "normal" and SFX samples;
-
Complex inside, user-friendly outside:
- Zero-config DMA protection (no extra flags to set and unset, simply don't stop Z80 on DMA's);
- Native .WAV file support, native PCM format (no custom converters required!);
- Auto-detects issues with sample formats or configuration on startup;
-
Battle-tested to the extremes:
- Z80 portion of Mega PCM is unique in that it's extensively auto-tested in a virtual machine;
- A special Z80 emulator was created to emulate Mega PCM and carefully test its core and various functions;
- Tests also verify that all Mega PCM playback loops and branches are cycle-accurate;
Note
Mega PCM is a DAC-only sound driver! It runs primarily on Z80 CPU and was designed to work alongside the "main" M68K sound driver to drive the remaining FM and PSG channels.
Generally speaking, Mega PCM can be integrated with any M68K sound driver. Currently, only SMPS 68K integration is officially provided.
- Converting samples for Mega PCM 2
- Migrating from MegaPCM 1.x
- How to play SFX samples
- How to play DAC BGM
- Small Demo ROMs - Demonstrates Mega PCM API in a simple manner
- DMA Survival Test - Advanced tests for surviving large DMA transfers
- Sonic 1 SMPS Integration - Reference integration with Sonic 1's SMPS driver
- Sonic 1 Github AS disassembly with Mega PCM 2 pre-installed: https://github.com/vladikcomper/s1disasm-megapcm2
- Unofficial Sonic 2 Clone Driver v2 with Mega PCM 2 integrations by TheBlad768:
- Sonic Clean Engine (S.C.E.): https://github.com/TheBlad768/Sonic-Clean-Engine-S.C.E.-
- Sonic 3 & Knuckles, Sonic & Knuckles, Sonic 3: https://github.com/TheBlad768/skdisasm-clone-driver
- Sonic 2: https://github.com/TheBlad768/s2disasm-clone-driver
- Sonic 1: https://github.com/TheBlad768/s1disasm-clone-driver
You need to have Wine, Python 3, GCC/Clang and Make installed on your system. Here's how to install these under Ubuntu/Debian:
sudo apt update && sudo apt upgrade
sudo apt install gcc make python3 wineThe following commands build the bare minimum toolset:
make # builds Mega PCM bundles
make dpcm-hq-conv # builds `dpcm-hq-conv` tool
make examples # builds demo ROMs using all Mega PCM bundles (AS, ASM68K, ASM68K-linkable)Or run make all to build everything, including development artifacts (e.g. Mega PCM Viz tool, which requires SDL3).
Please install WSL2 with Ubuntu (see How to install Linux on Windows with WSL), then follow Linux instructions.
Warning
Make sure to install Mega PCM 2 repository on Linux-side file system, otherwise a lot of executables may not run!
Almost the same as Linux, however you need to make sure to use GNU version of Make. Install GNU Make and always use gmake command instead of make.
Mega PCM 2's main source code and its dependencies (src/ and lib-68k/ directories) are fully free and open source and are provided under MIT license. See LICENSE file.
DPCM HQ Converter for Mega PCM 2 (tools/dpcm-hq-conv) is provided under MIT license.
Source code for Mega PCM 2 implementation examples (examples/ directory) is also MIT-licensed, however, some included assets and disassembled "SMPS" sound driver may be proprietary and provided for educational purposes only.
Also included in this repo, but not distributed with Mega PCM 2 releases:
-
Mega PCM 2 Vizualizer tool (
tools/megapacm-vizdirectory) - MIT-licensed; -
Mega PCM 2's testing suite (
test/directory) - MIT-licensed; -
Mega PCM Emu Library (
lib/megapcm-emu) - MIT-licensed; -
Z80VM Library (
lib/z80vm) - based on extended and modified z80emu v.1.3.0 (c) by Lin Ke-Fong; comes with permissive free license. -
For developer's convenience this repo also includes a few binary tools (see
toolchain/directory):-
The AS Macro Assembler is available under GPL-2.0 license with link to the source code;
-
asm68kandpsylinkare (c) by S.N. Systems Software Limited and come with proprietary license, but are considered abandonware; -
sjasmplusis a free and open source Z80 assembler available under BSD-3-Clause license; -
convsym,cbundleand others are written by me and are available under permissive MIT License.
-