19682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/* 29682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL - Simple DirectMedia Layer 39682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Copyright (C) 1997-2012 Sam Lantinga 49682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 59682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall This library is free software; you can redistribute it and/or 69682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall modify it under the terms of the GNU Library General Public 79682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall License as published by the Free Software Foundation; either 89682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall version 2 of the License, or (at your option) any later version. 99682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 109682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall This library is distributed in the hope that it will be useful, 119682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall but WITHOUT ANY WARRANTY; without even the implied warranty of 129682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 139682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Library General Public License for more details. 149682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 159682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall You should have received a copy of the GNU Library General Public 169682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall License along with this library; if not, write to the Free 179682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 189682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 199682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Sam Lantinga 209682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall slouken@devolution.com 219682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall*/ 229682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 239682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/* 249682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_epocvideo.cpp 259682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Epoc based SDL video driver implementation 269682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 279682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Markus Mertama 289682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall*/ 299682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 309682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 319682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 329682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include "epoc_sdl.h" 339682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 349682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include <stdlib.h> 359682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include <stdio.h> 369682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include <string.h> 379682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 389682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallextern "C" { 399682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include "SDL_error.h" 409682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include "SDL_timer.h" 419682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include "SDL_video.h" 429682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#undef NULL 439682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include "SDL_pixels_c.h" 449682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include "SDL.h" 459682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include "SDL_mouse.h" 469682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} 479682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 489682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include "SDL_epocvideo.h" 499682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include "SDL_epocevents_c.h" 509682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 519682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 529682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 539682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include <coedef.h> 549682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include <flogger.h> 559682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 569682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include <eikenv.h> 579682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include <eikappui.h> 589682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include <eikapp.h> 599682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include "sdlepocapi.h" 609682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 619682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 629682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall//////////////////////////////////////////////////////////////// 639682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 649682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 659682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 669682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 679682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall_LIT(KLibName, "SDL"); 689682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 699682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallvoid RDebug_Print_b(char* error_str, void* param) 709682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 719682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall TBuf8<128> error8((TUint8*)error_str); 729682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall TBuf<128> error; 739682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall error.Copy(error8); 749682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 759682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#ifndef TRACE_TO_FILE 769682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (param) //!! Do not work if the parameter is really 0!! 779682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall RDebug::Print(error, param); 789682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall else 799682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall RDebug::Print(error); 809682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#else 819682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (param) //!! Do not work if the parameter is really 0!! 829682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall RFileLogger::WriteFormat(KLibName, _L("SDL.txt"), EFileLoggingModeAppend, error, param); 839682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall else 849682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall RFileLogger::Write(KLibName, _L("SDL.txt"), EFileLoggingModeAppend, error); 859682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#endif 869682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 879682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 889682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 899682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallextern "C" void RDebug_Print(char* error_str, void* param) 909682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 919682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall RDebug_Print_b(error_str, param); 929682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 939682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 949682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/* 959682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallint Debug_AvailMem2() 969682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 979682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall //User::CompressAllHeaps(); 989682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall TMemoryInfoV1Buf membuf; 999682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall User::LeaveIfError(UserHal::MemoryInfo(membuf)); 1009682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall TMemoryInfoV1 minfo = membuf(); 1019682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return(minfo.iFreeRamInBytes); 1029682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 1039682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1049682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallextern "C" int Debug_AvailMem() 1059682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 1069682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return(Debug_AvailMem2()); 1079682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 1089682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1099682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall*/ 1109682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1119682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallextern "C" { 1129682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1139682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/* Initialization/Query functions */ 1149682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1159682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic int EPOC_VideoInit(_THIS, SDL_PixelFormat *vformat); 1169682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic SDL_Rect **EPOC_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags); 1179682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic SDL_Surface *EPOC_SetVideoMode(_THIS, SDL_Surface *current, int width, int height, int bpp, Uint32 flags); 1189682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic int EPOC_SetColors(_THIS, int firstcolor, int ncolors, 1199682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_Color *colors); 1209682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic void EPOC_VideoQuit(_THIS); 1219682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1229682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/* Hardware surface functions */ 1239682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1249682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic int EPOC_AllocHWSurface(_THIS, SDL_Surface *surface); 1259682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic int EPOC_LockHWSurface(_THIS, SDL_Surface *surface); 1269682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic int EPOC_FlipHWSurface(_THIS, SDL_Surface *surface); 1279682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic void EPOC_UnlockHWSurface(_THIS, SDL_Surface *surface); 1289682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic void EPOC_FreeHWSurface(_THIS, SDL_Surface *surface); 1299682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic void EPOC_DirectUpdate(_THIS, int numrects, SDL_Rect *rects); 1309682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1319682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic int EPOC_Available(void); 1329682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic SDL_VideoDevice *EPOC_CreateDevice(int devindex); 1339682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1349682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallvoid DrawBackground(_THIS); 1359682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallvoid DirectDraw(_THIS, int numrects, SDL_Rect *rects, TUint16* screenBuffer); 1369682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallvoid DirectDrawRotated(_THIS, int numrects, SDL_Rect *rects, TUint16* screenBuffer); 1379682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1389682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/* Mouse functions */ 1399682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1409682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic WMcursor *EPOC_CreateWMCursor(_THIS, Uint8 *data, Uint8 *mask, int w, int h, int hot_x, int hot_y); 1419682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic void EPOC_FreeWMCursor(_THIS, WMcursor *cursor); 1429682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic int EPOC_ShowWMCursor(_THIS, WMcursor *cursor); 1439682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} 1449682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1459682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1469682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallextern "C" 1479682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 1489682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall struct WMcursor 1499682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 1509682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall }; 1519682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 1529682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1539682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/* Epoc video driver bootstrap functions */ 1549682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1559682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1569682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic int EPOC_Available(void) 1579682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 1589682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return 1; /* Always available */ 1599682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 1609682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1619682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic void EPOC_DeleteDevice(SDL_VideoDevice *device) 1629682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 1639682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall User::Free(device->hidden); 1649682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall User::Free(device); 1659682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 1669682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1679682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic SDL_VideoDevice *EPOC_CreateDevice(int /*devindex*/) 1689682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 1699682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_VideoDevice *device; 1709682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1719682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_TRACE("SDL:EPOC_CreateDevice"); 1729682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1739682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* Allocate all variables that we free on delete */ 1749682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall device = static_cast<SDL_VideoDevice*>(User::Alloc(sizeof(SDL_VideoDevice))); 1759682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( device ) 1769682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 1779682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Mem::FillZ(device, (sizeof *device)); 1789682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall device->hidden = static_cast<struct SDL_PrivateVideoData*> 1799682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall (User::Alloc((sizeof *device->hidden))); 1809682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 1819682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( (device == NULL) || (device->hidden == NULL) ) 1829682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 1839682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_OutOfMemory(); 1849682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( device ) { 1859682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall User::Free(device); 1869682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 1879682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return(0); 1889682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 1899682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Mem::FillZ(device->hidden, (sizeof *device->hidden)); 1909682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1919682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* Set the function pointers */ 1929682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall device->VideoInit = EPOC_VideoInit; 1939682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall device->ListModes = EPOC_ListModes; 1949682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall device->SetVideoMode = EPOC_SetVideoMode; 1959682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall device->SetColors = EPOC_SetColors; 1969682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall device->UpdateRects = NULL; 1979682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall device->VideoQuit = EPOC_VideoQuit; 1989682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall device->AllocHWSurface = EPOC_AllocHWSurface; 1999682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall device->CheckHWBlit = NULL; 2009682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall device->FillHWRect = NULL; 2019682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall device->SetHWColorKey = NULL; 2029682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall device->SetHWAlpha = NULL; 2039682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall device->LockHWSurface = EPOC_LockHWSurface; 2049682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall device->UnlockHWSurface = EPOC_UnlockHWSurface; 2059682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall device->FlipHWSurface = EPOC_FlipHWSurface; 2069682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall device->FreeHWSurface = EPOC_FreeHWSurface; 2079682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall device->SetIcon = NULL; 2089682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall device->SetCaption = NULL; 2099682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall device->GetWMInfo = NULL; 2109682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall device->FreeWMCursor = EPOC_FreeWMCursor; 2119682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall device->CreateWMCursor = EPOC_CreateWMCursor; 2129682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall device->ShowWMCursor = EPOC_ShowWMCursor; 2139682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall device->WarpWMCursor = NULL; 2149682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall device->InitOSKeymap = EPOC_InitOSKeymap; 2159682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall device->PumpEvents = EPOC_PumpEvents; 2169682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall device->free = EPOC_DeleteDevice; 2179682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 2189682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return device; 2199682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} 2209682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 2219682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 2229682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse HallVideoBootStrap EPOC_bootstrap = { 2239682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall "epoc\0\0\0", "EPOC system", 2249682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall EPOC_Available, EPOC_CreateDevice 2259682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall}; 2269682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 2279682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 2289682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 2299682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallvoid DisableKeyBlocking(_THIS) 2309682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 2319682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall EpocSdlEnv::Request(EpocSdlEnv::EDisableKeyBlocking); 2329682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 2339682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 2349682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallvoid ConstructWindowL(_THIS) 2359682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 2369682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_TRACE("SDL:ConstructWindowL"); 2379682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall DisableKeyBlocking(_this); //disable key blocking 2389682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 2399682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 2409682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 2419682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallint EPOC_VideoInit(_THIS, SDL_PixelFormat *vformat) 2429682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 2439682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* Construct Epoc window */ 2449682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 2459682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall ConstructWindowL(_this); 2469682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 2479682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* Initialise Epoc frame buffer */ 2489682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 2499682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 2509682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall const TDisplayMode displayMode = EpocSdlEnv::DisplayMode(); 2519682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 2529682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* The "best" video format should be returned to caller. */ 2539682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 2549682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall vformat->BitsPerPixel = TDisplayModeUtils::NumDisplayModeBitsPerPixel(displayMode); 2559682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall vformat->BytesPerPixel = TDisplayModeUtils::NumDisplayModeBitsPerPixel(displayMode) / 8; 2569682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 2579682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 2589682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall //?? Private->iWindow->PointerFilter(EPointerFilterDrag, 0); 2599682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 2609682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Private->iScreenPos = TPoint(0, 0); 2619682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 2629682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Private->iRect.x = Private->iScreenPos.iX; 2639682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Private->iRect.y = Private->iScreenPos.iY; 2649682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 2659682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall const TSize sz = EpocSdlEnv::WindowSize(); 2669682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 2679682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Private->iRect.w = sz.iWidth; 2689682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Private->iRect.h = sz.iHeight; 2699682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Private->iRectPtr = &Private->iRect; 2709682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 2719682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return(0); 2729682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 2739682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 2749682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 2759682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse HallSDL_Rect **EPOC_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags) 2769682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 2779682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if(flags & SDL_HWSURFACE) 2789682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 2799682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if(format->BytesPerPixel != 4) //in HW only full color is supported 2809682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return NULL; 2819682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 2829682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if(flags & SDL_FULLSCREEN) 2839682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 2849682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return &Private->iRectPtr; 2859682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 2869682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return (SDL_Rect **)(-1); //everythingisok, unless too small shoes 2879682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 2889682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 2899682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 2909682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallint EPOC_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors) 2919682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 2929682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ((firstcolor+ncolors) > 256) 2939682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return -1; 2949682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall TUint32 palette[256]; 2959682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall const TDisplayMode mode = EpocSdlEnv::DisplayMode(); 2969682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if(TDisplayModeUtils::NumDisplayModeColors(mode) == 4096) 2979682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 2989682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall // Set 12 bit palette 2999682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall for(int i = firstcolor; i < ncolors; i++) 3009682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 3019682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall // 4k value: 0000 rrrr gggg bbbb 3029682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall TUint32 color4K = (colors[i].r & 0x0000f0) << 4; 3039682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall color4K |= (colors[i].g & 0x0000f0); 3049682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall color4K |= (colors[i].b & 0x0000f0) >> 4; 3059682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall palette[i] = color4K; 3069682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 3079682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 3089682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall else if(TDisplayModeUtils::NumDisplayModeColors(mode) == 65536) 3099682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 3109682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall for(int i = firstcolor; i < ncolors; i++) 3119682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 3129682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall // 64k-colour displays effectively support RGB values 3139682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall // with 5 bits allocated to red, 6 to green and 5 to blue 3149682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall // 64k value: rrrr rggg gggb bbbb 3159682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall TUint32 color64K = (colors[i].r & 0x0000f8) << 8; 3169682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall color64K |= (colors[i].g & 0x0000fc) << 3; 3179682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall color64K |= (colors[i].b & 0x0000f8) >> 3; 3189682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall palette[i] = color64K; 3199682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 3209682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 3219682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall else if(TDisplayModeUtils::NumDisplayModeColors(mode) == 16777216) 3229682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 3239682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall for(int i = firstcolor; i < ncolors; i++) 3249682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 3259682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall // 16M-colour 3269682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall //0000 0000 rrrr rrrr gggg gggg bbbb bbbb 3279682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall TUint32 color16M = colors[i].r << 16; 3289682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall color16M |= colors[i].g << 8; 3299682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall color16M |= colors[i].b; 3309682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall palette[i] = color16M; 3319682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 3329682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 3339682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall else 3349682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 3359682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return -2; 3369682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 3379682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if(EpocSdlEnv::SetPalette(firstcolor, ncolors, palette) == KErrNone) 3389682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return 0; 3399682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return -1; 3409682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 3419682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 3429682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 3439682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/* 3449682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallvoid AllocHWSurfaceL(CFbsBitmap*& aBitmap, const TDisplayMode& aMode, const TSize& aSize) 3459682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 3469682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall aBitmap = new (ELeave) CFbsBitmap(); 3479682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if(KErrNone != aBitmap->CreateHardwareBitmap(aSize, aMode, 3489682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall EpocSdlEnv::EikonEnv().EikAppUi()->Application()->AppDllUid())) 3499682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall //...if it fails - should we use wsbitmaps??? 3509682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall {//the good reason to use hw bitmaps is that they wont need lock heap 3519682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall PANIC_IF_ERROR(aBitmap->Create(aSize, aMode)); 3529682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 3539682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 3549682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 3559682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallint CreateSurfaceL(_THIS, SDL_Surface* surface) 3569682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 3579682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall __ASSERT_ALWAYS(Private->iFrame == NULL, PANIC(KErrAlreadyExists)); 3589682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall; 3599682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall TInt dmode = EColorLast; 3609682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 3619682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall TDisplayMode displayMode; 3629682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall EpocSdlEnv::GetDiplayMode(displayMode); 3639682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 3649682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if( 3659682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall TDisplayModeUtils::NumDisplayModeBitsPerPixel(displayMode) 3669682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall == surface->format->BitsPerPixel) 3679682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 3689682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall dmode = displayMode; 3699682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 3709682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall else 3719682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 3729682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall --dmode; 3739682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall while(TDisplayModeUtils::IsDisplayModeColor(TDisplayMode(dmode)) && 3749682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall TDisplayModeUtils::NumDisplayModeBitsPerPixel(TDisplayMode(dmode)) != 3759682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall surface->format->BitsPerPixel) 3769682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall --dmode; 3779682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 3789682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 3799682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall __ASSERT_ALWAYS(TDisplayModeUtils::IsDisplayModeColor(TDisplayMode(dmode)), PANIC(KErrNotSupported)); 3809682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall TRAPD(err, AllocHWSurfaceL(Private->iFrame, TDisplayMode(dmode), TSize(surface->w, surface->h))); 3819682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return err == KErrNone ? 0 : -1; 3829682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 3839682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall*/ 3849682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 3859682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse HallTDisplayMode GetDisplayMode(TInt aBitsPerPixel) 3869682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 3879682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall const TDisplayMode displayMode = EpocSdlEnv::DisplayMode(); 3889682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall TInt dmode = EColorLast; 3899682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if( 3909682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall TDisplayModeUtils::NumDisplayModeBitsPerPixel(displayMode) 3919682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall == aBitsPerPixel) 3929682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 3939682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall dmode = displayMode; 3949682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 3959682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall else 3969682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 3979682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall --dmode; 3989682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall while(TDisplayModeUtils::IsDisplayModeColor(TDisplayMode(dmode)) && 3999682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall TDisplayModeUtils::NumDisplayModeBitsPerPixel(TDisplayMode(dmode)) != 4009682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall aBitsPerPixel) 4019682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall --dmode; 4029682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 4039682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return TDisplayMode(dmode); 4049682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 4059682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 4069682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse HallSDL_Surface *EPOC_SetVideoMode(_THIS, SDL_Surface *current, 4079682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall int width, int height, int bpp, Uint32 flags) 4089682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 4099682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall const TSize screenSize = EpocSdlEnv::WindowSize(TSize(width, height)); 4109682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if(width > screenSize.iWidth || height > screenSize.iHeight) 4119682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 4129682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if(flags & SDL_FULLSCREEN) 4139682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 4149682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall width = screenSize.iWidth; 4159682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall height = screenSize.iHeight; 4169682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 4179682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall else 4189682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return NULL; 4199682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 4209682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 4219682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if(current && current->pixels) 4229682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 4239682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall // free(current->pixels); 4249682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall current->pixels = NULL; 4259682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 4269682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 4279682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if(!SDL_ReallocFormat(current, bpp, 0, 0, 0, 0)) 4289682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 4299682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return(NULL); 4309682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 4319682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 4329682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall current->flags = 0; 4339682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if(width == screenSize.iWidth && height == screenSize.iHeight) 4349682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall current->flags |= SDL_FULLSCREEN; 4359682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 4369682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall const int numBytesPerPixel = ((bpp-1)>>3) + 1; 4379682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall current->pitch = numBytesPerPixel * width; // Number of bytes in scanline 4389682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 4399682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* Set up the new mode framebuffer */ 4409682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall current->flags |= SDL_PREALLOC; 4419682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 4429682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if(bpp <= 8) 4439682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall current->flags |= SDL_HWPALETTE; 4449682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 4459682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall User::Free(Private->iSwSurface); 4469682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall current->pixels = NULL; 4479682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Private->iSwSurface = NULL; 4489682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 4499682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if(flags & SDL_HWSURFACE) 4509682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 4519682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall current->flags |= SDL_HWSURFACE; 4529682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall // current->pixels = NULL; 4539682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall // Private->iSwSurface = NULL; 4549682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 4559682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall else 4569682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 4579682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall current->flags |= SDL_SWSURFACE; 4589682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall const TInt surfacesize = width * height * numBytesPerPixel; 4599682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Private->iSwSurfaceSize = TSize(width, height); 4609682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall delete Private->iSwSurface; 4619682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Private->iSwSurface = NULL; 4629682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall current->pixels = (TUint8*) User::AllocL(surfacesize); 4639682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Private->iSwSurface = (TUint8*) current->pixels; 4649682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall const TInt err = EpocSdlEnv::AllocSwSurface 4659682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall (TSize(width, height), GetDisplayMode(current->format->BitsPerPixel)); 4669682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if(err != KErrNone) 4679682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return NULL; 4689682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 4699682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 4709682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall current->w = width; 4719682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall current->h = height; 4729682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 4739682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 4749682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 4759682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* Set the blit function */ 4769682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall _this->UpdateRects = EPOC_DirectUpdate; 4779682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 4789682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* 4799682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall * Logic for getting suitable screen dimensions, offset, scaling and orientation 4809682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall */ 4819682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 4829682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 4839682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* Centralize game window on device screen */ 4849682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 4859682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 4869682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Private->iScreenPos.iX = Max(0, (screenSize.iWidth - width) / 2); 4879682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Private->iScreenPos.iY = Max(0, (screenSize.iHeight - height) / 2); 4889682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 4899682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall // delete (Private->iFrame); 4909682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall// Private->iFrame = NULL; 4919682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 4929682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall // TRAPD(err, CreateSurfaceL(_this, current)); 4939682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall // PANIC_IF_ERROR(err); 4949682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 4959682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_TRACE1("View width %d", width); 4969682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_TRACE1("View height %d", height); 4979682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_TRACE1("View bmode %d", bpp); 4989682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_TRACE1("View x %d", Private->iScreenPos.iX); 4999682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_TRACE1("View y %d", Private->iScreenPos.iY); 5009682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 5019682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall EpocSdlEnv::LockPalette(EFalse); 5029682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* We're done */ 5039682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return(current); 5049682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} 5059682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 5069682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 5079682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 5089682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic int EPOC_AllocHWSurface(_THIS, SDL_Surface* surface) 5099682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 5109682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return KErrNone == EpocSdlEnv::AllocHwSurface(TSize(surface->w, surface->h), GetDisplayMode(surface->format->BitsPerPixel)); 5119682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 5129682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 5139682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic void EPOC_FreeHWSurface(_THIS, SDL_Surface* /*surface*/) 5149682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 5159682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 5169682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 5179682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic int EPOC_LockHWSurface(_THIS, SDL_Surface* surface) 5189682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 5199682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if(EpocSdlEnv::IsDsaAvailable()) 5209682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 5219682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall TUint8* address = EpocSdlEnv::LockHwSurface(); 5229682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if(address != NULL) 5239682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 5249682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall surface->pixels = address; 5259682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return 1; 5269682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 5279682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 5289682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return 0; 5299682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 5309682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic void EPOC_UnlockHWSurface(_THIS, SDL_Surface* /*surface*/) 5319682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 5329682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall EpocSdlEnv::UnlockHwSurface(); 5339682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 5349682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 5359682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic int EPOC_FlipHWSurface(_THIS, SDL_Surface* /*surface*/) 5369682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 5379682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return(0); 5389682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 5399682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 5409682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic void EPOC_DirectUpdate(_THIS, int numrects, SDL_Rect *rects) 5419682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 5429682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if(EpocSdlEnv::IsDsaAvailable()) 5439682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 5449682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if(Private->iSwSurface) 5459682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 5469682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall const TRect target(Private->iScreenPos, Private->iSwSurfaceSize); 5479682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall for(TInt i = 0; i < numrects ;i++) 5489682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 5499682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall const TRect rect(TPoint(rects[i].x, rects[i].y), 5509682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall TSize(rects[i].w, rects[i].h)); 5519682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if(!EpocSdlEnv::AddUpdateRect(Private->iSwSurface, rect, target)) 5529682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return; //not succesful 5539682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 5549682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall EpocSdlEnv::UpdateSwSurface(); 5559682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 5569682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_PauseAudio(0); 5579682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 5589682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall else 5599682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 5609682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_PauseAudio(1); 5619682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall EpocSdlEnv::WaitDsaAvailable(); 5629682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 5639682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 5649682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 5659682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 5669682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/* Note: If we are terminated, this could be called in the middle of 5679682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall another SDL video routine -- notably UpdateRects. 5689682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall*/ 5699682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallvoid EPOC_VideoQuit(_THIS) 5709682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 5719682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall// delete Private->iFrame; 5729682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall// Private->iFrame = NULL; 5739682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall User::Free(Private->iSwSurface); 5749682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Private->iSwSurface = NULL; 5759682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall EpocSdlEnv::FreeSurface(); 5769682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 5779682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 5789682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 5799682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 5809682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 5819682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse HallWMcursor *EPOC_CreateWMCursor(_THIS, Uint8* /*data*/, Uint8* /*mask*/, int /*w*/, int /*h*/, int /*hot_x*/, int /*hot_y*/) 5829682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 5839682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return (WMcursor*) 1; //hii! prevents SDL to view a std cursor 5849682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 5859682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 5869682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallvoid EPOC_FreeWMCursor(_THIS, WMcursor* /*cursor*/) 5879682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 5889682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 5899682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 5909682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallint EPOC_ShowWMCursor(_THIS, WMcursor *cursor) 5919682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 5929682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return true; 5939682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 5949682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 595