Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Faster Draw
#1
Code:
DIM a as uinteger  

    FOR a=0 to 175
    PLOT 0,0
    DRAW 255,a
    NEXT a

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/infoseeki...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!
Reply
#2
Oh, more info on beta basic 3.0 here:

http://www.worldofspectrum.org/showmag.c...700024.jpg
Reply
#3
britlion Wrote:Oh, more info on beta basic 3.0 here:

http://www.worldofspectrum.org/showmag.c...700024.jpg
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.
Reply
#4
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!)
Reply
#5
How about this? Seems to test all aspects of drawing..

Sinclair Basic version:
Code:
10 FOR i=1 TO 127
20 DRAW i,160
30 PLOT i,0
40 NEXT i

50 OVER 1

60 FOR i=0 TO 80
70 PLOT 0,i
80 DRAW 250,i
90 NEXT i

100 REM OVER 2

110 FOR i=1 TO 80
120 CIRCLE 127,87,i
130 NEXT i

140 REM OVER 3

150 FOR i=10 TO 18
160 PLOT 127,87
170 DRAW i,i,i
180 NEXT i

I realised I can't test over 2,3 in sinclair basic...but still:

Code:
start:
for i=1 to 127
draw i,160
plot i,0
next i

OVER 1

for i=0 to 80
plot 0,i
draw 250,i
next i

OVER 2

for i = 1 to 80
circle 127,87,i
next i

OVER 3

for i = 10 to 18
plot 127,87
draw i,i,i
next i
Reply
#6
I think they're Ok. Also check agains HiSoft. I was very surprised for they very-fast drawing routine.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)