Cleaning up.
This commit is contained in:
parent
10d149316f
commit
69ed0614c9
2
Cxbx.dsp
2
Cxbx.dsp
|
@ -1,5 +1,5 @@
|
|||
# Microsoft Developer Studio Project File - Name="Cxbx" - Package Owner=<4>
|
||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
||||
# Microsoft Developer Studio Generated Build File, Format Version 60000
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Application" 0x0101
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
Cxbx Todo:
|
||||
|
||||
Some sort of delete-after-emulation type of functionality?
|
||||
|
||||
Use SetDataFormat instead of parsing device input by hand?
|
||||
|
||||
Batch config all buttons (should be very easy..just click one by one)
|
||||
|
|
|
@ -52,7 +52,7 @@ extern "C" CXBXKRNL_API void NTAPI EmuInit(uint32 TlsAdjust, Xbe::LibraryVersion
|
|||
// ******************************************************************
|
||||
// * func: EmuCleanup
|
||||
// ******************************************************************
|
||||
extern "C" CXBXKRNL_API void NTAPI EmuCleanup();
|
||||
extern "C" CXBXKRNL_API void NTAPI EmuCleanup(const char *szErrorMessage);
|
||||
|
||||
// ******************************************************************
|
||||
// * func: EmuPanic
|
||||
|
|
|
@ -45,7 +45,7 @@ namespace xapi
|
|||
// ******************************************************************
|
||||
// * func: EmuDInputInit
|
||||
// ******************************************************************
|
||||
extern void EmuDInputInit();
|
||||
extern bool EmuDInputInit();
|
||||
|
||||
// ******************************************************************
|
||||
// * func: EmuDInputCleanup
|
||||
|
|
|
@ -34,5 +34,15 @@
|
|||
#ifndef EMUKRNL_H
|
||||
#define EMUKRNL_H
|
||||
|
||||
// ******************************************************************
|
||||
// * Linked list of threads
|
||||
// ******************************************************************
|
||||
struct ThreadList
|
||||
{
|
||||
static ThreadList *pHead;
|
||||
|
||||
HANDLE hThread;
|
||||
ThreadList *pNext;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -45,6 +45,7 @@ namespace xboxkrnl
|
|||
#include "Emu.h"
|
||||
#include "EmuFS.h"
|
||||
#include "EmuD3D8.h"
|
||||
#include "EmuKrnl.h"
|
||||
#include "EmuShared.h"
|
||||
#include "HLEDataBase.h"
|
||||
|
||||
|
@ -255,22 +256,52 @@ extern "C" CXBXKRNL_API void NTAPI EmuInit(uint32 TlsAdjust, Xbe::LibraryVersion
|
|||
|
||||
fflush(stdout);
|
||||
|
||||
while(true)
|
||||
Sleep(1000);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// ******************************************************************
|
||||
// * func: EmuCleanup
|
||||
// ******************************************************************
|
||||
extern "C" CXBXKRNL_API void NTAPI EmuCleanup()
|
||||
extern "C" CXBXKRNL_API void NTAPI EmuCleanup(const char *szErrorMessage)
|
||||
{
|
||||
if(EmuIsXboxFS())
|
||||
EmuSwapFS(); // Win2k/XP FS
|
||||
|
||||
// ******************************************************************
|
||||
// * Suspend all Threads
|
||||
// ******************************************************************
|
||||
while(true)
|
||||
{
|
||||
ThreadList *tl = ThreadList::pHead;
|
||||
|
||||
if(tl == NULL)
|
||||
break;
|
||||
|
||||
SuspendThread(tl->hThread);
|
||||
|
||||
ThreadList::pHead = tl->pNext;
|
||||
|
||||
delete tl;
|
||||
}
|
||||
|
||||
// ******************************************************************
|
||||
// * Print out ErrorMessage (if exists)
|
||||
// ******************************************************************
|
||||
if(szErrorMessage != NULL)
|
||||
{
|
||||
char buffer[255];
|
||||
|
||||
sprintf(buffer, "CxbxKrnl: Recieved Exception \"%s\"\n", szErrorMessage);
|
||||
|
||||
printf("%s", buffer);
|
||||
|
||||
MessageBox(NULL, buffer, "CxbxKrnl", MB_OK | MB_ICONEXCLAMATION);
|
||||
}
|
||||
|
||||
// EmuD3DCleanup();
|
||||
|
||||
printf("CxbxKrnl: Terminating Process\n");
|
||||
|
||||
ExitProcess(0);
|
||||
|
||||
return;
|
||||
|
@ -293,7 +324,7 @@ extern "C" CXBXKRNL_API void NTAPI EmuPanic()
|
|||
MessageBox(NULL, "Kernel Panic! Process will now terminate.", "CxbxKrnl", MB_OK | MB_ICONEXCLAMATION);
|
||||
#endif
|
||||
|
||||
EmuCleanup();
|
||||
EmuCleanup("Kernel Panic!");
|
||||
|
||||
EmuSwapFS(); // XBox FS
|
||||
}
|
||||
|
|
|
@ -70,6 +70,7 @@ uint32 g_XbeHeaderSize = 0; // XbeHeaderSize
|
|||
HWND g_EmuWindow = NULL; // Rendering Window
|
||||
xd3d8::D3DCAPS8 g_D3DCaps; // Direct3D8 Caps
|
||||
bool g_ThreadInitialized = false;
|
||||
HBRUSH g_hBgBrush = NULL; // Background Brush
|
||||
|
||||
// ******************************************************************
|
||||
// * statics
|
||||
|
@ -111,6 +112,9 @@ VOID EmuD3DInit(Xbe::Header *XbeHeader, uint32 XbeHeaderSize)
|
|||
// xbox Direct3DCreate8 returns "1" always, so we need our own ptr
|
||||
g_pD3D8 = Direct3DCreate8(D3D_SDK_VERSION);
|
||||
|
||||
if(g_pD3D8 == NULL)
|
||||
EmuCleanup("Could not initialize Direct3D!");
|
||||
|
||||
g_pD3D8->GetDeviceCaps(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, &g_D3DCaps);
|
||||
}
|
||||
}
|
||||
|
@ -140,6 +144,10 @@ void EmuRenderWindow(PVOID)
|
|||
HMODULE hCxbxDll = GetModuleHandle("Cxbx.dll");
|
||||
#endif
|
||||
|
||||
LOGBRUSH logBrush = {BS_SOLID, RGB(0,0,0)};
|
||||
|
||||
g_hBgBrush = CreateBrushIndirect(&logBrush);
|
||||
|
||||
WNDCLASSEX wc =
|
||||
{
|
||||
sizeof(WNDCLASSEX),
|
||||
|
@ -148,7 +156,7 @@ void EmuRenderWindow(PVOID)
|
|||
0, 0, GetModuleHandle(NULL),
|
||||
LoadIcon(hCxbxDll, MAKEINTRESOURCE(IDI_CXBX)),
|
||||
LoadCursor(NULL, IDC_ARROW),
|
||||
(HBRUSH)(COLOR_APPWORKSPACE + 1), NULL,
|
||||
(HBRUSH)(g_hBgBrush), NULL,
|
||||
"CxbxRender",
|
||||
NULL
|
||||
};
|
||||
|
@ -201,7 +209,8 @@ void EmuRenderWindow(PVOID)
|
|||
// ******************************************************************
|
||||
// * initialize direct input
|
||||
// ******************************************************************
|
||||
EmuDInputInit();
|
||||
if(!EmuDInputInit())
|
||||
EmuCleanup("Could not initialize DirectInput!");
|
||||
|
||||
// ******************************************************************
|
||||
// * message processing loop
|
||||
|
@ -224,7 +233,7 @@ void EmuRenderWindow(PVOID)
|
|||
Sleep(10);
|
||||
}
|
||||
|
||||
EmuCleanup();
|
||||
EmuCleanup(NULL);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -236,6 +245,7 @@ LRESULT WINAPI EmuMsgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
|||
switch(msg)
|
||||
{
|
||||
case WM_DESTROY:
|
||||
DeleteObject(g_hBgBrush);
|
||||
PostQuitMessage(0);
|
||||
return 0;
|
||||
|
||||
|
|
|
@ -57,13 +57,16 @@ namespace xapi
|
|||
// ******************************************************************
|
||||
// * func: EmuDInputInit
|
||||
// ******************************************************************
|
||||
void EmuDInputInit()
|
||||
bool EmuDInputInit()
|
||||
{
|
||||
g_EmuShared->GetXBController(&g_XBController);
|
||||
|
||||
g_XBController.ListenBegin(g_EmuWindow);
|
||||
|
||||
return;
|
||||
if(g_XBController.GetError())
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// ******************************************************************
|
||||
|
@ -72,6 +75,9 @@ void EmuDInputInit()
|
|||
void EmuDInputCleanup()
|
||||
{
|
||||
g_XBController.ListenEnd();
|
||||
|
||||
if(g_XBController.GetError())
|
||||
MessageBox(NULL, g_XBController.GetError(), "Cxbx [*UNHANDLED!*]", MB_OK); // TODO: Handle this!
|
||||
}
|
||||
|
||||
// ******************************************************************
|
||||
|
@ -80,5 +86,9 @@ void EmuDInputCleanup()
|
|||
void EmuDInputPoll(xapi::PXINPUT_STATE Controller)
|
||||
{
|
||||
g_XBController.ListenPoll(Controller);
|
||||
|
||||
if(g_XBController.GetError())
|
||||
MessageBox(NULL, g_XBController.GetError(), "Cxbx [*UNHANDLED!*]", MB_OK); // TODO: Handle this!
|
||||
|
||||
return;
|
||||
}
|
|
@ -55,6 +55,12 @@ namespace xntdll
|
|||
#include "Emu.h"
|
||||
#include "EmuFS.h"
|
||||
#include "EmuFile.h"
|
||||
#include "EmuKrnl.h"
|
||||
|
||||
// ******************************************************************
|
||||
// * Globals
|
||||
// ******************************************************************
|
||||
ThreadList *ThreadList::pHead = new ThreadList;
|
||||
|
||||
// ******************************************************************
|
||||
// * Loaded at run-time to avoid linker conflicts
|
||||
|
@ -91,6 +97,13 @@ static DWORD WINAPI PCSTProxy
|
|||
IN PVOID Parameter
|
||||
)
|
||||
{
|
||||
ThreadList *tl = ThreadList::pHead;
|
||||
|
||||
tl->hThread = GetCurrentThread();
|
||||
tl->pNext = new ThreadList;
|
||||
tl->pNext->pNext = NULL;
|
||||
tl->pHead = tl->pNext;
|
||||
|
||||
PCSTProxyParam *iPCSTProxyParam = (PCSTProxyParam*)Parameter;
|
||||
|
||||
uint32 StartContext1 = (uint32)iPCSTProxyParam->StartContext1;
|
||||
|
|
|
@ -445,7 +445,7 @@ VOID WINAPI xapi::EmuXapiBootDash(DWORD UnknownA, DWORD UnknownB, DWORD UnknownC
|
|||
}
|
||||
#endif
|
||||
|
||||
MessageBox(NULL, "Warning: XBE has terminated unexpectedly.\n\nThis process might not terminate elegantly.", "Cxbx", MB_OK);
|
||||
MessageBox(NULL, "EmuXapiBootDash (Emulation can not continue).", "Cxbx", MB_OK | MB_ICONSTOP);
|
||||
|
||||
ExitProcess(0);
|
||||
|
||||
|
|
Loading…
Reference in New Issue