Skip to content

feat(zaparoo): add native CRT launch mode#1

Merged
wizzomafizzo merged 11 commits into
masterfrom
codex/zaparoo-prelaunch-video-state
May 9, 2026
Merged

feat(zaparoo): add native CRT launch mode#1
wizzomafizzo merged 11 commits into
masterfrom
codex/zaparoo-prelaunch-video-state

Conversation

@asturur
Copy link
Copy Markdown
Member

@asturur asturur commented May 6, 2026

Summary

Adds a Zaparoo native CRT launch path for the new Zaparoo Launcher core
(see ZaparooProject/Menu_MiSTer).
When that core is loaded, Main_MiSTer disables the HPS framebuffer/scaler,
sets status[9] so the FPGA reads frames from the core's native DDR video
reader, and spawns the alt launcher with --crt.

CRT mode is inferred entirely from the core's reported name — there is no
new MiSTer.ini option
. Loading any other core (or running with no Zaparoo
core at all) keeps the existing behaviour unchanged.

End-user setup

  1. MiSTer.ini has ALT_LAUNCHER=zaparoo/launcher (path to the launcher
    binary) and FB_TERMINAL=1.
  2. The Zaparoo Launcher RBF is dropped anywhere in the SD card layout —
    e.g. /media/fat/_Other/Zaparoo_Launcher.rbf. Stock menu.rbf is
    never overwritten.
    Detection is by core name, not by path, so the RBF
    can live wherever the package wants to put it.
  3. Optional: bootcore= in MiSTer.ini can point at the launcher RBF for
    automatic boot. Otherwise the user picks it from the OSD file browser.

When the core loads, Main_MiSTer recognises the reported name
(Zaparoo Launcher) and brings up the CRT path automatically.

Behaviour change for non-Zaparoo users

None. All native-CRT side effects (writes to
/sys/module/MiSTer_fb/parameters/mode, set_vga_fb(0), status[9]
toggling) are gated on s_native_crt, which only becomes true after
alt_launcher_init(true) — itself only callable from
zaparoo_alt_launcher_init_for_core(), which short-circuits unless
cfg.alt_launcher[0] && cfg.fb_terminal && zaparoo_is_native_core().
HDMI-only users without ALT_LAUNCHER configured see byte-for-byte
identical behaviour to upstream.

