Expand description
SNES cheat-code decoding: Game Genie and Pro Action Replay (v0.8.0 "Instrumentation",
T-81-003).
Ported from bsnes’s CheatEditor::decodeSNES (ref-proj/bsnes/bsnes/target-bsnes/tools/ cheat-editor.cpp) and cross-checked bit-for-bit against Mesen2’s independent
CheatManager::ConvertFromSnesGameGenie/ConvertFromSnesProActionReplay
(ref-proj/Mesen2/Core/Shared/CheatManager.cpp) — both codebases compute an identical 24-bit
address and value byte for any given code string. Test vectors below are real commercial
codes drawn from Mesen2’s shipped cheat database (ref-proj/Mesen2/UI/Dependencies/Internal/ CheatDb.Snes.json), 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§
- Cheat
Patch - A decoded cheat patch: substitute
valueat CPU-busaddress($bank:offset, 24-bit).
Enums§
- Cheat
Error - Error decoding a cheat-code string.
Functions§
- decode
- Decode
codeas a Game Genie code, falling back to Pro Action Replay only whencodedoesn’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).