Field batch 2: 15 routines with the porting tools (fixes #54) #55

Merged
Gatchan merged 3 commits from field-batch2 into main 2026-11-04 13:54:40 +00:00
Owner

Field batch 2 (refs #54, fixes #54): 15 field routines ported with the tools (draftc -> draft_check -> port -> generated bridge -> groundtruth + shadow).

Ported: SetTopSpriteMSB, SetBtmSpriteMSB, FixPlayerSpritePriority, UpdateObjLayerPriorityAfter, UpdateMosaic, UpdateFixedColor, UpdatePalAnimPulse, UpdateShake, Rand (field), ShiftPrevLetter, DrawLetter, CopyDlgTextToBuf, ClearTextGfxBuf, CloseMapTitleWindow, CheckTimer.

New tool: tools/portbridge.py generates each bridge and registry row from the routine's drafts (entry guards, live outputs from liveness, don't-care set, hardware writes); the porter states how each live output the routine may change is left (--set/--same), the tool refuses otherwise. Documented in docs/drafts.md.

Validation

  • Drafts proven first (draft_check, 28 drafts, title_to_mines_save + field_menu_tour US/JP): 436 407 calls, 2 mismatches, both SetWindowSelect (PPU BG1 hscroll changed by HDMA during the original, not written by it) -> SetWindowSelect skipped.
  • Shadow, 5 routes, all ports: US 745 371 calls of the 15 ports, JP 668 195, 0 mismatch, 0 fallback (UpdateMosaic guard fixed after 7 fallbacks/version on narshe_to_world_map, rerun 0/0); every movie matches its end hashes.
  • Fuzz (field_menu_tour state, 120 iterations/version + callees alone 60): 0 mismatch, 0 fallback.
  • Original instructions executed (routes + fuzz coverage): 683/683 US, 683/683 JP.
  • groundtruth: 16/30 same; the differences are tool limits (buffer accessors, scratch carried by the bridge, overlapping HDMA element names) and UpdateShake reading the offsets to keep their low byte.
  • portstyle 0 findings; debug and clang builds 0 warnings, ctest -LE slow 27/27 each.

Skipped: SetWindowSelect (PPU compare noise, needs a window video service), TfrBGAnimGfx/TfrBG3AnimGfx/TfrObjGfxSub (VRAM DMA with partial register setups: need a vid VRAM upload service; TfrObjGfxSub keeps everything live), InitBG1/2VScroll, _c0249a, UpdateBG1, UpdateBG3HScroll, UpdateScrollHDMA, InitMaskHDMAData, _c0714a, MoveObjs, DrawOverlaySprites, LoadLetterGfx, UpdateDlgWindow (larger, scratch-heavy: next batch). Frame-crossing routines not attempted (#37).

🤖 Generated with Claude Code

Field batch 2 (refs #54, fixes #54): 15 field routines ported with the tools (draftc -> draft_check -> port -> generated bridge -> groundtruth + shadow). Ported: SetTopSpriteMSB, SetBtmSpriteMSB, FixPlayerSpritePriority, UpdateObjLayerPriorityAfter, UpdateMosaic, UpdateFixedColor, UpdatePalAnimPulse, UpdateShake, Rand (field), ShiftPrevLetter, DrawLetter, CopyDlgTextToBuf, ClearTextGfxBuf, CloseMapTitleWindow, CheckTimer. New tool: `tools/portbridge.py` generates each bridge and registry row from the routine's drafts (entry guards, live outputs from liveness, don't-care set, hardware writes); the porter states how each live output the routine may change is left (`--set`/`--same`), the tool refuses otherwise. Documented in docs/drafts.md. Validation - Drafts proven first (draft_check, 28 drafts, title_to_mines_save + field_menu_tour US/JP): 436 407 calls, 2 mismatches, both SetWindowSelect (PPU BG1 hscroll changed by HDMA during the original, not written by it) -> SetWindowSelect skipped. - Shadow, 5 routes, all ports: US 745 371 calls of the 15 ports, JP 668 195, 0 mismatch, 0 fallback (UpdateMosaic guard fixed after 7 fallbacks/version on narshe_to_world_map, rerun 0/0); every movie matches its end hashes. - Fuzz (field_menu_tour state, 120 iterations/version + callees alone 60): 0 mismatch, 0 fallback. - Original instructions executed (routes + fuzz coverage): 683/683 US, 683/683 JP. - groundtruth: 16/30 same; the differences are tool limits (buffer accessors, scratch carried by the bridge, overlapping HDMA element names) and UpdateShake reading the offsets to keep their low byte. - portstyle 0 findings; debug and clang builds 0 warnings, `ctest -LE slow` 27/27 each. Skipped: SetWindowSelect (PPU compare noise, needs a window video service), TfrBGAnimGfx/TfrBG3AnimGfx/TfrObjGfxSub (VRAM DMA with partial register setups: need a vid VRAM upload service; TfrObjGfxSub keeps everything live), InitBG1/2VScroll, _c0249a, UpdateBG1, UpdateBG3HScroll, UpdateScrollHDMA, InitMaskHDMAData, _c0714a, MoveObjs, DrawOverlaySprites, LoadLetterGfx, UpdateDlgWindow (larger, scratch-heavy: next batch). Frame-crossing routines not attempted (#37). 🤖 Generated with [Claude Code](https://claude.com/claude-code)
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!55
No description provided.