Mode 7 Mandelbrot (OOP)
FractalsThe same 64×56 fixed-point Mandelbrot as Mode 7
Mandelbrot — rebuilt through the snesgfx object-oriented C interface
instead of procedural snes_* calls. A formal verification client: it proves Mode
7 works as a polymorphic Drawable, with one coarse-grained virtual dispatch per
frame, never inside the per-pixel loop.
Self-running — the fractal reveals coarse-to-fine, then spins and zooms.
Click the screen, then play. (Tab away and it pauses.)
What it is
Pixel-for-pixel the same computation as Mode 7
Mandelbrot, but every hardware interaction is routed through snesgfx's
Drawable interface (reserve/emit) instead of direct
register writes — the object-oriented C pattern this toolchain's SNES library is built
on.
Object-oriented C on the 65816
| Item | What it exercises |
|---|---|
| Mode 7 as a Drawable | The Mandelbrot layer is a MandelLayer struct whose first member is the base Drawable — a C vtable upcast, not a language feature. scene_emit() dispatches through one virtual call per Drawable per frame (never inside the inner mandel_cell loop), proving the OOP-in-C pattern stays coarse-grained. |
| zero bare REG_*/snes_* in main() | main() never touches a hardware register or a snes_* call directly — every side effect flows through the Drawable interface (reserve/emit), the same discipline the snesgfx library uses for every other demo. |
| same fractal, same answer | Pixel math, grid, and far-pointer WRAM buffer are identical to mandel-display.c — same corpus_result CRC (0x204F). This program exists purely to prove the OOP path costs nothing behaviourally: procedural and OOP must render bit-identical images. |
| result: correct | LTO devirtualizes the single-drawable dispatch to zero indirect JMPs; OOP overhead is +338 B (+10%) vs the procedural version for the vtable/upcast scaffolding. host == +mos-a16 on bsnes-jg, -verify-machineinstrs clean. |
Written in C with the llvm-mos 65816 toolchain and verified against bsnes-jg.
Hit Verify fidelity to reproduce the build gate's WRAM assert
(image CRC 0x204F, matching the procedural version exactly) live in this tab.
host == +mos-a16, -verify clean.