Allowing .xbe files to be auto-opened by command line
This commit is contained in:
parent
ffdcf67fda
commit
2358492724
|
@ -1,11 +1,11 @@
|
|||
cxbx website: http://www.caustik.com/xbox/
|
||||
|
||||
version: 0.6.0-pre12 (02/??/03)
|
||||
version: 0.6.0-pre12 (02/23/03)
|
||||
--------------------------------
|
||||
|
||||
- HLE has advanced to intercepting Direct3D and
|
||||
Xapilib calls. A simple Xbox app built with a
|
||||
1.0.4361 XDK has been shown to work.
|
||||
4361 or 4627 XDK has been shown to work.
|
||||
|
||||
version: 0.6.0-pre11 (02/09/03)
|
||||
--------------------------------
|
||||
|
|
|
@ -52,7 +52,7 @@ typedef signed long sint32;
|
|||
// ******************************************************************
|
||||
// * Version Information
|
||||
// ******************************************************************
|
||||
#define CXBX_VERSION "0.6.0-pre12"
|
||||
#define CXBX_VERSION "0.6.0-pre13"
|
||||
|
||||
// ******************************************************************
|
||||
// * Define this to trace intercepted function calls
|
||||
|
|
|
@ -48,9 +48,21 @@ class WndMain : public Wnd
|
|||
|
||||
LRESULT CALLBACK WndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
|
||||
|
||||
private:
|
||||
void SaveXbe(const char *x_filename);
|
||||
void SaveXbeAs();
|
||||
|
||||
void SuggestFilename(const char *x_orig_filename, char *x_filename, char x_extension[4]);
|
||||
void OpenXbe(const char *x_filename);
|
||||
void CloseXbe();
|
||||
|
||||
bool ConvertToExe(const char *x_filename, bool x_bVerifyIfExists);
|
||||
|
||||
void StartEmulation(bool x_bAutoConvert);
|
||||
|
||||
bool isCreated() { return m_bCreated; }
|
||||
|
||||
static void SuggestFilename(const char *x_orig_filename, char *x_filename, char x_extension[4]);
|
||||
|
||||
private:
|
||||
|
||||
void XbeLoaded(); // after an xbe is loaded, some stuff needs to update
|
||||
|
||||
|
@ -58,13 +70,6 @@ class WndMain : public Wnd
|
|||
|
||||
void UpdateDebugConsoles(); // Allocate / Deallocate debug consoles as per configuration
|
||||
|
||||
bool ConvertToExe();
|
||||
|
||||
void SaveXbe(const char *x_filename);
|
||||
void SaveXbeAs();
|
||||
|
||||
void CloseXbe();
|
||||
|
||||
HDC m_back_dc;
|
||||
HDC m_logo_dc;
|
||||
|
||||
|
@ -83,6 +88,8 @@ class WndMain : public Wnd
|
|||
bool m_xbe_changed;
|
||||
bool m_exe_changed;
|
||||
|
||||
bool m_bCreated;
|
||||
|
||||
enum DebugMode m_CxbxDebug;
|
||||
enum DebugMode m_KrnlDebug;
|
||||
|
||||
|
|
|
@ -77,13 +77,13 @@ BEGIN
|
|||
MENUITEM "&Open Xbe...", ID_FILE_OPEN_XBE
|
||||
MENUITEM "&Close xbe", ID_FILE_CLOSE_XBE, GRAYED
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "&Import Exe...", ID_FILE_IMPORTFROMEXE
|
||||
MENUITEM "&Export Exe...", ID_FILE_EXPORTTOEXE, GRAYED
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "&Save Xbe", ID_FILE_SAVEXBEFILE, GRAYED
|
||||
MENUITEM "Save Xbe &As...", ID_FILE_SAVEXBEFILEAS
|
||||
, GRAYED
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "&Import Exe...", ID_FILE_IMPORTFROMEXE
|
||||
MENUITEM "&Export Exe...", ID_FILE_EXPORTTOEXE, GRAYED
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "E&xit", ID_FILE_EXIT
|
||||
END
|
||||
POPUP "&Edit"
|
||||
|
|
|
@ -28,13 +28,14 @@
|
|||
#define ID_VIEW_DEBUGOUTPUTGUI_FILE 40036
|
||||
#define ID_VIEW_DEBUGOUTPUTKERNEL_CONSOLE 40037
|
||||
#define ID_VIEW_DEBUGOUTPUTKERNEL_FILE 40038
|
||||
#define ID_FILE_RECENTFILES 40040
|
||||
|
||||
// Next default values for new objects
|
||||
//
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
#ifndef APSTUDIO_READONLY_SYMBOLS
|
||||
#define _APS_NEXT_RESOURCE_VALUE 110
|
||||
#define _APS_NEXT_COMMAND_VALUE 40039
|
||||
#define _APS_NEXT_COMMAND_VALUE 40041
|
||||
#define _APS_NEXT_CONTROL_VALUE 1000
|
||||
#define _APS_NEXT_SYMED_VALUE 103
|
||||
#endif
|
||||
|
|
|
@ -45,6 +45,19 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
|
|||
{
|
||||
WndMain *caustik = new WndMain(hInstance);
|
||||
|
||||
if(__argc > 1)
|
||||
{
|
||||
while(!caustik->isCreated() && caustik->ProcessMessages())
|
||||
Sleep(10);
|
||||
|
||||
if(caustik->GetError() == 0)
|
||||
{
|
||||
caustik->OpenXbe(__argv[1]);
|
||||
|
||||
caustik->StartEmulation(true);
|
||||
}
|
||||
}
|
||||
|
||||
while(caustik->GetError() == 0 && caustik->ProcessMessages())
|
||||
Sleep(10);
|
||||
|
||||
|
|
|
@ -42,7 +42,7 @@
|
|||
WndAbout::WndAbout(HINSTANCE x_hInstance, HWND x_parent) : Wnd(x_hInstance)
|
||||
{
|
||||
m_classname = "WndAbout";
|
||||
m_wndname = "Cxbx : About";
|
||||
m_wndname = "Cxbx : About (Version " CXBX_VERSION ")";
|
||||
|
||||
m_w = 285;
|
||||
m_h = 180;
|
||||
|
|
|
@ -42,7 +42,7 @@
|
|||
// ******************************************************************
|
||||
// * constructor
|
||||
// ******************************************************************
|
||||
WndMain::WndMain(HINSTANCE x_hInstance) : Wnd(x_hInstance), m_xbe(0), m_exe(0), m_exe_changed(false), m_xbe_changed(false), m_KrnlDebug(DM_NONE), m_CxbxDebug(DM_NONE)
|
||||
WndMain::WndMain(HINSTANCE x_hInstance) : Wnd(x_hInstance), m_bCreated(false), m_xbe(0), m_exe(0), m_exe_changed(false), m_xbe_changed(false), m_KrnlDebug(DM_NONE), m_CxbxDebug(DM_NONE)
|
||||
{
|
||||
m_classname = "WndMain";
|
||||
m_wndname = "Cxbx : Xbox Emulator";
|
||||
|
@ -188,6 +188,8 @@ LRESULT CALLBACK WndMain::WndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lP
|
|||
if(hDC != NULL)
|
||||
ReleaseDC(hwnd, hDC);
|
||||
}
|
||||
|
||||
m_bCreated = true;
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -263,8 +265,6 @@ LRESULT CALLBACK WndMain::WndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lP
|
|||
{
|
||||
case ID_FILE_OPEN_XBE:
|
||||
{
|
||||
m_ExeFilename[0] = '\0';
|
||||
|
||||
OPENFILENAME ofn = {0};
|
||||
|
||||
char filename[260] = {0};
|
||||
|
@ -281,23 +281,7 @@ LRESULT CALLBACK WndMain::WndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lP
|
|||
ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST;
|
||||
|
||||
if(GetOpenFileName(&ofn) == TRUE)
|
||||
{
|
||||
strcpy(m_XbeFilename, ofn.lpstrFile);
|
||||
|
||||
m_xbe = new Xbe(ofn.lpstrFile);
|
||||
|
||||
if(m_xbe->GetError() != 0)
|
||||
{
|
||||
MessageBox(m_hwnd, m_xbe->GetError(), "Cxbx", MB_ICONSTOP | MB_OK);
|
||||
|
||||
delete m_xbe; m_xbe = 0;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
XbeLoaded();
|
||||
}
|
||||
|
||||
OpenXbe(ofn.lpstrFile);
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -375,7 +359,7 @@ LRESULT CALLBACK WndMain::WndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lP
|
|||
break;
|
||||
|
||||
case ID_FILE_EXPORTTOEXE:
|
||||
ConvertToExe();
|
||||
ConvertToExe(NULL, true);
|
||||
break;
|
||||
|
||||
case ID_FILE_EXIT:
|
||||
|
@ -841,39 +825,7 @@ LRESULT CALLBACK WndMain::WndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lP
|
|||
|
||||
case ID_EMULATION_START:
|
||||
{
|
||||
if(m_ExeFilename[0] == '\0' || m_exe_changed)
|
||||
if(!ConvertToExe())
|
||||
break;
|
||||
|
||||
// shell .exe
|
||||
{
|
||||
char dir[260];
|
||||
|
||||
GetModuleFileName(NULL, dir, 260);
|
||||
|
||||
sint32 spot=-1;
|
||||
for(int v=0;v<260;v++)
|
||||
{
|
||||
if(dir[v] == '\\')
|
||||
spot = v;
|
||||
else if(dir[v] == '\0')
|
||||
break;
|
||||
}
|
||||
|
||||
if(spot != -1)
|
||||
dir[spot] = '\0';
|
||||
|
||||
if((int)ShellExecute(NULL, "open", m_ExeFilename, NULL, dir, SW_SHOWDEFAULT) <= 32)
|
||||
{
|
||||
MessageBox(m_hwnd, "Shell failed. (try converting .exe again)", "Cxbx", MB_ICONSTOP | MB_OK);
|
||||
|
||||
printf("WndMain: %s shell failed.\n", m_xbe->m_szAsciiTitle);
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("WndMain: %s emulation started.\n", m_xbe->m_szAsciiTitle);
|
||||
}
|
||||
}
|
||||
StartEmulation(false);
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -968,7 +920,8 @@ void WndMain::SuggestFilename(const char *x_orig_filename, char *x_filename, cha
|
|||
|
||||
if(found != 0)
|
||||
{
|
||||
strcpy(x_filename, x_orig_filename + found + 1);
|
||||
// strcpy(x_filename, x_orig_filename + found + 1);
|
||||
strcpy(x_filename, x_orig_filename);
|
||||
|
||||
uint32 loc = 0;
|
||||
uint32 c = 0;
|
||||
|
@ -1169,47 +1122,57 @@ void WndMain::UpdateDebugConsoles()
|
|||
// ******************************************************************
|
||||
// * ConvertToExe
|
||||
// ******************************************************************
|
||||
bool WndMain::ConvertToExe()
|
||||
bool WndMain::ConvertToExe(const char *x_filename, bool x_bVerifyIfExists)
|
||||
{
|
||||
OPENFILENAME ofn = {0};
|
||||
|
||||
char filename[260] = "default.exe";
|
||||
|
||||
SuggestFilename(m_XbeFilename, filename, ".exe");
|
||||
if(x_filename == NULL)
|
||||
{
|
||||
OPENFILENAME ofn = {0};
|
||||
|
||||
ofn.lStructSize = sizeof(OPENFILENAME);
|
||||
ofn.hwndOwner = m_hwnd;
|
||||
ofn.lpstrFilter = "Windows Executables (*.exe)\0*.exe\0";
|
||||
ofn.lpstrFile = filename;
|
||||
ofn.nMaxFile = 260;
|
||||
ofn.nFilterIndex = 1;
|
||||
ofn.lpstrFileTitle = NULL;
|
||||
ofn.nMaxFileTitle = 0;
|
||||
ofn.lpstrInitialDir = NULL;
|
||||
ofn.lpstrDefExt = "exe";
|
||||
ofn.Flags = OFN_PATHMUSTEXIST;
|
||||
SuggestFilename(m_XbeFilename, filename, ".exe");
|
||||
|
||||
if(GetSaveFileName(&ofn) == FALSE)
|
||||
return false;
|
||||
ofn.lStructSize = sizeof(OPENFILENAME);
|
||||
ofn.hwndOwner = m_hwnd;
|
||||
ofn.lpstrFilter = "Windows Executables (*.exe)\0*.exe\0";
|
||||
ofn.lpstrFile = filename;
|
||||
ofn.nMaxFile = 260;
|
||||
ofn.nFilterIndex = 1;
|
||||
ofn.lpstrFileTitle = NULL;
|
||||
ofn.nMaxFileTitle = 0;
|
||||
ofn.lpstrInitialDir = NULL;
|
||||
ofn.lpstrDefExt = "exe";
|
||||
ofn.Flags = OFN_PATHMUSTEXIST;
|
||||
|
||||
if(GetSaveFileName(&ofn) == FALSE)
|
||||
return false;
|
||||
|
||||
strcpy(filename, ofn.lpstrFile);
|
||||
}
|
||||
else
|
||||
{
|
||||
strcpy(filename, x_filename);
|
||||
}
|
||||
|
||||
// check if file exists
|
||||
if(x_bVerifyIfExists)
|
||||
{
|
||||
FILE *tmp = fopen(ofn.lpstrFile, "r");
|
||||
FILE *chkExists = fopen(filename, "r");
|
||||
|
||||
if(tmp != 0)
|
||||
if(chkExists != 0)
|
||||
{
|
||||
fclose(tmp);
|
||||
fclose(chkExists);
|
||||
|
||||
if(MessageBox(m_hwnd, "Overwrite existing file?", "Cxbx", MB_ICONQUESTION | MB_YESNO) != IDYES)
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// convert file
|
||||
// convert file
|
||||
{
|
||||
EmuExe i_EmuExe(m_xbe, m_KrnlDebug, m_KrnlDebugFilename);
|
||||
|
||||
i_EmuExe.Export(ofn.lpstrFile);
|
||||
i_EmuExe.Export(filename);
|
||||
|
||||
if(i_EmuExe.GetError() != 0)
|
||||
{
|
||||
|
@ -1218,16 +1181,10 @@ bool WndMain::ConvertToExe()
|
|||
}
|
||||
else
|
||||
{
|
||||
strcpy(m_ExeFilename, ofn.lpstrFile);
|
||||
|
||||
char buffer[255];
|
||||
|
||||
sprintf(buffer, "%s was successfully converted to .exe.", m_xbe->m_szAsciiTitle);
|
||||
strcpy(m_ExeFilename, filename);
|
||||
|
||||
printf("WndMain: %s was converted to .exe.\n", m_xbe->m_szAsciiTitle);
|
||||
|
||||
MessageBox(m_hwnd, buffer, "Cxbx", MB_ICONINFORMATION | MB_OK);
|
||||
|
||||
m_exe_changed = false;
|
||||
}
|
||||
}
|
||||
|
@ -1302,6 +1259,32 @@ void WndMain::SaveXbe(const char *x_filename)
|
|||
}
|
||||
}
|
||||
|
||||
// ******************************************************************
|
||||
// * OpenXbe
|
||||
// ******************************************************************
|
||||
void WndMain::OpenXbe(const char *x_filename)
|
||||
{
|
||||
if(m_xbe != 0)
|
||||
return;
|
||||
|
||||
m_ExeFilename[0] = '\0';
|
||||
|
||||
strcpy(m_XbeFilename, x_filename);
|
||||
|
||||
m_xbe = new Xbe(m_XbeFilename);
|
||||
|
||||
if(m_xbe->GetError() != 0)
|
||||
{
|
||||
MessageBox(m_hwnd, m_xbe->GetError(), "Cxbx", MB_ICONSTOP | MB_OK);
|
||||
|
||||
delete m_xbe; m_xbe = 0;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
XbeLoaded();
|
||||
}
|
||||
|
||||
// ******************************************************************
|
||||
// * CloseXbe
|
||||
// ******************************************************************
|
||||
|
@ -1393,3 +1376,57 @@ void WndMain::CloseXbe()
|
|||
|
||||
RedrawWindow(m_hwnd, NULL, NULL, RDW_INVALIDATE);
|
||||
}
|
||||
|
||||
// ******************************************************************
|
||||
// * StartEmulation
|
||||
// ******************************************************************
|
||||
void WndMain::StartEmulation(bool x_bAutoConvert)
|
||||
{
|
||||
if(m_ExeFilename[0] == '\0' || m_exe_changed)
|
||||
{
|
||||
if(x_bAutoConvert)
|
||||
{
|
||||
char filename[260];
|
||||
|
||||
SuggestFilename(m_XbeFilename, filename, ".exe");
|
||||
|
||||
ConvertToExe(filename, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(!ConvertToExe(NULL, true))
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// shell .exe
|
||||
{
|
||||
char dir[260];
|
||||
|
||||
GetModuleFileName(NULL, dir, 260);
|
||||
|
||||
sint32 spot=-1;
|
||||
for(int v=0;v<260;v++)
|
||||
{
|
||||
if(dir[v] == '\\')
|
||||
spot = v;
|
||||
else if(dir[v] == '\0')
|
||||
break;
|
||||
}
|
||||
|
||||
if(spot != -1)
|
||||
dir[spot] = '\0';
|
||||
|
||||
if((int)ShellExecute(NULL, "open", m_ExeFilename, NULL, dir, SW_SHOWDEFAULT) <= 32)
|
||||
{
|
||||
MessageBox(m_hwnd, "Shell failed. (try converting .exe again)", "Cxbx", MB_ICONSTOP | MB_OK);
|
||||
|
||||
printf("WndMain: %s shell failed.\n", m_xbe->m_szAsciiTitle);
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("WndMain: %s emulation started.\n", m_xbe->m_szAsciiTitle);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -7,7 +7,7 @@
|
|||
// * `88bo,__,o, oP"``"Yo, _88o,,od8P oP"``"Yo,
|
||||
// * "YUMMMMMP",m" "Mm,""YUMMMP" ,m" "Mm,
|
||||
// *
|
||||
// * Cxbx->Win32->CxbxKrnl->CxbxKrnl.cpp
|
||||
// * Cxbx->Win32->CxbxKrnl->EmuXLDT.cpp
|
||||
// *
|
||||
// * This file is part of the Cxbx project.
|
||||
// *
|
||||
|
|
Loading…
Reference in New Issue