interpreter

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// The display parameters for original CHIP-8
	DisplayWidth  = 64
	DisplayHeight = 32
)

Variables

View Source
var (
	Base    = Color{25, 23, 36}
	Surface = Color{31, 29, 46}
	Overlay = Color{38, 35, 58}
	Muted   = Color{110, 106, 134}
	Subtle  = Color{144, 140, 170}
	Text    = Color{224, 222, 244}
	Love    = Color{235, 111, 146}
	Gold    = Color{246, 193, 119}
	Rose    = Color{235, 188, 186}
	Pine    = Color{49, 116, 143}
	Foam    = Color{156, 207, 216}
	Iris    = Color{196, 167, 231}
)
View Source
var (
	SupportedModes = []string{
		"CHIP-8 (default)",
		"COSMAC-VIP",
	}
)

Functions

This section is empty.

Types

type CHIP8

type CHIP8 struct {

	// Index register, holding addresses in memory.
	I uint16

	// CPU registers.
	V [16]byte

	// Tweakable settings to use when running the interpreter
	Options CHIP8Options

	// Logger object to use
	Logger *log.Logger
	// contains filtered or unexported fields
}

func NewCHIP8

func NewCHIP8(program *[]byte) *CHIP8

NewDefaultApp creates a new App with default options.

func (*CHIP8) Draw

func (app *CHIP8) Draw(screen *ebiten.Image)

func (*CHIP8) Layout

func (app *CHIP8) Layout(outsideWidth, outsideHeight int) (screenWidth, screenHeight int)

func (*CHIP8) Update

func (app *CHIP8) Update() error

type CHIP8Options

type CHIP8Options struct {
	// So it can be seen on modern displays
	DisplayScaleFactor int `mapstructure:"display_scale_factor"`
	// Max cycle speed of CHIP-8 exec loop
	ThrottleSpeed int `mapstructure:"throttle_speed"`
	// Limit how many instruction_limits the program is run for. For debug purposes.
	InstructionLimit int `mapstructure:"instruction_limit"`
	// Enable quirks for COSMAC-like behavior
	CosmacQuirks COSMACQuirks `mapstructure:"cosmac-vip"`
}

func DefaultCHIP8Options

func DefaultCHIP8Options() CHIP8Options

type COSMACQuirks

type COSMACQuirks struct {
	// reset VF to 0 during instructions 8XY1, 8XY2, 8XY3
	ResetVF bool `mapstructure:"reset_vf"`
	// increment memory index I during FX55 and FX65
	IncrementI bool `mapstructure:"increment_i"`
}

func (*COSMACQuirks) EnableAll

func (cq *COSMACQuirks) EnableAll()

type Color

type Color struct {
	R, G, B uint8
}

func (Color) RGBA

func (c Color) RGBA() color.RGBA

type Display

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

type Instruction

type Instruction uint16

Instruction represents a 16-bit instruction

type Stack

type Stack []uint16

func (*Stack) Pop

func (s *Stack) Pop() (uint16, error)

func (*Stack) Push

func (s *Stack) Push(v uint16)

Function to manage the stack.

Jump to

Keyboard shortcuts

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