From fb031ba1186458d50fa74fd9ddf0801f72bfdb5e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herm=C3=A8s=20B=C3=A9lusca-Ma=C3=AFto?= Date: Sun, 17 Nov 2013 20:44:23 +0000 Subject: [PATCH] [NTVDM] Initialize LastClockUpdate, LastVerticalRefresh and LastCyclePrintout with the value of StartTickCount. svn path=/branches/ntvdm/; revision=61021 --- subsystems/ntvdm/ntvdm.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/subsystems/ntvdm/ntvdm.c b/subsystems/ntvdm/ntvdm.c index 974559df74c..36e602feabe 100644 --- a/subsystems/ntvdm/ntvdm.c +++ b/subsystems/ntvdm/ntvdm.c @@ -70,15 +70,14 @@ INT wmain(INT argc, WCHAR *argv[]) { INT i; CHAR CommandLine[DOS_CMDLINE_LENGTH]; - DWORD CurrentTickCount; - DWORD Cycles = 0; - DWORD LastCyclePrintout = GetTickCount(); - DWORD LastVerticalRefresh = GetTickCount(); - DWORD LastClockUpdate = GetTickCount(); + LARGE_INTEGER StartPerfCount; LARGE_INTEGER Frequency, LastTimerTick, LastRtcTick, Counter; LONGLONG TimerTicks; - LARGE_INTEGER StartPerfCount; - DWORD StartTickCount; + DWORD StartTickCount, CurrentTickCount; + DWORD LastClockUpdate; + DWORD LastVerticalRefresh; + DWORD LastCyclePrintout; + DWORD Cycles = 0; /* Set the handler routine */ SetConsoleCtrlHandler(ConsoleCtrlHandler, TRUE); @@ -109,7 +108,7 @@ INT wmain(INT argc, WCHAR *argv[]) wprintf(L"FATAL: Failed to initialize the CPU emulator\n"); goto Cleanup; } - + /* Initialize the performance counter (needed for hardware timers) */ if (!QueryPerformanceFrequency(&Frequency)) { @@ -151,7 +150,10 @@ INT wmain(INT argc, WCHAR *argv[]) /* Find the starting performance and tick count */ StartTickCount = GetTickCount(); QueryPerformanceCounter(&StartPerfCount); - + + /* Set the different last counts to the starting count */ + LastClockUpdate = LastVerticalRefresh = LastCyclePrintout = StartTickCount; + /* Set the last timer ticks to the current time */ LastTimerTick = LastRtcTick = StartPerfCount; @@ -163,7 +165,7 @@ INT wmain(INT argc, WCHAR *argv[]) /* Get the current number of ticks */ CurrentTickCount = GetTickCount(); - + if ((PitResolution <= 1000) && (RtcFrequency <= 1000)) { /* Calculate the approximate performance counter value instead */ @@ -176,7 +178,7 @@ INT wmain(INT argc, WCHAR *argv[]) /* Get the current performance counter value */ QueryPerformanceCounter(&Counter); } - + /* Get the number of PIT ticks that have passed */ TimerTicks = ((Counter.QuadPart - LastTimerTick.QuadPart) * PIT_BASE_FREQUENCY) / Frequency.QuadPart;