From 98b7d8aaca1e9c667b4d8ee55d7015998588646f Mon Sep 17 00:00:00 2001 From: Jaime Passos Date: Wed, 1 Jan 2020 15:55:18 -0300 Subject: [PATCH 01/11] Fix broken model light lists in ACZ3 --- src/hardware/hw_md2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hardware/hw_md2.c b/src/hardware/hw_md2.c index 630c1e181..13a8cc44e 100644 --- a/src/hardware/hw_md2.c +++ b/src/hardware/hw_md2.c @@ -1108,7 +1108,7 @@ boolean HWR_DrawModel(gr_vissprite_t *spr) { sector_t *sector = spr->mobj->subsector->sector; UINT8 lightlevel = 255; - extracolormap_t *colormap = sector->extra_colormap; + extracolormap_t *colormap = NULL; if (sector->numlights) { From 401c35b4075d2345609b690420705c81d34b6423 Mon Sep 17 00:00:00 2001 From: Jaime Passos Date: Wed, 1 Jan 2020 17:28:22 -0300 Subject: [PATCH 02/11] Fix transparent PNG conversion --- src/r_patch.c | 61 ++++++++++++++++++++++++++++++++++++++++++--------- src/r_patch.h | 2 +- src/w_wad.c | 31 +++++++++++++------------- 3 files changed, 67 insertions(+), 27 deletions(-) diff --git a/src/r_patch.c b/src/r_patch.c index 18dfe523a..7508234a5 100644 --- a/src/r_patch.c +++ b/src/r_patch.c @@ -250,6 +250,9 @@ patch_t *R_FlatToPatch(UINT8 *raw, UINT16 width, UINT16 height, UINT16 leftoffse UINT8 *colpointers, *startofspan; size_t size = 0; + if (!raw) + return NULL; + // Write image size and offset WRITEINT16(imgptr, width); WRITEINT16(imgptr, height); @@ -353,12 +356,13 @@ patch_t *R_FlatToPatch(UINT8 *raw, UINT16 width, UINT16 height, UINT16 leftoffse // // Convert a 16-bit flat to a patch. // -patch_t *R_FlatToPatch_16bpp(UINT16 *raw, UINT16 width, UINT16 height, size_t *size) +patch_t *R_FlatToPatch_16bpp(UINT16 *raw, UINT16 width, UINT16 height, UINT16 leftoffset, UINT16 topoffset, size_t *destsize) { UINT32 x, y; UINT8 *img; UINT8 *imgptr = imgbuf; UINT8 *colpointers, *startofspan; + size_t size = 0; if (!raw) return NULL; @@ -366,9 +370,8 @@ patch_t *R_FlatToPatch_16bpp(UINT16 *raw, UINT16 width, UINT16 height, size_t *s // Write image size and offset WRITEINT16(imgptr, width); WRITEINT16(imgptr, height); - // no offsets - WRITEINT16(imgptr, 0); - WRITEINT16(imgptr, 0); + WRITEINT16(imgptr, leftoffset); + WRITEINT16(imgptr, topoffset); // Leave placeholder to column pointers colpointers = imgptr; @@ -452,9 +455,12 @@ patch_t *R_FlatToPatch_16bpp(UINT16 *raw, UINT16 width, UINT16 height, size_t *s WRITEUINT8(imgptr, 0xFF); } - *size = imgptr-imgbuf; - img = Z_Malloc(*size, PU_STATIC, NULL); - memcpy(img, imgbuf, *size); + size = imgptr-imgbuf; + img = Z_Malloc(size, PU_STATIC, NULL); + memcpy(img, imgbuf, size); + + if (destsize != NULL) + *destsize = size; return (patch_t *)img; } @@ -677,6 +683,41 @@ static UINT8 *PNG_RawConvert(const UINT8 *png, UINT16 *w, UINT16 *h, INT16 *topo return flat; } +// Convert a PNG with transparency to a raw image. +static UINT16 *PNG_RawConvert_16bpp(const UINT8 *png, UINT16 *w, UINT16 *h, INT16 *topoffset, INT16 *leftoffset, size_t size) +{ + UINT16 *flat; + png_uint_32 x, y; + png_bytep *row_pointers = PNG_Read(png, w, h, topoffset, leftoffset, size); + png_uint_32 width = *w, height = *h; + size_t flatsize, i; + + if (!row_pointers) + I_Error("PNG_RawConvert_16bpp: conversion failed"); + + // Convert the image to 16bpp + flatsize = (width * height); + flat = Z_Malloc(flatsize * sizeof(UINT16), PU_LEVEL, NULL); + + // can't memset here + for (i = 0; i < flatsize; i++) + flat[i] = 0xFF00; + + for (y = 0; y < height; y++) + { + png_bytep row = row_pointers[y]; + for (x = 0; x < width; x++) + { + png_bytep px = &(row[x * 4]); + if ((UINT8)px[3]) + flat[((y * width) + x)] = NearestColor((UINT8)px[0], (UINT8)px[1], (UINT8)px[2]); + } + } + free(row_pointers); + + return flat; +} + // // R_PNGToFlat // @@ -696,12 +737,12 @@ patch_t *R_PNGToPatch(const UINT8 *png, size_t size, size_t *destsize, boolean t { UINT16 width, height; INT16 topoffset = 0, leftoffset = 0; - UINT8 *raw = PNG_RawConvert(png, &width, &height, &topoffset, &leftoffset, size); + UINT16 *raw = PNG_RawConvert_16bpp(png, &width, &height, &topoffset, &leftoffset, size); if (!raw) I_Error("R_PNGToPatch: conversion failed"); - return R_FlatToPatch(raw, width, height, leftoffset, topoffset, destsize, transparency); + return R_FlatToPatch_16bpp(raw, width, height, leftoffset, topoffset, destsize); } // @@ -1264,7 +1305,7 @@ void R_CacheRotSprite(spritenum_t sprnum, UINT8 frame, spriteinfo_t *sprinfo, sp } // make patch - newpatch = R_FlatToPatch_16bpp(rawdst, newwidth, newheight, &size); + newpatch = R_FlatToPatch_16bpp(rawdst, newwidth, newheight, 0, 0, &size); { newpatch->leftoffset = (newpatch->width / 2) + (leftoffset - px); newpatch->topoffset = (newpatch->height / 2) + (patch->topoffset - py); diff --git a/src/r_patch.h b/src/r_patch.h index 53d306b88..71f715ccc 100644 --- a/src/r_patch.h +++ b/src/r_patch.h @@ -47,7 +47,7 @@ void R_TextureToFlat(size_t tex, UINT8 *flat); void R_PatchToFlat(patch_t *patch, UINT8 *flat); void R_PatchToFlat_16bpp(patch_t *patch, UINT16 *raw, boolean flip); patch_t *R_FlatToPatch(UINT8 *raw, UINT16 width, UINT16 height, UINT16 leftoffset, UINT16 topoffset, size_t *destsize, boolean transparency); -patch_t *R_FlatToPatch_16bpp(UINT16 *raw, UINT16 width, UINT16 height, size_t *size); +patch_t *R_FlatToPatch_16bpp(UINT16 *raw, UINT16 width, UINT16 height, UINT16 leftoffset, UINT16 topoffset, size_t *destsize); // Portable Network Graphics boolean R_IsLumpPNG(const UINT8 *d, size_t s); diff --git a/src/w_wad.c b/src/w_wad.c index d8b362d49..82f9526c6 100644 --- a/src/w_wad.c +++ b/src/w_wad.c @@ -1465,6 +1465,21 @@ boolean W_IsPatchCached(lumpnum_t lumpnum, void *ptr) return W_IsPatchCachedPWAD(WADFILENUM(lumpnum),LUMPNUM(lumpnum), ptr); } +void W_FlushCachedPatches(void) +{ + if (needpatchflush) + { + Z_FreeTag(PU_CACHE); + Z_FreeTag(PU_PATCH); + Z_FreeTag(PU_HUDGFX); + Z_FreeTag(PU_HWRPATCHINFO); + Z_FreeTag(PU_HWRMODELTEXTURE); + Z_FreeTag(PU_HWRCACHE); + Z_FreeTags(PU_HWRCACHE_UNLOCKED, PU_HWRPATCHINFO_UNLOCKED); + } + needpatchflush = false; +} + // ========================================================================== // W_CacheLumpName // ========================================================================== @@ -1488,22 +1503,6 @@ void *W_CacheLumpName(const char *name, INT32 tag) // Cache a patch into heap memory, convert the patch format as necessary // -void W_FlushCachedPatches(void) -{ - if (needpatchflush) - { - Z_FreeTag(PU_CACHE); - Z_FreeTag(PU_PATCH); - Z_FreeTag(PU_HUDGFX); - Z_FreeTag(PU_HWRPATCHINFO); - Z_FreeTag(PU_HWRMODELTEXTURE); - Z_FreeTag(PU_HWRCACHE); - Z_FreeTags(PU_HWRCACHE_UNLOCKED, PU_HWRPATCHINFO_UNLOCKED); - } - needpatchflush = false; -} - -// Software-only compile cache the data without conversion void *W_CachePatchNumPwad(UINT16 wad, UINT16 lump, INT32 tag) { #ifdef HWRENDER From 6d2f2e0865ffceb59e825897d5eda5b23facf541 Mon Sep 17 00:00:00 2001 From: Jaime Passos Date: Wed, 1 Jan 2020 17:30:07 -0300 Subject: [PATCH 03/11] Update copyrights --- src/r_patch.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/r_patch.c b/src/r_patch.c index 7508234a5..db5d874b4 100644 --- a/src/r_patch.c +++ b/src/r_patch.c @@ -2,8 +2,8 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 2005-2009 by Andrey "entryway" Budko. -// Copyright (C) 2018-2019 by Jaime "Lactozilla" Passos. -// Copyright (C) 2019 by Sonic Team Junior. +// Copyright (C) 2018-2020 by Jaime "Lactozilla" Passos. +// Copyright (C) 2019-2020 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. From c7794d4ce03eff87afd40d59234de7129c319dc7 Mon Sep 17 00:00:00 2001 From: Jaime Passos Date: Wed, 1 Jan 2020 17:36:55 -0300 Subject: [PATCH 04/11] Remove unused parameter --- src/hardware/hw_cache.c | 4 ++-- src/r_data.c | 2 +- src/r_patch.c | 2 +- src/r_patch.h | 2 +- src/r_things.c | 2 +- src/w_wad.c | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/hardware/hw_cache.c b/src/hardware/hw_cache.c index c47833187..46f7b2bde 100644 --- a/src/hardware/hw_cache.c +++ b/src/hardware/hw_cache.c @@ -654,7 +654,7 @@ static void HWR_GenerateTexture(INT32 texnum, GLTexture_t *grtex) #ifndef NO_PNG_LUMPS if (R_IsLumpPNG((UINT8 *)realpatch, lumplength)) - realpatch = R_PNGToPatch((UINT8 *)realpatch, lumplength, NULL, false); + realpatch = R_PNGToPatch((UINT8 *)realpatch, lumplength, NULL); else #endif #ifdef WALLFLATS @@ -698,7 +698,7 @@ void HWR_MakePatch (const patch_t *patch, GLPatch_t *grPatch, GLMipmap_t *grMipm // lump is a png so convert it size_t len = W_LumpLengthPwad(grPatch->wadnum, grPatch->lumpnum); if ((patch != NULL) && R_IsLumpPNG((const UINT8 *)patch, len)) - patch = R_PNGToPatch((const UINT8 *)patch, len, NULL, true); + patch = R_PNGToPatch((const UINT8 *)patch, len, NULL); #endif // don't do it twice (like a cache) diff --git a/src/r_data.c b/src/r_data.c index bfd83a62d..5eac508d6 100644 --- a/src/r_data.c +++ b/src/r_data.c @@ -571,7 +571,7 @@ static UINT8 *R_GenerateTexture(size_t texnum) #ifndef NO_PNG_LUMPS if (R_IsLumpPNG((UINT8 *)realpatch, lumplength)) - realpatch = R_PNGToPatch((UINT8 *)realpatch, lumplength, NULL, false); + realpatch = R_PNGToPatch((UINT8 *)realpatch, lumplength, NULL); else #endif #ifdef WALLFLATS diff --git a/src/r_patch.c b/src/r_patch.c index db5d874b4..308385686 100644 --- a/src/r_patch.c +++ b/src/r_patch.c @@ -733,7 +733,7 @@ UINT8 *R_PNGToFlat(UINT16 *width, UINT16 *height, UINT8 *png, size_t size) // // Convert a PNG to a patch. // -patch_t *R_PNGToPatch(const UINT8 *png, size_t size, size_t *destsize, boolean transparency) +patch_t *R_PNGToPatch(const UINT8 *png, size_t size, size_t *destsize) { UINT16 width, height; INT16 topoffset = 0, leftoffset = 0; diff --git a/src/r_patch.h b/src/r_patch.h index 71f715ccc..2a216193f 100644 --- a/src/r_patch.h +++ b/src/r_patch.h @@ -55,7 +55,7 @@ boolean R_IsLumpPNG(const UINT8 *d, size_t s); #ifndef NO_PNG_LUMPS UINT8 *R_PNGToFlat(UINT16 *width, UINT16 *height, UINT8 *png, size_t size); -patch_t *R_PNGToPatch(const UINT8 *png, size_t size, size_t *destsize, boolean transparency); +patch_t *R_PNGToPatch(const UINT8 *png, size_t size, size_t *destsize); boolean R_PNGDimensions(UINT8 *png, INT16 *width, INT16 *height, size_t size); #endif diff --git a/src/r_things.c b/src/r_things.c index a328da03a..7ecb14e7e 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -284,7 +284,7 @@ static boolean R_AddSingleSpriteDef(const char *sprname, spritedef_t *spritedef, // lump is a png so convert it if (R_IsLumpPNG((UINT8 *)png, len)) { - png = R_PNGToPatch((UINT8 *)png, len, NULL, true); + png = R_PNGToPatch((UINT8 *)png, len, NULL); M_Memcpy(&patch, png, sizeof(INT16)*4); } Z_Free(png); diff --git a/src/w_wad.c b/src/w_wad.c index 82f9526c6..bbb30d3fa 100644 --- a/src/w_wad.c +++ b/src/w_wad.c @@ -1540,7 +1540,7 @@ void *W_CachePatchNumPwad(UINT16 wad, UINT16 lump, INT32 tag) if (R_IsLumpPNG((UINT8 *)lumpdata, len)) { size_t newlen; - srcdata = R_PNGToPatch((UINT8 *)lumpdata, len, &newlen, true); + srcdata = R_PNGToPatch((UINT8 *)lumpdata, len, &newlen); ptr = Z_Realloc(ptr, newlen, tag, &lumpcache[lump]); M_Memcpy(ptr, srcdata, newlen); Z_Free(srcdata); From 03d4082f218fa3cb8282357d70e2bcd838d0e69d Mon Sep 17 00:00:00 2001 From: Jaime Passos Date: Wed, 1 Jan 2020 17:46:26 -0300 Subject: [PATCH 05/11] Rename functions --- src/r_patch.c | 29 +++++++++++++++++------------ src/r_patch.h | 4 ++-- 2 files changed, 19 insertions(+), 14 deletions(-) diff --git a/src/r_patch.c b/src/r_patch.c index 308385686..31f4411b1 100644 --- a/src/r_patch.c +++ b/src/r_patch.c @@ -201,11 +201,15 @@ void R_PatchToFlat(patch_t *patch, UINT8 *flat) } // -// R_PatchToFlat_16bpp +// R_PatchToMaskedFlat // -// Convert a patch to a 16-bit flat. +// Convert a patch to a masked flat. +// Now, what is a "masked" flat anyway? +// It means the flat uses two bytes to store image data. +// The upper byte is used to store the transparent pixel, +// and the lower byte stores a palette index. // -void R_PatchToFlat_16bpp(patch_t *patch, UINT16 *raw, boolean flip) +void R_PatchToMaskedFlat(patch_t *patch, UINT16 *raw, boolean flip) { fixed_t col, ofs; column_t *column; @@ -352,11 +356,12 @@ patch_t *R_FlatToPatch(UINT8 *raw, UINT16 width, UINT16 height, UINT16 leftoffse } // -// R_FlatToPatch_16bpp +// R_MaskedFlatToPatch // -// Convert a 16-bit flat to a patch. +// Convert a masked flat to a patch. +// Explanation of "masked" flats in R_PatchToMaskedFlat. // -patch_t *R_FlatToPatch_16bpp(UINT16 *raw, UINT16 width, UINT16 height, UINT16 leftoffset, UINT16 topoffset, size_t *destsize) +patch_t *R_MaskedFlatToPatch(UINT16 *raw, UINT16 width, UINT16 height, UINT16 leftoffset, UINT16 topoffset, size_t *destsize) { UINT32 x, y; UINT8 *img; @@ -684,7 +689,7 @@ static UINT8 *PNG_RawConvert(const UINT8 *png, UINT16 *w, UINT16 *h, INT16 *topo } // Convert a PNG with transparency to a raw image. -static UINT16 *PNG_RawConvert_16bpp(const UINT8 *png, UINT16 *w, UINT16 *h, INT16 *topoffset, INT16 *leftoffset, size_t size) +static UINT16 *PNG_MaskedRawConvert(const UINT8 *png, UINT16 *w, UINT16 *h, INT16 *topoffset, INT16 *leftoffset, size_t size) { UINT16 *flat; png_uint_32 x, y; @@ -693,7 +698,7 @@ static UINT16 *PNG_RawConvert_16bpp(const UINT8 *png, UINT16 *w, UINT16 *h, INT1 size_t flatsize, i; if (!row_pointers) - I_Error("PNG_RawConvert_16bpp: conversion failed"); + I_Error("PNG_MaskedRawConvert: conversion failed"); // Convert the image to 16bpp flatsize = (width * height); @@ -737,12 +742,12 @@ patch_t *R_PNGToPatch(const UINT8 *png, size_t size, size_t *destsize) { UINT16 width, height; INT16 topoffset = 0, leftoffset = 0; - UINT16 *raw = PNG_RawConvert_16bpp(png, &width, &height, &topoffset, &leftoffset, size); + UINT16 *raw = PNG_MaskedRawConvert(png, &width, &height, &topoffset, &leftoffset, size); if (!raw) I_Error("R_PNGToPatch: conversion failed"); - return R_FlatToPatch_16bpp(raw, width, height, leftoffset, topoffset, destsize); + return R_MaskedFlatToPatch(raw, width, height, leftoffset, topoffset, destsize); } // @@ -1209,7 +1214,7 @@ void R_CacheRotSprite(spritenum_t sprnum, UINT8 frame, spriteinfo_t *sprinfo, sp for (i = 0; i < size; i++) rawsrc[i] = 0xFF00; - R_PatchToFlat_16bpp(patch, rawsrc, bflip); + R_PatchToMaskedFlat(patch, rawsrc, bflip); // Don't cache angle = 0 for (angle = 1; angle < ROTANGLES; angle++) @@ -1305,7 +1310,7 @@ void R_CacheRotSprite(spritenum_t sprnum, UINT8 frame, spriteinfo_t *sprinfo, sp } // make patch - newpatch = R_FlatToPatch_16bpp(rawdst, newwidth, newheight, 0, 0, &size); + newpatch = R_MaskedFlatToPatch(rawdst, newwidth, newheight, 0, 0, &size); { newpatch->leftoffset = (newpatch->width / 2) + (leftoffset - px); newpatch->topoffset = (newpatch->height / 2) + (patch->topoffset - py); diff --git a/src/r_patch.h b/src/r_patch.h index 2a216193f..f5c98ad76 100644 --- a/src/r_patch.h +++ b/src/r_patch.h @@ -45,9 +45,9 @@ typedef struct boolean R_CheckIfPatch(lumpnum_t lump); void R_TextureToFlat(size_t tex, UINT8 *flat); void R_PatchToFlat(patch_t *patch, UINT8 *flat); -void R_PatchToFlat_16bpp(patch_t *patch, UINT16 *raw, boolean flip); +void R_PatchToMaskedFlat(patch_t *patch, UINT16 *raw, boolean flip); patch_t *R_FlatToPatch(UINT8 *raw, UINT16 width, UINT16 height, UINT16 leftoffset, UINT16 topoffset, size_t *destsize, boolean transparency); -patch_t *R_FlatToPatch_16bpp(UINT16 *raw, UINT16 width, UINT16 height, UINT16 leftoffset, UINT16 topoffset, size_t *destsize); +patch_t *R_MaskedFlatToPatch(UINT16 *raw, UINT16 width, UINT16 height, UINT16 leftoffset, UINT16 topoffset, size_t *destsize); // Portable Network Graphics boolean R_IsLumpPNG(const UINT8 *d, size_t s); From 874d4d01ee3320aa1474c1ba83458095fa5bbf26 Mon Sep 17 00:00:00 2001 From: Jaime Passos Date: Wed, 1 Jan 2020 18:00:01 -0300 Subject: [PATCH 06/11] Don't Y-billboard papersprite models (?!?!??!??!?!?) --- src/hardware/hw_md2.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/hardware/hw_md2.c b/src/hardware/hw_md2.c index 13a8cc44e..d1d6e91a2 100644 --- a/src/hardware/hw_md2.c +++ b/src/hardware/hw_md2.c @@ -1145,6 +1145,7 @@ boolean HWR_DrawModel(gr_vissprite_t *spr) INT32 durs = spr->mobj->state->tics; INT32 tics = spr->mobj->tics; //mdlframe_t *next = NULL; + const boolean papersprite = (spr->mobj->frame & FF_PAPERSPRITE); const UINT8 flip = (UINT8)(!(spr->mobj->eflags & MFE_VERTICALFLIP) != !(spr->mobj->frame & FF_VERTICALFLIP)); spritedef_t *sprdef; spriteframe_t *sprframe; @@ -1367,14 +1368,12 @@ boolean HWR_DrawModel(gr_vissprite_t *spr) sprframe = &sprdef->spriteframes[spr->mobj->frame & FF_FRAMEMASK]; - if (sprframe->rotate) + if (sprframe->rotate || papersprite) { fixed_t anglef = AngleFixed(spr->mobj->angle); if (spr->mobj->player) anglef = AngleFixed(spr->mobj->player->drawangle); - else - anglef = AngleFixed(spr->mobj->angle); p.angley = FIXED_TO_FLOAT(anglef); } From 6d754821fbe565ed6dd714c877caad7ed68015f9 Mon Sep 17 00:00:00 2001 From: Jaime Passos Date: Fri, 3 Jan 2020 23:25:26 -0300 Subject: [PATCH 07/11] AA trees are not needed at all for rotated patches --- src/hardware/hw_cache.c | 17 ----------------- src/hardware/hw_glob.h | 3 --- src/r_defs.h | 3 --- src/r_patch.c | 6 ++++-- src/r_things.c | 3 --- 5 files changed, 4 insertions(+), 28 deletions(-) diff --git a/src/hardware/hw_cache.c b/src/hardware/hw_cache.c index 46f7b2bde..3b69c3c40 100644 --- a/src/hardware/hw_cache.c +++ b/src/hardware/hw_cache.c @@ -1324,23 +1324,6 @@ GLPatch_t *HWR_GetCachedGLPatch(lumpnum_t lumpnum) return HWR_GetCachedGLPatchPwad(WADFILENUM(lumpnum),LUMPNUM(lumpnum)); } -#ifdef ROTSPRITE -GLPatch_t *HWR_GetCachedGLRotSprite(aatree_t *hwrcache, UINT16 rollangle, patch_t *rawpatch) -{ - GLPatch_t *grpatch; - - if (!(grpatch = M_AATreeGet(hwrcache, rollangle))) - { - grpatch = Z_Calloc(sizeof(GLPatch_t), PU_HWRPATCHINFO, NULL); - grpatch->rawpatch = rawpatch; - grpatch->mipmap = Z_Calloc(sizeof(GLMipmap_t), PU_HWRPATCHINFO, NULL); - M_AATreeSet(hwrcache, rollangle, grpatch); - } - - return grpatch; -} -#endif - // Need to do this because they aren't powers of 2 static void HWR_DrawFadeMaskInCache(GLMipmap_t *mipmap, INT32 pblockwidth, INT32 pblockheight, lumpnum_t fademasklumpnum, UINT16 fmwidth, UINT16 fmheight) diff --git a/src/hardware/hw_glob.h b/src/hardware/hw_glob.h index cf98e7317..a2bf79817 100644 --- a/src/hardware/hw_glob.h +++ b/src/hardware/hw_glob.h @@ -113,9 +113,6 @@ GLPatch_t *HWR_GetPic(lumpnum_t lumpnum); void HWR_SetPalette(RGBA_t *palette); GLPatch_t *HWR_GetCachedGLPatchPwad(UINT16 wad, UINT16 lump); GLPatch_t *HWR_GetCachedGLPatch(lumpnum_t lumpnum); -#ifdef ROTSPRITE -GLPatch_t *HWR_GetCachedGLRotSprite(aatree_t *hwrcache, UINT16 rollangle, patch_t *rawpatch); -#endif void HWR_GetFadeMask(lumpnum_t fademasklumpnum); // -------- diff --git a/src/r_defs.h b/src/r_defs.h index 2791ac8b0..f6ea36f9f 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -740,9 +740,6 @@ typedef struct { patch_t *patch[8][ROTANGLES]; boolean cached[8]; -#ifdef HWRENDER - aatree_t *hardware_patch[8]; -#endif/*HWRENDER*/ } rotsprite_t; #endif/*ROTSPRITE*/ diff --git a/src/r_patch.c b/src/r_patch.c index 31f4411b1..c1f251ae7 100644 --- a/src/r_patch.c +++ b/src/r_patch.c @@ -1326,9 +1326,11 @@ void R_CacheRotSprite(spritenum_t sprnum, UINT8 frame, spriteinfo_t *sprinfo, sp #ifdef HWRENDER if (rendermode == render_opengl) { - GLPatch_t *grPatch = HWR_GetCachedGLRotSprite(sprframe->rotsprite.hardware_patch[rot], angle, newpatch); - HWR_MakePatch(newpatch, grPatch, grPatch->mipmap, false); + GLPatch_t *grPatch = Z_Calloc(sizeof(GLPatch_t), PU_HWRPATCHINFO, NULL); + grPatch->mipmap = Z_Calloc(sizeof(GLMipmap_t), PU_HWRPATCHINFO, NULL); + grPatch->rawpatch = newpatch; sprframe->rotsprite.patch[rot][angle] = (patch_t *)grPatch; + HWR_MakePatch(newpatch, grPatch, grPatch->mipmap, false); } else #endif // HWRENDER diff --git a/src/r_things.c b/src/r_things.c index 7ecb14e7e..d22c8d2ca 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -125,9 +125,6 @@ static void R_InstallSpriteLump(UINT16 wad, // graphics patch sprtemp[frame].rotsprite.cached[r] = false; for (ang = 0; ang < ROTANGLES; ang++) sprtemp[frame].rotsprite.patch[r][ang] = NULL; -#ifdef HWRENDER - sprtemp[frame].rotsprite.hardware_patch[r] = M_AATreeAlloc(AATREE_ZUSER); -#endif/*HWRENDER*/ } #endif/*ROTSPRITE*/ From d93adbacbb60b5f571991bcc7874059db38e7490 Mon Sep 17 00:00:00 2001 From: Jaime Passos Date: Fri, 3 Jan 2020 23:01:12 -0300 Subject: [PATCH 08/11] Fix GetTextureUsed --- src/hardware/r_opengl/r_opengl.c | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/src/hardware/r_opengl/r_opengl.c b/src/hardware/r_opengl/r_opengl.c index 129bf5678..9fa49cf76 100644 --- a/src/hardware/r_opengl/r_opengl.c +++ b/src/hardware/r_opengl/r_opengl.c @@ -2275,14 +2275,30 @@ EXPORT void HWRAPI(SetTransform) (FTransform *stransform) EXPORT INT32 HWRAPI(GetTextureUsed) (void) { - FTextureInfo* tmp = gr_cachehead; - INT32 res = 0; + FTextureInfo *tmp = gr_cachehead; + INT32 res = 0; while (tmp) { - res += tmp->height*tmp->width*(screen_depth/8); + // Figure out the correct bytes-per-pixel for this texture + // I don't know which one the game actually _uses_ but this + // follows format2bpp in hw_cache.c + int bpp = 1; + int format = tmp->grInfo.format; + if (format == GR_RGBA) + bpp = 4; + else if (format == GR_TEXFMT_RGB_565 + || format == GR_TEXFMT_ARGB_1555 + || format == GR_TEXFMT_ARGB_4444 + || format == GR_TEXFMT_ALPHA_INTENSITY_88 + || format == GR_TEXFMT_AP_88) + bpp = 2; + + // Add it up! + res += tmp->height*tmp->width*bpp; tmp = tmp->nextmipmap; } + return res; } From 9086b1851d0c76a52a724e3c183cd1ada4c84f39 Mon Sep 17 00:00:00 2001 From: Jaime Passos Date: Sun, 5 Jan 2020 22:04:19 -0300 Subject: [PATCH 09/11] Fix chroma key --- src/hardware/hw_cache.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/hardware/hw_cache.c b/src/hardware/hw_cache.c index 3b69c3c40..ccffc8a49 100644 --- a/src/hardware/hw_cache.c +++ b/src/hardware/hw_cache.c @@ -122,11 +122,11 @@ static void HWR_DrawColumnInCache(const column_t *patchcol, UINT8 *block, GLMipm if (mipmap->colormap) texel = mipmap->colormap[texel]; - // transparent pixel - if (texel == HWR_PATCHES_CHROMAKEY_COLORINDEX) + // If the mipmap is chromakeyed, check if the texel's color + // is equivalent to the chroma key's color index. + alpha = 0xff; + if ((mipmap->flags & TF_CHROMAKEYED) && (texel == HWR_PATCHES_CHROMAKEY_COLORINDEX)) alpha = 0x00; - else - alpha = 0xff; // hope compiler will get this switch out of the loops (dreams...) // gcc do it ! but vcc not ! (why don't use cygwin gcc for win32 ?) From 808d7316527375c323eb1fbd9f492ad07ed253c3 Mon Sep 17 00:00:00 2001 From: Steel Titanium Date: Mon, 6 Jan 2020 17:16:27 -0500 Subject: [PATCH 10/11] Update copyright statements for changed names --- src/f_wipe.c | 2 +- src/m_anigif.c | 2 +- src/m_anigif.h | 2 +- src/m_cond.c | 2 +- src/m_cond.h | 2 +- src/m_menu.c | 2 +- src/m_menu.h | 2 +- src/m_random.c | 2 +- src/m_random.h | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/f_wipe.c b/src/f_wipe.c index a83d104f2..a350e0f36 100644 --- a/src/f_wipe.c +++ b/src/f_wipe.c @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 2013-2016 by Matthew "Inuyasha" Walsh. +// Copyright (C) 2013-2016 by Matthew "Kaito Sinclaire" Walsh. // Copyright (C) 1999-2019 by Sonic Team Junior. // // This program is free software distributed under the diff --git a/src/m_anigif.c b/src/m_anigif.c index f761db143..32fc2746d 100644 --- a/src/m_anigif.c +++ b/src/m_anigif.c @@ -1,6 +1,6 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- -// Copyright (C) 2013-2016 by Matthew "Inuyasha" Walsh. +// Copyright (C) 2013-2016 by Matthew "Kaito Sinclaire" Walsh. // Copyright (C) 2013 by "Ninji". // Copyright (C) 2013-2019 by Sonic Team Junior. // diff --git a/src/m_anigif.h b/src/m_anigif.h index 592d2cf19..9bdf2cc7f 100644 --- a/src/m_anigif.h +++ b/src/m_anigif.h @@ -1,6 +1,6 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- -// Copyright (C) 2013-2016 by Matthew "Inuyasha" Walsh. +// Copyright (C) 2013-2016 by Matthew "Kaito Sinclaire" Walsh. // Copyright (C) 2013-2019 by Sonic Team Junior. // // This program is free software distributed under the diff --git a/src/m_cond.c b/src/m_cond.c index 1e761fdb4..08f3fe038 100644 --- a/src/m_cond.c +++ b/src/m_cond.c @@ -1,6 +1,6 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- -// Copyright (C) 2012-2016 by Matthew "Inuyasha" Walsh. +// Copyright (C) 2012-2016 by Matthew "Kaito Sinclaire" Walsh. // Copyright (C) 2012-2019 by Sonic Team Junior. // // This program is free software distributed under the diff --git a/src/m_cond.h b/src/m_cond.h index 3ea77145d..f4f017787 100644 --- a/src/m_cond.h +++ b/src/m_cond.h @@ -1,6 +1,6 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- -// Copyright (C) 2012-2016 by Matthew "Inuyasha" Walsh. +// Copyright (C) 2012-2016 by Matthew "Kaito Sinclaire" Walsh. // Copyright (C) 2012-2019 by Sonic Team Junior. // // This program is free software distributed under the diff --git a/src/m_menu.c b/src/m_menu.c index ea2c5c6d8..fb89b7e7b 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 2011-2016 by Matthew "Inuyasha" Walsh. +// Copyright (C) 2011-2016 by Matthew "Kaito Sinclaire" Walsh. // Copyright (C) 1999-2019 by Sonic Team Junior. // // This program is free software distributed under the diff --git a/src/m_menu.h b/src/m_menu.h index 00c258fe8..3504868c9 100644 --- a/src/m_menu.h +++ b/src/m_menu.h @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 2011-2016 by Matthew "Inuyasha" Walsh. +// Copyright (C) 2011-2016 by Matthew "Kaito Sinclaire" Walsh. // Copyright (C) 1999-2019 by Sonic Team Junior. // // This program is free software distributed under the diff --git a/src/m_random.c b/src/m_random.c index 8a7b62b19..8fd0e1e4e 100644 --- a/src/m_random.c +++ b/src/m_random.c @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 2012-2016 by Matthew "Inuyasha" Walsh. +// Copyright (C) 2012-2016 by Matthew "Kaito Sinclaire" Walsh. // Copyright (C) 1999-2019 by Sonic Team Junior. // // This program is free software distributed under the diff --git a/src/m_random.h b/src/m_random.h index fb14249bc..5efd3e02c 100644 --- a/src/m_random.h +++ b/src/m_random.h @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 2012-2016 by Matthew "Inuyasha" Walsh. +// Copyright (C) 2012-2016 by Matthew "Kaito Sinclaire" Walsh. // Copyright (C) 1999-2019 by Sonic Team Junior. // // This program is free software distributed under the From e069e149d983a6795aecb362bd502efa46007dc3 Mon Sep 17 00:00:00 2001 From: lachwright Date: Tue, 7 Jan 2020 13:56:54 +0800 Subject: [PATCH 11/11] Apply skin's highresscale to continue screen --- src/f_finale.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/f_finale.c b/src/f_finale.c index bf5f2ba40..bc904d8f2 100644 --- a/src/f_finale.c +++ b/src/f_finale.c @@ -3790,7 +3790,7 @@ void F_ContinueDrawer(void) sprdef = &contskins[n]->sprites[cont_spr2[n][0]];\ sprframe = &sprdef->spriteframes[cont_spr2[n][1]];\ patch = W_CachePatchNum(sprframe->lumppat[cont_spr2[n][2]], PU_PATCH);\ - V_DrawFixedPatch((dx), (dy), FRACUNIT, (sprframe->flip & (1<highresscale, (sprframe->flip & (1<