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 ¶
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.
func SystemFromName ¶
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.