After optimizing my code in my last article, I was rather pleased with the performance, however, I started to notice something rather redundant about my code. I was performing several similar operations. Primarily, the program involves a lot of addition and subtraction of the same values to ensure smooth program flow. What if we combine some of those calculations?
To do this, I’m going to have to rearrange some of the program flow. Our current flow looks something like this:
Tag: graphics
Converting Bresenham to Assembler (pass 2) Part 1

In my previous article, I presented a fairly straightforward method for converting my C code for Bresenham’s line algorithm to assembly language. It is certainly faster than the C equivalent, however, it is not optimized. In this article, we are going to improve this code and try to save some bytes and some T-States.
This article is going to be rather lengthy and will be split into 2 parts.
Before we start performing any optimizations, let’s remember the quote from Donald Knuth: “Premature optimization is the root of all evil”. To me, this means don’t optimize unless you know what the implications are going to be. So I’m not going to go too unorthodox in my optimizations and as always, test edge cases as well as general cases.
Continue reading “Converting Bresenham to Assembler (pass 2) Part 1”Exploring the Bresenham Line routine
The Bresenham Line routine (https://en.wikipedia.org/wiki/Bresenham%27s_line_algorithm) was created by Jack Bresenham back in 1962. It has been described as one of the most important algorithms made for computer graphics. It allows you to use integer math to draw a line, and it’s fast.
We’re going to implement several different versions of this algorithm in C to improve its speed compared to the default algorithm listed on Wikipedia.
A fast pixel routine for the ZX Spectrum
In 2022 I was working on one of my silly projects and decided that I wanted to play around with some plot routines. As you may already know, plotting or placing a pixel on the screen on the ZX Spectrum is a bit tricky. This is due to the non linear nature of the ZX Spectrum display. Plotting in a controlled method requires a calculation or by using a look up table (LUT) of some sort.
Continue reading “A fast pixel routine for the ZX Spectrum”