+VOID EmulatorException(BYTE ExceptionNumber, LPWORD Stack)
+{
+ WORD CodeSegment, InstructionPointer;
+ PBYTE Opcode;
+
+ ASSERT(ExceptionNumber < 8);
+
+ /* Get the CS:IP */
+ InstructionPointer = Stack[STACK_IP];
+ CodeSegment = Stack[STACK_CS];
+ Opcode = (PBYTE)SEG_OFF_TO_PTR(CodeSegment, InstructionPointer);
+
+ /* Display a message to the user */
+ DisplayMessage(L"Exception: %s occured at %04X:%04X\n"
+ L"Opcode: %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X",
+ ExceptionName[ExceptionNumber],
+ CodeSegment,
+ InstructionPointer,
+ Opcode[0],
+ Opcode[1],
+ Opcode[2],
+ Opcode[3],
+ Opcode[4],
+ Opcode[5],
+ Opcode[6],
+ Opcode[7],
+ Opcode[8],
+ Opcode[9]);
+
+ /* Stop the VDM */
+ VdmRunning = FALSE;
+ return;
+}
+
+// FIXME: This function assumes 16-bit mode!!!
+VOID EmulatorExecute(WORD Segment, WORD Offset)
+{
+ /* Tell Fast486 to move the instruction pointer */
+ Fast486ExecuteAt(&EmulatorContext, Segment, Offset);
+}
+
+VOID EmulatorStep(VOID)
+{
+ /* Dump the state for debugging purposes */
+ // Fast486DumpState(&EmulatorContext);
+
+ /* Execute the next instruction */
+ Fast486StepInto(&EmulatorContext);
+}
+
+VOID EmulatorSimulate(VOID)
+{
+ if (CpuCallLevel > MaxCpuCallLevel)
+ {
+ DisplayMessage(L"Too many CPU levels of recursion (%d, expected maximum %d)",
+ CpuCallLevel, MaxCpuCallLevel);
+
+ /* Stop the VDM */
+ VdmRunning = FALSE;
+ return;
+ }
+ CpuCallLevel++;
+
+ CpuSimulate = TRUE;
+ while (VdmRunning && CpuSimulate) ClockUpdate();
+
+ CpuCallLevel--;
+ if (CpuCallLevel < 0) CpuCallLevel = 0;
+
+ /* This takes into account for reentrance */
+ CpuSimulate = TRUE;
+}
+
+VOID EmulatorUnsimulate(VOID)
+{
+ /* Stop simulation */
+ CpuSimulate = FALSE;
+}
+
+VOID EmulatorInterrupt(BYTE Number)
+{
+ /* Call the Fast486 API */
+ Fast486Interrupt(&EmulatorContext, Number);
+}
+
+VOID EmulatorInterruptSignal(VOID)
+{
+ /* Call the Fast486 API */
+ Fast486InterruptSignal(&EmulatorContext);
+}
+
+VOID EmulatorSetA20(BOOLEAN Enabled)
+{
+ A20Line = Enabled;
+}
+
+VOID WINAPI EmulatorDebugBreakBop(LPWORD Stack)