This query is not actually assembler specific, but there is no 'General coding' subforum. The point is that I need to know how to do this using only the ability to turn on individual pixels one after the other to form a line. Assume there are no OS or Mid / High level language line drawing functions available.
I have a project in mind which is not actually for Atari but for an even older system using a single monochrome bitplane with one bit = 1 pixel on or off. The Atari in hi-rez mode would be an ideal system to test out methods.
I'm OK with how to turn a particular pixel at a particular co-ordinate in a single bitmapped plane on or off, so you can assume I have a pre-existing subroutine which I can call for that purpose. Let's call the subroutine PLOT (X,Y)
Suppose I have a 2D grid of 32 * 32 pixels.
The requirement is for a routine which is to draw a line between X1, Y1 and X2, Y2 when those two co-ordinates can be anywhere in the 32 * 32 grid, any distance apart within the boundaries of the grid, and X2 may have a greater OR lower value than X1, and Y2 may have a greater OR lower value than Y1.
The main problem I have with visualising this is how to translate the slope on a line into the necessary 'three pixels along, one step up, three pixels along, one step up, three pixels along, one step up' action. If I go into mspaint, select the thinnest possible line (one pixel wide) to draw with and zoom in to see what's happening, it pulls some fairly complex patterns in order to get the line to fit between two chosen end points.
Sometimes it's just three along, one down, three along, one down - other times two down, one across, six down, one across, two down, one across, six down, one across with perhaps a shorter group of four at each end in order to make the line between the two points as smooth and direct as possible.
Can anyone suggest a way to calculate the ideal pixel step size / length with which to draw a line between (X1,Y1), (X2, Y2)? Oh, one further problem. Integer maths only. Still possible?