chip8

package
v0.0.0-...-20f391c Latest Latest
Warning

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

Go to latest
Published: May 27, 2019 License: MIT Imports: 7 Imported by: 1

Documentation

Index

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 DisplayToWindow

func DisplayToWindow(x int, y int, width int, height int) (int, int)

func InitScreen

func InitScreen(screen tcell.Screen)

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 CreateCpu

func CreateCpu() Cpu

func (*Cpu) DrawScreen

func (cpu *Cpu) DrawScreen(screen tcell.Screen)

func (*Cpu) Handle00Opcodes

func (cpu *Cpu) Handle00Opcodes() error

func (*Cpu) Handle1NNNOpcode

func (cpu *Cpu) Handle1NNNOpcode() error

jump to address NNN

func (*Cpu) Handle2NNNOpcode

func (cpu *Cpu) Handle2NNNOpcode() error

call function (jump-and-link) at address NNN

func (*Cpu) Handle3XNNOpcode

func (cpu *Cpu) Handle3XNNOpcode() error

Skip next instruction if V[X] == NN

func (*Cpu) Handle4XNNOpcode

func (cpu *Cpu) Handle4XNNOpcode() error

Skip next instruction if V[X] != NN

func (*Cpu) Handle5XY0Opcode

func (cpu *Cpu) Handle5XY0Opcode() error

Skip next instruction if V[X] == V[Y]

func (*Cpu) Handle6XNNOpcode

func (cpu *Cpu) Handle6XNNOpcode() error

V[X] = NN

func (*Cpu) Handle7xNNOpcode

func (cpu *Cpu) Handle7xNNOpcode() error

V[X] += NN

func (*Cpu) Handle8XYOpcodes

func (cpu *Cpu) Handle8XYOpcodes() error

func (*Cpu) Handle9XY0Opcode

func (cpu *Cpu) Handle9XY0Opcode() error

Skip next instruction if V[X] != V[Y]

func (*Cpu) HandleANNNOpcode

func (cpu *Cpu) HandleANNNOpcode() error

I = NNN

func (*Cpu) HandleBNNNOpcode

func (cpu *Cpu) HandleBNNNOpcode() error

PC = V[0] + NNN

func (*Cpu) HandleCXNNOpcode

func (cpu *Cpu) HandleCXNNOpcode(seed int64) error

V[x] = rand() & NN

func (*Cpu) HandleDXYNOpcode

func (cpu *Cpu) HandleDXYNOpcode() error

func (*Cpu) HandleEXOpcodes

func (cpu *Cpu) HandleEXOpcodes() error

func (*Cpu) HandleFXOpcodes

func (cpu *Cpu) HandleFXOpcodes() error

func (*Cpu) HandleOpcode

func (cpu *Cpu) HandleOpcode() error

func (*Cpu) LoadProgram

func (cpu *Cpu) LoadProgram(path string) error

func (*Cpu) PrintScreen

func (cpu *Cpu) PrintScreen()

func (*Cpu) Update

func (cpu *Cpu) Update() error

func (*Cpu) UpdateKeys

func (cpu *Cpu) UpdateKeys(screen tcell.Screen) bool

Jump to

Keyboard shortcuts

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