MCPcopy
hub / github.com/Humpheh/goboy

github.com/Humpheh/goboy @v0.5 sqlite

repository ↗ · DeepWiki ↗ · release v0.5 ↗
239 symbols 664 edges 30 files 193 documented · 81%
README

GoBoy

Build Status codecov Go Report Card GoDoc

GoBoy is a multi-platform Nintendo GameBoy and GameBoy Color emulator written in go. The emulator can run the majority of GB games and some CGB games. There is also colour and sound support. This emulator was primarily built as a development exercise and is still work in progress. Please feel free to contribute if you're interested in GameBoy emulator development.

The program includes debugging functions making it useful for understanding the emulator operation for building one yourself. These functions include printing of opcodes and register values to the console at each step (although will greatly slow down the emulation) and toggling of individual sound channels.

Installation

Download the latest release of GoBoy from the releases page.

Building from source

With go installed, you can install GoBoy into your go bin by running:

go get github.com/Humpheh/goboy/cmd/goboy

If you have Go 1.11 you can also do:

git clone https://github.com/Humpheh/goboy.git
cd goboy
go build -o goboy cmd/goboy/main.go

GoBoy is compatible with MacOS, Windows and Linux. Building on Windows 10 requires MinGW and on Linux, you'll need to install gtk.

GoBoy uses the go library pixel for control binding and graphics rendering, which requires OpenGL. You may need to install some requirements which can be found on the pixels readme.

Usage

goboy 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:

  -dmg
        set to force dmg mode
  -mute
        mute sound output

Debug or experimental options:

  -cpuprofile string
        write cpu profile to file (debugging)
  -disableVsync
        set to disable vsync (debugging)
  -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

Please feel free to open pull requests to this project or play around if you're interested! There are still plenty of small bugs that can easily be found through playing games on the emulator, or take a task from the TODO list below!

Known Bugs and TODO list

  • [x] Sprites near edge of screen not drawing
  • [x] Top half of sprite disappearing off top of screen
  • [x] Small sprites row glitch
  • [x] BG tile window offset issue - visible on Pokemon Red splash screen - possibly mistimed interrupt?
  • [x] Harry Potter and The Chamber of Secrets has odd sprite issues
  • [x] Request to set screen to white does not do so
  • [x] MBC3 banking support
  • [x] Improve APU (see Pokemon Yellow opening screen for reason why)
  • [x] Resizable window
  • [x] White screen when off
  • [x] STOP opcode behaviour
  • [ ] Sprite Z-drawing bugs
  • [ ] Minor APU timing issues
  • [ ] Better APU buffering
  • [ ] Stop jittering
  • [ ] MBC3 clock support
  • [ ] Speed up CPU and PPU
  • [ ] Platform native UI?
  • [ ] More DMG colour palettes
  • [ ] Support save-states
  • [ ] Support boot roms
  • [ ] 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

Extension points exported contracts — how you extend this code

BankingController (Interface)
BankingController provides methods for accessing and writing data to a cartridge, which provides different banking funct [5 …
pkg/cart/controller.go
IOBinding (Interface)
IOBinding provides an interface for display and input bindings. [1 implementers]
pkg/gb/input.go
WaveGenerator (FuncType)
WaveGenerator is a function which can be used for generating waveform samples for different channels.
pkg/apu/waves.go
GameboyOption (FuncType)
GameboyOption is an option for the Gameboy execution.
pkg/gb/options.go

Core symbols most depended-on inside this repo

Hi
called by 166
pkg/gb/cpu.go
HiLo
called by 73
pkg/gb/cpu.go
Lo
called by 59
pkg/gb/cpu.go
SetHi
called by 53
pkg/gb/cpu.go
Read
called by 45
pkg/cart/controller.go
popPC
called by 30
pkg/gb/instructions.go
SetLo
called by 29
pkg/gb/cpu.go
SetH
called by 29
pkg/gb/cpu.go

Shape

Method 163
Function 53
Struct 17
FuncType 2
Interface 2
TypeAlias 2

Languages

Go100%

Modules by API surface

pkg/gb/gameboy.go27 symbols
pkg/gb/cpu.go19 symbols
pkg/cart/controller.go17 symbols
pkg/gb/functions.go15 symbols
pkg/gb/ppu.go11 symbols
pkg/gb/memory.go11 symbols
pkg/gb/input.go11 symbols
pkg/gb/instructions_cb.go10 symbols
pkg/apu/apu.go10 symbols
pkg/gb/palettes.go9 symbols
pkg/gb/options.go9 symbols
pkg/gb/io/pixelgl.go8 symbols

Dependencies from manifests, versioned

github.com/faiface/glhfv0.0.0-2018101822262 · 1×
github.com/faiface/mainthreadv0.0.0-2017112001131 · 1×
github.com/faiface/pixelv0.8.0 · 1×
github.com/go-gl/glv0.0.0-2019032018090 · 1×
github.com/go-gl/glfwv0.0.0-2019040900403 · 1×
github.com/go-gl/mathglv0.0.0-2019041616012 · 1×
github.com/gotk3/gotk3v0.0.0-2020010310163 · 1×
github.com/hajimehoshi/otov0.5.4 · 1×
github.com/sqweek/dialogv0.0.0-2019072810350 · 1×

For agents

$ claude mcp add goboy \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact