Video platform service (SNES backend): commands for PPU registers, VRAM/CGRAM/OAM uploads, HDMA tables #33

Closed
opened 2026-10-29 20:36:27 +00:00 by Gatchan · 2 comments
Owner

Brief §5 (platform services, "commands, not diffs") and §7.4 (no PPU/DMA register number in core/game). Needed before porting field routines that write PPU registers or start DMA (TfrObjGfxSub, InitMaskHDMAData, UpdateScrollHDMA, UpdateFixedColor, TfrBGAnimGfx, SetTopSpriteMSB...).

  1. core/platform/video.h: operations named for what they do (upload tiles/tilemap/palette/OAM, set scroll, layer/window/colour-math state, HDMA channel tables, brightness/forced blank), game-facing types.
  2. SNES backend in core/hw/: performs exactly the register writes and DMA transfers the original does (same order and values), so per-call shadow keeps comparing VRAM/CGRAM/OAM/PPU registers byte for byte.
  3. Shadow comparison extended to PPU registers and DMA/HDMA channel registers where needed.
  4. Port one hardware-touching field leaf with it as proof (e.g. SetTopSpriteMSB or UpdateFixedColor), shadow 0 mismatch US+JP.
Brief §5 (platform services, "commands, not diffs") and §7.4 (no PPU/DMA register number in core/game). Needed before porting field routines that write PPU registers or start DMA (TfrObjGfxSub, InitMaskHDMAData, UpdateScrollHDMA, UpdateFixedColor, TfrBGAnimGfx, SetTopSpriteMSB...). 1. `core/platform/video.h`: operations named for what they do (upload tiles/tilemap/palette/OAM, set scroll, layer/window/colour-math state, HDMA channel tables, brightness/forced blank), game-facing types. 2. SNES backend in `core/hw/`: performs exactly the register writes and DMA transfers the original does (same order and values), so per-call shadow keeps comparing VRAM/CGRAM/OAM/PPU registers byte for byte. 3. Shadow comparison extended to PPU registers and DMA/HDMA channel registers where needed. 4. Port one hardware-touching field leaf with it as proof (e.g. SetTopSpriteMSB or UpdateFixedColor), shadow 0 mismatch US+JP.
Author
Owner

Starting now (branch video-service), after #32. Order: platform video API, SNES backend reproducing the exact writes, shadow extended to PPU/DMA state, one hardware-touching field leaf as proof.

Starting now (branch `video-service`), after #32. Order: platform video API, SNES backend reproducing the exact writes, shadow extended to PPU/DMA state, one hardware-touching field leaf as proof.
Author
Owner

Done in PR (merged). Evidence (release build, routes = the five committed movies, all ports in shadow):

  • New ports field/UpdateBrightness, field/TfrPal, field/TfrSprites: shadow 0 mismatch, 0 skipped, 0 fallback; US 74 738 calls each, JP 68 636 each. The shadow now also compares PPU and DMA channel registers for these ports.
  • Earlier field ports: counts identical to docs/ports.md with the extended comparison.
  • Fuzz (fades incl. wrap-around, random palettes and sprite tables): US 8 628/8 628, JP 7 937/7 937, 0 mismatch. A recheck after the review fixes (2 routes + fuzz 40, US+JP) also gave 0 mismatch.
  • Original instructions executed: UpdateBrightness 30/30, TfrSprites 16/16, TfrPal 16/16 (US and JP).
  • Negative tests: a wrong DMA control byte is reported as DMA channel 0 indirect byte 0: 01/00; an undeclared PPU write is reported as writes PPU registers not declared PORT_WRITES_PPU.
  • ctest: release 61/61 incl. route_ports_on 5/5 US+JP (10 748 s); debug and clang -LE slow 24/24; 0 warnings.
  • Independent readability review: merge after must-fix. Applied (0649296): the style record covers every per-module choice, undeclared hardware writes and unreachable upload sources are reported, video contracts moved to the header; plus casts, the field_base_palettes rename and the JP check on rSpritesHi.
Done in PR (merged). Evidence (release build, routes = the five committed movies, all ports in shadow): - New ports `field/UpdateBrightness`, `field/TfrPal`, `field/TfrSprites`: shadow 0 mismatch, 0 skipped, 0 fallback; US 74 738 calls each, JP 68 636 each. The shadow now also compares PPU and DMA channel registers for these ports. - Earlier field ports: counts identical to docs/ports.md with the extended comparison. - Fuzz (fades incl. wrap-around, random palettes and sprite tables): US 8 628/8 628, JP 7 937/7 937, 0 mismatch. A recheck after the review fixes (2 routes + fuzz 40, US+JP) also gave 0 mismatch. - Original instructions executed: UpdateBrightness 30/30, TfrSprites 16/16, TfrPal 16/16 (US and JP). - Negative tests: a wrong DMA control byte is reported as `DMA channel 0 indirect byte 0: 01/00`; an undeclared PPU write is reported as `writes PPU registers not declared PORT_WRITES_PPU`. - ctest: release 61/61 incl. route_ports_on 5/5 US+JP (10 748 s); debug and clang -LE slow 24/24; 0 warnings. - Independent readability review: merge after must-fix. Applied (0649296): the style record covers every per-module choice, undeclared hardware writes and unreachable upload sources are reported, video contracts moved to the header; plus casts, the `field_base_palettes` rename and the JP check on rSpritesHi.
Sign in to join this conversation.
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
Gatchan/FF6Portage#33
No description provided.