Documentation
¶
Index ¶
- Constants
- func ColorEq(c1, c2 color.Color) bool
- func DumpEmu(emu *Emulator)
- func Each(d Display, fn func(int, int) error) error
- func NewRAM(size int) ([]byte, error)
- func ToAddr3(p []int) (uint16, error)
- func ToByte(p []int) (byte, error)
- type ArgCountError
- type DebugDisplay
- func (d *DebugDisplay) At(x, y int) color.Color
- func (d *DebugDisplay) Bounds() image.Rectangle
- func (d *DebugDisplay) ColorClear() color.Color
- func (d *DebugDisplay) ColorModel() color.Model
- func (d *DebugDisplay) ColorSet() color.Color
- func (d *DebugDisplay) Set(x, y int, c color.Color)
- func (d *DebugDisplay) String() string
- type Direction
- type Display
- type Emulator
- type Instruction
- type InstructionNotImplementedError
- type KeyInputSource
- type Opcode
- type Stack
- type StubKeyInputSource
Constants ¶
View Source
const ( ColorClear = iota ColorSet )
View Source
const ( ProgramCounterSize = 2 // Size in bytes. RegisterCount = 16 // V0-VF. StartAddress = 0x200 // starting address of PC. NumKeys = 16 InstructionSize = 2 // each instruction is 2 bytes wide. )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ArgCountError ¶
type ArgCountError struct {
// contains filtered or unexported fields
}
func (ArgCountError) Error ¶
func (e ArgCountError) Error() string
type DebugDisplay ¶
type DebugDisplay struct {
// contains filtered or unexported fields
}
func NewDebugDisplay ¶
func NewDebugDisplay(w, h int) (*DebugDisplay, error)
func (*DebugDisplay) Bounds ¶
func (d *DebugDisplay) Bounds() image.Rectangle
func (*DebugDisplay) ColorClear ¶
func (d *DebugDisplay) ColorClear() color.Color
func (*DebugDisplay) ColorModel ¶
func (d *DebugDisplay) ColorModel() color.Model
func (*DebugDisplay) ColorSet ¶
func (d *DebugDisplay) ColorSet() color.Color
func (*DebugDisplay) String ¶
func (d *DebugDisplay) String() string
type Emulator ¶
type Emulator struct {
PC uint16
V [RegisterCount]byte
DelayTimer byte
SoundTimer byte
Index uint16
Keys KeyInputSource
Stack *Stack
RAM []byte
Display Display
LastInstruction Instruction
// contains filtered or unexported fields
}
func NewEmulator ¶
func NewEmulator(stackSize, ramSize int, display Display, keys KeyInputSource) (*Emulator, error)
func (*Emulator) Execute ¶
func (emu *Emulator) Execute(instr Instruction) error
func (*Emulator) Fetch ¶
Fetch will read the instruction pointed at by the PC. It will do a bounds check.
type Instruction ¶
func Decode ¶
func Decode(p []byte) (Instruction, error)
func (Instruction) String ¶
func (instr Instruction) String() string
type InstructionNotImplementedError ¶
type InstructionNotImplementedError struct {
// contains filtered or unexported fields
}
func (InstructionNotImplementedError) Error ¶
func (e InstructionNotImplementedError) Error() string
type KeyInputSource ¶
type Opcode ¶
type Opcode string
const ( Unknown Opcode = "Unknown" Nop Opcode = "Nop" ExecNNN Opcode = "ExecNNN" Clear Opcode = "Clear" ReturnFromSub Opcode = "ReturnFromSub" JumpNNN Opcode = "JumpNNN" CallSub Opcode = "CallSub" SkipIfXEqNN Opcode = "SkipIfXEqNN" SkipIfXNotEqNN Opcode = "SkipIfXNotEqNN" SkipIfXEqY Opcode = "SkipIfXEqY" StoreNNInX Opcode = "StoreNNInX" AddNNToX Opcode = "AddNNToX" StoreYinX Opcode = "StoreYinX" SetXToXORY Opcode = "SetXToXORY" SetXToXANDY Opcode = "SetXToXANDY" SetXToXXORY Opcode = "SetXToXXORY" AddYToX Opcode = "AddYToX" SubYFromX Opcode = "SubYFromX" StoreYShiftedRightInX Opcode = "StoreYShiftedRightInX" SetXToYMinusX Opcode = "SetXToYMinusX" StoreYShiftedLeftInX Opcode = "StoreYShiftedLeftInX" SkipIfXNotEqY Opcode = "SkipIfXNotEqY" StoreMemAddrNNNInRegI Opcode = "StoreMemAddrNNNInRegI" JumpToAddrNNNPlusV0 Opcode = "JumpToAddrNNNPlusV0" SetXToRandomNumWithMaskNN Opcode = "SetXToRandomNumWithMaskNN" DrawSpriteInXY Opcode = "DrawSpriteInXY" SkipIfKeyInXIsPressed Opcode = "SkipIfKeyInXIsPressed" SkipIfKeyInXNotPressed Opcode = "SkipIfKeyInXNotPressed" StoreValDTInX Opcode = "StoreValDTInX" WaitForKeyAndStoreInX Opcode = "WaitForKeyAndStoreInX" SetDTToX Opcode = "SetDTToX" SetSTToX Opcode = "SetSTToX" AddXToI Opcode = "AddXToI" SetIToMemAddrOfSpriteInX Opcode = "SetIToMemAddrOfSpriteInX" StoreBCDOfXInI Opcode = "StoreBCDOfXInI" Store0ToXInI Opcode = "Store0ToXInI" Fill0ToXWithValueInAddrI Opcode = "Fill0ToXWithValueInAddrI" )
func DetermineOpcode ¶
DetermineOpcode will return the appropriate Opcode given the digits passed in. It expects digits to have length 4.
type Stack ¶
type Stack struct {
// contains filtered or unexported fields
}
Stack is LIFO data structure, it provides a Push/Pop API. @TODO: consider adding support for ShiftLeft and ShiftRight.
type StubKeyInputSource ¶
type StubKeyInputSource struct{}
func (*StubKeyInputSource) Get ¶
func (stub *StubKeyInputSource) Get(_ int) bool
func (*StubKeyInputSource) Set ¶
func (stub *StubKeyInputSource) Set(_ int, _ bool)
func (*StubKeyInputSource) WaitUntilKeypress ¶
func (stub *StubKeyInputSource) WaitUntilKeypress() <-chan int
Source Files
¶
Click to show internal directories.
Click to hide internal directories.