Skip to main content

Module cheat

Module cheat 

Source
Expand description

SNES cheat-code decoding: Game Genie and Pro Action Replay (v0.8.0 "Instrumentation", T-81-003).

Both code formats are publicly documented data formats, and are implemented here from that documentation. Pro Action Replay is plain AAAAAADD hex (fullsnes, “SNES Cart Cheat Devices - Code Formats”). Game Genie applies a 16-symbol hex-digit substitution followed by a fixed bit transposition, published since the 1990s in the Game Genie code-format notes that circulated on Usenet and are catalogued today by gamehacking.org’s “Game Genie Encryption Schemes”. A code format is a fact about the device, not an expression owned by any emulator that also reads it.

Cross-checked against bsnes and Mesen2 as behavioural oracles — both compute the same 24-bit address and value byte for a given code string, which is the agreement any correct implementation of a documented format produces. No third-party emulator code is incorporated. Test vectors below are real commercial codes with widely published decodings, each decoded independently by hand against the bit formula as a third check.

Both formats decode to a plain 24-bit CPU-bus address ($bank:offset) plus an 8-bit substitute value — no LoROM/HiROM bank translation happens here (that is the Bus’s normal memory-map job, same as crate::Bus::poke_wram/crate::Bus::peek_wram). Neither SNES format supports a compare byte (unlike NES’s 8-character Game Genie) — a decoded cheat is always an unconditional address/value substitution.

A cheat is host-applied external input, not emulated hardware behavior (docs/adr/0004) — it is not part of any save state and is not evaluated unless the frontend’s cheats feature is on and a patch is actually applied, so the determinism contract is untouched when no cheat is active.

Structs§

CheatPatch
A decoded cheat patch: substitute value at CPU-bus address ($bank:offset, 24-bit).

Enums§

CheatError
Error decoding a cheat-code string.

Functions§

decode
Decode code as a Game Genie code, falling back to Pro Action Replay only when code doesn’t match the Game Genie shape at all.
decode_game_genie
Decode a Game Genie code: XXXX-XXXX (case-insensitive, a dash at index 4, 9 characters total).
decode_pro_action_replay
Decode a Pro Action Replay code: 8 hex digits (case-insensitive), no scrambling — AAAAAADD (6 hex-digit address, high; 2 hex-digit value, low).