gb

package
v0.0.0-...-5cb0c46 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2024 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BOOT_ROM_BASE        = 0x0
	BOOR_ROM_TOP         = 0xFF
	BOOT_ROM_ENABLE_ADDR = 0xFF50
)

boot rom will take precedence before I/O address space, for R/W to 0xFF50

View Source
const (
	ROM_BASE = 0x0
	ROM_TOP  = 0x7FFF

	EXT_RAM_BASE = 0xA000
	EXT_RAM_TOP  = 0xBFFF
)
View Source
const (
	ZERO_FLAG_BIT       = 7
	SUB_FLAG_BIT        = 6
	HALF_CARRY_FLAG_BIT = 5
	CARRY_FLAG_BIT      = 4
)
View Source
const (
	FPS             = 60
	TICKS_PER_FRAME = TICKS_PER_SCANLINE * SCANLINES_PER_FRAME

	GB_SCREEN_WIDTH  = 160
	GB_SCREEN_HEIGHT = 144

	TILE_DATA_SCREEN_WIDTH  = 128
	TILE_DATA_SCREEN_HEIGHT = 192

	TILE_MAP_SCREEN_WIDTH  = 256
	TILE_MAP_SCREEN_HEIGHT = 256
)
View Source
const (
	RAM_SIZE = 0x6000
	RAM_BASE = 0xA000
	RAM_TOP  = 0xFFFF
)
View Source
const (
	IF_ADDR     = 0xFF0F
	IE_ADDR     = 0xFFFF
	INTRUPT_MSK = 0xE0

	VBLANK_INTRUPT_BIT = 0
	LCD_INTRUPT_BIT    = 1
	TIMER_INTRUPT_BIT  = 2
	SERIAL_INTRUPT_BIT = 3
	JOYPAD_INTRUPT_BIT = 4

	VBLANK_INTRUPT_VEC = 0x40
	STAT_INTRUPT_VEC   = 0x48
	TIMER_INTRUPT_VEC  = 0x50
	SERIAL_INTRUPT_VEC = 0x58
	JOYPAD_INTRUPT_VEC = 0x60

	ISR_CLOCK_TICKS = 20
)
View Source
const (
	JOYP_ADDR        = 0xFF00
	JOYP_A_RIGHT     = 0
	JOYP_B_LEFT      = 1
	JOYP_SELECT_UP   = 2
	JOYP_START_DOWN  = 3
	JOYP_DPAD_SELECT = 4
	JOYP_BTN_SELECT  = 5
)
View Source
const (
	MODE0 = 0
	MODE1 = 1
)
View Source
const (
	RAM_SELECT = 0
	RTC_SELECT = 1

	RTC_S  = 0x08
	RTC_M  = 0x09
	RTC_H  = 0x0A
	RTC_DL = 0x0B
	RTC_DH = 0x0C
)
View Source
const (
	ReadTileID     PixelFIFOState = 0
	ReadTileDataLo PixelFIFOState = 1
	ReadTileDataHi PixelFIFOState = 2
	Sleep          PixelFIFOState = 3
	PushFIFO       PixelFIFOState = 4

	BGP  Palette = 0
	OBP0 Palette = 1
	OBP1 Palette = 2
)
View Source
const (
	VRAM_SIZE = 0x2000
	VRAM_BASE = 0x8000
	VRAM_TOP  = 0x9FFF

	OAM_SIZE = 0xA0
	OAM_BASE = 0xFE00
	OAM_TOP  = 0xFE9F

	TILE_SIZE       = 16
	TILE_WIDTH      = 8
	TILE_MAP_WIDTH  = 32
	NUM_SP_PALETTES = 2

	LCDC_ADDR             = 0xFF40
	STAT_ADDR             = 0xFF41
	SCY_ADDR              = 0xFF42
	SCX_ADDR              = 0xFF43
	LY_ADDR               = 0xFF44
	LYC_ADDR              = 0xFF45
	OAM_DMA_TRANSFER_ADDR = 0xFF46
	BG_PALETTE_ADDR       = 0xFF47
	OBP0_ADDR             = 0xFF48
	OBP1_ADDR             = 0xFF49
	WY_ADDR               = 0xFF4A
	WX_ADDR               = 0xFF4B

	TICKS_PER_SCANLINE  = 456
	SCANLINES_PER_FRAME = GB_SCREEN_HEIGHT + 10

	STAT_LYC           = 2
	STAT_SELECT_HBLANK = 3
	STAT_SELECT_VBLANK = 4
	STAT_SELECT_OAM    = 5
	STAT_SELECT_LYC    = 6
	STAT_MSK           = 0x7F
	STAT_RW_MSK        = 0x78

	LCDC_BGWIN_ENABLE   = 0
	LCDC_OBJ_ENABLE     = 1
	LCDC_OBJ_SIZE       = 2
	LCDC_BG_TILE_MAP    = 3
	LCDC_TILE_DATA_AREA = 4
	LCDC_WIN_ENABLE     = 5
	LCDC_WIN_TILE_MAP   = 6
	LCDC_LCD_ENABLE     = 7

	SPRITES_PER_SCANLINE = 10

	OAM_SCAN       PPUState = 2
	PIXEL_TRANSFER PPUState = 3
	HBLANK         PPUState = 0
	VBLANK         PPUState = 1

	OAM_SCAN_TICKS = 80
)
View Source
const (
	SB_ADDR = 0xFF01
	SC_ADDR = 0xFF02
)
View Source
const (
	DIV_ADDR  = 0xFF04
	TIMA_ADDR = 0xFF05
	TMA_ADDR  = 0xFF06
	TAC_ADDR  = 0xFF07

	TAC_TIMER_ENABLE_BIT = 2
	TAC_FREQ_DIV_MSK     = 0x3
	TAC_MSK              = 0x7

	HZ_4096   = 0
	HZ_262144 = 1
	HZ_65536  = 2
	HZ_16386  = 3
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Addressable

type Addressable interface {
	// contains filtered or unexported methods
}

type BankMode

type BankMode uint8

type BootRom

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

type Button

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

type CPU

type CPU struct {
	IME      bool
	IMEDelay bool
	// contains filtered or unexported fields
}

type Cart

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

type DMAController

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

type Gameboy

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

func NewGameboy

func NewGameboy(opts GameboyOptions) *Gameboy

func (*Gameboy) Draw

func (gb *Gameboy) Draw(screen *ebiten.Image)

func (*Gameboy) Layout

func (gb *Gameboy) Layout(outsideWidth, outsideHeight int) (screenWidth, screenHeight int)

func (*Gameboy) Start

func (gb *Gameboy) Start()

func (*Gameboy) Update

func (gb *Gameboy) Update() error

type GameboyOptions

type GameboyOptions struct {
	Filename        string
	DebugMode       bool
	BootRomFilename string
	Stats           bool
}

type GenericRAM

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

type IntruptController

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

type Joypad

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

type MBC1

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

type MBC3

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

type MMU

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

type MemoryBankController

type MemoryBankController interface {
	Addressable
	// contains filtered or unexported methods
}

type PPU

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

func (*PPU) LCDEnabled

func (ppu *PPU) LCDEnabled() bool

type PPUState

type PPUState uint8

type Palette

type Palette uint8

type PixelFIFO

type PixelFIFO struct {
	BGWinComplete bool
	// contains filtered or unexported fields
}

type PixelFIFOItem

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

type PixelFIFOState

type PixelFIFOState uint8

type Registers

type Registers struct {
	A  uint8
	B  uint8
	C  uint8
	D  uint8
	E  uint8
	F  uint8
	H  uint8
	L  uint8
	SP uint16
	PC uint16
}

type SelectMode

type SelectMode uint8

type SerialPort

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

type Sprite

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

type Timer

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

Jump to

Keyboard shortcuts

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