CRC32 Texture
Rendering & Graphics
A flowing "hash marble" on a Super Nintendo — every cell's colour is a real
CRC32 (the same checksum
zip and PNG use) of its (x, y, time) coordinates. It's computed the classic way:
a 256-entry look-up table baked into ROM, one indexed load per byte. Feed coordinates
through a checksum and you get a procedural texture that scatters neighbours to unrelated
colours and flows as time advances. Runs automatically; no joypad needed. Written in C and
compiled with the llvm-mos-based 65816
toolchain (+mos-a16, 16-bit accumulator mode).
Self-running demo — the hash field flows and mutates on its own.
Click the screen to focus, then watch. Tab away and it pauses.
What it is
A CRC is normally used to detect corruption: run your data through it and compare the number. The fast, standard way to compute one processes a byte at a time through a 256-entry table:
crc = 0xFFFFFFFF;
for (each byte b of (x, y, time)) {
crc = TABLE[(crc ^ b) & 0xFF] ^ (crc >> 8); // ← 256-entry ROM look-up
}
colour = crc & 0xF; // hash → palette index That table is a kilobyte of constants living in the cartridge ROM, and the inner loop is one indexed 32-bit load per byte. Here the "data" is each pixel's position and the frame counter, so the checksum becomes a colour — a deterministic pseudo-random field that flows as time advances. It stays bit-exact across every codegen mode.
Compiler stress-test
| Item | What it exercises |
|---|---|
| 256-entry ROM LUT | The CRC32 table is a const uint32_t[256] — 1 KiB baked into the cartridge ROM. Each byte processed is one indexed 32-bit load from that table, plus an XOR and a shift. A tight ROM-look-up loop no other demo in the battery runs. |
| real CRC-32 | This is the bit-exact standard CRC-32 (reflected, polynomial 0xEDB88320) — the same checksum used by zip, PNG and Ethernet. crc32("123456789") == 0xCBF43926 verifies it byte-for-byte. |
| indexed load | On the 65816 the table index becomes a pointer add + an indirect-indexed load (lda (ptr),y). The differential proves that indexing — across default-8-bit, +mos-a16 and +mos-xy16 — is bit-exact. |
| procedural texture | Feeding a pixel's (x, y, time) through the CRC turns a checksum into a hash-marble field: neighbouring cells scatter to unrelated colours, and advancing time flows the whole field. |
Written in C with the llvm-mos 65816 toolchain and verified against bsnes-jg
(and MAME where the SPC700 IPL is present). Hit Verify fidelity to reproduce the build
gate's WRAM assert (gate CRC 0xDBBA — a fold of the CRC32 of 240 sampled cells)
live in this tab. No far pointers — the same source passes every way: host == default ==
+mos-a16 == +mos-xy16 == bsnes-jg, -verify clean.