Mercurial > sdl-ios-xcode
annotate src/video/cybergfx/SDL_cgxmodes.c @ 1162:2651158f59b8
Enable altivec blitters on PowerPC Linux, and some fixes for recent
GCCs versions.
author | Ryan C. Gordon <icculus@icculus.org> |
---|---|
date | Thu, 20 Oct 2005 06:55:26 +0000 |
parents | dcb5e869f8b5 |
children | c9b51268668f |
rev | line source |
---|---|
0 | 1 /* |
2 SDL - Simple DirectMedia Layer | |
255
dcb5e869f8b5
Updated Amiga port by Gabriele Greco
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
3 Copyright (C) 1997, 1998, 1999, 2000 Sam Lantinga |
0 | 4 |
5 This library is free software; you can redistribute it and/or | |
6 modify it under the terms of the GNU Library General Public | |
7 License as published by the Free Software Foundation; either | |
8 version 2 of the License, or (at your option) any later version. | |
9 | |
10 This library is distributed in the hope that it will be useful, | |
11 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
13 Library General Public License for more details. | |
14 | |
15 You should have received a copy of the GNU Library General Public | |
16 License along with this library; if not, write to the Free | |
17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
18 | |
19 Sam Lantinga | |
252
e8157fcb3114
Updated the source with the correct e-mail address
Sam Lantinga <slouken@libsdl.org>
parents:
21
diff
changeset
|
20 slouken@libsdl.org |
0 | 21 */ |
22 | |
23 #ifdef SAVE_RCSID | |
24 static char rcsid = | |
25 "@(#) $Id$"; | |
26 #endif | |
27 | |
28 /* Utilities for getting and setting the X display mode */ | |
29 | |
30 /* | |
31 #include <stdlib.h> | |
32 #include <string.h> | |
33 */ | |
34 | |
35 #include "SDL_timer.h" | |
36 #include "SDL_error.h" | |
37 #include "SDL_events.h" | |
38 #include "SDL_events_c.h" | |
39 #include "SDL_cgxvideo.h" | |
40 #include "SDL_cgxwm_c.h" | |
41 #include "SDL_cgxmodes_c.h" | |
42 | |
43 #define CGX_DEBUG | |
44 | |
45 static void set_best_resolution(_THIS, int width, int height) | |
46 { | |
47 Uint32 idok; | |
48 int depth=8; | |
49 | |
50 if(SDL_Display) | |
51 depth=GetCyberMapAttr(SDL_Display->RastPort.BitMap,CYBRMATTR_DEPTH); | |
52 | |
53 idok=BestCModeIDTags(CYBRBIDTG_NominalWidth,width, | |
54 CYBRBIDTG_NominalHeight,height, | |
55 CYBRBIDTG_Depth,depth, | |
56 TAG_DONE); | |
57 | |
58 if(idok!=INVALID_ID) | |
59 { | |
60 if(SDL_Display) | |
61 { | |
62 if(currently_fullscreen) | |
63 CloseScreen(SDL_Display); | |
64 else | |
65 UnlockPubScreen(NULL,SDL_Display); | |
66 } | |
67 SDL_Display=GFX_Display=OpenScreenTags(NULL,SA_Width,width,SA_Height,height, | |
68 SA_Depth,depth,SA_DisplayID,idok, | |
255
dcb5e869f8b5
Updated Amiga port by Gabriele Greco
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
69 SA_ShowTitle,FALSE, |
0 | 70 TAG_DONE); |
71 } | |
72 } | |
73 | |
74 static void get_real_resolution(_THIS, int* w, int* h) | |
75 { | |
255
dcb5e869f8b5
Updated Amiga port by Gabriele Greco
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
76 *w = /*SDL_Display->Width*/ SDL_Window->Width-SDL_Window->BorderLeft-SDL_Window->BorderRight; |
dcb5e869f8b5
Updated Amiga port by Gabriele Greco
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
77 *h = /*SDL_Display->Height*/ SDL_Window->Height-SDL_Window->BorderBottom-SDL_Window->BorderTop; |
0 | 78 } |
79 | |
21
75a95f82bc1f
Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
80 static void move_cursor_to(_THIS, int x, int y) |
75a95f82bc1f
Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
81 { |
75a95f82bc1f
Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
82 /* XWarpPointer(SDL_Display, None, SDL_Root, 0, 0, 0, 0, x, y); */ |
75a95f82bc1f
Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
83 |
75a95f82bc1f
Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
84 /* DA FARE! */ |
75a95f82bc1f
Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
85 } |
75a95f82bc1f
Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
86 |
0 | 87 static void add_visual(_THIS, int depth, int class) |
88 { | |
89 Uint32 tID; | |
90 | |
91 tID=BestCModeIDTags(CYBRBIDTG_Depth,depth, | |
92 CYBRBIDTG_NominalWidth,640, | |
93 CYBRBIDTG_NominalHeight,480, | |
94 TAG_DONE); | |
95 | |
96 if(tID!=INVALID_ID) | |
97 { | |
98 int n = this->hidden->nvisuals; | |
99 | |
100 this->hidden->visuals[n].depth = depth; | |
101 this->hidden->visuals[n].visual = tID; | |
102 this->hidden->visuals[n].bpp = GetCyberIDAttr(CYBRIDATTR_BPPIX,tID); | |
103 this->hidden->nvisuals++; | |
104 } | |
105 } | |
106 | |
107 #define TrueColor 1 | |
108 #define PseudoColor 2 | |
109 | |
110 int CGX_GetVideoModes(_THIS) | |
111 { | |
112 int i; | |
113 ULONG nextid; | |
114 int nmodes=0; | |
115 | |
116 SDL_modelist=NULL; | |
117 | |
118 nextid=NextDisplayInfo(INVALID_ID); | |
119 | |
120 while(nextid!=INVALID_ID) | |
121 { | |
122 if(IsCyberModeID(nextid)) | |
123 { | |
124 DisplayInfoHandle h; | |
125 | |
126 if(h=FindDisplayInfo(nextid)) | |
127 { | |
128 struct DimensionInfo info; | |
129 | |
130 if(GetDisplayInfoData(h,(char *)&info,sizeof(struct DimensionInfo),DTAG_DIMS,NULL)) | |
131 { | |
132 int ok=0; | |
133 | |
134 for(i=0;i<nmodes;i++) | |
135 { | |
136 if( SDL_modelist[i]->w == (info.Nominal.MaxX+1) && | |
137 SDL_modelist[i]->h == (info.Nominal.MaxY+1) ) | |
138 ok=1; | |
139 } | |
140 | |
141 if(!ok) | |
142 { | |
143 nmodes++; | |
144 | |
145 SDL_modelist = (SDL_Rect **)realloc(SDL_modelist,(nmodes+1)*sizeof(SDL_Rect *)); | |
146 SDL_modelist[nmodes]=NULL; | |
147 | |
255
dcb5e869f8b5
Updated Amiga port by Gabriele Greco
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
148 if ( SDL_modelist ) |
0 | 149 { |
150 SDL_modelist[nmodes-1] = (SDL_Rect *)malloc(sizeof(SDL_Rect)); | |
151 | |
255
dcb5e869f8b5
Updated Amiga port by Gabriele Greco
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
152 if ( SDL_modelist[nmodes-1] == NULL ) |
0 | 153 break; |
154 | |
155 SDL_modelist[nmodes-1]->x = 0; | |
156 SDL_modelist[nmodes-1]->y = 0; | |
157 SDL_modelist[nmodes-1]->w = info.Nominal.MaxX+1; | |
158 SDL_modelist[nmodes-1]->h = info.Nominal.MaxY+1; | |
159 } | |
255
dcb5e869f8b5
Updated Amiga port by Gabriele Greco
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
160 } |
0 | 161 } |
162 } | |
163 } | |
164 nextid=NextDisplayInfo(nextid); | |
165 } | |
166 | |
167 | |
168 this->hidden->nvisuals = 0; | |
169 /* Search for the visuals in deepest-first order, so that the first | |
170 will be the richest one */ | |
171 add_visual(this, 32, TrueColor); | |
172 add_visual(this, 24, TrueColor); | |
173 add_visual(this, 16, TrueColor); | |
174 add_visual(this, 15, TrueColor); | |
175 add_visual(this, 8, PseudoColor); | |
176 | |
177 if(this->hidden->nvisuals == 0) { | |
178 SDL_SetError("Found no sufficiently capable CGX visuals"); | |
179 return -1; | |
180 } | |
181 | |
182 if ( SDL_modelist == NULL ) { | |
183 SDL_modelist = (SDL_Rect **)malloc((1+1)*sizeof(SDL_Rect *)); | |
184 i = 0; | |
185 if ( SDL_modelist ) { | |
186 SDL_modelist[i] = (SDL_Rect *)malloc(sizeof(SDL_Rect)); | |
187 if ( SDL_modelist[i] ) { | |
188 SDL_modelist[i]->x = 0; | |
189 SDL_modelist[i]->y = 0; | |
190 SDL_modelist[i]->w = SDL_Display->Width; | |
191 SDL_modelist[i]->h = SDL_Display->Height; | |
192 ++i; | |
193 } | |
194 SDL_modelist[i] = NULL; | |
195 } | |
196 } | |
197 | |
198 D( if ( SDL_modelist ) { | |
199 bug("CGX video mode list: (%ld)\n",nmodes); | |
200 for ( i=0; SDL_modelist[i]; ++i ) { | |
201 bug( "\t%ld x %ld\n", | |
202 SDL_modelist[i]->w, SDL_modelist[i]->h); | |
203 } | |
204 } | |
205 ); | |
206 | |
207 D( { bug("CGX visuals list: (%ld)\n",this->hidden->nvisuals); | |
208 | |
209 for(i=0;i<this->hidden->nvisuals;i++) | |
210 bug("\t%lx - depth: %ld bpp: %ld\n",this->hidden->visuals[i].visual,this->hidden->visuals[i].depth,this->hidden->visuals[i].bpp); | |
211 } | |
212 ); | |
213 return 0; | |
214 } | |
215 | |
216 int CGX_SupportedVisual(_THIS, SDL_PixelFormat *format) | |
217 { | |
218 int i; | |
219 for(i = 0; i < this->hidden->nvisuals; i++) | |
220 { | |
221 if(this->hidden->visuals[i].depth == format->BitsPerPixel) // Era bpp | |
222 return 1; | |
223 } | |
224 return 0; | |
225 } | |
226 | |
227 SDL_Rect **CGX_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags) | |
228 { | |
229 if ( CGX_SupportedVisual(this, format) ) { | |
230 if ( flags & SDL_FULLSCREEN ) { | |
231 return(SDL_modelist); | |
232 } else { | |
233 return((SDL_Rect **)-1); | |
234 } | |
235 } else { | |
236 return((SDL_Rect **)0); | |
237 } | |
238 } | |
239 | |
240 void CGX_FreeVideoModes(_THIS) | |
241 { | |
242 int i; | |
243 | |
244 if ( SDL_modelist ) { | |
245 for ( i=0; SDL_modelist[i]; ++i ) { | |
246 free(SDL_modelist[i]); | |
247 } | |
248 free(SDL_modelist); | |
249 SDL_modelist = NULL; | |
250 } | |
251 } | |
252 | |
253 int CGX_ResizeFullScreen(_THIS) | |
254 { | |
255 int x, y; | |
256 int real_w, real_h; | |
257 | |
258 if ( currently_fullscreen ) { | |
259 /* Per ora non faccio nulla qui */ | |
260 } | |
261 return(1); | |
262 } | |
263 | |
264 void _QueueEnterFullScreen(_THIS) | |
265 { | |
266 } | |
267 | |
268 int CGX_EnterFullScreen(_THIS) | |
269 { | |
270 int okay; | |
255
dcb5e869f8b5
Updated Amiga port by Gabriele Greco
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
271 Uint32 saved_flags; |
0 | 272 |
273 okay = 1; | |
255
dcb5e869f8b5
Updated Amiga port by Gabriele Greco
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
274 saved_flags = this->screen->flags; |
dcb5e869f8b5
Updated Amiga port by Gabriele Greco
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
275 |
dcb5e869f8b5
Updated Amiga port by Gabriele Greco
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
276 if ( ! currently_fullscreen ) |
0 | 277 { |
278 int real_w, real_h; | |
279 | |
280 /* Map the fullscreen window to blank the screen */ | |
281 get_real_resolution(this, &real_w, &real_h); | |
255
dcb5e869f8b5
Updated Amiga port by Gabriele Greco
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
282 |
0 | 283 CGX_DestroyWindow(this,this->screen); |
284 set_best_resolution(this, real_w,real_h); | |
285 | |
286 /* Grab the mouse on the fullscreen window | |
287 The event handling will know when we become active, and then | |
288 enter fullscreen mode if we can't grab the mouse this time. | |
289 */ | |
290 #if 0 | |
291 if ( (XGrabPointer(SDL_Display, FSwindow, True, 0, | |
292 GrabModeAsync, GrabModeAsync, | |
293 FSwindow, None, CurrentTime) != GrabSuccess) || | |
294 (XGrabKeyboard(SDL_Display, WMwindow, True, | |
295 GrabModeAsync, GrabModeAsync, CurrentTime) != 0) ) { | |
296 XUnmapWindow(SDL_Display, FSwindow); | |
297 X11_WaitUnmapped(this, FSwindow); | |
298 X11_QueueEnterFullScreen(this); | |
299 return(0); | |
300 } | |
301 #endif | |
302 | |
303 currently_fullscreen = 1; | |
255
dcb5e869f8b5
Updated Amiga port by Gabriele Greco
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
304 this->screen->flags = saved_flags; |
0 | 305 |
255
dcb5e869f8b5
Updated Amiga port by Gabriele Greco
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
306 CGX_CreateWindow(this,this->screen,real_w,real_h,GetCyberMapAttr(SDL_Display->RastPort.BitMap,CYBRMATTR_DEPTH),this->screen->flags); |
0 | 307 |
308 /* Set the new resolution */ | |
309 okay = CGX_ResizeFullScreen(this); | |
310 if ( ! okay ) { | |
311 CGX_LeaveFullScreen(this); | |
312 } | |
313 /* Set the colormap */ | |
314 /* | |
315 if ( SDL_XColorMap ) { | |
316 XInstallColormap(SDL_Display, SDL_XColorMap); | |
317 } | |
318 */ | |
255
dcb5e869f8b5
Updated Amiga port by Gabriele Greco
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
319 } |
0 | 320 // CGX_GrabInputNoLock(this, this->input_grab | SDL_GRAB_FULLSCREEN); |
321 return(okay); | |
322 } | |
323 | |
324 int CGX_LeaveFullScreen(_THIS) | |
325 { | |
326 if ( currently_fullscreen ) { | |
327 int width,height; | |
328 if ( SDL_Window ) { | |
329 CloseWindow(SDL_Window); | |
330 SDL_Window=NULL; | |
331 } | |
332 CloseScreen(SDL_Display); | |
333 | |
334 GFX_Display=SDL_Display=LockPubScreen(NULL); | |
335 | |
336 currently_fullscreen = 0; | |
337 | |
338 CGX_CreateWindow(this,this->screen,this->screen->w,this->screen->h,GetCyberMapAttr(SDL_Display->RastPort.BitMap,CYBRMATTR_DEPTH),this->screen->flags); | |
339 CGX_ResizeImage(this,this->screen,0L); | |
340 } | |
341 | |
342 return(0); | |
343 } |