diff --git a/subsystems/ntvdm/dos/dem.c b/subsystems/ntvdm/dos/dem.c index df578400b63..c8d832b8bfa 100644 --- a/subsystems/ntvdm/dos/dem.c +++ b/subsystems/ntvdm/dos/dem.c @@ -75,7 +75,7 @@ Quit: if (!Success) { /* We failed everything, stop the VDM */ - VdmRunning = FALSE; + EmulatorTerminate(); } break; diff --git a/subsystems/ntvdm/emulator.c b/subsystems/ntvdm/emulator.c index e843ca01e4c..fe4bdfd4a13 100644 --- a/subsystems/ntvdm/emulator.c +++ b/subsystems/ntvdm/emulator.c @@ -170,7 +170,7 @@ VOID EmulatorException(BYTE ExceptionNumber, LPWORD Stack) Opcode[9]); /* Stop the VDM */ - VdmRunning = FALSE; + EmulatorTerminate(); return; } @@ -198,7 +198,7 @@ VOID EmulatorSimulate(VOID) CpuCallLevel, MaxCpuCallLevel); /* Stop the VDM */ - VdmRunning = FALSE; + EmulatorTerminate(); return; } CpuCallLevel++; @@ -219,6 +219,12 @@ VOID EmulatorUnsimulate(VOID) CpuSimulate = FALSE; } +VOID EmulatorTerminate(VOID) +{ + /* Stop the VDM */ + VdmRunning = FALSE; +} + VOID EmulatorInterrupt(BYTE Number) { /* Call the Fast486 API */ @@ -236,13 +242,13 @@ VOID EmulatorSetA20(BOOLEAN Enabled) A20Line = Enabled; } -VOID WINAPI EmulatorDebugBreakBop(LPWORD Stack) +static VOID WINAPI EmulatorDebugBreakBop(LPWORD Stack) { DPRINT1("NTVDM: BOP_DEBUGGER\n"); DebugBreak(); } -VOID WINAPI EmulatorUnsimulateBop(LPWORD Stack) +static VOID WINAPI EmulatorUnsimulateBop(LPWORD Stack) { EmulatorUnsimulate(); } @@ -443,7 +449,7 @@ WINAPI VDDTerminateVDM(VOID) { /* Stop the VDM */ - VdmRunning = FALSE; + EmulatorTerminate(); } PBYTE diff --git a/subsystems/ntvdm/emulator.h b/subsystems/ntvdm/emulator.h index eaf03b20b92..20e9a07a98c 100644 --- a/subsystems/ntvdm/emulator.h +++ b/subsystems/ntvdm/emulator.h @@ -119,16 +119,19 @@ UCHAR WINAPI EmulatorIntAcknowledge VOID EmulatorException(BYTE ExceptionNumber, LPWORD Stack); -BOOLEAN EmulatorInitialize(HANDLE ConsoleInput, HANDLE ConsoleOutput); VOID EmulatorExecute(WORD Segment, WORD Offset); -VOID EmulatorInterrupt(BYTE Number); -VOID EmulatorInterruptSignal(VOID); VOID EmulatorStep(VOID); VOID EmulatorSimulate(VOID); VOID EmulatorUnsimulate(VOID); -VOID EmulatorCleanup(VOID); +VOID EmulatorTerminate(VOID); + +VOID EmulatorInterrupt(BYTE Number); +VOID EmulatorInterruptSignal(VOID); VOID EmulatorSetA20(BOOLEAN Enabled); +BOOLEAN EmulatorInitialize(HANDLE ConsoleInput, HANDLE ConsoleOutput); +VOID EmulatorCleanup(VOID); + #endif // _EMULATOR_H_ /* EOF */ diff --git a/subsystems/ntvdm/hardware/ps2.c b/subsystems/ntvdm/hardware/ps2.c index 9599a51bdc9..c98d32e76df 100644 --- a/subsystems/ntvdm/hardware/ps2.c +++ b/subsystems/ntvdm/hardware/ps2.c @@ -214,8 +214,8 @@ static VOID WINAPI PS2WritePort(ULONG Port, BYTE Data) case 0xFC: case 0xFE: { - /* Stop the simulation */ - VdmRunning = FALSE; + /* Stop the VDM */ + EmulatorTerminate(); break; } } @@ -243,8 +243,8 @@ static VOID WINAPI PS2WritePort(ULONG Port, BYTE Data) /* Check if bit 0 is unset */ if (!(Data & (1 << 0))) { - /* CPU disabled - end simulation */ - VdmRunning = FALSE; + /* CPU disabled - Stop the VDM */ + EmulatorTerminate(); } /* Update the A20 line setting */ diff --git a/subsystems/ntvdm/hardware/vga.c b/subsystems/ntvdm/hardware/vga.c index cd471fcad86..d41736c021b 100644 --- a/subsystems/ntvdm/hardware/vga.c +++ b/subsystems/ntvdm/hardware/vga.c @@ -450,7 +450,7 @@ static BOOL VgaAttachToConsole(PCOORD Resolution) if (!Success) { DisplayMessage(L"RegisterConsoleVDM failed with error %d\n", GetLastError()); - VdmRunning = FALSE; + EmulatorTerminate(); return FALSE; } @@ -982,7 +982,7 @@ static BOOL VgaEnterTextMode(PCOORD Resolution) if (!VgaAttachToConsole(Resolution)) { DisplayMessage(L"An unexpected error occurred!\n"); - VdmRunning = FALSE; + EmulatorTerminate(); return FALSE; } @@ -1045,7 +1045,7 @@ static VOID VgaChangeMode(VOID) if (!VgaEnterTextMode(&Resolution)) { DisplayMessage(L"An unexpected VGA error occurred while switching into text mode."); - VdmRunning = FALSE; + EmulatorTerminate(); return; } } @@ -1055,7 +1055,7 @@ static VOID VgaChangeMode(VOID) if (!VgaEnterGraphicsMode(&Resolution)) { DisplayMessage(L"An unexpected VGA error occurred while switching into graphics mode."); - VdmRunning = FALSE; + EmulatorTerminate(); return; } } diff --git a/subsystems/ntvdm/ntvdm.c b/subsystems/ntvdm/ntvdm.c index a86cfba7a8e..f5c2095c8e0 100644 --- a/subsystems/ntvdm/ntvdm.c +++ b/subsystems/ntvdm/ntvdm.c @@ -124,12 +124,11 @@ CreateVdmMenu(HANDLE ConOutHandle) hConsoleMenu = ConsoleMenuControl(ConsoleOutput, ID_SHOWHIDE_MOUSE, ID_VDM_QUIT); - if (hConsoleMenu != NULL) - { - VdmMenuPos = GetMenuItemCount(hConsoleMenu); - AppendMenuItems(hConsoleMenu, VdmMainMenuItems); - DrawMenuBar(GetConsoleWindow()); - } + if (hConsoleMenu == NULL) return; + + VdmMenuPos = GetMenuItemCount(hConsoleMenu); + AppendMenuItems(hConsoleMenu, VdmMainMenuItems); + DrawMenuBar(GetConsoleWindow()); } static VOID @@ -200,7 +199,7 @@ BOOL WINAPI ConsoleCtrlHandler(DWORD ControlType) default: { /* Stop the VDM if the user logs out or closes the console */ - VdmRunning = FALSE; + EmulatorTerminate(); } } return TRUE; @@ -256,7 +255,8 @@ DWORD WINAPI PumpConsoleInput(LPVOID Parameter) break; case ID_VDM_QUIT: - VdmRunning = FALSE; + /* Stop the VDM */ + EmulatorTerminate(); break; default: diff --git a/subsystems/ntvdm/vddsup.c b/subsystems/ntvdm/vddsup.c index c37c74a62f6..92a0ff1ac3b 100644 --- a/subsystems/ntvdm/vddsup.c +++ b/subsystems/ntvdm/vddsup.c @@ -188,7 +188,7 @@ Quit: { DPRINT1("Invalid VDD DLL Handle: %d\n", Entry); /* Stop the VDM */ - VdmRunning = FALSE; + EmulatorTerminate(); return; } @@ -214,7 +214,7 @@ Quit: { DPRINT1("Invalid VDD DLL Handle: %d\n", Entry); /* Stop the VDM */ - VdmRunning = FALSE; + EmulatorTerminate(); return; }