Skip to content

Add sprites sample#87

Merged
jonathanpeppers merged 1 commit intomainfrom
sprites.c
Feb 14, 2026
Merged

Add sprites sample#87
jonathanpeppers merged 1 commit intomainfrom
sprites.c

Conversation

@jonathanpeppers
Copy link
Owner

Summary

Implements the 8bitworkshop sprites.c demo - 32 hardware sprites bouncing around the screen with random velocities.

Reduced from 64 to 32 actors because 4 arrays x 64 bytes = 256 bytes exceeds the NES zero-page local memory available.

APIs used

pal_all, oam_clear, oam_spr (5 params with return value), oam_hide_rest, ppu_on_all, ppu_wait_frame, rand8().
All patterns already supported - no transpiler changes needed.

Testing

All 168 tests pass (166 existing + 2 new).

Copilot AI review requested due to automatic review settings February 14, 2026 22:42
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new sprites sample (based on the 8bitworkshop sprites.c demo) to the dotnes repo, and wires it into the existing snapshot-based transpiler test suite and sample documentation.

Changes:

  • Adds samples/sprites (C# implementation + CHR data + csproj) and registers it in samples/samples.sln.
  • Adds new test inputs (sprites.debug.dll / sprites.release.dll) and a new verified ROM snapshot for TranspilerTests.Write.sprites.
  • Updates docs/8bitworkshop-samples.md to mark sprites.c as implemented.

Reviewed changes

Copilot reviewed 7 out of 10 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
src/dotnes.tests/TranspilerTests.cs Adds sprites to the snapshot test matrix (debug + release).
src/dotnes.tests/TranspilerTests.Write.sprites.verified.bin New expected ROM output snapshot for the sprites sample.
src/dotnes.tests/Data/sprites.release.dll New release-mode test input DLL for transpilation.
src/dotnes.tests/Data/sprites.debug.dll New debug-mode test input DLL for transpilation.
samples/sprites/sprites.csproj New sample project definition for sprites.
samples/sprites/sprites.c Reference C source for the original demo being ported.
samples/sprites/chr_generic.s CHR ROM data used by the sample.
samples/sprites/Program.cs C# top-level program implementing the sprites sample behavior.
samples/samples.sln Registers the new sprites sample project in the samples solution.
docs/8bitworkshop-samples.md Moves sprites.c into “Already Implemented” and documents required APIs.

Implements the 8bitworkshop sprites.c demo using oam_spr to animate
32 individual hardware sprites with random positions and velocities.
Reduced from 64 to 32 actors due to NES zero-page memory limits.

Uses: pal_all, oam_clear, oam_spr (5 params with return value),
oam_hide_rest, ppu_on_all, ppu_wait_frame, rand8().

Fix oam_spr to always use decsp4 argument passing pattern, which
correctly handles runtime args from array elements (ldelem_u1) and
locals (ldloc_s). The IL arg scanner now recognizes Ldloc_s and
Ldelem_u1 (array + index pair) in addition to Ldloc_0..3 and Ldc.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@jonathanpeppers jonathanpeppers merged commit 845b1f9 into main Feb 14, 2026
1 check passed
@jonathanpeppers jonathanpeppers deleted the sprites.c branch February 14, 2026 23:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant