From bb4936257710e4c6c04e3b39989b8138e701a93b Mon Sep 17 00:00:00 2001 From: Nevur Date: Sat, 4 Mar 2017 20:59:43 +0100 Subject: [PATCH 01/10] Add rudimentary and non-working code for translucency on patches. --- src/r_data.c | 47 ++++++++++++++++++++++++++++++++++++++++++++++- src/r_data.h | 5 +++++ 2 files changed, 51 insertions(+), 1 deletion(-) diff --git a/src/r_data.c b/src/r_data.c index cd9ff6273..e32ef425e 100644 --- a/src/r_data.c +++ b/src/r_data.c @@ -211,6 +211,41 @@ static inline void R_DrawFlippedColumnInCache(column_t *patch, UINT8 *cache, INT patch = (column_t *)((UINT8 *)patch + patch->length + 4); } } +R_DrawTranslucentColumn_8() +static inline void R_DrawTransColumnInCache(column_t *patch, UINT8 *cache, INT32 originy, INT32 cacheheight) +{ + INT32 count, position; + UINT8 *source; + INT32 topdelta, prevdelta = -1; + + while (patch->topdelta != 0xff) + { + topdelta = patch->topdelta; + if (topdelta <= prevdelta) + topdelta += prevdelta; + prevdelta = topdelta; + source = (UINT8 *)patch + 3; + count = patch->length; + position = originy + topdelta; + + if (position < 0) + { + count += position; + source -= position; // start further down the column + position = 0; + } + + if (position + count > cacheheight) + count = cacheheight - position; + + if (count > 0) + M_Memcpy(cache + position, source, count); + + patch = (column_t *)((UINT8 *)patch + patch->length + 4); + } +} + + // // R_GenerateTexture @@ -588,6 +623,8 @@ static texpatch_t *R_ParsePatch(boolean actuallyLoadPatch) INT16 patchXPos; INT16 patchYPos; UINT8 flip = 0; + UINT8 alpha = 255; + enum patchalphastyle style = AST_COPY; texpatch_t *resultPatch = NULL; lumpnum_t patchLumpNum; @@ -703,7 +740,13 @@ static texpatch_t *R_ParsePatch(boolean actuallyLoadPatch) } while (strcmp(texturesToken,"}")!=0) { - if (stricmp(texturesToken, "FLIPX")==0) + if (stricmp(texturesToken, "ALPHA")==0) + { + Z_Free(texturesToken); + texturesToken = M_GetToken(NULL); + alpha = 255*strtof(texturesToken, NULL); + } + else if (stricmp(texturesToken, "FLIPX")==0) flip |= 1; else if (stricmp(texturesToken, "FLIPY")==0) flip |= 2; @@ -736,6 +779,8 @@ static texpatch_t *R_ParsePatch(boolean actuallyLoadPatch) resultPatch->lump = patchLumpNum & 65535; resultPatch->wad = patchLumpNum>>16; resultPatch->flip = flip; + resultPatch->alpha = alpha; + resultPatch->style = style; // Clean up a little after ourselves Z_Free(patchName); // Then return it diff --git a/src/r_data.h b/src/r_data.h index bea1cba3b..f8b31f8a3 100644 --- a/src/r_data.h +++ b/src/r_data.h @@ -21,6 +21,9 @@ #pragma interface #endif +// Possible alpha types for a patch. +enum patchalphastyle {AST_COPY, AST_TRANSLUCENT}; // , AST_ADD, AST_SUBTRACT, AST_REVERSESUBTRACT, AST_MODULATE, AST_OVERLAY}; + // moved here for r_sky.c (texpatch_t is used) // A single patch from a texture definition, @@ -32,6 +35,8 @@ typedef struct INT16 originx, originy; UINT16 wad, lump; UINT8 flip; // 1 = flipx, 2 = flipy, 3 = both + UINT8 alpha; // Translucency value + enum patchalphastyle style; } texpatch_t; // A maptexturedef_t describes a rectangular texture, From bf5a10e4b7a0a7ae3ff3afc980ab68d93bdaff49 Mon Sep 17 00:00:00 2001 From: Nevur Date: Sun, 5 Mar 2017 00:29:10 +0100 Subject: [PATCH 02/10] The translucency feature is now functional, but it doesn't exactly work as expected. Need to make it behave like FOF translucencies etc., I guess. --- src/r_data.c | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/src/r_data.c b/src/r_data.c index e32ef425e..162e49adb 100644 --- a/src/r_data.c +++ b/src/r_data.c @@ -211,11 +211,12 @@ static inline void R_DrawFlippedColumnInCache(column_t *patch, UINT8 *cache, INT patch = (column_t *)((UINT8 *)patch + patch->length + 4); } } -R_DrawTranslucentColumn_8() -static inline void R_DrawTransColumnInCache(column_t *patch, UINT8 *cache, INT32 originy, INT32 cacheheight) + +static inline void R_DrawTransColumnInCache(column_t *patch, UINT8 *cache, INT32 originy, INT32 cacheheight, UINT8 alpha) { INT32 count, position; - UINT8 *source; + UINT8 *source, *dest; + UINT8 *mytransmap = transtables + ((8*alpha/255) << FF_TRANSSHIFT); INT32 topdelta, prevdelta = -1; while (patch->topdelta != 0xff) @@ -238,8 +239,14 @@ static inline void R_DrawTransColumnInCache(column_t *patch, UINT8 *cache, INT32 if (position + count > cacheheight) count = cacheheight - position; + dest = cache + position; if (count > 0) - M_Memcpy(cache + position, source, count); + { + for (; dest < cache + position + count; ++source) + //*dest++ = transtables[(*source)<<8 + *dest]; + *dest++ = *(mytransmap + ((*source)<<8) + (*dest)); + //*dest++ = *source; + } patch = (column_t *)((UINT8 *)patch + patch->length + 4); } @@ -382,7 +389,9 @@ static UINT8 *R_GenerateTexture(size_t texnum) // generate column ofset lookup colofs[x] = LONG((x * texture->height) + (texture->width*4)); - if (patch->flip & 2) + if (patch->style == AST_TRANSLUCENT) + R_DrawTransColumnInCache(patchcol, block + LONG(colofs[x]), patch->originy, texture->height, patch->alpha); + else if (patch->flip & 2) R_DrawFlippedColumnInCache(patchcol, block + LONG(colofs[x]), patch->originy, texture->height, height); else R_DrawColumnInCache(patchcol, block + LONG(colofs[x]), patch->originy, texture->height); @@ -745,6 +754,13 @@ static texpatch_t *R_ParsePatch(boolean actuallyLoadPatch) Z_Free(texturesToken); texturesToken = M_GetToken(NULL); alpha = 255*strtof(texturesToken, NULL); + } + else if (stricmp(texturesToken, "STYLE")==0) + { + Z_Free(texturesToken); + texturesToken = M_GetToken(NULL); + if(stricmp(texturesToken, "TRANSLUCENT")==0) + style = AST_TRANSLUCENT; } else if (stricmp(texturesToken, "FLIPX")==0) flip |= 1; From 829be5bd43f4c16b690db21e3f496debef7ff993 Mon Sep 17 00:00:00 2001 From: Nevur Date: Sun, 5 Mar 2017 12:49:09 +0100 Subject: [PATCH 03/10] Changed how R_GenerateTexture picks the function to draw the columns so it checks once per patch. Also had to set the same args for all of the three current column drawer functions. --- src/r_data.c | 36 ++++++++++++++++++++++++++---------- 1 file changed, 26 insertions(+), 10 deletions(-) diff --git a/src/r_data.c b/src/r_data.c index 162e49adb..dbe896360 100644 --- a/src/r_data.c +++ b/src/r_data.c @@ -141,11 +141,13 @@ static INT32 tidcachelen = 0; // R_DrawColumnInCache // Clip and draw a column from a patch into a cached post. // -static inline void R_DrawColumnInCache(column_t *patch, UINT8 *cache, INT32 originy, INT32 cacheheight) + +static inline void R_DrawColumnInCache(column_t *patch, UINT8 *cache, texpatch_t *originPatch, INT32 cacheheight, INT32 patchheight) { INT32 count, position; UINT8 *source; INT32 topdelta, prevdelta = -1; + INT32 originy = originPatch->originy; while (patch->topdelta != 0xff) { @@ -174,11 +176,12 @@ static inline void R_DrawColumnInCache(column_t *patch, UINT8 *cache, INT32 orig } } -static inline void R_DrawFlippedColumnInCache(column_t *patch, UINT8 *cache, INT32 originy, INT32 cacheheight, INT32 patchheight) +static inline void R_DrawFlippedColumnInCache(column_t *patch, UINT8 *cache, texpatch_t *originPatch, INT32 cacheheight, INT32 patchheight) { INT32 count, position; UINT8 *source, *dest; INT32 topdelta, prevdelta = -1; + INT32 originy = originPatch->originy; while (patch->topdelta != 0xff) { @@ -212,12 +215,13 @@ static inline void R_DrawFlippedColumnInCache(column_t *patch, UINT8 *cache, INT } } -static inline void R_DrawTransColumnInCache(column_t *patch, UINT8 *cache, INT32 originy, INT32 cacheheight, UINT8 alpha) +static inline void R_DrawTransColumnInCache(column_t *patch, UINT8 *cache, texpatch_t *originPatch, INT32 cacheheight, INT32 patchheight) { INT32 count, position; UINT8 *source, *dest; - UINT8 *mytransmap = transtables + ((8*alpha/255) << FF_TRANSSHIFT); + UINT8 *mytransmap = transtables + ((8*(originPatch->alpha)/255) << FF_TRANSSHIFT); INT32 topdelta, prevdelta = -1; + INT32 originy = originPatch->originy; while (patch->topdelta != 0xff) { @@ -366,6 +370,23 @@ static UINT8 *R_GenerateTexture(size_t texnum) // Composite the columns together. for (i = 0, patch = texture->patches; i < texture->patchcount; i++, patch++) { + static void (*ColumnDrawerPointer)(column_t *, UINT8 *, texpatch_t *, INT32, INT32); // Column drawing function pointer. + if (patch->style == AST_TRANSLUCENT) + { + if (patch->flip & 2) + ColumnDrawerPointer = &R_DrawTransColumnInCache; + else + ColumnDrawerPointer = &R_DrawTransColumnInCache; + } + else + { + if (patch->flip & 2) + ColumnDrawerPointer = &R_DrawFlippedColumnInCache; + else + ColumnDrawerPointer = &R_DrawColumnInCache; + } + + realpatch = W_CacheLumpNumPwad(patch->wad, patch->lump, PU_CACHE); x1 = patch->originx; width = SHORT(realpatch->width); @@ -389,12 +410,7 @@ static UINT8 *R_GenerateTexture(size_t texnum) // generate column ofset lookup colofs[x] = LONG((x * texture->height) + (texture->width*4)); - if (patch->style == AST_TRANSLUCENT) - R_DrawTransColumnInCache(patchcol, block + LONG(colofs[x]), patch->originy, texture->height, patch->alpha); - else if (patch->flip & 2) - R_DrawFlippedColumnInCache(patchcol, block + LONG(colofs[x]), patch->originy, texture->height, height); - else - R_DrawColumnInCache(patchcol, block + LONG(colofs[x]), patch->originy, texture->height); + (*ColumnDrawerPointer)(patchcol, block + LONG(colofs[x]), patch, texture->height, height); } } From 13dbe7d3a3e2c4b59a098da88738829f52b9144c Mon Sep 17 00:00:00 2001 From: Nevur Date: Sun, 5 Mar 2017 18:53:34 +0100 Subject: [PATCH 04/10] Fixed issue with vertical offsets being broken. Add a vertical flip variant for the translucent column drawer. Translucency is now properly distributed: 0.00 leads to no render at all, 0.1 to TRANS10, ..., 0.9 to TRANS90, 1 to regular column drawer. --- src/r_data.c | 52 +++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 45 insertions(+), 7 deletions(-) diff --git a/src/r_data.c b/src/r_data.c index dbe896360..1ca6472d3 100644 --- a/src/r_data.c +++ b/src/r_data.c @@ -219,7 +219,7 @@ static inline void R_DrawTransColumnInCache(column_t *patch, UINT8 *cache, texpa { INT32 count, position; UINT8 *source, *dest; - UINT8 *mytransmap = transtables + ((8*(originPatch->alpha)/255) << FF_TRANSSHIFT); + UINT8 *mytransmap = transtables + ((8*(originPatch->alpha) + 255/8)/(255 - 255/11) << FF_TRANSSHIFT); // The equation's not exact but it works as intended. I'll call it a day for now. INT32 topdelta, prevdelta = -1; INT32 originy = originPatch->originy; @@ -246,17 +246,53 @@ static inline void R_DrawTransColumnInCache(column_t *patch, UINT8 *cache, texpa dest = cache + position; if (count > 0) { - for (; dest < cache + position + count; ++source) - //*dest++ = transtables[(*source)<<8 + *dest]; - *dest++ = *(mytransmap + ((*source)<<8) + (*dest)); - //*dest++ = *source; + for (; dest < cache + position + count; source++, dest++) + *dest = *(mytransmap + ((*dest)<<8) + (*source)); } patch = (column_t *)((UINT8 *)patch + patch->length + 4); } } +static inline void R_DrawTransFlippedColumnInCache(column_t *patch, UINT8 *cache, texpatch_t *originPatch, INT32 cacheheight, INT32 patchheight) +{ + INT32 count, position; + UINT8 *source, *dest; + UINT8 *mytransmap = transtables + ((8*(originPatch->alpha) + 255/8)/(255 - 255/11) << FF_TRANSSHIFT); // The equation's not exact but it works as intended. I'll call it a day for now. + INT32 topdelta, prevdelta = -1; + INT32 originy = originPatch->originy; + while (patch->topdelta != 0xff) + { + topdelta = patch->topdelta; + if (topdelta <= prevdelta) + topdelta += prevdelta; + prevdelta = topdelta; + topdelta = patchheight-patch->length-topdelta; + source = (UINT8 *)patch + 2 + patch->length; // patch + 3 + (patch->length-1) + count = patch->length; + position = originy + topdelta; + + if (position < 0) + { + count += position; + source += position; // start further UP the column + position = 0; + } + + if (position + count > cacheheight) + count = cacheheight - position; + + dest = cache + position; + if (count > 0) + { + for (; dest < cache + position + count; --source, dest++) + *dest = *(mytransmap + ((*dest)<<8) + (*source)); + } + + patch = (column_t *)((UINT8 *)patch + patch->length + 4); + } +} // // R_GenerateTexture @@ -371,10 +407,12 @@ static UINT8 *R_GenerateTexture(size_t texnum) for (i = 0, patch = texture->patches; i < texture->patchcount; i++, patch++) { static void (*ColumnDrawerPointer)(column_t *, UINT8 *, texpatch_t *, INT32, INT32); // Column drawing function pointer. - if (patch->style == AST_TRANSLUCENT) + if ((patch->style == AST_TRANSLUCENT) && (patch->alpha <= (10*255/11))) // Alpha style set to translucent? Is the alpha small enough for translucency? { + if (patch->alpha < 255/11) // Is the patch way too translucent? Don't render then. + continue; if (patch->flip & 2) - ColumnDrawerPointer = &R_DrawTransColumnInCache; + ColumnDrawerPointer = &R_DrawTransFlippedColumnInCache; else ColumnDrawerPointer = &R_DrawTransColumnInCache; } From 144514247de694e5cb99c33ae5facf3ab31ed7d8 Mon Sep 17 00:00:00 2001 From: Nevur Date: Sun, 12 Mar 2017 20:02:29 +0100 Subject: [PATCH 05/10] Added exceptions to the transparent column drawers to avoid modifying pixels with the cyan color. --- src/r_data.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/r_data.c b/src/r_data.c index 1ca6472d3..1a2cb8364 100644 --- a/src/r_data.c +++ b/src/r_data.c @@ -141,7 +141,6 @@ static INT32 tidcachelen = 0; // R_DrawColumnInCache // Clip and draw a column from a patch into a cached post. // - static inline void R_DrawColumnInCache(column_t *patch, UINT8 *cache, texpatch_t *originPatch, INT32 cacheheight, INT32 patchheight) { INT32 count, position; @@ -176,6 +175,10 @@ static inline void R_DrawColumnInCache(column_t *patch, UINT8 *cache, texpatch_t } } +// +// R_DrawFlippedColumnInCache +// Similar to R_DrawColumnInCache; it draws the column inverted, however. +// static inline void R_DrawFlippedColumnInCache(column_t *patch, UINT8 *cache, texpatch_t *originPatch, INT32 cacheheight, INT32 patchheight) { INT32 count, position; @@ -215,6 +218,10 @@ static inline void R_DrawFlippedColumnInCache(column_t *patch, UINT8 *cache, tex } } +// +// R_DrawTransColumnInCache +// Draws a translucent column into the cache, applying a half-cooked equation to get a proper translucency value (Needs code in R_GenerateTexture()). +// static inline void R_DrawTransColumnInCache(column_t *patch, UINT8 *cache, texpatch_t *originPatch, INT32 cacheheight, INT32 patchheight) { INT32 count, position; @@ -247,13 +254,17 @@ static inline void R_DrawTransColumnInCache(column_t *patch, UINT8 *cache, texpa if (count > 0) { for (; dest < cache + position + count; source++, dest++) - *dest = *(mytransmap + ((*dest)<<8) + (*source)); + *dest = *dest == 0xFF ? *dest : *(mytransmap + ((*dest)<<8) + (*source)); } patch = (column_t *)((UINT8 *)patch + patch->length + 4); } } +// +// R_DrawTransColumnInCache +// Similar to the one above except that the column is inverted. +// static inline void R_DrawTransFlippedColumnInCache(column_t *patch, UINT8 *cache, texpatch_t *originPatch, INT32 cacheheight, INT32 patchheight) { INT32 count, position; @@ -287,7 +298,7 @@ static inline void R_DrawTransFlippedColumnInCache(column_t *patch, UINT8 *cache if (count > 0) { for (; dest < cache + position + count; --source, dest++) - *dest = *(mytransmap + ((*dest)<<8) + (*source)); + *dest = *dest == 0xFF ? *dest : *(mytransmap + ((*dest)<<8) + (*source)); } patch = (column_t *)((UINT8 *)patch + patch->length + 4); From be9ca534d73fc70ac9e9ebc698c5c54d7e425bbc Mon Sep 17 00:00:00 2001 From: Nevur Date: Sun, 12 Mar 2017 20:26:45 +0100 Subject: [PATCH 06/10] Whitespace indenting. --- src/r_data.c | 78 ++++++++++++++++++++++++++-------------------------- src/r_data.h | 2 +- 2 files changed, 40 insertions(+), 40 deletions(-) diff --git a/src/r_data.c b/src/r_data.c index 1a2cb8364..8eaa8163b 100644 --- a/src/r_data.c +++ b/src/r_data.c @@ -146,7 +146,7 @@ static inline void R_DrawColumnInCache(column_t *patch, UINT8 *cache, texpatch_t INT32 count, position; UINT8 *source; INT32 topdelta, prevdelta = -1; - INT32 originy = originPatch->originy; + INT32 originy = originPatch->originy; while (patch->topdelta != 0xff) { @@ -184,7 +184,7 @@ static inline void R_DrawFlippedColumnInCache(column_t *patch, UINT8 *cache, tex INT32 count, position; UINT8 *source, *dest; INT32 topdelta, prevdelta = -1; - INT32 originy = originPatch->originy; + INT32 originy = originPatch->originy; while (patch->topdelta != 0xff) { @@ -228,7 +228,7 @@ static inline void R_DrawTransColumnInCache(column_t *patch, UINT8 *cache, texpa UINT8 *source, *dest; UINT8 *mytransmap = transtables + ((8*(originPatch->alpha) + 255/8)/(255 - 255/11) << FF_TRANSSHIFT); // The equation's not exact but it works as intended. I'll call it a day for now. INT32 topdelta, prevdelta = -1; - INT32 originy = originPatch->originy; + INT32 originy = originPatch->originy; while (patch->topdelta != 0xff) { @@ -250,12 +250,12 @@ static inline void R_DrawTransColumnInCache(column_t *patch, UINT8 *cache, texpa if (position + count > cacheheight) count = cacheheight - position; - dest = cache + position; + dest = cache + position; if (count > 0) - { + { for (; dest < cache + position + count; source++, dest++) *dest = *dest == 0xFF ? *dest : *(mytransmap + ((*dest)<<8) + (*source)); - } + } patch = (column_t *)((UINT8 *)patch + patch->length + 4); } @@ -271,7 +271,7 @@ static inline void R_DrawTransFlippedColumnInCache(column_t *patch, UINT8 *cache UINT8 *source, *dest; UINT8 *mytransmap = transtables + ((8*(originPatch->alpha) + 255/8)/(255 - 255/11) << FF_TRANSSHIFT); // The equation's not exact but it works as intended. I'll call it a day for now. INT32 topdelta, prevdelta = -1; - INT32 originy = originPatch->originy; + INT32 originy = originPatch->originy; while (patch->topdelta != 0xff) { @@ -417,23 +417,23 @@ static UINT8 *R_GenerateTexture(size_t texnum) // Composite the columns together. for (i = 0, patch = texture->patches; i < texture->patchcount; i++, patch++) { - static void (*ColumnDrawerPointer)(column_t *, UINT8 *, texpatch_t *, INT32, INT32); // Column drawing function pointer. - if ((patch->style == AST_TRANSLUCENT) && (patch->alpha <= (10*255/11))) // Alpha style set to translucent? Is the alpha small enough for translucency? - { - if (patch->alpha < 255/11) // Is the patch way too translucent? Don't render then. - continue; - if (patch->flip & 2) - ColumnDrawerPointer = &R_DrawTransFlippedColumnInCache; - else - ColumnDrawerPointer = &R_DrawTransColumnInCache; - } - else - { - if (patch->flip & 2) - ColumnDrawerPointer = &R_DrawFlippedColumnInCache; - else - ColumnDrawerPointer = &R_DrawColumnInCache; - } + static void (*ColumnDrawerPointer)(column_t *, UINT8 *, texpatch_t *, INT32, INT32); // Column drawing function pointer. + if ((patch->style == AST_TRANSLUCENT) && (patch->alpha <= (10*255/11))) // Alpha style set to translucent? Is the alpha small enough for translucency? + { + if (patch->alpha < 255/11) // Is the patch way too translucent? Don't render then. + continue; + if (patch->flip & 2) + ColumnDrawerPointer = &R_DrawTransFlippedColumnInCache; + else + ColumnDrawerPointer = &R_DrawTransColumnInCache; + } + else + { + if (patch->flip & 2) + ColumnDrawerPointer = &R_DrawFlippedColumnInCache; + else + ColumnDrawerPointer = &R_DrawColumnInCache; + } realpatch = W_CacheLumpNumPwad(patch->wad, patch->lump, PU_CACHE); @@ -599,11 +599,11 @@ void R_LoadTextures(void) // Allocate texture column offset table. texturecolumnofs = (void *)((UINT8 *)textures + (numtextures * sizeof(void *))); // Allocate texture referencing cache. - texturecache = (void *)((UINT8 *)textures + ((numtextures * sizeof(void *)) * 2)); + texturecache = (void *)((UINT8 *)textures + ((numtextures * sizeof(void *)) * 2)); // Allocate texture width mask table. texturewidthmask = (void *)((UINT8 *)textures + ((numtextures * sizeof(void *)) * 3)); // Allocate texture height mask table. - textureheight = (void *)((UINT8 *)textures + ((numtextures * sizeof(void *)) * 4)); + textureheight = (void *)((UINT8 *)textures + ((numtextures * sizeof(void *)) * 4)); // Create translation table for global animation. texturetranslation = Z_Malloc((numtextures + 1) * sizeof(*texturetranslation), PU_STATIC, NULL); @@ -814,19 +814,19 @@ static texpatch_t *R_ParsePatch(boolean actuallyLoadPatch) } while (strcmp(texturesToken,"}")!=0) { - if (stricmp(texturesToken, "ALPHA")==0) - { - Z_Free(texturesToken); - texturesToken = M_GetToken(NULL); - alpha = 255*strtof(texturesToken, NULL); - } - else if (stricmp(texturesToken, "STYLE")==0) - { - Z_Free(texturesToken); - texturesToken = M_GetToken(NULL); - if(stricmp(texturesToken, "TRANSLUCENT")==0) - style = AST_TRANSLUCENT; - } + if (stricmp(texturesToken, "ALPHA")==0) + { + Z_Free(texturesToken); + texturesToken = M_GetToken(NULL); + alpha = 255*strtof(texturesToken, NULL); + } + else if (stricmp(texturesToken, "STYLE")==0) + { + Z_Free(texturesToken); + texturesToken = M_GetToken(NULL); + if(stricmp(texturesToken, "TRANSLUCENT")==0) + style = AST_TRANSLUCENT; + } else if (stricmp(texturesToken, "FLIPX")==0) flip |= 1; else if (stricmp(texturesToken, "FLIPY")==0) diff --git a/src/r_data.h b/src/r_data.h index f8b31f8a3..2d984c1c8 100644 --- a/src/r_data.h +++ b/src/r_data.h @@ -36,7 +36,7 @@ typedef struct UINT16 wad, lump; UINT8 flip; // 1 = flipx, 2 = flipy, 3 = both UINT8 alpha; // Translucency value - enum patchalphastyle style; + enum patchalphastyle style; } texpatch_t; // A maptexturedef_t describes a rectangular texture, From 191623e2469ca7c68cc815383931aa3c11e59ee9 Mon Sep 17 00:00:00 2001 From: Nevur Date: Wed, 15 Mar 2017 15:46:04 +0100 Subject: [PATCH 07/10] Made tweaks suggested by toaster to make the code a bit less dumb. --- src/r_data.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/src/r_data.c b/src/r_data.c index 8eaa8163b..47bffd471 100644 --- a/src/r_data.c +++ b/src/r_data.c @@ -254,7 +254,7 @@ static inline void R_DrawTransColumnInCache(column_t *patch, UINT8 *cache, texpa if (count > 0) { for (; dest < cache + position + count; source++, dest++) - *dest = *dest == 0xFF ? *dest : *(mytransmap + ((*dest)<<8) + (*source)); + if (*dest != 0xFF) *dest = *(mytransmap + ((*dest)<<8) + (*source)); } patch = (column_t *)((UINT8 *)patch + patch->length + 4); @@ -298,7 +298,7 @@ static inline void R_DrawTransFlippedColumnInCache(column_t *patch, UINT8 *cache if (count > 0) { for (; dest < cache + position + count; --source, dest++) - *dest = *dest == 0xFF ? *dest : *(mytransmap + ((*dest)<<8) + (*source)); + if (*dest != 0xFF) *dest = *(mytransmap + ((*dest)<<8) + (*source)); } patch = (column_t *)((UINT8 *)patch + patch->length + 4); @@ -422,20 +422,13 @@ static UINT8 *R_GenerateTexture(size_t texnum) { if (patch->alpha < 255/11) // Is the patch way too translucent? Don't render then. continue; - if (patch->flip & 2) - ColumnDrawerPointer = &R_DrawTransFlippedColumnInCache; - else - ColumnDrawerPointer = &R_DrawTransColumnInCache; + ColumnDrawerPointer = (patch->flip & 2) ? &R_DrawTransFlippedColumnInCache : &R_DrawTransColumnInCache; } else { - if (patch->flip & 2) - ColumnDrawerPointer = &R_DrawFlippedColumnInCache; - else - ColumnDrawerPointer = &R_DrawColumnInCache; + ColumnDrawerPointer = (patch->flip & 2) ? &R_DrawFlippedColumnInCache : &R_DrawColumnInCache; } - realpatch = W_CacheLumpNumPwad(patch->wad, patch->lump, PU_CACHE); x1 = patch->originx; width = SHORT(realpatch->width); From 0e9761bc57ba64aaff8c13be17cae399b7de3306 Mon Sep 17 00:00:00 2001 From: Inuyasha Date: Sun, 19 Mar 2017 05:37:04 -0700 Subject: [PATCH 08/10] HUD changes don't trip isgamemodified (some HUD patches renamed because they're dumb) --- src/hu_stuff.c | 15 --------------- src/st_stuff.c | 21 ++++++++++++--------- src/w_wad.c | 28 +++++++++++++++++++--------- 3 files changed, 31 insertions(+), 33 deletions(-) diff --git a/src/hu_stuff.c b/src/hu_stuff.c index 01d4ed524..de6561337 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -198,21 +198,6 @@ void HU_LoadGraphics(void) tny_font[i] = (patch_t *)W_CachePatchName(buffer, PU_HUDGFX); } - // cache the level title font for entire game execution - lt_font[0] = (patch_t *)W_CachePatchName("LTFNT039", PU_HUDGFX); /// \note fake start hack - - // Number support - lt_font[9] = (patch_t *)W_CachePatchName("LTFNT048", PU_HUDGFX); - lt_font[10] = (patch_t *)W_CachePatchName("LTFNT049", PU_HUDGFX); - lt_font[11] = (patch_t *)W_CachePatchName("LTFNT050", PU_HUDGFX); - lt_font[12] = (patch_t *)W_CachePatchName("LTFNT051", PU_HUDGFX); - lt_font[13] = (patch_t *)W_CachePatchName("LTFNT052", PU_HUDGFX); - lt_font[14] = (patch_t *)W_CachePatchName("LTFNT053", PU_HUDGFX); - lt_font[15] = (patch_t *)W_CachePatchName("LTFNT054", PU_HUDGFX); - lt_font[16] = (patch_t *)W_CachePatchName("LTFNT055", PU_HUDGFX); - lt_font[17] = (patch_t *)W_CachePatchName("LTFNT056", PU_HUDGFX); - lt_font[18] = (patch_t *)W_CachePatchName("LTFNT057", PU_HUDGFX); - j = LT_FONTSTART; for (i = 0; i < LT_FONTSIZE; i++) { diff --git a/src/st_stuff.c b/src/st_stuff.c index 658c2c6d6..a226a9025 100644 --- a/src/st_stuff.c +++ b/src/st_stuff.c @@ -67,7 +67,7 @@ static patch_t *sborings; static patch_t *sboover; static patch_t *timeover; static patch_t *stlivex; -static patch_t *rrings; +static patch_t *sboredrings; static patch_t *getall; // Special Stage HUD static patch_t *timeup; // Special Stage HUD static patch_t *hunthoming[6]; @@ -143,7 +143,7 @@ hudinfo_t hudinfo[NUMHUDITEMS] = { 16, 10}, // HUD_SCORE { 128, 10}, // HUD_SCORENUM - { 17, 26}, // HUD_TIME + { 16, 26}, // HUD_TIME { 136, 10}, // HUD_TIMESPLIT { 88, 26}, // HUD_MINUTES { 188, 10}, // HUD_MINUTESSPLIT @@ -251,16 +251,19 @@ void ST_LoadGraphics(void) // but load them in R_AddSkins, that gets called // first anyway // cache the status bar overlay icons (fullscreen mode) - sborings = W_CachePatchName("SBORINGS", PU_HUDGFX); - sboscore = W_CachePatchName("SBOSCORE", PU_HUDGFX); + + // Prefix "STT" is whitelisted (doesn't trigger ISGAMEMODIFIED), btw + sborings = W_CachePatchName("STTRINGS", PU_HUDGFX); + sboredrings = W_CachePatchName("STTRRING", PU_HUDGFX); + sboscore = W_CachePatchName("STTSCORE", PU_HUDGFX); + sbotime = W_CachePatchName("STTTIME", PU_HUDGFX); // Time logo + sbocolon = W_CachePatchName("STTCOLON", PU_HUDGFX); // Colon for time + sboperiod = W_CachePatchName("STTPERIO", PU_HUDGFX); // Period for time centiseconds + sboover = W_CachePatchName("SBOOVER", PU_HUDGFX); timeover = W_CachePatchName("TIMEOVER", PU_HUDGFX); stlivex = W_CachePatchName("STLIVEX", PU_HUDGFX); livesback = W_CachePatchName("STLIVEBK", PU_HUDGFX); - rrings = W_CachePatchName("RRINGS", PU_HUDGFX); - sbotime = W_CachePatchName("SBOTIME", PU_HUDGFX); // Time logo - sbocolon = W_CachePatchName("SBOCOLON", PU_HUDGFX); // Colon for time - sboperiod = W_CachePatchName("SBOPERIO", PU_HUDGFX); // Period for time centiseconds nrec_timer = W_CachePatchName("NGRTIMER", PU_HUDGFX); // Timer for NiGHTS getall = W_CachePatchName("GETALL", PU_HUDGFX); // Special Stage HUD timeup = W_CachePatchName("TIMEUP", PU_HUDGFX); // Special Stage HUD @@ -681,7 +684,7 @@ static inline void ST_drawRings(void) { INT32 ringnum = max(stplyr->rings, 0); - ST_DrawPatchFromHudWS(HUD_RINGS, ((stplyr->rings <= 0 && leveltime/5 & 1) ? rrings : sborings)); + ST_DrawPatchFromHudWS(HUD_RINGS, ((stplyr->rings <= 0 && leveltime/5 & 1) ? sboredrings : sborings)); if (objectplacing) ringnum = op_currentdoomednum; diff --git a/src/w_wad.c b/src/w_wad.c index e4cb93050..ecba4064f 100644 --- a/src/w_wad.c +++ b/src/w_wad.c @@ -1215,15 +1215,25 @@ int W_VerifyNMUSlumps(const char *filename) // ENDOOM text and palette lumps lumpchecklist_t NMUSlist[] = { - {"D_", 2}, - {"O_", 2}, - {"DS", 2}, - {"ENDOOM", 6}, - {"PLAYPAL", 7}, - {"COLORMAP", 8}, - {"PAL", 3}, - {"CLM", 3}, - {"TRANS", 5}, + {"D_", 2}, // MIDI music + {"O_", 2}, // Digital music + {"DS", 2}, // Sound effects + + {"ENDOOM", 6}, // ENDOOM text lump + + {"PLAYPAL", 7}, // Palette changes + {"PAL", 3}, // Palette changes + {"COLORMAP", 8}, // Colormap changes + {"CLM", 3}, // Colormap changes + {"TRANS", 5}, // Translucency map changes + + {"LTFNT", 5}, // Level title font changes + {"TTL", 3}, // Act number changes + {"STCFN", 5}, // Console font changes + {"TNYFN", 5}, // Tiny console font changes + {"STT", 3}, // Acceptable HUD changes (Score Time Rings) + {"YB_", 3}, // Intermission graphics, goes with the above + {NULL, 0}, }; return W_VerifyFile(filename, NMUSlist, false); From 351a391e43fdfa8fe48239aec8960dabcbd9fe8a Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Sun, 19 Mar 2017 19:43:02 +0000 Subject: [PATCH 09/10] Fixed errors reported while compiling --- src/dehacked.c | 2 +- src/r_data.c | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/dehacked.c b/src/dehacked.c index c71c55ac1..baa8a655e 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -2898,7 +2898,7 @@ static void readpatch(MYFILE *f, const char *name, UINT16 wad) char *word2; char *tmp; INT32 i = 0, j = 0, value; - texpatch_t patch = {0, 0, UINT16_MAX, UINT16_MAX, 0}; + texpatch_t patch = {0, 0, UINT16_MAX, UINT16_MAX, 0, 255, AST_COPY}; // Jump to the texture this patch belongs to, which, // coincidentally, is always the last one on the buffer cache. diff --git a/src/r_data.c b/src/r_data.c index 47bffd471..ddf626893 100644 --- a/src/r_data.c +++ b/src/r_data.c @@ -148,6 +148,8 @@ static inline void R_DrawColumnInCache(column_t *patch, UINT8 *cache, texpatch_t INT32 topdelta, prevdelta = -1; INT32 originy = originPatch->originy; + (void)patchheight; // This parameter is unused + while (patch->topdelta != 0xff) { topdelta = patch->topdelta; @@ -230,6 +232,8 @@ static inline void R_DrawTransColumnInCache(column_t *patch, UINT8 *cache, texpa INT32 topdelta, prevdelta = -1; INT32 originy = originPatch->originy; + (void)patchheight; // This parameter is unused + while (patch->topdelta != 0xff) { topdelta = patch->topdelta; From 5877cc40d921cb914595976dc1cd978d22d904c3 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Sun, 19 Mar 2017 20:08:33 +0000 Subject: [PATCH 10/10] You actually don't need to set ColumnDrawerPointer to &R_DrawColumnInCache etc, C allows you to set it directly to R_DrawColumnInCache etc. ColumnDrawerPointer can then be called without the (* ) stuff --- src/r_data.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/r_data.c b/src/r_data.c index ddf626893..4df5209a5 100644 --- a/src/r_data.c +++ b/src/r_data.c @@ -426,11 +426,11 @@ static UINT8 *R_GenerateTexture(size_t texnum) { if (patch->alpha < 255/11) // Is the patch way too translucent? Don't render then. continue; - ColumnDrawerPointer = (patch->flip & 2) ? &R_DrawTransFlippedColumnInCache : &R_DrawTransColumnInCache; + ColumnDrawerPointer = (patch->flip & 2) ? R_DrawTransFlippedColumnInCache : R_DrawTransColumnInCache; } else { - ColumnDrawerPointer = (patch->flip & 2) ? &R_DrawFlippedColumnInCache : &R_DrawColumnInCache; + ColumnDrawerPointer = (patch->flip & 2) ? R_DrawFlippedColumnInCache : R_DrawColumnInCache; } realpatch = W_CacheLumpNumPwad(patch->wad, patch->lump, PU_CACHE); @@ -456,7 +456,7 @@ static UINT8 *R_GenerateTexture(size_t texnum) // generate column ofset lookup colofs[x] = LONG((x * texture->height) + (texture->width*4)); - (*ColumnDrawerPointer)(patchcol, block + LONG(colofs[x]), patch, texture->height, height); + ColumnDrawerPointer(patchcol, block + LONG(colofs[x]), patch, texture->height, height); } }