Skip to content

Add shared cheats and target discovery tools#83

Merged
jiangxincode merged 10 commits into
masterfrom
feat/cheats
Jul 9, 2026
Merged

Add shared cheats and target discovery tools#83
jiangxincode merged 10 commits into
masterfrom
feat/cheats

Conversation

@jiangxincode

@jiangxincode jiangxincode commented Jul 8, 2026

Copy link
Copy Markdown
Owner

Summary

Adds a shared cheat system to native32emu-core and exposes it through both supported frontends: standalone CLI rules and RetroArch's emulator-handled cheat interface. The PR also adds standalone-only target discovery/filtering tools, verifies game-specific codes for EBBLADE, EGUNFIRE, EMETAL, and ESTORM, and reorganizes the frontend documentation around complete standalone and RetroArch guides.

Implementation

Shared cheat engine

  • Adds CheatManager, indexed cheat slots, rule parsing, enable/disable state, reset behavior, and per-frame application in native32emu-core.
  • Applies enabled rules after normal game logic on every emulation tick so locked values are restored consistently.
  • Keeps cheat rule parsing and application frontend-independent so standalone and libretro use the same code strings and runtime behavior.
  • Supports these rule forms:
    • var:<name>=<value> for VM variables.
    • sprite:<name>.<field>=<value> and movie:<name>.<field>=<value> for x, y, depth, frame, visible, and playing.
    • frame:goto=<n> for main-timeline jumps.
    • frame:playing=<bool> for main-timeline play/pause state.
  • Accepts 1/0, true/false, on/off, and yes/no for boolean fields.

Standalone integration

  • Adds repeatable --cheat <RULE> arguments.
  • Logs and ignores malformed CLI rules instead of aborting game startup.
  • Adds --debug-cheats to periodically list the current timeline, VM variables, and sprite targets.
  • Adds --cheat-debug-interval <N> with a default interval of 30 frames.
  • Adds --cheat-debug-filter <GLOB> to filter variable names with case-sensitive * and ? matching, for example p_*.

RetroArch integration

  • Implements retro_cheat_set with indexed slots and enabled state.
  • Implements retro_cheat_reset to clear all core-managed cheats.
  • Uses RetroArch's Emulator cheat handler so rule strings are passed to the core rather than interpreted as frontend memory-address cheats.
  • Keeps cheat target discovery out of the RetroArch core options to keep the core UI and documentation simpler; target discovery is supported only by the standalone emulator.
  • Reapplies normal core option changes live without reloading content.

Target discovery

  • Standalone-only discovery logs sorted VM variables and sprite state, capped at 64 entries per category with omitted-entry counts.
  • Includes current frame, playback state, sprite movie/frame/position/depth/visibility/playback state, and pending frame information.
  • Preserves filtering configuration when debug logging settings are updated.
  • Adds focused tests for target formatting, debug configuration, and glob matching.

Verified game codes

EBBLADE (Blades of Red / 赤刃) was tested with player-variable filtering. p_hp was observed dropping from 96 to 88 after damage, then remaining at 96 when this rule was enabled:

var:p_hp=96

EGUNFIRE (Gun Fire / 枪火) was tested by directly loading NA32SSL/ENGLISH/GUNFIRE/GUNF1.SSL for target discovery. he_l was observed dropping from 104 to 100 without cheats, then remaining at 104 through 720 ticks when this rule was enabled:

var:he_l=104

The score rule was also verified through debug output and displayed score sprites:

var:he_score=999999

EMETAL (Metal Storm / 钢铁风暴) target discovery found pl_hp in NA32SSL/ENGLISH/METAL/MSPLAY10.SSL. The documented rule keeps the player health variable at its observed maximum:

var:pl_hp=60

ESTORM (Storm / 风暴之翼) was tested through NA32SSL/ENGLISH/STORM/STPLAY10.SSL. Target discovery identified player health, lives, bombs, and score variables; the enabled rules kept these values fixed through the verification run:

var:p_hp=9
var:p_life=9
var:p_bomb=9
var:p_score=999999

The verified codes are recorded in docs/Cheat-Codes.md. Cheat codes are shared by the standalone emulator and RetroArch core; only target discovery is standalone-only.

Documentation

  • Replaces the narrow options-only documents with complete frontend guides:
    • docs/Standalone-Emulator.md
    • docs/RetroArch-Core.md
  • Moves ZIP/FHUI menu and ESC behavior into the standalone guide.
  • Moves RetroArch installation, supported features, RetroPad mapping, core options, and emulator-handled cheat setup into the RetroArch guide.
  • Keeps docs/Cheat-Codes.md focused on verified codes grouped by game for future expansion.
  • Adds EBBLADE, EGUNFIRE, EMETAL, and ESTORM cheat codes to the game-code list.
  • Simplifies README usage and keeps shared audio capabilities in the main feature list.
  • Updates website footer links and labels for the renamed guides.

Validation

  • cargo test --all
  • cargo clippy -- -D warnings
  • cargo fmt -- --check
  • cargo check -p native32emu
  • cargo check -p native32emu-libretro
  • cargo run -p native32emu -- --help
  • Manual EBBLADE target-discovery and var:p_hp=96 lock verification
  • Manual EGUNFIRE target-discovery, var:he_l=104 lock verification, and var:he_score=999999 score verification
  • Manual EMETAL target-discovery for var:pl_hp=60
  • Manual ESTORM target-discovery and var:p_hp=9, var:p_life=9, var:p_bomb=9, var:p_score=999999 verification

@jiangxincode jiangxincode changed the title Add shared cheat support Add shared cheats and target discovery tools Jul 8, 2026
@sonarqubecloud

sonarqubecloud Bot commented Jul 9, 2026

Copy link
Copy Markdown

@jiangxincode jiangxincode merged commit 23df736 into master Jul 9, 2026
7 checks passed
@jiangxincode

Copy link
Copy Markdown
Owner Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant