mmu

package
v0.0.0-...-9d1ad58 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 4, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// fixed size of each memory region
	WRAM_SIZE = 0x2000
	HRAM_SIZE = 0x80

	// offsets of where the memory region starts
	WRAM_OFFSET = 0xC000
	HRAM_OFFSET = 0xFF80
)
View Source
const (
	SB_SERIAL_TRANSFER = 0xFF01
	SC_SERIAL_CONTROL  = 0xFF02
)

Variables

View Source
var (
	// 0x0000 - 0x3FFF : ROM Bank 0
	// 0x4000 - 0x7FFF : ROM Bank 1 - Switchable
	ROMRange = Range{0x0000, 0x7FFF}
	// 0x8000 - 0x97FF : CHR RAM
	// 0x9800 - 0x9BFF : BG Map 1
	// 0x9C00 - 0x9FFF : BG Map 2
	CharMapRange = Range{0x8000, 0x9FFF}
	// 0xA000 - 0xBFFF : Cartridge RAM
	CartRAMRange = Range{0xA000, 0xBFFF}
	// 0xC000 - 0xCFFF : RAM Bank 0
	// 0xD000 - 0xDFFF : RAM Bank 1-7 - switchable - Color only
	WRAMRange = Range{0xC000, 0xDFFF}
	// 0xE000 - 0xFDFF : Reserved - Echo RAM
	RESERVED_EchoRamRange = Range{0xE000, 0xFDFF}
	// 0xFE00 - 0xFE9F : Object Attribute Memory
	OAMRange = Range{0xFE00, 0xFE9F}
	// 0xFEA0 - 0xFEFF : Reserved - Unusable
	RESERVED_UnusableRange = Range{0xFEA0, 0xFEFF}
	// 0xFF00 : Joypad input
	JobpadInputRange = Range{0xFF00, 0xFF00}
	// 0xFF01 - 0xFF02 : Serial transfer
	SerialTransferRange = Range{0xFF01, 0xFF02}
	// 0xFF04 - 0xFF07 : Timer and divider
	TimerDividerRange = Range{0xFF04, 0xFF07}
	// 0xFF0F : Interrupt flag register
	InterruptFlagRange = Range{0xFF0F, 0xFF0F}
	// 0xFF10 - 0xFF26 : Audio
	// 0xFF30 - 0xFF3F : Wave pattern
	AudioRange = Range{0xFF10, 0xFF3F}
	// 0xFF40 - 0xFF4B : LCD
	LCDRange = Range{0xFF40, 0xFF4B}
	// 0xFF4D : CGB Speed Switch
	ColorSpeedSwitchRange = Range{0xFF4D, 0xFF4D}
	// 0xFF4F : VRAM Bank Select
	VRAMBankSelectRange = Range{0xFF4F, 0xFF4F}
	// 0xFF50 : Disable boot rom
	DisableBootRomRange = Range{0xFF50, 0xFF50}
	// 0xFF51 - 0xFF55 : VRAM DMA
	VRAMDMARange = Range{0xFF51, 0xFF55}
	// 0xFF68 - 0xFF69 : BG / OBJ Palettes
	BgObjPaletteRange = Range{0xFF51, 0xFF55}
	// 0xFF70 : WRAM Bank Select
	WRAMBankSelectRange = Range{0xFF50, 0xFF50}
	// 0xFF80 - 0xFFFE : Zero Page (HRAM)
	HRAMRange = Range{0xFF80, 0xFFFE}
	// 0xFFFF : Interrupt enable register
	InterruptEnableRange = Range{0xFFFF, 0xFFFF}
)

https://gbdev.io/pandocs/Memory_Map.html

Functions

This section is empty.

Types

type MMU

type MMU struct {
	// contains filtered or unexported fields
}

func New

func New(
	cart *cartridge.Cartridge,
	inter *interrupt.Interrupt,
	time *timer.Timer,
) *MMU

func (*MMU) DebugMem

func (mmu *MMU) DebugMem()

func (*MMU) DebugSerial

func (mmu *MMU) DebugSerial()

func (*MMU) Read16

func (mmu *MMU) Read16(address uint16) uint16

func (*MMU) Read8

func (mmu *MMU) Read8(address uint16) byte

func (*MMU) Write16

func (mmu *MMU) Write16(address uint16, value uint16)

func (*MMU) Write8

func (mmu *MMU) Write8(address uint16, data byte)

type Range

type Range struct {
	Start, End uint16
}

Range is a inclusive start/end range defined in memory

func (*Range) Contains

func (r *Range) Contains(addr uint16) bool

Contains checks if the given address is included in the memory range

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL