Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Using screen lookup tables
#5
AlcoholicsAnonymous Wrote:
britlion Wrote:2> It should be used, if available, by other ZX Basic functions - I'm thinking in particular of plot and draw, which use the ROM routine PIXELADD. Very important this. If we're willing to give up memory for a table, lets have everything use it!

Stuff like DRAW, CIRCLE (and PFILL as you saw :-) ) are always plotting a point above, below, to the left or to the right from the last point plotted. A fast implementation should not be computing screen addresses from pixel coordinates for each point plotted but instead should be modifying an existing screen address and pixel mask for the next point plotted. This is much, much quicker.
This is exactly what ZX BASIC DRAW routine is doing plus using Bresenham's algorithm for faster coordinates computation. I also tried at first lookup tables, but the speed gain was low comparing and the memory space requires was high. I couldn't find a better approximation than this one.

ZX BASIC CIRCLE also uses Bresenham's (much faster), but calculates only 1/4 of circle and plot the other 3 quarters by reflection (so the plotted pixels are not in a contiguous sequence and this method cannot be used). The result is pretty fast, anyway.

DRAW3 was really problematic. To mimic the ROM DRAW x, y, z behaviour I ended up copyting the ROM routine and removing the parsing code within. So it's slow and takes memory, but other than that, it woks almost identical to the original one (with all pixels shifted down 16 scan lines).
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)