⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ddraw.c

📁 uboot在arm处理器s3c2410的移植代码
💻 C
📖 第 1 页 / 共 2 页
字号:
/******************************************************************************                   SciTech Multi-platform Graphics Library**  ========================================================================**    The contents of this file are subject to the SciTech MGL Public*    License Version 1.0 (the "License"); you may not use this file*    except in compliance with the License. You may obtain a copy of*    the License at http://www.scitechsoft.com/mgl-license.txt**    Software distributed under the License is distributed on an*    "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or*    implied. See the License for the specific language governing*    rights and limitations under the License.**    The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc.**    The Initial Developer of the Original Code is SciTech Software, Inc.*    All Rights Reserved.**  ========================================================================** Language:     ANSI C* Environment:  Win32** Description:  Win32 implementation for the SciTech cross platform*               event library.*****************************************************************************/#include "event.h"#include "pmapi.h"#include "win32/oshdr.h"#include "nucleus/graphics.h"/*---------------------------- Global Variables ---------------------------*//* Publicly accessible variables */int                 _PM_deskX,_PM_deskY;/* Desktop dimentions           */HWND                _PM_hwndConsole;    /* Window handle for console    */#ifdef  __INTEL__uint                _PM_cw_default;     /* Default FPU control word     */#endif/* Private internal variables */static HINSTANCE    hInstApp = NULL;/* Application instance handle      */static HWND         hwndUser = NULL;/* User window handle               */static HINSTANCE    hInstDD = NULL; /* Handle to DirectDraw DLL         */static LPDIRECTDRAW lpDD = NULL;    /* DirectDraw object                */static LONG         oldWndStyle;    /* Info about old user window       */static LONG         oldExWndStyle;  /* Info about old user window       */static int          oldWinPosX;     /* Old window position X coordinate */static int          oldWinPosY;     /* Old window pisition Y coordinate */static int          oldWinSizeX;    /* Old window size X                */static int          oldWinSizeY;    /* Old window size Y                */static WNDPROC      oldWinProc = NULL;static PM_saveState_cb suspendApp = NULL;static ibool        waitActive = false;static ibool        isFullScreen = false;static ibool        backInGDI = false;/* Internal strings */static char *szWinClassName     = "SciTechDirectDrawWindow";static char *szAutoPlayKey      = "Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer";static char *szAutoPlayValue    = "NoDriveTypeAutoRun";/* Dynalinks to DirectDraw functions */static HRESULT (WINAPI *pDirectDrawCreate)(GUID FAR *lpGUID, LPDIRECTDRAW FAR *lplpDD, IUnknown FAR *pUnkOuter);/*---------------------------- Implementation -----------------------------*//****************************************************************************REMARKS:Temporarily disables AutoPlay operation while we are running in fullscreengraphics modes.****************************************************************************/static void DisableAutoPlay(void){    DWORD   dwAutoPlay,dwSize = sizeof(dwAutoPlay);    HKEY    hKey;    if (RegOpenKeyEx(HKEY_CURRENT_USER,szAutoPlayKey,0,KEY_EXECUTE | KEY_WRITE,&hKey) == ERROR_SUCCESS) {	RegQueryValueEx(hKey,szAutoPlayValue,NULL,NULL,(void*)&dwAutoPlay,&dwSize);	dwAutoPlay |= AUTOPLAY_DRIVE_CDROM;	RegSetValueEx(hKey,szAutoPlayValue,0,REG_DWORD,(void*)&dwAutoPlay,dwSize);	RegCloseKey(hKey);	}}/****************************************************************************REMARKS:Re-enables AutoPlay operation when we return to regular GDI mode.****************************************************************************/static void RestoreAutoPlay(void){    DWORD   dwAutoPlay,dwSize = sizeof(dwAutoPlay);    HKEY    hKey;    if (RegOpenKeyEx(HKEY_CURRENT_USER,szAutoPlayKey,0,KEY_EXECUTE | KEY_WRITE,&hKey) == ERROR_SUCCESS) {	RegQueryValueEx(hKey,szAutoPlayValue,NULL,NULL,(void*)&dwAutoPlay,&dwSize);	dwAutoPlay &= ~AUTOPLAY_DRIVE_CDROM;	RegSetValueEx(hKey,szAutoPlayValue,0,REG_DWORD,(void*)&dwAutoPlay,dwSize);	RegCloseKey(hKey);	}}/****************************************************************************REMARKS:Suspends the application by switching back to the GDI desktop, allowingnormal application code to be processed, and then waiting for theapplication activate command to bring us back to fullscreen mode with ourwindow minimised.****************************************************************************/static void LeaveFullScreen(void){    int retCode = PM_SUSPEND_APP;    if (backInGDI)	return;    if (suspendApp)	retCode = suspendApp(PM_DEACTIVATE);    RestoreAutoPlay();    backInGDI = true;    /* Now process messages normally until we are re-activated */    waitActive = true;    if (retCode != PM_NO_SUSPEND_APP) {	while (waitActive) {	    _EVT_pumpMessages();	    Sleep(200);	    }	}}/****************************************************************************REMARKS:Reactivate all the surfaces for DirectDraw and set the system back up forfullscreen rendering.****************************************************************************/static void RestoreFullScreen(void){    static ibool    firstTime = true;    if (firstTime) {	/* Clear the message queue while waiting for the surfaces to be	 * restored.	 */	firstTime = false;	while (1) {	    /* Continue looping until out application has been restored	     * and we have reset the display mode.	     */	    _EVT_pumpMessages();	    if (GetActiveWindow() == _PM_hwndConsole) {		if (suspendApp)		    suspendApp(PM_REACTIVATE);		DisableAutoPlay();		backInGDI = false;		waitActive = false;		firstTime = true;		return;		}	    Sleep(200);	    }	}}/****************************************************************************REMARKS:This function suspends the application by switching back to the GDI desktop,allowing normal application code to be processed and then waiting for theapplication activate command to bring us back to fullscreen mode with ourwindow minimised.This version only gets called if we have not captured the screen switch inour activate message loops and will occur if the DirectDraw drivers lose asurface for some reason while rendering. This should not normally happen,but it is included just to be sure (it can happen on WinNT/2000 if the userhits the Ctrl-Alt-Del key combination). Note that this code will alwaysspin loop, and we cannot disable the spin looping from this version (ie:if the user hits Ctrl-Alt-Del under WinNT/2000 the application main loopwill cease to be executed until the user switches back to the application).****************************************************************************/void PMAPI PM_doSuspendApp(void){    static  ibool firstTime = true;    /* Call system DLL version if found */    if (_PM_imports.PM_doSuspendApp != PM_doSuspendApp) {	_PM_imports.PM_doSuspendApp();	return;	}    if (firstTime) {	if (suspendApp)	    suspendApp(PM_DEACTIVATE);	RestoreAutoPlay();	firstTime = false;	backInGDI = true;	}    RestoreFullScreen();    firstTime = true;}/****************************************************************************REMARKS:Main Window proc for the full screen DirectDraw Window that we create whilerunning in full screen mode. Here we capture all mouse and keyboard eventsfor the window and plug them into our event queue.****************************************************************************/static LONG CALLBACK PM_winProc(    HWND hwnd,    UINT msg,    WPARAM wParam,    LONG lParam){    switch (msg) {	case WM_SYSCHAR:	    /* Stop Alt-Space from pausing our application */	    return 0;	case WM_KEYDOWN:	case WM_SYSKEYDOWN:	    if (HIWORD(lParam) & KF_REPEAT) {		if (msg == WM_SYSKEYDOWN)		    return 0;		break;		}	    /* Fall through for keydown events */	case WM_KEYUP:	case WM_SYSKEYUP:	    if (msg == WM_SYSKEYDOWN || msg == WM_SYSKEYUP) {		if ((HIWORD(lParam) & KF_ALTDOWN) && wParam == VK_RETURN)		    break;		/* We ignore the remainder of the system keys to stop the		 * system menu from being activated from the keyboard and pausing		 * our app while fullscreen (ie: pressing the Alt key).		 */		return 0;		}	    break;	case WM_SYSCOMMAND:	    switch (wParam & ~0x0F) {		case SC_SCREENSAVE:		case SC_MONITORPOWER:		    /* Ignore screensaver requests in fullscreen modes */		    return 0;		}	    break;	case WM_SIZE:	    if (waitActive && backInGDI && (wParam != SIZE_MINIMIZED)) {		/* Start the re-activation process */		PostMessage(hwnd,WM_DO_SUSPEND_APP,WM_PM_RESTORE_FULLSCREEN,0);		}	    else if (!waitActive && isFullScreen && !backInGDI && (wParam == SIZE_MINIMIZED)) {		/* Start the de-activation process */		PostMessage(hwnd,WM_DO_SUSPEND_APP,WM_PM_LEAVE_FULLSCREEN,0);		}	    break;	case WM_DO_SUSPEND_APP:	    switch (wParam) {				case WM_PM_RESTORE_FULLSCREEN:					RestoreFullScreen();					break;				case WM_PM_LEAVE_FULLSCREEN:					LeaveFullScreen();					break;		}	    return 0;	}    if (oldWinProc)	return oldWinProc(hwnd,msg,wParam,lParam);    return DefWindowProc(hwnd,msg,wParam,lParam);}/****************************************************************************PARAMETERS:hwnd    - User window to convertwidth   - Window of the fullscreen windowheight  - Height of the fullscreen windowRETURNS:Handle to converted fullscreen Window.REMARKS:This function takes the original user window handle and modifies the size,position and attributes for the window to convert it into a fullscreenwindow that we can use.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -