From 37df262313bd18716c51061f2ee4af61f9fc2b20 Mon Sep 17 00:00:00 2001 From: pagefault <> Date: Fri, 15 Jun 2001 00:29:53 +0000 Subject: [PATCH] Overlay fix --- zsnes/src/gui/guikeys.inc | 1 - zsnes/src/gui/guimouse.inc | 2 +- zsnes/src/win/winlink.cpp | 76 +++++++++++++++++++++++++++++++++----- 3 files changed, 67 insertions(+), 12 deletions(-) diff --git a/zsnes/src/gui/guikeys.inc b/zsnes/src/gui/guikeys.inc index ad1bce68..5e8dab5d 100644 --- a/zsnes/src/gui/guikeys.inc +++ b/zsnes/src/gui/guikeys.inc @@ -892,7 +892,6 @@ GUIOptionKeys: cmp dh,'Y' jne .nooverlay xor byte[OverlayEnabled],1 - call guimustrestartmsg .nooverlay cmp dh,'S' jne .noalttimer diff --git a/zsnes/src/gui/guimouse.inc b/zsnes/src/gui/guimouse.inc index 6ef4a5ae..85843a15 100644 --- a/zsnes/src/gui/guimouse.inc +++ b/zsnes/src/gui/guimouse.inc @@ -2120,7 +2120,7 @@ DisplayGUIOptionClick: GUIClickCButton 11,156,byte[AutoState] GUIClickCButton 11,166,byte[DontSavePath] %ifdef __WIN32__ - GUIClickCButtonat 11,176,byte[OverlayEnabled] + GUIClickCButton 11,176,byte[OverlayEnabled] GUIClickCButtonat 11,186,byte[AlternateTimer] %endif ; Frameskip = 0 diff --git a/zsnes/src/win/winlink.cpp b/zsnes/src/win/winlink.cpp index 109eb88d..257d1506 100644 --- a/zsnes/src/win/winlink.cpp +++ b/zsnes/src/win/winlink.cpp @@ -1494,12 +1494,19 @@ DDSURFACEDESC2 ddsd; DWORD LockSurface() { + HRESULT hr; + if (DD_CFB == NULL) return(0); memset(&ddsd,0,sizeof(ddsd)); ddsd.dwSize = sizeof( ddsd ); ddsd.dwFlags = DDSD_LPSURFACE | DDSD_PITCH; - if (DD_CFB->Lock(NULL,&ddsd,DDLOCK_WAIT,NULL) != DD_OK) + if (Overlay == 1 && vsyncon == 1 && (DD_BackBuffer)) + hr=DD_BackBuffer->Lock(NULL,&ddsd,DDLOCK_WAIT,NULL); + else + hr=DD_CFB->Lock(NULL,&ddsd,DDLOCK_WAIT,NULL); + + if (hr != DD_OK) { return(0); } @@ -1510,7 +1517,7 @@ DWORD LockSurface() void UnlockSurface() { - if (Overlay && (vsyncon == 1)) + if (Overlay == 1 && vsyncon == 1 && (DD_BackBuffer)) DD_BackBuffer->Unlock((struct tagRECT *)ddsd.lpSurface); else DD_CFB->Unlock((struct tagRECT *)ddsd.lpSurface); @@ -1929,6 +1936,8 @@ void CheckTimers(void) extern BYTE GUIOn2; +extern unsigned char FPUCopy; + void UpdateVFrame(void) { @@ -1975,13 +1984,61 @@ void UpdateVFrame(void) DSPBuffer1=(int *)&DSPBuffer; - for(i=0;i32767)Buffer[i]=32767; - if (DSPBuffer1[i]<-32767)Buffer[i]=-32767; - if (T36HZEnabled)Buffer[i]=0; - } + int buffer_ptr = (int)&Buffer[0]; + + if (T36HZEnabled) + if (FPUCopy) + _asm + { + mov edi, buffer_ptr + mov ecx, SPCSize + shr ecx, 2 + pxor mm0,mm0 +_blank_top_fpu: + movq [edi],mm0 + add edi,8 + dec ecx + jne _blank_top_fpu + emms + } + else + _asm + { + mov edi, buffer_ptr + mov ecx, SPCSize + shr ecx, 1 + xor eax,eax +_blank_top: + mov [edi],eax + add edi,4 + dec ecx + jne _blank_top + } + else + if (FPUCopy) + _asm + { + mov esi, DSPBuffer1 + mov edi, buffer_ptr + mov ecx, SPCSize + shr ecx, 2 +_top_mmx: + movq mm0, [esi] + packssdw mm0, [esi+8] + movq [edi], mm0 + add esi, 16 + add edi, 8 + dec ecx + jne _top_mmx + emms + } + else + for(i=0;i32767)Buffer[i]=32767; + if (DSPBuffer1[i]<-32767)Buffer[i]=-32767; + } if (DS_OK!=lpSoundBuffer->Lock(LastUsedPos, SPCSize*2, &lpvPtr1, @@ -2017,7 +2074,6 @@ extern DWORD AddEndBytes; extern DWORD NumBytesPerLine; extern unsigned char * WinVidMemStart; extern void copy640x480x16bwin(void); -extern unsigned char FPUCopy; extern unsigned char NGNoTransp; extern unsigned char newengen;