annotate src/video/epoc/SDL_epocvideo.cpp @ 1338:604d73db6802

Removed uses of stdlib.h and string.h
author Sam Lantinga <slouken@libsdl.org>
date Tue, 07 Feb 2006 09:29:18 +0000
parents 3692456e7b0f
children c71e05b4dc2e
rev   line source
173
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1 /*
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2 SDL - Simple DirectMedia Layer
297
f6ffac90895c Updated copyright information for 2002
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
3 Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002 Sam Lantinga
173
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5 This library is free software; you can redistribute it and/or
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
6 modify it under the terms of the GNU Library General Public
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
7 License as published by the Free Software Foundation; either
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
8 version 2 of the License, or (at your option) any later version.
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
9
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
10 This library is distributed in the hope that it will be useful,
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
13 Library General Public License for more details.
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
14
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
15 You should have received a copy of the GNU Library General Public
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
16 License along with this library; if not, write to the Free
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
18
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
19 Sam Lantinga
252
e8157fcb3114 Updated the source with the correct e-mail address
Sam Lantinga <slouken@libsdl.org>
parents: 173
diff changeset
20 slouken@libsdl.org
173
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
21 */
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
22
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
23 /*
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
24 SDL_epocvideo.cpp
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
25 Epoc based SDL video driver implementation
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
26
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
27 Epoc version by Hannu Viitala (hannu.j.viitala@mbnet.fi)
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
28 */
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
29
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
30
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
31
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
32 extern "C" {
1338
604d73db6802 Removed uses of stdlib.h and string.h
Sam Lantinga <slouken@libsdl.org>
parents: 1336
diff changeset
33 #include "SDL_stdlib.h"
604d73db6802 Removed uses of stdlib.h and string.h
Sam Lantinga <slouken@libsdl.org>
parents: 1336
diff changeset
34 #include "SDL_string.h"
173
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
35 #include "SDL_error.h"
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
36 #include "SDL_timer.h"
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
37 #include "SDL_video.h"
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
38 #undef NULL
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
39 #include "SDL_pixels_c.h"
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
40 };
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
41
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
42 #include "SDL_epocvideo.h"
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
43 #include "SDL_epocevents_c.h"
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
44
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
45 #include <hal.h>
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
46 #include <coedef.h>
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
47
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
48 /* For debugging */
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
49
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
50 void RDebug_Print_b(char* error_str, void* param)
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
51 {
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
52 TBuf8<128> error8((TUint8*)error_str);
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
53 TBuf<128> error;
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
54 error.Copy(error8);
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
55 if (param) //!! Do not work if the parameter is really 0!!
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
56 RDebug::Print(error, param);
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
57 else
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
58 RDebug::Print(error);
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
59 }
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
60
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
61 extern "C" void RDebug_Print(char* error_str, void* param)
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
62 {
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
63 RDebug_Print_b(error_str, param);
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
64 }
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
65
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
66
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
67 int Debug_AvailMem2()
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
68 {
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
69 //User::CompressAllHeaps();
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
70 TMemoryInfoV1Buf membuf;
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
71 User::LeaveIfError(UserHal::MemoryInfo(membuf));
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
72 TMemoryInfoV1 minfo = membuf();
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
73 return(minfo.iFreeRamInBytes);
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
74 }
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
75
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
76 extern "C" int Debug_AvailMem()
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
77 {
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
78 return(Debug_AvailMem2());
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
79 }
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
80
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
81
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
82 extern "C" {
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
83
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
84 /* Initialization/Query functions */
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
85
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
86 static int EPOC_VideoInit(_THIS, SDL_PixelFormat *vformat);
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
87 static SDL_Rect **EPOC_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags);
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
88 static SDL_Surface *EPOC_SetVideoMode(_THIS, SDL_Surface *current, int width, int height, int bpp, Uint32 flags);
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
89 static int EPOC_SetColors(_THIS, int firstcolor, int ncolors,
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
90 SDL_Color *colors);
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
91 static void EPOC_VideoQuit(_THIS);
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
92
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
93 /* Hardware surface functions */
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
94
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
95 static int EPOC_AllocHWSurface(_THIS, SDL_Surface *surface);
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
96 static int EPOC_LockHWSurface(_THIS, SDL_Surface *surface);
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
97 static int EPOC_FlipHWSurface(_THIS, SDL_Surface *surface);
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
98 static void EPOC_UnlockHWSurface(_THIS, SDL_Surface *surface);
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
99 static void EPOC_FreeHWSurface(_THIS, SDL_Surface *surface);
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
100 static void EPOC_DirectUpdate(_THIS, int numrects, SDL_Rect *rects);
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
101
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
102 static int EPOC_Available(void);
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
103 static SDL_VideoDevice *EPOC_CreateDevice(int devindex);
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
104
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
105 /* Mouse functions */
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
106
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
107 static WMcursor *EPOC_CreateWMCursor(_THIS, Uint8 *data, Uint8 *mask, int w, int h, int hot_x, int hot_y);
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
108 static void EPOC_FreeWMCursor(_THIS, WMcursor *cursor);
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
109 static int EPOC_ShowWMCursor(_THIS, WMcursor *cursor);
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
110
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
111
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
112
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
113 /* !! Table for fast conversion from 8 bit to 12 bit */
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
114 static TUint16 EPOC_HWPalette_256_to_4k[256];
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
115
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
116 VideoBootStrap EPOC_bootstrap = {
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
117 "epoc", "EPOC system",
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
118 EPOC_Available, EPOC_CreateDevice
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
119 };
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
120
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
121 const TUint32 WindowClientHandle = 9210; //!!
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
122
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
123 /* Epoc video driver bootstrap functions */
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
124
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
125 static int EPOC_Available(void)
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
126 {
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
127 return 1; /* Always available */
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
128 }
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
129
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
130 static void EPOC_DeleteDevice(SDL_VideoDevice *device)
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
131 {
1336
3692456e7b0f Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
132 SDL_free(device->hidden);
3692456e7b0f Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
133 SDL_free(device);
173
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
134 }
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
135
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
136 static SDL_VideoDevice *EPOC_CreateDevice(int devindex)
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
137 {
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
138 SDL_VideoDevice *device;
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
139
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
140 /* Allocate all variables that we free on delete */
1336
3692456e7b0f Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
141 device = (SDL_VideoDevice *)SDL_malloc(sizeof(SDL_VideoDevice));
173
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
142 if ( device ) {
1336
3692456e7b0f Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
143 SDL_memset(device, 0, (sizeof *device));
173
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
144 device->hidden = (struct SDL_PrivateVideoData *)
1336
3692456e7b0f Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
145 SDL_malloc((sizeof *device->hidden));
173
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
146 }
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
147 if ( (device == NULL) || (device->hidden == NULL) ) {
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
148 SDL_OutOfMemory();
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
149 if ( device ) {
1336
3692456e7b0f Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
150 SDL_free(device);
173
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
151 }
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
152 return(0);
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
153 }
1336
3692456e7b0f Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
154 SDL_memset(device->hidden, 0, (sizeof *device->hidden));
173
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
155
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
156 /* Set the function pointers */
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
157 device->VideoInit = EPOC_VideoInit;
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
158 device->ListModes = EPOC_ListModes;
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
159 device->SetVideoMode = EPOC_SetVideoMode;
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
160 device->SetColors = EPOC_SetColors;
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
161 device->UpdateRects = NULL;
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
162 device->VideoQuit = EPOC_VideoQuit;
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
163 device->AllocHWSurface = EPOC_AllocHWSurface;
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
164 device->CheckHWBlit = NULL;
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
165 device->FillHWRect = NULL;
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
166 device->SetHWColorKey = NULL;
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
167 device->SetHWAlpha = NULL;
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
168 device->LockHWSurface = EPOC_LockHWSurface;
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
169 device->UnlockHWSurface = EPOC_UnlockHWSurface;
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
170 device->FlipHWSurface = EPOC_FlipHWSurface;
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
171 device->FreeHWSurface = EPOC_FreeHWSurface;
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
172 device->SetIcon = NULL;
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
173 device->SetCaption = NULL;
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
174 device->GetWMInfo = NULL;
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
175 device->FreeWMCursor = EPOC_FreeWMCursor;
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
176 device->CreateWMCursor = EPOC_CreateWMCursor;
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
177 device->ShowWMCursor = EPOC_ShowWMCursor;
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
178 device->WarpWMCursor = NULL;
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
179 device->InitOSKeymap = EPOC_InitOSKeymap;
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
180 device->PumpEvents = EPOC_PumpEvents;
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
181 device->free = EPOC_DeleteDevice;
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
182
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
183 return device;
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
184 }
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
185
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
186
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
187 int GetBpp(TDisplayMode displaymode)
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
188 {
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
189 TInt numColors = TDisplayModeUtils::NumDisplayModeColors(displaymode);
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
190 TInt bitsPerPixel = 1;
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
191 for (TInt32 i = 2; i < numColors; i <<= 1, bitsPerPixel++);
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
192 return bitsPerPixel;
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
193 }
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
194
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
195 void ConstructWindowL(_THIS)
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
196 {
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
197 TInt error;
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
198
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
199 error = Private->EPOC_WsSession.Connect();
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
200 User::LeaveIfError(error);
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
201 Private->EPOC_WsScreen=new(ELeave) CWsScreenDevice(Private->EPOC_WsSession);
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
202 User::LeaveIfError(Private->EPOC_WsScreen->Construct());
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
203 User::LeaveIfError(Private->EPOC_WsScreen->CreateContext(Private->EPOC_WindowGc));
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
204
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
205 Private->EPOC_WsWindowGroup=RWindowGroup(Private->EPOC_WsSession);
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
206 User::LeaveIfError(Private->EPOC_WsWindowGroup.Construct(WindowClientHandle));
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
207 Private->EPOC_WsWindowGroup.SetOrdinalPosition(0);
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
208
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
209 //!!
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
210 TBuf<32> winGroupName;
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
211 winGroupName.Append(0);
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
212 winGroupName.Append(0);
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
213 winGroupName.Append(0);// uid
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
214 winGroupName.Append(0);
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
215 winGroupName.Append(_L("SDL")); // caption
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
216 winGroupName.Append(0);
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
217 winGroupName.Append(0); //doc name
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
218 Private->EPOC_WsWindowGroup.SetName(winGroupName); //!!
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
219
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
220 Private->EPOC_WsWindow=RWindow(Private->EPOC_WsSession);
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
221 User::LeaveIfError(Private->EPOC_WsWindow.Construct(Private->EPOC_WsWindowGroup,WindowClientHandle));
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
222 Private->EPOC_WsWindow.SetBackgroundColor(KRgbWhite);
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
223 Private->EPOC_WsWindow.Activate();
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
224 Private->EPOC_WsWindow.SetSize(Private->EPOC_WsScreen->SizeInPixels());
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
225 Private->EPOC_WsWindow.SetVisible(ETrue);
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
226
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
227 Private->EPOC_WsWindowGroupID = Private->EPOC_WsWindowGroup.Identifier();
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
228 Private->EPOC_IsWindowFocused = EFalse;
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
229 }
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
230
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
231
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
232 int EPOC_VideoInit(_THIS, SDL_PixelFormat *vformat)
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
233 {
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
234 // !!TODO:handle leave functions!
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
235
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
236 int i;
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
237
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
238 /* Initialize all variables that we clean on shutdown */
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
239
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
240 for ( i=0; i<SDL_NUMMODES; ++i ) {
1336
3692456e7b0f Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
241 Private->SDL_modelist[i] = (SDL_Rect *)SDL_malloc(sizeof(SDL_Rect));
173
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
242 Private->SDL_modelist[i]->x = Private->SDL_modelist[i]->y = 0;
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
243 }
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
244 /* Modes sorted largest to smallest !!TODO:sorting order??*/
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
245 Private->SDL_modelist[0]->w = 640; Private->SDL_modelist[0]->h = 200;
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
246 Private->SDL_modelist[1]->w = 320; Private->SDL_modelist[1]->h = 200;
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
247 Private->SDL_modelist[2]->w = 640; Private->SDL_modelist[2]->h = 400;
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
248 Private->SDL_modelist[3]->w = 640; Private->SDL_modelist[3]->h = 480;
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
249 Private->SDL_modelist[4] = NULL;
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
250
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
251 /* Construct Epoc window */
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
252
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
253 ConstructWindowL(_this);
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
254
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
255 /* Initialise Epoc frame buffer */
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
256
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
257 TDisplayMode displayMode = Private->EPOC_WsScreen->DisplayMode();
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
258
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
259 #ifndef __WINS__
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
260
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
261 TScreenInfoV01 screenInfo;
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
262 TPckg<TScreenInfoV01> sInfo(screenInfo);
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
263 UserSvr::ScreenInfo(sInfo);
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
264
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
265 Private->EPOC_ScreenSize = screenInfo.iScreenSize;
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
266 Private->EPOC_DisplayMode = displayMode;
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
267 Private->EPOC_HasFrameBuffer = screenInfo.iScreenAddressValid;
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
268 Private->EPOC_FrameBuffer = Private->EPOC_HasFrameBuffer ? (TUint8*) screenInfo.iScreenAddress : NULL;
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
269 Private->EPOC_BytesPerPixel = ((GetBpp(displayMode)-1) / 8) + 1;
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
270 Private->EPOC_BytesPerScanLine = screenInfo.iScreenSize.iWidth * Private->EPOC_BytesPerPixel;
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
271
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
272 /* It seems that in SA1100 machines for 8bpp displays there is a 512 palette table at the
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
273 * beginning of the frame buffer. E.g. Series 7 and Netbook.
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
274 * In 12 bpp machines the table has 16 entries.
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
275 */
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
276 if (Private->EPOC_HasFrameBuffer && GetBpp(displayMode) == 8)
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
277 Private->EPOC_FrameBuffer += 512;
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
278 if (Private->EPOC_HasFrameBuffer && GetBpp(displayMode) == 12)
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
279 Private->EPOC_FrameBuffer += 16 * 2;
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
280
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
281 #else /* defined __WINS__ */
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
282
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
283 /* Create bitmap, device and context for screen drawing */
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
284 Private->EPOC_ScreenSize = Private->EPOC_WsScreen->SizeInPixels();
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
285
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
286 Private->EPOC_Bitmap = new (ELeave) CWsBitmap(Private->EPOC_WsSession);
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
287 Private->EPOC_Bitmap->Create(Private->EPOC_ScreenSize, displayMode);
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
288
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
289 Private->EPOC_DisplayMode = displayMode;
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
290 Private->EPOC_HasFrameBuffer = ETrue;
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
291 Private->EPOC_FrameBuffer = NULL; /* Private->EPOC_Bitmap->DataAddress() can change any time */
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
292 Private->EPOC_BytesPerPixel = ((GetBpp(displayMode)-1) / 8) + 1;
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
293 Private->EPOC_BytesPerScanLine = Private->EPOC_WsScreen->SizeInPixels().iWidth * Private->EPOC_BytesPerPixel;
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
294
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
295 #endif /* __WINS__ */
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
296
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
297 /* The "best" video format should be returned to caller. */
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
298
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
299 vformat->BitsPerPixel = /*!!GetBpp(displayMode) */ 8;
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
300 vformat->BytesPerPixel = /*!!Private->EPOC_BytesPerPixel*/ 1;
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
301
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
302 /* Activate events for me */
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
303
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
304 Private->EPOC_WsEventStatus = KRequestPending;
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
305 Private->EPOC_WsSession.EventReady(&Private->EPOC_WsEventStatus);
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
306 Private->EPOC_RedrawEventStatus = KRequestPending;
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
307 Private->EPOC_WsSession.RedrawReady(&Private->EPOC_RedrawEventStatus);
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
308 Private->EPOC_WsWindow.PointerFilter(EPointerFilterDrag, 0);
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
309
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
310 Private->EPOC_ScreenOffset = 0;
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
311
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
312 //!! TODO: error handling
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
313 //if (ret != KErrNone)
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
314 // return(-1);
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
315 //else
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
316 return(0);
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
317 }
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
318
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
319
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
320 SDL_Rect **EPOC_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags)
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
321 {
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
322 if (format->BitsPerPixel == 12 || format->BitsPerPixel == 8)
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
323 return Private->SDL_modelist;
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
324 return NULL;
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
325 }
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
326
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
327 int EPOC_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors)
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
328 {
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
329 for(int i = firstcolor; i < ncolors; i++) {
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
330 // 4k value: 000rgb
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
331 TUint16 color4K = 0;
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
332 color4K |= (colors[i].r & 0x0000f0) << 4;
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
333 color4K |= (colors[i].g & 0x0000f0);
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
334 color4K |= (colors[i].b & 0x0000f0) >> 4;
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
335 EPOC_HWPalette_256_to_4k[i] = color4K;
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
336 }
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
337 return(0);
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
338 }
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
339
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
340
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
341 SDL_Surface *EPOC_SetVideoMode(_THIS, SDL_Surface *current,
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
342 int width, int height, int bpp, Uint32 flags)
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
343 {
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
344 /* Check parameters */
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
345 if (!((width == 640 && height == 200 && bpp == 12) ||
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
346 (width == 640 && height == 400 && bpp == 12) ||
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
347 (width == 640 && height == 480 && bpp == 12) ||
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
348 (width == 320 && height == 200 && bpp == 12) ||
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
349 (width == 640 && height == 200 && bpp == 8) ||
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
350 (width == 640 && height == 400 && bpp == 8) ||
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
351 (width == 640 && height == 480 && bpp == 8) ||
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
352 (width == 320 && height == 200 && bpp == 8))) {
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
353 SDL_SetError("Requested video mode is not supported");
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
354 return NULL;
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
355 }
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
356
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
357 if (current && current->pixels) {
1336
3692456e7b0f Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
358 SDL_free(current->pixels);
173
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
359 current->pixels = NULL;
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
360 }
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
361 if ( ! SDL_ReallocFormat(current, bpp, 0, 0, 0, 0) ) {
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
362 return(NULL);
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
363 }
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
364
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
365 /* Set up the new mode framebuffer */
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
366 if (bpp == 8)
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
367 current->flags = (SDL_FULLSCREEN|SDL_SWSURFACE|SDL_PREALLOC|SDL_HWPALETTE);
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
368 else // 12 bpp
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
369 current->flags = (SDL_FULLSCREEN|SDL_SWSURFACE|SDL_PREALLOC);
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
370 current->w = width;
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
371 current->h = height;
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
372 int numBytesPerPixel = ((bpp-1)>>3) + 1;
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
373 current->pitch = numBytesPerPixel * width; // Number of bytes in scanline
1336
3692456e7b0f Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
374 current->pixels = SDL_malloc(width * height * numBytesPerPixel);
3692456e7b0f Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
375 SDL_memset(current->pixels, 0, width * height * numBytesPerPixel);
173
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
376
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
377 /* Set the blit function */
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
378 _this->UpdateRects = EPOC_DirectUpdate;
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
379
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
380 /* Must buffer height be shrinked to screen by 2 ? */
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
381 if (current->h >= 400)
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
382 Private->EPOC_ShrinkedHeight = ETrue;
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
383
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
384 /* Centralize game window on device screen */
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
385 Private->EPOC_ScreenOffset = (Private->EPOC_ScreenSize.iWidth - current->w) / 2;
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
386
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
387 /* We're done */
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
388 return(current);
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
389 }
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
390
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
391 void RedrawWindowL(_THIS)
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
392 {
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
393 SDL_Rect fullScreen;
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
394 fullScreen.x = 0;
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
395 fullScreen.y = 0;
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
396 fullScreen.w = _this->screen->w;
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
397 fullScreen.h = _this->screen->h;
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
398
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
399 #ifdef __WINS__
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
400 TBitmapUtil lock(Private->EPOC_Bitmap);
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
401 lock.Begin(TPoint(0,0)); // Lock bitmap heap
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
402 Private->EPOC_WindowGc->Activate(Private->EPOC_WsWindow);
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
403 #endif
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
404
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
405 if (fullScreen.w < Private->EPOC_ScreenSize.iWidth
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
406 && fullScreen.w < Private->EPOC_ScreenSize.iWidth) {
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
407 /* Draw blue stripes background */
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
408 #ifdef __WINS__
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
409 TUint16* screenBuffer = (TUint16*)Private->EPOC_Bitmap->DataAddress();
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
410 #else
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
411 TUint16* screenBuffer = (TUint16*)Private->EPOC_FrameBuffer;
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
412 #endif
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
413 for (int y=0; y < Private->EPOC_ScreenSize.iHeight; y++) {
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
414 for (int x=0; x < Private->EPOC_ScreenSize.iWidth; x++) {
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
415 TUint16 color = ((x+y)>>1) & 0xf; /* Draw pattern */
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
416 *screenBuffer++ = color;
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
417 }
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
418 }
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
419 }
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
420
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
421
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
422 /* Tell the system that something has been drawn */
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
423 TRect rect = TRect(Private->EPOC_WsWindow.Size());
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
424 Private->EPOC_WsWindow.Invalidate(rect);
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
425
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
426 #ifdef __WINS__
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
427 Private->EPOC_WsWindow.BeginRedraw(rect);
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
428 Private->EPOC_WindowGc->BitBlt(TPoint(), Private->EPOC_Bitmap);
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
429 Private->EPOC_WsWindow.EndRedraw();
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
430 Private->EPOC_WindowGc->Deactivate();
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
431 lock.End(); // Unlock bitmap heap
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
432 Private->EPOC_WsSession.Flush();
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
433 #endif
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
434
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
435 /* Draw current buffer */
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
436 EPOC_DirectUpdate(_this, 1, &fullScreen);
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
437 }
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
438
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
439
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
440 /* We don't actually allow hardware surfaces other than the main one */
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
441 static int EPOC_AllocHWSurface(_THIS, SDL_Surface *surface)
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
442 {
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
443 return(-1);
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
444 }
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
445 static void EPOC_FreeHWSurface(_THIS, SDL_Surface *surface)
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
446 {
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
447 return;
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
448 }
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
449
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
450 static int EPOC_LockHWSurface(_THIS, SDL_Surface *surface)
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
451 {
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
452 return(0);
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
453 }
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
454 static void EPOC_UnlockHWSurface(_THIS, SDL_Surface *surface)
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
455 {
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
456 return;
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
457 }
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
458
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
459 static int EPOC_FlipHWSurface(_THIS, SDL_Surface *surface)
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
460 {
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
461 return(0);
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
462 }
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
463
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
464 static void EPOC_DirectUpdate(_THIS, int numrects, SDL_Rect *rects)
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
465 {
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
466 TInt focusWindowGroupId = Private->EPOC_WsSession.GetFocusWindowGroup();
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
467 if (focusWindowGroupId != Private->EPOC_WsWindowGroupID) {
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
468
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
469 /* Force focus window to redraw again for cleaning away SDL screen graphics */
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
470
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
471
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
472 TInt pos = Private->EPOC_WsWindowGroup.OrdinalPosition();
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
473 Private->EPOC_WsWindowGroup.SetOrdinalPosition(0, KMaxTInt);
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
474 TRect rect = TRect(Private->EPOC_WsWindow.Size());
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
475 Private->EPOC_WsWindow.Invalidate(rect);
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
476 Private->EPOC_WsWindowGroup.SetOrdinalPosition(pos, ECoeWinPriorityNormal);
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
477
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
478 /* If this is not the topmost window, wait here! Sleep for 1 second to give cpu to
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
479 multitasking and poll for being the topmost window.
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
480 */
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
481 while (Private->EPOC_WsSession.GetFocusWindowGroup() != Private->EPOC_WsWindowGroupID)
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
482 SDL_Delay(1000);
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
483
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
484 RedrawWindowL(_this);
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
485 }
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
486
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
487 TInt i;
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
488 TInt sourceNumBytesPerPixel = ((_this->screen->format->BitsPerPixel-1)>>3) + 1;
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
489 TInt targetNumBytesPerPixel = Private->EPOC_BytesPerPixel;
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
490 TInt fixedOffset = Private->EPOC_ScreenOffset;
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
491 TInt screenW = _this->screen->w;
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
492 TInt screenH = _this->screen->h;
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
493 TInt sourceScanlineLength = screenW;
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
494 if (Private->EPOC_ShrinkedHeight) { /* simulate 400 pixel height in 200 pixel screen */
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
495 sourceScanlineLength <<= 1;
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
496 screenH >>= 1;
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
497 }
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
498 TInt targetScanlineLength = Private->EPOC_ScreenSize.iWidth;
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
499 #ifdef __WINS__
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
500 TBitmapUtil lock(Private->EPOC_Bitmap);
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
501 lock.Begin(TPoint(0,0)); // Lock bitmap heap
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
502 Private->EPOC_WindowGc->Activate(Private->EPOC_WsWindow);
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
503 TUint16* screenBuffer = (TUint16*)Private->EPOC_Bitmap->DataAddress();
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
504 #else
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
505 TUint16* screenBuffer = (TUint16*)Private->EPOC_FrameBuffer;
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
506 #endif
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
507
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
508
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
509 /* Render the rectangles in the list */
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
510
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
511 for ( i=0; i < numrects; ++i ) {
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
512 SDL_Rect rect2;
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
513 const SDL_Rect& currentRect = rects[i];
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
514 rect2.x = currentRect.x;
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
515 rect2.y = currentRect.y;
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
516 rect2.w = currentRect.w;
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
517 rect2.h = currentRect.h;
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
518
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
519 if (rect2.w <= 0 || rect2.h <= 0) /* sanity check */
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
520 continue;
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
521
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
522 if (Private->EPOC_ShrinkedHeight) { /* simulate 400 pixel height in 200 pixel screen */
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
523 rect2.y >>= 1;
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
524 if (!(rect2.h >>= 1))
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
525 rect2.h = 1; // always at least 1 pixel height!
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
526 }
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
527
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
528 /* All variables are measured in pixels */
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
529
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
530 /* Check rects validity, i.e. upper and lower bounds */
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
531 TInt maxX = Min(screenW - 1, rect2.x + rect2.w - 1);
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
532 TInt maxY = Min(screenH - 1, rect2.y + rect2.h - 1);
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
533 if (maxX < 0 || maxY < 0) /* sanity check */
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
534 continue;
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
535 maxY = Min(maxY, 199);
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
536
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
537 TInt sourceRectWidth = maxX - rect2.x + 1;
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
538 TInt sourceRectWidthInBytes = sourceRectWidth * sourceNumBytesPerPixel;
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
539 TInt sourceRectHeight = maxY - rect2.y + 1;
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
540 TInt sourceStartOffset = rect2.x + rect2.y * sourceScanlineLength;
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
541 TInt targetStartOffset = fixedOffset + rect2.x + rect2.y * targetScanlineLength;
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
542
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
543 // !! Nokia9210 native mode: 12 bpp --> 12 bpp
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
544 if (_this->screen->format->BitsPerPixel == 12) {
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
545 TUint16* bitmapLine = (TUint16*)_this->screen->pixels + sourceStartOffset;
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
546 TUint16* screenMemory = screenBuffer + targetStartOffset;
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
547 for(TInt y = 0 ; y < sourceRectHeight ; y++) {
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
548 __ASSERT_DEBUG(screenMemory < (screenBuffer
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
549 + Private->EPOC_ScreenSize.iWidth * Private->EPOC_ScreenSize.iHeight),
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
550 User::Panic(_L("SDL"), KErrCorrupt));
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
551 __ASSERT_DEBUG(screenMemory >= screenBuffer,
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
552 User::Panic(_L("SDL"), KErrCorrupt));
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
553 __ASSERT_DEBUG(bitmapLine < ((TUint16*)_this->screen->pixels +
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
554 + (_this->screen->w * _this->screen->h)),
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
555 User::Panic(_L("SDL"), KErrCorrupt));
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
556 __ASSERT_DEBUG(bitmapLine >= (TUint16*)_this->screen->pixels,
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
557 User::Panic(_L("SDL"), KErrCorrupt));
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
558 Mem::Copy(screenMemory, bitmapLine, sourceRectWidthInBytes);
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
559 bitmapLine += sourceScanlineLength;
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
560 screenMemory += targetScanlineLength;
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
561 }
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
562 }
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
563 // !! 256 color paletted mode: 8 bpp --> 12 bpp
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
564 else {
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
565 TUint8* bitmapLine = (TUint8*)_this->screen->pixels + sourceStartOffset;
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
566 TUint16* screenMemory = screenBuffer + targetStartOffset;
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
567 for(TInt y = 0 ; y < sourceRectHeight ; y++) {
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
568 TUint8* bitmapPos = bitmapLine; /* 1 byte per pixel */
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
569 TUint16* screenMemoryLinePos = screenMemory; /* 2 bytes per pixel */
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
570 /* Convert each pixel from 256 palette to 4k color values */
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
571 for(TInt x = 0 ; x < sourceRectWidth ; x++) {
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
572 __ASSERT_DEBUG(screenMemoryLinePos < (screenBuffer
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
573 + (Private->EPOC_ScreenSize.iWidth * Private->EPOC_ScreenSize.iHeight)),
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
574 User::Panic(_L("SDL"), KErrCorrupt));
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
575 __ASSERT_DEBUG(screenMemoryLinePos >= screenBuffer,
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
576 User::Panic(_L("SDL"), KErrCorrupt));
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
577 __ASSERT_DEBUG(bitmapPos < ((TUint8*)_this->screen->pixels +
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
578 + (_this->screen->w * _this->screen->h)),
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
579 User::Panic(_L("SDL"), KErrCorrupt));
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
580 __ASSERT_DEBUG(bitmapPos >= (TUint8*)_this->screen->pixels,
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
581 User::Panic(_L("SDL"), KErrCorrupt));
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
582 *screenMemoryLinePos = EPOC_HWPalette_256_to_4k[*bitmapPos];
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
583 bitmapPos++;
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
584 screenMemoryLinePos++;
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
585 }
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
586 bitmapLine += sourceScanlineLength;
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
587 screenMemory += targetScanlineLength;
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
588 }
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
589 }
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
590
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
591 }
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
592
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
593 #ifdef __WINS__
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
594
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
595 TRect rect = TRect(Private->EPOC_WsWindow.Size());
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
596 Private->EPOC_WsWindow.Invalidate(rect);
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
597 Private->EPOC_WsWindow.BeginRedraw(rect);
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
598 Private->EPOC_WindowGc->BitBlt(TPoint(), Private->EPOC_Bitmap);
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
599 Private->EPOC_WsWindow.EndRedraw();
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
600 Private->EPOC_WindowGc->Deactivate();
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
601 lock.End(); // Unlock bitmap heap
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
602 Private->EPOC_WsSession.Flush();
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
603
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
604 #endif
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
605
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
606 /* Update virtual cursor */
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
607 //!!Private->EPOC_WsSession.SetPointerCursorPosition(Private->EPOC_WsSession.PointerCursorPosition());
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
608
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
609 return;
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
610 }
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
611
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
612
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
613 /* Note: If we are terminated, this could be called in the middle of
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
614 another SDL video routine -- notably UpdateRects.
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
615 */
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
616 void EPOC_VideoQuit(_THIS)
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
617 {
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
618 int i;
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
619
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
620 /* Free video mode lists */
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
621 for ( i=0; i<SDL_NUMMODES; ++i ) {
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
622 if ( Private->SDL_modelist[i] != NULL ) {
1336
3692456e7b0f Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
623 SDL_free(Private->SDL_modelist[i]);
173
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
624 Private->SDL_modelist[i] = NULL;
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
625 }
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
626 }
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
627
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
628 if ( _this->screen && (_this->screen->flags & SDL_HWSURFACE) ) {
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
629 /* Direct screen access, no memory buffer */
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
630 _this->screen->pixels = NULL;
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
631 }
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
632
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
633 if (_this->screen && _this->screen->pixels) {
1336
3692456e7b0f Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
634 SDL_free(_this->screen->pixels);
173
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
635 _this->screen->pixels = NULL;
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
636 }
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
637
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
638 /* Free Epoc resources */
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
639
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
640 /* Disable events for me */
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
641 if (Private->EPOC_WsEventStatus != KRequestPending)
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
642 Private->EPOC_WsSession.EventReadyCancel();
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
643 if (Private->EPOC_RedrawEventStatus != KRequestPending)
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
644 Private->EPOC_WsSession.RedrawReadyCancel();
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
645
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
646 #ifdef __WINS__
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
647 delete Private->EPOC_Bitmap;
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
648 Private->EPOC_Bitmap = NULL;
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
649 #endif
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
650
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
651 if (Private->EPOC_WsWindow.WsHandle())
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
652 Private->EPOC_WsWindow.Close();
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
653
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
654 if (Private->EPOC_WsWindowGroup.WsHandle())
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
655 Private->EPOC_WsWindowGroup.Close();
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
656
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
657 delete Private->EPOC_WindowGc;
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
658 Private->EPOC_WindowGc = NULL;
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
659
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
660 delete Private->EPOC_WsScreen;
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
661 Private->EPOC_WsScreen = NULL;
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
662
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
663 if (Private->EPOC_WsSession.WsHandle())
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
664 Private->EPOC_WsSession.Close();
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
665 }
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
666
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
667
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
668 WMcursor *EPOC_CreateWMCursor(_THIS, Uint8 *data, Uint8 *mask, int w, int h, int hot_x, int hot_y)
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
669 {
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
670 return (WMcursor *) 9210; // it's ok to return something unuseful but true
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
671 }
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
672
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
673 void EPOC_FreeWMCursor(_THIS, WMcursor *cursor)
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
674 {
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
675 /* Disable virtual cursor */
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
676 HAL::Set(HAL::EMouseState, HAL::EMouseState_Invisible);
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
677 Private->EPOC_WsSession.SetPointerCursorMode(EPointerCursorNone);
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
678 }
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
679
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
680 int EPOC_ShowWMCursor(_THIS, WMcursor *cursor)
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
681 {
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
682
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
683 if (cursor == (WMcursor *)9210) {
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
684 /* Enable virtual cursor */
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
685 HAL::Set(HAL::EMouseState, HAL::EMouseState_Visible);
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
686 Private->EPOC_WsSession.SetPointerCursorMode(EPointerCursorNormal);
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
687 }
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
688 else {
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
689 /* Disable virtual cursor */
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
690 HAL::Set(HAL::EMouseState, HAL::EMouseState_Invisible);
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
691 Private->EPOC_WsSession.SetPointerCursorMode(EPointerCursorNone);
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
692 }
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
693
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
694 return(1);
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
695 }
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
696
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
697 }; // extern "C"
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
698