A great old-timey game-programming hack (2013) blog.moertel.com · 48 points · 8 ...
HN Best 200 @best
A great old-timey game-programming hack (2013) blog.moertel.com · 48 points · 8 comments · HN thread
TL;DR A former college game programmer recounts (originally 2013) how he and a friend sped up a 6809-based PC side-scroller's background tile drawing by about 70 percent. The trick used the 6809's PULS/PSHU stack instructions as block-copy tools, which required pre-reversed tile data and commandeering both stack pointers, and then interrupt-driven sound corrupted memory, fixed by drawing tiles in reverse order.
- The original tile copy used an unrolled loop of LDU/STU pairs; the friend's optimized version took 98 cycles per row versus 157 for the naive loop.
- Using PULS/PSHU with the 6809's direct-page register as an extra go-between copied 7 bytes per pair, bringing a row copy to 56 cycles.
- Pushes and pulls reverse row order and swap the two 7-byte halves of each row, so tile data was pre-reversed at load time so the copy would come out correct.
- The routine used S and U as pointers, so any interrupt (needed for sampled sound) pushed state onto the corrupted stack area.
- The fix was to swap which pointer targeted the screen buffer and to draw tiles from high to low addresses, so any corruption was overwritten by the next tile before display.
- The reported result was a 70 percent speedup in the routine, which translated into a perceived one-third to one-half faster game.
Discussion The thread is short and appreciative, mostly sharing related stories of clever low-level hacks. Commenters compare it to classic folklore like The Story of Mel, recount their own early experiences with TI-BASIC, 6502 and Game Boy tricks, and tell of a VGA chip FIFO anecdote. The mood is nostalgic and admiring, with a few light jokes about modern software and AI.
- Admiration for the cleverness and joy of low-level hacking (most): Many readers praise the story as an impressive, elegant effort that shows deep knowledge of the machine. Commenters describe it as the kind of work that makes older optimization feel satisfying.
- Related stories of clever hardware hacks deserve sharing (some): Several commenters add their own examples, such as a Video Seven VGA designer's one-deep write FIFO and Monster Max's unrolled push loops on Game Boy. These show that similar tricks were common in the era.
- Nostalgia for early programming on limited machines (some): Some commenters recall their first programming experiences, including TI-83+ BASIC tricks and 6502 page-boundary work, and say those years shaped their later skills.
- Comparison to The Story of Mel (a few): One commenter links the classic folklore story and notes the shared theme of exploiting machine details, though they prefer this account for its focus on understanding the machine.
- Contrast with modern AI-era software development (a few): A brief comment suggests that this kind of deliberate process is missing in the current AI era, without elaboration.
Links from the comments