Solved
ASM Translation
Posted on 1998-10-16
I am currently trying to learn some good asm optimizing techniques for a graphics program I am running, and was wondering if there was a fast way to do what I'm doing below in ASM. (I'm sure there is)
for(x=0; x < 320; x++)
for(y=0; y < 200; y++)
{
total_distance=0;
for(ctr=0; ctr < total; ctr++)
{
total_distance += (100/distance_formula(x, y, struct[ctr].x,
struct[ctr].y));
}
if(total_distance > 10)
put_pixel(x,y,total_distance);
}
I don't need help with the algorithm, the algorithm is sound for quick 2D meta-balls, I just want to know what is the best way to do this is. Basically, I figure there must be some ASM opcodes to do this faster I don't know about. The putpixel routine outputs to a virtual screen, so there's room for optimization there, so just help me out here.
Below is just the algorithm above in english:
Loop through the entire virtual screen 64000 bytes (320x200).
For every point on the screen :
Loop from 0 to a set amount of vertex's
In the loop, divide 100 by the distance from the current x,y you are at, to the vertex in the nested loop you're running. Then plot the pixel to the virtual screen.
The X and Y variables are integers (even in the structures)
The total_distance variable is a float (so if I don't see you using EAX, I'll be upset!:)