https://github.com/jabolol/gameboy
An accurate GameBoy emulator written in C from scratch
https://github.com/jabolol/gameboy
c emulator gameboy
Last synced: 11 months ago
JSON representation
An accurate GameBoy emulator written in C from scratch
- Host: GitHub
- URL: https://github.com/jabolol/gameboy
- Owner: Jabolol
- License: mit
- Created: 2023-04-09T12:30:23.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2025-03-13T22:46:28.000Z (over 1 year ago)
- Last Synced: 2025-06-06T14:42:12.932Z (about 1 year ago)
- Topics: c, emulator, gameboy
- Language: C
- Homepage: https://gameboy.deno.dev/
- Size: 7.1 MB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# gameboy
An accurate **gameboy** emulator written in C from scratch.

## development
In order to run the emulator, you need to have `cmake`, a build system like
`ninja` and a C compiler. `SDL2` is included as a submodule and will be compiled
along with the project.
1. Clone the repository
```bash
git clone --recurse-submodules git@github.com:Jabolol/gameboy.git .
```
2. Add the `ROMs` directory with the ROMs to be loaded in the web version
```bash
mkdir ROMs && cp /path/to/rom.gb ROMs
```
3. Compile the project
```bash
cmake -B build -G Ninja && cmake --build build
```
4. Run the emulator
```bash
./build/gameboy /path/to/rom.gb
```
## features
- [x] Bus (Memory Management)
- [x] CPU
- [x] PPU (Graphics)
- [x] Input (Joypad)
- [x] Timer
- [x] Interrupts (V-Blank, LCD, Timer, Serial, Joypad)
- [x] MBC1 - MBC7 (Memory Bank Controllers 1-7)
- [x] Save States (.sav files)
- [x] Sound (Square Wave, Wave, Noise)
- [x] Web version at [gameboy.deno.dev](https://gameboy.deno.dev/)
## controls
- `Arrow Keys` - D-Pad
- `A` - A
- `B` - B
- `U` - Volume Up
- `D` - Volume Down
- `Enter` - Start
## web version
The emulator is also available as a web version using `emscripten` and `deno`.
In order to run the web version, you need to have `deno` installed.
Some games are preloaded in the web version, just append `?game=${game}` to the
url to load a different game. The supported games are shown
[here](./www/static/inject.js).
The web version will bundle the ROMs available at `ROMs` directory and serve
them at `http://localhost:8000`.
```bash
deno task --cwd www start
```
## screenshots
> [Legend of Zelda, The - Link's Awakening](https://gameboy.deno.dev/?game=zelda)

> [Pokemon - Yellow Version - Special Pikachu Edition](https://gameboy.deno.dev/?game=pokemon-yellow)

> [Dr. Mario](https://gameboy.deno.dev/?game=dr-mario)

> [Mega Man - Dr. Wily's Revenge](https://gameboy.deno.dev/?game=megaman-willy)

> [Contra - The Alien Wars](https://gameboy.deno.dev/?game=contra)

> [Kirby - Dream Land](https://gameboy.deno.dev/?game=kirby-dream)

> [Kirby - Dream Land 2](https://gameboy.deno.dev/?game=kirby-dream-2)

> [Tetris](https://gameboy.deno.dev/?game=tetris)

## resources
- [Gameboy CPU Manual](http://marc.rawer.de/Gameboy/Docs/GBCPUman.pdf): A
comprehensive guide to the Gameboy CPU.
- [Gameboy Opcodes](https://www.pastraiser.com/cpu/gameboy/gameboy_opcodes.html):
List of all opcodes for the Gameboy CPU.
- [Gameboy Pan Docs](https://gbdev.io/pandocs/): A detailed guide to the Gameboy
hardware.
## license
This project is licensed under the MIT License - see the [LICENSE](./LICENSE)
file for details.