Documentation ¶
Index ¶
- Constants
- type ConfigCpu
- type ConfigDisplay
- type ConfigKeyboard
- type ConfigMemory
- type Cpu
- type Display
- type Instruction
- func (instr *Instruction) GetN() (byte, error)
- func (instr *Instruction) GetNN() (byte, error)
- func (instr *Instruction) GetNNN() (uint16, error)
- func (instr *Instruction) GetTypeAndSubType() (t InstructionType, s InstructionSubType, err error)
- func (instr *Instruction) GetX() (byte, error)
- func (instr *Instruction) GetY() (byte, error)
- type InstructionSubType
- type InstructionType
- type Key
- type Keyboard
- type Memory
- type Register
- type Sound
- type Stack
- type StandardDisplay
- type StandardKeyboard
- type StandardMemory
- func (sm *StandardMemory) Load(register []byte, i uint16)
- func (sm *StandardMemory) LoadChar(vx byte) uint16
- func (sm *StandardMemory) LoadInstruction(pc uint16) Instruction
- func (sm *StandardMemory) LoadSprite(i uint16) byte
- func (sm *StandardMemory) Log()
- func (sm *StandardMemory) Save(register []byte, i uint16)
- func (sm *StandardMemory) SaveBCD(vx byte, i uint16)
Constants ¶
const Black = "■"
const White = "□"
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ConfigDisplay ¶
type ConfigKeyboard ¶
type Cpu ¶
type Cpu struct {
// contains filtered or unexported fields
}
func (*Cpu) NextInstruction ¶
func (*Cpu) Process ¶
func (c *Cpu) Process(instr Instruction) error
Process is a function that process a instruction
type Instruction ¶
type Instruction []byte
func (*Instruction) GetN ¶
func (instr *Instruction) GetN() (byte, error)
GetN returns the parameter N of instruction
func (*Instruction) GetNN ¶
func (instr *Instruction) GetNN() (byte, error)
GetNN returns the parameter NN of instruction
func (*Instruction) GetNNN ¶
func (instr *Instruction) GetNNN() (uint16, error)
GetNNN returns the parameter NNN of instruction
func (*Instruction) GetTypeAndSubType ¶
func (instr *Instruction) GetTypeAndSubType() (t InstructionType, s InstructionSubType, err error)
func (*Instruction) GetX ¶
func (instr *Instruction) GetX() (byte, error)
GetX returns the parameter X of instruction
func (*Instruction) GetY ¶
func (instr *Instruction) GetY() (byte, error)
GetY returns the parameter Y of instruction
type InstructionSubType ¶
type InstructionSubType byte
type InstructionType ¶
type InstructionType byte
type Keyboard ¶
type Keyboard interface { /* KeyDown should return a Key mapping the input to any key of CHIP-8 (0x00 - 0x0F). When none key is down return Key(0xFF) */ KeyDown() Key }
type Memory ¶
type Memory interface { /* Save should saves the register on the memory starting from I on memory */ Save(register []byte, i uint16) /* SaveBCD should convert vx to decimal and saves each decimal on addresses I, I+1, I+2 */ SaveBCD(vx byte, i uint16) /* Load should loads the register on the memory starting from I on memory */ Load(register []byte, i uint16) /* LoadInstruction should loads the instruction (2 bytes) of program */ LoadInstruction(pc uint16) Instruction /* LoadChar should return the address of char referring to vx */ LoadChar(vx byte) uint16 /* LoadSprite should return the Sprite on I */ LoadSprite(i uint16) byte }
type StandardDisplay ¶
type StandardDisplay struct {
// contains filtered or unexported fields
}
StandardDisplay implements interface Display
func NewStandardDisplay ¶
func NewStandardDisplay(config *ConfigDisplay) *StandardDisplay
NewStandardDisplay is a function that receive a config as param and return a pointer to StandardDisplay
func (*StandardDisplay) Draw ¶
func (sd *StandardDisplay) Draw(xDisplay, yDisplay, sprite byte) bool
Draw draws a sprint on position xDisplay and yDisplay
func (*StandardDisplay) Flush ¶
func (sd *StandardDisplay) Flush()
Flush is a function that paint the screen with information of attribute "screen"
type StandardKeyboard ¶
type StandardKeyboard struct {
// contains filtered or unexported fields
}
StandardKeyboard implements KeyBoard It's just useful for example "terminal.go"
func NewStandardKeyboard ¶
func NewStandardKeyboard(config *ConfigKeyboard) *StandardKeyboard
NewStandardKeyboard is a function that receive a config as param and return a pointer to StandardKeyboard
func (*StandardKeyboard) KeyDown ¶
func (sk *StandardKeyboard) KeyDown() Key
KeyDown check the input and translate to CHIP-8
type StandardMemory ¶
type StandardMemory struct {
// contains filtered or unexported fields
}
StandardMemory implements interface Memory
func NewStandardMemory ¶
func NewStandardMemory(config *ConfigMemory) *StandardMemory
NewStandardMemory is a function that receive a config as param and return a pointer to StandardMemory
func (*StandardMemory) Load ¶
func (sm *StandardMemory) Load(register []byte, i uint16)
Load loads to the register from of memory starting on register I
func (*StandardMemory) LoadChar ¶
func (sm *StandardMemory) LoadChar(vx byte) uint16
LoadChar returns the address to char VX
func (*StandardMemory) LoadInstruction ¶
func (sm *StandardMemory) LoadInstruction(pc uint16) Instruction
LoadInstruction returns the instruction addressed by register PC
func (*StandardMemory) LoadSprite ¶
func (sm *StandardMemory) LoadSprite(i uint16) byte
LoadSprit returns the sprite on position I
func (*StandardMemory) Log ¶
func (sm *StandardMemory) Log()
Log writes values of memory to "log" of Memory
func (*StandardMemory) Save ¶
func (sm *StandardMemory) Save(register []byte, i uint16)
Save saves the registers on memory starting on register I
func (*StandardMemory) SaveBCD ¶
func (sm *StandardMemory) SaveBCD(vx byte, i uint16)
SaveBCD convert vx byte to decimal and save each digit on I, I+1 and I+2