📄 winlink.cpp
字号:
case 4: SurfaceX=1024; SurfaceY=960; break; } BlitArea.top = 0; BlitArea.left = 0; BlitArea.right = SurfaceX; if ((SurfaceX == 602) || (SurfaceX == 640) || (SurfaceX == 320)) BlitArea.bottom = SurfaceY; else if (!NTSCFilter) BlitArea.bottom = (SurfaceY/240)*resolutn; if (PrevRes == 0) PrevRes = resolutn; } if (((PrevStereoSound!=StereoSound)||(PrevSoundQuality!=SoundQuality))&&FirstSound!=1) ReInitSound(); if (!FirstVid) { if (X<0)X=0; if (X>(int)(GetSystemMetrics(SM_CXSCREEN) - WindowWidth)) X=(GetSystemMetrics(SM_CXSCREEN) - WindowWidth); if (Y<0)Y=0; if (Y>(int)(GetSystemMetrics(SM_CYSCREEN) - WindowHeight)) Y=(GetSystemMetrics(SM_CYSCREEN) - WindowHeight); if (FullScreen==1) {X=0; Y=0;} if (FullScreen==0 && newmode == 1) { X = MainWindowX; Y = MainWindowY; } else if (FullScreen==0) { MainWindowX = X; MainWindowY = Y; } MoveWindow(hMainWindow, X, Y, WindowWidth, WindowHeight, TRUE); wndpl.length = sizeof(wndpl); GetWindowPlacement(hMainWindow, &wndpl); SetRect(&rc1, 0, 0, WindowWidth, WindowHeight); AdjustWindowRectEx(&rc1,GetWindowLong(hMainWindow, GWL_STYLE), GetMenu(hMainWindow) != NULL, GetWindowLong(hMainWindow, GWL_EXSTYLE)); GetClientRect(hMainWindow, &rcWindow); ClientToScreen(hMainWindow, (LPPOINT) &rcWindow); ClientToScreen(hMainWindow, (LPPOINT) &rcWindow + 1); if (FullScreen == 1) { if (HQMode && !DSMode) { int marginx = (rcWindow.right - rcWindow.left - BlitArea.right + BlitArea.left)/2; int marginy = (rcWindow.bottom - rcWindow.top - BlitArea.bottom + BlitArea.top)/2; if (marginx>0) { rcWindow.left += marginx; rcWindow.right -= marginx; } if (marginy>0) { rcWindow.top += marginy; rcWindow.bottom -= marginy; } } if ((DSMode == 1) && (scanlines != 0)) { int OldHeight = rcWindow.bottom - rcWindow.top; if ((OldHeight % 240) == 0) { int NewHeight = (OldHeight/240)*resolutn; rcWindow.top += (OldHeight - NewHeight)/2; rcWindow.bottom = rcWindow.top + NewHeight; clear_display(); } } } if (CheckTVRatioReq()) KeepTVRatio(); } else { atexit(ExitFunction); if (!QueryPerformanceFrequency((LARGE_INTEGER*)&freq)) return; if (!RegisterWinClass()) { exit(1); } X=(GetSystemMetrics(SM_CXSCREEN) - WindowWidth) / 2; Y=(GetSystemMetrics(SM_CYSCREEN) - WindowHeight) / 2; if (FullScreen==1) {X=0; Y=0;} if (hMainWindow) { CloseWindow(hMainWindow); } if (SaveMainWindowPos == 1 && MainWindowX != -1 && FullScreen == 0) { X = MainWindowX; Y = MainWindowY; } hMainWindow = CreateWindow( "ZSNES", WinName, WS_VISIBLE|WS_POPUP,X,Y, //WS_OVERLAPPED "ZSNES" WindowWidth,WindowHeight,NULL,NULL,hInst,NULL); if (!hMainWindow) { return; } // Hide the cursor ShowCursor(0); // Set window attributes ShowWindow(hMainWindow, SW_SHOWNORMAL); SetWindowText(hMainWindow,"ZSNES"); // Run ZSNES Windows GUI callback functions to set initial values CheckPriority(); CheckAlwaysOnTop(); CheckScreenSaver(); // Init various DirectX subsystems InitInput(); InitSound(); TestJoy();// if (debugger) InitDebugger(); // Start debugger such that it is at this point } if (FirstVid == 1) { FirstVid = 0; if (KitchenSync) Refresh = totlines == 263 ? 120 : 100; else if (KitchenSyncPAL && totlines == 314) Refresh = 100; else if (ForceRefreshRate) Refresh = SetRefreshRate; InitDirectDraw(); clearwin(); Clear2xSaIBuffer(); clear_display(); } else if (newmode == 1 && Moving != 1) { ReleaseDirectDraw(); InitDirectDraw(); if (CheckTVRatioReq()) KeepTVRatio(); clearwin(); Clear2xSaIBuffer(); clear_display(); }}extern unsigned int vidbuffer;extern void SoundProcess();extern int DSPBuffer;int * DSPBuffer1;DWORD ScreenPtr;DWORD ScreenPtr2;void GUI36hzcall(void);void Game60hzcall(void);void CheckTimers(void){ // Lame fix for GUI using 100% CPU if (GUIOn || GUIOn2 || EMUPause) Sleep(1); QueryPerformanceCounter((LARGE_INTEGER*)&end2); while ((end2 - start2) >= update_ticks_pc2) { start2 += update_ticks_pc2; } if (T60HZEnabled == 1) { QueryPerformanceCounter((LARGE_INTEGER*)&end); while ((end - start) >= update_ticks_pc) { Game60hzcall(); start += update_ticks_pc; } } if (T36HZEnabled == 1) { QueryPerformanceCounter((LARGE_INTEGER*)&end); while ((end - start) >= update_ticks_pc) { GUI36hzcall(); start += update_ticks_pc; } }}extern "C" {volatile int SPCSize;volatile int buffer_ptr;extern unsigned char MMXSupport;}void UpdateVFrame(void){ int DataNeeded; SPCSize=256; //if (StereoSound==1) SPCSize=256; while (PeekMessage(&msg,NULL,0,0,PM_REMOVE)) { TranslateMessage(&msg); DispatchMessage(&msg); } WinUpdateDevices(); CheckTimers(); if (SoundEnabled == 0) return; if(!UsePrimaryBuffer) lpSoundBuffer->GetCurrentPosition(&CurrentPos,&WritePos); else lpPrimaryBuffer->GetCurrentPosition(&CurrentPos,&WritePos); if (LastUsedPos <= CurrentPos) { DataNeeded=CurrentPos-LastUsedPos; } else { DataNeeded=SoundBufferSize - LastUsedPos + CurrentPos; } DataNeeded/=(SPCSize*2); DataNeeded*=(SPCSize*2); while (DataNeeded>0) { asm_call(SoundProcess); DSPBuffer1=(int *)&DSPBuffer; buffer_ptr = (int)&Buffer[0]; if (T36HZEnabled == 1) { if (MMXSupport == 1) { ASM_BEGIN ASM_COMMAND3(mov edi,buffer_ptr) ASM_COMMAND3(mov ecx,SPCSize) ASM_COMMAND2(shr ecx,2) ASM_COMMAND2(pxor mm0,mm0)ASM_COMMAND(_blank_top_fpu:) ASM_COMMAND2(movq [edi],mm0) ASM_COMMAND2(add edi,8) ASM_COMMAND(dec ecx) ASM_COMMAND(jne _blank_top_fpu) ASM_COMMAND(emms) ASM_END } else { ASM_BEGIN ASM_COMMAND3(mov edi,buffer_ptr) ASM_COMMAND3(mov ecx,SPCSize) ASM_COMMAND2(shr ecx,1) ASM_COMMAND2(xor eax,eax)ASM_COMMAND(_blank_top:) ASM_COMMAND2(mov [edi],eax) ASM_COMMAND2(add edi,4) ASM_COMMAND(dec ecx) ASM_COMMAND(jne _blank_top) ASM_END } } else { if (MMXSupport == 1) { ASM_BEGIN ASM_COMMAND3(mov esi,DSPBuffer1) ASM_COMMAND3(mov edi,buffer_ptr) ASM_COMMAND3(mov ecx,SPCSize) ASM_COMMAND2(shr ecx,2)ASM_COMMAND(_top_mmx:) ASM_COMMAND2(movq mm0,[esi]) ASM_COMMAND2(packssdw mm0,[esi+8]) ASM_COMMAND2(movq [edi],mm0) ASM_COMMAND2(add esi,16) ASM_COMMAND2(add edi,8) ASM_COMMAND(dec ecx) ASM_COMMAND(jne _top_mmx) ASM_COMMAND(emms) ASM_END } else { for(i=0;i<SPCSize;i++) { Buffer[i]=DSPBuffer1[i]; if (DSPBuffer1[i]>32767)Buffer[i]=32767; if (DSPBuffer1[i]<-32767)Buffer[i]=-32767; } } } if(!UsePrimaryBuffer) { if (DS_OK!=lpSoundBuffer->Lock(LastUsedPos, SPCSize*2, &lpvPtr1, &dwBytes1, &lpvPtr2, &dwBytes2, 0)) { return; } } else { if (DS_OK!=lpPrimaryBuffer->Lock(LastUsedPos, SPCSize*2, &lpvPtr1, &dwBytes1, &lpvPtr2, &dwBytes2, 0)) { return; } } Sound=(short *)lpvPtr1; CopyMemory(lpvPtr1, &Buffer[0], dwBytes1); if (NULL != lpvPtr2) { CopyMemory(lpvPtr2, &Buffer[0]+dwBytes1, dwBytes2); } if(!UsePrimaryBuffer) { if (DS_OK != lpSoundBuffer->Unlock(lpvPtr1, dwBytes1, lpvPtr2, dwBytes2)) { return; } } else { if (DS_OK != lpPrimaryBuffer->Unlock(lpvPtr1, dwBytes1, lpvPtr2, dwBytes2)) { return; } } LastUsedPos+=SPCSize*2; if (LastUsedPos==SoundBufferSize) LastUsedPos=0; DataNeeded-=(SPCSize*2); }}extern unsigned char curblank;extern DWORD AddEndBytes;extern DWORD NumBytesPerLine;extern unsigned char * WinVidMemStart;void copy640x480x16bwin(void);void hq2x_16b(void);void hq2x_32b(void);void hq3x_16b(void);void hq3x_32b(void);void hq4x_16b(void);void hq4x_32b(void);extern unsigned char NGNoTransp;void ClearWin16();void ClearWin32();void clearwin(){ pitch=LockSurface(); if (pitch==0) { return; } SurfBufD=(DWORD) &SurfBuf[0]; if (AltSurface == 0) { switch (BitDepth) { case 16: ClearWin16(); break; case 32: ClearWin32(); break; } } else ClearWin16(); UnlockSurface();}extern "C"{ void initDirectDraw() { InitDirectDraw(); if (CheckTVRatioReq()) KeepTVRatio(); clearwin(); Clear2xSaIBuffer(); clear_display(); }}void clear_display(){ if (FullScreen == 1) { DDBLTFX ddbltfx; ddbltfx.dwSize = sizeof(ddbltfx); ddbltfx.dwFillColor = 0; if (TripleBufferWin == 1) { if ((DD_Primary != NULL) && (DD_BackBuffer != NULL)) { if (DD_BackBuffer->Blt( NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &ddbltfx ) == DDERR_SURFACELOST) DD_Primary->Restore(); if (DD_Primary->Flip(NULL, DDFLIP_WAIT) == DDERR_SURFACELOST) DD_Primary->Restore(); if (DD_BackBuffer->Blt( NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &ddbltfx ) == DDERR_SURFACELOST) DD_Primary->Restore(); if (DD_Primary->Flip(NULL, DDFLIP_WAIT) == DDERR_SURFACELOST) DD_Primary->Restore(); if (DD_BackBuffer->Blt( NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &ddbltfx ) == DDERR_SURFACELOST) DD_Primary->Restore(); } } else { if (DD_Primary != NULL) { if (vsyncon == 1) { if (lpDD->WaitForVerticalBlank(DDWAITVB_BLOCKBEGIN, NULL) != DD_OK) { DDrawError(); } } if (DD_Primary->Blt( NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &ddbltfx ) == DDERR_SURFACELOST) DD_Primary->Restore(); } } }}void DrawWin256x224x16();void DrawWin256x224x32();void DrawWin320x240x16();volatile __int64 copymaskRB = 0x001FF800001FF800LL;volatile __int64 copymaskG = 0x0000FC000000FC00LL;volatile __int64 copymagic = 0x0008010000080100LL;void drawscreenwin(void){ DWORD i,j,color32; DWORD *SURFDW; NGNoTransp = 0; // Set this value to 1 within the appropriate // video mode if you want to add a custom // transparency routine or hardware // transparency. This only works if // the value of newengen is equal to 1. // (see ProcessTransparencies in newgfx16.asm // for ZSNES' current transparency code) UpdateVFrame(); if (curblank!=0) return; if (!(pitch = LockSurface())) return; ScreenPtr=vidbuffer; ScreenPtr+=16*2+32*2+256*2; DWORD HQMode=0; if (MMXSupport == 0) hqFilter=0; if ( hqFilter != 0 ) { if ((GUIHQ2X[cvidmode] != 0) && (hqFilterlevel == 2)) HQMode=2; if ((GUIHQ3X[cvidmode] != 0) && (hqFilterlevel == 3)) HQMode=3; if ((GUIHQ4X[cvidmode] != 0) && (hqFilterlevel == 4)) HQMode=4; } if (PrevRes != resolutn) { if ((SurfaceX == 640) || (SurfaceX == 320)) BlitArea.bottom = SurfaceY; else if (!NTSCFilter) BlitArea.bottom = (SurfaceY/240)*resolutn; if ((FullScreen == 0) && (SMode == 0) && (DSMode == 0) && !NTSCFilter) Wi
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -