Skip to content

Port 8bitworkshop monobitmap.c sample: UxROM mapper with CHR RAM#175

Merged
jonathanpeppers merged 4 commits intomainfrom
copilot/port-monobitmap-sample
Mar 14, 2026
Merged

Port 8bitworkshop monobitmap.c sample: UxROM mapper with CHR RAM#175
jonathanpeppers merged 4 commits intomainfrom
copilot/port-monobitmap-sample

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 14, 2026

Adds the monobitmap sample demonstrating UxROM mapper (mapper 2) with CHR RAM — no transpiler changes needed, the infrastructure already supports arbitrary mapper numbers and NESChrBanks=0.

Sample

Simplified port of 8bitworkshop's monobitmap.c. Uploads custom tile patterns to CHR RAM at runtime via vram_write(), arranges them in the nametable to draw a bordered rectangle with diagonal fill, and uses poke() for direct PPU register manipulation.

<!-- monobitmap.csproj -->
<NESMapper>2</NESMapper>
<NESChrBanks>0</NESChrBanks>

The original's inline assembly delay loops, vram_read() with pointers, and abs() are not portable to dotnes — this port focuses on the core UxROM + CHR RAM + poke() demonstration.

Changes

  • samples/monobitmap/ — Program.cs, .csproj (mapper 2, chrBanks=0), chr_generic.s placeholder
  • src/dotnes.tests/ — Debug/release test DLLs, InlineData entries in TranspilerTests.Write, verified ROM snapshot
  • docs/8bitworkshop-samples.md — monobitmap moved from 🔴 Complex → ✅ Implemented

ROM verification

iNES header: 4E45531A 0200 2000 — mapper 2 (UxROM), 0 CHR banks (CHR RAM), 2 PRG banks. 32,784 bytes total (16 header + 32K PRG, no CHR ROM). All 389 tests pass.

Original prompt

This section details on the original issue you should resolve

<issue_title>Port 8bitworkshop sample: monobitmap.c</issue_title>
<issue_description>Port the monobitmap.c sample from 8bitworkshop. This demonstrates UxROM mapper with CHR RAM for a 256x240 monochrome bitmap.

Features needed

Complexity: High

Requires mapper + CHR RAM infrastructure.

8bitworkshop reference

https://8bitworkshop.com/ (monobitmap.c)
</issue_description>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 2 commits March 14, 2026 03:16
Co-authored-by: jonathanpeppers <840039+jonathanpeppers@users.noreply.github.com>
Co-authored-by: jonathanpeppers <840039+jonathanpeppers@users.noreply.github.com>
Copilot AI changed the title [WIP] Port monobitmap.c sample from 8bitworkshop Port 8bitworkshop monobitmap.c sample: UxROM mapper with CHR RAM Mar 14, 2026
Copilot AI requested a review from jonathanpeppers March 14, 2026 03:21
@jonathanpeppers jonathanpeppers marked this pull request as ready for review March 14, 2026 03:45
Copilot AI review requested due to automatic review settings March 14, 2026 03:45
Copy link
Copy Markdown
Contributor

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 monobitmap sample to the dotnes repository to demonstrate UxROM (mapper 2) with CHR RAM (NESChrBanks=0), including ROM snapshot coverage and documentation updates for the 8bitworkshop port status.

Changes:

  • Add samples/monobitmap/ (Program + project settings for mapper 2 / CHR RAM).
  • Add transpiler snapshot coverage for monobitmap (InlineData + verified ROM + test DLLs).
  • Update 8bitworkshop sample status documentation to mark monobitmap.c as implemented (simplified).

Reviewed changes

Copilot reviewed 5 out of 8 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/dotnes.tests/TranspilerTests.cs Adds snapshot test cases for the new monobitmap sample with mapper=2 and chrBanks=0.
src/dotnes.tests/TranspilerTests.Write.monobitmap.verified.bin Adds the verified ROM output snapshot for monobitmap.
src/dotnes.tests/Data/monobitmap.release.dll Adds prebuilt release test input DLL for the snapshot tests.
src/dotnes.tests/Data/monobitmap.debug.dll Adds prebuilt debug test input DLL for the snapshot tests.
samples/monobitmap/monobitmap.csproj New sample project configured for UxROM + CHR RAM.
samples/monobitmap/chr_generic.s Placeholder CHR segment file consistent with CHR RAM builds.
samples/monobitmap/Program.cs New sample program that uploads tiles to CHR RAM and draws a simple monochrome scene using VRAM ops and poke().
docs/8bitworkshop-samples.md Marks monobitmap.c as implemented (simplified) and updates summary counts.

Comment thread samples/monobitmap/Program.cs
@jonathanpeppers jonathanpeppers force-pushed the copilot/port-monobitmap-sample branch from 45c4724 to 01c89e6 Compare March 14, 2026 16:57
The monobitmap sample had poke(PPU_CTRL, 0) and poke(PPU_MASK, 0) at
startup to disable rendering during VRAM writes. However, poke(PPU_CTRL, 0)
disables NMI, which causes ppu_on_all -> ppu_onoff -> ppu_wait_nmi to hang
forever since NMI never fires to increment STARTUP.

Fix: Remove both poke calls. Rendering is already off at startup (neslib
initializes with PPU_MASK=0), so they were redundant. NMI stays enabled
from the startup code, allowing ppu_wait_nmi to work correctly.

Also: added peek(PPU_STATUS) before scroll writes per review feedback,
added trailing newline to chr_generic.s, added monobitmap screenshot.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@jonathanpeppers jonathanpeppers force-pushed the copilot/port-monobitmap-sample branch from 01c89e6 to 674cedf Compare March 14, 2026 17:15
@jonathanpeppers jonathanpeppers merged commit 7bf4db1 into main Mar 14, 2026
1 check passed
@jonathanpeppers jonathanpeppers deleted the copilot/port-monobitmap-sample branch March 14, 2026 20:19
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.

Port 8bitworkshop sample: monobitmap.c

3 participants