Documentation
¶
Index ¶
Constants ¶
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cartridge ¶
type Cartridge struct {
// contains filtered or unexported fields
}
Cartridge holds the data and metadata of a gameboy cartridge.
func NewCartridge ¶
func NewCartridge() *Cartridge
NewCartridge creates an empty cartridge, useful only for debugging purposes.
func NewCartridgeWithData ¶
NewCartridgeWithData initializes a new Cartridge from a slice of bytes.
type MBC ¶
type MBC interface { // Read reads a byte from the specified address Read(addr uint16) uint8 // Write writes a byte to the specified address, returns the written value Write(addr uint16, value uint8) uint8 }
MBC represents a Memory Bank Controller interface that all MBC types must implement
type MBC1 ¶
type MBC1 struct {
// contains filtered or unexported fields
}
MBC1 is the first and most common MBC chip. Features include: - Supports up to 2MB ROM (125 16KB banks) - Up to 32KB RAM (4 8KB banks) - Bank 0 always mapped to 0x0000-0x3FFF - Switchable ROM bank at 0x4000-0x7FFF - Optional RAM banking at 0xA000-0xBFFF - Two banking modes:
- Mode 0 (ROM): Allows access to full ROM but only 8KB RAM
- Mode 1 (RAM): Restricts ROM banking but allows full RAM access
- Optional battery backup for RAM persistence
type MBC2 ¶
type MBC2 struct {
// contains filtered or unexported fields
}
MBC2 is a simpler MBC chip with built-in RAM. Features include:
- Supports up to 256KB ROM (16 16KB banks)
- Built-in 512x4 bits RAM (not external)
- RAM does not require enabling (always accessible)
- ROM banking similar to MBC1 but simpler
- The least significant bit of the upper address byte selects between ROM banking and RAM access
- RAM is limited to 4-bit values (upper 4 bits are ignored)
- Optional battery backup for the built-in RAM
type MBC3 ¶
type MBC3 struct {
// contains filtered or unexported fields
}
MBC3 is an advanced MBC chip with RTC support. Features include: - Supports up to 2MB ROM (128 16KB banks) - Up to 32KB RAM (4 8KB banks) - Real-Time Clock (RTC) functionality - RTC has 5 registers: Seconds, Minutes, Hours, Days (lower), Days (upper)/Flags - Similar banking to MBC1 but with different register layout - RAM and RTC can be battery backed - Used in games that needed to track real time (e.g. Pokémon Gold/Silver)
type MBC5 ¶
type MBC5 struct {
// contains filtered or unexported fields
}
MBC5 is the most advanced MBC chip. Features include: - Supports up to 8MB ROM (512 16KB banks) - Up to 128KB RAM (16 8KB banks) - Simple ROM/RAM banking with no quirks (unlike MBC1) - 9-bit ROM bank number (allows all 512 banks to be directly accessed) - Optional rumble motor support - Used in Game Boy Color games that needed more ROM/RAM - Backwards compatible with Game Boy
type MMU ¶
type MMU struct {
// contains filtered or unexported fields
}
MMU allows access to all memory mapped I/O and data/registers
func New ¶
func New() *MMU
New creates a new memory unity with default data, i.e. nothing cartridge loaded. Equivalent to turning on a Gameboy without a cartridge in.
func NewWithCartridge ¶
NewWithCartridge creates a new memory unit with the provided cartridge data loaded. Equivalent to turning on a Gameboy with a cartridge in.
func (*MMU) RequestInterrupt ¶
RequestInterrupt sets the interrupt flag (IF register) of the chosen interrupt to 1.
type NoMBC ¶
type NoMBC struct {
// contains filtered or unexported fields
}
NoMBC represents cartridges with no memory banking capabilities. These are typically smaller games (32KB or less) that fit entirely in the base memory region. The cartridge ROM is directly mapped to 0x0000-0x7FFF and cannot be banked/switched. These cartridges cannot have external RAM.