diff --git a/AppleWin/source/Applewin.cpp b/AppleWin/source/Applewin.cpp index 7e9bb5e3..c5741ab5 100644 --- a/AppleWin/source/Applewin.cpp +++ b/AppleWin/source/Applewin.cpp @@ -100,6 +100,36 @@ ULONGLONG g_nPerfFreq = 0; //--------------------------------------------------------------------------- +static bool g_bPriorityNormal = true; + +// Make APPLEWIN process higher priority +void SetPriorityAboveNormal() +{ + if (!g_bPriorityNormal) + return; + + if ( SetPriorityClass(GetCurrentProcess(), ABOVE_NORMAL_PRIORITY_CLASS) ) + { + SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_ABOVE_NORMAL); + g_bPriorityNormal = false; + } +} + +// Make APPLEWIN process normal priority +void SetPriorityNormal() +{ + if (g_bPriorityNormal) + return; + + if ( SetPriorityClass(GetCurrentProcess(), NORMAL_PRIORITY_CLASS) ) + { + SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_NORMAL); + g_bPriorityNormal = true; + } +} + +//--------------------------------------------------------------------------- + void ContinueExecution() { static BOOL pageflipping = 0; //? @@ -131,12 +161,19 @@ void ContinueExecution() SysClk_StopTimer(); g_nCpuCyclesFeedback = 0; // For the case when this is a big -ve number + + // Switch to normal priority so that APPLEWIN process doesn't hog machine! + //. EG: No disk in Drive-1, and boot Apple: Windows will start to crawl! + SetPriorityNormal(); } else { // Don't call Spkr_Demute() MB_Demute(); SysClk_StartTimerUsec(nExecutionPeriodUsec); + + // Switch to higher priority, eg. for audio (BUG #015394) + SetPriorityAboveNormal(); } // @@ -873,16 +910,6 @@ int APIENTRY WinMain (HINSTANCE passinstance, HINSTANCE, LPSTR lpCmdLine, int) // - // Make APPLEWIN process higher priority - // . BUG: No disk in Drive-1, and boot Apple: Windows will start to crawl! - if ( SetPriorityClass(GetCurrentProcess(), ABOVE_NORMAL_PRIORITY_CLASS) ) - { - // Make main thread (for audio) higher priority - SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_ABOVE_NORMAL); - } - - // - do { // DO INITIALIZATION THAT MUST BE REPEATED FOR A RESTART diff --git a/AppleWin/source/Keyboard.cpp b/AppleWin/source/Keyboard.cpp index 3509d035..ca2b7464 100644 --- a/AppleWin/source/Keyboard.cpp +++ b/AppleWin/source/Keyboard.cpp @@ -42,7 +42,7 @@ bool g_bShiftKey = false; bool g_bCtrlKey = false; bool g_bAltKey = false; -bool g_bCapsLock = true; //Caps lock key for Apple2 and Lat/Cyr lock for Pravets8 +static bool g_bCapsLock = true; //Caps lock key for Apple2 and Lat/Cyr lock for Pravets8 static bool g_bP8CapsLock = true; //Caps lock key of Pravets 8A/C static int lastvirtkey = 0; // Current PC keycode static BYTE keycode = 0; // Current Apple keycode