Skip to content

Draw BG modes 4-6 with the compatibility renderer under NewRenderer - #215

Merged
mstan merged 1 commit into
RetroPortingToolKit:mainfrom
pogoflow:fix/ppu-modes-4-6-new-renderer
Oct 27, 2026
Merged

mstan merged 1 commit into
RetroPortingToolKit:mainfrom
pogoflow:fix/ppu-modes-4-6-new-renderer

Conversation

@pogoflow

Copy link
Copy Markdown
Contributor

PpuDrawWholeLine implements modes 0-3 and treats every other mode as mode 7. With NewRenderer on, a mode 4, 5 or 6 screen therefore samples BG1's tilemap as a mode-7 pixel map. I hit this on a HiROM title: a mode 5 menu (hi-res text over a 4bpp background) came out as vertical colour stripes, while VRAM, CGRAM and OAM matched a reference emulator. NewRenderer = 1 is the host default, and widescreen forces it, so the reference renderer is not a way out there.

Change
ppu_runLine routes modes 4-6 to ppu_draw_whole_line_legacy, which already handles 16-pixel-wide tiles, the hi-res column split and offset-per-tile. Modes 0-3 and 7 stay on the optimized path. This is meant as a correct fallback until the optimized renderer grows those modes, not as a replacement for that work.

Test
tests/ppu/ppu_hires_mode_test.c (no ROM needed): for modes 4, 5 and 6 the optimized renderer must produce the compatibility renderer's scanline, mode 5 must show the 16-pixel tile split, and mode 1 must stay on the optimized path. It is registered in tests/ppu/run.ps1 and tests/run_c_tests.sh.

Against unchanged ppu.c, 6 checks fail (modes 4/5/6 differ from the compatibility scanline, and the mode 5 tile split is missing). With the change it passes. tests/ppu/run.ps1 passes all six PPU tests, and the compiler warning count for ppu.c is unchanged. Full Python suite on the branch: 846 passed, 2 skipped (Windows, MinGW gcc 16.2).

On Windows, tests/run_c_tests.sh passes every section up to and including the PPU ones, then stops at "SNES lobby caps" because setenv/unsetenv don't exist on MinGW. That test and its section are untouched by this change.

PpuDrawWholeLine implements modes 0-3 and treats every other mode as
mode 7. A mode 4, 5 or 6 screen therefore sampled BG1's tilemap as a
mode-7 pixel map: a mode 5 menu with hi-res text over a 4bpp background
came out as vertical colour stripes, while VRAM, CGRAM and OAM matched a
reference emulator. Found on a HiROM title.

ppu_runLine now routes modes 4-6 to ppu_draw_whole_line_legacy, which
already handles 16-pixel-wide tiles, the hi-res column split and
offset-per-tile, until the optimized renderer grows them. Modes 0-3 and 7
are unchanged.

tests/ppu/ppu_hires_mode_test.c: for modes 4, 5 and 6 the optimized
renderer must produce the compatibility renderer's scanline, mode 5 must
show the 16-pixel tile split, and mode 1 stays on the optimized path.
Registered in tests/ppu/run.ps1 and tests/run_c_tests.sh.

@mstan mstan left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

No blocking code findings. The per-scanline mode check routes only the unsupported modes 4/5/6 to the existing compatibility renderer; modes 0–3 and 7 retain the optimized path. The fallback preserves the compatibility renderer's existing 256-sample hi-res presentation; it does not claim full 512-pixel output.

Reviewed with #199 and #214 on current main 246c0d4. All six production PPU tests pass, including the new regression. Extra compiled checks compare the fallback at 256/342/512/800-pixel output widths and verify framebuffer guards. The combined tree also passes the codegen width lint, 860 Python tests (2 platform skips), and the production runtime dispatch fixture. All three workflows on this reviewed PR head are green.

The shared regression branch is review/open-prs-final-20261026 (b19edfb). This is code and automated-fixture approval; the new #214/#215 pair still needs the normal combined title gameplay/current-build save-load/runtime gate and owner handoff before merge. The fixtures alone do not establish real-title menu appearance or frame times. No games were relaunched in this review.

@mstan mstan left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Combined regression follow-up: this reviewed head is included with #199/#214 on current-main integration branch review/open-prs-final-20261026 at b19edfb. All 860 Python tests (2 platform skips), six production PPU harnesses, runtime dispatch and extra 256/342/512/800-pixel framebuffer-bound checks pass. Existing 256-sample hi-res presentation remains the supported limitation.

All eight matched baseline/candidate Release builds are provenance-stamped. Muted gameplay, movement, current-build save/load and nonzero emulated audio checks pass in Mega Man X, ALttP, SMW and Super Metroid. Brief built-runtime checks show no consistent introduced regression, including opposite-order SM repeats after an initial timing outlier. SMW's bounded Yoshi's House check remains paced near 60fps and does not establish wide-stage margins; SM's original Zebes-loader setup bypasses Ceres.

The automated combined gate is complete. Approval stands; the owner's quick visual/play check of the new #214/#215 batch remains pending before merge. No author changes requested.

mstan added a commit that referenced this pull request Oct 27, 2026
…racts-193

Share HiROM contracts and evidence while preserving execution banks.

Qualified in the combined #199/#214/#215 regression batch at b19edfb: 860 Python tests, native checks, and four representative matched gameplay/save-load/runtime checks. Owner explicitly approved merge after regression confirmation.
mstan added a commit that referenced this pull request Oct 27, 2026
Clear the index high bytes when the X flag is set.

Qualified in the combined #199/#214/#215 regression batch at b19edfb: 860 Python tests, native checks, and four representative matched gameplay/save-load/runtime checks. Owner explicitly approved merge after regression confirmation.
@mstan
mstan merged commit 503063e into RetroPortingToolKit:main Oct 27, 2026
8 checks 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.

2 participants