single-window
This commit is contained in:
parent
18c5d2924b
commit
8e85a0bae0
2
Cxbx.dsp
2
Cxbx.dsp
|
@ -83,7 +83,7 @@ BSC32=bscmake.exe
|
||||||
# ADD BSC32 /nologo
|
# ADD BSC32 /nologo
|
||||||
LINK32=link.exe
|
LINK32=link.exe
|
||||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept
|
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept
|
||||||
# ADD LINK32 libjpeg.lib d3d8.lib dinput8.lib dxguid.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /map /debug /machine:I386 /pdbtype:sept /libpath:"Lib"
|
# ADD LINK32 libjpeg.lib d3d8.lib dinput8.lib dxguid.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /map /debug /machine:I386 /nodefaultlib:"libc" /pdbtype:sept /libpath:"Lib"
|
||||||
# SUBTRACT LINK32 /pdb:none
|
# SUBTRACT LINK32 /pdb:none
|
||||||
|
|
||||||
!ENDIF
|
!ENDIF
|
||||||
|
|
|
@ -2,6 +2,8 @@ Cxbx Todo (* denotes high priority, + denotes medium priority)
|
||||||
|
|
||||||
HLE :
|
HLE :
|
||||||
|
|
||||||
|
* NSIS installer. Option to clear UDATA/TDATA/CxbxCache
|
||||||
|
|
||||||
* Modularize inline vertex buffers (Begin()/End())
|
* Modularize inline vertex buffers (Begin()/End())
|
||||||
|
|
||||||
* Direct3D_SetPushBufferSize for Antz Extreme Racing (4361). Do this
|
* Direct3D_SetPushBufferSize for Antz Extreme Racing (4361). Do this
|
||||||
|
|
|
@ -35,6 +35,7 @@
|
||||||
#define EMUEXE_H
|
#define EMUEXE_H
|
||||||
|
|
||||||
#include "Exe.h"
|
#include "Exe.h"
|
||||||
|
#include <windows.h>
|
||||||
|
|
||||||
// ******************************************************************
|
// ******************************************************************
|
||||||
// * class : EmuExe
|
// * class : EmuExe
|
||||||
|
@ -45,7 +46,7 @@ class EmuExe : public Exe
|
||||||
// ******************************************************************
|
// ******************************************************************
|
||||||
// * Construct via Xbe file object
|
// * Construct via Xbe file object
|
||||||
// ******************************************************************
|
// ******************************************************************
|
||||||
EmuExe(class Xbe *x_Xbe, DebugMode x_debug_mode, char *x_debug_filename);
|
EmuExe(class Xbe *x_Xbe, DebugMode x_debug_mode, char *x_debug_filename, HWND hwndParent = NULL);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -93,13 +93,14 @@
|
||||||
#define ID_SETTINGS_GENXP 40078
|
#define ID_SETTINGS_GENXP 40078
|
||||||
#define ID_SETTINGS_GENWT 40079
|
#define ID_SETTINGS_GENWT 40079
|
||||||
#define ID_SETTINGS_GENMA 40080
|
#define ID_SETTINGS_GENMA 40080
|
||||||
|
#define ID_EMULATION_STOP 40082
|
||||||
|
|
||||||
// Next default values for new objects
|
// Next default values for new objects
|
||||||
//
|
//
|
||||||
#ifdef APSTUDIO_INVOKED
|
#ifdef APSTUDIO_INVOKED
|
||||||
#ifndef APSTUDIO_READONLY_SYMBOLS
|
#ifndef APSTUDIO_READONLY_SYMBOLS
|
||||||
#define _APS_NEXT_RESOURCE_VALUE 119
|
#define _APS_NEXT_RESOURCE_VALUE 119
|
||||||
#define _APS_NEXT_COMMAND_VALUE 40082
|
#define _APS_NEXT_COMMAND_VALUE 40083
|
||||||
#define _APS_NEXT_CONTROL_VALUE 1050
|
#define _APS_NEXT_CONTROL_VALUE 1050
|
||||||
#define _APS_NEXT_SYMED_VALUE 104
|
#define _APS_NEXT_SYMED_VALUE 104
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -80,12 +80,17 @@ class WndMain : public Wnd
|
||||||
// * Exe operations
|
// * Exe operations
|
||||||
// ******************************************************************
|
// ******************************************************************
|
||||||
void ImportExe(const char *x_filename);
|
void ImportExe(const char *x_filename);
|
||||||
bool ConvertToExe(const char *x_filename, bool x_bVerifyIfExists);
|
bool ConvertToExe(const char *x_filename, bool x_bVerifyIfExists, HWND hwndParent);
|
||||||
|
|
||||||
// ******************************************************************
|
// ******************************************************************
|
||||||
// * start emulation (converting to .exe if not done already)
|
// * start emulation (converting to .exe if not done already)
|
||||||
// ******************************************************************
|
// ******************************************************************
|
||||||
void StartEmulation(EnumAutoConvert x_bAutoConvert);
|
void StartEmulation(EnumAutoConvert x_bAutoConvert, HWND hwndParent);
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * stop emulation (close existing child window)
|
||||||
|
// ******************************************************************
|
||||||
|
void StopEmulation();
|
||||||
|
|
||||||
// ******************************************************************
|
// ******************************************************************
|
||||||
// * accessor
|
// * accessor
|
||||||
|
@ -144,6 +149,7 @@ class WndMain : public Wnd
|
||||||
// ******************************************************************
|
// ******************************************************************
|
||||||
bool m_bXbeChanged;
|
bool m_bXbeChanged;
|
||||||
bool m_bExeChanged;
|
bool m_bExeChanged;
|
||||||
|
bool m_bCanStart;
|
||||||
|
|
||||||
// ******************************************************************
|
// ******************************************************************
|
||||||
// * cached filenames
|
// * cached filenames
|
||||||
|
@ -151,6 +157,11 @@ class WndMain : public Wnd
|
||||||
char *m_XbeFilename;
|
char *m_XbeFilename;
|
||||||
char *m_ExeFilename;
|
char *m_ExeFilename;
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * cached child window handle
|
||||||
|
// ******************************************************************
|
||||||
|
HWND m_hwndChild;
|
||||||
|
|
||||||
// ******************************************************************
|
// ******************************************************************
|
||||||
// * should emulation always auto-create the .exe?
|
// * should emulation always auto-create the .exe?
|
||||||
// ******************************************************************
|
// ******************************************************************
|
||||||
|
|
|
@ -50,7 +50,7 @@ extern "C" CXBXKRNL_API bool NTAPI EmuVerifyVersion(const char *szVersion);
|
||||||
extern "C" CXBXKRNL_API void NTAPI EmuCleanThread();
|
extern "C" CXBXKRNL_API void NTAPI EmuCleanThread();
|
||||||
|
|
||||||
// initialize emulation
|
// initialize emulation
|
||||||
extern "C" CXBXKRNL_API void NTAPI EmuInit(void *pTLSData, Xbe::TLS *pTLS, Xbe::LibraryVersion *LibraryVersion, DebugMode DbgMode, char *szDebugFilename, Xbe::Header *XbeHeader, uint32 XbeHeaderSize, void (*Entry)());
|
extern "C" CXBXKRNL_API void NTAPI EmuInit(HWND hwndParent, void *pTLSData, Xbe::TLS *pTLS, Xbe::LibraryVersion *LibraryVersion, DebugMode DbgMode, char *szDebugFilename, Xbe::Header *XbeHeader, uint32 XbeHeaderSize, void (*Entry)());
|
||||||
|
|
||||||
// print out a warning message to the kernel debug log file
|
// print out a warning message to the kernel debug log file
|
||||||
#ifdef _DEBUG_WARNINGS
|
#ifdef _DEBUG_WARNINGS
|
||||||
|
|
|
@ -169,6 +169,7 @@ BEGIN
|
||||||
POPUP "E&mulation"
|
POPUP "E&mulation"
|
||||||
BEGIN
|
BEGIN
|
||||||
MENUITEM "&Start\tF5", ID_EMULATION_START, GRAYED
|
MENUITEM "&Start\tF5", ID_EMULATION_START, GRAYED
|
||||||
|
MENUITEM "S&top\tF6", ID_EMULATION_STOP, GRAYED
|
||||||
END
|
END
|
||||||
POPUP "&Help"
|
POPUP "&Help"
|
||||||
BEGIN
|
BEGIN
|
||||||
|
@ -266,10 +267,10 @@ BEGIN
|
||||||
WS_VSCROLL | WS_TABSTOP
|
WS_VSCROLL | WS_TABSTOP
|
||||||
COMBOBOX IDC_VC_VIDEO_RESOLUTION,76,49,173,100,CBS_DROPDOWNLIST |
|
COMBOBOX IDC_VC_VIDEO_RESOLUTION,76,49,173,100,CBS_DROPDOWNLIST |
|
||||||
WS_VSCROLL | WS_TABSTOP
|
WS_VSCROLL | WS_TABSTOP
|
||||||
CONTROL "Start in Fullscreen",IDC_CV_FULLSCREEN,"Button",
|
CONTROL "Use Hardware Video Mode",IDC_CV_FULLSCREEN,"Button",
|
||||||
BS_AUTOCHECKBOX | WS_TABSTOP,76,71,73,10
|
BS_AUTOCHECKBOX | WS_TABSTOP,76,71,98,10
|
||||||
CONTROL "Force VSync",IDC_CV_VSYNC,"Button",BS_AUTOCHECKBOX |
|
CONTROL "Force VSync",IDC_CV_VSYNC,"Button",BS_AUTOCHECKBOX |
|
||||||
WS_TABSTOP,154,71,65,10
|
WS_TABSTOP,182,71,65,10
|
||||||
PUSHBUTTON "Cancel",IDC_VC_CANCEL,146,92,50,14,BS_FLAT
|
PUSHBUTTON "Cancel",IDC_VC_CANCEL,146,92,50,14,BS_FLAT
|
||||||
PUSHBUTTON "Accept",IDC_VC_ACCEPT,203,92,50,14,BS_FLAT
|
PUSHBUTTON "Accept",IDC_VC_ACCEPT,203,92,50,14,BS_FLAT
|
||||||
GROUPBOX "Direct3D Configuration",IDC_STATIC,4,1,250,87,BS_CENTER
|
GROUPBOX "Direct3D Configuration",IDC_STATIC,4,1,250,87,BS_CENTER
|
||||||
|
|
|
@ -40,7 +40,7 @@
|
||||||
// ******************************************************************
|
// ******************************************************************
|
||||||
// * constructor
|
// * constructor
|
||||||
// ******************************************************************
|
// ******************************************************************
|
||||||
EmuExe::EmuExe(Xbe *x_Xbe, DebugMode x_debug_mode, char *x_debug_filename) : Exe()
|
EmuExe::EmuExe(Xbe *x_Xbe, DebugMode x_debug_mode, char *x_debug_filename, HWND hwndParent) : Exe()
|
||||||
{
|
{
|
||||||
ConstructorInit();
|
ConstructorInit();
|
||||||
|
|
||||||
|
@ -578,6 +578,9 @@ EmuExe::EmuExe(Xbe *x_Xbe, DebugMode x_debug_mode, char *x_debug_filename) : Exe
|
||||||
*(uint32 *)((uint32)m_bzSection[i] + 41) = 0;
|
*(uint32 *)((uint32)m_bzSection[i] + 41) = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Param 0 : hwndParent
|
||||||
|
*(uint32 *)((uint32)m_bzSection[i] + 46) = (uint32)hwndParent;
|
||||||
|
|
||||||
printf("OK\n");
|
printf("OK\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,6 +63,7 @@ __declspec(allocate(".cxbxplg")) uint08 Prolog[] =
|
||||||
0x68, 0xC3, 0xC3, 0xC3, 0xC3, // push 0xC3C3C3C3
|
0x68, 0xC3, 0xC3, 0xC3, 0xC3, // push 0xC3C3C3C3
|
||||||
0x68, 0xC3, 0xC3, 0xC3, 0xC3, // push 0xC3C3C3C3
|
0x68, 0xC3, 0xC3, 0xC3, 0xC3, // push 0xC3C3C3C3
|
||||||
0x68, 0xC3, 0xC3, 0xC3, 0xC3, // push 0xC3C3C3C3
|
0x68, 0xC3, 0xC3, 0xC3, 0xC3, // push 0xC3C3C3C3
|
||||||
|
0x68, 0xC3, 0xC3, 0xC3, 0xC3, // push 0xC3C3C3C3
|
||||||
0xFF, 0xD6, // call esi
|
0xFF, 0xD6, // call esi
|
||||||
0xC3 // ret
|
0xC3 // ret
|
||||||
};
|
};
|
||||||
|
|
|
@ -58,7 +58,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
|
||||||
{
|
{
|
||||||
MainWindow->OpenXbe(__argv[1]);
|
MainWindow->OpenXbe(__argv[1]);
|
||||||
|
|
||||||
MainWindow->StartEmulation(AUTO_CONVERT_WINDOWS_TEMP);
|
MainWindow->StartEmulation(AUTO_CONVERT_WINDOWS_TEMP, MainWindow->GetHwnd());
|
||||||
}
|
}
|
||||||
|
|
||||||
while(MainWindow->GetError() == 0 && MainWindow->ProcessMessages())
|
while(MainWindow->GetError() == 0 && MainWindow->ProcessMessages())
|
||||||
|
|
|
@ -47,7 +47,7 @@ Wnd::Wnd(HINSTANCE x_hInstance) : m_hInstance(x_hInstance)
|
||||||
m_h = 240;
|
m_h = 240;
|
||||||
m_parent = NULL;
|
m_parent = NULL;
|
||||||
m_clsstyle = CS_HREDRAW | CS_VREDRAW;
|
m_clsstyle = CS_HREDRAW | CS_VREDRAW;
|
||||||
m_wndstyle = WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX | WS_VISIBLE;
|
m_wndstyle = WS_CLIPCHILDREN | WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX | WS_VISIBLE;
|
||||||
m_background = (HBRUSH)GetStockObject(BLACK_BRUSH);
|
m_background = (HBRUSH)GetStockObject(BLACK_BRUSH);
|
||||||
m_initialized = false;
|
m_initialized = false;
|
||||||
|
|
||||||
|
|
|
@ -42,7 +42,7 @@
|
||||||
|
|
||||||
#include <io.h>
|
#include <io.h>
|
||||||
|
|
||||||
WndMain::WndMain(HINSTANCE x_hInstance) : Wnd(x_hInstance), m_bCreated(false), m_Xbe(0), m_Exe(0), m_bExeChanged(false), m_bXbeChanged(false), m_AutoConvertToExe(AUTO_CONVERT_WINDOWS_TEMP), m_KrnlDebug(DM_NONE), m_CxbxDebug(DM_NONE), m_dwRecentXbe(0), m_dwRecentExe(0)
|
WndMain::WndMain(HINSTANCE x_hInstance) : Wnd(x_hInstance), m_bCreated(false), m_Xbe(0), m_Exe(0), m_bExeChanged(false), m_bXbeChanged(false), m_bCanStart(true), m_hwndChild(NULL), m_AutoConvertToExe(AUTO_CONVERT_WINDOWS_TEMP), m_KrnlDebug(DM_NONE), m_CxbxDebug(DM_NONE), m_dwRecentXbe(0), m_dwRecentExe(0)
|
||||||
{
|
{
|
||||||
// initialize members
|
// initialize members
|
||||||
{
|
{
|
||||||
|
@ -297,6 +297,42 @@ LRESULT CALLBACK WndMain::WndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lP
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case WM_PARENTNOTIFY:
|
||||||
|
{
|
||||||
|
switch(LOWORD(wParam))
|
||||||
|
{
|
||||||
|
case WM_CREATE:
|
||||||
|
{
|
||||||
|
m_hwndChild = GetWindow(hwnd, GW_CHILD);
|
||||||
|
|
||||||
|
char AsciiTitle[255];
|
||||||
|
|
||||||
|
sprintf(AsciiTitle, "Cxbx : Emulating %s...", m_Xbe->m_szAsciiTitle);
|
||||||
|
|
||||||
|
SetWindowText(m_hwnd, AsciiTitle);
|
||||||
|
|
||||||
|
RefreshMenus();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case WM_DESTROY:
|
||||||
|
{
|
||||||
|
m_hwndChild = NULL;
|
||||||
|
SetWindowText(m_hwnd, "Cxbx " _CXBX_VERSION);
|
||||||
|
RefreshMenus();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
case WM_SYSKEYDOWN:
|
||||||
|
{
|
||||||
|
if(m_hwndChild != 0)
|
||||||
|
{
|
||||||
|
SendMessage(m_hwndChild, uMsg, wParam, lParam);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
case WM_PAINT:
|
case WM_PAINT:
|
||||||
{
|
{
|
||||||
static bool s_bInitMenu = true;
|
static bool s_bInitMenu = true;
|
||||||
|
@ -366,10 +402,30 @@ LRESULT CALLBACK WndMain::WndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lP
|
||||||
{
|
{
|
||||||
case VK_F5:
|
case VK_F5:
|
||||||
{
|
{
|
||||||
if(m_Xbe != 0)
|
if(m_Xbe != 0 && (m_hwndChild == NULL) && m_bCanStart)
|
||||||
StartEmulation(m_AutoConvertToExe);
|
{
|
||||||
|
m_bCanStart = false;
|
||||||
|
StartEmulation(m_AutoConvertToExe, hwnd);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case VK_F6:
|
||||||
|
{
|
||||||
|
if(m_hwndChild != NULL && !m_bCanStart)
|
||||||
|
{
|
||||||
|
StopEmulation();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
if(m_hwndChild != 0)
|
||||||
|
{
|
||||||
|
SendMessage(m_hwndChild, uMsg, wParam, lParam);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -458,7 +514,7 @@ LRESULT CALLBACK WndMain::WndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lP
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ID_FILE_EXPORTTOEXE:
|
case ID_FILE_EXPORTTOEXE:
|
||||||
ConvertToExe(NULL, true);
|
ConvertToExe(NULL, true, hwnd);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ID_FILE_RXBE_0:
|
case ID_FILE_RXBE_0:
|
||||||
|
@ -1004,7 +1060,11 @@ LRESULT CALLBACK WndMain::WndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lP
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ID_EMULATION_START:
|
case ID_EMULATION_START:
|
||||||
StartEmulation(m_AutoConvertToExe);
|
StartEmulation(m_AutoConvertToExe, hwnd);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case ID_EMULATION_STOP:
|
||||||
|
StopEmulation();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ID_SETTINGS_GENWT:
|
case ID_SETTINGS_GENWT:
|
||||||
|
@ -1320,7 +1380,10 @@ void WndMain::RefreshMenus()
|
||||||
HMENU emul_menu = GetSubMenu(menu, 4);
|
HMENU emul_menu = GetSubMenu(menu, 4);
|
||||||
|
|
||||||
// enable emulation start
|
// enable emulation start
|
||||||
EnableMenuItem(emul_menu, ID_EMULATION_START, MF_BYCOMMAND | (m_Xbe == 0) ? MF_GRAYED : MF_ENABLED);
|
EnableMenuItem(emul_menu, ID_EMULATION_START, MF_BYCOMMAND | (m_Xbe == 0 || (m_hwndChild != NULL)) ? MF_GRAYED : MF_ENABLED);
|
||||||
|
|
||||||
|
// enable emulation stop
|
||||||
|
EnableMenuItem(emul_menu, ID_EMULATION_STOP, MF_BYCOMMAND | (m_hwndChild == NULL) ? MF_GRAYED : MF_ENABLED);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1513,6 +1576,8 @@ void WndMain::OpenXbe(const char *x_filename)
|
||||||
// close xbe file
|
// close xbe file
|
||||||
void WndMain::CloseXbe()
|
void WndMain::CloseXbe()
|
||||||
{
|
{
|
||||||
|
StopEmulation();
|
||||||
|
|
||||||
if(m_bXbeChanged)
|
if(m_bXbeChanged)
|
||||||
{
|
{
|
||||||
int ret = MessageBox(m_hwnd, "Changes have been made, do you wish to save?", "Cxbx", MB_ICONQUESTION | MB_YESNOCANCEL);
|
int ret = MessageBox(m_hwnd, "Changes have been made, do you wish to save?", "Cxbx", MB_ICONQUESTION | MB_YESNOCANCEL);
|
||||||
|
@ -1689,7 +1754,7 @@ void WndMain::ImportExe(const char *x_filename)
|
||||||
}
|
}
|
||||||
|
|
||||||
// convert to exe file
|
// convert to exe file
|
||||||
bool WndMain::ConvertToExe(const char *x_filename, bool x_bVerifyIfExists)
|
bool WndMain::ConvertToExe(const char *x_filename, bool x_bVerifyIfExists, HWND hwndParent)
|
||||||
{
|
{
|
||||||
char filename[260] = "default.exe";
|
char filename[260] = "default.exe";
|
||||||
|
|
||||||
|
@ -1733,7 +1798,7 @@ bool WndMain::ConvertToExe(const char *x_filename, bool x_bVerifyIfExists)
|
||||||
|
|
||||||
// convert file
|
// convert file
|
||||||
{
|
{
|
||||||
EmuExe i_EmuExe(m_Xbe, m_KrnlDebug, m_KrnlDebugFilename);
|
EmuExe i_EmuExe(m_Xbe, m_KrnlDebug, m_KrnlDebugFilename, hwndParent);
|
||||||
|
|
||||||
i_EmuExe.Export(filename);
|
i_EmuExe.Export(filename);
|
||||||
|
|
||||||
|
@ -1756,7 +1821,7 @@ bool WndMain::ConvertToExe(const char *x_filename, bool x_bVerifyIfExists)
|
||||||
}
|
}
|
||||||
|
|
||||||
// start emulation
|
// start emulation
|
||||||
void WndMain::StartEmulation(EnumAutoConvert x_AutoConvert)
|
void WndMain::StartEmulation(EnumAutoConvert x_AutoConvert, HWND hwndParent)
|
||||||
{
|
{
|
||||||
char szBuffer[260];
|
char szBuffer[260];
|
||||||
|
|
||||||
|
@ -1782,19 +1847,19 @@ void WndMain::StartEmulation(EnumAutoConvert x_AutoConvert)
|
||||||
|
|
||||||
strcat(szTempPath, &szBuffer[c]);
|
strcat(szTempPath, &szBuffer[c]);
|
||||||
|
|
||||||
if(!ConvertToExe(szTempPath, false))
|
if(!ConvertToExe(szTempPath, false, hwndParent))
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if(x_AutoConvert == AUTO_CONVERT_XBE_PATH)
|
else if(x_AutoConvert == AUTO_CONVERT_XBE_PATH)
|
||||||
{
|
{
|
||||||
SuggestFilename(m_XbeFilename, szBuffer, ".exe");
|
SuggestFilename(m_XbeFilename, szBuffer, ".exe");
|
||||||
|
|
||||||
if(!ConvertToExe(szBuffer, false))
|
if(!ConvertToExe(szBuffer, false, hwndParent))
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if(!ConvertToExe(NULL, true))
|
if(!ConvertToExe(NULL, true, hwndParent))
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1820,6 +1885,7 @@ void WndMain::StartEmulation(EnumAutoConvert x_AutoConvert)
|
||||||
|
|
||||||
if((int)ShellExecute(NULL, "open", m_ExeFilename, NULL, szBuffer, SW_SHOWDEFAULT) <= 32)
|
if((int)ShellExecute(NULL, "open", m_ExeFilename, NULL, szBuffer, SW_SHOWDEFAULT) <= 32)
|
||||||
{
|
{
|
||||||
|
m_bCanStart = true;
|
||||||
MessageBox(m_hwnd, "Emulation failed.\n\nTry converting again. If this message repeats, the Xbe is not supported.", "Cxbx", MB_ICONSTOP | MB_OK);
|
MessageBox(m_hwnd, "Emulation failed.\n\nTry converting again. If this message repeats, the Xbe is not supported.", "Cxbx", MB_ICONSTOP | MB_OK);
|
||||||
|
|
||||||
printf("WndMain: %s shell failed.\n", m_Xbe->m_szAsciiTitle);
|
printf("WndMain: %s shell failed.\n", m_Xbe->m_szAsciiTitle);
|
||||||
|
@ -1830,3 +1896,10 @@ void WndMain::StartEmulation(EnumAutoConvert x_AutoConvert)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// stop emulation
|
||||||
|
void WndMain::StopEmulation()
|
||||||
|
{
|
||||||
|
SendMessage(m_hwndChild, WM_CLOSE, 0, 0);
|
||||||
|
m_bCanStart = true;
|
||||||
|
}
|
||||||
|
|
|
@ -63,6 +63,7 @@ namespace XTL
|
||||||
|
|
||||||
// Ugly Global Pull-In
|
// Ugly Global Pull-In
|
||||||
extern HWND g_hEmuWindow; // rendering window
|
extern HWND g_hEmuWindow; // rendering window
|
||||||
|
extern HWND g_hEmuParent; // rendering window parent
|
||||||
|
|
||||||
// Global Variable(s)
|
// Global Variable(s)
|
||||||
extern Xbe::TLS *g_pTLS = NULL;
|
extern Xbe::TLS *g_pTLS = NULL;
|
||||||
|
@ -140,6 +141,7 @@ extern "C" CXBXKRNL_API void NTAPI EmuCleanThread()
|
||||||
// initialize emulation
|
// initialize emulation
|
||||||
extern "C" CXBXKRNL_API void NTAPI EmuInit
|
extern "C" CXBXKRNL_API void NTAPI EmuInit
|
||||||
(
|
(
|
||||||
|
HWND hwndParent,
|
||||||
void *pTLSData,
|
void *pTLSData,
|
||||||
Xbe::TLS *pTLS,
|
Xbe::TLS *pTLS,
|
||||||
Xbe::LibraryVersion *pLibraryVersion,
|
Xbe::LibraryVersion *pLibraryVersion,
|
||||||
|
@ -153,8 +155,9 @@ extern "C" CXBXKRNL_API void NTAPI EmuInit
|
||||||
g_pTLS = pTLS;
|
g_pTLS = pTLS;
|
||||||
g_pTLSData = pTLSData;
|
g_pTLSData = pTLSData;
|
||||||
g_pXbeHeader = pXbeHeader;
|
g_pXbeHeader = pXbeHeader;
|
||||||
|
g_hEmuParent = hwndParent;
|
||||||
|
|
||||||
// For Unicode Conversions
|
// For Unicode Conversions
|
||||||
setlocale(LC_ALL, "English");
|
setlocale(LC_ALL, "English");
|
||||||
|
|
||||||
// debug console allocation (if configured)
|
// debug console allocation (if configured)
|
||||||
|
@ -198,6 +201,7 @@ extern "C" CXBXKRNL_API void NTAPI EmuInit
|
||||||
|
|
||||||
printf("EmuMain (0x%X): EmuInit\n"
|
printf("EmuMain (0x%X): EmuInit\n"
|
||||||
"(\n"
|
"(\n"
|
||||||
|
" hwndParent : 0x%.08X\n"
|
||||||
" pTLSData : 0x%.08X\n"
|
" pTLSData : 0x%.08X\n"
|
||||||
" pTLS : 0x%.08X\n"
|
" pTLS : 0x%.08X\n"
|
||||||
" pLibraryVersion : 0x%.08X\n"
|
" pLibraryVersion : 0x%.08X\n"
|
||||||
|
@ -207,7 +211,7 @@ extern "C" CXBXKRNL_API void NTAPI EmuInit
|
||||||
" pXBEHeaderSize : 0x%.08X\n"
|
" pXBEHeaderSize : 0x%.08X\n"
|
||||||
" Entry : 0x%.08X\n"
|
" Entry : 0x%.08X\n"
|
||||||
");\n",
|
");\n",
|
||||||
GetCurrentThreadId(), pTLSData, pTLS, pLibraryVersion, DbgMode, szDebugFilename, pXbeHeader, dwXbeHeaderSize, Entry);
|
GetCurrentThreadId(), hwndParent, pTLSData, pTLS, pLibraryVersion, DbgMode, szDebugFilename, pXbeHeader, dwXbeHeaderSize, Entry);
|
||||||
|
|
||||||
#else
|
#else
|
||||||
printf("EmuMain (0x%X): Debug Trace Disabled.\n", GetCurrentThreadId());
|
printf("EmuMain (0x%X): Debug Trace Disabled.\n", GetCurrentThreadId());
|
||||||
|
@ -559,7 +563,7 @@ extern "C" CXBXKRNL_API void NTAPI EmuInit
|
||||||
// _USE_XGMATH Disabled in mesh :[
|
// _USE_XGMATH Disabled in mesh :[
|
||||||
// halo : dword_0_2E2D18
|
// halo : dword_0_2E2D18
|
||||||
// halo : 1744F0 (bink)
|
// halo : 1744F0 (bink)
|
||||||
_asm int 3
|
//_asm int 3
|
||||||
|
|
||||||
Entry();
|
Entry();
|
||||||
|
|
||||||
|
@ -653,6 +657,8 @@ extern "C" CXBXKRNL_API void NTAPI EmuCleanup(const char *szErrorMessage, ...)
|
||||||
freopen("nul", "w", stdout);
|
freopen("nul", "w", stdout);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SendMessage(g_hEmuParent, WM_PARENTNOTIFY, WM_DESTROY, 0);
|
||||||
|
|
||||||
TerminateProcess(GetCurrentProcess(), 0);
|
TerminateProcess(GetCurrentProcess(), 0);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
@ -717,10 +723,10 @@ extern "C" CXBXKRNL_API void NTAPI EmuSuspend()
|
||||||
{
|
{
|
||||||
char szBuffer[256];
|
char szBuffer[256];
|
||||||
|
|
||||||
GetWindowText(g_hEmuWindow, szBuffer, 255 - 10);
|
GetWindowText(g_hEmuParent, szBuffer, 255 - 10);
|
||||||
|
|
||||||
strcat(szBuffer, " (paused)");
|
strcat(szBuffer, " (paused)");
|
||||||
SetWindowText(g_hEmuWindow, szBuffer);
|
SetWindowText(g_hEmuParent, szBuffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
g_bEmuSuspended = TRUE;
|
g_bEmuSuspended = TRUE;
|
||||||
|
@ -736,11 +742,11 @@ extern "C" CXBXKRNL_API void NTAPI EmuResume()
|
||||||
{
|
{
|
||||||
char szBuffer[256];
|
char szBuffer[256];
|
||||||
|
|
||||||
GetWindowText(g_hEmuWindow, szBuffer, 255);
|
GetWindowText(g_hEmuParent, szBuffer, 255);
|
||||||
|
|
||||||
szBuffer[strlen(szBuffer)-9] = '\0';
|
szBuffer[strlen(szBuffer)-9] = '\0';
|
||||||
|
|
||||||
SetWindowText(g_hEmuWindow, szBuffer);
|
SetWindowText(g_hEmuParent, szBuffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
for(int v=0;v<MAXIMUM_XBOX_THREADS;v++)
|
for(int v=0;v<MAXIMUM_XBOX_THREADS;v++)
|
||||||
|
@ -898,6 +904,9 @@ extern int EmuException(LPEXCEPTION_POINTERS e)
|
||||||
{
|
{
|
||||||
printf("EmuMain (0x%X): Aborting Emulation\n", GetCurrentThreadId());
|
printf("EmuMain (0x%X): Aborting Emulation\n", GetCurrentThreadId());
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
|
|
||||||
|
SendMessage(g_hEmuParent, WM_PARENTNOTIFY, WM_DESTROY, 0);
|
||||||
|
|
||||||
ExitProcess(1);
|
ExitProcess(1);
|
||||||
}
|
}
|
||||||
else if(ret == IDIGNORE)
|
else if(ret == IDIGNORE)
|
||||||
|
@ -922,6 +931,9 @@ extern int EmuException(LPEXCEPTION_POINTERS e)
|
||||||
{
|
{
|
||||||
printf("EmuMain (0x%X): Aborting Emulation\n", GetCurrentThreadId());
|
printf("EmuMain (0x%X): Aborting Emulation\n", GetCurrentThreadId());
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
|
|
||||||
|
SendMessage(g_hEmuParent, WM_PARENTNOTIFY, WM_DESTROY, 0);
|
||||||
|
|
||||||
ExitProcess(1);
|
ExitProcess(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1164,6 +1176,8 @@ int ExitException(LPEXCEPTION_POINTERS e)
|
||||||
return EXCEPTION_CONTINUE_SEARCH;
|
return EXCEPTION_CONTINUE_SEARCH;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SendMessage(g_hEmuParent, WM_PARENTNOTIFY, WM_DESTROY, 0);
|
||||||
|
|
||||||
ExitProcess(1);
|
ExitProcess(1);
|
||||||
|
|
||||||
return EXCEPTION_CONTINUE_SEARCH;
|
return EXCEPTION_CONTINUE_SEARCH;
|
||||||
|
|
|
@ -57,6 +57,7 @@ namespace XTL
|
||||||
|
|
||||||
// Global(s)
|
// Global(s)
|
||||||
extern HWND g_hEmuWindow = NULL; // rendering window
|
extern HWND g_hEmuWindow = NULL; // rendering window
|
||||||
|
extern HWND g_hEmuParent = NULL; // rendering window parent
|
||||||
extern XTL::LPDIRECT3DDEVICE8 g_pD3DDevice8 = NULL; // Direct3D8 Device
|
extern XTL::LPDIRECT3DDEVICE8 g_pD3DDevice8 = NULL; // Direct3D8 Device
|
||||||
extern XTL::LPDIRECTDRAWSURFACE7 g_pDDSPrimary = NULL; // DirectDraw7 Primary Surface
|
extern XTL::LPDIRECTDRAWSURFACE7 g_pDDSPrimary = NULL; // DirectDraw7 Primary Surface
|
||||||
extern XTL::LPDIRECTDRAWSURFACE7 g_pDDSOverlay7 = NULL; // DirectDraw7 Overlay Surface
|
extern XTL::LPDIRECTDRAWSURFACE7 g_pDDSOverlay7 = NULL; // DirectDraw7 Overlay Surface
|
||||||
|
@ -156,6 +157,9 @@ VOID XTL::EmuD3DInit(Xbe::Header *XbeHeader, uint32 XbeHeaderSize)
|
||||||
{
|
{
|
||||||
g_EmuShared->GetXBVideo(&g_XBVideo);
|
g_EmuShared->GetXBVideo(&g_XBVideo);
|
||||||
|
|
||||||
|
if(g_XBVideo.GetFullscreen())
|
||||||
|
g_hEmuParent = NULL;
|
||||||
|
|
||||||
// cache XbeHeader and size of XbeHeader
|
// cache XbeHeader and size of XbeHeader
|
||||||
g_XbeHeader = XbeHeader;
|
g_XbeHeader = XbeHeader;
|
||||||
g_XbeHeaderSize = XbeHeaderSize;
|
g_XbeHeaderSize = XbeHeaderSize;
|
||||||
|
@ -265,7 +269,7 @@ static BOOL WINAPI EmuEnumDisplayDevices(GUID FAR *lpGUID, LPSTR lpDriverDescrip
|
||||||
}
|
}
|
||||||
|
|
||||||
// window message processing thread
|
// window message processing thread
|
||||||
static DWORD WINAPI EmuRenderWindow(LPVOID)
|
static DWORD WINAPI EmuRenderWindow(LPVOID lpVoid)
|
||||||
{
|
{
|
||||||
char AsciiTitle[50];
|
char AsciiTitle[50];
|
||||||
|
|
||||||
|
@ -317,7 +321,7 @@ static DWORD WINAPI EmuRenderWindow(LPVOID)
|
||||||
|
|
||||||
// create the window
|
// create the window
|
||||||
{
|
{
|
||||||
DWORD dwStyle = WS_OVERLAPPEDWINDOW;
|
DWORD dwStyle = g_XBVideo.GetFullscreen() ? WS_OVERLAPPEDWINDOW : WS_CHILD;
|
||||||
|
|
||||||
int nTitleHeight = GetSystemMetrics(SM_CYCAPTION);
|
int nTitleHeight = GetSystemMetrics(SM_CYCAPTION);
|
||||||
int nBorderWidth = GetSystemMetrics(SM_CXSIZEFRAME);
|
int nBorderWidth = GetSystemMetrics(SM_CXSIZEFRAME);
|
||||||
|
@ -336,17 +340,29 @@ static DWORD WINAPI EmuRenderWindow(LPVOID)
|
||||||
dwStyle = WS_POPUP;
|
dwStyle = WS_POPUP;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
HWND hwndParent = GetDesktopWindow();
|
||||||
|
|
||||||
|
if(!g_XBVideo.GetFullscreen())
|
||||||
|
{
|
||||||
|
hwndParent = g_hEmuParent;
|
||||||
|
}
|
||||||
|
|
||||||
g_hEmuWindow = CreateWindow
|
g_hEmuWindow = CreateWindow
|
||||||
(
|
(
|
||||||
"CxbxRender", AsciiTitle,
|
"CxbxRender", AsciiTitle,
|
||||||
dwStyle, x, y, nWidth, nHeight,
|
dwStyle, x, y, nWidth, nHeight,
|
||||||
GetDesktopWindow(), NULL, GetModuleHandle(NULL), NULL
|
hwndParent, NULL, GetModuleHandle(NULL), NULL
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
ShowWindow(g_hEmuWindow, SW_SHOWDEFAULT);
|
ShowWindow(g_hEmuWindow, g_XBVideo.GetFullscreen() ? SW_SHOWDEFAULT : SW_SHOWMAXIMIZED);
|
||||||
UpdateWindow(g_hEmuWindow);
|
UpdateWindow(g_hEmuWindow);
|
||||||
|
|
||||||
|
if(!g_XBVideo.GetFullscreen())
|
||||||
|
{
|
||||||
|
SetFocus(g_hEmuParent);
|
||||||
|
}
|
||||||
|
|
||||||
// initialize direct input
|
// initialize direct input
|
||||||
if(!XTL::EmuDInputInit())
|
if(!XTL::EmuDInputInit())
|
||||||
EmuCleanup("Could not initialize DirectInput!");
|
EmuCleanup("Could not initialize DirectInput!");
|
||||||
|
@ -387,25 +403,20 @@ void ToggleFauxFullscreen(HWND hWnd)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
static bool bIsNormal = true;
|
static bool bIsNormal = true;
|
||||||
static LONG lRestore = 0, lRestoreEx = 0;
|
|
||||||
static RECT Rect;
|
|
||||||
|
|
||||||
if(bIsNormal)
|
if(bIsNormal)
|
||||||
{
|
{
|
||||||
lRestore = GetWindowLong(hWnd, GWL_STYLE);
|
SetParent(hWnd, NULL);
|
||||||
lRestoreEx = GetWindowLong(hWnd, GWL_EXSTYLE);
|
|
||||||
|
|
||||||
SetWindowLong(hWnd, GWL_STYLE, WS_POPUP);
|
SetWindowLong(hWnd, GWL_STYLE, WS_POPUP);
|
||||||
SetWindowPos(hWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE);
|
SetWindowPos(hWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE);
|
||||||
GetWindowRect(hWnd, &Rect);
|
|
||||||
ShowWindow(hWnd, SW_MAXIMIZE);
|
ShowWindow(hWnd, SW_MAXIMIZE);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
SetWindowLong(hWnd, GWL_STYLE, lRestore);
|
SetParent(hWnd, g_hEmuParent);
|
||||||
SetWindowLong(hWnd, GWL_EXSTYLE, lRestoreEx);
|
SetWindowLong(hWnd, GWL_STYLE, WS_CHILD);
|
||||||
ShowWindow(hWnd, SW_RESTORE);
|
ShowWindow(hWnd, SW_MAXIMIZE);
|
||||||
SetWindowPos(hWnd, HWND_NOTOPMOST, Rect.left, Rect.top, Rect.right - Rect.left, Rect.bottom - Rect.top, 0);
|
SetFocus(g_hEmuParent);
|
||||||
}
|
}
|
||||||
|
|
||||||
bIsNormal = !bIsNormal;
|
bIsNormal = !bIsNormal;
|
||||||
|
@ -498,6 +509,15 @@ static LRESULT WINAPI EmuMsgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lPar
|
||||||
DestroyWindow(hWnd);
|
DestroyWindow(hWnd);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case WM_SETFOCUS:
|
||||||
|
{
|
||||||
|
if(g_hEmuParent != NULL)
|
||||||
|
{
|
||||||
|
SetFocus(g_hEmuParent);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
case WM_SETCURSOR:
|
case WM_SETCURSOR:
|
||||||
{
|
{
|
||||||
if(g_XBVideo.GetFullscreen())
|
if(g_XBVideo.GetFullscreen())
|
||||||
|
@ -4928,9 +4948,9 @@ VOID WINAPI XTL::EmuIDirect3DDevice8_UpdateOverlay
|
||||||
RECT SourRect = {0, 0, g_dwOverlayW, g_dwOverlayH}, DestRect;
|
RECT SourRect = {0, 0, g_dwOverlayW, g_dwOverlayH}, DestRect;
|
||||||
MONITORINFO MonitorInfo = {0};
|
MONITORINFO MonitorInfo = {0};
|
||||||
|
|
||||||
int nTitleHeight = GetSystemMetrics(SM_CYCAPTION);
|
int nTitleHeight = 0;//GetSystemMetrics(SM_CYCAPTION);
|
||||||
int nBorderWidth = GetSystemMetrics(SM_CXSIZEFRAME);
|
int nBorderWidth = 0;//GetSystemMetrics(SM_CXSIZEFRAME);
|
||||||
int nBorderHeight = GetSystemMetrics(SM_CYSIZEFRAME);
|
int nBorderHeight = 0;//GetSystemMetrics(SM_CYSIZEFRAME);
|
||||||
|
|
||||||
MonitorInfo.cbSize = sizeof(MONITORINFO);
|
MonitorInfo.cbSize = sizeof(MONITORINFO);
|
||||||
GetMonitorInfo(g_hMonitor, &MonitorInfo);
|
GetMonitorInfo(g_hMonitor, &MonitorInfo);
|
||||||
|
|
Loading…
Reference in New Issue