Add oam_spr_2x2 for drawing 16x16 sprites from sequential tiles#446
Draft
Add oam_spr_2x2 for drawing 16x16 sprites from sequential tiles#446
Conversation
- Add oam_spr_2x2 method stub in NESLib.cs with 8 parameters - Add IL dispatch case in IL2NESWriter.ILDispatch.cs - Implement EmitOamSpr2x2() handler that builds metasprite array at compile time and emits oam_meta_spr call - Ensure oam_meta_spr subroutine is included when oam_spr_2x2 is used - Update staticsprite and movingsprite samples to use oam_spr_2x2 - Add two RoslynTests for constant and local argument patterns - Update PublicAPI.Unshipped.txt Agent-Logs-Url: https://github.com/jonathanpeppers/dotnes/sessions/21fbfb2a-9c75-4408-b1f8-04fea4eee6a9 Co-authored-by: jonathanpeppers <840039+jonathanpeppers@users.noreply.github.com>
Agent-Logs-Url: https://github.com/jonathanpeppers/dotnes/sessions/21fbfb2a-9c75-4408-b1f8-04fea4eee6a9 Co-authored-by: jonathanpeppers <840039+jonathanpeppers@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Add oam_spr_2x2 for drawing 16x16 sprites from sequential tiles
Add oam_spr_2x2 for drawing 16x16 sprites from sequential tiles
Apr 4, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Drawing a 2×2 (16×16) sprite currently requires 4
oam_sprcalls with manual offset math.oam_spr_2x2replaces this with a single call:Implementation
Implemented as a compile-time intrinsic — no new 6502 subroutine needed:
NESLib.cs— Method stub:byte oam_spr_2x2(byte x, byte y, byte topLeft, byte bottomLeft, byte topRight, byte bottomRight, byte attr, byte sprid)IL2NESWriter.OamSprites.cs—EmitOamSpr2x2()handler that:Stlocskip logic for Roslyn Release optimizer reordering)oam_meta_sprcalling convention (TEMP=x, TEMP2=y, PTR=array, A=sprid)IL2NESWriter.ILDispatch.cs— Dispatch routingProgram6502.cs— Includeoam_meta_sprsubroutine whenoam_spr_2x2is usedSample updates
oam_spr→ 1oam_spr_2x2(all constant args)oam_spr→ 1oam_spr_2x2(local x/y, constant tiles)Tests
Two
RoslynTestsadded:OamSpr2x2WithConstantArgsandOamSpr2x2WithLocalArgs.