From 5f941e862e6a650db1094b9c8f09ec8753da2c37 Mon Sep 17 00:00:00 2001 From: galaxyhaxz Date: Sun, 10 Nov 2019 20:11:32 -0600 Subject: [PATCH] Fix function order [palette.cpp] --- Source/palette.cpp | 128 ++++++++++++++++++++++----------------------- Source/palette.h | 5 -- 2 files changed, 64 insertions(+), 69 deletions(-) diff --git a/Source/palette.cpp b/Source/palette.cpp index ed294c412..78d541096 100644 --- a/Source/palette.cpp +++ b/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; diff --git a/Source/palette.h b/Source/palette.h index 1181e72a0..58099287e 100644 --- a/Source/palette.h +++ b/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();