Add color fade

This commit is contained in:
elasota
2020-05-22 21:14:43 -04:00
parent 482487d81c
commit f5ff8eb013
13 changed files with 272 additions and 152 deletions

View File

@@ -156,10 +156,9 @@ void RedrawSplashScreen (void); // --- MainWindow.c
void UpdateMainWindow (void); void UpdateMainWindow (void);
void OpenMainWindow (void); void OpenMainWindow (void);
void CloseMainWindow (void); void CloseMainWindow (void);
void ZoomBetweenWindows (void);
void UpdateEditWindowTitle (void); void UpdateEditWindowTitle (void);
void HandleMainClick (Point, Boolean); void HandleMainClick (Point, Boolean);
//void WashColorIn (void); void WashColorIn (void);
void CenterMapOnRoom (SInt16, SInt16); // --- Map.c void CenterMapOnRoom (SInt16, SInt16); // --- Map.c
Boolean ThisRoomVisibleOnMap (void); Boolean ThisRoomVisibleOnMap (void);

View File

@@ -12,6 +12,7 @@
#include "Environ.h" #include "Environ.h"
#include "IOStream.h" #include "IOStream.h"
#include "House.h" #include "House.h"
#include "WindowManager.h"
#define kPrefsVersion 0x0035 #define kPrefsVersion 0x0035
@@ -352,6 +353,10 @@ int gpAppMain()
InitSrcRects(); InitSrcRects();
CreateOffscreens(); SpinCursor(2); CreateOffscreens(); SpinCursor(2);
OpenMainWindow(); OpenMainWindow();
if (isDoColorFade)
PortabilityLayer::WindowManager::GetInstance()->SetWindowDesaturation(mainWindow, 1.0);
InitSound(); SpinCursor(2); InitSound(); SpinCursor(2);
InitMusic(); SpinCursor(2); InitMusic(); SpinCursor(2);
BuildHouseList(); BuildHouseList();
@@ -366,17 +371,8 @@ int gpAppMain()
// HideMenuBarOld(); // HideMenuBarOld();
#endif #endif
// if ((isDoColorFade) && (thisMac.isDepth == 8)) if (isDoColorFade)
// { WashColorIn();
// wasSeed = ExtractCTSeed((CGrafPtr)mainWindow);
// WashColorIn();
// ForceCTSeed((CGrafPtr)mainWindow, wasSeed);
// }
// if ((!thisMac.hasSM3) && (numSMWarnings < 3))
// {
// numSMWarnings++;
// BitchAboutSM3();
// }
UpdateMainWindow(); UpdateMainWindow();

View File

@@ -579,54 +579,20 @@ void HardDrawMainWindow (void)
//-------------------------------------------------------------- WashColorIn //-------------------------------------------------------------- WashColorIn
// Slowly walks the palette from its gray luminance state to the full color<6F> // Slowly walks the palette from its gray luminance state to the full color<6F>
// palette. In this way, color appears to slowly wash in. // palette. In this way, color appears to slowly wash in.
/*
void WashColorIn (void) void WashColorIn (void)
{ {
#define kGray2ColorSteps 180 #define kGray2ColorSteps 180
GDHandle theDevice;
long longDelta; long longDelta;
short i, c; short i, c;
theDevice = GetGDevice();
SetGDevice(thisGDevice);
for (i = 0; i < kGray2ColorSteps; i++) for (i = 0; i < kGray2ColorSteps; i++)
{ {
for (c = 0; c < 256; c++) PortabilityLayer::WindowManager::GetInstance()->SetWindowDesaturation(mainWindow, static_cast<float>(kGray2ColorSteps - i) / static_cast<float>(kGray2ColorSteps));
{
if (c != 5)
{
longDelta = (((long)wasColors[c].rgb.red -
(long)newColors[c].rgb.red) /
(long)(kGray2ColorSteps - i)) + (long)newColors[c].rgb.red;
newColors[c].rgb.red = (unsigned short)longDelta;
longDelta = (((long)wasColors[c].rgb.green - Delay(1, nullptr);
(long)newColors[c].rgb.green) / if (PortabilityLayer::InputManager::GetInstance()->GetKeys()->m_mouse.Get(GpMouseButtons::kLeft))
(long)(kGray2ColorSteps - i)) +
(long)newColors[c].rgb.green;
newColors[c].rgb.green = (unsigned short)longDelta;
longDelta = (((long)wasColors[c].rgb.blue -
(long)newColors[c].rgb.blue) /
(long)(kGray2ColorSteps - i)) +
(long)newColors[c].rgb.blue;
newColors[c].rgb.blue = (unsigned short)longDelta;
}
}
SetEntries(0, 255, newColors);
if (Button())
break; break;
} }
SetEntries(0, 255, wasColors); PortabilityLayer::WindowManager::GetInstance()->SetWindowDesaturation(mainWindow, 0.0f);
SetGDevice(theDevice);
RestoreColorsSlam();
if (wasColors != nil)
DisposePtr((Ptr)wasColors);
if (newColors != nil)
DisposePtr((Ptr)newColors);
} }
*/

