Mercurial > sdl-ios-xcode
comparison src/video/cybergfx/SDL_cgxvideo.c @ 1662:782fd950bd46 SDL-1.3
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
WARNING: None of the video drivers have been updated for the new API yet! The API is still under design and very fluid.
The code is now run through a consistent indent format:
indent -i4 -nut -nsc -br -ce
The headers are being converted to automatically generate doxygen documentation.
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Sun, 28 May 2006 13:04:16 +0000 |
parents | e49147870aac |
children | 4da1ee79c9af |
comparison
equal
deleted
inserted
replaced
1661:281d3f4870e5 | 1662:782fd950bd46 |
---|---|
41 #include "SDL_amigaevents_c.h" | 41 #include "SDL_amigaevents_c.h" |
42 #include "SDL_cgxmodes_c.h" | 42 #include "SDL_cgxmodes_c.h" |
43 #include "SDL_cgximage_c.h" | 43 #include "SDL_cgximage_c.h" |
44 | 44 |
45 /* Initialization/Query functions */ | 45 /* Initialization/Query functions */ |
46 static int CGX_VideoInit(_THIS, SDL_PixelFormat *vformat); | 46 static int CGX_VideoInit (_THIS, SDL_PixelFormat * vformat); |
47 static SDL_Surface *CGX_SetVideoMode(_THIS, SDL_Surface *current, int width, int height, int bpp, Uint32 flags); | 47 static SDL_Surface *CGX_SetVideoMode (_THIS, SDL_Surface * current, int width, |
48 static int CGX_ToggleFullScreen(_THIS, int on); | 48 int height, int bpp, Uint32 flags); |
49 static void CGX_UpdateMouse(_THIS); | 49 static int CGX_ToggleFullScreen (_THIS, int on); |
50 static int CGX_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors); | 50 static void CGX_UpdateMouse (_THIS); |
51 static void CGX_VideoQuit(_THIS); | 51 static int CGX_SetColors (_THIS, int firstcolor, int ncolors, |
52 SDL_Color * colors); | |
53 static void CGX_VideoQuit (_THIS); | |
52 | 54 |
53 /* CGX driver bootstrap functions */ | 55 /* CGX driver bootstrap functions */ |
54 | 56 |
55 struct Library *CyberGfxBase=NULL; | 57 struct Library *CyberGfxBase = NULL; |
56 struct IntuitionBase *IntuitionBase=NULL; | 58 struct IntuitionBase *IntuitionBase = NULL; |
57 struct GfxBase *GfxBase=NULL; | 59 struct GfxBase *GfxBase = NULL; |
58 | 60 |
59 int CGX_SetGamma(_THIS, float red, float green, float blue) | 61 int |
60 { | 62 CGX_SetGamma (_THIS, float red, float green, float blue) |
61 SDL_SetError("Gamma correction not supported"); | 63 { |
64 SDL_SetError ("Gamma correction not supported"); | |
62 return -1; | 65 return -1; |
63 } | 66 } |
64 | 67 |
65 int CGX_GetGamma(_THIS, float red, float green, float blue) | 68 int |
66 { | 69 CGX_GetGamma (_THIS, float red, float green, float blue) |
67 SDL_SetError("Gamma correction not supported"); | 70 { |
71 SDL_SetError ("Gamma correction not supported"); | |
68 return -1; | 72 return -1; |
69 } | 73 } |
70 | 74 |
71 int CGX_SetGammaRamp(_THIS, Uint16 *ramp) | 75 int |
76 CGX_SetGammaRamp (_THIS, Uint16 * ramp) | |
72 { | 77 { |
73 #if 0 | 78 #if 0 |
74 Int i, ncolors; | 79 Int i, ncolors; |
75 XColor xcmap[256]; | 80 XColor xcmap[256]; |
76 | 81 |
77 /* See if actually setting the gamma is supported */ | 82 /* See if actually setting the gamma is supported */ |
78 if ( SDL_Visual->class != DirectColor ) { | 83 if (SDL_Visual->class != DirectColor) { |
79 SDL_SetError("Gamma correction not supported on this visual"); | 84 SDL_SetError ("Gamma correction not supported on this visual"); |
80 return(-1); | 85 return (-1); |
81 } | 86 } |
82 | 87 |
83 /* Calculate the appropriate palette for the given gamma ramp */ | 88 /* Calculate the appropriate palette for the given gamma ramp */ |
84 ncolors = SDL_Visual->map_entries; | 89 ncolors = SDL_Visual->map_entries; |
85 for ( i=0; i<ncolors; ++i ) { | 90 for (i = 0; i < ncolors; ++i) { |
86 Uint8 c = (256 * i / ncolors); | 91 Uint8 c = (256 * i / ncolors); |
87 xcmap[i].pixel = SDL_MapRGB(this->screen->format, c, c, c); | 92 xcmap[i].pixel = SDL_MapRGB (this->screen->format, c, c, c); |
88 xcmap[i].red = ramp[0*256+c]; | 93 xcmap[i].red = ramp[0 * 256 + c]; |
89 xcmap[i].green = ramp[1*256+c]; | 94 xcmap[i].green = ramp[1 * 256 + c]; |
90 xcmap[i].blue = ramp[2*256+c]; | 95 xcmap[i].blue = ramp[2 * 256 + c]; |
91 xcmap[i].flags = (DoRed|DoGreen|DoBlue); | 96 xcmap[i].flags = (DoRed | DoGreen | DoBlue); |
92 } | 97 } |
93 XStoreColors(GFX_Display, SDL_XColorMap, xcmap, ncolors); | 98 XStoreColors (GFX_Display, SDL_XColorMap, xcmap, ncolors); |
94 XSync(GFX_Display, False); | 99 XSync (GFX_Display, False); |
95 | 100 |
96 return(0); | 101 return (0); |
97 | 102 |
98 #else | 103 #else |
99 SDL_SetError("Gamma correction not supported on this visual"); | 104 SDL_SetError ("Gamma correction not supported on this visual"); |
100 return(-1); | 105 return (-1); |
101 | 106 |
102 #endif | 107 #endif |
103 } | 108 } |
104 | 109 |
105 static void DestroyScreen(_THIS) | 110 static void |
106 { | 111 DestroyScreen (_THIS) |
107 if(currently_fullscreen) | 112 { |
108 { | 113 if (currently_fullscreen) { |
109 if(this->hidden->dbuffer) | 114 if (this->hidden->dbuffer) { |
110 { | 115 extern struct MsgPort *safeport, *dispport; |
111 extern struct MsgPort *safeport,*dispport; | 116 |
112 | 117 this->hidden->dbuffer = 0; |
113 this->hidden->dbuffer=0; | 118 |
114 | 119 if (safeport) { |
115 if(safeport) | 120 while (GetMsg (safeport) != NULL); |
116 { | 121 DeleteMsgPort (safeport); |
117 while(GetMsg(safeport)!=NULL); | 122 } |
118 DeleteMsgPort(safeport); | 123 if (dispport) { |
119 } | 124 while (GetMsg (dispport) != NULL); |
120 if(dispport) | 125 DeleteMsgPort (dispport); |
121 { | 126 } |
122 while(GetMsg(dispport)!=NULL); | 127 |
123 DeleteMsgPort(dispport); | 128 this->hidden->SB[0]->sb_DBufInfo->dbi_SafeMessage. |
124 } | 129 mn_ReplyPort = |
125 | 130 this->hidden->SB[0]->sb_DBufInfo->dbi_DispMessage. |
126 this->hidden->SB[0]->sb_DBufInfo->dbi_SafeMessage.mn_ReplyPort=this->hidden->SB[0]->sb_DBufInfo->dbi_DispMessage.mn_ReplyPort=NULL; | 131 mn_ReplyPort = NULL; |
127 this->hidden->SB[1]->sb_DBufInfo->dbi_SafeMessage.mn_ReplyPort=this->hidden->SB[1]->sb_DBufInfo->dbi_DispMessage.mn_ReplyPort=NULL; | 132 this->hidden->SB[1]->sb_DBufInfo->dbi_SafeMessage. |
128 | 133 mn_ReplyPort = |
129 if(this->hidden->SB[1]) | 134 this->hidden->SB[1]->sb_DBufInfo->dbi_DispMessage. |
130 FreeScreenBuffer(SDL_Display,this->hidden->SB[1]); | 135 mn_ReplyPort = NULL; |
131 if(this->hidden->SB[0]) | 136 |
132 FreeScreenBuffer(SDL_Display,this->hidden->SB[0]); | 137 if (this->hidden->SB[1]) |
133 | 138 FreeScreenBuffer (SDL_Display, this->hidden->SB[1]); |
134 | 139 if (this->hidden->SB[0]) |
135 this->hidden->SB[0]=this->hidden->SB[1]=NULL; | 140 FreeScreenBuffer (SDL_Display, this->hidden->SB[0]); |
136 | 141 |
137 if(SDL_RastPort && SDL_RastPort != &SDL_Display->RastPort) | 142 |
138 SDL_free(SDL_RastPort); | 143 this->hidden->SB[0] = this->hidden->SB[1] = NULL; |
139 | 144 |
140 SDL_RastPort=NULL; | 145 if (SDL_RastPort && SDL_RastPort != &SDL_Display->RastPort) |
141 } | 146 SDL_free (SDL_RastPort); |
142 CloseScreen(GFX_Display); | 147 |
143 currently_fullscreen=0; | 148 SDL_RastPort = NULL; |
144 } | 149 } |
145 else if(GFX_Display) | 150 CloseScreen (GFX_Display); |
146 UnlockPubScreen(NULL,GFX_Display); | 151 currently_fullscreen = 0; |
147 | 152 } else if (GFX_Display) |
148 GFX_Display = NULL; | 153 UnlockPubScreen (NULL, GFX_Display); |
149 } | 154 |
150 | 155 GFX_Display = NULL; |
151 static int CGX_Available(void) | 156 } |
152 { | 157 |
153 struct Library *l; | 158 static int |
154 | 159 CGX_Available (void) |
155 l = OpenLibrary("cybergraphics.library",0L); | 160 { |
156 | 161 struct Library *l; |
157 if ( l != NULL ) { | 162 |
158 D(bug("CGX video device AVAILABLE\n")); | 163 l = OpenLibrary ("cybergraphics.library", 0L); |
159 CloseLibrary(l); | 164 |
160 } | 165 if (l != NULL) { |
161 D(else bug("**CGX video device UNAVAILABLE\n")); | 166 D (bug ("CGX video device AVAILABLE\n")); |
162 | 167 CloseLibrary (l); |
163 return(l != NULL); | 168 } |
164 } | 169 D ( |
165 | 170 else |
166 static void CGX_DeleteDevice(SDL_VideoDevice *device) | 171 bug ("**CGX video device UNAVAILABLE\n")); |
167 { | 172 |
168 if ( device ) { | 173 return (l != NULL); |
169 if ( device->hidden ) { | 174 } |
170 SDL_free(device->hidden); | 175 |
171 } | 176 static void |
172 if ( device->gl_data ) { | 177 CGX_DeleteDevice (SDL_VideoDevice * device) |
173 SDL_free(device->gl_data); | 178 { |
174 } | 179 if (device) { |
175 SDL_free(device); | 180 if (device->hidden) { |
176 } | 181 SDL_free (device->hidden); |
177 } | 182 } |
178 | 183 if (device->gl_data) { |
179 static SDL_VideoDevice *CGX_CreateDevice(int devindex) | 184 SDL_free (device->gl_data); |
180 { | 185 } |
181 SDL_VideoDevice *device; | 186 SDL_free (device); |
182 | 187 } |
183 /* Initialize all variables that we clean on shutdown */ | 188 } |
184 device = (SDL_VideoDevice *)SDL_malloc(sizeof(SDL_VideoDevice)); | 189 |
185 if ( device ) { | 190 static SDL_VideoDevice * |
186 SDL_memset(device, 0, (sizeof *device)); | 191 CGX_CreateDevice (int devindex) |
187 device->hidden = (struct SDL_PrivateVideoData *) | 192 { |
188 SDL_malloc((sizeof *device->hidden)); | 193 SDL_VideoDevice *device; |
189 device->gl_data = (struct SDL_PrivateGLData *) | 194 |
190 SDL_malloc((sizeof *device->gl_data)); | 195 /* Initialize all variables that we clean on shutdown */ |
191 } | 196 device = (SDL_VideoDevice *) SDL_malloc (sizeof (SDL_VideoDevice)); |
192 if ( (device == NULL) || (device->hidden == NULL) || | 197 if (device) { |
193 (device->gl_data == NULL) ) { | 198 SDL_memset (device, 0, (sizeof *device)); |
194 D(bug("Unable to create video device!\n")); | 199 device->hidden = (struct SDL_PrivateVideoData *) |
195 SDL_OutOfMemory(); | 200 SDL_malloc ((sizeof *device->hidden)); |
196 CGX_DeleteDevice(device); | 201 device->gl_data = (struct SDL_PrivateGLData *) |
197 return(0); | 202 SDL_malloc ((sizeof *device->gl_data)); |
198 } | 203 } |
199 SDL_memset(device->hidden, 0, sizeof(*device->hidden)); | 204 if ((device == NULL) || (device->hidden == NULL) || |
200 SDL_memset(device->gl_data, 0, sizeof(*device->gl_data)); | 205 (device->gl_data == NULL)) { |
201 | 206 D (bug ("Unable to create video device!\n")); |
202 /* Set the driver flags */ | 207 SDL_OutOfMemory (); |
203 device->handles_any_size = 1; | 208 CGX_DeleteDevice (device); |
204 | 209 return (0); |
205 /* Set the function pointers */ | 210 } |
206 device->VideoInit = CGX_VideoInit; | 211 SDL_memset (device->hidden, 0, sizeof (*device->hidden)); |
207 device->ListModes = CGX_ListModes; | 212 SDL_memset (device->gl_data, 0, sizeof (*device->gl_data)); |
208 device->SetVideoMode = CGX_SetVideoMode; | 213 |
209 device->ToggleFullScreen = CGX_ToggleFullScreen; | 214 /* Set the driver flags */ |
210 device->UpdateMouse = CGX_UpdateMouse; | 215 device->handles_any_size = 1; |
211 device->SetColors = CGX_SetColors; | 216 |
212 device->UpdateRects = NULL; | 217 /* Set the function pointers */ |
213 device->VideoQuit = CGX_VideoQuit; | 218 device->VideoInit = CGX_VideoInit; |
214 device->AllocHWSurface = CGX_AllocHWSurface; | 219 device->ListModes = CGX_ListModes; |
215 device->CheckHWBlit = CGX_CheckHWBlit; | 220 device->SetVideoMode = CGX_SetVideoMode; |
216 device->FillHWRect = CGX_FillHWRect; | 221 device->ToggleFullScreen = CGX_ToggleFullScreen; |
217 device->SetHWColorKey = CGX_SetHWColorKey; | 222 device->UpdateMouse = CGX_UpdateMouse; |
218 device->SetHWAlpha = NULL; | 223 device->SetColors = CGX_SetColors; |
219 device->LockHWSurface = CGX_LockHWSurface; | 224 device->UpdateRects = NULL; |
220 device->UnlockHWSurface = CGX_UnlockHWSurface; | 225 device->VideoQuit = CGX_VideoQuit; |
221 device->FlipHWSurface = CGX_FlipHWSurface; | 226 device->AllocHWSurface = CGX_AllocHWSurface; |
222 device->FreeHWSurface = CGX_FreeHWSurface; | 227 device->CheckHWBlit = CGX_CheckHWBlit; |
223 device->SetGamma = CGX_SetGamma; | 228 device->FillHWRect = CGX_FillHWRect; |
224 device->GetGamma = CGX_GetGamma; | 229 device->SetHWColorKey = CGX_SetHWColorKey; |
225 device->SetGammaRamp = CGX_SetGammaRamp; | 230 device->SetHWAlpha = NULL; |
226 device->GetGammaRamp = NULL; | 231 device->LockHWSurface = CGX_LockHWSurface; |
232 device->UnlockHWSurface = CGX_UnlockHWSurface; | |
233 device->FlipHWSurface = CGX_FlipHWSurface; | |
234 device->FreeHWSurface = CGX_FreeHWSurface; | |
235 device->SetGamma = CGX_SetGamma; | |
236 device->GetGamma = CGX_GetGamma; | |
237 device->SetGammaRamp = CGX_SetGammaRamp; | |
238 device->GetGammaRamp = NULL; | |
227 #if SDL_VIDEO_OPENGL | 239 #if SDL_VIDEO_OPENGL |
228 device->GL_LoadLibrary = CGX_GL_LoadLibrary; | 240 device->GL_LoadLibrary = CGX_GL_LoadLibrary; |
229 device->GL_GetProcAddress = CGX_GL_GetProcAddress; | 241 device->GL_GetProcAddress = CGX_GL_GetProcAddress; |
230 device->GL_GetAttribute = CGX_GL_GetAttribute; | 242 device->GL_GetAttribute = CGX_GL_GetAttribute; |
231 device->GL_MakeCurrent = CGX_GL_MakeCurrent; | 243 device->GL_MakeCurrent = CGX_GL_MakeCurrent; |
232 device->GL_SwapBuffers = CGX_GL_SwapBuffers; | 244 device->GL_SwapBuffers = CGX_GL_SwapBuffers; |
233 #endif | 245 #endif |
234 device->SetIcon = CGX_SetIcon; | 246 device->SetIcon = CGX_SetIcon; |
235 device->SetCaption = CGX_SetCaption; | 247 device->SetCaption = CGX_SetCaption; |
236 device->IconifyWindow = NULL; /* CGX_IconifyWindow; */ | 248 device->IconifyWindow = NULL; /* CGX_IconifyWindow; */ |
237 device->GrabInput = NULL /* CGX_GrabInput*/; | 249 device->GrabInput = NULL /* CGX_GrabInput */ ; |
238 device->GetWMInfo = CGX_GetWMInfo; | 250 device->GetWMInfo = CGX_GetWMInfo; |
239 device->FreeWMCursor = amiga_FreeWMCursor; | 251 device->FreeWMCursor = amiga_FreeWMCursor; |
240 device->CreateWMCursor = amiga_CreateWMCursor; | 252 device->CreateWMCursor = amiga_CreateWMCursor; |
241 device->ShowWMCursor = amiga_ShowWMCursor; | 253 device->ShowWMCursor = amiga_ShowWMCursor; |
242 device->WarpWMCursor = amiga_WarpWMCursor; | 254 device->WarpWMCursor = amiga_WarpWMCursor; |
243 device->CheckMouseMode = amiga_CheckMouseMode; | 255 device->CheckMouseMode = amiga_CheckMouseMode; |
244 device->InitOSKeymap = amiga_InitOSKeymap; | 256 device->InitOSKeymap = amiga_InitOSKeymap; |
245 device->PumpEvents = amiga_PumpEvents; | 257 device->PumpEvents = amiga_PumpEvents; |
246 | 258 |
247 device->free = CGX_DeleteDevice; | 259 device->free = CGX_DeleteDevice; |
248 | 260 |
249 return device; | 261 return device; |
250 } | 262 } |
251 | 263 |
252 VideoBootStrap CGX_bootstrap = { | 264 VideoBootStrap CGX_bootstrap = { |
253 "CGX", "AmigaOS CyberGraphics", CGX_Available, CGX_CreateDevice | 265 "CGX", "AmigaOS CyberGraphics", CGX_Available, CGX_CreateDevice |
254 }; | 266 }; |
255 | 267 |
256 Uint32 MakeBitMask(_THIS,int type,int format,int *bpp) | 268 Uint32 |
257 { | 269 MakeBitMask (_THIS, int type, int format, int *bpp) |
258 D(if(type==0)bug("REAL pixel format: ")); | 270 { |
259 | 271 D (if (type == 0) bug ("REAL pixel format: ")); |
260 if(this->hidden->depth==*bpp) | 272 |
261 { | 273 if (this->hidden->depth == *bpp) { |
262 | 274 |
263 switch(format) | 275 switch (format) { |
264 { | 276 case PIXFMT_LUT8: |
265 case PIXFMT_LUT8: | 277 D (if (type == 0) bug ("LUT8\n")); |
266 D(if(type==0)bug("LUT8\n")); | 278 return 0; |
267 return 0; | 279 case PIXFMT_BGR15: |
268 case PIXFMT_BGR15: | 280 case PIXFMT_RGB15PC: |
269 case PIXFMT_RGB15PC: | 281 switch (type) { |
270 switch(type) | 282 case 0: |
271 { | 283 D (bug ("RGB15PC/BGR15\n")); |
272 case 0: | 284 return 31; |
273 D(bug("RGB15PC/BGR15\n")); | 285 case 1: |
274 return 31; | 286 return 992; |
275 case 1: | 287 case 2: |
276 return 992; | 288 return 31744; |
277 case 2: | 289 } |
278 return 31744; | 290 case PIXFMT_RGB15: |
279 } | 291 case PIXFMT_BGR15PC: |
280 case PIXFMT_RGB15: | 292 switch (type) { |
281 case PIXFMT_BGR15PC: | 293 case 0: |
282 switch(type) | 294 D (bug ("RGB15/BGR15PC\n")); |
283 { | 295 return 31744; |
284 case 0: | 296 case 1: |
285 D(bug("RGB15/BGR15PC\n")); | 297 return 992; |
286 return 31744; | 298 case 2: |
287 case 1: | 299 return 31; |
288 return 992; | 300 } |
289 case 2: | 301 case PIXFMT_BGR16PC: |
290 return 31; | 302 case PIXFMT_RGB16: |
291 } | 303 switch (type) { |
292 case PIXFMT_BGR16PC: | 304 case 0: |
293 case PIXFMT_RGB16: | 305 D (bug ("RGB16PC\n")); |
294 switch(type) | 306 return 63488; |
295 { | 307 case 1: |
296 case 0: | 308 return 2016; |
297 D(bug("RGB16PC\n")); | 309 case 2: |
298 return 63488; | 310 return 31; |
299 case 1: | 311 } |
300 return 2016; | 312 case PIXFMT_BGR16: |
301 case 2: | 313 case PIXFMT_RGB16PC: |
302 return 31; | 314 switch (type) { |
303 } | 315 case 0: |
304 case PIXFMT_BGR16: | 316 D (bug ("RGB16PC/BGR16\n")); |
305 case PIXFMT_RGB16PC: | 317 return 31; |
306 switch(type) | 318 case 1: |
307 { | 319 return 2016; |
308 case 0: | 320 case 2: |
309 D(bug("RGB16PC/BGR16\n")); | 321 return 63488; |
310 return 31; | 322 } |
311 case 1: | 323 |
312 return 2016; | 324 case PIXFMT_RGB24: |
313 case 2: | 325 switch (type) { |
314 return 63488; | 326 case 0: |
315 } | 327 D (bug ("RGB24/BGR24\n")); |
316 | 328 return 0xff0000; |
317 case PIXFMT_RGB24: | 329 case 1: |
318 switch(type) | 330 return 0xff00; |
319 { | 331 case 2: |
320 case 0: | 332 return 0xff; |
321 D(bug("RGB24/BGR24\n")); | 333 } |
322 return 0xff0000; | 334 case PIXFMT_BGR24: |
323 case 1: | 335 switch (type) { |
324 return 0xff00; | 336 case 0: |
325 case 2: | 337 D (bug ("BGR24\n")); |
326 return 0xff; | 338 return 0xff; |
327 } | 339 case 1: |
328 case PIXFMT_BGR24: | 340 return 0xff00; |
329 switch(type) | 341 case 2: |
330 { | 342 return 0xff0000; |
331 case 0: | 343 } |
332 D(bug("BGR24\n")); | 344 case PIXFMT_ARGB32: |
333 return 0xff; | 345 switch (type) { |
334 case 1: | 346 case 0: |
335 return 0xff00; | 347 D (bug ("ARGB32\n")); |
336 case 2: | 348 return 0xff0000; |
337 return 0xff0000; | 349 case 1: |
338 } | 350 return 0xff00; |
339 case PIXFMT_ARGB32: | 351 case 2: |
340 switch(type) | 352 return 0xff; |
341 { | 353 } |
342 case 0: | 354 case PIXFMT_BGRA32: |
343 D(bug("ARGB32\n")); | 355 switch (type) { |
344 return 0xff0000; | 356 case 0: |
345 case 1: | 357 D (bug ("BGRA32\n")); |
346 return 0xff00; | 358 return 0xff00; |
347 case 2: | 359 case 1: |
348 return 0xff; | 360 return 0xff0000; |
349 } | 361 case 2: |
350 case PIXFMT_BGRA32: | 362 return 0xff000000; |
351 switch(type) | 363 } |
352 { | 364 case PIXFMT_RGBA32: |
353 case 0: | 365 switch (type) { |
354 D(bug("BGRA32\n")); | 366 case 0: |
355 return 0xff00; | 367 D (bug ("RGBA32\n")); |
356 case 1: | 368 return 0xff000000; |
357 return 0xff0000; | 369 case 1: |
358 case 2: | 370 return 0xff0000; |
359 return 0xff000000; | 371 case 2: |
360 } | 372 return 0xff00; |
361 case PIXFMT_RGBA32: | 373 } |
362 switch(type) | 374 default: |
363 { | 375 D (bug ("Unknown pixel format! Default to 24bit\n")); |
364 case 0: | 376 return (Uint32) (255 << (type * 8)); |
365 D(bug("RGBA32\n")); | 377 } |
366 return 0xff000000; | 378 } else { |
367 case 1: | 379 D (if (type == 0) |
368 return 0xff0000; | 380 bug ("DIFFERENT from screen.\nAllocated screen format: ")); |
369 case 2: | 381 |
370 return 0xff00; | 382 switch (*bpp) { |
371 } | 383 case 32: |
372 default: | 384 D (if (type == 0) bug ("RGBA32\n")); |
373 D(bug("Unknown pixel format! Default to 24bit\n")); | 385 switch (type) { |
374 return (Uint32) (255<<(type*8)); | 386 case 0: |
375 } | 387 return 0xff000000; |
376 } | 388 case 1: |
377 else | 389 return 0xff0000; |
378 { | 390 case 2: |
379 D(if(type==0)bug("DIFFERENT from screen.\nAllocated screen format: ")); | 391 return 0xff00; |
380 | 392 } |
381 switch(*bpp) | 393 break; |
382 { | 394 case 24: |
383 case 32: | 395 use_truecolor: |
384 D(if(type==0) bug("RGBA32\n")); | 396 switch (type) { |
385 switch(type) | 397 case 0: |
386 { | 398 D (bug ("RGB24\n")); |
387 case 0: | 399 return 0xff0000; |
388 return 0xff000000; | 400 case 1: |
389 case 1: | 401 return 0xff00; |
390 return 0xff0000; | 402 case 2: |
391 case 2: | 403 return 0xff; |
392 return 0xff00; | 404 } |
393 } | 405 case 16: |
394 break; | 406 case 15: |
395 case 24: | 407 D (if (type == 0) |
396 use_truecolor: | 408 bug ("Not supported, switching to 24bit!\n")); |
397 switch(type) | 409 *bpp = 24; |
398 { | 410 goto use_truecolor; |
399 case 0: | 411 break; |
400 D(bug("RGB24\n")); | 412 default: |
401 return 0xff0000; | 413 D (if (type == 0) bug ("This is a chunky display\n")); |
402 case 1: | |
403 return 0xff00; | |
404 case 2: | |
405 return 0xff; | |
406 } | |
407 case 16: | |
408 case 15: | |
409 D(if(type==0) bug("Not supported, switching to 24bit!\n")); | |
410 *bpp=24; | |
411 goto use_truecolor; | |
412 break; | |
413 default: | |
414 D(if(type==0)bug("This is a chunky display\n")); | |
415 // For chunky display mask is always 0; | 414 // For chunky display mask is always 0; |
416 return 0; | 415 return 0; |
417 } | 416 } |
418 } | 417 } |
419 return 0; | 418 return 0; |
420 } | 419 } |
421 | 420 |
422 static int CGX_VideoInit(_THIS, SDL_PixelFormat *vformat) | 421 static int |
423 { | 422 CGX_VideoInit (_THIS, SDL_PixelFormat * vformat) |
424 int i; | 423 { |
425 struct Library *RTGBase; | 424 int i; |
426 | 425 struct Library *RTGBase; |
427 D(bug("VideoInit... Opening libraries\n")); | 426 |
428 | 427 D (bug ("VideoInit... Opening libraries\n")); |
429 if(!IntuitionBase) { | 428 |
430 if( !(IntuitionBase=(struct IntuitionBase *)OpenLibrary("intuition.library",39L))) { | 429 if (!IntuitionBase) { |
431 SDL_SetError("Couldn't open intuition V39+"); | 430 if (! |
432 return -1; | 431 (IntuitionBase = |
433 } | 432 (struct IntuitionBase *) OpenLibrary ("intuition.library", |
434 } | 433 39L))) { |
435 | 434 SDL_SetError ("Couldn't open intuition V39+"); |
436 if(!GfxBase) { | 435 return -1; |
437 if( !(GfxBase=(struct GfxBase *)OpenLibrary("graphics.library",39L))) { | 436 } |
438 SDL_SetError("Couldn't open graphics V39+"); | 437 } |
439 return -1; | 438 |
440 } | 439 if (!GfxBase) { |
441 } | 440 if (! |
442 | 441 (GfxBase = |
443 if(!CyberGfxBase) { | 442 (struct GfxBase *) OpenLibrary ("graphics.library", 39L))) { |
444 if( !(CyberGfxBase=OpenLibrary("cybergraphics.library",40L))) { | 443 SDL_SetError ("Couldn't open graphics V39+"); |
445 SDL_SetError("Couldn't open cybergraphics."); | 444 return -1; |
446 return(-1); | 445 } |
447 } | 446 } |
448 } | 447 |
449 | 448 if (!CyberGfxBase) { |
450 if(RTGBase=OpenLibrary("libs:picasso96/rtg.library",0L)) { | 449 if (!(CyberGfxBase = OpenLibrary ("cybergraphics.library", 40L))) { |
451 extern int use_picasso96; | 450 SDL_SetError ("Couldn't open cybergraphics."); |
452 | 451 return (-1); |
453 CloseLibrary(RTGBase); | 452 } |
454 use_picasso96=1; | 453 } |
455 } | 454 |
456 | 455 if (RTGBase = OpenLibrary ("libs:picasso96/rtg.library", 0L)) { |
457 D(bug("Library intialized, locking screen...\n")); | 456 extern int use_picasso96; |
458 | 457 |
459 SDL_Display = LockPubScreen(NULL); | 458 CloseLibrary (RTGBase); |
460 | 459 use_picasso96 = 1; |
461 if ( SDL_Display == NULL ) { | 460 } |
462 D(bug("Cannot lock display...\n")); | 461 |
463 SDL_SetError("Couldn't lock the display"); | 462 D (bug ("Library intialized, locking screen...\n")); |
464 return(-1); | 463 |
465 } | 464 SDL_Display = LockPubScreen (NULL); |
466 this->info.current_w = SDL_Display->Width; | 465 |
467 this->info.current_h = SDL_Display->Height; | 466 if (SDL_Display == NULL) { |
468 | 467 D (bug ("Cannot lock display...\n")); |
469 D(bug("Checking if we are using a CGX native display...\n")); | 468 SDL_SetError ("Couldn't lock the display"); |
470 | 469 return (-1); |
471 if(!IsCyberModeID(GetVPModeID(&SDL_Display->ViewPort))) | 470 } |
472 { | 471 this->info.current_w = SDL_Display->Width; |
473 Uint32 okid=BestCModeIDTags(CYBRBIDTG_NominalWidth,SDL_Display->Width, | 472 this->info.current_h = SDL_Display->Height; |
474 CYBRBIDTG_NominalHeight,SDL_Display->Height, | 473 |
475 CYBRBIDTG_Depth,8, | 474 D (bug ("Checking if we are using a CGX native display...\n")); |
476 TAG_DONE); | 475 |
477 | 476 if (!IsCyberModeID (GetVPModeID (&SDL_Display->ViewPort))) { |
478 D(bug("Default visual is not CGX native!\n")); | 477 Uint32 okid = |
479 | 478 BestCModeIDTags (CYBRBIDTG_NominalWidth, SDL_Display->Width, |
480 UnlockPubScreen(NULL,SDL_Display); | 479 CYBRBIDTG_NominalHeight, SDL_Display->Height, |
481 | 480 CYBRBIDTG_Depth, 8, |
482 GFX_Display=NULL; | 481 TAG_DONE); |
483 | 482 |
484 if(okid!=INVALID_ID) | 483 D (bug ("Default visual is not CGX native!\n")); |
485 { | 484 |
486 GFX_Display=OpenScreenTags(NULL, | 485 UnlockPubScreen (NULL, SDL_Display); |
487 SA_Width,SDL_Display->Width, | 486 |
488 SA_Height,SDL_Display->Height, | 487 GFX_Display = NULL; |
489 SA_Depth,8,SA_Quiet,TRUE, | 488 |
490 SA_ShowTitle,FALSE, | 489 if (okid != INVALID_ID) { |
491 SA_DisplayID,okid, | 490 GFX_Display = OpenScreenTags (NULL, |
492 TAG_DONE); | 491 SA_Width, SDL_Display->Width, |
493 } | 492 SA_Height, SDL_Display->Height, |
494 | 493 SA_Depth, 8, SA_Quiet, TRUE, |
495 if(!GFX_Display) | 494 SA_ShowTitle, FALSE, |
496 { | 495 SA_DisplayID, okid, TAG_DONE); |
497 SDL_SetError("Unable to open a suited CGX display"); | 496 } |
498 return -1; | 497 |
499 } | 498 if (!GFX_Display) { |
500 else SDL_Display=GFX_Display; | 499 SDL_SetError ("Unable to open a suited CGX display"); |
501 | 500 return -1; |
502 } | 501 } else |
503 else GFX_Display = SDL_Display; | 502 SDL_Display = GFX_Display; |
504 | 503 |
505 | 504 } else |
506 /* See whether or not we need to swap pixels */ | 505 GFX_Display = SDL_Display; |
507 | 506 |
508 swap_pixels = 0; | 507 |
508 /* See whether or not we need to swap pixels */ | |
509 | |
510 swap_pixels = 0; | |
509 | 511 |
510 // Non e' detto che sia cosi' pero', alcune schede potrebbero gestire i modi in modo differente | 512 // Non e' detto che sia cosi' pero', alcune schede potrebbero gestire i modi in modo differente |
511 | 513 |
512 if ( SDL_BYTEORDER == SDL_LIL_ENDIAN ) { | 514 if (SDL_BYTEORDER == SDL_LIL_ENDIAN) { |
513 swap_pixels = 1; | 515 swap_pixels = 1; |
514 } | 516 } |
515 | 517 |
516 D(bug("Before GetVideoModes....\n")); | 518 D (bug ("Before GetVideoModes....\n")); |
517 | 519 |
518 /* Get the available video modes */ | 520 /* Get the available video modes */ |
519 if(CGX_GetVideoModes(this) < 0) | 521 if (CGX_GetVideoModes (this) < 0) |
520 return -1; | 522 return -1; |
521 | 523 |
522 /* Determine the default screen depth: | 524 /* Determine the default screen depth: |
523 Use the default visual (or at least one with the same depth) */ | 525 Use the default visual (or at least one with the same depth) */ |
524 | 526 |
525 for(i = 0; i < this->hidden->nvisuals; i++) | 527 for (i = 0; i < this->hidden->nvisuals; i++) |
526 if(this->hidden->visuals[i].depth == GetCyberMapAttr(SDL_Display->RastPort.BitMap,CYBRMATTR_DEPTH)) | 528 if (this->hidden->visuals[i].depth == |
527 break; | 529 GetCyberMapAttr (SDL_Display->RastPort.BitMap, CYBRMATTR_DEPTH)) |
528 if(i == this->hidden->nvisuals) { | 530 break; |
529 /* default visual was useless, take the deepest one instead */ | 531 if (i == this->hidden->nvisuals) { |
530 i = 0; | 532 /* default visual was useless, take the deepest one instead */ |
531 } | 533 i = 0; |
532 SDL_Visual = this->hidden->visuals[i].visual; | 534 } |
533 | 535 SDL_Visual = this->hidden->visuals[i].visual; |
534 // SDL_XColorMap = SDL_DisplayColormap; | 536 |
535 | 537 // SDL_XColorMap = SDL_DisplayColormap; |
536 this->hidden->depth = this->hidden->visuals[i].depth; | 538 |
537 D(bug("Init: Setting screen depth to: %ld\n",this->hidden->depth)); | 539 this->hidden->depth = this->hidden->visuals[i].depth; |
538 vformat->BitsPerPixel = this->hidden->visuals[i].depth; /* this->hidden->visuals[i].bpp; */ | 540 D (bug ("Init: Setting screen depth to: %ld\n", this->hidden->depth)); |
539 | 541 vformat->BitsPerPixel = this->hidden->visuals[i].depth; /* this->hidden->visuals[i].bpp; */ |
540 { | 542 |
541 int form; | 543 { |
542 APTR handle; | 544 int form; |
543 struct DisplayInfo info; | 545 APTR handle; |
544 | 546 struct DisplayInfo info; |
545 if(!(handle=FindDisplayInfo(this->hidden->visuals[i].visual))) | 547 |
546 { | 548 if (!(handle = FindDisplayInfo (this->hidden->visuals[i].visual))) { |
547 D(bug("Unable to get visual info...\n")); | 549 D (bug ("Unable to get visual info...\n")); |
548 return -1; | 550 return -1; |
549 } | 551 } |
550 | 552 |
551 if(!GetDisplayInfoData(handle,(char *)&info,sizeof(struct DisplayInfo),DTAG_DISP,NULL)) { | 553 if (!GetDisplayInfoData |
552 D(bug("Unable to get visual info data...\n")); | 554 (handle, (char *) &info, sizeof (struct DisplayInfo), DTAG_DISP, |
553 return -1; | 555 NULL)) { |
554 } | 556 D (bug ("Unable to get visual info data...\n")); |
555 | 557 return -1; |
556 form=GetCyberIDAttr(CYBRIDATTR_PIXFMT,SDL_Visual); | 558 } |
559 | |
560 form = GetCyberIDAttr (CYBRIDATTR_PIXFMT, SDL_Visual); | |
557 | 561 |
558 // In this case I use makebitmask in a way that I'm sure I'll get PIXFMT pixel mask | 562 // In this case I use makebitmask in a way that I'm sure I'll get PIXFMT pixel mask |
559 | 563 |
560 if ( vformat->BitsPerPixel > 8 ) | 564 if (vformat->BitsPerPixel > 8) { |
561 { | 565 vformat->Rmask = |
562 vformat->Rmask = MakeBitMask(this,0,form,&this->hidden->depth); | 566 MakeBitMask (this, 0, form, &this->hidden->depth); |
563 vformat->Gmask = MakeBitMask(this,1,form,&this->hidden->depth); | 567 vformat->Gmask = |
564 vformat->Bmask = MakeBitMask(this,2,form,&this->hidden->depth); | 568 MakeBitMask (this, 1, form, &this->hidden->depth); |
565 } | 569 vformat->Bmask = |
566 } | 570 MakeBitMask (this, 2, form, &this->hidden->depth); |
567 | 571 } |
568 /* See if we have been passed a window to use */ | 572 } |
573 | |
574 /* See if we have been passed a window to use */ | |
569 /* SDL_windowid = SDL_getenv("SDL_WINDOWID"); */ | 575 /* SDL_windowid = SDL_getenv("SDL_WINDOWID"); */ |
570 SDL_windowid=NULL; | 576 SDL_windowid = NULL; |
571 | 577 |
572 /* Create the blank cursor */ | 578 /* Create the blank cursor */ |
573 SDL_BlankCursor = AllocMem(16,MEMF_CHIP|MEMF_CLEAR); | 579 SDL_BlankCursor = AllocMem (16, MEMF_CHIP | MEMF_CLEAR); |
574 | 580 |
575 /* Fill in some window manager capabilities */ | 581 /* Fill in some window manager capabilities */ |
576 this->info.wm_available = 1; | 582 this->info.wm_available = 1; |
577 this->info.blit_hw = 1; | 583 this->info.blit_hw = 1; |
578 this->info.blit_hw_CC = 1; | 584 this->info.blit_hw_CC = 1; |
579 this->info.blit_sw = 1; | 585 this->info.blit_sw = 1; |
580 this->info.blit_fill = 1; | 586 this->info.blit_fill = 1; |
581 this->info.video_mem=2000000; // Not always true but almost any Amiga card has this memory! | 587 this->info.video_mem = 2000000; // Not always true but almost any Amiga card has this memory! |
582 | 588 |
583 this->hidden->same_format=0; | 589 this->hidden->same_format = 0; |
584 SDL_RastPort=&SDL_Display->RastPort; | 590 SDL_RastPort = &SDL_Display->RastPort; |
585 /* We're done! */ | 591 /* We're done! */ |
586 D(bug("End of CGX_VideoInit\n")); | 592 D (bug ("End of CGX_VideoInit\n")); |
587 | 593 |
588 return(0); | 594 return (0); |
589 } | 595 } |
590 | 596 |
591 void CGX_DestroyWindow(_THIS, SDL_Surface *screen) | 597 void |
592 { | 598 CGX_DestroyWindow (_THIS, SDL_Surface * screen) |
593 D(bug("Destroy Window...\n")); | 599 { |
594 | 600 D (bug ("Destroy Window...\n")); |
595 if ( ! SDL_windowid ) { | 601 |
596 /* Hide the managed window */ | 602 if (!SDL_windowid) { |
597 int was_fullscreen=0; | 603 /* Hide the managed window */ |
598 | 604 int was_fullscreen = 0; |
599 /* Clean up OpenGL */ | 605 |
600 if ( screen ) { | 606 /* Clean up OpenGL */ |
601 screen->flags &= ~SDL_INTERNALOPENGL; | 607 if (screen) { |
602 } | 608 screen->flags &= ~SDL_INTERNALOPENGL; |
603 | 609 } |
604 if ( screen && (screen->flags & SDL_FULLSCREEN) ) { | 610 |
605 was_fullscreen=1; | 611 if (screen && (screen->flags & SDL_FULLSCREEN)) { |
606 screen->flags &= ~SDL_FULLSCREEN; | 612 was_fullscreen = 1; |
607 // CGX_LeaveFullScreen(this); tolto x crash | 613 screen->flags &= ~SDL_FULLSCREEN; |
608 } | 614 // CGX_LeaveFullScreen(this); tolto x crash |
609 | 615 } |
610 /* Destroy the output window */ | 616 |
611 if ( SDL_Window ) { | 617 /* Destroy the output window */ |
612 CloseWindow(SDL_Window); | 618 if (SDL_Window) { |
613 SDL_Window=NULL; | 619 CloseWindow (SDL_Window); |
614 } | 620 SDL_Window = NULL; |
615 | 621 } |
616 /* Free the colormap entries */ | 622 |
617 if ( SDL_XPixels ) { | 623 /* Free the colormap entries */ |
618 int numcolors; | 624 if (SDL_XPixels) { |
619 unsigned long pixel; | 625 int numcolors; |
620 | 626 unsigned long pixel; |
621 if(this->screen->format&&this->hidden->depth==8&&!was_fullscreen) | 627 |
622 { | 628 if (this->screen->format && this->hidden->depth == 8 |
623 numcolors = 1<<this->screen->format->BitsPerPixel; | 629 && !was_fullscreen) { |
624 | 630 numcolors = 1 << this->screen->format->BitsPerPixel; |
625 if(numcolors>256) | 631 |
626 numcolors=256; | 632 if (numcolors > 256) |
627 | 633 numcolors = 256; |
628 if(!was_fullscreen&&this->hidden->depth==8) | 634 |
629 { | 635 if (!was_fullscreen && this->hidden->depth == 8) { |
630 for ( pixel=0; pixel<numcolors; pixel++ ) | 636 for (pixel = 0; pixel < numcolors; pixel++) { |
631 { | 637 if (SDL_XPixels[pixel] >= 0) |
632 if(SDL_XPixels[pixel]>=0) | 638 ReleasePen (GFX_Display->ViewPort. |
633 ReleasePen(GFX_Display->ViewPort.ColorMap,SDL_XPixels[pixel]); | 639 ColorMap, SDL_XPixels[pixel]); |
634 } | 640 } |
635 } | 641 } |
636 } | 642 } |
637 SDL_free(SDL_XPixels); | 643 SDL_free (SDL_XPixels); |
638 SDL_XPixels = NULL; | 644 SDL_XPixels = NULL; |
639 } | 645 } |
640 } | 646 } |
641 } | 647 } |
642 | 648 |
643 static void CGX_SetSizeHints(_THIS, int w, int h, Uint32 flags) | 649 static void |
644 { | 650 CGX_SetSizeHints (_THIS, int w, int h, Uint32 flags) |
645 if ( flags & SDL_RESIZABLE ) { | 651 { |
646 WindowLimits(SDL_Window, 32, 32,4096,4096); | 652 if (flags & SDL_RESIZABLE) { |
647 } else { | 653 WindowLimits (SDL_Window, 32, 32, 4096, 4096); |
648 WindowLimits(SDL_Window, w,h,w,h); | 654 } else { |
649 } | 655 WindowLimits (SDL_Window, w, h, w, h); |
650 if ( flags & SDL_FULLSCREEN ) { | 656 } |
651 flags&=~SDL_RESIZABLE; | 657 if (flags & SDL_FULLSCREEN) { |
652 } else if ( SDL_getenv("SDL_VIDEO_CENTERED") ) { | 658 flags &= ~SDL_RESIZABLE; |
653 int display_w, display_h; | 659 } else if (SDL_getenv ("SDL_VIDEO_CENTERED")) { |
654 | 660 int display_w, display_h; |
655 display_w = SDL_Display->Width; | 661 |
656 display_h = SDL_Display->Height; | 662 display_w = SDL_Display->Width; |
657 ChangeWindowBox(SDL_Window,(display_w - w - SDL_Window->BorderLeft-SDL_Window->BorderRight)/2, | 663 display_h = SDL_Display->Height; |
658 (display_h - h - SDL_Window->BorderTop-SDL_Window->BorderBottom)/2, | 664 ChangeWindowBox (SDL_Window, |
659 w+SDL_Window->BorderLeft+SDL_Window->BorderRight, | 665 (display_w - w - SDL_Window->BorderLeft - |
660 h+SDL_Window->BorderTop+SDL_Window->BorderBottom); | 666 SDL_Window->BorderRight) / 2, |
661 } | 667 (display_h - h - SDL_Window->BorderTop - |
662 } | 668 SDL_Window->BorderBottom) / 2, |
663 | 669 w + SDL_Window->BorderLeft + |
664 int CGX_CreateWindow(_THIS, SDL_Surface *screen, | 670 SDL_Window->BorderRight, |
665 int w, int h, int bpp, Uint32 flags) | 671 h + SDL_Window->BorderTop + |
672 SDL_Window->BorderBottom); | |
673 } | |
674 } | |
675 | |
676 int | |
677 CGX_CreateWindow (_THIS, SDL_Surface * screen, | |
678 int w, int h, int bpp, Uint32 flags) | |
666 { | 679 { |
667 #if 0 | 680 #if 0 |
668 int i, depth; | 681 int i, depth; |
669 Uint32 vis; | 682 Uint32 vis; |
670 #endif | 683 #endif |
671 D(bug("CGX_CreateWindow\n")); | 684 D (bug ("CGX_CreateWindow\n")); |
672 | 685 |
673 /* If a window is already present, destroy it and start fresh */ | 686 /* If a window is already present, destroy it and start fresh */ |
674 if ( SDL_Window ) { | 687 if (SDL_Window) { |
675 CGX_DestroyWindow(this, screen); | 688 CGX_DestroyWindow (this, screen); |
676 } | 689 } |
677 | 690 |
678 /* See if we have been given a window id */ | 691 /* See if we have been given a window id */ |
679 if ( SDL_windowid ) { | 692 if (SDL_windowid) { |
680 SDL_Window = (struct Window *)atol(SDL_windowid); | 693 SDL_Window = (struct Window *) atol (SDL_windowid); |
681 } else { | 694 } else { |
682 SDL_Window = 0; | 695 SDL_Window = 0; |
683 } | 696 } |
684 | 697 |
685 /* find out which visual we are going to use */ | 698 /* find out which visual we are going to use */ |
686 #if 0 | 699 #if 0 |
687 /* questo l'ho spostato nell'apertura dello schermo, in quanto su Amiga le finestre | 700 /* questo l'ho spostato nell'apertura dello schermo, in quanto su Amiga le finestre |
688 hanno il pixel mode degli schermi. | 701 hanno il pixel mode degli schermi. |
689 */ | 702 */ |
690 /*if ( flags & SDL_INTERNALOPENGL ) { | 703 /*if ( flags & SDL_INTERNALOPENGL ) { |
691 SDL_SetError("OpenGL not supported by the Amiga SDL!"); | 704 SDL_SetError("OpenGL not supported by the Amiga SDL!"); |
692 return -1; | 705 return -1; |
693 } | 706 } |
694 else {*/ | 707 else { */ |
695 for ( i = 0; i < this->hidden->nvisuals; i++ ) { | 708 for (i = 0; i < this->hidden->nvisuals; i++) { |
696 if ( this->hidden->visuals[i].depth == bpp ) /* era .depth */ | 709 if (this->hidden->visuals[i].depth == bpp) /* era .depth */ |
697 break; | 710 break; |
698 } | 711 } |
699 if ( i == this->hidden->nvisuals ) { | 712 if (i == this->hidden->nvisuals) { |
700 SDL_SetError("No matching visual for requested depth"); | 713 SDL_SetError ("No matching visual for requested depth"); |
701 return -1; /* should never happen */ | 714 return -1; /* should never happen */ |
702 } | 715 } |
703 vis = this->hidden->visuals[i].visual; | 716 vis = this->hidden->visuals[i].visual; |
704 depth = this->hidden->visuals[i].depth; | 717 depth = this->hidden->visuals[i].depth; |
705 // } | 718 // } |
706 SDL_Visual = vis; | 719 SDL_Visual = vis; |
707 this->hidden->depth = depth; | 720 this->hidden->depth = depth; |
708 D(bug("Setting screen depth to: %ld\n",this->hidden->depth)); | 721 D (bug ("Setting screen depth to: %ld\n", this->hidden->depth)); |
709 #endif | 722 #endif |
710 | 723 |
711 /* Allocate the new pixel format for this video mode */ | 724 /* Allocate the new pixel format for this video mode */ |
712 { | 725 { |
713 Uint32 form; | 726 Uint32 form; |
714 APTR handle; | 727 APTR handle; |
715 struct DisplayInfo info; | 728 struct DisplayInfo info; |
716 | 729 |
717 if(!(handle=FindDisplayInfo(SDL_Visual))) | 730 if (!(handle = FindDisplayInfo (SDL_Visual))) |
718 return -1; | 731 return -1; |
719 | 732 |
720 if(!GetDisplayInfoData(handle,(char *)&info,sizeof(struct DisplayInfo),DTAG_DISP,NULL)) | 733 if (!GetDisplayInfoData |
721 return -1; | 734 (handle, (char *) &info, sizeof (struct DisplayInfo), DTAG_DISP, |
722 | 735 NULL)) |
723 form=GetCyberIDAttr(CYBRIDATTR_PIXFMT,SDL_Visual); | 736 return -1; |
724 | 737 |
725 if(flags&SDL_HWSURFACE) | 738 form = GetCyberIDAttr (CYBRIDATTR_PIXFMT, SDL_Visual); |
726 { | 739 |
727 if(bpp!=this->hidden->depth) | 740 if (flags & SDL_HWSURFACE) { |
728 { | 741 if (bpp != this->hidden->depth) { |
729 bpp=this->hidden->depth; | 742 bpp = this->hidden->depth; |
730 D(bug("Accel forces bpp to be equal (%ld)\n",bpp)); | 743 D (bug ("Accel forces bpp to be equal (%ld)\n", bpp)); |
731 } | 744 } |
732 } | 745 } |
733 | 746 |
734 D(bug("BEFORE screen allocation: bpp:%ld (real:%ld)\n",bpp,this->hidden->depth)); | 747 D (bug |
748 ("BEFORE screen allocation: bpp:%ld (real:%ld)\n", bpp, | |
749 this->hidden->depth)); | |
735 | 750 |
736 /* With this call if needed I'll revert the wanted bpp to a bpp best suited for the display, actually occurs | 751 /* With this call if needed I'll revert the wanted bpp to a bpp best suited for the display, actually occurs |
737 only with requested format 15/16bit and display format != 15/16bit | 752 only with requested format 15/16bit and display format != 15/16bit |
738 */ | 753 */ |
739 | 754 |
740 if ( ! SDL_ReallocFormat(screen, bpp, | 755 if (!SDL_ReallocFormat (screen, bpp, |
741 MakeBitMask(this,0,form,&bpp), MakeBitMask(this,1,form,&bpp), MakeBitMask(this,2,form,&bpp), 0) ) | 756 MakeBitMask (this, 0, form, &bpp), |
742 return -1; | 757 MakeBitMask (this, 1, form, &bpp), |
743 | 758 MakeBitMask (this, 2, form, &bpp), 0)) |
744 D(bug("AFTER screen allocation: bpp:%ld (real:%ld)\n",bpp,this->hidden->depth)); | 759 return -1; |
745 | 760 |
746 } | 761 D (bug |
747 | 762 ("AFTER screen allocation: bpp:%ld (real:%ld)\n", bpp, |
748 /* Create the appropriate colormap */ | 763 this->hidden->depth)); |
764 | |
765 } | |
766 | |
767 /* Create the appropriate colormap */ | |
749 /* | 768 /* |
750 if ( SDL_XColorMap != SDL_DisplayColormap ) { | 769 if ( SDL_XColorMap != SDL_DisplayColormap ) { |
751 XFreeColormap(SDL_Display, SDL_XColorMap); | 770 XFreeColormap(SDL_Display, SDL_XColorMap); |
752 } | 771 } |
753 */ | 772 */ |
754 if ( GetCyberMapAttr(SDL_Display->RastPort.BitMap,CYBRMATTR_PIXFMT)==PIXFMT_LUT8 || bpp==8 ) { | 773 if (GetCyberMapAttr (SDL_Display->RastPort.BitMap, CYBRMATTR_PIXFMT) == |
755 int ncolors,i; | 774 PIXFMT_LUT8 || bpp == 8) { |
756 D(bug("XPixels palette allocation...\n")); | 775 int ncolors, i; |
757 | 776 D (bug ("XPixels palette allocation...\n")); |
758 /* Allocate the pixel flags */ | 777 |
759 | 778 /* Allocate the pixel flags */ |
760 if(bpp==8) | 779 |
761 ncolors=256; | 780 if (bpp == 8) |
762 else | 781 ncolors = 256; |
763 ncolors = 1 << screen->format->BitsPerPixel; | 782 else |
764 | 783 ncolors = 1 << screen->format->BitsPerPixel; |
765 SDL_XPixels = (Sint32 *)SDL_malloc(ncolors * sizeof(Sint32)); | 784 |
766 | 785 SDL_XPixels = (Sint32 *) SDL_malloc (ncolors * sizeof (Sint32)); |
767 if(SDL_XPixels == NULL) { | 786 |
768 SDL_OutOfMemory(); | 787 if (SDL_XPixels == NULL) { |
769 return -1; | 788 SDL_OutOfMemory (); |
770 } | 789 return -1; |
771 | 790 } |
772 | 791 |
773 for(i=0;i<ncolors;i++) | 792 |
774 SDL_XPixels[i]=-1; | 793 for (i = 0; i < ncolors; i++) |
775 | 794 SDL_XPixels[i] = -1; |
776 /* always allocate a private colormap on non-default visuals */ | 795 |
777 if(bpp==8) | 796 /* always allocate a private colormap on non-default visuals */ |
778 flags |= SDL_HWPALETTE; | 797 if (bpp == 8) |
779 | 798 flags |= SDL_HWPALETTE; |
780 if ( flags & SDL_HWPALETTE ) | 799 |
781 screen->flags |= SDL_HWPALETTE; | 800 if (flags & SDL_HWPALETTE) |
782 } | 801 screen->flags |= SDL_HWPALETTE; |
783 | 802 } |
784 /* resize the (possibly new) window manager window */ | 803 |
785 | 804 /* resize the (possibly new) window manager window */ |
786 /* Create (or use) the X11 display window */ | 805 |
787 | 806 /* Create (or use) the X11 display window */ |
788 if ( !SDL_windowid ) { | 807 |
789 if( flags & SDL_FULLSCREEN ) | 808 if (!SDL_windowid) { |
790 { | 809 if (flags & SDL_FULLSCREEN) { |
791 SDL_Window = OpenWindowTags(NULL,WA_Width,w,WA_Height,h, | 810 SDL_Window = OpenWindowTags (NULL, WA_Width, w, WA_Height, h, |
792 WA_Flags,WFLG_ACTIVATE|WFLG_RMBTRAP|WFLG_BORDERLESS|WFLG_BACKDROP|WFLG_REPORTMOUSE, | 811 WA_Flags, |
793 WA_IDCMP,IDCMP_RAWKEY|IDCMP_MOUSEBUTTONS|IDCMP_MOUSEMOVE, | 812 WFLG_ACTIVATE | WFLG_RMBTRAP | |
794 WA_CustomScreen,(ULONG)SDL_Display, | 813 WFLG_BORDERLESS | WFLG_BACKDROP | |
795 TAG_DONE); | 814 WFLG_REPORTMOUSE, WA_IDCMP, |
796 | 815 IDCMP_RAWKEY | IDCMP_MOUSEBUTTONS |
797 D(bug("Opening backdrop window %ldx%ld on display %lx!\n",w,h,SDL_Display)); | 816 | IDCMP_MOUSEMOVE, |
798 } | 817 WA_CustomScreen, |
799 else | 818 (ULONG) SDL_Display, TAG_DONE); |
800 { | 819 |
801 /* Create GimmeZeroZero window when OpenGL is used */ | 820 D (bug |
802 unsigned long gzz = FALSE; | 821 ("Opening backdrop window %ldx%ld on display %lx!\n", w, h, |
803 if( flags & SDL_INTERNALOPENGL ) { | 822 SDL_Display)); |
804 gzz = TRUE; | 823 } else { |
805 } | 824 /* Create GimmeZeroZero window when OpenGL is used */ |
806 | 825 unsigned long gzz = FALSE; |
807 SDL_Window = OpenWindowTags(NULL,WA_InnerWidth,w,WA_InnerHeight,h, | 826 if (flags & SDL_INTERNALOPENGL) { |
808 WA_Flags,WFLG_REPORTMOUSE|WFLG_ACTIVATE|WFLG_RMBTRAP | ((flags&SDL_NOFRAME) ? 0 : (WFLG_DEPTHGADGET|WFLG_CLOSEGADGET|WFLG_DRAGBAR | ((flags&SDL_RESIZABLE) ? WFLG_SIZEGADGET|WFLG_SIZEBBOTTOM : 0))), | 827 gzz = TRUE; |
809 WA_IDCMP,IDCMP_RAWKEY|IDCMP_CLOSEWINDOW|IDCMP_MOUSEBUTTONS|IDCMP_NEWSIZE|IDCMP_MOUSEMOVE, | 828 } |
810 WA_PubScreen,(ULONG)SDL_Display, | 829 |
811 WA_GimmeZeroZero, gzz, | 830 SDL_Window = |
812 TAG_DONE); | 831 OpenWindowTags (NULL, WA_InnerWidth, w, WA_InnerHeight, h, |
813 D(bug("Opening WB window of size: %ldx%ld!\n",w,h)); | 832 WA_Flags, |
814 } | 833 WFLG_REPORTMOUSE | WFLG_ACTIVATE | |
815 | 834 WFLG_RMBTRAP | ((flags & SDL_NOFRAME) ? 0 |
816 if(!SDL_Window) | 835 : (WFLG_DEPTHGADGET | |
817 return -1; | 836 WFLG_CLOSEGADGET | |
818 } | 837 WFLG_DRAGBAR | |
819 | 838 ((flags & |
820 this->hidden->BytesPerPixel=GetCyberMapAttr(SDL_Window->RPort->BitMap,CYBRMATTR_BPPIX); | 839 SDL_RESIZABLE) ? |
821 | 840 WFLG_SIZEGADGET | |
822 if(screen->flags & SDL_DOUBLEBUF) | 841 WFLG_SIZEBBOTTOM : |
823 { | 842 0))), WA_IDCMP, |
824 if(SDL_RastPort=SDL_malloc(sizeof(struct RastPort))) | 843 IDCMP_RAWKEY | IDCMP_CLOSEWINDOW | |
825 { | 844 IDCMP_MOUSEBUTTONS | IDCMP_NEWSIZE | |
826 InitRastPort(SDL_RastPort); | 845 IDCMP_MOUSEMOVE, WA_PubScreen, |
827 SDL_RastPort->BitMap=this->hidden->SB[1]->sb_BitMap; | 846 (ULONG) SDL_Display, WA_GimmeZeroZero, |
828 } | 847 gzz, TAG_DONE); |
829 else | 848 D (bug ("Opening WB window of size: %ldx%ld!\n", w, h)); |
830 return -1; | 849 } |
831 } | 850 |
832 else SDL_RastPort=SDL_Window->RPort; | 851 if (!SDL_Window) |
833 | 852 return -1; |
834 if(flags&SDL_HWSURFACE) | 853 } |
835 screen->flags|=SDL_HWSURFACE; | 854 |
836 | 855 this->hidden->BytesPerPixel = |
837 if( !SDL_windowid ) { | 856 GetCyberMapAttr (SDL_Window->RPort->BitMap, CYBRMATTR_BPPIX); |
838 CGX_SetSizeHints(this, w, h, flags); | 857 |
839 } | 858 if (screen->flags & SDL_DOUBLEBUF) { |
840 | 859 if (SDL_RastPort = SDL_malloc (sizeof (struct RastPort))) { |
841 /* Set our colormaps when not setting a GL mode */ | 860 InitRastPort (SDL_RastPort); |
861 SDL_RastPort->BitMap = this->hidden->SB[1]->sb_BitMap; | |
862 } else | |
863 return -1; | |
864 } else | |
865 SDL_RastPort = SDL_Window->RPort; | |
866 | |
867 if (flags & SDL_HWSURFACE) | |
868 screen->flags |= SDL_HWSURFACE; | |
869 | |
870 if (!SDL_windowid) { | |
871 CGX_SetSizeHints (this, w, h, flags); | |
872 } | |
873 | |
874 /* Set our colormaps when not setting a GL mode */ | |
842 /* | 875 /* |
843 if ( ! (flags & SDL_INTERNALOPENGL) ) { | 876 if ( ! (flags & SDL_INTERNALOPENGL) ) { |
844 XSetWindowColormap(SDL_Display, SDL_Window, SDL_XColorMap); | 877 XSetWindowColormap(SDL_Display, SDL_Window, SDL_XColorMap); |
845 } | 878 } |
846 */ | 879 */ |
847 | 880 |
848 /* Map them both and go fullscreen, if requested */ | 881 /* Map them both and go fullscreen, if requested */ |
849 if ( ! SDL_windowid ) { | 882 if (!SDL_windowid) { |
850 if ( flags & SDL_FULLSCREEN ) { | 883 if (flags & SDL_FULLSCREEN) { |
851 screen->flags |= SDL_FULLSCREEN; | 884 screen->flags |= SDL_FULLSCREEN; |
852 currently_fullscreen=1; | 885 currently_fullscreen = 1; |
853 // CGX_EnterFullScreen(this); Ci siamo gia'! | 886 // CGX_EnterFullScreen(this); Ci siamo gia'! |
854 } else { | 887 } else { |
855 screen->flags &= ~SDL_FULLSCREEN; | 888 screen->flags &= ~SDL_FULLSCREEN; |
856 } | 889 } |
857 } | 890 } |
858 screen->w = w; | 891 screen->w = w; |
859 screen->h = h; | 892 screen->h = h; |
860 screen->pitch = SDL_CalculatePitch(screen); | 893 screen->pitch = SDL_CalculatePitch (screen); |
861 CGX_ResizeImage(this, screen, flags); | 894 CGX_ResizeImage (this, screen, flags); |
862 | 895 |
863 /* Make OpenGL Context if needed*/ | 896 /* Make OpenGL Context if needed */ |
864 if(flags & SDL_INTERNALOPENGL) { | 897 if (flags & SDL_INTERNALOPENGL) { |
865 if(this->gl_data->gl_active == 0) { | 898 if (this->gl_data->gl_active == 0) { |
866 if(CGX_GL_Init(this) < 0) | 899 if (CGX_GL_Init (this) < 0) |
867 return -1; | 900 return -1; |
868 else | 901 else |
869 screen->flags |= SDL_INTERNALOPENGL; | 902 screen->flags |= SDL_INTERNALOPENGL; |
870 } | 903 } else { |
871 else { | 904 if (CGX_GL_Update (this) < 0) |
872 if(CGX_GL_Update(this) < 0) | 905 return -1; |
873 return -1; | 906 else |
874 else | 907 screen->flags |= SDL_INTERNALOPENGL; |
875 screen->flags |= SDL_INTERNALOPENGL; | 908 } |
876 } | 909 } |
877 } | 910 } |
878 } | 911 |
879 | 912 int |
880 int CGX_ResizeWindow(_THIS, | 913 CGX_ResizeWindow (_THIS, SDL_Surface * screen, int w, int h, Uint32 flags) |
881 SDL_Surface *screen, int w, int h, Uint32 flags) | 914 { |
882 { | 915 D (bug ("CGX_ResizeWindow\n")); |
883 D(bug("CGX_ResizeWindow\n")); | 916 |
884 | 917 if (!SDL_windowid) { |
885 if ( ! SDL_windowid ) { | 918 /* Resize the window manager window */ |
886 /* Resize the window manager window */ | 919 CGX_SetSizeHints (this, w, h, flags); |
887 CGX_SetSizeHints(this, w, h, flags); | 920 |
888 | 921 ChangeWindowBox (SDL_Window, SDL_Window->LeftEdge, |
889 ChangeWindowBox(SDL_Window,SDL_Window->LeftEdge,SDL_Window->TopEdge, w+SDL_Window->BorderLeft+SDL_Window->BorderRight, | 922 SDL_Window->TopEdge, |
890 h+SDL_Window->BorderTop+SDL_Window->BorderBottom); | 923 w + SDL_Window->BorderLeft + |
891 | 924 SDL_Window->BorderRight, |
892 screen->w = w; | 925 h + SDL_Window->BorderTop + |
893 screen->h = h; | 926 SDL_Window->BorderBottom); |
894 screen->pitch = SDL_CalculatePitch(screen); | 927 |
895 CGX_ResizeImage(this, screen, flags); | 928 screen->w = w; |
896 } | 929 screen->h = h; |
897 return(0); | 930 screen->pitch = SDL_CalculatePitch (screen); |
898 } | 931 CGX_ResizeImage (this, screen, flags); |
899 | 932 } |
900 static SDL_Surface *CGX_SetVideoMode(_THIS, SDL_Surface *current, | 933 return (0); |
901 int width, int height, int bpp, Uint32 flags) | 934 } |
902 { | 935 |
903 Uint32 saved_flags; | 936 static SDL_Surface * |
904 int needcreate=0; | 937 CGX_SetVideoMode (_THIS, SDL_Surface * current, |
905 | 938 int width, int height, int bpp, Uint32 flags) |
906 D(bug("CGX_SetVideoMode current:%lx\n",current)); | 939 { |
907 | 940 Uint32 saved_flags; |
908 /* Lock the event thread, in multi-threading environments */ | 941 int needcreate = 0; |
909 SDL_Lock_EventThread(); | 942 |
943 D (bug ("CGX_SetVideoMode current:%lx\n", current)); | |
944 | |
945 /* Lock the event thread, in multi-threading environments */ | |
946 SDL_Lock_EventThread (); | |
910 | 947 |
911 // Check if the window needs to be closed or can be resized | 948 // Check if the window needs to be closed or can be resized |
912 | 949 |
913 if( (flags&SDL_FULLSCREEN) || (current && current->flags&SDL_FULLSCREEN && !(flags&SDL_FULLSCREEN))) | 950 if ((flags & SDL_FULLSCREEN) |
914 needcreate=1; | 951 || (current && current->flags & SDL_FULLSCREEN |
952 && !(flags & SDL_FULLSCREEN))) | |
953 needcreate = 1; | |
915 | 954 |
916 // Check if we need to close an already existing videomode... | 955 // Check if we need to close an already existing videomode... |
917 | 956 |
918 if(current && current->flags&SDL_FULLSCREEN && !(flags&SDL_FULLSCREEN)) { | 957 if (current && current->flags & SDL_FULLSCREEN |
919 unsigned long i; | 958 && !(flags & SDL_FULLSCREEN)) { |
920 D(bug("Destroying image, window & screen!\n")); | 959 unsigned long i; |
921 | 960 D (bug ("Destroying image, window & screen!\n")); |
922 CGX_DestroyImage(this,current); | 961 |
923 CGX_DestroyWindow(this,current); | 962 CGX_DestroyImage (this, current); |
924 DestroyScreen(this); | 963 CGX_DestroyWindow (this, current); |
925 GFX_Display=SDL_Display=LockPubScreen(NULL); | 964 DestroyScreen (this); |
926 | 965 GFX_Display = SDL_Display = LockPubScreen (NULL); |
927 bpp=this->hidden->depth=GetCyberMapAttr(SDL_Display->RastPort.BitMap,CYBRMATTR_DEPTH); | 966 |
928 | 967 bpp = this->hidden->depth = |
929 for ( i = 0; i < this->hidden->nvisuals; i++ ) { | 968 GetCyberMapAttr (SDL_Display->RastPort.BitMap, CYBRMATTR_DEPTH); |
930 if ( this->hidden->visuals[i].depth == bpp ) /* era .depth */ | 969 |
931 break; | 970 for (i = 0; i < this->hidden->nvisuals; i++) { |
932 } | 971 if (this->hidden->visuals[i].depth == bpp) /* era .depth */ |
933 if ( i == this->hidden->nvisuals ) { | 972 break; |
934 SDL_SetError("No matching visual for requested depth"); | 973 } |
935 return NULL; /* should never happen */ | 974 if (i == this->hidden->nvisuals) { |
936 } | 975 SDL_SetError ("No matching visual for requested depth"); |
937 SDL_Visual = this->hidden->visuals[i].visual; | 976 return NULL; /* should never happen */ |
938 | 977 } |
939 D(bug("Setting screen depth to: %ld\n",this->hidden->depth)); | 978 SDL_Visual = this->hidden->visuals[i].visual; |
940 | 979 |
941 } | 980 D (bug ("Setting screen depth to: %ld\n", this->hidden->depth)); |
942 /* Check the combination of flags we were passed */ | 981 |
943 if ( flags & SDL_FULLSCREEN ) { | 982 } |
944 int i; | 983 /* Check the combination of flags we were passed */ |
945 | 984 if (flags & SDL_FULLSCREEN) { |
946 /* Clear fullscreen flag if not supported */ | 985 int i; |
947 if ( SDL_windowid ) { | 986 |
948 flags &= ~SDL_FULLSCREEN; | 987 /* Clear fullscreen flag if not supported */ |
949 } | 988 if (SDL_windowid) { |
950 else if(current && current->flags&SDL_FULLSCREEN ) { | 989 flags &= ~SDL_FULLSCREEN; |
951 if(current->w!=width || | 990 } else if (current && current->flags & SDL_FULLSCREEN) { |
952 current->h!=height || | 991 if (current->w != width || |
953 (this->hidden && this->hidden->depth!=bpp)) | 992 current->h != height || |
954 { | 993 (this->hidden && this->hidden->depth != bpp)) { |
955 D(bug("Deleting previous window...\n")); | 994 D (bug ("Deleting previous window...\n")); |
956 CGX_DestroyImage(this,current); | 995 CGX_DestroyImage (this, current); |
957 CGX_DestroyWindow(this,current); | 996 CGX_DestroyWindow (this, current); |
958 DestroyScreen(this); | 997 DestroyScreen (this); |
959 goto buildnewscreen; | 998 goto buildnewscreen; |
960 } | 999 } |
961 } | 1000 } else |
962 else | 1001 buildnewscreen: |
963 buildnewscreen: | 1002 { |
964 { | 1003 Uint32 okid = BestCModeIDTags (CYBRBIDTG_NominalWidth, width, |
965 Uint32 okid=BestCModeIDTags(CYBRBIDTG_NominalWidth,width, | 1004 CYBRBIDTG_NominalHeight, |
966 CYBRBIDTG_NominalHeight,height, | 1005 height, |
967 CYBRBIDTG_Depth,bpp, | 1006 CYBRBIDTG_Depth, bpp, |
968 TAG_DONE); | 1007 TAG_DONE); |
969 | 1008 |
970 GFX_Display=NULL; | 1009 GFX_Display = NULL; |
971 | 1010 |
972 D(bug("Opening screen...\n")); | 1011 D (bug ("Opening screen...\n")); |
973 | 1012 |
974 if(okid!=INVALID_ID) | 1013 if (okid != INVALID_ID) |
975 GFX_Display=OpenScreenTags(NULL, | 1014 GFX_Display = OpenScreenTags (NULL, |
976 SA_Width,width, | 1015 SA_Width, width, |
977 SA_Height,height, | 1016 SA_Height, height, |
978 SA_Quiet,TRUE,SA_ShowTitle,FALSE, | 1017 SA_Quiet, TRUE, |
979 SA_Depth,bpp, | 1018 SA_ShowTitle, FALSE, |
980 SA_DisplayID,okid, | 1019 SA_Depth, bpp, SA_DisplayID, |
981 TAG_DONE); | 1020 okid, TAG_DONE); |
982 | 1021 |
983 if(!GFX_Display) { | 1022 if (!GFX_Display) { |
984 GFX_Display=SDL_Display; | 1023 GFX_Display = SDL_Display; |
985 flags &= ~SDL_FULLSCREEN; | 1024 flags &= ~SDL_FULLSCREEN; |
986 flags &= ~SDL_DOUBLEBUF; | 1025 flags &= ~SDL_DOUBLEBUF; |
987 } | 1026 } else { |
988 else { | 1027 UnlockPubScreen (NULL, SDL_Display); |
989 UnlockPubScreen(NULL,SDL_Display); | 1028 SDL_Display = GFX_Display; |
990 SDL_Display=GFX_Display; | 1029 |
991 | 1030 D (bug ("Screen opened.\n")); |
992 D(bug("Screen opened.\n")); | 1031 |
993 | 1032 if (flags & SDL_DOUBLEBUF) { |
994 if(flags&SDL_DOUBLEBUF) { | 1033 int ok = 0; |
995 int ok=0; | 1034 D (bug ("Start of DBuffering allocations...\n")); |
996 D(bug("Start of DBuffering allocations...\n")); | 1035 |
997 | 1036 if (this->hidden->SB[0] = |
998 if(this->hidden->SB[0]=AllocScreenBuffer(SDL_Display,NULL,SB_SCREEN_BITMAP)) { | 1037 AllocScreenBuffer (SDL_Display, NULL, |
999 | 1038 SB_SCREEN_BITMAP)) { |
1000 if(this->hidden->SB[1]=AllocScreenBuffer(SDL_Display,NULL,0L)) { | 1039 |
1001 extern struct MsgPort *safeport,*dispport; | 1040 if (this->hidden->SB[1] = |
1002 | 1041 AllocScreenBuffer (SDL_Display, NULL, 0L)) { |
1003 safeport=CreateMsgPort(); | 1042 extern struct MsgPort *safeport, *dispport; |
1004 dispport=CreateMsgPort(); | 1043 |
1005 | 1044 safeport = CreateMsgPort (); |
1006 if(!safeport || !dispport) { | 1045 dispport = CreateMsgPort (); |
1007 if(safeport) { | 1046 |
1008 DeleteMsgPort(safeport); | 1047 if (!safeport || !dispport) { |
1009 safeport=NULL; | 1048 if (safeport) { |
1010 } | 1049 DeleteMsgPort (safeport); |
1011 if(dispport) { | 1050 safeport = NULL; |
1012 DeleteMsgPort(dispport); | 1051 } |
1013 dispport=NULL; | 1052 if (dispport) { |
1014 } | 1053 DeleteMsgPort (dispport); |
1015 FreeScreenBuffer(SDL_Display,this->hidden->SB[0]); | 1054 dispport = NULL; |
1016 FreeScreenBuffer(SDL_Display,this->hidden->SB[1]); | 1055 } |
1017 } | 1056 FreeScreenBuffer (SDL_Display, |
1018 else { | 1057 this->hidden->SB[0]); |
1019 extern ULONG safe_sigbit,disp_sigbit; | 1058 FreeScreenBuffer (SDL_Display, |
1020 int i; | 1059 this->hidden->SB[1]); |
1021 | 1060 } else { |
1022 safe_sigbit=1L<< safeport->mp_SigBit; | 1061 extern ULONG safe_sigbit, disp_sigbit; |
1023 disp_sigbit=1L<< dispport->mp_SigBit; | 1062 int i; |
1024 | 1063 |
1025 for(i=0;i<2;i++) { | 1064 safe_sigbit = 1L << safeport->mp_SigBit; |
1026 this->hidden->SB[i]->sb_DBufInfo->dbi_SafeMessage.mn_ReplyPort=safeport; | 1065 disp_sigbit = 1L << dispport->mp_SigBit; |
1027 this->hidden->SB[i]->sb_DBufInfo->dbi_DispMessage.mn_ReplyPort=dispport; | 1066 |
1028 } | 1067 for (i = 0; i < 2; i++) { |
1029 | 1068 this->hidden->SB[i]-> |
1030 ok=1; | 1069 sb_DBufInfo-> |
1031 D(bug("Dbuffering enabled!\n")); | 1070 dbi_SafeMessage. |
1032 this->hidden->dbuffer=1; | 1071 mn_ReplyPort = safeport; |
1033 current->flags|=SDL_DOUBLEBUF; | 1072 this->hidden->SB[i]-> |
1034 } | 1073 sb_DBufInfo-> |
1035 } | 1074 dbi_DispMessage. |
1036 else { | 1075 mn_ReplyPort = dispport; |
1037 FreeScreenBuffer(SDL_Display,this->hidden->SB[1]); | 1076 } |
1038 this->hidden->SB[0]=NULL; | 1077 |
1039 } | 1078 ok = 1; |
1040 } | 1079 D (bug ("Dbuffering enabled!\n")); |
1041 | 1080 this->hidden->dbuffer = 1; |
1042 if(!ok) | 1081 current->flags |= SDL_DOUBLEBUF; |
1043 flags&=~SDL_DOUBLEBUF; | 1082 } |
1044 } | 1083 } else { |
1045 } | 1084 FreeScreenBuffer (SDL_Display, |
1046 | 1085 this->hidden->SB[1]); |
1047 if(GetCyberMapAttr(SDL_Display->RastPort.BitMap,CYBRMATTR_DEPTH)==bpp) | 1086 this->hidden->SB[0] = NULL; |
1048 this->hidden->same_format=1; | 1087 } |
1049 } | 1088 } |
1050 | 1089 |
1051 bpp=this->hidden->depth=GetCyberMapAttr(SDL_Display->RastPort.BitMap,CYBRMATTR_DEPTH); | 1090 if (!ok) |
1052 D(bug("Setting screen depth to: %ld\n",this->hidden->depth)); | 1091 flags &= ~SDL_DOUBLEBUF; |
1053 | 1092 } |
1054 for ( i = 0; i < this->hidden->nvisuals; i++ ) | 1093 } |
1055 if ( this->hidden->visuals[i].depth == bpp ) /* era .depth */ | 1094 |
1056 break; | 1095 if (GetCyberMapAttr |
1057 | 1096 (SDL_Display->RastPort.BitMap, CYBRMATTR_DEPTH) == bpp) |
1058 if ( i == this->hidden->nvisuals ) { | 1097 this->hidden->same_format = 1; |
1059 SDL_SetError("No matching visual for requested depth"); | 1098 } |
1060 return NULL; /* should never happen */ | 1099 |
1061 } | 1100 bpp = this->hidden->depth = |
1062 SDL_Visual = this->hidden->visuals[i].visual; | 1101 GetCyberMapAttr (SDL_Display->RastPort.BitMap, CYBRMATTR_DEPTH); |
1063 | 1102 D (bug ("Setting screen depth to: %ld\n", this->hidden->depth)); |
1064 } | 1103 |
1065 | 1104 for (i = 0; i < this->hidden->nvisuals; i++) |
1066 /* Set up the X11 window */ | 1105 if (this->hidden->visuals[i].depth == bpp) /* era .depth */ |
1067 saved_flags = current->flags; | 1106 break; |
1068 | 1107 |
1069 if (SDL_Window && (saved_flags&SDL_INTERNALOPENGL) == (flags&SDL_INTERNALOPENGL) | 1108 if (i == this->hidden->nvisuals) { |
1070 && bpp == current->format->BitsPerPixel && !needcreate) { | 1109 SDL_SetError ("No matching visual for requested depth"); |
1071 if (CGX_ResizeWindow(this, current, width, height, flags) < 0) { | 1110 return NULL; /* should never happen */ |
1072 current = NULL; | 1111 } |
1073 goto done; | 1112 SDL_Visual = this->hidden->visuals[i].visual; |
1074 } | 1113 |
1075 } else { | 1114 } |
1076 if (CGX_CreateWindow(this,current,width,height,bpp,flags) < 0) { | 1115 |
1077 current = NULL; | 1116 /* Set up the X11 window */ |
1078 goto done; | 1117 saved_flags = current->flags; |
1079 } | 1118 |
1080 } | 1119 if (SDL_Window |
1120 && (saved_flags & SDL_INTERNALOPENGL) == (flags & SDL_INTERNALOPENGL) | |
1121 && bpp == current->format->BitsPerPixel && !needcreate) { | |
1122 if (CGX_ResizeWindow (this, current, width, height, flags) < 0) { | |
1123 current = NULL; | |
1124 goto done; | |
1125 } | |
1126 } else { | |
1127 if (CGX_CreateWindow (this, current, width, height, bpp, flags) < 0) { | |
1128 current = NULL; | |
1129 goto done; | |
1130 } | |
1131 } | |
1081 | 1132 |
1082 #if 0 | 1133 #if 0 |
1083 /* Set up the new mode framebuffer */ | 1134 /* Set up the new mode framebuffer */ |
1084 if ( ((current->w != width) || (current->h != height)) || | 1135 if (((current->w != width) || (current->h != height)) || |
1085 ((saved_flags&SDL_INTERNALOPENGL) != (flags&SDL_INTERNALOPENGL)) ) { | 1136 ((saved_flags & SDL_INTERNALOPENGL) != (flags & SDL_INTERNALOPENGL))) |
1086 current->w = width; | 1137 { |
1087 current->h = height; | 1138 current->w = width; |
1088 current->pitch = SDL_CalculatePitch(current); | 1139 current->h = height; |
1089 CGX_ResizeImage(this, current, flags); | 1140 current->pitch = SDL_CalculatePitch (current); |
1090 } | 1141 CGX_ResizeImage (this, current, flags); |
1142 } | |
1091 #endif | 1143 #endif |
1092 | 1144 |
1093 current->flags |= (flags&SDL_RESIZABLE); // Resizable only if the user asked it | 1145 current->flags |= (flags & SDL_RESIZABLE); // Resizable only if the user asked it |
1094 | 1146 |
1095 done: | 1147 done: |
1096 /* Release the event thread */ | 1148 /* Release the event thread */ |
1097 SDL_Unlock_EventThread(); | 1149 SDL_Unlock_EventThread (); |
1098 | 1150 |
1099 /* We're done! */ | 1151 /* We're done! */ |
1100 return(current); | 1152 return (current); |
1101 } | 1153 } |
1102 | 1154 |
1103 static int CGX_ToggleFullScreen(_THIS, int on) | 1155 static int |
1104 { | 1156 CGX_ToggleFullScreen (_THIS, int on) |
1105 Uint32 event_thread; | 1157 { |
1106 | 1158 Uint32 event_thread; |
1107 /* Don't switch if we don't own the window */ | 1159 |
1108 if ( SDL_windowid ) { | 1160 /* Don't switch if we don't own the window */ |
1109 return(0); | 1161 if (SDL_windowid) { |
1110 } | 1162 return (0); |
1111 | 1163 } |
1112 /* Don't lock if we are the event thread */ | 1164 |
1113 event_thread = SDL_EventThreadID(); | 1165 /* Don't lock if we are the event thread */ |
1114 if ( event_thread && (SDL_ThreadID() == event_thread) ) { | 1166 event_thread = SDL_EventThreadID (); |
1115 event_thread = 0; | 1167 if (event_thread && (SDL_ThreadID () == event_thread)) { |
1116 } | 1168 event_thread = 0; |
1117 if ( event_thread ) { | 1169 } |
1118 SDL_Lock_EventThread(); | 1170 if (event_thread) { |
1119 } | 1171 SDL_Lock_EventThread (); |
1120 if ( on ) { | 1172 } |
1121 this->screen->flags |= SDL_FULLSCREEN; | 1173 if (on) { |
1122 CGX_EnterFullScreen(this); | 1174 this->screen->flags |= SDL_FULLSCREEN; |
1123 } else { | 1175 CGX_EnterFullScreen (this); |
1124 this->screen->flags &= ~SDL_FULLSCREEN; | 1176 } else { |
1125 CGX_LeaveFullScreen(this); | 1177 this->screen->flags &= ~SDL_FULLSCREEN; |
1126 } | 1178 CGX_LeaveFullScreen (this); |
1127 | 1179 } |
1128 CGX_RefreshDisplay(this); | 1180 |
1129 if ( event_thread ) { | 1181 CGX_RefreshDisplay (this); |
1130 SDL_Unlock_EventThread(); | 1182 if (event_thread) { |
1131 } | 1183 SDL_Unlock_EventThread (); |
1132 | 1184 } |
1133 SDL_ResetKeyboard(); | 1185 |
1134 | 1186 SDL_ResetKeyboard (); |
1135 return(1); | 1187 |
1136 } | 1188 return (1); |
1137 | 1189 } |
1138 static void SetSingleColor(Uint32 fmt, unsigned char r, unsigned char g, unsigned char b, unsigned char *c) | 1190 |
1139 { | 1191 static void |
1140 switch(fmt) | 1192 SetSingleColor (Uint32 fmt, unsigned char r, unsigned char g, unsigned char b, |
1141 { | 1193 unsigned char *c) |
1142 case PIXFMT_BGR15: | 1194 { |
1143 case PIXFMT_RGB15PC: | 1195 switch (fmt) { |
1144 { | 1196 case PIXFMT_BGR15: |
1145 Uint16 *t=(Uint16 *)c; | 1197 case PIXFMT_RGB15PC: |
1146 *t=(r>>3) | ((g>>3)<<5) | ((b>>3)<<10) ; | 1198 { |
1147 } | 1199 Uint16 *t = (Uint16 *) c; |
1148 break; | 1200 *t = (r >> 3) | ((g >> 3) << 5) | ((b >> 3) << 10); |
1149 case PIXFMT_RGB15: | 1201 } |
1150 case PIXFMT_BGR15PC: | 1202 break; |
1151 { | 1203 case PIXFMT_RGB15: |
1152 Uint16 *t=(Uint16 *)c; | 1204 case PIXFMT_BGR15PC: |
1153 *t=(b>>3) | ((g>>3)<<5) | ((r>>3)<<10) ; | 1205 { |
1154 } | 1206 Uint16 *t = (Uint16 *) c; |
1155 break; | 1207 *t = (b >> 3) | ((g >> 3) << 5) | ((r >> 3) << 10); |
1156 case PIXFMT_BGR16PC: | 1208 } |
1157 case PIXFMT_RGB16: | 1209 break; |
1158 { | 1210 case PIXFMT_BGR16PC: |
1159 Uint16 *t=(Uint16 *)c; | 1211 case PIXFMT_RGB16: |
1160 *t=(b>>3) | ((g>>2)<<5) | ((r>>3)<<11) ; | 1212 { |
1161 } | 1213 Uint16 *t = (Uint16 *) c; |
1162 break; | 1214 *t = (b >> 3) | ((g >> 2) << 5) | ((r >> 3) << 11); |
1163 case PIXFMT_BGR16: | 1215 } |
1164 case PIXFMT_RGB16PC: | 1216 break; |
1165 { | 1217 case PIXFMT_BGR16: |
1166 Uint16 *t=(Uint16 *)c; | 1218 case PIXFMT_RGB16PC: |
1167 *t=(r>>3) | ((g>>2)<<5) | ((b>>3)<<11) ; | 1219 { |
1168 } | 1220 Uint16 *t = (Uint16 *) c; |
1169 break; | 1221 *t = (r >> 3) | ((g >> 2) << 5) | ((b >> 3) << 11); |
1170 case PIXFMT_RGB24: | 1222 } |
1171 c[0]=r; | 1223 break; |
1172 c[1]=g; | 1224 case PIXFMT_RGB24: |
1173 c[2]=b; | 1225 c[0] = r; |
1174 c[3]=0; | 1226 c[1] = g; |
1175 break; | 1227 c[2] = b; |
1176 case PIXFMT_BGR24: | 1228 c[3] = 0; |
1177 c[0]=b; | 1229 break; |
1178 c[1]=g; | 1230 case PIXFMT_BGR24: |
1179 c[2]=r; | 1231 c[0] = b; |
1180 c[3]=0; | 1232 c[1] = g; |
1181 break; | 1233 c[2] = r; |
1182 case PIXFMT_ARGB32: | 1234 c[3] = 0; |
1183 c[0]=0; | 1235 break; |
1184 c[1]=r; | 1236 case PIXFMT_ARGB32: |
1185 c[2]=g; | 1237 c[0] = 0; |
1186 c[3]=b; | 1238 c[1] = r; |
1187 break; | 1239 c[2] = g; |
1188 case PIXFMT_BGRA32: | 1240 c[3] = b; |
1189 c[0]=b; | 1241 break; |
1190 c[1]=g; | 1242 case PIXFMT_BGRA32: |
1191 c[2]=r; | 1243 c[0] = b; |
1192 c[3]=0; | 1244 c[1] = g; |
1193 break; | 1245 c[2] = r; |
1194 case PIXFMT_RGBA32: | 1246 c[3] = 0; |
1195 c[0]=r; | 1247 break; |
1196 c[1]=g; | 1248 case PIXFMT_RGBA32: |
1197 c[2]=b; | 1249 c[0] = r; |
1198 c[3]=0; | 1250 c[1] = g; |
1199 break; | 1251 c[2] = b; |
1200 | 1252 c[3] = 0; |
1201 default: | 1253 break; |
1202 D(bug("Error, SetSingleColor with PIXFMT %ld!\n",fmt)); | 1254 |
1203 } | 1255 default: |
1256 D (bug ("Error, SetSingleColor with PIXFMT %ld!\n", fmt)); | |
1257 } | |
1204 } | 1258 } |
1205 | 1259 |
1206 /* Update the current mouse state and position */ | 1260 /* Update the current mouse state and position */ |
1207 static void CGX_UpdateMouse(_THIS) | 1261 static void |
1208 { | 1262 CGX_UpdateMouse (_THIS) |
1209 /* Lock the event thread, in multi-threading environments */ | 1263 { |
1210 SDL_Lock_EventThread(); | 1264 /* Lock the event thread, in multi-threading environments */ |
1211 | 1265 SDL_Lock_EventThread (); |
1212 if(currently_fullscreen) | 1266 |
1213 { | 1267 if (currently_fullscreen) { |
1214 SDL_PrivateAppActive(1, SDL_APPMOUSEFOCUS); | 1268 SDL_PrivateAppActive (1, SDL_APPMOUSEFOCUS); |
1215 SDL_PrivateMouseMotion(0, 0, SDL_Display->MouseX, SDL_Display->MouseY); | 1269 SDL_PrivateMouseMotion (0, 0, SDL_Display->MouseX, |
1216 } | 1270 SDL_Display->MouseY); |
1217 else | 1271 } else { |
1218 { | 1272 if (SDL_Display->MouseX >= |
1219 if( SDL_Display->MouseX>=(SDL_Window->LeftEdge+SDL_Window->BorderLeft) && SDL_Display->MouseX<(SDL_Window->LeftEdge+SDL_Window->Width-SDL_Window->BorderRight) && | 1273 (SDL_Window->LeftEdge + SDL_Window->BorderLeft) |
1220 SDL_Display->MouseY>=(SDL_Window->TopEdge+SDL_Window->BorderLeft) && SDL_Display->MouseY<(SDL_Window->TopEdge+SDL_Window->Height-SDL_Window->BorderBottom) | 1274 && SDL_Display->MouseX < |
1221 ) | 1275 (SDL_Window->LeftEdge + SDL_Window->Width - |
1222 { | 1276 SDL_Window->BorderRight) |
1223 SDL_PrivateAppActive(1, SDL_APPMOUSEFOCUS); | 1277 && SDL_Display->MouseY >= |
1224 SDL_PrivateMouseMotion(0, 0, SDL_Display->MouseX-SDL_Window->LeftEdge-SDL_Window->BorderLeft, | 1278 (SDL_Window->TopEdge + SDL_Window->BorderLeft) |
1225 SDL_Display->MouseY-SDL_Window->TopEdge-SDL_Window->BorderTop); | 1279 && SDL_Display->MouseY < |
1226 } | 1280 (SDL_Window->TopEdge + SDL_Window->Height - |
1227 else | 1281 SDL_Window->BorderBottom)) { |
1228 { | 1282 SDL_PrivateAppActive (1, SDL_APPMOUSEFOCUS); |
1229 SDL_PrivateAppActive(0, SDL_APPMOUSEFOCUS); | 1283 SDL_PrivateMouseMotion (0, 0, |
1230 } | 1284 SDL_Display->MouseX - |
1231 } | 1285 SDL_Window->LeftEdge - |
1232 SDL_Unlock_EventThread(); | 1286 SDL_Window->BorderLeft, |
1233 } | 1287 SDL_Display->MouseY - |
1234 | 1288 SDL_Window->TopEdge - |
1235 static int CGX_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors) | 1289 SDL_Window->BorderTop); |
1236 { | 1290 } else { |
1237 int i; | 1291 SDL_PrivateAppActive (0, SDL_APPMOUSEFOCUS); |
1238 | 1292 } |
1239 /* Check to make sure we have a colormap allocated */ | 1293 } |
1240 | 1294 SDL_Unlock_EventThread (); |
1241 /* It's easy if we have a hidden colormap */ | 1295 } |
1242 if ( (this->screen->flags & SDL_HWPALETTE) && currently_fullscreen ) | 1296 |
1243 { | 1297 static int |
1244 ULONG xcmap[256*3+2]; | 1298 CGX_SetColors (_THIS, int firstcolor, int ncolors, SDL_Color * colors) |
1245 | 1299 { |
1246 xcmap[0]=(ncolors<<16); | 1300 int i; |
1247 xcmap[0]+=firstcolor; | 1301 |
1248 | 1302 /* Check to make sure we have a colormap allocated */ |
1249 // D(bug("Setting %ld colors on an HWPALETTE screen\n",ncolors)); | 1303 |
1250 | 1304 /* It's easy if we have a hidden colormap */ |
1251 for ( i=0; i<ncolors; i++ ) { | 1305 if ((this->screen->flags & SDL_HWPALETTE) && currently_fullscreen) { |
1252 xcmap[i*3+1] = colors[i+firstcolor].r<<24; | 1306 ULONG xcmap[256 * 3 + 2]; |
1253 xcmap[i*3+2] = colors[i+firstcolor].g<<24; | 1307 |
1254 xcmap[i*3+3] = colors[i+firstcolor].b<<24; | 1308 xcmap[0] = (ncolors << 16); |
1255 } | 1309 xcmap[0] += firstcolor; |
1256 xcmap[ncolors*3+1]=0; | 1310 |
1257 LoadRGB32(&GFX_Display->ViewPort,xcmap); | 1311 // D(bug("Setting %ld colors on an HWPALETTE screen\n",ncolors)); |
1258 } else { | 1312 |
1313 for (i = 0; i < ncolors; i++) { | |
1314 xcmap[i * 3 + 1] = colors[i + firstcolor].r << 24; | |
1315 xcmap[i * 3 + 2] = colors[i + firstcolor].g << 24; | |
1316 xcmap[i * 3 + 3] = colors[i + firstcolor].b << 24; | |
1317 } | |
1318 xcmap[ncolors * 3 + 1] = 0; | |
1319 LoadRGB32 (&GFX_Display->ViewPort, xcmap); | |
1320 } else { | |
1259 // XPixels are not needed on 8bit screen with hwpalette | 1321 // XPixels are not needed on 8bit screen with hwpalette |
1260 unsigned long pixel; | 1322 unsigned long pixel; |
1261 | 1323 |
1262 if ( SDL_XPixels == NULL ) { | 1324 if (SDL_XPixels == NULL) { |
1263 D(bug("SetColors without colormap!")); | 1325 D (bug ("SetColors without colormap!")); |
1264 return(0); | 1326 return (0); |
1265 } | 1327 } |
1266 | 1328 |
1267 if(this->hidden->depth==8) | 1329 if (this->hidden->depth == 8) { |
1268 { | |
1269 // In this case I have to unalloc and realloc the full palette | 1330 // In this case I have to unalloc and realloc the full palette |
1270 D(bug("Obtaining %ld colors on the screen\n",ncolors)); | 1331 D (bug ("Obtaining %ld colors on the screen\n", ncolors)); |
1271 | 1332 |
1272 /* Free existing allocated colors */ | 1333 /* Free existing allocated colors */ |
1273 for ( pixel=0; pixel<this->screen->format->palette->ncolors; ++pixel ) { | 1334 for (pixel = 0; |
1274 if(SDL_XPixels[pixel]>=0) | 1335 pixel < this->screen->format->palette->ncolors; ++pixel) { |
1275 ReleasePen(GFX_Display->ViewPort.ColorMap,SDL_XPixels[pixel]); | 1336 if (SDL_XPixels[pixel] >= 0) |
1276 } | 1337 ReleasePen (GFX_Display->ViewPort.ColorMap, |
1277 | 1338 SDL_XPixels[pixel]); |
1278 /* Try to allocate all the colors */ | 1339 } |
1279 for ( i=0; i<this->screen->format->palette->ncolors; ++i ) { | 1340 |
1280 SDL_XPixels[i]=ObtainBestPenA(GFX_Display->ViewPort.ColorMap,colors[i].r<<24,colors[i].g<<24,colors[i].b<<24,NULL); | 1341 /* Try to allocate all the colors */ |
1281 } | 1342 for (i = 0; i < this->screen->format->palette->ncolors; ++i) { |
1282 } | 1343 SDL_XPixels[i] = |
1283 else | 1344 ObtainBestPenA (GFX_Display->ViewPort.ColorMap, |
1284 { | 1345 colors[i].r << 24, |
1346 colors[i].g << 24, | |
1347 colors[i].b << 24, NULL); | |
1348 } | |
1349 } else { | |
1285 #ifndef USE_CGX_WRITELUTPIXEL | 1350 #ifndef USE_CGX_WRITELUTPIXEL |
1286 Uint32 fmt; | 1351 Uint32 fmt; |
1287 D(bug("Preparing a conversion pixel table...\n")); | 1352 D (bug ("Preparing a conversion pixel table...\n")); |
1288 | 1353 |
1289 fmt=GetCyberMapAttr(SDL_Display->RastPort.BitMap,CYBRMATTR_PIXFMT); | 1354 fmt = |
1290 | 1355 GetCyberMapAttr (SDL_Display->RastPort.BitMap, |
1291 for(i=0;i<ncolors;i++) | 1356 CYBRMATTR_PIXFMT); |
1292 { | 1357 |
1293 SetSingleColor(fmt,colors[firstcolor+i].r,colors[firstcolor+i].g,colors[firstcolor+i].b,(unsigned char *)&SDL_XPixels[firstcolor+i]); | 1358 for (i = 0; i < ncolors; i++) { |
1294 } | 1359 SetSingleColor (fmt, colors[firstcolor + i].r, |
1360 colors[firstcolor + i].g, | |
1361 colors[firstcolor + i].b, (unsigned char *) | |
1362 &SDL_XPixels[firstcolor + i]); | |
1363 } | |
1295 #else | 1364 #else |
1296 // D(bug("Executing XPixel(%lx) remapping: (from %ld, %ld colors) first: r%ld g%ld b%ld\n",SDL_XPixels,firstcolor,ncolors,colors[firstcolor].r,colors[firstcolor].g,colors[firstcolor].b)); | 1365 // D(bug("Executing XPixel(%lx) remapping: (from %ld, %ld colors) first: r%ld g%ld b%ld\n",SDL_XPixels,firstcolor,ncolors,colors[firstcolor].r,colors[firstcolor].g,colors[firstcolor].b)); |
1297 for(i=0;i<ncolors;i++) | 1366 for (i = 0; i < ncolors; i++) |
1298 SDL_XPixels[i+firstcolor]=(colors[firstcolor+i].r<<16)+(colors[firstcolor+i].g<<8)+colors[firstcolor+i].b; | 1367 SDL_XPixels[i + firstcolor] = |
1368 (colors[firstcolor + i].r << 16) + | |
1369 (colors[firstcolor + i].g << 8) + colors[firstcolor + | |
1370 i].b; | |
1299 #endif | 1371 #endif |
1300 } | 1372 } |
1301 } | 1373 } |
1302 | 1374 |
1303 // Actually it cannot fail! | 1375 // Actually it cannot fail! |
1304 | 1376 |
1305 return 1; | 1377 return 1; |
1306 } | 1378 } |
1307 | 1379 |
1308 /* Note: If we are terminated, this could be called in the middle of | 1380 /* Note: If we are terminated, this could be called in the middle of |
1309 another SDL video routine -- notably UpdateRects. | 1381 another SDL video routine -- notably UpdateRects. |
1310 */ | 1382 */ |
1311 static void CGX_VideoQuit(_THIS) | 1383 static void |
1312 { | 1384 CGX_VideoQuit (_THIS) |
1313 /* Shutdown everything that's still up */ | 1385 { |
1314 /* The event thread should be done, so we can touch SDL_Display */ | 1386 /* Shutdown everything that's still up */ |
1315 D(bug("CGX_VideoQuit\n")); | 1387 /* The event thread should be done, so we can touch SDL_Display */ |
1316 | 1388 D (bug ("CGX_VideoQuit\n")); |
1317 if ( SDL_Display != NULL ) { | 1389 |
1318 /* Clean up OpenGL */ | 1390 if (SDL_Display != NULL) { |
1319 if(this->gl_data->gl_active == 1) { | 1391 /* Clean up OpenGL */ |
1320 CGX_GL_Quit(this); | 1392 if (this->gl_data->gl_active == 1) { |
1321 } | 1393 CGX_GL_Quit (this); |
1322 /* Start shutting down the windows */ | 1394 } |
1323 D(bug("Destroying image...\n")); | 1395 /* Start shutting down the windows */ |
1324 CGX_DestroyImage(this, this->screen); | 1396 D (bug ("Destroying image...\n")); |
1325 D(bug("Destroying window...\n")); | 1397 CGX_DestroyImage (this, this->screen); |
1326 CGX_DestroyWindow(this, this->screen); | 1398 D (bug ("Destroying window...\n")); |
1399 CGX_DestroyWindow (this, this->screen); | |
1327 // Otherwise SDL_VideoQuit will try to free it! | 1400 // Otherwise SDL_VideoQuit will try to free it! |
1328 SDL_VideoSurface=NULL; | 1401 SDL_VideoSurface = NULL; |
1329 | 1402 |
1330 CGX_FreeVideoModes(this); | 1403 CGX_FreeVideoModes (this); |
1331 | 1404 |
1332 /* Free that blank cursor */ | 1405 /* Free that blank cursor */ |
1333 if ( SDL_BlankCursor != NULL ) { | 1406 if (SDL_BlankCursor != NULL) { |
1334 FreeMem(SDL_BlankCursor,16); | 1407 FreeMem (SDL_BlankCursor, 16); |
1335 SDL_BlankCursor = NULL; | 1408 SDL_BlankCursor = NULL; |
1336 } | 1409 } |
1337 | 1410 |
1338 /* Close the X11 graphics connection */ | 1411 /* Close the X11 graphics connection */ |
1339 this->hidden->same_format=0; | 1412 this->hidden->same_format = 0; |
1340 | 1413 |
1341 D(bug("Destroying screen...\n")); | 1414 D (bug ("Destroying screen...\n")); |
1342 | 1415 |
1343 if ( GFX_Display != NULL ) | 1416 if (GFX_Display != NULL) |
1344 DestroyScreen(this); | 1417 DestroyScreen (this); |
1345 | 1418 |
1346 /* Close the X11 display connection */ | 1419 /* Close the X11 display connection */ |
1347 SDL_Display = NULL; | 1420 SDL_Display = NULL; |
1348 | 1421 |
1349 /* Unload GL library after X11 shuts down */ | 1422 /* Unload GL library after X11 shuts down */ |
1350 } | 1423 } |
1351 | 1424 |
1352 D(bug("Closing libraries...\n")); | 1425 D (bug ("Closing libraries...\n")); |
1353 | 1426 |
1354 if( CyberGfxBase) { | 1427 if (CyberGfxBase) { |
1355 CloseLibrary(CyberGfxBase); | 1428 CloseLibrary (CyberGfxBase); |
1356 CyberGfxBase=NULL; | 1429 CyberGfxBase = NULL; |
1357 } | 1430 } |
1358 | 1431 |
1359 if (IntuitionBase) { | 1432 if (IntuitionBase) { |
1360 CloseLibrary((struct Library *)IntuitionBase); | 1433 CloseLibrary ((struct Library *) IntuitionBase); |
1361 IntuitionBase=NULL; | 1434 IntuitionBase = NULL; |
1362 } | 1435 } |
1363 if (GfxBase) { | 1436 if (GfxBase) { |
1364 CloseLibrary((struct Library *)GfxBase); | 1437 CloseLibrary ((struct Library *) GfxBase); |
1365 GfxBase=NULL; | 1438 GfxBase = NULL; |
1366 } | 1439 } |
1367 | 1440 |
1368 if ( this->screen && (this->screen->flags & SDL_HWSURFACE) ) { | 1441 if (this->screen && (this->screen->flags & SDL_HWSURFACE)) { |
1369 /* Direct screen access, no memory buffer */ | 1442 /* Direct screen access, no memory buffer */ |
1370 this->screen->pixels = NULL; | 1443 this->screen->pixels = NULL; |
1371 } | 1444 } |
1372 D(bug("End of CGX_VideoQuit.\n")); | 1445 D (bug ("End of CGX_VideoQuit.\n")); |
1373 | 1446 |
1374 } | 1447 } |
1375 | 1448 |
1449 /* vi: set ts=4 sw=4 expandtab: */ |