Skip to content
 
 

Latest commit

 

History

31 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

BlastEm Hardware Audio Bridge

This is a modified version of BlastEm that streams real-time audio register writes to Genesis Engine hardware for authentic audio playback through real YM2612 and SN76489 chips.

How It Works

BlastEm emulates the Genesis/Mega Drive with cycle-accurate timing. When the emulated CPU writes to the YM2612 (FM synthesizer) or SN76489 (PSG), we intercept those writes and stream them over serial using VGM-style timing commands to a microcontroller connected to real audio chips.

BlastEm (emulation)          Serial (1Mbaud)          Genesis Engine Board
┌─────────────────┐                                  ┌──────────────────┐
│   YM2612 write  │ ──── [wait] 0x52 reg val ───────>│ Real YM2612 chip │
│   PSG write     │ ──── [wait] 0x50 val ───────────>│ Real SN76489 PSG │
└─────────────────┘                                  └──────────────────┘
         │
         └── VGM-style wait commands encode timing at 44.1kHz sample resolution

Building

Prerequisites

  • GCC or compatible C compiler
  • SDL2 development libraries
  • GLEW development libraries (unless building with NO_GL=1)

Windows (MSYS2/MinGW)

pacman -S mingw-w64-x86_64-gcc mingw-w64-x86_64-SDL2 mingw-w64-x86_64-glew

Linux (Debian/Ubuntu)

sudo apt install build-essential libsdl2-dev libglew-dev

macOS (Homebrew)

brew install sdl2 glew

Build Commands

cd blastem

# Standard build
make

# Windows cross-compile (from Linux)
make OS=Windows

# Without OpenGL (simpler build)
make NO_GL=1

Running Pre-built Binaries

Pre-built binaries are available from the Releases page.

Windows

All required DLLs (SDL2.dll, glew32.dll) are included. Just extract and run.

Linux

Install runtime libraries:

sudo apt install libsdl2-2.0-0 libglew2.2

macOS

Install runtime libraries:

brew install sdl2 glew

Hardware Setup

  1. Upload the EmulatorBridge sketch to your Genesis Engine board:

    • Located at: GenesisEngine/examples/EmulatorBridge/EmulatorBridge.ino
    • Requires the GenesisBoard library
  2. Connect the board via USB

Usage

Hardware audio is automatically detected on startup:

  1. Connect your Genesis Engine board via USB
  2. Start BlastEm: ./blastem game.bin
  3. If detected, you'll see: "Genesis Engine audio board found, using hardware audio"
  4. If not detected: "Genesis Engine audio board not found. Check connection and restart BlastEm"

When hardware audio is connected, software audio is automatically disabled - all audio comes from the real chips.

Protocol

The bridge uses VGM-compatible command bytes with timing:

Audio Commands

Command Format Description
0x50 0x50 <value> Write to PSG
0x52 0x52 <reg> <value> Write to YM2612 Port 0
0x53 0x53 <reg> <value> Write to YM2612 Port 1

Timing Commands

Command Format Description
0x61 0x61 <lo> <hi> Wait N samples (16-bit little-endian, 44.1kHz)
0x62 0x62 Wait 735 samples (1/60 sec)
0x63 0x63 Wait 882 samples (1/50 sec)
0x70-0x7F single byte Wait 1-16 samples (0x70=1, 0x7F=16)

Control Commands

Command Format Description
0xAA 0xAA PING (connection test)
0x66 0x66 End stream / reset hardware

The board responds to PING with: 0x0F <board_type> 0x06 (ACK + type + READY)

Files Modified

From the original BlastEm source:

  • serial_bridge.c / serial_bridge.h - NEW: Serial communication and VGM-style timing
  • ym2612.c - Added serial_bridge_ym2612_write() calls
  • psg.c - Added serial_bridge_psg_write() call
  • genesis.c - Added cycle adjustment sync, silence on pause/menu
  • blastem.c - Added auto-connect on startup
  • render_sdl.c - Added disconnect on application close
  • render_audio.c - Mute software audio when hardware connected
  • Makefile - Added serial_bridge.o to AUDIOOBJS

Troubleshooting

No connection / "No Genesis Engine board found"

  • Check USB cable and board power
  • Verify the EmulatorBridge sketch is uploaded
  • On Linux, add user to dialout group: sudo usermod -a -G dialout $USER
  • Check available ports: ls /dev/ttyUSB* /dev/ttyACM* (Linux) or Device Manager (Windows)

Audio glitches

  • Ensure BlastEm is running at normal speed (not turbo/fast-forward)
  • Try a different USB port (avoid USB hubs)
  • Check for other programs using the serial port

Hanging notes when pausing

  • Notes are automatically silenced when entering menus or pausing
  • Closing the application sends a reset command to silence hardware

License

BlastEm is licensed under the GNU GPL v3. This modification is provided under the same license.

Credits

  • BlastEm by Mike Pavone
  • Genesis Engine hardware and library by the FM-90s project

About

BlastEm with hardware audio output to Genesis Engine board

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages