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

v2_02_40_src

Former-commit-id: 53c980c6de887b9d936afba8a95c8060b400864f
This commit is contained in:
gho tik 2013-11-10 11:38:26 -05:00 committed by Refael ACkermann
parent 0b3d188631
commit e8b01bcd28
32 changed files with 2170 additions and 9389 deletions

View File

@ -110,6 +110,10 @@
#define NODDRAWBLT 0x10000000 // Suppress ddraw Blt to primary #define NODDRAWBLT 0x10000000 // Suppress ddraw Blt to primary
#define NODDRAWFLIP 0x20000000 // Suppress ddraw Flip to primary #define NODDRAWFLIP 0x20000000 // Suppress ddraw Flip to primary
#define NOGDIBLT 0x40000000 // Suppress GDI Blt to video device #define NOGDIBLT 0x40000000 // Suppress GDI Blt to video device
#define NOPIXELFORMAT 0x80000000 // Don't fix the pixel format for plain surfaces
// fourth flags DWORD dxw.dwFlags4:
#define NOALPHACHANNEL 0x00000001 // By default, create surfaces with no DDPF_ALPHAPIXELS capability
// logging Tflags DWORD: // logging Tflags DWORD:
#define OUTTRACE 0x00000001 // enables tracing to dxwnd.log in general #define OUTTRACE 0x00000001 // enables tracing to dxwnd.log in general

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,167 +0,0 @@
[window]
posx=1452
posy=365
sizx=320
sizy=514
[target]
title0=Rayman 2 Demo
path0=D:\Games\Rayman2Demo\Rayman2Demo.exe
module0=
opengllib0=
ver0=1
coord0=0
flag0=402653217
flagg0=1210056704
flagh0=2097172
flagi0=0
tflag0=64
initx0=0
inity0=0
minx0=0
miny0=0
maxx0=0
maxy0=0
posx0=50
posy0=50
sizx0=800
sizy0=600
maxfps0=0
initts0=0
title1=Mirror's Edge
path1=D:\Games\Mirror's Edge\Binaries\MirrorsEdge.exe
module1=
opengllib1=
ver1=0
coord1=0
flag1=-2013265882
flagg1=1207959552
flagh1=2097172
flagi1=0
tflag1=5
initx1=0
inity1=0
minx1=0
miny1=0
maxx1=0
maxy1=0
posx1=50
posy1=50
sizx1=800
sizy1=600
maxfps1=0
initts1=6
title2=LastHalfWin.exe
path2=D:\Games\Last Half Of Darkness\LastHalfWin.exe
module2=
opengllib2=
ver2=1
coord2=0
flag2=134217760
flagg2=1207959552
flagh2=4
flagi2=0
tflag2=512
initx2=0
inity2=0
minx2=0
miny2=0
maxx2=0
maxy2=0
posx2=50
posy2=50
sizx2=800
sizy2=600
maxfps2=0
initts2=0
title3=DOOM95.EXE
path3=D:\Games\Doom95i\DOOM95.EXE
module3=
opengllib3=
ver3=0
coord3=0
flag3=134217762
flagg3=1207959552
flagh3=20
flagi3=0
tflag3=512
initx3=0
inity3=0
minx3=0
miny3=0
maxx3=0
maxy3=0
posx3=50
posy3=50
sizx3=800
sizy3=600
maxfps3=0
initts3=0
title4=CNC3.exe
path4=D:\Games\Command & Conquer 3\CNC3.exe
module4=
opengllib4=
ver4=9
coord4=0
flag4=134217762
flagg4=1207959552
flagh4=20
flagi4=0
tflag4=512
initx4=0
inity4=0
minx4=0
miny4=0
maxx4=0
maxy4=0
posx4=50
posy4=50
sizx4=800
sizy4=600
maxfps4=0
initts4=0
title5=Div.exe
path5=D:\Games\Beyond Divinity\Div.exe
module5=
opengllib5=
ver5=0
coord5=0
flag5=134217762
flagg5=1207959552
flagh5=20
flagi5=0
tflag5=512
initx5=0
inity5=0
minx5=0
miny5=0
maxx5=0
maxy5=0
posx5=50
posy5=50
sizx5=800
sizy5=600
maxfps5=0
initts5=0
title6=martian gothic.exe
path6=D:\Games\Martian Gothic\martian gothic.exe
module6=
opengllib6=
ver6=7
coord6=0
flag6=201326626
flagg6=1208090624
flagh6=276
flagi6=0
tflag6=263
initx6=0
inity6=0
minx6=0
miny6=0
maxx6=0
maxy6=0
posx6=50
posy6=50
sizx6=800
sizy6=600
maxfps6=0
initts6=0

View File

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1 version https://git-lfs.github.com/spec/v1
oid sha256:af6a5009d304a3e8cd4b4303697b68a8a6e060a6815e60b70a75a622cf8e4870 oid sha256:f72014ec45098420011258296358843eced6ce66d98dd791d8997884a624db18
size 421376 size 422400

View File

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1 version https://git-lfs.github.com/spec/v1
oid sha256:78e9db00462bdbd92c3b15f0f9e7aa7ae434573ccaa808af1226ba489104837f oid sha256:645d3eb20a6c06832fd937ba3847de75e82273c684ccfac31dbfface9881df50
size 532480 size 532480

View File

