More gl related palette fixes

This commit is contained in:
nukeykt 2019-10-13 07:27:12 +09:00 committed by Christoph Oelckers
parent aa922dcd25
commit 57ae890140
5 changed files with 84 additions and 41 deletions

View file

@ -132,8 +132,7 @@ void GrabPalette()
{ {
SetOverscan(BASEPAL); SetOverscan(BASEPAL);
memcpy(curpalettefaded, curpalette, sizeof(curpalette)); videoSetPalette(0, BASEPAL, 2+8);
videoUpdatePalette(0, 256);
nPalDiff = 0; nPalDiff = 0;
nPalDelay = 0; nPalDelay = 0;
@ -141,6 +140,9 @@ void GrabPalette()
btint = 0; btint = 0;
gtint = 0; gtint = 0;
rtint = 0; rtint = 0;
#ifdef USE_OPENGL
videoTintBlood(0, 0, 0);
#endif
} }
void BlackOut() void BlackOut()
@ -152,12 +154,17 @@ void BlackOut()
curpalettefaded[i].b = 0; curpalettefaded[i].b = 0;
} }
videoUpdatePalette(0, 256); videoUpdatePalette(0, 256);
#ifdef USE_OPENGL
videoTintBlood(0, 0, 0);
#endif
} }
void RestorePalette() void RestorePalette()
{ {
memcpy(curpalettefaded, curpalette, sizeof(curpalette)); videoSetPalette(0, BASEPAL, 2+8);
videoUpdatePalette(0, 256); #ifdef USE_OPENGL
videoTintBlood(0, 0, 0);
#endif
} }
void WaitTicks(int nTicks) void WaitTicks(int nTicks)
@ -179,6 +186,14 @@ void WaitTicks(int nTicks)
// unused // unused
void DoFadeToRed() void DoFadeToRed()
{ {
#ifdef USE_OPENGL
if (videoGetRenderMode() >= REND_POLYMOST)
{
videoTintBlood(-255, -255, -255);
videoNextPage();
return;
}
#endif
for (int i = 0; i < 256; i++) for (int i = 0; i < 256; i++)
{ {
if (curpalettefaded[i].g > 0) if (curpalettefaded[i].g > 0)
@ -202,10 +217,17 @@ void DoFadeToRed()
void FadeToWhite() void FadeToWhite()
{ {
int ebx = 0; 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; palette_t *pPal = curpalettefaded;
@ -213,21 +235,21 @@ void FadeToWhite()
{ {
if (pPal->r < 255) if (pPal->r < 255)
{ {
pPal->r += palstep; pPal->r += 4;
if (pPal->r > 255) if (pPal->r > 255)
pPal->r = 255; pPal->r = 255;
ebx++; ebx++;
} }
if (pPal->g < 255) if (pPal->g < 255)
{ {
pPal->g += palstep; pPal->g += 4;
if (pPal->g > 255) if (pPal->g > 255)
pPal->g = 255; pPal->g = 255;
ebx++; ebx++;
} }
if (pPal->b < 255) if (pPal->b < 255)
{ {
pPal->b += palstep; pPal->b += 4;
if (pPal->b > 255) if (pPal->b > 255)
pPal->b = 255; pPal->b = 255;
ebx++; ebx++;
@ -249,13 +271,20 @@ void FadeToWhite()
void FadeOut(int bFadeMusic) void FadeOut(int bFadeMusic)
{ {
int const palstep = (videoGetRenderMode() >= REND_POLYMOST) ? 255 : 4;
int const fadestep = (videoGetRenderMode() >= REND_POLYMOST) ? 1 : 64;
if (bFadeMusic) { if (bFadeMusic) {
StartfadeCDaudio(); 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; int v4 = 0;
palette_t *pPal = curpalettefaded; palette_t *pPal = curpalettefaded;
@ -264,21 +293,21 @@ void FadeOut(int bFadeMusic)
{ {
if (pPal->r > 0) if (pPal->r > 0)
{ {
pPal->r -= palstep; pPal->r -= 4;
if (pPal->r < 0) if (pPal->r < 0)
pPal->r = 0; pPal->r = 0;
v4++; v4++;
} }
if (pPal->g > 0) if (pPal->g > 0)
{ {
pPal->g -= palstep; pPal->g -= 4;
if (pPal->g < 0) if (pPal->g < 0)
pPal->g = 0; pPal->g = 0;
v4++; v4++;
} }
if (pPal->b > 0) if (pPal->b > 0)
{ {
pPal->b -= palstep; pPal->b -= 4;
if (pPal->b < 0) if (pPal->b < 0)
pPal->b = 0; pPal->b = 0;
v4++; v4++;
@ -316,6 +345,15 @@ void StartFadeIn()
int DoFadeIn() 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; int v2 = 0;
for (int i = 0; i < 256; i++) for (int i = 0; i < 256; i++)
@ -356,13 +394,14 @@ int DoFadeIn()
void FadeIn() void FadeIn()
{ {
#ifdef USE_OPENGL
if (videoGetRenderMode() >= REND_POLYMOST) if (videoGetRenderMode() >= REND_POLYMOST)
{ {
Bmemcpy(curpalettefaded, curpalette, sizeof(curpalette)); videoSetPalette(0, BASEPAL, 2+8);
videoUpdatePalette(0, 256);
videoNextPage(); videoNextPage();
return; return;
} }
#endif
StartFadeIn(); StartFadeIn();
int val; int val;

View file

@ -1810,17 +1810,28 @@ void CinemaFadeIn()
{ {
BlackOut(); 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); WaitTicks(2);
if (val <= 0) { // need to page flip in each iteration of the loop for non DOS version
break; videoNextPage();
}
} } while (val > 0);
} }
void ComputeCinemaText(int nLine) void ComputeCinemaText(int nLine)
@ -2071,7 +2082,6 @@ void GoToTheCinema(int nVal)
overwritesprite(0, 0, 764, 100, 2, kPalNormal); overwritesprite(0, 0, 764, 100, 2, kPalNormal);
videoNextPage(); videoNextPage();
videoSetPalette(0, BASEPAL, 0);
GrabPalette(); GrabPalette();
Clip(); Clip();
} }

View file

@ -71,7 +71,7 @@ int ReadFrame(FILE *fp)
fread(&var_1C, sizeof(var_1C), 1, fp); fread(&var_1C, sizeof(var_1C), 1, fp);
paletteSetColorTable(ANIMPAL, palette); paletteSetColorTable(ANIMPAL, palette);
videoSetPalette(0, ANIMPAL, 0); videoSetPalette(0, ANIMPAL, 2+8);
memset(CurFrame, overscanindex, 4); //sizeof(CurFrame)); memset(CurFrame, overscanindex, 4); //sizeof(CurFrame));
continue; continue;
@ -175,7 +175,7 @@ void PlayMovie(const char *fileName)
int angle = 1536; int angle = 1536;
int z = 0; int z = 0;
videoSetPalette(0, ANIMPAL, 0); videoSetPalette(0, ANIMPAL, 2+8);
if (ReadFrame(fp)) if (ReadFrame(fp))
{ {

View file

@ -122,16 +122,9 @@ static int osdcmd_initgroupfile(osdcmdptr_t parm)
void onvideomodechange(int32_t newmode) void onvideomodechange(int32_t newmode)
{ {
// TODO: uint8_t palid = BASEPAL;
#if 0 #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 #ifdef POLYMER
if (videoGetRenderMode() == REND_POLYMER) if (videoGetRenderMode() == REND_POLYMER)
{ {
@ -149,11 +142,9 @@ void onvideomodechange(int32_t newmode)
} }
} }
#endif #endif
videoSetPalette(ud.brightness>>2, palid, 0);
g_restorePalette = -1;
g_crosshairSum = -1;
#endif #endif
videoSetPalette(0, palid, 0);
} }
static int osdcmd_button(osdcmdptr_t parm) static int osdcmd_button(osdcmdptr_t parm)

View file

@ -165,6 +165,9 @@ void ResetView()
EraseScreen(overscanindex); EraseScreen(overscanindex);
memcpy(curpalettefaded, curpalette, sizeof(curpalette)); memcpy(curpalettefaded, curpalette, sizeof(curpalette));
videoUpdatePalette(0, 256); videoUpdatePalette(0, 256);
#ifdef USE_OPENGL
videoTintBlood(0, 0, 0);
#endif
LoadStatus(); LoadStatus();
} }