Loading…
← BACK TO ARCHIVE

Compose in 32 bits, present in 8: the CastaliaOS renderer

The entire CastaliaOS 98 PE interface composes into a 32-bit XRGB back buffer and presents to 8- or 16-bit hardware as dirty rectangles. No dithering, no palette search, no alpha.

Windows XP’s glossy chrome cost a GPU with acceleration. We wanted it on a Pentium II with VESA and 4 MB of VRAM, drawn entirely in software. The solution is three counterintuitive decisions, all born from the same question: what can this machine actually afford?

Decision 1: always compose in 32 bits

Everything draws into ONE 32-bit XRGB back buffer in system RAM. It sounds ruinously expensive for the era and it is the opposite: the drawing code is format-independent and there is no dithering anywhere. Gradients, bevels and shadows are computed once, clean. Only the present() step converts to the hardware’s real format.

At 8bpp we use a 3-3-2 palette: three bits of red, three of green, two of blue. Converting a 32-bit pixel is a shift and a mask — zero table lookups, zero “nearest color”: it is the three lines of gfx_pack_index_332(). At 16bpp, straight RGB565. And only dirty rectangles get converted: a click repaints a window, not a screen.

There is no per-pixel alpha in the whole system. Icons use a magenta color key; shadows are a cheap read-modify-write on the edge strips.

Decision 3: ban alpha

Per-pixel transparency is the luxury a period machine cannot afford. So it does not exist: icons and cursors use a 1-bit magenta color key, and window shadows are a cheap darkening of the edge strips. The eye is fooled exactly the same, and it fits the budget. The host checks — 457 when we wrote this, 7,609 today — run under both gcc and clang on every push, make sure no commit breaks the conversion.

The file manager with its blue task pane: gradients, bevels and shadows composited in 32 bits and presented at 16bpp. Not one pixel of alpha in the whole scene.
The file manager with its blue task pane: gradients, bevels and shadows composited in 32 bits and presented at 16bpp. Not one pixel of alpha in the whole scene.

D. ABELLÁN · FOUNDER · PRINCETON, IL · 2026.04.22

About CastaliaOS 98 PE →

// NEXT STEP

Read it, now run it

// ARCHIVE

RELATED FILES

LINKED FILES
TRANSMISSION · BY EMAIL// SUBSCRIBE

Get on the mailing list.

Devlogs, patches and launches, straight to your inbox. Zero spam, zero analytics, no automated list: to unsubscribe, just hit reply.

9DEVLOGS PUBLISHEDSINCE 2026
2LANGUAGESES · EN
0SPAM · TRACKINGEVER

NO TRACKING100%
PRIVACY100%
FREQUENCY2-3/MONTH
// NO AUTOMATED LIST// 0 ANALYTICS// REPLY TO LEAVE// HOSTED IN VIRGINIA