View File

@@ -16,6 +16,7 @@ struct GpDisplayDriverSurfaceEffects
int32_t m_flickerAxisY; int32_t m_flickerAxisY;
int32_t m_flickerStartThreshold; int32_t m_flickerStartThreshold;
int32_t m_flickerEndThreshold; int32_t m_flickerEndThreshold;
float m_desaturation;
}; };
// Display drivers are responsible for timing and calling the game tick function. // Display drivers are responsible for timing and calling the game tick function.
@@ -48,5 +49,6 @@ inline GpDisplayDriverSurfaceEffects::GpDisplayDriverSurfaceEffects()
, m_flickerAxisY(0) , m_flickerAxisY(0)
, m_flickerStartThreshold(0) , m_flickerStartThreshold(0)
, m_flickerEndThreshold(0) , m_flickerEndThreshold(0)
, m_desaturation(0)
{ {
} }

View File

@@ -1,10 +1,10 @@
static unsigned char gs_shaderData[] = { static unsigned char gs_shaderData[] = {
68, 88, 66, 67, 16, 112, 155, 167, 152, 216, 111, 160, 194, 37, 151, 68, 88, 66, 67, 123, 171, 231, 206, 83, 178, 250, 149, 189, 168, 129,
206, 26, 38, 150, 132, 1, 0, 0, 0, 140, 5, 0, 0, 5, 0, 29, 12, 186, 195, 194, 1, 0, 0, 0, 24, 9, 0, 0, 5, 0,
0, 0, 52, 0, 0, 0, 48, 2, 0, 0, 136, 2, 0, 0, 188, 0, 0, 52, 0, 0, 0, 172, 2, 0, 0, 4, 3, 0, 0, 56,
2, 0, 0, 16, 5, 0, 0, 82, 68, 69, 70, 244, 1, 0, 0, 3, 0, 0, 156, 8, 0, 0, 82, 68, 69, 70, 112, 2, 0, 0,
1, 0, 0, 0, 180, 0, 0, 0, 3, 0, 0, 0, 28, 0, 0, 1, 0, 0, 0, 180, 0, 0, 0, 3, 0, 0, 0, 28, 0, 0,
0, 0, 4, 255, 255, 0, 137, 0, 0, 202, 1, 0, 0, 124, 0, 0, 0, 4, 255, 255, 0, 137, 0, 0, 72, 2, 0, 0, 124, 0,
0, 0, 2, 0, 0, 0, 4, 0, 0, 0, 4, 0, 0, 0, 255, 0, 0, 2, 0, 0, 0, 4, 0, 0, 0, 4, 0, 0, 0, 255,
255, 255, 255, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 255, 255, 255, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0,
139, 0, 0, 0, 2, 0, 0, 0, 5, 0, 0, 0, 2, 0, 0, 139, 0, 0, 0, 2, 0, 0, 0, 5, 0, 0, 0, 2, 0, 0,
@@ -15,85 +15,146 @@ static unsigned char gs_shaderData[] = {
117, 114, 101, 0, 112, 97, 108, 101, 116, 116, 101, 84, 101, 120, 116, 117, 114, 101, 0, 112, 97, 108, 101, 116, 116, 101, 84, 101, 120, 116,
117, 114, 101, 0, 83, 68, 114, 97, 119, 81, 117, 97, 100, 80, 105, 117, 114, 101, 0, 83, 68, 114, 97, 119, 81, 117, 97, 100, 80, 105,
120, 101, 108, 67, 111, 110, 115, 116, 97, 110, 116, 115, 0, 171, 171, 120, 101, 108, 67, 111, 110, 115, 116, 97, 110, 116, 115, 0, 171, 171,
154, 0, 0, 0, 4, 0, 0, 0, 204, 0, 0, 0, 32, 0, 0, 154, 0, 0, 0, 6, 0, 0, 0, 204, 0, 0, 0, 48, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 44, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 92, 1, 0, 0, 0, 0,
0, 0, 16, 0, 0, 0, 2, 0, 0, 0, 68, 1, 0, 0, 0, 0, 0, 16, 0, 0, 0, 2, 0, 0, 0, 116, 1, 0, 0, 0,
0, 0, 0, 84, 1, 0, 0, 16, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 132, 1, 0, 0, 16, 0, 0, 0, 8, 0, 0, 0,
2, 0, 0, 0, 108, 1, 0, 0, 0, 0, 0, 0, 124, 1, 0, 2, 0, 0, 0, 156, 1, 0, 0, 0, 0, 0, 0, 172, 1, 0,
0, 24, 0, 0, 0, 4, 0, 0, 0, 2, 0, 0, 0, 156, 1, 0, 24, 0, 0, 0, 4, 0, 0, 0, 2, 0, 0, 0, 204, 1,
0, 0, 0, 0, 0, 0, 172, 1, 0, 0, 28, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 220, 1, 0, 0, 28, 0, 0, 0, 4,
0, 0, 0, 2, 0, 0, 0, 156, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 204, 1, 0, 0, 0, 0, 0, 0,
99, 111, 110, 115, 116, 97, 110, 116, 115, 95, 77, 111, 100, 117, 108, 250, 1, 0, 0, 32, 0, 0, 0, 4, 0, 0, 0, 2, 0, 0,
97, 116, 105, 111, 110, 0, 171, 171, 171, 1, 0, 3, 0, 1, 0, 0, 20, 2, 0, 0, 0, 0, 0, 0, 36, 2, 0, 0, 36, 0,
4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 99, 111, 110, 115, 116, 0, 0, 12, 0, 0, 0, 0, 0, 0, 0, 56, 2, 0, 0, 0,
97, 110, 116, 115, 95, 70, 108, 105, 99, 107, 101, 114, 65, 120, 105, 0, 0, 0, 99, 111, 110, 115, 116, 97, 110, 116, 115, 95, 77, 111,
115, 0, 171, 171, 1, 0, 2, 0, 1, 0, 2, 0, 0, 0, 0, 100, 117, 108, 97, 116, 105, 111, 110, 0, 171, 171, 171, 1, 0, 3,
0, 0, 0, 0, 0, 99, 111, 110, 115, 116, 97, 110, 116, 115, 95, 0, 1, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 99, 111,
70, 108, 105, 99, 107, 101, 114, 83, 116, 97, 114, 116, 84, 104, 114, 110, 115, 116, 97, 110, 116, 115, 95, 70, 108, 105, 99, 107, 101, 114,
101, 115, 104, 111, 108, 100, 0, 0, 0, 2, 0, 1, 0, 1, 0, 65, 120, 105, 115, 0, 171, 171, 1, 0, 2, 0, 1, 0, 2, 0,
0, 0, 0, 0, 0, 0, 0, 0, 99, 111, 110, 115, 116, 97, 110, 0, 0, 0, 0, 0, 0, 0, 0, 99, 111, 110, 115, 116, 97, 110,
116, 115, 95, 70, 108, 105, 99, 107, 101, 114, 69, 110, 100, 84, 104, 116, 115, 95, 70, 108, 105, 99, 107, 101, 114, 83, 116, 97, 114, 116,
114, 101, 115, 104, 111, 108, 100, 0, 77, 105, 99, 114, 111, 115, 111, 84, 104, 114, 101, 115, 104, 111, 108, 100, 0, 0, 0, 2, 0, 1,
102, 116, 32, 40, 82, 41, 32, 72, 76, 83, 76, 32, 83, 104, 97, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 99, 111, 110, 115,
100, 101, 114, 32, 67, 111, 109, 112, 105, 108, 101, 114, 32, 49, 48, 116, 97, 110, 116, 115, 95, 70, 108, 105, 99, 107, 101, 114, 69, 110,
46, 49, 0, 171, 171, 73, 83, 71, 78, 80, 0, 0, 0, 2, 0, 100, 84, 104, 114, 101, 115, 104, 111, 108, 100, 0, 99, 111, 110, 115,
0, 0, 8, 0, 0, 0, 56, 0, 0, 0, 0, 0, 0, 0, 1, 116, 97, 110, 116, 115, 95, 68, 101, 115, 97, 116, 117, 114, 97, 116,
0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 15, 0, 0, 0, 105, 111, 110, 0, 171, 171, 171, 0, 0, 3, 0, 1, 0, 1, 0,
68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 99, 111, 110, 115, 116, 97, 110,
0, 1, 0, 0, 0, 3, 3, 0, 0, 83, 86, 95, 80, 79, 83, 116, 115, 95, 85, 110, 117, 115, 101, 100, 0, 171, 171, 171, 1, 0,
73, 84, 73, 79, 78, 0, 84, 69, 88, 67, 79, 79, 82, 68, 0, 3, 0, 1, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 77,
171, 171, 171, 79, 83, 71, 78, 44, 0, 0, 0, 1, 0, 0, 0, 105, 99, 114, 111, 115, 111, 102, 116, 32, 40, 82, 41, 32, 72, 76,
8, 0, 0, 0, 32, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 83, 76, 32, 83, 104, 97, 100, 101, 114, 32, 67, 111, 109, 112, 105,
0, 3, 0, 0, 0, 0, 0, 0, 0, 15, 0, 0, 0, 83, 86, 108, 101, 114, 32, 49, 48, 46, 49, 0, 73, 83, 71, 78, 80, 0,
95, 84, 65, 82, 71, 69, 84, 0, 171, 171, 83, 72, 68, 82, 76, 0, 0, 2, 0, 0, 0, 8, 0, 0, 0, 56, 0, 0, 0, 0,
2, 0, 0, 64, 0, 0, 0, 147, 0, 0, 0, 89, 0, 0, 4, 0, 0, 0, 1, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0,
70, 142, 32, 0, 0, 0, 0, 0, 2, 0, 0, 0, 88, 24, 0, 15, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
4, 0, 112, 16, 0, 0, 0, 0, 0, 68, 68, 0, 0, 88, 16, 0, 3, 0, 0, 0, 1, 0, 0, 0, 3, 3, 0, 0, 83, 86,
0, 4, 0, 112, 16, 0, 1, 0, 0, 0, 85, 85, 0, 0, 98, 95, 80, 79, 83, 73, 84, 73, 79, 78, 0, 84, 69, 88, 67, 79,
16, 0, 3, 50, 16, 16, 0, 1, 0, 0, 0, 101, 0, 0, 3, 79, 82, 68, 0, 171, 171, 171, 79, 83, 71, 78, 44, 0, 0, 0,
242, 32, 16, 0, 0, 0, 0, 0, 104, 0, 0, 2, 2, 0, 0, 1, 0, 0, 0, 8, 0, 0, 0, 32, 0, 0, 0, 0, 0, 0,
0, 65, 0, 0, 5, 50, 0, 16, 0, 0, 0, 0, 0, 70, 16, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 15, 0,
16, 0, 1, 0, 0, 0, 27, 0, 0, 5, 50, 0, 16, 0, 0, 0, 0, 83, 86, 95, 84, 65, 82, 71, 69, 84, 0, 171, 171, 83,
0, 0, 0, 70, 0, 16, 0, 0, 0, 0, 0, 54, 0, 0, 8, 72, 68, 82, 92, 5, 0, 0, 64, 0, 0, 0, 87, 1, 0, 0,
194, 0, 16, 0, 0, 0, 0, 0, 2, 64, 0, 0, 0, 0, 0, 89, 0, 0, 4, 70, 142, 32, 0, 0, 0, 0, 0, 3, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 45, 0, 0, 88, 24, 0, 4, 0, 112, 16, 0, 0, 0, 0, 0, 68, 68,
0, 7, 242, 0, 16, 0, 1, 0, 0, 0, 70, 14, 16, 0, 0, 0, 0, 88, 16, 0, 4, 0, 112, 16, 0, 1, 0, 0, 0, 85,
0, 0, 0, 70, 126, 16, 0, 0, 0, 0, 0, 54, 0, 0, 8, 85, 0, 0, 98, 16, 0, 3, 50, 16, 16, 0, 1, 0, 0, 0,
226, 0, 16, 0, 1, 0, 0, 0, 2, 64, 0, 0, 0, 0, 0, 101, 0, 0, 3, 242, 32, 16, 0, 0, 0, 0, 0, 104, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 45, 0, 2, 4, 0, 0, 0, 65, 0, 0, 5, 50, 0, 16, 0, 0, 0,
0, 7, 242, 0, 16, 0, 1, 0, 0, 0, 70, 14, 16, 0, 1, 0, 0, 70, 16, 16, 0, 1, 0, 0, 0, 27, 0, 0, 5, 50,
0, 0, 0, 70, 126, 16, 0, 1, 0, 0, 0, 54, 0, 0, 5, 0, 16, 0, 0, 0, 0, 0, 70, 0, 16, 0, 0, 0, 0, 0,
130, 0, 16, 0, 1, 0, 0, 0, 1, 64, 0, 0, 0, 0, 128, 54, 0, 0, 8, 194, 0, 16, 0, 0, 0, 0, 0, 2, 64, 0,
63, 56, 0, 0, 8, 242, 0, 16, 0, 1, 0, 0, 0, 70, 14,
16, 0, 1, 0, 0, 0, 70, 142, 32, 0, 0, 0, 0, 0, 0,
0, 0, 0, 38, 0, 0, 9, 0, 208, 0, 0, 50, 0, 16, 0,
0, 0, 0, 0, 70, 0, 16, 0, 0, 0, 0, 0, 70, 128, 32,
0, 0, 0, 0, 0, 1, 0, 0, 0, 30, 0, 0, 7, 18, 0,
16, 0, 0, 0, 0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0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 70, 14, 16,
0, 1, 0, 0, 0, 60, 0, 0, 7, 18, 0, 16, 0, 0, 0,
0, 0, 10, 0, 16, 0, 0, 0, 0, 0, 26, 0, 16, 0, 0,
0, 0, 0, 55, 0, 0, 12, 242, 0, 16, 0, 0, 0, 0, 0,
6, 0, 16, 0, 0, 0, 0, 0, 70, 14, 16, 0, 1, 0, 0,
0, 2, 64, 0, 0, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0,
128, 63, 0, 0, 128, 63, 57, 0, 0, 8, 18, 0, 16, 0, 1,
0, 0, 0, 10, 128, 32, 0, 0, 0, 0, 0, 2, 0, 0, 0,
1, 64, 0, 0, 0, 0, 0, 0, 31, 0, 4, 3, 10, 0, 16,
0, 1, 0, 0, 0, 29, 0, 0, 10, 114, 0, 16, 0, 1, 0,
0, 0, 2, 64, 0, 0, 28, 46, 77, 59, 28, 46, 77, 59, 28,
46, 77, 59, 0, 0, 0, 0, 70, 2, 16, 0, 0, 0, 0, 0,
56, 0, 0, 10, 114, 0, 16, 0, 2, 0, 0, 0, 70, 2, 16,
0, 0, 0, 0, 0, 2, 64, 0, 0, 82, 184, 78, 65, 82, 184,
78, 65, 82, 184, 78, 65, 0, 0, 0, 0, 47, 0, 0, 5, 114,
0, 16, 0, 3, 0, 0, 0, 70, 2, 16, 0, 0, 0, 0, 0,
56, 0, 0, 10, 114, 0, 16, 0, 3, 0, 0, 0, 70, 2, 16,
0, 3, 0, 0, 0, 2, 64, 0, 0, 85, 85, 213, 62, 85, 85,
213, 62, 85, 85, 213, 62, 0, 0, 0, 0, 25, 0, 0, 5, 114,
0, 16, 0, 3, 0, 0, 0, 70, 2, 16, 0, 3, 0, 0, 0,
50, 0, 0, 15, 114, 0, 16, 0, 3, 0, 0, 0, 70, 2, 16,
0, 3, 0, 0, 0, 2, 64, 0, 0, 61, 10, 135, 63, 61, 10,
135, 63, 61, 10, 135, 63, 0, 0, 0, 0, 2, 64, 0, 0, 174,
71, 97, 189, 174, 71, 97, 189, 174, 71, 97, 189, 0, 0, 0, 0,
55, 0, 0, 9, 114, 0, 16, 0, 1, 0, 0, 0, 70, 2, 16,
0, 1, 0, 0, 0, 70, 2, 16, 0, 2, 0, 0, 0, 70, 2,
16, 0, 3, 0, 0, 0, 16, 0, 0, 10, 130, 0, 16, 0, 1,
0, 0, 0, 70, 2, 16, 0, 1, 0, 0, 0, 2, 64, 0, 0,
154, 153, 153, 62, 154, 153, 25, 63, 205, 204, 204, 61, 0, 0, 0,
0, 0, 0, 0, 9, 18, 0, 16, 0, 2, 0, 0, 0, 10, 128,
32, 128, 65, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 1,
64, 0, 0, 0, 0, 128, 63, 56, 0, 0, 8, 130, 0, 16, 0,
1, 0, 0, 0, 58, 0, 16, 0, 1, 0, 0, 0, 10, 128, 32,
0, 0, 0, 0, 0, 2, 0, 0, 0, 50, 0, 0, 9, 114, 0,
16, 0, 1, 0, 0, 0, 70, 2, 16, 0, 1, 0, 0, 0, 6,
0, 16, 0, 2, 0, 0, 0, 246, 15, 16, 0, 1, 0, 0, 0,
29, 0, 0, 10, 114, 0, 16, 0, 2, 0, 0, 0, 2, 64, 0,
0, 230, 174, 37, 61, 230, 174, 37, 61, 230, 174, 37, 61, 0, 0,
0, 0, 70, 2, 16, 0, 1, 0, 0, 0, 56, 0, 0, 10, 114,
0, 16, 0, 3, 0, 0, 0, 70, 2, 16, 0, 1, 0, 0, 0,
2, 64, 0, 0, 145, 131, 158, 61, 145, 131, 158, 61, 145, 131, 158,
61, 0, 0, 0, 0, 0, 0, 0, 10, 114, 0, 16, 0, 1, 0,
0, 0, 70, 2, 16, 0, 1, 0, 0, 0, 2, 64, 0, 0, 174,
71, 97, 61, 174, 71, 97, 61, 174, 71, 97, 61, 0, 0, 0, 0,
56, 0, 0, 10, 114, 0, 16, 0, 1, 0, 0, 0, 70, 2, 16,
0, 1, 0, 0, 0,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0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0,
}; };
namespace GpBinarizedShaders namespace GpBinarizedShaders

View File

@@ -1094,6 +1094,8 @@ void GpDisplayDriverD3D11::DrawSurface(IGpDisplayDriverSurface *surface, int32_t
pConstantsData.m_flickerStart = -2; pConstantsData.m_flickerStart = -2;
} }
pConstantsData.m_desaturation = effects->m_desaturation;
if (effects->m_darken) if (effects->m_darken)
for (int i = 0; i < 3; i++) for (int i = 0; i < 3; i++)
pConstantsData.m_modulation[i] = 0.5f; pConstantsData.m_modulation[i] = 0.5f;

