From bf13726c1e804bb0859ce080b635c3321ff7c0ca Mon Sep 17 00:00:00 2001 From: Latapostrophe Date: Thu, 13 Jun 2019 10:14:07 +0200 Subject: [PATCH] encore colormaps, fixups + flat align --- src/hardware/hw_cache.c | 14 ++++++------ src/hardware/hw_main.c | 20 ++++++++++------- src/p_setup.c | 48 ++++++++++++++++++++++++++++++++++------- 3 files changed, 59 insertions(+), 23 deletions(-) diff --git a/src/hardware/hw_cache.c b/src/hardware/hw_cache.c index 32f9c285..64b7e0a9 100644 --- a/src/hardware/hw_cache.c +++ b/src/hardware/hw_cache.c @@ -346,10 +346,10 @@ static void HWR_GenerateTexture(INT32 texnum, GLTexture_t *grtex) grtex->mipmap.height = (UINT16)blockheight; grtex->mipmap.grInfo.format = textureformat; -#ifdef GLENCORE grtex->mipmap.colormap = colormaps; - - if (encoremode) + +#ifdef GLENCORE + if (encoremap) grtex->mipmap.colormap += (256*32); #endif @@ -634,11 +634,11 @@ void HWR_GetFlat(lumpnum_t flatlumpnum) GLMipmap_t *grmip; grmip = &HWR_GetCachedGLPatch(flatlumpnum)->mipmap; - -#ifdef GLENCORE + grmip->colormap = colormaps; - - if (encoremode) + +#ifdef GLENCORE + if (encoremap) grmip->colormap += (256*32); #endif diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 1b7cc4b1..3b1327cd 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -387,13 +387,13 @@ void HWR_RenderPlane(extrasubsector_t *xsub, boolean isceiling, fixed_t fixedhei { scrollx = FIXED_TO_FLOAT(FOFsector->floor_xoffs)/fflatsize; scrolly = FIXED_TO_FLOAT(FOFsector->floor_yoffs)/fflatsize; - angle = FOFsector->floorpic_angle>>ANGLETOFINESHIFT; + angle = FOFsector->floorpic_angle; } else // it's a ceiling { scrollx = FIXED_TO_FLOAT(FOFsector->ceiling_xoffs)/fflatsize; scrolly = FIXED_TO_FLOAT(FOFsector->ceiling_yoffs)/fflatsize; - angle = FOFsector->ceilingpic_angle>>ANGLETOFINESHIFT; + angle = FOFsector->ceilingpic_angle; } } else if (gr_frontsector) @@ -402,24 +402,27 @@ void HWR_RenderPlane(extrasubsector_t *xsub, boolean isceiling, fixed_t fixedhei { scrollx = FIXED_TO_FLOAT(gr_frontsector->floor_xoffs)/fflatsize; scrolly = FIXED_TO_FLOAT(gr_frontsector->floor_yoffs)/fflatsize; - angle = gr_frontsector->floorpic_angle>>ANGLETOFINESHIFT; + angle = gr_frontsector->floorpic_angle; } else // it's a ceiling { scrollx = FIXED_TO_FLOAT(gr_frontsector->ceiling_xoffs)/fflatsize; scrolly = FIXED_TO_FLOAT(gr_frontsector->ceiling_yoffs)/fflatsize; - angle = gr_frontsector->ceilingpic_angle>>ANGLETOFINESHIFT; + angle = gr_frontsector->ceilingpic_angle; } } + if (angle) // Only needs to be done if there's an altered angle { + angle = InvAngle(angle)>>ANGLETOFINESHIFT; + // This needs to be done so that it scrolls in a different direction after rotation like software - tempxsow = FLOAT_TO_FIXED(scrollx); + /*tempxsow = FLOAT_TO_FIXED(scrollx); tempytow = FLOAT_TO_FIXED(scrolly); scrollx = (FIXED_TO_FLOAT(FixedMul(tempxsow, FINECOSINE(angle)) - FixedMul(tempytow, FINESINE(angle)))); - scrolly = (FIXED_TO_FLOAT(FixedMul(tempxsow, FINESINE(angle)) + FixedMul(tempytow, FINECOSINE(angle)))); + scrolly = (FIXED_TO_FLOAT(FixedMul(tempxsow, FINESINE(angle)) + FixedMul(tempytow, FINECOSINE(angle))));*/ // This needs to be done so everything aligns after rotation // It would be done so that rotation is done, THEN the translation, but I couldn't get it to rotate AND scroll like software does @@ -429,6 +432,7 @@ void HWR_RenderPlane(extrasubsector_t *xsub, boolean isceiling, fixed_t fixedhei flatyref = (FIXED_TO_FLOAT(FixedMul(tempxsow, FINESINE(angle)) + FixedMul(tempytow, FINECOSINE(angle)))); } + for (i = 0; i < nrPlaneVerts; i++,v3d++,pv++) { // Hurdler: add scrolling texture on floor/ceiling @@ -4381,7 +4385,7 @@ void HWR_ProjectSprite(mobj_t *thing) { vis->colormap = colormaps; #ifdef GLENCORE - if (encoremap && (thing->flags & (MF_SCENERY|MF_NOTHINK))) + if (encoremap && (thing->flags & (MF_SCENERY|MF_NOTHINK)) && !(thing->flags & MF_DONTENCOREMAP)) vis->colormap += (256*32); #endif } @@ -4499,7 +4503,7 @@ void HWR_ProjectPrecipitationSprite(precipmobj_t *thing) vis->colormap = colormaps; #ifdef GLENCORE - if (encoremap) + if (encoremap && !(thing->flags & MF_DONTENCOREMAP)) vis->colormap += (256*32); #endif diff --git a/src/p_setup.c b/src/p_setup.c index 6c6ef828..c5bded51 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -1408,6 +1408,8 @@ static void P_LoadRawSideDefs2(void *data) { UINT16 i; INT32 num; + size_t j; + UINT32 cr, cg, cb; for (i = 0; i < numsides; i++) { @@ -1486,10 +1488,26 @@ static void P_LoadRawSideDefs2(void *data) { col = msd->toptexture; - sec->extra_colormap->rgba = - (HEX2INT(col[1]) << 4) + (HEX2INT(col[2]) << 0) + - (HEX2INT(col[3]) << 12) + (HEX2INT(col[4]) << 8) + - (HEX2INT(col[5]) << 20) + (HEX2INT(col[6]) << 16); + // encore mode colormaps! + // do it like software by aproximating a color to a palette index, and then convert it to its encore variant and then back to a color code. + // do this for both the start and fade colormaps. + + cr = (HEX2INT(col[1]) << 4) + (HEX2INT(col[2]) << 0); + cg = (HEX2INT(col[3]) << 12) + (HEX2INT(col[4]) << 8); + cb = (HEX2INT(col[5]) << 20) + (HEX2INT(col[6]) << 16); + +#ifdef GLENCORE + if (encoremap) + { + j = encoremap[NearestColor((UINT8)cr, (UINT8)cg, (UINT8)cb)]; + //CONS_Printf("R_CreateColormap: encoremap[%d] = %d\n", j, encoremap[j]); -- moved encoremap upwards for optimisation + cr = pLocalPalette[j].s.red; + cg = pLocalPalette[j].s.green; + cb = pLocalPalette[j].s.blue; + } +#endif + + sec->extra_colormap->rgba = cr + cg + cb; // alpha if (msd->toptexture[7]) @@ -1515,10 +1533,24 @@ static void P_LoadRawSideDefs2(void *data) { col = msd->bottomtexture; - sec->extra_colormap->fadergba = - (HEX2INT(col[1]) << 4) + (HEX2INT(col[2]) << 0) + - (HEX2INT(col[3]) << 12) + (HEX2INT(col[4]) << 8) + - (HEX2INT(col[5]) << 20) + (HEX2INT(col[6]) << 16); + // do the exact same thing as above here. + + cr = (HEX2INT(col[1]) << 4) + (HEX2INT(col[2]) << 0); + cg = (HEX2INT(col[3]) << 12) + (HEX2INT(col[4]) << 8); + cb = (HEX2INT(col[5]) << 20) + (HEX2INT(col[6]) << 16); + +#ifdef GLENCORE + if (encoremap) + { + j = encoremap[NearestColor((UINT8)cr, (UINT8)cg, (UINT8)cb)]; + //CONS_Printf("R_CreateColormap: encoremap[%d] = %d\n", j, encoremap[j]); -- moved encoremap upwards for optimisation + cr = pLocalPalette[j].s.red; + cg = pLocalPalette[j].s.green; + cb = pLocalPalette[j].s.blue; + } +#endif + + sec->extra_colormap->fadergba = cr + cg + cb; // alpha if (msd->bottomtexture[7])