Cheat databases
Third-party GameShark / Pro-Action-Replay cheat code dumps for Legend of Legaia (NTSC-U) are an unusually rich source of ground-truth RAM addresses. This page documents the encoding, the parser, the citation table, and the runtime applier wired into legaia-engine play-window --cheat-file.
Data files
The corpus lives at data/cheats/ in the repo:
legaia-ntsc-u.gs.txt- GameShark text dump format (one effect per line).legaia-ntsc-u.cht- Mednafen.chtformat (TOML-shaped triples; multi-write effects join codes with+).
Both files describe the same effects in different on-disk encodings; round-trip between them is part of the test suite.
GameShark code prefix table
The high byte of the address is the operation prefix:
| Prefix | Operation | Example |
|---|---|---|
0x80 | u16 LE write | 80084816 0064 → mem16[0x80084816] = 0x0064 |
0x30 | u8 write | 300848A3 0000 → mem8[0x800848A3] = 0x00 |
0xD0 | conditional: if mem16 == value, execute next | D007B7C0 0100 (Select pressed) |
0xE0 | conditional: if mem16 != value, execute next | E007B83C 0003 |
Parser + classifier
The crates/cheats crate exposes parse_gs_text, parse_mednafen_cht, and classify_address. The companion cheat-tool CLI:
cargo run -p legaia-cheats --bin cheat-tool -- parse data/cheats/legaia-ntsc-u.cht
cargo run -p legaia-cheats --bin cheat-tool -- classify data/cheats/legaia-ntsc-u.gs.txt --dedupe
cargo run -p legaia-cheats --bin cheat-tool -- diff data/cheats/legaia-ntsc-u.gs.txt data/cheats/legaia-ntsc-u.cht
cargo run -p legaia-cheats --bin cheat-tool -- extract-offsets data/cheats/legaia-ntsc-u.cht
cargo run -p legaia-cheats --bin cheat-tool -- offset-table data/cheats/legaia-ntsc-u.cht
Categories the classifier emits: CharacterRecord, PartyMoney, Inventory, BattleActor, ScriptVmGlobal, CameraGlobal, PadInput, WorldStoryFlag, Minigame, FieldVmCollision, ScratchActiveActor, CodePatch, Unknown.
taxonomy::classify_writes(addrs) rolls a set of changed RAM addresses up into per-region buckets (the classification half of a gameplay-driven write tracer), flagging writes that land outside every known data region or in the 0x8007Bxxx script-VM / build-flag scratch. Wired end-to-end as mednafen-state write-taxonomy LEFT RIGHT, which diffs two save states at byte granularity and prints the per-region roll-up + attack-surface candidates.
Notable citations the cheat database pinned
- Inventory layout:
0x80085958+ 2-byte stride, 72 slots, alternating(id, count). Pinned by the "Have 99 Items" / "Have Max Items" / "Item Modifier" cheat triplet. - Battle actor pool stride:
0x800EC9E8+0x2D4per party slot. Vahn HP at+0x14C/ Noa at base+0x2D4+0x14C=0x800ECE08. The "Infinite HP/MP" cheats target both the live (+0x14C/+0x150) and settled (+0x172/+0x174) sites. - Story flag bitmap:
0x80085600..0x80085800holds town-visited / Door of Wind state. "Access All Towns" writes0xF77F / 0xF8FFat0x8008575C/E. - Code-patch sites: cheats writing
0x2400(MIPSnop) flag specific instructions: inventory-add (0x800422F4), count-decrement (0x8004309E), Vahn chest draw (0x80043910), HP-write branch (0x8007EA96). Useful Ghidra anchors.
Runtime applier
legaia-engine play-window --cheat-file <PATH> parses the file, applies every entry through the legaia_engine_core::ram_map registry, and logs per-entry status:
Cheat report (49 entries, 96 writes; 71 applied, 25 unmapped, 0 unknown):
ok Infinite HP (Vahn)............... 4/4 writes
ok Infinite Gold (Never Glitchy).... 1/1 writes
skip Walk Thru Walls.................. 0/4 writes (FieldVmCollision unmapped)
...
Conditional codes are treated as always-true by default. Pass --cheat-strict to honour them, which will skip every cheat that gates on a button press the engine doesn't emulate.
See also
- Per-character save record format - full
0x414-byte offset table the cheat citations anchor. - PSX RAM map - newly-pinned globals from the cheat database.