From 7e485903d5fad970ffbe9bb8e17b5fae1ac29d23 Mon Sep 17 00:00:00 2001 From: pagefault <> Date: Sun, 27 May 2001 20:24:36 +0000 Subject: [PATCH] Implemented vsync in windows port --- zsnes/src/cfgload.asm | 4 +- zsnes/src/gui/gui.asm | 2 +- zsnes/src/gui/guikeys.inc | 26 +++++------ zsnes/src/gui/guimouse.inc | 18 +++----- zsnes/src/gui/guiwindp.inc | 88 +++++++++++++++----------------------- zsnes/src/win/winlink.cpp | 11 ++++- 6 files changed, 67 insertions(+), 82 deletions(-) diff --git a/zsnes/src/cfgload.asm b/zsnes/src/cfgload.asm index 8138c9e6..1b2b4946 100644 --- a/zsnes/src/cfgload.asm +++ b/zsnes/src/cfgload.asm @@ -659,11 +659,13 @@ db '; This option also Enables EAGLE - 640x480x256 mode only',13,10 db '',13,10 db 'Interpolation = %a',13,10 db '',13,10 -%ifdef __MSDOS__ +%ifndef __LINUX__ db '; VSync (1 = Enable, 0 = Disable) - Wait for Vertical Sync (Fast cpu reqd)',13,10 db '',13,10 db 'VSync = %p',13,10 db '',13,10 +%endif +%ifdef __MSDOS__ db '; Skip Enter Press at Beginning (1 = Yes, 0 = No)',13,10 db '',13,10 db 'EnterSkip = %b',13,10 diff --git a/zsnes/src/gui/gui.asm b/zsnes/src/gui/gui.asm index 25ff1255..6cc6ce80 100644 --- a/zsnes/src/gui/gui.asm +++ b/zsnes/src/gui/gui.asm @@ -601,7 +601,7 @@ ModemOKStat db 0 ; OK is detected on modem status ; LOAD STAT INPT OPT VID SND CHT NET GMKEY GUIOP ABT RSET SRC STCN MOVE CMBO ADDO 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 +GUIwinsizex dd 0,244 ,126 ,189 ,167 ,170 ,148 ,244 ,8*16,13*16,240 ,7*16,9*16,8*16,9*16,140 ,250 ,160 GUIwinsizey dd 0,190 ,3*16,166 ,190 ,192 ,168 ,191 ,40 ,189 ,192 ,98 ,42 ,40 ,42 ,70 ,190 ,60 GUIwinptr db 0 diff --git a/zsnes/src/gui/guikeys.inc b/zsnes/src/gui/guikeys.inc index e2a0aed7..af4fb987 100644 --- a/zsnes/src/gui/guikeys.inc +++ b/zsnes/src/gui/guikeys.inc @@ -812,19 +812,13 @@ GUIOptionKeys: mov [cfgnewgfx],al .invalidng .nonewgfx -%ifdef __MSDOS__ +%ifndef __LINUX__ cmp dh,'V' jne .novsync xor byte[vsyncon],1 mov al,[vsyncon] mov [cfgvsync],al .novsync -%endif -%ifdef __WIN32__ - cmp dh,'H' - jne .nohighpriority - xor byte[HighPriority],1 -.nohighpriority %endif cmp dh,'M' jne .nommxcopy @@ -853,10 +847,10 @@ GUIOptionKeys: xor byte[SidewinderFix],1 .noswfix %ifdef __WIN32__ - cmp dh,'S' - jne .noalttimer - xor byte[AlternateTimer],1 -.noalttimer + cmp dh,'H' + jne .nohighpriority + xor byte[HighPriority],1 +.nohighpriority %endif cmp dh,'F' jne .nofpsatstart @@ -898,10 +892,12 @@ GUIOptionKeys: jne .nospcdisable xor byte[SPCDisable],1 .nospcdisable - cmp dh,'P' - jne .notransmsg - xor byte[GUIEnableTransp],1 -.notransmsg +%ifdef __WIN32__ + cmp dh,'S' + jne .noalttimer + xor byte[AlternateTimer],1 +.noalttimer +%endif ret GUIGUIOptnsKeys: diff --git a/zsnes/src/gui/guimouse.inc b/zsnes/src/gui/guimouse.inc index b8bd9339..77a25da7 100644 --- a/zsnes/src/gui/guimouse.inc +++ b/zsnes/src/gui/guimouse.inc @@ -2085,22 +2085,16 @@ DisplayGUIOptionClick: jne near .invalidng GUIClickCButton2 11,36,byte[newengen],byte[cfgnewgfx],1 .invalidng -%ifdef __MSDOS__ +%ifndef __LINUX__ GUIClickCButton2 11,46,byte[vsyncon],byte[cfgvsync],1 -%endif -%ifdef __WIN32__ - GUIClickCButton 11,46,byte[HighPriority] %endif GUIClickCButton2 11,56,byte[FPUCopy],byte[cfgcopymethod],2 GUIClickCButtonM 11,66,byte[pl12s34] -; cmp byte[OSPort],3 -; je near .win32config %ifdef __MSDOS__ GUIClickCButton 11,76,byte[SidewinderFix] %endif -;.win32config %ifdef __WIN32__ - GUIClickCButton 11,76,byte[AlternateTimer] + GUIClickCButton 11,76,byte[HighPriority] %endif GUIClickCButton 11,86,byte[FPSAtStart] GUIClickCButton 11,96,byte[Turbo30hz] @@ -2112,7 +2106,9 @@ DisplayGUIOptionClick: GUIClickCButton 11,156,byte[AutoState] GUIClickCButton 11,166,byte[DontSavePath] GUIClickCButton 11,176,byte[SPCDisable] - GUIClickCButton 11,186,byte[GUIEnableTransp] +%ifdef __WIN32__ + GUIClickCButton 11,186,byte[AlternateTimer] +%endif ; Frameskip = 0 cmp byte[frameskip],0 je near .autopress @@ -2631,13 +2627,13 @@ DisplayGUIOptnsClick: GUIClickCButton 12,73,byte[JoyPad1Move] GUIClickCButton6 12,83,byte[GUIEffect],1 GUIClickCButton6 12,93,byte[GUIEffect],2 + GUIClickCButton 124,23,byte[GUIEnableTransp] %ifdef __WIN32__ GUIClickCButton 12,168,byte[AlwaysOnTop] GUIClickCButton 12,178,byte[SaveMainWindowPos] GUIClickCButton 12,188,byte[AllowMultipleInst] - GUIClickCButton 124,23,byte[MouseWheel] + GUIClickCButton 124,33,byte[MouseWheel] %endif - GUIPButtonHole 48,108,byte[CurPalSelect],0 GUIPButtonHole 88,108,byte[CurPalSelect],1 GUIPButtonHole 135,108,byte[CurPalSelect],2 diff --git a/zsnes/src/gui/guiwindp.inc b/zsnes/src/gui/guiwindp.inc index 37599406..d696da42 100644 --- a/zsnes/src/gui/guiwindp.inc +++ b/zsnes/src/gui/guiwindp.inc @@ -1350,25 +1350,20 @@ DisplayGUIOption: GUIOuttextwin2 4,6,16,[GUITemp] GUIOuttextwin2u 4,26,31,GUIOptionText2,0 GUIOuttextwin2u 4,26,41,GUIOptionText4,0 -; cmp byte[OSPort],3 -; je near .win32b -%ifdef __MSDOS__ +%ifndef __LINUX__ GUIOuttextwin2u 4,26,51,GUIOptionText5,0 %endif %ifdef __WIN32__ - GUIOuttextwin2u 4,26,51,GUIOptionText5b,0 + GUIOuttextwin2u 4,26,191,GUIOptionTextL,1 %endif -;.win32b GUIOuttextwin2u 4,26,61,GUIOptionText6,0 GUIOuttextwin2u 4,26,71,GUIOptionText7,0 -; cmp byte[OSPort],3 -; je near .win32b2 %ifdef __MSDOS__ GUIOuttextwin2u 4,26,81,GUIOptionTextA,0 %endif -;.win32b2 %ifdef __WIN32__ - GUIOuttextwin2u 4,26,81,GUIOptionTextAb,1 + GUIOuttextwin2u 4,26,81,GUIOptionTextAb,0 + GUIOuttextwin2u 4,26,191,GUIOptionTextL,1 %endif GUIOuttextwin2u 4,26,91,GUIOptionTextB,0 GUIOuttextwin2u 4,26,101,GUIOptionTextC,2 @@ -1380,30 +1375,21 @@ DisplayGUIOption: GUIOuttextwin2u 4,26,161,GUIOptionTextI,15 GUIOuttextwin2u 4,26,171,GUIOptionTextJ,0 GUIOuttextwin2u 4,26,181,GUIOptionTextK,1 - GUIOuttextwin2u 4,26,191,GUIOptionTextL,5 add byte[GUItextcolor],15 GUIOuttextwin2 4,5,15,[GUITemp] GUIOuttextwin2 4,25,30,GUIOptionText2 GUIOuttextwin2 4,25,40,GUIOptionText4 -; cmp byte[OSPort],3 -; je near .win32c -%ifdef __MSDOS__ +%ifndef __LINUX__ GUIOuttextwin2 4,25,50,GUIOptionText5 %endif -%ifdef __WIN32__ - GUIOuttextwin2 4,25,50,GUIOptionText5b -%endif -;.win32c GUIOuttextwin2 4,25,60,GUIOptionText6 GUIOuttextwin2 4,25,70,GUIOptionText7 -; cmp byte[OSPort],3 -; je near .win32c2 %ifdef __MSDOS__ GUIOuttextwin2 4,25,80,GUIOptionTextA %endif -;.win32c2 %ifdef __WIN32__ GUIOuttextwin2 4,25,80,GUIOptionTextAb + GUIOuttextwin2 4,25,190,GUIOptionTextL %endif GUIOuttextwin2 4,25,90,GUIOptionTextB GUIOuttextwin2 4,25,100,GUIOptionTextC @@ -1415,7 +1401,6 @@ DisplayGUIOption: GUIOuttextwin2 4,25,160,GUIOptionTextI GUIOuttextwin2 4,25,170,GUIOptionTextJ GUIOuttextwin2 4,25,180,GUIOptionTextK - GUIOuttextwin2 4,25,190,GUIOptionTextL mov dword[GUITemp],GUIIconDataCheckBoxUC cmp byte[TimerEnable],0 je .nocheckboxt @@ -1435,24 +1420,14 @@ DisplayGUIOption: mov dword[GUITemp],GUIIconDataCheckBoxC .nocheckbox1 GUIDisplayIconWin 4,11,36,[GUITemp] -%ifdef __MSDOS__ +%ifndef __LINUX__ mov dword[GUITemp],GUIIconDataCheckBoxUC cmp byte[vsyncon],0 je .nocheckbox2 mov dword[GUITemp],GUIIconDataCheckBoxC -; cmp byte[OSPort],3 -; je near .win32 - GUIDisplayIconWin 4,11,46,[GUITemp] -%endif -;.win32 -%ifdef __WIN32__ - mov dword[GUITemp],GUIIconDataCheckBoxUC - cmp byte[HighPriority],0 - je .nocheckbox2 - mov dword[GUITemp],GUIIconDataCheckBoxC -%endif .nocheckbox2 GUIDisplayIconWin 4,11,46,[GUITemp] +%endif mov dword[GUITemp],GUIIconDataCheckBoxUC cmp byte[FPUCopy],2 jne .nocheckbox3 @@ -1465,23 +1440,20 @@ DisplayGUIOption: mov dword[GUITemp],GUIIconDataCheckBoxC .nocheckbox4 GUIDisplayIconWin 4,11,66,[GUITemp] +%ifdef __MSDOS__ mov dword[GUITemp],GUIIconDataCheckBoxUC cmp byte[SidewinderFix],0 je .nocheckbox5 mov dword[GUITemp],GUIIconDataCheckBoxC .nocheckbox5 -; cmp byte[OSPort],3 -; je near .win322 -%ifdef __MSDOS__ GUIDisplayIconWin 4,11,76,[GUITemp] %endif -;.win322 %ifdef __WIN32__ mov dword[GUITemp],GUIIconDataCheckBoxUC - cmp byte[AlternateTimer],0 - je .win323 + cmp byte[HighPriority],0 + je .nocheckbox5 mov dword[GUITemp],GUIIconDataCheckBoxC -.win323 +.nocheckbox5 GUIDisplayIconWin 4,11,76,[GUITemp] %endif mov dword[GUITemp],GUIIconDataCheckBoxUC @@ -1538,12 +1510,14 @@ DisplayGUIOption: mov dword[GUITemp],GUIIconDataCheckBoxC .nocheckbox14 GUIDisplayIconWin 4,11,176,[GUITemp] +%ifdef __WIN32__ mov dword[GUITemp],GUIIconDataCheckBoxUC - cmp byte[GUIEnableTransp],0 - je .nocheckbox15 + cmp byte[AlternateTimer],0 + je .win323 mov dword[GUITemp],GUIIconDataCheckBoxC -.nocheckbox15 +.win323 GUIDisplayIconWin 4,11,186,[GUITemp] +%endif cmp byte[frameskip],0 je near .auto DrawGUIWinBox 4,75,13,93,21,167 @@ -1593,11 +1567,10 @@ GUIOptionText2 db 'AUTO FRAME RATE',0 GUIOptionText3 db 'MAX FRAME SKIP',0 GUIOptionText4 db 'NEW GFX ENGINE',0 GUIOptionText5 db 'VSYNC',0 -GUIOptionText5b db 'HIGH PRIORITY MODE',0 GUIOptionText6 db 'MMX SUPPORT',0 GUIOptionText7 db 'USE PL3/4 AS PL1/2',0 GUIOptionTextA db 'SIDEWINDER FIX',0 -GUIOptionTextAb db 'USE ALTERNATE TIMER',0 +GUIOptionTextAb db 'HIGH PRIORITY MODE',0 GUIOptionTextB db 'FPS AT START',0 GUIOptionTextC db 'USE 30HZ FOR TURBO',0 GUIOptionTextD db 'ENABLE GAME CLOCK',0 @@ -1608,7 +1581,7 @@ GUIOptionTextH db 'START AT LATEST SAVE',0 GUIOptionTextI db 'AUTO STATE SAVE/LOAD',0 GUIOptionTextJ db 'DON',39,'T SAVE CURRENT PATH',0 GUIOptionTextK db 'DISABLE SOUND CPU EMU',0 -GUIOptionTextL db 'TRANSPARENT MESSAGES',0 +GUIOptionTextL db 'USE ALTERNATE TIMER',0 GUIOptionText8 db '-',0 GUIOptionText9 db '+',0 GUIOptionText10 db '-',0 @@ -4688,14 +4661,20 @@ DisplayGUIOptns: mov dword[GUITemp],22 add [GUITemp],eax GUIDisplayIconWin 10,[GUITemp],144,GUIIconDataSlideBar + mov dword[GUITemp],GUIIconDataCheckBoxUC + cmp byte[GUIEnableTransp],1 + jne .nocheckt + mov dword[GUITemp],GUIIconDataCheckBoxC +.nocheckt + GUIDisplayIconWin 10,124,23,[GUITemp] %ifdef __WIN32__ mov dword[GUITemp],GUIIconDataCheckBoxUC cmp byte[MouseWheel],1 jne .nocheckr mov dword[GUITemp],GUIIconDataCheckBoxC .nocheckr - GUIDisplayIconWin 10,124,23,[GUITemp] + GUIDisplayIconWin 10,124,33,[GUITemp] %endif mov dword[GUITemp],GUIIconDataCheckBoxUC cmp byte[mousewrap],1 @@ -4799,11 +4778,12 @@ DisplayGUIOptns: GUIOuttextwin2 10,147,111,GUIGUIOptnsTextI GUIOuttextwin2 10,26,88,GUIGUIOptnsTextB GUIOuttextwin2 10,26,98,GUIGUIOptnsTextC + GUIOuttextwin2 10,138,28,GUIGUIOptnsTextJ %ifdef __WIN32__ GUIOuttextwin2 10,26,173,GUIGUIOptnsTextE GUIOuttextwin2 10,26,183,GUIGUIOptnsTextF - GUIOuttextwin2u 10,138,28,GUIGUIOptnsTextJ,1 - GUIOuttextwin2 10,26,193,GUIGUIOptnsTextK + GUIOuttextwin2u 10,138,38,GUIGUIOptnsTextK,1 + GUIOuttextwin2 10,26,193,GUIGUIOptnsTextL %endif mov byte[GUIGUIOptnsText6],'R' GUIOuttextwin2 10,16,123,GUIGUIOptnsText6 @@ -4823,11 +4803,12 @@ DisplayGUIOptns: GUIOuttextwin2 10,146,110,GUIGUIOptnsTextI GUIOuttextwin2 10,25,87,GUIGUIOptnsTextB GUIOuttextwin2 10,25,97,GUIGUIOptnsTextC + GUIOuttextwin2 10,137,27,GUIGUIOptnsTextJ %ifdef __WIN32__ GUIOuttextwin2 10,25,172,GUIGUIOptnsTextE GUIOuttextwin2 10,25,182,GUIGUIOptnsTextF - GUIOuttextwin2 10,137,27,GUIGUIOptnsTextJ - GUIOuttextwin2 10,25,192,GUIGUIOptnsTextK + GUIOuttextwin2 10,137,37,GUIGUIOptnsTextK + GUIOuttextwin2 10,25,192,GUIGUIOptnsTextL %endif mov byte[GUIGUIOptnsText6],'R' GUIOuttextwin2 10,15,122,GUIGUIOptnsText6 @@ -4918,8 +4899,9 @@ GUIGUIOptnsTextF db 'SAVE MAIN WINDOW POSITION',0 GUIGUIOptnsTextG db 'BACK',0 GUIGUIOptnsTextH db 'TITLE',0 GUIGUIOptnsTextI db 'WIN',0 -GUIGUIOptnsTextJ db 'WHEEL MOUSE',0 -GUIGUIOptnsTextK db 'ALLOW MULTIPLE INSTANCES',0 +GUIGUIOptnsTextJ db 'TRANSPARENT MSGS',0 +GUIGUIOptnsTextK db 'WHEEL MOUSE',0 +GUIGUIOptnsTextL db 'ALLOW MULTIPLE INSTANCES',0 DisplayGUIAbout: ; cmp byte[OSPort],3 diff --git a/zsnes/src/win/winlink.cpp b/zsnes/src/win/winlink.cpp index 9e7082d8..36ab7da1 100644 --- a/zsnes/src/win/winlink.cpp +++ b/zsnes/src/win/winlink.cpp @@ -145,10 +145,19 @@ void DDrawError(){ MessageBox (NULL, message1, "DirectDraw Error" , MB_ICONERROR ); } +extern "C" BYTE vsyncon; + void DrawScreen() { if(DD_CFB==NULL) return; - if(DD_Primary->Blt(&rcWindow,DD_CFB,NULL,DDBLT_WAIT,NULL)!=DD_OK) + if (vsyncon == 1) + { + if (lpDD->WaitForVerticalBlank(DDWAITVB_BLOCKBEGIN, NULL) != DD_OK) + { + DDrawError(); + } + } + if(DD_Primary->Blt(&rcWindow,DD_CFB,NULL,DDBLT_WAIT,NULL) != DD_OK) { DDrawError(); }