How victorgomes/gb works
Leiksveinn is a C Game Boy/Color emulator with SDL3 and browser/WASM hosts. The main workflow is to load a ROM, select its cartridge mapper, execute CPU instructions over the memory bus while timed hardware advances, then present video and audio. Cartridge persistence, save states, link play, printer output, and camera input are additional product branches. The browser shell adds touch controls and IndexedDB persistence, while its service worker caches the offline app shell. The sampled source is partial; unsampled subsystem links are included only where the README or module roles support them.
Main entry points: main.c SDL host · main.js Browser shell · mmu.c System bus · cartridge.c Cartridge mapper
Components 22
Hosts and controls
- SDL host
src/main.c - Browser shell
web/main.js - WASM core
src/main.c - Offline shell
web/sw.js
Emulation core
- SM83 CPU
src/cpu.c - System bus
src/mmu.c - Pixel renderer
src/ppu.c - Audio unit
src/apu.c - Timer
src/timer.c
Cartridges and persistence
- Cartridge mapper
src/cartridge.c - Configuration
src/config.c - Save states
src/state.c - Battery saves
src/cartridge.c - Browser storage
web/main.js
Peripheral I/O
- Serial link
src/serial.c - Game Boy Printer
src/printer.c - Camera device
src/camera.c
Other components
- Player
- Game ROM
- Host camera
- Audio output
- Display
Connections 33
- Player → SDL host: controls
- Player → Browser shell: controls
- Game ROM → SDL host: loads
- Game ROM → Browser shell: loads
- SDL host → Configuration: loads settings
- SDL host → Cartridge mapper: loads cartridge
- SDL host → SM83 CPU: runs emulation
- Browser shell → WASM core: drives frames
- WASM core → SM83 CPU: runs emulation
- SM83 CPU → System bus: reads and writes
- System bus → Cartridge mapper: dispatches access
- System bus → Pixel renderer: advances timing
- System bus → Audio unit: advances timing
- System bus → Timer: advances timing
- System bus → Serial link: dispatches access
- Cartridge mapper → Battery saves: persists SRAM
- SDL host → Save states: saves snapshots
- Browser shell → Save states: saves snapshots
- Browser shell → Browser storage: reads and writes
- Save states → Browser storage: browser snapshots
- Pixel renderer → SDL host: framebuffer
- SDL host → Display: presents video
- Pixel renderer → Browser shell: framebuffer
- Browser shell → Display: draws video
- Audio unit → SDL host: audio samples
- SDL host → Audio output: plays audio
- Audio unit → Browser shell: audio samples
- Browser shell → Audio output: streams audio
- Serial link → Game Boy Printer: sends print data
- Game Boy Printer → SDL host: print output
- Cartridge mapper → Camera device: camera cartridge
- Camera device → Host camera: captures image
- SDL host → Offline shell: registers worker