Skip to content

Add oam_spr_2x2 for drawing 16x16 sprites from sequential tiles #425

@jonathanpeppers

Description

@jonathanpeppers

Drawing a 2x2 (16x16) sprite from individual 8x8 tiles requires 4 separate oam_spr calls with manual offset math. This appears in staticsprite, movingsprite, pong, and other samples:

// Today: 4 calls with manual x+8, y+8 offsets and OAM slot math
oam_spr(x, y, 0xD8, 0, 0);
oam_spr((byte)(x + 8), y, 0xDA, 0, 4);
oam_spr(x, (byte)(y + 8), 0xD9, 0, 8);
oam_spr((byte)(x + 8), (byte)(y + 8), 0xDB, 0, 12);

Proposed API:

// Draw a 2x2 sprite grid from 4 tile indices, returns next sprid
byte sprid = oam_spr_2x2(x, y, 0xD8, 0xD9, 0xDA, 0xDB, attr, sprid);

This is the drawing counterpart to meta_spr_2x2 (#419 which creates metasprite data arrays). oam_spr_2x2 directly writes 4 entries into the OAM buffer with the standard 8-pixel offsets.

Parameters are (topLeft, bottomLeft, topRight, bottomRight) to match existing NES tile layout convention.

Once implemented, the staticsprite, movingsprite, and pong samples should be updated to use it.

Related to #30

Metadata

Metadata

Labels

enhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions