1
0
mirror of https://github.com/DxWnd/DxWnd.reloaded synced 2024-12-30 09:25:35 +01:00

v2_03_01_src

Former-commit-id: aa0c0917a03868571476a952c97f65283c8283e7
This commit is contained in:
gho tik 2014-11-28 11:40:02 -05:00 committed by Refael ACkermann
parent 659df29aad
commit 9b385bb3ec
42 changed files with 304 additions and 133 deletions

3
build/Resources_CN.dll Normal file
View File

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:7bebe395edfd439cfe09e4875e481f37506e0a980a3c589958dd9781c7dc4e65
size 105472

3
build/Resources_EN.dll Normal file
View File

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:0612ced9b9f9b7805a31213cba47f847cc10eb0d6a95e2d47adff97484edf5f5
size 89600

3
build/Resources_RU.dll Normal file
View File

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:36821f95e5eac34a48bccb62115ffdf4b1ff5f6bde33f90e220c709fa4be086a
size 114176

View File

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:9824b03ee7247489a9910c7407a1ac7ff990854e60fdfcb46311763dc75a5df8
size 525312
oid sha256:59e618b7d0672f738eebd3958be555bdbcfa2da9f34681a37df8cc6258bad250
size 524288

View File

@ -0,0 +1,28 @@
[target]
title0=Breath of Fire IV
path0=D:\Games\Breath of Fire 4\BOF4.exe
launchpath0=
module0=
opengllib0=
ver0=0
coord0=0
flag0=134217762
flagg0=1476395024
flagh0=4116
flagi0=-2011168764
flagj0=4224
tflag0=6402
initx0=0
inity0=0
minx0=0
miny0=0
maxx0=0
maxy0=0
posx0=50
posy0=50
sizx0=800
sizy0=600
maxfps0=0
initts0=0
winver0=0
maxres0=-1

View File

@ -0,0 +1,28 @@
[target]
title0=Typing of the Dead, the
path0=D:\Games\Typing of the dead\Tod_e.exe
launchpath0=
module0=
opengllib0=
ver0=0
coord0=0
flag0=671088674
flagg0=1207959552
flagh0=20
flagi0=138412036
flagj0=4224
tflag0=1
initx0=0
inity0=0
minx0=0
miny0=0
maxx0=0
maxy0=0
posx0=50
posy0=50
sizx0=800
sizy0=600
maxfps0=0
initts0=0
winver0=0
maxres0=-1

View File

@ -1,5 +1,5 @@
[window]
posx=1122
posy=297
sizx=365
sizy=298
posx=1392
posy=53
sizx=320
sizy=841

3
build/filter.dll Normal file
View File

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:d364d53ff922e8381c306d23d51c3a93a0512325824e5e0513c424e9372f9b4c
size 13312

View File

@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:df0d752747c863568c9965f6c437e91e3e21594695a9665dee285def0d20d6fe
size 16384

View File

@ -645,3 +645,17 @@ fix: revised ddsurface capabilities policy to allow D3D1-7 games to run in emula
v2.02.99
fix: completed bilinear filtering for 16bpp desktop color depth
fix: fixed surface handling, Suppress SYSTEMMEMORY options now moved to debug flags (maybe unnecessary)
fix: AERO compatibility is now declared just once
fix: fast bilinear blitting in the 32 -> 32 BPP case
add: texture hooking
add: texture management
add: Direct3D dedicated configuration tab
v2.3.01
fix: fixed some bitmap handling while processing textures
add: texture management dump to texture.out folder and hack from texture.in folder
fix: AERO optimized mode with ddraw7 only surfaces: "Hoyle Casino Empire" works at least in fullscreen mode.
fix: bilinear filters compiled with optimized and openmp flags - big speed improvement.
fix: reduced the maximum amount of visible video card with "Limit available resources" flag: now "Breath of Fire IV" works.

View File

