From dc36dd350732eb015682a40d2f4532dd50fdd371 Mon Sep 17 00:00:00 2001 From: pagefault <> Date: Thu, 24 May 2001 04:23:56 +0000 Subject: [PATCH] Added suspend in background option to minimize cpu usage while not active --- zsnes/src/gui/gui.asm | 3 ++- zsnes/src/gui/guimouse.inc | 1 + zsnes/src/gui/guiwindp.inc | 9 +++++++++ zsnes/src/win/winlink.cpp | 23 ++++++++++------------- 4 files changed, 22 insertions(+), 14 deletions(-) diff --git a/zsnes/src/gui/gui.asm b/zsnes/src/gui/gui.asm index c2e11427..3a738189 100644 --- a/zsnes/src/gui/gui.asm +++ b/zsnes/src/gui/gui.asm @@ -581,6 +581,7 @@ NEWSYM GUIWBAdd, db 25 NEWSYM BlackAndWhite, db 0 NEWSYM MouseWheel, db 1 NEWSYM AlternateTimer, db 0 +NEWSYM SuspendInBackground, db 0 GUIsave equ $-GUIRAdd @@ -601,7 +602,7 @@ ModemOKStat db 0 ; OK is detected on modem status GUIwinposxo dd 0,5 ,60 ,30 ,55 ,50 ,65 ,5 ,30 ,20 ,10 ,80 ,65 ,20 ,70 ,50 ,3 ,50 GUIwinposyo dd 0,20 ,70 ,30 ,20 ,20 ,36 ,20 ,30 ,20 ,20 ,50 ,60 ,30 ,65 ,50 ,22 ,60 GUIwinsizex dd 0,244 ,126 ,189 ,167 ,170 ,148 ,244 ,8*16,13*16,220 ,7*16,9*16,8*16,9*16,140 ,250 ,160 -GUIwinsizey dd 0,190 ,3*16,166 ,190 ,192 ,168 ,191 ,40 ,189 ,182 ,98 ,42 ,40 ,42 ,70 ,190 ,60 +GUIwinsizey dd 0,190 ,3*16,166 ,190 ,192 ,168 ,191 ,40 ,189 ,192 ,98 ,42 ,40 ,42 ,70 ,190 ,60 GUIwinptr db 0 GUItextcolor db 0,0,0,0,0 diff --git a/zsnes/src/gui/guimouse.inc b/zsnes/src/gui/guimouse.inc index 5fb815f4..aaab1eaa 100644 --- a/zsnes/src/gui/guimouse.inc +++ b/zsnes/src/gui/guimouse.inc @@ -2634,6 +2634,7 @@ DisplayGUIOptnsClick: %ifdef __WIN32__ GUIClickCButton 12,168,byte[AlwaysOnTop] GUIClickCButton 12,178,byte[SaveMainWindowPos] + GUIClickCButton 12,188,byte[SuspendInBackground] GUIClickCButton 124,23,byte[MouseWheel] %endif diff --git a/zsnes/src/gui/guiwindp.inc b/zsnes/src/gui/guiwindp.inc index cab4438d..65df1a1d 100644 --- a/zsnes/src/gui/guiwindp.inc +++ b/zsnes/src/gui/guiwindp.inc @@ -4758,6 +4758,12 @@ DisplayGUIOptns: mov dword[GUITemp],GUIIconDataCheckBoxC .nocheck10 GUIDisplayIconWin 10,12,178,[GUITemp] + mov dword[GUITemp],GUIIconDataCheckBoxUC + cmp byte[SuspendInBackground],1 + jne .nocheck11 + mov dword[GUITemp],GUIIconDataCheckBoxC +.nocheck11 + GUIDisplayIconWin 10,12,188,[GUITemp] %endif mov al,[GUIWincol] mov byte[GUItextcolor],al @@ -4797,6 +4803,7 @@ DisplayGUIOptns: GUIOuttextwin2 10,26,173,GUIGUIOptnsTextE GUIOuttextwin2 10,26,183,GUIGUIOptnsTextF GUIOuttextwin2u 10,138,28,GUIGUIOptnsTextJ,1 + GUIOuttextwin2 10,26,193,GUIGUIOptnsTextK %endif mov byte[GUIGUIOptnsText6],'R' GUIOuttextwin2 10,16,123,GUIGUIOptnsText6 @@ -4820,6 +4827,7 @@ DisplayGUIOptns: GUIOuttextwin2 10,25,172,GUIGUIOptnsTextE GUIOuttextwin2 10,25,182,GUIGUIOptnsTextF GUIOuttextwin2 10,137,27,GUIGUIOptnsTextJ + GUIOuttextwin2 10,25,192,GUIGUIOptnsTextK %endif mov byte[GUIGUIOptnsText6],'R' GUIOuttextwin2 10,15,122,GUIGUIOptnsText6 @@ -4911,6 +4919,7 @@ GUIGUIOptnsTextG db 'BACK',0 GUIGUIOptnsTextH db 'TITLE',0 GUIGUIOptnsTextI db 'WIN',0 GUIGUIOptnsTextJ db 'WHEEL MOUSE',0 +GUIGUIOptnsTextK db 'SUSPEND IN BACKGROUND',0 DisplayGUIAbout: ; cmp byte[OSPort],3 diff --git a/zsnes/src/win/winlink.cpp b/zsnes/src/win/winlink.cpp index 383710de..33b90dfb 100644 --- a/zsnes/src/win/winlink.cpp +++ b/zsnes/src/win/winlink.cpp @@ -117,6 +117,8 @@ int MouseMove2Y; DWORD SurfaceX=0; DWORD SurfaceY=0; +BYTE IsActivated = 1; + extern "C" { DWORD MouseButton; } @@ -189,6 +191,7 @@ extern BYTE HighPriority; extern BYTE AlwaysOnTop; extern BYTE SaveMainWindowPos; extern BYTE AlternateTimer; +extern BYTE SuspendInBackground; extern signed short int MainWindowX; extern signed short int MainWindowY; extern int CurKeyPos; @@ -196,19 +199,10 @@ extern int CurKeyReadPos; extern int KeyBuffer[16]; } -BYTE IsActivated = 1; - extern "C" void CheckPriority() { - if (IsActivated == 1) - { - if (HighPriority == 1) SetPriorityClass(GetCurrentProcess(), HIGH_PRIORITY_CLASS); - else SetPriorityClass(GetCurrentProcess(), NORMAL_PRIORITY_CLASS); - } - else - { - SetPriorityClass(GetCurrentProcess(), IDLE_PRIORITY_CLASS); - } + if (HighPriority == 1) SetPriorityClass(GetCurrentProcess(), HIGH_PRIORITY_CLASS); + else SetPriorityClass(GetCurrentProcess(), NORMAL_PRIORITY_CLASS); } extern "C" void CheckAlwaysOnTop() @@ -412,7 +406,6 @@ LRESULT CALLBACK Main_Proc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) break; case WM_ACTIVATE: IsActivated = 1; - CheckPriority(); if(LOWORD(wParam)==WA_INACTIVE) { ChangeDisplaySettings(NULL,0); @@ -440,7 +433,6 @@ LRESULT CALLBACK Main_Proc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) ChangeDisplaySettings(NULL,0); InputDeAcquire(); IsActivated = 0; - CheckPriority(); break; case WM_DESTROY: ChangeDisplaySettings(NULL,0); @@ -843,6 +835,8 @@ BOOL FAR PASCAL InitJoystickInput(LPCDIDEVICEINSTANCE pdinst, LPVOID pvRef) void endgame() { + +MessageBox(NULL, "blah", "blah", MB_OK); if(lpDirectSound) { lpDirectSound->Release(); @@ -1594,6 +1588,9 @@ void CheckTimers(void) void UpdateVFrame(void) { + + if (SuspendInBackground == 1 && IsActivated == 0) WaitMessage(); + int DataNeeded; int SPCSize=256;