gbc

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2021 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NoIRQ = iota
	VBlankIRQ
	LCDCIRQ
	TimerIRQ
	SerialIRQ
	JoypadIRQ
)
View Source
const (
	JOYPIO    byte = 0x00
	SBIO      byte = 0x01
	SCIO      byte = 0x02
	DIVIO     byte = 0x04
	TIMAIO    byte = 0x05
	TMAIO     byte = 0x06
	TACIO     byte = 0x07
	IFIO      byte = 0x0f
	LCDCIO    byte = 0x40
	LCDSTATIO byte = 0x41
	SCYIO     byte = 0x42
	SCXIO     byte = 0x43
	LYIO      byte = 0x44
	LYCIO     byte = 0x45
	DMAIO     byte = 0x46
	BGPIO     byte = 0x47
	OBP0IO    byte = 0x48
	OBP1IO    byte = 0x49
	WYIO      byte = 0x4a
	WXIO      byte = 0x4b
	KEY0IO    byte = 0x4c
	KEY1IO    byte = 0x4d
	VBKIO     byte = 0x4f
	BANKIO    byte = 0x50
	HDMA1IO   byte = 0x51
	HDMA2IO   byte = 0x52
	HDMA3IO   byte = 0x53
	HDMA4IO   byte = 0x54
	HDMA5IO   byte = 0x55
	BCPSIO    byte = 0x68
	BCPDIO    byte = 0x69
	OCPSIO    byte = 0x6a
	OCPDIO    byte = 0x6b
	SVBKIO    byte = 0x70
	IEIO      byte = 0xff
)
View Source
const (
	INS_ADC = iota
	INS_AND
	INS_ADD
	INS_CP
	INS_DEC
	INS_INC
	INS_OR
	INS_SBC
	INS_SUB
	INS_XOR
	INS_BIT
	INS_RES
	INS_SET
	INS_SWAP
	INS_RL
	INS_RLA
	INS_RLC
	INS_RLCA
	INS_RR
	INS_RRA
	INS_RRC
	INS_RRCA
	INS_SLA
	INS_SRA
	INS_SRL
	INS_LD
	INS_CALL
	INS_JP
	INS_JR
	INS_RET
	INS_RETI
	INS_RST
	INS_POP
	INS_PUSH
	INS_CCF
	INS_CPL
	INS_DAA
	INS_DI
	INS_EI
	INS_HALT
	INS_NOP
	INS_SCF
	INS_STOP
	INS_PREFIX
	INS_NONE
	INS_LDH
)
View Source
const (
	OP_NONE = iota
	OP_BC
	OP_d16
	OP_BC_PAREN
	OP_A
	OP_AF
	OP_B
	OP_d8
	OP_a16_PAREN
	OP_SP
	OP_SP_PLUS_r8
	OP_HL
	OP_C
	OP_C_PAREN
	OP_DE
	OP_DE_PAREN
	OP_D
	OP_r8
	OP_a8_PAREN
	OP_a16
	OP_E
	OP_NZ
	OP_NC
	OP_H
	OP_L
	OP_Z
	OP_HLPLUS_PAREN
	OP_HLMINUS_PAREN
	OP_HL_PAREN
)
View Source
const (
	A = iota
	B
	C
	D
	E
	H
	L
	F
)
View Source
const (
	AF = iota
	BC
	DE
	HL
	HLI
	HLD
	SP
	PC
)
View Source
const (
	GB_DMG_DIV_PERIOD = 16 // this is INTERNAL div interval, 16cycle or 8cycles
)

Variables

This section is empty.

Functions

This section is empty.

Types

type CurInst

type CurInst struct {
	Opcode byte
	PC     uint16
}

type Dma

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

type GBC

type GBC struct {
	Reg  Register
	Inst CurInst

	// memory
	ROM  ROM
	RAM  RAM
	WRAM WRAM
	IO   [0x100]byte // 0xff00-0xffff

	Cartridge *cart.Cartridge

	Halt bool

	Sound       *apu.APU
	Video       *video.Video
	RTC         *rtc.RTC
	DoubleSpeed bool

	// plugins
	Callbacks []*util.Callback
	// contains filtered or unexported fields
}

GBC core structure

func New

func New(romData []byte, j [8](func() bool), setAudioStream func([]byte)) *GBC

func (*GBC) Draw

func (g *GBC) Draw() []byte

func (*GBC) Frame

func (g *GBC) Frame() int

func (*GBC) Load8

func (g *GBC) Load8(addr uint16) (value byte)

Load8 fetch value from ram

func (*GBC) PanicHandler

func (g *GBC) PanicHandler(place string, stack bool)

func (*GBC) Step

func (g *GBC) Step()

Exec 1cycle

func (*GBC) Store8

func (g *GBC) Store8(addr uint16, value byte)

Store8 set value into RAM

func (*GBC) TransferROM

func (g *GBC) TransferROM(rom []byte)

TransferROM Transfer ROM from cartridge to Memory

func (*GBC) Update

func (g *GBC) Update()

1 frame

type Hdma

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

type Inst

type Inst struct {
	Operand1, Operand2 int
	Cycle1, Cycle2     int // cond is true(1)/false(2)
	Handler            func(*GBC, int, int)
	// contains filtered or unexported fields
}

type RAM

type RAM struct {
	Buffer [16][0x2000]byte // num of banks changes depending on ROM
	// contains filtered or unexported fields
}

RAM - 0xa000-0xbfff

type ROM

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

ROM

0x0000-0x3fff: bank0

0x4000-0x7fff: bank1-256

type Register

type Register struct {
	R   [8]byte
	SP  uint16
	PC  uint16
	IME bool
}

Register Z80

func (*Register) AF

func (r *Register) AF() uint16

func (*Register) BC

func (r *Register) BC() uint16

func (*Register) DE

func (r *Register) DE() uint16

func (*Register) HL

func (r *Register) HL() uint16

func (*Register) R16

func (r *Register) R16(i int) uint16

type Timer

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

func NewTimer

func NewTimer(p *GBC) *Timer

type WRAM

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

WRAM

0xc000-0xcfff: bank0

0xd000-0xdfff: bank1-7

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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