GitHub - Humpheh/goboy: Multi-platform Nintendo Game Boy Color emulator written...
source link: https://github.com/Humpheh/goboy
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
README.md
GoBoy
GoBoy is a multi-platform Nintendo GameBoy and GameBoy Color emulator written in go. This emulator was primarily built as a development exercise, and while still work in progress it should run the majority of GB games, and some CGB games. There is also experimental sound and colour support implemented.
The program includes debugging functions which make it useful for understanding how the emulator is working or for building one yourself, such as a method for printing out opcodes and register values to the console at each step. Turning these on will slow down the emulation.
Installation
go get github.com/Humpheh/goboy
The program has been tested on MacOS and Windows 10, and is likely to work on Linux. Building on Windows 10 requires MinGW.
GoBoy uses the go library pixel for control binding and graphics rendering, which requires OpenGL. Instructions on installing them can be found on the pixels readme.
Usage
goboy -sound -cgb -rom zelda.gb
Controls: ← ↑ ↓ → Z X Enter Backspace
The colour palette can be cycled with = (in DMG mode), and the game can be made fullscreen with F.
Other options:
-cgb set to enable cgb mode -cpuprofile string write cpu profile to file -disableVsync set to disable vsync -load string location of save state to load (experimental) -rom string location of rom file (required) -sound set to enable sound emulation (experimental) -stepthrough step through opcodes (debugging) -unlocked if to unlock the cpu speed (debugging)
Debugging
There are a few keyboard shortcuts useful for debugging:
Q - force toggle background
W - force toggle sprites
A - print gb background palette data (cgb)
S - print sprite palette data (cgb)
D - print background map to log
E - toggle opcode printing to console (will slow down execution)
7,8,9,0 - toggle sound channels 1 through 4.
Saving
If the loaded rom supports a battery a <rom-name>.sav
(e.g. zelda.gb.sav
) file will be created
next to the loaded rom containing a dump of the RAM from the cartridge. A loop in the program will
update this save file every second while the game is running.
Testing
GoBoy currently passes all of the tests in Blargg's cpu_instrs
and instr_timing
test roms.
These roms are included in the source code along with a test to check the output is as expected
(instructions_test.go
and timing_test.go
). These tests are also run on each commit.
Contributing
Feel free to open pull requests to this project or play around if you're interested!
Known Bugs
- Sprite Z-drawing
- Sprites near edge of screen not drawing
- Top half of sprite disappearing off top of screen
- Small sprites row glitch
- Many CGB bugs
- BG tile window offset issue - visible on Pokemon Red splash screen - possibly mistimed interrupt?
TODO List
- MBC3 banking support
- GameBoy Color support (partial)
- Rewrite APU emulation
- MBC3 clock support
- Complete CGB emulation
- Icon
- White screen when off
- Speed up CPU
- Resizable window
- Some kind of nice UI
- MBC4-7 support (?)
- More colour palettes
- STOP opcode behaviour
- Blargg's test ROMs
Resources
A large variety of resources were used to understand and test the GameBoy hardware. Some of these include:
- http://www.codeslinger.co.uk/pages/projects/gameboy/files/GB.pdf
- https://github.com/retrio/gb-test-roms
- http://www.codeslinger.co.uk/pages/projects/gameboy/beginning.html
- http://bgb.bircd.org/ - invaluable for debugging
- https://github.com/AntonioND/giibiiadvance/tree/master/docs
- https://github.com/trekawek/coffee-gb
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK