chip8

package module
v0.0.0-...-ecac4c3 Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2018 License: MIT Imports: 7 Imported by: 0

README

chip8

MIT license Go Report Card GoDoc

chip8 is a graphics library independent implementation of the CHIP-8 virtual machine.

An example is included in cmd/chip8 using the SDL2 library.

Install Library

$ go get -u github.com/wilmerpaulino/chip8

Import Library

import "github.com/wilmerpaulino/chip8"

Install SDL2 CHIP-8 Implementation

First, you'll need to install the SDL2 library. You can do so here.

It may also be available in your operating system's package manager. For example, on macOS:

$ brew install sdl2

Once SDL2 is installed, you can install the CHIP-8 emulator to your $GOPATH. Make sure it is set beforehand.

$ go get -u github.com/wilmerpaulino/chip8/cmd/chip8

Run SDL2 CHIP-8 Implementation

Once installed, it can be run directly from your $GOPATH:

$ $GOPATH/bin/chip8 -rom $GOPATH/src/wilmerpaulino/chip8/roms/PONG2

License

This project is distributed under the MIT license.

Documentation

Index

Constants

View Source
const (
	// DisplayWidth is the width of the display in pixels.
	DisplayWidth = 64

	// DisplayHeight is the height of the display in pixels.
	DisplayHeight = 32
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Display

Display represents the display of the CHIP-8 virtual machine.

type Renderer

type Renderer interface {
	// Render renders the display.
	Render(display Display) error

	// Beep makes an audible beep.
	Beep() error
}

Renderer represents the abstract renderer for the CHIP-8 virtual machine.

type VirtualMachine

type VirtualMachine struct {
	// contains filtered or unexported fields
}

VirtualMachine emulates the CHIP-8 virtual machine.

func New

func New(r Renderer) *VirtualMachine

New creates a new CHIP-8 virtual machine.

func (*VirtualMachine) LoadROM

func (vm *VirtualMachine) LoadROM(rom []byte) error

LoadROM loads the ROM's data, in bytes, into the virtual machine's memory.

func (*VirtualMachine) PressKey

func (vm *VirtualMachine) PressKey(idx int)

PressKey signals the virtual machine that the key was pressed.

func (*VirtualMachine) ReleaseKey

func (vm *VirtualMachine) ReleaseKey(idx int)

ReleaseKey signals the virtual machine that the key was released.

func (*VirtualMachine) Reset

func (vm *VirtualMachine) Reset()

Reset resets the virtual machine to its initial state.

func (*VirtualMachine) Start

func (vm *VirtualMachine) Start()

Start starts executing the virtual machine.

func (*VirtualMachine) Stop

func (vm *VirtualMachine) Stop()

Stop stops executing the virtual machine.

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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