• Stars
    star
    297
  • Rank 140,075 (Top 3 %)
  • Language
    C
  • Created almost 2 years ago
  • Updated 9 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A Galaga, Pac-Man and Donkey Kong arcade emulator for the ESP32

Galagino - ESP32 Arcade Emulator

Play Galaga, Pac-Man and Donkey Kong on the ESP32

Cabinet

Pac-Man screenshot Galaga screencast Donkey Kong screenshot

Pac-Man, Galaga and Donkey Kong are three of the most iconic arcade machines of all times and are listed on places #1 to #3 on the Killer List of Video Games.

Especially Pac-Man and Galaga have been remade and emulated many times. So far the cheapest and smallest system able to do a faithful emulation of the original arcade machines was the raspberry pi. But even the much cheaper ESP32 should be able to easily emulate a machine from the early โ€™80s, shouldn't it?

Well, things are not that easy. The Galaga arcade was driven by three Z80 CPUs, each running at 3Mhz. Additionally the arcade machine included two more CPUs, one for button and coin handling and one for audio support. And finally the hardware itself had dedicated support for simple wavetable audio, tilemap graphics and up to 64 sprites. The video resultion was 224 by 288 pixels.

The ESP32 on the other hand comes with two cores running at 240MHz. But it lacks dedicated video hardware. Emulating the various CPUs as well as the handling of audio and graphics turned out to be challenging for the ESP32.

Cheap TFT screens with a resolution of 320 by 240 pixels are avaialable in various sizes from 2.0 inch to 3.2 inch allowing for a very small and cheap galagino setup.

These small displays usually allow for SPI clock rates of up to 40MHz allowing for a max screen refresh rate of ~30Hz. This is exactly half the refresh rate of the original arcade machine. 30Hz is sufficient for a very fluid gameplay. However, with displays coping with 80MHz SPI clock, Galagino will run at full 60Hz refresh.

Youtube videos

Hardware

The hardware is built around one of those cheap ESP32 development boards like the ESP32 Devkit V4 depicted in the images below. The components needed for the breadboard setup are listed below. If you plan to build the cabinet instead you might want to make sure you order the exact parts that aren't only electrically compatible but also mechanically.

  • ESP32 development board (e.g. Devkit V4)
  • A 320x240 SPI TFT screen (no touch needed)
    • Either a ILI9341 based screen as depicted, or
    • a ST7789 based screen with 320x240 pixels
  • An audio amplifier and speaker
  • five push buttons, or
  • one push button and a five way joystick breakout (for Pac-Man and Donkey Kong)
  • breadboard and wires

The entire setup should be connected as depiced below. The Devkit is too wide for the breadboard leaving no space above it to connect wires. Thus the wires going to the top pin row of the Devkit are placed underneath the DevKit with the connections done as shown in the image below. See galagino/config.h for the button mappings.

Breadboard scheme

PDF

Breadboard photo

This setup with five buttons works fine for Galaga since there is no vertical movement in the game that requires a joystick. A joystick is needed for Pac-Man and Donkey Kong. The joystick based setup would then be wired in the following way:

Breadboard scheme with 5 way joystick

PDF

Software

The software consists of three parts:

Galagino uses code that is not freely available and thus not included in this repository. Preparing the firmware thus consists of a few additional steps:

  • The ROM files have to be placed in the roms directory, together with the ZIP file containing the Z80 emulator.
  • A set of python scripts is then being used to convert and patch the ROM data and emulator code and to include the resulting code into the galagino sketch directory.
  • The same scripts are afterwards being used to convert audio sample files into the desired format.

The ROM conversion as well as the audio sample conversion create a whole bunch of additional files in the galagino directory. Please check the README's in the romconv and samples directories for further instructions.

With all these files in place, the galagino.ino sketch can be loaded into the Arduino IDE. The Arduino IDE must have the ESP32 board support installed and the appropriate board like e.g. the ESP32 Dev Module should be selected. Finally the default core used by Arduino should be 1 (this is the default) as Galagino will use core 0 for audio and video emulation. Furthermore the FastLED library should be installed to support the LEDs in the cabinets marquee. LED support can be disabled in the configuration if no LEDs are going to be installed.

Configuration

The Galagino code can be configured through the galagino/config.h file. This is also the place where it's possible to choose between the ILI9341 controller (default) and the ST7789.

Also the pin assignment can be adjusted as well as the TFT SPI clock or the use of LEDs for the marquee.

More Repositories

1

I2C-Tiny-USB

Cheap and simple IยฒC to USB interface
C
361
star
2

LCD2USB

Cheap and simple USB to HD44780 text LCD interface
C
132
star
3

MiSTeryNano

Atari STE MiSTery core for the Tang Nano 20k FPGA
SystemVerilog
84
star
4

NanoVM

A really tiny Java Virtual Machine
C
75
star
5

palmos

Source code for my 25 year old palmos projects
C
48
star
6

TouchUI

Touchscreen UI written in PyQt
Python
31
star
7

ftduino

fischertechnik compatible arduino
C++
30
star
8

GLCD2USB

USB interface for ks0108 based displays
Stata
29
star
9

Pacman-TangNano9k

A Pac-Man Arcade implementation for the TangNano9K using HDMI
VHDL
22
star
10

upide

uPIDE is a simple IDE for Micropython
Python
20
star
11

LittleBlockly

LVGL + Micropython + Blockly
Python
13
star
12

cfw-apps

Some small apps i wrote for the fischertechnik TXT
JavaScript
11
star
13

ftDuino-controller

Firmware for the ftDuino controller
JavaScript
11
star
14

RPI-BLE-toy-control

Control lego and fischertechnik controllers with the R-Pi via bluetooth LE
Python
9
star
15

make-block-reloaded

Code for https://shop.heise.de/katalog/make-block-reloaded
C++
5
star
16

kvv

Epaper time table for KVV, Karlsruhe, Germany
C
5
star
17

WebBTSmart

Using the chrome web API to access the fischertechnik BT Smart Controller
HTML
4
star
18

DIY_Stereo_Projector

Stereoscopic image viewer and movie player using two Aiptek T20 USB projectors.
C
3
star
19

ftDuinoBlue

Source code for the Android app and the arduino sketches of ftDuinoBlue
Java
2
star
20

brickly-plugins

Plugins for brickly
2
star
21

ftduino32

ESP32 based variant of the ftDuino
HTML
2
star
22

CacheMe

QT based geocaching application for Linux, Meego, Maemo, Windows and Symbian
C++
1
star
23

dotlite

DOTTI compatible DIY 8x8 bluetooth LE led matrix
C++
1
star
24

xfig-gcode

xfig with CNC GCode export
C
1
star
25

maerklin

C++
1
star
26

X3dToSvg

Attempt to convert X3D files into scalable 2D SVG files
Python
1
star
27

SofTXT

Pure python implementation of a fischertechnik TXT-4.0 controller to be used with Blockly based Robo Pro Coding.
Python
1
star
28

fischertechnik-joystick

A simple USB controller for building joystick like devices with fischertechnik
Eagle
1
star