Skip to content

[DRAFT] Add In-Game Reset (IGR) feature support - #341

Draft
mrj1m0thy wants to merge 2 commits into
Polprzewodnikowy:mainfrom
mrj1m0thy:feat/in_game_reset
Draft

[DRAFT] Add In-Game Reset (IGR) feature support#341
mrj1m0thy wants to merge 2 commits into
Polprzewodnikowy:mainfrom
mrj1m0thy:feat/in_game_reset

Conversation

@mrj1m0thy

Copy link
Copy Markdown

Adds IGR payload installation alongside cheats, controlled by new igr_enabled setting. IGR is only enabled for SummerCart64 with expansion pak. Includes new igr.c module, boot parameter, settings UI option, and integration across ROM/disk/emulator loading paths.

Add In-Game Reset (IGR) support for SummerCart64

Description

This PR implements an In-Game Reset (IGR) feature that allows users to soft-reboot back to the flashcart menu from a running N64 game by pressing a specific controller button combination.

Core implementation:

  • Added src/boot/igr.h and src/boot/igr.c: A MIPS payload generator that injects code into the cheat engine's exception handler. On every vertical interrupt (VI), it polls controller 1 buttons from PIF RAM and triggers an SC64 soft reboot via the AUX register (0xBFFF0018) when the combo is detected.
  • Added I_SLL macro to src/boot/vr4300_asm.h for shift-left-logical instruction generation used in the payload.
  • Extended cheats_install() signature in src/boot/cheats.h and src/boot/cheats.c with a new bool igr_enabled parameter. The cheat engine now installs the IGR payload even when no cheat list is present, provided IGR is enabled and the Expansion Pak is present.
  • Added igr_enabled to boot_params_t (src/boot/boot.h) and wired it through src/boot/boot.c.
  • Added igr_enabled to the settings system (src/menu/settings.h, src/menu/settings.c) with load/save support in config.ini under the [menu] section.
  • Added an "In-Game Reset" toggle to the settings UI (src/menu/views/settings_editor.c).
  • Wired igr_enabled into all boot paths: load_rom.c, load_disk.c, and load_emulator.c. IGR is gated to SummerCart64 only (cart_type == CART_SC) and requires an Expansion Pak.
  • Zero-initialized boot_params in src/main.c to prevent stale struct fields.
  • Added boot/igr.c to the Makefile SRCS.

Button combination: L + R + Z + A + B + Start (mask 0xF030) — chosen to minimize accidental activation.

Current limitations:

  • IGR is implemented exclusively for SummerCart64 (sc64) because it relies on the SC64 AUX register soft-reboot primitive (0xFF000002).
  • Requires the Expansion Pak because the payload is installed in the expanded RDRAM region used by the cheat engine.

Motivation and Context

Currently, once a ROM is launched from the menu, the only way to return is to physically press the console's reset button or power cycle. This is inconvenient for users who want to quickly switch games or return to the menu without leaving their seat. IGR solves this by allowing a controller-based soft reboot back to the flashcart menu.

This implementation leverages the existing cheat engine infrastructure (IPL3 patching, exception vector hooking at 0x80000180, and engine code placement at 0x80700000+) to inject the IGR payload, avoiding the need for a separate patching mechanism.

How Has This Been Tested?

  • Compiled successfully with make sc64 after setting N64_INST.
  • Verified that the sc64menu.n64 output includes the new igr.c object.
  • Code-reviewed the MIPS payload branch offsets and register usage ($k0, $k1) to ensure they are safe within the exception handler context.
  • Verified that cheats_install() correctly falls back to DEFAULT_ENGINE_ADDRESS when cheat_list is NULL but IGR is enabled (via the upstream fix applied to cheats.c).
  • Not yet tested on real hardware. The PIF RAM button offsets (0xBFC007C4 / 0xBFC007C5) are based on standard libultra OSContPad layout and may require adjustment after hardware validation.

Testing environment:

  • Windows 11
  • libdragon toolchain (latest stable)

Screenshots

N/A — no visual UI changes beyond the settings toggle.

Types of changes

  • Improvement (non-breaking change that adds a new feature)
  • Bug fix (fixes an issue)
  • Breaking change (breaking change)
  • Documentation Improvement
  • Config and build (change in the configuration and build system, has no impact on code or features)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

You agree with the license terms and that other license types may be granted with permission of the original N64FlashcartMenu project license holders.

Signed-off-by: mrj1m0thy mrj1m0thy4@gmail.com

Adds IGR payload installation alongside cheats, controlled by new igr_enabled setting. IGR is only enabled for SummerCart64 with expansion pak. Includes new igr.c module, boot parameter, settings UI option, and integration across ROM/disk/emulator loading paths.
@coderabbitai

coderabbitai Bot commented May 28, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 5848f9ee-5e49-4130-8218-ca9f2819f9a9

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@mrj1m0thy

Copy link
Copy Markdown
Author

Testing required. going to do tests soon when i get time and do some debugging if necessary.

@networkfusion networkfusion changed the title Add In-Game Reset (IGR) feature support [Draft] Add In-Game Reset (IGR) feature support Aug 15, 2026
@networkfusion networkfusion changed the title [Draft] Add In-Game Reset (IGR) feature support [DRAFT] Add In-Game Reset (IGR) feature support Aug 15, 2026
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