Game Boy Emulator made in C++.
MIT License
Game Boy Emulator developed in C++ using SDL2. You can compile the program using CMake. Games like Pokémon aren't working due to the lack of MBC3/MBC5 cartridges implementation.
SDL2 website: https://www.libsdl.org
Note C++ version 17 SDL2 version 2.0.14.
The Emulator features :
Tetris | Super Mario Land 2 |
---|---|
Kirby's Dream Land | The Legend of Zelda Link's Awakening |
---|---|
To use the emulator it depends on your system. Please follow the steps in section Windows
or Linux
.
All the releases can be found in the link below: Source code and releases
You can download the emulator by clicking on one of the Windows or Linux images, depending on your operating system.
Once download make sure you have the sdl2.dll
file next to the emulator .exe file, you can start the emulator by doing
a drag and drop of a rom to the .exe file, it will automatically start the game. You can also start the emulator by
typing the following command in your terminal.
./GameBoyEmulator.exe <romPath>
Once download you'll need to install the SDL2 library
by typing one of the following commands :
sudo apt-get install libsdl2-dev
or
sudo apt-get install libsdl2-2.0-0
Warning Depending on your Linux distribution the command to install SDL2 may change.
Once it's done, you can start the emulator by doing a drag and drop of a rom on the emulator file, or you can type the following command:
./GameBoyEmulator.exe <romPath>
Emulator is supported under Linux and Windows.
The source code provide a CMakeList.txt
file to compile the emulator.
You can download CMake here: https://cmake.org
Linux's users need to install the developer version of SDL2 to compile the Emulator. To install it types the following command in your terminal:
sudo apt-get install libsdl2-dev
F10 : Switch Game Boy's color mode (GreenScale or Grayscale)
F11 : Switch between Fullscreen and windowed mode
Escape button/click cross to exit emulation
O : Create a screenshot of the game in the folder next to tha app (screenshots/)
P : Pause emulation
U : Increase emulator audio volume
J : Decrease emulator audio volume
B : create save-state
N : load save-state
Tab : restart game/emulator
To use a save-state press the B button on your keyboard, it will create a bmp image file named with the name of the game and the extension .gb.state.bmp. To load it, just press the N on your keyboard to load it when the game is playing.
The save-state is a screenshot of the game, allowing you to know where you're going to resume the game if you use it.
The emulator allow you to do screenshot of the game everytime. You can create one by pushing the IMP key on your
keyboard. The screenshots will be saved in the folder next to the Emulator screenshots/<gameName>
.
You can play games with your keyboard and also with Xbox or Playstation controller.
The controller must be connected before you start the emulator. The selected controller will Rumble for you to know which controller has been selected (for PlayStation user the controller's led will be green).
Console buttons | Emulator buttons | Xbox Controller | Playstation Controller |
---|---|---|---|
A | D | B | O |
B | S | A | X |
Start | Enter | start | options |
Select | Space | select | share |
← | ← | arrow/joystick | arrow/joystick |
→ | → | arrow/joystick | arrow/joystick |
↓ | ↓ | arrow/joystick | arrow/joystick |
↑ | ↑ | arrow/joystick | arrow/joystick |
When you download/start the emulator you will get a GameBoyEmulator.ini file. This file allows you to change some parameters about the emulator.
Ini file setting | Description |
---|---|
startBios | load or not bios |
biosPath | set boot-rom path |
width | window width |
height | window height |
colorMode | change color mode (from 0 to 3) |
You can modify each of these parameters manually. To disable the bios load, put the value 0 in
Original .ini file:
startBios='0'
biosPath='./dmg_boot.bin'
width='640'
height='576'
colorMode='0'
Zelda Link's Awakening in grayscale | Zelda Link's Awakening in green-scale |
---|---|
The repository has a GitHub Actions file to verify the good behaviour of the project before merging/pushing to the main branch with a wrong code.
CMake: https://cmake.org
SDL wiki: https://wiki.libsdl.org
Video overview of the Game Boy, to understand the fundamental: https://www.youtube.com/watch?v=HyzD8pNlpwI
The main documentation about the console: https://archive.org/details/GameBoyProgManVer1.1/mode/2up https://gbdev.io/pandocs/Specifications.html
The boot-rom: https://gbdev.gg8.se/wiki/articles/Gameboy_Bootstrap_ROM
Opcodes map: https://www.pastraiser.com/cpu/gameboy/gameboy_opcodes.html
Rom/Ram banking: http://www.codeslinger.co.uk/pages/projects/gameboy/beginning.html
PPU: https://hacktixme.ga/GBEDG/ppu/
Audio and sound: https://xiph.org/video/vid1.shtml
SPU: https://nightshade256.github.io/2021/03/27/gb-sound-emulation.html https://emudev.de https://www.youtube.com/watch?v=a52p6ji1WZs
Test roms I used to debug my emulator: https://gbdev.gg8.se/files/roms/blargg-gb-tests/ https://github.com/mattcurrie/dmg-acid2
Other docs (mostly about emulation in general): https://emudev.org http://emulator101.com/
Quentin MOREL :