Skip to content

feat(zaparoo): adopt native CRT video v2 DDR contract#8

Merged
wizzomafizzo merged 4 commits into
masterfrom
feat/zaparoo-native-video-v2
Jun 20, 2026
Merged

feat(zaparoo): adopt native CRT video v2 DDR contract#8
wizzomafizzo merged 4 commits into
masterfrom
feat/zaparoo-native-video-v2

Conversation

@wizzomafizzo

@wizzomafizzo wizzomafizzo commented Jun 11, 2026

Copy link
Copy Markdown
Member
  • Update the native CRT framebuffer to the v2 geometry (352x240 stride 1408, was 320x240 stride 1280) and blank the full 3 MB DDR region the new core scans.
  • Remove the dead status[9] CRT-enable writes and the 500 ms re-assert timer, since the new Menu_MiSTer core has no CRT status bit — publishing DDR frames is the mode switch.
  • Remove H/V offset handling (status pushes on [13:10]/[17:14], persistence, getters/setters); centering now lives in DDR word1, written by the frontend.
  • Zero DDR word0/word1 on CRT-path teardown so the core deterministically reverts to its noise pattern even when the frontend crashed before its own stop handler could run.
  • Add an exit-code-42 respawn path: the frontend rewrites zaparoo_launcher_crt.bin itself and exits 42 to be respawned under the new CRT setting without restarting Main.
  • Remove the OSD CRT/Video pages entirely (the launcher owns CRT mode now), which also shrinks the fork's menu.cpp diff against upstream.

Summary by CodeRabbit

  • Refactor
    • Simplified Zaparoo launcher menu/navigation: removed dedicated video/settings pages and routed actions through the system menu
    • Removed manual H/V offset controls from the launcher UI
  • New Features
    • Added a persisted “CRT mode” toggle in the OSD; changing it respawns the frontend immediately
  • Bug Fixes
    • Improved native CRT enable/disable and restart handling for more consistent initialization and shutdown

The Menu_MiSTer core dropped its status[9] CRT-enable bit and H/V offset
status bits; publishing DDR frames is now the mode switch and centering
moves into DDR word1 (frontend-owned). Update the Main side to match:

- fb mode 320x240 stride 1280 -> 352x240 stride 1408; blank the full 3 MB
  v2 DDR region.
- Remove all status[9] writes and the 500 ms re-assert timer; remove H/V
  offset handling (status pushes, persistence, getters/setters).
- Zero DDR word0/word1 on CRT-path teardown so the core reverts to its
  noise pattern even after a frontend crash.
- Add exit-code-42 respawn: the frontend rewrites zaparoo_launcher_crt.bin
  itself and exits 42 to be respawned under the new setting.
- Remove the OSD CRT/Video pages entirely (launcher owns CRT mode now);
  this also shrinks the fork's menu.cpp diff against upstream.
@coderabbitai

coderabbitai Bot commented Jun 11, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 08c802f2-3f9c-4113-bc0f-26325760de2a

📥 Commits

Reviewing files that changed from the base of the PR and between eb44d98 and c3a9826.

📒 Files selected for processing (1)
  • support/zaparoo/alt_launcher.h
🚧 Files skipped from review as they are similar to previous changes (1)
  • support/zaparoo/alt_launcher.h

📝 Walkthrough

Walkthrough

This PR removes Zaparoo launcher/video menu pages and their menu routing, replaces offset/toggle APIs with persisted native-CRT state APIs, updates native CRT geometry/blanking and deterministic teardown, and implements a respawn flow (ALT_LAUNCHER_EXIT_RELOAD) that reloads persisted CRT settings.

Changes

Zaparoo Launcher Architecture Refactoring

Layer / File(s) Summary
Menu system decommissioning
menu.cpp, support/zaparoo/launcher_pages.cpp, support/zaparoo/launcher_pages.h
Removes the launcher_pages.h include, deletes MENU_ZAPAROO_LAUNCHER* and MENU_ZAPAROO_VIDEO* enum states and switch handlers, and deletes the entire launcher_pages.cpp implementation.
Native CRT persisted mode and lifecycle flow
support/zaparoo/alt_launcher.cpp
Adds persisted 2-byte native-CRT state (enabled flag + mode byte), introduces mode-driven framebuffer geometry selection (352x240 NTSC, 352x288 PAL, 720x480), adds zero_native_crt_words() for deterministic shared-memory control clearing, removes user_io_status_set("[9]", ...) signaling, updates enable/disable/teardown paths, implements ALT_LAUNCHER_EXIT_RELOAD respawn to reload and reinitialize, and simplifies menu init to use persisted CRT flag only.
Public API and system menu rewiring
support/zaparoo/alt_launcher.h, support/zaparoo/alt_launcher_menu.cpp
Removes offset getter/setter functions and old alt_launcher_toggle_crt(), adds alt_launcher_native_crt_persisted() query and alt_launcher_toggle_native_crt() toggle APIs; updates system OSD title/mask and reindexes CRT/Reboot/Exit menu rows so CRT mode handling toggles persisted state and forces menu redraw.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

  • ZaparooProject/Main_MiSTer#2: Previously wired the System OSD "CRT mode" entry to the old alt_launcher_toggle_crt() path; functionally related to the removed menu wiring and toggle APIs being replaced by persisted state handling.

I hopped along the launcher trail with care,
I stashed CRT modes in a file to share,
I blanked the screen, parked the hardware clean,
Respawned the frontend to match the scene,
A rabbit's tidy patch — quick, neat, and fair. 🐰

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 4.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the main change: adopting a native CRT video v2 DDR contract, which is the core objective reflected across all file modifications.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/zaparoo-native-video-v2

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
support/zaparoo/alt_launcher.cpp (1)

138-155: 💤 Low value

Consider extracting the shared DDR address constant.

0x3A000000u is duplicated here and in blank_native_crt_fb() at line 125. Extracting to a shared constant (e.g., static const uint32_t kNativeCrtDdrAddr = 0x3A000000u;) would reduce the risk of the values diverging if the DDR layout changes again.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@support/zaparoo/alt_launcher.cpp` around lines 138 - 155, Extract the
duplicated DDR base address literal into a single shared constant (e.g., declare
static const uint32_t kNativeCrtDdrAddr = 0x3A000000u) and replace the
hard-coded 0x3A000000u occurrences in zero_native_crt_words and
blank_native_crt_fb with that constant; keep the existing map_size and behavior,
and ensure both functions call shmem_map(kNativeCrtDdrAddr, map_size) /
shmem_unmap(...) so the address is maintained in one place.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@support/zaparoo/alt_launcher.cpp`:
- Around line 138-155: Extract the duplicated DDR base address literal into a
single shared constant (e.g., declare static const uint32_t kNativeCrtDdrAddr =
0x3A000000u) and replace the hard-coded 0x3A000000u occurrences in
zero_native_crt_words and blank_native_crt_fb with that constant; keep the
existing map_size and behavior, and ensure both functions call
shmem_map(kNativeCrtDdrAddr, map_size) / shmem_unmap(...) so the address is
maintained in one place.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: e7dbe0f0-632c-4a2e-b935-ea3cecdec5a2

📥 Commits

Reviewing files that changed from the base of the PR and between 2951e83 and 15d773f.

📒 Files selected for processing (6)
  • menu.cpp
  • support/zaparoo/alt_launcher.cpp
  • support/zaparoo/alt_launcher.h
  • support/zaparoo/alt_launcher_menu.cpp
  • support/zaparoo/launcher_pages.cpp
  • support/zaparoo/launcher_pages.h
💤 Files with no reviewable changes (4)
  • support/zaparoo/launcher_pages.h
  • support/zaparoo/launcher_pages.cpp
  • support/zaparoo/alt_launcher.h
  • menu.cpp

Extend zaparoo_launcher_crt.bin to two bytes [enabled, mode], where
mode is the DDR word1 id (0 NTSC 352x240, 1 480i 720x480, 2 PAL
352x288). set_native_crt_fb_mode() programs the matching geometry and
enable_native_crt_path() refreshes the mode from the file on every CRT
spawn, so a video-standard change in the frontend (rewrite file, exit
42) gets the right framebuffer on respawn - including the T+1s
re-assert, which previously stomped any non-NTSC shape back to
352x240. Legacy 1-byte files partial-read as NTSC.

Restore a CRT mode toggle to the OSD System Settings menu, under
Scripts. It flips byte 0 of the same state file (preserving the
standard byte) and respawns the frontend through the same re-entry
steps as the exit-42 reload, re-arming after an earlier give-up or
escape. Contained in the zaparoo support files; menu.cpp untouched.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
support/zaparoo/alt_launcher.h (1)

15-16: Confirm removed alt_launcher API call sites have been migrated

  • No remaining C/C++ call sites to alt_launcher_toggle_crt, alt_launcher_h_offset, alt_launcher_v_offset, alt_launcher_set_h_offset, or alt_launcher_set_v_offset outside support/zaparoo/alt_launcher.h.
  • Only remaining references are in ZAPAROO_FORK.md as documentation mentioning support/zaparoo/alt_launcher.cpp.
  • Optional: add brief doc comments for alt_launcher_native_crt_persisted() and alt_launcher_toggle_native_crt() in support/zaparoo/alt_launcher.h.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@support/zaparoo/alt_launcher.h` around lines 15 - 16, The header declares
alt_launcher_native_crt_persisted() and alt_launcher_toggle_native_crt() while
older API functions (alt_launcher_toggle_crt, alt_launcher_h_offset,
alt_launcher_v_offset, alt_launcher_set_h_offset, alt_launcher_set_v_offset)
were removed—confirm there are no remaining C/C++ call sites using those old
symbols by searching the repo for those function names and migrating any callers
to the new APIs (or updating them to no-op/removal); ensure only documentation
(ZAPAROO_FORK.md) references the old alt_launcher.cpp if intended, and
optionally add short doc comments above alt_launcher_native_crt_persisted() and
alt_launcher_toggle_native_crt() in support/zaparoo/alt_launcher.h describing
their purpose and behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@support/zaparoo/alt_launcher.h`:
- Around line 15-16: The header declares alt_launcher_native_crt_persisted() and
alt_launcher_toggle_native_crt() while older API functions
(alt_launcher_toggle_crt, alt_launcher_h_offset, alt_launcher_v_offset,
alt_launcher_set_h_offset, alt_launcher_set_v_offset) were removed—confirm there
are no remaining C/C++ call sites using those old symbols by searching the repo
for those function names and migrating any callers to the new APIs (or updating
them to no-op/removal); ensure only documentation (ZAPAROO_FORK.md) references
the old alt_launcher.cpp if intended, and optionally add short doc comments
above alt_launcher_native_crt_persisted() and alt_launcher_toggle_native_crt()
in support/zaparoo/alt_launcher.h describing their purpose and behavior.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: d692eda8-2194-46a9-a0fb-d7eca3c932ad

📥 Commits

Reviewing files that changed from the base of the PR and between 15d773f and a0c1bae.

📒 Files selected for processing (3)
  • support/zaparoo/alt_launcher.cpp
  • support/zaparoo/alt_launcher.h
  • support/zaparoo/alt_launcher_menu.cpp
🚧 Files skipped from review as they are similar to previous changes (2)
  • support/zaparoo/alt_launcher_menu.cpp
  • support/zaparoo/alt_launcher.cpp

…-video-v2

# Conflicts:
#	support/zaparoo/alt_launcher.cpp
#	support/zaparoo/alt_launcher.h
@wizzomafizzo wizzomafizzo merged commit b03fed9 into master Jun 20, 2026
1 check passed
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