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 .cht format (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:

PrefixOperationExample
0x80u16 LE write80084816 0064mem16[0x80084816] = 0x0064
0x30u8 write300848A3 0000mem8[0x800848A3] = 0x00
0xD0conditional: if mem16 == value, execute nextD007B7C0 0100 (Select pressed)
0xE0conditional: if mem16 != value, execute nextE007B83C 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 + 0x2D4 per 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..0x80085800 holds town-visited / Door of Wind state. "Access All Towns" writes 0xF77F / 0xF8FF at 0x8008575C/E.
  • Code-patch sites: cheats writing 0x2400 (MIPS nop) 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