diff --git a/build/Resources_CN.dll b/build/Resources_CN.dll new file mode 100644 index 0000000..aec1a83 --- /dev/null +++ b/build/Resources_CN.dll @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7bebe395edfd439cfe09e4875e481f37506e0a980a3c589958dd9781c7dc4e65 +size 105472 diff --git a/build/Resources_EN.dll b/build/Resources_EN.dll new file mode 100644 index 0000000..e87acca --- /dev/null +++ b/build/Resources_EN.dll @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:0612ced9b9f9b7805a31213cba47f847cc10eb0d6a95e2d47adff97484edf5f5 +size 89600 diff --git a/build/Resources_RU.dll b/build/Resources_RU.dll new file mode 100644 index 0000000..adbda6a --- /dev/null +++ b/build/Resources_RU.dll @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:36821f95e5eac34a48bccb62115ffdf4b1ff5f6bde33f90e220c709fa4be086a +size 114176 diff --git a/build/dxwnd.dll b/build/dxwnd.dll index 366d0fa..39fbedc 100644 --- a/build/dxwnd.dll +++ b/build/dxwnd.dll @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:9824b03ee7247489a9910c7407a1ac7ff990854e60fdfcb46311763dc75a5df8 -size 525312 +oid sha256:59e618b7d0672f738eebd3958be555bdbcfa2da9f34681a37df8cc6258bad250 +size 524288 diff --git a/build/exports/Breath of Fire IV.dxw b/build/exports/Breath of Fire IV.dxw new file mode 100644 index 0000000..ef8dcb8 --- /dev/null +++ b/build/exports/Breath of Fire IV.dxw @@ -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 diff --git a/build/exports/Typing of the Dead, the.dxw b/build/exports/Typing of the Dead, the.dxw new file mode 100644 index 0000000..8cdcf03 --- /dev/null +++ b/build/exports/Typing of the Dead, the.dxw @@ -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 diff --git a/build/exports/dxwnd.ini b/build/exports/dxwnd.ini index 49efe1f..4e7b98e 100644 --- a/build/exports/dxwnd.ini +++ b/build/exports/dxwnd.ini @@ -1,5 +1,5 @@ [window] -posx=1122 -posy=297 -sizx=365 -sizy=298 +posx=1392 +posy=53 +sizx=320 +sizy=841 diff --git a/build/filter.dll b/build/filter.dll new file mode 100644 index 0000000..41f9d5a --- /dev/null +++ b/build/filter.dll @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d364d53ff922e8381c306d23d51c3a93a0512325824e5e0513c424e9372f9b4c +size 13312 diff --git a/build/mp.dll b/build/mp.dll deleted file mode 100644 index 528e5f5..0000000 --- a/build/mp.dll +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:df0d752747c863568c9965f6c437e91e3e21594695a9665dee285def0d20d6fe -size 16384 diff --git a/build/readme-relnotes.txt b/build/readme-relnotes.txt index c3a2fe2..0eb71ce 100644 --- a/build/readme-relnotes.txt +++ b/build/readme-relnotes.txt @@ -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. + diff --git a/dll/ddraw.cpp b/dll/ddraw.cpp index c822a94..f983209 100644 --- a/dll/ddraw.cpp +++ b/dll/ddraw.cpp @@ -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){ diff --git a/dll/dxhelper.cpp b/dll/dxhelper.cpp index 91c1d90..fe54348 100644 --- a/dll/dxhelper.cpp +++ b/dll/dxhelper.cpp @@ -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+"); diff --git a/dll/dxwnd.cpp b/dll/dxwnd.cpp index 91d1160..10c7778 100644 --- a/dll/dxwnd.cpp +++ b/dll/dxwnd.cpp @@ -24,7 +24,7 @@ along with this program. If not, see . #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 diff --git a/dll/dxwnd.vs2008.suo b/dll/dxwnd.vs2008.suo index 8dcc06a..95e9705 100644 Binary files a/dll/dxwnd.vs2008.suo and b/dll/dxwnd.vs2008.suo differ diff --git a/dll/dxwnd.vs2008.vcproj.User-PC.User.user b/dll/dxwnd.vs2008.vcproj.User-PC.User.user new file mode 100644 index 0000000..facf31e --- /dev/null +++ b/dll/dxwnd.vs2008.vcproj.User-PC.User.user @@ -0,0 +1,65 @@ + + + + + + + + + + + diff --git a/dll/hd3d7.cpp b/dll/hd3d7.cpp index 5a94159..8fa743c 100644 --- a/dll/hd3d7.cpp +++ b/dll/hd3d7.cpp @@ -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){ diff --git a/dll/texv4handle.cpp b/dll/texv4handle.cpp index 2e8284f..bffd8a9 100644 --- a/dll/texv4handle.cpp +++ b/dll/texv4handle.cpp @@ -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; } } diff --git a/mp/bilinear16_555.cpp b/filter/bilinear16_555.cpp similarity index 100% rename from mp/bilinear16_555.cpp rename to filter/bilinear16_555.cpp diff --git a/mp/bilinear16_565.cpp b/filter/bilinear16_565.cpp similarity index 100% rename from mp/bilinear16_565.cpp rename to filter/bilinear16_565.cpp diff --git a/mp/bilinear32.cpp b/filter/bilinear32.cpp similarity index 100% rename from mp/bilinear32.cpp rename to filter/bilinear32.cpp diff --git a/mp/mp.def b/filter/filter.def similarity index 83% rename from mp/mp.def rename to filter/filter.def index f1cd989..ad1ddd1 100644 --- a/mp/mp.def +++ b/filter/filter.def @@ -1,4 +1,4 @@ -LIBRARY mp +LIBRARY filter EXPORTS Resize_HQ_4ch @1 Resize_HQ_2ch565 @2 diff --git a/mp/mp.sln b/filter/filter.sln similarity index 85% rename from mp/mp.sln rename to filter/filter.sln index 3c2c4d2..2c0c570 100644 --- a/mp/mp.sln +++ b/filter/filter.sln @@ -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 diff --git a/filter/filter.suo b/filter/filter.suo new file mode 100644 index 0000000..f8e3a3c Binary files /dev/null and b/filter/filter.suo differ diff --git a/mp/mp.vcproj b/filter/filter.vcproj similarity index 86% rename from mp/mp.vcproj rename to filter/filter.vcproj index ef9aa5a..036a7d0 100644 --- a/mp/mp.vcproj +++ b/filter/filter.vcproj @@ -2,9 +2,9 @@ @@ -39,16 +39,18 @@ /> diff --git a/mp/mp.suo b/filter/mp.suo similarity index 70% rename from mp/mp.suo rename to filter/mp.suo index b37c43d..29341e5 100644 Binary files a/mp/mp.suo and b/filter/mp.suo differ diff --git a/locale/cn/Resources_Cn.rc b/locale/cn/Resources_Cn.rc index 9a86a9f..3e2d46d 100644 Binary files a/locale/cn/Resources_Cn.rc and b/locale/cn/Resources_Cn.rc differ diff --git a/locale/cn/Resources_Cn.suo b/locale/cn/Resources_Cn.suo index b0f99b8..3231b3d 100644 Binary files a/locale/cn/Resources_Cn.suo and b/locale/cn/Resources_Cn.suo differ diff --git a/locale/en/Resources_EN.rc b/locale/en/Resources_EN.rc index 1a713bb..52ac7d8 100644 Binary files a/locale/en/Resources_EN.rc and b/locale/en/Resources_EN.rc differ diff --git a/locale/en/Resources_En.suo b/locale/en/Resources_En.suo index 4b60a88..aeadd08 100644 Binary files a/locale/en/Resources_En.suo and b/locale/en/Resources_En.suo differ diff --git a/locale/ru/Resources_RU.rc b/locale/ru/Resources_RU.rc index 14fc747..8ed97c1 100644 Binary files a/locale/ru/Resources_RU.rc and b/locale/ru/Resources_RU.rc differ diff --git a/locale/ru/Resources_Ru.suo b/locale/ru/Resources_Ru.suo index a658ad4..1f912f4 100644 Binary files a/locale/ru/Resources_Ru.suo and b/locale/ru/Resources_Ru.suo differ diff --git a/mp/Release/BuildLog.htm b/mp/Release/BuildLog.htm deleted file mode 100644 index bf53ed7..0000000 Binary files a/mp/Release/BuildLog.htm and /dev/null differ diff --git a/mp/Release/bilinear16_555.obj b/mp/Release/bilinear16_555.obj deleted file mode 100644 index f830298..0000000 Binary files a/mp/Release/bilinear16_555.obj and /dev/null differ diff --git a/mp/Release/bilinear16_565.obj b/mp/Release/bilinear16_565.obj deleted file mode 100644 index 2d23de8..0000000 Binary files a/mp/Release/bilinear16_565.obj and /dev/null differ diff --git a/mp/Release/bilinear32.obj b/mp/Release/bilinear32.obj deleted file mode 100644 index f8cfb5f..0000000 Binary files a/mp/Release/bilinear32.obj and /dev/null differ diff --git a/mp/Release/mp.dll.embed.manifest b/mp/Release/mp.dll.embed.manifest deleted file mode 100644 index bfec505..0000000 --- a/mp/Release/mp.dll.embed.manifest +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/mp/Release/mp.dll.embed.manifest.res b/mp/Release/mp.dll.embed.manifest.res deleted file mode 100644 index 03f5c96..0000000 Binary files a/mp/Release/mp.dll.embed.manifest.res and /dev/null differ diff --git a/mp/Release/mp.dll.intermediate.manifest b/mp/Release/mp.dll.intermediate.manifest deleted file mode 100644 index 7256947..0000000 --- a/mp/Release/mp.dll.intermediate.manifest +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - - - - - - - diff --git a/mp/Release/mt.dep b/mp/Release/mt.dep deleted file mode 100644 index a39d202..0000000 --- a/mp/Release/mt.dep +++ /dev/null @@ -1 +0,0 @@ -Manifest resource last updated at 12:28:44.86 on 23/11/2014 diff --git a/mp/Release/vc90.idb b/mp/Release/vc90.idb deleted file mode 100644 index 6b486a5..0000000 Binary files a/mp/Release/vc90.idb and /dev/null differ diff --git a/mp/Release/vc90.pdb b/mp/Release/vc90.pdb deleted file mode 100644 index 281774d..0000000 Binary files a/mp/Release/vc90.pdb and /dev/null differ diff --git a/mp/mp.vcproj.user b/mp/mp.vcproj.user deleted file mode 100644 index 0ce2ced..0000000 --- a/mp/mp.vcproj.user +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file