cheats

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2026 License: GPL-3.0 Imports: 5 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package cheats decodes cheat code strings, such as Action Replay codes, into memory operations. It depends only on the standard library and has no knowledge of the application using it.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cheat

type Cheat struct {
	Name string
	// Code is the code string as written, for display.
	Code string
	// ID identifies the cheat independent of its name and position: the
	// normalized code string.
	ID  string
	Ops []Op
}

Cheat is one decoded cheat.

func ParseCode

func ParseCode(code string, sys System, coreBigEndian bool) (Cheat, error)

ParseCode parses one cheat's code string, such as Action Replay codes separated by "+", spaces, or new lines. sys selects the decoders. coreBigEndian is the byte order of the core's memory; the ops are converted to it. The returned cheat has Code and ID set and no name. When the code cannot be applied, the error gives the reason.

type Op

type Op struct {
	Kind  OpKind
	Space Space
	Addr  uint32
	Size  int // value width in bytes: 1, 2, or 4
	// Mask selects the bits a 1-byte op reads and writes. It is 0xFF for
	// whole bytes and for wider values.
	Mask      uint8
	Value     uint32
	BigEndian bool // byte order of 2 and 4 byte values
}

Op is one decoded memory operation.

type OpKind

type OpKind int

OpKind is what an operation does. A compare kind gates the op after it in the same cheat. Only OpSet and OpIfEqual are produced by a decoder today; the engine applies every kind.

const (
	OpSet        OpKind = iota // write Value
	OpAdd                      // add Value to the current value
	OpSub                      // subtract Value from the current value
	OpIfEqual                  // run the next op only if current == Value
	OpIfNotEqual               // run the next op only if current != Value
	OpIfGreater                // run the next op only if current > Value
	OpIfLess                   // run the next op only if current < Value
)

type Space

type Space int

Space is the address space of an operation's address.

const (
	// SpaceBus addresses are native bus addresses of the system. Code
	// string cheats, such as Action Replay codes, use this space.
	SpaceBus Space = iota
	// SpaceFlat addresses are offsets into the system's flat memory
	// layout. No decoder produces this space today; the engine applies it.
	SpaceFlat
)

type System

type System int

System is a game system whose cheat code formats are known. The zero value is not a valid system.

const (
	SystemSaturn System = iota + 1
)

func SystemFromName

func SystemFromName(name string) (System, error)

SystemFromName returns the system for a name, compared without case, such as "saturn" or "Sega Saturn". It returns an error for names of systems without cheat support.

Jump to

Keyboard shortcuts

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