Documentation ¶
Index ¶
- Constants
- Variables
- func DisplayToWindow(x int, y int, width int, height int) (int, int)
- func InitScreen(screen tcell.Screen)
- type Cpu
- func (cpu *Cpu) DrawScreen(screen tcell.Screen)
- func (cpu *Cpu) Handle00Opcodes() error
- func (cpu *Cpu) Handle1NNNOpcode() error
- func (cpu *Cpu) Handle2NNNOpcode() error
- func (cpu *Cpu) Handle3XNNOpcode() error
- func (cpu *Cpu) Handle4XNNOpcode() error
- func (cpu *Cpu) Handle5XY0Opcode() error
- func (cpu *Cpu) Handle6XNNOpcode() error
- func (cpu *Cpu) Handle7xNNOpcode() error
- func (cpu *Cpu) Handle8XYOpcodes() error
- func (cpu *Cpu) Handle9XY0Opcode() error
- func (cpu *Cpu) HandleANNNOpcode() error
- func (cpu *Cpu) HandleBNNNOpcode() error
- func (cpu *Cpu) HandleCXNNOpcode(seed int64) error
- func (cpu *Cpu) HandleDXYNOpcode() error
- func (cpu *Cpu) HandleEXOpcodes() error
- func (cpu *Cpu) HandleFXOpcodes() error
- func (cpu *Cpu) HandleOpcode() error
- func (cpu *Cpu) LoadProgram(path string) error
- func (cpu *Cpu) PrintScreen()
- func (cpu *Cpu) Update() error
- func (cpu *Cpu) UpdateKeys(screen tcell.Screen) bool
Constants ¶
View Source
const FREQUENCY = 60
View Source
const KEYPAD_SIZE = 16
View Source
const MEMORY_SIZE = 4096
View Source
const NUM_COLS = 64
View Source
const NUM_REGISTERS = 16
View Source
const NUM_ROWS = 32
View Source
const PC_START = 0x200
View Source
const STACK_SIZE = 16
Variables ¶
View Source
var Fontset = [...]uint8{
0xF0, 0x90, 0x90, 0x90, 0xF0,
0x20, 0x60, 0x20, 0x20, 0x70,
0xF0, 0x10, 0xF0, 0x80, 0xF0,
0xF0, 0x10, 0xF0, 0x10, 0xF0,
0x90, 0x90, 0xF0, 0x10, 0x10,
0xF0, 0x80, 0xF0, 0x10, 0xF0,
0xF0, 0x80, 0xF0, 0x90, 0xF0,
0xF0, 0x10, 0x20, 0x40, 0x40,
0xF0, 0x90, 0xF0, 0x90, 0xF0,
0xF0, 0x90, 0xF0, 0x10, 0xF0,
0xF0, 0x90, 0xF0, 0x90, 0x90,
0xE0, 0x90, 0xE0, 0x90, 0xE0,
0xF0, 0x80, 0x80, 0x80, 0xF0,
0xE0, 0x90, 0x90, 0x90, 0xE0,
0xF0, 0x80, 0xF0, 0x80, 0xF0,
0xF0, 0x80, 0xF0, 0x80, 0x80,
}
View Source
var Keypad = [...]uint8{
'1', '2', '3', '4',
'q', 'w', 'e', 'r',
'a', 's', 'd', 'f',
'z', 'x', 'c', 'v',
}
Functions ¶
func InitScreen ¶
Types ¶
type Cpu ¶
type Cpu struct { Opcode uint16 Memory [MEMORY_SIZE]uint8 Stack [STACK_SIZE]uint16 V [NUM_REGISTERS]uint8 //main registers (V0 -> VF) I uint16 //index register PC uint16 //program counter SP uint16 //stack pointer DelayTimer uint8 SoundTimer uint8 Display [NUM_COLS * NUM_ROWS]uint8 Keypad [KEYPAD_SIZE]uint8 ShouldDraw bool TimeController <-chan time.Time }
func (*Cpu) DrawScreen ¶
func (*Cpu) Handle00Opcodes ¶
func (*Cpu) Handle2NNNOpcode ¶
call function (jump-and-link) at address NNN
func (*Cpu) Handle3XNNOpcode ¶
Skip next instruction if V[X] == NN
func (*Cpu) Handle4XNNOpcode ¶
Skip next instruction if V[X] != NN
func (*Cpu) Handle5XY0Opcode ¶
Skip next instruction if V[X] == V[Y]
func (*Cpu) Handle8XYOpcodes ¶
func (*Cpu) Handle9XY0Opcode ¶
Skip next instruction if V[X] != V[Y]
func (*Cpu) HandleCXNNOpcode ¶
V[x] = rand() & NN
func (*Cpu) HandleDXYNOpcode ¶
func (*Cpu) HandleEXOpcodes ¶
func (*Cpu) HandleFXOpcodes ¶
func (*Cpu) HandleOpcode ¶
func (*Cpu) LoadProgram ¶
func (*Cpu) PrintScreen ¶
func (cpu *Cpu) PrintScreen()
Click to show internal directories.
Click to hide internal directories.