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

📄 sdl_epocvideo.cpp

📁 SDL库 在进行视频显示程序spcaview安装时必须的库文件
💻 CPP
📖 第 1 页 / 共 2 页
字号:
/*    SDL - Simple DirectMedia Layer    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga    This library is free software; you can redistribute it and/or    modify it under the terms of the GNU Library General Public    License as published by the Free Software Foundation; either    version 2 of the License, or (at your option) any later version.    This library is distributed in the hope that it will be useful,    but WITHOUT ANY WARRANTY; without even the implied warranty of    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU    Library General Public License for more details.    You should have received a copy of the GNU Library General Public    License along with this library; if not, write to the Free    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA    Sam Lantinga    slouken@devolution.com*//*    SDL_epocvideo.cpp    Epoc based SDL video driver implementation    Markus Mertama*/#include "epoc_sdl.h"#include <stdlib.h>#include <stdio.h>#include <string.h>extern "C" {#include "SDL_error.h"#include "SDL_timer.h"#include "SDL_video.h"#undef NULL#include "SDL_pixels_c.h"#include "SDL.h"#include "SDL_mouse.h"}#include "SDL_epocvideo.h"#include "SDL_epocevents_c.h"#include <coedef.h>#include <flogger.h>#include <eikenv.h>#include <eikappui.h>#include <eikapp.h>#include "sdlepocapi.h"////////////////////////////////////////////////////////////////_LIT(KLibName, "SDL");void RDebug_Print_b(char* error_str, void* param)    {    TBuf8<128> error8((TUint8*)error_str);    TBuf<128> error;    error.Copy(error8);#ifndef TRACE_TO_FILE    if (param) //!! Do not work if the parameter is really 0!!        RDebug::Print(error, param);    else         RDebug::Print(error);#else    if (param) //!! Do not work if the parameter is really 0!!        RFileLogger::WriteFormat(KLibName, _L("SDL.txt"), EFileLoggingModeAppend, error, param);    else         RFileLogger::Write(KLibName, _L("SDL.txt"), EFileLoggingModeAppend, error);#endif    }extern "C" void RDebug_Print(char* error_str, void* param)    {    RDebug_Print_b(error_str, param);    }/*int Debug_AvailMem2()    {    //User::CompressAllHeaps();    TMemoryInfoV1Buf membuf;     User::LeaveIfError(UserHal::MemoryInfo(membuf));    TMemoryInfoV1 minfo = membuf();	return(minfo.iFreeRamInBytes);    }extern "C" int Debug_AvailMem()    {    return(Debug_AvailMem2());    }    */extern "C" {/* Initialization/Query functions */static int EPOC_VideoInit(_THIS, SDL_PixelFormat *vformat);static SDL_Rect **EPOC_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags);static SDL_Surface *EPOC_SetVideoMode(_THIS, SDL_Surface *current, int width, int height, int bpp, Uint32 flags);static int EPOC_SetColors(_THIS, int firstcolor, int ncolors,			  SDL_Color *colors);static void EPOC_VideoQuit(_THIS);/* Hardware surface functions */static int EPOC_AllocHWSurface(_THIS, SDL_Surface *surface);static int EPOC_LockHWSurface(_THIS, SDL_Surface *surface);static int EPOC_FlipHWSurface(_THIS, SDL_Surface *surface);static void EPOC_UnlockHWSurface(_THIS, SDL_Surface *surface);static void EPOC_FreeHWSurface(_THIS, SDL_Surface *surface);static void EPOC_DirectUpdate(_THIS, int numrects, SDL_Rect *rects);static int EPOC_Available(void);static SDL_VideoDevice *EPOC_CreateDevice(int devindex);void DrawBackground(_THIS);void DirectDraw(_THIS, int numrects, SDL_Rect *rects, TUint16* screenBuffer);void DirectDrawRotated(_THIS, int numrects, SDL_Rect *rects, TUint16* screenBuffer);/* Mouse functions */static WMcursor *EPOC_CreateWMCursor(_THIS, Uint8 *data, Uint8 *mask, int w, int h, int hot_x, int hot_y);static void EPOC_FreeWMCursor(_THIS, WMcursor *cursor);static int EPOC_ShowWMCursor(_THIS, WMcursor *cursor);}extern "C"	{	struct WMcursor		{		};	}/* Epoc video driver bootstrap functions */static int EPOC_Available(void)    {    return 1; /* Always available */    }static void EPOC_DeleteDevice(SDL_VideoDevice *device)    {	User::Free(device->hidden);	User::Free(device);    }static SDL_VideoDevice *EPOC_CreateDevice(int /*devindex*/)    {	SDL_VideoDevice *device;	SDL_TRACE("SDL:EPOC_CreateDevice");	/* Allocate all variables that we free on delete */	device = static_cast<SDL_VideoDevice*>(User::Alloc(sizeof(SDL_VideoDevice)));	if ( device ) 	    {		Mem::FillZ(device, (sizeof *device));		device->hidden = static_cast<struct SDL_PrivateVideoData*>				(User::Alloc((sizeof *device->hidden)));	    }	if ( (device == NULL) || (device->hidden == NULL) )	    {		SDL_OutOfMemory();		if ( device ) {		User::Free(device);		}		return(0);	}	Mem::FillZ(device->hidden, (sizeof *device->hidden));	/* Set the function pointers */	device->VideoInit = EPOC_VideoInit;	device->ListModes = EPOC_ListModes;	device->SetVideoMode = EPOC_SetVideoMode;	device->SetColors = EPOC_SetColors;	device->UpdateRects = NULL;	device->VideoQuit = EPOC_VideoQuit;	device->AllocHWSurface = EPOC_AllocHWSurface;	device->CheckHWBlit = NULL;	device->FillHWRect = NULL;	device->SetHWColorKey = NULL;	device->SetHWAlpha = NULL;	device->LockHWSurface = EPOC_LockHWSurface;	device->UnlockHWSurface = EPOC_UnlockHWSurface;	device->FlipHWSurface = EPOC_FlipHWSurface;	device->FreeHWSurface = EPOC_FreeHWSurface;	device->SetIcon = NULL;	device->SetCaption = NULL;	device->GetWMInfo = NULL;	device->FreeWMCursor = EPOC_FreeWMCursor;	device->CreateWMCursor = EPOC_CreateWMCursor;	device->ShowWMCursor = EPOC_ShowWMCursor;	device->WarpWMCursor = NULL;	device->InitOSKeymap = EPOC_InitOSKeymap;	device->PumpEvents = EPOC_PumpEvents;	device->free = EPOC_DeleteDevice;	return device;}VideoBootStrap EPOC_bootstrap = {	"epoc\0\0\0", "EPOC system",    EPOC_Available, EPOC_CreateDevice};void DisableKeyBlocking(_THIS)    {    EpocSdlEnv::Request(EpocSdlEnv::EDisableKeyBlocking);    }void ConstructWindowL(_THIS)	{	SDL_TRACE("SDL:ConstructWindowL");	DisableKeyBlocking(_this); //disable key blocking	}		int EPOC_VideoInit(_THIS, SDL_PixelFormat *vformat)	{    /* Construct Epoc window */    ConstructWindowL(_this);    /* Initialise Epoc frame buffer */      const TDisplayMode displayMode = EpocSdlEnv::DisplayMode();    /* The "best" video format should be returned to caller. */    vformat->BitsPerPixel 	= TDisplayModeUtils::NumDisplayModeBitsPerPixel(displayMode);    vformat->BytesPerPixel  = TDisplayModeUtils::NumDisplayModeBitsPerPixel(displayMode) / 8;     //??   Private->iWindow->PointerFilter(EPointerFilterDrag, 0);     Private->iScreenPos = TPoint(0, 0);        Private->iRect.x = Private->iScreenPos.iX;    Private->iRect.y = Private->iScreenPos.iY;        const TSize sz = EpocSdlEnv::WindowSize();        Private->iRect.w = sz.iWidth;    Private->iRect.h = sz.iHeight;	Private->iRectPtr = &Private->iRect;	return(0);	}SDL_Rect **EPOC_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags)	{	if(flags & SDL_HWSURFACE)		{		if(format->BytesPerPixel != 4) //in HW only full color is supported			return NULL;		}	if(flags & SDL_FULLSCREEN)		{		return &Private->iRectPtr;		}    return (SDL_Rect **)(-1); //everythingisok, unless too small shoes	}int EPOC_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors)	{	if ((firstcolor+ncolors) > 256)		return -1;	TUint32 palette[256];	const TDisplayMode mode = EpocSdlEnv::DisplayMode();    if(TDisplayModeUtils::NumDisplayModeColors(mode) == 4096)        {	// Set 12 bit palette

⌨️ 快捷键说明

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