Details

  • Adds support/zaparoo/alt_launcher.{cpp,h} helpers
    zaparoo_is_native_core() and zaparoo_alt_launcher_init_for_core()
    (gated on alt-launcher config + fb_terminal + matching core name).
  • Extends alt_launcher_init() with a native_crt flag.
  • In native CRT mode:
    • Disables VGA FB and HPS framebuffer/scaler output before launch
    • Sets /sys/module/MiSTer_fb/parameters/mode to
      8888 1 320 240 1280 (RGBX8888, stride 320×4 = 1280; matches
      Menu_MiSTer's native_video_reader.sv 320×240 contract)
    • Raises status[9]
    • Skips the normal post-VT video_fb_enable(1)
    • Refreshes status[9] and the fb mode while the launcher is alive
      (some cores re-clock the FB after a delay)
    • Exports ALT_LAUNCHER_CRT=1 and execs the launcher with --crt
  • In non-CRT mode:
    • Keeps the existing launcher behaviour
    • Switches to VT2
    • Calls video_fb_enable(1)
  • On launcher exit / crash give-up / fork failure / shutdown:
    • If s_native_crt was set, clears status[9] and restores the
      default 960×720 fb mode
    • Otherwise falls back to plain video_fb_enable(0), identical to
      pre-PR behaviour

Upstream merge surface

Per AGENTS.md, this fork is auto-rebased against
MiSTer-devel/Main_MiSTer. Touching upstream files is minimised:

  • user_io.cpp: +1 line — a single call to
    zaparoo_alt_launcher_init_for_core() inside the existing
    CORE_TYPE_8BIT else branch.
  • input.cpp, menu.cpp: untouched by this feature
    (menu.cpp shows a diff vs fork master only because the PR
    branch picked up upstream commit fca5f11 F7 = Keyboard Map (#1187)
    via a master merge).
  • All new logic lives in support/zaparoo/alt_launcher.{cpp,h},
    which is glob-included by the Makefile and has zero conflict
    surface against upstream.

Validation

  • Built cleanly with ./docker-build.sh (produces
    bin/MiSTer_Zaparoo, no warnings).
  • Static checks confirm s_native_crt mutation is contained and the
    HDMI/no-launcher path is unchanged.
  • Hardware smoke tests pending end-user confirmation:
    • HDMI-only setup, no ALT_LAUNCHER configured: cores boot and
      run normally.
    • Existing Zaparoo Menu core + ALT_LAUNCHER=zaparoo/launcher:
      launcher starts on VT2 with the HPS framebuffer (non-CRT path).
    • New Zaparoo Launcher core: launcher starts with --crt,
      status[9]=1 visible in core, native 320×240 RGBX8888 video
      reaches CRT.

Summary by CodeRabbit

Release Notes

  • New Features

    • Native CRT mode support added for the Zaparoo launcher, enabling users to toggle CRT display settings during launcher operation.
  • Improvements

    • Enhanced display mode handling during launcher initialization and shutdown.
    • Improved key routing behavior when launcher is active.

Review Change Stack

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 6, 2026

Caution

Review failed

Pull request was closed or merged during review

📝 Walkthrough

Walkthrough

Alt launcher system adds native CRT mode support with environment-based process spawning, framebuffer state management, conditional shutdown behavior, and core-type detection. Input routing and core initialization are updated to integrate the new functionality.

Changes

Native CRT Alt Launcher Support

Layer / File(s) Summary
Public API Contract
support/zaparoo/alt_launcher.h
alt_launcher_init() now accepts optional native_crt parameter; new functions zaparoo_is_native_core() and zaparoo_alt_launcher_init_for_core() added for core detection and initialization.
Native CRT State, Helpers, and Path Control
support/zaparoo/alt_launcher.cpp
Global state for native CRT mode with timers and sysfs path constant; helper functions set framebuffer mode via sysfs; enable/disable path functions manage UI updates, framebuffer calls, and timer initialization/reset.
Launcher Lifecycle Functions
support/zaparoo/alt_launcher.cpp
alt_launcher_init() accepts and stores native CRT mode; alt_launcher_poll() updates timers and framebuffer settings in native CRT mode; alt_launcher_shutdown() conditionally disables native CRT path or reverts HPS framebuffer.
Process Spawning and Environment Setup
support/zaparoo/alt_launcher.cpp
Generated bash wrapper conditionally execs launcher with --crt flag based on ALT_LAUNCHER_CRT; child process environment exports native CRT state; post-spawn configuration selects between HPS framebuffer and native CRT mode.
Return to Normal Mode
support/zaparoo/alt_launcher.cpp
Shutdown path conditionally disables native CRT when active or reverts HPS framebuffer when normal.
Public Interface and System Integration
support/zaparoo/alt_launcher.cpp, user_io.cpp, input.cpp
New public helpers detect "Zaparoo Launcher" core and initialize launcher in CRT mode; user_io.cpp calls initialization during CORE_TYPE_8BIT setup; input.cpp routes framebuffer keys when launcher is active or framebuffer is enabled.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐰 A native CRT path unfolds,
Framebuffer states the launcher holds,
Timers poll and helpers guide,
Core detection, well-applied!
Terminal keys now flow so free,
Through launcher modes for all to see! 🖥️✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.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 'feat(zaparoo): add native CRT launch mode' accurately and concisely describes the main change: introducing a native CRT launch mode for the Zaparoo Launcher core.
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 codex/zaparoo-prelaunch-video-state

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


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.

@asturur
Copy link
Copy Markdown
Member Author

asturur commented May 6, 2026

Validation update: Main now launches 3S-ARM CRT mode with fb0 set to RGB565 384x224 (mode: 565 1 384 224 768), keeps status[9] asserted, skips video_fb_enable(1), and restores 960x720 rgb32 on exit. Verified on MiSTer: CORENAME/RBFNAME=3S-ARM, launcher --crt, native writer logs copying RGB565 from /dev/fb0 384x224 to DDR.

asturur and others added 7 commits May 6, 2026 20:19
Reduce upstream merge surface and prevent regressions for users without
the Zaparoo core:

- Move is_zaparoo_native_core() / zaparoo_alt_launcher_init_for_core()
  out of user_io.cpp into support/zaparoo/alt_launcher.{cpp,h}.
- Drop the temporary "3S-ARM" core-name constant; only "Zaparoo Launcher"
  is recognised.
- Drop the CORE_TYPE_UNKNOWN call site (unreachable: the launcher core
  uses standard hps_io and identifies as CORE_TYPE_8BIT). Net diff in
  user_io.cpp is now a single added function call.
- Gate disable_native_crt_path() on s_native_crt at every call site so
  HDMI / non-launcher users never see writes to
  /sys/module/MiSTer_fb/parameters/mode, set_vga_fb(0), or status[9]
  changes on core load.
- Remove unused s_tty_deadline and the obsolete 384x224 RGB565 dead line
  in set_native_crt_fb_mode().
@wizzomafizzo wizzomafizzo marked this pull request as ready for review May 9, 2026 10:39
@wizzomafizzo wizzomafizzo merged commit 562b60c into master May 9, 2026
1 check was pending
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