Video service (SNES backend) and field vblank video ports #48

Merged
Gatchan merged 6 commits from video-service into main 2026-11-03 14:05:15 +00:00
Owner

Video platform service with SNES backend, and the first ports that touch the hardware (#33).

  • core/platform/video.h: vid_set_brightness, vid_upload_colors, vid_upload_sprites; contracts documented in the header. Design and the planned operations for the next leaves are in docs/platform.md.
  • core/hw/hw_video.c: performs the original register writes and DMA in the same order with the same values. A per-module upload style record covers the SNES encoding details; only the field style exists. A started DMA completes before the call returns.
  • Shadow (core/port/port.c): VRAM, CGRAM and OAM mismatches now give the exact word. Ports that declare PORT_WRITES_PPU or PORT_WRITES_DMA also get their PPU and DMA channel registers compared. Writes a port did not declare are reported as mismatches.
  • RAM map: kind = "hardware_buffer" entries get *_buffer(g) pointer accessors (sprite_table, field_palettes). The fade direction meaning is fixed (bit 7 = fade out).
  • Ports: field_update_brightness, field_upload_palettes, field_upload_sprites (core/game/field/field_screen.c).

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.

Fixes #33. Follow-up: #47 (LakeSnes brightness global).

🤖 Generated with Claude Code

Video platform service with SNES backend, and the first ports that touch the hardware (#33). - `core/platform/video.h`: `vid_set_brightness`, `vid_upload_colors`, `vid_upload_sprites`; contracts documented in the header. Design and the planned operations for the next leaves are in `docs/platform.md`. - `core/hw/hw_video.c`: performs the original register writes and DMA in the same order with the same values. A per-module upload style record covers the SNES encoding details; only the field style exists. A started DMA completes before the call returns. - Shadow (`core/port/port.c`): VRAM, CGRAM and OAM mismatches now give the exact word. Ports that declare `PORT_WRITES_PPU` or `PORT_WRITES_DMA` also get their PPU and DMA channel registers compared. Writes a port did not declare are reported as mismatches. - RAM map: `kind = "hardware_buffer"` entries get `*_buffer(g)` pointer accessors (`sprite_table`, `field_palettes`). The fade direction meaning is fixed (bit 7 = fade out). - Ports: `field_update_brightness`, `field_upload_palettes`, `field_upload_sprites` (core/game/field/field_screen.c). 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. Fixes #33. Follow-up: #47 (LakeSnes brightness global). 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Gatchan deleted branch video-service 2026-11-03 14:05:16 +00:00
Sign in to join this conversation.
No reviewers
No milestone
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!48
No description provided.