feat: dual-mode menu core with switchable native FB reader#3
Open
asturur wants to merge 3 commits into
Open
Conversation
Adds a runtime-switchable "FB mode" alongside the original menu behavior. When status[9]=0 (default), the menu core renders the original cosine+LFSR pattern through the unchanged PAL/NTSC scandoubler timing — every existing menu surface (HDMI wallpaper compositor, OSD, F1 wallpaper cycle) keeps working. When status[9]=1, native_video_top takes over and feeds VGA from the 320x240 RGBX8888 framebuffer the HPS-side launcher writes into DDR. Carried forward from codex/zaparoo-rgbx8888-native-core (PR #2): - rtl/native_video_reader.sv — DDR burst reader with ping-pong buffers - rtl/native_video_timing.sv — 320x240 NTSC native CRT timing - rtl/native_video_top.sv — wrapper - PLL output1 20 MHz -> 27.027 MHz (required for 15.734 kHz NTSC line rate) Deliberately NOT carried forward — preserves original menu functionality: - CONF_STR title stays "MENU" (so is_menu() in Main_MiSTer still matches, F1 wallpaper cycling still works) - VIDEO_ARX/ARY stay 0/0 (no aspect-ratio change in cosine mode) - PAL/NTSC scandoubler ce_pix logic intact - Original cosine HV counters intact Mux on status[9] & native_active, with fallback to the cosine path until the first DDR frame is loaded so the output is never undriven. The DDR clear loop is removed — it was one-time boot scaffolding using the same DDRAM_* signals the native reader now owns. native_video_reader holds ddr_rd/ddr_we low when status[9]=0, so DDR is unused in the default mode.
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
5 tasks
The previous commit kept the original cosine timing block (H_TOTAL=638,
forced_scandoubler-conditional ce_pix) but switched the PLL to 27.027 MHz.
That produced a line rate of ~42 kHz scandoubled or ~21 kHz interlaced —
nothing standard, so a CRT could not lock on the analog VGA output.
This commit makes native_video_timing the single source of truth for sync
and DE in both modes:
- ce_pix is now a fixed /4 divider of CLK_VIDEO -> 6.756 MHz pixel rate
-> 15.749 kHz line rate (within 0.1% of NTSC 15.734 kHz).
- VGA_HS/VS/DE always come from native_video_top regardless of status[9].
- The cosine + LFSR fallback paints into the active area only; outside DE
we drive black so sync stays clean.
- vvc steps on native_new_frame instead of the old vc wrap; cos LUT is
indexed by vcount from the shared timing.
- native_video_top exposes vcount and new_frame so the cosine path can
reuse the same vertical position the FB reader sees.
The cosine pattern still renders (it was always intended as fallback noise),
but now at NTSC-spec 320x240 timing instead of broken 27 MHz / 638-cycle
timing. Sync locks on real CRTs.
PAL parametrisation is deferred — native_video_timing is currently NTSC-only.
forced_scandoubler is still wired from hps_io but unused; preserve it as a
known placeholder for the eventual PAL/scandoubler follow-up.
Shifts the active image by repartitioning the native timing's front and back porches; H_TOTAL/V_TOTAL stay fixed so the CRT keeps the same line and frame rate. V blanking rebalanced from 6/3/13 to 8/3/11 to give a symmetric +/-8 budget without changing refresh rate. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a runtime-switchable native FB mode to the menu core without removing any of the original menu functionality. When
status[9]=0(default), the core behaves exactly like the upstream menu — same cosine+LFSR pattern, same PAL/NTSC scandoubler timing, same HDMI wallpaper compositor, F1 wallpaper cycle still works, OSD overlays unchanged. Whenstatus[9]=1(set byMain_MiSTer/support/zaparoo/alt_launcher.cpp),native_video_toptakes over and feeds VGA from the 320×240 RGBX8888 framebuffer the launcher writes into DDR.This is the additive counterpart to #2 — same DDR reader, same timing, but layered on top of the original menu instead of replacing parts of it.
What's carried forward from PR #2 (codex/zaparoo-rgbx8888-native-core)
rtl/native_video_reader.sv— DDR burst reader with ping-pong buffers (control word at0x3A000000, buf0 at0x3A000100, buf1 at0x3A04B100)rtl/native_video_timing.sv— 320×240 @ 15.734 kHz NTSC native CRT timingrtl/native_video_top.sv— wrapper20 MHz→27.027 MHz(required for the 15.734 kHz NTSC line rate)What's deliberately not carried forward
To preserve original menu behavior:
"MENU"(sois_menu()in Main_MiSTer keeps matching; F1 wallpaper cycle keeps working)VIDEO_ARX/ARYstay0/0(no aspect-ratio change in cosine mode)ce_pixPAL/NTSC scandoubler logic intactThe mux
native_active = enable & frame_ready, so until the launcher fills the first DDR buffer, the cosine pattern keeps driving the output — no undriven screen on toggle.DDR clear loop
Removed. It was one-time boot scaffolding driving DDRAM_* with zeros;
native_video_readernow owns those signals. Whenstatus[9]=0the reader holdsddr_rd=0/ddr_we=0, so DDR is unused in default mode just as before.Test plan
status[9]=1): 320×240 RGBX content from DDR appears on CRT and HDMI (HDMI via ascal scaling)Notes for follow-up (out of scope here)
Main_MiSTer/menu.cppto flipstatus[9]+video_fb_enable(0/1)+input_switch(0/1)atomically — keep tracking in a separate PR on the Main_MiSTer forknative_video_timing(320×240 at 50 Hz with H_TOTAL=432, V_TOTAL=312) keyed offstatus[4]— defer until 320×240 NTSC is validated on hardware🤖 Generated with Claude Code