Skip to content

LiarPrincess/Swift-plays-Pokemon

Repository files navigation

Swift plays Pokemon

Game Boy emulator written in Swift.

Features

  • Instruction accurate - while it is not per-cycle accurate, it will run most of the games without any problems.
  • Supports following cartridge types (MBC stands for memory bank controller):
    • no MBC - for example: Tetris
    • MBC1 - for example: Legend of Zelda - The Links Awakening and Kirby's Dream Land
    • MBC3 - for example: Pokemon Red
  • blargg tests:
    • ✅ cpu_instrs
    • ✅ instr_timing
  • Save/load emulator state to file
  • Safe from Meltdown and Spectre

Not supported:

  • Audio
  • stop instruction (0x10 from unprefixed instruction set) - not really used

Source map

  • Swift plays Pokemon.xcodeproj - XCode project file. Use this instead of Swift Package Manager (SPM does not support Metal shaders that we use inside GameBoyMac). Although, if your code depends only on GameBoyKit framework, then SPM is ok.

  • Sources

    • GameBoyMac - Mac app that runs the emulator. You can use --rom argument to specify ROM (or just give it as a last argument). It uses GameBoyKit framework.

    • GameBoyKit - Main implementation of GameBoy logic. It contains GameBoy class alongside many other useful things like: Cpu, Lcd and Debugger.

    • Code generation - Code generation executable, based on lmmendes/game-boy-opcodes.

  • Tests

  • ROMs - directory that holds games/test ROMs.

Screenshots

Tetris Pokemon Red Legend of Zelda - The Links Awakening Super Mario Land Bomberman Kirby's Dream Land

Keys

For the GameBoyMac target (emulator executable) following key map is used:

Action Key
DPAD-UP
DPAD-DOWN
DPAD-LEFT
DPAD-RIGHT
B S
A A
START Q
SELECT W
Save state R

Tests

Blargg's tests:

Test Result Note
cpu_instrs Essential
instr_timing Essential
cgb_sound Audio is not implemented
dmg_sound Audio is not implemented
interrupt_time ⚠️ Not tested
mem_timing ⚠️ Not tested
halt_bug No game requires it
oam_bug Game Boy bug that we do not implement, see The Ultimate Game Boy Talk - 46m 30s

Links

License

“Swift plays Pokemon” is licensed under the Mozilla Public License 2.0. See LICENSE file for more information.

About

Game Boy emulator written in Swift.

Topics

Resources

License

Stars

Watchers

Forks

Sponsor this project

Languages