mirror of
https://git.do.srb2.org/KartKrew/Kart-Public.git
synced 2025-01-14 13:51:31 +00:00
Further optimization of fading code because I'm crazy
The less branches, the better. Optimization is a bitch, you know.
This commit is contained in:
parent
4eb8ba7bf7
commit
fea0a9577a
1 changed files with 35 additions and 17 deletions
52
src/f_wipe.c
52
src/f_wipe.c
|
@ -231,34 +231,52 @@ static void F_DoWipe(fademask_t *fademask)
|
||||||
maskx = masky = 0;
|
maskx = masky = 0;
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
// pointer to transtable that this mask would use
|
|
||||||
transtbl = transtables + ((9 - *mask)<<FF_TRANSSHIFT);
|
|
||||||
// (ignore that it goes out of bounds if *mask is 0 or 10 --
|
|
||||||
// it wouldn't be used in those cases anyway)
|
|
||||||
|
|
||||||
draw_rowstart = scrxpos[maskx];
|
draw_rowstart = scrxpos[maskx];
|
||||||
draw_rowend = scrxpos[maskx + 1];
|
draw_rowend = scrxpos[maskx + 1];
|
||||||
draw_linestart = scrypos[masky];
|
draw_linestart = scrypos[masky];
|
||||||
draw_lineend = scrypos[masky + 1];
|
draw_lineend = scrypos[masky + 1];
|
||||||
|
|
||||||
// DRAWING LOOP
|
|
||||||
relativepos = (draw_linestart * vid.width) + draw_rowstart;
|
relativepos = (draw_linestart * vid.width) + draw_rowstart;
|
||||||
draw_linestogo = draw_lineend - draw_linestart;
|
draw_linestogo = draw_lineend - draw_linestart;
|
||||||
while (draw_linestogo--)
|
|
||||||
|
if (*mask == 0)
|
||||||
{
|
{
|
||||||
w = w_base + relativepos;
|
// shortcut - memcpy source to work
|
||||||
s = s_base + relativepos;
|
while (draw_linestogo--)
|
||||||
e = e_base + relativepos;
|
|
||||||
draw_rowstogo = draw_rowend - draw_rowstart;
|
|
||||||
while (draw_rowstogo--)
|
|
||||||
{
|
{
|
||||||
if (*s != *e)
|
M_Memcpy(w_base+relativepos, s_base+relativepos, draw_rowend-draw_rowstart);
|
||||||
*w = ((*mask == 0) ? *s : (*mask == 10) ? *e : transtbl[(*e<<8) + *s]);
|
relativepos += vid.width;
|
||||||
++w, ++s, ++e;
|
|
||||||
}
|
}
|
||||||
relativepos += vid.width;
|
|
||||||
}
|
}
|
||||||
// END DRAWING LOOP
|
else if (*mask == 10)
|
||||||
|
{
|
||||||
|
// shortcut - memcpy target to work
|
||||||
|
while (draw_linestogo--)
|
||||||
|
{
|
||||||
|
M_Memcpy(w_base+relativepos, e_base+relativepos, draw_rowend-draw_rowstart);
|
||||||
|
relativepos += vid.width;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// pointer to transtable that this mask would use
|
||||||
|
transtbl = transtables + ((9 - *mask)<<FF_TRANSSHIFT);
|
||||||
|
|
||||||
|
// DRAWING LOOP
|
||||||
|
while (draw_linestogo--)
|
||||||
|
{
|
||||||
|
w = w_base + relativepos;
|
||||||
|
s = s_base + relativepos;
|
||||||
|
e = e_base + relativepos;
|
||||||
|
draw_rowstogo = draw_rowend - draw_rowstart;
|
||||||
|
|
||||||
|
while (draw_rowstogo--)
|
||||||
|
*w++ = transtbl[ ( *e++ << 8 ) + *s++ ];
|
||||||
|
|
||||||
|
relativepos += vid.width;
|
||||||
|
}
|
||||||
|
// END DRAWING LOOP
|
||||||
|
}
|
||||||
|
|
||||||
if (++maskx >= fademask->width)
|
if (++maskx >= fademask->width)
|
||||||
++masky, maskx = 0;
|
++masky, maskx = 0;
|
||||||
|
|
Loading…
Reference in a new issue