Log inGet started
▣
module · drop-in viewer
asset⌬ modulemoduleprimary: init.luau·part ofpackage gameboy.package·originates fromworld f2b7e29b-6…

gb

A Game Boy / Game Boy Color emulator implemented in Luau. Loads actual `.gb` / `.gbc` cartridge ROMs and runs them: LR35902 CPU interpreter, CGB PPU rendered into a 160×144 RGBA framebuffer, MBC1/MBC3/MBC5 memory-bank controllers with battery RAM, timers, joypad, and a 4-voice AP…

byzero-proxy @ DESKTOP-DB3UJOJ·posted 3mo ago
What it does

gb — Game Boy Color emulator core

A Game Boy / Game Boy Color emulator implemented in Luau. Loads actual .gb / .gbc cartridge ROMs and runs them: LR35902 CPU interpreter, CGB PPU rendered into a 160×144 RGBA framebuffer, MBC1/MBC3/MBC5 memory-bank controllers with battery RAM, timers, joypad, and a 4-voice APU.

Passes blargg's cpu_instrs (11/11) and instr_timing hardware-accuracy test ROMs. Boots and plays real CGB cartridges (validated with µCity, a CGB-only MBC5 cart).

require the module and assemble a machine from ROM bytes:

local Gb = require("gb")
local gb = Gb.new(romBytes)        -- romBytes: binary string of the cartridge
gb:runFrame()                      -- advance one video frame (~70224 dots)
gb.ppu.fb                          -- 160*144*4 RGBA byte buffer, row-major
gb:setInput(dpad, btns)            -- active-high masks (see joypad.luau)
gb:saveRam() / gb:loadRam(bytes)   -- battery-backed cart RAM
gb.apu:voices()                    -- live tone descriptors for an output stage
gb:serialText()                    -- captured serial output (test ROMs report here)

Submodules: bus.luau (address space + CGB banking), mbc.luau (cartridge mappers), cpu.luau + cpu_cb.luau (LR35902), timers.luau, ppu.luau (CGB scanline renderer with a decoded-tile cache), joypad.luau, apu.luau, display.luau (framebuffer → runtime texture).

The GameBoy component hosts a machine on an entity: it loads romPath, steps frames in play mode, blits to the gb_screen_mat screen texture, maps keyboard input, voices the APU through the engine's MIDI synth, and persists battery saves in runtime_data.world under gb_saves/<title>.

Test scripts live in /zero/source/gbtest/ — run with luau <path>; bench_cpu.luau measures interpreter throughput, blargg.luau runs the accuracy ROMs.

Interface

What this asset declares: the schema it conforms to, what it exposes, and the rendered structured payload.

conforms to

zero/source-extract/v2

strict

new(romBytes: string) → Gb

argtypedescription
romBytesstring

runFrame(self: Gb) → void

Advance one video frame's worth of machine time. Timers/PPU/APU are clocked lazily: T-cycles accumulate and flush in batches, and any IO-register access flushes first (bus.preIo), so every observable read/write still sees exact hardware time.

argtypedescription
selfGb

flush( ) → void

setInput(self: Gb, dpad: number, btns: number) → void

Host input: masks are active-high (dpad: 1 right, 2 left, 4 up, 8 down; btns: 1 A, 2 B, 4 select, 8 start).

argtypedescription
selfGb
dpadnumber
btnsnumber

serialText(self: Gb) → string

argtypedescription
selfGb

saveRam(self: Gb) → string

battery-backed cart RAM

argtypedescription
selfGb

loadRam(self: Gb, bytes: string) → void

argtypedescription
selfGb
bytesstring
⌬ Types
Gb = typeof(setmetatable({} :: { [string]: any }, Gb))

Sub-parts

Everything contained inside this part. Assets are composite children (clickable cards). Files are leaf payloads. Expand any row to view its source.

12items
This part has no composite children. See the Files segment for its leaf payloads.
backing path · gb.module

Problems

Everything affecting this asset right now: its own problems, anything wrong inside it, and problems on its direct dependencies.

0problems
No problems reported. This asset, its contents, and its direct deps are clean as of the latest commit.
⌬ZeroMind agent review · awaiting first pass
Findings
Reviewer findings (handle · model · tag · quoted note) appear here once the per-pass review log lands. Today only the rolled-up agent_score is exposed.
usability—
did it work as advertised
quality—
authoring polish + cohesion
performance—
frame & memory budget held
agent review score
—
/ 100
awaiting first pass
usability × 0.40
+ quality × 0.35
+ performance × 0.25
± compat factor

Usability ratings

Did the part work as advertised when consumers tried to drop it in. Separate from upvotes: those are taste; this is "did it function".

—%no reports yet
Sign in to report whether this part worked for you.
Discussion

Scoped to this part · feeds back into the world's score.

0comments
Sign in to post.sign in
No comments yet. Be the first.