mirror of
https://github.com/DxWnd/DxWnd.reloaded
synced 2024-12-30 09:25:35 +01:00
v2_02_19_src
Former-commit-id: 3808bbe5af8b015d87647397a1b618985d6bb309
This commit is contained in:
parent
061a3d0f34
commit
24d116b534
@ -79,6 +79,7 @@
|
||||
|
||||
// third flags DWORD dxw.dwFlags3:
|
||||
#define FORCEHOOKOPENGL 0x00000001 // loads OpenGL32.dll and hooks it
|
||||
#define MARKBLIT 0x00000002 // higlights the blit to primary surface operation by surroundig the rect in color
|
||||
|
||||
// logging Tflags DWORD:
|
||||
#define OUTTRACE 0x00000001 // enables tracing to dxwnd.log in general
|
||||
|
@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:4254ded87b12758c82865086e3af480673f216886af7b44d71477cc06be75705
|
||||
size 311296
|
||||
oid sha256:2d27bd94b95b7ca824b05b37e72626d7250273d4c55512eac260ea59ed8cb2cb
|
||||
size 314880
|
||||
|
@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:c299cf7d537a05c2aefa8e169e5b25abe44450db15171d2bf9a0f66dbb976df0
|
||||
size 501760
|
||||
oid sha256:c518035d2eea78a680be7ee136ab574ad087f8f346f923be2e43b1ba9fa5b3ee
|
||||
size 502272
|
||||
|
4657
build/dxwnd.ini
4657
build/dxwnd.ini
File diff suppressed because it is too large
Load Diff
@ -97,3 +97,21 @@ D3D hooking: Added Wireframe option for D3D games
|
||||
Added hooking of CLSID_DxDiagProvider through CoCreateInstance
|
||||
Fixed (further simplified) clipping handling of primary/backbuffer surfaces
|
||||
ChangeDisplaySettings hook: fixed x,y coordinate inversion in log message
|
||||
|
||||
v2.02.19
|
||||
Saves GUI coordinates
|
||||
Fixed "Remap client rect" option for Diablo's windows and Premier Manager 98 mouse movements
|
||||
Added "Highlight blit to primary" option to draw a yellow bounding box around blits to primary surface
|
||||
Fixed some exception conditions when closing the programs
|
||||
Fixed CreateSurface handling to allow Premier Manager 98 start in emulated mode
|
||||
Fixed ONEPIXELFIX handling
|
||||
Fixed BIG WIN handling for Diablo's windows
|
||||
Fixed FillRect hook to prevent filling outside virtual desktop
|
||||
Disabled hooking of system libraries
|
||||
Fixed a nasty bug that caused your desktop to freeze until shutdown !!!
|
||||
Fixed GetWindowRect handling for windows not created by the task: Diablo queries the explorer window size! Now the retrieved RECT can't be larger than the virtual desktop
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -21,6 +21,8 @@ extern int Set_dwSize_From_Surface(LPDIRECTDRAWSURFACE);
|
||||
#define SwitchdwSize(s) s.dwSize=(s.dwSize==sizeof(DDSURFACEDESC))?sizeof(DDSURFACEDESC2):sizeof(DDSURFACEDESC)
|
||||
|
||||
#define DXWNDDIRECTBLITTING 1
|
||||
#define MARKBLITCOLOR32 0x00FFFF00
|
||||
#define MARKBLITCOLOR16 0x0FF0
|
||||
extern Blt_Type pBlt;
|
||||
EmuBlt_Type pEmuBlt;
|
||||
RevBlt_Type pRevBlt;
|
||||
@ -29,12 +31,44 @@ RevBlt_Type pRevBlt;
|
||||
// Emulated blitting procedures: fills a 32BPP surface from the content of 8BPP or 16BPP ones.
|
||||
//--------------------------------------------------------------------------------------------//
|
||||
|
||||
static void MarkRect32(DWORD *dest, int w, int h, int destpitch)
|
||||
{
|
||||
int x, y;
|
||||
|
||||
for(x = 0; x < w; x ++) *(dest ++) = MARKBLITCOLOR32;
|
||||
dest += destpitch;
|
||||
for(y = 0; y < h-2; y ++){
|
||||
*dest = MARKBLITCOLOR32;
|
||||
dest += w-1;
|
||||
*dest = MARKBLITCOLOR32;
|
||||
dest += destpitch + 1;
|
||||
}
|
||||
for(x = 0; x < w; x ++) *(dest ++) = MARKBLITCOLOR32;
|
||||
return;
|
||||
}
|
||||
|
||||
static void MarkRect16(SHORT *dest, int w, int h, int destpitch)
|
||||
{
|
||||
int x, y;
|
||||
|
||||
for(x = 0; x < w; x ++) *(dest ++) = MARKBLITCOLOR16;
|
||||
dest += destpitch;
|
||||
for(y = 0; y < h-2; y ++){
|
||||
*dest = MARKBLITCOLOR16;
|
||||
dest += w-1;
|
||||
*dest = MARKBLITCOLOR16;
|
||||
dest += destpitch + 1;
|
||||
}
|
||||
for(x = 0; x < w; x ++) *(dest ++) = MARKBLITCOLOR16;
|
||||
return;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI EmuBlt_8_to_32(LPDIRECTDRAWSURFACE lpddsdst, LPRECT lpdestrect,
|
||||
LPDIRECTDRAWSURFACE lpddssrc, LPRECT lpsrcrect, DWORD dwflags, LPVOID lpsurface)
|
||||
{
|
||||
HRESULT res;
|
||||
BYTE *src8;
|
||||
DWORD *dest;
|
||||
DWORD *dest, *dest0;
|
||||
DDSURFACEDESC2 ddsd_src, ddsd_dst;
|
||||
long srcpitch, destpitch;
|
||||
DWORD x, y, w, h;
|
||||
@ -75,6 +109,7 @@ static HRESULT WINAPI EmuBlt_8_to_32(LPDIRECTDRAWSURFACE lpddsdst, LPRECT lpdest
|
||||
dest += lpdestrect->top*ddsd_dst.lPitch;
|
||||
dest += lpdestrect->left;
|
||||
destpitch = ddsd_dst.lPitch - w;
|
||||
dest0 = dest;
|
||||
|
||||
src8 = (BYTE *)lpsurface;
|
||||
src8 += lpsrcrect->top*ddsd_src.lPitch;
|
||||
@ -90,6 +125,8 @@ static HRESULT WINAPI EmuBlt_8_to_32(LPDIRECTDRAWSURFACE lpddsdst, LPRECT lpdest
|
||||
src8 += srcpitch;
|
||||
}
|
||||
|
||||
if(dxw.dwFlags3 & MARKBLIT) MarkRect32(dest0, w, h, destpitch);
|
||||
|
||||
res=(*pUnlockMethod(lpddsdst))(lpddsdst, lpdestrect);
|
||||
if (res) OutTraceE("EmuBlt8_32: Unlock ERROR dds=%x res=%x(%s) at %d\n", lpddsdst, res, ExplainDDError(res), __LINE__);
|
||||
res=(*pUnlockMethod(lpddssrc))(lpddssrc, lpsrcrect);
|
||||
@ -103,7 +140,7 @@ static HRESULT WINAPI EmuBlt_16_to_32(LPDIRECTDRAWSURFACE lpddsdst, LPRECT lpdes
|
||||
{
|
||||
HRESULT res;
|
||||
WORD *src16;
|
||||
DWORD *dest;
|
||||
DWORD *dest, *dest0;
|
||||
DDSURFACEDESC2 ddsd_src, ddsd_dst;
|
||||
long srcpitch, destpitch;
|
||||
DWORD x, y, w, h;
|
||||
@ -144,6 +181,7 @@ static HRESULT WINAPI EmuBlt_16_to_32(LPDIRECTDRAWSURFACE lpddsdst, LPRECT lpdes
|
||||
dest += lpdestrect->top*ddsd_dst.lPitch;
|
||||
dest += lpdestrect->left;
|
||||
destpitch = ddsd_dst.lPitch - w;
|
||||
dest0 = dest;
|
||||
|
||||
ddsd_src.lPitch >>= 1;
|
||||
src16 = (WORD *)(lpsurface ? lpsurface:ddsd_src.lpSurface);
|
||||
@ -187,6 +225,8 @@ static HRESULT WINAPI EmuBlt_16_to_32(LPDIRECTDRAWSURFACE lpddsdst, LPRECT lpdes
|
||||
src16 += srcpitch;
|
||||
}
|
||||
|
||||
if(dxw.dwFlags3 & MARKBLIT) MarkRect32(dest0, w, h, destpitch);
|
||||
|
||||
res=(*pUnlockMethod(lpddsdst))(lpddsdst, lpdestrect);
|
||||
if (res) OutTraceE("EmuBlt16_32: Unlock ERROR dds=%x res=%x(%s) at %d\n", lpddsdst, res, ExplainDDError(res), __LINE__);
|
||||
res=(*pUnlockMethod(lpddssrc))(lpddssrc, lpsrcrect);
|
||||
@ -199,7 +239,7 @@ static HRESULT WINAPI EmuBlt_24_to_32(LPDIRECTDRAWSURFACE lpddsdst, LPRECT lpdes
|
||||
{
|
||||
HRESULT res;
|
||||
BYTE *src24;
|
||||
DWORD *dest;
|
||||
DWORD *dest, *dest0;
|
||||
DDSURFACEDESC2 ddsd_src, ddsd_dst;
|
||||
long srcpitch, destpitch;
|
||||
DWORD x, y, w, h;
|
||||
@ -240,6 +280,7 @@ static HRESULT WINAPI EmuBlt_24_to_32(LPDIRECTDRAWSURFACE lpddsdst, LPRECT lpdes
|
||||
dest += lpdestrect->top*ddsd_dst.lPitch;
|
||||
dest += lpdestrect->left;
|
||||
destpitch = ddsd_dst.lPitch - w;
|
||||
dest0 = dest;
|
||||
|
||||
src24 = (BYTE *)lpsurface;
|
||||
src24 += lpsrcrect->top*ddsd_src.lPitch;
|
||||
@ -258,6 +299,8 @@ static HRESULT WINAPI EmuBlt_24_to_32(LPDIRECTDRAWSURFACE lpddsdst, LPRECT lpdes
|
||||
src24 += srcpitch;
|
||||
}
|
||||
|
||||
if(dxw.dwFlags3 & MARKBLIT) MarkRect32(dest0, w, h, destpitch);
|
||||
|
||||
res=(*pUnlockMethod(lpddsdst))(lpddsdst, lpdestrect);
|
||||
if (res) OutTraceE("EmuBlt24_32: Unlock ERROR dds=%x res=%x(%s) at %d\n", lpddsdst, res, ExplainDDError(res), __LINE__);
|
||||
res=(*pUnlockMethod(lpddssrc))(lpddssrc, lpsrcrect);
|
||||
@ -276,7 +319,7 @@ static HRESULT WINAPI EmuBlt_32_to_32(LPDIRECTDRAWSURFACE lpddsdst, LPRECT lpdes
|
||||
long srcpitch, destpitch;
|
||||
HRESULT res;
|
||||
DWORD *src32;
|
||||
DWORD *dest;
|
||||
DWORD *dest, dest0;
|
||||
DDSURFACEDESC2 ddsd_src, ddsd_dst;
|
||||
|
||||
w = lpdestrect->right - lpdestrect->left;
|
||||
@ -315,6 +358,7 @@ static HRESULT WINAPI EmuBlt_32_to_32(LPDIRECTDRAWSURFACE lpddsdst, LPRECT lpdes
|
||||
dest += lpdestrect->top*ddsd_dst.lPitch;
|
||||
dest += lpdestrect->left;
|
||||
destpitch = ddsd_dst.lPitch - w;
|
||||
dest0 = dest;
|
||||
|
||||
ddsd_src.lPitch >>= 2;
|
||||
src32 = (DWORD *)(lpsurface ? lpsurface:ddsd_src.lpSurface);
|
||||
@ -330,6 +374,8 @@ static HRESULT WINAPI EmuBlt_32_to_32(LPDIRECTDRAWSURFACE lpddsdst, LPRECT lpdes
|
||||
src32 += srcpitch;
|
||||
}
|
||||
|
||||
if(dxw.dwFlags3 & MARKBLIT) MarkRect32(dest0, w, h, destpitch);
|
||||
|
||||
res=(*pUnlockMethod(lpddsdst))(lpddsdst,lpdestrect);
|
||||
if (res) OutTraceE("EmuBlt32_32: Unlock ERROR dds=%x res=%x(%s) at %d\n", lpddsdst, res, ExplainDDError(res), __LINE__);
|
||||
res=(*pUnlockMethod(lpddssrc))(lpddssrc, lpsrcrect);
|
||||
@ -343,7 +389,7 @@ static HRESULT WINAPI EmuBlt_8_to_16(LPDIRECTDRAWSURFACE lpddsdst, LPRECT lpdest
|
||||
{
|
||||
HRESULT res;
|
||||
BYTE *src8;
|
||||
SHORT *dest;
|
||||
SHORT *dest, *dest0;
|
||||
DDSURFACEDESC2 ddsd_src, ddsd_dst;
|
||||
long srcpitch, destpitch;
|
||||
DWORD x, y, w, h;
|
||||
@ -384,6 +430,7 @@ static HRESULT WINAPI EmuBlt_8_to_16(LPDIRECTDRAWSURFACE lpddsdst, LPRECT lpdest
|
||||
dest += lpdestrect->top*ddsd_dst.lPitch;
|
||||
dest += lpdestrect->left;
|
||||
destpitch = ddsd_dst.lPitch - w;
|
||||
dest0 = dest;
|
||||
|
||||
src8 = (BYTE *)lpsurface;
|
||||
src8 += lpsrcrect->top*ddsd_src.lPitch;
|
||||
@ -393,15 +440,14 @@ static HRESULT WINAPI EmuBlt_8_to_16(LPDIRECTDRAWSURFACE lpddsdst, LPRECT lpdest
|
||||
// OutTraceD("DEBUG: h=%d w=%d src=%x dst=%x spitch=%d dpitch=%d\n",h,w,src8,dest,srcpitch,destpitch);
|
||||
for(y = 0; y < h; y ++){
|
||||
for(x = 0; x < w; x ++){
|
||||
//DWORD pixel;
|
||||
//pixel = PaletteEntries[*(src8 ++)];
|
||||
//*(dest ++) = ((pixel&0x0000FF)>>3) | ((pixel&0x00FF00)>>7) | ((pixel&0xFF0000)>>19);
|
||||
*(dest ++) = (SHORT)PaletteEntries[*(src8 ++)];
|
||||
}
|
||||
dest += destpitch;
|
||||
src8 += srcpitch;
|
||||
}
|
||||
|
||||
if(dxw.dwFlags3 & MARKBLIT) MarkRect16(dest0, w, h, destpitch);
|
||||
|
||||
res=(*pUnlockMethod(lpddsdst))(lpddsdst, lpdestrect);
|
||||
if (res) OutTraceE("EmuBlt8_16: Unlock ERROR dds=%x res=%x(%s) at %d\n", lpddsdst, res, ExplainDDError(res), __LINE__);
|
||||
res=(*pUnlockMethod(lpddssrc))(lpddssrc, lpsrcrect);
|
||||
@ -426,7 +472,7 @@ static HRESULT WINAPI EmuBlt_24_to_16(LPDIRECTDRAWSURFACE lpddsdst, LPRECT lpdes
|
||||
{
|
||||
HRESULT res;
|
||||
BYTE *src24;
|
||||
SHORT *dest;
|
||||
SHORT *dest, *dest0;
|
||||
DDSURFACEDESC2 ddsd_src, ddsd_dst;
|
||||
long srcpitch, destpitch;
|
||||
DWORD x, y, w, h;
|
||||
@ -467,6 +513,7 @@ static HRESULT WINAPI EmuBlt_24_to_16(LPDIRECTDRAWSURFACE lpddsdst, LPRECT lpdes
|
||||
dest += lpdestrect->top*ddsd_dst.lPitch;
|
||||
dest += lpdestrect->left;
|
||||
destpitch = ddsd_dst.lPitch - w;
|
||||
dest0 = dest;
|
||||
|
||||
src24 = (BYTE *)lpsurface;
|
||||
src24 += lpsrcrect->top*ddsd_src.lPitch;
|
||||
@ -482,6 +529,8 @@ static HRESULT WINAPI EmuBlt_24_to_16(LPDIRECTDRAWSURFACE lpddsdst, LPRECT lpdes
|
||||
src24 += srcpitch;
|
||||
}
|
||||
|
||||
if(dxw.dwFlags3 & MARKBLIT) MarkRect16(dest0, w, h, destpitch);
|
||||
|
||||
res=(*pUnlockMethod(lpddsdst))(lpddsdst, lpdestrect);
|
||||
if (res) OutTraceE("EmuBlt24_16: Unlock ERROR dds=%x res=%x(%s) at %d\n", lpddsdst, res, ExplainDDError(res), __LINE__);
|
||||
res=(*pUnlockMethod(lpddssrc))(lpddssrc, lpsrcrect);
|
||||
|
@ -727,8 +727,8 @@ LRESULT CALLBACK extWindowProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lp
|
||||
lparam = MAKELPARAM(curr.x, curr.y);
|
||||
OutTraceC("WindowProc: hwnd=%x pos XY=(%d,%d)->(%d,%d)\n", hwnd, prev.x, prev.y, curr.x, curr.y);
|
||||
}
|
||||
GetHookInfo()->CursorX=(short)curr.x;
|
||||
GetHookInfo()->CursorY=(short)curr.y;
|
||||
GetHookInfo()->CursorX=LOWORD(lparam);
|
||||
GetHookInfo()->CursorY=HIWORD(lparam);
|
||||
break;
|
||||
// fall through cases:
|
||||
case WM_MOUSEWHEEL:
|
||||
@ -750,8 +750,8 @@ LRESULT CALLBACK extWindowProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lp
|
||||
lparam = MAKELPARAM(curr.x, curr.y);
|
||||
OutTraceC("WindowProc: hwnd=%x pos XY=(%d,%d)->(%d,%d)\n", hwnd, prev.x, prev.y, curr.x, curr.y);
|
||||
}
|
||||
GetHookInfo()->CursorX=(short)curr.x;
|
||||
GetHookInfo()->CursorY=(short)curr.y;
|
||||
GetHookInfo()->CursorX=LOWORD(lparam);
|
||||
GetHookInfo()->CursorY=HIWORD(lparam);
|
||||
break;
|
||||
case WM_SETFOCUS:
|
||||
if (dxw.dwFlags1 & ENABLECLIPPING) extClipCursor(lpClipRegion);
|
||||
@ -1279,6 +1279,7 @@ int HookInit(TARGETMAP *target, HWND hwnd)
|
||||
WINDOWPOS wp;
|
||||
HMODULE base;
|
||||
char *sModule;
|
||||
char sModuleBuf[60+1];
|
||||
static char *dxversions[14]={
|
||||
"Automatic", "DirectX1~6", "", "", "", "", "",
|
||||
"DirectX7", "DirectX8", "DirectX9", "DirectX10", "DirectX11", "None", ""
|
||||
@ -1291,8 +1292,8 @@ int HookInit(TARGETMAP *target, HWND hwnd)
|
||||
dxw.hParentWnd=GetParent(hwnd);
|
||||
dxw.hChildWnd=hwnd;
|
||||
|
||||
OutTraceD("HookInit: path=\"%s\" module=\"%s\" dxversion=%s hWnd=%x dxw.hParentWnd=%x\n",
|
||||
target->path, target->module, dxversions[dxw.dwTargetDDVersion], hwnd, dxw.hParentWnd);
|
||||
OutTraceD("HookInit: path=\"%s\" module=\"%s\" dxversion=%s hWnd=%x dxw.hParentWnd=%x desktop=%x\n",
|
||||
target->path, target->module, dxversions[dxw.dwTargetDDVersion], hwnd, dxw.hParentWnd, GetDesktopWindow());
|
||||
if (IsDebug){
|
||||
DWORD dwStyle, dwExStyle;
|
||||
dwStyle=GetWindowLong(dxw.GethWnd(), GWL_STYLE);
|
||||
@ -1327,17 +1328,19 @@ int HookInit(TARGETMAP *target, HWND hwnd)
|
||||
// extern BOOL ListProcessModules(BOOL);
|
||||
// ListProcessModules(true);
|
||||
//}
|
||||
sModule=strtok(dxw.gsModules," ");
|
||||
strncpy(sModuleBuf, dxw.gsModules, 60);
|
||||
sModule=strtok(sModuleBuf," ;");
|
||||
while (sModule) {
|
||||
base=(*pLoadLibraryA)(sModule);
|
||||
if(!base){
|
||||
OutTraceE("HookInit: LoadLibrary ERROR module=%s err=%d\n", sModule, GetLastError());
|
||||
continue;
|
||||
}
|
||||
OutTraceD("HookInit: hooking additional module=%s base=%x\n", sModule, base);
|
||||
if (dxw.dwTFlags & OUTIMPORTTABLE) DumpImportTable(base);
|
||||
HookModule(base, dxw.dwTargetDDVersion);
|
||||
sModule=strtok(NULL," ");
|
||||
else {
|
||||
OutTraceD("HookInit: hooking additional module=%s base=%x\n", sModule, base);
|
||||
if (dxw.dwTFlags & OUTIMPORTTABLE) DumpImportTable(base);
|
||||
HookModule(base, dxw.dwTargetDDVersion);
|
||||
}
|
||||
sModule=strtok(NULL," ;");
|
||||
}
|
||||
|
||||
|
||||
|
147
dll/dxwcore.cpp
147
dll/dxwcore.cpp
@ -141,6 +141,17 @@ RECT dxwCore::GetScreenRect()
|
||||
return Screen;
|
||||
}
|
||||
|
||||
BOOL dxwCore::IsDesktop(HWND hwnd)
|
||||
{
|
||||
return (
|
||||
(hwnd == 0)
|
||||
||
|
||||
(hwnd == (*pGetDesktopWindow)())
|
||||
||
|
||||
(hwnd == hWnd)
|
||||
);
|
||||
}
|
||||
|
||||
// v2.1.93: FixCursorPos completely revised to introduce a clipping tolerance in
|
||||
// clipping regions as well as in normal operations
|
||||
|
||||
@ -264,14 +275,6 @@ void dxwCore::EraseClipCursor()
|
||||
(*pClipCursor)(NULL);
|
||||
}
|
||||
|
||||
// MapWindow Rect: returns a rectangle in the real coordinate system from the virtual coordinates
|
||||
// of an emulated fullscreen window. NULL or void returns the rectangle of the whole client area.
|
||||
|
||||
RECT dxwCore::MapWindowRect(void)
|
||||
{
|
||||
return MapWindowRect(NULL);
|
||||
}
|
||||
|
||||
RECT dxwCore::MapWindowRect(LPRECT lpRect)
|
||||
{
|
||||
POINT UpLeft={0,0};
|
||||
@ -298,7 +301,17 @@ RECT dxwCore::MapWindowRect(LPRECT lpRect)
|
||||
return RetRect;
|
||||
}
|
||||
|
||||
void dxwCore::MapRect(int *nXDest, int *nYDest, int *nWDest, int *nHDest)
|
||||
void dxwCore::MapClient(LPRECT rect)
|
||||
{
|
||||
RECT client;
|
||||
(*pGetClientRect)(hWnd, &client);
|
||||
rect->left= rect->left * client.right / dwScreenWidth;
|
||||
rect->top= rect->top * client.bottom / dwScreenHeight;
|
||||
rect->right= rect->right * client.right / dwScreenWidth;
|
||||
rect->bottom= rect->bottom * client.bottom / dwScreenHeight;
|
||||
}
|
||||
|
||||
void dxwCore::MapClient(int *nXDest, int *nYDest, int *nWDest, int *nHDest)
|
||||
{
|
||||
RECT client;
|
||||
(*pGetClientRect)(hWnd, &client);
|
||||
@ -308,7 +321,7 @@ void dxwCore::MapRect(int *nXDest, int *nYDest, int *nWDest, int *nHDest)
|
||||
*nHDest= *nHDest * client.bottom / dwScreenHeight;
|
||||
}
|
||||
|
||||
void dxwCore::MapPoint(LPPOINT lppoint)
|
||||
void dxwCore::MapClient(LPPOINT lppoint)
|
||||
{
|
||||
RECT client;
|
||||
(*pGetClientRect)(hWnd, &client);
|
||||
@ -316,12 +329,109 @@ void dxwCore::MapPoint(LPPOINT lppoint)
|
||||
lppoint->y = (lppoint->y * client.bottom) / dwScreenHeight;
|
||||
}
|
||||
|
||||
void dxwCore::UnmapPoint(LPPOINT lppoint)
|
||||
void dxwCore::MapWindow(LPRECT rect)
|
||||
{
|
||||
RECT client;
|
||||
POINT upleft = {0,0};
|
||||
(*pGetClientRect)(hWnd, &client);
|
||||
if (client.right) lppoint->x = (lppoint->x * dwScreenWidth) / client.right;
|
||||
if (client.bottom) lppoint->y = (lppoint->y * dwScreenHeight) / client.bottom;
|
||||
(*pClientToScreen)(hWnd, &upleft);
|
||||
rect->left= upleft.x + ((rect->left * client.right) / dwScreenWidth);
|
||||
rect->top= upleft.y + ((rect->top * client.bottom) / dwScreenHeight);
|
||||
rect->right= upleft.x + ((rect->right * client.right) / dwScreenWidth);
|
||||
rect->bottom= upleft.y + ((rect->bottom * client.bottom) / dwScreenHeight);
|
||||
}
|
||||
|
||||
void dxwCore::MapWindow(int *nXDest, int *nYDest, int *nWDest, int *nHDest)
|
||||
{
|
||||
RECT client;
|
||||
POINT upleft = {0,0};
|
||||
(*pGetClientRect)(hWnd, &client);
|
||||
(*pClientToScreen)(hWnd, &upleft);
|
||||
*nXDest= upleft.x + ((*nXDest * client.right) / dwScreenWidth);
|
||||
*nYDest= upleft.y + ((*nYDest * client.bottom) / dwScreenHeight);
|
||||
*nWDest= (*nWDest * client.right) / dwScreenWidth;
|
||||
*nHDest= (*nHDest * client.bottom) / dwScreenHeight;
|
||||
}
|
||||
|
||||
void dxwCore::MapWindow(LPPOINT lppoint)
|
||||
{
|
||||
RECT client;
|
||||
POINT upleft = {0,0};
|
||||
(*pGetClientRect)(hWnd, &client);
|
||||
(*pClientToScreen)(hWnd, &upleft);
|
||||
lppoint->x = upleft.x + ((lppoint->x * client.right) / dwScreenWidth);
|
||||
lppoint->y = upleft.y + ((lppoint->y * client.bottom) / dwScreenHeight);
|
||||
}
|
||||
|
||||
POINT dxwCore::ClientOffset(HWND hwnd)
|
||||
{
|
||||
RECT desktop;
|
||||
POINT upleft, win0, desk0, ret;
|
||||
ret.x = ret.y = 0;
|
||||
|
||||
(*pGetClientRect)(hWnd,&desktop);
|
||||
if(!desktop.right || !desktop.bottom) return ret;
|
||||
|
||||
upleft.x = upleft.y = 0;
|
||||
(*pClientToScreen)(hwnd, &upleft);
|
||||
win0 = upleft;
|
||||
upleft.x = upleft.y = 0;
|
||||
(*pClientToScreen)(hWnd, &upleft);
|
||||
desk0 = upleft;
|
||||
if (desktop.right) ret.x = ((win0.x - desk0.x) * (LONG)dwScreenWidth) / desktop.right;
|
||||
if (desktop.bottom) ret.y = ((win0.y - desk0.y) * (LONG)dwScreenHeight) / desktop.bottom;
|
||||
OutTraceB("ClientOffset: hwnd=%x offset=(%d,%d)\n", hwnd, ret.x, ret.y);
|
||||
return ret;
|
||||
}
|
||||
|
||||
RECT dxwCore::GetWindowRect(RECT win)
|
||||
{
|
||||
RECT desktop;
|
||||
POINT desk0;
|
||||
desk0.x = desk0.y = 0;
|
||||
|
||||
(*pGetClientRect)(hWnd, &desktop);
|
||||
(*pClientToScreen)(hWnd,&desk0);
|
||||
|
||||
if(!desktop.right || !desktop.bottom) return win;
|
||||
|
||||
win.left = ((win.left - desk0.x) * (LONG)dwScreenWidth) / desktop.right;
|
||||
win.top = ((win.top - desk0.y) * (LONG)dwScreenHeight) / desktop.bottom;
|
||||
win.right = ((win.right - desk0.x) * (LONG)dwScreenWidth) / desktop.right;
|
||||
win.bottom = ((win.bottom - desk0.y) * (LONG)dwScreenWidth) / desktop.right;
|
||||
|
||||
return win;
|
||||
}
|
||||
|
||||
RECT dxwCore::GetClientRect(RECT win)
|
||||
{
|
||||
RECT desktop;
|
||||
(*pGetClientRect)(hWnd, &desktop);
|
||||
|
||||
if(!desktop.right || !desktop.bottom) return win;
|
||||
|
||||
win.left = (win.left * dwScreenWidth) / desktop.right;
|
||||
win.top = (win.top * dwScreenHeight) / desktop.bottom;
|
||||
win.right = (win.right * dwScreenWidth) / desktop.right;
|
||||
win.bottom = (win.bottom * dwScreenHeight) / desktop.bottom;
|
||||
|
||||
return win;
|
||||
}
|
||||
|
||||
POINT dxwCore::AddCoordinates(POINT p1, POINT p2)
|
||||
{
|
||||
POINT ps;
|
||||
ps.x = p1.x + p2.x;
|
||||
ps.y = p1.y + p2.y;
|
||||
return ps;
|
||||
}
|
||||
|
||||
POINT dxwCore::SubCoordinates(POINT p1, POINT p2)
|
||||
{
|
||||
POINT ps;
|
||||
ps.x = p1.x - p2.x;
|
||||
ps.y = p1.y - p2.y;
|
||||
return ps;
|
||||
}
|
||||
|
||||
void dxwCore::ScreenRefresh(void)
|
||||
@ -331,7 +441,6 @@ void dxwCore::ScreenRefresh(void)
|
||||
#define DXWREFRESHINTERVAL 20
|
||||
|
||||
LPDIRECTDRAWSURFACE lpDDSPrim;
|
||||
// extern LPDIRECTDRAWSURFACE GetPrimarySurface();
|
||||
extern HRESULT WINAPI extBlt(LPDIRECTDRAWSURFACE lpdds, LPRECT lpdestrect, LPDIRECTDRAWSURFACE lpddssrc, LPRECT lpsrcrect, DWORD dwflags, LPDDBLTFX lpddbltfx);
|
||||
|
||||
static int t = -1;
|
||||
@ -376,7 +485,7 @@ static void CountFPS(HWND hwnd)
|
||||
DWORD tmp;
|
||||
tmp = (*pGetTickCount)();
|
||||
if((tmp - time) > 1000) {
|
||||
char sBuf[80+12+1]; // title + fps string + terminator
|
||||
char sBuf[80+15+1]; // title + fps string + terminator
|
||||
char *fpss;
|
||||
// log fps count
|
||||
OutTrace("FPS: Delta=%x FPSCount=%d\n", (tmp-time), FPSCount);
|
||||
@ -387,7 +496,7 @@ static void CountFPS(HWND hwnd)
|
||||
GetWindowText(hwnd, sBuf, 80);
|
||||
fpss=strstr(sBuf," ~ (");
|
||||
if(fpss==NULL) fpss=&sBuf[strlen(sBuf)];
|
||||
sprintf(fpss, " ~ (%d FPS)", FPSCount);
|
||||
sprintf_s(fpss, 15, " ~ (%d FPS)", FPSCount);
|
||||
SetWindowText(hwnd, sBuf);
|
||||
}
|
||||
// reset
|
||||
@ -396,7 +505,7 @@ static void CountFPS(HWND hwnd)
|
||||
}
|
||||
else {
|
||||
FPSCount++;
|
||||
OutTrace("FPS: Delta=%x FPSCount++=%d\n", (tmp-time), FPSCount);
|
||||
OutTraceB("FPS: Delta=%x FPSCount++=%d\n", (tmp-time), FPSCount);
|
||||
}
|
||||
}
|
||||
|
||||
@ -573,7 +682,7 @@ void dxwCore::ShowFPS(HDC xdc)
|
||||
SetTextColor(xdc,color);
|
||||
//SetBkMode(xdc, TRANSPARENT);
|
||||
SetBkMode(xdc, OPAQUE);
|
||||
sprintf(sBuf, "FPS: %d", GetHookInfo()->FPSCount);
|
||||
sprintf_s(sBuf, 80, "FPS: %d", GetHookInfo()->FPSCount);
|
||||
TextOut(xdc, x, y, sBuf, strlen(sBuf));
|
||||
}
|
||||
|
||||
@ -602,7 +711,7 @@ void dxwCore::ShowFPS(LPDIRECTDRAWSURFACE lpdds)
|
||||
SetTextColor(xdc,color);
|
||||
//SetBkMode(xdc, TRANSPARENT);
|
||||
SetBkMode(xdc, OPAQUE);
|
||||
sprintf(sBuf, "FPS: %d", GetHookInfo()->FPSCount);
|
||||
sprintf_s(sBuf, 80, "FPS: %d", GetHookInfo()->FPSCount);
|
||||
TextOut(xdc, x, y, sBuf, strlen(sBuf));
|
||||
lpdds->ReleaseDC(xdc);
|
||||
}
|
||||
|
@ -20,10 +20,9 @@ public: // methods
|
||||
void SetScreenSize(int x, int y) {if(x)dwScreenWidth=x; if(y)dwScreenHeight=y;}
|
||||
DWORD GetScreenWidth(void) {return dwScreenWidth;}
|
||||
DWORD GetScreenHeight(void) {return dwScreenHeight;}
|
||||
RECT GetScreenRect(void);
|
||||
void MapRect(int *, int *, int *, int *);
|
||||
void SetFullScreen(BOOL fs) {FullScreen=fs;}
|
||||
BOOL IsFullScreen() {return FullScreen;}
|
||||
BOOL IsDesktop(HWND);
|
||||
POINT FixCursorPos(POINT);
|
||||
POINT FixCursorPos(HWND, POINT);
|
||||
void FixNCHITCursorPos(LPPOINT);
|
||||
@ -31,8 +30,18 @@ public: // methods
|
||||
void EraseClipCursor(void);
|
||||
RECT MapWindowRect(LPRECT lpRect);
|
||||
RECT MapWindowRect(void);
|
||||
void MapPoint(LPPOINT);
|
||||
void UnmapPoint(LPPOINT);
|
||||
void MapClient(LPPOINT);
|
||||
void MapClient(LPRECT);
|
||||
void MapClient(int *, int *, int *, int *);
|
||||
void MapWindow(LPPOINT);
|
||||
void MapWindow(LPRECT);
|
||||
void MapWindow(int *, int *, int *, int *);
|
||||
RECT GetScreenRect(void);
|
||||
RECT GetWindowRect(RECT);
|
||||
RECT GetClientRect(RECT);
|
||||
POINT AddCoordinates(POINT, POINT);
|
||||
POINT SubCoordinates(POINT, POINT);
|
||||
POINT ClientOffset(HWND);
|
||||
void ScreenRefresh(void);
|
||||
BOOL HandleFPS(void);
|
||||
DWORD GetTickCount(void);
|
||||
|
@ -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.18"
|
||||
#define VERSION "2.02.19"
|
||||
|
||||
LRESULT CALLBACK HookProc(int ncode, WPARAM wparam, LPARAM lparam);
|
||||
|
||||
|
Binary file not shown.
65
dll/dxwnd.vs2008.vcproj.User-PC.User.user
Normal file
65
dll/dxwnd.vs2008.vcproj.User-PC.User.user
Normal 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>
|
@ -361,6 +361,10 @@ HRESULT WINAPI extCreateDevice(void *lpd3d, UINT adapter, D3DDEVTYPE devicetype,
|
||||
param[2] = mode.Format;
|
||||
OutTraceD(" Current Format = 0x%x\n", mode.Format);
|
||||
|
||||
// useless ...
|
||||
//param[0] = 0; //defaulting to window width
|
||||
//param[1] = 0; //defaulting to window height
|
||||
//param[2] = D3DFMT_UNKNOWN; // try
|
||||
|
||||
if(dwD3DVersion == 9){
|
||||
param[7] = 0; //hDeviceWindow
|
||||
|
124
dll/hddraw.cpp
124
dll/hddraw.cpp
@ -671,7 +671,12 @@ int lpddsHookedVersion(LPDIRECTDRAWSURFACE lpdds)
|
||||
char sMsg[81];
|
||||
void * extGetCaps;
|
||||
|
||||
__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;
|
||||
@ -688,7 +693,12 @@ int lpddHookedVersion(LPDIRECTDRAW lpdd)
|
||||
char sMsg[81];
|
||||
void * extCreateSurface;
|
||||
|
||||
__try{
|
||||
extCreateSurface=(void *)*(DWORD *)(*(DWORD *)lpdd + 24);
|
||||
}
|
||||
__except (EXCEPTION_EXECUTE_HANDLER){
|
||||
extCreateSurface=NULL;
|
||||
};
|
||||
if(extCreateSurface==(void *)extCreateSurface1) return 1;
|
||||
if(extCreateSurface==(void *)extCreateSurface2) return 2;
|
||||
if(extCreateSurface==(void *)extCreateSurface4) return 4;
|
||||
@ -1788,7 +1798,7 @@ HRESULT WINAPI extCreateSurfaceEmu(int dxversion, CreateSurface_Type pCreateSurf
|
||||
// some games (Monopoly 3D) may depend on this setting - i.e. they could close
|
||||
// the exceeding references - so this is better be replicated adding an initial
|
||||
// reference to the zero count.
|
||||
lpDDSBack->AddRef(); // should it be repeated BBCount times????
|
||||
if (lpDDSBack) lpDDSBack->AddRef(); // should it be repeated BBCount times????
|
||||
|
||||
// rebuild emulated primary surface
|
||||
|
||||
@ -1847,28 +1857,19 @@ HRESULT WINAPI extCreateSurfaceEmu(int dxversion, CreateSurface_Type pCreateSurf
|
||||
OutTraceD("CreateSurface: created DDSEmu_Prim=%x DDSEmu_Back=%x DDSPrim=%x DDSBack=%x\n",
|
||||
lpDDSEmu_Prim, lpDDSEmu_Back, lpDDSPrim, lpDDSBack);
|
||||
|
||||
// creation of lpDDSHDC service surfae moved to GetDC method
|
||||
// creation of lpDDSHDC service surface moved to GetDC method
|
||||
|
||||
if(dxw.dwFlags1 & CLIPCURSOR) dxw.SetClipCursor();
|
||||
return 0;
|
||||
}
|
||||
|
||||
// not primary emulated surface ....
|
||||
// try begin
|
||||
//if((ddsd.dwFlags && DDSD_CAPS) && (ddsd.ddsCaps.dwCaps && DDSCAPS_ZBUFFER)){
|
||||
// pfmt="untouched";
|
||||
//}
|
||||
//else
|
||||
//end try
|
||||
if(((ddsd.dwFlags & DDSD_WIDTH) && !(ddsd.dwFlags & DDSD_HEIGHT)) ||
|
||||
(ddsd.dwFlags & DDSD_ZBUFFERBITDEPTH) ||
|
||||
//(ddsd.dwFlags & DDSD_PIXELFORMAT) ||
|
||||
((ddsd.dwFlags & DDSD_PIXELFORMAT) && !(ddsd.dwFlags & DDSD_PITCH)) || // fix good for "Wargames"
|
||||
//((ddsd.dwFlags & DDSD_CAPS) && (ddsd.ddsCaps.dwCaps & DDSCAPS_TEXTURE)) ||
|
||||
((ddsd.dwFlags & DDSD_CAPS) && (ddsd.ddsCaps.dwCaps & DDSCAPS_3DDEVICE))){
|
||||
((ddsd.dwFlags & DDSD_PIXELFORMAT) && !(ddsd.dwFlags & DDSD_PITCH) && !(ddsd.ddsCaps.dwCaps & DDSCAPS_3DDEVICE)) || // fix good for "Wargames"
|
||||
((ddsd.dwFlags & DDSD_CAPS) && (ddsd.ddsCaps.dwCaps & DDSCAPS_3DDEVICE) && !(ddsd.dwFlags & DDSD_PIXELFORMAT)) // fix good for Premier Manager 98
|
||||
){
|
||||
// don't alter pixel format
|
||||
//ddsd.dwFlags &= ~DDSD_PIXELFORMAT; // Warhammer Dark Omen
|
||||
ddsd.dwFlags &= ~DDSD_PIXELFORMAT; // Wargames ???
|
||||
ddsd.dwFlags &= ~DDSD_PIXELFORMAT; // Wargames, Warhammer Dark Omen
|
||||
pfmt="(none)";
|
||||
}
|
||||
else {
|
||||
@ -2261,6 +2262,21 @@ static void BlitError(HRESULT res, LPRECT lps, LPRECT lpd, int line)
|
||||
return;
|
||||
}
|
||||
|
||||
static void BlitTrace(char *label, LPRECT lps, LPRECT lpd, int line)
|
||||
{
|
||||
OutTrace("Blt: %s", label);
|
||||
if (lps)
|
||||
OutTrace(" src=(%d,%d)-(%d,%d)",lps->left, lps->top, lps->right, lps->bottom);
|
||||
else
|
||||
OutTrace(" src=(NULL)");
|
||||
if (lpd)
|
||||
OutTrace(" dest=(%d,%d)-(%d,%d)",lpd->left, lpd->top, lpd->right, lpd->bottom);
|
||||
else
|
||||
OutTrace(" dest=(NULL)");
|
||||
OutTrace(" at %d\n", __LINE__);
|
||||
return;
|
||||
}
|
||||
|
||||
HRESULT WINAPI sBlt(char *api, LPDIRECTDRAWSURFACE lpdds, LPRECT lpdestrect,
|
||||
LPDIRECTDRAWSURFACE lpddssrc, LPRECT lpsrcrect, DWORD dwflags, LPDDBLTFX lpddbltfx, BOOL isFlipping)
|
||||
{
|
||||
@ -2299,22 +2315,24 @@ HRESULT WINAPI sBlt(char *api, LPDIRECTDRAWSURFACE lpdds, LPRECT lpdestrect,
|
||||
OutTrace("\n");
|
||||
}
|
||||
|
||||
#define ONEPIXELFIXFlag 1
|
||||
#ifdef ONEPIXELFIX
|
||||
if (lpdestrect){
|
||||
if ((lpdestrect->top == 0) && (lpdestrect->bottom == dxw.GetScreenHeight() -1)) lpdestrect->bottom = dxw.GetScreenHeight();
|
||||
if ((lpdestrect->left == 0) && (lpdestrect->right == dxw.GetScreenWidth() -1)) lpdestrect->right = dxw.GetScreenWidth();
|
||||
}
|
||||
if (lpsrcrect){
|
||||
if ((lpsrcrect->top == 0) && (lpsrcrect->bottom == dxw.GetScreenHeight() -1)) lpsrcrect->bottom = dxw.GetScreenHeight();
|
||||
if ((lpsrcrect->left == 0) && (lpsrcrect->right == dxw.GetScreenWidth() -1)) lpsrcrect->right = dxw.GetScreenWidth();
|
||||
}
|
||||
#endif
|
||||
|
||||
#define FIXBIGGERRECT 1
|
||||
|
||||
if (ONEPIXELFIXFlag){
|
||||
if (lpdestrect){
|
||||
if (lpdestrect->bottom == dxw.GetScreenHeight() -1) lpdestrect->bottom = dxw.GetScreenHeight();
|
||||
if (lpdestrect->right == dxw.GetScreenWidth() -1) lpdestrect->right = dxw.GetScreenWidth();
|
||||
}
|
||||
}
|
||||
|
||||
if(FIXBIGGERRECT){
|
||||
if(ToPrim && lpdestrect){
|
||||
if((DWORD)lpdestrect->bottom > dxw.GetScreenHeight()) lpdestrect->bottom = dxw.GetScreenHeight();
|
||||
if((DWORD)lpdestrect->right > dxw.GetScreenWidth()) lpdestrect->right = dxw.GetScreenWidth();
|
||||
}
|
||||
#ifdef FIXBIGGERRECT
|
||||
if(ToPrim && lpdestrect){
|
||||
if((DWORD)lpdestrect->bottom > dxw.GetScreenHeight()) lpdestrect->bottom = dxw.GetScreenHeight();
|
||||
if((DWORD)lpdestrect->right > dxw.GetScreenWidth()) lpdestrect->right = dxw.GetScreenWidth();
|
||||
}
|
||||
#endif
|
||||
|
||||
if((dxw.dwFlags1 & EMULATESURFACE) && (dwflags==DDBLT_COLORFILL)){
|
||||
OutTraceD("Debug: dwFillDepth=%d, EmuBPP=%d, dwFillColor=%x\n",
|
||||
@ -2370,18 +2388,22 @@ HRESULT WINAPI sBlt(char *api, LPDIRECTDRAWSURFACE lpdds, LPRECT lpdestrect,
|
||||
srcrect=dxw.MapWindowRect(lpsrcrect);
|
||||
}
|
||||
}
|
||||
|
||||
if (IsDebug) BlitTrace("NOPRIM", lpsrcrect, lpdestrect, __LINE__);
|
||||
res= (*pBlt)(lpdds, lpdestrect, lpddssrc, lpsrcrect ? &srcrect : NULL, dwflags, lpddbltfx);
|
||||
// Blitting compressed data may work to screen surfaces only. In this case, it may be worth
|
||||
// trying blitting directly to lpDDSEmu_Prim: it makes DK2 intro movies working.
|
||||
switch(res){
|
||||
case DDERR_UNSUPPORTED:
|
||||
if (dxw.dwFlags1 & EMULATESURFACE){
|
||||
if (IsDebug) BlitTrace("UNSUPP", lpsrcrect ? &srcrect : NULL, lpdestrect, __LINE__);
|
||||
res=(*pBlt)(lpDDSEmu_Prim, lpdestrect, lpddssrc, lpsrcrect ? &srcrect : NULL, dwflags, lpddbltfx);
|
||||
}
|
||||
break;
|
||||
case DDERR_SURFACEBUSY:
|
||||
(*pUnlockMethod(lpdds))(lpdds, NULL);
|
||||
if (lpddssrc) (*pUnlockMethod(lpddssrc))(lpddssrc, NULL);
|
||||
if (lpddssrc) (*pUnlockMethod(lpddssrc))(lpddssrc, NULL);
|
||||
if (IsDebug) BlitTrace("BUSY", lpsrcrect ? &srcrect : NULL, lpdestrect, __LINE__);
|
||||
res=(*pBlt)(lpdds, lpdestrect, lpddssrc, lpsrcrect ? &srcrect : NULL, dwflags|DDBLT_WAIT, lpddbltfx);
|
||||
break;
|
||||
default:
|
||||
@ -2402,8 +2424,7 @@ HRESULT WINAPI sBlt(char *api, LPDIRECTDRAWSURFACE lpdds, LPRECT lpdestrect,
|
||||
res=0;
|
||||
// blit only when source and dest surface are different. Should make ScreenRefresh faster.
|
||||
if (lpdds != lpddssrc) {
|
||||
//OutTrace("DEBUG: lpdds=%x lpddssrc=%x destrect=(%d,%d)-(%d,%d) lpsrcrect=%x flags=%x lpddbltfx=%x\n",
|
||||
// lpdds, lpddssrc, destrect.left, destrect.top, destrect.right, destrect.bottom, lpsrcrect, dwflags, lpddbltfx);
|
||||
if (IsDebug) BlitTrace("PRIM-NOEMU", lpsrcrect, &destrect, __LINE__);
|
||||
res= (*pBlt)(lpdds, &destrect, lpddssrc, lpsrcrect, dwflags, lpddbltfx);
|
||||
}
|
||||
if(res){
|
||||
@ -2411,6 +2432,7 @@ HRESULT WINAPI sBlt(char *api, LPDIRECTDRAWSURFACE lpdds, LPRECT lpdestrect,
|
||||
// Try to handle HDC lock concurrency....
|
||||
if(res==DDERR_SURFACEBUSY){
|
||||
(*pUnlockMethod(lpdds))(lpdds, NULL);
|
||||
if (IsDebug) BlitTrace("BUSY", lpsrcrect, &destrect, __LINE__);
|
||||
res= (*pBlt)(lpdds, &destrect, lpddssrc, lpsrcrect, dwflags, lpddbltfx);
|
||||
if (res) BlitError(res, lpsrcrect, &destrect, __LINE__);
|
||||
}
|
||||
@ -2445,8 +2467,10 @@ HRESULT WINAPI sBlt(char *api, LPDIRECTDRAWSURFACE lpdds, LPRECT lpdestrect,
|
||||
|
||||
res=0;
|
||||
// blit only when source and dest surface are different. Should make ScreenRefresh faster.
|
||||
if (lpdds != lpddssrc)
|
||||
if (lpdds != lpddssrc){
|
||||
if (IsDebug) BlitTrace("SRC2EMU", &emurect, &destrect, __LINE__);
|
||||
res=(*pBlt)(lpdds, &emurect, lpddssrc, lpsrcrect, dwflags, lpddbltfx);
|
||||
}
|
||||
|
||||
if (res) {
|
||||
BlitError(res, lpsrcrect, &emurect, __LINE__);
|
||||
@ -2458,6 +2482,7 @@ HRESULT WINAPI sBlt(char *api, LPDIRECTDRAWSURFACE lpdds, LPRECT lpdestrect,
|
||||
*/
|
||||
if(res==DDERR_UNSUPPORTED){
|
||||
if (dxw.dwFlags2 & SHOWFPSOVERLAY) dxw.ShowFPS(lpddssrc);
|
||||
if (IsDebug) BlitTrace("UNSUPP", &emurect, &destrect, __LINE__);
|
||||
res=(*pBlt)(lpDDSEmu_Prim, &destrect, lpddssrc, lpsrcrect, dwflags, lpddbltfx);
|
||||
if (res) BlitError(res, lpsrcrect, &destrect, __LINE__);
|
||||
}
|
||||
@ -2466,6 +2491,7 @@ HRESULT WINAPI sBlt(char *api, LPDIRECTDRAWSURFACE lpdds, LPRECT lpdestrect,
|
||||
if(res==DDERR_SURFACEBUSY){
|
||||
res=(*pUnlockMethod(lpddssrc))(lpddssrc, NULL);
|
||||
if(res) OutTraceE("Unlock ERROR: err=%x(%s)\n", res, ExplainDDError(res));
|
||||
if (IsDebug) BlitTrace("BUSY", &emurect, &destrect, __LINE__);
|
||||
res=(*pBlt)(lpdds, &emurect, lpddssrc, lpsrcrect, dwflags, lpddbltfx);
|
||||
if (res) BlitError(res, lpsrcrect, &destrect, __LINE__);
|
||||
}
|
||||
@ -2494,14 +2520,17 @@ HRESULT WINAPI sBlt(char *api, LPDIRECTDRAWSURFACE lpdds, LPRECT lpdestrect,
|
||||
}
|
||||
|
||||
if (dxw.dwFlags2 & SHOWFPSOVERLAY) dxw.ShowFPS(lpDDSSource);
|
||||
if (IsDebug) BlitTrace("BACK2PRIM", &emurect, &destrect, __LINE__);
|
||||
res=(*pBlt)(lpDDSEmu_Prim, &destrect, lpDDSSource, &emurect, DDBLT_WAIT, 0);
|
||||
if (res==DDERR_NOCLIPLIST){
|
||||
RenewClipper(lpDD, lpDDSEmu_Prim);
|
||||
if (IsDebug) BlitTrace("NOCLIP", &emurect, &destrect, __LINE__);
|
||||
res=(*pBlt)(lpDDSEmu_Prim, &destrect, lpDDSSource, &emurect, DDBLT_WAIT, 0);
|
||||
}
|
||||
|
||||
if (res) BlitError(res, &emurect, &destrect, __LINE__);
|
||||
if(dxw.dwFlags1 & SUPPRESSDXERRORS) res=0;
|
||||
if (IsDebug) OutTrace("%s: done ret=%x at %d\n", api, res, __LINE__);
|
||||
return res;
|
||||
}
|
||||
|
||||
@ -2739,35 +2768,10 @@ HRESULT WINAPI extSetPalette(LPDIRECTDRAWSURFACE lpdds, LPDIRECTDRAWPALETTE lpdd
|
||||
isPrim=dxw.IsAPrimarySurface(lpdds);
|
||||
OutTraceD("SetPalette: lpdds=%x%s lpddp=%x\n", lpdds, isPrim?"(PRIM)":"", lpddp);
|
||||
|
||||
#if 0
|
||||
if(!(dxw.dwFlags1 & EMULATESURFACE) || !isPrim) {
|
||||
res=(*pSetPalette)(lpdds, lpddp);
|
||||
if(res)OutTraceE("SetPalette: ERROR res=%x(%s) at %d\n", res, ExplainDDError(res), __LINE__);
|
||||
return res;
|
||||
}
|
||||
|
||||
OutTraceD("SetPalette: DEBUG emulating palette\n");
|
||||
lpDDP = lpddp;
|
||||
//if (lpDDSBack) { GHOGHO
|
||||
// res=(*pSetPalette)(lpDDSBack, lpddp);
|
||||
// if(res) OutTraceE("SetPalette: ERROR res=%x(%s) at %d\n", res, ExplainDDError(res), __LINE__);
|
||||
//}
|
||||
// add a reference to simulate what would happen in reality....
|
||||
lpdds->AddRef();
|
||||
|
||||
if(lpddp){
|
||||
lpentries = (LPPALETTEENTRY)PaletteEntries;
|
||||
res=lpddp->GetEntries(0, 0, 256, lpentries);
|
||||
if(res) OutTraceE("SetPalette: GetEntries ERROR res=%x(%s)\n", res, ExplainDDError(res));
|
||||
mySetPalette(0, 256, lpentries);
|
||||
}
|
||||
|
||||
return 0;
|
||||
#else
|
||||
res=(*pSetPalette)(lpdds, lpddp);
|
||||
if(res)OutTraceE("SetPalette: ERROR res=%x(%s) at %d\n", res, ExplainDDError(res), __LINE__);
|
||||
|
||||
if((dxw.dwFlags1 & EMULATESURFACE) && (res==DD_OK)){
|
||||
if(dxw.dwFlags1 & EMULATESURFACE){
|
||||
OutTraceD("SetPalette: DEBUG emulating palette\n");
|
||||
lpDDP = lpddp;
|
||||
|
||||
@ -2778,10 +2782,10 @@ HRESULT WINAPI extSetPalette(LPDIRECTDRAWSURFACE lpdds, LPDIRECTDRAWPALETTE lpdd
|
||||
if(res2) OutTraceE("SetPalette: GetEntries ERROR res=%x(%s)\n", res2, ExplainDDError(res2));
|
||||
mySetPalette(0, 256, lpentries);
|
||||
}
|
||||
res=0;
|
||||
}
|
||||
|
||||
return res;
|
||||
#endif
|
||||
}
|
||||
|
||||
HRESULT WINAPI extSetEntries(LPDIRECTDRAWPALETTE lpddp, DWORD dwflags, DWORD dwstart, DWORD dwcount, LPPALETTEENTRY lpentries)
|
||||
|
175
dll/syslibs.cpp
175
dll/syslibs.cpp
@ -192,6 +192,10 @@ HWND WINAPI extCreateWindowExA(
|
||||
)
|
||||
&&
|
||||
(((DWORD)nWidth>=dxw.GetScreenWidth())&&((DWORD)nHeight>=dxw.GetScreenHeight()))
|
||||
&&
|
||||
!(dwExStyle & WS_EX_CONTROLPARENT) // Diablo fix
|
||||
&&
|
||||
!(dwStyle & WS_CHILD) // Diablo fix
|
||||
){
|
||||
RECT screen;
|
||||
POINT upleft = {0,0};
|
||||
@ -240,32 +244,19 @@ HWND WINAPI extCreateWindowExA(
|
||||
// tested on Gangsters: coordinates must be window-relative!!!
|
||||
// Age of Empires....
|
||||
if (dwStyle & WS_CHILD){
|
||||
RECT screen;
|
||||
(*pGetClientRect)(dxw.GethWnd(),&screen);
|
||||
x=x*screen.right/dxw.GetScreenWidth();
|
||||
y=y*screen.bottom/dxw.GetScreenHeight();
|
||||
nWidth=nWidth*screen.right/dxw.GetScreenWidth();
|
||||
nHeight=nHeight*screen.bottom/dxw.GetScreenHeight();
|
||||
dxw.MapClient(&x, &y, &nWidth, &nHeight);
|
||||
OutTraceD("CreateWindowEx: fixed WS_CHILD pos=(%d,%d) size=(%d,%d)\n",
|
||||
x, y, nWidth, nHeight);
|
||||
}
|
||||
// needed for Diablo, that creates a new control parent window that must be
|
||||
// overlapped to the directdraw surface.
|
||||
else if (dwExStyle & WS_EX_CONTROLPARENT){
|
||||
RECT screen;
|
||||
POINT upleft = {0,0};
|
||||
(*pGetClientRect)(dxw.GethWnd(),&screen);
|
||||
(*pClientToScreen)(dxw.GethWnd(),&upleft);
|
||||
x=upleft.x;
|
||||
y=upleft.y;
|
||||
nWidth=screen.right;
|
||||
nHeight=screen.bottom;
|
||||
OutTraceD("CreateWindowEx: fixed WS_EX_CONTROLPARENT win=(%d,%d)-(%d,%d)\n",
|
||||
x, y, x+nWidth, y+nHeight);
|
||||
dxw.MapWindow(&x, &y, &nWidth, &nHeight);
|
||||
OutTraceD("CreateWindowEx: fixed WS_EX_CONTROLPARENT pos=(%d,%d) size=(%d,%d)\n",
|
||||
x, y, nWidth, nHeight);
|
||||
}
|
||||
|
||||
if(IsDebug)
|
||||
OutTrace("CreateWindowEx: fixed pos=(%d,%d) size=(%d,%d) Style=%x(%s) ExStyle=%x(%s)\n",
|
||||
OutTraceB("CreateWindowEx: fixed pos=(%d,%d) size=(%d,%d) Style=%x(%s) ExStyle=%x(%s)\n",
|
||||
x, y, nWidth, nHeight, dwStyle, ExplainStyle(dwStyle), dwExStyle, ExplainExStyle(dwExStyle));
|
||||
|
||||
wndh= (*pCreateWindowExA)(dwExStyle, lpClassName, lpWindowName, dwStyle, x, y, nWidth, nHeight,
|
||||
@ -281,7 +272,6 @@ HWND WINAPI extCreateWindowExA(
|
||||
extern void AdjustWindowPos(HWND, DWORD, DWORD);
|
||||
(*pSetWindowLong)(wndh, GWL_STYLE, (dxw.dwFlags2 & MODALSTYLE) ? 0 : WS_OVERLAPPEDWINDOW);
|
||||
(*pSetWindowLong)(wndh, GWL_EXSTYLE, 0);
|
||||
//(*pShowWindow)(wndh, SW_SHOWNORMAL);
|
||||
OutTraceD("CreateWindow: hwnd=%x, set style=WS_OVERLAPPEDWINDOW extstyle=0\n", wndh);
|
||||
AdjustWindowPos(wndh, nWidth, nHeight);
|
||||
(*pShowWindow)(wndh, SW_SHOWNORMAL);
|
||||
@ -536,10 +526,26 @@ BOOL WINAPI extRectangle(HDC hdc, int nLeftRect, int nTopRect, int nRightRect, i
|
||||
|
||||
int WINAPI extFillRect(HDC hdc, const RECT *lprc, HBRUSH hbr)
|
||||
{
|
||||
RECT rc;
|
||||
RECT rc, trim;
|
||||
HWND hWnd;
|
||||
OutTraceD("FillRect: hdc=%x xy=(%d,%d)-(%d,%d)\n", hdc, lprc->left, lprc->top, lprc->right, lprc->bottom);
|
||||
memcpy(&rc, lprc, sizeof(rc));
|
||||
hWnd = WindowFromDC(hdc);
|
||||
if((hWnd == dxw.GethWnd()) ||
|
||||
(hWnd == 0) ||
|
||||
(hWnd == GetDesktopWindow())){
|
||||
// trim: some games (Player Manager 98) clear the screen by filling an exagerated rect
|
||||
(*pGetClientRect)(dxw.GethWnd(), &trim);
|
||||
hdc=GetDC(dxw.GethWnd());
|
||||
dxw.MapWindowRect(&rc);
|
||||
if(rc.left < trim.left) rc.left = trim.left;
|
||||
if(rc.top < trim.top) rc.top = trim.top;
|
||||
if(rc.right > trim.right) rc.right = trim.right;
|
||||
if(rc.bottom > trim.bottom) rc.bottom = trim.bottom;
|
||||
OutTraceD("FillRect: hwnd=%x hdc=%x fixed xy=(%d,%d)-(%d,%d)\n", hWnd, hdc, rc.left, rc.top, rc.right, rc.bottom);
|
||||
}
|
||||
if (dxw.dwFlags1 & FIXTEXTOUT) {
|
||||
// to be verified: why shifting and not scaling?
|
||||
POINT anchor;
|
||||
anchor.x=rc.left;
|
||||
anchor.y=rc.top;
|
||||
@ -1274,10 +1280,11 @@ BOOL WINAPI extClientToScreen(HWND hwnd, LPPOINT lppoint)
|
||||
{
|
||||
// v2.02.10: fully revised to handle scaled windows
|
||||
BOOL res;
|
||||
|
||||
OutTraceB("ClientToScreen: hwnd=%x hWnd=%x FullScreen=%x point=(%d,%d)\n",
|
||||
hwnd, dxw.GethWnd(), dxw.IsFullScreen(), lppoint->x, lppoint->y);
|
||||
if (lppoint && dxw.IsFullScreen()){
|
||||
dxw.MapPoint(lppoint);
|
||||
*lppoint = dxw.AddCoordinates(*lppoint, dxw.ClientOffset(hwnd));
|
||||
OutTraceB("ClientToScreen: FIXED point=(%d,%d)\n", lppoint->x, lppoint->y);
|
||||
res=TRUE;
|
||||
}
|
||||
@ -1293,8 +1300,11 @@ BOOL WINAPI extScreenToClient(HWND hwnd, LPPOINT lppoint)
|
||||
BOOL res;
|
||||
OutTraceB("ScreenToClient: hwnd=%x hWnd=%x FullScreen=%x point=(%d,%d)\n",
|
||||
hwnd, dxw.GethWnd(), dxw.IsFullScreen(), lppoint->x, lppoint->y);
|
||||
|
||||
if (lppoint && (lppoint->x == -32000) && (lppoint->y == -32000)) return 1;
|
||||
|
||||
if (lppoint && dxw.IsFullScreen()){
|
||||
dxw.UnmapPoint(lppoint);
|
||||
*lppoint = dxw.SubCoordinates(*lppoint, dxw.ClientOffset(hwnd));
|
||||
OutTraceB("ScreenToClient: FIXED point=(%d,%d)\n", lppoint->x, lppoint->y);
|
||||
res=TRUE;
|
||||
}
|
||||
@ -1307,72 +1317,62 @@ BOOL WINAPI extScreenToClient(HWND hwnd, LPPOINT lppoint)
|
||||
BOOL WINAPI extGetClientRect(HWND hwnd, LPRECT lpRect)
|
||||
{
|
||||
BOOL ret;
|
||||
OutTraceD("GetClientRect: whnd=%x FullScreen=%x\n", hwnd, dxw.IsFullScreen());
|
||||
if (lpRect && dxw.IsFullScreen() && (hwnd == dxw.GethWnd())){
|
||||
lpRect->left=0;
|
||||
lpRect->top=0;
|
||||
lpRect->right=dxw.GetScreenWidth();
|
||||
lpRect->bottom=dxw.GetScreenHeight();
|
||||
OutTraceD("GetClientRect: fixed rect=(%d,%d)-(%d,%d)\n", lpRect->left, lpRect->top, lpRect->right, lpRect->bottom);
|
||||
return 1;
|
||||
}
|
||||
OutTraceB("GetClientRect: whnd=%x FullScreen=%x\n", hwnd, dxw.IsFullScreen());
|
||||
|
||||
if(!lpRect) return 0;
|
||||
|
||||
// v2.1.75: in PREVENTMAXIMIZE mode, prevent the application to know the actual size of the desktop
|
||||
// by calling GetClientRect on it!! Used to windowize "AfterLife".
|
||||
// should I do the same with hwnd==0 ??
|
||||
if ((hwnd==(*pGetDesktopWindow)()) || (hwnd==0)){
|
||||
lpRect->left=0;
|
||||
lpRect->top=0;
|
||||
lpRect->right=dxw.GetScreenWidth();
|
||||
lpRect->bottom=dxw.GetScreenHeight();
|
||||
OutTraceD("GetClientRect: fixed rect=(%d,%d)-(%d,%d)\n", lpRect->left, lpRect->top, lpRect->right, lpRect->bottom);
|
||||
return 1;
|
||||
}
|
||||
|
||||
// proxed call
|
||||
ret=(*pGetClientRect)(hwnd, lpRect);
|
||||
OutTraceB("GetClientRect: rect=(%d,%d)-(%d,%d) ret=%d\n", lpRect->left, lpRect->top, lpRect->right, lpRect->bottom, ret);
|
||||
return ret;
|
||||
if(!ret) {
|
||||
OutTraceE("GetClientRect: ERROR hwnd=%x err=%d at %d\n", hwnd, GetLastError(), __LINE__);
|
||||
return ret;
|
||||
}
|
||||
OutTraceB("GetClientRect: actual rect=(%d,%d)-(%d,%d)\n", lpRect->left, lpRect->top, lpRect->right, lpRect->bottom);
|
||||
|
||||
if (dxw.IsDesktop(hwnd)){
|
||||
*lpRect = dxw.GetScreenRect();
|
||||
OutTraceB("GetClientRect: desktop rect=(%d,%d)-(%d,%d)\n", lpRect->left, lpRect->top, lpRect->right, lpRect->bottom);
|
||||
}
|
||||
else
|
||||
if (dxw.IsFullScreen()){
|
||||
*lpRect=dxw.GetClientRect(*lpRect);
|
||||
OutTraceB("GetClientRect: fixed rect=(%d,%d)-(%d,%d)\n", lpRect->left, lpRect->top, lpRect->right, lpRect->bottom);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
BOOL WINAPI extGetWindowRect(HWND hwnd, LPRECT lpRect)
|
||||
{
|
||||
BOOL ret;
|
||||
|
||||
OutTraceD("GetWindowRect: hwnd=%x hWnd=%x FullScreen=%x\n", hwnd, dxw.GethWnd(), dxw.IsFullScreen());
|
||||
if (lpRect && dxw.IsFullScreen() && (hwnd == dxw.GethWnd())){
|
||||
// a fullscreen window should have NO BORDERS!
|
||||
lpRect->left = 0;
|
||||
lpRect->top = 0;
|
||||
lpRect->right = dxw.GetScreenWidth();
|
||||
lpRect->bottom = dxw.GetScreenHeight();
|
||||
OutTraceD("GetWindowRect: fixed rect=(%d,%d)-(%d,%d)\n", lpRect->left, lpRect->top, lpRect->right, lpRect->bottom);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (dxw.IsFullScreen() && ((*pGetWindowLong)(hwnd, GWL_STYLE) & WS_CHILD)){
|
||||
// a child win should return the original supposed size
|
||||
// so you basically revert here the coordinates compensation.
|
||||
// Used by "Road Rash" to blit graphic on top of child windows
|
||||
POINT upleft={0,0};
|
||||
RECT client;
|
||||
(*pClientToScreen)(dxw.GethWnd(),&upleft);
|
||||
(*pGetClientRect)(dxw.GethWnd(),&client);
|
||||
|
||||
// using GetWindowRect and compensate for displacement.....
|
||||
ret=(*pGetWindowRect)(hwnd, lpRect);
|
||||
if (client.right && client.bottom){ // avoid divide by 0
|
||||
lpRect->left = ((lpRect->left - upleft.x) * dxw.GetScreenWidth()) / client.right;
|
||||
lpRect->top = ((lpRect->top - upleft.y) * dxw.GetScreenHeight()) / client.bottom;
|
||||
lpRect->right = ((lpRect->right - upleft.x) * dxw.GetScreenWidth()) / client.right;
|
||||
lpRect->bottom = ((lpRect->bottom - upleft.y) * dxw.GetScreenHeight()) / client.bottom;
|
||||
OutTraceD("GetWindowRect: fixed CHILD rect=(%d,%d)-(%d,%d)\n", lpRect->left, lpRect->top, lpRect->right, lpRect->bottom);
|
||||
}
|
||||
OutTraceB("GetWindowRect: hwnd=%x hWnd=%x FullScreen=%x\n", hwnd, dxw.GethWnd(), dxw.IsFullScreen());
|
||||
ret=(*pGetWindowRect)(hwnd, lpRect);
|
||||
if(!ret) {
|
||||
OutTraceE("GetWindowRect: GetWindowRect hwnd=%x error %d at %d\n", hwnd, GetLastError(), __LINE__);
|
||||
return ret;
|
||||
}
|
||||
OutTraceB("GetWindowRect: rect=(%d,%d)-(%d,%d)\n", lpRect->left, lpRect->top, lpRect->right, lpRect->bottom);
|
||||
|
||||
// minimized windows behaviour
|
||||
if((lpRect->left == -32000)||(lpRect->top == -32000)) return ret;
|
||||
|
||||
if (dxw.IsDesktop(hwnd)){
|
||||
// to avoid keeping track of window frame
|
||||
*lpRect = dxw.GetScreenRect();
|
||||
OutTraceB("GetWindowRect: desktop rect=(%d,%d)-(%d,%d)\n", lpRect->left, lpRect->top, lpRect->right, lpRect->bottom);
|
||||
}
|
||||
else
|
||||
if (dxw.IsFullScreen()){
|
||||
*lpRect=dxw.GetWindowRect(*lpRect);
|
||||
|
||||
// Diablo fix: it retrieves coordinates for the explorer window, that are as big as the real desktop!!!
|
||||
if(lpRect->left < 0) lpRect->left=0;
|
||||
if(lpRect->right > (LONG)dxw.GetScreenWidth()) lpRect->right=dxw.GetScreenWidth();
|
||||
if(lpRect->top < 0) lpRect->top=0;
|
||||
if(lpRect->bottom > (LONG)dxw.GetScreenHeight()) lpRect->bottom=dxw.GetScreenHeight();
|
||||
|
||||
OutTraceB("GetWindowRect: fixed rect=(%d,%d)-(%d,%d)\n", lpRect->left, lpRect->top, lpRect->right, lpRect->bottom);
|
||||
}
|
||||
|
||||
ret=(*pGetWindowRect)(hwnd, lpRect);
|
||||
OutTraceD("GetWindowRect: rect=(%d,%d)-(%d,%d)\n", lpRect->left, lpRect->top, lpRect->right, lpRect->bottom);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -1429,6 +1429,8 @@ BOOL WINAPI extPeekMessage(LPMSG lpMsg, HWND hwnd, UINT wMsgFilterMin, UINT wMsg
|
||||
if((MsgCopy.message <= WM_MOUSELAST) && (MsgCopy.message >= WM_MOUSEFIRST)) MsgCopy.lParam = MAKELPARAM(MsgCopy.pt.x, MsgCopy.pt.y);
|
||||
OutTraceC("PeekMessage: fixed lparam/pt=(%d,%d)\n", MsgCopy.pt.x, MsgCopy.pt.y);
|
||||
lpMsg=&MsgCopy;
|
||||
GetHookInfo()->CursorX=(short)MsgCopy.pt.x;
|
||||
GetHookInfo()->CursorY=(short)MsgCopy.pt.y;
|
||||
}
|
||||
|
||||
return res;
|
||||
@ -1455,6 +1457,8 @@ BOOL WINAPI extGetMessage(LPMSG lpMsg, HWND hwnd, UINT wMsgFilterMin, UINT wMsgF
|
||||
lpMsg->pt=FixMessagePt(FixedHwnd, lpMsg->pt);
|
||||
lpMsg->lParam = MAKELPARAM(lpMsg->pt.x, lpMsg->pt.y);
|
||||
OutTraceC("PeekMessage: fixed lparam/pt=(%d,%d)\n", lpMsg->pt.x, lpMsg->pt.y);
|
||||
GetHookInfo()->CursorX=(short)lpMsg->pt.x;
|
||||
GetHookInfo()->CursorY=(short)lpMsg->pt.y;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
@ -1469,6 +1473,7 @@ BOOL WINAPI extGetMessage(LPMSG lpMsg, HWND hwnd, UINT wMsgFilterMin, UINT wMsgF
|
||||
#define SYSLIBIDX_DIRECTDRAW 4
|
||||
#define SYSLIBIDX_OPENGL 5
|
||||
#define SYSLIBIDX_MSVFW 6
|
||||
//#define SYSLIBIDX_SMACK 7
|
||||
#define SYSLIBIDX_MAX 7 // array size
|
||||
HMODULE SysLibs[SYSLIBIDX_MAX];
|
||||
char *SysNames[SYSLIBIDX_MAX]={
|
||||
@ -1478,7 +1483,8 @@ char *SysNames[SYSLIBIDX_MAX]={
|
||||
"ole32.dll",
|
||||
"ddraw.dll",
|
||||
"opengl32.dll",
|
||||
"msvfw32.dll"
|
||||
//"msvfw32.dll",
|
||||
"smackw32.dll"
|
||||
};
|
||||
char *SysNames2[SYSLIBIDX_MAX]={
|
||||
"kernel32",
|
||||
@ -1487,7 +1493,8 @@ char *SysNames2[SYSLIBIDX_MAX]={
|
||||
"ole32",
|
||||
"ddraw",
|
||||
"opengl32",
|
||||
"msvfw32"
|
||||
//"msvfw32",
|
||||
"smackw32"
|
||||
};
|
||||
extern void HookModule(HMODULE, int);
|
||||
extern void HookSysLibs(HMODULE);
|
||||
@ -1525,7 +1532,7 @@ HMODULE WINAPI LoadLibraryExWrapper(LPCTSTR lpFileName, HANDLE hFile, DWORD dwFl
|
||||
idx=SYSLIBIDX_OPENGL;
|
||||
SysLibs[idx]=libhandle;
|
||||
}
|
||||
HookModule(libhandle, 0);
|
||||
if (idx == SYSLIBIDX_MAX) HookModule(libhandle, 0);
|
||||
return libhandle;
|
||||
}
|
||||
|
||||
@ -1537,7 +1544,7 @@ HMODULE WINAPI extLoadLibraryA(LPCTSTR lpFileName)
|
||||
HMODULE WINAPI extLoadLibraryW(LPCWSTR lpFileName)
|
||||
{
|
||||
char sFileName[256+1];
|
||||
wcstombs(sFileName, lpFileName, 80);
|
||||
wcstombs_s(NULL, sFileName, lpFileName, 80);
|
||||
return LoadLibraryExWrapper(sFileName, NULL, 0, "LoadLibraryW");;
|
||||
}
|
||||
|
||||
@ -1549,7 +1556,7 @@ HMODULE WINAPI extLoadLibraryExA(LPCTSTR lpFileName, HANDLE hFile, DWORD dwFlags
|
||||
HMODULE WINAPI extLoadLibraryExW(LPCWSTR lpFileName, HANDLE hFile, DWORD dwFlags)
|
||||
{
|
||||
char sFileName[256+1];
|
||||
wcstombs(sFileName, lpFileName, 80);
|
||||
wcstombs_s(NULL, sFileName, lpFileName, 80);
|
||||
return LoadLibraryExWrapper(sFileName, hFile, dwFlags, "LoadLibraryExW");;
|
||||
}
|
||||
|
||||
@ -1829,7 +1836,7 @@ BOOL WINAPI extGDIBitBlt(HDC hdcDest, int nXDest, int nYDest, int nWidth, int nH
|
||||
int nWDest, nHDest;
|
||||
nWDest= nWidth;
|
||||
nHDest= nHeight;
|
||||
dxw.MapRect(&nXDest, &nYDest, &nWDest, &nHDest);
|
||||
dxw.MapClient(&nXDest, &nYDest, &nWDest, &nHDest);
|
||||
if (dxw.dwFlags2 & SHOWFPSOVERLAY) dxw.ShowFPS(hdcDest);
|
||||
res=(*pGDIStretchBlt)(hdcDest, nXDest, nYDest, nWDest, nHDest, hdcSrc, nXSrc, nYSrc, nWidth, nHeight, dwRop);
|
||||
}
|
||||
@ -1852,7 +1859,7 @@ BOOL WINAPI extGDIPatBlt(HDC hdcDest, int nXDest, int nYDest, int nWidth, int nH
|
||||
|
||||
if (dxw.IsFullScreen() && (OBJ_DC == GetObjectType(hdcDest))){
|
||||
int nWDest, nHDest;
|
||||
dxw.MapRect(&nXDest, &nYDest, &nWDest, &nHDest);
|
||||
dxw.MapClient(&nXDest, &nYDest, &nWDest, &nHDest);
|
||||
if (dxw.dwFlags2 & SHOWFPSOVERLAY) dxw.ShowFPS(hdcDest);
|
||||
res=(*pGDIPatBlt)(hdcDest, nXDest, nYDest, nWDest, nHDest, dwRop);
|
||||
}
|
||||
|
@ -82,6 +82,8 @@
|
||||
#define IDC_USERGB565 1033
|
||||
#define IDC_SUPPRESSDXERRORS 1034
|
||||
#define IDC_PREVENTMAXIMIZE 1035
|
||||
#define IDC_SUPPRESSDXERRORS2 1035
|
||||
#define IDC_MARKBLIT 1035
|
||||
#define IDC_OUTWINMESSAGES 1036
|
||||
#define IDC_OUTDXTRACE 1037
|
||||
#define IDC_MODEXEMULATION 1038
|
||||
|
@ -38,6 +38,7 @@ void CTabDirectX::DoDataExchange(CDataExchange* pDX)
|
||||
DDX_Check(pDX, IDC_VIDEOTOSYSTEMMEM, cTarget->m_VideoToSystemMem);
|
||||
DDX_Check(pDX, IDC_USERGB565, cTarget->m_UseRGB565);
|
||||
DDX_Check(pDX, IDC_SUPPRESSDXERRORS, cTarget->m_SuppressDXErrors);
|
||||
DDX_Check(pDX, IDC_MARKBLIT, cTarget->m_MarkBlit);
|
||||
DDX_Check(pDX, IDC_MAPGDITOPRIMARY, cTarget->m_MapGDIToPrimary);
|
||||
DDX_Check(pDX, IDC_BACKBUFATTACH, cTarget->m_BackBufAttach);
|
||||
DDX_Check(pDX, IDC_FULLRECTBLT, cTarget->m_FullRectBlt);
|
||||
|
@ -60,6 +60,7 @@ CTargetDlg::CTargetDlg(CWnd* pParent /*=NULL*/)
|
||||
m_KeepCursorFixed = FALSE;
|
||||
m_UseRGB565 = FALSE;
|
||||
m_SuppressDXErrors = FALSE;
|
||||
m_MarkBlit = FALSE;
|
||||
m_PreventMaximize = FALSE;
|
||||
m_ClientRemapping = FALSE;
|
||||
m_MapGDIToPrimary = FALSE;
|
||||
|
@ -64,6 +64,7 @@ public:
|
||||
BOOL m_KeepCursorFixed;
|
||||
BOOL m_UseRGB565;
|
||||
BOOL m_SuppressDXErrors;
|
||||
BOOL m_MarkBlit;
|
||||
BOOL m_PreventMaximize;
|
||||
BOOL m_ClientRemapping;
|
||||
BOOL m_MapGDIToPrimary;
|
||||
|
Binary file not shown.
@ -326,6 +326,7 @@ BEGIN
|
||||
CONTROL "DirectInput Hooking",IDC_HOOKDI,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,14,182,97,12
|
||||
GROUPBOX "DirectInput",IDC_STATIC,7,172,286,61
|
||||
CONTROL "Set AERO compatible mode",IDC_SETCOMPATIBILITY,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,118,153,109,12
|
||||
CONTROL "Highlight blit to primary",IDC_MARKBLIT,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,118,84,127,10
|
||||
END
|
||||
|
||||
IDD_TAB_MOUSE DIALOGEX 0, 0, 300, 240
|
||||
|
Binary file not shown.
@ -98,6 +98,25 @@ CDxwndhostView::CDxwndhostView()
|
||||
EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &this->InitDevMode);
|
||||
}
|
||||
|
||||
void CDxwndhostView::SaveWinPos()
|
||||
{
|
||||
char val[32];
|
||||
RECT rect;
|
||||
|
||||
// save window rect
|
||||
//::GetWindowRect(::GetActiveWindow(), &rect);
|
||||
this->GetActiveWindow()->GetWindowRect(&rect);
|
||||
if((rect.top < 0) || (rect.bottom < 0) || (rect.left < 0) || (rect.right < 0)) return;
|
||||
sprintf_s(val, sizeof(val), "%i", rect.left);
|
||||
WritePrivateProfileString("window", "posx", val, InitPath);
|
||||
sprintf_s(val, sizeof(val), "%i", rect.top);
|
||||
WritePrivateProfileString("window", "posy", val, InitPath);
|
||||
sprintf_s(val, sizeof(val), "%i", rect.right-rect.left);
|
||||
WritePrivateProfileString("window", "sizx", val, InitPath);
|
||||
sprintf_s(val, sizeof(val), "%i", rect.bottom-rect.top);
|
||||
WritePrivateProfileString("window", "sizy", val, InitPath);
|
||||
}
|
||||
|
||||
void CDxwndhostView::SaveConfigFile()
|
||||
{
|
||||
int i;
|
||||
@ -234,6 +253,7 @@ CDxwndhostView::~CDxwndhostView()
|
||||
void CDxwndhostView::OnExit()
|
||||
{
|
||||
// check for running apps ....
|
||||
this->SaveWinPos();
|
||||
if (GetHookStatus(NULL)==DXW_RUNNING){
|
||||
if (MessageBoxEx(0,
|
||||
"A hooked task is still running.\n"
|
||||
@ -267,6 +287,7 @@ void CDxwndhostView::OnInitialUpdate()
|
||||
LV_ITEM listitem;
|
||||
int i;
|
||||
char key[32];
|
||||
RECT rect;
|
||||
|
||||
listcol.mask = LVCF_WIDTH;
|
||||
listcol.cx = 100;
|
||||
@ -275,6 +296,17 @@ void CDxwndhostView::OnInitialUpdate()
|
||||
GetCurrentDirectory(MAX_PATH, InitPath);
|
||||
strcat_s(InitPath, sizeof(InitPath), "\\");
|
||||
strcat_s(InitPath, sizeof(InitPath), m_ConfigFileName);
|
||||
|
||||
// restore last window pos
|
||||
AfxGetApp()->m_pMainWnd->GetWindowRect(&rect);
|
||||
rect.left = GetPrivateProfileInt("window", "posx", 50, InitPath);
|
||||
rect.top = GetPrivateProfileInt("window", "posy", 50, InitPath);
|
||||
rect.right = rect.left + GetPrivateProfileInt("window", "sizx", 320, InitPath);
|
||||
rect.bottom = rect.top + GetPrivateProfileInt("window", "sizy", 200, InitPath);
|
||||
AfxGetApp()->m_pMainWnd->MoveWindow(&rect, TRUE);
|
||||
AfxGetApp()->m_pMainWnd->ShowWindow(SW_SHOW);
|
||||
AfxGetApp()->m_pMainWnd->UpdateWindow();
|
||||
|
||||
for(i = 0; i < MAXTARGETS; i ++){
|
||||
sprintf_s(key, sizeof(key), "path%i", i);
|
||||
GetPrivateProfileString("target", key, "", TargetMaps[i].path, MAX_PATH, InitPath);
|
||||
@ -427,6 +459,7 @@ void CDxwndhostView::OnModify()
|
||||
dlg.m_KeepCursorFixed = TargetMaps[i].flags2 & KEEPCURSORFIXED ? 1 : 0;
|
||||
dlg.m_UseRGB565 = TargetMaps[i].flags & USERGB565 ? 1 : 0;
|
||||
dlg.m_SuppressDXErrors = TargetMaps[i].flags & SUPPRESSDXERRORS ? 1 : 0;
|
||||
dlg.m_MarkBlit = TargetMaps[i].flags3 & MARKBLIT ? 1 : 0;
|
||||
dlg.m_PreventMaximize = TargetMaps[i].flags & PREVENTMAXIMIZE ? 1 : 0;
|
||||
dlg.m_ClientRemapping = TargetMaps[i].flags & CLIENTREMAPPING ? 1 : 0;
|
||||
dlg.m_MapGDIToPrimary = TargetMaps[i].flags & MAPGDITOPRIMARY ? 1 : 0;
|
||||
@ -538,6 +571,7 @@ void CDxwndhostView::OnModify()
|
||||
if(dlg.m_KeepCursorFixed) TargetMaps[i].flags2 |= KEEPCURSORFIXED;
|
||||
if(dlg.m_UseRGB565) TargetMaps[i].flags |= USERGB565;
|
||||
if(dlg.m_SuppressDXErrors) TargetMaps[i].flags |= SUPPRESSDXERRORS;
|
||||
if(dlg.m_MarkBlit) TargetMaps[i].flags3 |= MARKBLIT;
|
||||
if(dlg.m_PreventMaximize) TargetMaps[i].flags |= PREVENTMAXIMIZE;
|
||||
if(dlg.m_ClientRemapping) TargetMaps[i].flags |= CLIENTREMAPPING;
|
||||
if(dlg.m_MapGDIToPrimary) TargetMaps[i].flags |= MAPGDITOPRIMARY;
|
||||
@ -840,6 +874,7 @@ void CDxwndhostView::OnAdd()
|
||||
if(dlg.m_KeepCursorFixed) TargetMaps[i].flags2 |= KEEPCURSORFIXED;
|
||||
if(dlg.m_UseRGB565) TargetMaps[i].flags |= USERGB565;
|
||||
if(dlg.m_SuppressDXErrors) TargetMaps[i].flags |= SUPPRESSDXERRORS;
|
||||
if(dlg.m_MarkBlit) TargetMaps[i].flags3 |= MARKBLIT;
|
||||
if(dlg.m_PreventMaximize) TargetMaps[i].flags |= PREVENTMAXIMIZE;
|
||||
if(dlg.m_ClientRemapping) TargetMaps[i].flags |= CLIENTREMAPPING;
|
||||
if(dlg.m_MapGDIToPrimary) TargetMaps[i].flags |= MAPGDITOPRIMARY;
|
||||
@ -1093,6 +1128,7 @@ void CDxwndhostView::OnGoToTrayIcon()
|
||||
|
||||
void CDxwndhostView::OnSaveFile()
|
||||
{
|
||||
this->SaveWinPos();
|
||||
if (this->isUpdated)
|
||||
if (MessageBoxEx(0,
|
||||
"Task list has changed.\n"
|
||||
|
@ -20,6 +20,7 @@ protected: // Create from serialization only features.
|
||||
private:
|
||||
void Resize(void);
|
||||
void SaveConfigFile();
|
||||
void SaveWinPos();
|
||||
TARGETMAP TargetMaps[MAXTARGETS];
|
||||
PRIVATEMAP TitleMaps[MAXTARGETS];
|
||||
char InitPath[MAX_PATH];
|
||||
|
Loading…
x
Reference in New Issue
Block a user