chip8

package
v0.0.0-...-957b034 Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Fontset = [80]byte{
	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,
}

The CHIP-8 fontset.

Functions

This section is empty.

Types

type CPU

type CPU struct {
	PC uint16    // program counter
	V  [16]uint8 // registers
	I  uint16    // index register
	SP uint8     // stack pointer

	Memory     *Memory     // memory
	DelayTimer uint8       // delay timer
	SoundTimer uint8       // sound timer
	Display    *image.RGBA // display
	Draw       bool        // draw flag
	Keys       Keys        // input state
	// contains filtered or unexported fields
}

func NewCPU

func NewCPU(memory *Memory) *CPU

func (*CPU) ClearDisplay

func (cpu *CPU) ClearDisplay()

func (*CPU) Execute

func (cpu *CPU) Execute()

func (*CPU) UpdateDelayTimer

func (cpu *CPU) UpdateDelayTimer()

func (*CPU) UpdateSoundTimer

func (cpu *CPU) UpdateSoundTimer()

func (*CPU) UpdateTimers

func (cpu *CPU) UpdateTimers()

Update the timers. This must be called at 60 Hz

type Keys

type Keys [16]bool

func (*Keys) IsPressed

func (keys *Keys) IsPressed(key uint8) bool

Check if a key is currently pressed.

func (*Keys) Press

func (keys *Keys) Press(key uint8)

Set a key to pressed state.

func (*Keys) Release

func (keys *Keys) Release(key uint8)

Set a key to released state.

type Memory

type Memory struct {
	RAM []byte
}

func NewMemory

func NewMemory() *Memory

func (*Memory) LoadROM

func (m *Memory) LoadROM(rom []byte)

Load a game ROM in the appropriate memory location.

func (*Memory) ReadShort

func (m *Memory) ReadShort(address uint16) uint16

Read a big-endian 16-bit value from the given address

Jump to

Keyboard shortcuts

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