Browse Source

Fix function order [palette.cpp]

pull/481/head
galaxyhaxz 6 years ago committed by Anders Jenbo
parent
commit
5f941e862e
  1. 128
      Source/palette.cpp
  2. 5
      Source/palette.h

128
Source/palette.cpp

@ -12,38 +12,45 @@ int gamma_correction = 100;
BOOL color_cycling_enabled = TRUE;
BOOLEAN sgbFadedIn = TRUE;
void SaveGamma()
static void palette_update()
{
SRegSaveValue("Diablo", "Gamma Correction", 0, gamma_correction);
SRegSaveValue("Diablo", "Color Cycling", FALSE, color_cycling_enabled);
int nentries;
int max_entries;
if (lpDDPalette) {
nentries = 0;
max_entries = 256;
if (!fullscreen) {
nentries = gdwPalEntries;
max_entries = 2 * (128 - gdwPalEntries);
}
SDrawUpdatePalette(nentries, max_entries, &system_palette[nentries], 0);
}
}
void palette_init()
static void ApplyGamma(PALETTEENTRY *dst, PALETTEENTRY *src, int n)
{
DWORD error_code;
int i;
double g;
LoadGamma();
memcpy(system_palette, orig_palette, sizeof(orig_palette));
LoadSysPal();
#ifdef __cplusplus
error_code = lpDDInterface->CreatePalette(DDPCAPS_ALLOW256 | DDPCAPS_8BIT, system_palette, &lpDDPalette, NULL);
#else
error_code = lpDDInterface->lpVtbl->CreatePalette(lpDDInterface, DDPCAPS_ALLOW256 | DDPCAPS_8BIT, system_palette, &lpDDPalette, NULL);
#endif
if (error_code)
ErrDlg(IDD_DIALOG8, error_code, "C:\\Src\\Diablo\\Source\\PALETTE.CPP", 143);
#ifdef __cplusplus
error_code = lpDDSPrimary->SetPalette(lpDDPalette);
#else
error_code = lpDDSPrimary->lpVtbl->SetPalette(lpDDSPrimary, lpDDPalette);
#endif
#ifndef RGBMODE
if (error_code)
ErrDlg(IDD_DIALOG8, error_code, "C:\\Src\\Diablo\\Source\\PALETTE.CPP", 146);
#endif
g = gamma_correction / 100.0;
for (i = 0; i < n; i++) {
dst->peRed = pow(src->peRed / 256.0, g) * 256.0;
dst->peGreen = pow(src->peGreen / 256.0, g) * 256.0;
dst->peBlue = pow(src->peBlue / 256.0, g) * 256.0;
dst++;
src++;
}
}
void SaveGamma()
{
SRegSaveValue("Diablo", "Gamma Correction", 0, gamma_correction);
SRegSaveValue("Diablo", "Color Cycling", FALSE, color_cycling_enabled);
}
void LoadGamma()
static void LoadGamma()
{
int gamma_value;
int value;
@ -63,7 +70,7 @@ void LoadGamma()
color_cycling_enabled = value;
}
void LoadSysPal()
static void LoadSysPal()
{
HDC hDC;
int i, iStartIndex;
@ -90,6 +97,31 @@ void LoadSysPal()
}
}
void palette_init()
{
DWORD error_code;
LoadGamma();
memcpy(system_palette, orig_palette, sizeof(orig_palette));
LoadSysPal();
#ifdef __cplusplus
error_code = lpDDInterface->CreatePalette(DDPCAPS_ALLOW256 | DDPCAPS_8BIT, system_palette, &lpDDPalette, NULL);
#else
error_code = lpDDInterface->lpVtbl->CreatePalette(lpDDInterface, DDPCAPS_ALLOW256 | DDPCAPS_8BIT, system_palette, &lpDDPalette, NULL);
#endif
if (error_code)
ErrDlg(IDD_DIALOG8, error_code, "C:\\Src\\Diablo\\Source\\PALETTE.CPP", 143);
#ifdef __cplusplus
error_code = lpDDSPrimary->SetPalette(lpDDPalette);
#else
error_code = lpDDSPrimary->lpVtbl->SetPalette(lpDDSPrimary, lpDDPalette);
#endif
#ifndef RGBMODE
if (error_code)
ErrDlg(IDD_DIALOG8, error_code, "C:\\Src\\Diablo\\Source\\PALETTE.CPP", 146);
#endif
}
void LoadPalette(char *pszFileName)
{
int i;
@ -149,38 +181,6 @@ void IncreaseGamma()
}
}
void palette_update()
{
int nentries;
int max_entries;
if (lpDDPalette) {
nentries = 0;
max_entries = 256;
if (!fullscreen) {
nentries = gdwPalEntries;
max_entries = 2 * (128 - gdwPalEntries);
}
SDrawUpdatePalette(nentries, max_entries, &system_palette[nentries], 0);
}
}
void ApplyGamma(PALETTEENTRY *dst, PALETTEENTRY *src, int n)
{
int i;
double g;
g = gamma_correction / 100.0;
for (i = 0; i < n; i++) {
dst->peRed = pow(src->peRed / 256.0, g) * 256.0;
dst->peGreen = pow(src->peGreen / 256.0, g) * 256.0;
dst->peBlue = pow(src->peBlue / 256.0, g) * 256.0;
dst++;
src++;
}
}
void DecreaseGamma()
{
if (gamma_correction > 30) {
@ -202,12 +202,7 @@ int UpdateGamma(int gamma)
return 130 - gamma_correction;
}
void BlackPalette()
{
SetFadeLevel(0);
}
void SetFadeLevel(DWORD fadeval)
static void SetFadeLevel(DWORD fadeval)
{
int i;
@ -227,6 +222,11 @@ void SetFadeLevel(DWORD fadeval)
}
}
void BlackPalette()
{
SetFadeLevel(0);
}
void PaletteFadeIn(int fr)
{
int i;

5
Source/palette.h

@ -9,18 +9,13 @@ extern int gdwPalEntries;
void SaveGamma();
void palette_init();
void LoadGamma();
void LoadSysPal();
void LoadPalette(char *pszFileName);
void LoadRndLvlPal(int l);
void ResetPal();
void IncreaseGamma();
void palette_update();
void ApplyGamma(PALETTEENTRY *dst, PALETTEENTRY *src, int n);
void DecreaseGamma();
int UpdateGamma(int gamma);
void BlackPalette();
void SetFadeLevel(DWORD fadeval);
void PaletteFadeIn(int fr);
void PaletteFadeOut(int fr);
void palette_update_caves();

Loading…
Cancel
Save