#include "emulator.h"
#include "bios/bios.h"
+#include "dos/dem.h"
#include "hardware/cmos.h"
#include "hardware/ps2.h"
#include "hardware/timer.h"
#include "hardware/vga.h"
-#include "dos/dos.h"
/*
* Activate this line if you want to be able to test NTVDM with:
*/
#define TESTING
+/*
+ * Activate IPS_DISPLAY if you want to display the
+ * number of instructions per second, as well as
+ * the computed number of ticks for the PIT.
+ */
+// #define IPS_DISPLAY
+
+/*
+ * Activate WORKING_TIMER when the PIT timing problem is fixed.
+ */
+// #define WORKING_TIMER
+
/* PUBLIC VARIABLES ***********************************************************/
static HANDLE ConsoleInput = INVALID_HANDLE_VALUE;
DWORD StartTickCount, CurrentTickCount;
DWORD LastClockUpdate;
DWORD LastVerticalRefresh;
+#ifdef IPS_DISPLAY
DWORD LastCyclePrintout;
DWORD Cycles = 0;
+#endif
INT KeyboardIntCounter = 0;
#ifndef TESTING
}
/* Initialize the VDM DOS kernel */
- if (!DosInitialize())
+ if (!DosInitialize(NULL))
{
wprintf(L"FATAL: Failed to initialize the VDM DOS kernel.\n");
goto Cleanup;
QueryPerformanceCounter(&StartPerfCount);
/* Set the different last counts to the starting count */
- LastClockUpdate = LastVerticalRefresh = LastCyclePrintout = StartTickCount;
+ LastClockUpdate = LastVerticalRefresh =
+#ifdef IPS_DISPLAY
+ LastCyclePrintout =
+#endif
+ StartTickCount;
/* Set the last timer ticks to the current time */
LastTimerTick = LastRtcTick = StartPerfCount;
/* Main loop */
while (VdmRunning)
{
+#ifdef WORKING_TIMER
DWORD PitResolution = PitGetResolution();
+#endif
DWORD RtcFrequency = RtcGetTicksPerSecond();
/* Get the current number of ticks */
CurrentTickCount = GetTickCount();
+#ifdef WORKING_TIMER
if ((PitResolution <= 1000) && (RtcFrequency <= 1000))
{
/* Calculate the approximate performance counter value instead */
* (Frequency.QuadPart / 1000);
}
else
+#endif
{
/* Get the current performance counter value */
QueryPerformanceCounter(&Counter);
/* Update the PIT */
if (TimerTicks > 0)
{
- PitDecrementCount(TimerTicks);
+ PitClock(TimerTicks);
LastTimerTick = Counter;
}
for (i = 0; (i < STEPS_PER_CYCLE) && VdmRunning; i++)
{
EmulatorStep();
+#ifdef IPS_DISPLAY
Cycles++;
+#endif
}
+#ifdef IPS_DISPLAY
if ((CurrentTickCount - LastCyclePrintout) >= 1000)
{
- DPRINT1("NTVDM: %lu Instructions Per Second\n", Cycles);
+ DPRINT1("NTVDM: %lu Instructions Per Second; TimerTicks = %I64d\n", Cycles, TimerTicks);
LastCyclePrintout = CurrentTickCount;
Cycles = 0;
}
+#endif
}
/* Perform another screen refresh */