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);
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;

View file

@ -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();
}

View file

@ -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))
{

View file

@ -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)

View file

@ -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();
}