Skip to content

Wire up transpiler recognition for oam_begin / OamFrame.Dispose #430

@jonathanpeppers

Description

@jonathanpeppers

Context

This is Phase 3 of the using var pattern support (#427). Depends on #428 (try/finally) and #429 (OamFrame struct).

Proposed transpiler changes

The transpiler needs to recognize two method calls and emit the corresponding 6502 code:

oam_begin()

When the transpiler sees a call to NESLib.oam_begin(), emit:

LDA #0
STA oam_off      ; reset OAM buffer offset
JSR oam_clear    ; clear all sprite entries

The return value (OamFrame struct) is a zero-size sentinel -- no actual data needs to be stored.

OamFrame.Dispose()

When the transpiler sees a call to OamFrame.Dispose() (which appears in the finally block), emit:

LDA oam_off
JSR oam_hide_rest  ; hide all unused OAM entries from current offset

Detection approach

The transpiler already recognizes method names for built-in subroutine dispatch. This follows the same pattern:

  1. In Transpiler.cs: detect oam_begin in the used methods set, add OamClear to required subroutines
  2. In IL2NESWriter.cs: add cases for oam_begin and Dispose calls on the OamFrame type
  3. Ensure oam_hide_rest is included in the subroutine list when OamFrame is used

Part of #427

Metadata

Metadata

Labels

enhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions