Since the end For/Next loop evaluates the end expression each iteration in Dbpro, it's worth pre-computing such values outside of the loops.
Just quickly, so this
lock pixel
for y=0 to screen height() step 1
for x=0 to screen width() step 1
dot x,y,rgb(0,128 + rnd(127),0)
next x
next y
unlock pixel
Could be expressed as
lock pixel
SH=screen height()-1
Sw=screen width()-1
for y=0 to sh
for x=0 to sw
dot x,y,rgb(0,128 + rnd(127),0)
next x
next y
unlock pixel
A simple rearrangement, but you're saving a call to Screen Width() every pixel drawn. So for a screen size 1024*768 that's a lot of call overhead wasted.
Might be able to unroll the inner loops to further improve this, as manually adding/bumping the X offset, might be quicker than the normal FOR/NEXT loop over head. (which is likely, but not a guarantee )
So perhaps,
lock pixel
SH=screen height()-1
Sw=screen width()-1
for y=0 to sh
for x=0 to sw step 4
dot x,y ,rgb(0,128 + rnd(127),0)
dot x+1,y,rgb(0,128 + rnd(127),0)
dot x+2,y,rgb(0,128 + rnd(127),0)
dot x+3,y,rgb(0,128 + rnd(127),0)
next x
next y
unlock pixel
Note: This assumes the width is an evenly divisiable by 4
The best option would probably be remove the DOT and write directly into the surface. So lock the surface, grab the address and pitch and write each 32bit colour value into the buffer and bump pointer directly
(pseudo DBpro styled code)
SH=screen height()-1
Sw=screen width()-1
lock pixel
IMageAddress = Get Screen Ptr() ; whatever the functions called in DBpro
IMagePitch = Get Screen Pitch() ; whatever the functions called in DBpro
for y=0 to sh
RowAddress=ImageAddress
for x=0 to sw step 4
*RowAddress=rgb(0,128 + rnd(127),0)
RowAddress=RowAddress+4
*RowAddress=rgb(0,128 + rnd(127),0)
RowAddress=RowAddress+4
*RowAddress=rgb(0,128 + rnd(127),0)
RowAddress=RowAddress+4
*RowAddress=rgb(0,128 + rnd(127),0)
RowAddress=RowAddress+4
next x
ImageAddress=ImageAddress+ImagePitch
next y
unlock pixel
Just go to careful not to run off the edges of the image buffer, which means certain crash. Also need to be sure that the buffer is indeed 32bits before hammering on it. If it's not, the the inner loops would need be to customized for 16/24 bit situations.