mirror of
https://github.com/jmarshall23/CnC_Remastered_Collection.git
synced 2026-08-16 08:11:00 +02:00
Moved ddraw into exe, temp added libsmacker to test out movie event code. Movies work if converted to SMK.
This commit is contained in:
@@ -1059,11 +1059,28 @@ HRESULT __stdcall IDirectDrawSurfaceWrapper::Unlock(LPVOID lpRect)
|
||||
}*/
|
||||
|
||||
// Always unlock full rect(fix)
|
||||
extern byte* raw_image_buffer;
|
||||
//int* hackPaletteLookup = (int*)&raw_image_buffer[0];
|
||||
|
||||
// Translate all of raw video memory to rgb video memory with palette
|
||||
for(long i = 0; i < surfaceWidth * surfaceHeight; i++)
|
||||
if (raw_image_buffer == NULL)
|
||||
{
|
||||
rgbVideoMem[i] = attachedPalette->rgbPalette[rawVideoMem[i]];
|
||||
for (long i = 0; i < surfaceWidth * surfaceHeight; i++)
|
||||
{
|
||||
rgbVideoMem[i] = attachedPalette->rgbPalette[rawVideoMem[i]];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
byte* rgbVideoMemRaw = (byte*)rgbVideoMem;
|
||||
for (long i = 0; i < surfaceWidth * surfaceHeight; i++)
|
||||
{
|
||||
//rgbVideoMem[i] = hackPaletteLookup[rawVideoMem[i]];
|
||||
rgbVideoMemRaw[(i * 4) + 0] = raw_image_buffer[(rawVideoMem[i] * 3) + 2];
|
||||
rgbVideoMemRaw[(i * 4) + 1] = raw_image_buffer[(rawVideoMem[i] * 3) + 1];
|
||||
rgbVideoMemRaw[(i * 4) + 2] = raw_image_buffer[(rawVideoMem[i] * 3) + 0];
|
||||
rgbVideoMemRaw[(i * 4) + 3] = 255;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#define UNICODE
|
||||
#include "DirectDrawWrapper.h"
|
||||
#include "resource.h"
|
||||
//#include "resource.h"
|
||||
|
||||
/*******************
|
||||
**IUnknown methods**
|
||||
@@ -1269,9 +1270,11 @@ HRESULT IDirectDrawWrapper::Present()
|
||||
}
|
||||
|
||||
// Copy bits to texture by scanline observing pitch
|
||||
for(DWORD y = 0; y < displayModeHeight; y++)
|
||||
extern byte* raw_image_buffer;
|
||||
|
||||
for (DWORD y = 0; y < displayModeHeight; y++)
|
||||
{
|
||||
memcpy((BYTE *)d3dlrect.pBits + (y * d3dlrect.Pitch), &lpAttachedSurface->rgbVideoMem[y * displayModeWidth], displayModeWidth * sizeof(UINT32));
|
||||
memcpy((BYTE*)d3dlrect.pBits + (y * d3dlrect.Pitch), &lpAttachedSurface->rgbVideoMem[y * displayModeWidth], displayModeWidth * sizeof(UINT32));
|
||||
}
|
||||
|
||||
// Unlock dynamic texture
|
||||
@@ -2093,12 +2096,12 @@ bool IDirectDrawWrapper::CreateSurfaceTexture()
|
||||
}
|
||||
|
||||
// Create menu text texture
|
||||
HRESULT hr = D3DXCreateTextureFromResource(d3d9Device, hModule, MAKEINTRESOURCE(SPRITEDATA), &menuTexture);
|
||||
if(hr != D3D_OK)
|
||||
{
|
||||
debugMessage(0, "IDirectDrawWrapper::CreateSurfaceTexture","Unable to create texture from resource.");
|
||||
return false;
|
||||
}
|
||||
//HRESULT hr = D3DXCreateTextureFromResource(d3d9Device, hModule, MAKEINTRESOURCE(SPRITEDATA), &menuTexture);
|
||||
//if(hr != D3D_OK)
|
||||
//{
|
||||
// debugMessage(0, "IDirectDrawWrapper::CreateSurfaceTexture","Unable to create texture from resource.");
|
||||
// return false;
|
||||
//}
|
||||
|
||||
debugMessage(2, "IDirectDrawWrapper::CreateSurfaceTexture", "D3D9 Texture Created");
|
||||
return true;
|
||||
|
||||
@@ -243,6 +243,8 @@ class FAR IDirectDrawSurfaceWrapper : public IDirectDrawSurface
|
||||
{
|
||||
// Implemented interfaces
|
||||
public:
|
||||
IDirectDrawSurfaceWrapper() { attachedPalette = NULL; }
|
||||
|
||||
/*** IUnknown methods ***/
|
||||
HRESULT __stdcall QueryInterface(REFIID riid, LPVOID FAR * ppvObj);
|
||||
ULONG __stdcall AddRef();
|
||||
|
||||
@@ -1,38 +0,0 @@
|
||||
#include "resource.h"
|
||||
#include <windows.h>
|
||||
|
||||
SPRITEDATA RCDATA diablo_sprites.png
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
//FILEVERSION 1,0,0,0
|
||||
//PRODUCTVERSION 1,0,0,0
|
||||
FILEVERSION 6,1,7600,16385
|
||||
PRODUCTVERSION 6,1,7600,16385
|
||||
FILEFLAGSMASK VS_FF_PRERELEASE
|
||||
FILEOS VOS__WINDOWS32
|
||||
FILETYPE VFT_DLL
|
||||
FILESUBTYPE VFT2_UNKNOWN
|
||||
BEGIN
|
||||
BLOCK "StringFileInfo"
|
||||
BEGIN
|
||||
BLOCK "040904B0" /* LANG_ENGLISH/SUBLANG_ENGLISH_US,Unicode CP */
|
||||
BEGIN
|
||||
VALUE "CompanyName", "StrangeBytes.com"
|
||||
VALUE "FileDescription", "Microsoft DirectDraw"
|
||||
//VALUE "FileVersion", "1.0B\0"
|
||||
VALUE "FileVersion", "6.1.7600.16385"
|
||||
VALUE "InternalName", "ddrawwrapper"
|
||||
//VALUE "OriginalFilename", "ddraw.dll"
|
||||
VALUE "OriginalFilename", "DDraw.dll"
|
||||
VALUE "ProductName", "DiabloDirectDrawPatch"
|
||||
VALUE "LegalCopyright", "StrangeBytes.com"
|
||||
//VALUE "ProductVersion", "1.0B\0"
|
||||
VALUE "ProductVersion", "6.1.7600.16385"
|
||||
END
|
||||
END
|
||||
BLOCK "VarFileInfo"
|
||||
BEGIN
|
||||
VALUE "Translation", 0x04B0
|
||||
END
|
||||
END
|
||||
END
|
||||
@@ -1,7 +1,7 @@
|
||||
#pragma comment(linker, "/EXPORT:DirectDrawCreate=_DirectDrawCreate@12")
|
||||
|
||||
#include "DirectDrawWrapper.h"
|
||||
#include "resource.h"
|
||||
//#include "resource.h"
|
||||
//#include "detours.h"
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
@@ -171,112 +171,8 @@ LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
return CallWindowProc(lpDD->lpPrevWndFunc, hwnd, message, wParam, lParam);
|
||||
}
|
||||
|
||||
// Main dll entry
|
||||
BOOL APIENTRY DllMain( HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved)
|
||||
{
|
||||
LONG error;
|
||||
|
||||
switch (ul_reason_for_call)
|
||||
{
|
||||
// Initial process attach
|
||||
case DLL_PROCESS_ATTACH:
|
||||
// Store module handle
|
||||
hMod = hModule;
|
||||
|
||||
// Set default variables
|
||||
debugLevel = 0;
|
||||
debugDisplay = -1;
|
||||
|
||||
// Set time start
|
||||
start_time = GetTickCount();
|
||||
|
||||
// Not in menu to start
|
||||
inMenu = false;
|
||||
|
||||
// Retrieve command line arguments
|
||||
LPWSTR *szArgList;
|
||||
int argCount;
|
||||
szArgList = CommandLineToArgvW(GetCommandLine(), &argCount);
|
||||
|
||||
// If arguments
|
||||
if(szArgList != NULL)
|
||||
{
|
||||
for(int i = 0; i < argCount; i++)
|
||||
{
|
||||
// If debug
|
||||
if(wcscmp(szArgList[i], L"/ddrawdebug") == 0) {
|
||||
debugDisplay = 0;
|
||||
debugLevel = 2;
|
||||
// Create the debug console
|
||||
AllocConsole();
|
||||
// Redirect stdout to console
|
||||
freopen( "CONOUT$", "wb", stdout);
|
||||
break;
|
||||
}
|
||||
// If ddrawlog
|
||||
else if(wcscmp(szArgList[i], L"/ddrawlog") == 0) {
|
||||
debugDisplay = 1;
|
||||
debugLevel = 2;
|
||||
// Redireect stdout to file
|
||||
char curPath[MAX_PATH];
|
||||
char filename[MAX_PATH];
|
||||
GetCurrentDirectoryA(MAX_PATH, curPath);
|
||||
sprintf_s(filename, MAX_PATH, "%s\\ddraw_debug.log", curPath);
|
||||
freopen_s(&debugFile, filename, "wb", stdout);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
LocalFree(szArgList);
|
||||
|
||||
// Hook setcursorpos
|
||||
//DetourRestoreAfterWith();
|
||||
//DetourTransactionBegin();
|
||||
//DetourUpdateThread(GetCurrentThread());
|
||||
//DetourAttach(&(PVOID&)TrueSetCursorPos, OverrideSetCursorPos);
|
||||
////DetourAttach(&(PVOID&)TrueLoadLibraryA, OverrideLoadLibraryA);
|
||||
//error = DetourTransactionCommit();
|
||||
//if (error == NO_ERROR) {
|
||||
// debugMessage(2, "DllMain(DLL_PROCESS_ATTACH)", "Successfully detoured SetCursorPos");
|
||||
//}
|
||||
//else {
|
||||
// debugMessage(1, "DllMain(DLL_PROCESS_ATTACH)", "Failed to detour SetCursorPos");
|
||||
//}
|
||||
break;
|
||||
case DLL_THREAD_ATTACH:
|
||||
// Do nothing on thread attach
|
||||
break;
|
||||
case DLL_THREAD_DETACH:
|
||||
// Do nothing on thread detach
|
||||
break;
|
||||
case DLL_PROCESS_DETACH:
|
||||
// Delete DirectDrawWrapper object
|
||||
delete lpDD;
|
||||
|
||||
// Detach function hook
|
||||
//DetourTransactionBegin();
|
||||
//DetourUpdateThread(GetCurrentThread());
|
||||
//DetourDetach(&(PVOID&)TrueSetCursorPos, OverrideSetCursorPos);
|
||||
//error = DetourTransactionCommit();
|
||||
|
||||
|
||||
//cleanup debug console or file if exists
|
||||
if(debugDisplay == 0)
|
||||
{
|
||||
FreeConsole();
|
||||
}
|
||||
else if(debugDisplay == 1)
|
||||
{
|
||||
fclose(debugFile);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// Emulated direct draw create
|
||||
extern HRESULT WINAPI DirectDrawCreate(GUID FAR* lpGUID, LPDIRECTDRAW FAR* lplpDD, IUnknown FAR* pUnkOuter)
|
||||
HRESULT WINAPI DirectDrawCreate(GUID FAR* lpGUID, LPDIRECTDRAW FAR* lplpDD, IUnknown FAR* pUnkOuter)
|
||||
{
|
||||
// Create directdraw object
|
||||
lpDD = new IDirectDrawWrapper();
|
||||
@@ -1,121 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="4.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>{99418D1A-5BE9-4905-9002-B66A5979640B}</ProjectGuid>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<RootNamespace>ddrawwrapper</RootNamespace>
|
||||
<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>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
</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>
|
||||
<TargetName>ddraw</TargetName>
|
||||
<IncludePath>$(DXSDK_DIR)\Include\;$(IncludePath)</IncludePath>
|
||||
<LibraryPath>$(DXSDK_DIR)\Lib\$(PlatformShortName)\;$(LibraryPath)</LibraryPath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<TargetName>ddraw</TargetName>
|
||||
<IncludePath>$(DXSDK_DIR)\Include\;$(IncludePath)</IncludePath>
|
||||
<LibraryPath>$(DXSDK_DIR)\Lib\$(PlatformShortName)\;$(LibraryPath)</LibraryPath>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;DDRAWWRAPPER_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||
<AdditionalIncludeDirectories>D:\projects\RedAlert\code\dxsdk\Include</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalDependencies>kernel32.lib;user32.lib;d3d9.lib;d3dx9.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<OutputFile>D:\projects\RedAlert\ddraw.dll</OutputFile>
|
||||
<AdditionalLibraryDirectories>D:\projects\RedAlert\code\dxsdk\Lib\x86</AdditionalLibraryDirectories>
|
||||
</Link>
|
||||
<PostBuildEvent>
|
||||
<Command>
|
||||
</Command>
|
||||
</PostBuildEvent>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;DDRAWWRAPPER_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
<AdditionalIncludeDirectories>D:\projects\RedAlert\code\dxsdk\Include</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<AdditionalDependencies>kernel32.lib;user32.lib;d3d9.lib;d3dx9.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<OutputFile>D:\projects\RedAlert\ddraw.dll</OutputFile>
|
||||
<AdditionalLibraryDirectories>D:\projects\RedAlert\code\dxsdk\Lib\x86</AdditionalLibraryDirectories>
|
||||
</Link>
|
||||
<PostBuildEvent>
|
||||
<Command>
|
||||
</Command>
|
||||
</PostBuildEvent>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="ddraw.cpp" />
|
||||
<ClCompile Include="DirectDrawClipperWrapper.cpp" />
|
||||
<ClCompile Include="DirectDrawPaletteWrapper.cpp" />
|
||||
<ClCompile Include="DirectDrawSurfaceWrapper.cpp" />
|
||||
<ClCompile Include="DirectDrawWrapper.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="ddraw.h" />
|
||||
<ClInclude Include="DirectDrawWrapper.h" />
|
||||
<ClInclude Include="resource.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="ddraw.rc" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
@@ -1,50 +0,0 @@
|
||||
<?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;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>
|
||||
<ClCompile Include="ddraw.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="DirectDrawWrapper.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="DirectDrawSurfaceWrapper.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="DirectDrawPaletteWrapper.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="DirectDrawClipperWrapper.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="DirectDrawWrapper.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="ddraw.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="resource.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="ddraw.rc">
|
||||
<Filter>Resource Files</Filter>
|
||||
</ResourceCompile>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -1,3 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
</Project>
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 62 KiB |
@@ -1 +0,0 @@
|
||||
#define SPRITEDATA 300
|
||||
Reference in New Issue
Block a user