Paper Boi

Paper Boi is a native PC and Android port of Paperboy for the Sega Genesis that includes widescreen, save states, rewind, and analog steering.

README

Paper Boi

A native PC and Android port of Paperboy for the Sega Genesis / Mega Drive (Tengen, 1991), built by statically recompiling the game's 68000 code into C.

Deliver the papers, dodge the traffic and break a few windows. It now runs as a native Windows program or Android app, with save states, rewind, widescreen, a CRT filter and analog steering. On Android, a game controller is recommended; touch controls are there too.

Gameplay

Important

This project does not include the game. You need your own copy of the Paperboy (USA, Europe) Sega Genesis ROM (CRC32 0A44819B). Nothing in this repository or its downloads is taken from the ROM. Paperboy is a trademark of its owners. This is an unofficial fan project, not affiliated with or endorsed by Atari, Tengen, Sega or any rights holder.


Features

Plays like the original

  • Every instruction of the game's 68000 code that can run (8,345 of them) is translated to C, and checked frame by frame against a reference 68000 emulator. The result is the same pictures and the same memory, every frame.
  • Full sound: FM music (YM2612 via ymfm), the PSG tone/noise chip, and the Z80 sound CPU that drives them.

Looks the way you want

  • Widescreen (16:9): the game draws more of the street at both sides instead of stretching. There's an optional soft-edged look too. Static screens such as the title and the report get black side bars.
  • Picture modes: 4:3 sharp (the shape a TV showed, with crisp edges), pixel perfect (whole-number scaling) or stretch.
  • CRT filter with scanlines.
  • Fullscreen or a window of any size.

Modern conveniences

  • Save states in numbered slots.
  • Rewind: hold a button to go back in time, then let go to play on from there.
  • Analog steering: the stick steers in proportion to how far you push it. Accelerate and brake are on the triggers, so you're not holding Up and Down.
  • Controls you can change for both keyboard and controller (F10).
  • Tap assist: the game only checks the controller every few frames on some screens, such as high-score entry. Tap assist holds quick taps until the game sees them, so none go missing.
  • On-screen help (F1) and short messages for every action.
  • Settings are remembered between sessions.

Android

  • Best with a game controller. Any Bluetooth or USB controller Android recognises works, with analog steering on the stick and accelerate and brake on the triggers. The touch controls hide while you use it and come back when you touch the screen.
  • Touch controls if you have no controller: a floating D-pad, A/B/C in the Genesis layout, START, a menu button and a hold-to-rewind button.
  • Touch menu for everything the PC's F-keys do: save and load, picture, CRT, widescreen, tap assist and more.
  • Choose your ROM on first launch with Android's file picker. A .zip is fine.
WidescreenCRT filter
WidescreenCRT filter
Android touch controlsHelp (F1)
Android touch controlsHelp panel

Getting started

Downloads are on the Releases page.

Windows
  1. Download PaperBoi-windows-x64.zip and unzip it anywhere.
  2. Put your Paperboy (USA, Europe) ROM in the same folder as paperboy.exe. Any file name works (.md, .bin, .gen or .smd), but it must be unzipped. Or drag the ROM file onto paperboy.exe.
  3. Run paperboy.exe. Press F1 for the controls.

Settings, save states and recordings are kept next to paperboy.exe.

Android (7.0 or later, 64-bit ARM)
  1. Download PaperBoi-android-arm64.apk on your phone and open it. Android will ask you to allow installs from the app you opened it with, such as your browser or Files.
  2. Open Paperboy (BYO ROM) and tap Choose ROM file. Pick your ROM, zipped or not. It's checked and copied into the app, and you're only asked once.
  3. Connect a game controller (recommended): pair it in Android's Bluetooth settings or plug it in, and just start pressing buttons. Without one, the touch controls work, but a real D-pad or stick is much easier for steering around traffic. Press Select (Back / View) on the controller to open the menu.

Controls

GenesisKeyboardControllerTouch
D-padArrow keysD-pad / left stick (analog steering)D-pad (left side)
Speed up / slow downLeft Shift / Left CtrlRight trigger / left triggerD-pad up / down
A / B / CZ / X / CA / B / XA / B / C
STARTEnterStartSTART
Rewind (hold)BackspaceLeft shoulder<<
MenuSelect (Back / View)MENU
KeyAction
F1Help
F2Tap assist on/off
F3CRT filter
F4Widescreen (off / on / soft edges)
F5 / F9Save / load state
F7 / F8Save slot down / up
F6Picture mode
F10Change controls
F11 or Alt+EnterFullscreen
F12Screenshot
EscQuit

