Path: utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!thunder.mcrcim.mcgill.edu!snorkelwacker.mit.edu!spool.mu.edu!uunet!mcsun!ukc!slxsys!ibmpcug!mantis!mathew From: mathew@mantis.co.uk (mathew) Newsgroups: comp.sys.acorn,eunet.micro.acorn Subject: Re: Archimedes Suggestions Message-ID: <3BaoX5w163w@mantis.co.uk> Date: 20 Feb 91 15:03:13 GMT References: <1991Feb13.163527.7782@vax1.tcd.ie> Organization: Mantis Consultants, Cambridge. UK. Lines: 38 In article <1991Feb12.212522.14434@watdragon.waterloo.edu>, gcwilliams@watdra > Here's one thing I'd like to see. The graphics code in ROM for drawing > circles and rectangles and such like appears to be very inefficient, > it'd be nice if these could be made faster (like by a factor of 3 or 4 > in some cases - I believe this is possible) As someone else has pointed out, the existing routines are quite general, and you're unlikely to be able to get them any faster without losing some generality. I think they use Bresenham's algorithm for circles, which is about as good as you get. If you really do need lots of circles very quickly, you can write your own very fast algorithms providing you assume a few things. Look at some books on graphics algorithms. If you can assume no clipping, that helps a lot. As far as rectangles go, you may be able to get a factor of 4 or more speedup if you're careful to arrange things suitably. If the video RAM is organized in bitplanes, you can choose your colours carefully so that you only ever need to blit to one or two of them. This is how games on the ST manage to do smooth scrolling; the 68000 wouldn't really be up to whacking 32KB of RAM around every refresh. For general rotation, circles and the like, my favourite trick is to use a circular array of 360 signed words as a look-up table for sin and cos values. You pre-compute 32767 * sin( rad (x)) for x = 0 to 359 and store the answers away. You can then get sin and cos values extremely quickly :-) I used to do this all the time on the BBC micro, in order to speed up graphics demos. ('Course, in them days I was usin' bytes... Aye... We only 'ad one register, and that were t'program counter...) [ By circular array, I mean that if you ask for A[x] where x>360, you subtract 360 and try again. ] It's an obvious trick, but quite a few people seem not to have thought of it... Jeff Minter uses "yakly degrees", which go from 0 to 255 :-) mathew.