Urgent.News

What's breaking now, across thousands of outlets.

Tech

JIT bitmap text rendering for microcontrollers

I have been working on vic-2350, a modern interpretation of an 80s home computer on an RP2350 microcontroller board. Text rendering is essential for such a project, and bitmap fonts were chosen due to their efficiency and aesthetic appeal at low resolutions. Proportional spacing and kerning were also desired, as they provide an early Macintosh-like appearance.

Achieving good performance in RP2350 projects is challenging, as most text rendering is based on a fixed character cell. This blog post introduces a method for extremely fast rendering of bitmap text on microcontrollers like the RP2350. It is implemented within the race-the-beam renderer, but the same approach would work with a framebuffer as well.

The core concept involves generating highly optimized code on the fly using a Just-In-Time (JIT) compiler. In the 80s, there was a shift in text display technology, moving from a fixed cell size to a bitmap framebuffer, which offered greater flexibility at the cost of increased computational power. The RP2350 is capable of DVI video output, but it relies solely on software to fill the video buffer.

Due to the limited 520kB SRAM, a framebuffer must be optimized for resolution and bit depth. Instead, the rendering process "races the beam," filling the video buffer each scanline. This approach allows for higher visual richness and lower latency, but imposes a hard performance constraint on the renderer. The RP2350's performance budget is approximately 6 cycles per pixel.

Assembly language is not sufficient for meeting this requirement, so the renderer and much of the vic-2350 project are written in symbolasm, a programming language developed for high-performance Cortex-M33 programming. The renderer operates using a display list, which is double-buffered and built by the application. The list is sorted by y0 order, and during rendering, the renderer calls the render method for each display object in the active list.

Text rendering is implemented as a display object, containing the string, font pointer, and colors. To optimize memory usage, a specialized bitmap allocator is employed, ensuring fast and deterministic memory allocation. The start method allocates scratch space for JIT code and an intermediate buffer, then invokes the JIT compiler to expand the string into code.

Written by urgent.news from Lobsters's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at linebender.org →

More in Tech

More from Friday 13 November →