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

v2_03_75_src

Former-commit-id: a616cd9c318d40393233f30c84c4587aacefb377
This commit is contained in:
gho tik 2016-10-07 12:46:22 -04:00 committed by Refael ACkermann
parent f07fc28344
commit 1a522bb76b
18 changed files with 263 additions and 28 deletions

View File

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:49d7c2658bf62db9650233f60f2cf5dd82912f2a522c26d4c115891440ccabd9
size 659968
oid sha256:7fd28d3540f74ceab1034bff9cd6fd4059e759568c2c207393d61fe20f0367da
size 660480

View File

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:c966fe71e5250ed781b9e1415ce53fec601a93c4384893a2afb78bab76d75e56
size 640512
oid sha256:b4833fd88b00f606494df68b4af21d27e5f419a90686cb407e0539166dea762e
size 642560

View File

@ -1146,4 +1146,13 @@ add: revised log configuration, added "Separate" mode to make each process to wr
v2.03.74
fix: logging of dwFOURCC field text value
fix: Injection routine: avoid closing a few handles that should not be closed, simplified logic.
add: GUI global configuration panel
add: GUI global configuration panel
v2.03.75
fix: handling of restore previous screen mode when a primary fullscreen window is terminated. Fixes "Dethkarz" initialization error after 8BPP intro movie termination.
fix: SystemParameterInfo for SPI_SETSCREENSAVERRUNNING does not return an error
fix: added default pixel format specification to backbuffer: improves the possibility of ZBUFFER attach
fix: recovery of DDERR_SURFACELOST error on primary surface in PrimaryStretchBlt routine.
fix: possible palette handle leakage
fix: DC leakage caused by CreateCompatibleDC. Fix "Mechwarrior 3" repeated play sessions.
add: GUI drag & drop of game executables

View File

