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

v2_03_02_src

Former-commit-id: 3761b000afb06eab3fdce96c73b86c5cac40d3f9
This commit is contained in:
gho tik 2014-04-12 12:40:05 -04:00 committed by Refael ACkermann
parent 9b385bb3ec
commit 1f79c0ab09
21 changed files with 162 additions and 97 deletions

3
build/Resources_IT.dll Normal file
View File

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

View File

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

View File

@ -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

View File

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

View File

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:8512c89fbd6ea22a4efd33008c987208f2483763e568bc9ce0c8e9ce211b9b0a
oid sha256:9cbd160962bb3334a41daaa0ab1869ba7726faa7c5590649000cfb8409be83c8
size 532992

View File

@ -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

View File

@ -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

View File

@ -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;
}

Binary file not shown.

View File

@ -1,65 +0,0 @@
<?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

@ -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 && (w<MinTexX)) || (MinTexY && (h<MinTexY))) {
OutTrace("TextureDump: SKIP small texture\n");
break;
}
if((MaxTexX && (w>MaxTexX)) || (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

View File

@ -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;

View File

@ -7,7 +7,7 @@
#include <windows.h>
#include <tlhelp32.h>
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)

View File

@ -31,6 +31,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
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;

Binary file not shown.

View File

@ -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);

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.