From 57ae890140eebebe60d3951032359caa9adf1de2 Mon Sep 17 00:00:00 2001 From: nukeykt Date: Sun, 13 Oct 2019 07:27:12 +0900 Subject: [PATCH] More gl related palette fixes --- source/exhumed/src/light.cpp | 75 ++++++++++++++++++++++++++-------- source/exhumed/src/menu.cpp | 26 ++++++++---- source/exhumed/src/movie.cpp | 4 +- source/exhumed/src/osdcmds.cpp | 17 ++------ source/exhumed/src/view.cpp | 3 ++ 5 files changed, 84 insertions(+), 41 deletions(-) diff --git a/source/exhumed/src/light.cpp b/source/exhumed/src/light.cpp index 360254289..e7ac73f08 100644 --- a/source/exhumed/src/light.cpp +++ b/source/exhumed/src/light.cpp @@ -132,8 +132,7 @@ void GrabPalette() { SetOverscan(BASEPAL); - memcpy(curpalettefaded, curpalette, sizeof(curpalette)); - videoUpdatePalette(0, 256); + videoSetPalette(0, BASEPAL, 2+8); nPalDiff = 0; nPalDelay = 0; @@ -141,6 +140,9 @@ void GrabPalette() btint = 0; gtint = 0; rtint = 0; +#ifdef USE_OPENGL + videoTintBlood(0, 0, 0); +#endif } void BlackOut() @@ -152,12 +154,17 @@ void BlackOut() curpalettefaded[i].b = 0; } videoUpdatePalette(0, 256); +#ifdef USE_OPENGL + videoTintBlood(0, 0, 0); +#endif } void RestorePalette() { - memcpy(curpalettefaded, curpalette, sizeof(curpalette)); - videoUpdatePalette(0, 256); + videoSetPalette(0, BASEPAL, 2+8); +#ifdef USE_OPENGL + videoTintBlood(0, 0, 0); +#endif } void WaitTicks(int nTicks) @@ -179,6 +186,14 @@ void WaitTicks(int nTicks) // unused void DoFadeToRed() { +#ifdef USE_OPENGL + if (videoGetRenderMode() >= REND_POLYMOST) + { + videoTintBlood(-255, -255, -255); + videoNextPage(); + return; + } +#endif for (int i = 0; i < 256; i++) { if (curpalettefaded[i].g > 0) @@ -202,10 +217,17 @@ void DoFadeToRed() void FadeToWhite() { int ebx = 0; - int const palstep = (videoGetRenderMode() >= REND_POLYMOST) ? 255 : 4; - int const fadestep = (videoGetRenderMode() >= REND_POLYMOST) ? 1 : 64; - for (int i = 0; i < fadestep; i++) +#ifdef USE_OPENGL + if (videoGetRenderMode() >= REND_POLYMOST) + { + videoTintBlood(255, 255, 255); + videoNextPage(); + return; + } +#endif + + for (int i = 0; i < 64; i++) { palette_t *pPal = curpalettefaded; @@ -213,21 +235,21 @@ void FadeToWhite() { if (pPal->r < 255) { - pPal->r += palstep; + pPal->r += 4; if (pPal->r > 255) pPal->r = 255; ebx++; } if (pPal->g < 255) { - pPal->g += palstep; + pPal->g += 4; if (pPal->g > 255) pPal->g = 255; ebx++; } if (pPal->b < 255) { - pPal->b += palstep; + pPal->b += 4; if (pPal->b > 255) pPal->b = 255; ebx++; @@ -249,13 +271,20 @@ void FadeToWhite() void FadeOut(int bFadeMusic) { - int const palstep = (videoGetRenderMode() >= REND_POLYMOST) ? 255 : 4; - int const fadestep = (videoGetRenderMode() >= REND_POLYMOST) ? 1 : 64; if (bFadeMusic) { StartfadeCDaudio(); } - for (int i = fadestep; i > 0; i--) + +#ifdef USE_OPENGL + if (videoGetRenderMode() >= REND_POLYMOST) + { + videoTintBlood(-255, -255, -255); + videoNextPage(); + } + else +#endif + for (int i = 64; i > 0; i--) { int v4 = 0; palette_t *pPal = curpalettefaded; @@ -264,21 +293,21 @@ void FadeOut(int bFadeMusic) { if (pPal->r > 0) { - pPal->r -= palstep; + pPal->r -= 4; if (pPal->r < 0) pPal->r = 0; v4++; } if (pPal->g > 0) { - pPal->g -= palstep; + pPal->g -= 4; if (pPal->g < 0) pPal->g = 0; v4++; } if (pPal->b > 0) { - pPal->b -= palstep; + pPal->b -= 4; if (pPal->b < 0) pPal->b = 0; v4++; @@ -316,6 +345,15 @@ void StartFadeIn() int DoFadeIn() { +#ifdef USE_OPENGL + if (videoGetRenderMode() >= REND_POLYMOST) + { + paletteSetColorTable(curbasepal, basepaltable[BASEPAL]); + videoSetPalette(0, curbasepal, 2+8); + videoNextPage(); + return 0; + } +#endif int v2 = 0; for (int i = 0; i < 256; i++) @@ -356,13 +394,14 @@ int DoFadeIn() void FadeIn() { +#ifdef USE_OPENGL if (videoGetRenderMode() >= REND_POLYMOST) { - Bmemcpy(curpalettefaded, curpalette, sizeof(curpalette)); - videoUpdatePalette(0, 256); + videoSetPalette(0, BASEPAL, 2+8); videoNextPage(); return; } +#endif StartFadeIn(); int val; diff --git a/source/exhumed/src/menu.cpp b/source/exhumed/src/menu.cpp index e115ae40b..88adccd18 100644 --- a/source/exhumed/src/menu.cpp +++ b/source/exhumed/src/menu.cpp @@ -1810,17 +1810,28 @@ void CinemaFadeIn() { BlackOut(); - videoSetPalette(0, ANIMPAL, 0); + paletteSetColorTable(ANIMPAL, cinemapal); + videoSetPalette(0, ANIMPAL, 2+8); - while (1) +#ifdef USE_OPENGL + if (videoGetRenderMode() >= REND_POLYMOST) { - int val = DoFadeIn(); + videoNextPage(); + return; + } +#endif + + int val; + + do + { + val = DoFadeIn(); WaitTicks(2); - if (val <= 0) { - break; - } - } + // need to page flip in each iteration of the loop for non DOS version + videoNextPage(); + + } while (val > 0); } void ComputeCinemaText(int nLine) @@ -2071,7 +2082,6 @@ void GoToTheCinema(int nVal) overwritesprite(0, 0, 764, 100, 2, kPalNormal); videoNextPage(); - videoSetPalette(0, BASEPAL, 0); GrabPalette(); Clip(); } diff --git a/source/exhumed/src/movie.cpp b/source/exhumed/src/movie.cpp index fcea4e086..c16c7b760 100644 --- a/source/exhumed/src/movie.cpp +++ b/source/exhumed/src/movie.cpp @@ -71,7 +71,7 @@ int ReadFrame(FILE *fp) fread(&var_1C, sizeof(var_1C), 1, fp); paletteSetColorTable(ANIMPAL, palette); - videoSetPalette(0, ANIMPAL, 0); + videoSetPalette(0, ANIMPAL, 2+8); memset(CurFrame, overscanindex, 4); //sizeof(CurFrame)); continue; @@ -175,7 +175,7 @@ void PlayMovie(const char *fileName) int angle = 1536; int z = 0; - videoSetPalette(0, ANIMPAL, 0); + videoSetPalette(0, ANIMPAL, 2+8); if (ReadFrame(fp)) { diff --git a/source/exhumed/src/osdcmds.cpp b/source/exhumed/src/osdcmds.cpp index ecc8e5e9d..905090f7d 100644 --- a/source/exhumed/src/osdcmds.cpp +++ b/source/exhumed/src/osdcmds.cpp @@ -122,16 +122,9 @@ static int osdcmd_initgroupfile(osdcmdptr_t parm) void onvideomodechange(int32_t newmode) { - // TODO: + uint8_t palid = BASEPAL; + #if 0 - uint8_t palid; - - // XXX? - if (!newmode || g_player[screenpeek].ps->palette < BASEPALCOUNT) - palid = g_player[screenpeek].ps->palette; - else - palid = BASEPAL; - #ifdef POLYMER if (videoGetRenderMode() == REND_POLYMER) { @@ -149,11 +142,9 @@ void onvideomodechange(int32_t newmode) } } #endif - - videoSetPalette(ud.brightness>>2, palid, 0); - g_restorePalette = -1; - g_crosshairSum = -1; #endif + + videoSetPalette(0, palid, 0); } static int osdcmd_button(osdcmdptr_t parm) diff --git a/source/exhumed/src/view.cpp b/source/exhumed/src/view.cpp index 57054f988..4db850a33 100644 --- a/source/exhumed/src/view.cpp +++ b/source/exhumed/src/view.cpp @@ -165,6 +165,9 @@ void ResetView() EraseScreen(overscanindex); memcpy(curpalettefaded, curpalette, sizeof(curpalette)); videoUpdatePalette(0, 256); +#ifdef USE_OPENGL + videoTintBlood(0, 0, 0); +#endif LoadStatus(); }