Skip to main content

Crate gb

Crate gb 

Source
Expand description

gb: Game Boy hardware abstractions.

§Feature flags

  • bank — Enable ROM banking: the gb::bank module and the #[gb::bank] attribute.

    A banked build needs a cartridge controller, but the code compiles without one, so a crate can carry banked code that a 32 KiB program still links.

  • pak — Enable the Game Pak’s own hardware: gb::pak.

    Which peripherals a cartridge actually has comes from header.toml.

  • cgb — Enable Game Boy Color hardware features.

  • cgb-double-speed — Run in CGB double speed mode.

    The processor and the timer run twice as fast, while the screen and sound carry on as they were. A cartridge built with this is a Color-only one.

  • critical-section-impl — Register an implementation of the critical-section crate.

    IME is write-only, so the implementation tracks every interrupt state change in a mirror variable, which costs a store in each gb::interrupt call and at the entry and exit of every handler. Turn it on only to link a driver that requires it; in your own code use free or the token a handler is already handed.

Modules§

apu
The four sound channels and the mixer.
bankbank
Compile-time-safe ROM bank switching for the Game Boy.
hram
Typed handles to the Game Boy’s High RAM (HRAM, 0xFF80..=0xFFFE).
interrupt
Interrupt control: the IME master switch and the IE / IF masks.
ircgb
The Game Boy Color’s infrared port.
joypad
The eight buttons.
mmio
Typed, volatile handles to the Game Boy’s hardware registers and memory.
pakpak
The Game Pak’s own hardware.
ppu
The pixel-processing unit, which draws the screen.
ram_fn
Functions whose machine code can be copied into RAM (or HRAM) and run there.
rt
Core Game Boy (SM83) runtime.
serial
Byte exchange over the link cable.
timer
The timer and the free-running divider.

Macros§

hram
Declare static HRAM cells and areas, each at a linker-assigned High RAM address.

Functions§

is_cgb
Whether the machine has the Game Boy Color’s hardware.
is_gba
Whether the machine is a Game Boy Advance running a Game Boy Color cartridge.

Attribute Macros§

bankbank
Mark a function, static, impl block, or trait as banked.
ram_fn
Define a RAM-copyable function with any non-generic signature.
srampak
Place a value at the base of an SRAM bank.