-
-
Notifications
You must be signed in to change notification settings - Fork 217
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3f590ef
commit 19f644a
Showing
9 changed files
with
410 additions
and
100 deletions.
There are no files selected for viewing
101 changes: 101 additions & 0 deletions
101
ThePunisher_widescreen_fix/ThePunisher_widescreen_fix.vcxproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<ItemGroup Label="ProjectConfigurations"> | ||
<ProjectConfiguration Include="Debug|Win32"> | ||
<Configuration>Debug</Configuration> | ||
<Platform>Win32</Platform> | ||
</ProjectConfiguration> | ||
<ProjectConfiguration Include="Release|Win32"> | ||
<Configuration>Release</Configuration> | ||
<Platform>Win32</Platform> | ||
</ProjectConfiguration> | ||
</ItemGroup> | ||
<PropertyGroup Label="Globals"> | ||
<ProjectGuid>{1F7D0F01-3B52-413B-8852-913ECCD4927C}</ProjectGuid> | ||
<Keyword>Win32Proj</Keyword> | ||
<RootNamespace>ThePunisher_widescreen_fix</RootNamespace> | ||
</PropertyGroup> | ||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> | ||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> | ||
<ConfigurationType>DynamicLibrary</ConfigurationType> | ||
<UseDebugLibraries>true</UseDebugLibraries> | ||
<PlatformToolset>v120</PlatformToolset> | ||
<CharacterSet>Unicode</CharacterSet> | ||
</PropertyGroup> | ||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> | ||
<ConfigurationType>DynamicLibrary</ConfigurationType> | ||
<UseDebugLibraries>false</UseDebugLibraries> | ||
<PlatformToolset>v120</PlatformToolset> | ||
<WholeProgramOptimization>true</WholeProgramOptimization> | ||
<CharacterSet>MultiByte</CharacterSet> | ||
</PropertyGroup> | ||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> | ||
<ImportGroup Label="ExtensionSettings"> | ||
</ImportGroup> | ||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> | ||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> | ||
</ImportGroup> | ||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> | ||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> | ||
</ImportGroup> | ||
<PropertyGroup Label="UserMacros" /> | ||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> | ||
<LinkIncremental>true</LinkIncremental> | ||
</PropertyGroup> | ||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> | ||
<LinkIncremental>false</LinkIncremental> | ||
<TargetExt>.asi</TargetExt> | ||
<OutDir>$(SolutionDir)$(Configuration)\$(ProjectName)\</OutDir> | ||
</PropertyGroup> | ||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> | ||
<ClCompile> | ||
<PrecompiledHeader>Use</PrecompiledHeader> | ||
<WarningLevel>Level3</WarningLevel> | ||
<Optimization>Disabled</Optimization> | ||
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;THEPUNISHER_WIDESCREEN_FIX_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions> | ||
</ClCompile> | ||
<Link> | ||
<SubSystem>Windows</SubSystem> | ||
<GenerateDebugInformation>true</GenerateDebugInformation> | ||
</Link> | ||
</ItemDefinitionGroup> | ||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> | ||
<ClCompile> | ||
<WarningLevel>Level4</WarningLevel> | ||
<PrecompiledHeader>Use</PrecompiledHeader> | ||
<Optimization>MaxSpeed</Optimization> | ||
<FunctionLevelLinking>true</FunctionLevelLinking> | ||
<IntrinsicFunctions>true</IntrinsicFunctions> | ||
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;THEPUNISHER_WIDESCREEN_FIX_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions> | ||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary> | ||
</ClCompile> | ||
<Link> | ||
<SubSystem>Windows</SubSystem> | ||
<GenerateDebugInformation>true</GenerateDebugInformation> | ||
<EnableCOMDATFolding>true</EnableCOMDATFolding> | ||
<OptimizeReferences>true</OptimizeReferences> | ||
</Link> | ||
</ItemDefinitionGroup> | ||
<ItemGroup> | ||
<ClInclude Include="stdafx.h" /> | ||
<ClInclude Include="targetver.h" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<ClCompile Include="..\includes\IniReader.cpp" /> | ||
<ClCompile Include="dllmain.cpp"> | ||
<CompileAsManaged Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</CompileAsManaged> | ||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> | ||
</PrecompiledHeader> | ||
<CompileAsManaged Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</CompileAsManaged> | ||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> | ||
</PrecompiledHeader> | ||
</ClCompile> | ||
<ClCompile Include="stdafx.cpp"> | ||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader> | ||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader> | ||
</ClCompile> | ||
</ItemGroup> | ||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> | ||
<ImportGroup Label="ExtensionTargets"> | ||
</ImportGroup> | ||
</Project> |
36 changes: 36 additions & 0 deletions
36
ThePunisher_widescreen_fix/ThePunisher_widescreen_fix.vcxproj.filters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<ItemGroup> | ||
<Filter Include="Source Files"> | ||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier> | ||
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions> | ||
</Filter> | ||
<Filter Include="Header Files"> | ||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier> | ||
<Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions> | ||
</Filter> | ||
<Filter Include="Resource Files"> | ||
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier> | ||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions> | ||
</Filter> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<ClInclude Include="stdafx.h"> | ||
<Filter>Header Files</Filter> | ||
</ClInclude> | ||
<ClInclude Include="targetver.h"> | ||
<Filter>Header Files</Filter> | ||
</ClInclude> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<ClCompile Include="stdafx.cpp"> | ||
<Filter>Source Files</Filter> | ||
</ClCompile> | ||
<ClCompile Include="dllmain.cpp"> | ||
<Filter>Source Files</Filter> | ||
</ClCompile> | ||
<ClCompile Include="..\includes\IniReader.cpp"> | ||
<Filter>Source Files</Filter> | ||
</ClCompile> | ||
</ItemGroup> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,163 @@ | ||
#include "stdafx.h" | ||
#include "..\includes\CPatch.h" | ||
#include "..\includes\IniReader.h" | ||
#define _USE_MATH_DEFINES | ||
#include "math.h" | ||
HWND hWnd; | ||
|
||
int res_x, res_y, hud_res_x, hud_res_y; | ||
float fres_x, fres_y; | ||
float fDynamicScreenFieldOfViewScale; | ||
float fAspectRatio; | ||
float hud_multiplier_x; | ||
|
||
#define DEGREE_TO_RADIAN(fAngle) \ | ||
((fAngle)* (float)M_PI / 180.0f) | ||
#define RADIAN_TO_DEGREE(fAngle) \ | ||
((fAngle)* 180.0f / (float)M_PI) | ||
#define SCREEN_FOV_HORIZONTAL 60.0f | ||
#define SCREEN_FOV_VERTICAL (2.0f * RADIAN_TO_DEGREE(atan(tan(DEGREE_TO_RADIAN(SCREEN_FOV_HORIZONTAL * 0.5f)) / (4.0f / 3.0f)))) | ||
|
||
void _declspec(naked) asm_res_fix1() | ||
{ | ||
_asm | ||
{ | ||
mov eax, hud_res_x | ||
ret | ||
} | ||
} | ||
|
||
void _declspec(naked) asm_res_fix2() | ||
{ | ||
_asm | ||
{ | ||
mov eax, hud_res_y | ||
ret | ||
} | ||
} | ||
|
||
void Init() | ||
{ | ||
CIniReader iniReader(""); | ||
res_x = iniReader.ReadInteger("MAIN", "X", 0); | ||
res_y = iniReader.ReadInteger("MAIN", "Y", 0); | ||
hud_res_x = iniReader.ReadInteger("MAIN", "HUD_RESX", 1280); | ||
hud_res_y = iniReader.ReadInteger("MAIN", "HUD_RESY", 960); | ||
|
||
if (!res_x || !res_y) { | ||
HMONITOR monitor = MonitorFromWindow(hWnd, MONITOR_DEFAULTTONEAREST); | ||
MONITORINFO info; | ||
info.cbSize = sizeof(MONITORINFO); | ||
GetMonitorInfo(monitor, &info); | ||
res_x = info.rcMonitor.right - info.rcMonitor.left; | ||
res_y = info.rcMonitor.bottom - info.rcMonitor.top; | ||
} | ||
|
||
fres_x = static_cast<float>(res_x); | ||
fres_y = static_cast<float>(res_y); | ||
|
||
fAspectRatio = fres_x / fres_y; | ||
fDynamicScreenFieldOfViewScale = 2.0f * RADIAN_TO_DEGREE(atan(tan(DEGREE_TO_RADIAN(SCREEN_FOV_VERTICAL * 0.5f)) * fAspectRatio)); | ||
|
||
if ((*(DWORD*)0x401F60 == 640)) // HOODLUM 2,48 MB (2 605 056 bytes) | ||
{ | ||
CPatch::RedirectCall(0x465360, asm_res_fix1); | ||
CPatch::RedirectCall(0x46536A, asm_res_fix2); | ||
|
||
CPatch::RedirectCall(0x477D37, asm_res_fix1); | ||
CPatch::RedirectCall(0x477D31, asm_res_fix2); | ||
|
||
CPatch::Nop(0x4DD6CB, 2); | ||
CPatch::Nop(0x4DD6ED, 2); | ||
CPatch::SetUInt(0x4DD6CD + 0x3, res_x); | ||
CPatch::SetUInt(0x4DD6EF + 0x4, res_y); | ||
|
||
CPatch::SetFloat(0x4922AC + 0x6, fDynamicScreenFieldOfViewScale); | ||
CPatch::SetFloat(0x4922DE + 0x6, fDynamicScreenFieldOfViewScale); | ||
CPatch::SetFloat(0x493590 + 0x6, fDynamicScreenFieldOfViewScale); | ||
CPatch::SetFloat(0x4B73A8 + 0x6, fDynamicScreenFieldOfViewScale); | ||
CPatch::SetFloat(0x4B7CDB + 0x6, fDynamicScreenFieldOfViewScale); | ||
CPatch::SetFloat(0x4B8585 + 0x6, fDynamicScreenFieldOfViewScale); | ||
|
||
CPatch::SetFloat(0x403DD4 + 0x6, fDynamicScreenFieldOfViewScale); | ||
CPatch::SetFloat(0x404340 + 0x1, fDynamicScreenFieldOfViewScale); | ||
CPatch::SetFloat(0x404E95 + 0x1, fDynamicScreenFieldOfViewScale); | ||
CPatch::SetFloat(0x406E6B + 0x6, fDynamicScreenFieldOfViewScale); | ||
CPatch::SetFloat(0x4072C4 + 0x6, fDynamicScreenFieldOfViewScale); | ||
CPatch::SetFloat(0x4C4CA2 + 0x4, fDynamicScreenFieldOfViewScale); | ||
|
||
CPatch::Nop(0x4DD5B9, 5); // no intro | ||
} | ||
else | ||
{ | ||
if ((*(DWORD*)0x401F70 == 640) && (*(DWORD*)0x514871 != 750)) // unknown 2,44 MB (2 562 048 bytes) | ||
{ | ||
CPatch::RedirectCall(0x465290, asm_res_fix1); | ||
CPatch::RedirectCall(0x46529A, asm_res_fix2); | ||
|
||
CPatch::RedirectCall(0x477D81, asm_res_fix1); | ||
CPatch::RedirectCall(0x477D87, asm_res_fix2); | ||
|
||
CPatch::Nop(0x4DD877, 2); | ||
CPatch::Nop(0x4DD899, 2); | ||
CPatch::SetUInt(0x4DD879 + 0x3, res_x); | ||
CPatch::SetUInt(0x4DD89B + 0x4, res_y); | ||
|
||
CPatch::SetFloat(0x49236C + 0x6, fDynamicScreenFieldOfViewScale); //to do | ||
CPatch::SetFloat(0x49239E + 0x6, fDynamicScreenFieldOfViewScale); | ||
CPatch::SetFloat(0x493650 + 0x6, fDynamicScreenFieldOfViewScale); | ||
CPatch::SetFloat(0x4B7508 + 0x6, fDynamicScreenFieldOfViewScale); | ||
CPatch::SetFloat(0x4B7E3B + 0x6, fDynamicScreenFieldOfViewScale); | ||
CPatch::SetFloat(0x4B86E5 + 0x6, fDynamicScreenFieldOfViewScale); | ||
|
||
CPatch::SetFloat(0x403DE4 + 0x6, fDynamicScreenFieldOfViewScale); | ||
CPatch::SetFloat(0x404350 + 0x1, fDynamicScreenFieldOfViewScale); | ||
CPatch::SetFloat(0x404EA5 + 0x1, fDynamicScreenFieldOfViewScale); | ||
CPatch::SetFloat(0x406E7B + 0x6, fDynamicScreenFieldOfViewScale); | ||
CPatch::SetFloat(0x4072D4 + 0x6, fDynamicScreenFieldOfViewScale); | ||
CPatch::SetFloat(0x4C4DE2 + 0x4, fDynamicScreenFieldOfViewScale); | ||
|
||
CPatch::Nop(0x4DD74B, 5); // no intro | ||
} | ||
else | ||
{ | ||
//Unpacked with ProcDump32 (C) G-RoM, Lorian & Stone - 1998, 1999 2,59 MB (2 719 744 bytes) | ||
|
||
CPatch::RedirectCall(0x465380, asm_res_fix1); | ||
CPatch::RedirectCall(0x46538A, asm_res_fix2); | ||
|
||
CPatch::RedirectCall(0x477E57, asm_res_fix1); | ||
CPatch::RedirectCall(0x477E51, asm_res_fix2); | ||
|
||
CPatch::Nop(0x4DD9EC, 2); | ||
CPatch::Nop(0x4DDA0E, 2); | ||
CPatch::SetUInt(0x4DD9EE + 0x3, res_x); | ||
CPatch::SetUInt(0x4DDA10 + 0x4, res_y); | ||
|
||
CPatch::SetFloat(0x4924CC + 0x6, fDynamicScreenFieldOfViewScale); | ||
CPatch::SetFloat(0x4924CC + 0x6, fDynamicScreenFieldOfViewScale); | ||
CPatch::SetFloat(0x4924FE + 0x6, fDynamicScreenFieldOfViewScale); | ||
CPatch::SetFloat(0x4B7658 + 0x6, fDynamicScreenFieldOfViewScale); | ||
CPatch::SetFloat(0x4B7F8B + 0x6, fDynamicScreenFieldOfViewScale); | ||
CPatch::SetFloat(0x4B8835 + 0x6, fDynamicScreenFieldOfViewScale); | ||
|
||
CPatch::SetFloat(0x403DE4 + 0x6, fDynamicScreenFieldOfViewScale); | ||
CPatch::SetFloat(0x404350 + 0x1, fDynamicScreenFieldOfViewScale); | ||
CPatch::SetFloat(0x404EA5 + 0x1, fDynamicScreenFieldOfViewScale); | ||
CPatch::SetFloat(0x406E7B + 0x6, fDynamicScreenFieldOfViewScale); | ||
CPatch::SetFloat(0x4072D4 + 0x6, fDynamicScreenFieldOfViewScale); | ||
CPatch::SetFloat(0x4C4F52 + 0x4, fDynamicScreenFieldOfViewScale); | ||
|
||
CPatch::Nop(0x4DD8A9, 5); // no intro | ||
} | ||
} | ||
} | ||
|
||
BOOL APIENTRY DllMain(HMODULE /*hModule*/, DWORD reason, LPVOID /*lpReserved*/) | ||
{ | ||
if (reason == DLL_PROCESS_ATTACH) | ||
{ | ||
Init(); | ||
} | ||
return TRUE; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
// stdafx.cpp : source file that includes just the standard includes | ||
// ThePunisher_widescreen_fix.pch will be the pre-compiled header | ||
// stdafx.obj will contain the pre-compiled type information | ||
|
||
#include "stdafx.h" | ||
|
||
// TODO: reference any additional headers you need in STDAFX.H | ||
// and not in this file |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// stdafx.h : include file for standard system include files, | ||
// or project specific include files that are used frequently, but | ||
// are changed infrequently | ||
// | ||
|
||
#pragma once | ||
|
||
#include "targetver.h" | ||
|
||
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers | ||
// Windows Header Files: | ||
#include <windows.h> | ||
|
||
|
||
|
||
// TODO: reference additional headers your program requires here |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#pragma once | ||
|
||
// Including SDKDDKVer.h defines the highest available Windows platform. | ||
|
||
// If you wish to build your application for a previous Windows platform, include WinSDKVer.h and | ||
// set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h. | ||
|
||
#include <SDKDDKVer.h> |
Oops, something went wrong.