Mercurial > sdl-ios-xcode
comparison src/video/cybergfx/SDL_cgxvideo.c @ 1895:c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Mon, 10 Jul 2006 21:04:37 +0000 |
parents | 8d9bb0cf2c2a |
children |
comparison
equal
deleted
inserted
replaced
1894:c69cee13dd76 | 1895:c121d94672cb |
---|---|
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 int height, int bpp, Uint32 flags); | |
48 static int CGX_ToggleFullScreen(_THIS, int on); | 49 static int CGX_ToggleFullScreen(_THIS, int on); |
49 static void CGX_UpdateMouse(_THIS); | 50 static void CGX_UpdateMouse(_THIS); |
50 static int CGX_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors); | 51 static int CGX_SetColors(_THIS, int firstcolor, int ncolors, |
52 SDL_Color * colors); | |
51 static void CGX_VideoQuit(_THIS); | 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 |
62 CGX_SetGamma(_THIS, float red, float green, float blue) | |
60 { | 63 { |
61 SDL_SetError("Gamma correction not supported"); | 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 |
69 CGX_GetGamma(_THIS, float red, float green, float blue) | |
66 { | 70 { |
67 SDL_SetError("Gamma correction not supported"); | 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 = MakeBitMask(this, 0, form, &this->hidden->depth); |
562 vformat->Rmask = MakeBitMask(this,0,form,&this->hidden->depth); | 566 vformat->Gmask = MakeBitMask(this, 1, form, &this->hidden->depth); |
563 vformat->Gmask = MakeBitMask(this,1,form,&this->hidden->depth); | 567 vformat->Bmask = MakeBitMask(this, 2, form, &this->hidden->depth); |
564 vformat->Bmask = MakeBitMask(this,2,form,&this->hidden->depth); | 568 } |
565 } | 569 } |
566 } | 570 |
567 | 571 /* See if we have been passed a window to use */ |
568 /* See if we have been passed a window to use */ | |
569 /* SDL_windowid = SDL_getenv("SDL_WINDOWID"); */ | 572 /* SDL_windowid = SDL_getenv("SDL_WINDOWID"); */ |
570 SDL_windowid=NULL; | 573 SDL_windowid = NULL; |
571 | 574 |
572 /* Create the blank cursor */ | 575 /* Create the blank cursor */ |
573 SDL_BlankCursor = AllocMem(16,MEMF_CHIP|MEMF_CLEAR); | 576 SDL_BlankCursor = AllocMem(16, MEMF_CHIP | MEMF_CLEAR); |
574 | 577 |
575 /* Fill in some window manager capabilities */ | 578 /* Fill in some window manager capabilities */ |
576 this->info.wm_available = 1; | 579 this->info.wm_available = 1; |
577 this->info.blit_hw = 1; | 580 this->info.blit_hw = 1; |
578 this->info.blit_hw_CC = 1; | 581 this->info.blit_hw_CC = 1; |
579 this->info.blit_sw = 1; | 582 this->info.blit_sw = 1; |
580 this->info.blit_fill = 1; | 583 this->info.blit_fill = 1; |
581 this->info.video_mem=2000000; // Not always true but almost any Amiga card has this memory! | 584 this->info.video_mem = 2000000; // Not always true but almost any Amiga card has this memory! |
582 | 585 |
583 this->hidden->same_format=0; | 586 this->hidden->same_format = 0; |
584 SDL_RastPort=&SDL_Display->RastPort; | 587 SDL_RastPort = &SDL_Display->RastPort; |
585 /* We're done! */ | 588 /* We're done! */ |
586 D(bug("End of CGX_VideoInit\n")); | 589 D(bug("End of CGX_VideoInit\n")); |
587 | 590 |
588 return(0); | 591 return (0); |
589 } | 592 } |
590 | 593 |
591 void CGX_DestroyWindow(_THIS, SDL_Surface *screen) | 594 void |
592 { | 595 CGX_DestroyWindow(_THIS, SDL_Surface * screen) |
593 D(bug("Destroy Window...\n")); | 596 { |
594 | 597 D(bug("Destroy Window...\n")); |
595 if ( ! SDL_windowid ) { | 598 |
596 /* Hide the managed window */ | 599 if (!SDL_windowid) { |
597 int was_fullscreen=0; | 600 /* Hide the managed window */ |
598 | 601 int was_fullscreen = 0; |
599 /* Clean up OpenGL */ | 602 |
600 if ( screen ) { | 603 /* Clean up OpenGL */ |
601 screen->flags &= ~(SDL_OPENGL|SDL_OPENGLBLIT); | 604 if (screen) { |
602 } | 605 screen->flags &= ~SDL_INTERNALOPENGL; |
603 | 606 } |
604 if ( screen && (screen->flags & SDL_FULLSCREEN) ) { | 607 |
605 was_fullscreen=1; | 608 if (screen && (screen->flags & SDL_FULLSCREEN)) { |
606 screen->flags &= ~SDL_FULLSCREEN; | 609 was_fullscreen = 1; |
607 // CGX_LeaveFullScreen(this); tolto x crash | 610 screen->flags &= ~SDL_FULLSCREEN; |
608 } | 611 // CGX_LeaveFullScreen(this); tolto x crash |
609 | 612 } |
610 /* Destroy the output window */ | 613 |
611 if ( SDL_Window ) { | 614 /* Destroy the output window */ |
612 CloseWindow(SDL_Window); | 615 if (SDL_Window) { |
613 SDL_Window=NULL; | 616 CloseWindow(SDL_Window); |
614 } | 617 SDL_Window = NULL; |
615 | 618 } |
616 /* Free the colormap entries */ | 619 |
617 if ( SDL_XPixels ) { | 620 /* Free the colormap entries */ |
618 int numcolors; | 621 if (SDL_XPixels) { |
619 unsigned long pixel; | 622 int numcolors; |
620 | 623 unsigned long pixel; |
621 if(this->screen->format&&this->hidden->depth==8&&!was_fullscreen) | 624 |
622 { | 625 if (this->screen->format && this->hidden->depth == 8 |
623 numcolors = 1<<this->screen->format->BitsPerPixel; | 626 && !was_fullscreen) { |
624 | 627 numcolors = 1 << this->screen->format->BitsPerPixel; |
625 if(numcolors>256) | 628 |
626 numcolors=256; | 629 if (numcolors > 256) |
627 | 630 numcolors = 256; |
628 if(!was_fullscreen&&this->hidden->depth==8) | 631 |
629 { | 632 if (!was_fullscreen && this->hidden->depth == 8) { |
630 for ( pixel=0; pixel<numcolors; pixel++ ) | 633 for (pixel = 0; pixel < numcolors; pixel++) { |
631 { | 634 if (SDL_XPixels[pixel] >= 0) |
632 if(SDL_XPixels[pixel]>=0) | 635 ReleasePen(GFX_Display->ViewPort. |
633 ReleasePen(GFX_Display->ViewPort.ColorMap,SDL_XPixels[pixel]); | 636 ColorMap, SDL_XPixels[pixel]); |
634 } | 637 } |
635 } | 638 } |
636 } | 639 } |
637 SDL_free(SDL_XPixels); | 640 SDL_free(SDL_XPixels); |
638 SDL_XPixels = NULL; | 641 SDL_XPixels = NULL; |
639 } | 642 } |
640 } | 643 } |
641 } | 644 } |
642 | 645 |
643 static void CGX_SetSizeHints(_THIS, int w, int h, Uint32 flags) | 646 static void |
644 { | 647 CGX_SetSizeHints(_THIS, int w, int h, Uint32 flags) |
645 if ( flags & SDL_RESIZABLE ) { | 648 { |
646 WindowLimits(SDL_Window, 32, 32,4096,4096); | 649 if (flags & SDL_RESIZABLE) { |
647 } else { | 650 WindowLimits(SDL_Window, 32, 32, 4096, 4096); |
648 WindowLimits(SDL_Window, w,h,w,h); | 651 } else { |
649 } | 652 WindowLimits(SDL_Window, w, h, w, h); |
650 if ( flags & SDL_FULLSCREEN ) { | 653 } |
651 flags&=~SDL_RESIZABLE; | 654 if (flags & SDL_FULLSCREEN) { |
652 } else if ( SDL_getenv("SDL_VIDEO_CENTERED") ) { | 655 flags &= ~SDL_RESIZABLE; |
653 int display_w, display_h; | 656 } else if (SDL_getenv("SDL_VIDEO_CENTERED")) { |
654 | 657 int display_w, display_h; |
655 display_w = SDL_Display->Width; | 658 |
656 display_h = SDL_Display->Height; | 659 display_w = SDL_Display->Width; |
657 ChangeWindowBox(SDL_Window,(display_w - w - SDL_Window->BorderLeft-SDL_Window->BorderRight)/2, | 660 display_h = SDL_Display->Height; |
658 (display_h - h - SDL_Window->BorderTop-SDL_Window->BorderBottom)/2, | 661 ChangeWindowBox(SDL_Window, |
659 w+SDL_Window->BorderLeft+SDL_Window->BorderRight, | 662 (display_w - w - SDL_Window->BorderLeft - |
660 h+SDL_Window->BorderTop+SDL_Window->BorderBottom); | 663 SDL_Window->BorderRight) / 2, |
661 } | 664 (display_h - h - SDL_Window->BorderTop - |
662 } | 665 SDL_Window->BorderBottom) / 2, |
663 | 666 w + SDL_Window->BorderLeft + |
664 int CGX_CreateWindow(_THIS, SDL_Surface *screen, | 667 SDL_Window->BorderRight, |
665 int w, int h, int bpp, Uint32 flags) | 668 h + SDL_Window->BorderTop + SDL_Window->BorderBottom); |
669 } | |
670 } | |
671 | |
672 int | |
673 CGX_CreateWindow(_THIS, SDL_Surface * screen, | |
674 int w, int h, int bpp, Uint32 flags) | |
666 { | 675 { |
667 #if 0 | 676 #if 0 |
668 int i, depth; | 677 int i, depth; |
669 Uint32 vis; | 678 Uint32 vis; |
670 #endif | 679 #endif |
671 D(bug("CGX_CreateWindow\n")); | 680 D(bug("CGX_CreateWindow\n")); |
672 | 681 |
673 /* If a window is already present, destroy it and start fresh */ | 682 /* If a window is already present, destroy it and start fresh */ |
674 if ( SDL_Window ) { | 683 if (SDL_Window) { |
675 CGX_DestroyWindow(this, screen); | 684 CGX_DestroyWindow(this, screen); |
676 } | 685 } |
677 | 686 |
678 /* See if we have been given a window id */ | 687 /* See if we have been given a window id */ |
679 if ( SDL_windowid ) { | 688 if (SDL_windowid) { |
680 SDL_Window = (struct Window *)atol(SDL_windowid); | 689 SDL_Window = (struct Window *) atol(SDL_windowid); |
681 } else { | 690 } else { |
682 SDL_Window = 0; | 691 SDL_Window = 0; |
683 } | 692 } |
684 | 693 |
685 /* find out which visual we are going to use */ | 694 /* find out which visual we are going to use */ |
686 #if 0 | 695 #if 0 |
687 /* questo l'ho spostato nell'apertura dello schermo, in quanto su Amiga le finestre | 696 /* questo l'ho spostato nell'apertura dello schermo, in quanto su Amiga le finestre |
688 hanno il pixel mode degli schermi. | 697 hanno il pixel mode degli schermi. |
689 */ | 698 */ |
690 /*if ( flags & SDL_OPENGL ) { | 699 /*if ( flags & SDL_INTERNALOPENGL ) { |
691 SDL_SetError("OpenGL not supported by the Amiga SDL!"); | 700 SDL_SetError("OpenGL not supported by the Amiga SDL!"); |
692 return -1; | 701 return -1; |
693 } | 702 } |
694 else {*/ | 703 else { */ |
695 for ( i = 0; i < this->hidden->nvisuals; i++ ) { | 704 for (i = 0; i < this->hidden->nvisuals; i++) { |
696 if ( this->hidden->visuals[i].depth == bpp ) /* era .depth */ | 705 if (this->hidden->visuals[i].depth == bpp) /* era .depth */ |
697 break; | 706 break; |
698 } | 707 } |
699 if ( i == this->hidden->nvisuals ) { | 708 if (i == this->hidden->nvisuals) { |
700 SDL_SetError("No matching visual for requested depth"); | 709 SDL_SetError("No matching visual for requested depth"); |
701 return -1; /* should never happen */ | 710 return -1; /* should never happen */ |
702 } | 711 } |
703 vis = this->hidden->visuals[i].visual; | 712 vis = this->hidden->visuals[i].visual; |
704 depth = this->hidden->visuals[i].depth; | 713 depth = this->hidden->visuals[i].depth; |
705 // } | 714 // } |
706 SDL_Visual = vis; | 715 SDL_Visual = vis; |
707 this->hidden->depth = depth; | 716 this->hidden->depth = depth; |
708 D(bug("Setting screen depth to: %ld\n",this->hidden->depth)); | 717 D(bug("Setting screen depth to: %ld\n", this->hidden->depth)); |
709 #endif | 718 #endif |
710 | 719 |
711 /* Allocate the new pixel format for this video mode */ | 720 /* Allocate the new pixel format for this video mode */ |
712 { | 721 { |
713 Uint32 form; | 722 Uint32 form; |
714 APTR handle; | 723 APTR handle; |
715 struct DisplayInfo info; | 724 struct DisplayInfo info; |
716 | 725 |
717 if(!(handle=FindDisplayInfo(SDL_Visual))) | 726 if (!(handle = FindDisplayInfo(SDL_Visual))) |
718 return -1; | 727 return -1; |
719 | 728 |
720 if(!GetDisplayInfoData(handle,(char *)&info,sizeof(struct DisplayInfo),DTAG_DISP,NULL)) | 729 if (!GetDisplayInfoData |
721 return -1; | 730 (handle, (char *) &info, sizeof(struct DisplayInfo), DTAG_DISP, |
722 | 731 NULL)) |
723 form=GetCyberIDAttr(CYBRIDATTR_PIXFMT,SDL_Visual); | 732 return -1; |
724 | 733 |
725 if(flags&SDL_HWSURFACE) | 734 form = GetCyberIDAttr(CYBRIDATTR_PIXFMT, SDL_Visual); |
726 { | 735 |
727 if(bpp!=this->hidden->depth) | 736 if (flags & SDL_HWSURFACE) { |
728 { | 737 if (bpp != this->hidden->depth) { |
729 bpp=this->hidden->depth; | 738 bpp = this->hidden->depth; |
730 D(bug("Accel forces bpp to be equal (%ld)\n",bpp)); | 739 D(bug("Accel forces bpp to be equal (%ld)\n", bpp)); |
731 } | 740 } |
732 } | 741 } |
733 | 742 |
734 D(bug("BEFORE screen allocation: bpp:%ld (real:%ld)\n",bpp,this->hidden->depth)); | 743 D(bug |
744 ("BEFORE screen allocation: bpp:%ld (real:%ld)\n", bpp, | |
745 this->hidden->depth)); | |
735 | 746 |
736 /* With this call if needed I'll revert the wanted bpp to a bpp best suited for the display, actually occurs | 747 /* 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 | 748 only with requested format 15/16bit and display format != 15/16bit |
738 */ | 749 */ |
739 | 750 |
740 if ( ! SDL_ReallocFormat(screen, bpp, | 751 if (!SDL_ReallocFormat(screen, bpp, |
741 MakeBitMask(this,0,form,&bpp), MakeBitMask(this,1,form,&bpp), MakeBitMask(this,2,form,&bpp), 0) ) | 752 MakeBitMask(this, 0, form, &bpp), |
742 return -1; | 753 MakeBitMask(this, 1, form, &bpp), |
743 | 754 MakeBitMask(this, 2, form, &bpp), 0)) |
744 D(bug("AFTER screen allocation: bpp:%ld (real:%ld)\n",bpp,this->hidden->depth)); | 755 return -1; |
745 | 756 |
746 } | 757 D(bug |
747 | 758 ("AFTER screen allocation: bpp:%ld (real:%ld)\n", bpp, |
748 /* Create the appropriate colormap */ | 759 this->hidden->depth)); |
760 | |
761 } | |
762 | |
763 /* Create the appropriate colormap */ | |
749 /* | 764 /* |
750 if ( SDL_XColorMap != SDL_DisplayColormap ) { | 765 if ( SDL_XColorMap != SDL_DisplayColormap ) { |
751 XFreeColormap(SDL_Display, SDL_XColorMap); | 766 XFreeColormap(SDL_Display, SDL_XColorMap); |
752 } | 767 } |
753 */ | 768 */ |
754 if ( GetCyberMapAttr(SDL_Display->RastPort.BitMap,CYBRMATTR_PIXFMT)==PIXFMT_LUT8 || bpp==8 ) { | 769 if (GetCyberMapAttr(SDL_Display->RastPort.BitMap, CYBRMATTR_PIXFMT) == |
755 int ncolors,i; | 770 PIXFMT_LUT8 || bpp == 8) { |
756 D(bug("XPixels palette allocation...\n")); | 771 int ncolors, i; |
757 | 772 D(bug("XPixels palette allocation...\n")); |
758 /* Allocate the pixel flags */ | 773 |
759 | 774 /* Allocate the pixel flags */ |
760 if(bpp==8) | 775 |
761 ncolors=256; | 776 if (bpp == 8) |
762 else | 777 ncolors = 256; |
763 ncolors = 1 << screen->format->BitsPerPixel; | 778 else |
764 | 779 ncolors = 1 << screen->format->BitsPerPixel; |
765 SDL_XPixels = (Sint32 *)SDL_malloc(ncolors * sizeof(Sint32)); | 780 |
766 | 781 SDL_XPixels = (Sint32 *) SDL_malloc(ncolors * sizeof(Sint32)); |
767 if(SDL_XPixels == NULL) { | 782 |
768 SDL_OutOfMemory(); | 783 if (SDL_XPixels == NULL) { |
769 return -1; | 784 SDL_OutOfMemory(); |
770 } | 785 return -1; |
771 | 786 } |
772 | 787 |
773 for(i=0;i<ncolors;i++) | 788 |
774 SDL_XPixels[i]=-1; | 789 for (i = 0; i < ncolors; i++) |
775 | 790 SDL_XPixels[i] = -1; |
776 /* always allocate a private colormap on non-default visuals */ | 791 |
777 if(bpp==8) | 792 /* always allocate a private colormap on non-default visuals */ |
778 flags |= SDL_HWPALETTE; | 793 if (bpp == 8) |
779 | 794 flags |= SDL_HWPALETTE; |
780 if ( flags & SDL_HWPALETTE ) | 795 |
781 screen->flags |= SDL_HWPALETTE; | 796 if (flags & SDL_HWPALETTE) |
782 } | 797 screen->flags |= SDL_HWPALETTE; |
783 | 798 } |
784 /* resize the (possibly new) window manager window */ | 799 |
785 | 800 /* resize the (possibly new) window manager window */ |
786 /* Create (or use) the X11 display window */ | 801 |
787 | 802 /* Create (or use) the X11 display window */ |
788 if ( !SDL_windowid ) { | 803 |
789 if( flags & SDL_FULLSCREEN ) | 804 if (!SDL_windowid) { |
790 { | 805 if (flags & SDL_FULLSCREEN) { |
791 SDL_Window = OpenWindowTags(NULL,WA_Width,w,WA_Height,h, | 806 SDL_Window = OpenWindowTags(NULL, WA_Width, w, WA_Height, h, |
792 WA_Flags,WFLG_ACTIVATE|WFLG_RMBTRAP|WFLG_BORDERLESS|WFLG_BACKDROP|WFLG_REPORTMOUSE, | 807 WA_Flags, |
793 WA_IDCMP,IDCMP_RAWKEY|IDCMP_MOUSEBUTTONS|IDCMP_MOUSEMOVE, | 808 WFLG_ACTIVATE | WFLG_RMBTRAP | |
794 WA_CustomScreen,(ULONG)SDL_Display, | 809 WFLG_BORDERLESS | WFLG_BACKDROP | |
795 TAG_DONE); | 810 WFLG_REPORTMOUSE, WA_IDCMP, |
796 | 811 IDCMP_RAWKEY | IDCMP_MOUSEBUTTONS |
797 D(bug("Opening backdrop window %ldx%ld on display %lx!\n",w,h,SDL_Display)); | 812 | IDCMP_MOUSEMOVE, |
798 } | 813 WA_CustomScreen, |
799 else | 814 (ULONG) SDL_Display, TAG_DONE); |
800 { | 815 |
801 /* Create GimmeZeroZero window when OpenGL is used */ | 816 D(bug |
802 unsigned long gzz = FALSE; | 817 ("Opening backdrop window %ldx%ld on display %lx!\n", w, h, |
803 if( flags & SDL_OPENGL ) { | 818 SDL_Display)); |
804 gzz = TRUE; | 819 } else { |
805 } | 820 /* Create GimmeZeroZero window when OpenGL is used */ |
806 | 821 unsigned long gzz = FALSE; |
807 SDL_Window = OpenWindowTags(NULL,WA_InnerWidth,w,WA_InnerHeight,h, | 822 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))), | 823 gzz = TRUE; |
809 WA_IDCMP,IDCMP_RAWKEY|IDCMP_CLOSEWINDOW|IDCMP_MOUSEBUTTONS|IDCMP_NEWSIZE|IDCMP_MOUSEMOVE, | 824 } |
810 WA_PubScreen,(ULONG)SDL_Display, | 825 |
811 WA_GimmeZeroZero, gzz, | 826 SDL_Window = |
812 TAG_DONE); | 827 OpenWindowTags(NULL, WA_InnerWidth, w, WA_InnerHeight, h, |
813 D(bug("Opening WB window of size: %ldx%ld!\n",w,h)); | 828 WA_Flags, |
814 } | 829 WFLG_REPORTMOUSE | WFLG_ACTIVATE | |
815 | 830 WFLG_RMBTRAP | ((flags & SDL_NOFRAME) ? 0 |
816 if(!SDL_Window) | 831 : (WFLG_DEPTHGADGET | |
817 return -1; | 832 WFLG_CLOSEGADGET | |
818 } | 833 WFLG_DRAGBAR | |
819 | 834 ((flags & |
820 this->hidden->BytesPerPixel=GetCyberMapAttr(SDL_Window->RPort->BitMap,CYBRMATTR_BPPIX); | 835 SDL_RESIZABLE) ? |
821 | 836 WFLG_SIZEGADGET | |
822 if(screen->flags & SDL_DOUBLEBUF) | 837 WFLG_SIZEBBOTTOM : |
823 { | 838 0))), WA_IDCMP, |
824 if(SDL_RastPort=SDL_malloc(sizeof(struct RastPort))) | 839 IDCMP_RAWKEY | IDCMP_CLOSEWINDOW | |
825 { | 840 IDCMP_MOUSEBUTTONS | IDCMP_NEWSIZE | |
826 InitRastPort(SDL_RastPort); | 841 IDCMP_MOUSEMOVE, WA_PubScreen, |
827 SDL_RastPort->BitMap=this->hidden->SB[1]->sb_BitMap; | 842 (ULONG) SDL_Display, WA_GimmeZeroZero, |
828 } | 843 gzz, TAG_DONE); |
829 else | 844 D(bug("Opening WB window of size: %ldx%ld!\n", w, h)); |
830 return -1; | 845 } |
831 } | 846 |
832 else SDL_RastPort=SDL_Window->RPort; | 847 if (!SDL_Window) |
833 | 848 return -1; |
834 if(flags&SDL_HWSURFACE) | 849 } |
835 screen->flags|=SDL_HWSURFACE; | 850 |
836 | 851 this->hidden->BytesPerPixel = |
837 if( !SDL_windowid ) { | 852 GetCyberMapAttr(SDL_Window->RPort->BitMap, CYBRMATTR_BPPIX); |
838 CGX_SetSizeHints(this, w, h, flags); | 853 |
839 } | 854 if (screen->flags & SDL_DOUBLEBUF) { |
840 | 855 if (SDL_RastPort = SDL_malloc(sizeof(struct RastPort))) { |
841 /* Set our colormaps when not setting a GL mode */ | 856 InitRastPort(SDL_RastPort); |
857 SDL_RastPort->BitMap = this->hidden->SB[1]->sb_BitMap; | |
858 } else | |
859 return -1; | |
860 } else | |
861 SDL_RastPort = SDL_Window->RPort; | |
862 | |
863 if (flags & SDL_HWSURFACE) | |
864 screen->flags |= SDL_HWSURFACE; | |
865 | |
866 if (!SDL_windowid) { | |
867 CGX_SetSizeHints(this, w, h, flags); | |
868 } | |
869 | |
870 /* Set our colormaps when not setting a GL mode */ | |
842 /* | 871 /* |
843 if ( ! (flags & SDL_OPENGL) ) { | 872 if ( ! (flags & SDL_INTERNALOPENGL) ) { |
844 XSetWindowColormap(SDL_Display, SDL_Window, SDL_XColorMap); | 873 XSetWindowColormap(SDL_Display, SDL_Window, SDL_XColorMap); |
845 } | 874 } |
846 */ | 875 */ |
847 | 876 |
848 /* Map them both and go fullscreen, if requested */ | 877 /* Map them both and go fullscreen, if requested */ |
849 if ( ! SDL_windowid ) { | 878 if (!SDL_windowid) { |
850 if ( flags & SDL_FULLSCREEN ) { | 879 if (flags & SDL_FULLSCREEN) { |
851 screen->flags |= SDL_FULLSCREEN; | 880 screen->flags |= SDL_FULLSCREEN; |
852 currently_fullscreen=1; | 881 currently_fullscreen = 1; |
853 // CGX_EnterFullScreen(this); Ci siamo gia'! | 882 // CGX_EnterFullScreen(this); Ci siamo gia'! |
854 } else { | 883 } else { |
855 screen->flags &= ~SDL_FULLSCREEN; | 884 screen->flags &= ~SDL_FULLSCREEN; |
856 } | 885 } |
857 } | 886 } |
858 screen->w = w; | 887 screen->w = w; |
859 screen->h = h; | 888 screen->h = h; |
860 screen->pitch = SDL_CalculatePitch(screen); | 889 screen->pitch = SDL_CalculatePitch(screen); |
861 CGX_ResizeImage(this, screen, flags); | 890 CGX_ResizeImage(this, screen, flags); |
862 | 891 |
863 /* Make OpenGL Context if needed*/ | 892 /* Make OpenGL Context if needed */ |
864 if(flags & SDL_OPENGL) { | 893 if (flags & SDL_INTERNALOPENGL) { |
865 if(this->gl_data->gl_active == 0) { | 894 if (this->gl_data->gl_active == 0) { |
866 if(CGX_GL_Init(this) < 0) | 895 if (CGX_GL_Init(this) < 0) |
867 return -1; | 896 return -1; |
868 else | 897 else |
869 screen->flags |= SDL_OPENGL; | 898 screen->flags |= SDL_INTERNALOPENGL; |
870 } | 899 } else { |
871 else { | 900 if (CGX_GL_Update(this) < 0) |
872 if(CGX_GL_Update(this) < 0) | 901 return -1; |
873 return -1; | 902 else |
874 else | 903 screen->flags |= SDL_INTERNALOPENGL; |
875 screen->flags |= SDL_OPENGL; | 904 } |
876 } | 905 } |
877 } | 906 } |
878 } | 907 |
879 | 908 int |
880 int CGX_ResizeWindow(_THIS, | 909 CGX_ResizeWindow(_THIS, SDL_Surface * screen, int w, int h, Uint32 flags) |
881 SDL_Surface *screen, int w, int h, Uint32 flags) | 910 { |
882 { | 911 D(bug("CGX_ResizeWindow\n")); |
883 D(bug("CGX_ResizeWindow\n")); | 912 |
884 | 913 if (!SDL_windowid) { |
885 if ( ! SDL_windowid ) { | 914 /* Resize the window manager window */ |
886 /* Resize the window manager window */ | 915 CGX_SetSizeHints(this, w, h, flags); |
887 CGX_SetSizeHints(this, w, h, flags); | 916 |
888 | 917 ChangeWindowBox(SDL_Window, SDL_Window->LeftEdge, |
889 ChangeWindowBox(SDL_Window,SDL_Window->LeftEdge,SDL_Window->TopEdge, w+SDL_Window->BorderLeft+SDL_Window->BorderRight, | 918 SDL_Window->TopEdge, |
890 h+SDL_Window->BorderTop+SDL_Window->BorderBottom); | 919 w + SDL_Window->BorderLeft + |
891 | 920 SDL_Window->BorderRight, |
892 screen->w = w; | 921 h + SDL_Window->BorderTop + SDL_Window->BorderBottom); |
893 screen->h = h; | 922 |
894 screen->pitch = SDL_CalculatePitch(screen); | 923 screen->w = w; |
895 CGX_ResizeImage(this, screen, flags); | 924 screen->h = h; |
896 } | 925 screen->pitch = SDL_CalculatePitch(screen); |
897 return(0); | 926 CGX_ResizeImage(this, screen, flags); |
898 } | 927 } |
899 | 928 return (0); |
900 static SDL_Surface *CGX_SetVideoMode(_THIS, SDL_Surface *current, | 929 } |
901 int width, int height, int bpp, Uint32 flags) | 930 |
902 { | 931 static SDL_Surface * |
903 Uint32 saved_flags; | 932 CGX_SetVideoMode(_THIS, SDL_Surface * current, |
904 int needcreate=0; | 933 int width, int height, int bpp, Uint32 flags) |
905 | 934 { |
906 D(bug("CGX_SetVideoMode current:%lx\n",current)); | 935 Uint32 saved_flags; |
907 | 936 int needcreate = 0; |
908 /* Lock the event thread, in multi-threading environments */ | 937 |
909 SDL_Lock_EventThread(); | 938 D(bug("CGX_SetVideoMode current:%lx\n", current)); |
939 | |
940 /* Lock the event thread, in multi-threading environments */ | |
941 SDL_Lock_EventThread(); | |
910 | 942 |
911 // Check if the window needs to be closed or can be resized | 943 // Check if the window needs to be closed or can be resized |
912 | 944 |
913 if( (flags&SDL_FULLSCREEN) || (current && current->flags&SDL_FULLSCREEN && !(flags&SDL_FULLSCREEN))) | 945 if ((flags & SDL_FULLSCREEN) |
914 needcreate=1; | 946 || (current && current->flags & SDL_FULLSCREEN |
947 && !(flags & SDL_FULLSCREEN))) | |
948 needcreate = 1; | |
915 | 949 |
916 // Check if we need to close an already existing videomode... | 950 // Check if we need to close an already existing videomode... |
917 | 951 |
918 if(current && current->flags&SDL_FULLSCREEN && !(flags&SDL_FULLSCREEN)) { | 952 if (current && current->flags & SDL_FULLSCREEN |
919 unsigned long i; | 953 && !(flags & SDL_FULLSCREEN)) { |
920 D(bug("Destroying image, window & screen!\n")); | 954 unsigned long i; |
921 | 955 D(bug("Destroying image, window & screen!\n")); |
922 CGX_DestroyImage(this,current); | 956 |
923 CGX_DestroyWindow(this,current); | 957 CGX_DestroyImage(this, current); |
924 DestroyScreen(this); | 958 CGX_DestroyWindow(this, current); |
925 GFX_Display=SDL_Display=LockPubScreen(NULL); | 959 DestroyScreen(this); |
926 | 960 GFX_Display = SDL_Display = LockPubScreen(NULL); |
927 bpp=this->hidden->depth=GetCyberMapAttr(SDL_Display->RastPort.BitMap,CYBRMATTR_DEPTH); | 961 |
928 | 962 bpp = this->hidden->depth = |
929 for ( i = 0; i < this->hidden->nvisuals; i++ ) { | 963 GetCyberMapAttr(SDL_Display->RastPort.BitMap, CYBRMATTR_DEPTH); |
930 if ( this->hidden->visuals[i].depth == bpp ) /* era .depth */ | 964 |
931 break; | 965 for (i = 0; i < this->hidden->nvisuals; i++) { |
932 } | 966 if (this->hidden->visuals[i].depth == bpp) /* era .depth */ |
933 if ( i == this->hidden->nvisuals ) { | 967 break; |
934 SDL_SetError("No matching visual for requested depth"); | 968 } |
935 return NULL; /* should never happen */ | 969 if (i == this->hidden->nvisuals) { |
936 } | 970 SDL_SetError("No matching visual for requested depth"); |
937 SDL_Visual = this->hidden->visuals[i].visual; | 971 return NULL; /* should never happen */ |
938 | 972 } |
939 D(bug("Setting screen depth to: %ld\n",this->hidden->depth)); | 973 SDL_Visual = this->hidden->visuals[i].visual; |
940 | 974 |
941 } | 975 D(bug("Setting screen depth to: %ld\n", this->hidden->depth)); |
942 /* Check the combination of flags we were passed */ | 976 |
943 if ( flags & SDL_FULLSCREEN ) { | 977 } |
944 int i; | 978 /* Check the combination of flags we were passed */ |
945 | 979 if (flags & SDL_FULLSCREEN) { |
946 /* Clear fullscreen flag if not supported */ | 980 int i; |
947 if ( SDL_windowid ) { | 981 |
948 flags &= ~SDL_FULLSCREEN; | 982 /* Clear fullscreen flag if not supported */ |
949 } | 983 if (SDL_windowid) { |
950 else if(current && current->flags&SDL_FULLSCREEN ) { | 984 flags &= ~SDL_FULLSCREEN; |
951 if(current->w!=width || | 985 } else if (current && current->flags & SDL_FULLSCREEN) { |
952 current->h!=height || | 986 if (current->w != width || |
953 (this->hidden && this->hidden->depth!=bpp)) | 987 current->h != height || |
954 { | 988 (this->hidden && this->hidden->depth != bpp)) { |
955 D(bug("Deleting previous window...\n")); | 989 D(bug("Deleting previous window...\n")); |
956 CGX_DestroyImage(this,current); | 990 CGX_DestroyImage(this, current); |
957 CGX_DestroyWindow(this,current); | 991 CGX_DestroyWindow(this, current); |
958 DestroyScreen(this); | 992 DestroyScreen(this); |
959 goto buildnewscreen; | 993 goto buildnewscreen; |
960 } | 994 } |
961 } | 995 } else |
962 else | 996 buildnewscreen: |
963 buildnewscreen: | 997 { |
964 { | 998 Uint32 okid = BestCModeIDTags(CYBRBIDTG_NominalWidth, width, |
965 Uint32 okid=BestCModeIDTags(CYBRBIDTG_NominalWidth,width, | 999 CYBRBIDTG_NominalHeight, |
966 CYBRBIDTG_NominalHeight,height, | 1000 height, |
967 CYBRBIDTG_Depth,bpp, | 1001 CYBRBIDTG_Depth, bpp, |
968 TAG_DONE); | 1002 TAG_DONE); |
969 | 1003 |
970 GFX_Display=NULL; | 1004 GFX_Display = NULL; |
971 | 1005 |
972 D(bug("Opening screen...\n")); | 1006 D(bug("Opening screen...\n")); |
973 | 1007 |
974 if(okid!=INVALID_ID) | 1008 if (okid != INVALID_ID) |
975 GFX_Display=OpenScreenTags(NULL, | 1009 GFX_Display = OpenScreenTags(NULL, |
976 SA_Width,width, | 1010 SA_Width, width, |
977 SA_Height,height, | 1011 SA_Height, height, |
978 SA_Quiet,TRUE,SA_ShowTitle,FALSE, | 1012 SA_Quiet, TRUE, |
979 SA_Depth,bpp, | 1013 SA_ShowTitle, FALSE, |
980 SA_DisplayID,okid, | 1014 SA_Depth, bpp, SA_DisplayID, |
981 TAG_DONE); | 1015 okid, TAG_DONE); |
982 | 1016 |
983 if(!GFX_Display) { | 1017 if (!GFX_Display) { |
984 GFX_Display=SDL_Display; | 1018 GFX_Display = SDL_Display; |
985 flags &= ~SDL_FULLSCREEN; | 1019 flags &= ~SDL_FULLSCREEN; |
986 flags &= ~SDL_DOUBLEBUF; | 1020 flags &= ~SDL_DOUBLEBUF; |
987 } | 1021 } else { |
988 else { | 1022 UnlockPubScreen(NULL, SDL_Display); |
989 UnlockPubScreen(NULL,SDL_Display); | 1023 SDL_Display = GFX_Display; |
990 SDL_Display=GFX_Display; | 1024 |
991 | 1025 D(bug("Screen opened.\n")); |
992 D(bug("Screen opened.\n")); | 1026 |
993 | 1027 if (flags & SDL_DOUBLEBUF) { |
994 if(flags&SDL_DOUBLEBUF) { | 1028 int ok = 0; |
995 int ok=0; | 1029 D(bug("Start of DBuffering allocations...\n")); |
996 D(bug("Start of DBuffering allocations...\n")); | 1030 |
997 | 1031 if (this->hidden->SB[0] = |
998 if(this->hidden->SB[0]=AllocScreenBuffer(SDL_Display,NULL,SB_SCREEN_BITMAP)) { | 1032 AllocScreenBuffer(SDL_Display, NULL, |
999 | 1033 SB_SCREEN_BITMAP)) { |
1000 if(this->hidden->SB[1]=AllocScreenBuffer(SDL_Display,NULL,0L)) { | 1034 |
1001 extern struct MsgPort *safeport,*dispport; | 1035 if (this->hidden->SB[1] = |
1002 | 1036 AllocScreenBuffer(SDL_Display, NULL, 0L)) { |
1003 safeport=CreateMsgPort(); | 1037 extern struct MsgPort *safeport, *dispport; |
1004 dispport=CreateMsgPort(); | 1038 |
1005 | 1039 safeport = CreateMsgPort(); |
1006 if(!safeport || !dispport) { | 1040 dispport = CreateMsgPort(); |
1007 if(safeport) { | 1041 |
1008 DeleteMsgPort(safeport); | 1042 if (!safeport || !dispport) { |
1009 safeport=NULL; | 1043 if (safeport) { |
1010 } | 1044 DeleteMsgPort(safeport); |
1011 if(dispport) { | 1045 safeport = NULL; |
1012 DeleteMsgPort(dispport); | 1046 } |
1013 dispport=NULL; | 1047 if (dispport) { |
1014 } | 1048 DeleteMsgPort(dispport); |
1015 FreeScreenBuffer(SDL_Display,this->hidden->SB[0]); | 1049 dispport = NULL; |
1016 FreeScreenBuffer(SDL_Display,this->hidden->SB[1]); | 1050 } |
1017 } | 1051 FreeScreenBuffer(SDL_Display, |
1018 else { | 1052 this->hidden->SB[0]); |
1019 extern ULONG safe_sigbit,disp_sigbit; | 1053 FreeScreenBuffer(SDL_Display, |
1020 int i; | 1054 this->hidden->SB[1]); |
1021 | 1055 } else { |
1022 safe_sigbit=1L<< safeport->mp_SigBit; | 1056 extern ULONG safe_sigbit, disp_sigbit; |
1023 disp_sigbit=1L<< dispport->mp_SigBit; | 1057 int i; |
1024 | 1058 |
1025 for(i=0;i<2;i++) { | 1059 safe_sigbit = 1L << safeport->mp_SigBit; |
1026 this->hidden->SB[i]->sb_DBufInfo->dbi_SafeMessage.mn_ReplyPort=safeport; | 1060 disp_sigbit = 1L << dispport->mp_SigBit; |
1027 this->hidden->SB[i]->sb_DBufInfo->dbi_DispMessage.mn_ReplyPort=dispport; | 1061 |
1028 } | 1062 for (i = 0; i < 2; i++) { |
1029 | 1063 this->hidden->SB[i]-> |
1030 ok=1; | 1064 sb_DBufInfo-> |
1031 D(bug("Dbuffering enabled!\n")); | 1065 dbi_SafeMessage. |
1032 this->hidden->dbuffer=1; | 1066 mn_ReplyPort = safeport; |
1033 current->flags|=SDL_DOUBLEBUF; | 1067 this->hidden->SB[i]-> |
1034 } | 1068 sb_DBufInfo-> |
1035 } | 1069 dbi_DispMessage. |
1036 else { | 1070 mn_ReplyPort = dispport; |
1037 FreeScreenBuffer(SDL_Display,this->hidden->SB[1]); | 1071 } |
1038 this->hidden->SB[0]=NULL; | 1072 |
1039 } | 1073 ok = 1; |
1040 } | 1074 D(bug("Dbuffering enabled!\n")); |
1041 | 1075 this->hidden->dbuffer = 1; |
1042 if(!ok) | 1076 current->flags |= SDL_DOUBLEBUF; |
1043 flags&=~SDL_DOUBLEBUF; | 1077 } |
1044 } | 1078 } else { |
1045 } | 1079 FreeScreenBuffer(SDL_Display, |
1046 | 1080 this->hidden->SB[1]); |
1047 if(GetCyberMapAttr(SDL_Display->RastPort.BitMap,CYBRMATTR_DEPTH)==bpp) | 1081 this->hidden->SB[0] = NULL; |
1048 this->hidden->same_format=1; | 1082 } |
1049 } | 1083 } |
1050 | 1084 |
1051 bpp=this->hidden->depth=GetCyberMapAttr(SDL_Display->RastPort.BitMap,CYBRMATTR_DEPTH); | 1085 if (!ok) |
1052 D(bug("Setting screen depth to: %ld\n",this->hidden->depth)); | 1086 flags &= ~SDL_DOUBLEBUF; |
1053 | 1087 } |
1054 for ( i = 0; i < this->hidden->nvisuals; i++ ) | 1088 } |
1055 if ( this->hidden->visuals[i].depth == bpp ) /* era .depth */ | 1089 |
1056 break; | 1090 if (GetCyberMapAttr |
1057 | 1091 (SDL_Display->RastPort.BitMap, CYBRMATTR_DEPTH) == bpp) |
1058 if ( i == this->hidden->nvisuals ) { | 1092 this->hidden->same_format = 1; |
1059 SDL_SetError("No matching visual for requested depth"); | 1093 } |
1060 return NULL; /* should never happen */ | 1094 |
1061 } | 1095 bpp = this->hidden->depth = |
1062 SDL_Visual = this->hidden->visuals[i].visual; | 1096 GetCyberMapAttr(SDL_Display->RastPort.BitMap, CYBRMATTR_DEPTH); |
1063 | 1097 D(bug("Setting screen depth to: %ld\n", this->hidden->depth)); |
1064 } | 1098 |
1065 | 1099 for (i = 0; i < this->hidden->nvisuals; i++) |
1066 /* Set up the X11 window */ | 1100 if (this->hidden->visuals[i].depth == bpp) /* era .depth */ |
1067 saved_flags = current->flags; | 1101 break; |
1068 | 1102 |
1069 if (SDL_Window && (saved_flags&SDL_OPENGL) == (flags&SDL_OPENGL) | 1103 if (i == this->hidden->nvisuals) { |
1070 && bpp == current->format->BitsPerPixel && !needcreate) { | 1104 SDL_SetError("No matching visual for requested depth"); |
1071 if (CGX_ResizeWindow(this, current, width, height, flags) < 0) { | 1105 return NULL; /* should never happen */ |
1072 current = NULL; | 1106 } |
1073 goto done; | 1107 SDL_Visual = this->hidden->visuals[i].visual; |
1074 } | 1108 |
1075 } else { | 1109 } |
1076 if (CGX_CreateWindow(this,current,width,height,bpp,flags) < 0) { | 1110 |
1077 current = NULL; | 1111 /* Set up the X11 window */ |
1078 goto done; | 1112 saved_flags = current->flags; |
1079 } | 1113 |
1080 } | 1114 if (SDL_Window |
1115 && (saved_flags & SDL_INTERNALOPENGL) == (flags & SDL_INTERNALOPENGL) | |
1116 && bpp == current->format->BitsPerPixel && !needcreate) { | |
1117 if (CGX_ResizeWindow(this, current, width, height, flags) < 0) { | |
1118 current = NULL; | |
1119 goto done; | |
1120 } | |
1121 } else { | |
1122 if (CGX_CreateWindow(this, current, width, height, bpp, flags) < 0) { | |
1123 current = NULL; | |
1124 goto done; | |
1125 } | |
1126 } | |
1081 | 1127 |
1082 #if 0 | 1128 #if 0 |
1083 /* Set up the new mode framebuffer */ | 1129 /* Set up the new mode framebuffer */ |
1084 if ( ((current->w != width) || (current->h != height)) || | 1130 if (((current->w != width) || (current->h != height)) || |
1085 ((saved_flags&SDL_OPENGL) != (flags&SDL_OPENGL)) ) { | 1131 ((saved_flags & SDL_INTERNALOPENGL) != (flags & SDL_INTERNALOPENGL))) |
1086 current->w = width; | 1132 { |
1087 current->h = height; | 1133 current->w = width; |
1088 current->pitch = SDL_CalculatePitch(current); | 1134 current->h = height; |
1089 CGX_ResizeImage(this, current, flags); | 1135 current->pitch = SDL_CalculatePitch(current); |
1090 } | 1136 CGX_ResizeImage(this, current, flags); |
1137 } | |
1091 #endif | 1138 #endif |
1092 | 1139 |
1093 current->flags |= (flags&SDL_RESIZABLE); // Resizable only if the user asked it | 1140 current->flags |= (flags & SDL_RESIZABLE); // Resizable only if the user asked it |
1094 | 1141 |
1095 done: | 1142 done: |
1096 /* Release the event thread */ | 1143 /* Release the event thread */ |
1097 SDL_Unlock_EventThread(); | 1144 SDL_Unlock_EventThread(); |
1098 | 1145 |
1099 /* We're done! */ | 1146 /* We're done! */ |
1100 return(current); | 1147 return (current); |
1101 } | 1148 } |
1102 | 1149 |
1103 static int CGX_ToggleFullScreen(_THIS, int on) | 1150 static int |
1104 { | 1151 CGX_ToggleFullScreen(_THIS, int on) |
1105 Uint32 event_thread; | 1152 { |
1106 | 1153 Uint32 event_thread; |
1107 /* Don't switch if we don't own the window */ | 1154 |
1108 if ( SDL_windowid ) { | 1155 /* Don't switch if we don't own the window */ |
1109 return(0); | 1156 if (SDL_windowid) { |
1110 } | 1157 return (0); |
1111 | 1158 } |
1112 /* Don't lock if we are the event thread */ | 1159 |
1113 event_thread = SDL_EventThreadID(); | 1160 /* Don't lock if we are the event thread */ |
1114 if ( event_thread && (SDL_ThreadID() == event_thread) ) { | 1161 event_thread = SDL_EventThreadID(); |
1115 event_thread = 0; | 1162 if (event_thread && (SDL_ThreadID() == event_thread)) { |
1116 } | 1163 event_thread = 0; |
1117 if ( event_thread ) { | 1164 } |
1118 SDL_Lock_EventThread(); | 1165 if (event_thread) { |
1119 } | 1166 SDL_Lock_EventThread(); |
1120 if ( on ) { | 1167 } |
1121 this->screen->flags |= SDL_FULLSCREEN; | 1168 if (on) { |
1122 CGX_EnterFullScreen(this); | 1169 this->screen->flags |= SDL_FULLSCREEN; |
1123 } else { | 1170 CGX_EnterFullScreen(this); |
1124 this->screen->flags &= ~SDL_FULLSCREEN; | 1171 } else { |
1125 CGX_LeaveFullScreen(this); | 1172 this->screen->flags &= ~SDL_FULLSCREEN; |
1126 } | 1173 CGX_LeaveFullScreen(this); |
1127 | 1174 } |
1128 CGX_RefreshDisplay(this); | 1175 |
1129 if ( event_thread ) { | 1176 CGX_RefreshDisplay(this); |
1130 SDL_Unlock_EventThread(); | 1177 if (event_thread) { |
1131 } | 1178 SDL_Unlock_EventThread(); |
1132 | 1179 } |
1133 SDL_ResetKeyboard(); | 1180 |
1134 | 1181 SDL_ResetKeyboard(); |
1135 return(1); | 1182 |
1136 } | 1183 return (1); |
1137 | 1184 } |
1138 static void SetSingleColor(Uint32 fmt, unsigned char r, unsigned char g, unsigned char b, unsigned char *c) | 1185 |
1139 { | 1186 static void |
1140 switch(fmt) | 1187 SetSingleColor(Uint32 fmt, unsigned char r, unsigned char g, unsigned char b, |
1141 { | 1188 unsigned char *c) |
1142 case PIXFMT_BGR15: | 1189 { |
1143 case PIXFMT_RGB15PC: | 1190 switch (fmt) { |
1144 { | 1191 case PIXFMT_BGR15: |
1145 Uint16 *t=(Uint16 *)c; | 1192 case PIXFMT_RGB15PC: |
1146 *t=(r>>3) | ((g>>3)<<5) | ((b>>3)<<10) ; | 1193 { |
1147 } | 1194 Uint16 *t = (Uint16 *) c; |
1148 break; | 1195 *t = (r >> 3) | ((g >> 3) << 5) | ((b >> 3) << 10); |
1149 case PIXFMT_RGB15: | 1196 } |
1150 case PIXFMT_BGR15PC: | 1197 break; |
1151 { | 1198 case PIXFMT_RGB15: |
1152 Uint16 *t=(Uint16 *)c; | 1199 case PIXFMT_BGR15PC: |
1153 *t=(b>>3) | ((g>>3)<<5) | ((r>>3)<<10) ; | 1200 { |
1154 } | 1201 Uint16 *t = (Uint16 *) c; |
1155 break; | 1202 *t = (b >> 3) | ((g >> 3) << 5) | ((r >> 3) << 10); |
1156 case PIXFMT_BGR16PC: | 1203 } |
1157 case PIXFMT_RGB16: | 1204 break; |
1158 { | 1205 case PIXFMT_BGR16PC: |
1159 Uint16 *t=(Uint16 *)c; | 1206 case PIXFMT_RGB16: |
1160 *t=(b>>3) | ((g>>2)<<5) | ((r>>3)<<11) ; | 1207 { |
1161 } | 1208 Uint16 *t = (Uint16 *) c; |
1162 break; | 1209 *t = (b >> 3) | ((g >> 2) << 5) | ((r >> 3) << 11); |
1163 case PIXFMT_BGR16: | 1210 } |
1164 case PIXFMT_RGB16PC: | 1211 break; |
1165 { | 1212 case PIXFMT_BGR16: |
1166 Uint16 *t=(Uint16 *)c; | 1213 case PIXFMT_RGB16PC: |
1167 *t=(r>>3) | ((g>>2)<<5) | ((b>>3)<<11) ; | 1214 { |
1168 } | 1215 Uint16 *t = (Uint16 *) c; |
1169 break; | 1216 *t = (r >> 3) | ((g >> 2) << 5) | ((b >> 3) << 11); |
1170 case PIXFMT_RGB24: | 1217 } |
1171 c[0]=r; | 1218 break; |
1172 c[1]=g; | 1219 case PIXFMT_RGB24: |
1173 c[2]=b; | 1220 c[0] = r; |
1174 c[3]=0; | 1221 c[1] = g; |
1175 break; | 1222 c[2] = b; |
1176 case PIXFMT_BGR24: | 1223 c[3] = 0; |
1177 c[0]=b; | 1224 break; |
1178 c[1]=g; | 1225 case PIXFMT_BGR24: |
1179 c[2]=r; | 1226 c[0] = b; |
1180 c[3]=0; | 1227 c[1] = g; |
1181 break; | 1228 c[2] = r; |
1182 case PIXFMT_ARGB32: | 1229 c[3] = 0; |
1183 c[0]=0; | 1230 break; |
1184 c[1]=r; | 1231 case PIXFMT_ARGB32: |
1185 c[2]=g; | 1232 c[0] = 0; |
1186 c[3]=b; | 1233 c[1] = r; |
1187 break; | 1234 c[2] = g; |
1188 case PIXFMT_BGRA32: | 1235 c[3] = b; |
1189 c[0]=b; | 1236 break; |
1190 c[1]=g; | 1237 case PIXFMT_BGRA32: |
1191 c[2]=r; | 1238 c[0] = b; |
1192 c[3]=0; | 1239 c[1] = g; |
1193 break; | 1240 c[2] = r; |
1194 case PIXFMT_RGBA32: | 1241 c[3] = 0; |
1195 c[0]=r; | 1242 break; |
1196 c[1]=g; | 1243 case PIXFMT_RGBA32: |
1197 c[2]=b; | 1244 c[0] = r; |
1198 c[3]=0; | 1245 c[1] = g; |
1199 break; | 1246 c[2] = b; |
1200 | 1247 c[3] = 0; |
1201 default: | 1248 break; |
1202 D(bug("Error, SetSingleColor with PIXFMT %ld!\n",fmt)); | 1249 |
1203 } | 1250 default: |
1251 D(bug("Error, SetSingleColor with PIXFMT %ld!\n", fmt)); | |
1252 } | |
1204 } | 1253 } |
1205 | 1254 |
1206 /* Update the current mouse state and position */ | 1255 /* Update the current mouse state and position */ |
1207 static void CGX_UpdateMouse(_THIS) | 1256 static void |
1208 { | 1257 CGX_UpdateMouse(_THIS) |
1209 /* Lock the event thread, in multi-threading environments */ | 1258 { |
1210 SDL_Lock_EventThread(); | 1259 /* Lock the event thread, in multi-threading environments */ |
1211 | 1260 SDL_Lock_EventThread(); |
1212 if(currently_fullscreen) | 1261 |
1213 { | 1262 if (currently_fullscreen) { |
1214 SDL_PrivateAppActive(1, SDL_APPMOUSEFOCUS); | 1263 SDL_PrivateAppActive(1, SDL_APPMOUSEFOCUS); |
1215 SDL_PrivateMouseMotion(0, 0, SDL_Display->MouseX, SDL_Display->MouseY); | 1264 SDL_PrivateMouseMotion(0, 0, SDL_Display->MouseX, |
1216 } | 1265 SDL_Display->MouseY); |
1217 else | 1266 } else { |
1218 { | 1267 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) && | 1268 (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) | 1269 && SDL_Display->MouseX < |
1221 ) | 1270 (SDL_Window->LeftEdge + SDL_Window->Width - |
1222 { | 1271 SDL_Window->BorderRight) |
1223 SDL_PrivateAppActive(1, SDL_APPMOUSEFOCUS); | 1272 && SDL_Display->MouseY >= |
1224 SDL_PrivateMouseMotion(0, 0, SDL_Display->MouseX-SDL_Window->LeftEdge-SDL_Window->BorderLeft, | 1273 (SDL_Window->TopEdge + SDL_Window->BorderLeft) |
1225 SDL_Display->MouseY-SDL_Window->TopEdge-SDL_Window->BorderTop); | 1274 && SDL_Display->MouseY < |
1226 } | 1275 (SDL_Window->TopEdge + SDL_Window->Height - |
1227 else | 1276 SDL_Window->BorderBottom)) { |
1228 { | 1277 SDL_PrivateAppActive(1, SDL_APPMOUSEFOCUS); |
1229 SDL_PrivateAppActive(0, SDL_APPMOUSEFOCUS); | 1278 SDL_PrivateMouseMotion(0, 0, |
1230 } | 1279 SDL_Display->MouseX - |
1231 } | 1280 SDL_Window->LeftEdge - |
1232 SDL_Unlock_EventThread(); | 1281 SDL_Window->BorderLeft, |
1233 } | 1282 SDL_Display->MouseY - |
1234 | 1283 SDL_Window->TopEdge - |
1235 static int CGX_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors) | 1284 SDL_Window->BorderTop); |
1236 { | 1285 } else { |
1237 int i; | 1286 SDL_PrivateAppActive(0, SDL_APPMOUSEFOCUS); |
1238 | 1287 } |
1239 /* Check to make sure we have a colormap allocated */ | 1288 } |
1240 | 1289 SDL_Unlock_EventThread(); |
1241 /* It's easy if we have a hidden colormap */ | 1290 } |
1242 if ( (this->screen->flags & SDL_HWPALETTE) && currently_fullscreen ) | 1291 |
1243 { | 1292 static int |
1244 ULONG xcmap[256*3+2]; | 1293 CGX_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color * colors) |
1245 | 1294 { |
1246 xcmap[0]=(ncolors<<16); | 1295 int i; |
1247 xcmap[0]+=firstcolor; | 1296 |
1248 | 1297 /* Check to make sure we have a colormap allocated */ |
1249 // D(bug("Setting %ld colors on an HWPALETTE screen\n",ncolors)); | 1298 |
1250 | 1299 /* It's easy if we have a hidden colormap */ |
1251 for ( i=0; i<ncolors; i++ ) { | 1300 if ((this->screen->flags & SDL_HWPALETTE) && currently_fullscreen) { |
1252 xcmap[i*3+1] = colors[i+firstcolor].r<<24; | 1301 ULONG xcmap[256 * 3 + 2]; |
1253 xcmap[i*3+2] = colors[i+firstcolor].g<<24; | 1302 |
1254 xcmap[i*3+3] = colors[i+firstcolor].b<<24; | 1303 xcmap[0] = (ncolors << 16); |
1255 } | 1304 xcmap[0] += firstcolor; |
1256 xcmap[ncolors*3+1]=0; | 1305 |
1257 LoadRGB32(&GFX_Display->ViewPort,xcmap); | 1306 // D(bug("Setting %ld colors on an HWPALETTE screen\n",ncolors)); |
1258 } else { | 1307 |
1308 for (i = 0; i < ncolors; i++) { | |
1309 xcmap[i * 3 + 1] = colors[i + firstcolor].r << 24; | |
1310 xcmap[i * 3 + 2] = colors[i + firstcolor].g << 24; | |
1311 xcmap[i * 3 + 3] = colors[i + firstcolor].b << 24; | |
1312 } | |
1313 xcmap[ncolors * 3 + 1] = 0; | |
1314 LoadRGB32(&GFX_Display->ViewPort, xcmap); | |
1315 } else { | |
1259 // XPixels are not needed on 8bit screen with hwpalette | 1316 // XPixels are not needed on 8bit screen with hwpalette |
1260 unsigned long pixel; | 1317 unsigned long pixel; |
1261 | 1318 |
1262 if ( SDL_XPixels == NULL ) { | 1319 if (SDL_XPixels == NULL) { |
1263 D(bug("SetColors without colormap!")); | 1320 D(bug("SetColors without colormap!")); |
1264 return(0); | 1321 return (0); |
1265 } | 1322 } |
1266 | 1323 |
1267 if(this->hidden->depth==8) | 1324 if (this->hidden->depth == 8) { |
1268 { | |
1269 // In this case I have to unalloc and realloc the full palette | 1325 // In this case I have to unalloc and realloc the full palette |
1270 D(bug("Obtaining %ld colors on the screen\n",ncolors)); | 1326 D(bug("Obtaining %ld colors on the screen\n", ncolors)); |
1271 | 1327 |
1272 /* Free existing allocated colors */ | 1328 /* Free existing allocated colors */ |
1273 for ( pixel=0; pixel<this->screen->format->palette->ncolors; ++pixel ) { | 1329 for (pixel = 0; |
1274 if(SDL_XPixels[pixel]>=0) | 1330 pixel < this->screen->format->palette->ncolors; ++pixel) { |
1275 ReleasePen(GFX_Display->ViewPort.ColorMap,SDL_XPixels[pixel]); | 1331 if (SDL_XPixels[pixel] >= 0) |
1276 } | 1332 ReleasePen(GFX_Display->ViewPort.ColorMap, |
1277 | 1333 SDL_XPixels[pixel]); |
1278 /* Try to allocate all the colors */ | 1334 } |
1279 for ( i=0; i<this->screen->format->palette->ncolors; ++i ) { | 1335 |
1280 SDL_XPixels[i]=ObtainBestPenA(GFX_Display->ViewPort.ColorMap,colors[i].r<<24,colors[i].g<<24,colors[i].b<<24,NULL); | 1336 /* Try to allocate all the colors */ |
1281 } | 1337 for (i = 0; i < this->screen->format->palette->ncolors; ++i) { |
1282 } | 1338 SDL_XPixels[i] = |
1283 else | 1339 ObtainBestPenA(GFX_Display->ViewPort.ColorMap, |
1284 { | 1340 colors[i].r << 24, |
1341 colors[i].g << 24, | |
1342 colors[i].b << 24, NULL); | |
1343 } | |
1344 } else { | |
1285 #ifndef USE_CGX_WRITELUTPIXEL | 1345 #ifndef USE_CGX_WRITELUTPIXEL |
1286 Uint32 fmt; | 1346 Uint32 fmt; |
1287 D(bug("Preparing a conversion pixel table...\n")); | 1347 D(bug("Preparing a conversion pixel table...\n")); |
1288 | 1348 |
1289 fmt=GetCyberMapAttr(SDL_Display->RastPort.BitMap,CYBRMATTR_PIXFMT); | 1349 fmt = |
1290 | 1350 GetCyberMapAttr(SDL_Display->RastPort.BitMap, |
1291 for(i=0;i<ncolors;i++) | 1351 CYBRMATTR_PIXFMT); |
1292 { | 1352 |
1293 SetSingleColor(fmt,colors[firstcolor+i].r,colors[firstcolor+i].g,colors[firstcolor+i].b,(unsigned char *)&SDL_XPixels[firstcolor+i]); | 1353 for (i = 0; i < ncolors; i++) { |
1294 } | 1354 SetSingleColor(fmt, colors[firstcolor + i].r, |
1355 colors[firstcolor + i].g, | |
1356 colors[firstcolor + i].b, (unsigned char *) | |
1357 &SDL_XPixels[firstcolor + i]); | |
1358 } | |
1295 #else | 1359 #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)); | 1360 // 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++) | 1361 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; | 1362 SDL_XPixels[i + firstcolor] = |
1363 (colors[firstcolor + i].r << 16) + | |
1364 (colors[firstcolor + i].g << 8) + colors[firstcolor + | |
1365 i].b; | |
1299 #endif | 1366 #endif |
1300 } | 1367 } |
1301 } | 1368 } |
1302 | 1369 |
1303 // Actually it cannot fail! | 1370 // Actually it cannot fail! |
1304 | 1371 |
1305 return 1; | 1372 return 1; |
1306 } | 1373 } |
1307 | 1374 |
1308 /* Note: If we are terminated, this could be called in the middle of | 1375 /* Note: If we are terminated, this could be called in the middle of |
1309 another SDL video routine -- notably UpdateRects. | 1376 another SDL video routine -- notably UpdateRects. |
1310 */ | 1377 */ |
1311 static void CGX_VideoQuit(_THIS) | 1378 static void |
1312 { | 1379 CGX_VideoQuit(_THIS) |
1313 /* Shutdown everything that's still up */ | 1380 { |
1314 /* The event thread should be done, so we can touch SDL_Display */ | 1381 /* Shutdown everything that's still up */ |
1315 D(bug("CGX_VideoQuit\n")); | 1382 /* The event thread should be done, so we can touch SDL_Display */ |
1316 | 1383 D(bug("CGX_VideoQuit\n")); |
1317 if ( SDL_Display != NULL ) { | 1384 |
1318 /* Clean up OpenGL */ | 1385 if (SDL_Display != NULL) { |
1319 if(this->gl_data->gl_active == 1) { | 1386 /* Clean up OpenGL */ |
1320 CGX_GL_Quit(this); | 1387 if (this->gl_data->gl_active == 1) { |
1321 } | 1388 CGX_GL_Quit(this); |
1322 /* Start shutting down the windows */ | 1389 } |
1323 D(bug("Destroying image...\n")); | 1390 /* Start shutting down the windows */ |
1324 CGX_DestroyImage(this, this->screen); | 1391 D(bug("Destroying image...\n")); |
1325 D(bug("Destroying window...\n")); | 1392 CGX_DestroyImage(this, this->screen); |
1326 CGX_DestroyWindow(this, this->screen); | 1393 D(bug("Destroying window...\n")); |
1394 CGX_DestroyWindow(this, this->screen); | |
1327 // Otherwise SDL_VideoQuit will try to free it! | 1395 // Otherwise SDL_VideoQuit will try to free it! |
1328 SDL_VideoSurface=NULL; | 1396 SDL_VideoSurface = NULL; |
1329 | 1397 |
1330 CGX_FreeVideoModes(this); | 1398 CGX_FreeVideoModes(this); |
1331 | 1399 |
1332 /* Free that blank cursor */ | 1400 /* Free that blank cursor */ |
1333 if ( SDL_BlankCursor != NULL ) { | 1401 if (SDL_BlankCursor != NULL) { |
1334 FreeMem(SDL_BlankCursor,16); | 1402 FreeMem(SDL_BlankCursor, 16); |
1335 SDL_BlankCursor = NULL; | 1403 SDL_BlankCursor = NULL; |
1336 } | 1404 } |
1337 | 1405 |
1338 /* Close the X11 graphics connection */ | 1406 /* Close the X11 graphics connection */ |
1339 this->hidden->same_format=0; | 1407 this->hidden->same_format = 0; |
1340 | 1408 |
1341 D(bug("Destroying screen...\n")); | 1409 D(bug("Destroying screen...\n")); |
1342 | 1410 |
1343 if ( GFX_Display != NULL ) | 1411 if (GFX_Display != NULL) |
1344 DestroyScreen(this); | 1412 DestroyScreen(this); |
1345 | 1413 |
1346 /* Close the X11 display connection */ | 1414 /* Close the X11 display connection */ |
1347 SDL_Display = NULL; | 1415 SDL_Display = NULL; |
1348 | 1416 |
1349 /* Unload GL library after X11 shuts down */ | 1417 /* Unload GL library after X11 shuts down */ |
1350 } | 1418 } |
1351 | 1419 |
1352 D(bug("Closing libraries...\n")); | 1420 D(bug("Closing libraries...\n")); |
1353 | 1421 |
1354 if( CyberGfxBase) { | 1422 if (CyberGfxBase) { |
1355 CloseLibrary(CyberGfxBase); | 1423 CloseLibrary(CyberGfxBase); |
1356 CyberGfxBase=NULL; | 1424 CyberGfxBase = NULL; |
1357 } | 1425 } |
1358 | 1426 |
1359 if (IntuitionBase) { | 1427 if (IntuitionBase) { |
1360 CloseLibrary((struct Library *)IntuitionBase); | 1428 CloseLibrary((struct Library *) IntuitionBase); |
1361 IntuitionBase=NULL; | 1429 IntuitionBase = NULL; |
1362 } | 1430 } |
1363 if (GfxBase) { | 1431 if (GfxBase) { |
1364 CloseLibrary((struct Library *)GfxBase); | 1432 CloseLibrary((struct Library *) GfxBase); |
1365 GfxBase=NULL; | 1433 GfxBase = NULL; |
1366 } | 1434 } |
1367 | 1435 |
1368 if ( this->screen && (this->screen->flags & SDL_HWSURFACE) ) { | 1436 if (this->screen && (this->screen->flags & SDL_HWSURFACE)) { |
1369 /* Direct screen access, no memory buffer */ | 1437 /* Direct screen access, no memory buffer */ |
1370 this->screen->pixels = NULL; | 1438 this->screen->pixels = NULL; |
1371 } | 1439 } |
1372 D(bug("End of CGX_VideoQuit.\n")); | 1440 D(bug("End of CGX_VideoQuit.\n")); |
1373 | 1441 |
1374 } | 1442 } |
1375 | 1443 |
1444 /* vi: set ts=4 sw=4 expandtab: */ |