diff --git a/polymer/eduke32/build/include/polymost.h b/polymer/eduke32/build/include/polymost.h index b100989f5..4f98ea3c9 100644 --- a/polymer/eduke32/build/include/polymost.h +++ b/polymer/eduke32/build/include/polymost.h @@ -189,7 +189,7 @@ typedef struct pthtyp_t char skyface; } pthtyp; -extern void gloadtile_art(int32_t,int32_t,int32_t,int32_t,pthtyp *,int32_t); +extern void gloadtile_art(int32_t,int32_t,int32_t,int32_t,int32_t,pthtyp *,int32_t); extern int32_t gloadtile_hi(int32_t,int32_t,int32_t,hicreplctyp *,int32_t,pthtyp *,int32_t,char); extern int32_t globalnoeffect; diff --git a/polymer/eduke32/build/src/polymost.c b/polymer/eduke32/build/src/polymost.c index 564df8b1b..98f082d92 100644 --- a/polymer/eduke32/build/src/polymost.c +++ b/polymer/eduke32/build/src/polymost.c @@ -799,7 +799,7 @@ static void polymost_setuptexture(const int32_t dameth, int filter) } } -void gloadtile_art(int32_t dapic, int32_t dapal, int32_t dashade, int32_t dameth, pthtyp *pth, int32_t doalloc) +void gloadtile_art(int32_t dapic, int32_t dapal, int32_t tintpalnum, int32_t dashade, int32_t dameth, pthtyp *pth, int32_t doalloc) { static int32_t fullbrightloadingpass = 0; @@ -884,6 +884,35 @@ void gloadtile_art(int32_t dapic, int32_t dapal, int32_t dashade, int32_t dameth } bricolor((palette_t *)wpptr, dacol); + + if (!fullbrightloadingpass && tintpalnum >= 0) + { + uint8_t const r = hictinting[tintpalnum].r; + uint8_t const g = hictinting[tintpalnum].g; + uint8_t const b = hictinting[tintpalnum].b; + uint8_t const effect = hictinting[tintpalnum].f; + + if (effect & HICTINT_GRAYSCALE) + { + wpptr->g = wpptr->r = wpptr->b = (uint8_t) ((wpptr->r * GRAYSCALE_COEFF_RED) + + (wpptr->g * GRAYSCALE_COEFF_GREEN) + + (wpptr->b * GRAYSCALE_COEFF_BLUE)); + } + + if (effect & HICTINT_INVERT) + { + wpptr->b = 255 - wpptr->b; + wpptr->g = 255 - wpptr->g; + wpptr->r = 255 - wpptr->r; + } + + if (effect & HICTINT_COLORIZE) + { + wpptr->b = min((int32_t)((wpptr->b) * b) >> 6, 255); + wpptr->g = min((int32_t)((wpptr->g) * g) >> 6, 255); + wpptr->r = min((int32_t)((wpptr->r) * r) >> 6, 255); + } + } } } } @@ -934,7 +963,7 @@ void gloadtile_art(int32_t dapic, int32_t dapal, int32_t dashade, int32_t dameth pth->ofb = (pthtyp *)Xcalloc(1,sizeof(pthtyp)); pth->flags |= PTH_HASFULLBRIGHT; - gloadtile_art(dapic, dapal, 0, dameth, pth->ofb, 1); + gloadtile_art(dapic, dapal, -1, 0, dameth, pth->ofb, 1); fullbrightloadingpass = 0; } diff --git a/polymer/eduke32/build/src/texcache.c b/polymer/eduke32/build/src/texcache.c index 748543eda..18a54f2fa 100644 --- a/polymer/eduke32/build/src/texcache.c +++ b/polymer/eduke32/build/src/texcache.c @@ -31,13 +31,19 @@ static const char *texcache_errorstr[TEXCACHEERRORS] = { "bglGetTexLevelParameteriv failed", }; -static pthtyp *texcache_tryart(int32_t dapicnum, int32_t dapalnum, int32_t dashade, int32_t dameth) +static pthtyp *texcache_tryart(int32_t const dapicnum, int32_t const dapalnum, int32_t const dashade, int32_t const dameth) { const int32_t j = dapicnum&(GLTEXCACHEADSIZ-1); pthtyp *pth; + int32_t tintpalnum = -1; + int32_t searchpalnum = dapalnum; - if ((hictinting[dapalnum].f & HICTINT_USEONART) && !(hictinting[dapalnum].f & HICTINT_APPLYOVERPALSWAP)) - dapalnum = 0; + if (hictinting[dapalnum].f & HICTINT_USEONART) + { + tintpalnum = dapalnum; + if (!(hictinting[dapalnum].f & HICTINT_APPLYOVERPALSWAP)) + searchpalnum = 0; + } // load from art for (pth=texcache.list[j]; pth; pth=pth->next) @@ -49,7 +55,8 @@ static pthtyp *texcache_tryart(int32_t dapicnum, int32_t dapalnum, int32_t dasha if (pth->flags & PTH_INVALIDATED) { pth->flags &= ~PTH_INVALIDATED; - gloadtile_art(dapicnum, dapalnum, dashade, dameth, pth, 0); + gloadtile_art(dapicnum, searchpalnum, tintpalnum, dashade, dameth, pth, 0); + pth->palnum = dapalnum; } return(pth); @@ -57,8 +64,9 @@ static pthtyp *texcache_tryart(int32_t dapicnum, int32_t dapalnum, int32_t dasha pth = (pthtyp *)Xcalloc(1,sizeof(pthtyp)); - gloadtile_art(dapicnum,dapalnum,dashade,dameth,pth,1); + gloadtile_art(dapicnum, searchpalnum, tintpalnum, dashade, dameth, pth, 1); + pth->palnum = dapalnum; pth->next = texcache.list[j]; texcache.list[j] = pth;