something liek this:
sub render_thread(world as world_struct pointer)
dim as integer x,y
dim as single d
dim as integer pointer display=world->display+(world->y_start*world->wwidth)
dim as vector_struct pointer vector=world->vectors+(world->y_start*world->wwidth)
for y=world->y_start to world->y_end
for x=0 to world->wwidth-1
*display=raytrace(world,vector)
display+=1
vector+=1
next
next
world->busy=0
end sub
sub render_world(world as world_struct pointer)
dim as integer y=0,i=0
dim world_thread(0 to 3) as world_struct
dim as any pointer thread(0 to 3)
world_thread(0)=*world
world_thread(1)=*world
world_thread(2)=*world
world_thread(3)=*world
while y<world->height
i=(i+1)and 3
if (@world_thread(i))->busy=0 then
(@world_thread(i))->y_start=y
(@world_thread(i))->y_end=y+9
(@world_thread(i))->busy=1
thread(i)=threadcreate(@render_thread,@world_thread(i))
y+=10
end if
wend
threadwait(thread(0))
threadwait(thread(1))
threadwait(thread(2))
threadwait(thread(3))
end sub
with the field 'busy as integer' added to the world_struct type.
Does it in blocks of 10 rows at a time, the current values need the screen size to be some multiple of 10 in height.