View File

@@ -74,6 +74,9 @@ private:
int32_t m_flickerAxis[2]; int32_t m_flickerAxis[2];
int32_t m_flickerStart; int32_t m_flickerStart;
int32_t m_flickerEnd; int32_t m_flickerEnd;
float m_desaturation;
float m_unused[3];
}; };
struct ScaleQuadPixelConstants struct ScaleQuadPixelConstants

View File

@@ -503,12 +503,6 @@ void GetMouse(Window *window, Point *point)
point->v = relativePos.m_y; point->v = relativePos.m_y;
} }
Boolean Button()
{
PL_NotYetImplemented();
return false;
}
Boolean StillDown() Boolean StillDown()
{ {
return PortabilityLayer::InputManager::GetInstance()->GetKeys()->m_mouse.Get(GpMouseButtons::kLeft); return PortabilityLayer::InputManager::GetInstance()->GetKeys()->m_mouse.Get(GpMouseButtons::kLeft);

View File

@@ -110,6 +110,13 @@ namespace PortabilityLayer
static const RGBAColor kLightColor; static const RGBAColor kLightColor;
}; };
struct WindowEffects
{
WindowEffects();
float m_desaturationLevel;
};
class WindowImpl final : public Window class WindowImpl final : public Window
{ {
public: public:
@@ -140,7 +147,12 @@ namespace PortabilityLayer
void SetTitle(const PLPasStr &str); void SetTitle(const PLPasStr &str);
const PascalStr<255> &GetTitle() const; const PascalStr<255> &GetTitle() const;
WindowEffects &GetEffects();
const WindowEffects &GetEffects() const;
private: private:
WindowEffects m_effects;
WindowImpl *m_windowAbove; WindowImpl *m_windowAbove;
WindowImpl *m_windowBelow; WindowImpl *m_windowBelow;
@@ -175,6 +187,8 @@ namespace PortabilityLayer
void FlickerWindowIn(Window *window, int32_t velocity) override; void FlickerWindowIn(Window *window, int32_t velocity) override;
void FlickerWindowOut(Window *window, int32_t velocity) override; void FlickerWindowOut(Window *window, int32_t velocity) override;
void SetWindowDesaturation(Window *window, float desaturationLevel) override;
void SetResizeInProgress(Window *window, const PortabilityLayer::Vec2i &size) override; void SetResizeInProgress(Window *window, const PortabilityLayer::Vec2i &size) override;
void ClearResizeInProgress() override; void ClearResizeInProgress() override;
@@ -786,6 +800,12 @@ namespace PortabilityLayer
surface->FillRect(Rect::Create(rect.top, rect.right - 4, rect.bottom, rect.right - 2), midColor); surface->FillRect(Rect::Create(rect.top, rect.right - 4, rect.bottom, rect.right - 2), midColor);
} }
//---------------------------------------------------------------------------
WindowEffects::WindowEffects()
: m_desaturationLevel(0.0f)
{
}
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
WindowImpl::WindowImpl() WindowImpl::WindowImpl()
: m_windowAbove(nullptr) : m_windowAbove(nullptr)
@@ -974,6 +994,18 @@ namespace PortabilityLayer
return m_title; return m_title;
} }
WindowEffects &WindowImpl::GetEffects()
{
return m_effects;
}
const WindowEffects &WindowImpl::GetEffects() const
{
return m_effects;
}
WindowManagerImpl::WindowManagerImpl() WindowManagerImpl::WindowManagerImpl()
: m_windowStackTop(nullptr) : m_windowStackTop(nullptr)
, m_windowStackBottom(nullptr) , m_windowStackBottom(nullptr)
@@ -1318,6 +1350,12 @@ namespace PortabilityLayer
m_flickerWindow = nullptr; m_flickerWindow = nullptr;
} }
void WindowManagerImpl::SetWindowDesaturation(Window *window, float desaturationLevel)
{
static_cast<WindowImpl*>(window)->GetEffects().m_desaturationLevel = desaturationLevel;
}
void WindowManagerImpl::SetResizeInProgress(Window *window, const PortabilityLayer::Vec2i &size) void WindowManagerImpl::SetResizeInProgress(Window *window, const PortabilityLayer::Vec2i &size)
{ {
ResolveCachingColor blackColor = StdColors::Black(); ResolveCachingColor blackColor = StdColors::Black();
@@ -1500,6 +1538,8 @@ namespace PortabilityLayer
if (m_exclusiveWindow != nullptr && m_exclusiveWindow != window) if (m_exclusiveWindow != nullptr && m_exclusiveWindow != window)
effects.m_darken = true; effects.m_darken = true;
effects.m_desaturation = window->GetEffects().m_desaturationLevel;
bool hasFlicker = (m_flickerWindow == window); bool hasFlicker = (m_flickerWindow == window);
DrawSurface &graf = *window->GetDrawSurface(); DrawSurface &graf = *window->GetDrawSurface();

View File

@@ -41,6 +41,8 @@ namespace PortabilityLayer
virtual void FlickerWindowIn(Window *window, int32_t velocity) = 0; virtual void FlickerWindowIn(Window *window, int32_t velocity) = 0;
virtual void FlickerWindowOut(Window *window, int32_t velocity) = 0; virtual void FlickerWindowOut(Window *window, int32_t velocity) = 0;
virtual void SetWindowDesaturation(Window *window, float desaturationLevel) = 0;
virtual void SetResizeInProgress(Window *window, const PortabilityLayer::Vec2i &size) = 0; virtual void SetResizeInProgress(Window *window, const PortabilityLayer::Vec2i &size) = 0;
virtual void ClearResizeInProgress() = 0; virtual void ClearResizeInProgress() = 0;

View File

@@ -1,5 +1,6 @@
#include "DrawQuad.h" #include "DrawQuad.h"
#include "DrawQuadPixelConstants.h" #include "DrawQuadPixelConstants.h"
#include "Functions.h"
SamplerState nearestNeighborSampler : register(s0); SamplerState nearestNeighborSampler : register(s0);
Texture2D<uint> surfaceTexture : register(t0); Texture2D<uint> surfaceTexture : register(t0);
@@ -20,7 +21,10 @@ SDrawQuadPixelOutput PSMain(SDrawQuadPixelInput input)
{ {
SDrawQuadPixelOutput result; SDrawQuadPixelOutput result;
int2 pixelCoordinate = int2(floor(input.texCoord.xy)); int2 pixelCoordinate = int2(floor(input.texCoord.xy));
result.color = ApplyFlicker(pixelCoordinate, float4(SamplePixel(int2(floor(input.texCoord.xy))), 1.0) * constants_Modulation); result.color = float4(SamplePixel(int2(floor(input.texCoord.xy))), 1.0);
result.color *= constants_Modulation;
result.color = ApplyFlicker(pixelCoordinate, constants_FlickerStartThreshold, constants_FlickerEndThreshold, result.color * constants_Modulation);
result.color = ApplyDesaturation(constants_Desaturation, result.color);
if (result.color.a <= 0.0) if (result.color.a <= 0.0)
discard; discard;

View File

@@ -5,15 +5,7 @@ cbuffer SDrawQuadPixelConstants : register(b0)
int2 constants_FlickerAxis; int2 constants_FlickerAxis;
int constants_FlickerStartThreshold; int constants_FlickerStartThreshold;
int constants_FlickerEndThreshold; int constants_FlickerEndThreshold;
};
float4 ApplyFlicker(int2 coordinate, float4 color) float constants_Desaturation;
{ float3 constants_Unused;
int flickerTotal = dot(constants_FlickerAxis, coordinate); };
if (flickerTotal < constants_FlickerStartThreshold)
return float4(0, 0, 0, 0);
else if (flickerTotal >= constants_FlickerEndThreshold)
return color;
else
return float4(1, 1, 1, 1);
}

59
ShaderSrc/Functions.h Normal file
View File

@@ -0,0 +1,59 @@
float SRGBToLinear(float v)
{
if (v <= 0.04045)
return v * (1.0 / 12.92);
else
return pow(((v + 0.055) * (1.0 / 1.055)), 2.4);
}
float2 SRGBToLinear(float2 v)
{
return float2(SRGBToLinear(v.x), SRGBToLinear(v.y));
}
float3 SRGBToLinear(float3 v)
{
return float3(SRGBToLinear(v.x), SRGBToLinear(v.y), SRGBToLinear(v.z));
}
float LinearToSRGB(float v)
{
if (v <= 0.0031308)
return 12.92 * v;
else
return 1.055 * pow(v, 1.0 / 2.4) - 0.055;
}
float2 LinearToSRGB(float2 v)
{
return float2(LinearToSRGB(v.x), LinearToSRGB(v.y));
}
float3 LinearToSRGB(float3 v)
{
return float3(LinearToSRGB(v.x), LinearToSRGB(v.y), LinearToSRGB(v.z));
}
float4 ApplyFlicker(int2 coordinate, int startThreshold, int endThreshold, float4 color)
{
int flickerTotal = dot(constants_FlickerAxis, coordinate);
if (flickerTotal < startThreshold)
return float4(0, 0, 0, 0);
else if (flickerTotal >= endThreshold)
return color;
return float4(1, 1, 1, 1);
}
float4 ApplyDesaturation(float desaturation, float4 color)
{
if (desaturation == 0.0)
return color;
float3 srgbColor = LinearToSRGB(color.rgb);
float grayLevel = dot(srgbColor, float3(3.0, 6.0, 1.0) / 10.0);
srgbColor = srgbColor * (1.0 - desaturation) + float3(grayLevel, grayLevel, grayLevel) * desaturation;
return float4(SRGBToLinear(srgbColor), color.a);
}