Play Kid

A DMG Game Boy emulator written in Rust

3 minute read

Play Kid is yet another Game Boy emulator, written in Rust. But hey, it is MY Game Boy emulator, and I’m proud of it. I wrote some words about its development here.

Play Kid running different games with different color palettes.

Here are the main features of Play Kid:

  • All CPU instructions implemented.
  • Full memory map implemented.
  • Modes: ROM, MBC1, MBC2, MBC3.
  • Audio is implemented, with 4 channels, envelopes, sweep, and stereo.
  • Supports game controllers via SDL.
  • Multiple color palettes.
  • Save screenshot of current frame buffer.
  • Respects 160:144 aspect ratio by letter-boxing.
  • Debug mode:
    • Step instruction.
    • Step scanline.
    • Pause/continue current execution.
    • FPS counter.
    • Displays internal state.
    • Breakpoints.
    • Uses own minimal UI library with horizontal/vertical layouts, labels, buttons, and text fields.
  • Save RAM to .sav files to emulate the battery-backed SRAM.
  • Automatically adapts to multi-DPI setups by scaling the UI.
  • Tested and working games/roms:
    • Passes dmg-acid2
    • Tetris
    • Pokémon Red
    • Super Mario Land
    • Super Mario Land 2: 6 Golden Coins
    • Super Mario Land 3: Wario Land
    • Wario Land II
    • Bugs Bunny Crazy Castle
    • The Amazing Spider-Man
    • Kirby’s Dream Land
    • Dr. Mario
    • Probably many more
  • For Linux, macOS, and Windows.

Run

The usual Rust stuff. Check out the repository and run with cargo.

git clone https://codeberg.org/langurmonkey/rts-engine.git
cargo run -- [ROM_FILE]

Make the binary with:

cargo build --release

Operation

Here are the keyboard mappings:

  • enter - Start button
  • space - Select button
  • a - A button
  • b - B button

You can also use any game controller. The SDL2 usual mappings apply.

Additionally, there are some more actions available:

  • p - change the palette colors
  • w - trigger the SRAM save operation to .sav file.
  • f - toggle FPS monitor
  • s - save a screenshot, with name screenshot_[time].jpg
  • d - enter debug mode
  • Esc - exit the emulator

Debug mode

You can enter the debug mode any time by pressing d, or activate it at launch with the -d/--debug flag.

The debug mode.

You can use the provided UI controls to work with debug mode. You can also use the keyboard. These are the key bindings:

  • F6 - step a single instruction
  • F7 - step a scanline
  • F9 - continue execution until breakpoint (if paused), or pause execution (if running)
  • r - reset the CPU
  • d - exit debug mode and go back to normal full-speed emulation
  • Esc - exit the emulator

You can also use breakpoints. A list with the current breakpoint addresses is provided in yellow. To create a breakpoint, enter the desired address (in $abcd format) into the text field and click Add BR. Remove a breakpoint with Remove BR. Clear all current breakpoints with Clear all.

CLI args

There are some CLI arguments that you can use:

Play Kid 0.1.0

Minimalist Game Boy emulator for the cool kids.

Usage: playkid [OPTIONS] <INPUT>

Arguments:
  <INPUT>  Path to the input ROM file to load

Options:
  -s, --scale <SCALE>  Initial window scale. It can also be resized manually [default: 4]
  -d, --debug          Activate debug mode. Use `d` to stop program at any point
  -f, --fps            Show FPS counter. Use `f` to toggle on and off
      --skipcheck      Skip global checksum, header checksum, and logo sequence check
  -h, --help           Print help
  -V, --version        Print version

Useful links

Website design by myself. See the privacy policy.
Content licensed under CC-BY-NC-SA 4.0 .