diff --git a/src/CxbxKrnl/EmuD3D8.cpp b/src/CxbxKrnl/EmuD3D8.cpp index f96747e2f..5a0e67e4f 100755 --- a/src/CxbxKrnl/EmuD3D8.cpp +++ b/src/CxbxKrnl/EmuD3D8.cpp @@ -3972,24 +3972,24 @@ DWORD WINAPI XTL::EMUPATCH(D3DDevice_Swap) DEBUG_D3DRESULT(hRet, "g_pD3DDevice8->Present"); hRet = g_pD3DDevice8->BeginScene(); - if (!g_UncapFramerate) { - // If the last frame completed faster than the Xbox VBlank period, wait for it - // TODO: Read the frame rate target from the Xbox display mode - // See comments in GetNextVblankTime(); - auto targetDuration = 16.6666666667ms; - while (std::chrono::high_resolution_clock::now() - frameStartTime < targetDuration) { - // We use an empty while loop because actually sleeping is too unstable - // Sleeping causes the frame duration to jitter... - ; - } - - frameStartTime = std::chrono::high_resolution_clock::now(); - } - UpdateFPSCounter(); if (Flags == CXBX_SWAP_PRESENT_FORWARD) // Only do this when forwarded from Present { + if (!g_UncapFramerate) { + // If the last frame completed faster than the Xbox VBlank period, wait for it + // TODO: Read the frame rate target from the Xbox display mode + // See comments in GetNextVblankTime(); + auto targetDuration = 16.6666666667ms; + while (std::chrono::high_resolution_clock::now() - frameStartTime < targetDuration) { + // We use an empty while loop because actually sleeping is too unstable + // Sleeping causes the frame duration to jitter... + ; + } + + frameStartTime = std::chrono::high_resolution_clock::now(); + } + // Put primitives per frame in the title /*{ char szString[64]; diff --git a/src/CxbxKrnl/EmuKrnlRtl.cpp b/src/CxbxKrnl/EmuKrnlRtl.cpp index 1a0d07352..7c9a5b2a9 100644 --- a/src/CxbxKrnl/EmuKrnlRtl.cpp +++ b/src/CxbxKrnl/EmuKrnlRtl.cpp @@ -144,8 +144,7 @@ static BOOL TryEnterHostCriticalSection(xboxkrnl::PRTL_CRITICAL_SECTION xbox_cri DWORD WINAPI RtlAnsiStringToUnicodeSize(const xboxkrnl::STRING *str) { - DWORD ret = mbstowcs(nullptr, str->Buffer, str->Length); - return ret + sizeof(WCHAR); // + for the terminating null character + return (str->Length + sizeof(ANSI_NULL)) * sizeof(WCHAR); } // ****************************************************************** diff --git a/src/CxbxKrnl/EmuXapi.cpp b/src/CxbxKrnl/EmuXapi.cpp index e8133691e..2eb59beee 100644 --- a/src/CxbxKrnl/EmuXapi.cpp +++ b/src/CxbxKrnl/EmuXapi.cpp @@ -954,7 +954,7 @@ DWORD WINAPI XTL::EMUPATCH(QueueUserAPC) DWORD dwData ) { - FUNC_EXPORTS + //FUNC_EXPORTS LOG_FUNC_BEGIN LOG_FUNC_ARG_TYPE(PVOID, pfnAPC)