mirror of
https://github.com/yquake2/yquake2remaster.git
synced 2024-11-26 06:20:48 +00:00
Merge pull request #1121 from 0lvin/backport
Improve pcx support and cleanup soft render
This commit is contained in:
commit
8c0904f0c8
5 changed files with 50 additions and 43 deletions
|
@ -85,7 +85,7 @@ SCR_LoadPCX(char *filename, byte **pic, byte **palette, int *width, int *height)
|
||||||
{
|
{
|
||||||
byte *raw;
|
byte *raw;
|
||||||
pcx_t *pcx;
|
pcx_t *pcx;
|
||||||
int x, y;
|
int x, y, bpl;
|
||||||
int len, full_size;
|
int len, full_size;
|
||||||
int dataByte, runLength;
|
int dataByte, runLength;
|
||||||
byte *out, *pix;
|
byte *out, *pix;
|
||||||
|
@ -115,6 +115,12 @@ SCR_LoadPCX(char *filename, byte **pic, byte **palette, int *width, int *height)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bpl = LittleShort(pcx->bytes_per_line);
|
||||||
|
if (bpl <= pcx->xmax)
|
||||||
|
{
|
||||||
|
bpl = pcx->xmax + 1;
|
||||||
|
}
|
||||||
|
|
||||||
full_size = (pcx->ymax + 1) * (pcx->xmax + 1);
|
full_size = (pcx->ymax + 1) * (pcx->xmax + 1);
|
||||||
out = Z_Malloc(full_size);
|
out = Z_Malloc(full_size);
|
||||||
|
|
||||||
|
@ -140,7 +146,7 @@ SCR_LoadPCX(char *filename, byte **pic, byte **palette, int *width, int *height)
|
||||||
|
|
||||||
for (y = 0; y <= pcx->ymax; y++, pix += pcx->xmax + 1)
|
for (y = 0; y <= pcx->ymax; y++, pix += pcx->xmax + 1)
|
||||||
{
|
{
|
||||||
for (x = 0; x <= pcx->xmax; )
|
for (x = 0; x < bpl; )
|
||||||
{
|
{
|
||||||
dataByte = *raw++;
|
dataByte = *raw++;
|
||||||
|
|
||||||
|
|
|
@ -173,6 +173,12 @@ LoadPCX(const char *origname, byte **pic, byte **palette, int *width, int *heigh
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (pcx->bytes_per_line <= pcx_width)
|
||||||
|
{
|
||||||
|
pcx->bytes_per_line = pcx_width + 1;
|
||||||
|
image_issues = true;
|
||||||
|
}
|
||||||
|
|
||||||
full_size = (pcx_height + 1) * (pcx_width + 1);
|
full_size = (pcx_height + 1) * (pcx_width + 1);
|
||||||
out = malloc(full_size);
|
out = malloc(full_size);
|
||||||
if (!out)
|
if (!out)
|
||||||
|
@ -218,7 +224,7 @@ LoadPCX(const char *origname, byte **pic, byte **palette, int *width, int *heigh
|
||||||
|
|
||||||
for (y = 0; y <= pcx_height; y++, pix += pcx_width + 1)
|
for (y = 0; y <= pcx_height; y++, pix += pcx_width + 1)
|
||||||
{
|
{
|
||||||
for (x = 0; x <= pcx_width; )
|
for (x = 0; x < pcx->bytes_per_line; )
|
||||||
{
|
{
|
||||||
if (raw - (byte *)pcx > len)
|
if (raw - (byte *)pcx > len)
|
||||||
{
|
{
|
||||||
|
|
|
@ -221,6 +221,8 @@ typedef struct
|
||||||
pixel_t *pskin;
|
pixel_t *pskin;
|
||||||
int skinwidth;
|
int skinwidth;
|
||||||
int skinheight;
|
int skinheight;
|
||||||
|
float scalewidth;
|
||||||
|
float scaleheight;
|
||||||
} affinetridesc_t;
|
} affinetridesc_t;
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
|
@ -343,7 +345,6 @@ extern qboolean r_dowarp;
|
||||||
extern affinetridesc_t r_affinetridesc;
|
extern affinetridesc_t r_affinetridesc;
|
||||||
|
|
||||||
void D_WarpScreen(void);
|
void D_WarpScreen(void);
|
||||||
void R_PolysetUpdateTables(void);
|
|
||||||
|
|
||||||
//=======================================================================//
|
//=======================================================================//
|
||||||
|
|
||||||
|
|
|
@ -526,10 +526,10 @@ R_AliasSetupSkin(const entity_t *currententity, const model_t *currentmodel)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
r_affinetridesc.pskin = pskindesc->pixels[0];
|
r_affinetridesc.pskin = pskindesc->pixels[0];
|
||||||
r_affinetridesc.skinwidth = pskindesc->width;
|
r_affinetridesc.skinwidth = pskindesc->asset_width;
|
||||||
r_affinetridesc.skinheight = pskindesc->height;
|
r_affinetridesc.skinheight = pskindesc->asset_height;
|
||||||
|
r_affinetridesc.scalewidth = (float)pskindesc->asset_width / s_pmdl->skinwidth;
|
||||||
R_PolysetUpdateTables (); // FIXME: precalc edge lookups
|
r_affinetridesc.scaleheight = (float)pskindesc->asset_height / s_pmdl->skinheight;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -77,10 +77,6 @@ static light3_t d_lightbasestep, d_lightextrastep;
|
||||||
static int d_sfracbasestep, d_tfracbasestep;
|
static int d_sfracbasestep, d_tfracbasestep;
|
||||||
static zvalue_t d_ziextrastep, d_zibasestep;
|
static zvalue_t d_ziextrastep, d_zibasestep;
|
||||||
|
|
||||||
static byte *skintable[MAX_LBM_HEIGHT];
|
|
||||||
int skinwidth;
|
|
||||||
static pixel_t *skinstart;
|
|
||||||
|
|
||||||
void (*d_pdrawspans)(const entity_t *currententity, spanpackage_t *pspanpackage);
|
void (*d_pdrawspans)(const entity_t *currententity, spanpackage_t *pspanpackage);
|
||||||
|
|
||||||
static void R_PolysetSetEdgeTable(void);
|
static void R_PolysetSetEdgeTable(void);
|
||||||
|
@ -131,29 +127,6 @@ static const byte irtable[256] = {
|
||||||
|
|
||||||
// ======================
|
// ======================
|
||||||
|
|
||||||
/*
|
|
||||||
================
|
|
||||||
R_PolysetUpdateTables
|
|
||||||
================
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
R_PolysetUpdateTables (void)
|
|
||||||
{
|
|
||||||
byte *s;
|
|
||||||
|
|
||||||
if (r_affinetridesc.skinwidth != skinwidth ||
|
|
||||||
r_affinetridesc.pskin != skinstart)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
|
|
||||||
skinwidth = r_affinetridesc.skinwidth;
|
|
||||||
skinstart = r_affinetridesc.pskin;
|
|
||||||
s = skinstart;
|
|
||||||
for (i=0 ; i<MAX_LBM_HEIGHT ; i++, s+=skinwidth)
|
|
||||||
skintable[i] = s;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
================
|
================
|
||||||
R_DrawTriangle
|
R_DrawTriangle
|
||||||
|
@ -300,27 +273,41 @@ FloorDivMod(int numer, int denom, int *quo, int *rem)
|
||||||
#if defined(__i386__) || defined(__amd64__)
|
#if defined(__i386__) || defined(__amd64__)
|
||||||
q = numer / denom;
|
q = numer / denom;
|
||||||
r = numer - q * denom;
|
r = numer - q * denom;
|
||||||
|
|
||||||
if (-1/2 || 1/-2 || -1/-2) {
|
if (-1/2 || 1/-2 || -1/-2) {
|
||||||
// long live C89
|
// long live C89
|
||||||
if (r < 0 && r < denom) {
|
if (r < 0 && r < denom) {
|
||||||
q += 1;
|
q += 1;
|
||||||
r -= denom;
|
r -= denom;
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
// C99 always truncates to 0
|
// C99 always truncates to 0
|
||||||
if ((numer ^ denom) < 0 && r != 0) {
|
if ((numer ^ denom) < 0 && r != 0)
|
||||||
|
{
|
||||||
q -= 1;
|
q -= 1;
|
||||||
r += denom;
|
r += denom;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((numer < 0) ^ (denom < 0))
|
if ((numer < 0) ^ (denom < 0))
|
||||||
|
{
|
||||||
assert(q <= 0);
|
assert(q <= 0);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
assert(q >= 0);
|
assert(q >= 0);
|
||||||
|
}
|
||||||
|
|
||||||
if (denom < 0)
|
if (denom < 0)
|
||||||
|
{
|
||||||
assert(r > denom && r <= 0);
|
assert(r > denom && r <= 0);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
assert(r >= 0 && r < denom);
|
assert(r >= 0 && r < denom);
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
float num = numer, den = denom;
|
float num = numer, den = denom;
|
||||||
float x;
|
float x;
|
||||||
|
@ -781,8 +768,8 @@ R_PolysetDrawSpans8_Opaque (const entity_t *currententity, spanpackage_t *pspanp
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
R_ProcessLeftEdge(compactvert_t *plefttop, compactvert_t *prighttop,
|
R_ProcessLeftEdge(const compactvert_t *plefttop, const compactvert_t *prighttop,
|
||||||
compactvert_t *pleftbottom)
|
const compactvert_t *pleftbottom)
|
||||||
{
|
{
|
||||||
light3_t working_lstepx;
|
light3_t working_lstepx;
|
||||||
pixel_t *d_ptex;
|
pixel_t *d_ptex;
|
||||||
|
@ -795,8 +782,8 @@ R_ProcessLeftEdge(compactvert_t *plefttop, compactvert_t *prighttop,
|
||||||
v = plefttop->v;
|
v = plefttop->v;
|
||||||
d_aspancount = plefttop->u - prighttop->u;
|
d_aspancount = plefttop->u - prighttop->u;
|
||||||
|
|
||||||
s = plefttop->s;
|
s = plefttop->s * r_affinetridesc.scalewidth;
|
||||||
t = plefttop->t;
|
t = plefttop->t * r_affinetridesc.scaleheight;
|
||||||
i = (s >> SHIFT16XYZ) + (t >> SHIFT16XYZ) * r_affinetridesc.skinwidth;
|
i = (s >> SHIFT16XYZ) + (t >> SHIFT16XYZ) * r_affinetridesc.skinwidth;
|
||||||
d_ptex = &r_affinetridesc.pskin[i];
|
d_ptex = &r_affinetridesc.pskin[i];
|
||||||
d_sfrac = s & 0xFFFF;
|
d_sfrac = s & 0xFFFF;
|
||||||
|
@ -821,7 +808,9 @@ R_ProcessLeftEdge(compactvert_t *plefttop, compactvert_t *prighttop,
|
||||||
// ceil (), but plus a little bit)
|
// ceil (), but plus a little bit)
|
||||||
t = ubasestep < 0;
|
t = ubasestep < 0;
|
||||||
for (i = 0; i < 3; i++)
|
for (i = 0; i < 3; i++)
|
||||||
|
{
|
||||||
working_lstepx[i] = r_lstepx[i] - t;
|
working_lstepx[i] = r_lstepx[i] - t;
|
||||||
|
}
|
||||||
|
|
||||||
// base steps for drawers
|
// base steps for drawers
|
||||||
s = r_sstepy + r_sstepx * ubasestep;
|
s = r_sstepy + r_sstepx * ubasestep;
|
||||||
|
@ -832,7 +821,9 @@ R_ProcessLeftEdge(compactvert_t *plefttop, compactvert_t *prighttop,
|
||||||
d_tfracbasestep = t & 0xFFFF;
|
d_tfracbasestep = t & 0xFFFF;
|
||||||
|
|
||||||
for (i = 0; i < 3; i++)
|
for (i = 0; i < 3; i++)
|
||||||
|
{
|
||||||
d_lightbasestep[i] = r_lstepy[i] + working_lstepx[i] * ubasestep;
|
d_lightbasestep[i] = r_lstepy[i] + working_lstepx[i] * ubasestep;
|
||||||
|
}
|
||||||
|
|
||||||
d_zibasestep = r_zistepy + r_zistepx * ubasestep;
|
d_zibasestep = r_zistepy + r_zistepx * ubasestep;
|
||||||
|
|
||||||
|
@ -845,7 +836,9 @@ R_ProcessLeftEdge(compactvert_t *plefttop, compactvert_t *prighttop,
|
||||||
d_tfracextrastep = t & 0xFFFF;
|
d_tfracextrastep = t & 0xFFFF;
|
||||||
|
|
||||||
for (i = 0; i < 3; i++)
|
for (i = 0; i < 3; i++)
|
||||||
|
{
|
||||||
d_lightextrastep[i] = d_lightbasestep[i] + working_lstepx[i];
|
d_lightextrastep[i] = d_lightbasestep[i] + working_lstepx[i];
|
||||||
|
}
|
||||||
|
|
||||||
d_ziextrastep = d_zibasestep + r_zistepx;
|
d_ziextrastep = d_zibasestep + r_zistepx;
|
||||||
|
|
||||||
|
@ -860,7 +853,8 @@ R_RasterizeAliasPolySmooth
|
||||||
static void
|
static void
|
||||||
R_RasterizeAliasPolySmooth(const entity_t *currententity)
|
R_RasterizeAliasPolySmooth(const entity_t *currententity)
|
||||||
{
|
{
|
||||||
compactvert_t *plefttop, *prighttop, *pleftbottom, *prightbottom;
|
const compactvert_t *pleftbottom, *prightbottom;
|
||||||
|
const compactvert_t *plefttop, *prighttop;
|
||||||
spanpackage_t *pstart;
|
spanpackage_t *pstart;
|
||||||
int originalcount;
|
int originalcount;
|
||||||
int leftheight, rightheight;
|
int leftheight, rightheight;
|
||||||
|
@ -951,7 +945,7 @@ R_PolysetSetEdgeTable
|
||||||
================
|
================
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
R_PolysetSetEdgeTable (void)
|
R_PolysetSetEdgeTable(void)
|
||||||
{
|
{
|
||||||
int edgetableindex;
|
int edgetableindex;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue