Tom Moertel recalls helping a friend speed up tile drawing in an 8-bit side-scroller. Its copy loop was already unrolled and carefully tuned. A Motorola 6809 instruction that pulls or pushes several registers at once offered a much bigger gain, but borrowing the stack created a problem when audio interrupts arrived.
- Move seven bytes per pair. The 6809 could pull data from one stack and push it through registers onto another. Moertel even used its direct-page register as a spare byte of transfer space.
- Prepare the data for the fast path. Stack operations reversed the tile’s row order and swapped its seven-byte halves. Reversing seven-byte chunks in the stored tiles ahead of time made the screen output come out right.
- Count the right speedup. Moertel estimates 1,689 cycles per tile versus 2,893 for his friend’s tuned routine: about 70% more tile copies per unit time. He says the whole game felt about a third to a half faster.
- Account for asynchronous users of the stack. Timer interrupts for sampled sound pushed state through the borrowed system-stack pointer, corrupting reference tiles. Pointing it at the off-screen buffer instead protected the source.
- Repair before display. Drawing tiles from high to low addresses let the next tile overwrite the bytes an interrupt could damage. The buffer stayed invisible until the frame was complete.
The clever part is the end-to-end fix: use a faster primitive, preprocess data for its odd ordering, then arrange writes so interrupts cannot leave visible damage. Moertel reconstructs the instruction counts from memory, so treat them as the story’s estimates, not a fresh benchmark.