Skip to content

Genesis CPU setting (Normal / 125%), wait-loop skip, Maximum Carnage fix - #138

Merged
finger563 merged 6 commits into
mainfrom
feat/genesis-cpu-setting
Nov 14, 2026
Merged

finger563 merged 6 commits into
mainfrom
feat/genesis-cpu-setting

Conversation

@finger563

@finger563 finger563 commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Builds on #137 (based on its branch; retarget to main once #137 is merged). Needs esp-cpp/gwenesis#2, which this pins.

What

  • Genesis CPU setting: a new settings-menu row, "Genesis CPU", toggles Normal ↔ 125%. It's stored as genesis_cpu_percent in a new SettingsV2, which migrates from SettingsV1 through espp::PersistentData. It's applied when a Genesis game launches. 125% removes Sonic 3's native slowdown when Sonic loses his rings.
  • Wait-loop skip: enabled with M68K_IDLE_SKIP, next to M68K_OVERCLOCK_SHIFT=8.
  • gwenesis bump (68000 clock setting, wait-loop skip, and a Z80 reset fix (Maximum Carnage hang) gwenesis#2):
    • fixes the Maximum Carnage hang after START GAME (the Z80 was restarted on every "release reset" write);
    • keeps the sound CPU running while muted;
    • keeps the Z80 interrupt setting correct when loading older saves.

Testing (ESP32-S3-BOX-3)

  • Maximum Carnage: a fresh start reaches the first level at 60 fps.
  • Sonic 3: ring loss holds 60 fps at 125%; the sound was checked by ear.
  • Other games: Sonic 1/2, Aladdin and Lion King start with sound.
  • Settings: the box booted from an existing V1 settings file. Persistence of the new value across a reboot hasn't been checked separately yet.

Note: a slot-0 Maximum Carnage save written during the old hang still loads into the hang. Start fresh or use the menu Reset.

🤖 Generated with Claude Code

https://claude.ai/code/session_01SFCMzomCZ5wRHJN4sxwkvY

finger563 and others added 2 commits November 13, 2026 13:11
- Settings v2 (migrated from v1) adds genesis_cpu_percent; the launcher's
  settings get a "Genesis CPU" row (Normal / 125%), applied when a Genesis
  game starts. At 125% the 68000 finishes its frame work in time: Sonic 3
  no longer drops to half speed for ~3 s when Sonic loses his rings, at the
  cost of a few drawn frames (the 68000 takes ~1 ms more per frame).
- gwenesis: built with M68K_OVERCLOCK_SHIFT (the clock setting) and
  M68K_IDLE_SKIP (the 68000's wait-for-frame loops are not emulated,
  recovering most of the overclock's 68000 time).

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SFCMzomCZ5wRHJN4sxwkvY
… muted)

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SFCMzomCZ5wRHJN4sxwkvY
Copilot AI balanced review requested due to automatic review settings November 13, 2026 21:47
finger563 and others added 2 commits November 13, 2026 16:00
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SFCMzomCZ5wRHJN4sxwkvY
…wenesis #2

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SFCMzomCZ5wRHJN4sxwkvY

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Warning

Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.

Copilot review overview

3 open issues
What changed in this PR

Adds a persisted “Genesis CPU” setting (Normal vs 125%) and applies it on Genesis launch, while also updating the bundled gwenesis submodule and enabling M68K idle-loop skipping / overclock support at build time.

Changes:

  • Introduce SettingsV2 with genesis_cpu_percent and migrate from SettingsV1 via espp::PersistentData.
  • Add a new GUI settings-row to toggle Genesis CPU (Normal ↔ 125%) and apply it when initializing Genesis emulation.
  • Update gwenesis submodule and enable M68K_OVERCLOCK_SHIFT + M68K_IDLE_SKIP build definitions.
File Description
main/​main.cpp Extend settings logging to include Genesis CPU percent.
main/​genesis_cart.hpp Apply the configured Genesis CPU percent during Genesis cart init.
components/​settings/​src/​settings.cpp Include genesis_cpu_percent in settings equality comparison.
components/​settings/​include/​settings.hpp Add SettingsV2, migration, and update persistent store template parameters.
components/​gui/​src/​gui.cpp Add GUI controls + behavior for Genesis CPU toggle.
components/​gui/​include/​gui.hpp Declare Genesis CPU setter and store new LVGL object pointers.
components/​genesis/​gwenesis Bump gwenesis submodule revision.
components/​genesis/​CMakeLists.txt Enable overclock/idle-skip compile-time flags for the Genesis component.

Review effort: Lite

Comment thread components/gui/src/gui.cpp Outdated
Comment on lines +40 to +42
AppSettings::get().modify([percent](Settings &s) { s.genesis_cpu_percent = static_cast<uint8_t>(percent); });
if (genesis_cpu_label_) {
lv_label_set_text(genesis_cpu_label_, percent > 100 ? "125%" : "Normal");

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 32ee4e8: Settings::genesis_cpu_choice() maps any value to exactly 100 or 125; the setter stores that, and the label and toggle are based on it.

Comment thread main/genesis_cart.hpp Outdated
case Emulator::SEGA_GENESIS:
case Emulator::SEGA_MEGA_DRIVE:
logger_.info("genesis::init()");
genesis_set_cpu_percent(AppSettings::get().get_settings().genesis_cpu_percent);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 32ee4e8: the cart applies Settings::genesis_cpu_choice(...), so a stored value outside the two choices runs as one of them. (genesis_set_cpu_percent() in the core also clamps to 100..200.)

Comment thread main/main.cpp
Comment on lines +116 to +117
s.volume, s.muted ? " (muted)" : "", s.brightness, s.video_setting, s.resume_last_save,
s.haptic_waveform, s.genesis_cpu_percent, s.last_rom);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No change here: fmt formats unsigned char / signed char (so uint8_t) as integers; only plain char is formatted as a character. The values print as numbers.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SFCMzomCZ5wRHJN4sxwkvY
Base automatically changed from fix/audio-pops-and-genesis-saves to main November 13, 2026 22:58
Settings::genesis_cpu_choice() maps any stored value to 100 or 125; the GUI
stores, shows and toggles through it and the Genesis cart applies it.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SFCMzomCZ5wRHJN4sxwkvY
@github-actions

Copy link
Copy Markdown

✅Static analysis result - no issues found! ✅

@github-actions

Copy link
Copy Markdown

ESP-IDF Size Report for 'Esp Box Emu'

Metric Base PR Delta
FLASH 4,215,856 bytes (67.01%) 4,211,512 bytes (66.94%) ⬇️ -4,344 bytes (-0.07%)
DRAM 170,565 bytes (49.91%) 170,405 bytes (49.86%) ⬇️ -160 bytes (-0.05%)
IRAM 0 bytes 0 bytes 0 bytes
RAM (DRAM+IRAM) 170,565 bytes 170,405 bytes ⬇️ -160 bytes (-0.05%)

FLASH uses app .bin size or json2 flash sum. RAM sums DRAM+IRAM via idf_size. Percentages shown when totals are available.
DRAM/IRAM usage does not include memory used by the heap allocator at runtime.
This report was generated by esp-idf-size-delta.

@finger563
finger563 merged commit 27b2719 into main Nov 14, 2026
3 checks passed
@finger563
finger563 deleted the feat/genesis-cpu-setting branch November 14, 2026 00:11
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.

2 participants