Mail Archives: djgpp/2000/04/18/03:34:44
Alexei A. Frounze wrote:
>3. Dieter, I hope you won't try to convert span() to plane C. :)
^^^^^
(Nice misspelling. With optimizing plane C-compiler, you shouldn't
need any assembly for 3d graphics ;)
Sorry, I must dissapoint you.
>This replacement doesn't work even nearly fast:
> while (n--) {
> *scr++ = *(texture+((v1>>8)&0xFF00)+((u1>>16)&0xFF));
> u1 += du;
> v1 += dv;
> };
^
Why this semicolon? The same thing I see everywhere in your sources.
Assuming n >= 0, and taking the liberty of slightly changing
your interface (the pointers are not needed), I got after a few
minutes:
/* Add this to the top of T_Map() */
static void
span2(char *scr, char *texture, int n, int u1, int v1, int du, int dv)
{
switch (n&3)
{
case 3:
*scr++ = texture[((v1>>8)&0xFF00)+((u1>>16)&0xFF)];
u1 += du;
v1 += dv;
case 2:
*scr++ = texture[((v1>>8)&0xFF00)+((u1>>16)&0xFF)];
u1 += du;
v1 += dv;
case 1:
*scr++ = texture[((v1>>8)&0xFF00)+((u1>>16)&0xFF)];
u1 += du;
v1 += dv;
}
if ((n >>= 2) != 0)
{
do
{
scr[0] = texture[((v1>>8)&0xFF00)+((u1>>16)&0xFF)];
u1 += du;
v1 += dv;
scr[1] = texture[((v1>>8)&0xFF00)+((u1>>16)&0xFF)];
u1 += du;
v1 += dv;
scr[2] = texture[((v1>>8)&0xFF00)+((u1>>16)&0xFF)];
u1 += du;
v1 += dv;
scr[3] = texture[((v1>>8)&0xFF00)+((u1>>16)&0xFF)];
u1 += du;
v1 += dv;
scr += 4;
}
while (--n != 0);
}
}
I replaced
span (scr, texture, n, &u1, &v1, du, dv);
by
span2(scr, texture, n, u1, v1, du, dv);
in T_Map(). Speed went up by 2 FPS ;)
I must admit, that this is really surprising. A fast look at
your assembly implementation has shown: I don't understand it.
And I actually feel no desire at all to understand it.
But it certainly looks fast. So, your results may differ.
- Raw text -