mirror of
https://github.com/sfall-team/sfall.git
synced 2026-07-27 16:52:34 -07:00
Reverted the palette update method for DX9 mode to pre-4.3.1
* moving the processing to GPU (commit edbfc05)
Improved the functionality of AllowDShowMovies:
now can take screenshots and press any key to skip AVI movies.
Code edits to Logging.cpp.
This commit is contained in:
+48
-26
@@ -62,7 +62,7 @@ technique T1
|
||||
//
|
||||
|
||||
ps_2_0
|
||||
def c5, -1, -0.00100000005, 1, 0
|
||||
def c5, -1, -0.00100000005, 4, 1
|
||||
dcl t0.xy
|
||||
dcl_2d s0
|
||||
dcl_2d s1
|
||||
@@ -78,15 +78,18 @@ technique T1
|
||||
texld r1, r1, s1
|
||||
texld r2, r2, s3
|
||||
add r1.w, r0.w, c5.x
|
||||
abs r1.w, r1.w
|
||||
add r1.w, r1.w, c5.y
|
||||
cmp r0.xyz, r1.w, r1, r3
|
||||
mul r0.x, r1.z, c5.z
|
||||
mul r0.y, r1.y, c5.z
|
||||
mul r0.z, r1.x, c5.z
|
||||
abs r0.w, r1.w
|
||||
add r0.w, r0.w, c5.y
|
||||
cmp r0.xyz, r0.w, r0, r3
|
||||
add_sat r1.xyz, r2, r0
|
||||
cmp r0.xyz, -c1.x, r0, r1
|
||||
mov r0.w, c5.z
|
||||
mov r0.w, c5.w
|
||||
mov oC0, r0
|
||||
|
||||
// approximately 17 instruction slots used (4 texture, 13 arithmetic)
|
||||
// approximately 20 instruction slots used (4 texture, 16 arithmetic)
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -116,17 +119,20 @@ technique T0
|
||||
//
|
||||
|
||||
ps_2_0
|
||||
def c0, 1, 0, 0, 0
|
||||
def c0, 4, 1, 0, 0
|
||||
dcl t0.xy
|
||||
dcl_2d s0
|
||||
dcl_2d s1
|
||||
texld r0, t0, s0
|
||||
mov r0.xy, r0.w
|
||||
texld r0, r0, s1
|
||||
mov r0.w, c0.x
|
||||
mov oC0, r0
|
||||
mul r1.x, r0.z, c0.x
|
||||
mul r1.y, r0.y, c0.x
|
||||
mul r1.z, r0.x, c0.x
|
||||
mov r1.w, c0.y
|
||||
mov oC0, r1
|
||||
|
||||
// approximately 5 instruction slots used (2 texture, 3 arithmetic)
|
||||
// approximately 8 instruction slots used (2 texture, 6 arithmetic)
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -419,7 +425,7 @@ const BYTE gpuEffectA8[] =
|
||||
0, 0, 1, 0, 0, 0,
|
||||
0, 0, 0, 0, 255, 255,
|
||||
255, 255, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 52, 1,
|
||||
0, 0, 0, 0, 100, 1,
|
||||
0, 0, 0, 2, 255, 255,
|
||||
254, 255, 42, 0, 67, 84,
|
||||
65, 66, 28, 0, 0, 0,
|
||||
@@ -451,8 +457,8 @@ const BYTE gpuEffectA8[] =
|
||||
46, 57, 53, 50, 46, 51,
|
||||
49, 49, 49, 0, 81, 0,
|
||||
0, 5, 0, 0, 15, 160,
|
||||
0, 0, 128, 63, 0, 0,
|
||||
0, 0, 0, 0, 0, 0,
|
||||
0, 0, 128, 64, 0, 0,
|
||||
128, 63, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 31, 0,
|
||||
0, 2, 0, 0, 0, 128,
|
||||
0, 0, 3, 176, 31, 0,
|
||||
@@ -467,15 +473,23 @@ const BYTE gpuEffectA8[] =
|
||||
255, 128, 66, 0, 0, 3,
|
||||
0, 0, 15, 128, 0, 0,
|
||||
228, 128, 1, 8, 228, 160,
|
||||
1, 0, 0, 2, 0, 0,
|
||||
8, 128, 0, 0, 0, 160,
|
||||
5, 0, 0, 3, 1, 0,
|
||||
1, 128, 0, 0, 170, 128,
|
||||
0, 0, 0, 160, 5, 0,
|
||||
0, 3, 1, 0, 2, 128,
|
||||
0, 0, 85, 128, 0, 0,
|
||||
0, 160, 5, 0, 0, 3,
|
||||
1, 0, 4, 128, 0, 0,
|
||||
0, 128, 0, 0, 0, 160,
|
||||
1, 0, 0, 2, 1, 0,
|
||||
8, 128, 0, 0, 85, 160,
|
||||
1, 0, 0, 2, 0, 8,
|
||||
15, 128, 0, 0, 228, 128,
|
||||
15, 128, 1, 0, 228, 128,
|
||||
255, 255, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0,
|
||||
255, 255, 255, 255, 0, 0,
|
||||
0, 0, 0, 0, 0, 0,
|
||||
180, 4, 0, 0, 0, 2,
|
||||
228, 4, 0, 0, 0, 2,
|
||||
255, 255, 254, 255, 84, 0,
|
||||
67, 84, 65, 66, 28, 0,
|
||||
0, 0, 27, 1, 0, 0,
|
||||
@@ -620,8 +634,8 @@ const BYTE gpuEffectA8[] =
|
||||
255, 255, 0, 0, 81, 0,
|
||||
0, 5, 5, 0, 15, 160,
|
||||
0, 0, 128, 191, 111, 18,
|
||||
131, 186, 0, 0, 128, 63,
|
||||
0, 0, 0, 0, 31, 0,
|
||||
131, 186, 0, 0, 128, 64,
|
||||
0, 0, 128, 63, 31, 0,
|
||||
0, 2, 0, 0, 0, 128,
|
||||
0, 0, 3, 176, 31, 0,
|
||||
0, 2, 0, 0, 0, 144,
|
||||
@@ -657,14 +671,22 @@ const BYTE gpuEffectA8[] =
|
||||
228, 128, 3, 8, 228, 160,
|
||||
2, 0, 0, 3, 1, 0,
|
||||
8, 128, 0, 0, 255, 128,
|
||||
5, 0, 0, 160, 35, 0,
|
||||
0, 2, 1, 0, 8, 128,
|
||||
5, 0, 0, 160, 5, 0,
|
||||
0, 3, 0, 0, 1, 128,
|
||||
1, 0, 170, 128, 5, 0,
|
||||
170, 160, 5, 0, 0, 3,
|
||||
0, 0, 2, 128, 1, 0,
|
||||
85, 128, 5, 0, 170, 160,
|
||||
5, 0, 0, 3, 0, 0,
|
||||
4, 128, 1, 0, 0, 128,
|
||||
5, 0, 170, 160, 35, 0,
|
||||
0, 2, 0, 0, 8, 128,
|
||||
1, 0, 255, 128, 2, 0,
|
||||
0, 3, 1, 0, 8, 128,
|
||||
1, 0, 255, 128, 5, 0,
|
||||
0, 3, 0, 0, 8, 128,
|
||||
0, 0, 255, 128, 5, 0,
|
||||
85, 160, 88, 0, 0, 4,
|
||||
0, 0, 7, 128, 1, 0,
|
||||
255, 128, 1, 0, 228, 128,
|
||||
0, 0, 7, 128, 0, 0,
|
||||
255, 128, 0, 0, 228, 128,
|
||||
3, 0, 228, 128, 2, 0,
|
||||
0, 3, 1, 0, 23, 128,
|
||||
2, 0, 228, 128, 0, 0,
|
||||
@@ -673,7 +695,7 @@ const BYTE gpuEffectA8[] =
|
||||
0, 161, 0, 0, 228, 128,
|
||||
1, 0, 228, 128, 1, 0,
|
||||
0, 2, 0, 0, 8, 128,
|
||||
5, 0, 170, 160, 1, 0,
|
||||
5, 0, 255, 160, 1, 0,
|
||||
0, 2, 0, 8, 15, 128,
|
||||
0, 0, 228, 128, 255, 255,
|
||||
0, 0, 255, 255, 255, 255,
|
||||
|
||||
@@ -21,7 +21,7 @@ float4 P1(in float2 Tex : TEXCOORD0) : COLOR0
|
||||
if (abs(backdrop - 1.0) < 0.001) { // (48.0 / 255.0) // 48 - key index color
|
||||
result = tex2D(s2, saturate((Tex - corner) / size));
|
||||
} else {
|
||||
result = tex1D(s1, backdrop); // get color in palette
|
||||
result = tex1D(s1, backdrop).bgr * 4; // get color in palette
|
||||
}
|
||||
// blend highlights
|
||||
if (showhl) {
|
||||
@@ -40,7 +40,7 @@ technique T1
|
||||
float4 P0(in float2 Tex : TEXCOORD0) : COLOR0
|
||||
{
|
||||
float3 result = tex1D(s1, tex2D(s0, Tex).a); // get color in palette
|
||||
return float4(result, 1);
|
||||
return float4(result.bgr * 4, 1);
|
||||
}
|
||||
|
||||
technique T0
|
||||
|
||||
+48
-26
@@ -62,7 +62,7 @@ technique T1
|
||||
//
|
||||
|
||||
ps_2_0
|
||||
def c5, -1, -0.00100000005, 1, 0
|
||||
def c5, -1, -0.00100000005, 4, 1
|
||||
dcl t0.xy
|
||||
dcl_2d s0
|
||||
dcl_2d s1
|
||||
@@ -78,15 +78,18 @@ technique T1
|
||||
texld r3, r0, s1
|
||||
texld r2, r2, s3
|
||||
add r1.w, r0.x, c5.x
|
||||
abs r1.w, r1.w
|
||||
add r1.w, r1.w, c5.y
|
||||
cmp r0.xyz, r1.w, r3, r1
|
||||
mul r0.x, r3.z, c5.z
|
||||
mul r0.y, r3.y, c5.z
|
||||
mul r0.z, r3.x, c5.z
|
||||
abs r0.w, r1.w
|
||||
add r0.w, r0.w, c5.y
|
||||
cmp r0.xyz, r0.w, r0, r1
|
||||
add_sat r1.xyz, r2, r0
|
||||
cmp r0.xyz, -c1.x, r0, r1
|
||||
mov r0.w, c5.z
|
||||
mov r0.w, c5.w
|
||||
mov oC0, r0
|
||||
|
||||
// approximately 17 instruction slots used (4 texture, 13 arithmetic)
|
||||
// approximately 20 instruction slots used (4 texture, 16 arithmetic)
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -116,17 +119,20 @@ technique T0
|
||||
//
|
||||
|
||||
ps_2_0
|
||||
def c0, 1, 0, 0, 0
|
||||
def c0, 4, 1, 0, 0
|
||||
dcl t0.xy
|
||||
dcl_2d s0
|
||||
dcl_2d s1
|
||||
texld r0, t0, s0
|
||||
mov r0.xy, r0.x
|
||||
texld r0, r0, s1
|
||||
mov r0.w, c0.x
|
||||
mov oC0, r0
|
||||
mul r1.x, r0.z, c0.x
|
||||
mul r1.y, r0.y, c0.x
|
||||
mul r1.z, r0.x, c0.x
|
||||
mov r1.w, c0.y
|
||||
mov oC0, r1
|
||||
|
||||
// approximately 5 instruction slots used (2 texture, 3 arithmetic)
|
||||
// approximately 8 instruction slots used (2 texture, 6 arithmetic)
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -419,7 +425,7 @@ const BYTE gpuEffectL8[] =
|
||||
0, 0, 1, 0, 0, 0,
|
||||
0, 0, 0, 0, 255, 255,
|
||||
255, 255, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 52, 1,
|
||||
0, 0, 0, 0, 100, 1,
|
||||
0, 0, 0, 2, 255, 255,
|
||||
254, 255, 42, 0, 67, 84,
|
||||
65, 66, 28, 0, 0, 0,
|
||||
@@ -451,8 +457,8 @@ const BYTE gpuEffectL8[] =
|
||||
46, 57, 53, 50, 46, 51,
|
||||
49, 49, 49, 0, 81, 0,
|
||||
0, 5, 0, 0, 15, 160,
|
||||
0, 0, 128, 63, 0, 0,
|
||||
0, 0, 0, 0, 0, 0,
|
||||
0, 0, 128, 64, 0, 0,
|
||||
128, 63, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 31, 0,
|
||||
0, 2, 0, 0, 0, 128,
|
||||
0, 0, 3, 176, 31, 0,
|
||||
@@ -467,15 +473,23 @@ const BYTE gpuEffectL8[] =
|
||||
0, 128, 66, 0, 0, 3,
|
||||
0, 0, 15, 128, 0, 0,
|
||||
228, 128, 1, 8, 228, 160,
|
||||
1, 0, 0, 2, 0, 0,
|
||||
8, 128, 0, 0, 0, 160,
|
||||
5, 0, 0, 3, 1, 0,
|
||||
1, 128, 0, 0, 170, 128,
|
||||
0, 0, 0, 160, 5, 0,
|
||||
0, 3, 1, 0, 2, 128,
|
||||
0, 0, 85, 128, 0, 0,
|
||||
0, 160, 5, 0, 0, 3,
|
||||
1, 0, 4, 128, 0, 0,
|
||||
0, 128, 0, 0, 0, 160,
|
||||
1, 0, 0, 2, 1, 0,
|
||||
8, 128, 0, 0, 85, 160,
|
||||
1, 0, 0, 2, 0, 8,
|
||||
15, 128, 0, 0, 228, 128,
|
||||
15, 128, 1, 0, 228, 128,
|
||||
255, 255, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0,
|
||||
255, 255, 255, 255, 0, 0,
|
||||
0, 0, 0, 0, 0, 0,
|
||||
180, 4, 0, 0, 0, 2,
|
||||
228, 4, 0, 0, 0, 2,
|
||||
255, 255, 254, 255, 84, 0,
|
||||
67, 84, 65, 66, 28, 0,
|
||||
0, 0, 27, 1, 0, 0,
|
||||
@@ -620,8 +634,8 @@ const BYTE gpuEffectL8[] =
|
||||
255, 255, 0, 0, 81, 0,
|
||||
0, 5, 5, 0, 15, 160,
|
||||
0, 0, 128, 191, 111, 18,
|
||||
131, 186, 0, 0, 128, 63,
|
||||
0, 0, 0, 0, 31, 0,
|
||||
131, 186, 0, 0, 128, 64,
|
||||
0, 0, 128, 63, 31, 0,
|
||||
0, 2, 0, 0, 0, 128,
|
||||
0, 0, 3, 176, 31, 0,
|
||||
0, 2, 0, 0, 0, 144,
|
||||
@@ -657,14 +671,22 @@ const BYTE gpuEffectL8[] =
|
||||
228, 128, 3, 8, 228, 160,
|
||||
2, 0, 0, 3, 1, 0,
|
||||
8, 128, 0, 0, 0, 128,
|
||||
5, 0, 0, 160, 35, 0,
|
||||
0, 2, 1, 0, 8, 128,
|
||||
5, 0, 0, 160, 5, 0,
|
||||
0, 3, 0, 0, 1, 128,
|
||||
3, 0, 170, 128, 5, 0,
|
||||
170, 160, 5, 0, 0, 3,
|
||||
0, 0, 2, 128, 3, 0,
|
||||
85, 128, 5, 0, 170, 160,
|
||||
5, 0, 0, 3, 0, 0,
|
||||
4, 128, 3, 0, 0, 128,
|
||||
5, 0, 170, 160, 35, 0,
|
||||
0, 2, 0, 0, 8, 128,
|
||||
1, 0, 255, 128, 2, 0,
|
||||
0, 3, 1, 0, 8, 128,
|
||||
1, 0, 255, 128, 5, 0,
|
||||
0, 3, 0, 0, 8, 128,
|
||||
0, 0, 255, 128, 5, 0,
|
||||
85, 160, 88, 0, 0, 4,
|
||||
0, 0, 7, 128, 1, 0,
|
||||
255, 128, 3, 0, 228, 128,
|
||||
0, 0, 7, 128, 0, 0,
|
||||
255, 128, 0, 0, 228, 128,
|
||||
1, 0, 228, 128, 2, 0,
|
||||
0, 3, 1, 0, 23, 128,
|
||||
2, 0, 228, 128, 0, 0,
|
||||
@@ -673,7 +695,7 @@ const BYTE gpuEffectL8[] =
|
||||
0, 161, 0, 0, 228, 128,
|
||||
1, 0, 228, 128, 1, 0,
|
||||
0, 2, 0, 0, 8, 128,
|
||||
5, 0, 170, 160, 1, 0,
|
||||
5, 0, 255, 160, 1, 0,
|
||||
0, 2, 0, 8, 15, 128,
|
||||
0, 0, 228, 128, 255, 255,
|
||||
0, 0, 255, 255, 255, 255,
|
||||
|
||||
@@ -21,7 +21,7 @@ float4 P1(in float2 Tex : TEXCOORD0) : COLOR0
|
||||
if (abs(backdrop - 1.0) < 0.001) {
|
||||
result = tex2D(s2, saturate((Tex - corner) / size));
|
||||
} else {
|
||||
result = tex1D(s1, backdrop);
|
||||
result = tex1D(s1, backdrop).bgr * 4;
|
||||
}
|
||||
// blend highlights
|
||||
if (showhl) {
|
||||
@@ -40,7 +40,7 @@ technique T1
|
||||
float4 P0(in float2 Tex : TEXCOORD0) : COLOR0
|
||||
{
|
||||
float3 result = tex1D(s1, tex2D(s0, Tex).r);
|
||||
return float4(result, 1);
|
||||
return float4(result.bgr * 4, 1);
|
||||
}
|
||||
|
||||
technique T0
|
||||
|
||||
+19
-18
@@ -29,47 +29,49 @@ namespace sfall
|
||||
static int DebugTypes = 0;
|
||||
static std::ofstream Log;
|
||||
|
||||
void dlog(const char* a) {
|
||||
template <class T>
|
||||
static void OutLog(T a) {
|
||||
Log << a;
|
||||
Log.flush();
|
||||
}
|
||||
|
||||
template <class T>
|
||||
static void OutLogN(T a) {
|
||||
Log << a << "\n";
|
||||
Log.flush();
|
||||
}
|
||||
|
||||
void dlog(const char* a, int type) {
|
||||
if (isDebug && (type == DL_MAIN || (type & DebugTypes))) {
|
||||
Log << a;
|
||||
Log.flush();
|
||||
if (type == DL_MAIN || (isDebug && (type & DebugTypes))) {
|
||||
OutLog(a);
|
||||
}
|
||||
}
|
||||
|
||||
void dlog(const std::string& a, int type) {
|
||||
if (isDebug && (type == DL_MAIN || (type & DebugTypes))) {
|
||||
Log << a;
|
||||
Log.flush();
|
||||
if (type == DL_MAIN || (isDebug && (type & DebugTypes))) {
|
||||
OutLog(a);
|
||||
}
|
||||
}
|
||||
|
||||
void dlogr(const char* a, int type) {
|
||||
if (isDebug && (type == DL_MAIN || (type & DebugTypes))) {
|
||||
Log << a << "\n";
|
||||
Log.flush();
|
||||
if (type == DL_MAIN || (isDebug && (type & DebugTypes))) {
|
||||
OutLogN(a);
|
||||
}
|
||||
}
|
||||
|
||||
void dlogr(const std::string& a, int type) {
|
||||
if (isDebug && (type == DL_MAIN || (type & DebugTypes))) {
|
||||
Log << a << "\n";
|
||||
Log.flush();
|
||||
if (type == DL_MAIN || (isDebug && (type & DebugTypes))) {
|
||||
OutLogN(a);
|
||||
}
|
||||
}
|
||||
|
||||
void dlog_f(const char* fmt, int type, ...) {
|
||||
if (isDebug && (type == DL_MAIN || (type & DebugTypes))) {
|
||||
if (type == DL_MAIN || (isDebug && (type & DebugTypes))) {
|
||||
va_list args;
|
||||
va_start(args, type);
|
||||
char buf[1024];
|
||||
vsnprintf_s(buf, sizeof(buf), _TRUNCATE, fmt, args);
|
||||
Log << buf;
|
||||
Log.flush();
|
||||
OutLog(buf);
|
||||
va_end(args);
|
||||
}
|
||||
}
|
||||
@@ -82,8 +84,7 @@ void devlog_f(const char* fmt, int type, ...) {
|
||||
va_start(args, type);
|
||||
char buf[1024];
|
||||
vsnprintf_s(buf, sizeof(buf), _TRUNCATE, fmt, args);
|
||||
Log << buf;
|
||||
Log.flush();
|
||||
OutLog(buf);
|
||||
va_end(args);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,7 +30,6 @@
|
||||
namespace sfall
|
||||
{
|
||||
|
||||
void dlog(const char* msg);
|
||||
void dlog(const char* msg, int type);
|
||||
void dlog(const std::string& msg, int type);
|
||||
void dlogr(const char* msg, int type);
|
||||
|
||||
+20
-31
@@ -44,9 +44,9 @@ namespace sfall
|
||||
#define UNUSEDFUNCTION { return DDERR_GENERIC; }
|
||||
#define SAFERELEASE(a) { if (a) { a->Release(); a = nullptr; } }
|
||||
|
||||
#define ShowMessageBox(text) ShowWindow(window, SW_MINIMIZE); \
|
||||
#define ShowMessageBox(text) if (!Graphics::IsWindowedMode) ShowWindow(window, SW_MINIMIZE); \
|
||||
MessageBoxA(window, text, "sfall DirectX 9", MB_TASKMODAL | MB_ICONWARNING); \
|
||||
ShowWindow(window, SW_RESTORE)
|
||||
if (!Graphics::IsWindowedMode) ShowWindow(window, SW_RESTORE)
|
||||
|
||||
#if !(NDEBUG) && !(_DEBUG)
|
||||
static LPD3DXFONT font;
|
||||
@@ -108,7 +108,6 @@ static IDirect3DVertexBuffer9* vertexSfallRes;
|
||||
static IDirect3DVertexBuffer9* vertexMovie; // for AVI
|
||||
//static IDirect3DVertexBuffer9* vertexStaticScreen; // splash/death/endslides
|
||||
|
||||
static IDirect3DTexture9* paletteTex;
|
||||
static IDirect3DTexture9* gpuPalette;
|
||||
static ID3DXEffect* gpuBltEffect;
|
||||
|
||||
@@ -206,6 +205,9 @@ static void ResetDevice(bool create) {
|
||||
d3d9Device->GetDeviceCaps(&caps);
|
||||
ShaderVersion = ((caps.PixelShaderVersion & 0x0000FF00) >> 8) * 10 + (caps.PixelShaderVersion & 0xFF);
|
||||
|
||||
bool npow2 = ((caps.TextureCaps & D3DPTEXTURECAPS_POW2) != 0); //(caps.TextureCaps & D3DPTEXTURECAPS_NONPOW2CONDITIONAL)
|
||||
if (npow2) dlogr("Warning: The graphics card does not support non-power-of-two textures.", DL_MAIN);
|
||||
|
||||
// Use: 0 - only CPU, 1 - force GPU, 2 - Auto Mode (GPU or switch to CPU)
|
||||
if (Graphics::GPUBlt == 2 && ShaderVersion < 20) Graphics::GPUBlt = 0;
|
||||
|
||||
@@ -228,8 +230,6 @@ static void ResetDevice(bool create) {
|
||||
|
||||
Graphics::SetDefaultTechnique();
|
||||
|
||||
d3d9Device->CreateTexture(256, 1, 1, 0, D3DFMT_X8R8G8B8, D3DPOOL_SYSTEMMEM, &paletteTex, 0);
|
||||
|
||||
textureFormat = (A8IsSupported) ? D3DFMT_A8 : D3DFMT_L8; // D3DFMT_A8 - not supported on some older video cards
|
||||
} else {
|
||||
ShowMessageBox("Failed to create shader effects.\nSwitching to CPU for the palette conversion.");
|
||||
@@ -246,7 +246,8 @@ static void ResetDevice(bool create) {
|
||||
"Set 'GPUBlt' option to CPU to bypass this warning message.");
|
||||
Graphics::GPUBlt = 0;
|
||||
}
|
||||
if (Graphics::GPUBlt == 0) palette = new DirectDraw::PALCOLOR[256];
|
||||
|
||||
palette = new DirectDraw::PALCOLOR[256];
|
||||
|
||||
#if !(NDEBUG) && !(_DEBUG)
|
||||
D3DXCreateFontA(d3d9Device, 24, 0, 500, 0, 0, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE, "Arial", &font);
|
||||
@@ -576,7 +577,10 @@ void Graphics::SetDefaultTechnique() {
|
||||
}
|
||||
|
||||
static void SetGPUPalette() {
|
||||
d3d9Device->UpdateTexture(paletteTex, gpuPalette);
|
||||
D3DLOCKED_RECT lock;
|
||||
gpuPalette->LockRect(0, &lock, 0, D3DLOCK_DISCARD);
|
||||
std::memcpy(lock.pBits, palette, 256 * 4);
|
||||
gpuPalette->UnlockRect(0);
|
||||
}
|
||||
|
||||
class FakeDirectDrawSurface : IDirectDrawSurface {
|
||||
@@ -758,10 +762,7 @@ public:
|
||||
ResetDevice(false);
|
||||
DeviceLost = false;
|
||||
// restore palette
|
||||
if (Graphics::GPUBlt) {
|
||||
paletteTex->AddDirtyRect(0);
|
||||
SetGPUPalette();
|
||||
}
|
||||
if (Graphics::GPUBlt) SetGPUPalette();
|
||||
#ifndef NDEBUG
|
||||
dlogr("\nD3D9 Device restored.", DL_MAIN);
|
||||
#endif
|
||||
@@ -907,34 +908,23 @@ public:
|
||||
fo::PALETTE* destPal = (fo::PALETTE*)d;
|
||||
|
||||
if (Graphics::GPUBlt) {
|
||||
D3DLOCKED_RECT pal;
|
||||
if (c != 256) {
|
||||
RECT rect = { (long)b, 0, (long)(b + c), 1 };
|
||||
paletteTex->LockRect(0, &pal, &rect, D3DLOCK_NO_DIRTY_UPDATE);
|
||||
paletteTex->AddDirtyRect(&rect);
|
||||
b = 0;
|
||||
} else {
|
||||
paletteTex->LockRect(0, &pal, 0, 0);
|
||||
}
|
||||
// copy and swap color B <> R
|
||||
do {
|
||||
((DirectDraw::PALCOLOR*)pal.pBits)[b].R = destPal->R << 2;
|
||||
((DirectDraw::PALCOLOR*)pal.pBits)[b].G = destPal->G << 2;
|
||||
((DirectDraw::PALCOLOR*)pal.pBits)[b].B = destPal->B << 2;
|
||||
while (true) {
|
||||
palette[b].xRGB = *(DWORD*)destPal;
|
||||
if (--c == 0) break;
|
||||
destPal++;
|
||||
b++;
|
||||
} while (--c);
|
||||
paletteTex->UnlockRect(0);
|
||||
}
|
||||
if (!DeviceLost) SetGPUPalette();
|
||||
} else {
|
||||
// copy and swap color B <> R
|
||||
do {
|
||||
while (true) {
|
||||
palette[b].R = destPal->R << 2;
|
||||
palette[b].G = destPal->G << 2;
|
||||
palette[b].B = destPal->B << 2;
|
||||
if (--c == 0) break;
|
||||
destPal++;
|
||||
b++;
|
||||
} while (--c);
|
||||
}
|
||||
|
||||
primarySurface->SetPalette(0); // update texture
|
||||
if (FakeDirectDrawSurface::IsPlayMovie) return DD_OK; // prevents flickering at the beginning of playback (w/o HRP & GPUBlt=2)
|
||||
@@ -973,7 +963,6 @@ public:
|
||||
SAFERELEASE(sTex2);
|
||||
SAFERELEASE(vertexOrigRes);
|
||||
SAFERELEASE(vertexSfallRes);
|
||||
SAFERELEASE(paletteTex);
|
||||
SAFERELEASE(gpuPalette);
|
||||
SAFERELEASE(gpuBltEffect);
|
||||
SAFERELEASE(vertexMovie);
|
||||
@@ -1324,7 +1313,7 @@ void Graphics::init() {
|
||||
if (Graphics::mode < 0 || Graphics::mode > 6) {
|
||||
Graphics::mode = 0;
|
||||
}
|
||||
IsWindowedMode = (mode == 2 || mode == 3 || mode == 5 || mode == 6);
|
||||
IsWindowedMode = (mode == 2 || mode == 3 || mode >= 5);
|
||||
|
||||
if (Graphics::mode >= 4) {
|
||||
dlog("Applying DX9 graphics patch.", DL_INIT);
|
||||
|
||||
@@ -295,7 +295,7 @@ DWORD CreateDSGraph(wchar_t* path, sDSTexture* movie) {
|
||||
static __int64 endMoviePosition;
|
||||
|
||||
// Movie play looping
|
||||
static DWORD __fastcall PlayMovieLoop() {
|
||||
static DWORD __fastcall PlayMovieLoop(long kCode) {
|
||||
static bool onlyOnce = false;
|
||||
|
||||
if (aviPlayState == AviState::ReadyToPlay) {
|
||||
@@ -314,7 +314,7 @@ static DWORD __fastcall PlayMovieLoop() {
|
||||
}
|
||||
}
|
||||
|
||||
if (GetAsyncKeyState(VK_ESCAPE) & 0x8000) {
|
||||
if (kCode != -1) {
|
||||
StopMovie();
|
||||
return 0; // break play
|
||||
}
|
||||
@@ -332,11 +332,8 @@ static DWORD __fastcall PlayMovieLoop() {
|
||||
static void __declspec(naked) gmovie_play_hook() {
|
||||
__asm {
|
||||
push ecx;
|
||||
call fo::funcoffs::GNW95_process_message_; // windows message pump
|
||||
cmp ds:[FO_VAR_GNW95_isActive], 0;
|
||||
jnz skip;
|
||||
call fo::funcoffs::GNW95_lost_focus_;
|
||||
skip:
|
||||
call fo::funcoffs::get_input_; // also windows message pump
|
||||
mov ecx, eax;
|
||||
call PlayMovieLoop;
|
||||
pop ecx;
|
||||
retn;
|
||||
@@ -345,7 +342,7 @@ skip:
|
||||
|
||||
static void __declspec(naked) gmovie_play_hook_input() {
|
||||
__asm {
|
||||
xor eax,eax;
|
||||
xor eax, eax;
|
||||
dec eax;
|
||||
retn; // return -1
|
||||
}
|
||||
|
||||
+1
-1
@@ -214,7 +214,7 @@ static HMODULE SfallInit() {
|
||||
// enabling debugging features
|
||||
isDebug = (IniReader::GetIntDefaultConfig("Debugging", "Enable", 0) != 0);
|
||||
|
||||
if (!ddraw.dll) dlog("Error: Cannot load the original ddraw.dll library.\n");
|
||||
if (!ddraw.dll) dlogr("Error: Cannot load the original ddraw.dll library.", DL_MAIN);
|
||||
|
||||
if (!HRP::Setting::CheckExternalPatch()) {
|
||||
WinProc::init();
|
||||
|
||||
Reference in New Issue
Block a user