Short post today; updated the libraries and demo code to include the following:
- math.asm – Added sqrt and multiply routines (thanks to the Internet).
- vector.asm – Added circle, optimised horizontal line & wireframe triangle routines.
- screen_buffer.asm – Added fast stack pointer clear screen routine.
The source for demo_vector.asm has also been updated to allow the user to select which point on the triangle to move with the cursor by pressing the space bar, and drawing a circle through the cursor with the centre of the circle on one of the triangle points. Again, no clipping, so go off screen at your peril!
The circle algorithm is similar to one I used back in the day and is much, much quicker than the standard Spectrum circle algorithm. It was inspired by the planets and sun in the BBC / Spectrum game Elite and (like the line algorithm) based upon information in the excellent book “Computer Graphics: Principles and Practice” (Foley, van Dam, Feiner, Hughes) ISBN-10: 0-201-84840-6.