diff --git a/Cxbx.dsp b/Cxbx.dsp index 8fd64629d..01d858922 100644 --- a/Cxbx.dsp +++ b/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 diff --git a/Include/Win32/CxbxKrnl/Emu.h b/Include/Win32/CxbxKrnl/Emu.h index 83aeb01eb..1c0270c6f 100644 --- a/Include/Win32/CxbxKrnl/Emu.h +++ b/Include/Win32/CxbxKrnl/Emu.h @@ -79,7 +79,8 @@ extern "C" CXBXKRNL_API void NTAPI EmuSuspend(); // resume emulation extern "C" CXBXKRNL_API void NTAPI EmuResume(); -// global flag specifying current emulation state +// global flags specifying current emulation state +extern BOOL g_bEmuException; extern BOOL g_bEmuSuspended; // global exception patching address diff --git a/Source/Win32/CxbxKrnl/Emu.cpp b/Source/Win32/CxbxKrnl/Emu.cpp index 3f25d1cf5..93299ff05 100644 --- a/Source/Win32/CxbxKrnl/Emu.cpp +++ b/Source/Win32/CxbxKrnl/Emu.cpp @@ -72,6 +72,7 @@ extern HANDLE g_hTDrive = NULL; extern HANDLE g_hUDrive = NULL; extern HANDLE g_hZDrive = NULL; extern BOOL g_bEmuSuspended = FALSE; +extern BOOL g_bEmuException = FALSE; // global exception patching address extern uint32 g_HaloHack[4] = {0}; @@ -510,7 +511,7 @@ extern "C" CXBXKRNL_API void NTAPI EmuInit // _USE_XGMATH Disabled in mesh :[ // halo : dword_0_2E2D18 // halo : 1744F0 (bink) - //_asm int 3 + _asm int 3 Entry(); @@ -563,7 +564,7 @@ extern "C" CXBXKRNL_API void NTAPI EmuWarning(const char *szWarningMessage, ...) // cleanup emulation extern "C" CXBXKRNL_API void NTAPI EmuCleanup(const char *szErrorMessage, ...) { - EmuSuspend(); + g_bEmuException = TRUE; // print out error message (if exists) if(szErrorMessage != NULL) @@ -589,8 +590,6 @@ extern "C" CXBXKRNL_API void NTAPI EmuCleanup(const char *szErrorMessage, ...) MessageBox(NULL, szBuffer1, "CxbxKrnl", MB_OK | MB_ICONSTOP); } - EmuResume(); - printf("CxbxKrnl: Terminating Process\n"); fflush(stdout); @@ -642,7 +641,7 @@ extern "C" CXBXKRNL_API void NTAPI EmuRegisterThread(HANDLE hThread) // suspend all threads that have been created with PsCreateSystemThreadEx extern "C" CXBXKRNL_API void NTAPI EmuSuspend() { - if(g_bEmuSuspended) + if(g_bEmuSuspended || g_bEmuException) return; g_bEmuSuspended = TRUE; @@ -697,6 +696,8 @@ extern "C" CXBXKRNL_API void NTAPI EmuResume() // exception handler extern int EmuException(LPEXCEPTION_POINTERS e) { + g_bEmuException = TRUE; + if(EmuIsXboxFS()) EmuSwapFS(); @@ -745,6 +746,8 @@ extern int EmuException(LPEXCEPTION_POINTERS e) printf("EmuMain (0x%X): Halo Access Adjust 1 was applied!\n", GetCurrentThreadId()); #endif + g_bEmuException = FALSE; + return EXCEPTION_CONTINUE_EXECUTION; } } @@ -778,6 +781,8 @@ extern int EmuException(LPEXCEPTION_POINTERS e) printf("EmuMain (0x%X): Halo Access Adjust 2 was applied!\n", GetCurrentThreadId()); #endif + g_bEmuException = FALSE; + return EXCEPTION_CONTINUE_EXECUTION; } } @@ -830,6 +835,9 @@ extern int EmuException(LPEXCEPTION_POINTERS e) else if(ret == IDIGNORE) { printf("EmuMain (0x%X): Ignored Breakpoint Exception\n", GetCurrentThreadId()); + + g_bEmuException = FALSE; + return EXCEPTION_CONTINUE_EXECUTION; } } @@ -851,6 +859,8 @@ extern int EmuException(LPEXCEPTION_POINTERS e) } } + g_bEmuException = FALSE; + return EXCEPTION_CONTINUE_SEARCH; } diff --git a/Source/Win32/CxbxKrnl/EmuD3D8.cpp b/Source/Win32/CxbxKrnl/EmuD3D8.cpp index 93cc2ddb7..749c058b4 100644 --- a/Source/Win32/CxbxKrnl/EmuD3D8.cpp +++ b/Source/Win32/CxbxKrnl/EmuD3D8.cpp @@ -3327,11 +3327,13 @@ BOOL WINAPI XTL::EmuIDirect3DResource8_IsBusy // debug trace #ifdef _DEBUG_TRACE { + /* too much output printf("EmuD3D8 (0x%X): EmuIDirect3DResource8_IsBusy\n" "(\n" " pThis : 0x%.08X\n" ");\n", GetCurrentThreadId(), pThis); + //*/ } #endif @@ -5000,10 +5002,10 @@ HRESULT WINAPI XTL::EmuIDirect3DDevice8_SetStreamSource printf("EmuD3D8 (0x%X): EmuIDirect3DDevice8_SetStreamSource\n" "(\n" " StreamNumber : 0x%.08X\n" - " pStreamData : 0x%.08X\n" + " pStreamData : 0x%.08X (0x%.08X)\n" " Stride : 0x%.08X\n" ");\n", - GetCurrentThreadId(), StreamNumber, pStreamData, Stride); + GetCurrentThreadId(), StreamNumber, pStreamData, (pStreamData != 0) ? pStreamData->EmuVertexBuffer8 : 0, Stride); } #endif @@ -5459,9 +5461,12 @@ VOID WINAPI XTL::EmuIDirect3DDevice8_DrawIndexedVertices uint32 nStride = EmuFixupVerticesA(PrimitiveType, PrimitiveCount, pOrigVertexBuffer8, pHackVertexBuffer8, 0, 0, 0, 0); + if(pIndexData != 0) + EmuCleanup("Unsupported?"); + g_pD3DDevice8->DrawIndexedPrimitive ( - PCPrimitiveType, 0, VertexCount, ((DWORD)pIndexData)/2, PrimitiveCount + PCPrimitiveType, 0, VertexCount, /*((DWORD)pIndexData)/2*/0, PrimitiveCount ); if(nStride != -1)