@ -251,31 +251,21 @@ DWORD *Palette16BPP = NULL;
void *EmuScreenBuffer = NULL; // to implement pitch bug fix void *EmuScreenBuffer = NULL; // to implement pitch bug fix
DWORD rPitch = 0; DWORD rPitch = 0;
LPVOID rSurface = NULL; LPVOID rSurface = NULL;
static char *SetPixFmt(LPDDSURFACEDESC2); static void SetPixFmt(LPDDSURFACEDESC2);
static void GetPixFmt(LPDDSURFACEDESC2);
static HookEntry_Type ddHooks[]={
{"DirectDrawCreate", (FARPROC)NULL, (FARPROC *)&pDirectDrawCreate, (FARPROC)extDirectDrawCreate},
{"DirectDrawCreateEx", (FARPROC)NULL, (FARPROC *)&pDirectDrawCreateEx, (FARPROC)extDirectDrawCreateEx},
{"DirectDrawCreate", (FARPROC)NULL, (FARPROC *)&pDirectDrawCreate, (FARPROC)extDirectDrawCreate},
{"DirectDrawCreate", (FARPROC)NULL, (FARPROC *)&pDirectDrawCreate, (FARPROC)extDirectDrawCreate},
{0, NULL, 0, 0} // terminator
};
FARPROC Remap_ddraw_ProcAddress(LPCSTR proc, HMODULE hModule) FARPROC Remap_ddraw_ProcAddress(LPCSTR proc, HMODULE hModule)
{ {
if (!strcmp(proc,"DirectDrawCreate")){ FARPROC addr;
pDirectDrawCreate=(DirectDrawCreate_Type)(*pGetProcAddress)(hModule, proc); if (addr=RemapLibrary(proc, hModule, ddHooks)) return addr;
OutTraceD("GetProcAddress: hooking proc=%s at addr=%x\n", ProcToString(proc), pDirectDrawCreate);
return (FARPROC)extDirectDrawCreate;
}
if (!strcmp(proc,"DirectDrawCreateEx")){
pDirectDrawCreateEx=(DirectDrawCreateEx_Type)(*pGetProcAddress)(hModule, proc);
OutTraceD("GetProcAddress: hooking proc=%s at addr=%x\n", ProcToString(proc), pDirectDrawCreateEx);
return (FARPROC)extDirectDrawCreateEx;
}
if (!strcmp(proc,"DirectDrawEnumerateA")){
pDirectDrawEnumerate=(DirectDrawEnumerate_Type)(*pGetProcAddress)(hModule, proc);
OutTraceP("GetProcAddress: hooking proc=%s at addr=%x\n", proc, pDirectDrawEnumerate);
return (FARPROC)extDirectDrawEnumerateProxy;
}
if (!strcmp(proc,"DirectDrawEnumerateExA")){
pDirectDrawEnumerateEx=(DirectDrawEnumerateEx_Type)(*pGetProcAddress)(hModule, proc);
OutTraceP("GetProcAddress: hooking proc=%s at addr=%x\n", proc, pDirectDrawEnumerateEx);
return (FARPROC)extDirectDrawEnumerateExProxy;
}
// NULL -> keep the original call address
return NULL; return NULL;
} }
@ -303,7 +293,7 @@ static void Stopper(char *s, int line)
#define REFPROBE(obj, op) #define REFPROBE(obj, op)
#endif #endif
#define STOPPER_TEST // comment out to eliminate //#define STOPPER_TEST // comment out to eliminate
#ifdef STOPPER_TEST #ifdef STOPPER_TEST
#define STOPPER(s) Stopper(s, __LINE__) #define STOPPER(s) Stopper(s, __LINE__)
#else #else
@ -333,11 +323,19 @@ static char *DumpPixelFormat(LPDDSURFACEDESC2 lpddsd)
sprintf(sBuf, " PixelFormat size=%d flags=%x(%s) BPP=%d", sprintf(sBuf, " PixelFormat size=%d flags=%x(%s) BPP=%d",
lpddsd->dwSize, flags, ExplainPixelFormatFlags(flags), lpddsd->ddpfPixelFormat.dwRGBBitCount); lpddsd->dwSize, flags, ExplainPixelFormatFlags(flags), lpddsd->ddpfPixelFormat.dwRGBBitCount);
if (flags & DDPF_RGB) { if (flags & DDPF_RGB) {
sprintf(sItem, " RGBA=(%x,%x,%x,%x)", if (flags & DDPF_ALPHAPIXELS) {
lpddsd->ddpfPixelFormat.dwRBitMask, sprintf(sItem, " RGBA=(%x,%x,%x,%x)",
lpddsd->ddpfPixelFormat.dwGBitMask, lpddsd->ddpfPixelFormat.dwRBitMask,
lpddsd->ddpfPixelFormat.dwBBitMask, lpddsd->ddpfPixelFormat.dwGBitMask,
lpddsd->ddpfPixelFormat.dwRGBAlphaBitMask); lpddsd->ddpfPixelFormat.dwBBitMask,
lpddsd->ddpfPixelFormat.dwRGBAlphaBitMask);
}
else {
sprintf(sItem, " RGB=(%x,%x,%x)",
lpddsd->ddpfPixelFormat.dwRBitMask,
lpddsd->ddpfPixelFormat.dwGBitMask,
lpddsd->ddpfPixelFormat.dwBBitMask);
}
strcat(sBuf, sItem); strcat(sBuf, sItem);
} }
if (flags & DDPF_YUV) { if (flags & DDPF_YUV) {
@ -559,18 +557,10 @@ void InitDDScreenParameters(LPDIRECTDRAW lpdd)
return; return;
} }
OutTraceD("InitDDScreenParameters: Flags=%x FourCC=%x RGBBitCount=%d RGBA BitMask=(%x,%x,%x,%x)\n", OutTraceD("InitDDScreenParameters: Actual %s\n", DumpPixelFormat((LPDDSURFACEDESC2)&ddsd));
ddsd.ddpfPixelFormat.dwFlags,
ddsd.ddpfPixelFormat.dwFourCC,
ddsd.ddpfPixelFormat.dwRGBBitCount,
ddsd.ddpfPixelFormat.dwRBitMask,
ddsd.ddpfPixelFormat.dwGBitMask,
ddsd.ddpfPixelFormat.dwBBitMask,
ddsd.ddpfPixelFormat.dwRGBAlphaBitMask);
dxw.ActualPixelFormat=ddsd.ddpfPixelFormat; dxw.ActualPixelFormat=ddsd.ddpfPixelFormat;
if(dxw.VirtualPixelFormat.dwRGBBitCount==0) dxw.VirtualPixelFormat=ddsd.ddpfPixelFormat;
SetBltTransformations(); SetBltTransformations();
return; return;
} }
@ -578,24 +568,17 @@ void InitDSScreenParameters(LPDIRECTDRAWSURFACE lpdds)
{ {
HRESULT res; HRESULT res;
DDPIXELFORMAT p; DDPIXELFORMAT p;
DDSURFACEDESC2 ddsd;
p.dwSize=sizeof(DDPIXELFORMAT); p.dwSize=sizeof(DDPIXELFORMAT);
if(res=(*pGetPixelFormat)(lpdds, &p)){ if(res=(*pGetPixelFormat)(lpdds, &p)){
OutTraceE("GetPixelFormat: ERROR res=%x(%s) at %d\n", res, ExplainDDError(res), __LINE__); OutTraceE("GetPixelFormat: ERROR res=%x(%s) at %d\n", res, ExplainDDError(res), __LINE__);
return; return;
} }
OutTraceD("InitDSScreenParameters: Flags=%x FourCC=%x RGBBitCount=%d RGBA BitMask=(%x,%x,%x,%x)\n", ddsd.ddpfPixelFormat = p;
p.dwFlags, OutTraceD("InitDSScreenParameters: Actual %s\n", DumpPixelFormat(&ddsd));
p.dwFourCC,
p.dwRGBBitCount,
p.dwRBitMask,
p.dwGBitMask,
p.dwBBitMask,
p.dwRGBAlphaBitMask);
dxw.ActualPixelFormat=p; dxw.ActualPixelFormat=p;
SetBltTransformations(); SetBltTransformations();
return; return;
} }
@ -624,7 +607,6 @@ void InitScreenParameters()
// initialize to default null values, but dwRGBBitCount // initialize to default null values, but dwRGBBitCount
dxw.ActualPixelFormat.dwRGBBitCount=CurrDevMode.dmBitsPerPel; dxw.ActualPixelFormat.dwRGBBitCount=CurrDevMode.dmBitsPerPel;
dxw.VirtualPixelFormat.dwRGBBitCount=CurrDevMode.dmBitsPerPel; // until set differently dxw.VirtualPixelFormat.dwRGBBitCount=CurrDevMode.dmBitsPerPel; // until set differently
//if(dxw.dwFlags2 & INIT8BPP) dxw.VirtualPixelFormat.dwRGBBitCount = 8;
OutTraceD("InitScreenParameters: RGBBitCount=%d\n", CurrDevMode.dmBitsPerPel); OutTraceD("InitScreenParameters: RGBBitCount=%d\n", CurrDevMode.dmBitsPerPel);
SetBltTransformations(); SetBltTransformations();
@ -644,19 +626,20 @@ void FixPixelFormat(int ColorDepth, DDPIXELFORMAT *pf)
pf->dwRGBAlphaBitMask = 0x0000; pf->dwRGBAlphaBitMask = 0x0000;
break; break;
case 16: case 16:
pf->dwFlags |= DDPF_ALPHAPIXELS; // v2.02.33
pf->dwRGBBitCount = 16; pf->dwRGBBitCount = 16;
if (dxw.dwFlags1 & USERGB565){ if (dxw.dwFlags1 & USERGB565){
pf->dwRBitMask = 0xf800; pf->dwRBitMask = 0xf800;
pf->dwGBitMask = 0x07e0; pf->dwGBitMask = 0x07e0;
pf->dwBBitMask = 0x001f; pf->dwBBitMask = 0x001f;
pf->dwRGBAlphaBitMask = 0x0000;
} }
else { else {
if(!(dxw.dwFlags4 & NOALPHACHANNEL)) pf->dwFlags |= DDPF_ALPHAPIXELS; // v2.02.33,40
pf->dwRBitMask = 0x7c00; pf->dwRBitMask = 0x7c00;
pf->dwGBitMask = 0x03e0; pf->dwGBitMask = 0x03e0;
pf->dwBBitMask = 0x001f; pf->dwBBitMask = 0x001f;
pf->dwRGBAlphaBitMask = 0x8000;
} }
pf->dwRGBAlphaBitMask = 0x8000;
break; break;
case 24: case 24:
pf->dwRGBBitCount = 24; pf->dwRGBBitCount = 24;
@ -666,7 +649,7 @@ void FixPixelFormat(int ColorDepth, DDPIXELFORMAT *pf)
pf->dwRGBAlphaBitMask = 0x00000000; pf->dwRGBAlphaBitMask = 0x00000000;
break; break;
case 32: case 32:
pf->dwFlags |= DDPF_ALPHAPIXELS; // v2.02.33 if(!(dxw.dwFlags4 & NOALPHACHANNEL)) pf->dwFlags |= DDPF_ALPHAPIXELS; // v2.02.33
pf->dwRGBBitCount = 32; pf->dwRGBBitCount = 32;
pf->dwRBitMask = 0x00FF0000; pf->dwRBitMask = 0x00FF0000;
pf->dwGBitMask = 0x0000FF00; pf->dwGBitMask = 0x0000FF00;
@ -863,59 +846,44 @@ int lpddHookedVersion(LPDIRECTDRAW lpdd)
/* ------------------------------------------------------------------ */ /* ------------------------------------------------------------------ */
static char *SetPixFmt(LPDDSURFACEDESC2 lpdd) // SetPixFmt: builds a pixel format descriptor when no one is specified, starting from the color depth, the current
// desktop pixel format (when the color depth is the same) or the config flags
static void SetPixFmt(LPDDSURFACEDESC2 lpdd)
{ {
char *pfstr; OutTraceD("SetPixFmt: BPP=%d Use565=%d NoAlpha=%d\n",
OutTraceD("SetPixFmt: BPP=%d Use565=%d\n", dxw.VirtualPixelFormat.dwRGBBitCount, dxw.dwFlags1 & USERGB565 ? 1:0); dxw.VirtualPixelFormat.dwRGBBitCount,
dxw.dwFlags1 & USERGB565 ? 1:0,
dxw.dwFlags4 & NOALPHACHANNEL ? 1:0);
memset(&lpdd->ddpfPixelFormat,0,sizeof(DDPIXELFORMAT)); memset(&lpdd->ddpfPixelFormat,0,sizeof(DDPIXELFORMAT));
lpdd->ddpfPixelFormat.dwSize = sizeof(DDPIXELFORMAT); lpdd->ddpfPixelFormat.dwSize = sizeof(DDPIXELFORMAT);
lpdd->ddpfPixelFormat.dwRGBBitCount = dxw.ActualPixelFormat.dwRGBBitCount;
if(dxw.ActualPixelFormat.dwRGBBitCount==dxw.VirtualPixelFormat.dwRGBBitCount && dxw.ActualPixelFormat.dwRBitMask){ switch (dxw.VirtualPixelFormat.dwRGBBitCount)
// if same color depth, choose current color masks
pfstr="CURRENT";
lpdd->ddpfPixelFormat=dxw.ActualPixelFormat;
}
else
{ {
switch (dxw.VirtualPixelFormat.dwRGBBitCount) case 8:
{ case 16:
case 8: case 24:
pfstr="RGB8"; case 32:
FixPixelFormat(8, &lpdd->ddpfPixelFormat); FixPixelFormat(dxw.VirtualPixelFormat.dwRGBBitCount, &lpdd->ddpfPixelFormat);
break; break;
case 16: default:
pfstr=(dxw.dwFlags1 & USERGB565)?"RGB16-565":"RGB16-555"; OutTraceE("CreateSurface ERROR: Unsupported resolution ColorBPP=%d\n", dxw.VirtualPixelFormat.dwRGBBitCount);
FixPixelFormat(16, &lpdd->ddpfPixelFormat); break;
break;
case 24:
pfstr="RGB24";
FixPixelFormat(24, &lpdd->ddpfPixelFormat);
break;
case 32:
pfstr="RGB32";
FixPixelFormat(32, &lpdd->ddpfPixelFormat);
break;
default:
pfstr="unsupported";
OutTraceE("CreateSurface ERROR: Unsupported resolution ColorBPP=%d\n", dxw.VirtualPixelFormat.dwRGBBitCount);
break;
}
} }
// remember current virtual settings // remember current virtual settings
dxw.VirtualPixelFormat=lpdd->ddpfPixelFormat; dxw.VirtualPixelFormat=lpdd->ddpfPixelFormat;
OutTraceD("SetPixFmt: %s\n", DumpPixelFormat(lpdd));
}
OutTraceD("SetPixFmt: RGBBitCount=%d Flags=%x FourCC=%x RGBA BitMask=(%x,%x,%x,%x)\n", // retrieves the stored pixel format
lpdd->ddpfPixelFormat.dwRGBBitCount,
lpdd->ddpfPixelFormat.dwFlags,
lpdd->ddpfPixelFormat.dwFourCC,
lpdd->ddpfPixelFormat.dwRBitMask,
lpdd->ddpfPixelFormat.dwGBitMask,
lpdd->ddpfPixelFormat.dwBBitMask,
lpdd->ddpfPixelFormat.dwRGBAlphaBitMask);
return pfstr; static void GetPixFmt(LPDDSURFACEDESC2 lpdd)
{
lpdd->ddpfPixelFormat = dxw.VirtualPixelFormat;
OutTraceD("GetPixFmt: %s\n", DumpPixelFormat(lpdd));
} }
static void RenewClipper(LPDIRECTDRAW lpdd, LPDIRECTDRAWSURFACE lpdds) static void RenewClipper(LPDIRECTDRAW lpdd, LPDIRECTDRAWSURFACE lpdds)
@ -1433,15 +1401,17 @@ HRESULT WINAPI extGetCapsD(LPDIRECTDRAW lpdd, LPDDCAPS c1, LPDDCAPS c2)
if(res) if(res)
OutTraceE("GetCaps(D): ERROR res=%x(%s)\n", res, ExplainDDError(res)); OutTraceE("GetCaps(D): ERROR res=%x(%s)\n", res, ExplainDDError(res));
else { else {
if (c1) OutTraceD("GetCaps(D-HW): caps=%x(%s) caps2=%x(%s) fxcaps=%x(%s) fxalphacaps=%x(%s) keycaps=%x(%s)\n", if (c1) OutTraceD("GetCaps(D-HW): caps=%x(%s) caps2=%x(%s) palcaps=%x(%s) fxcaps=%x(%s) fxalphacaps=%x(%s) keycaps=%x(%s)\n",
c1->dwCaps, ExplainDDDCaps(c1->dwCaps), c1->dwCaps, ExplainDDDCaps(c1->dwCaps),
c1->dwCaps2, ExplainDDDCaps2(c1->dwCaps2), c1->dwCaps2, ExplainDDDCaps2(c1->dwCaps2),
c1->dwPalCaps, ExplainDDPalCaps(c1->dwPalCaps),
c1->dwFXCaps, ExplainDDFXCaps(c1->dwFXCaps), c1->dwFXCaps, ExplainDDFXCaps(c1->dwFXCaps),
c1->dwFXAlphaCaps, ExplainDDFXALPHACaps(c1->dwFXAlphaCaps), c1->dwFXAlphaCaps, ExplainDDFXALPHACaps(c1->dwFXAlphaCaps),
c1->dwCKeyCaps, ExplainDDCKeyCaps(c1->dwCKeyCaps)); c1->dwCKeyCaps, ExplainDDCKeyCaps(c1->dwCKeyCaps));
if (c2) OutTraceD("GetCaps(D-SW): caps=%x(%s) caps2=%x(%s) fxcaps=%x(%s) fxalphacaps=%x(%s) keycaps=%x(%s)\n", if (c2) OutTraceD("GetCaps(D-SW): caps=%x(%s) caps2=%x(%s) palcaps=%x(%s) fxcaps=%x(%s) fxalphacaps=%x(%s) keycaps=%x(%s)\n",
c2->dwCaps, ExplainDDDCaps(c2->dwCaps), c2->dwCaps, ExplainDDDCaps(c2->dwCaps),
c2->dwCaps2, ExplainDDDCaps2(c2->dwCaps2), c2->dwCaps2, ExplainDDDCaps2(c2->dwCaps2),
c2->dwPalCaps, ExplainDDPalCaps(c2->dwPalCaps),
c2->dwFXCaps, ExplainDDFXCaps(c2->dwFXCaps), c2->dwFXCaps, ExplainDDFXCaps(c2->dwFXCaps),
c2->dwFXAlphaCaps, ExplainDDFXALPHACaps(c2->dwFXAlphaCaps), c2->dwFXAlphaCaps, ExplainDDFXALPHACaps(c2->dwFXAlphaCaps),
c2->dwCKeyCaps, ExplainDDCKeyCaps(c2->dwCKeyCaps)); c2->dwCKeyCaps, ExplainDDCKeyCaps(c2->dwCKeyCaps));
@ -1457,7 +1427,10 @@ HRESULT WINAPI extGetCapsD(LPDIRECTDRAW lpdd, LPDDCAPS c1, LPDDCAPS c2)
c2=&swcaps; c2=&swcaps;
res=(*pGetCapsD)(lpdd, NULL, c2); res=(*pGetCapsD)(lpdd, NULL, c2);
} }
//DWORD AlphaCaps;
//AlphaCaps=c1->dwFXAlphaCaps;
memcpy((void *)c1, (void *)c2, size); memcpy((void *)c1, (void *)c2, size);
//c1->dwFXAlphaCaps=AlphaCaps;
} }
if((dxw.dwFlags3 & CAPMASK) && c1 && c2) MaskCapsD(c1, c2); if((dxw.dwFlags3 & CAPMASK) && c1 && c2) MaskCapsD(c1, c2);
@ -1825,10 +1798,8 @@ HRESULT WINAPI extSetDisplayMode(int version, LPDIRECTDRAW lpdd,
if(IsTraceD){ if(IsTraceD){
OutTrace("SetDisplayMode: version=%d dwWidth=%i dwHeight=%i dwBPP=%i", OutTrace("SetDisplayMode: version=%d dwWidth=%i dwHeight=%i dwBPP=%i",
version, dwwidth, dwheight, dwbpp); version, dwwidth, dwheight, dwbpp);
if (version==2) if (version==2) OutTrace(" dwRefresh=%i dwFlags=%x\n", dwrefreshrate, dwflags);
OutTrace(" dwRefresh=%i dwFlags=%x\n", dwrefreshrate, dwflags); else OutTrace("\n");
else
OutTrace("\n");
} }
dxw.SetScreenSize(dwwidth, dwheight); dxw.SetScreenSize(dwwidth, dwheight);
@ -1837,16 +1808,17 @@ HRESULT WINAPI extSetDisplayMode(int version, LPDIRECTDRAW lpdd,
AdjustWindowFrame(dxw.GethWnd(), dwwidth, dwheight); AdjustWindowFrame(dxw.GethWnd(), dwwidth, dwheight);
if(dxw.dwFlags1 & EMULATESURFACE){ if(dxw.dwFlags1 & EMULATESURFACE){
// in EMULATESURFACE mode, let SetPixFmt decide upon the PixelFormat
dxw.VirtualPixelFormat.dwRGBBitCount = dwbpp; dxw.VirtualPixelFormat.dwRGBBitCount = dwbpp;
dwbpp = dxw.ActualPixelFormat.dwRGBBitCount; SetPixFmt(&ddsd);
SetBltTransformations(); SetBltTransformations();
OutTraceD("SetDisplayMode: mode=EMULATESURFACE EmuBPP=%d ActBPP=%d\n", dxw.VirtualPixelFormat.dwRGBBitCount, dxw.ActualPixelFormat.dwRGBBitCount); OutTraceD("SetDisplayMode: mode=EMULATE %s ret=OK\n", DumpPixelFormat(&ddsd));
} return DD_OK;
else {
OutTraceD("SetDisplayMode: mode=STANDARD BPP=%d\n", dwbpp);
dxw.ActualPixelFormat.dwRGBBitCount = dwbpp;
} }
OutTraceD("SetDisplayMode: mode=STANDARD BPP=%d\n", dwbpp);
dxw.ActualPixelFormat.dwRGBBitCount = dwbpp;
ZeroMemory(&ddsd, sizeof(ddsd)); ZeroMemory(&ddsd, sizeof(ddsd));
ddsd.dwSize = Set_dwSize_From_DDraw(lpdd); ddsd.dwSize = Set_dwSize_From_DDraw(lpdd);
ddsd.dwFlags = DDSD_WIDTH | DDSD_HEIGHT | DDSD_PIXELFORMAT | DDSD_REFRESHRATE; ddsd.dwFlags = DDSD_WIDTH | DDSD_HEIGHT | DDSD_PIXELFORMAT | DDSD_REFRESHRATE;
@ -1854,14 +1826,13 @@ HRESULT WINAPI extSetDisplayMode(int version, LPDIRECTDRAW lpdd,
ddsd.ddpfPixelFormat.dwFlags = DDPF_RGB; ddsd.ddpfPixelFormat.dwFlags = DDPF_RGB;
(*pGetDisplayMode)(lpdd, (LPDDSURFACEDESC)&ddsd); (*pGetDisplayMode)(lpdd, (LPDDSURFACEDESC)&ddsd);
if(ddsd.ddpfPixelFormat.dwRGBBitCount != dwbpp){ if (version==1)
OutTraceD("SetDisplayMode: fixing colordepth current=%d required=%d size=(%dx%d)\n", res = (*pSetDisplayMode1)(lpdd, ddsd.dwWidth, ddsd.dwHeight, dwbpp);
else
res = (*pSetDisplayMode2)(lpdd, ddsd.dwWidth, ddsd.dwHeight, dwbpp, ddsd.dwRefreshRate, 0);
OutTraceD("SetDisplayMode: fixing colordepth current=%d required=%d size=(%dx%d)\n",
ddsd.ddpfPixelFormat.dwRGBBitCount, dwbpp, ddsd.dwWidth, ddsd.dwHeight); ddsd.ddpfPixelFormat.dwRGBBitCount, dwbpp, ddsd.dwWidth, ddsd.dwHeight);
if (version==1)
res = (*pSetDisplayMode1)(lpdd, ddsd.dwWidth, ddsd.dwHeight, dwbpp);
else
res = (*pSetDisplayMode2)(lpdd, ddsd.dwWidth, ddsd.dwHeight, dwbpp, ddsd.dwRefreshRate, 0);
}
return 0; return 0;
} }
@ -1883,7 +1854,10 @@ HRESULT WINAPI extGetDisplayMode(LPDIRECTDRAW lpdd, LPDDSURFACEDESC lpddsd)
OutTraceD("GetDisplayMode\n"); OutTraceD("GetDisplayMode\n");
(*pGetDisplayMode)(lpdd, lpddsd); (*pGetDisplayMode)(lpdd, lpddsd);
if(dxw.dwFlags1 & EMULATESURFACE) SetPixFmt((LPDDSURFACEDESC2)lpddsd); if(dxw.dwFlags1 & EMULATESURFACE) {
GetPixFmt((LPDDSURFACEDESC2)lpddsd);
if(!lpddsd->ddpfPixelFormat.dwFlags) SetPixFmt((LPDDSURFACEDESC2)lpddsd);
}
lpddsd->dwWidth = dxw.GetScreenWidth(); lpddsd->dwWidth = dxw.GetScreenWidth();
lpddsd->dwHeight = dxw.GetScreenHeight(); lpddsd->dwHeight = dxw.GetScreenHeight();
@ -1894,13 +1868,15 @@ HRESULT WINAPI extGetDisplayMode(LPDIRECTDRAW lpdd, LPDDSURFACEDESC lpddsd)
OutTraceD("GetDisplayMode: fix RGBBitCount=%d\n", lpddsd->ddpfPixelFormat.dwRGBBitCount); OutTraceD("GetDisplayMode: fix RGBBitCount=%d\n", lpddsd->ddpfPixelFormat.dwRGBBitCount);
} }
OutTraceD("GetDisplayMode: returning WxH=(%dx%d) PixelFormat Flags=%x(%s) RGBBitCount=%d RGBAmask=(%x,%x,%x,%x) Caps=%x(%s)\n", //OutTraceD("GetDisplayMode: returning WxH=(%dx%d) PixelFormat Flags=%x(%s) RGBBitCount=%d RGBAmask=(%x,%x,%x,%x) Caps=%x(%s)\n",
lpddsd->dwWidth, lpddsd->dwHeight, // lpddsd->dwWidth, lpddsd->dwHeight,
lpddsd->ddpfPixelFormat.dwFlags, ExplainPixelFormatFlags(lpddsd->ddpfPixelFormat.dwFlags), // lpddsd->ddpfPixelFormat.dwFlags, ExplainPixelFormatFlags(lpddsd->ddpfPixelFormat.dwFlags),
lpddsd->ddpfPixelFormat.dwRGBBitCount, // lpddsd->ddpfPixelFormat.dwRGBBitCount,
lpddsd->ddpfPixelFormat.dwRBitMask, lpddsd->ddpfPixelFormat.dwGBitMask, lpddsd->ddpfPixelFormat.dwBBitMask, // lpddsd->ddpfPixelFormat.dwRBitMask, lpddsd->ddpfPixelFormat.dwGBitMask, lpddsd->ddpfPixelFormat.dwBBitMask,
lpddsd->ddpfPixelFormat.dwRGBAlphaBitMask, // lpddsd->ddpfPixelFormat.dwRGBAlphaBitMask,
lpddsd->ddsCaps.dwCaps, ExplainDDSCaps(lpddsd->ddsCaps.dwCaps)); // lpddsd->ddsCaps.dwCaps, ExplainDDSCaps(lpddsd->ddsCaps.dwCaps));
OutTraceD("GetDisplayMode: returning size=(%dx%d) %s\n", lpddsd->dwWidth, lpddsd->dwHeight, DumpPixelFormat((LPDDSURFACEDESC2)lpddsd));
return 0; return 0;
} }
@ -2006,7 +1982,7 @@ void FixSurfaceCapsAnalytic(LPDDSURFACEDESC2 lpddsd, int dxversion)
// lpddsd->ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN|DDSCAPS_SYSTEMMEMORY; // lpddsd->ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN|DDSCAPS_SYSTEMMEMORY;
// lpddsd->dwHeight = dxw.GetScreenHeight(); // lpddsd->dwHeight = dxw.GetScreenHeight();
// lpddsd->dwWidth = dxw.GetScreenWidth(); // lpddsd->dwWidth = dxw.GetScreenWidth();
// SetPixFmt(lpddsd); // GetPixFmt(lpddsd);
// return; // return;
// break; // break;
// } // }
@ -2016,7 +1992,7 @@ void FixSurfaceCapsAnalytic(LPDDSURFACEDESC2 lpddsd, int dxversion)
// dwFlags: DDSD_CAPS+HEIGHT+WIDTH+PIXELFORMAT+TEXTURESTAGE // dwFlags: DDSD_CAPS+HEIGHT+WIDTH+PIXELFORMAT+TEXTURESTAGE
// dwCaps1: DDSCAPS_OFFSCREENPLAIN+SYSTEMMEMORY+TEXTURE // dwCaps1: DDSCAPS_OFFSCREENPLAIN+SYSTEMMEMORY+TEXTURE
// dwCaps2: DDSCAPS2_TEXTUREMANAGE // dwCaps2: DDSCAPS2_TEXTUREMANAGE
SetPixFmt(lpddsd); GetPixFmt(lpddsd);
return; return;
break; break;
case DDSD_CAPS|DDSD_WIDTH|DDSD_HEIGHT|DDSD_ZBUFFERBITDEPTH: case DDSD_CAPS|DDSD_WIDTH|DDSD_HEIGHT|DDSD_ZBUFFERBITDEPTH:
@ -2067,54 +2043,54 @@ void FixSurfaceCapsAnalytic(LPDDSURFACEDESC2 lpddsd, int dxversion)
break; break;
case DDSCAPS_OFFSCREENPLAIN|DDSCAPS_VIDEOMEMORY: case DDSCAPS_OFFSCREENPLAIN|DDSCAPS_VIDEOMEMORY:
// Alien Nations, Heroes of Might & Magic IV --- troublesome!!!! // Alien Nations, Heroes of Might & Magic IV --- troublesome!!!!
//lpddsd->dwFlags = 0; lpddsd->dwFlags = (DDSD_CAPS|DDSD_HEIGHT|DDSD_WIDTH|DDSD_PIXELFORMAT);
//lpddsd->ddsCaps.dwCaps = (DDSCAPS_OFFSCREENPLAIN|DDSCAPS_SYSTEMMEMORY); lpddsd->ddsCaps.dwCaps = (DDSCAPS_OFFSCREENPLAIN|DDSCAPS_SYSTEMMEMORY);
lpddsd->ddsCaps.dwCaps = 0; GetPixFmt(lpddsd);
return; return;
break; break;
case DDSCAPS_OFFSCREENPLAIN|DDSCAPS_SYSTEMMEMORY: case DDSCAPS_OFFSCREENPLAIN|DDSCAPS_SYSTEMMEMORY:
// Cave Story, HoMM3 // Cave Story, HoMM3
lpddsd->dwFlags |= DDSD_PIXELFORMAT; lpddsd->dwFlags |= DDSD_PIXELFORMAT;
SetPixFmt(lpddsd); GetPixFmt(lpddsd);
return; return;
break; break;
case DDSCAPS_SYSTEMMEMORY: case DDSCAPS_SYSTEMMEMORY:
// Magic & Mayhem // Magic & Mayhem
lpddsd->dwFlags |= DDSD_PIXELFORMAT; lpddsd->dwFlags |= DDSD_PIXELFORMAT;
lpddsd->ddsCaps.dwCaps = DDSCAPS_SYSTEMMEMORY|DDSCAPS_OFFSCREENPLAIN; lpddsd->ddsCaps.dwCaps = DDSCAPS_SYSTEMMEMORY|DDSCAPS_OFFSCREENPLAIN;
SetPixFmt(lpddsd); GetPixFmt(lpddsd);
return; return;
break; break;
case DDSCAPS_OFFSCREENPLAIN: case DDSCAPS_OFFSCREENPLAIN:
// Cave Story, Magic & Mayhem // Cave Story, Magic & Mayhem
lpddsd->dwFlags |= DDSD_PIXELFORMAT; lpddsd->dwFlags |= DDSD_PIXELFORMAT;
lpddsd->ddsCaps.dwCaps = DDSCAPS_SYSTEMMEMORY|DDSCAPS_OFFSCREENPLAIN; lpddsd->ddsCaps.dwCaps = DDSCAPS_SYSTEMMEMORY|DDSCAPS_OFFSCREENPLAIN;
SetPixFmt(lpddsd); GetPixFmt(lpddsd);
return; return;
break; break;
case DDSCAPS_OFFSCREENPLAIN|DDSCAPS_3DDEVICE: case DDSCAPS_OFFSCREENPLAIN|DDSCAPS_3DDEVICE:
// Nightmare Ned // Nightmare Ned
lpddsd->dwFlags |= DDSD_PIXELFORMAT; lpddsd->dwFlags |= DDSD_PIXELFORMAT;
SetPixFmt(lpddsd); GetPixFmt(lpddsd);
return; return;
break; break;
case DDSCAPS_SYSTEMMEMORY|DDSCAPS_3DDEVICE: case DDSCAPS_SYSTEMMEMORY|DDSCAPS_3DDEVICE:
// Actua Soccer 3 // Actua Soccer 3
lpddsd->dwFlags |= DDSD_PIXELFORMAT; lpddsd->dwFlags |= DDSD_PIXELFORMAT;
SetPixFmt(lpddsd); GetPixFmt(lpddsd);
return; return;
break; break;
case DDSCAPS_VIDEOMEMORY|DDSCAPS_3DDEVICE: case DDSCAPS_VIDEOMEMORY|DDSCAPS_3DDEVICE:
// Actua Soccer 3 // Actua Soccer 3
lpddsd->dwFlags |= DDSD_PIXELFORMAT; lpddsd->dwFlags |= DDSD_PIXELFORMAT;
lpddsd->ddsCaps.dwCaps = DDSCAPS_SYSTEMMEMORY|DDSCAPS_3DDEVICE; lpddsd->ddsCaps.dwCaps = DDSCAPS_SYSTEMMEMORY|DDSCAPS_3DDEVICE;
SetPixFmt(lpddsd); GetPixFmt(lpddsd);
return; return;
break; break;
case DDSCAPS_OFFSCREENPLAIN|DDSCAPS_3DDEVICE|DDSCAPS_SYSTEMMEMORY: case DDSCAPS_OFFSCREENPLAIN|DDSCAPS_3DDEVICE|DDSCAPS_SYSTEMMEMORY:
// Nightmare Ned, The Sims ??? // Nightmare Ned, The Sims ???
lpddsd->dwFlags |= DDSD_PIXELFORMAT; lpddsd->dwFlags |= DDSD_PIXELFORMAT;
SetPixFmt(lpddsd); GetPixFmt(lpddsd);
return; return;
break; break;
} }
@ -2139,14 +2115,26 @@ void FixSurfaceCapsAnalytic(LPDDSURFACEDESC2 lpddsd, int dxversion)
lpddsd->ddsCaps.dwCaps = (DDSCAPS_OFFSCREENPLAIN|DDSCAPS_3DDEVICE|DDSCAPS_SYSTEMMEMORY); lpddsd->ddsCaps.dwCaps = (DDSCAPS_OFFSCREENPLAIN|DDSCAPS_3DDEVICE|DDSCAPS_SYSTEMMEMORY);
// eotry // eotry
return; return;
break; case DDSCAPS_OFFSCREENPLAIN: break;
case DDSCAPS_OFFSCREENPLAIN:
// Submarine titans (8BPP) // Submarine titans (8BPP)
lpddsd->ddsCaps.dwCaps = (DDSCAPS_SYSTEMMEMORY|DDSCAPS_OFFSCREENPLAIN); lpddsd->ddsCaps.dwCaps = (DDSCAPS_SYSTEMMEMORY|DDSCAPS_OFFSCREENPLAIN);
SetPixFmt(lpddsd); GetPixFmt(lpddsd);
return; return;
break; break;
case DDSCAPS_OFFSCREENPLAIN|DDSCAPS_SYSTEMMEMORY: case DDSCAPS_OFFSCREENPLAIN|DDSCAPS_SYSTEMMEMORY:
// Duckman, HoM&M4 // Duckman, HoM&M4, Beavis & Butthead do U.
// unsetting the Pixel Format may cause the backbuffer to be created with DDPF_ALPHAPIXELS flag on
// and some generic surface with DDPF_ALPHAPIXELS off, so that blitting is unsupported.
// But it seems impossible to get HOMM4 to cope with Beavis & Butthead!!!
if(!(dxw.dwFlags3 & NOPIXELFORMAT)) GetPixFmt(lpddsd);
return;
break;
case DDSCAPS_OFFSCREENPLAIN|DDSCAPS_VIDEOMEMORY:
// Dungeon Keeper II GOG release (intro screen): doesn't like calling GetPixFmt!!!
// need not to be configurable until we get a different case.
// it works both on VIDEOMEMORY or SYSTEMMEMORY. The latter should be more stable.
lpddsd->ddsCaps.dwCaps = (DDSCAPS_SYSTEMMEMORY|DDSCAPS_OFFSCREENPLAIN);
return; return;
break; break;
case DDSCAPS_SYSTEMMEMORY|DDSCAPS_ZBUFFER: case DDSCAPS_SYSTEMMEMORY|DDSCAPS_ZBUFFER:
@ -2154,7 +2142,7 @@ void FixSurfaceCapsAnalytic(LPDDSURFACEDESC2 lpddsd, int dxversion)
return; return;
break; break;
case DDSCAPS_SYSTEMMEMORY|DDSCAPS_TEXTURE: case DDSCAPS_SYSTEMMEMORY|DDSCAPS_TEXTURE:
// Wargames Direct3D hw acceleration // Wargames Direct3D hw acceleration
// Star Wars Shadows of the Empire in RGB HEL mode // Star Wars Shadows of the Empire in RGB HEL mode
return; return;
break; break;
@ -2174,7 +2162,7 @@ void FixSurfaceCapsAnalytic(LPDDSURFACEDESC2 lpddsd, int dxversion)
break; break;
case DDSCAPS_OFFSCREENPLAIN|DDSCAPS_SYSTEMMEMORY|DDSCAPS_3DDEVICE: case DDSCAPS_OFFSCREENPLAIN|DDSCAPS_SYSTEMMEMORY|DDSCAPS_3DDEVICE:
// Premier Manager 98 // Premier Manager 98
SetPixFmt(lpddsd); GetPixFmt(lpddsd);
return; return;
break; break;
case DDSCAPS_OVERLAY|DDSCAPS_VIDEOMEMORY: // NOT WORKING case DDSCAPS_OVERLAY|DDSCAPS_VIDEOMEMORY: // NOT WORKING
@ -2185,16 +2173,15 @@ void FixSurfaceCapsAnalytic(LPDDSURFACEDESC2 lpddsd, int dxversion)
case DDSCAPS_SYSTEMMEMORY: case DDSCAPS_SYSTEMMEMORY:
// Star Force Deluxe // Star Force Deluxe
lpddsd->ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN|DDSCAPS_SYSTEMMEMORY; lpddsd->ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN|DDSCAPS_SYSTEMMEMORY;
// SetPixFmt(lpddsd); // GetPixFmt(lpddsd);
return; return;
break; break;
case DDSCAPS_TEXTURE|DDSCAPS_VIDEOMEMORY|DDSCAPS_ALLOCONLOAD: case DDSCAPS_TEXTURE|DDSCAPS_VIDEOMEMORY|DDSCAPS_ALLOCONLOAD:
// Star Wars Shadows of the Empire // Star Wars Shadows of the Empire
// seems to work both with/without SetPixFmt, but doesn't like DDSCAPS_SYSTEMMEMORY textures. // seems to work both with/without GetPixFmt, but doesn't like DDSCAPS_SYSTEMMEMORY textures.
// Setting SetPixFmt makes bad alpha transparencies! // Setting GetPixFmt makes bad alpha transparencies!
// DDSCAPS_VIDEOMEMORY doesn't work with HEL only! Better switch to DDSCAPS_SYSTEMMEMORY. // DDSCAPS_VIDEOMEMORY doesn't work with HEL only! Better switch to DDSCAPS_SYSTEMMEMORY.
if (dxw.dwFlags3 & FORCESHEL) lpddsd->ddsCaps.dwCaps = (DDSCAPS_TEXTURE|DDSCAPS_SYSTEMMEMORY|DDSCAPS_ALLOCONLOAD); if (dxw.dwFlags3 & FORCESHEL) lpddsd->ddsCaps.dwCaps = (DDSCAPS_TEXTURE|DDSCAPS_SYSTEMMEMORY|DDSCAPS_ALLOCONLOAD);
//SetPixFmt(lpddsd);
return; return;
break; break;
} }
@ -2204,7 +2191,7 @@ void FixSurfaceCapsAnalytic(LPDDSURFACEDESC2 lpddsd, int dxversion)
case DDSCAPS_SYSTEMMEMORY: case DDSCAPS_SYSTEMMEMORY:
// Wargames // Wargames
lpddsd->ddsCaps.dwCaps = (DDSCAPS_SYSTEMMEMORY|DDSCAPS_OFFSCREENPLAIN); lpddsd->ddsCaps.dwCaps = (DDSCAPS_SYSTEMMEMORY|DDSCAPS_OFFSCREENPLAIN);
SetPixFmt(lpddsd); GetPixFmt(lpddsd);
//lpddsd->dwFlags = DDSD_CAPS|DDSD_WIDTH|DDSD_HEIGHT|DDSD_PITCH; // turn DDSD_PIXELFORMAT off //lpddsd->dwFlags = DDSD_CAPS|DDSD_WIDTH|DDSD_HEIGHT|DDSD_PITCH; // turn DDSD_PIXELFORMAT off
return; return;
break; break;
@ -2237,6 +2224,8 @@ static void FixSurfaceCaps(LPDDSURFACEDESC2 lpddsd, int dxversion)
// 5) ignore DDSD_CKSRCBLT, .... // 5) ignore DDSD_CKSRCBLT, ....
// 6) setting a different pixel format in memory requires DDSCAPS_OFFSCREENPLAIN capability // 6) setting a different pixel format in memory requires DDSCAPS_OFFSCREENPLAIN capability
// 7) DDSD_TEXTURESTAGE surfaces may need to adjust fixel format (....???) // 7) DDSD_TEXTURESTAGE surfaces may need to adjust fixel format (....???)
// 8) Generic surfaces are mapped to SYSTEMMEMORY and set to primary surface PixelFormat
// 9) When pixelformat is unspecified, be sure to pick the right one (with or without alphapixels?)
if(!(lpddsd->dwFlags & DDSD_CAPS)) lpddsd->ddsCaps.dwCaps = 0; if(!(lpddsd->dwFlags & DDSD_CAPS)) lpddsd->ddsCaps.dwCaps = 0;
@ -2251,7 +2240,7 @@ static void FixSurfaceCaps(LPDDSURFACEDESC2 lpddsd, int dxversion)
} }
if((lpddsd->dwFlags & (DDSD_PIXELFORMAT|DDSD_TEXTURESTAGE)) == (DDSD_PIXELFORMAT|DDSD_TEXTURESTAGE)){ if((lpddsd->dwFlags & (DDSD_PIXELFORMAT|DDSD_TEXTURESTAGE)) == (DDSD_PIXELFORMAT|DDSD_TEXTURESTAGE)){
// textures, set proper color depth and make no further changes // textures, set proper color depth and make no further changes
SetPixFmt(lpddsd); GetPixFmt(lpddsd);
return; return;
} }
if((lpddsd->dwFlags & DDSD_CAPS) && (lpddsd->ddsCaps.dwCaps & DDSCAPS_ZBUFFER)) { // z-buffer surface - set to memory if((lpddsd->dwFlags & DDSD_CAPS) && (lpddsd->ddsCaps.dwCaps & DDSCAPS_ZBUFFER)) { // z-buffer surface - set to memory
@ -2261,7 +2250,7 @@ static void FixSurfaceCaps(LPDDSURFACEDESC2 lpddsd, int dxversion)
if((lpddsd->dwFlags & DDSD_CAPS) && (lpddsd->ddsCaps.dwCaps & DDSCAPS_3DDEVICE)) { // 3DDEVICE: enforce PIXELFORMAT on MEMORY if((lpddsd->dwFlags & DDSD_CAPS) && (lpddsd->ddsCaps.dwCaps & DDSCAPS_3DDEVICE)) { // 3DDEVICE: enforce PIXELFORMAT on MEMORY
lpddsd->dwFlags |= DDSD_PIXELFORMAT; lpddsd->dwFlags |= DDSD_PIXELFORMAT;
lpddsd->ddsCaps.dwCaps = (DDSCAPS_OFFSCREENPLAIN|DDSCAPS_SYSTEMMEMORY|DDSCAPS_3DDEVICE); lpddsd->ddsCaps.dwCaps = (DDSCAPS_OFFSCREENPLAIN|DDSCAPS_SYSTEMMEMORY|DDSCAPS_3DDEVICE);
SetPixFmt(lpddsd); GetPixFmt(lpddsd);
return; return;
} }
//// DDSCAPS_ALLOCONLOAD on VIDEOMEMORY can't be done when HAL is disabled - it returns DDERR_NODIRECTDRAWHW error //// DDSCAPS_ALLOCONLOAD on VIDEOMEMORY can't be done when HAL is disabled - it returns DDERR_NODIRECTDRAWHW error
@ -2282,28 +2271,23 @@ static void FixSurfaceCaps(LPDDSURFACEDESC2 lpddsd, int dxversion)
if(lpddsd->dwFlags & DDSD_ZBUFFERBITDEPTH){ if(lpddsd->dwFlags & DDSD_ZBUFFERBITDEPTH){
lpddsd->dwFlags &= ~DDSD_PIXELFORMAT; lpddsd->dwFlags &= ~DDSD_PIXELFORMAT;
} }
#if 0
// HoM&M3/4 fix.... // HoM&M3/4 fix....
if(((lpddsd->dwFlags & (DDSD_CAPS|DDSD_WIDTH|DDSD_HEIGHT)) == (DDSD_CAPS|DDSD_HEIGHT|DDSD_WIDTH)) && if(((lpddsd->dwFlags & (DDSD_CAPS|DDSD_WIDTH|DDSD_HEIGHT)) == (DDSD_CAPS|DDSD_HEIGHT|DDSD_WIDTH)) &&
(lpddsd->ddsCaps.dwCaps == (DDSCAPS_OFFSCREENPLAIN|DDSCAPS_VIDEOMEMORY))){ ((lpddsd->ddsCaps.dwCaps & ~(DDSCAPS_SYSTEMMEMORY|DDSCAPS_VIDEOMEMORY) == DDSCAPS_OFFSCREENPLAIN)){
lpddsd->ddsCaps.dwCaps = 0; //lpddsd->ddsCaps.dwCaps = 0;
lpddsd->dwFlags = (DDSD_CAPS|DDSD_HEIGHT|DDSD_WIDTH|DDSD_PIXELFORMAT);
lpddsd->ddsCaps.dwCaps = (DDSCAPS_OFFSCREENPLAIN|DDSCAPS_SYSTEMMEMORY);
GetPixFmt(lpddsd);
return; return;
} }
// HoM&M3/4 fix.... don't alter pixel format set to OFFSCREENPLAIN+SYSTEMMEMORY surface #endif
if(((lpddsd->dwFlags & (DDSD_CAPS|DDSD_WIDTH|DDSD_HEIGHT|DDSD_PIXELFORMAT)) == (DDSD_CAPS|DDSD_WIDTH|DDSD_HEIGHT|DDSD_PIXELFORMAT)) &&
(lpddsd->ddsCaps.dwCaps == (DDSCAPS_OFFSCREENPLAIN|DDSCAPS_SYSTEMMEMORY))){
return;
}
if(((lpddsd->dwFlags & (DDSD_CAPS|DDSD_WIDTH|DDSD_HEIGHT|DDSD_PIXELFORMAT)) == (DDSD_CAPS|DDSD_WIDTH|DDSD_HEIGHT|DDSD_PIXELFORMAT)) &&
(lpddsd->ddsCaps.dwCaps == (DDSCAPS_OFFSCREENPLAIN|DDSCAPS_SYSTEMMEMORY))){
return;
}
// default case: adjust pixel format // default case: adjust pixel format
OutTraceB("FixSurfaceCaps: suppress DDSCAPS_VIDEOMEMORY case\n"); OutTraceB("FixSurfaceCaps: suppress DDSCAPS_VIDEOMEMORY case\n");
lpddsd->dwFlags |= (DDSD_CAPS|DDSD_PIXELFORMAT); lpddsd->dwFlags |= (DDSD_CAPS|DDSD_PIXELFORMAT);
lpddsd->ddsCaps.dwCaps &= ~DDSCAPS_VIDEOMEMORY; lpddsd->ddsCaps.dwCaps &= ~DDSCAPS_VIDEOMEMORY;
lpddsd->ddsCaps.dwCaps |= (DDSCAPS_SYSTEMMEMORY|DDSCAPS_OFFSCREENPLAIN); lpddsd->ddsCaps.dwCaps |= (DDSCAPS_SYSTEMMEMORY|DDSCAPS_OFFSCREENPLAIN);
SetPixFmt(lpddsd); if(!(dxw.dwFlags3 & NOPIXELFORMAT)) GetPixFmt(lpddsd);
return; return;
} }
@ -2322,6 +2306,14 @@ static HRESULT BuildPrimaryEmu(LPDIRECTDRAW lpdd, CreateSurface_Type pCreateSurf
// emulated primary surface // emulated primary surface
memcpy((void *)&ddsd, lpddsd, lpddsd->dwSize); memcpy((void *)&ddsd, lpddsd, lpddsd->dwSize);
// handle the surface attributes before the ddsd.dwFlags gets updated:
// if a surface desc is NOT specified, build one
if(!(ddsd.dwFlags & DDSD_PIXELFORMAT)) SetPixFmt((LPDDSURFACEDESC2)&ddsd);
// then save it
dxw.VirtualPixelFormat = ddsd.ddpfPixelFormat;
OutTraceD("DDSD_PIXELFORMAT: color=%d flags=%x\n", dxw.VirtualPixelFormat.dwRGBBitCount, dxw.VirtualPixelFormat.dwFlags);
ddsd.dwFlags &= ~(DDSD_BACKBUFFERCOUNT|DDSD_REFRESHRATE); ddsd.dwFlags &= ~(DDSD_BACKBUFFERCOUNT|DDSD_REFRESHRATE);
ddsd.dwFlags |= (DDSD_CAPS|DDSD_WIDTH|DDSD_HEIGHT|DDSD_PIXELFORMAT); ddsd.dwFlags |= (DDSD_CAPS|DDSD_WIDTH|DDSD_HEIGHT|DDSD_PIXELFORMAT);
ddsd.ddsCaps.dwCaps &= ~(DDSCAPS_PRIMARYSURFACE|DDSCAPS_FLIP|DDSCAPS_COMPLEX|DDSCAPS_VIDEOMEMORY|DDSCAPS_LOCALVIDMEM); ddsd.ddsCaps.dwCaps &= ~(DDSCAPS_PRIMARYSURFACE|DDSCAPS_FLIP|DDSCAPS_COMPLEX|DDSCAPS_VIDEOMEMORY|DDSCAPS_LOCALVIDMEM);
@ -2329,7 +2321,6 @@ static HRESULT BuildPrimaryEmu(LPDIRECTDRAW lpdd, CreateSurface_Type pCreateSurf
ddsd.ddsCaps.dwCaps |= (DDSCAPS_SYSTEMMEMORY|DDSCAPS_OFFSCREENPLAIN); ddsd.ddsCaps.dwCaps |= (DDSCAPS_SYSTEMMEMORY|DDSCAPS_OFFSCREENPLAIN);
ddsd.dwWidth = dxw.GetScreenWidth(); ddsd.dwWidth = dxw.GetScreenWidth();
ddsd.dwHeight = dxw.GetScreenHeight(); ddsd.dwHeight = dxw.GetScreenHeight();
SetPixFmt((LPDDSURFACEDESC2)&ddsd);
// create Primary surface // create Primary surface
DumpSurfaceAttributes((LPDDSURFACEDESC)&ddsd, "[Primary]" , __LINE__); DumpSurfaceAttributes((LPDDSURFACEDESC)&ddsd, "[Primary]" , __LINE__);
@ -2358,7 +2349,7 @@ static HRESULT BuildPrimaryEmu(LPDIRECTDRAW lpdd, CreateSurface_Type pCreateSurf
ClearSurfaceDesc((void *)&ddsd, dxversion); ClearSurfaceDesc((void *)&ddsd, dxversion);
ddsd.dwFlags = DDSD_CAPS; ddsd.dwFlags = DDSD_CAPS;
ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE; ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
SetPixFmt(&ddsd); GetPixFmt(&ddsd);
DumpSurfaceAttributes((LPDDSURFACEDESC)&ddsd, "[EmuPrim]" , __LINE__); DumpSurfaceAttributes((LPDDSURFACEDESC)&ddsd, "[EmuPrim]" , __LINE__);
res=(*pCreateSurface)(lpdd, &ddsd, &lpDDSEmu_Prim, 0); res=(*pCreateSurface)(lpdd, &ddsd, &lpDDSEmu_Prim, 0);
@ -2477,7 +2468,7 @@ static HRESULT BuildBackBufferEmu(LPDIRECTDRAW lpdd, CreateSurface_Type pCreateS
ddsd.ddsCaps.dwCaps |= (DDSCAPS_SYSTEMMEMORY|DDSCAPS_OFFSCREENPLAIN); ddsd.ddsCaps.dwCaps |= (DDSCAPS_SYSTEMMEMORY|DDSCAPS_OFFSCREENPLAIN);
ddsd.dwWidth = dxw.GetScreenWidth(); ddsd.dwWidth = dxw.GetScreenWidth();
ddsd.dwHeight = dxw.GetScreenHeight(); ddsd.dwHeight = dxw.GetScreenHeight();
SetPixFmt(&ddsd); GetPixFmt(&ddsd);
DumpSurfaceAttributes((LPDDSURFACEDESC)&ddsd, "[Backbuf]" , __LINE__); DumpSurfaceAttributes((LPDDSURFACEDESC)&ddsd, "[Backbuf]" , __LINE__);
res=(*pCreateSurface)(lpdd, &ddsd, lplpdds, 0); res=(*pCreateSurface)(lpdd, &ddsd, lplpdds, 0);
@ -2977,11 +2968,13 @@ HRESULT WINAPI sBlt(char *api, LPDIRECTDRAWSURFACE lpdds, LPRECT lpdestrect,
// debug suppressions // debug suppressions
if(ToPrim){ if(ToPrim){
if(isFlipping) if(isFlipping){
if(dxw.dwFlags3 & NODDRAWFLIP) return DD_OK; if(dxw.dwFlags3 & NODDRAWFLIP) return DD_OK;
else }
else {
if(dxw.dwFlags3 & NODDRAWBLT) return DD_OK; if(dxw.dwFlags3 & NODDRAWBLT) return DD_OK;
} }
}
#ifdef ONEPIXELFIX #ifdef ONEPIXELFIX
if (lpdestrect){ if (lpdestrect){
@ -3033,6 +3026,8 @@ HRESULT WINAPI sBlt(char *api, LPDIRECTDRAWSURFACE lpdds, LPRECT lpdestrect,
res= (*pBlt)(lpdds, lpdestrect, lpddssrc, lpsrcrect ? &srcrect : NULL, dwflags, lpddbltfx); 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 // 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. // trying blitting directly to lpDDSEmu_Prim: it makes DK2 intro movies working.
// Wrong guess!!! The cause was not compression, but simply a pixelformat mismatch. Better
// configure things properly and avoid this branch.
switch(res){ switch(res){
case DDERR_UNSUPPORTED: case DDERR_UNSUPPORTED:
if (dxw.dwFlags1 & EMULATESURFACE){ if (dxw.dwFlags1 & EMULATESURFACE){
@ -3338,44 +3333,6 @@ HRESULT WINAPI extBltFast(LPDIRECTDRAWSURFACE lpdds, DWORD dwx, DWORD dwy,
return ret; return ret;
} }
#define DDPCAPS_INITIALIZE_LEGACY 0x00000008l
HRESULT WINAPI extCreatePalette(LPDIRECTDRAW lpdd, DWORD dwflags, LPPALETTEENTRY lpddpa,
LPDIRECTDRAWPALETTE *lplpddp, IUnknown *pu)
{
HRESULT res;
OutTraceD("CreatePalette: dwFlags=%x(%s)\n", dwflags, ExplainCreatePaletteFlags(dwflags));
if(!(dxw.dwFlags1 & EMULATESURFACE)){
res = (*pCreatePalette)(lpdd, dwflags, lpddpa, lplpddp, pu);
if (res) {
OutTraceD("CreatePalette: res=%x(%s)\n", res, ExplainDDError(res));
return res;
}
HookDDPalette(lplpddp);
OutTraceD("CreatePalette: GENUINE lpddp=%x\n", *lplpddp);
return res;
}
if (dwflags & ~(DDPCAPS_PRIMARYSURFACE|DDPCAPS_8BIT|DDPCAPS_ALLOW256|DDPCAPS_INITIALIZE_LEGACY)) STOPPER("Palette flags");
res = (*pCreatePalette)(lpdd, dwflags & ~DDPCAPS_PRIMARYSURFACE, lpddpa, lplpddp, pu);
if(res) {
if (res) OutTraceD("CreatePalette: res=%x(%s)\n", res, ExplainDDError(res));
return res;
}
HookDDPalette(lplpddp);
if((dwflags & (DDPCAPS_8BIT|DDPCAPS_PRIMARYSURFACE)) == (DDPCAPS_8BIT|DDPCAPS_PRIMARYSURFACE)){ // v2.02.39
mySetPalette(0, 256, lpddpa);
lpDDP = *lplpddp;
}
OutTraceD("CreatePalette: EMULATED lpddp=%x\n", *lplpddp);
return 0;
}
HRESULT WINAPI extWaitForVerticalBlank(LPDIRECTDRAW lpdd, DWORD dwflags, HANDLE hevent) HRESULT WINAPI extWaitForVerticalBlank(LPDIRECTDRAW lpdd, DWORD dwflags, HANDLE hevent)
{ {
static DWORD time = 0; static DWORD time = 0;
@ -3391,7 +3348,37 @@ HRESULT WINAPI extWaitForVerticalBlank(LPDIRECTDRAW lpdd, DWORD dwflags, HANDLE
return 0; return 0;
} }
// extGetPalette: To revise completely. #define DDPCAPS_INITIALIZE_LEGACY 0x00000008l
HRESULT WINAPI extCreatePalette(LPDIRECTDRAW lpdd, DWORD dwflags, LPPALETTEENTRY lpddpa,
LPDIRECTDRAWPALETTE *lplpddp, IUnknown *pu)
{
HRESULT res;
OutTraceD("CreatePalette: dwFlags=%x(%s)\n", dwflags, ExplainCreatePaletteFlags(dwflags));
if(IsDebug && (dwflags & DDPCAPS_8BIT)){
int idx;
OutTrace("CreatePalette: ");
for(idx=0; idx<256; idx++) OutTrace("(%02x.%02x.%02x)",
lpddpa[idx].peRed,
lpddpa[idx].peGreen,
lpddpa[idx].peBlue );
OutTrace("\n");
}
if (dwflags & ~(DDPCAPS_PRIMARYSURFACE|DDPCAPS_8BIT|DDPCAPS_ALLOW256|DDPCAPS_INITIALIZE_LEGACY)) STOPPER("Palette flags");
if(dxw.dwFlags1 & EMULATESURFACE) dwflags &= ~DDPCAPS_PRIMARYSURFACE;
res = (*pCreatePalette)(lpdd, dwflags, lpddpa, lplpddp, pu);
if (res) {
OutTraceE("CreatePalette: ERROR res=%x(%s)\n", res, ExplainDDError(res));
return res;
}
else OutTrace("CreatePalette: OK lpddp=%x\n", *lplpddp);
HookDDPalette(lplpddp);
return 0;
}
HRESULT WINAPI extGetPalette(LPDIRECTDRAWSURFACE lpdds, LPDIRECTDRAWPALETTE *lplpddp) HRESULT WINAPI extGetPalette(LPDIRECTDRAWSURFACE lpdds, LPDIRECTDRAWPALETTE *lplpddp)
{ {
@ -3399,24 +3386,10 @@ HRESULT WINAPI extGetPalette(LPDIRECTDRAWSURFACE lpdds, LPDIRECTDRAWPALETTE *lpl
OutTraceD("GetPalette: lpdds=%x\n", lpdds); OutTraceD("GetPalette: lpdds=%x\n", lpdds);
// if NO-EMU mode, just proxy the call res=(*pGetPalette)(lpdds, lplpddp);
if(!(dxw.dwFlags1 & EMULATESURFACE)){ if (res) OutTraceE("GetPalette: ERROR res=%x(%s)\n", res, ExplainDDError(res));
res=(*pGetPalette)(lpdds, lplpddp); else OutTrace("GetPalette: OK\n");
if (res) OutTraceE("GetPalette: ERROR res=%x(%s)\n", res, ExplainDDError(res)); return res;
return 0;
return res;
}
// in EMU mode, return the global palette ptr
if (lpDDP){
*lplpddp = lpDDP;
return 0;
}
else {
OutTraceD("GetPalette: ASSERT no lpDDP\n");
*lplpddp = lpDDP;
return DDERR_NOPALETTEATTACHED;
}
} }
HRESULT WINAPI extSetPalette(LPDIRECTDRAWSURFACE lpdds, LPDIRECTDRAWPALETTE lpddp) HRESULT WINAPI extSetPalette(LPDIRECTDRAWSURFACE lpdds, LPDIRECTDRAWPALETTE lpddp)
@ -3425,17 +3398,17 @@ HRESULT WINAPI extSetPalette(LPDIRECTDRAWSURFACE lpdds, LPDIRECTDRAWPALETTE lpdd
BOOL isPrim; BOOL isPrim;
HRESULT res; HRESULT res;
dxw.IsGDIPalette=FALSE;
isPrim=dxw.IsAPrimarySurface(lpdds); isPrim=dxw.IsAPrimarySurface(lpdds);
OutTraceD("SetPalette: lpdds=%x%s lpddp=%x\n", lpdds, isPrim?"(PRIM)":"", lpddp); OutTraceD("SetPalette: lpdds=%x%s lpddp=%x\n", lpdds, isPrim?"(PRIM)":"", lpddp);
res=(*pSetPalette)(lpdds, lpddp); res=(*pSetPalette)(lpdds, lpddp);
res=DD_OK;
if(res)OutTraceE("SetPalette: ERROR res=%x(%s) at %d\n", res, ExplainDDError(res), __LINE__); if(res)OutTraceE("SetPalette: ERROR res=%x(%s) at %d\n", res, ExplainDDError(res), __LINE__);
else OutTrace("SetPalette: OK\n");
if(dxw.dwFlags1 & EMULATESURFACE){ if((dxw.dwFlags1 & EMULATESURFACE) && isPrim){
OutTraceD("SetPalette: DEBUG emulating palette\n"); OutTraceD("SetPalette: register PRIMARY palette lpDDP=%x\n", lpddp);
lpDDP = lpddp; lpDDP = lpddp;
if(lpddp){ if(lpddp){
HRESULT res2; HRESULT res2;
lpentries = (LPPALETTEENTRY)PaletteEntries; lpentries = (LPPALETTEENTRY)PaletteEntries;
@ -3453,31 +3426,30 @@ HRESULT WINAPI extSetEntries(LPDIRECTDRAWPALETTE lpddp, DWORD dwflags, DWORD dws
{ {
HRESULT res; HRESULT res;
dxw.IsGDIPalette=FALSE;
OutTraceD("SetEntries: lpddp=%x dwFlags=%x, start=%d, count=%d entries=%x\n", //GHO: added trace infos OutTraceD("SetEntries: lpddp=%x dwFlags=%x, start=%d, count=%d entries=%x\n", //GHO: added trace infos
lpddp, dwflags, dwstart, dwcount, lpentries); lpddp, dwflags, dwstart, dwcount, lpentries);
res = (*pSetEntries)(lpddp, dwflags, dwstart, dwcount, lpentries); res = (*pSetEntries)(lpddp, dwflags, dwstart, dwcount, lpentries);
if(res) OutTraceE("SetEntries: ERROR res=%x(%s)\n", res, ExplainDDError(res)); if(res) OutTraceE("SetEntries: ERROR res=%x(%s)\n", res, ExplainDDError(res));
else OutTrace("SetEntries: OK\n");
if(!(dxw.dwFlags1 & EMULATESURFACE) || lpDDP != lpddp){ if((dxw.dwFlags1 & EMULATESURFACE) && (lpDDP == lpddp)){
return res; OutTraceD("SetEntries: update PRIMARY palette lpDDP=%x\n", lpddp);
if ((dwstart + dwcount > 256) || (dwstart<0)){
dwcount=256;
dwstart=0;
OutTraceD("SetEntries: ASSERT start+count > 256\n");
}
mySetPalette(dwstart, dwcount, lpentries);
// GHO: needed for fixed rect and variable palette animations,
// e.g. dungeon keeper loading screen, Warcraft II splash, ...
// GHO: but refreshing cause flickering when GDI was used without updating the primary surface
// e.g. Tomb Raider 2 intro titles, Virtua Fighter PC, ...
if ((dxw.dwFlags1 & EMULATESURFACE) && !(dxw.dwFlags2 & NOPALETTEUPDATE)) dxw.ScreenRefresh();
} }
return res;
if ((dwstart + dwcount > 256) || (dwstart<0)){
dwcount=256;
dwstart=0;
OutTraceD("SetEntries: ASSERT start+count > 256\n");
}
mySetPalette(dwstart, dwcount, lpentries);
// GHO: needed for fixed rect and variable palette animations,
// e.g. dungeon keeper loading screen, Warcraft II splash, ...
// GHO: but refreshing cause flickering when GDI was used without updating the primary surface
// e.g. Tomb Raider 2 intro titles
if ((dxw.dwFlags1 & EMULATESURFACE) && !(dxw.dwFlags2 & NOPALETTEUPDATE)) dxw.ScreenRefresh();
return 0;
} }
HRESULT WINAPI extSetClipper(LPDIRECTDRAWSURFACE lpdds, LPDIRECTDRAWCLIPPER lpddc) HRESULT WINAPI extSetClipper(LPDIRECTDRAWSURFACE lpdds, LPDIRECTDRAWCLIPPER lpddc)
@ -3772,7 +3744,6 @@ HRESULT WINAPI extFlipToGDISurface(LPDIRECTDRAW lpdd)
//HRESULT res; //HRESULT res;
OutTraceD("FlipToGDISurface: lpdd=%x\n", lpdd); OutTraceD("FlipToGDISurface: lpdd=%x\n", lpdd);
STOPPER("FlipToGDISurface");
// to revise: so far, it seems the best thing to do is NOTHING, just return 0. // to revise: so far, it seems the best thing to do is NOTHING, just return 0.
//res=(*pFlipToGDISurface)(lpdd); //res=(*pFlipToGDISurface)(lpdd);
//if (res) OutTraceE("FlipToGDISurface: ERROR res=%x(%s), skipping\n", res, ExplainDDError(res)); //if (res) OutTraceE("FlipToGDISurface: ERROR res=%x(%s), skipping\n", res, ExplainDDError(res));
@ -3814,14 +3785,7 @@ HRESULT WINAPI EnumModesCallbackDumper(LPDDSURFACEDESC lpDDSurfaceDesc, LPVOID l
OutTrace("\tdwBackBufferCount=%d\n", lpDDSurfaceDesc->dwBackBufferCount); OutTrace("\tdwBackBufferCount=%d\n", lpDDSurfaceDesc->dwBackBufferCount);
OutTrace("\tdwRefreshRate=%d\n", lpDDSurfaceDesc->dwRefreshRate); OutTrace("\tdwRefreshRate=%d\n", lpDDSurfaceDesc->dwRefreshRate);
OutTrace("\tlpSurface=%x\n", lpDDSurfaceDesc->lpSurface); OutTrace("\tlpSurface=%x\n", lpDDSurfaceDesc->lpSurface);
OutTrace("\tddpfPixelFormat.dwSize=%D\n", lpDDSurfaceDesc->ddpfPixelFormat.dwSize); OutTrace("\tddpfPixelFormat %s\n", DumpPixelFormat((LPDDSURFACEDESC2)lpDDSurfaceDesc));
OutTrace("\tddpfPixelFormat.dwFlags=%x\n", lpDDSurfaceDesc->ddpfPixelFormat.dwFlags);
OutTrace("\tddpfPixelFormat.dwRGBBitCount=%d\n", lpDDSurfaceDesc->ddpfPixelFormat.dwRGBBitCount);
OutTrace("\tddpfPixelFormat.dwARGBBitMask=(%x,%x,%x,%x)\n",
lpDDSurfaceDesc->ddpfPixelFormat.dwRGBAlphaBitMask,
lpDDSurfaceDesc->ddpfPixelFormat.dwRBitMask,
lpDDSurfaceDesc->ddpfPixelFormat.dwGBitMask,
lpDDSurfaceDesc->ddpfPixelFormat.dwBBitMask);
return DDENUMRET_OK; return DDENUMRET_OK;
} }

View File

@ -298,30 +298,43 @@ char *ExplainDDFXCaps(DWORD c)
return(eb); return(eb);
} }
char *ExplainDDPalCaps(DWORD c)
{
static char eb[256];
unsigned int l;
strcpy(eb,"DDPCAPS_");
if (c & DDPCAPS_ALPHA) strcat(eb, "ALPHA+");
if (c & DDPCAPS_PRIMARYSURFACE) strcat(eb, "PRIMARYSURFACE+");
l=strlen(eb);
if (l>strlen("DDPCAPS_")) eb[l-1]=0; // delete last '+' if any
else eb[0]=0;
return(eb);
}
char *ExplainDDCKeyCaps(DWORD c) char *ExplainDDCKeyCaps(DWORD c)
{ {
static char eb[512]; static char eb[512];
unsigned int l; unsigned int l;
strcpy(eb,"DDCKEYCAPS_"); strcpy(eb,"DDCKEYCAPS_");
if (c & DDCKEYCAPS_DESTBLT) strcat(eb, "DDCKEYCAPS_DESTBLT+"); if (c & DDCKEYCAPS_DESTBLT) strcat(eb, "DESTBLT+");
if (c & DDCKEYCAPS_DESTBLTCLRSPACE) strcat(eb, "DDCKEYCAPS_DESTBLTCLRSPACE+"); if (c & DDCKEYCAPS_DESTBLTCLRSPACE) strcat(eb, "DESTBLTCLRSPACE+");
if (c & DDCKEYCAPS_DESTBLTCLRSPACEYUV) strcat(eb, "DDCKEYCAPS_DESTBLTCLRSPACEYUV+"); if (c & DDCKEYCAPS_DESTBLTCLRSPACEYUV) strcat(eb, "DESTBLTCLRSPACEYUV+");
if (c & DDCKEYCAPS_DESTBLTYUV) strcat(eb, "DDCKEYCAPS_DESTBLTYUV+"); if (c & DDCKEYCAPS_DESTBLTYUV) strcat(eb, "DESTBLTYUV+");
if (c & DDCKEYCAPS_DESTOVERLAY) strcat(eb, "DDCKEYCAPS_DESTOVERLAY+"); if (c & DDCKEYCAPS_DESTOVERLAY) strcat(eb, "DESTOVERLAY+");
if (c & DDCKEYCAPS_DESTOVERLAYCLRSPACE) strcat(eb, "DDCKEYCAPS_DESTOVERLAYCLRSPACE+"); if (c & DDCKEYCAPS_DESTOVERLAYCLRSPACE) strcat(eb, "DESTOVERLAYCLRSPACE+");
if (c & DDCKEYCAPS_DESTOVERLAYCLRSPACEYUV) strcat(eb, "DDCKEYCAPS_DESTOVERLAYCLRSPACEYUV+"); if (c & DDCKEYCAPS_DESTOVERLAYCLRSPACEYUV) strcat(eb, "DESTOVERLAYCLRSPACEYUV+");
if (c & DDCKEYCAPS_DESTOVERLAYONEACTIVE) strcat(eb, "DDCKEYCAPS_DESTOVERLAYONEACTIVE+"); if (c & DDCKEYCAPS_DESTOVERLAYONEACTIVE) strcat(eb, "DESTOVERLAYONEACTIVE+");
if (c & DDCKEYCAPS_DESTOVERLAYYUV) strcat(eb, "DDCKEYCAPS_DESTOVERLAYYUV+"); if (c & DDCKEYCAPS_DESTOVERLAYYUV) strcat(eb, "DESTOVERLAYYUV+");
if (c & DDCKEYCAPS_SRCBLT) strcat(eb, "DDCKEYCAPS_SRCBLT+"); if (c & DDCKEYCAPS_SRCBLT) strcat(eb, "SRCBLT+");
if (c & DDCKEYCAPS_SRCBLTCLRSPACE) strcat(eb, "DDCKEYCAPS_SRCBLTCLRSPACE+"); if (c & DDCKEYCAPS_SRCBLTCLRSPACE) strcat(eb, "SRCBLTCLRSPACE+");
if (c & DDCKEYCAPS_SRCBLTCLRSPACEYUV) strcat(eb, "DDCKEYCAPS_SRCBLTCLRSPACEYUV+"); if (c & DDCKEYCAPS_SRCBLTCLRSPACEYUV) strcat(eb, "SRCBLTCLRSPACEYUV+");
if (c & DDCKEYCAPS_SRCBLTYUV) strcat(eb, "DDCKEYCAPS_SRCBLTYUV+"); if (c & DDCKEYCAPS_SRCBLTYUV) strcat(eb, "SRCBLTYUV+");
if (c & DDCKEYCAPS_SRCOVERLAY) strcat(eb, "DDCKEYCAPS_SRCOVERLAY+"); if (c & DDCKEYCAPS_SRCOVERLAY) strcat(eb, "SRCOVERLAY+");
if (c & DDCKEYCAPS_SRCOVERLAYCLRSPACE) strcat(eb, "DDCKEYCAPS_SRCOVERLAYCLRSPACE+"); if (c & DDCKEYCAPS_SRCOVERLAYCLRSPACE) strcat(eb, "SRCOVERLAYCLRSPACE+");
if (c & DDCKEYCAPS_SRCOVERLAYCLRSPACEYUV) strcat(eb, "DDCKEYCAPS_SRCOVERLAYCLRSPACEYUV+"); if (c & DDCKEYCAPS_SRCOVERLAYCLRSPACEYUV) strcat(eb, "SRCOVERLAYCLRSPACEYUV+");
if (c & DDCKEYCAPS_SRCOVERLAYONEACTIVE) strcat(eb, "DDCKEYCAPS_SRCOVERLAYONEACTIVE+"); if (c & DDCKEYCAPS_SRCOVERLAYONEACTIVE) strcat(eb, "SRCOVERLAYONEACTIVE+");
if (c & DDCKEYCAPS_SRCOVERLAYYUV) strcat(eb, "DDCKEYCAPS_SRCOVERLAYYUV+"); if (c & DDCKEYCAPS_SRCOVERLAYYUV) strcat(eb, "SRCOVERLAYYUV+");
if (c & DDCKEYCAPS_NOCOSTOVERLAY) strcat(eb, "DDCKEYCAPS_NOCOSTOVERLAY+"); if (c & DDCKEYCAPS_NOCOSTOVERLAY) strcat(eb, "NOCOSTOVERLAY+");
l=strlen(eb); l=strlen(eb);
if (l>strlen("DDCKEYCAPS_")) eb[l-1]=0; // delete last '+' if any if (l>strlen("DDCKEYCAPS_")) eb[l-1]=0; // delete last '+' if any
else eb[0]=0; else eb[0]=0;
@ -1521,8 +1534,16 @@ char *ExplainGetDCExFlags(DWORD c)
return(eb); return(eb);
} }
char *ExplainPaletteUse(UINT uUsage)
{
char *eb = SYSPAL_ERROR;
switch(uUsage){
case SYSPAL_STATIC: eb="SYSPAL_STATIC"; break;
case SYSPAL_NOSTATIC: eb="SYSPAL_NOSTATIC"; break;
case SYSPAL_NOSTATIC256: eb="SYSPAL_NOSTATIC256"; break;
}
return eb;
}

View File

@ -7,6 +7,7 @@ extern char *ExplainDDSCaps2(DWORD);
extern char *ExplainDDSCaps3(DWORD); extern char *ExplainDDSCaps3(DWORD);
extern char *ExplainDDDCaps(DWORD); extern char *ExplainDDDCaps(DWORD);
extern char *ExplainDDDCaps2(DWORD); extern char *ExplainDDDCaps2(DWORD);
extern char *ExplainDDPalCaps(DWORD);
extern char *ExplainDDFXALPHACaps(DWORD); extern char *ExplainDDFXALPHACaps(DWORD);
extern char *ExplainDDFXCaps(DWORD); extern char *ExplainDDFXCaps(DWORD);
extern char *ExplainDDCKeyCaps(DWORD); extern char *ExplainDDCKeyCaps(DWORD);
@ -43,3 +44,4 @@ extern char *ExplainRegType(DWORD);
extern char *ExplainDCType(DWORD); extern char *ExplainDCType(DWORD);
extern char *ExplainPeekRemoveMsg(DWORD); extern char *ExplainPeekRemoveMsg(DWORD);
extern char *ExplainGetDCExFlags(DWORD); extern char *ExplainGetDCExFlags(DWORD);
extern char *ExplainPaletteUse(UINT);

View File

@ -59,9 +59,9 @@ static char *Flag3Names[32]={
"SAVECAPS", "SINGLEPROCAFFINITY", "EMULATEREGISTRY", "CDROMDRIVETYPE", "SAVECAPS", "SINGLEPROCAFFINITY", "EMULATEREGISTRY", "CDROMDRIVETYPE",
"NOWINDOWMOVE", "DISABLEHAL", "LOCKSYSCOLORS", "EMULATEDC", "NOWINDOWMOVE", "DISABLEHAL", "LOCKSYSCOLORS", "EMULATEDC",
"FULLSCREENONLY", "FONTBYPASS", "YUV2RGB", "RGB2YUV", "FULLSCREENONLY", "FONTBYPASS", "YUV2RGB", "RGB2YUV",
"BUFFEREDIOFIX", "FILTERMESSAGES", "Flags3:23", "Flags3:24", "BUFFEREDIOFIX", "FILTERMESSAGES", "PEEKALLMESSAGES", "SURFACEWARN",
"Flags3:25", "Flags3:26", "Flags3:27", "Flags3:28", "ANALYTICMODE", "FORCESHEL", "CAPMASK", "COLORFIX",
"Flags3:29", "Flags3:30", "Flags3:31", "Flags3:32", "NODDRAWBLT", "NODDRAWFLIP", "NOGDIBLT", "NOPIXELFORMAT",
}; };
static char *Flag4Names[32]={ static char *Flag4Names[32]={
@ -490,12 +490,12 @@ void *HookAPI(HMODULE module, char *dll, void *apiproc, const char *apiname, voi
__try{ __try{
pnth = PIMAGE_NT_HEADERS(PBYTE(base) + PIMAGE_DOS_HEADER(base)->e_lfanew); pnth = PIMAGE_NT_HEADERS(PBYTE(base) + PIMAGE_DOS_HEADER(base)->e_lfanew);
if(!pnth) { if(!pnth) {
OutTraceE("HookAPI: ERROR no PNTH at %d\n", __LINE__); OutTraceH("HookAPI: ERROR no PNTH at %d\n", __LINE__);
return 0; return 0;
} }
rva = pnth->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_IMPORT].VirtualAddress; rva = pnth->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_IMPORT].VirtualAddress;
if(!rva) { if(!rva) {
OutTraceE("HookAPI: ERROR no RVA at %d\n", __LINE__); OutTraceH("HookAPI: ERROR no RVA at %d\n", __LINE__);
return 0; return 0;
} }
pidesc = (PIMAGE_IMPORT_DESCRIPTOR)(base + rva); pidesc = (PIMAGE_IMPORT_DESCRIPTOR)(base + rva);
@ -778,6 +778,17 @@ LRESULT CALLBACK extChildWindowProc(HWND hwnd, UINT message, WPARAM wparam, LPAR
return DefWindowProc(hwnd, message, wparam, lparam); return DefWindowProc(hwnd, message, wparam, lparam);
} }
static void dx_UpdatePositionLock(HWND hwnd)
{
RECT rect;
POINT p={0,0};
(*pGetClientRect)(hwnd,&rect);
(*pClientToScreen)(hwnd,&p);
dxw.dwFlags1 |= LOCKWINPOS;
OutTraceD("Toggle position lock ON\n");
dxw.InitWindowPos(p.x, p.y, rect.right-rect.left, rect.bottom-rect.top);
}
static void dx_TogglePositionLock(HWND hwnd) static void dx_TogglePositionLock(HWND hwnd)
{ {
// toggle position locking // toggle position locking
@ -787,15 +798,9 @@ static void dx_TogglePositionLock(HWND hwnd)
dxw.dwFlags1 &= ~LOCKWINPOS; dxw.dwFlags1 &= ~LOCKWINPOS;
} }
else { else {
// lock and update window position!!!
// v2.1.80: fixed
RECT rect;
POINT p={0,0};
(*pGetClientRect)(hwnd,&rect);
(*pClientToScreen)(hwnd,&p);
dxw.dwFlags1 |= LOCKWINPOS;
OutTraceD("Toggle position lock ON\n"); OutTraceD("Toggle position lock ON\n");
dxw.InitWindowPos(p.x, p.y, rect.right-rect.left, rect.bottom-rect.top); dxw.dwFlags1 |= LOCKWINPOS;
dx_UpdatePositionLock(hwnd);
} }
} }
@ -834,6 +839,13 @@ LRESULT CALLBACK extWindowProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lp
WNDPROC pWindowProc; WNDPROC pWindowProc;
extern void dxwFixWindowPos(char *, HWND, LPARAM); extern void dxwFixWindowPos(char *, HWND, LPARAM);
extern LPRECT lpClipRegion; extern LPRECT lpClipRegion;
static BOOL DoOnce = TRUE;
static BOOL IsToBeLocked;
if(DoOnce){
DoOnce=FALSE;
IsToBeLocked=(dxw.dwFlags1 & LOCKWINPOS);
}
// v2.1.93: adjust clipping region // v2.1.93: adjust clipping region
@ -974,11 +986,18 @@ LRESULT CALLBACK extWindowProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lp
OutTraceD("WindowProc: WM_WINDOWPOSCHANGING fixed size=(%d,%d)\n", wp->cx, wp->cy); OutTraceD("WindowProc: WM_WINDOWPOSCHANGING fixed size=(%d,%d)\n", wp->cx, wp->cy);
break; break;
case WM_ENTERSIZEMOVE: case WM_ENTERSIZEMOVE:
if(IsToBeLocked){
dxw.dwFlags1 &= ~LOCKWINPOS;
}
while((*pShowCursor)(1) < 0); while((*pShowCursor)(1) < 0);
if(dxw.dwFlags1 & CLIPCURSOR) dxw.EraseClipCursor(); if(dxw.dwFlags1 & CLIPCURSOR) dxw.EraseClipCursor();
if(dxw.dwFlags1 & ENABLECLIPPING) (*pClipCursor)(NULL); if(dxw.dwFlags1 & ENABLECLIPPING) (*pClipCursor)(NULL);
break; break;
case WM_EXITSIZEMOVE: case WM_EXITSIZEMOVE:
if(IsToBeLocked){
dxw.dwFlags1 |= LOCKWINPOS;
dx_UpdatePositionLock(hwnd);
}
if (dxw.dwFlags1 & HIDEHWCURSOR) while((*pShowCursor)(0) >= 0); if (dxw.dwFlags1 & HIDEHWCURSOR) while((*pShowCursor)(0) >= 0);
if (dxw.dwFlags2 & SHOWHWCURSOR) while((*pShowCursor)(1) < 0); if (dxw.dwFlags2 & SHOWHWCURSOR) while((*pShowCursor)(1) < 0);
if(dxw.dwFlags1 & ENABLECLIPPING) extClipCursor(lpClipRegion); if(dxw.dwFlags1 & ENABLECLIPPING) extClipCursor(lpClipRegion);

View File

@ -25,7 +25,7 @@ dxwCore::dxwCore()
TimeShift = 0; TimeShift = 0;
lpDDSPrimHDC = NULL; lpDDSPrimHDC = NULL;
//IsWithinDDraw = FALSE; //IsWithinDDraw = FALSE;
IsGDIPalette = FALSE; //IsGDIPalette = FALSE;
memset(PrimSurfaces, 0, sizeof(PrimSurfaces)); memset(PrimSurfaces, 0, sizeof(PrimSurfaces));
ResetEmulatedDC(); ResetEmulatedDC();
} }

View File

@ -105,7 +105,7 @@ public: // simple data variables
short iSizX; short iSizX;
short iSizY; short iSizY;
//BOOL IsWithinDDraw; // flag to avoid double intervention at ddraw & GDI level //BOOL IsWithinDDraw; // flag to avoid double intervention at ddraw & GDI level
BOOL IsGDIPalette; //BOOL IsGDIPalette;
char *CustomOpenGLLib; char *CustomOpenGLLib;
WORD palVersion; WORD palVersion;
WORD palNumEntries; WORD palNumEntries;

Binary file not shown.

View File

@ -24,7 +24,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "dxwnd.h" #include "dxwnd.h"
#include "dxwcore.hpp" #include "dxwcore.hpp"
#define VERSION "2.02.39" #define VERSION "2.02.40"
#define DDTHREADLOCK 1 #define DDTHREADLOCK 1

Binary file not shown.

1664
dll/gdi32.1.cpp Normal file

File diff suppressed because it is too large Load Diff

View File

@ -5,6 +5,22 @@
#include "dxhook.h" #include "dxhook.h"
#include "dxhelper.h" #include "dxhelper.h"
#include "stdio.h"
static void Stopper(char *s, int line)
{
char sMsg[81];
sprintf(sMsg,"break: \"%s\"", s);
MessageBox(0, sMsg, "break", MB_OK | MB_ICONEXCLAMATION);
}
#define STOPPER_TEST // comment out to eliminate
#ifdef STOPPER_TEST
#define STOPPER(s) Stopper(s, __LINE__)
#else
#define STOPPER(s)
#endif
/* /*
dlg->m_DCEmulationMode = 0; dlg->m_DCEmulationMode = 0;
if(t->flags2 & HOOKGDI) dlg->m_DCEmulationMode = 1; if(t->flags2 & HOOKGDI) dlg->m_DCEmulationMode = 1;
@ -17,15 +33,17 @@ static HookEntry_Type Hooks[]={
{"ScaleWindowExtEx", (FARPROC)ScaleWindowExtEx, (FARPROC *)&pGDIScaleWindowExtEx, (FARPROC)extScaleWindowExtEx}, {"ScaleWindowExtEx", (FARPROC)ScaleWindowExtEx, (FARPROC *)&pGDIScaleWindowExtEx, (FARPROC)extScaleWindowExtEx},
{"SaveDC", (FARPROC)SaveDC, (FARPROC *)&pGDISaveDC, (FARPROC)extGDISaveDC}, {"SaveDC", (FARPROC)SaveDC, (FARPROC *)&pGDISaveDC, (FARPROC)extGDISaveDC},
{"RestoreDC", (FARPROC)RestoreDC, (FARPROC *)&pGDIRestoreDC, (FARPROC)extGDIRestoreDC}, {"RestoreDC", (FARPROC)RestoreDC, (FARPROC *)&pGDIRestoreDC, (FARPROC)extGDIRestoreDC},
{"AnimatePalette", (FARPROC)AnimatePalette, (FARPROC *)&pAnimatePalette, (FARPROC)extAnimatePalette},
{"CreatePalette", (FARPROC)CreatePalette, (FARPROC *)&pGDICreatePalette, (FARPROC)extGDICreatePalette}, {"CreatePalette", (FARPROC)CreatePalette, (FARPROC *)&pGDICreatePalette, (FARPROC)extGDICreatePalette},
{"SelectPalette", (FARPROC)SelectPalette, (FARPROC *)&pGDISelectPalette, (FARPROC)extSelectPalette}, {"SelectPalette", (FARPROC)SelectPalette, (FARPROC *)&pGDISelectPalette, (FARPROC)extSelectPalette},
{"RealizePalette", (FARPROC)RealizePalette, (FARPROC *)&pGDIRealizePalette, (FARPROC)extRealizePalette}, {"RealizePalette", (FARPROC)RealizePalette, (FARPROC *)&pGDIRealizePalette, (FARPROC)extRealizePalette},
{"GetSystemPaletteEntries", (FARPROC)GetSystemPaletteEntries, (FARPROC *)&pGDIGetSystemPaletteEntries, (FARPROC)extGetSystemPaletteEntries}, {"GetSystemPaletteEntries", (FARPROC)GetSystemPaletteEntries, (FARPROC *)&pGDIGetSystemPaletteEntries, (FARPROC)extGetSystemPaletteEntries},
{"SetSystemPaletteUse", (FARPROC)SetSystemPaletteUse, (FARPROC *)&pSetSystemPaletteUse, (FARPROC)extSetSystemPaletteUse},
{"StretchDIBits", (FARPROC)StretchDIBits, (FARPROC *)&pStretchDIBits, (FARPROC)extStretchDIBits}, {"StretchDIBits", (FARPROC)StretchDIBits, (FARPROC *)&pStretchDIBits, (FARPROC)extStretchDIBits},
//{"SetDIBitsToDevice", (FARPROC)NULL, (FARPROC *)&pSetDIBitsToDevice, (FARPROC)extSetDIBitsToDevice}, //{"SetDIBitsToDevice", (FARPROC)NULL, (FARPROC *)&pSetDIBitsToDevice, (FARPROC)extSetDIBitsToDevice},
//{"CreateCompatibleBitmap", (FARPROC)NULL, (FARPROC *)&pCreateCompatibleBitmap, (FARPROC)extCreateCompatibleBitmap}, //{"CreateCompatibleBitmap", (FARPROC)NULL, (FARPROC *)&pCreateCompatibleBitmap, (FARPROC)extCreateCompatibleBitmap},
{0, NULL, 0, 0} // terminator {0, NULL, 0, 0} // terminator
}; };
static HookEntry_Type RemapHooks[]={ static HookEntry_Type RemapHooks[]={
{"SetViewportOrgEx", (FARPROC)SetViewportOrgEx, (FARPROC *)&pSetViewportOrgEx, (FARPROC)extSetViewportOrgEx}, // needed in ShowBanner {"SetViewportOrgEx", (FARPROC)SetViewportOrgEx, (FARPROC *)&pSetViewportOrgEx, (FARPROC)extSetViewportOrgEx}, // needed in ShowBanner
@ -131,10 +149,11 @@ void HookGDI32(HMODULE module)
if(dxw.dwFlags1 & CLIENTREMAPPING) if(dxw.dwFlags1 & CLIENTREMAPPING)
HookLibrary(module, RemapHooks, libname); HookLibrary(module, RemapHooks, libname);
if(dxw.dwFlags3 & EMULATEDC) if(dxw.dwFlags3 & EMULATEDC){
HookLibrary(module, EmulateHooks, libname); HookLibrary(module, EmulateHooks, libname);
HookLibrary(module, ScaledHooks, libname); HookLibrary(module, ScaledHooks, libname);
HookLibrary(module, GDIHooks, libname); HookLibrary(module, GDIHooks, libname);
}
if(dxw.dwFlags2 & HOOKGDI){ if(dxw.dwFlags2 & HOOKGDI){
HookLibrary(module, EmulateHooks, libname); HookLibrary(module, EmulateHooks, libname);
@ -441,7 +460,6 @@ int WINAPI extGDISaveDC(HDC hdc)
ret=(*pGDISaveDC)(hdc); ret=(*pGDISaveDC)(hdc);
OutTraceD("GDI.SaveDC: hdc=%x ret=%x\n", hdc, ret); OutTraceD("GDI.SaveDC: hdc=%x ret=%x\n", hdc, ret);
//AutoRefreshThread=CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)AutoRefresh, (LPVOID)hdc, 0, &dwThrdId);
return ret; return ret;
} }
@ -451,7 +469,6 @@ BOOL WINAPI extGDIRestoreDC(HDC hdc, int nSavedDC)
ret=(*pGDIRestoreDC)(hdc, nSavedDC); ret=(*pGDIRestoreDC)(hdc, nSavedDC);
OutTraceD("GDI.RestoreDC: hdc=%x nSavedDC=%x ret=%x\n", hdc, nSavedDC, ret); OutTraceD("GDI.RestoreDC: hdc=%x nSavedDC=%x ret=%x\n", hdc, nSavedDC, ret);
//TerminateThread(AutoRefreshThread, 0);
return ret; return ret;
} }
@ -466,7 +483,6 @@ HPALETTE WINAPI extGDICreatePalette(CONST LOGPALETTE *plpal)
HPALETTE ret; HPALETTE ret;
int idx; int idx;
dxw.IsGDIPalette=TRUE;
OutTraceD("GDI.CreatePalette: plpal=%x version=%x NumEntries=%x\n", plpal, plpal->palVersion, plpal->palNumEntries); OutTraceD("GDI.CreatePalette: plpal=%x version=%x NumEntries=%x\n", plpal, plpal->palVersion, plpal->palNumEntries);
ret=(*pGDICreatePalette)(plpal); ret=(*pGDICreatePalette)(plpal);
if(IsDebug){ if(IsDebug){
@ -474,76 +490,83 @@ HPALETTE WINAPI extGDICreatePalette(CONST LOGPALETTE *plpal)
for(idx=0; idx<plpal->palNumEntries; idx++) OutTraceD("(%x)", plpal->palPalEntry[idx]); for(idx=0; idx<plpal->palNumEntries; idx++) OutTraceD("(%x)", plpal->palPalEntry[idx]);
OutTraceD("\n"); OutTraceD("\n");
} }
dxw.palVersion=plpal->palVersion;
dxw.palNumEntries=plpal->palNumEntries;
if(dxw.palNumEntries>256) dxw.palNumEntries=256;
for(idx=0; idx<dxw.palNumEntries; idx++) dxw.palPalEntry[idx]=plpal->palPalEntry[idx];
OutTraceD("GDI.CreatePalette: hPalette=%x\n", ret); OutTraceD("GDI.CreatePalette: hPalette=%x\n", ret);
return ret; return ret;
} }
HPALETTE hDesktopPalette=NULL;
HPALETTE WINAPI extSelectPalette(HDC hdc, HPALETTE hpal, BOOL bForceBackground) HPALETTE WINAPI extSelectPalette(HDC hdc, HPALETTE hpal, BOOL bForceBackground)
{ {
HPALETTE ret; HPALETTE ret;
ret=(*pGDISelectPalette)(hdc, hpal, bForceBackground); ret=(*pGDISelectPalette)(hdc, hpal, bForceBackground);
OutTraceD("GDI.SelectPalette: hdc=%x hpal=%x ForceBackground=%x ret=%x\n", hdc, hpal, bForceBackground, ret); OutTraceD("GDI.SelectPalette: hdc=%x hpal=%x ForceBackground=%x ret=%x\n", hdc, hpal, bForceBackground, ret);
if((OBJ_DC == GetObjectType(hdc)) && (dxw.dwFlags1 & EMULATESURFACE)){
OutTraceD("GDI.SelectPalette: register desktop palette hpal=%x\n", hpal);
hDesktopPalette=hpal;
}
return ret; return ret;
} }
BOOL WINAPI extAnimatePalette(HPALETTE hpal, UINT iStartIndex, UINT cEntries, const PALETTEENTRY *ppe)
{
// Invoked by "Pharaoh's Ascent 1.4"
//STOPPER("AnimatePalette");
return TRUE;
}
UINT WINAPI extRealizePalette(HDC hdc) UINT WINAPI extRealizePalette(HDC hdc)
{ {
UINT ret; UINT ret;
extern void mySetPalette(int, int, LPPALETTEENTRY); extern void mySetPalette(int, int, LPPALETTEENTRY);
ret=(*pGDIRealizePalette)(hdc); OutTraceD("GDI.RealizePalette: hdc=%x\n", hdc);
OutTraceD("GDI.RealizePalette: hdc=%x ret=%x\n", hdc, ret); if((OBJ_DC == GetObjectType(hdc)) && (dxw.dwFlags1 & EMULATESURFACE)){
PALETTEENTRY PalEntries[256];
if(!dxw.IsGDIPalette) return ret; UINT nEntries;
nEntries=GetPaletteEntries(hDesktopPalette, 0, 255, PalEntries);
// quick & dirty implementation through a nasty global: mySetPalette(0, nEntries, PalEntries);
// if the SelectPalette didn't force to the background (arg bForceBackground==FALSE) if(IsDebug){
// then don't override the current palette set by the DirectDrawPalette class. UINT idx;
// should be cleaned up a little.... OutTraceD("PaletteEntries[%x]= ", nEntries);
// maybe not: now both Diablo & Dementia colors are working... for(idx=0; idx<256; idx++) OutTraceD("(%02x.%02x.%02x)", PalEntries[idx].peRed, PalEntries[idx].peGreen, PalEntries[idx].peBlue);
if(dxw.dwFlags1 & EMULATESURFACE) OutTraceD("\n");
mySetPalette(0, dxw.palNumEntries, dxw.palPalEntry); }
// DEBUGGING ret=DD_OK;
if(IsDebug){
int idx;
OutTraceD("PaletteEntries[%x]= ", dxw.palNumEntries);
for(idx=0; idx<dxw.palNumEntries; idx++) OutTraceD("(%x)", PaletteEntries[idx]);
OutTraceD("\n");
} }
else
ret=(*pGDIRealizePalette)(hdc);
OutTraceD("GDI.RealizePalette: hdc=%x ret=%x\n", hdc, ret);
return ret; return ret;
} }
// In emulated mode (when color depyth is 8BPP ?) it may happen that the game // In emulated mode (when color depyth is 8BPP ?) it may happen that the game
// expects to get the requested system palette entries, while the 32BPP screen // expects to get the requested system palette entries, while the 32BPP screen
// returns 0. "Mission Frce Cyberstorm" is one of these. Returning the same // returns 0. "Mission Force Cyberstorm" is one of these. Returning the same
// value as nEntries, even though lppe is untouched, fixes the problem. // value as nEntries, even though lppe is untouched, fixes the problem.
UINT WINAPI extGetSystemPaletteEntries(HDC hdc, UINT iStartIndex, UINT nEntries, LPPALETTEENTRY lppe) UINT WINAPI extGetSystemPaletteEntries(HDC hdc, UINT iStartIndex, UINT nEntries, LPPALETTEENTRY lppe)
{ {
int ret; int ret;
OutTraceD("GetSystemPaletteEntries: hdc=%x start=%d num=%d\n", hdc, iStartIndex, nEntries); OutTraceD("GetSystemPaletteEntries: hdc=%x start=%d num=%d\n", hdc, iStartIndex, nEntries);
ret=(*pGDIGetSystemPaletteEntries)(hdc, iStartIndex, nEntries, lppe); ret=(*pGDIGetSystemPaletteEntries)(hdc, iStartIndex, nEntries, lppe);
OutTraceD("GetSystemPaletteEntries: ret=%d\n", ret); OutTraceD("GetSystemPaletteEntries: ret=%d\n", ret);
if((ret == 0) && (dxw.dwFlags1 & EMULATESURFACE)) { if((ret == 0) && (dxw.dwFlags1 & EMULATESURFACE)) {
//OutTraceD("GetSystemPaletteEntries: fixing ret=%d\n", nEntries);
//ret = nEntries;
// this seems to build a more reasonable system palette .... // this seems to build a more reasonable system palette ....
HPALETTE hpal; HPALETTE hpal;
hpal=CreateHalftonePalette(NULL); hpal=CreateHalftonePalette(NULL);
GetPaletteEntries(hpal, iStartIndex, nEntries, lppe); ret = GetPaletteEntries(hpal, iStartIndex, nEntries, lppe);
ret = nEntries; //ret = nEntries;
OutTraceD("GetSystemPaletteEntries: fixing ret=%d\n", ret); OutTraceD("GetSystemPaletteEntries: fixing with halftone ret=%d\n", ret);
if(IsDebug){ if(IsDebug){
UINT idx; UINT idx;
OutTraceD("PaletteEntries[%x]= ", nEntries); OutTraceD("PaletteEntries[%x]= ", nEntries);
for(idx=0; idx<nEntries; idx++) OutTraceD("(%02x.%02x.%02x)", lppe[idx].peRed, lppe[idx].peGreen, lppe[idx].peBlue); for(idx=0; idx<nEntries; idx++) OutTraceD("(%02x.%02x.%02x)", lppe[idx].peRed, lppe[idx].peGreen, lppe[idx].peBlue);
OutTraceD("\n"); OutTraceD("\n");
} }
for(UINT idx=iStartIndex; idx<iStartIndex+nEntries; idx++) lppe[idx].peFlags=0; // not useful, but ....
} }
return ret; return ret;
} }
@ -591,6 +614,7 @@ BOOL WINAPI extDDDeleteDC(HDC hdc)
return res; return res;
} }
#if 1
static HDC WINAPI winDDGetDC(HWND hwnd, char *api) static HDC WINAPI winDDGetDC(HWND hwnd, char *api)
{ {
HDC hdc; HDC hdc;
@ -601,7 +625,6 @@ static HDC WINAPI winDDGetDC(HWND hwnd, char *api)
dxw.ResetPrimarySurface(); dxw.ResetPrimarySurface();
dxw.SetPrimarySurface(); dxw.SetPrimarySurface();
if(dxw.IsRealDesktop(hwnd)) hwnd=dxw.GethWnd(); if(dxw.IsRealDesktop(hwnd)) hwnd=dxw.GethWnd();
if(dxw.lpDDSPrimHDC){ if(dxw.lpDDSPrimHDC){
@ -637,6 +660,42 @@ static HDC WINAPI winDDGetDC(HWND hwnd, char *api)
OutTraceE("%s: ERROR err=%d at %d\n", api, GetLastError, __LINE__); OutTraceE("%s: ERROR err=%d at %d\n", api, GetLastError, __LINE__);
return(hdc); return(hdc);
} }
#else
HDC hPrimaryDC=NULL;
static HDC WINAPI winDDGetDC(HWND hwnd, char *api)
{
HDC hdc;
//HRESULT res;
//extern HRESULT WINAPI extGetDC(LPDIRECTDRAWSURFACE, HDC FAR *);
OutTraceD("%s: hwnd=%x\n", api, hwnd);
//dxw.ResetPrimarySurface();
//dxw.SetPrimarySurface();
if(dxw.IsRealDesktop(hwnd) && dxw.IsFullScreen()){
LPDIRECTDRAWSURFACE lpPrim;
HDC PrimDC;
lpPrim=dxw.GetPrimarySurface();
(*pGetDC)(lpPrim, &PrimDC);
hdc=(*pGDICreateCompatibleDC)(PrimDC);
(*pReleaseDC)(lpPrim, PrimDC);
OutTraceD("%s: returning DDRAW DC handle hwnd=%x hdc=%x\n", api, hwnd, hdc);
hPrimaryDC=hdc;
return hdc;
}
else {
hdc=(*pGDIGetDC)(hwnd ? hwnd : dxw.GethWnd());
OutTraceD("%s: returning window DC handle hwnd=%x hdc=%x\n", api, hwnd, hdc);
//PrimHDC=NULL;
}
if(hdc)
OutTraceD("%s: hwnd=%x hdc=%x\n", api, hwnd, hdc);
else
OutTraceE("%s: ERROR err=%d at %d\n", api, GetLastError, __LINE__);
return(hdc);
}
#endif
HDC WINAPI extDDCreateDC(LPSTR Driver, LPSTR Device, LPSTR Output, CONST DEVMODE *InitData) HDC WINAPI extDDCreateDC(LPSTR Driver, LPSTR Device, LPSTR Output, CONST DEVMODE *InitData)
{ {
@ -677,6 +736,7 @@ HDC WINAPI extDDGetWindowDC(HWND hwnd)
return ret; return ret;
} }
#if 1
int WINAPI extDDReleaseDC(HWND hwnd, HDC hDC) int WINAPI extDDReleaseDC(HWND hwnd, HDC hDC)
{ {
int res; int res;
@ -698,6 +758,27 @@ int WINAPI extDDReleaseDC(HWND hwnd, HDC hDC)
} }
return(res); return(res);
} }
#else
int WINAPI extDDReleaseDC(HWND hwnd, HDC hDC)
{
int res;
extern HRESULT WINAPI extReleaseDC(LPDIRECTDRAWSURFACE, HDC);
OutTraceD("GDI.ReleaseDC: hwnd=%x hdc=%x\n", hwnd, hDC);
res=0;
if (hDC == hPrimaryDC){
OutTraceD("GDI.ReleaseDC: refreshing primary surface lpdds=%x\n",dxw.lpDDSPrimHDC);
//extReleaseDC(dxw.lpDDSPrimHDC, hDC);
hPrimaryDC=NULL;
res=1; // 1 = OK
}
else {
res=(*pGDIReleaseDC)(hwnd, hDC);
if (!res) OutTraceE("GDI.ReleaseDC: ERROR err=%d at %d\n", GetLastError(), __LINE__);
}
return(res);
}
#endif
BOOL WINAPI extDDBitBlt(HDC hdcDest, int nXDest, int nYDest, int nWidth, int nHeight, HDC hdcSrc, int nXSrc, int nYSrc, DWORD dwRop) BOOL WINAPI extDDBitBlt(HDC hdcDest, int nXDest, int nYDest, int nWidth, int nHeight, HDC hdcSrc, int nXSrc, int nYSrc, DWORD dwRop)
{ {
@ -720,9 +801,7 @@ BOOL WINAPI extDDBitBlt(HDC hdcDest, int nXDest, int nYDest, int nWidth, int nHe
res=(*pGDIBitBlt)(hdcDest, nXDest, nYDest, nWidth, nHeight, hdcSrc, nXSrc, nYSrc, dwRop); res=(*pGDIBitBlt)(hdcDest, nXDest, nYDest, nWidth, nHeight, hdcSrc, nXSrc, nYSrc, dwRop);
if(!res) OutTraceE("GDI.BitBlt: ERROR err=%d at %d\n", GetLastError(), __LINE__); if(!res) OutTraceE("GDI.BitBlt: ERROR err=%d at %d\n", GetLastError(), __LINE__);
res=(*pGDIBitBlt)(NULL, nXDest, nYDest, nWidth, nHeight, hdcSrc, nXSrc, nYSrc, dwRop); res=(*pGDIBitBlt)(NULL, nXDest, nYDest, nWidth, nHeight, hdcSrc, nXSrc, nYSrc, dwRop);
if(!res) ret=0; if(!res) ret=0;
return ret; return ret;
} }
@ -806,14 +885,13 @@ BOOL WINAPI extGDIBitBlt(HDC hdcDest, int nXDest, int nYDest, int nWidth, int nH
OutTraceD("GDI.BitBlt: HDC=%x nXDest=%d nYDest=%d nWidth=%d nHeight=%d hdcSrc=%x nXSrc=%d nYSrc=%d dwRop=%x(%s)\n", OutTraceD("GDI.BitBlt: HDC=%x nXDest=%d nYDest=%d nWidth=%d nHeight=%d hdcSrc=%x nXSrc=%d nYSrc=%d dwRop=%x(%s)\n",
hdcDest, nXDest, nYDest, nWidth, nHeight, hdcSrc, nXSrc, nYSrc, dwRop, ExplainROP(dwRop)); hdcDest, nXDest, nYDest, nWidth, nHeight, hdcSrc, nXSrc, nYSrc, dwRop, ExplainROP(dwRop));
OutTraceB("GDI.StretchBlt: DEBUG FullScreen=%x target hdctype=%x(%s) hwnd=%x\n", OutTraceB("GDI.BitBlt: DEBUG FullScreen=%x target hdctype=%x(%s) hwnd=%x\n",
dxw.IsFullScreen(), GetObjectType(hdcDest), ExplainDCType(GetObjectType(hdcDest)), WindowFromDC(hdcDest)); dxw.IsFullScreen(), GetObjectType(hdcDest), ExplainDCType(GetObjectType(hdcDest)), WindowFromDC(hdcDest));
// beware: HDC could refer to screen DC that are written directly on screen, or memory DC that will be scaled to // beware: HDC could refer to screen DC that are written directly on screen, or memory DC that will be scaled to
// the screen surface later on, on ReleaseDC or ddraw Blit / Flip operation. Scaling of rect coordinates is // the screen surface later on, on ReleaseDC or ddraw Blit / Flip operation. Scaling of rect coordinates is
// needed only in the first case, and must be avoided on the second, otherwise the image would be scaled twice! // needed only in the first case, and must be avoided on the second, otherwise the image would be scaled twice!
res=0;
if (OBJ_DC == GetObjectType(hdcDest)){ if (OBJ_DC == GetObjectType(hdcDest)){
if (dxw.HandleFPS()) return TRUE; if (dxw.HandleFPS()) return TRUE;
if (dxw.dwFlags3 & NOGDIBLT) return TRUE; if (dxw.dwFlags3 & NOGDIBLT) return TRUE;
@ -836,6 +914,10 @@ BOOL WINAPI extGDIBitBlt(HDC hdcDest, int nXDest, int nYDest, int nWidth, int nH
if (dxw.dwFlags2 & SHOWFPSOVERLAY) dxw.ShowFPS(hdcDest); if (dxw.dwFlags2 & SHOWFPSOVERLAY) dxw.ShowFPS(hdcDest);
OutTrace("Debug: NULL dest=(%d,%d) size=(%d,%d)\n", nXDest, nYDest, nWDest, nHDest); OutTrace("Debug: NULL dest=(%d,%d) size=(%d,%d)\n", nXDest, nYDest, nWDest, nHDest);
} }
else{
res=(*pGDIBitBlt)(hdcDest, nXDest, nYDest, nWidth, nHeight, hdcSrc, nXSrc, nYSrc, dwRop);
OutTrace("Debug: PROXY dest=(%d,%d) size=(%d,%d)\n", nXDest, nYDest, nWidth, nHeight);
}
} }
else { else {
res=(*pGDIBitBlt)(hdcDest, nXDest, nYDest, nWidth, nHeight, hdcSrc, nXSrc, nYSrc, dwRop); res=(*pGDIBitBlt)(hdcDest, nXDest, nYDest, nWidth, nHeight, hdcSrc, nXSrc, nYSrc, dwRop);
@ -1643,6 +1725,13 @@ int WINAPI extAddFontResourceW(LPCWSTR lpszFontFile)
if(!res) OutTraceE("AddFontResource: ERROR err=%d at=%d\n", GetLastError(), __LINE__); if(!res) OutTraceE("AddFontResource: ERROR err=%d at=%d\n", GetLastError(), __LINE__);
} }
UINT WINAPI extSetSystemPaletteUse(HDC hdc, UINT uUsage)
{
//BOOL res;
OutTraceD("SetSystemPaletteUse: hdc=%x Usage=%x(%s)\n", hdc, uUsage, ExplainPaletteUse(uUsage));
return SYSPAL_NOSTATIC256;
}
#if 0 #if 0
// to map: // to map:
// GetCurrentPositionEx // GetCurrentPositionEx

View File

@ -693,6 +693,15 @@ HRESULT WINAPI extCreatePaletteProxy(LPDIRECTDRAW lpdd, DWORD dwflags, LPPALETTE
HRESULT res; HRESULT res;
OutTraceP("CreatePalette(D): PROXED lpdd=%x dwFlags=%x(%s)\n", lpdd, dwflags, ExplainCreatePaletteFlags(dwflags)); OutTraceP("CreatePalette(D): PROXED lpdd=%x dwFlags=%x(%s)\n", lpdd, dwflags, ExplainCreatePaletteFlags(dwflags));
if(IsDebug && (dwflags & DDPCAPS_8BIT)){
int idx;
OutTrace("CreatePalette: ");
for(idx=0; idx<256; idx++) OutTrace("(%02x.%02x.%02x)",
lpddpa[idx].peRed,
lpddpa[idx].peGreen,
lpddpa[idx].peBlue );
OutTrace("\n");
}
res = (*pCreatePalette)(lpdd, dwflags, lpddpa, lplpddp, pu); res = (*pCreatePalette)(lpdd, dwflags, lpddpa, lplpddp, pu);
if (res) { if (res) {
OutTraceP("CreatePalette(D): ERROR res=%x(%s)\n", res, ExplainDDError(res)); OutTraceP("CreatePalette(D): ERROR res=%x(%s)\n", res, ExplainDDError(res));
@ -2042,6 +2051,12 @@ UINT WINAPI extGetSystemPaletteEntriesProxy(HDC hdc, UINT iStartIndex, UINT nEnt
ret=(*pGDIGetSystemPaletteEntries)(hdc, iStartIndex, nEntries, lppe); ret=(*pGDIGetSystemPaletteEntries)(hdc, iStartIndex, nEntries, lppe);
OutTrace("GDI.GetSystemPaletteEntries: PROXED hdc=%x start=%d num=%d ret=%d\n", hdc, iStartIndex, nEntries, ret); OutTrace("GDI.GetSystemPaletteEntries: PROXED hdc=%x start=%d num=%d ret=%d\n", hdc, iStartIndex, nEntries, ret);
if(ret && IsDebug){
UINT idx;
OutTraceD("PaletteEntries[%x]= ", nEntries);
for(idx=iStartIndex; idx<nEntries; idx++) OutTraceD("(%02x.%02x.%02x-F%02x)", lppe[idx].peRed, lppe[idx].peGreen, lppe[idx].peBlue, lppe[idx].peFlags);
OutTraceD("\n");
}
if(!ret) OutTrace("GDI.GetSystemPaletteEntries: ERROR err=%d\n", GetLastError()); if(!ret) OutTrace("GDI.GetSystemPaletteEntries: ERROR err=%d\n", GetLastError());
return ret; return ret;
} }

View File

@ -317,8 +317,6 @@ HMODULE WINAPI LoadLibraryExWrapper(LPCTSTR lpFileName, HANDLE hFile, DWORD dwFl
HMODULE libhandle; HMODULE libhandle;
int idx; int idx;
//if(!strcmp(lpFileName, "d3d9.dll") && GetModuleHandle(lpFileName)) return GetModuleHandle(lpFileName); // attempt to avoid loading same dll twice....
libhandle=(*pLoadLibraryExA)(lpFileName, hFile, dwFlags); libhandle=(*pLoadLibraryExA)(lpFileName, hFile, dwFlags);
OutTraceD("%s: FileName=%s hFile=%x Flags=%x(%s) hmodule=%x\n", api, lpFileName, hFile, dwFlags, ExplainLoadLibFlags(dwFlags), libhandle); OutTraceD("%s: FileName=%s hFile=%x Flags=%x(%s) hmodule=%x\n", api, lpFileName, hFile, dwFlags, ExplainLoadLibFlags(dwFlags), libhandle);
if(!libhandle){ if(!libhandle){

View File

@ -88,6 +88,8 @@ typedef BOOL (WINAPI *GetViewportOrgEx_Type)(HDC, LPPOINT);
typedef BOOL (WINAPI *GetWindowOrgEx_Type)(HDC, LPPOINT); typedef BOOL (WINAPI *GetWindowOrgEx_Type)(HDC, LPPOINT);
typedef BOOL (WINAPI *SetWindowOrgEx_Type)(HDC, int, int, LPPOINT); typedef BOOL (WINAPI *SetWindowOrgEx_Type)(HDC, int, int, LPPOINT);
typedef BOOL (WINAPI *GetCurrentPositionEx_Type)(HDC, LPPOINT); typedef BOOL (WINAPI *GetCurrentPositionEx_Type)(HDC, LPPOINT);
typedef BOOL (WINAPI *AnimatePalette_Type)(HPALETTE, UINT, UINT, const PALETTEENTRY *);
typedef UINT (WINAPI *SetSystemPaletteUse_Type)(HDC, UINT);
// Kernel32.dll: // Kernel32.dll:
typedef BOOL (WINAPI *GetDiskFreeSpaceA_Type)(LPCSTR, LPDWORD, LPDWORD, LPDWORD, LPDWORD); typedef BOOL (WINAPI *GetDiskFreeSpaceA_Type)(LPCSTR, LPDWORD, LPDWORD, LPDWORD, LPDWORD);
@ -271,6 +273,8 @@ DXWEXTERN CreateScalableFontResourceA_Type pCreateScalableFontResourceA DXWINITI
DXWEXTERN AddFontResourceA_Type pAddFontResourceA DXWINITIALIZED; DXWEXTERN AddFontResourceA_Type pAddFontResourceA DXWINITIALIZED;
DXWEXTERN CreateScalableFontResourceW_Type pCreateScalableFontResourceW DXWINITIALIZED; DXWEXTERN CreateScalableFontResourceW_Type pCreateScalableFontResourceW DXWINITIALIZED;
DXWEXTERN AddFontResourceW_Type pAddFontResourceW DXWINITIALIZED; DXWEXTERN AddFontResourceW_Type pAddFontResourceW DXWINITIALIZED;
DXWEXTERN AnimatePalette_Type pAnimatePalette DXWINITIALIZED;
DXWEXTERN SetSystemPaletteUse_Type pSetSystemPaletteUse DXWINITIALIZED;
// Kernel32.dll: // Kernel32.dll:
DXWEXTERN GetDiskFreeSpaceA_Type pGetDiskFreeSpaceA DXWINITIALIZED; DXWEXTERN GetDiskFreeSpaceA_Type pGetDiskFreeSpaceA DXWINITIALIZED;
@ -443,6 +447,8 @@ extern BOOL WINAPI extCreateScalableFontResourceA(DWORD, LPCTSTR, LPCTSTR, LPCTS
extern int WINAPI extAddFontResourceA(LPCTSTR); extern int WINAPI extAddFontResourceA(LPCTSTR);
extern BOOL WINAPI extCreateScalableFontResourceW(DWORD, LPCWSTR, LPCWSTR, LPCWSTR); extern BOOL WINAPI extCreateScalableFontResourceW(DWORD, LPCWSTR, LPCWSTR, LPCWSTR);
extern int WINAPI extAddFontResourceW(LPCWSTR); extern int WINAPI extAddFontResourceW(LPCWSTR);
extern BOOL WINAPI extAnimatePalette(HPALETTE, UINT, UINT, const PALETTEENTRY *);
extern UINT WINAPI extSetSystemPaletteUse(HDC, UINT);
// Kernel32.dll: // Kernel32.dll:
extern BOOL WINAPI extGetDiskFreeSpaceA(LPCSTR, LPDWORD, LPDWORD, LPDWORD, LPDWORD); extern BOOL WINAPI extGetDiskFreeSpaceA(LPCSTR, LPDWORD, LPDWORD, LPDWORD, LPDWORD);

File diff suppressed because it is too large Load Diff

View File

@ -130,9 +130,13 @@ static char *libname = "user32.dll";
void HookUser32(HMODULE hModule) void HookUser32(HMODULE hModule)
{ {
HookLibrary(hModule, Hooks, libname); HookLibrary(hModule, Hooks, libname);
if ((dxw.dwFlags3 & EMULATEDC) || (dxw.dwFlags2 & HOOKGDI) || (dxw.dwFlags1 & MAPGDITOPRIMARY)) //if ((dxw.dwFlags3 & EMULATEDC) || (dxw.dwFlags2 & HOOKGDI) || (dxw.dwFlags1 & MAPGDITOPRIMARY))
HookLibrary(hModule, EmulateHooks, libname); // HookLibrary(hModule, EmulateHooks, libname);
HookLibrary(hModule, (dxw.dwFlags1 & MAPGDITOPRIMARY) ? DDHooks : GDIHooks, libname); //HookLibrary(hModule, (dxw.dwFlags1 & MAPGDITOPRIMARY) ? DDHooks : GDIHooks, libname);
if (dxw.dwFlags3 & EMULATEDC) HookLibrary(hModule, EmulateHooks, libname);
if (dxw.dwFlags2 & HOOKGDI) HookLibrary(hModule, GDIHooks, libname);
if (dxw.dwFlags1 & MAPGDITOPRIMARY) HookLibrary(hModule, DDHooks, libname);
if (dxw.dwFlags1 & CLIENTREMAPPING) HookLibrary(hModule, RemapHooks, libname); if (dxw.dwFlags1 & CLIENTREMAPPING) HookLibrary(hModule, RemapHooks, libname);
if(dxw.dwFlags1 & MODIFYMOUSE)HookLibrary(hModule, MouseHooks, libname); if(dxw.dwFlags1 & MODIFYMOUSE)HookLibrary(hModule, MouseHooks, libname);
if (dxw.dwFlags1 & (PREVENTMAXIMIZE|FIXWINFRAME|LOCKWINPOS|LOCKWINSTYLE))HookLibrary(hModule, WinHooks, libname); if (dxw.dwFlags1 & (PREVENTMAXIMIZE|FIXWINFRAME|LOCKWINPOS|LOCKWINSTYLE))HookLibrary(hModule, WinHooks, libname);
@ -1236,17 +1240,17 @@ int WINAPI extFillRect(HDC hdc, const RECT *lprc, HBRUSH hbr)
OutTraceD("FillRect: hdc=%x hbrush=%x rect=(%d,%d)-(%d,%d)\n", hdc, hbr, lprc->left, lprc->top, lprc->right, lprc->bottom); OutTraceD("FillRect: hdc=%x hbrush=%x rect=(%d,%d)-(%d,%d)\n", hdc, hbr, lprc->left, lprc->top, lprc->right, lprc->bottom);
// when not in fullscreen mode, just proxy the call // when not in fullscreen mode, just proxy the call
if(!dxw.IsFullScreen()) return (*pFillRect)(hdc, lprc, hbr); // better not: some games may use excessive coordinates: see "Premier Manager 98"
// if(!dxw.IsFullScreen()) return (*pFillRect)(hdc, lprc, hbr);
memcpy(&rc, lprc, sizeof(rc)); memcpy(&rc, lprc, sizeof(rc));
if(OBJ_DC == GetObjectType(hdc)){ if(rc.left < 0) rc.left = 0;
if(rc.left < 0) rc.left = 0; if(rc.top < 0) rc.top = 0;
if(rc.top < 0) rc.top = 0; if((DWORD)rc.right > dxw.GetScreenWidth()) rc.right = dxw.GetScreenWidth();
if((DWORD)rc.right > dxw.GetScreenWidth()) rc.right = dxw.GetScreenWidth(); if((DWORD)rc.bottom > dxw.GetScreenHeight()) rc.bottom = dxw.GetScreenHeight();
if((DWORD)rc.bottom > dxw.GetScreenHeight()) rc.bottom = dxw.GetScreenHeight(); if(OBJ_DC == GetObjectType(hdc)) dxw.MapWindow(&rc);
dxw.MapClient(&rc); //else dxw.MapClient(&rc);
OutTraceD("FillRect: fixed rect=(%d,%d)-(%d,%d)\n", rc.left, rc.top, rc.right, rc.bottom); OutTraceD("FillRect: fixed rect=(%d,%d)-(%d,%d)\n", rc.left, rc.top, rc.right, rc.bottom);
}
res=(*pFillRect)(hdc, &rc, hbr); res=(*pFillRect)(hdc, &rc, hbr);
return res; return res;

View File

@ -33,6 +33,9 @@ END_MESSAGE_MAP()
// CPaletteDialog message handlers // CPaletteDialog message handlers
CDib dib;
CWnd *myWin;
void CPaletteDialog::OnTimer(UINT_PTR nIDEvent) void CPaletteDialog::OnTimer(UINT_PTR nIDEvent)
{ {
DXWNDSTATUS DxWndStatus; DXWNDSTATUS DxWndStatus;
@ -41,14 +44,14 @@ void CPaletteDialog::OnTimer(UINT_PTR nIDEvent)
extern TARGETMAP *pTargets; extern TARGETMAP *pTargets;
RECT Rect; RECT Rect;
int h, w; int h, w;
static BOOL PaletteUpdated = FALSE;
DxStatus=GetHookStatus(&DxWndStatus); DxStatus=GetHookStatus(&DxWndStatus);
this->GetDC()->GetWindow()->GetClientRect(&Rect); myWin->GetClientRect(&Rect);
h=Rect.bottom - Rect.top; h=Rect.bottom - Rect.top;
w=Rect.right - Rect.left; w=Rect.right - Rect.left;
if((h==0) || (w==0)) return;
CDib dib;
dib.ReadFromResource(IDB_PALETTE);
if(DxStatus==DXW_RUNNING){ if(DxStatus==DXW_RUNNING){
for(int row=0; row<16; row++){ for(int row=0; row<16; row++){
for(int col=0; col<16; col++){ for(int col=0; col<16; col++){
@ -61,13 +64,26 @@ void CPaletteDialog::OnTimer(UINT_PTR nIDEvent)
dib.SetPixel(col, row, rgbq); dib.SetPixel(col, row, rgbq);
} }
} }
PaletteUpdated = TRUE;
} }
dib.Draw(this->GetDC(), CRect(0, 0, w, h), CRect(0, 0, 16, 16)); else{
if (PaletteUpdated) dib.ReadFromResource(IDB_PALETTE);
PaletteUpdated = FALSE;
}
CDC *dc;
dc=this->GetDC();
if(dc) dib.Draw(dc, CRect(0, 0, w, h), CRect(0, 0, 16, 16));
this->ReleaseDC(dc);
} }
BOOL CPaletteDialog::OnInitDialog() BOOL CPaletteDialog::OnInitDialog()
{ {
CDC *myDC;
CDialog::OnInitDialog(); CDialog::OnInitDialog();
if((myDC=this->GetDC())==NULL) return FALSE;
if((myWin=myDC->GetWindow())==NULL) return FALSE;
dib.ReadFromResource(IDB_PALETTE);
SetTimer(IDPaletteTIMER, 200, NULL); SetTimer(IDPaletteTIMER, 200, NULL);
return TRUE; // return TRUE unless you set the focus to a control return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE // EXCEPTION: OCX Property Pages should return FALSE
@ -76,7 +92,8 @@ BOOL CPaletteDialog::OnInitDialog()
void CPaletteDialog::OnOK() void CPaletteDialog::OnOK()
{ {
// TODO: Add your specialized code here and/or call the base class // TODO: Add your specialized code here and/or call the base class
KillTimer(IDPaletteTIMER);
// stop timer // stop timer
KillTimer(IDPaletteTIMER);
// delete(dib);
CDialog::OnOK(); CDialog::OnOK();
} }

View File

@ -183,10 +183,11 @@
#define IDC_CAPMASK 1136 #define IDC_CAPMASK 1136
#define IDC_FORCESHEL 1137 #define IDC_FORCESHEL 1137
#define IDC_COLORFIX 1138 #define IDC_COLORFIX 1138
#define IDC_NODDRAWBLIT 1139
#define IDC_NODDRAWBLT 1139 #define IDC_NODDRAWBLT 1139
#define IDC_NODDRAWFLIP 1140 #define IDC_NODDRAWFLIP 1140
#define IDC_NOGDIBLT 1141 #define IDC_NOGDIBLT 1141
#define IDC_NOPIXELFORMAT 1142
#define IDC_NOALPHACHANNEL 1143
#define ID_MODIFY 32771 #define ID_MODIFY 32771
#define ID_DELETE 32772 #define ID_DELETE 32772
#define ID_ADD 32773 #define ID_ADD 32773

View File

@ -40,6 +40,8 @@ void CTabDirectX::DoDataExchange(CDataExchange* pDX)
DDX_Check(pDX, IDC_DISABLEHAL, cTarget->m_DisableHAL); DDX_Check(pDX, IDC_DISABLEHAL, cTarget->m_DisableHAL);
DDX_Check(pDX, IDC_FORCESHEL, cTarget->m_ForcesHEL); DDX_Check(pDX, IDC_FORCESHEL, cTarget->m_ForcesHEL);
DDX_Check(pDX, IDC_COLORFIX, cTarget->m_ColorFix); DDX_Check(pDX, IDC_COLORFIX, cTarget->m_ColorFix);
DDX_Check(pDX, IDC_NOPIXELFORMAT, cTarget->m_NoPixelFormat);
DDX_Check(pDX, IDC_NOALPHACHANNEL, cTarget->m_NoAlphaChannel);
//DDX_Check(pDX, IDC_SAVECAPS, cTarget->m_SaveCaps); //DDX_Check(pDX, IDC_SAVECAPS, cTarget->m_SaveCaps);
// DirectInput // DirectInput
DDX_Check(pDX, IDC_HOOKDI, cTarget->m_HookDI); DDX_Check(pDX, IDC_HOOKDI, cTarget->m_HookDI);

View File

@ -40,6 +40,8 @@ CTargetDlg::CTargetDlg(CWnd* pParent /*=NULL*/)
m_DisableHAL = FALSE; m_DisableHAL = FALSE;
m_ForcesHEL = FALSE; m_ForcesHEL = FALSE;
m_ColorFix = FALSE; m_ColorFix = FALSE;
m_NoPixelFormat = FALSE;
m_NoAlphaChannel = FALSE;
m_LockSysColors = FALSE; m_LockSysColors = FALSE;
m_ForceYUVtoRGB = FALSE; m_ForceYUVtoRGB = FALSE;
m_ForceRGBtoYUV = FALSE; m_ForceRGBtoYUV = FALSE;

View File

@ -120,6 +120,8 @@ public:
BOOL m_DisableHAL; BOOL m_DisableHAL;
BOOL m_ForcesHEL; BOOL m_ForcesHEL;
BOOL m_ColorFix; BOOL m_ColorFix;
BOOL m_NoPixelFormat;
BOOL m_NoAlphaChannel;
BOOL m_LockSysColors; BOOL m_LockSysColors;
BOOL m_SaveCaps; BOOL m_SaveCaps;
BOOL m_SingleProcAffinity; BOOL m_SingleProcAffinity;

Binary file not shown.

View File

@ -314,9 +314,9 @@ BEGIN
CONTROL "Locked Surface",IDC_LOCKEDSURFACE,"Button",BS_AUTORADIOBUTTON,14,144,67,12 CONTROL "Locked Surface",IDC_LOCKEDSURFACE,"Button",BS_AUTORADIOBUTTON,14,144,67,12
CONTROL "Primary Surface",IDC_EMULATESURFACE,"Button",BS_AUTORADIOBUTTON,14,156,77,12 CONTROL "Primary Surface",IDC_EMULATESURFACE,"Button",BS_AUTORADIOBUTTON,14,156,77,12
GROUPBOX "DirectX Version Hook",IDC_STATIC,6,3,98,103,WS_GROUP GROUPBOX "DirectX Version Hook",IDC_STATIC,6,3,98,103,WS_GROUP
GROUPBOX "Emulation",IDC_STATIC,7,109,98,61,WS_GROUP GROUPBOX "Emulation",IDC_STATIC,7,109,98,66,WS_GROUP
CONTROL "Auto Primary Surface Refresh",IDC_AUTOREFRESH,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,118,16,126,9 CONTROL "Auto Primary Surface Refresh",IDC_AUTOREFRESH,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,118,16,126,9
GROUPBOX "DirectDraw Surface handling",IDC_STATIC,112,3,181,167 GROUPBOX "DirectDraw Surface handling",IDC_STATIC,112,3,181,173
CONTROL "switch VIDEO to SYSTEM on fail",IDC_VIDEOTOSYSTEMMEM, CONTROL "switch VIDEO to SYSTEM on fail",IDC_VIDEOTOSYSTEMMEM,
"Button",BS_AUTOCHECKBOX | BS_MULTILINE | WS_TABSTOP,118,28,126,9 "Button",BS_AUTOCHECKBOX | BS_MULTILINE | WS_TABSTOP,118,28,126,9
CONTROL "Suppress DX common errors",IDC_SUPPRESSDXERRORS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,118,40,127,10 CONTROL "Suppress DX common errors",IDC_SUPPRESSDXERRORS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,118,40,127,10
@ -338,12 +338,15 @@ BEGIN
EDITTEXT IDC_MINY,97,209,17,14,ES_AUTOHSCROLL,WS_EX_RIGHT EDITTEXT IDC_MINY,97,209,17,14,ES_AUTOHSCROLL,WS_EX_RIGHT
EDITTEXT IDC_MAXX,124,209,17,14,ES_AUTOHSCROLL,WS_EX_RIGHT EDITTEXT IDC_MAXX,124,209,17,14,ES_AUTOHSCROLL,WS_EX_RIGHT
EDITTEXT IDC_MAXY,148,209,17,14,ES_AUTOHSCROLL,WS_EX_RIGHT EDITTEXT IDC_MAXY,148,209,17,14,ES_AUTOHSCROLL,WS_EX_RIGHT
CONTROL "DirectInput Hooking",IDC_HOOKDI,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,14,182,97,12 CONTROL "DirectInput Hooking",IDC_HOOKDI,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,183,210,97,12
GROUPBOX "DirectInput",IDC_STATIC,7,172,286,61 GROUPBOX "DirectInput",IDC_STATIC,7,176,286,57
CONTROL "Set AERO compatible mode",IDC_SETCOMPATIBILITY,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,118,100,109,12 CONTROL "Set AERO compatible mode",IDC_SETCOMPATIBILITY,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,118,100,109,12
CONTROL "Disable HAL support",IDC_DISABLEHAL,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,118,112,109,12 CONTROL "Disable HAL support",IDC_DISABLEHAL,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,118,112,109,12
CONTROL "Forces HEL ",IDC_FORCESHEL,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,118,124,109,12 CONTROL "Forces HEL ",IDC_FORCESHEL,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,118,124,109,12
CONTROL "Win7 color fix",IDC_COLORFIX,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,118,136,109,12 CONTROL "Win7 color fix",IDC_COLORFIX,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,118,136,109,12
CONTROL "Don't fix the Pixel Format",IDC_NOPIXELFORMAT,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,118,148,109,12
CONTROL "by default set no ALPHACHANNEL",IDC_NOALPHACHANNEL,
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,118,160,123,12
END END
IDD_TAB_MOUSE DIALOGEX 0, 0, 300, 240 IDD_TAB_MOUSE DIALOGEX 0, 0, 300, 240

Binary file not shown.

View File

@ -160,6 +160,8 @@ static void SetTargetFromDlg(TARGETMAP *t, CTargetDlg *dlg)
if(dlg->m_DisableHAL) t->flags3 |= DISABLEHAL; if(dlg->m_DisableHAL) t->flags3 |= DISABLEHAL;
if(dlg->m_ForcesHEL) t->flags3 |= FORCESHEL; if(dlg->m_ForcesHEL) t->flags3 |= FORCESHEL;
if(dlg->m_ColorFix) t->flags3 |= COLORFIX; if(dlg->m_ColorFix) t->flags3 |= COLORFIX;
if(dlg->m_NoPixelFormat) t->flags3 |= NOPIXELFORMAT;
if(dlg->m_NoAlphaChannel) t->flags4 |= NOALPHACHANNEL;
if(dlg->m_LockSysColors) t->flags3 |= LOCKSYSCOLORS; if(dlg->m_LockSysColors) t->flags3 |= LOCKSYSCOLORS;
if(dlg->m_ForceYUVtoRGB) t->flags3 |= YUV2RGB; if(dlg->m_ForceYUVtoRGB) t->flags3 |= YUV2RGB;
if(dlg->m_ForceRGBtoYUV) t->flags3 |= RGB2YUV; if(dlg->m_ForceRGBtoYUV) t->flags3 |= RGB2YUV;
@ -290,6 +292,8 @@ static void SetDlgFromTarget(TARGETMAP *t, CTargetDlg *dlg)
dlg->m_DisableHAL = t->flags3 & DISABLEHAL ? 1 : 0; dlg->m_DisableHAL = t->flags3 & DISABLEHAL ? 1 : 0;
dlg->m_ForcesHEL = t->flags3 & FORCESHEL ? 1 : 0; dlg->m_ForcesHEL = t->flags3 & FORCESHEL ? 1 : 0;
dlg->m_ColorFix = t->flags3 & COLORFIX ? 1 : 0; dlg->m_ColorFix = t->flags3 & COLORFIX ? 1 : 0;
dlg->m_NoPixelFormat = t->flags3 & NOPIXELFORMAT ? 1 : 0;
dlg->m_NoAlphaChannel = t->flags4 & NOALPHACHANNEL ? 1 : 0;
dlg->m_LockSysColors = t->flags3 & LOCKSYSCOLORS ? 1 : 0; dlg->m_LockSysColors = t->flags3 & LOCKSYSCOLORS ? 1 : 0;
dlg->m_ForceRGBtoYUV = t->flags3 & RGB2YUV ? 1 : 0; dlg->m_ForceRGBtoYUV = t->flags3 & RGB2YUV ? 1 : 0;
dlg->m_ForceYUVtoRGB = t->flags3 & YUV2RGB ? 1 : 0; dlg->m_ForceYUVtoRGB = t->flags3 & YUV2RGB ? 1 : 0;

BIN
host/res/palette0.bmp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 314 B