Skip to content

Commit

Permalink
Fix laser "explosions" in XvT.
Browse files Browse the repository at this point in the history
Also bump tools versions and version to 1.5.9.
  • Loading branch information
rdoeffinger committed Apr 9, 2019
1 parent b03c7d5 commit ec85a86
Show file tree
Hide file tree
Showing 11 changed files with 52 additions and 15 deletions.
5 changes: 5 additions & 0 deletions impl11/ddraw/DeviceResources.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include "../Debug/MainPixelShaderBpp4ColorKey20.h"
#include "../Debug/VertexShader.h"
#include "../Debug/PixelShaderAtest565.h"
#include "../Debug/PixelShaderAtestDiscardBlack.h"
#include "../Debug/PixelShaderAtestTexture.h"
#include "../Debug/PixelShaderAtestTextureNoAlpha.h"
#include "../Debug/PixelShaderTexture.h"
Expand All @@ -31,6 +32,7 @@
#include "../Release/MainPixelShaderBpp4ColorKey20.h"
#include "../Release/VertexShader.h"
#include "../Release/PixelShaderAtest565.h"
#include "../Release/PixelShaderAtestDiscardBlack.h"
#include "../Release/PixelShaderAtestTexture.h"
#include "../Release/PixelShaderAtestTextureNoAlpha.h"
#include "../Release/PixelShaderTexture.h"
Expand Down Expand Up @@ -618,6 +620,9 @@ HRESULT DeviceResources::LoadResources()
if (FAILED(hr = this->_d3dDevice->CreatePixelShader(g_PixelShaderAtest565, sizeof(g_PixelShaderAtest565), nullptr, &_pixelShaderAtest565)))
return hr;

if (FAILED(hr = this->_d3dDevice->CreatePixelShader(g_PixelShaderAtestDiscardBlack, sizeof(g_PixelShaderAtestDiscardBlack), nullptr, &_pixelShaderAtestDiscardBlack)))
return hr;

if (FAILED(hr = this->_d3dDevice->CreatePixelShader(g_PixelShaderAtestTexture, sizeof(g_PixelShaderAtestTexture), nullptr, &_pixelShaderAtestTexture)))
return hr;

Expand Down
1 change: 1 addition & 0 deletions impl11/ddraw/DeviceResources.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ class DeviceResources
ComPtr<ID3D11InputLayout> _inputLayout;
ComPtr<ID3D11PixelShader> _pixelShaderTexture;
ComPtr<ID3D11PixelShader> _pixelShaderAtest565;
ComPtr<ID3D11PixelShader> _pixelShaderAtestDiscardBlack;
ComPtr<ID3D11PixelShader> _pixelShaderAtestTexture;
ComPtr<ID3D11PixelShader> _pixelShaderAtestTextureNoAlpha;
ComPtr<ID3D11PixelShader> _pixelShaderSolid;
Expand Down
3 changes: 3 additions & 0 deletions impl11/ddraw/Direct3DDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -507,6 +507,9 @@ void Direct3DDevice::UpdatePixelShader(ID3D11DeviceContext *context, Direct3DTex
// HACK: This is a workaround because NVidia cards may return 0 alpha for 565 textures,
// causing flicker and holes e.g. in the rear of the A-Wing in XWA (most visible from the side).
if (texture->_surface->_pixelFormat.dwRGBAlphaBitMask == 0) pixelShader = this->_deviceResources->_pixelShaderAtest565;
// On the other hand, XvT relies on this behaviour for laser "explosions"...
// TODO: might this be a unsupported color key ssue??
if (g_config.isXvT && texture->_surface->_pixelFormat.dwRGBAlphaBitMask == 0) pixelShader = this->_deviceResources->_pixelShaderAtestDiscardBlack;
}

this->_deviceResources->InitPixelShader(pixelShader);
Expand Down
4 changes: 2 additions & 2 deletions impl11/ddraw/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ Config::Config()
bool isXWA = len >= 17 && _stricmp(name + len - 17, "xwingalliance.exe") == 0;
isXWing = len >= 11 && _stricmp(name + len - 11, "xwing95.exe") == 0;
isTIE = len >= 9 && _stricmp(name + len - 9, "tie95.exe") == 0;
bool isXvT = len >= 11 && _stricmp(name + len - 11, "z_xvt__.exe") == 0 &&
isXvT = len >= 11 && _stricmp(name + len - 11, "z_xvt__.exe") == 0 &&
*(const unsigned long long *)0x523aec == 0x54534c2e31505352ull;
bool isBoP = len >= 11 && _stricmp(name + len - 11, "z_xvt__.exe") == 0 &&
*(const unsigned long long *)0x5210bc == 0x54534c2e31505352ull;
Expand Down Expand Up @@ -352,4 +352,4 @@ void Config::runAutopatch()
VirtualProtect((void *)0x4f2a8c, 4, old, &dummy);
}
FlushInstructionCache(GetCurrentProcess(), NULL, 0);
}
}
1 change: 1 addition & 0 deletions impl11/ddraw/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class Config
bool XWAMode;
bool isTIE;
bool isXWing;
bool isXvT;

float Concourse3DScale;

Expand Down
8 changes: 4 additions & 4 deletions impl11/ddraw/ddraw.rc
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ END
//

1 VERSIONINFO
FILEVERSION 1,5,8
PRODUCTVERSION 1,5,8
FILEVERSION 1,5,9
PRODUCTVERSION 1,5,9
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
Expand All @@ -66,12 +66,12 @@ BEGIN
BEGIN
VALUE "CompanyName", "Jérémy Ansel"
VALUE "FileDescription", "Direct3D 11 implementation for X-Wing series"
VALUE "FileVersion", "1.5.8"
VALUE "FileVersion", "1.5.9"
VALUE "InternalName", "ddraw.dll"
VALUE "LegalCopyright", "Copyright (C) Jérémy Ansel 2014, Reimar Döffinger 2015-2019"
VALUE "OriginalFilename", "ddraw.dll"
VALUE "ProductName", "xwa_ddraw_d3d11"
VALUE "ProductVersion", "1.5.8"
VALUE "ProductVersion", "1.5.9"
END
END
BLOCK "VarFileInfo"
Expand Down
6 changes: 3 additions & 3 deletions impl11/ddraw/ddraw.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,19 @@
<ProjectGuid>{C03DE3A0-EF2A-4596-AFDE-66E4C4FD6E23}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>ddraw</RootNamespace>
<WindowsTargetPlatformVersion>10.0.17763.0</WindowsTargetPlatformVersion>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<PlatformToolset>v142</PlatformToolset>
<CharacterSet>NotSet</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<PlatformToolset>v142</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>NotSet</CharacterSet>
</PropertyGroup>
Expand Down
22 changes: 22 additions & 0 deletions impl11/shaders/PixelShaderAtestDiscardBlack.hlsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// Copyright (c) 2014 Jérémy Ansel
// Licensed under the MIT license. See LICENSE.txt


Texture2D texture0 : register(t0);
SamplerState sampler0 : register(s0);

struct PixelShaderInput
{
float4 pos : SV_POSITION;
float4 color : COLOR0;
float2 tex : TEXCOORD;
};

float4 main(PixelShaderInput input) : SV_TARGET
{
float4 texelColor = texture0.Sample(sampler0, input.tex);
if (input.color.a == 0) discard;
if (texelColor.r == 0 && texelColor.g == 0 && texelColor.b == 0) discard;
texelColor *= input.color;
return float4(texelColor.rgb, input.color.a);
}
10 changes: 7 additions & 3 deletions impl11/shaders/shaders.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,19 @@
<PropertyGroup Label="Globals">
<ProjectGuid>{EBD25ABF-9127-4887-9BF2-C7D3880BF68B}</ProjectGuid>
<RootNamespace>shaders</RootNamespace>
<WindowsTargetPlatformVersion>10.0.17763.0</WindowsTargetPlatformVersion>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<PlatformToolset>v142</PlatformToolset>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<PlatformToolset>v142</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
Expand Down Expand Up @@ -113,6 +113,10 @@
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Pixel</ShaderType>
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Pixel</ShaderType>
</FxCompile>
<FxCompile Include="PixelShaderAtestDiscardBlack.hlsl">
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Pixel</ShaderType>
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Pixel</ShaderType>
</FxCompile>
<FxCompile Include="PixelShaderAtestTexture.hlsl">
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Pixel</ShaderType>
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Pixel</ShaderType>
Expand Down
1 change: 1 addition & 0 deletions impl11/shaders/shaders.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,6 @@
<FxCompile Include="MainPixelShaderBpp4ColorKey20.hlsl" />
<FxCompile Include="MainPixelShaderBpp2ColorKey00.hlsl" />
<FxCompile Include="PixelShaderAtest565.hlsl" />
<FxCompile Include="PixelShaderAtestDiscardBlack.hlsl" />
</ItemGroup>
</Project>
6 changes: 3 additions & 3 deletions impl11/tests/tests.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,19 @@
<ProjectGuid>{0F3CC45E-5B7D-49DF-88E2-044BDB7554A0}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>tests</RootNamespace>
<WindowsTargetPlatformVersion>10.0.17763.0</WindowsTargetPlatformVersion>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<PlatformToolset>v142</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<PlatformToolset>v142</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
Expand Down

0 comments on commit ec85a86

Please sign in to comment.