A gameboy emulator that only plays Pokemon Blue, in ~70 lines of c++.

pokegb

A gameboy emulator that only plays Pokemon Blue, in ~70 lines of c++.

See the technical write-up.

Features

Plays Pokemon Blue (and Red).

Building

Only builds on Linux and macOS AFAIK.

$ make

On macOS, you'll need to create a save file too (just the first time):

$ make rom.sav

Running

Put Pokemon Blue in rom.gb, then run:

$ ./pokegb

The save file is written to rom.sav.

Keys:

Action Key
DPAD-UP
DPAD-DOWN
DPAD-LEFT
DPAD-RIGHT
B Z
A X
START Enter
SELECT Tab

Updating keys

Look for line 30 the source. The following table shows which numbers map to which keyboard keys:

number default key gameboy button
27 X A Button
29 Z B Button
43 Tab Select Button
40 Return Start Button
79 Arrow Right DPAD Right
80 Arrow Left DPAD Left
81 Arrow Down DPAD Down
82 Arrow Up DPAD Up

Replace the numbers on this line with one from the SDL scancode list.

Owner
Ben Smith
Mostly webby: @WebAssembly @chromium @v8 @google. NaCl... Some games back in the day, but nothing you'd find on here.
Ben Smith
Comments
  • Build error

    Build error

    when building I get this error:

    /usr/bin/ld: /tmp/ccloiK2Y.o: in function `main':
    pokegb.cc:(.text.startup+0xe3): undefined reference to `SDL_Init'
    /usr/bin/ld: pokegb.cc:(.text.startup+0x104): undefined reference to `SDL_CreateWindow'
    /usr/bin/ld: pokegb.cc:(.text.startup+0x116): undefined reference to `SDL_CreateRenderer'
    /usr/bin/ld: pokegb.cc:(.text.startup+0x138): undefined reference to `SDL_CreateTexture'
    /usr/bin/ld: pokegb.cc:(.text.startup+0x144): undefined reference to `SDL_GetKeyboardState'
    /usr/bin/ld: pokegb.cc:(.text.startup+0x2a4): undefined reference to `SDL_LockTexture'
    /usr/bin/ld: pokegb.cc:(.text.startup+0x32c): undefined reference to `SDL_UnlockTexture'
    /usr/bin/ld: pokegb.cc:(.text.startup+0x340): undefined reference to `SDL_RenderCopy'
    /usr/bin/ld: pokegb.cc:(.text.startup+0x348): undefined reference to `SDL_RenderPresent'
    /usr/bin/ld: pokegb.cc:(.text.startup+0x362): undefined reference to `SDL_PollEvent'
    collect2: error: ld returned 1 exit status
    

    I have libsdl2-dev installed, I'm not sure why it's not working

  • Segmentation fault upon launch

    Segmentation fault upon launch

    System Information

    Operating System

    $ uname --all
    Linux foobar 4.19.0-16-amd64 #1 SMP Debian 4.19.181-1 (2021-03-19) x86_64 GNU/Linux
    

    Application

    9c03ea4

    Actual Behaviour

    After successful build, the program crashes with a segmentation fault after (very) briefly rendering a (blank) window:

    $ sudo apt-get install libsdl2-dev
    $ make
    cc -O2 -Wall -Wno-return-type -Wno-misleading-indentation -lSDL2 -o pokegb pokegb.cc
    $ ./pokegb
    Segmentation fault
    

    Expected Behaviour

    No segmentation fault.

  • crash on Arch

    crash on Arch

    What happen

    I try to run this on my lattop, clone and build is ok. When try to run, it just went wrong.

    How it happen

    [[email protected] c]$ git clone [email protected]:binji/pokegb.git
    正克隆到 'pokegb'...
    remote: Enumerating objects: 154, done.
    remote: Counting objects: 100% (154/154), done.
    remote: Compressing objects: 100% (84/84), done.
    remote: Total 154 (delta 81), reused 128 (delta 65), pack-reused 0
    接收对象中: 100% (154/154), 49.01 KiB | 44.00 KiB/s, 完成.
    处理 delta 中: 100% (81/81), 完成.
    [[email protected] c]$ cd pokegb/
    [[email protected] pokegb]$ make
    cc -O2 -Wall -Wno-return-type -Wno-misleading-indentation -Wno-parentheses -o pokegb pokegb.cc -lSDL2
    [[email protected] pokegb]$ ./pokegb 
    段错误 (核心已转储)
    
    [[email protected] pokegb]$ uname -a
    Linux arch 5.12.10-arch1-1 #1 SMP PREEMPT Thu, 10 Jun 2021 16:34:50 +0000 x86_64 GNU/Linux
    [[email protected] pokegb]$ ldd ./pokegb
            linux-vdso.so.1 (0x00007ffcd2fdc000)
            libSDL2-2.0.so.0 => /usr/lib/libSDL2-2.0.so.0 (0x00007f7f9ce12000)
            libc.so.6 => /usr/lib/libc.so.6 (0x00007f7f9cc46000)
            libm.so.6 => /usr/lib/libm.so.6 (0x00007f7f9cb02000)
            libdl.so.2 => /usr/lib/libdl.so.2 (0x00007f7f9cafb000)
            libpthread.so.0 => /usr/lib/libpthread.so.0 (0x00007f7f9cada000)
            /lib64/ld-linux-x86-64.so.2 => /usr/lib64/ld-linux-x86-64.so.2 (0x00007f7f9d005000)
    

    Did I forget something undone? Little confused aboout "Put Pokemon Blue in rom.gb"

  • Make configurable the A/B buttons

    Make configurable the A/B buttons

    Current Behaviour

    Currently, the buttons are set as "B Button"=Z, "A Button"=X. The problem is that for german keyboards (QWERTZ) the Z and the X are really far away. Instead, next to the X is the Y.

    Acceptance Criteria

    Make configurable the A/B buttons, so they can be chosen at compile time via an argument/option .

    Alternative easier/temporal solution: explain (in the docu) where to change it in the code.

  • Crash on macOS 11.4

    Crash on macOS 11.4

    pokegb_2021-06-05-175518_zhaoruideMac-mini.crash.zip

    Process: pokegb [22344] Path: /Users/USER/*/pokegb Identifier: pokegb Version: 0 Code Type: X86-64 (Native) Parent Process: zsh [21593] Responsible: Terminal [9659] User ID: 501

    Date/Time: 2021-06-05 17:55:18.291 +0800 OS Version: macOS 11.4 (20F71) Report Version: 12 Bridge OS Version: 5.4 (18P4663) Anonymous UUID: 496C124E-0C6B-6D7D-8520-206563EAFAC8

    Time Awake Since Boot: 690000 seconds

    System Integrity Protection: enabled

    Crashed Thread: 0 Dispatch queue: com.apple.main-thread

    Exception Type: EXC_BAD_ACCESS (SIGSEGV) Exception Codes: KERN_INVALID_ADDRESS at 0x00000000000000ff Exception Note: EXC_CORPSE_NOTIFY

    Termination Signal: Segmentation fault: 11 Termination Reason: Namespace SIGNAL, Code 0xb Terminating Process: exc handler [22344]

    VM Regions Near 0xff: --> __TEXT 10ccc0000-10ccc4000 [ 16K] r-x/r-x SM=COW /Users/*

    Thread 0 Crashed:: Dispatch queue: com.apple.main-thread 0 pokegb 0x000000010ccc1a03 me(unsigned short, unsigned char, int) + 163 1 pokegb 0x000000010ccc23e4 main + 1764 2 libdyld.dylib 0x00007fff204b2f5d start + 1

    Thread 1: 0 libsystem_pthread.dylib 0x00007fff20493420 start_wqthread + 0

    Thread 2: 0 libsystem_pthread.dylib 0x00007fff20493420 start_wqthread + 0

    Thread 0 crashed with X86 Thread State (64-bit): rax: 0xffffffffffffffff rbx: 0x0000000000000000 rcx: 0x0000000000000100 rdx: 0x0000000000000000 rdi: 0x0000000000000100 rsi: 0x0000000000000000 rbp: 0x00007ffee2f3f940 rsp: 0x00007ffee2f3f910 r8: 0x0000000000002859 r9: 0x0000000000000001 r10: 0x0000000000000001 r11: 0x000000010cd012b4 r12: 0x0000000000000000 r13: 0x0000000000000100 r14: 0x0000000000000000 r15: 0x0000000000000000 rip: 0x000000010ccc1a03 rfl: 0x0000000000010203 cr2: 0x00000000000000ff

    Logical CPU: 1 Error Code: 0x00000004 (no mapping for user data read) Trap Number: 14

    Thread 0 instruction stream: d2 74 1d 44 88 34 08 e9-6d 01 00 00 41 0f b7 c5 .t.D.4..m...A... 25 ff 1f 00 00 48 8d 0d-21 6a 00 00 85 d2 75 e3 %....H..!j....u. 44 8a 34 08 e9 50 01 00-00 85 d2 74 28 44 89 f0 D.4..P.....t(D.. 24 3f 45 84 f6 0f b6 c0-b9 01 00 00 00 0f 45 c8 $?E...........E. 0f b6 c1 48 c1 e0 0e 48-03 05 d7 67 00 00 48 89 ...H...H...g..H. 05 d8 67 00 00 48 8b 05-c9 67 00 00 41 0f b7 cd ..g..H...g..A... [44]8a 34 08 e9 10 01 00-00 41 80 fe 03 77 1a 85 D.4......A...w.. <== d2 74 16 41 0f b6 c6 48-c1 e0 0d 48 03 05 bb c9 .t.A...H...H.... 00 00 48 89 05 bc c9 00-00 48 8b 05 9d 67 00 00 ..H......H...g.. 41 81 e5 ff 3f 00 00 46-8a 34 28 e9 d9 00 00 00 A...?..F.4(..... 41 0f b7 c5 25 ff 1f 00-00 85 d2 0f 84 ba 00 00 A...%........... 00 48 8b 0d 8d c9 00 00-44 88 34 01 e9 ad 00 00 .H......D.4.....

    Thread 0 last branch register state not available.

A CTRPF plugin for the Nintendo 3DS Pokémon games in which, supports both the 6th and 7th generations.

Multi-Pokémon Framework Multi-Pokémon Framework is a Pokémon plugin developed by Jared0714 that is based off of Nanquitas' CTRPluginFramework. This pl

Jun 6, 2022
DMGPlus, upgraded internals for the original GameBoy

These are various files for the DMGPlus project. Note that I did this over the time span of about three years, so there's no plug-and-play recipe to b

Dec 19, 2021
Realtime strategy game for Gameboy Advance
Realtime strategy game for Gameboy Advance

Skyland Overview A Gameboy Advance game created, frantically, for a game jam, in about twenty days. A simple realtime strategy game where you build fl

May 20, 2022
GameBoy Advance dungeon crawling game

inheritors-of-the-oubliette GameBoy Advance dungeon crawling game Compilation instructions: have devkitpro installed with all the GBA dev stuff. Also

Jan 22, 2022
Gameboy Port of LazyDevs' Porklike

porklike.gb A port of the wonderful Porklike, created by Krystian Majewski, to the original Game Boy! Please see the original pico-8 game at https://k

Apr 5, 2022
A cycle-accurate Game Boy and Game Boy Color Emulator, with rewind feature.
A cycle-accurate Game Boy and Game Boy Color Emulator, with rewind feature.

Azayaka is a free and open-source Game Boy and Game Boy Color emulator written in C++. Features Cycle-Accurate emulation. Console based Debugg

Dec 16, 2021
MVS64 -- A NeoGeo emulator for Nintendo 64
 MVS64 -- A NeoGeo emulator for Nintendo 64

MVS64 -- A NeoGeo emulator for Nintendo 64 Status This emulator is in VERY EARLY STAGE. Only a handful of games boot or work. Performance on N64 is st

Mar 15, 2022
yuzu is an experimental open-source emulator for the Nintendo Switch from the creators of Citra.

yuzu (Nintendo Switch Emulator) yuzu is an experimental open-source emulator for the Nintendo Switch from the creators of Citra. It is written in C++

Jun 17, 2022
Experimental Nintendo 64 emulator in C11

shibumi | 渋味 "Shibui (adjective), shibumi (noun) or shibusa (noun) are Japanese words that refer to a particular aesthetic or beauty that is simple, s

Jun 14, 2022
Modification of Marat Fayzullin's Z80 emulator to run on the Arduino Mega

Z80 Core for Arduino Mega This library only functions with the Arduino Mega or Mega 2560 due to memory constraints! This is a free, open source projec

Jun 19, 2022
SameBoy DX is a Qt-based interface of SameBoy, a free, highly accurate Game Boy and Game Boy Color emulator.

SameBoy DX SameBoy DX is a Qt-based interface of SameBoy, a free, highly accurate Game Boy and Game Boy Color emulator. Build requirements: CMake Pyth

Jun 4, 2022
A Game Boy emulator with serial data transfer (link cable) support over tcp.

gbmulator A Game Boy emulator with serial data transfer (link cable) support over tcp. Key bindings Key bindings are not configurable yet. Key Action

Jun 2, 2022
bsnes is a Super Nintendo (SNES) emulator focused on performance, features, and ease of use.
bsnes is a Super Nintendo (SNES) emulator focused on performance, features, and ease of use.

bsnes is a Super Nintendo (SNES) emulator focused on performance, features, and ease of use.

Jun 15, 2022
Game Boy, Game Boy Color, and Game Boy Advanced Emulator
Game Boy, Game Boy Color, and Game Boy Advanced Emulator

SkyEmu SkyEmu is low level cycle accurate GameBoy, GameBoy Color and Game Boy Advance emulator that I have been developing in my spare time. Its prima

Jun 19, 2022
NeoGB Printer an SD card-based standalone Game Boy Printer emulator.
NeoGB Printer an SD card-based standalone Game Boy Printer emulator.

An open-source and standalone Gameboy Printer emulator 100% compatible with all officially released games (110 in total) that support the accessory. Just print and save the images as BMP

Jun 15, 2022
A Game Boy Printer emulator that supports the Phomemo T02 printer
A Game Boy Printer emulator that supports the Phomemo T02 printer

ESP32 + Phomemo T02 Game Boy Printer This project lets you print Game Boy Printer images via Bluetooth using a Phomemo T02 thermal printer and an ESP3

May 21, 2022
VE Font Cache is a single header-only GPU font rendering library designed for game engines.
VE Font Cache is a single header-only GPU font rendering library designed for game engines.

VE Font Cache is a single header-only GPU font rendering library designed for game engines. It aims to: Be fast and simple to integrate. Take advantag

May 3, 2022
Exploit allowing to load arbitrary code on the PSX using only a memory card (no game needed)

FreePSXBoot Exploit allowing to load arbitrary code on the PSX (i.e. PlayStation 1) using only a memory card (no game needed). In other words, it's a

Jun 15, 2022
sdl4cpp, header-only C++ wrapper around SDL2.

sdl4cpp sdl4cpp, header-only C++ wrapper around SDL2 (heavily work-in-progress) An example: #include "sdl4cpp/sdl4.hpp" #include "sdl4cpp/timer.hpp" #

Nov 28, 2021