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