Join Nostr
2025-06-07 10:27:07 UTC

Colin McMillen on Nostr: My adventures in 6502-land: I discovered that drawing lines is a pain in the ass. The ...

My adventures in 6502-land: I discovered that drawing lines is a pain in the ass. The reference algorithm is Bresenham's (https://en.wikipedia.org/wiki/Bresenham%27s_line_algorithm), which is really smart and good, but requires to check which point is at the right/the top of the other one to know where to start from, then which kind of slope the line has (to know whether to iterate on X or Y), and even if it involves no division, it involves a lot of additions/substractions/absolutes and branches.
Another, albeit much slower, possibility is to find the middle point (which just requires two additions and two right shifts, no 16-bit arithmetic involved), plot it, then recurse on both sides.