@ -2659,6 +2659,10 @@ static HRESULT BuildBackBufferEmu(LPDIRECTDRAW lpdd, CreateSurface_Type pCreateS
ddsd.dwFlags &= ~(DDSD_BACKBUFFERCOUNT|DDSD_REFRESHRATE);
ddsd.dwFlags |= (DDSD_CAPS|DDSD_HEIGHT|DDSD_WIDTH|DDSD_PIXELFORMAT);
ddsd.ddsCaps.dwCaps &= ~(DDSCAPS_BACKBUFFER|DDSCAPS_PRIMARYSURFACE|DDSCAPS_FLIP|DDSCAPS_COMPLEX|DDSCAPS_VIDEOMEMORY|DDSCAPS_LOCALVIDMEM);
// v2.03.75: if a surface desc is NOT specified, build one. This will allow ZBUF attach.
if(!(lpddsd->dwFlags & DDSD_PIXELFORMAT)) SetPixFmt((LPDDSURFACEDESC2)&ddsd);
// DDSCAPS_OFFSCREENPLAIN seems required to support the palette in memory surfaces
ddsd.ddsCaps.dwCaps |= (DDSCAPS_SYSTEMMEMORY|DDSCAPS_OFFSCREENPLAIN);
if(ddsd.ddsCaps.dwCaps & DDSCAPS_3DDEVICE) ddsd.ddsCaps.dwCaps &= ~DDSCAPS_SYSTEMMEMORY; // necessary: Martian Gotic crashes otherwise
@ -3426,14 +3430,27 @@ HRESULT WINAPI PrimaryStretchBlt(int dxversion, Blt_Type pBlt, LPDIRECTDRAWSURFA
OutTraceE("PrimaryStretchBlt: Blt ERROR %x(%s) at %d\n", res, ExplainDDError(res), __LINE__);
}
else {
// fast-blit to primary
if(dxw.dwFlags3 & FORCECLIPPER){
res= (*pBlt)(lpdds, lpdestrect, lpddsTmp, &TmpRect, DDBLT_WAIT, 0);
if(res) OutTraceE("PrimaryStretchBlt: Blt ERROR %x(%s) at %d\n", res, ExplainDDError(res), __LINE__);
}
else{
res= (*pBltFast)(lpdds, lpdestrect->left, lpdestrect->top, lpddsTmp, &TmpRect, DDBLTFAST_WAIT);
if(res) OutTraceE("PrimaryStretchBlt: BltFast ERROR %x(%s) at %d\n", res, ExplainDDError(res), __LINE__);
while(TRUE) {
// fast-blit to primary
if(dxw.dwFlags3 & FORCECLIPPER){
res= (*pBlt)(lpdds, lpdestrect, lpddsTmp, &TmpRect, DDBLT_WAIT, 0);
if(res) OutTraceE("PrimaryStretchBlt: Blt ERROR %x(%s) at %d\n", res, ExplainDDError(res), __LINE__);
}
else{
res= (*pBltFast)(lpdds, lpdestrect->left, lpdestrect->top, lpddsTmp, &TmpRect, DDBLTFAST_WAIT);
if(res) OutTraceE("PrimaryStretchBlt: BltFast ERROR %x(%s) at %d\n", res, ExplainDDError(res), __LINE__);
}
if(res == DDERR_SURFACELOST){
res = lpdds->Restore();
if(res) {
OutTraceE("PrimaryStretchBlt: Restore ERROR %x(%s) at %d\n", res, ExplainDDError(res), __LINE__);
}
else {
OutTraceDW("PrimaryStretchBlt: surface sucessfully recovered, retry\n");
continue;
}
}
break;
}
}
(*pReleaseSMethod(dxversion))(lpddsTmp);
@ -5522,8 +5539,16 @@ HRESULT WINAPI extReleaseP(LPDIRECTDRAWPALETTE lpddPalette)
OutTraceDDRAW("Release(P): lpddPalette=%x ref=%x\n", lpddPalette, ref);
if (lpddPalette == lpDDP) {
OutTraceDW("Release(P): lpDDP extrarefcount=%d\n", iDDPExtraRefCounter);
ref -= iDDPExtraRefCounter;
if(dxw.dwFlags4 & FIXREFCOUNTER) {
OutTraceDW("Release(P): lpDDP extrarefcount=%d\n", iDDPExtraRefCounter);
if((ULONG)iDDPExtraRefCounter >= ref){
while(ref) ref = (*pReleaseP)(lpddPalette);
lpDDP=NULL;
iDDPExtraRefCounter = 0;
return 0;
}
ref -= iDDPExtraRefCounter;
}
if (ref <= 0) {
ref = 0;
OutTraceDW("Release(P): clearing lpDDP=%x->NULL\n", lpDDP);

View File

@ -27,7 +27,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "TlHelp32.h"
#define VERSION "2.03.74"
#define VERSION "2.03.75"
#define DDTHREADLOCK 1
//#define LOCKTHREADS

Binary file not shown.

View File

@ -921,12 +921,15 @@ HDC WINAPI extCreateICA(LPCTSTR lpszDriver, LPCTSTR lpszDevice, LPCTSTR lpszOutp
HDC WINAPI extGDICreateCompatibleDC(HDC hdc)
{
// v2.03.75: fixed dc leakage that crashed "Mechwarrior 3"
HDC RetHdc;
DWORD LastError;
BOOL bSwitchedToMainWin = FALSE;
OutTraceDW("GDI.CreateCompatibleDC: hdc=%x\n", hdc);
if(hdc==0){
hdc=(*pGDIGetDC)(dxw.GethWnd());
bSwitchedToMainWin = TRUE;
if(dxw.dwFlags6 & CREATEDESKTOP){
extern HWND hDesktopWindow;
hdc=(*pGDIGetDC)(hDesktopWindow);
@ -937,6 +940,7 @@ HDC WINAPI extGDICreateCompatibleDC(HDC hdc)
// eliminated error message for errorcode 0.
SetLastError(0);
RetHdc=(*pGDICreateCompatibleDC)(hdc);
if(bSwitchedToMainWin) (*pGDIReleaseDC)(dxw.GethWnd(),hdc);
LastError=GetLastError();
if(LastError == 0){
OutTraceDW("GDI.CreateCompatibleDC: returning HDC=%x\n", RetHdc);

View File

@ -108,6 +108,9 @@ BOOL WINAPI extDrawMenuBar(HWND);
//typedef BOOL (WINAPI *TranslateMessage_Type)(MSG *);
//TranslateMessage_Type pTranslateMessage = NULL;
//BOOL WINAPI extTranslateMessage(MSG *);
typedef BOOL (WINAPI *EnumDisplayDevicesA_Type)(LPCSTR, DWORD, PDISPLAY_DEVICE, DWORD);
EnumDisplayDevicesA_Type pEnumDisplayDevicesA = NULL;
BOOL WINAPI extEnumDisplayDevicesA(LPCSTR, DWORD, PDISPLAY_DEVICE, DWORD);
#ifdef TRACEPALETTE
@ -200,6 +203,8 @@ static HookEntryEx_Type Hooks[]={
{HOOK_HOT_CANDIDATE, 0, "ShowScrollBar", (FARPROC)ShowScrollBar, (FARPROC *)&pShowScrollBar, (FARPROC)extShowScrollBar},
{HOOK_HOT_CANDIDATE, 0, "DrawMenuBar", (FARPROC)DrawMenuBar, (FARPROC *)&pDrawMenuBar, (FARPROC)extDrawMenuBar},
//{HOOK_HOT_CANDIDATE, 0, "EnumDisplayDevicesA", (FARPROC)EnumDisplayDevicesA, (FARPROC *)&pEnumDisplayDevicesA, (FARPROC)extEnumDisplayDevicesA},
{HOOK_IAT_CANDIDATE, 0, 0, NULL, 0, 0} // terminator
};
@ -1466,6 +1471,9 @@ static BOOL IsFullscreenWindow(
return FALSE;
}
static HWND hLastFullScrWin = 0;
static DDPIXELFORMAT ddpLastPixelFormat;
static HWND WINAPI extCreateWindowCommon(
LPCTSTR ApiName,
BOOL WideChar,
@ -1529,6 +1537,12 @@ static HWND WINAPI extCreateWindowCommon(
RECT screen;
POINT upleft = {0,0};
// if already in fullscreen mode, save previous settings
if(dxw.IsFullScreen() && dxw.GethWnd()){
hLastFullScrWin = dxw.GethWnd();
ddpLastPixelFormat = dxw.VirtualPixelFormat;
}
// update virtual screen size if it has grown
// v2.03.58 fix: do't consider CW_USEDEFAULT ad a big unsigned integer!! Fixes "Imperialism".
if((nWidth != CW_USEDEFAULT) && (nHeight != CW_USEDEFAULT)) dxw.SetScreenSize(nWidth, nHeight);
@ -2648,12 +2662,25 @@ BOOL WINAPI extDestroyWindow(HWND hWnd)
OutTraceB("DestroyWindow: hwnd=%x\n", hWnd);
if (hWnd == dxw.GethWnd()) {
OutTraceDW("DestroyWindow: destroy main hwnd=%x\n", hWnd);
if(hLastFullScrWin){
OutTraceDW("DestroyWindow: revert to main hwnd=%x bpp=%d\n",
hWnd, ddpLastPixelFormat.dwRGBBitCount);
dxw.SethWnd(hLastFullScrWin);
hLastFullScrWin = NULL;
dxw.VirtualPixelFormat = ddpLastPixelFormat;
extern int iBakBufferVersion;
SetBltTransformations(iBakBufferVersion);
}
else {
OutTraceDW("DestroyWindow: destroy main hwnd=%x\n", hWnd);
dxw.SethWnd(NULL);
}
if(dxw.dwFlags6 & NODESTROYWINDOW) {
OutTraceDW("DestroyWindow: do NOT destroy main hwnd=%x\n", hWnd);
return TRUE;
}
OutTraceDW("DestroyWindow: destroy main hwnd=%x\n", hWnd);
dxw.SethWnd(NULL);
}
if (hControlParentWnd && (hWnd == hControlParentWnd)) {
OutTraceDW("DestroyWindow: destroy control parent hwnd=%x\n", hWnd);
@ -3049,6 +3076,7 @@ BOOL WINAPI extSystemParametersInfoA(UINT uiAction, UINT uiParam, PVOID pvParam,
switch(uiAction){
case SPI_SETKEYBOARDDELAY:
case SPI_SETKEYBOARDSPEED:
case SPI_SETSCREENSAVERRUNNING: // v2.03.75 used by Dethkarz, but not really necessary
OutTraceDW("SystemParametersInfoA: bypass action=%x\n", uiAction);
return TRUE;
break;
@ -3722,4 +3750,22 @@ BOOL WINAPI extTranslateMessage(MSG *pMsg)
ret=(*pTranslateMessage)(pMsg);
return ret;
}
#endif
#endif
BOOL WINAPI extEnumDisplayDevicesA(LPCSTR lpDevice, DWORD iDevNum, PDISPLAY_DEVICE lpDisplayDevice, DWORD dwFlags)
{
BOOL ret;
MessageBox(0, "EnumDisplayDevicesA", "dxwnd", 0);
OutTrace("EnumDisplayDevices: device=%s devnum=%i flags=%x\n", lpDevice, iDevNum, dwFlags);
ret = (*pEnumDisplayDevicesA)(lpDevice, iDevNum, lpDisplayDevice, dwFlags);
if(ret){
OutTrace("EnumDisplayDevices: cb=%x devname=%s devstring=%s stateflags=%x\n",
lpDisplayDevice->cb, lpDisplayDevice->DeviceName, lpDisplayDevice->DeviceString, lpDisplayDevice->StateFlags);
}
else{
OutTraceE("EnumDisplayDevices ERROR: err=%d\n", GetLastError());
}
return ret;
}

35
host/CDragEdit.cpp Normal file
View File

@ -0,0 +1,35 @@
#include "stdafx.h"
#include "CDragEdit.h"
CDragEdit::CDragEdit()
{
}
CDragEdit::~CDragEdit()
{
}
BOOL CDragEdit::OnInitDialog()
{
DragAcceptFiles();
return TRUE;
}
void CDragEdit::OnDropFiles(HDROP dropInfo)
{
CString sFile;
DWORD nBuffer = 0;
// Get number of files
UINT nFilesDropped = DragQueryFile(dropInfo, 0xFFFFFFFF, NULL, 0);
if(nFilesDropped > 0){
nBuffer = DragQueryFile(dropInfo, 0, NULL, 0);
DragQueryFile(dropInfo, 0, sFile.GetBuffer(nBuffer+1), nBuffer+1);
SetWindowTextA(sFile.GetBuffer());
sFile.ReleaseBuffer();
}
DragFinish(dropInfo);
}
BEGIN_MESSAGE_MAP(CDragEdit, CEdit)
ON_WM_DROPFILES()
END_MESSAGE_MAP()

13
host/CDragEdit.h Normal file
View File

@ -0,0 +1,13 @@
// CDragEdit class: inherited by DEdit, adds drag & drop of file pathnames
// within the text field.
class CDragEdit : public CEdit
{
public:
CDragEdit();
virtual ~CDragEdit();
BOOL OnInitDialog();
private:
afx_msg void OnDropFiles(HDROP hDropInfo);
DECLARE_MESSAGE_MAP()
};

View File

@ -66,9 +66,10 @@ void CTabProgram::DoDataExchange(CDataExchange* pDX)
BEGIN_MESSAGE_MAP(CTabProgram, CDialog)
//{{AFX_MSG_MAP(CTabProgram)
// NOTE: the ClassWizard will add message map macros here
// NOTE: the ClassWizard will add message map macros here
ON_BN_CLICKED(IDC_OPEN, OnOpen)
ON_BN_CLICKED(IDC_OPENLAUNCH, OnOpenLaunch)
ON_WM_DROPFILES()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
@ -150,6 +151,25 @@ void CTabProgram::OnOpenLaunch()
}
}
void CTabProgram::OnDropFiles(HDROP dropInfo)
{
CString sFile;
DWORD nBuffer = 0;
// Get number of files
UINT nFilesDropped = DragQueryFile(dropInfo, 0xFFFFFFFF, NULL, 0);
if(nFilesDropped > 0){
nBuffer = DragQueryFile(dropInfo, 0, NULL, 0);
DragQueryFile(dropInfo, 0, sFile.GetBuffer(nBuffer+1), nBuffer+1);
//CTargetDlg *pDlg = (CTargetDlg *)this->GetParent()->GetParent();
//pDlg->m_FilePath = sFile;
CDragEdit *pEditFile = (CDragEdit *)this->GetDlgItem(IDC_FILE);
pEditFile->SetWindowTextA(sFile.GetBuffer());
//MessageBox(sFile.GetBuffer(), "debug", 0);
sFile.ReleaseBuffer();
}
DragFinish(dropInfo);
}
BOOL CTabProgram::OnInitDialog()
{
HINSTANCE Hinst;
@ -157,6 +177,17 @@ BOOL CTabProgram::OnInitDialog()
CStatic *IconBox;
IFormat *m_pRelIntegerFormat = new(RelIntegerFormat);
//ChangeWindowMessageFilter(WM_DROPFILES, MSGFLT_ADD);
//ChangeWindowMessageFilter(WM_COPYDATA, MSGFLT_ADD);
//ChangeWindowMessageFilter(0x0049, MSGFLT_ADD);
DragAcceptFiles();
CDragEdit *pEditFile;
pEditFile = (CDragEdit *)this->GetDlgItem(IDC_FILE);
pEditFile->DragAcceptFiles();
pEditFile = (CDragEdit *)this->GetDlgItem(IDC_LAUNCH);
pEditFile->DragAcceptFiles();
//m_File.DragAcceptFiles();
//m_Launch.DragAcceptFiles();
CDialog::OnInitDialog();
CTargetDlg *cTarget = ((CTargetDlg *)(this->GetParent()->GetParent()));
Hinst = ::LoadLibrary(cTarget->m_FilePath);

View File

@ -45,6 +45,7 @@ public:
protected:
CSpecialEdit m_EditPosX;
CSpecialEdit m_EditPosY;
afx_msg void OnDropFiles(HDROP hDropInfo);
};
//{{AFX_INSERT_LOCATION}}

View File

@ -8,6 +8,7 @@
//
#include "dxTabCtrl.h"
#include "SpecialEdit.h"
#include "CDragEdit.h"
/////////////////////////////////////////////////////////////////////////////
// CTargetDlg Dialog
@ -23,8 +24,8 @@ public:
//{{AFX_DATA(CTargetDlg)
enum { IDD = IDD_TARGET };
CDXTabCtrl m_tabdxTabCtrl;
CEdit m_File;
CEdit m_Launch;
CDragEdit m_File;
CDragEdit m_Launch;
int m_DXVersion;
int m_Coordinates;
int m_InitColorDepth;

Binary file not shown.

Binary file not shown.

View File

@ -221,6 +221,10 @@
Name="Source Files"
Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
>
<File
RelativePath=".\CDragEdit.cpp"
>
</File>
<File
RelativePath=".\CGlobalSettings.cpp"
>
@ -508,6 +512,10 @@
RelativePath=".\cdib.h"
>
</File>
<File
RelativePath=".\CDragEdit.h"
>
</File>
<File
RelativePath=".\CGlobalSettings.h"
>
@ -714,22 +722,22 @@
>
</File>
</Filter>
<File
RelativePath=".\alt-ctrl-shift.png"
>
</File>
<File
RelativePath=".\res\alt-ctrl-shift.png"
>
</File>
<File
RelativePath=".\res\alt.png"
RelativePath=".\alt-ctrl-shift.png"
>
</File>
<File
RelativePath=".\alt.png"
>
</File>
<File
RelativePath=".\res\alt.png"
>
</File>
<File
RelativePath=".\resource"
>

View File

@ -153,6 +153,7 @@ BEGIN_MESSAGE_MAP(CDxwndhostView, CListView)
ON_COMMAND(ID_MOVE_BOTTOM, OnMoveBottom)
ON_WM_RBUTTONDOWN()
ON_WM_HOTKEY()
ON_WM_DROPFILES()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
@ -1154,6 +1155,11 @@ void CDxwndhostView::OnInitialUpdate()
LV_ITEM listitem;
int i;
DragAcceptFiles();
ChangeWindowMessageFilter(WM_DROPFILES, MSGFLT_ADD);
ChangeWindowMessageFilter(WM_COPYDATA, MSGFLT_ADD);
ChangeWindowMessageFilter(0x0049, MSGFLT_ADD);
// Create 256 color image lists
HIMAGELIST hList = ImageList_Create(32,32, ILC_COLOR8 |ILC_MASK , 4, 1);
m_cImageListNormal.Attach(hList);
@ -1295,6 +1301,27 @@ void CDxwndhostView::OnExport()
}
}
void CDxwndhostView::OnImport(CString sFilePath)
{
LV_ITEM listitem;
int i;
for (i=0; strlen(TargetMaps[i].path) && i<MAXTARGETS; i++)
;
if (i==MAXTARGETS) {
MessageBoxLang(DXW_STRING_MAXENTRIES, DXW_STRING_WARNING, MB_OK | MB_ICONEXCLAMATION);
return;
}
CListCtrl& listctrl = GetListCtrl();
if(LoadConfigItem(&TargetMaps[i], &PrivateMaps[i], 0, (char *)sFilePath.GetString())){
listitem.mask = LVIF_TEXT | LVIF_IMAGE;
listitem.iItem = i;
listitem.iSubItem = 0;
listitem.iImage = SetTargetIcon(TargetMaps[i]);
listitem.pszText = PrivateMaps[i].title;
listctrl.InsertItem(&listitem);
}
}
void CDxwndhostView::OnImport()
{
LV_ITEM listitem;
@ -1802,7 +1829,12 @@ void CDxwndhostView::OnProcessKill()
RevertScreenChanges(&this->InitDevMode);
}
void CDxwndhostView::OnAdd()
void CDxwndhostView::OnAdd()
{
OnAdd(NULL);
}
void CDxwndhostView::OnAdd(char *sInitialPath)
{
// TODO: Please add a command handler code here.
int i;
@ -1815,6 +1847,8 @@ void CDxwndhostView::OnAdd()
return;
}
memset(&TargetMaps[i],0,sizeof(TARGETMAP)); // clean up, just in case....
if(sInitialPath) dlg.m_FilePath = CString(sInitialPath);
if(dlg.DoModal() == IDOK && dlg.m_FilePath.GetLength()){
strnncpy(PrivateMaps[i].title, (char *)dlg.m_Title.GetString(), MAX_TITLE);
PrivateMaps[i].notes = (char *)malloc(strlen(dlg.m_Notes.GetString())+1);
@ -2759,3 +2793,27 @@ void CDxwndhostView::OnClearCompatibilityFlags()
RegCloseKey(hk);
}
}
void CDxwndhostView::OnDropFiles(HDROP dropInfo)
{
CString sFile;
DWORD nBuffer = 0;
char *p;
// Get number of files
UINT nFilesDropped = DragQueryFile(dropInfo, 0xFFFFFFFF, NULL, 0);
if(nFilesDropped > 0){
nBuffer = DragQueryFile(dropInfo, 0, NULL, 0);
DragQueryFile(dropInfo, 0, sFile.GetBuffer(nBuffer+1), nBuffer+1);
p = (char *)sFile.GetString();
p += (strlen(p)-4);
if(!_strnicmp(p, ".dxw", 4)){
this->OnImport(sFile);
}
else {
this->OnAdd(sFile.GetBuffer());
}
sFile.ReleaseBuffer();
}
DragFinish(dropInfo);
}

View File

@ -19,6 +19,7 @@ protected: // Create from serialization only features.
DECLARE_DYNCREATE(CDxwndhostView)
BOOL isUpdated;
void SaveConfigFile();
BOOL OnInitDialog();
private:
void Resize(void);
@ -62,10 +63,12 @@ protected:
//{{AFX_MSG(CDxwndhostView)
afx_msg void OnDblclk(NMHDR* pNMHDR, LRESULT* pResult);
afx_msg void OnAdd();
afx_msg void OnAdd(char *);
afx_msg void OnDuplicate();
afx_msg void OnModify();
afx_msg void OnExport();
afx_msg void OnImport();
afx_msg void OnImport(CString);
afx_msg void OnDelete();
afx_msg void OnExplore();
afx_msg void OnKill();
@ -109,6 +112,7 @@ protected:
afx_msg void OnMoveUp();
afx_msg void OnMoveDown();
afx_msg void OnMoveBottom();
afx_msg void OnDropFiles(HDROP hDropInfo);
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};