Documentation
¶
Index ¶
Constants ¶
View Source
const DEFAULT_CLOCK_SPEED = 16 * time.Millisecond // 60hz
View Source
const DEFAULT_IPF = 1200 // Instructions per frame
View Source
const DISPLAY_HEIGHT = 32
View Source
const DISPLAY_SIZE = DISPLAY_WIDTH * DISPLAY_HEIGHT
View Source
const DISPLAY_WIDTH = 64
View Source
const FONT_START = 0x50
View Source
const FRAME_BUFFER_LENGTH = 3
View Source
const MEM_SIZE = 4 * 1024 // 4kb
View Source
const ROM_START = uint16(0x200)
Variables ¶
View Source
var ErrInvalidOpcode = fmt.Errorf("invalid opcode")
View Source
var FONT = [5 * 16]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,
}
View Source
var Keybinds = []pixel.Button{ pixel.KeyX, pixel.Key1, pixel.Key2, pixel.Key3, pixel.KeyQ, pixel.KeyW, pixel.KeyE, pixel.KeyA, pixel.KeyS, pixel.KeyD, pixel.KeyZ, pixel.KeyC, pixel.Key4, pixel.KeyR, pixel.KeyF, pixel.KeyV, }
TODO: make this configurable
Functions ¶
This section is empty.
Types ¶
type Emulator ¶
type Emulator interface {
Keypad
// LoadFile loads a ROM file from disk into emulator memory.
LoadFile(path string) error
// LoadBuffer loads a ROM file from a buffer into emulator memory.
LoadBuffer(buf io.Reader) error
// Cycle runs one CPU cycle.
Cycle() error
// Run runs the emulator in the background. Call Stop() to end it.
Run()
// Stop stops the background emulation process.
Stop()
// Frame returns the most recent frame from the display buffer
Frame() *image.RGBA
}
func NewEmulator ¶
NewEmulator takes a path to a ROM file and returns an Emulator with that ROM loaded.
Click to show internal directories.
Click to hide internal directories.