diff --git a/build/Resources_IT.dll b/build/Resources_IT.dll new file mode 100644 index 0000000..8b9cfc3 --- /dev/null +++ b/build/Resources_IT.dll @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:825e33de765c1346acb699050c248fb7e475c86c89378d55352f745b56e2256f +size 112128 diff --git a/build/Resources_RU.dll b/build/Resources_RU.dll index adbda6a..9382396 100644 --- a/build/Resources_RU.dll +++ b/build/Resources_RU.dll @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:36821f95e5eac34a48bccb62115ffdf4b1ff5f6bde33f90e220c709fa4be086a +oid sha256:f2673e4533d1eeb79eb96ba29f360d844b64b06cdf3000271441a9f6b026d7e5 size 114176 diff --git a/build/dxwnd.0.ini b/build/dxwnd.0.ini index b09eb5f..62664c1 100644 --- a/build/dxwnd.0.ini +++ b/build/dxwnd.0.ini @@ -4,6 +4,11 @@ posy=50 sizx=320 sizy=200 lang=automatic +[texture] +MinTexX=16 +MaxTexX=0 +MinTexY=16 +MaxTexY=0 [keymapping] timetoggle=0x72 altf4=0x73 diff --git a/build/dxwnd.dll b/build/dxwnd.dll index 39fbedc..638ec08 100644 --- a/build/dxwnd.dll +++ b/build/dxwnd.dll @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:59e618b7d0672f738eebd3958be555bdbcfa2da9f34681a37df8cc6258bad250 -size 524288 +oid sha256:ea2c1cd561a930d2b22057633659850296da519f6d1b7859ed94fa69f3c07795 +size 525824 diff --git a/build/dxwnd.exe b/build/dxwnd.exe index d4feaee..31bca86 100644 --- a/build/dxwnd.exe +++ b/build/dxwnd.exe @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:8512c89fbd6ea22a4efd33008c987208f2483763e568bc9ce0c8e9ce211b9b0a +oid sha256:9cbd160962bb3334a41daaa0ab1869ba7726faa7c5590649000cfb8409be83c8 size 532992 diff --git a/build/dxwnd.ini b/build/dxwnd.ini index b09eb5f..62664c1 100644 --- a/build/dxwnd.ini +++ b/build/dxwnd.ini @@ -4,6 +4,11 @@ posy=50 sizx=320 sizy=200 lang=automatic +[texture] +MinTexX=16 +MaxTexX=0 +MinTexY=16 +MaxTexY=0 [keymapping] timetoggle=0x72 altf4=0x73 diff --git a/build/readme-relnotes.txt b/build/readme-relnotes.txt index 0eb71ce..e587dab 100644 --- a/build/readme-relnotes.txt +++ b/build/readme-relnotes.txt @@ -659,3 +659,14 @@ fix: AERO optimized mode with ddraw7 only surfaces: "Hoyle Casino Empire" works 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. +v2.3.02 +fix: when creating an IID_IDirectDrawGammaControl object through lpdds->QueryInterface redirect fake primary surface to real one to make the object working. Fixes "Might & Magic 7" +fix: fixed logging of ddraw Set/GetGammaRamp methods. Added SUPPRESSDXERRORS error suppression +add: texture extraction parameters (min & max x,y size) in dxwnd.ini config file +add: texture extraction / hack made in DxWnd install folder, to allow usage also for games running from unwritable (CDRom) directory +fix: in "prevent maximize" mode, set the main window in maximized state. Allow "Hoyle Casino Empire" to continue after the intro movie is terminated +add: Process kill command now warns you about existence of task +fix: DxWnd window position save now works on multiscreen desktop + + + diff --git a/dll/ddraw.cpp b/dll/ddraw.cpp index f983209..adfe639 100644 --- a/dll/ddraw.cpp +++ b/dll/ddraw.cpp @@ -1851,6 +1851,9 @@ HRESULT WINAPI extQueryInterfaceS(void *lpdds, REFIID riid, LPVOID *obp) return(0); } + // fix the target for gamma ramp creation: if it is a primary surface, use the real one!! + if(dxw.IsAPrimarySurface((LPDIRECTDRAWSURFACE)lpdds) && IsGammaRamp) lpdds = lpDDSEmu_Prim; + res = (*pQueryInterfaceS)(lpdds, riid, obp); if(res) // added trace @@ -3743,8 +3746,15 @@ HRESULT WINAPI extLock(LPDIRECTDRAWSURFACE lpdds, LPRECT lprect, LPDDSURFACEDESC OutTraceB("Lock: lPitch=%d lpSurface=%x\n", lpDDSurfaceDesc->lPitch, lpDDSurfaceDesc->lpSurface); if(dxw.dwFlags1 & SUPPRESSDXERRORS) res=DD_OK; - // shouldn't happen.... if hooked to non primary surface, just call regular method. - // it happens in "Deadlock 2" backbuffer surface!!! + // Pitch fix: some video cards require alignement to a wide boundary, e.g. 128 bytes. + // on "Risk II" (Microprose version) you get a 800x600 generic surface that has a wider + // pitch (1664 bytes, that is the smaller 128 multiple of 800 * 2) that should be treated + // as if it were a smaller one (1600 = 800 * 2) to get a good blit. + // both fixes below are working (one is commented out). + if(dxw.dwFlags1 & EMULATESURFACE) + lpDDSurfaceDesc->lPitch = (lpDDSurfaceDesc->dwWidth * lpDDSurfaceDesc->ddpfPixelFormat.dwRGBBitCount) >> 3; + //lpDDSurfaceDesc->lPitch = (lpDDSurfaceDesc->lPitch / lpDDSurfaceDesc->dwWidth) * lpDDSurfaceDesc->dwWidth; + return res; } @@ -4848,19 +4858,41 @@ HRESULT WINAPI extDDGetGammaRamp(LPDIRECTDRAWSURFACE lpdds, DWORD dwFlags, LPDDG { HRESULT ret; OutTraceDDRAW("GetGammaRamp: dds=%x dwFlags=%x\n", lpdds, dwFlags); + + if(dxw.IsAPrimarySurface(lpdds)) lpdds=lpDDSEmu_Prim; + ret=(*pDDGetGammaRamp)(lpdds, dwFlags, lpgr); - if(ret) OutTraceE("GetGammaRamp: ERROR res=%x(%s)\n", ret, ExplainDDError(ret)); - else OutTraceDDRAW("GetGammaRamp: RGB=(%x,%x,%x)\n", lpgr->red, lpgr->green, lpgr->blue); + if(ret) { + OutTraceE("GetGammaRamp: ERROR res=%x(%s)\n", ret, ExplainDDError(ret)); + if(dxw.dwFlags1 & SUPPRESSDXERRORS) { + // clear the error code, and provide a reasonable gamma ramp array + for(int i=0; i<256; i++) lpgr->red[i]=lpgr->green[i]=lpgr->blue[i]=(i * 0x100); + ret=0; + } + } + else{ + if(IsDebug){ + OutTrace("GetGammaRamp: RGB="); + for(int i=0; i<256; i++) OutTrace("(%x,%x,%x)", lpgr->red[i], lpgr->green[i], lpgr->blue[i]); + OutTrace("\n"); + } + } return ret; } HRESULT WINAPI extDDSetGammaRamp(LPDIRECTDRAWSURFACE lpdds, DWORD dwFlags, LPDDGAMMARAMP lpgr) { HRESULT ret; - OutTraceDDRAW("SetGammaRamp: dds=%x dwFlags=%x RGB=(%x,%x,%x)\n", lpdds, dwFlags, lpgr->red, lpgr->green, lpgr->blue); + OutTraceDDRAW("SetGammaRamp: dds=%x dwFlags=%x\n", lpdds, dwFlags); + if(IsDebug){ + OutTrace("GetGammaRamp: RGB="); + for(int i=0; i<256; i++) OutTrace("(%x,%x,%x)", lpgr->red[i], lpgr->green[i], lpgr->blue[i]); + OutTrace("\n"); + } if (dxw.dwFlags2 & DISABLEGAMMARAMP) return DD_OK; ret=(*pDDSetGammaRamp)(lpdds, dwFlags, lpgr); if(ret) OutTraceE("SetGammaRamp: ERROR res=%x(%s)\n", ret, ExplainDDError(ret)); + if(dxw.dwFlags1 & SUPPRESSDXERRORS) ret = DD_OK; return ret; } diff --git a/dll/dxwnd.vs2008.suo b/dll/dxwnd.vs2008.suo index 95e9705..be3dbd5 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 deleted file mode 100644 index facf31e..0000000 --- a/dll/dxwnd.vs2008.vcproj.User-PC.User.user +++ /dev/null @@ -1,65 +0,0 @@ - - - - - - - - - - - diff --git a/dll/texv4handle.cpp b/dll/texv4handle.cpp index bffd8a9..4e1ed94 100644 --- a/dll/texv4handle.cpp +++ b/dll/texv4handle.cpp @@ -21,6 +21,26 @@ extern int Set_dwSize_From_Surface(LPDIRECTDRAWSURFACE); #define GRIDSIZE 16 +char *GetDxWndPath() +{ + static BOOL DoOnce = TRUE; + static char sFolderPath[MAX_PATH]; + + if(DoOnce){ // first time through, build the texture dir if not done yet + DWORD dwAttrib; + dwAttrib = GetFileAttributes("dxwnd.dll"); + if (dwAttrib != INVALID_FILE_ATTRIBUTES && !(dwAttrib & FILE_ATTRIBUTE_DIRECTORY)) { + MessageBox(0, "DXWND: ERROR can't locate itself", "ERROR", MB_OK | MB_ICONEXCLAMATION); + exit(0); + } + GetModuleFileName(GetModuleHandle("dxwnd"), sFolderPath, MAX_PATH); + sFolderPath[strlen(sFolderPath)-strlen("dxwnd.dll")] = 0; // terminate the string just before "dxwnd.dll" + DoOnce = FALSE; + } + + return sFolderPath; +} + /* RS Hash Function */ static unsigned int Hash(BYTE *buf, int len) @@ -128,10 +148,17 @@ static void TextureDump(LPDIRECTDRAWSURFACE s) DDSURFACEDESC2 ddsd; int w, h, iSurfaceSize, iScanLineSize; HRESULT res; + static int MinTexX, MinTexY, MaxTexX, MaxTexY; static BOOL DoOnce = TRUE; - if(DoOnce){ // first time through, build the texture dir if not done yet - CreateDirectory("texture.out", NULL); + if(DoOnce){ + char sProfilePath[MAX_PATH]; + sprintf(sProfilePath, "%s\\dxwnd.ini", GetDxWndPath()); + MinTexX=GetPrivateProfileInt("Texture", "MinTexX", 0, sProfilePath); + MaxTexX=GetPrivateProfileInt("Texture", "MaxTexX", 0, sProfilePath); + MinTexY=GetPrivateProfileInt("Texture", "MinTexY", 0, sProfilePath); + MaxTexY=GetPrivateProfileInt("Texture", "MaxTexY", 0, sProfilePath); + OutTrace("TextureDump: size min=(%dx%d) max=(%dx%d)\n", MinTexX, MinTexY, MaxTexX, MaxTexY); DoOnce = FALSE; } @@ -149,10 +176,18 @@ static void TextureDump(LPDIRECTDRAWSURFACE s) s, ddsd.ddpfPixelFormat.dwRGBBitCount, ddsd.dwWidth, ddsd.dwHeight); w = ddsd.dwWidth; h = ddsd.dwHeight; - if((w<2) && (h<2)) { + if((MinTexX && (wMaxTexX)) || (MaxTexY && (h>MaxTexY))) { + OutTrace("TextureDump: SKIP big texture\n"); + break; + } + if(ddsd.ddpfPixelFormat.dwRGBBitCount == 0) { + OutTrace("TextureDump: SKIP 0BPP texture\n"); + break; + } iSurfaceSize = ddsd.dwHeight * ddsd.lPitch; @@ -161,7 +196,7 @@ static void TextureDump(LPDIRECTDRAWSURFACE s) BITMAPFILEHEADER hdr; // bitmap file-header BITMAPV4HEADER pbi; // bitmap info-header //DWORD dwTmp; - char pszFile[81]; + char pszFile[MAX_PATH]; //pbih = (PBITMAPINFOHEADER)&pbi; memset((void *)&pbi, 0, sizeof(BITMAPV4HEADER)); @@ -194,7 +229,7 @@ static void TextureDump(LPDIRECTDRAWSURFACE s) } // Create the .BMP file. - sprintf_s(pszFile, 80, "texture.out/texture.%03d.%03d.%08X.bmp", ddsd.dwWidth, ddsd.dwHeight, hash); + sprintf_s(pszFile, 80, "%s\\texture.out\\texture.%03d.%03d.%08X.bmp", GetDxWndPath(), ddsd.dwWidth, ddsd.dwHeight, hash); hf = fopen(pszFile, "wb"); if(!hf) break; @@ -267,7 +302,7 @@ static void TextureHack(LPDIRECTDRAWSURFACE s) if(!hash) break; // almost certainly, an empty black surface! // Look for the .BMP file. - sprintf_s(pszFile, 80, "texture.in/texture.%03d.%03d.%08X.bmp", ddsd.dwWidth, ddsd.dwHeight, hash); + sprintf_s(pszFile, 80, "%s\\texture.in\\texture.%03d.%03d.%08X.bmp", GetDxWndPath(), ddsd.dwWidth, ddsd.dwHeight, hash); hf = fopen(pszFile, "rb"); if(!hf) break; // no updated texture to load diff --git a/dll/user32.cpp b/dll/user32.cpp index 46141d7..62c1bb4 100644 --- a/dll/user32.cpp +++ b/dll/user32.cpp @@ -547,6 +547,7 @@ BOOL WINAPI extShowWindow(HWND hwnd, int nCmdShow) } res=(*pShowWindow)(hwnd, nCmdShow); + OutTraceDW("ShowWindow: res=%x\n", res); return res; } @@ -1403,6 +1404,13 @@ static HWND WINAPI extCreateWindowCommon( if ((FIXCHILDSIZE) && (dwStyle & (WS_CHILD|WS_DLGFRAME))) WinDBPutSize(hwnd, iOrigW, iOrigH); + // "Hoyle Casino Empire" needs to be in a maximized state to continue after the intro movie. + // Sending a SW_MAXIMIZE message intercepted by the PREVENTMAXIMIZE handling fixes the problem. + if (dxw.IsFullScreen() && (dxw.dwFlags1 & PREVENTMAXIMIZE)){ + OutTraceDW("%s: entering maximized state\n", ApiName); + (*pShowWindow)(hwnd, SW_MAXIMIZE); + } + OutTraceDW("%s: ret=%x\n", ApiName, hwnd); return hwnd; } @@ -2045,7 +2053,7 @@ HDC WINAPI extEMUBeginPaint(HWND hwnd, LPPAINTSTRUCT lpPaint) HDC hdc; HDC EmuHDC; - OutTraceDW("GDI.BeginPaint: hwnd=%x lpPaint=%x FullScreen=%x\n", hwnd, lpPaint, dxw.IsFullScreen()); + OutTraceDW("GDI.BeginPaint(GDIEMULATEDC): hwnd=%x lpPaint=%x FullScreen=%x\n", hwnd, lpPaint, dxw.IsFullScreen()); hdc=(*pBeginPaint)(hwnd, lpPaint); // avoid access to real desktop @@ -2059,7 +2067,7 @@ HDC WINAPI extEMUBeginPaint(HWND hwnd, LPPAINTSTRUCT lpPaint) EmuHDC = dxw.AcquireEmulatedDC(hwnd); lpPaint->hdc=EmuHDC; - OutTraceDW("GDI.BeginPaint: hdc=%x -> %x\n", hdc, EmuHDC); + OutTraceDW("GDI.BeginPaint(GDIEMULATEDC): hdc=%x -> %x\n", hdc, EmuHDC); return EmuHDC; } @@ -2129,12 +2137,15 @@ BOOL WINAPI extEMUEndPaint(HWND hwnd, const PAINTSTRUCT *lpPaint) OutTraceDW("GDI.EndPaint: hwnd=%x lpPaint=%x lpPaint.hdc=%x\n", hwnd, lpPaint, lpPaint->hdc); if(dxw.IsFullScreen()){ + // avoid access to real desktop + if(dxw.IsRealDesktop(hwnd)) hwnd=dxw.GethWnd(); OutTraceDW("GDI.EndPaint(GDIEMULATEDC): hwnd=%x\n", hwnd); ret=dxw.ReleaseEmulatedDC(hwnd); } - else + else{ // proxy part ... ret=(*pEndPaint)(hwnd, lpPaint); + } OutTraceDW("GDI.EndPaint: hwnd=%x ret=%x\n", hwnd, ret); if(!ret) OutTraceE("GDI.EndPaint ERROR: err=%d at %d\n", GetLastError(), __LINE__); return ret; diff --git a/host/KillProc.cpp b/host/KillProc.cpp index d864119..dc6399e 100644 --- a/host/KillProc.cpp +++ b/host/KillProc.cpp @@ -7,7 +7,7 @@ #include #include -int KillProcByName(char *szToTerminate) +int KillProcByName(char *szToTerminate, BOOL bKill) // Created: 6/23/2000 (RK) // Last modified: 3/10/2002 (RK) // Please report any problems or bugs to kochhar@physiology.wisc.edu @@ -151,6 +151,12 @@ int KillProcByName(char *szToTerminate) { // Process found, now terminate it iFound=1; + + if(!bKill) { + FreeLibrary(hInstLib); + return 0; // just tell you found it. + } + // First open for termination hProc=OpenProcess(PROCESS_TERMINATE,FALSE,aiPID[i]); if(hProc) @@ -259,6 +265,15 @@ int KillProcByName(char *szToTerminate) { // Process found, now terminate it iFound=1; + + if(!bKill) { + // process terminated + CloseHandle(hSnapShotm); + CloseHandle(hSnapShot); + FreeLibrary(hInstLib); + return 0; // just tell you found it. + } + // First open for termination hProc=OpenProcess(PROCESS_TERMINATE,FALSE,procentry.th32ProcessID); if(hProc) diff --git a/host/MainFrm.cpp b/host/MainFrm.cpp index bae5892..99a50ad 100644 --- a/host/MainFrm.cpp +++ b/host/MainFrm.cpp @@ -31,6 +31,8 @@ along with this program. If not, see . static char THIS_FILE[] = __FILE__; #endif +#define MULTIMONITOR TRUE + ///////////////////////////////////////////////////////////////////////////// // CMainFrame @@ -108,7 +110,7 @@ int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs) { char InitPath[MAX_PATH]; - RECT DesktopRect; + int iMaxX, iMaxY; GetCurrentDirectory(MAX_PATH, InitPath); strcat_s(InitPath, sizeof(InitPath), "\\dxwnd.ini"); cs.x = GetPrivateProfileInt("window", "posx", 50, InitPath); @@ -116,15 +118,22 @@ BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs) cs.cx = GetPrivateProfileInt("window", "sizx", 320, InitPath); cs.cy = GetPrivateProfileInt("window", "sizy", 200, InitPath); - // keep window inside desktop boundaries +#ifdef MULTIMONITOR + iMaxX = ::GetSystemMetrics(SM_CXVIRTUALSCREEN); + iMaxY = ::GetSystemMetrics(SM_CYVIRTUALSCREEN); +#else + RECT DesktopRect; ::GetWindowRect(::GetDesktopWindow(), &DesktopRect); + iMaxX = DesktopRect.right; + iMaxY = DesktopRect.bottom; +#endif if(cs.cx < 320) cs.cx = 320; if(cs.cy < 200) cs.cy = 200; - if(cs.x < DesktopRect.left) cs.x = DesktopRect.left; - if(cs.y < DesktopRect.top) cs.y = DesktopRect.top; - if(cs.x+cs.cx > DesktopRect.right) cs.x = DesktopRect.right - cs.cx; - if(cs.y+cs.cy > DesktopRect.bottom) cs.y = DesktopRect.bottom - cs.cy; + if(cs.x < 0) cs.x = 0; + if(cs.y < 0) cs.y = 0; + if(cs.x+cs.cx > iMaxX) cs.x = iMaxX - cs.cx; + if(cs.y+cs.cy > iMaxY) cs.y = iMaxY - cs.cy; if( !CFrameWnd::PreCreateWindow(cs) ) return FALSE; diff --git a/host/dxwndhost.vs2008.suo b/host/dxwndhost.vs2008.suo index 16410ff..fa08ca2 100644 Binary files a/host/dxwndhost.vs2008.suo and b/host/dxwndhost.vs2008.suo differ diff --git a/host/dxwndhostView.cpp b/host/dxwndhostView.cpp index 97a15f0..8ca11e7 100644 --- a/host/dxwndhostView.cpp +++ b/host/dxwndhostView.cpp @@ -28,7 +28,7 @@ extern UINT m_StartToTray; extern UINT m_InitialState; extern char m_ConfigFileName[20+1]; extern BOOL Inject(DWORD, const char *); -extern int KillProcByName(char *); +extern int KillProcByName(char *, BOOL); PRIVATEMAP *pTitles; // global ptr: get rid of it!! TARGETMAP *pTargets; // idem. @@ -1243,16 +1243,20 @@ void CDxwndhostView::OnProcessKill() pos = listctrl.GetFirstSelectedItemPosition(); i = listctrl.GetNextSelectedItem(pos); - wchar_t *wcstring = new wchar_t[48+1]; - mbstowcs_s(NULL, wcstring, 48, TitleMaps[i].title, _TRUNCATE); - res=MessageBoxLangArg(DXW_STRING_KILLTASK, DXW_STRING_WARNING, MB_YESNO | MB_ICONQUESTION, wcstring); - if(res!=IDYES) return; - strncpy(FilePath,TargetMaps[i].path,MAX_PATH); lpProcName=FilePath; while (lpNext=strchr(lpProcName,'\\')) lpProcName=lpNext+1; - KillProcByName(lpProcName); + if(!KillProcByName(lpProcName, FALSE)){ + wchar_t *wcstring = new wchar_t[48+1]; + mbstowcs_s(NULL, wcstring, 48, TitleMaps[i].title, _TRUNCATE); + res=MessageBoxLangArg(DXW_STRING_KILLTASK, DXW_STRING_WARNING, MB_YESNO | MB_ICONQUESTION, wcstring); + if(res!=IDYES) return; + KillProcByName(lpProcName, TRUE); + } + else{ + MessageBoxLang(DXW_STRING_NOKILLTASK, DXW_STRING_INFO, MB_ICONEXCLAMATION); + } ClipCursor(NULL); RevertScreenChanges(&this->InitDevMode); diff --git a/host/resource - Copia b/host/resource - Copia deleted file mode 100644 index c9dff84..0000000 Binary files a/host/resource - Copia and /dev/null differ diff --git a/host/resource - Copia (2) b/host/resource - Copia (2) deleted file mode 100644 index c1e94d6..0000000 Binary files a/host/resource - Copia (2) and /dev/null differ diff --git a/host/resource.xxx b/host/resource.xxx deleted file mode 100644 index c9dff84..0000000 Binary files a/host/resource.xxx and /dev/null differ diff --git a/locale/it/Resources_IT.rc b/locale/it/Resources_IT.rc index 8ecbd4f..7b09628 100644 Binary files a/locale/it/Resources_IT.rc and b/locale/it/Resources_IT.rc differ diff --git a/locale/ru/Resources_RU.rc b/locale/ru/Resources_RU.rc index 8ed97c1..322ecc8 100644 Binary files a/locale/ru/Resources_RU.rc and b/locale/ru/Resources_RU.rc differ