Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 9 additions & 13 deletions docs/8bitworkshop-samples.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
>
> Analysis based on dotnes transpiler capabilities and the `NESLib.cs` API surface.
>
> Existing dotnes samples: `hello`, `hellofs`, `staticsprite`, `movingsprite`, `attributetable`, `flicker`, `metasprites`, `music`, `lols`, `tint`, `scroll`, `rletitle`, `tileset1`
> Existing dotnes samples: `hello`, `hellofs`, `staticsprite`, `movingsprite`, `attributetable`, `flicker`, `metasprites`, `music`, `lols`, `tint`, `scroll`, `rletitle`, `tileset1`, `sprites`

---

Expand Down Expand Up @@ -64,20 +64,16 @@
- **dotnes sample:** `tileset1`
- **Missing Features:** None — uses `pal_bg`, `vram_adr`, `vram_write`, `ppu_on_all`. The CHR RAM approach is replaced with CHR ROM containing the same tileset data, padded so ASCII codes map directly to tile indices.

### sprites.c
- **Description:** Animates 32 hardware sprites moving around the screen with random velocities, wrapping at screen edges.
- **Status:** ✅ Already Implemented
- **dotnes sample:** `sprites`
- **Missing Features:** None — uses `pal_all`, `oam_clear`, `oam_spr`, `oam_hide_rest`, `ppu_on_all`, `ppu_wait_frame`, `rand8()`. Reduced from 64 to 32 actors due to NES zero-page memory constraints.

Comment thread
jonathanpeppers marked this conversation as resolved.
---

## 🟠 Moderate (Significant Work Needed)

### sprites.c
- **Description:** Animates all 64 hardware sprites bouncing around the screen with random velocities.
- **Status:** 🟠 Moderate
- **Missing Features:**
- User-defined functions (`setup_graphics`) — must be inlined
- `for` loops → must use `while` loops
- `sbyte` (signed byte) arrays and signed arithmetic (`actor_dx`, `actor_dy`)
- Global arrays of fixed size (`byte actor_x[64]`, etc.) — dotnes only supports local arrays
- `ppu_wait_frame()` — may lack transpiler support

### metacursor.c
- **Description:** Reads controller input to move metasprites, demonstrating `pad_poll` for two players.
- **Status:** 🟠 Moderate
Expand Down Expand Up @@ -352,9 +348,9 @@

| Status | Count | Samples |
|--------|-------|---------|
| ✅ Already Implemented | 10 | hello, attributes, flicker, metasprites, music, tint, scroll, rletitle, tileset1 |
| ✅ Already Implemented | 11 | hello, attributes, flicker, metasprites, music, tint, scroll, rletitle, tileset1, sprites |
| 🟡 Feasible | 0 | |
| 🟠 Moderate | 8 | sprites, metacursor, metatrigger, apu, bcd, statusbar, vrambuffer, vrambuf |
| 🟠 Moderate | 7 | metacursor, metatrigger, apu, bcd, statusbar, vrambuffer, vrambuf |
| 🔴 Complex | 14 | aputest, ppuhello, fami, horizscroll, horizmask, bankswitch, monobitmap, conio, crypto, climber, transtable, irq, shoot2, siegegame |

### Key Blockers (by frequency)
Expand Down
14 changes: 14 additions & 0 deletions samples/samples.sln
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "rletitle", "rletitle\rletit
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "tileset1", "tileset1\tileset1.csproj", "{A17B6C20-20CD-4C25-A8D6-323B27A1EB63}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "sprites", "sprites\sprites.csproj", "{5DCF41AE-77F3-4DE7-B8D1-2B66D4903112}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -167,6 +169,18 @@ Global
{A17B6C20-20CD-4C25-A8D6-323B27A1EB63}.Release|x64.Build.0 = Release|Any CPU
{A17B6C20-20CD-4C25-A8D6-323B27A1EB63}.Release|x86.ActiveCfg = Release|Any CPU
{A17B6C20-20CD-4C25-A8D6-323B27A1EB63}.Release|x86.Build.0 = Release|Any CPU
{5DCF41AE-77F3-4DE7-B8D1-2B66D4903112}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5DCF41AE-77F3-4DE7-B8D1-2B66D4903112}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5DCF41AE-77F3-4DE7-B8D1-2B66D4903112}.Debug|x64.ActiveCfg = Debug|Any CPU
{5DCF41AE-77F3-4DE7-B8D1-2B66D4903112}.Debug|x64.Build.0 = Debug|Any CPU
{5DCF41AE-77F3-4DE7-B8D1-2B66D4903112}.Debug|x86.ActiveCfg = Debug|Any CPU
{5DCF41AE-77F3-4DE7-B8D1-2B66D4903112}.Debug|x86.Build.0 = Debug|Any CPU
{5DCF41AE-77F3-4DE7-B8D1-2B66D4903112}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5DCF41AE-77F3-4DE7-B8D1-2B66D4903112}.Release|Any CPU.Build.0 = Release|Any CPU
{5DCF41AE-77F3-4DE7-B8D1-2B66D4903112}.Release|x64.ActiveCfg = Release|Any CPU
{5DCF41AE-77F3-4DE7-B8D1-2B66D4903112}.Release|x64.Build.0 = Release|Any CPU
{5DCF41AE-77F3-4DE7-B8D1-2B66D4903112}.Release|x86.ActiveCfg = Release|Any CPU
{5DCF41AE-77F3-4DE7-B8D1-2B66D4903112}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
56 changes: 56 additions & 0 deletions samples/sprites/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/*
Sprite demo.
Animate 32 hardware sprites (reduced from 64 due to zero-page memory constraints).
Based on: https://github.com/sehugg/8bitworkshop/blob/master/presets/nes/sprites.c
*/

byte[] PALETTE = [
0x03, // screen color
0x11, 0x30, 0x27, 0x0, // background palette 0
0x1c, 0x20, 0x2c, 0x0, // background palette 1
0x00, 0x10, 0x20, 0x0, // background palette 2
0x06, 0x16, 0x26, 0x0, // background palette 3
0x16, 0x35, 0x24, 0x0, // sprite palette 0
0x00, 0x37, 0x25, 0x0, // sprite palette 1
0x0d, 0x2d, 0x3a, 0x0, // sprite palette 2
0x0d, 0x27, 0x2a // sprite palette 3
];

// actor positions and velocities (32 actors)
byte[] actor_x = new byte[32];
byte[] actor_y = new byte[32];
byte[] actor_dx = new byte[32];
byte[] actor_dy = new byte[32];

// initialize actors with random values
byte i = 0;
while (i < 32)
{
actor_x[i] = rand8();
actor_y[i] = rand8();
actor_dx[i] = (byte)((rand8() & 7) - 3);
actor_dy[i] = (byte)((rand8() & 7) - 3);
i = (byte)(i + 1);
}

// setup PPU
oam_clear();
pal_all(PALETTE);
ppu_on_all();

// main loop
while (true)
{
byte oam_id = 0;
i = 0;
while (i < 32)
{
oam_id = oam_spr(actor_x[i], actor_y[i], i, i, oam_id);
actor_x[i] = (byte)(actor_x[i] + actor_dx[i]);
actor_y[i] = (byte)(actor_y[i] + actor_dy[i]);
i = (byte)(i + 1);
Comment thread
jonathanpeppers marked this conversation as resolved.
}
if (oam_id != 0)
oam_hide_rest(oam_id);
ppu_wait_frame();
}
Loading