gb

package
v0.0.0-...-ba8b227 Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2017 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RLC = iota
	RRC
	RL
	RR
	SLA
	SRA
	SRL
)
View Source
const (
	VBlankInterrupt = iota
	LCDStatInterrupt
	TimerInterrupt
	SerialInterrupt
	JoypadInterrupt
)
View Source
const LCDSizeX uint = 160
View Source
const LCDSizeY uint = 144
View Source
const OAMblockSize uint = 4

Variables

View Source
var ByteRegisterNameMap map[ByteRegister]string = map[ByteRegister]string{
	B:     "B",
	C:     "C",
	D:     "D",
	E:     "E",
	H:     "H",
	L:     "L",
	A:     "A",
	HLind: "(HL)",
	Imm:   "d8",
}

Functions

func ADDSPimm

func ADDSPimm(cpu *CPU, sys *Sys) int

func CCF

func CCF(cpu *CPU, sys *Sys) int

func CPL

func CPL(cpu *CPU, sys *Sys) int

func DAA

func DAA(cpu *CPU, sys *Sys) int

Decimal adjust A

func DI

func DI(cpu *CPU, sys *Sys) int

func DRAGONS

func DRAGONS(cpu *CPU, sys *Sys) int

func EI

func EI(cpu *CPU, sys *Sys) int

func HALT

func HALT(cpu *CPU, sys *Sys) int

func JPHLind

func JPHLind(cpu *CPU, sys *Sys) int

func LDHLSPimm

func LDHLSPimm(cpu *CPU, sys *Sys) int

func LDSPHL

func LDSPHL(cpu *CPU, sys *Sys) int

func LDSPImmInd

func LDSPImmInd(cpu *CPU, sys *Sys) int

Load SP via an imediate value that points to another value

func NOP

func NOP(cpu *CPU, sys *Sys) int

func PANIC

func PANIC(cpu *CPU, sys *Sys) int

func POPAF

func POPAF(cpu *CPU, sys *Sys) int

func RLA

func RLA(cpu *CPU, sys *Sys) int

func RLCA

func RLCA(cpu *CPU, sys *Sys) int

func RRA

func RRA(cpu *CPU, sys *Sys) int

func RRCA

func RRCA(cpu *CPU, sys *Sys) int

func SCF

func SCF(cpu *CPU, sys *Sys) int

func STOP

func STOP(cpu *CPU, sys *Sys) int

Types

type ALUOp

type ALUOp int
const (
	ADD ALUOp = iota
	ADC
	SUB
	SBC
	AND
	XOR
	OR
	CP
)

type BusDev

type BusDev interface {
	R(addr uint16) uint8
	W(addr uint16, val uint8)
	Asserts(addr uint16) bool
}

type BusHole

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

func NewBusHole

func NewBusHole(startAddr uint16, endAddr uint16) *BusHole

func (*BusHole) Asserts

func (b *BusHole) Asserts(addr uint16) bool

func (*BusHole) R

func (b *BusHole) R(addr uint16) uint8

func (*BusHole) W

func (b *BusHole) W(addr uint16, val uint8)

type ButtonState

type ButtonState struct {
	Down         bool
	Up           bool
	Left         bool
	Right        bool
	Start        bool
	SelectButton bool
	B            bool
	A            bool
}

type ByteRegister

type ByteRegister int
const (
	B ByteRegister = iota
	C
	D
	E
	H
	L
	A
	HLind
	Imm
)

type CBROp

type CBROp int

type CPU

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

func NewCPU

func NewCPU() *CPU

func (*CPU) Pop

func (c *CPU) Pop(sys *Sys) uint16

func (*CPU) Push

func (c *CPU) Push(sys *Sys, v uint16)

func (*CPU) SetPostBootloaderState

func (c *CPU) SetPostBootloaderState(sys *Sys)

func (*CPU) State

func (c *CPU) State(sys *Sys) string

func (*CPU) Step

func (c *CPU) Step(sys *Sys) int

type CPUCond

type CPUCond int

type Interrupt

type Interrupt uint

type Joypad

type Joypad struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func NewJoypad

func NewJoypad() *Joypad

func (*Joypad) Asserts

func (j *Joypad) Asserts(addr uint16) bool

func (*Joypad) R

func (j *Joypad) R(_ uint16) uint8

func (*Joypad) UpdateButtons

func (j *Joypad) UpdateButtons(sys *Sys, state ButtonState)

func (*Joypad) W

func (j *Joypad) W(_ uint16, v uint8)

type LCDStatusRegister

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

func (*LCDStatusRegister) Asserts

func (l *LCDStatusRegister) Asserts(addr uint16) bool

func (*LCDStatusRegister) R

func (l *LCDStatusRegister) R(_ uint16) uint8

func (*LCDStatusRegister) W

func (l *LCDStatusRegister) W(addr uint16, v uint8)

type MemRegister

type MemRegister struct {
	RAM
}

func NewMemRegister

func NewMemRegister(addr uint16) *MemRegister

type NullSerialSwapper

type NullSerialSwapper struct {
}

Just acts like nothing is on the other side of the connection

func (*NullSerialSwapper) SerialSwap

func (n *NullSerialSwapper) SerialSwap(_ uint8) uint8

type OAMblock

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

type OAMblocksByReversePriority

type OAMblocksByReversePriority []OAMblock

func (OAMblocksByReversePriority) Len

func (OAMblocksByReversePriority) Less

func (a OAMblocksByReversePriority) Less(i, j int) bool

func (OAMblocksByReversePriority) Swap

func (a OAMblocksByReversePriority) Swap(i, j int)

type OpFunc

type OpFunc func(cpu *CPU, sys *Sys) int

func ADDS

func ADDS(sr ShortRegister) OpFunc

Add short

func ALU

func ALU(op ALUOp, br ByteRegister) OpFunc

func BIT

func BIT(n uint, br ByteRegister) OpFunc

func CALL

func CALL(con CPUCond) OpFunc

func CBR

func CBR(op CBROp, br ByteRegister) OpFunc

CB Rotates

func INCDECB

func INCDECB(br ByteRegister, mod int) OpFunc

Increment or decrement byte register

func INCDECS

func INCDECS(sr ShortRegister, mod int) OpFunc

Increment or decrement short register

func JP

func JP(con CPUCond) OpFunc

func JR

func JR(con CPUCond) OpFunc

func LDARegInd

func LDARegInd(br ShortRegister, mod int) OpFunc

Load A indirectly

func LDB

func LDB(destReg ByteRegister, srcReg ByteRegister) OpFunc

Load between byte registers

func LDBImm

func LDBImm(br ByteRegister) OpFunc

Load byte immediate

func LDBInd

func LDBInd(destReg ByteRegister, srcAddrReg ShortRegister, mod int) OpFunc

func LDH

func LDH(atoaddr bool) OpFunc

func LDHC

func LDHC(atoaddr bool) OpFunc

func LDHLBindir

func LDHLBindir(br ByteRegister) OpFunc

func LDSImm

func LDSImm(sr ShortRegister) OpFunc

Load short immediate

func LDSimmAddr

func LDSimmAddr(atoaddr bool) OpFunc

func POP

func POP(sr ShortRegister) OpFunc

func PUSH

func PUSH(sr ShortRegister) OpFunc

func RET

func RET(con CPUCond, enableInterrupts bool) OpFunc

func RST

func RST(addr uint16, fromInterrupt bool) OpFunc

func SETRES

func SETRES(set bool, n uint, br ByteRegister) OpFunc

func SWAP

func SWAP(br ByteRegister) OpFunc

type Pixel

type Pixel uint8

This value should only be from 0 to 3.

type RAM

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

func NewHiRAM

func NewHiRAM() *RAM

func NewRAM

func NewRAM(startAddr uint16, endAddr uint16) *RAM

func (*RAM) Asserts

func (r *RAM) Asserts(addr uint16) bool

func (*RAM) R

func (r *RAM) R(addr uint16) uint8

func (*RAM) W

func (r *RAM) W(addr uint16, val uint8)

type ROM

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

func LoadROM

func LoadROM(data []byte) (*ROM, error)

func LoadROMFromFile

func LoadROMFromFile(fn string) (*ROM, error)

func (*ROM) Asserts

func (r *ROM) Asserts(addr uint16) bool

func (*ROM) Dump

func (r *ROM) Dump()

func (*ROM) GlobalChecksum

func (r *ROM) GlobalChecksum() uint16

func (*ROM) HeaderChecksum

func (r *ROM) HeaderChecksum() byte

func (*ROM) Info

func (r *ROM) Info() string

func (*ROM) R

func (r *ROM) R(addr uint16) uint8

func (*ROM) W

func (r *ROM) W(addr uint16, val uint8)

type ReadOnlyRegister

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

func (*ReadOnlyRegister) Asserts

func (r *ReadOnlyRegister) Asserts(addr uint16) bool

func (*ReadOnlyRegister) R

func (r *ReadOnlyRegister) R(_ uint16) uint8

func (*ReadOnlyRegister) W

func (r *ReadOnlyRegister) W(_ uint16, _ uint8)

type Serial

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

func NewSerial

func NewSerial() *Serial

func (*Serial) Asserts

func (s *Serial) Asserts(addr uint16) bool

func (*Serial) R

func (s *Serial) R(addr uint16) uint8

func (*Serial) Step

func (s *Serial) Step(sys *Sys)

func (*Serial) W

func (s *Serial) W(addr uint16, val uint8)

type SerialSwapper

type SerialSwapper interface {
	SerialSwap(out uint8) uint8
}

type ShortRegister

type ShortRegister int
const (
	BC ShortRegister = iota
	DE
	HL
	SP
	AF
)

type SwapFunc

type SwapFunc func(pixels [LCDSizeX * LCDSizeY]Pixel)

type Sys

type Sys struct {
	Stop bool

	Wall int

	Debug bool
	// contains filtered or unexported fields
}

func NewSys

func NewSys(rom *ROM) *Sys

func (*Sys) FreqStep

func (s *Sys) FreqStep(desiredFreq uint) bool

* This only really works for values that divide evenly with the main clock, * but luckily those are all the values we need!

func (*Sys) HandleInterrupt

func (s *Sys) HandleInterrupt() *Interrupt

func (*Sys) IER

func (s *Sys) IER() uint8

func (*Sys) RaiseInterrupt

func (s *Sys) RaiseInterrupt(inter Interrupt)

func (*Sys) Rb

func (s *Sys) Rb(addr uint16) uint8

func (*Sys) RbLog

func (s *Sys) RbLog(addr uint16, l bool) uint8

func (*Sys) ReadBytes

func (s *Sys) ReadBytes(addr uint16, len uint16) []byte

func (*Sys) Rs

func (s *Sys) Rs(addr uint16) uint16

func (*Sys) RsLog

func (s *Sys) RsLog(addr uint16, l bool) uint16

func (*Sys) Run

func (s *Sys) Run()

func (*Sys) SetPostBootloaderState

func (s *Sys) SetPostBootloaderState()

func (*Sys) SetSerialSwapper

func (s *Sys) SetSerialSwapper(serialSwapper SerialSwapper)

func (*Sys) SetVideoSwapper

func (s *Sys) SetVideoSwapper(videoSwapper VideoSwapper)

func (*Sys) Step

func (s *Sys) Step()

Step four clock cycls.

func (*Sys) UpdateButtons

func (s *Sys) UpdateButtons(state ButtonState)

func (*Sys) Wb

func (s *Sys) Wb(addr uint16, val uint8)

func (*Sys) WbLog

func (s *Sys) WbLog(addr uint16, val uint8, l bool)

func (*Sys) WriteBytes

func (s *Sys) WriteBytes(bytes []byte, addr uint16)

func (*Sys) Ws

func (s *Sys) Ws(addr uint16, val uint16)

func (*Sys) WsLog

func (s *Sys) WsLog(addr uint16, val uint16, l bool)

type SystemRAM

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

* System RAM needs to assert specially in order to properly do the mirrioring * nonsense.

func NewSystemRAM

func NewSystemRAM() *SystemRAM

func (*SystemRAM) Asserts

func (sr *SystemRAM) Asserts(addr uint16) bool

func (*SystemRAM) R

func (sr *SystemRAM) R(addr uint16) uint8

func (*SystemRAM) W

func (sr *SystemRAM) W(addr uint16, val uint8)

type Timer

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

func NewTimer

func NewTimer() *Timer

func (*Timer) Asserts

func (t *Timer) Asserts(addr uint16) bool

func (*Timer) R

func (t *Timer) R(addr uint16) uint8

func (*Timer) State

func (t *Timer) State() string

func (*Timer) Step

func (t *Timer) Step(sys *Sys)

func (*Timer) W

func (t *Timer) W(addr uint16, val uint8)

type UpdateButtonser

type UpdateButtonser interface {
	UpdateButtons(state ButtonState)
}

type Video

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

func NewVideo

func NewVideo() *Video

func (*Video) Asserts

func (v *Video) Asserts(addr uint16) bool

func (*Video) R

func (v *Video) R(addr uint16) uint8

func (*Video) State

func (v *Video) State(sys *Sys) string

func (*Video) Step

func (v *Video) Step(sys *Sys)

func (*Video) W

func (v *Video) W(addr uint16, val uint8)

type VideoSwapper

type VideoSwapper interface {
	VideoSwap(pixels [LCDSizeX * LCDSizeY]Pixel)
}

type WriteOnlyRegister

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

func (*WriteOnlyRegister) Asserts

func (w *WriteOnlyRegister) Asserts(addr uint16) bool

func (*WriteOnlyRegister) R

func (w *WriteOnlyRegister) R(_ uint16) uint8

func (*WriteOnlyRegister) W

func (w *WriteOnlyRegister) W(_ uint16, val uint8)

Jump to

Keyboard shortcuts

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