The menu has the same options as the F-keys. Open it with Select on a controller, or on Android with MENU or the Back gesture. Move with the D-pad or stick (or the arrow keys), press A (or Enter) to choose, and B to go back to the game.


How it works

Paperboy is a 512 KB Genesis game written for the Motorola 68000. This project translates that machine code ahead of time into C, which a normal C compiler turns into a native program. This is called static recompilation; an emulator interprets the code while the game runs instead. Everything else a Genesis has around the CPU is recreated in the runtime.

ROM ──► tools/trace.py ──► every instruction proven to be code
                │
                ▼
        tools/recomp.py ──► generated/*.c  (one C function per block of 68000 code)
                │
                ▼
   runtime (C) ──► native program
     ├─ VDP: tiles, sprites, scrolling, palettes (own renderer)
     ├─ Z80 sound CPU (superzazu/z80), YM2612 FM (ymfm), PSG (own)
     ├─ controller, timing and interrupts
     └─ modern features: save states, rewind, widescreen, CRT, touch, settings
  • Finding the code. tools/trace.py follows every path from the 68000's start-up vectors, resolving jump tables and routine pointers. Anything it can't prove statically is filled in from logs of real play (tools/runlog.py).
  • Translating. tools/recomp.py writes C that works directly on the same CPU state as the Musashi 68000 emulator. That means the translated code and the emulator can take turns, and be checked against each other.
  • Checking. tools/lockstep.py replays recorded play sessions through both the translated code and the emulator, and compares the picture, sound and memory frame by frame. They are identical.
  • Widescreen. The extra width isn't stretched. A sandboxed second run of the game's own sprite routine, with its screen-edge limits widened, places the objects that would otherwise be cut off at the sides.
About the downloads

The translated C is derived from the game's code, so it is never included in this repository or its downloads. The downloadable builds contain the same runtime and features, but run the game's code on the built-in 68000 emulator, using the ROM you supply. That runs at full speed on anything from the last decade: on a Pixel 10 it uses about two-thirds of one CPU core. Its pictures and memory match the recompiled build frame for frame.

To get the fully recompiled build, build it yourself from your own ROM, as described below.


Building from source

Windows (fully recompiled build)

Requirements: CMake 3.20+, Ninja, a C/C++ compiler (developed with LLVM-MinGW) and Python 3.10+. SDL2, Musashi, the Z80 core and ymfm are downloaded by CMake at pinned versions.

# 1. put your ROM at rom/Paperboy (USA, Europe).md
# 2. find the code and translate it (writes generated/, which stays on your machine)
python -I tools/trace.py --quiet
python -I tools/recomp.py --strict
# 3. build
cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Release
cmake --build build
build/paperboy.exe

Without step 2, or with -DPB_NO_GAME_CODE=ON, you get the ROM-free build used for the downloads.

Android

Requirements: JDK 17, Android SDK platform 36, NDK r30, CMake 3.31 (from the SDK), Gradle 9.9. Build the Windows version first: the Android build reuses its downloaded libraries and Musashi's generated opcode tables.

cd android
gradle assembleByoromDebug    # ROM-free app, safe to share
gradle assembleNativeDebug    # with your generated/ code: for your own devices only

The APKs appear under android/app/build/outputs/apk/.

Command-line options

All options are listed at the top of runtime/src/main.c. They include --rom, --native off|on|shadow, --record/--replay for input recordings, --wav to record the sound, and --headless for testing.


Repository layout

PathWhat's there
tools/Python: 68000 decoder (m68k.py), code tracer, recompiler, lockstep checker, ROM and VDP inspection tools
runtime/src/C runtime: bus, VDP renderer, sound, Musashi glue, save states, rewind, widescreen, display, input, touch, settings
notes/Code addresses and names found while reverse-engineering (no ROM data)
android/Gradle project: SDL's activity plus a ROM picker
docs/screenshots/The pictures on this page

Credits and licences

The code in this repository is released under the MIT licence.

It builds on:

  • SDL2: window, sound and input (zlib licence)
  • Musashi by Karl Stenerud: the 68000 emulator (MIT)
  • superzazu/z80 by Nicolas Allemand: the Z80 (MIT)
  • ymfm by Aaron Giles: the YM2612 FM chip (BSD 3-Clause)

Full licence texts are in THIRD_PARTY_NOTICES.md.

Paperboy is a trademark of Atari Games. The Genesis version is © 1991 Tengen and was developed by Motivetime. This project contains none of their code, graphics or sound.