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 re-imagining of an 80s home computer on an RP2350 microcontroller board. Text rendering is a requirement for such a project. While bitmap fonts are now out of favor, they were chosen for their efficiency and aesthetic appeal at low resolutions. Proportional spacing and kerning were also desired for their early Macintosh aesthetic.

Most text rendering in RP2350 projects uses a fixed character cell, but the new technique presented achieves fast bitmap text rendering on microcontrollers. The core idea is a Just-In-Time (JIT) compiler that generates highly optimized code on the fly for rendering a string. The RP2350, capable of DVI video output via HSTX peripheral, still relies on software to fill the video buffer.

To meet the performance constraint, the renderer uses a race-the-beam approach, filling the video buffer each scanline. The rendering is modeled as a pipeline, with an interface between the application and renderer as a display list. The display list is double-buffered, with one list being rendered and scanned out while the other is built by the application.

At each vsync, if the app is ready, the display list is swapped. The allocation of display objects is not computationally intensive, but the application might be busy doing other tasks. The text object contains the string, font pointer, and foreground/background colors. RAM is valuable, especially for the double-buffered display list.

To optimize, the renderer keeps an active list of objects intersecting the current scanline, sorted by y0 order. During rendering, objects are inserted or deleted from the active list based on their y-coordinates. A specialized bitmap allocator ensures 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 Hacker News'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

How to find the owner of a small business and their contact info

If you sell to local businesses (a dental practice, a bakery, a franchise location), the person who signs is usually the owner. Their name is rarely on the website.

  • Search business website's About or team pages for owner's name
  • Check state registries, local news, awards, chamber pages for registered agents
  • Use VOYGR Enrich API for efficient owner and contact info retrieval

More from Sunday 8 November →