Hi, I've increased the speed even more. There's a lot of unnecessary screen updates in there. My tests show that spooky's version takes between 1500 to 1650 milliseconds to complete on this system. I've got this down to between 156 to 158 milliseconds just by moving the sync out of the For y loop. I've also modified a version to use memblocks, which gives me a slightly faster speed of 149 - 151ms.
sync on : sync rate 0
sync : sync
time = timer()
c as dword
for y= 0 to 479
lock pixels
for x= 0 to 639
a#=0.0
c#=0.0
s#=x/100.0-3.0
t#=y/80.0-3.0
n=0
repeat
inc n
h#=s#*s#
k#=t#*t#
c#=s#*(h#-3.0*k#)+0.5
a#=t#*(3.0*h#-k#)
t#=a#
s#=c#
until n=16 or fastabs(c#)>9.0 or fastabs(a#)>9.0
if fastabs(c#)<9.0 or fastabs(a#)<9.0
select n
case 1 : c=rgb(255,255,255) : endcase
case 2 : c=rgb(255,255,0): endcase
case 3 : c=rgb(255,0,255): endcase
case 4 : c=rgb(0,255,255): endcase
case 5 : c=rgb(255,0,0): endcase
case 6 : c=rgb(0,255,0): endcase
case 7 : c=rgb(0,0,255): endcase
case 8 : c=rgb(255,200,0): endcase
case 9 : c=rgb(0,255,200): endcase
case default : c=rgb(0,0,0) : endcase
endselect
dot x,y,c
endif
next x
unlock pixels
next y
sync
totaltime = timer() - time
Set Window Title str$(totaltime)
wait key
end
function fastabs(n#)
if n# < 0 then n# = -n#
endfunction n#
I've also wondered if using memblocks would be faster that the dot command with unlocked pixels.
Sync on
Sync rate 0
sync
Global width as DWORD
Global height as DWORD
Global bit as DWORD
c as dword
make memblock from bitmap 1, 0
width = memblock dword(1, 0)
height = memblock dword(1, 4)
bit = memblock dword(1, 8)
time = timer()
for y= 0 to 479
for x= 0 to 639
a#=0.0
c#=0.0
s#=x/100.0-3.0
t#=y/80.0-3.0
n=0
repeat
inc n
h#=s#*s#
k#=t#*t#
c#=s#*(h#-3.0*k#)+0.5
a#=t#*(3.0*h#-k#)
t#=a#
s#=c#
until n=16 or fastabs(c#)>9.0 or fastabs(a#)>9.0
if fastabs(c#)<9.0 or fastabs(a#)<9.0
select n
case 1 : c=rgb(255,255,255) : endcase
case 2 : c=rgb(255,255,0): endcase
case 3 : c=rgb(255,0,255): endcase
case 4 : c=rgb(0,255,255): endcase
case 5 : c=rgb(255,0,0): endcase
case 6 : c=rgb(0,255,0): endcase
case 7 : c=rgb(0,0,255): endcase
case 8 : c=rgb(255,200,0): endcase
case 9 : c=rgb(0,255,200): endcase
case default : c=rgb(0,0,0) : endcase
endselect
memloc = XYConvert(x, y)
write memblock dword 1, memloc, c
endif
next x
next y
make bitmap from memblock 0, 1
sync
totaltime = timer() - time
Set Window Title str$(totaltime)
wait key
end
function fastabs(n#)
if n# < 0 then n# = -n#
endfunction n#
Function XYConvert(a, b)
Offset = 12
a = a * 4
b = b * width * 4
output = Offset + a + b
EndFunction output