![]() |
Faster Draw - Printable Version +- Forum (https://www.boriel.com/forum) +-- Forum: Compilers and Computer Languages (https://www.boriel.com/forum/forumdisplay.php?fid=12) +--- Forum: ZX Basic Compiler (https://www.boriel.com/forum/forumdisplay.php?fid=11) +---- Forum: Wishlist (https://www.boriel.com/forum/forumdisplay.php?fid=14) +---- Thread: Faster Draw (/showthread.php?tid=128) |
Faster Draw - britlion - 08-17-2009 Code: DIM a as uinteger My timings on this code suggest it's possible to make the DRAW command quite a lot faster. It takes about 9.2 seconds after ZX Basic compiles it and run on a 48K spectrum. Running exactly the same code on a spectrum 128 with Beta Basic 4.0 added (find at: http://www.worldofspectrum.org/infoseekid.cgi?id=0007956 ) completes in 5.9 seconds. (56% faster execution) Remember, this is running in an extended variant of basic. In the beta basic newsletter 12 he describes a method of queuing up plot and draw commands into a string variable (as if it was an array), and using a very fast draw method to draw the whole array. I haven't tried that yet, but I get the impression it will be far faster (for anything we'd need to draw on screen more than once, anyway - creating the 'array' is still quite slow) I think Andrew wright's draw code must be pretty staggeringly fast to make that much difference in an interpreted language, though beta basic is generally faster. He has stated in material that his draw code is 2.5 to 3 times as fast as the Sinclair ROM code. Boriel, your circle routine is incredibly fast (beta basic has, I think, something very similar) - and you've said that the draw routine is faster than basic. I'm not sure I can see the difference in speed with yours over sinclair. Here's a source you might want to look at for a much faster algorithm. Just something you might want to look at some time! Re: Faster Draw - britlion - 08-17-2009 Oh, more info on beta basic 3.0 here: http://www.worldofspectrum.org/showmag.cgi?mag=MicroHobby/Issue067/Pages/MicroHobby06700024.jpg Re: Faster Draw - boriel - 08-17-2009 britlion Wrote:Oh, more info on beta basic 3.0 here:Thanks britlion, again. Effectively, ZX Basic DRAW is faster than BETA BASIC 3.1 one, but slower than 4.x. I will try to improve it. ZX BASIC Draw uses Bresenham's algorithm (the same as circle) wich is quite fast. I will try to examine BETA BASIC 4.x Draw to see what changes. Regarding to the "STRING" method, this is just a "Polyline Draw", and it will be faster than normal coordinate one, and take less memory: You store each (x, y) pair coordinate in two bytes, and draw from one to another. You can use a string for that (generate cords x, y appending CHR$(x) + CHR$(y) to the string), and later creating an asm routine which traverses the string and call draw subsequently. I'll see what can I do. Re: Faster Draw - boriel - 03-19-2011 Update: As of 1.2.7 the DRAW routine was speed up (somewhat). If you're still interested, you can make a new benchmark (and tell us, please!) Re: Faster Draw - britlion - 03-19-2011 How about this? Seems to test all aspects of drawing.. Sinclair Basic version: Code: 10 FOR i=1 TO 127 I realised I can't test over 2,3 in sinclair basic...but still: Code: start: Re: Faster Draw - boriel - 03-19-2011 I think they're Ok. Also check agains HiSoft. I was very surprised for they very-fast drawing routine. |