@ -756,18 +756,20 @@ Unlock4_Type pUnlockMethod(LPDIRECTDRAWSURFACE lpdds)
// to do: return extUnlock for unhooked surfaces
char sMsg[81];
void * extUnlock;
__try{ // v2.02.31: catch some possible exception (i.e. Abomination in EMULATION mode)
extUnlock=(void *)*(DWORD *)(*(DWORD *)lpdds + 128);
void * extUnlock = NULL;
if(lpdds){
__try{ // v2.02.31: catch some possible exception (i.e. Abomination in EMULATION mode)
extUnlock=(void *)*(DWORD *)(*(DWORD *)lpdds + 128);
}
__except (EXCEPTION_EXECUTE_HANDLER){
OutTraceE("Exception at %d\n",__LINE__);
extUnlock=NULL;
};
if(extUnlock==(void *)extUnlock1) return (Unlock4_Type)pUnlock1;
if(extUnlock==(void *)extUnlock4) return (Unlock4_Type)pUnlock4;
if(extUnlock==(void *)extUnlockDir1) return (Unlock4_Type)pUnlock1;
if(extUnlock==(void *)extUnlockDir4) return (Unlock4_Type)pUnlock4;
}
__except (EXCEPTION_EXECUTE_HANDLER){
OutTraceE("Exception at %d\n",__LINE__);
return (Unlock4_Type)pUnlock1;
};
if(extUnlock==(void *)extUnlock1) return (Unlock4_Type)pUnlock1;
if(extUnlock==(void *)extUnlock4) return (Unlock4_Type)pUnlock4;
if(extUnlock==(void *)extUnlockDir1) return (Unlock4_Type)pUnlock1;
if(extUnlock==(void *)extUnlockDir4) return (Unlock4_Type)pUnlock4;
sprintf_s(sMsg, 80, "pUnlockMethod: pUnlock(%x) can't match %x\n", lpdds, extUnlock);
OutTraceDW(sMsg);
if (IsAssertEnabled) MessageBox(0, sMsg, "pUnlockMethod", MB_OK | MB_ICONEXCLAMATION);
@ -779,19 +781,21 @@ Unlock4_Type pUnlockMethod(LPDIRECTDRAWSURFACE lpdds)
Lock_Type pLockMethod(LPDIRECTDRAWSURFACE lpdds)
{
char sMsg[81];
void * extUnlock;
__try{ // v2.02.31: catch some possible exception (i.e. Abomination in EMULATION mode)
extUnlock=(void *)*(DWORD *)(*(DWORD *)lpdds + 128);
void * extLock = NULL;
if(lpdds){
__try{ // v2.02.31: catch some possible exception (i.e. Abomination in EMULATION mode)
extLock=(void *)*(DWORD *)(*(DWORD *)lpdds + 128);
}
__except (EXCEPTION_EXECUTE_HANDLER){
OutTraceE("Exception at %d\n",__LINE__);
extLock=NULL;
};
if(extUnlock==(void *)extUnlock1) return pLock1;
if(extUnlock==(void *)extUnlock4) return pLock4;
if(extUnlock==(void *)extUnlockDir1) return pLock1;
if(extUnlock==(void *)extUnlockDir4) return pLock4;
}
__except (EXCEPTION_EXECUTE_HANDLER){
OutTraceE("Exception at %d\n",__LINE__);
return (Unlock4_Type)pUnlock1;
};
if(extUnlock==(void *)extUnlock1) return pLock1;
if(extUnlock==(void *)extUnlock4) return pLock4;
if(extUnlock==(void *)extUnlockDir1) return pLock1;
if(extUnlock==(void *)extUnlockDir4) return pLock4;
sprintf_s(sMsg, 80, "pLockMethod: pUnlock(%x) can't match %x\n", lpdds, extUnlock);
sprintf_s(sMsg, 80, "pLockMethod: pUnlock(%x) can't match %x\n", lpdds, extLock);
OutTraceDW(sMsg);
if (IsAssertEnabled) MessageBox(0, sMsg, "pLockMethod", MB_OK | MB_ICONEXCLAMATION);
if (pLock4) return pLock4;
@ -802,15 +806,23 @@ Lock_Type pLockMethod(LPDIRECTDRAWSURFACE lpdds)
CreateSurface2_Type pCreateSurfaceMethod(LPDIRECTDRAWSURFACE lpdds)
{
char sMsg[81];
void * extUnlock;
extUnlock=(void *)*(DWORD *)(*(DWORD *)lpdds + 128);
if(extUnlock==(void *)extUnlock1) return (CreateSurface2_Type)pCreateSurface1;
if(extUnlock==(void *)extUnlock4) return pCreateSurface7 ? (CreateSurface2_Type)pCreateSurface7 : (CreateSurface2_Type)pCreateSurface4;
if(extUnlock==(void *)extUnlockDir1) return (CreateSurface2_Type)pCreateSurface1;
if(extUnlock==(void *)extUnlockDir4) return pCreateSurface7 ? (CreateSurface2_Type)pCreateSurface7 : (CreateSurface2_Type)pCreateSurface4;
void * extUnlock = NULL;
if(lpdds){
__try{ // v2.02.31: catch some possible exception (i.e. Abomination in EMULATION mode)
extUnlock=(void *)*(DWORD *)(*(DWORD *)lpdds + 128); }
__except (EXCEPTION_EXECUTE_HANDLER){
OutTraceE("Exception at %d\n",__LINE__);
extUnlock = NULL;
};
if(extUnlock==(void *)extUnlock1) return (CreateSurface2_Type)pCreateSurface1;
if(extUnlock==(void *)extUnlock4) return pCreateSurface7 ? (CreateSurface2_Type)pCreateSurface7 : (CreateSurface2_Type)pCreateSurface4;
if(extUnlock==(void *)extUnlockDir1) return (CreateSurface2_Type)pCreateSurface1;
if(extUnlock==(void *)extUnlockDir4) return pCreateSurface7 ? (CreateSurface2_Type)pCreateSurface7 : (CreateSurface2_Type)pCreateSurface4;
}
sprintf_s(sMsg, 80, "pCreateSurfaceMethod: pUnlock(%x) can't match %x\n", lpdds, extUnlock);
OutTraceDW(sMsg);
if (IsAssertEnabled) MessageBox(0, sMsg, "pCreateSurfaceMethod", MB_OK | MB_ICONEXCLAMATION);
if (pCreateSurface7) return pCreateSurface7;
if (pCreateSurface4) return pCreateSurface4;
return (CreateSurface2_Type)pCreateSurface1;
}
@ -849,19 +861,21 @@ int SurfaceDescrSize(LPDIRECTDRAWSURFACE lpdds)
int lpddsHookedVersion(LPDIRECTDRAWSURFACE lpdds)
{
char sMsg[81];
void * extGetCaps;
void * extGetCaps = NULL;
__try{
extGetCaps=(void *)*(DWORD *)(*(DWORD *)lpdds + 56);
if(lpdds){
__try{
extGetCaps=(void *)*(DWORD *)(*(DWORD *)lpdds + 56);
}
__except (EXCEPTION_EXECUTE_HANDLER){
extGetCaps=NULL;
};
if(extGetCaps==(void *)extGetCaps1S) return 1;
if(extGetCaps==(void *)extGetCaps2S) return 2;
if(extGetCaps==(void *)extGetCaps3S) return 3;
if(extGetCaps==(void *)extGetCaps4S) return 4;
if(extGetCaps==(void *)extGetCaps7S) return 7;
}
__except (EXCEPTION_EXECUTE_HANDLER){
extGetCaps=NULL;
};
if(extGetCaps==(void *)extGetCaps1S) return 1;
if(extGetCaps==(void *)extGetCaps2S) return 2;
if(extGetCaps==(void *)extGetCaps3S) return 3;
if(extGetCaps==(void *)extGetCaps4S) return 4;
if(extGetCaps==(void *)extGetCaps7S) return 7;
sprintf_s(sMsg, 80, "lpddsHookedVersion(%x) can't match %x\n", lpdds, extGetCaps);
OutTraceDW(sMsg);
if (IsAssertEnabled) MessageBox(0, sMsg, "lpddsHookedVersion", MB_OK | MB_ICONEXCLAMATION);
@ -871,18 +885,20 @@ int lpddsHookedVersion(LPDIRECTDRAWSURFACE lpdds)
int lpddHookedVersion(LPDIRECTDRAW lpdd)
{
char sMsg[81];
void * extCreateSurface;
void *extCreateSurface = NULL;
__try{
extCreateSurface=(void *)*(DWORD *)(*(DWORD *)lpdd + 24);
if(lpPrimaryDD){
__try{
extCreateSurface=(void *)*(DWORD *)(*(DWORD *)lpdd + 24);
}
__except (EXCEPTION_EXECUTE_HANDLER){
extCreateSurface=NULL;
};
if(extCreateSurface==(void *)extCreateSurface7) return 7;
if(extCreateSurface==(void *)extCreateSurface4) return 4;
if(extCreateSurface==(void *)extCreateSurface2) return 2;
if(extCreateSurface==(void *)extCreateSurface1) return 1;
}
__except (EXCEPTION_EXECUTE_HANDLER){
extCreateSurface=NULL;
};
if(extCreateSurface==(void *)extCreateSurface7) return 7;
if(extCreateSurface==(void *)extCreateSurface4) return 4;
if(extCreateSurface==(void *)extCreateSurface2) return 2;
if(extCreateSurface==(void *)extCreateSurface1) return 1;
sprintf_s(sMsg, 80, "lpddHookedVersion(%x) can't match %x\n", lpdd, extCreateSurface);
OutTraceDW(sMsg);
if (IsAssertEnabled) MessageBox(0, sMsg, "lpddHookedVersion", MB_OK | MB_ICONEXCLAMATION);
@ -1587,7 +1603,7 @@ HRESULT WINAPI extDirectDrawCreate(GUID FAR *lpguid, LPDIRECTDRAW FAR *lplpdd, I
//OutTrace("DirectDrawCreate: drivercaps=%x(%s) emulcaps=%x(%s)\n", DriverCaps.ddsCaps, "???", EmulCaps.ddsCaps, "???");
}
lpPrimaryDD=*lplpdd;
if(lpPrimaryDD==NULL) lpPrimaryDD=*lplpdd; // do not override the value set when creating the primary surface!
return DD_OK;
}
@ -1659,7 +1675,7 @@ HRESULT WINAPI extDirectDrawCreateEx(GUID FAR *lpguid,
//OutTrace("DirectDrawCreate: drivercaps=%x(%s) emulcaps=%x(%s)\n", DriverCaps.ddsCaps, "???", EmulCaps.ddsCaps, "???");
}
lpPrimaryDD=*lplpdd;
if(lpPrimaryDD==NULL) lpPrimaryDD=*lplpdd; // do not override the value set when creating the primary surface!
return DD_OK;
}
@ -2258,6 +2274,9 @@ static HRESULT BuildPrimaryEmu(LPDIRECTDRAW lpdd, CreateSurface_Type pCreateSurf
if (dxw.dwTFlags & OUTPROXYTRACE) HookDDSurfaceGeneric(&lpDDSEmu_Back, dxversion);
}
// "Hoyle Casino Empire" opens a primary surface and NOT a backbuffer ....
iBakBufferVersion=dxversion; // v2.03.01
return DD_OK;
}
@ -2877,7 +2896,7 @@ void *LoadFilter(char *apiname)
*p=0;
SetDllDirectory(sSourcePath);
strcpy(p, "mp.dll");
strcpy(p, "filter.dll");
filterlib=(*pLoadLibraryA)(sSourcePath);
if(!filterlib) {
OutTraceDW("DXWND: Load lib=\"%s\" failed err=%d\n", sSourcePath, GetLastError());
@ -2979,10 +2998,10 @@ HRESULT WINAPI PrimaryBilinearBlt(LPDIRECTDRAWSURFACE lpdds, LPRECT lpdestrect,
break;
}
filterlib=(*pLoadLibraryA)("mp.dll");
filterlib=(*pLoadLibraryA)("filter.dll");
if(!filterlib) {
char sMsg[80+1];
sprintf(sMsg, "DXWND: ERROR can't load lib=\"mp.dll\" err=%x\n", GetLastError());
sprintf(sMsg, "DXWND: ERROR can't load lib=\"filter.dll\" err=%x\n", GetLastError());
OutTraceE(sMsg);
MessageBox(0, sMsg, "ERROR", MB_OK | MB_ICONEXCLAMATION);
exit(0);
@ -4848,7 +4867,9 @@ HRESULT WINAPI extDDGetGammaRamp(LPDIRECTDRAWSURFACE lpdds, DWORD dwFlags, LPDDG
HRESULT WINAPI extGetAvailableVidMem(LPDIRECTDRAW lpdd, LPDDSCAPS lpDDSCaps, LPDWORD lpdwTotal, LPDWORD lpdwFree, GetAvailableVidMem_Type pGetAvailableVidMem)
{
HRESULT res;
const DWORD dwMaxMem = 0x7FFFF000;
//const DWORD dwMaxMem = 0x7FFFF000;
// v03.01.01: limit to smaller value to allow "Breath of Fire IV" card detection
const DWORD dwMaxMem = 0x70000000;
OutTraceDDRAW("GetAvailableVidMem(D): lpdd=%x\n", lpdd);
res=(*pGetAvailableVidMem)(lpdd, lpDDSCaps, lpdwTotal, lpdwFree);
if(res){

View File

@ -143,7 +143,7 @@ char *ExplainDDSCaps3(DWORD c)
if (c & DDSCAPS3_DMAP) strcat(eb, "DDSCAPS3_DMAP+");
if (c & DDSCAPS3_MULTISAMPLE_QUALITY_MASK) {
DWORD dwQuality;
char sQuality[20];
char sQuality[32];
dwQuality = (c & DDSCAPS3_MULTISAMPLE_QUALITY_MASK) >> DDSCAPS3_MULTISAMPLE_QUALITY_SHIFT;
sprintf(sQuality, "QUALITY(%d)+", dwQuality);
strcat(eb, sQuality);
@ -1552,7 +1552,7 @@ char *ExplainPaletteUse(UINT uUsage)
char *ExplainRasterCaps(DWORD c)
{
static char eb[128];
static char eb[256];
unsigned int l;
strcpy(eb,"RC_");
if(c & RC_BITBLT) strcat(eb, "BITBLT+");

View File

@ -24,7 +24,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "dxwnd.h"
#include "dxwcore.hpp"
#define VERSION "2.02.99"
#define VERSION "2.03.01"
#define DXWACTIVATESINGLETASK 1 // comment to allow multiple task activations
#define DDTHREADLOCK 1

Binary file not shown.

View File

@ -0,0 +1,65 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioUserFile
ProjectType="Visual C++"
Version="9.00"
ShowAllFiles="false"
>
<Configurations>
<Configuration
Name="Debug|Win32"
>
<DebugSettings
Command=""
WorkingDirectory=""
CommandArguments=""
Attach="false"
DebuggerType="3"
Remote="1"
RemoteMachine="USER-PC"
RemoteCommand=""
HttpUrl=""
PDBPath=""
SQLDebugging=""
Environment=""
EnvironmentMerge="true"
DebuggerFlavor=""
MPIRunCommand=""
MPIRunArguments=""
MPIRunWorkingDirectory=""
ApplicationCommand=""
ApplicationArguments=""
ShimCommand=""
MPIAcceptMode=""
MPIAcceptFilter=""
/>
</Configuration>
<Configuration
Name="Release|Win32"
>
<DebugSettings
Command=""
WorkingDirectory=""
CommandArguments=""
Attach="false"
DebuggerType="3"
Remote="1"
RemoteMachine="USER-PC"
RemoteCommand=""
HttpUrl=""
PDBPath=""
SQLDebugging=""
Environment=""
EnvironmentMerge="true"
DebuggerFlavor=""
MPIRunCommand=""
MPIRunArguments=""
MPIRunWorkingDirectory=""
ApplicationCommand=""
ApplicationArguments=""
ShimCommand=""
MPIAcceptMode=""
MPIAcceptFilter=""
/>
</Configuration>
</Configurations>
</VisualStudioUserFile>

View File

@ -8,9 +8,6 @@
// exported API
//#undef OutTraceD3D
//#define OutTraceD3D OutTrace
typedef HRESULT (WINAPI *Direct3DCreateDevice_Type)(GUID FAR *, LPDIRECT3D, LPDIRECTDRAWSURFACE, LPDIRECT3D *, LPUNKNOWN);
typedef HRESULT (WINAPI *Direct3DCreate_Type)(UINT, LPDIRECT3D *, LPUNKNOWN);
@ -371,10 +368,10 @@ void HookDirect3DDevice(void **lpd3ddev, int d3dversion)
break;
case 7:
SetHook((void *)(**(DWORD **)lpd3ddev + 0), extQueryInterfaceD3, (void **)&pQueryInterfaceD3, "QueryInterface(D3D)");
SetHook((void *)(**(DWORD **)lpd3ddev + 20), extBeginScene7, (void **)&pBeginScene7, "BeginScene(7)");
SetHook((void *)(**(DWORD **)lpd3ddev + 24), extEndScene7, (void **)&pEndScene7, "EndScene(7)");
SetHook((void *)(**(DWORD **)lpd3ddev + 52), extSetViewport7, (void **)&pSetViewport7, "SetViewport(7)");
SetHook((void *)(**(DWORD **)lpd3ddev + 60), extGetViewport7, (void **)&pGetViewport7, "GetViewport(7)");
//SetHook((void *)(**(DWORD **)lpd3ddev + 20), extBeginScene7, (void **)&pBeginScene7, "BeginScene(7)");
//SetHook((void *)(**(DWORD **)lpd3ddev + 24), extEndScene7, (void **)&pEndScene7, "EndScene(7)");
//SetHook((void *)(**(DWORD **)lpd3ddev + 52), extSetViewport7, (void **)&pSetViewport7, "SetViewport(7)");
//SetHook((void *)(**(DWORD **)lpd3ddev + 60), extGetViewport7, (void **)&pGetViewport7, "GetViewport(7)");
SetHook((void *)(**(DWORD **)lpd3ddev + 80), extSetRenderState7, (void **)&pSetRenderState7, "SetRenderState(7)");
if (dxw.dwFlags4 & NOTEXTURES) SetHook((void *)(**(DWORD **)lpd3ddev + 140), extSetTexture7, (void **)&pSetTexture7, "SetTexture(D7)");
if(pSetRenderState7){

View File

@ -35,6 +35,21 @@ static unsigned int Hash(BYTE *buf, int len)
return hash;
}
static unsigned int HashSurface(BYTE *buf, int pitch, int width, int height)
{
unsigned int b = 378551;
unsigned int a = 63689;
DWORD hash = 0;
for(int y = 0; y < height; y++){
BYTE *p = buf + (y * pitch);
for(int x = 0; x < width; x++){
hash = hash * a + p[x];
a = a * b;
}
}
return hash;
}
void TextureHighlight(LPDIRECTDRAWSURFACE s)
{
DDSURFACEDESC2 ddsd;
@ -111,8 +126,14 @@ void TextureHighlight(LPDIRECTDRAWSURFACE s)
static void TextureDump(LPDIRECTDRAWSURFACE s)
{
DDSURFACEDESC2 ddsd;
int w, h, iSurfaceSize;
int w, h, iSurfaceSize, iScanLineSize;
HRESULT res;
static BOOL DoOnce = TRUE;
if(DoOnce){ // first time through, build the texture dir if not done yet
CreateDirectory("texture.out", NULL);
DoOnce = FALSE;
}
memset(&ddsd,0,sizeof(DDSURFACEDESC2));
ddsd.dwSize = Set_dwSize_From_Surface(s);
@ -121,12 +142,18 @@ static void TextureDump(LPDIRECTDRAWSURFACE s)
OutTraceE("TextureDump: Lock ERROR res=%x(%s) at %d\n", res, ExplainDDError(res), __LINE__);
return;
}
extern LPDIRECTDRAWSURFACE lpDDSBack;
if((ddsd.ddsCaps.dwCaps & DDSCAPS_TEXTURE) && (s != lpDDSBack)) while (TRUE) {
OutTrace("TextureDump: lpdds=%x BitCount=%d size=(%dx%d)\n",
s, ddsd.ddpfPixelFormat.dwRGBBitCount, ddsd.dwWidth, ddsd.dwHeight);
w = ddsd.dwWidth;
h = ddsd.dwHeight;
if((w<2) && (h<2)) {
OutTrace("TextureDump: SKIP small texture\n");
break;
}
iSurfaceSize = ddsd.dwHeight * ddsd.lPitch;
//HANDLE hf; // file handle
@ -156,17 +183,18 @@ static void TextureDump(LPDIRECTDRAWSURFACE s)
pbi.bV4AlphaMask = ddsd.ddpfPixelFormat.dwRGBAlphaBitMask;
pbi.bV4CSType = LCS_CALIBRATED_RGB;
//pbi.bV4CSType = 0xFFFFFFFF;
iScanLineSize = ((pbi.bV4Width * pbi.bV4BitCount + 0x1F) & ~0x1F)/8;
// calculate the bitmap hash
DWORD hash;
hash = Hash((BYTE *)ddsd.lpSurface, iSurfaceSize);
hash = HashSurface((BYTE *)ddsd.lpSurface, ddsd.lPitch, ddsd.dwWidth, ddsd.dwHeight);
if(!hash) {
OutTrace("TextureDump: lpdds=%x hash=NULL\n", s);
break; // almost certainly, an empty black surface!
}
// Create the .BMP file.
sprintf_s(pszFile, 80, "texture.%x.bmp", hash);
sprintf_s(pszFile, 80, "texture.out/texture.%03d.%03d.%08X.bmp", ddsd.dwWidth, ddsd.dwHeight, hash);
hf = fopen(pszFile, "wb");
if(!hf) break;
@ -186,9 +214,8 @@ static void TextureDump(LPDIRECTDRAWSURFACE s)
fwrite((LPVOID)&pbi, sizeof(BITMAPV4HEADER) + pbi.bV4ClrUsed * sizeof (RGBQUAD), 1, hf);
// Copy the array of color indices into the .BMP file.
fwrite((LPVOID)ddsd.lpSurface, iSurfaceSize, 1, hf);
if(pbi.bV4SizeImage > (DWORD)iSurfaceSize)
for (int i = pbi.bV4SizeImage - iSurfaceSize; i; i--) putc(0, hf);
for(int y=0; y<(int)ddsd.dwHeight; y++)
fwrite((BYTE *)ddsd.lpSurface + (y*ddsd.lPitch), iScanLineSize, 1, hf);
// Close the .BMP file.
fclose(hf);
@ -201,7 +228,7 @@ static void TextureDump(LPDIRECTDRAWSURFACE s)
static void TextureHack(LPDIRECTDRAWSURFACE s)
{
DDSURFACEDESC2 ddsd;
int w, h, iSurfaceSize;
int w, h, iSurfaceSize, iScanLineSize;
HRESULT res;
memset(&ddsd,0,sizeof(DDSURFACEDESC2));
@ -232,14 +259,15 @@ static void TextureHack(LPDIRECTDRAWSURFACE s)
pbi.biBitCount = (WORD)ddsd.ddpfPixelFormat.dwRGBBitCount;
pbi.biSizeImage = ((pbi.biWidth * pbi.biBitCount + 0x1F) & ~0x1F)/8 * pbi.biHeight;
iSizeImage = pbi.biSizeImage;
iScanLineSize = ((pbi.biWidth * pbi.biBitCount + 0x1F) & ~0x1F)/8;
// calculate the bitmap hash
DWORD hash;
hash = Hash((BYTE *)ddsd.lpSurface, iSurfaceSize);
hash = HashSurface((BYTE *)ddsd.lpSurface, ddsd.lPitch, ddsd.dwWidth, ddsd.dwHeight);
if(!hash) break; // almost certainly, an empty black surface!
// Look for the .BMP file.
sprintf_s(pszFile, 80, "texture.%x.bmp", hash);
sprintf_s(pszFile, 80, "texture.in/texture.%03d.%03d.%08X.bmp", ddsd.dwWidth, ddsd.dwHeight, hash);
hf = fopen(pszFile, "rb");
if(!hf) break; // no updated texture to load
@ -258,12 +286,18 @@ static void TextureHack(LPDIRECTDRAWSURFACE s)
// Read the new texture from the .BMP file.
if(pbi.biHeight < 0){
// height < 0 means scan lines in the up to down order, hence you can read them all
if(fread((LPVOID)ddsd.lpSurface, iSurfaceSize, 1, hf) != 1) break;
// biHeight < 0 -> scan lines from top to bottom, same as surface/texture convention
for(int y=0; y<(int)ddsd.dwHeight; y++){
BYTE *p = (BYTE *)ddsd.lpSurface + (ddsd.lPitch * y);
fseek(hf, hdr.bfOffBits + (iScanLineSize * y), SEEK_SET);
if(fread((LPVOID)p, ddsd.lPitch, 1, hf) != 1) break;
}
}
else {
// biHeight > 0 -> scan lines from bottom to top, inverse order as surface/texture convention
for(int y=0; y<(int)ddsd.dwHeight; y++){
BYTE *p = (BYTE *)ddsd.lpSurface + (ddsd.lPitch * ((ddsd.dwHeight-1) - y));
fseek(hf, hdr.bfOffBits + (iScanLineSize * y), SEEK_SET);
if(fread((LPVOID)p, ddsd.lPitch, 1, hf) != 1) break;
}
}

View File

@ -1,4 +1,4 @@
LIBRARY mp
LIBRARY filter
EXPORTS
Resize_HQ_4ch @1
Resize_HQ_2ch565 @2

View File

@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 10.00
# Visual Studio 2008
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mp", "mp.vcproj", "{F3E96EF0-AF9C-43C2-8E3E-0DD10B66E0FC}"
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "filter", "filter.vcproj", "{F3E96EF0-AF9C-43C2-8E3E-0DD10B66E0FC}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution

BIN
filter/filter.suo Normal file

Binary file not shown.

View File

@ -2,9 +2,9 @@
<VisualStudioProject
ProjectType="Visual C++"
Version="9.00"
Name="mp"
Name="filter"
ProjectGUID="{F3E96EF0-AF9C-43C2-8E3E-0DD10B66E0FC}"
RootNamespace="mp"
RootNamespace="filter"
Keyword="Win32Proj"
TargetFrameworkVersion="0"
>
@ -39,16 +39,18 @@
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
Optimization="2"
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;MP_EXPORTS;"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
MinimalRebuild="false"
BasicRuntimeChecks="0"
RuntimeLibrary="2"
BufferSecurityCheck="false"
FloatingPointModel="2"
OpenMP="true"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="4"
DebugInformationFormat="0"
/>
<Tool
Name="VCManagedResourceCompilerTool"
@ -64,7 +66,7 @@
OutputFile="..\Debug\mp.dll"
LinkIncremental="2"
AdditionalLibraryDirectories=""
ModuleDefinitionFile=".\mp.def"
ModuleDefinitionFile=".\filter.def"
GenerateDebugInformation="true"
SubSystem="2"
TargetMachine="1"
@ -114,12 +116,17 @@
/>
<Tool
Name="VCCLCompilerTool"
Optimization="2"
FavorSizeOrSpeed="1"
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;MP_EXPORTS;"
RuntimeLibrary="2"
BufferSecurityCheck="false"
FloatingPointModel="2"
OpenMP="true"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="3"
Detect64BitPortabilityProblems="false"
DebugInformationFormat="0"
/>
<Tool
Name="VCManagedResourceCompilerTool"
@ -133,8 +140,8 @@
<Tool
Name="VCLinkerTool"
OutputFile="..\$(OutDir)\$(ProjectName).dll"
LinkIncremental="2"
ModuleDefinitionFile=".\mp.def"
LinkIncremental="0"
ModuleDefinitionFile=".\filter.def"
GenerateDebugInformation="true"
SubSystem="2"
OptimizeReferences="2"
@ -197,7 +204,7 @@
>
</File>
<File
RelativePath=".\mp.def"
RelativePath=".\filter.def"
>
</File>
</Filter>

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -1,15 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
<security>
<requestedPrivileges>
<requestedExecutionLevel level="asInvoker" uiAccess="false"></requestedExecutionLevel>
</requestedPrivileges>
</security>
</trustInfo>
<dependency>
<dependentAssembly>
<assemblyIdentity type="win32" name="Microsoft.VC90.CRT" version="9.0.21022.8" processorArchitecture="x86" publicKeyToken="1fc8b3b9a1e18e3b"></assemblyIdentity>
</dependentAssembly>
</dependency>
</assembly>

Binary file not shown.

View File

@ -1,15 +0,0 @@
<?xml version='1.0' encoding='UTF-8' standalone='yes'?>
<assembly xmlns='urn:schemas-microsoft-com:asm.v1' manifestVersion='1.0'>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
<security>
<requestedPrivileges>
<requestedExecutionLevel level='asInvoker' uiAccess='false' />
</requestedPrivileges>
</security>
</trustInfo>
<dependency>
<dependentAssembly>
<assemblyIdentity type='win32' name='Microsoft.VC90.CRT' version='9.0.21022.8' processorArchitecture='x86' publicKeyToken='1fc8b3b9a1e18e3b' />
</dependentAssembly>
</dependency>
</assembly>

View File

@ -1 +0,0 @@
Manifest resource last updated at 12:28:44.86 on 23/11/2014

Binary file not shown.

Binary file not shown.

View File

@ -1 +0,0 @@
<?xml version="1.0" encoding="utf-8"?><VisualStudioUserFile ProjectType="Visual C++" Version="9.00" ShowAllFiles="true"></VisualStudioUserFile>