mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2025-02-09 09:41:12 +00:00
Mask the sprite patch column in R_DrawVisSprite
This commit is contained in:
parent
649669c217
commit
0c664681cd
5 changed files with 16 additions and 20 deletions
|
@ -811,6 +811,7 @@ typedef struct
|
||||||
{
|
{
|
||||||
INT16 width, height;
|
INT16 width, height;
|
||||||
INT16 leftoffset, topoffset;
|
INT16 leftoffset, topoffset;
|
||||||
|
INT32 width_po2, width_mask;
|
||||||
|
|
||||||
UINT8 *pixels;
|
UINT8 *pixels;
|
||||||
column_t *columns;
|
column_t *columns;
|
||||||
|
|
|
@ -40,11 +40,16 @@ patch_t *Patch_Create(softwarepatch_t *source, void *dest)
|
||||||
|
|
||||||
Patch_CalcDataSizes(source, &total_pixels, &total_posts);
|
Patch_CalcDataSizes(source, &total_pixels, &total_posts);
|
||||||
|
|
||||||
patch->columns = Z_Calloc(sizeof(column_t) * patch->width, PU_PATCH_DATA, NULL);
|
patch->width_po2 = 1;
|
||||||
|
while (patch->width_po2 < patch->width)
|
||||||
|
patch->width_po2 <<= 1;
|
||||||
|
patch->width_mask = patch->width_po2 - 1;
|
||||||
|
|
||||||
|
patch->columns = Z_Calloc(sizeof(column_t) * patch->width_po2, PU_PATCH_DATA, NULL);
|
||||||
patch->posts = Z_Calloc(sizeof(post_t) * total_posts, PU_PATCH_DATA, NULL);
|
patch->posts = Z_Calloc(sizeof(post_t) * total_posts, PU_PATCH_DATA, NULL);
|
||||||
patch->pixels = Z_Calloc(sizeof(UINT8) * total_pixels, PU_PATCH_DATA, NULL);
|
patch->pixels = Z_Calloc(sizeof(UINT8) * total_pixels, PU_PATCH_DATA, NULL);
|
||||||
|
|
||||||
Patch_MakeColumns(source, patch->width, patch->pixels, patch->columns, patch->posts, false);
|
Patch_MakeColumns(source, patch->width_po2, patch->width, patch->pixels, patch->columns, patch->posts, false);
|
||||||
|
|
||||||
return patch;
|
return patch;
|
||||||
}
|
}
|
||||||
|
@ -63,7 +68,7 @@ void Patch_CalcDataSizes(softwarepatch_t *source, size_t *total_pixels, size_t *
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Patch_MakeColumns(softwarepatch_t *source, size_t num_columns, UINT8 *pixels, column_t *columns, post_t *posts, boolean flip)
|
void Patch_MakeColumns(softwarepatch_t *source, size_t num_columns, INT16 width, UINT8 *pixels, column_t *columns, post_t *posts, boolean flip)
|
||||||
{
|
{
|
||||||
column_t *column = flip ? columns + (num_columns - 1) : columns;
|
column_t *column = flip ? columns + (num_columns - 1) : columns;
|
||||||
|
|
||||||
|
@ -76,6 +81,9 @@ void Patch_MakeColumns(softwarepatch_t *source, size_t num_columns, UINT8 *pixel
|
||||||
column->posts = posts;
|
column->posts = posts;
|
||||||
column->num_posts = 0;
|
column->num_posts = 0;
|
||||||
|
|
||||||
|
if (i >= (unsigned)width)
|
||||||
|
continue;
|
||||||
|
|
||||||
doompost_t *src_posts = (doompost_t*)((UINT8 *)source + LONG(source->columnofs[i]));
|
doompost_t *src_posts = (doompost_t*)((UINT8 *)source + LONG(source->columnofs[i]));
|
||||||
|
|
||||||
for (doompost_t *post = src_posts; post->topdelta != 0xff ;)
|
for (doompost_t *post = src_posts; post->topdelta != 0xff ;)
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
// Patch functions
|
// Patch functions
|
||||||
patch_t *Patch_Create(softwarepatch_t *source, void *dest);
|
patch_t *Patch_Create(softwarepatch_t *source, void *dest);
|
||||||
void Patch_CalcDataSizes(softwarepatch_t *source, size_t *total_pixels, size_t *total_posts);
|
void Patch_CalcDataSizes(softwarepatch_t *source, size_t *total_pixels, size_t *total_posts);
|
||||||
void Patch_MakeColumns(softwarepatch_t *source, size_t num_columns, UINT8 *pixels, column_t *columns, post_t *posts, boolean flip);
|
void Patch_MakeColumns(softwarepatch_t *source, size_t num_columns, INT16 width, UINT8 *pixels, column_t *columns, post_t *posts, boolean flip);
|
||||||
void Patch_Free(patch_t *patch);
|
void Patch_Free(patch_t *patch);
|
||||||
|
|
||||||
#define Patch_FreeTag(tagnum) Patch_FreeTags(tagnum, tagnum)
|
#define Patch_FreeTag(tagnum) Patch_FreeTags(tagnum, tagnum)
|
||||||
|
|
|
@ -319,7 +319,7 @@ UINT8 *R_GenerateTexture(size_t texnum)
|
||||||
|
|
||||||
texturecolumns[texnum] = columns;
|
texturecolumns[texnum] = columns;
|
||||||
|
|
||||||
Patch_MakeColumns(realpatch, texture->width, pixels, columns, posts, texture->flip);
|
Patch_MakeColumns(realpatch, texture->width, texture->width, pixels, columns, posts, texture->flip);
|
||||||
|
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
|
@ -947,15 +947,8 @@ static void R_DrawVisSprite(vissprite_t *vis)
|
||||||
// Vertically sheared sprite
|
// Vertically sheared sprite
|
||||||
for (dc_x = vis->x1; dc_x <= vis->x2; dc_x++, frac += vis->xiscale, dc_texturemid -= vis->shear.tan)
|
for (dc_x = vis->x1; dc_x <= vis->x2; dc_x++, frac += vis->xiscale, dc_texturemid -= vis->shear.tan)
|
||||||
{
|
{
|
||||||
#ifdef RANGECHECK
|
texturecolumn = (frac>>FRACBITS) & patch->width_mask;
|
||||||
texturecolumn = frac>>FRACBITS;
|
|
||||||
if (texturecolumn < 0 || texturecolumn >= pwidth)
|
|
||||||
I_Error("R_DrawSpriteRange: bad texturecolumn at %d from end", vis->x2 - dc_x);
|
|
||||||
column = &patch->columns[texturecolumn];
|
column = &patch->columns[texturecolumn];
|
||||||
#else
|
|
||||||
column = &patch->columns[frac>>FRACBITS];
|
|
||||||
#endif
|
|
||||||
|
|
||||||
sprtopscreen = (centeryfrac - FixedMul(dc_texturemid, spryscale));
|
sprtopscreen = (centeryfrac - FixedMul(dc_texturemid, spryscale));
|
||||||
localcolfunc (column);
|
localcolfunc (column);
|
||||||
}
|
}
|
||||||
|
@ -969,14 +962,8 @@ static void R_DrawVisSprite(vissprite_t *vis)
|
||||||
// Non-paper drawing loop
|
// Non-paper drawing loop
|
||||||
for (dc_x = vis->x1; dc_x <= vis->x2; dc_x++, frac += vis->xiscale, sprtopscreen += vis->shear.tan)
|
for (dc_x = vis->x1; dc_x <= vis->x2; dc_x++, frac += vis->xiscale, sprtopscreen += vis->shear.tan)
|
||||||
{
|
{
|
||||||
#ifdef RANGECHECK
|
texturecolumn = (frac>>FRACBITS) & patch->width_mask;
|
||||||
texturecolumn = frac>>FRACBITS;
|
|
||||||
if (texturecolumn < 0 || texturecolumn >= pwidth)
|
|
||||||
I_Error("R_DrawSpriteRange: bad texturecolumn at %d from end", vis->x2 - dc_x);
|
|
||||||
column = &patch->columns[texturecolumn];
|
column = &patch->columns[texturecolumn];
|
||||||
#else
|
|
||||||
column = &patch->columns[frac>>FRACBITS];
|
|
||||||
#endif
|
|
||||||
localcolfunc (column);
|
localcolfunc (column);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue