mirror of
https://github.com/DxWnd/DxWnd.reloaded
synced 2024-12-30 09:25:35 +01:00
v2_02_97_src
Former-commit-id: 825da04474b383bd6fe1649323fe622b6bb0a482
This commit is contained in:
parent
7418d7767b
commit
bde179852c
@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:322d82c850c81a6f45b224d9fe22ab45a18d9d725180702c6b1f2f41e5abcdb7
|
||||
size 534528
|
||||
oid sha256:5440c78286a678a28b71b54f938b0ff377b7811d6601f3d5b00aaffc39d7811a
|
||||
size 531968
|
||||
|
@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:88397843c92ba22bd48b166a9964201ee90431f17e9c1212a3349b857c039159
|
||||
oid sha256:155274eb76f293c76375ddbf6fb233076d82307a6afd440a11417e3673ece4ad
|
||||
size 559104
|
||||
|
@ -631,4 +631,8 @@ fix: missing initialization of variables in screen size limit handling
|
||||
fix: processing of mouse messages
|
||||
fix: GetSystemMetrics and LoadLibrary* calls hooked by hot patching to fix "Wind Fantasy SP" movie problems
|
||||
fix: completed winmm multimedia api hooking to fix "Wind Fantasy SP" movie problems, and not only....
|
||||
fix: revised FPS control to assure more stable fps when a FPS limit delay is set
|
||||
fix: revised FPS control to assure more stable fps when a FPS limit delay is set
|
||||
|
||||
v2.02.97
|
||||
fix: mouse black trails in "Deadlock II"
|
||||
fix: missing default value for filter mode
|
||||
|
@ -94,15 +94,9 @@ void Resize_HQ_4ch( unsigned char* src, RECT *srcrect, int srcpitch,
|
||||
// *256 weight_y
|
||||
// *256 (16*16) maximum # of input pixels (x,y) - unless we cut the weights down...
|
||||
int weight_shift = 0;
|
||||
float source_texels_per_out_pixel = ( (w1/(float)w2 + 1)
|
||||
* (h1/(float)h2 + 1)
|
||||
);
|
||||
float weight_per_pixel = source_texels_per_out_pixel * 256 * 256; //weight_x * weight_y
|
||||
float accum_per_pixel = weight_per_pixel*256; //color value is 0-255
|
||||
float weight_div = accum_per_pixel / 4294967000.0f;
|
||||
if (weight_div > 1)
|
||||
weight_shift = (int)ceilf( logf((float)weight_div)/logf(2.0f) );
|
||||
weight_shift = min(15, weight_shift); // this could go to 15 and still be ok.
|
||||
|
||||
//gsky916: weight_shift calculation in bUpsampleX && bUpsampleY cases are not necessary.
|
||||
//Move to else block to reduce floating point calculations.
|
||||
|
||||
float fh = 256*h1/(float)h2;
|
||||
float fw = 256*w1/(float)w2;
|
||||
@ -128,6 +122,8 @@ void Resize_HQ_4ch( unsigned char* src, RECT *srcrect, int srcpitch,
|
||||
}
|
||||
|
||||
// FOR EVERY OUTPUT PIXEL
|
||||
// gsky916: Use OpenMP to speed up nested for loops (Enable OpenMP support in compiler).
|
||||
#pragma omp parallel for schedule(dynamic)
|
||||
for (int y2=0; y2<h2; y2++)
|
||||
{
|
||||
// find the y-range of input pixels that will contribute:
|
||||
@ -178,6 +174,17 @@ void Resize_HQ_4ch( unsigned char* src, RECT *srcrect, int srcpitch,
|
||||
}
|
||||
else // either downscale on vertical or horizontal direction ...
|
||||
{
|
||||
//gsky916: weight_shift calculation moved here.
|
||||
float source_texels_per_out_pixel = ( (w1/(float)w2 + 1)
|
||||
* (h1/(float)h2 + 1)
|
||||
);
|
||||
float weight_per_pixel = source_texels_per_out_pixel * 256 * 256; //weight_x * weight_y
|
||||
float accum_per_pixel = weight_per_pixel*256; //color value is 0-255
|
||||
float weight_div = accum_per_pixel / 4294967000.0f;
|
||||
if (weight_div > 1)
|
||||
weight_shift = (int)ceilf( logf((float)weight_div)/logf(2.0f) );
|
||||
weight_shift = min(15, weight_shift); // this could go to 15 and still be ok.
|
||||
|
||||
// cache x1a, x1b for all the columns:
|
||||
// ...and your OS better have garbage collection on process exit :)
|
||||
if (g_px1ab_w < w2)
|
||||
|
@ -1781,25 +1781,6 @@ HRESULT WINAPI extQueryInterfaceS(void *lpdds, REFIID riid, LPVOID *obp)
|
||||
break;
|
||||
case 0x84e63de0:
|
||||
OutTraceDW("QueryInterface: IID_IDirect3DHALDevice\n");
|
||||
#ifdef COMMENTED_OUT
|
||||
if (dxw.dwFlags3 & DISABLEHAL){ // IID_IDirect3DHALDevice - Dark Vengeance
|
||||
// this is odd: this piece of code returns the very same error code returned by the actual
|
||||
// QueryInterface call, but avoid a memory corruption and makes the game working....
|
||||
// there must be something wrong behind it.
|
||||
|
||||
// SEEMS FIXED NOW, NO MORE CRASHES, THIS OPTION IS USELESS
|
||||
|
||||
OutTraceDW("QueryInterface: suppress IID_IDirect3DHALDevice interface res=DDERR_GENERIC\n");
|
||||
return DDERR_GENERIC;
|
||||
|
||||
//GUID IID_IDirect3DRGBDevice = {0xA4665C60,0x2673,0x11CF,0xA3,0x1A,0x00,0xAA,0x00,0xB9,0x33,0x56};
|
||||
//res = (*pQueryInterfaceS)(lpdds, IID_IDirect3DRGBDevice, obp);
|
||||
//OutTraceDW("QueryInterface: redirect IID_IDirect3DHALDevice to RGB interface res=%x(%s)\n", res, ExplainDDError(res));
|
||||
//return res;
|
||||
|
||||
//return DD_OK;
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
case 0xA4665C60: // IID_IDirect3DRGBDevice
|
||||
OutTraceDW("QueryInterface: IID_IDirect3DRGBDevice\n");
|
||||
@ -2069,7 +2050,7 @@ HRESULT WINAPI extSetCooperativeLevel(void *lpdd, HWND hwnd, DWORD dwflags)
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
#ifdef DXWND_ANALYTICMODE
|
||||
#define FIX_FLAGSMASK (DDSD_CAPS|DDSD_HEIGHT|DDSD_WIDTH|DDSD_PITCH|DDSD_PIXELFORMAT|DDSD_ZBUFFERBITDEPTH|DDSD_TEXTURESTAGE)
|
||||
|
||||
void FixSurfaceCapsAnalytic(LPDDSURFACEDESC2 lpddsd, int dxversion)
|
||||
@ -2202,9 +2183,6 @@ void FixSurfaceCapsAnalytic(LPDDSURFACEDESC2 lpddsd, int dxversion)
|
||||
// Airline Tycoon Evolution
|
||||
return;
|
||||
break;
|
||||
//case DDSCAPS_OFFSCREENPLAIN|DDSCAPS_SYSTEMMEMORY|DDSCAPS_3DDEVICE:
|
||||
// OutTrace("FixSurfaceCaps: ??? (Dungeon Keeper D3D)\n");
|
||||
// break;
|
||||
}
|
||||
break;
|
||||
case DDSD_CAPS|DDSD_WIDTH|DDSD_HEIGHT|DDSD_PIXELFORMAT:
|
||||
@ -2337,6 +2315,7 @@ void FixSurfaceCapsAnalytic(LPDDSURFACEDESC2 lpddsd, int dxversion)
|
||||
MessageBox(0, sMsg, "FixSurfaceCaps unmanaged setting", MB_OK | MB_ICONEXCLAMATION);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
static void FixSurfaceCaps(LPDDSURFACEDESC2 lpddsd, int dxversion)
|
||||
{
|
||||
@ -2359,7 +2338,9 @@ static void FixSurfaceCaps(LPDDSURFACEDESC2 lpddsd, int dxversion)
|
||||
OutTraceDW("FixSurfaceCaps: Flags=%x(%s) Caps=%x(%s)\n",
|
||||
lpddsd->dwFlags, ExplainFlags(lpddsd->dwFlags), lpddsd->ddsCaps.dwCaps, ExplainDDSCaps(lpddsd->ddsCaps.dwCaps));
|
||||
|
||||
#ifdef DXWND_ANALYTICMODE
|
||||
if(dxw.dwFlags3 & ANALYTICMODE) return FixSurfaceCapsAnalytic(lpddsd, dxversion);
|
||||
#endif
|
||||
|
||||
if((lpddsd->dwFlags & (DDSD_WIDTH|DDSD_HEIGHT)) == DDSD_WIDTH) {
|
||||
// buffer surface - no changes
|
||||
@ -2383,12 +2364,6 @@ static void FixSurfaceCaps(LPDDSURFACEDESC2 lpddsd, int dxversion)
|
||||
GetPixFmt(lpddsd);
|
||||
return;
|
||||
}
|
||||
//// DDSCAPS_ALLOCONLOAD on VIDEOMEMORY can't be done when HAL is disabled - it returns DDERR_NODIRECTDRAWHW error
|
||||
//if((lpddsd->dwFlags & DDSD_CAPS) &&
|
||||
// ((lpddsd->ddsCaps.dwCaps & (DDSCAPS_TEXTURE|DDSCAPS_ALLOCONLOAD))==(DDSCAPS_TEXTURE|DDSCAPS_ALLOCONLOAD))) {
|
||||
// if (dxw.dwFlags3 & FORCESHEL) lpddsd->ddsCaps.dwCaps = (DDSCAPS_TEXTURE|DDSCAPS_SYSTEMMEMORY|DDSCAPS_ALLOCONLOAD);
|
||||
// return;
|
||||
//}
|
||||
// DDSCAPS_TEXTURE surfaces must be left untouched, unless you set FORCESHEL: in this case switch VIDEOMEMORY to SYSTEMMEMORY
|
||||
if((lpddsd->dwFlags & DDSD_CAPS) && (lpddsd->ddsCaps.dwCaps & DDSCAPS_TEXTURE)){
|
||||
if (dxw.dwFlags3 & FORCESHEL) {
|
||||
@ -3020,14 +2995,6 @@ HRESULT WINAPI extGetAttachedSurface(int dxversion, GetAttachedSurface_Type pGet
|
||||
else
|
||||
OutTraceDDRAW("GetAttachedSurface(%d): attached=%x\n", dxversion, *lplpddas);
|
||||
|
||||
#if 0
|
||||
// beware: ddraw 7 surfaces can be created with FLIP capability, hence could have a backbuffer ???
|
||||
if((res==DDERR_NOTFOUND) && (dxversion==7) && (!IsPrim) && (!IsBack)){
|
||||
*lplpddas = lpdds;
|
||||
res = DD_OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
return res;
|
||||
|
||||
}
|
||||
@ -3907,7 +3874,7 @@ HRESULT WINAPI extLock(LPDIRECTDRAWSURFACE lpdds, LPRECT lprect, LPDDSURFACEDESC
|
||||
IsPrim=dxw.IsAPrimarySurface(lpdds);
|
||||
CleanRect(&lprect, __LINE__);
|
||||
|
||||
if(IsTraceDDRAW){
|
||||
if(IsTraceDW){
|
||||
OutTrace("Lock: lpdds=%x%s flags=%x(%s) lpDDSurfaceDesc=%x",
|
||||
lpdds, (IsPrim ? "(PRIM)":""), flags, ExplainLockFlags(flags), lpDDSurfaceDesc);
|
||||
if (lprect)
|
||||
@ -4038,7 +4005,18 @@ HRESULT WINAPI extUnlock(int dxversion, Unlock4_Type pUnlock, LPDIRECTDRAWSURFAC
|
||||
res=(*pUnlock)(lpdds, lprect);
|
||||
if(res==DDERR_NOTLOCKED) res=DD_OK; // ignore not locked error
|
||||
if (res) OutTraceE("Unlock ERROR res=%x(%s) at %d\n",res, ExplainDDError(res), __LINE__);
|
||||
if (IsPrim && res==DD_OK) sBlt("Unlock", lpdds, NULL, lpdds, NULL, NULL, 0, FALSE);
|
||||
if (IsPrim && res==DD_OK) {
|
||||
sBlt("Unlock", lpdds, NULL, lpdds, NULL, NULL, 0, FALSE);
|
||||
// v2.02.97: set dirty rect to syncronize with gdi operations. See "Deadlock II" problems...
|
||||
RECT dirty;
|
||||
if(lprect){
|
||||
dirty = *lprect;
|
||||
dxw.MapClient(&dirty);
|
||||
lprect = &dirty;
|
||||
}
|
||||
(*pInvalidateRect)(dxw.GethWnd(), lprect, FALSE);
|
||||
}
|
||||
|
||||
if(dxw.dwFlags1 & SUPPRESSDXERRORS) res=DD_OK;
|
||||
return res;
|
||||
}
|
||||
@ -4869,32 +4847,6 @@ HRESULT WINAPI extGetSurfaceDesc(GetSurfaceDesc_Type pGetSurfaceDesc, LPDIRECTDR
|
||||
lpddsd->ddsCaps.dwCaps &= ~DDSCAPS_SYSTEMMEMORY;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef EXPERIMENTAL_1
|
||||
if(1) {
|
||||
IsFixed=TRUE;
|
||||
if(lpddsd->ddsCaps.dwCaps & DDSCAPS_BACKBUFFER){
|
||||
lpddsd->dwSize = sizeof(DDSURFACEDESC2);
|
||||
lpddsd->ddsCaps.dwCaps |= DDSCAPS_RESERVED2;
|
||||
((LPDDSURFACEDESC2)lpddsd)->ddsCaps.dwCaps2 = DDSCAPS2_RESERVED2;
|
||||
((LPDDSURFACEDESC2)lpddsd)->ddsCaps.dwCaps3 = 0;
|
||||
}
|
||||
else
|
||||
if(lpddsd->ddsCaps.dwCaps & DDSCAPS_BACKBUFFER){
|
||||
}
|
||||
else {
|
||||
lpddsd->ddsCaps.dwCaps |= DDSCAPS_RESERVED2;
|
||||
((LPDDSURFACEDESC2)lpddsd)->ddsCaps.dwCaps2 |= DDSCAPS2_RESERVED2;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#ifdef EXPERIMENTAL_2
|
||||
if(1) {
|
||||
IsFixed=TRUE;
|
||||
lpddsd->ddpfPixelFormat.dwFlags |= DDPF_ALPHAPIXELS;
|
||||
lpddsd->ddsCaps.dwCaps |= DDSCAPS_3DDEVICE;
|
||||
}
|
||||
#endif
|
||||
|
||||
if(IsFixed) LogSurfaceAttributes(lpddsd, "GetSurfaceDesc [FIXED]", __LINE__);
|
||||
|
||||
|
@ -423,21 +423,6 @@ HRESULT WINAPI extDeviceProxy(LPCDIDEVICEINSTANCE dev, LPVOID arg)
|
||||
dev->dwSize, p, dev->guidInstance.Data1, dev->guidInstance.Data2, dev->guidInstance.Data3, dev->guidInstance.Data4,
|
||||
dev->dwDevType, dev->tszInstanceName, dev->tszProductName);
|
||||
|
||||
#if 0
|
||||
if(0){
|
||||
DIDEVICEINSTANCEW fixdev;
|
||||
fixdev.dwSize=sizeof(DIDEVICEINSTANCEW);
|
||||
fixdev.dwDevType=dev->dwDevType;
|
||||
fixdev.guidInstance=dev->guidInstance;
|
||||
fixdev.guidProduct=dev->guidProduct;
|
||||
mbstowcs(fixdev.tszInstanceName, dev->tszInstanceName, strlen(dev->tszInstanceName));
|
||||
mbstowcs(fixdev.tszProductName, dev->tszProductName, strlen(dev->tszProductName));
|
||||
res = ((LPDIENUMDEVICESCALLBACKW)(((CallbackArg *)arg)->cb))(&fixdev, ((CallbackArg *)arg)->arg);
|
||||
OutTraceDW("EnumDevices: CALLBACK ret=%x\n", res);
|
||||
return res;
|
||||
}
|
||||
#endif
|
||||
|
||||
res = (*(((CallbackArg *)arg)->cb))(dev, ((CallbackArg *)arg)->arg);
|
||||
OutTraceDW("EnumDevices: CALLBACK ret=%x\n", res);
|
||||
return res;
|
||||
|
600
dll/dxemublt.cpp
600
dll/dxemublt.cpp
@ -5,6 +5,8 @@
|
||||
#include "dxwcore.hpp"
|
||||
#include "hddraw.h"
|
||||
|
||||
//#define USEOPENMP
|
||||
|
||||
typedef HRESULT (WINAPI *Lock_Type)(LPDIRECTDRAWSURFACE, LPRECT, LPDDSURFACEDESC, DWORD, HANDLE);
|
||||
typedef HRESULT (WINAPI *Unlock4_Type)(LPDIRECTDRAWSURFACE, LPRECT);
|
||||
typedef HRESULT (WINAPI *Unlock1_Type)(LPDIRECTDRAWSURFACE, LPVOID);
|
||||
@ -24,7 +26,6 @@ extern int Set_dwSize_From_Surface(LPDIRECTDRAWSURFACE);
|
||||
#define MARKBLITCOLOR32 0x00FFFF00
|
||||
#define MARKBLITCOLOR16 0x0FF0
|
||||
EmuBlt_Type pEmuBlt;
|
||||
RevBlt_Type pRevBlt;
|
||||
PrimaryBlt_Type pPrimaryBlt;
|
||||
|
||||
extern Blt_Type pBlt;
|
||||
@ -143,7 +144,7 @@ static HRESULT WINAPI EmuBlt_8_to_32(LPDIRECTDRAWSURFACE lpddsdst, LPRECT lpdest
|
||||
DWORD *dest, *dest0;
|
||||
DDSURFACEDESC2 ddsd_src, ddsd_dst;
|
||||
long srcpitch, destpitch;
|
||||
DWORD x, y, w, h;
|
||||
int x, y, w, h;
|
||||
|
||||
w = lpdestrect->right - lpdestrect->left;
|
||||
h = lpdestrect->bottom - lpdestrect->top;
|
||||
@ -210,11 +211,11 @@ static HRESULT WINAPI BilinearBlt_8_to_32(LPDIRECTDRAWSURFACE lpddsdst, LPRECT l
|
||||
LPDIRECTDRAWSURFACE lpddssrc, LPRECT lpsrcrect, DWORD dwflags, LPVOID lpsurface)
|
||||
{
|
||||
HRESULT res;
|
||||
BYTE *src8;
|
||||
BYTE *src8, *src0;
|
||||
DWORD *dest, *dest0;
|
||||
DDSURFACEDESC2 ddsd_src, ddsd_dst;
|
||||
long srcpitch, destpitch;
|
||||
DWORD x, y, w, h;
|
||||
int w, h;
|
||||
|
||||
w = lpdestrect->right - lpdestrect->left;
|
||||
h = lpdestrect->bottom - lpdestrect->top;
|
||||
@ -263,17 +264,29 @@ static HRESULT WINAPI BilinearBlt_8_to_32(LPDIRECTDRAWSURFACE lpddsdst, LPRECT l
|
||||
src8 += (lpsrcrect->top >> 1)*ddsd_src.lPitch;
|
||||
src8 += (lpsrcrect->left >> 1);
|
||||
srcpitch = ddsd_src.lPitch - w;
|
||||
src0 = src8;
|
||||
|
||||
// OutTraceDW("DEBUG: h=%d w=%d src=%x dst=%x spitch=%d dpitch=%d\n",h,w,src8,dest,srcpitch,destpitch);
|
||||
for(y = 0; y < h-1; y ++){ // first h-1 lines ....
|
||||
#ifdef USEOPENMP
|
||||
#pragma omp parallel for schedule(static)
|
||||
#endif
|
||||
for(int y = 0; y < h; y ++){
|
||||
register DWORD Q1, Q2, Q3, Q4, Q5;
|
||||
src8 = src0 + (y * ddsd_src.lPitch);
|
||||
dest = dest0 + ((y * ddsd_dst.lPitch) << 1);
|
||||
Q5 = Melt32(PaletteEntries[*(src8)], PaletteEntries[*(src8+ddsd_src.lPitch)]);
|
||||
for(x = 0; x < w; x ++){
|
||||
for(int x = 0; x < w; x ++){
|
||||
Q1 = PaletteEntries[*(src8)];
|
||||
Q2 = Melt32(Q1, PaletteEntries[*(src8+1)]);
|
||||
Q3 = Q5;
|
||||
Q5 = Melt32(PaletteEntries[*(src8+1)], PaletteEntries[*(src8+ddsd_src.lPitch+1)]); // to be used in next for cycle
|
||||
Q4 = Melt32(Q3, Q5);
|
||||
if(y == h-1){
|
||||
Q3 = Q1;
|
||||
Q4 = Q2;
|
||||
}
|
||||
else{
|
||||
Q5 = Melt32(PaletteEntries[*(src8+1)], PaletteEntries[*(src8+ddsd_src.lPitch+1)]); // to be used in next for cycle
|
||||
Q4 = Melt32(Q3, Q5);
|
||||
}
|
||||
|
||||
*(dest) = Q1;
|
||||
*(dest+1) = Q2;
|
||||
@ -282,21 +295,7 @@ static HRESULT WINAPI BilinearBlt_8_to_32(LPDIRECTDRAWSURFACE lpddsdst, LPRECT l
|
||||
src8++;
|
||||
dest+=2;
|
||||
}
|
||||
src8 += srcpitch;
|
||||
dest += (ddsd_dst.lPitch + destpitch);
|
||||
}
|
||||
for(x = 0; x < w; x ++){ // last line (there's no next line to melt...)
|
||||
register DWORD Q1, Q2;
|
||||
Q1 = PaletteEntries[*(src8)];
|
||||
Q2 = Melt32(Q1, PaletteEntries[*(src8+1)]);
|
||||
|
||||
*(dest) = Q1;
|
||||
*(dest+1) = Q2;
|
||||
*(dest+ddsd_dst.lPitch) = Q1;
|
||||
*(dest+ddsd_dst.lPitch+1) = Q2;
|
||||
src8++;
|
||||
dest+=2;
|
||||
}
|
||||
|
||||
if(dxw.dwFlags3 & MARKBLIT) MarkRect32(dest0, 2*w, 2*h, destpitch);
|
||||
|
||||
@ -385,11 +384,11 @@ static HRESULT WINAPI BilinearBlt_16_to_32(LPDIRECTDRAWSURFACE lpddsdst, LPRECT
|
||||
LPDIRECTDRAWSURFACE lpddssrc, LPRECT lpsrcrect, DWORD dwflags, LPVOID lpsurface)
|
||||
{
|
||||
HRESULT res;
|
||||
WORD *src16;
|
||||
WORD *src16, *src0;
|
||||
DWORD *dest, *dest0;
|
||||
DDSURFACEDESC2 ddsd_src, ddsd_dst;
|
||||
long srcpitch, destpitch;
|
||||
DWORD x, y, w, h;
|
||||
int w, h;
|
||||
|
||||
w = lpdestrect->right - lpdestrect->left;
|
||||
h = lpdestrect->bottom - lpdestrect->top;
|
||||
@ -439,20 +438,31 @@ static HRESULT WINAPI BilinearBlt_16_to_32(LPDIRECTDRAWSURFACE lpddsdst, LPRECT
|
||||
src16 += (lpsrcrect->top >> 1)*ddsd_src.lPitch;
|
||||
src16 += (lpsrcrect->left >> 1);
|
||||
srcpitch = ddsd_src.lPitch - w;
|
||||
src0 = src16;
|
||||
|
||||
if (!Palette16BPP) SetPalette16BPP();
|
||||
|
||||
// OutTraceDW("DEBUG: h=%d w=%d src=%x dst=%x spitch=%d dpitch=%d\n",h,w,src8,dest,srcpitch,destpitch);
|
||||
for(y = 0; y < h-1; y ++){ // first h-1 lines ....
|
||||
#ifdef USEOPENMP
|
||||
#pragma omp parallel for schedule(static)
|
||||
#endif
|
||||
for(int y = 0; y < h; y ++){
|
||||
register DWORD Q1, Q2, Q3, Q4, Q5;
|
||||
src16 = src0 + (y * ddsd_src.lPitch);
|
||||
dest = dest0 + ((y * ddsd_dst.lPitch) << 1);
|
||||
Q5 = Melt32(Palette16BPP[*(src16)], Palette16BPP[*(src16+ddsd_src.lPitch)]);
|
||||
for(x = 0; x < w; x ++){
|
||||
for(int x = 0; x < w; x ++){
|
||||
Q1 = Palette16BPP[*(src16)];
|
||||
Q2 = Melt32(Q1, Palette16BPP[*(src16+1)]);
|
||||
Q3 = Q5;
|
||||
Q5 = Melt32(Palette16BPP[*(src16+1)], Palette16BPP[*(src16+ddsd_src.lPitch+1)]); // to be used in next for cycle
|
||||
Q4 = Melt32(Q3, Q5);
|
||||
|
||||
if(y == h-1){
|
||||
Q3 = Q1;
|
||||
Q4 = Q2;
|
||||
}
|
||||
else{
|
||||
Q5 = Melt32(Palette16BPP[*(src16+1)], Palette16BPP[*(src16+ddsd_src.lPitch+1)]); // to be used in next for cycle
|
||||
Q4 = Melt32(Q3, Q5);
|
||||
}
|
||||
*(dest) = Q1;
|
||||
*(dest+1) = Q2;
|
||||
*(dest+ddsd_dst.lPitch) = Q3;
|
||||
@ -460,21 +470,7 @@ static HRESULT WINAPI BilinearBlt_16_to_32(LPDIRECTDRAWSURFACE lpddsdst, LPRECT
|
||||
src16++;
|
||||
dest+=2;
|
||||
}
|
||||
src16 += srcpitch;
|
||||
dest += (ddsd_dst.lPitch + destpitch);
|
||||
}
|
||||
for(x = 0; x < w; x ++){ // last line (there's no next line to melt...)
|
||||
register DWORD Q1, Q2;
|
||||
Q1 = Palette16BPP[*(src16)];
|
||||
Q2 = Melt32(Q1, Palette16BPP[*(src16+1)]);
|
||||
|
||||
*(dest) = Q1;
|
||||
*(dest+1) = Q2;
|
||||
*(dest+ddsd_dst.lPitch) = Q1;
|
||||
*(dest+ddsd_dst.lPitch+1) = Q2;
|
||||
src16++;
|
||||
dest+=2;
|
||||
}
|
||||
|
||||
if(dxw.dwFlags3 & MARKBLIT) MarkRect32(dest0, 2*w, 2*h, destpitch);
|
||||
|
||||
@ -710,11 +706,11 @@ static HRESULT WINAPI BilinearBlt_8_to_16(LPDIRECTDRAWSURFACE lpddsdst, LPRECT l
|
||||
LPDIRECTDRAWSURFACE lpddssrc, LPRECT lpsrcrect, DWORD dwflags, LPVOID lpsurface)
|
||||
{
|
||||
HRESULT res;
|
||||
BYTE *src8;
|
||||
BYTE *src8, *src0;
|
||||
SHORT *dest, *dest0;
|
||||
DDSURFACEDESC2 ddsd_src, ddsd_dst;
|
||||
long srcpitch, destpitch;
|
||||
DWORD x, y, w, h;
|
||||
int w, h;
|
||||
typedef DWORD (*Melt16_Type)(DWORD, DWORD);
|
||||
Melt16_Type Melt16;
|
||||
|
||||
@ -767,18 +763,29 @@ static HRESULT WINAPI BilinearBlt_8_to_16(LPDIRECTDRAWSURFACE lpddsdst, LPRECT l
|
||||
src8 += (lpsrcrect->top >> 1)*ddsd_src.lPitch;
|
||||
src8 += (lpsrcrect->left >> 1);
|
||||
srcpitch = ddsd_src.lPitch - w;
|
||||
src0 = src8;
|
||||
|
||||
// OutTraceDW("DEBUG: h=%d w=%d src=%x dst=%x spitch=%d dpitch=%d\n",h,w,src8,dest,srcpitch,destpitch);
|
||||
for(y = 0; y < h-1; y ++){ // first h-1 lines ....
|
||||
#ifdef USEOPENMP
|
||||
#pragma omp parallel for schedule(static)
|
||||
#endif
|
||||
for(int y = 0; y < h; y ++){
|
||||
register DWORD Q1, Q2, Q3, Q4, Q5;
|
||||
src8 = src0 + (y * ddsd_src.lPitch);
|
||||
dest = dest0 + ((y * ddsd_dst.lPitch) << 1);
|
||||
Q5 = Melt16(PaletteEntries[*(src8)], PaletteEntries[*(src8+ddsd_src.lPitch)]);
|
||||
for(x = 0; x < w; x ++){
|
||||
for(int x = 0; x < w; x ++){
|
||||
Q1 = PaletteEntries[*(src8)];
|
||||
Q2 = Melt16(Q1, PaletteEntries[*(src8+1)]);
|
||||
Q3 = Q5;
|
||||
Q5 = Melt16(PaletteEntries[*(src8+1)], PaletteEntries[*(src8+ddsd_src.lPitch+1)]); // to be used in next for cycle
|
||||
Q4 = Melt16(Q3, Q5);
|
||||
|
||||
if(y == h-1){
|
||||
Q3 = Q1;
|
||||
Q4 = Q2;
|
||||
}
|
||||
else{
|
||||
Q5 = Melt16(PaletteEntries[*(src8+1)], PaletteEntries[*(src8+ddsd_src.lPitch+1)]); // to be used in next for cycle
|
||||
Q4 = Melt16(Q3, Q5);
|
||||
}
|
||||
*(dest) = (SHORT)Q1;
|
||||
*(dest+1) = (SHORT)Q2;
|
||||
*(dest+ddsd_dst.lPitch) = (SHORT)Q3;
|
||||
@ -786,21 +793,7 @@ static HRESULT WINAPI BilinearBlt_8_to_16(LPDIRECTDRAWSURFACE lpddsdst, LPRECT l
|
||||
src8++;
|
||||
dest+=2;
|
||||
}
|
||||
src8 += srcpitch;
|
||||
dest += (ddsd_dst.lPitch + destpitch);
|
||||
}
|
||||
for(x = 0; x < w; x ++){ // last line (there's no next line to melt...)
|
||||
register DWORD Q1, Q2;
|
||||
Q1 = PaletteEntries[*(src8)];
|
||||
Q2 = Melt16(Q1, PaletteEntries[*(src8+1)]);
|
||||
|
||||
*(dest) = (SHORT)Q1;
|
||||
*(dest+1) = (SHORT)Q2;
|
||||
*(dest+ddsd_dst.lPitch) = (SHORT)Q1;
|
||||
*(dest+ddsd_dst.lPitch+1) = (SHORT)Q2;
|
||||
src8++;
|
||||
dest+=2;
|
||||
}
|
||||
|
||||
if(dxw.dwFlags3 & MARKBLIT) MarkRect16(dest0, 2*w, 2*h, destpitch);
|
||||
|
||||
@ -814,23 +807,117 @@ static HRESULT WINAPI BilinearBlt_8_to_16(LPDIRECTDRAWSURFACE lpddsdst, LPRECT l
|
||||
static HRESULT WINAPI EmuBlt_16_to_16(LPDIRECTDRAWSURFACE lpddsdst, LPRECT lpdestrect,
|
||||
LPDIRECTDRAWSURFACE lpddssrc, LPRECT lpsrcrect, DWORD dwflags, LPVOID lpsurface)
|
||||
{
|
||||
#ifdef DXWNDDIRECTBLITTING
|
||||
#if 0
|
||||
return (*pBlt)(lpddsdst, lpdestrect, lpddssrc, lpsrcrect, dwflags, NULL);
|
||||
#else
|
||||
OutTraceDW("EmuBlt_16_to_16: UNSUPPORTED\n");
|
||||
return -1;
|
||||
#endif
|
||||
HRESULT res;
|
||||
SHORT *src16;
|
||||
SHORT *dest, *dest0;
|
||||
DDSURFACEDESC2 ddsd_src, ddsd_dst;
|
||||
long srcpitch, destpitch;
|
||||
DWORD x, y, w, h;
|
||||
BOOL is555src, is555dst;
|
||||
|
||||
w = lpdestrect->right - lpdestrect->left;
|
||||
h = lpdestrect->bottom - lpdestrect->top;
|
||||
|
||||
memset(&ddsd_dst,0,sizeof(DDSURFACEDESC2));
|
||||
ddsd_dst.dwSize = Set_dwSize_From_Surface(lpddsdst);
|
||||
ddsd_dst.dwFlags = DDSD_LPSURFACE | DDSD_PITCH;
|
||||
if(res=(*pLock)(lpddsdst, 0, (LPDDSURFACEDESC)&ddsd_dst, DDLOCK_SURFACEMEMORYPTR|DDLOCK_WRITEONLY|DDLOCK_WAIT, 0)){
|
||||
OutTraceE("EmuBlt16_16: Lock ERROR res=%x(%s) at %d\n", res, ExplainDDError(res), __LINE__);
|
||||
return res;
|
||||
}
|
||||
|
||||
memset(&ddsd_src,0,sizeof(DDSURFACEDESC2));
|
||||
ddsd_src.dwSize = Set_dwSize_From_Surface(lpddssrc);
|
||||
ddsd_src.dwFlags = DDSD_LPSURFACE | DDSD_PITCH;
|
||||
if (lpsurface) { // already locked, just get info ....
|
||||
if(res=lpddssrc->GetSurfaceDesc((LPDDSURFACEDESC)&ddsd_src)) {
|
||||
OutTraceE("EmuBlt16_16: GetSurfaceDesc ERROR res=%x(%s) at %d\n", res, ExplainDDError(res), __LINE__);
|
||||
(*pUnlockMethod(lpddsdst))(lpddsdst, lpdestrect);
|
||||
(*pUnlockMethod(lpddssrc))(lpddssrc, lpsrcrect);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if(res=(*pLock)(lpddssrc, 0, (LPDDSURFACEDESC)&ddsd_src, DDLOCK_SURFACEMEMORYPTR|DDLOCK_READONLY, 0)) {
|
||||
(*pUnlockMethod(lpddsdst))(lpddsdst,0);
|
||||
OutTraceE("EmuBlt16_16: Lock ERROR res=%x(%s) at %d\n", res, ExplainDDError(res), __LINE__);
|
||||
return 0;
|
||||
}
|
||||
lpsurface=ddsd_src.lpSurface;
|
||||
}
|
||||
|
||||
ddsd_dst.lPitch >>= 1;
|
||||
dest = (SHORT *)ddsd_dst.lpSurface;
|
||||
dest += lpdestrect->top*ddsd_dst.lPitch;
|
||||
dest += lpdestrect->left;
|
||||
destpitch = ddsd_dst.lPitch - w;
|
||||
dest0 = dest;
|
||||
is555dst = (ddsd_dst.ddpfPixelFormat.dwGBitMask == 0x3E0);
|
||||
|
||||
ddsd_src.lPitch >>= 1;
|
||||
src16 = (SHORT *)lpsurface;
|
||||
src16 += lpsrcrect->top*ddsd_src.lPitch;
|
||||
src16 += lpsrcrect->left;
|
||||
srcpitch = ddsd_src.lPitch - w;
|
||||
is555src = (ddsd_dst.ddpfPixelFormat.dwGBitMask == 0x3E0);
|
||||
|
||||
// OutTraceDW("DEBUG: h=%d w=%d src=%x dst=%x spitch=%d dpitch=%d\n",h,w,src8,dest,srcpitch,destpitch);
|
||||
if (is555dst == is555src){
|
||||
for(y = 0; y < h; y ++){
|
||||
// copy one whole pixel line at a time....
|
||||
memcpy(dest, src16, w<<1);
|
||||
dest += (w + destpitch);
|
||||
src16 += (w + srcpitch);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if(is555dst){
|
||||
for(y = 0; y < h; y ++){
|
||||
for(x = 0; x < w; x ++){
|
||||
SHORT pi;
|
||||
pi = *(src16 ++);
|
||||
pi = (pi & 0x1F) | (pi & 0x7C0)>>1 | (pi & 0xF800)>>1;
|
||||
*(dest ++) = pi;
|
||||
}
|
||||
dest += destpitch;
|
||||
src16 += srcpitch;
|
||||
}
|
||||
}
|
||||
else {
|
||||
for(y = 0; y < h; y ++){
|
||||
for(x = 0; x < w; x ++){
|
||||
SHORT pi;
|
||||
pi = *(src16 ++);
|
||||
pi = (pi & 0x1F) | (pi & 0x3E0)<<1 | (pi & 0x7C00)<<1;
|
||||
*(dest ++) = pi;
|
||||
}
|
||||
dest += destpitch;
|
||||
src16 += srcpitch;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(dxw.dwFlags3 & MARKBLIT) MarkRect16(dest0, w, h, destpitch);
|
||||
|
||||
res=(*pUnlockMethod(lpddsdst))(lpddsdst, lpdestrect);
|
||||
if (res) OutTraceE("EmuBlt16_16: Unlock ERROR dds=%x res=%x(%s) at %d\n", lpddsdst, res, ExplainDDError(res), __LINE__);
|
||||
res=(*pUnlockMethod(lpddssrc))(lpddssrc, lpsrcrect);
|
||||
if (res) OutTraceE("EmuBlt16_16: Unlock ERROR dds=%x res=%x(%s) at %d\n", lpddssrc, res, ExplainDDError(res), __LINE__);
|
||||
return res;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI BilinearBlt_16_to_16(LPDIRECTDRAWSURFACE lpddsdst, LPRECT lpdestrect,
|
||||
LPDIRECTDRAWSURFACE lpddssrc, LPRECT lpsrcrect, DWORD dwflags, LPVOID lpsurface)
|
||||
{
|
||||
HRESULT res;
|
||||
WORD *src16;
|
||||
WORD *src16, *src0;
|
||||
WORD *dest, *dest0;
|
||||
DDSURFACEDESC2 ddsd_src, ddsd_dst;
|
||||
long srcpitch, destpitch;
|
||||
DWORD x, y, w, h;
|
||||
int w, h;
|
||||
typedef DWORD (*Melt16_Type)(DWORD, DWORD);
|
||||
Melt16_Type Melt16;
|
||||
|
||||
@ -884,18 +971,29 @@ static HRESULT WINAPI BilinearBlt_16_to_16(LPDIRECTDRAWSURFACE lpddsdst, LPRECT
|
||||
src16 += (lpsrcrect->top >> 1)*ddsd_src.lPitch;
|
||||
src16 += (lpsrcrect->left >> 1);
|
||||
srcpitch = ddsd_src.lPitch - w;
|
||||
src0 = src16;
|
||||
|
||||
// OutTraceDW("DEBUG: h=%d w=%d src=%x dst=%x spitch=%d dpitch=%d\n",h,w,src8,dest,srcpitch,destpitch);
|
||||
for(y = 0; y < h-1; y ++){ // first h-1 lines ....
|
||||
#ifdef USEOPENMP
|
||||
#pragma omp parallel for schedule(static)
|
||||
#endif
|
||||
for(int y = 0; y < h; y ++){
|
||||
register DWORD Q1, Q2, Q3, Q4, Q5;
|
||||
src16 = src0 + (y * ddsd_src.lPitch);
|
||||
dest = dest0 + ((y * ddsd_dst.lPitch) << 1);
|
||||
Q5 = Melt16(*(src16), *(src16+ddsd_src.lPitch));
|
||||
for(x = 0; x < w; x ++){
|
||||
for(int x = 0; x < w; x ++){
|
||||
Q1 = *(src16);
|
||||
Q2 = Melt16(Q1, *(src16+1));
|
||||
Q3 = Q5;
|
||||
Q5 = Melt16(*(src16+1), *(src16+ddsd_src.lPitch+1)); // to be used in next for cycle
|
||||
Q4 = Melt16(Q3, Q5);
|
||||
|
||||
if(y == h-1){
|
||||
Q3 = Q1;
|
||||
Q4 = Q2;
|
||||
}
|
||||
else{
|
||||
Q5 = Melt16(*(src16+1), *(src16+ddsd_src.lPitch+1)); // to be used in next for cycle
|
||||
Q4 = Melt16(Q3, Q5);
|
||||
}
|
||||
*(dest) = (WORD)Q1;
|
||||
*(dest+1) = (WORD)Q2;
|
||||
*(dest+ddsd_dst.lPitch) = (WORD)Q3;
|
||||
@ -903,21 +1001,7 @@ static HRESULT WINAPI BilinearBlt_16_to_16(LPDIRECTDRAWSURFACE lpddsdst, LPRECT
|
||||
src16++;
|
||||
dest+=2;
|
||||
}
|
||||
src16 += srcpitch;
|
||||
dest += (ddsd_dst.lPitch + destpitch);
|
||||
}
|
||||
for(x = 0; x < w; x ++){ // last line (there's no next line to melt...)
|
||||
register DWORD Q1, Q2;
|
||||
Q1 = *(src16);
|
||||
Q2 = Melt16(Q1, *(src16+1));
|
||||
|
||||
*(dest) = (WORD)Q1;
|
||||
*(dest+1) = (WORD)Q2;
|
||||
*(dest+ddsd_dst.lPitch) = (WORD)Q1;
|
||||
*(dest+ddsd_dst.lPitch+1) = (WORD)Q2;
|
||||
src16++;
|
||||
dest+=2;
|
||||
}
|
||||
|
||||
if(dxw.dwFlags3 & MARKBLIT) MarkRect16((SHORT *)dest0, 2*w, 2*h, destpitch);
|
||||
|
||||
@ -1131,7 +1215,7 @@ static HRESULT WINAPI BilinearBlt_32_to_32(LPDIRECTDRAWSURFACE lpddsdst, LPRECT
|
||||
srcpitch = ddsd_src.lPitch - w;
|
||||
|
||||
// OutTraceDW("DEBUG: h=%d w=%d src=%x dst=%x spitch=%d dpitch=%d\n",h,w,src8,dest,srcpitch,destpitch);
|
||||
for(y = 0; y < h-1; y ++){ // first h-1 lines ....
|
||||
for(y = 0; y < h-1; y ++){
|
||||
register DWORD Q1, Q2, Q3, Q4, Q5;
|
||||
Q5 = Melt32(*(src32), *(src32+ddsd_src.lPitch));
|
||||
for(x = 0; x < w; x ++){
|
||||
@ -1182,335 +1266,6 @@ static HRESULT WINAPI EmuBlt_Null(LPDIRECTDRAWSURFACE lpddsdst, LPRECT lpdestrec
|
||||
return -1;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------//
|
||||
// Reverse blitting procedure: fills a 8BPP paletized surface from the content of a 32BPP one.
|
||||
//--------------------------------------------------------------------------------------------//
|
||||
#define REVPAL32SIZE 0x01000000
|
||||
#define REVPAL32MASK 0x00FFFFFF
|
||||
#define REVPAL16SIZE 0x00010000
|
||||
#define REVPAL16MASK 0x0000FFFF
|
||||
|
||||
// GetMatchingPaletteEntry: retrieves the best matching palette entry close to the given
|
||||
// input color crColor by using a minimum quadratic distance algorithm on each of the 3
|
||||
// RGB color components.
|
||||
|
||||
static int GetMatchingPaletteEntry32(DWORD crColor)
|
||||
{
|
||||
int iDistance, iMinDistance;
|
||||
int iColorIndex, iComponentIndex, iMinColorIndex;
|
||||
DWORD PalColor, TargetColor;
|
||||
|
||||
iMinDistance=0xFFFFFF;
|
||||
iMinColorIndex=0;
|
||||
|
||||
// for each palette entry
|
||||
for(iColorIndex=0; iColorIndex<256; iColorIndex++){
|
||||
int iDist;
|
||||
iDistance=0;
|
||||
PalColor=PaletteEntries[iColorIndex];
|
||||
TargetColor=crColor;
|
||||
// for each of the R,G,B color components
|
||||
for (iComponentIndex=0; iComponentIndex<3; iComponentIndex++){
|
||||
iDist = (TargetColor & 0xFF) - (PalColor & 0xFF);
|
||||
iDist *= iDist;
|
||||
iDistance += iDist;
|
||||
PalColor >>= 8;
|
||||
TargetColor >>= 8;
|
||||
}
|
||||
|
||||
if (iDistance < iMinDistance) {
|
||||
iMinDistance = iDistance;
|
||||
iMinColorIndex = iColorIndex;
|
||||
}
|
||||
|
||||
if (iMinDistance==0) break; // got the perfect match!
|
||||
}
|
||||
OutTraceDW("GetMatchingPaletteEntry32: color=%x matched with palette[%d]=%x dist=%d\n",
|
||||
crColor, iMinColorIndex, PaletteEntries[iMinColorIndex], iDistance);
|
||||
|
||||
return iMinColorIndex;
|
||||
}
|
||||
|
||||
static int GetMatchingPaletteEntry16(DWORD crColor)
|
||||
{
|
||||
int iDistance, iMinDistance;
|
||||
int iColorIndex, iComponentIndex, iMinColorIndex;
|
||||
DWORD PalColor, TargetColor;
|
||||
|
||||
iMinDistance=0xFFFFFF;
|
||||
iMinColorIndex=0;
|
||||
|
||||
// for each palette entry
|
||||
for(iColorIndex=0; iColorIndex<256; iColorIndex++){
|
||||
int iDist;
|
||||
iDistance=0;
|
||||
PalColor=PaletteEntries[iColorIndex];
|
||||
TargetColor=crColor;
|
||||
// for each of the R,G,B color components
|
||||
for (iComponentIndex=0; iComponentIndex<3; iComponentIndex++){
|
||||
iDist = (TargetColor & 0x1F) - (PalColor & 0x1F);
|
||||
iDist *= iDist;
|
||||
iDistance += iDist;
|
||||
PalColor >>= 5;
|
||||
TargetColor >>= 5;
|
||||
}
|
||||
|
||||
if (iDistance < iMinDistance) {
|
||||
iMinDistance = iDistance;
|
||||
iMinColorIndex = iColorIndex;
|
||||
}
|
||||
|
||||
if (iMinDistance==0) break; // got the perfect match!
|
||||
}
|
||||
OutTraceDW("GetMatchingPaletteEntry: color=%x matched with palette[%d]=%x dist=%d\n",
|
||||
crColor, iMinColorIndex, PaletteEntries[iMinColorIndex], iDistance);
|
||||
|
||||
return iMinColorIndex;
|
||||
}
|
||||
|
||||
// this is a real trick: since all 256 possible values of each PaletteRev32BPP entry are valid,
|
||||
// there is no way to tell whether the entry is valid or not. In theory, you should add a separate
|
||||
// status field to track this thing, but that would at least double the used space (REVPAL32SIZE bytes).
|
||||
// So an alternate solution is to pretend that a particular (random) value means the entry in unassigned:
|
||||
// this implies thet even if the entry is properly set, the RevBlt procedure will search for a
|
||||
// matching color anyway. So better avoid for this purpose any frequently used value: I would suggest to
|
||||
// eliminate 0x00 and 0xFF. 0xF0 seems a god candidate, but any other randomly chosen value would
|
||||
// probably be.
|
||||
|
||||
#define PALENTRY_FREE 0x1
|
||||
#define PALENTRY_BUSY 0x0
|
||||
//#define RANDOMENTRY 0xAA
|
||||
|
||||
static HRESULT WINAPI RevBlt_32_to_8(LPDIRECTDRAWSURFACE lpddsdst, LPRECT lpdestrect, LPDIRECTDRAWSURFACE lpddssrc, LPRECT lpsrcrect)
|
||||
{
|
||||
HRESULT res;
|
||||
BYTE *src8;
|
||||
DWORD *dest;
|
||||
DDSURFACEDESC2 ddsd_src, ddsd_dst;
|
||||
long srcpitch, destpitch;
|
||||
DWORD x, y, w, h;
|
||||
static BYTE *PaletteRev32BPP = NULL;
|
||||
static BYTE *PaletteFlags = NULL;
|
||||
int pi;
|
||||
|
||||
OutTraceDW("RevBlt32_8: src=%x dst=%d\n", lpddssrc, lpddsdst);
|
||||
|
||||
w = lpdestrect->right - lpdestrect->left;
|
||||
h = lpdestrect->bottom - lpdestrect->top;
|
||||
|
||||
memset(&ddsd_dst,0,sizeof(DDSURFACEDESC2));
|
||||
ddsd_dst.dwSize = Set_dwSize_From_Surface(lpddsdst);
|
||||
ddsd_dst.dwFlags = DDSD_LPSURFACE | DDSD_PITCH;
|
||||
if(res=(*pLock)(lpddsdst, 0, (LPDDSURFACEDESC)&ddsd_dst, DDLOCK_SURFACEMEMORYPTR|DDLOCK_WRITEONLY|DDLOCK_WAIT, 0)){
|
||||
OutTraceE("RevBlt32_8: Lock ERROR res=%x(%s) at %d\n", res, ExplainDDError(res), __LINE__);
|
||||
return res;
|
||||
}
|
||||
|
||||
memset(&ddsd_src,0,sizeof(DDSURFACEDESC2));
|
||||
ddsd_src.dwSize = Set_dwSize_From_Surface(lpddssrc);
|
||||
ddsd_src.dwFlags = DDSD_LPSURFACE | DDSD_PITCH;
|
||||
if(res=(*pLock)(lpddssrc, 0, (LPDDSURFACEDESC)&ddsd_src, DDLOCK_SURFACEMEMORYPTR|DDLOCK_WRITEONLY|DDLOCK_WAIT, 0)){
|
||||
OutTraceE("RevBlt32_8: Lock ERROR res=%x(%s) at %d\n", res, ExplainDDError(res), __LINE__);
|
||||
return res;
|
||||
}
|
||||
|
||||
ddsd_dst.lPitch >>= 2;
|
||||
dest = (DWORD *)ddsd_dst.lpSurface;
|
||||
dest += lpdestrect->top*ddsd_dst.lPitch;
|
||||
dest += lpdestrect->left;
|
||||
destpitch = ddsd_dst.lPitch - w;
|
||||
|
||||
src8 = (BYTE *)ddsd_src.lpSurface;
|
||||
src8 += lpsrcrect->top*ddsd_src.lPitch;
|
||||
src8 += lpsrcrect->left;
|
||||
srcpitch = ddsd_src.lPitch - w;
|
||||
|
||||
// OutTraceDW("DEBUG: h=%d w=%d src=%x dst=%x spitch=%d dpitch=%d\n",h,w,src8,dest,srcpitch,destpitch);
|
||||
if (!PaletteRev32BPP) { // first time through .....
|
||||
PaletteRev32BPP = (BYTE *)malloc(REVPAL32SIZE);
|
||||
PaletteFlags = (BYTE *)malloc(REVPAL32SIZE);
|
||||
}
|
||||
|
||||
extern BOOL isPaletteUpdated;
|
||||
if (isPaletteUpdated){
|
||||
isPaletteUpdated=FALSE; // do this just once per palette
|
||||
memset(PaletteFlags, PALENTRY_FREE, REVPAL32SIZE); // necessary in build->release mode
|
||||
for (pi=0; pi<256; pi++){
|
||||
int RevIndex=PaletteEntries[pi] & REVPAL32MASK;
|
||||
PaletteRev32BPP[RevIndex]=pi;
|
||||
PaletteFlags[RevIndex]=PALENTRY_BUSY;
|
||||
}
|
||||
}
|
||||
|
||||
for(y = 0; y < h; y ++){
|
||||
for(x = 0; x < w; x ++){
|
||||
int RevIndex = *dest++ & REVPAL32MASK;
|
||||
if(PaletteFlags[RevIndex]==PALENTRY_FREE){
|
||||
PaletteRev32BPP[RevIndex]=GetMatchingPaletteEntry32(RevIndex);
|
||||
PaletteFlags[RevIndex]=PALENTRY_BUSY;
|
||||
}
|
||||
*(src8 ++)= (BYTE)PaletteRev32BPP[RevIndex];
|
||||
}
|
||||
dest += destpitch;
|
||||
src8 += srcpitch;
|
||||
}
|
||||
|
||||
res=(*pUnlockMethod(lpddsdst))(lpddsdst,lpdestrect);
|
||||
if (res) OutTraceE("RevBlt32_8: Unlock ERROR dds=%x res=%x(%s) at %d\n", lpddsdst, res, ExplainDDError(res), __LINE__);
|
||||
res=(*pUnlockMethod(lpddssrc))(lpddssrc, lpsrcrect);
|
||||
if (res) OutTraceE("RevBlt32_8: Unlock ERROR dds=%x res=%x(%s) at %d\n", lpddssrc, res, ExplainDDError(res), __LINE__);
|
||||
return res;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI RevBlt_32_to_16(LPDIRECTDRAWSURFACE lpddsdst, LPRECT lpdestrect, LPDIRECTDRAWSURFACE lpddssrc, LPRECT lpsrcrect)
|
||||
{
|
||||
HRESULT res;
|
||||
WORD *src16;
|
||||
DWORD *dest;
|
||||
DDSURFACEDESC2 ddsd_src, ddsd_dst;
|
||||
long srcpitch, destpitch;
|
||||
DWORD x, y, w, h;
|
||||
|
||||
OutTraceDW("RevBlt32_16: src=%x dst=%d\n", lpddssrc, lpddsdst);
|
||||
|
||||
w = lpdestrect->right - lpdestrect->left;
|
||||
h = lpdestrect->bottom - lpdestrect->top;
|
||||
|
||||
memset(&ddsd_dst,0,sizeof(DDSURFACEDESC2));
|
||||
ddsd_dst.dwSize = Set_dwSize_From_Surface(lpddsdst);
|
||||
ddsd_dst.dwFlags = DDSD_LPSURFACE | DDSD_PITCH;
|
||||
if(res=(*pLock)(lpddsdst, 0, (LPDDSURFACEDESC)&ddsd_dst, DDLOCK_SURFACEMEMORYPTR|DDLOCK_WRITEONLY|DDLOCK_WAIT, 0)){
|
||||
OutTraceE("RevBlt32_16: Lock ERROR res=%x(%s) at %d\n", res, ExplainDDError(res), __LINE__);
|
||||
return res;
|
||||
}
|
||||
|
||||
memset(&ddsd_src,0,sizeof(DDSURFACEDESC2));
|
||||
ddsd_src.dwSize = Set_dwSize_From_Surface(lpddssrc);
|
||||
ddsd_src.dwFlags = DDSD_LPSURFACE | DDSD_PITCH;
|
||||
if(res=(*pLock)(lpddssrc, 0, (LPDDSURFACEDESC)&ddsd_src, DDLOCK_SURFACEMEMORYPTR|DDLOCK_WRITEONLY|DDLOCK_WAIT, 0)){
|
||||
OutTraceE("RevBlt32_16: Lock ERROR res=%x(%s) at %d\n", res, ExplainDDError(res), __LINE__);
|
||||
return res;
|
||||
}
|
||||
|
||||
ddsd_dst.lPitch >>= 2;
|
||||
dest = (DWORD *)ddsd_dst.lpSurface;
|
||||
dest += lpdestrect->top*ddsd_dst.lPitch;
|
||||
dest += lpdestrect->left;
|
||||
destpitch = ddsd_dst.lPitch - w;
|
||||
|
||||
ddsd_src.lPitch >>= 1;
|
||||
src16 = (WORD *)ddsd_src.lpSurface;
|
||||
src16 += lpsrcrect->top*ddsd_src.lPitch;
|
||||
src16 += lpsrcrect->left;
|
||||
srcpitch = ddsd_src.lPitch - w;
|
||||
|
||||
for(y = 0; y < h; y ++){
|
||||
for(x = 0; x < w; x ++){
|
||||
*(src16 ++)= (WORD)*(dest++) & 0xFFFF; // wrong, but visible.....
|
||||
}
|
||||
dest += destpitch;
|
||||
src16 += srcpitch;
|
||||
}
|
||||
|
||||
res=(*pUnlockMethod(lpddsdst))(lpddsdst, lpdestrect);
|
||||
if (res) OutTraceE("RevBlt32_16: Unlock ERROR dds=%x res=%x(%s) at %d\n", lpddsdst, res, ExplainDDError(res), __LINE__);
|
||||
res=(*pUnlockMethod(lpddssrc))(lpddssrc, lpsrcrect);
|
||||
if (res) OutTraceE("RevBlt32_16: Unlock ERROR dds=%x res=%x(%s) at %d\n", lpddssrc, res, ExplainDDError(res), __LINE__);
|
||||
return res;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI RevBlt_16_to_8(LPDIRECTDRAWSURFACE lpddsdst, LPRECT lpdestrect, LPDIRECTDRAWSURFACE lpddssrc, LPRECT lpsrcrect)
|
||||
{
|
||||
HRESULT res;
|
||||
BYTE *src8;
|
||||
USHORT *dest16;
|
||||
DDSURFACEDESC2 ddsd_src, ddsd_dst;
|
||||
long srcpitch, destpitch;
|
||||
DWORD x, y, w, h;
|
||||
static BYTE *PaletteRev16BPP = NULL;
|
||||
static BYTE *PaletteFlags = NULL;
|
||||
int pi;
|
||||
|
||||
OutTraceDW("RevBlt16_8: src=%x dst=%d\n", lpddssrc, lpddsdst);
|
||||
|
||||
w = lpdestrect->right - lpdestrect->left;
|
||||
h = lpdestrect->bottom - lpdestrect->top;
|
||||
|
||||
memset(&ddsd_dst,0,sizeof(DDSURFACEDESC2));
|
||||
ddsd_dst.dwSize = Set_dwSize_From_Surface(lpddsdst);
|
||||
ddsd_dst.dwFlags = DDSD_LPSURFACE | DDSD_PITCH;
|
||||
if(res=(*pLock)(lpddsdst, 0, (LPDDSURFACEDESC)&ddsd_dst, DDLOCK_SURFACEMEMORYPTR|DDLOCK_WRITEONLY|DDLOCK_WAIT, 0)){
|
||||
OutTraceE("RevBlt16_8: Lock ERROR res=%x(%s) at %d\n", res, ExplainDDError(res), __LINE__);
|
||||
return res;
|
||||
}
|
||||
|
||||
memset(&ddsd_src,0,sizeof(DDSURFACEDESC2));
|
||||
ddsd_src.dwSize = Set_dwSize_From_Surface(lpddssrc);
|
||||
ddsd_src.dwFlags = DDSD_LPSURFACE | DDSD_PITCH;
|
||||
if(res=(*pLock)(lpddssrc, 0, (LPDDSURFACEDESC)&ddsd_src, DDLOCK_SURFACEMEMORYPTR|DDLOCK_WRITEONLY|DDLOCK_WAIT, 0)){
|
||||
OutTraceE("RevBlt16_8: Lock ERROR res=%x(%s) at %d\n", res, ExplainDDError(res), __LINE__);
|
||||
return res;
|
||||
}
|
||||
|
||||
ddsd_dst.lPitch >>= 1;
|
||||
dest16 = (USHORT *)ddsd_dst.lpSurface;
|
||||
dest16 += lpdestrect->top*ddsd_dst.lPitch;
|
||||
dest16 += lpdestrect->left;
|
||||
destpitch = ddsd_dst.lPitch - w;
|
||||
|
||||
src8 = (BYTE *)ddsd_src.lpSurface;
|
||||
src8 += lpsrcrect->top*ddsd_src.lPitch;
|
||||
src8 += lpsrcrect->left;
|
||||
srcpitch = ddsd_src.lPitch - w;
|
||||
|
||||
// OutTraceDW("DEBUG: h=%d w=%d src=%x dst=%x spitch=%d dpitch=%d\n",h,w,src8,dest,srcpitch,destpitch);
|
||||
if (!PaletteRev16BPP) { // first time through .....
|
||||
PaletteRev16BPP = (BYTE *)malloc(REVPAL16SIZE);
|
||||
PaletteFlags = (BYTE *)malloc(REVPAL16SIZE);
|
||||
}
|
||||
|
||||
extern BOOL isPaletteUpdated;
|
||||
if (isPaletteUpdated){
|
||||
isPaletteUpdated=FALSE; // do this just once per palette
|
||||
memset(PaletteRev16BPP, PALENTRY_FREE, REVPAL16SIZE); // necessary in build->release mode
|
||||
for (pi=0; pi<256; pi++){
|
||||
int RevIndex=PaletteEntries[pi] & REVPAL16MASK;
|
||||
PaletteRev16BPP[RevIndex]=pi;
|
||||
PaletteFlags[RevIndex]=PALENTRY_BUSY;
|
||||
}
|
||||
}
|
||||
|
||||
for(y = 0; y < h; y ++){
|
||||
for(x = 0; x < w; x ++){
|
||||
int RevIndex = *dest16++ & REVPAL16MASK;
|
||||
if(PaletteFlags[RevIndex]==PALENTRY_FREE){
|
||||
PaletteRev16BPP[RevIndex]=GetMatchingPaletteEntry16(RevIndex);
|
||||
PaletteFlags[RevIndex]=PALENTRY_BUSY;
|
||||
}
|
||||
*(src8 ++)= (BYTE)PaletteRev16BPP[RevIndex];
|
||||
}
|
||||
dest16 += destpitch;
|
||||
src8 += srcpitch;
|
||||
}
|
||||
|
||||
res=(*pUnlockMethod(lpddsdst))(lpddsdst, lpdestrect);
|
||||
if (res) OutTraceE("RevBlt16_8: Unlock ERROR dds=%x res=%x(%s) at %d\n", lpddsdst, res, ExplainDDError(res), __LINE__);
|
||||
res=(*pUnlockMethod(lpddssrc))(lpddssrc, lpsrcrect);
|
||||
if (res) OutTraceE("RevBlt16_8: Unlock ERROR dds=%x res=%x(%s) at %d\n", lpddssrc, res, ExplainDDError(res), __LINE__);
|
||||
return res;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI RevBlt_16_to_16(LPDIRECTDRAWSURFACE lpddsdst, LPRECT lpdestrect, LPDIRECTDRAWSURFACE lpddssrc, LPRECT lpsrcrect)
|
||||
{
|
||||
return (*pBlt)(lpddsdst, lpdestrect, lpddssrc, lpsrcrect, 0, NULL);
|
||||
}
|
||||
|
||||
static HRESULT WINAPI RevBlt_Null(LPDIRECTDRAWSURFACE lpddsdst, LPRECT lpdestrect, LPDIRECTDRAWSURFACE lpddssrc, LPRECT lpsrcrect)
|
||||
{
|
||||
OutTraceE("EmuBlt: undefined color depth\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------//
|
||||
// exported methods
|
||||
//--------------------------------------------------------------------------------------------//
|
||||
@ -1521,26 +1276,22 @@ void SetBltTransformations()
|
||||
dxw.VirtualPixelFormat.dwRGBBitCount, dxw.ActualPixelFormat.dwRGBBitCount);
|
||||
|
||||
/* default (bad) setting */
|
||||
pRevBlt=RevBlt_Null;
|
||||
pEmuBlt=EmuBlt_Null;
|
||||
|
||||
switch (dxw.ActualPixelFormat.dwRGBBitCount){
|
||||
case 32:
|
||||
switch(dxw.VirtualPixelFormat.dwRGBBitCount){
|
||||
case 8:
|
||||
pRevBlt=RevBlt_32_to_8;
|
||||
pEmuBlt=EmuBlt_8_to_32;
|
||||
if(dxw.dwFlags4 & BILINEAR2XFILTER) pEmuBlt=BilinearBlt_8_to_32;
|
||||
OutTraceDW("set color transformation 8<->32\n");
|
||||
break;
|
||||
case 16:
|
||||
pRevBlt=RevBlt_32_to_16;
|
||||
pEmuBlt=EmuBlt_16_to_32;
|
||||
if(dxw.dwFlags4 & BILINEAR2XFILTER) pEmuBlt=BilinearBlt_16_to_32;
|
||||
OutTraceDW("set color transformation 16<->32\n");
|
||||
break;
|
||||
case 24:
|
||||
//pRevBlt=RevBlt_24_to_32;
|
||||
pEmuBlt=EmuBlt_24_to_32;
|
||||
OutTraceDW("set color transformation 24->32\n");
|
||||
break;
|
||||
@ -1557,19 +1308,16 @@ void SetBltTransformations()
|
||||
case 16:
|
||||
switch(dxw.VirtualPixelFormat.dwRGBBitCount){
|
||||
case 8:
|
||||
pRevBlt=RevBlt_16_to_8;
|
||||
pEmuBlt=EmuBlt_8_to_16;
|
||||
if(dxw.dwFlags4 & BILINEAR2XFILTER) pEmuBlt=BilinearBlt_8_to_16;
|
||||
OutTraceDW("set color transformation 8<->16\n");
|
||||
break;
|
||||
case 16:
|
||||
pRevBlt=RevBlt_16_to_16;
|
||||
pEmuBlt=EmuBlt_16_to_16;
|
||||
if(dxw.dwFlags4 & BILINEAR2XFILTER) pEmuBlt=BilinearBlt_16_to_16;
|
||||
OutTraceDW("set color transformation 16<->16\n");
|
||||
break;
|
||||
case 24:
|
||||
//pRevBlt=RevBlt_24_to_16;
|
||||
pEmuBlt=EmuBlt_24_to_16;
|
||||
OutTraceDW("set color transformation 24<->16\n");
|
||||
break;
|
||||
|
@ -1776,7 +1776,6 @@ void HookLibrary(HMODULE hModule, HookEntry_Type *Hooks, char *DLLName)
|
||||
((dxw.dwFlags4 & HOTPATCHALWAYS) && (Hooks->HookStatus != HOOK_HOT_LINKED))) // force hot patch and not already hooked
|
||||
&&
|
||||
Hooks->StoreAddress){ // and save ptr available
|
||||
#if 1
|
||||
// Hot Patch - beware! This way yo're likely to hook unneeded libraries.
|
||||
if(!Hooks->OriginalAddress) {
|
||||
if(!hDLL) {
|
||||
@ -1792,9 +1791,6 @@ void HookLibrary(HMODULE hModule, HookEntry_Type *Hooks, char *DLLName)
|
||||
continue;
|
||||
}
|
||||
}
|
||||
#else
|
||||
if(!Hooks->OriginalAddress) continue;
|
||||
#endif
|
||||
remapped_addr = HotPatch(Hooks->OriginalAddress, Hooks->APIName, Hooks->HookerAddress);
|
||||
if(remapped_addr == (void *)1) { // should never go here ...
|
||||
Hooks->HookStatus = HOOK_HOT_LINKED;
|
||||
|
@ -50,9 +50,9 @@ public: // methods
|
||||
void FixNCHITCursorPos(LPPOINT);
|
||||
void SetClipCursor(void);
|
||||
void EraseClipCursor(void);
|
||||
RECT MapWindowRect(LPRECT lpRect);
|
||||
RECT MapWindowRect(LPRECT);
|
||||
RECT MapWindowRect(void);
|
||||
RECT MapClientRect(LPRECT lpRect);
|
||||
RECT MapClientRect(LPRECT);
|
||||
void MapClient(LPPOINT);
|
||||
void MapClient(LPRECT);
|
||||
void MapClient(int *, int *, int *, int *);
|
||||
|
@ -24,7 +24,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#include "dxwnd.h"
|
||||
#include "dxwcore.hpp"
|
||||
|
||||
#define VERSION "2.02.96"
|
||||
#define VERSION "2.02.97"
|
||||
#define DXWACTIVATESINGLETASK 1 // comment to allow multiple task activations
|
||||
|
||||
#define DDTHREADLOCK 1
|
||||
|
Binary file not shown.
@ -101,6 +101,8 @@ SetTexture7_Type pSetTexture7 = NULL;
|
||||
|
||||
typedef HRESULT (WINAPI *InitializeVP_Type)(void *, LPDIRECT3D);
|
||||
typedef HRESULT (WINAPI *SetViewport_Type)(void *, LPD3DVIEWPORT);
|
||||
typedef HRESULT (WINAPI *SetMaterial_Type)(void *, LPD3DMATERIAL);
|
||||
typedef HRESULT (WINAPI *GetMaterial_Type)(void *, LPD3DMATERIAL);
|
||||
typedef HRESULT (WINAPI *GetViewport_Type)(void *, LPD3DVIEWPORT);
|
||||
typedef HRESULT (WINAPI *GetViewport2_Type)(void *, LPD3DVIEWPORT);
|
||||
typedef HRESULT (WINAPI *SetViewport2_Type)(void *, LPD3DVIEWPORT);
|
||||
@ -115,6 +117,8 @@ typedef HRESULT (WINAPI *NextViewport2_Type)(void *, LPDIRECT3DVIEWPORT2, LPDIRE
|
||||
|
||||
InitializeVP_Type pInitializeVP = NULL;
|
||||
SetViewport_Type pSetViewport = NULL;
|
||||
SetMaterial_Type pSetMaterial = NULL;
|
||||
GetMaterial_Type pGetMaterial = NULL;
|
||||
GetViewport_Type pGetViewport = NULL;
|
||||
GetViewport2_Type pGetViewport2 = NULL;
|
||||
SetViewport2_Type pSetViewport2 = NULL;
|
||||
@ -148,6 +152,8 @@ HRESULT WINAPI extNextViewport2(void *, LPDIRECT3DVIEWPORT2, LPDIRECT3DVIEWPORT2
|
||||
HRESULT WINAPI extInitializeVP(void *, LPDIRECT3D);
|
||||
HRESULT WINAPI extSetViewport(void *, LPD3DVIEWPORT);
|
||||
HRESULT WINAPI extGetViewport(void *, LPD3DVIEWPORT);
|
||||
HRESULT WINAPI extSetMaterial(void *, LPD3DMATERIAL);
|
||||
HRESULT WINAPI extGetMaterial(void *, LPD3DMATERIAL);
|
||||
HRESULT WINAPI extQueryInterfaceD3(void *, REFIID, LPVOID *);
|
||||
|
||||
HRESULT WINAPI extD3DInitialize(void *, LPDIRECT3D , LPGUID, LPD3DDEVICEDESC);
|
||||
@ -185,6 +191,7 @@ HRESULT WINAPI extSetTexture3(void *, DWORD, LPDIRECT3DTEXTURE2);
|
||||
HRESULT WINAPI extSetTexture7(void *, DWORD, LPDIRECTDRAWSURFACE7);
|
||||
|
||||
extern char *ExplainDDError(DWORD);
|
||||
int GD3DDeviceVersion;
|
||||
|
||||
int HookDirect3D7(HMODULE module, int version){
|
||||
void *tmp;
|
||||
@ -288,6 +295,7 @@ void HookDirect3DSession(LPDIRECTDRAW *lplpdd, int d3dversion)
|
||||
void HookDirect3DDevice(void **lpd3ddev, int d3dversion)
|
||||
{
|
||||
OutTraceD3D("HookDirect3DDevice: d3ddev=%x d3dversion=%d\n", lpd3ddev, d3dversion);
|
||||
GD3DDeviceVersion = d3dversion;
|
||||
|
||||
switch(d3dversion){
|
||||
case 1:
|
||||
@ -425,6 +433,22 @@ void HookViewport(LPDIRECT3DVIEWPORT *lpViewport, int d3dversion)
|
||||
}
|
||||
}
|
||||
|
||||
void HookMaterial(LPDIRECT3DMATERIAL *lpMaterial, int d3dversion)
|
||||
{
|
||||
OutTraceD3D("HookMaterial: Material=%x d3dversion=%d\n", *lpMaterial, d3dversion);
|
||||
|
||||
switch(d3dversion){
|
||||
case 1:
|
||||
SetHook((void *)(**(DWORD **)lpMaterial + 16), extSetMaterial, (void **)&pSetMaterial, "SetMaterial");
|
||||
SetHook((void *)(**(DWORD **)lpMaterial + 20), extGetMaterial, (void **)&pGetMaterial, "GetMaterial");
|
||||
break;
|
||||
default:
|
||||
SetHook((void *)(**(DWORD **)lpMaterial + 12), extSetMaterial, (void **)&pSetMaterial, "SetMaterial");
|
||||
SetHook((void *)(**(DWORD **)lpMaterial + 16), extGetMaterial, (void **)&pGetMaterial, "GetMaterial");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
HRESULT WINAPI extQueryInterfaceD3(void *lpd3d, REFIID riid, LPVOID *ppvObj)
|
||||
{
|
||||
HRESULT res;
|
||||
@ -605,6 +629,7 @@ HRESULT WINAPI extCreateMaterial(void *lpd3d, LPDIRECT3DMATERIAL *lpMaterial, IU
|
||||
res=(*pCreateMaterial)(lpd3d, lpMaterial, p0);
|
||||
if(res) OutTraceE("CreateMaterial ERROR: err=%x(%s) at %d\n", res, ExplainDDError(res), __LINE__);
|
||||
else OutTraceD3D("CreateMaterial: OK\n");
|
||||
HookMaterial(lpMaterial, GD3DDeviceVersion);
|
||||
return res;
|
||||
}
|
||||
|
||||
@ -1240,3 +1265,42 @@ HRESULT WINAPI extSetTexture7(void *d3dd, DWORD flags, LPDIRECTDRAWSURFACE7 lpte
|
||||
OutTraceD3D("SetTexture7: d3dd=%x, flags=%x, tex=%x res=%x\n", d3dd, flags, lptex, res);
|
||||
return res;
|
||||
}
|
||||
|
||||
HRESULT WINAPI extSetMaterial(void *d3dd, LPD3DMATERIAL lpMaterial)
|
||||
{
|
||||
HRESULT res;
|
||||
|
||||
OutTraceD3D("SetMaterial: d3dd=%x, material=%x\n", d3dd, lpMaterial);
|
||||
if(lpMaterial && IsDebug){
|
||||
OutTraceD3D("Material: Size=%d Texture=%x diffuse=(%f,%f,%f,%f) ambient=(%f,%f,%f,%f) specular=(%f,%f,%f,%f) emissive=(%f,%f,%f,%f) power=%f\n",
|
||||
lpMaterial->dwSize, lpMaterial->hTexture,
|
||||
lpMaterial->diffuse.a, lpMaterial->diffuse.r, lpMaterial->diffuse.g, lpMaterial->diffuse.b,
|
||||
lpMaterial->ambient.a, lpMaterial->ambient.r, lpMaterial->ambient.g, lpMaterial->ambient.b,
|
||||
lpMaterial->specular.a, lpMaterial->specular.r, lpMaterial->specular.g, lpMaterial->specular.b,
|
||||
lpMaterial->emissive.a, lpMaterial->emissive.r, lpMaterial->emissive.g, lpMaterial->emissive.b,
|
||||
lpMaterial->power
|
||||
);
|
||||
}
|
||||
res=(*pSetMaterial)(d3dd, lpMaterial);
|
||||
if(res) OutTraceD3D("SetMaterial: ERROR res=%x\n", res);
|
||||
return res;
|
||||
}
|
||||
|
||||
HRESULT WINAPI extGetMaterial(void *d3dd, LPD3DMATERIAL lpMaterial)
|
||||
{
|
||||
HRESULT res;
|
||||
|
||||
res=(*pGetMaterial)(d3dd, lpMaterial);
|
||||
OutTraceD3D("GetMaterial: d3dd=%x, material=%x res=%x\n", d3dd, lpMaterial, res);
|
||||
if(lpMaterial && IsDebug && (res==DD_OK)){
|
||||
OutTraceD3D("Material: Size=%d diffuse=(%f,%f,%f,%f) ambient=(%f,%f,%f,%f) specular=(%f,%f,%f,%f) emissive=(%f,%f,%f,%f) power=%f\n",
|
||||
lpMaterial->dwSize,
|
||||
lpMaterial->diffuse.a, lpMaterial->diffuse.r, lpMaterial->diffuse.g, lpMaterial->diffuse.b,
|
||||
lpMaterial->ambient.a, lpMaterial->ambient.r, lpMaterial->ambient.g, lpMaterial->ambient.b,
|
||||
lpMaterial->specular.a, lpMaterial->specular.r, lpMaterial->specular.g, lpMaterial->specular.b,
|
||||
lpMaterial->emissive.a, lpMaterial->emissive.r, lpMaterial->emissive.g, lpMaterial->emissive.b,
|
||||
lpMaterial->power
|
||||
);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
@ -590,17 +590,7 @@ LONG WINAPI extSetWindowLong(HWND hwnd, int nIndex, LONG dwNewLong, SetWindowLon
|
||||
if(dxw.dwFlags1 & LOCKWINSTYLE){
|
||||
if(nIndex==GWL_STYLE){
|
||||
OutTraceDW("SetWindowLong: Lock GWL_STYLE=%x\n", dwNewLong);
|
||||
#if 1
|
||||
return (*pGetWindowLongA)(hwnd, nIndex);
|
||||
#else
|
||||
dwNewLong = (*pGetWindowLongA)(hwnd, nIndex);
|
||||
if ((dxw.dwFlags1 & FIXWINFRAME) && !(dwNewLong & WS_CHILD) /*&& dxw.IsDesktop(hwnd)*/){
|
||||
OutTraceDW("SetWindowLong: GWL_STYLE %x force OVERLAPPEDWINDOW\n", dwNewLong);
|
||||
dwNewLong |= WS_OVERLAPPEDWINDOW;
|
||||
dwNewLong &= ~WS_CLIPSIBLINGS;
|
||||
}
|
||||
return dwNewLong;
|
||||
#endif
|
||||
}
|
||||
if(nIndex==GWL_EXSTYLE){
|
||||
OutTraceDW("SetWindowLong: Lock GWL_EXSTYLE=%x\n", dwNewLong);
|
||||
@ -833,21 +823,6 @@ BOOL WINAPI extGetCursorPos(LPPOINT lppoint)
|
||||
*lppoint=dxw.ScreenToClient(*lppoint);
|
||||
*lppoint=dxw.FixCursorPos(*lppoint);
|
||||
|
||||
#if 0
|
||||
if(dxw.dwFlags4 & FRAMECOMPENSATION){
|
||||
static int dx, dy, todo=TRUE;
|
||||
if (todo){
|
||||
POINT FrameOffset = dxw.GetFrameOffset();
|
||||
dx=FrameOffset.x;
|
||||
dy=FrameOffset.y;
|
||||
OutTraceC("GetCursorPos: frame compensation=(%d,%d)\n", dx, dy);
|
||||
todo=FALSE;
|
||||
}
|
||||
lppoint->x += dx;
|
||||
lppoint->y += dy;
|
||||
}
|
||||
#endif
|
||||
|
||||
GetHookInfo()->CursorX=(short)lppoint->x;
|
||||
GetHookInfo()->CursorY=(short)lppoint->y;
|
||||
OutTraceC("GetCursorPos: FIXED pos=(%d,%d)->(%d,%d)\n", prev.x, prev.y, lppoint->x, lppoint->y);
|
||||
@ -919,46 +894,6 @@ BOOL WINAPI extPeekMessage(LPMSG lpMsg, HWND hwnd, UINT wMsgFilterMin, UINT wMsg
|
||||
{
|
||||
BOOL res;
|
||||
|
||||
#if 0
|
||||
UINT bRemoveMsg = (wRemoveMsg & 0x000F);
|
||||
UINT message;
|
||||
|
||||
do{
|
||||
res=(*pPeekMessage)(lpMsg, hwnd, 0, 0, bRemoveMsg);
|
||||
if(!res) break; // no message available
|
||||
|
||||
OutTraceW("PeekMessage: GOT lpmsg=%x hwnd=%x filter=(%x-%x) remove=%x(%s) msg=%x(%s) wparam=%x, lparam=%x pt=(%d,%d) res=%x\n",
|
||||
lpMsg, lpMsg->hwnd, wMsgFilterMin, wMsgFilterMax, wRemoveMsg, ExplainPeekRemoveMsg(wRemoveMsg),
|
||||
lpMsg->message, ExplainWinMessage(lpMsg->message & 0xFFFF),
|
||||
lpMsg->wParam, lpMsg->lParam, lpMsg->pt.x, lpMsg->pt.y, res);
|
||||
|
||||
message = lpMsg->message;
|
||||
if(res &&(dxw.dwFlags3 & FILTERMESSAGES)){ // filter offending messages
|
||||
switch(message){
|
||||
case WM_NCMOUSEMOVE:
|
||||
case WM_NCLBUTTONDOWN:
|
||||
case WM_NCLBUTTONUP:
|
||||
case WM_NCLBUTTONDBLCLK:
|
||||
case WM_NCRBUTTONDOWN:
|
||||
case WM_NCRBUTTONUP:
|
||||
case WM_NCRBUTTONDBLCLK:
|
||||
case WM_NCMBUTTONDOWN:
|
||||
case WM_NCMBUTTONUP:
|
||||
case WM_NCMBUTTONDBLCLK:
|
||||
OutTraceDW("WindowProc[%x]: SUPPRESS WinMsg=[0x%x]%s(%x,%x)\n", hwnd, message, ExplainWinMessage(message), lpMsg->wParam, lpMsg->lParam);
|
||||
if(!bRemoveMsg) (*pPeekMessage)(lpMsg, hwnd, message, message, TRUE);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if((wMsgFilterMin==0) && (wMsgFilterMax == 0)) break; // no filtering, everything is good
|
||||
if((message < wMsgFilterMin) || (message > wMsgFilterMax)){
|
||||
OutTraceDW("WindowProc[%x]: SUPPRESS WinMsg=[0x%x]%s(%x,%x)\n", hwnd, message, ExplainWinMessage(message), lpMsg->wParam, lpMsg->lParam);
|
||||
if(!bRemoveMsg) (*pPeekMessage)(lpMsg, hwnd, message, message, TRUE);
|
||||
continue; // skip this one ....
|
||||
}
|
||||
} while(FALSE);
|
||||
#endif
|
||||
|
||||
if((wMsgFilterMin==0) && (wMsgFilterMax == 0)){
|
||||
// no filtering, everything is good
|
||||
res=(*pPeekMessage)(lpMsg, hwnd, wMsgFilterMin, wMsgFilterMax, (wRemoveMsg & 0x000F));
|
||||
@ -972,12 +907,6 @@ BOOL WINAPI extPeekMessage(LPMSG lpMsg, HWND hwnd, UINT wMsgFilterMin, UINT wMsg
|
||||
if(wMsgFilterMax<WM_KEYFIRST)(*pPeekMessage)(&Dummy, hwnd, wMsgFilterMax+1, WM_KEYFIRST-1, TRUE); // don't touch above WM_KEYFIRST !!!!
|
||||
}
|
||||
|
||||
#if 0
|
||||
MSG Dummy;
|
||||
(*pPeekMessage)(&Dummy, hwnd, 0x0F, 0x100, TRUE);
|
||||
res=(*pPeekMessage)(lpMsg, hwnd, wMsgFilterMin, wMsgFilterMax, (wRemoveMsg & 0x000F));
|
||||
#endif
|
||||
|
||||
if(res)
|
||||
OutTraceW("PeekMessage: ANY lpmsg=%x hwnd=%x filter=(%x-%x) remove=%x(%s) msg=%x(%s) wparam=%x, lparam=%x pt=(%d,%d) res=%x\n",
|
||||
lpMsg, lpMsg->hwnd, wMsgFilterMin, wMsgFilterMax, wRemoveMsg, ExplainPeekRemoveMsg(wRemoveMsg),
|
||||
|
@ -157,18 +157,6 @@ MCIERROR WINAPI extmciSendStringA(LPCTSTR lpszCommand, LPTSTR lpszReturnString,
|
||||
MCIERROR ret;
|
||||
if(IsWithinMCICall) return(*pmciSendStringA)(lpszCommand, lpszReturnString, cchReturn, hwndCallback); // just proxy ...
|
||||
OutTraceDW("mciSendStringA: Command=\"%s\" Return=%x Callback=%x\n", lpszCommand, cchReturn, hwndCallback);
|
||||
#ifdef WFSPONLY
|
||||
char *target="put movie destination at ";
|
||||
if(!strncmp(lpszCommand, target, strlen(target))) {
|
||||
char NewCommand[256];
|
||||
RECT rect;
|
||||
sscanf(&lpszCommand[strlen(target)], "%ld %ld %ld %ld", &(rect.left), &(rect.top), &(rect.right), &(rect.bottom));
|
||||
rect=dxw.MapClientRect(&rect);
|
||||
sprintf(NewCommand, "put movie destination at %d %d %d %d", rect.left, rect.top, rect.right, rect.bottom);
|
||||
lpszCommand=NewCommand;
|
||||
OutTraceDW("mciSendStringA: replaced Command=\"%s\"\n", lpszCommand);
|
||||
}
|
||||
#else
|
||||
char sMovieNickName[81];
|
||||
RECT rect;
|
||||
if (sscanf(lpszCommand, "put %s destination at %ld %ld %ld %ld",
|
||||
@ -179,7 +167,6 @@ MCIERROR WINAPI extmciSendStringA(LPCTSTR lpszCommand, LPTSTR lpszReturnString,
|
||||
lpszCommand=NewCommand;
|
||||
OutTraceDW("mciSendStringA: replaced Command=\"%s\"\n", lpszCommand);
|
||||
}
|
||||
#endif
|
||||
IsWithinMCICall=TRUE;
|
||||
ret=(*pmciSendStringA)(lpszCommand, lpszReturnString, cchReturn, hwndCallback);
|
||||
IsWithinMCICall=FALSE;
|
||||
@ -194,17 +181,6 @@ MCIERROR WINAPI extmciSendStringW(LPCWSTR lpszCommand, LPWSTR lpszReturnString,
|
||||
WCHAR *target=L"put movie destination at ";
|
||||
if(IsWithinMCICall) return(*pmciSendStringW)(lpszCommand, lpszReturnString, cchReturn, hwndCallback); // just proxy ...
|
||||
OutTraceDW("mciSendStringW: Command=\"%ls\" Return=%x Callback=%x\n", lpszCommand, cchReturn, hwndCallback);
|
||||
#ifdef WFSPONLY
|
||||
if(!wcsncmp(lpszCommand, target, wcslen(target))) {
|
||||
WCHAR NewCommand[256];
|
||||
RECT rect;
|
||||
swscanf(&lpszCommand[wcslen(target)], L"%ld %ld %ld %ld", &(rect.left), &(rect.top), &(rect.right), &(rect.bottom));
|
||||
rect=dxw.MapClientRect(&rect);
|
||||
swprintf(NewCommand, L"put movie destination at %d %d %d %d", rect.left, rect.top, rect.right, rect.bottom);
|
||||
lpszCommand=NewCommand;
|
||||
OutTraceDW("mciSendStringA: replaced Command=\"%ls\"\n", lpszCommand);
|
||||
}
|
||||
#else
|
||||
WCHAR sMovieNickName[81];
|
||||
RECT rect;
|
||||
if (swscanf(lpszCommand, L"put %ls destination at %ld %ld %ld %ld",
|
||||
@ -215,7 +191,6 @@ MCIERROR WINAPI extmciSendStringW(LPCWSTR lpszCommand, LPWSTR lpszReturnString,
|
||||
lpszCommand=NewCommand;
|
||||
OutTraceDW("mciSendStringW: replaced Command=\"%ls\"\n", lpszCommand);
|
||||
}
|
||||
#endif
|
||||
IsWithinMCICall=TRUE;
|
||||
ret=(*pmciSendStringW)(lpszCommand, lpszReturnString, cchReturn, hwndCallback);
|
||||
IsWithinMCICall=FALSE;
|
||||
|
@ -23,6 +23,7 @@ CTargetDlg::CTargetDlg(CWnd* pParent /*=NULL*/)
|
||||
m_DXVersion = 0;
|
||||
m_Coordinates = 0;
|
||||
m_DxEmulationMode = 4; // default: AUTOMATIC
|
||||
m_DxFilterMode = 0; // default: ddraw filtering
|
||||
m_DCEmulationMode = 0; // default: no emulation
|
||||
m_HookDI = FALSE;
|
||||
m_ModifyMouse = TRUE; // default true !!
|
||||
|
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user