Files
Threadwell/archive/threads/nicbarkeragain/2025-07-22-branchless-programming-is-a-term-used-to-describe/2025-07-22-RussellPolo-a-really-long-time-ago-programming-a-simple-game.md
T

1.4 KiB

title, type, source, source_url, author, handle, post_id, date, archived, draft, tags, description, in_reply_to, parent_post_id
title type source source_url author handle post_id date archived draft tags description in_reply_to parent_post_id
A really long time ago, programming a simple game in basic on a 6502 based Commodore PET, I changed the logic from: archive twitter https://x.com/RussellPolo/status/1947564413780680847 Russell Polo RussellPolo 1947564413780680847 2025-07-22 2026-08-25 false
archive
twitter
nicbarkeragain
A really long time ago, programming a simple game in basic on a 6502 based Commodore PET, I changed the logic from: 1947506500194472221

Source

Branch

1/ @RussellPolo ^1947564413780680847

A really long time ago, programming a simple game in basic on a 6502 based Commodore PET, I changed the logic from:

If then pos=pos-1 If then pos=pos+1 If...

To: pos=pos+key2motion[keypress]

The result was a dramatic improvement. Sluggish character movement became smooth, quick motion. The result wasn't as easy to understand, but the performance result more than justified the confusing code.

Ever since, I've always looked for ways to avoid branching logic. These are the types of optimizations you could never expect from a compiler.