Mercurial > sdl-ios-xcode
comparison src/video/macrom/SDL_romvideo.c @ 1895:c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Mon, 10 Jul 2006 21:04:37 +0000 |
parents | e6de7e5fd451 |
children |
comparison
equal
deleted
inserted
replaced
1894:c69cee13dd76 | 1895:c121d94672cb |
---|---|
51 #include "../maccommon/SDL_macwm_c.h" | 51 #include "../maccommon/SDL_macwm_c.h" |
52 #include "../maccommon/SDL_macmouse_c.h" | 52 #include "../maccommon/SDL_macmouse_c.h" |
53 #include "../maccommon/SDL_macevents_c.h" | 53 #include "../maccommon/SDL_macevents_c.h" |
54 | 54 |
55 /* Initialization/Query functions */ | 55 /* Initialization/Query functions */ |
56 static int ROM_VideoInit(_THIS, SDL_PixelFormat *vformat); | 56 static int ROM_VideoInit(_THIS, SDL_PixelFormat * vformat); |
57 static SDL_Rect **ROM_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags); | 57 static SDL_Rect **ROM_ListModes(_THIS, SDL_PixelFormat * format, |
58 static SDL_Surface *ROM_SetVideoMode(_THIS, SDL_Surface *current, int width, int height, int bpp, Uint32 flags); | 58 Uint32 flags); |
59 static SDL_Surface *ROM_SetVideoMode(_THIS, SDL_Surface * current, int width, | |
60 int height, int bpp, Uint32 flags); | |
59 static int ROM_SetColors(_THIS, int firstcolor, int ncolors, | 61 static int ROM_SetColors(_THIS, int firstcolor, int ncolors, |
60 SDL_Color *colors); | 62 SDL_Color * colors); |
61 static void ROM_VideoQuit(_THIS); | 63 static void ROM_VideoQuit(_THIS); |
62 | 64 |
63 /* Hardware surface functions */ | 65 /* Hardware surface functions */ |
64 static int ROM_AllocHWSurface(_THIS, SDL_Surface *surface); | 66 static int ROM_AllocHWSurface(_THIS, SDL_Surface * surface); |
65 static int ROM_LockHWSurface(_THIS, SDL_Surface *surface); | 67 static int ROM_LockHWSurface(_THIS, SDL_Surface * surface); |
66 static void ROM_UnlockHWSurface(_THIS, SDL_Surface *surface); | 68 static void ROM_UnlockHWSurface(_THIS, SDL_Surface * surface); |
67 static void ROM_FreeHWSurface(_THIS, SDL_Surface *surface); | 69 static void ROM_FreeHWSurface(_THIS, SDL_Surface * surface); |
68 | 70 |
69 #if !TARGET_API_MAC_CARBON /* This seems not to be available? -sts Aug 2000 */ | 71 #if !TARGET_API_MAC_CARBON /* This seems not to be available? -sts Aug 2000 */ |
70 /* Saved state for the menu bar */ | 72 /* Saved state for the menu bar */ |
71 static RgnHandle gSaveGrayRgn = nil; | 73 static RgnHandle gSaveGrayRgn = nil; |
72 static short gSaveMenuBar = 0; | 74 static short gSaveMenuBar = 0; |
73 static Boolean gSaveCSVis = true; | 75 static Boolean gSaveCSVis = true; |
74 | 76 |
75 #if powerc | 77 #if powerc |
76 /* Mixed mode glue to activate the 68K emulator and twiddle a register */ | 78 /* Mixed mode glue to activate the 68K emulator and twiddle a register */ |
77 #define ONEWORDSTUB(p1) \ | 79 #define ONEWORDSTUB(p1) \ |
78 { 0x41FA, 0x0010, 0x209F, (p1), 0x41FA, \ | 80 { 0x41FA, 0x0010, 0x209F, (p1), 0x41FA, \ |
85 #define THREEWORDSTUB(p1,p2,p3) \ | 87 #define THREEWORDSTUB(p1,p2,p3) \ |
86 { 0x41FA, 0x0014, 0x209F, (p1), (p2), (p3), 0x41FA, \ | 88 { 0x41FA, 0x0014, 0x209F, (p1), (p2), (p3), 0x41FA, \ |
87 0x0008, 0x2F10, 0x4E75, 0x0000, 0x0000, 0x0000 } | 89 0x0008, 0x2F10, 0x4E75, 0x0000, 0x0000, 0x0000 } |
88 | 90 |
89 /* ControlStrip inline glue for PowerPC */ | 91 /* ControlStrip inline glue for PowerPC */ |
90 static pascal Boolean SBIsControlStripVisible(void) | 92 static pascal Boolean |
91 { | 93 SBIsControlStripVisible(void) |
92 static short procData[] = TWOWORDSTUB(0x7000, 0xAAF2); | 94 { |
93 ProcInfoType procInfo = kD0DispatchedPascalStackBased | 95 static short procData[] = TWOWORDSTUB(0x7000, 0xAAF2); |
94 | RESULT_SIZE(SIZE_CODE(sizeof(Boolean))) | 96 ProcInfoType procInfo = kD0DispatchedPascalStackBased |
95 | DISPATCHED_STACK_ROUTINE_SELECTOR_SIZE(kFourByteCode); | 97 | RESULT_SIZE(SIZE_CODE(sizeof(Boolean))) |
96 | 98 | DISPATCHED_STACK_ROUTINE_SELECTOR_SIZE(kFourByteCode); |
97 return((Boolean) CallUniversalProc((UniversalProcPtr) procData, procInfo, 0x00)); | 99 |
98 } | 100 return ((Boolean) |
99 | 101 CallUniversalProc((UniversalProcPtr) procData, procInfo, 0x00)); |
100 static pascal void SBShowHideControlStrip(Boolean showIt) | 102 } |
101 { | 103 |
102 static short procData[] = THREEWORDSTUB(0x303C, 0x0101, 0xAAF2); | 104 static pascal void |
103 ProcInfoType procInfo = kD0DispatchedPascalStackBased | 105 SBShowHideControlStrip(Boolean showIt) |
104 | DISPATCHED_STACK_ROUTINE_SELECTOR_SIZE(kFourByteCode) | 106 { |
105 | DISPATCHED_STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(Boolean))); | 107 static short procData[] = THREEWORDSTUB(0x303C, 0x0101, 0xAAF2); |
106 | 108 ProcInfoType procInfo = kD0DispatchedPascalStackBased |
107 CallUniversalProc((UniversalProcPtr) procData, procInfo, 0x01, showIt); | 109 | DISPATCHED_STACK_ROUTINE_SELECTOR_SIZE(kFourByteCode) |
110 | DISPATCHED_STACK_ROUTINE_PARAMETER(1, | |
111 SIZE_CODE(sizeof(Boolean))); | |
112 | |
113 CallUniversalProc((UniversalProcPtr) procData, procInfo, 0x01, showIt); | |
108 } | 114 } |
109 #endif /* powerc */ | 115 #endif /* powerc */ |
110 #endif /* !TARGET_API_MAC_CARBON */ | 116 #endif /* !TARGET_API_MAC_CARBON */ |
111 | 117 |
112 /* Macintosh toolbox driver bootstrap functions */ | 118 /* Macintosh toolbox driver bootstrap functions */ |
113 | 119 |
114 static int ROM_Available(void) | 120 static int |
115 { | 121 ROM_Available(void) |
116 return(1); | 122 { |
117 } | 123 return (1); |
118 | 124 } |
119 static void ROM_DeleteDevice(SDL_VideoDevice *device) | 125 |
120 { | 126 static void |
121 SDL_free(device->hidden); | 127 ROM_DeleteDevice(SDL_VideoDevice * device) |
122 SDL_free(device); | 128 { |
123 } | 129 SDL_free(device->hidden); |
124 | 130 SDL_free(device); |
125 static SDL_VideoDevice *ROM_CreateDevice(int devindex) | 131 } |
126 { | 132 |
127 SDL_VideoDevice *device; | 133 static SDL_VideoDevice * |
128 | 134 ROM_CreateDevice(int devindex) |
129 /* Initialize all variables that we clean on shutdown */ | 135 { |
130 device = (SDL_VideoDevice *)SDL_malloc(sizeof(SDL_VideoDevice)); | 136 SDL_VideoDevice *device; |
131 if ( device ) { | 137 |
132 SDL_memset(device, 0, (sizeof *device)); | 138 /* Initialize all variables that we clean on shutdown */ |
133 device->hidden = (struct SDL_PrivateVideoData *) | 139 device = (SDL_VideoDevice *) SDL_malloc(sizeof(SDL_VideoDevice)); |
134 SDL_malloc((sizeof *device->hidden)); | 140 if (device) { |
135 } | 141 SDL_memset(device, 0, (sizeof *device)); |
136 if ( (device == NULL) || (device->hidden == NULL) ) { | 142 device->hidden = (struct SDL_PrivateVideoData *) |
137 SDL_OutOfMemory(); | 143 SDL_malloc((sizeof *device->hidden)); |
138 if ( device ) { | 144 } |
139 SDL_free(device); | 145 if ((device == NULL) || (device->hidden == NULL)) { |
140 } | 146 SDL_OutOfMemory(); |
141 return(0); | 147 if (device) { |
142 } | 148 SDL_free(device); |
143 SDL_memset(device->hidden, 0, (sizeof *device->hidden)); | 149 } |
144 | 150 return (0); |
145 /* Set the function pointers */ | 151 } |
146 device->VideoInit = ROM_VideoInit; | 152 SDL_memset(device->hidden, 0, (sizeof *device->hidden)); |
147 device->ListModes = ROM_ListModes; | 153 |
148 device->SetVideoMode = ROM_SetVideoMode; | 154 /* Set the function pointers */ |
149 device->SetColors = ROM_SetColors; | 155 device->VideoInit = ROM_VideoInit; |
150 device->UpdateRects = NULL; | 156 device->ListModes = ROM_ListModes; |
151 device->VideoQuit = ROM_VideoQuit; | 157 device->SetVideoMode = ROM_SetVideoMode; |
152 device->AllocHWSurface = ROM_AllocHWSurface; | 158 device->SetColors = ROM_SetColors; |
153 device->CheckHWBlit = NULL; | 159 device->UpdateRects = NULL; |
154 device->FillHWRect = NULL; | 160 device->VideoQuit = ROM_VideoQuit; |
155 device->SetHWColorKey = NULL; | 161 device->AllocHWSurface = ROM_AllocHWSurface; |
156 device->SetHWAlpha = NULL; | 162 device->CheckHWBlit = NULL; |
157 device->LockHWSurface = ROM_LockHWSurface; | 163 device->FillHWRect = NULL; |
158 device->UnlockHWSurface = ROM_UnlockHWSurface; | 164 device->SetHWColorKey = NULL; |
159 device->FlipHWSurface = NULL; | 165 device->SetHWAlpha = NULL; |
160 device->FreeHWSurface = ROM_FreeHWSurface; | 166 device->LockHWSurface = ROM_LockHWSurface; |
167 device->UnlockHWSurface = ROM_UnlockHWSurface; | |
168 device->FlipHWSurface = NULL; | |
169 device->FreeHWSurface = ROM_FreeHWSurface; | |
161 #if SDL_VIDEO_OPENGL | 170 #if SDL_VIDEO_OPENGL |
162 device->GL_MakeCurrent = Mac_GL_MakeCurrent; | 171 device->GL_MakeCurrent = Mac_GL_MakeCurrent; |
163 device->GL_SwapBuffers = Mac_GL_SwapBuffers; | 172 device->GL_SwapBuffers = Mac_GL_SwapBuffers; |
164 device->GL_LoadLibrary = Mac_GL_LoadLibrary; | 173 device->GL_LoadLibrary = Mac_GL_LoadLibrary; |
165 device->GL_GetProcAddress = Mac_GL_GetProcAddress; | 174 device->GL_GetProcAddress = Mac_GL_GetProcAddress; |
166 #endif // Have OpenGL | 175 #endif // Have OpenGL |
167 device->SetCaption = Mac_SetCaption; | 176 device->SetCaption = Mac_SetCaption; |
168 device->SetIcon = NULL; | 177 device->SetIcon = NULL; |
169 device->IconifyWindow = NULL; | 178 device->IconifyWindow = NULL; |
170 device->GrabInput = NULL; | 179 device->GrabInput = NULL; |
171 device->GetWMInfo = NULL; | 180 device->GetWMInfo = NULL; |
172 device->FreeWMCursor = Mac_FreeWMCursor; | 181 device->FreeWMCursor = Mac_FreeWMCursor; |
173 device->CreateWMCursor = Mac_CreateWMCursor; | 182 device->CreateWMCursor = Mac_CreateWMCursor; |
174 device->ShowWMCursor = Mac_ShowWMCursor; | 183 device->ShowWMCursor = Mac_ShowWMCursor; |
175 device->WarpWMCursor = Mac_WarpWMCursor; | 184 device->WarpWMCursor = Mac_WarpWMCursor; |
176 device->InitOSKeymap = Mac_InitOSKeymap; | 185 device->InitOSKeymap = Mac_InitOSKeymap; |
177 device->PumpEvents = Mac_PumpEvents; | 186 device->PumpEvents = Mac_PumpEvents; |
178 | 187 |
179 device->free = ROM_DeleteDevice; | 188 device->free = ROM_DeleteDevice; |
180 | 189 |
181 return device; | 190 return device; |
182 } | 191 } |
183 | 192 |
184 VideoBootStrap TOOLBOX_bootstrap = { | 193 VideoBootStrap TOOLBOX_bootstrap = { |
185 "toolbox", "MacOS ROM Toolbox", | 194 "toolbox", "MacOS ROM Toolbox", |
186 ROM_Available, ROM_CreateDevice | 195 ROM_Available, ROM_CreateDevice |
187 }; | 196 }; |
188 | 197 |
189 | 198 |
190 static int ROM_VideoInit(_THIS, SDL_PixelFormat *vformat) | 199 static int |
191 { | 200 ROM_VideoInit(_THIS, SDL_PixelFormat * vformat) |
192 long info; | 201 { |
193 | 202 long info; |
194 /* Check out some things about the system */ | 203 |
195 Gestalt(gestaltQuickdrawVersion, &info); | 204 /* Check out some things about the system */ |
196 if ( info == gestaltOriginalQD ) { | 205 Gestalt(gestaltQuickdrawVersion, &info); |
197 SDL_SetError("Color Quickdraw not available"); | 206 if (info == gestaltOriginalQD) { |
198 return(-1); | 207 SDL_SetError("Color Quickdraw not available"); |
199 } | 208 return (-1); |
200 | 209 } |
201 /* Start ROMintosh events */ | 210 |
202 Mac_InitEvents(this); | 211 /* Start ROMintosh events */ |
203 | 212 Mac_InitEvents(this); |
204 /* Get a handle to the main monitor */ | 213 |
205 SDL_Display = GetMainDevice(); | 214 /* Get a handle to the main monitor */ |
206 | 215 SDL_Display = GetMainDevice(); |
207 /* Determine the current screen size */ | 216 |
208 this->info.current_w = (**SDL_Display).gdRect.right; | 217 /* Determine the current screen size */ |
209 this->info.current_h = (**SDL_Display).gdRect.bottom; | 218 this->info.current_w = (**SDL_Display).gdRect.right; |
210 | 219 this->info.current_h = (**SDL_Display).gdRect.bottom; |
211 /* Determine pixel format */ | 220 |
212 vformat->BitsPerPixel = (**(**SDL_Display).gdPMap).pixelSize; | 221 /* Determine pixel format */ |
213 switch (vformat->BitsPerPixel) { | 222 vformat->BitsPerPixel = (**(**SDL_Display).gdPMap).pixelSize; |
214 case 16: /* 5-5-5 RGB */ | 223 switch (vformat->BitsPerPixel) { |
215 vformat->Rmask = 0x00007c00; | 224 case 16: /* 5-5-5 RGB */ |
216 vformat->Gmask = 0x000003e0; | 225 vformat->Rmask = 0x00007c00; |
217 vformat->Bmask = 0x0000001f; | 226 vformat->Gmask = 0x000003e0; |
218 break; | 227 vformat->Bmask = 0x0000001f; |
219 default: | 228 break; |
220 break; | 229 default: |
221 } | 230 break; |
222 | 231 } |
223 /* Create our palette */ | 232 |
224 SDL_CTab = (CTabHandle)NewHandle(sizeof(ColorSpec)*256 + 8); | 233 /* Create our palette */ |
225 if ( SDL_CTab == nil ) { | 234 SDL_CTab = (CTabHandle) NewHandle(sizeof(ColorSpec) * 256 + 8); |
226 SDL_OutOfMemory(); | 235 if (SDL_CTab == nil) { |
227 return(-1); | 236 SDL_OutOfMemory(); |
228 } | 237 return (-1); |
229 (**SDL_CTab).ctSeed = GetCTSeed(); | 238 } |
230 (**SDL_CTab).ctFlags = 0; | 239 (**SDL_CTab).ctSeed = GetCTSeed(); |
231 (**SDL_CTab).ctSize = 255; | 240 (**SDL_CTab).ctFlags = 0; |
232 CTabChanged(SDL_CTab); | 241 (**SDL_CTab).ctSize = 255; |
233 SDL_CPal = NewPalette(256, SDL_CTab, pmExplicit+pmTolerant, 0); | 242 CTabChanged(SDL_CTab); |
234 | 243 SDL_CPal = NewPalette(256, SDL_CTab, pmExplicit + pmTolerant, 0); |
235 /* Get a list of available fullscreen modes */ | 244 |
236 SDL_modelist = (SDL_Rect **)SDL_malloc((1+1)*sizeof(SDL_Rect *)); | 245 /* Get a list of available fullscreen modes */ |
237 if ( SDL_modelist ) { | 246 SDL_modelist = (SDL_Rect **) SDL_malloc((1 + 1) * sizeof(SDL_Rect *)); |
238 SDL_modelist[0] = (SDL_Rect *)SDL_malloc(sizeof(SDL_Rect)); | 247 if (SDL_modelist) { |
239 if ( SDL_modelist[0] ) { | 248 SDL_modelist[0] = (SDL_Rect *) SDL_malloc(sizeof(SDL_Rect)); |
240 SDL_modelist[0]->x = 0; | 249 if (SDL_modelist[0]) { |
241 SDL_modelist[0]->y = 0; | 250 SDL_modelist[0]->x = 0; |
242 SDL_modelist[0]->w = (**SDL_Display).gdRect.right; | 251 SDL_modelist[0]->y = 0; |
243 SDL_modelist[0]->h = (**SDL_Display).gdRect.bottom; | 252 SDL_modelist[0]->w = (**SDL_Display).gdRect.right; |
244 } | 253 SDL_modelist[0]->h = (**SDL_Display).gdRect.bottom; |
245 SDL_modelist[1] = NULL; | 254 } |
246 } | 255 SDL_modelist[1] = NULL; |
247 | 256 } |
248 /* Fill in some window manager capabilities */ | 257 |
249 this->info.wm_available = 1; | 258 /* Fill in some window manager capabilities */ |
250 | 259 this->info.wm_available = 1; |
251 /* We're done! */ | 260 |
252 return(0); | 261 /* We're done! */ |
253 } | 262 return (0); |
254 | 263 } |
255 static SDL_Rect **ROM_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags) | 264 |
256 { | 265 static SDL_Rect ** |
257 if ( this->screen->format->BitsPerPixel == format->BitsPerPixel ) { | 266 ROM_ListModes(_THIS, SDL_PixelFormat * format, Uint32 flags) |
258 if ( (flags & SDL_FULLSCREEN) == SDL_FULLSCREEN ) { | 267 { |
259 return(SDL_modelist); | 268 if (this->screen->format->BitsPerPixel == format->BitsPerPixel) { |
260 } else { | 269 if ((flags & SDL_FULLSCREEN) == SDL_FULLSCREEN) { |
261 return((SDL_Rect **)-1); | 270 return (SDL_modelist); |
262 } | 271 } else { |
263 } else { | 272 return ((SDL_Rect **) - 1); |
264 return((SDL_Rect **)0); | 273 } |
265 } | 274 } else { |
266 } | 275 return ((SDL_Rect **) 0); |
267 | 276 } |
268 static void ROM_HideMenuBar(_THIS) | 277 } |
269 { | 278 |
270 #if !TARGET_API_MAC_CARBON /* This seems not to be available? -sts Aug 2000 */ | 279 static void |
271 RgnHandle drawRgn = nil; | 280 ROM_HideMenuBar(_THIS) |
272 RgnHandle tempRgn = nil; | 281 { |
273 RgnHandle grayRgn = nil; | 282 #if !TARGET_API_MAC_CARBON /* This seems not to be available? -sts Aug 2000 */ |
274 WindowPtr window = nil; | 283 RgnHandle drawRgn = nil; |
275 GDHandle gd = nil; | 284 RgnHandle tempRgn = nil; |
276 GrafPtr savePort; | 285 RgnHandle grayRgn = nil; |
277 long response; | 286 WindowPtr window = nil; |
278 short height; | 287 GDHandle gd = nil; |
279 EventRecord theEvent; | 288 GrafPtr savePort; |
280 | 289 long response; |
281 height = GetMBarHeight(); | 290 short height; |
282 | 291 EventRecord theEvent; |
283 if ( height > 0 ) { | 292 |
284 tempRgn = NewRgn(); | 293 height = GetMBarHeight(); |
285 drawRgn = NewRgn(); | 294 |
286 gSaveGrayRgn = NewRgn(); | 295 if (height > 0) { |
287 if ( ! tempRgn || ! drawRgn || ! gSaveGrayRgn ) { | 296 tempRgn = NewRgn(); |
288 goto CLEANUP; | 297 drawRgn = NewRgn(); |
289 } | 298 gSaveGrayRgn = NewRgn(); |
290 grayRgn = GetGrayRgn(); /* No need to check for this */ | 299 if (!tempRgn || !drawRgn || !gSaveGrayRgn) { |
291 | 300 goto CLEANUP; |
292 GetPort(&savePort); | 301 } |
293 | 302 grayRgn = GetGrayRgn(); /* No need to check for this */ |
294 /* Hide the control strip if it's present, and record its | 303 |
295 previous position into the dirty region for redrawing. | 304 GetPort(&savePort); |
296 This isn't necessary, but may help catch stray bits. */ | 305 |
297 CopyRgn(grayRgn, tempRgn); | 306 /* Hide the control strip if it's present, and record its |
298 if (!Gestalt(gestaltControlStripAttr, &response) && | 307 previous position into the dirty region for redrawing. |
299 (response & (1L << gestaltControlStripExists))) { | 308 This isn't necessary, but may help catch stray bits. */ |
300 gSaveCSVis = SBIsControlStripVisible(); | 309 CopyRgn(grayRgn, tempRgn); |
301 if (gSaveCSVis) | 310 if (!Gestalt(gestaltControlStripAttr, &response) && |
302 SBShowHideControlStrip(false); | 311 (response & (1L << gestaltControlStripExists))) { |
303 } | 312 gSaveCSVis = SBIsControlStripVisible(); |
304 DiffRgn(grayRgn, tempRgn, drawRgn); | 313 if (gSaveCSVis) |
305 | 314 SBShowHideControlStrip(false); |
306 /* Save the gray region once the control strip is hidden*/ | 315 } |
307 CopyRgn(grayRgn, gSaveGrayRgn); | 316 DiffRgn(grayRgn, tempRgn, drawRgn); |
308 | 317 |
309 /* Change the menu height in lowmem */ | 318 /* Save the gray region once the control strip is hidden */ |
310 gSaveMenuBar = height; | 319 CopyRgn(grayRgn, gSaveGrayRgn); |
311 LMSetMBarHeight(0); | 320 |
312 | 321 /* Change the menu height in lowmem */ |
313 /* Walk the monitor rectangles, and combine any pieces that | 322 gSaveMenuBar = height; |
314 aren't in GrayRgn: menubar, round corners, fake floaters. */ | 323 LMSetMBarHeight(0); |
315 for(gd = GetDeviceList(); gd; gd = GetNextDevice(gd)) | 324 |
316 { | 325 /* Walk the monitor rectangles, and combine any pieces that |
317 if (!TestDeviceAttribute(gd, screenDevice)) continue; | 326 aren't in GrayRgn: menubar, round corners, fake floaters. */ |
318 if (!TestDeviceAttribute(gd, screenActive)) continue; | 327 for (gd = GetDeviceList(); gd; gd = GetNextDevice(gd)) { |
319 | 328 if (!TestDeviceAttribute(gd, screenDevice)) |
320 RectRgn(tempRgn, &(*gd)->gdRect); /* Get the whole screen */ | 329 continue; |
321 DiffRgn(tempRgn, grayRgn, tempRgn); /* Subtract out GrayRgn */ | 330 if (!TestDeviceAttribute(gd, screenActive)) |
322 UnionRgn(tempRgn, drawRgn, drawRgn);/* Combine all the bits */ | 331 continue; |
323 } | 332 |
324 | 333 RectRgn(tempRgn, &(*gd)->gdRect); /* Get the whole screen */ |
325 /* Add the bits into the GrayRgn */ | 334 DiffRgn(tempRgn, grayRgn, tempRgn); /* Subtract out GrayRgn */ |
326 UnionRgn(drawRgn, grayRgn, grayRgn); | 335 UnionRgn(tempRgn, drawRgn, drawRgn); /* Combine all the bits */ |
327 | 336 } |
328 /* Modify the vis regions of exposed windows */ | 337 |
329 window = (FrontWindow()) ? FrontWindow() : (WindowPtr) -1L; | 338 /* Add the bits into the GrayRgn */ |
330 PaintBehind(window, drawRgn); | 339 UnionRgn(drawRgn, grayRgn, grayRgn); |
331 CalcVisBehind(window, drawRgn); | 340 |
332 | 341 /* Modify the vis regions of exposed windows */ |
333 SetPort(savePort); | 342 window = (FrontWindow())? FrontWindow() : (WindowPtr) - 1L; |
334 | 343 PaintBehind(window, drawRgn); |
335 /* Yield time so that floaters can catch up */ | 344 CalcVisBehind(window, drawRgn); |
336 EventAvail(0, &theEvent); | 345 |
337 EventAvail(0, &theEvent); | 346 SetPort(savePort); |
338 EventAvail(0, &theEvent); | 347 |
339 EventAvail(0, &theEvent); | 348 /* Yield time so that floaters can catch up */ |
340 } | 349 EventAvail(0, &theEvent); |
341 | 350 EventAvail(0, &theEvent); |
342 CLEANUP: | 351 EventAvail(0, &theEvent); |
343 | 352 EventAvail(0, &theEvent); |
344 if (tempRgn) DisposeRgn(tempRgn); | 353 } |
345 if (drawRgn) DisposeRgn(drawRgn); | 354 |
355 CLEANUP: | |
356 | |
357 if (tempRgn) | |
358 DisposeRgn(tempRgn); | |
359 if (drawRgn) | |
360 DisposeRgn(drawRgn); | |
346 #endif /* !TARGET_API_MAC_CARBON */ | 361 #endif /* !TARGET_API_MAC_CARBON */ |
347 } | 362 } |
348 | 363 |
349 static void ROM_ShowMenuBar(_THIS) | 364 static void |
350 { | 365 ROM_ShowMenuBar(_THIS) |
351 #if !TARGET_API_MAC_CARBON /* This seems not to be available? -sts Aug 2000 */ | 366 { |
352 RgnHandle drawRgn = nil; | 367 #if !TARGET_API_MAC_CARBON /* This seems not to be available? -sts Aug 2000 */ |
353 RgnHandle menuRgn = nil; | 368 RgnHandle drawRgn = nil; |
354 RgnHandle tempRgn = nil; | 369 RgnHandle menuRgn = nil; |
355 RgnHandle grayRgn = nil; | 370 RgnHandle tempRgn = nil; |
356 WindowPtr window = nil; | 371 RgnHandle grayRgn = nil; |
357 GrafPtr wMgrPort; | 372 WindowPtr window = nil; |
358 GrafPtr savePort; | 373 GrafPtr wMgrPort; |
359 Rect menuRect; | 374 GrafPtr savePort; |
360 long response; | 375 Rect menuRect; |
361 short height; | 376 long response; |
362 EventRecord theEvent; | 377 short height; |
363 RGBColor saveRGB; | 378 EventRecord theEvent; |
364 RGBColor blackRGB = { 0, 0, 0 }; | 379 RGBColor saveRGB; |
365 | 380 RGBColor blackRGB = { 0, 0, 0 }; |
366 height = GetMBarHeight(); | 381 |
367 | 382 height = GetMBarHeight(); |
368 if ((height <= 0) && (gSaveMenuBar > 0)) { | 383 |
369 drawRgn = NewRgn(); | 384 if ((height <= 0) && (gSaveMenuBar > 0)) { |
370 menuRgn = NewRgn(); | 385 drawRgn = NewRgn(); |
371 tempRgn = NewRgn(); | 386 menuRgn = NewRgn(); |
372 if ( ! tempRgn || ! drawRgn || ! gSaveGrayRgn ) { | 387 tempRgn = NewRgn(); |
373 goto CLEANUP; | 388 if (!tempRgn || !drawRgn || !gSaveGrayRgn) { |
374 } | 389 goto CLEANUP; |
375 grayRgn = GetGrayRgn(); /* No need to check for this */ | 390 } |
376 | 391 grayRgn = GetGrayRgn(); /* No need to check for this */ |
377 GetPort(&savePort); | 392 |
378 GetWMgrPort(&wMgrPort); | 393 GetPort(&savePort); |
379 | 394 GetWMgrPort(&wMgrPort); |
380 /* Set the height properly */ | 395 |
381 LMSetMBarHeight(gSaveMenuBar); | 396 /* Set the height properly */ |
382 | 397 LMSetMBarHeight(gSaveMenuBar); |
383 /* Restore the old GrayRgn: rounded corners, etc, but not | 398 |
384 the menubar -- subtract that out first! */ | 399 /* Restore the old GrayRgn: rounded corners, etc, but not |
385 if (gSaveGrayRgn) | 400 the menubar -- subtract that out first! */ |
386 { | 401 if (gSaveGrayRgn) { |
387 menuRect = (*GetMainDevice())->gdRect; | 402 menuRect = (*GetMainDevice())->gdRect; |
388 menuRect.bottom = menuRect.top + gSaveMenuBar; | 403 menuRect.bottom = menuRect.top + gSaveMenuBar; |
389 RectRgn(menuRgn, &menuRect); | 404 RectRgn(menuRgn, &menuRect); |
390 | 405 |
391 DiffRgn(grayRgn, gSaveGrayRgn, drawRgn); /* What do we inval? */ | 406 DiffRgn(grayRgn, gSaveGrayRgn, drawRgn); /* What do we inval? */ |
392 DiffRgn(drawRgn, menuRgn, drawRgn); /* Clip out the menu */ | 407 DiffRgn(drawRgn, menuRgn, drawRgn); /* Clip out the menu */ |
393 | 408 |
394 /* Now redraw the corners and other bits black */ | 409 /* Now redraw the corners and other bits black */ |
395 SetPort(wMgrPort); | 410 SetPort(wMgrPort); |
396 GetClip(tempRgn); | 411 GetClip(tempRgn); |
397 SetClip(drawRgn); | 412 SetClip(drawRgn); |
398 GetForeColor(&saveRGB); | 413 GetForeColor(&saveRGB); |
399 RGBForeColor(&blackRGB); | 414 RGBForeColor(&blackRGB); |
400 PaintRgn(drawRgn); | 415 PaintRgn(drawRgn); |
401 RGBForeColor(&saveRGB); | 416 RGBForeColor(&saveRGB); |
402 SetClip(tempRgn); | 417 SetClip(tempRgn); |
403 SetPort(savePort); | 418 SetPort(savePort); |
404 | 419 |
405 UnionRgn(drawRgn, menuRgn, drawRgn); /* Put back the menu */ | 420 UnionRgn(drawRgn, menuRgn, drawRgn); /* Put back the menu */ |
406 | 421 |
407 /* Now actually restore the GrayRgn */ | 422 /* Now actually restore the GrayRgn */ |
408 CopyRgn(gSaveGrayRgn, grayRgn); | 423 CopyRgn(gSaveGrayRgn, grayRgn); |
409 DisposeRgn(gSaveGrayRgn); | 424 DisposeRgn(gSaveGrayRgn); |
410 gSaveGrayRgn = nil; | 425 gSaveGrayRgn = nil; |
411 } | 426 } |
412 | 427 |
413 /* Modify the vis regions of exposed windows and draw menubar */ | 428 /* Modify the vis regions of exposed windows and draw menubar */ |
414 window = (FrontWindow()) ? FrontWindow() : (WindowPtr) -1L; | 429 window = (FrontWindow())? FrontWindow() : (WindowPtr) - 1L; |
415 PaintBehind(window, drawRgn); | 430 PaintBehind(window, drawRgn); |
416 CalcVisBehind(window, drawRgn); | 431 CalcVisBehind(window, drawRgn); |
417 DrawMenuBar(); | 432 DrawMenuBar(); |
418 | 433 |
419 SetPort(savePort); | 434 SetPort(savePort); |
420 gSaveMenuBar = 0; | 435 gSaveMenuBar = 0; |
421 | 436 |
422 /* Now show the control strip if it's present */ | 437 /* Now show the control strip if it's present */ |
423 if (!Gestalt(gestaltControlStripAttr, &response) && | 438 if (!Gestalt(gestaltControlStripAttr, &response) && |
424 (response & (1L << gestaltControlStripExists))) | 439 (response & (1L << gestaltControlStripExists))) { |
425 { | 440 if (gSaveCSVis && !SBIsControlStripVisible()) |
426 if (gSaveCSVis && !SBIsControlStripVisible()) | 441 SBShowHideControlStrip(true); |
427 SBShowHideControlStrip(true); | 442 gSaveCSVis = true; |
428 gSaveCSVis = true; | 443 } |
429 } | 444 |
430 | 445 /* Yield time so that floaters can catch up */ |
431 /* Yield time so that floaters can catch up */ | 446 EventAvail(0, &theEvent); |
432 EventAvail(0, &theEvent); | 447 EventAvail(0, &theEvent); |
433 EventAvail(0, &theEvent); | 448 EventAvail(0, &theEvent); |
434 EventAvail(0, &theEvent); | 449 EventAvail(0, &theEvent); |
435 EventAvail(0, &theEvent); | 450 } |
436 } | 451 |
437 | 452 CLEANUP: |
438 CLEANUP: | 453 |
439 | 454 if (drawRgn) |
440 if (drawRgn) DisposeRgn(drawRgn); | 455 DisposeRgn(drawRgn); |
441 if (menuRgn) DisposeRgn(menuRgn); | 456 if (menuRgn) |
442 if (tempRgn) DisposeRgn(tempRgn); | 457 DisposeRgn(menuRgn); |
458 if (tempRgn) | |
459 DisposeRgn(tempRgn); | |
443 #endif /* !TARGET_API_MAC_CARBON */ | 460 #endif /* !TARGET_API_MAC_CARBON */ |
444 } | 461 } |
445 | 462 |
446 /* Various screen update functions available */ | 463 /* Various screen update functions available */ |
447 static void ROM_DirectUpdate(_THIS, int numrects, SDL_Rect *rects); | 464 static void ROM_DirectUpdate(_THIS, int numrects, SDL_Rect * rects); |
448 static void ROM_WindowUpdate(_THIS, int numrects, SDL_Rect *rects); | 465 static void ROM_WindowUpdate(_THIS, int numrects, SDL_Rect * rects); |
449 | 466 |
450 static void ROM_UnsetVideoMode(_THIS, SDL_Surface *current) | 467 static void |
451 { | 468 ROM_UnsetVideoMode(_THIS, SDL_Surface * current) |
452 /* Free the current window, if any */ | 469 { |
453 if ( SDL_Window != nil ) { | 470 /* Free the current window, if any */ |
454 GWorldPtr memworld; | 471 if (SDL_Window != nil) { |
455 | 472 GWorldPtr memworld; |
456 /* Handle OpenGL support */ | 473 |
457 Mac_GL_Quit(this); | 474 /* Handle OpenGL support */ |
458 | 475 Mac_GL_Quit(this); |
459 memworld = (GWorldPtr)GetWRefCon(SDL_Window); | 476 |
460 if ( memworld != nil ) { | 477 memworld = (GWorldPtr) GetWRefCon(SDL_Window); |
461 UnlockPixels(GetGWorldPixMap(memworld)); | 478 if (memworld != nil) { |
462 DisposeGWorld(memworld); | 479 UnlockPixels(GetGWorldPixMap(memworld)); |
463 } | 480 DisposeGWorld(memworld); |
464 if ( (current->flags & SDL_FULLSCREEN) == SDL_FULLSCREEN ) { | 481 } |
482 if ((current->flags & SDL_FULLSCREEN) == SDL_FULLSCREEN) { | |
465 #if USE_QUICKTIME | 483 #if USE_QUICKTIME |
466 EndFullScreen(fullscreen_ctx, nil); | 484 EndFullScreen(fullscreen_ctx, nil); |
467 SDL_Window = nil; | 485 SDL_Window = nil; |
468 #else | 486 #else |
469 ROM_ShowMenuBar(this); | 487 ROM_ShowMenuBar(this); |
470 #endif | 488 #endif |
471 } | 489 } |
472 } | 490 } |
473 current->pixels = NULL; | 491 current->pixels = NULL; |
474 current->flags &= ~(SDL_HWSURFACE|SDL_FULLSCREEN); | 492 current->flags &= ~(SDL_HWSURFACE | SDL_FULLSCREEN); |
475 } | 493 } |
476 | 494 |
477 static SDL_Surface *ROM_SetVideoMode(_THIS, SDL_Surface *current, | 495 static SDL_Surface * |
478 int width, int height, int bpp, Uint32 flags) | 496 ROM_SetVideoMode(_THIS, SDL_Surface * current, |
479 { | 497 int width, int height, int bpp, Uint32 flags) |
480 Rect wrect, orect; | 498 { |
499 Rect wrect, orect; | |
481 #if TARGET_API_MAC_CARBON | 500 #if TARGET_API_MAC_CARBON |
482 Rect tmprect; | 501 Rect tmprect; |
483 #endif | 502 #endif |
484 | 503 |
485 /* Free any previous video mode */ | 504 /* Free any previous video mode */ |
486 ROM_UnsetVideoMode(this, current); | 505 ROM_UnsetVideoMode(this, current); |
487 | 506 |
488 /* Create the ROM window and SDL video surface */ | 507 /* Create the ROM window and SDL video surface */ |
489 current->flags = 0; /* Clear flags */ | 508 current->flags = 0; /* Clear flags */ |
490 current->w = width; | 509 current->w = width; |
491 current->h = height; | 510 current->h = height; |
492 SetRect(&wrect, 0, 0, width, height); | 511 SetRect(&wrect, 0, 0, width, height); |
493 if ( SDL_Window ) { | 512 if (SDL_Window) { |
494 /* If we recreate the window, don't move it around */ | 513 /* If we recreate the window, don't move it around */ |
495 #if TARGET_API_MAC_CARBON | 514 #if TARGET_API_MAC_CARBON |
496 orect = *GetWindowPortBounds(SDL_Window, &tmprect); | 515 orect = *GetWindowPortBounds(SDL_Window, &tmprect); |
497 #else | 516 #else |
498 orect = SDL_Window->portRect; | 517 orect = SDL_Window->portRect; |
499 #endif | 518 #endif |
500 OffsetRect(&wrect, orect.left, orect.top); | 519 OffsetRect(&wrect, orect.left, orect.top); |
501 } else { | 520 } else { |
502 /* Center the window the first time we show it */ | 521 /* Center the window the first time we show it */ |
503 OffsetRect(&wrect, | 522 OffsetRect(&wrect, |
504 (SDL_modelist[0]->w-width)/2, (SDL_modelist[0]->h-height)/2); | 523 (SDL_modelist[0]->w - width) / 2, |
505 } | 524 (SDL_modelist[0]->h - height) / 2); |
525 } | |
506 | 526 |
507 #if defined(__MACOSX__) && !USE_QUICKTIME | 527 #if defined(__MACOSX__) && !USE_QUICKTIME |
508 /* Hum.. fullscreen mode is broken */ | 528 /* Hum.. fullscreen mode is broken */ |
509 flags &= ~SDL_FULLSCREEN; | 529 flags &= ~SDL_FULLSCREEN; |
510 #endif | 530 #endif |
511 if ( (flags & SDL_FULLSCREEN) == SDL_FULLSCREEN ) { | 531 if ((flags & SDL_FULLSCREEN) == SDL_FULLSCREEN) { |
512 /* Create the fullscreen window and use screen bits */ | 532 /* Create the fullscreen window and use screen bits */ |
513 current->flags |= SDL_HWSURFACE|SDL_FULLSCREEN; | 533 current->flags |= SDL_HWSURFACE | SDL_FULLSCREEN; |
514 if ( SDL_Window ) { | 534 if (SDL_Window) { |
515 DisposeWindow(SDL_Window); | 535 DisposeWindow(SDL_Window); |
516 } | 536 } |
517 #if USE_QUICKTIME | 537 #if USE_QUICKTIME |
518 BeginFullScreen(&fullscreen_ctx, nil, 0,0, &SDL_Window, nil, 0); | 538 BeginFullScreen(&fullscreen_ctx, nil, 0, 0, &SDL_Window, nil, 0); |
519 #else | 539 #else |
520 SDL_Window = NewCWindow(nil, &wrect, "\p", true, plainDBox, | 540 SDL_Window = NewCWindow(nil, &wrect, "\p", true, plainDBox, |
521 (WindowPtr)-1, false, 0); | 541 (WindowPtr) - 1, false, 0); |
522 ROM_HideMenuBar(this); | 542 ROM_HideMenuBar(this); |
523 #endif | 543 #endif |
524 current->pitch = (**(**SDL_Display).gdPMap).rowBytes & 0x3FFF; | 544 current->pitch = (**(**SDL_Display).gdPMap).rowBytes & 0x3FFF; |
525 current->pixels = (**(**SDL_Display).gdPMap).baseAddr; | 545 current->pixels = (**(**SDL_Display).gdPMap).baseAddr; |
526 this->UpdateRects = ROM_DirectUpdate; | 546 this->UpdateRects = ROM_DirectUpdate; |
527 } else { | 547 } else { |
528 GWorldPtr memworld; | 548 GWorldPtr memworld; |
529 PixMapHandle pixmap; | 549 PixMapHandle pixmap; |
530 int style; | 550 int style; |
531 | 551 |
532 style = noGrowDocProc; | 552 style = noGrowDocProc; |
533 if ( flags & SDL_NOFRAME ) { | 553 if (flags & SDL_NOFRAME) { |
534 style = plainDBox; | 554 style = plainDBox; |
535 current->flags |= SDL_NOFRAME; | 555 current->flags |= SDL_NOFRAME; |
536 } else | 556 } else if (flags & SDL_RESIZABLE) { |
537 if ( flags & SDL_RESIZABLE ) { | 557 style = zoomDocProc; |
538 style = zoomDocProc; | 558 current->flags |= SDL_RESIZABLE; |
539 current->flags |= SDL_RESIZABLE; | 559 } |
540 } | 560 if (SDL_Window && (style == current_style)) { |
541 if ( SDL_Window && (style == current_style) ) { | 561 /* Resize existing window, if necessary */ |
542 /* Resize existing window, if necessary */ | 562 if (((orect.right - orect.left) != width) || |
543 if ( ((orect.right-orect.left) != width) || | 563 ((orect.bottom - orect.top) != height)) { |
544 ((orect.bottom-orect.top) != height) ) { | 564 SizeWindow(SDL_Window, width, height, false); |
545 SizeWindow(SDL_Window, width, height, false); | 565 } |
546 } | 566 } else { |
547 } else { | 567 /* Recreate the window in the new style */ |
548 /* Recreate the window in the new style */ | 568 if (SDL_Window) { |
549 if ( SDL_Window ) { | 569 DisposeWindow(SDL_Window); |
550 DisposeWindow(SDL_Window); | 570 } |
551 } | 571 SDL_Window = NewCWindow(nil, &wrect, "\p", true, |
552 SDL_Window = NewCWindow(nil, &wrect, "\p", true, | 572 style, (WindowPtr) - 1, true, 0); |
553 style, (WindowPtr)-1, true, 0); | 573 |
554 | 574 /* Set the window title, if any */ |
555 /* Set the window title, if any */ | 575 { |
556 { char *title; | 576 char *title; |
557 SDL_WM_GetCaption(&title, NULL); | 577 SDL_WM_GetCaption(&title, NULL); |
558 if ( title ) { | 578 if (title) { |
559 Mac_SetCaption(this, title, NULL); | 579 Mac_SetCaption(this, title, NULL); |
560 } | 580 } |
561 } | 581 } |
562 } | 582 } |
563 current_style = style; | 583 current_style = style; |
564 SetPalette(SDL_Window, SDL_CPal, false); | 584 SetPalette(SDL_Window, SDL_CPal, false); |
565 ActivatePalette(SDL_Window); | 585 ActivatePalette(SDL_Window); |
566 if ( NewGWorld(&memworld, 0, | 586 if (NewGWorld(&memworld, 0, |
567 #if TARGET_API_MAC_CARBON | 587 #if TARGET_API_MAC_CARBON |
568 GetWindowPortBounds(SDL_Window, &tmprect), | 588 GetWindowPortBounds(SDL_Window, &tmprect), |
569 #else | 589 #else |
570 &SDL_Window->portRect, | 590 &SDL_Window->portRect, |
571 #endif | 591 #endif |
572 SDL_CTab, nil, 0) != noErr ) { | 592 SDL_CTab, nil, 0) != noErr) { |
573 SDL_SetError("NewGWorld() failed"); | 593 SDL_SetError("NewGWorld() failed"); |
574 return(NULL); | 594 return (NULL); |
575 } | 595 } |
576 SetWRefCon(SDL_Window, (long)memworld); | 596 SetWRefCon(SDL_Window, (long) memworld); |
577 pixmap = GetGWorldPixMap(memworld); | 597 pixmap = GetGWorldPixMap(memworld); |
578 LockPixels(pixmap); | 598 LockPixels(pixmap); |
579 current->pitch = (**pixmap).rowBytes & 0x3FFF; | 599 current->pitch = (**pixmap).rowBytes & 0x3FFF; |
580 current->pixels = GetPixBaseAddr(pixmap); | 600 current->pixels = GetPixBaseAddr(pixmap); |
581 this->UpdateRects = ROM_WindowUpdate; | 601 this->UpdateRects = ROM_WindowUpdate; |
582 } | 602 } |
583 SetPortWindowPort(SDL_Window); | 603 SetPortWindowPort(SDL_Window); |
584 SelectWindow(SDL_Window); | 604 SelectWindow(SDL_Window); |
585 | 605 |
586 /* Handle OpenGL support */ | 606 /* Handle OpenGL support */ |
587 if ( flags & SDL_OPENGL ) { | 607 if (flags & SDL_INTERNALOPENGL) { |
588 if ( Mac_GL_Init(this) == 0 ) { | 608 if (Mac_GL_Init(this) == 0) { |
589 current->flags |= SDL_OPENGL; | 609 current->flags |= SDL_INTERNALOPENGL; |
590 } else { | 610 } else { |
591 current = NULL; | 611 current = NULL; |
592 } | 612 } |
593 } | 613 } |
594 | 614 |
595 if ( (flags & SDL_HWPALETTE) && (flags & SDL_FULLSCREEN) ) | 615 if ((flags & SDL_HWPALETTE) && (flags & SDL_FULLSCREEN)) |
596 current->flags |= SDL_HWPALETTE; | 616 current->flags |= SDL_HWPALETTE; |
597 | 617 |
598 /* We're live! */ | 618 /* We're live! */ |
599 return(current); | 619 return (current); |
600 } | 620 } |
601 | 621 |
602 /* We don't actually allow hardware surfaces other than the main one */ | 622 /* We don't actually allow hardware surfaces other than the main one */ |
603 static int ROM_AllocHWSurface(_THIS, SDL_Surface *surface) | 623 static int |
604 { | 624 ROM_AllocHWSurface(_THIS, SDL_Surface * surface) |
605 return(-1); | 625 { |
606 } | 626 return (-1); |
607 static void ROM_FreeHWSurface(_THIS, SDL_Surface *surface) | 627 } |
608 { | 628 static void |
609 return; | 629 ROM_FreeHWSurface(_THIS, SDL_Surface * surface) |
610 } | 630 { |
611 static int ROM_LockHWSurface(_THIS, SDL_Surface *surface) | 631 return; |
612 { | 632 } |
613 return(0); | 633 static int |
614 } | 634 ROM_LockHWSurface(_THIS, SDL_Surface * surface) |
615 static void ROM_UnlockHWSurface(_THIS, SDL_Surface *surface) | 635 { |
616 { | 636 return (0); |
617 return; | 637 } |
618 } | 638 static void |
619 | 639 ROM_UnlockHWSurface(_THIS, SDL_Surface * surface) |
620 static void ROM_DirectUpdate(_THIS, int numrects, SDL_Rect *rects) | 640 { |
621 { | 641 return; |
622 /* The application is already updating the visible video memory */ | 642 } |
623 return; | 643 |
624 } | 644 static void |
625 | 645 ROM_DirectUpdate(_THIS, int numrects, SDL_Rect * rects) |
626 static void ROM_WindowUpdate(_THIS, int numrects, SDL_Rect *rects) | 646 { |
627 { | 647 /* The application is already updating the visible video memory */ |
628 GWorldPtr memworld; | 648 return; |
629 GrafPtr saveport; | 649 } |
630 CGrafPtr thePort; | 650 |
631 const BitMap *memBits; | 651 static void |
632 const BitMap *winBits; | 652 ROM_WindowUpdate(_THIS, int numrects, SDL_Rect * rects) |
633 int i; | 653 { |
634 Rect update; | 654 GWorldPtr memworld; |
635 | 655 GrafPtr saveport; |
636 /* Copy from the offscreen GWorld to the window port */ | 656 CGrafPtr thePort; |
637 GetPort(&saveport); | 657 const BitMap *memBits; |
638 SetPortWindowPort(SDL_Window); | 658 const BitMap *winBits; |
639 thePort = GetWindowPort(SDL_Window); | 659 int i; |
640 memworld = (GWorldPtr)GetWRefCon(SDL_Window); | 660 Rect update; |
661 | |
662 /* Copy from the offscreen GWorld to the window port */ | |
663 GetPort(&saveport); | |
664 SetPortWindowPort(SDL_Window); | |
665 thePort = GetWindowPort(SDL_Window); | |
666 memworld = (GWorldPtr) GetWRefCon(SDL_Window); | |
641 #if TARGET_API_MAC_CARBON && ACCESSOR_CALLS_ARE_FUNCTIONS | 667 #if TARGET_API_MAC_CARBON && ACCESSOR_CALLS_ARE_FUNCTIONS |
642 memBits = GetPortBitMapForCopyBits((CGrafPtr) memworld); | 668 memBits = GetPortBitMapForCopyBits((CGrafPtr) memworld); |
643 #else | 669 #else |
644 memBits = &((GrafPtr)memworld)->portBits; | 670 memBits = &((GrafPtr) memworld)->portBits; |
645 #endif | 671 #endif |
646 #if TARGET_API_MAC_CARBON && ACCESSOR_CALLS_ARE_FUNCTIONS | 672 #if TARGET_API_MAC_CARBON && ACCESSOR_CALLS_ARE_FUNCTIONS |
647 winBits = GetPortBitMapForCopyBits(thePort); | 673 winBits = GetPortBitMapForCopyBits(thePort); |
648 #else | 674 #else |
649 winBits = &SDL_Window->portBits; | 675 winBits = &SDL_Window->portBits; |
650 #endif | 676 #endif |
651 for ( i=0; i<numrects; ++i ) { | 677 for (i = 0; i < numrects; ++i) { |
652 update.left = rects[i].x; | 678 update.left = rects[i].x; |
653 update.right = rects[i].x+rects[i].w; | 679 update.right = rects[i].x + rects[i].w; |
654 update.top = rects[i].y; | 680 update.top = rects[i].y; |
655 update.bottom = rects[i].y+rects[i].h; | 681 update.bottom = rects[i].y + rects[i].h; |
656 CopyBits(memBits, winBits, | 682 CopyBits(memBits, winBits, &update, &update, srcCopy, nil); |
657 &update, &update, srcCopy, nil); | 683 } |
658 } | |
659 #if TARGET_API_MAC_CARBON | 684 #if TARGET_API_MAC_CARBON |
660 if ( QDIsPortBuffered(thePort) ) { | 685 if (QDIsPortBuffered(thePort)) { |
661 QDFlushPortBuffer(thePort, NULL); | 686 QDFlushPortBuffer(thePort, NULL); |
662 } | 687 } |
663 #endif | 688 #endif |
664 SetPort(saveport); | 689 SetPort(saveport); |
665 } | 690 } |
666 | 691 |
667 static int ROM_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors) | 692 static int |
668 { | 693 ROM_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color * colors) |
669 CTabHandle cTab; | 694 { |
670 int i; | 695 CTabHandle cTab; |
671 | 696 int i; |
672 /* Get the colortable from the either the display or window */ | 697 |
673 if ( (this->screen->flags & SDL_FULLSCREEN) == SDL_FULLSCREEN ) { | 698 /* Get the colortable from the either the display or window */ |
674 cTab = (**(**SDL_Display).gdPMap).pmTable; | 699 if ((this->screen->flags & SDL_FULLSCREEN) == SDL_FULLSCREEN) { |
675 } else { | 700 cTab = (**(**SDL_Display).gdPMap).pmTable; |
676 cTab = SDL_CTab; | 701 } else { |
677 } | 702 cTab = SDL_CTab; |
678 | 703 } |
679 /* Verify the range of colors */ | 704 |
680 if ( (firstcolor+ncolors) > ((**cTab).ctSize+1) ) { | 705 /* Verify the range of colors */ |
681 return(0); | 706 if ((firstcolor + ncolors) > ((**cTab).ctSize + 1)) { |
682 } | 707 return (0); |
683 | 708 } |
684 /* Set the screen palette and update the display */ | 709 |
685 for ( i=0; i< ncolors; ++i ) { | 710 /* Set the screen palette and update the display */ |
686 int j = firstcolor + i; | 711 for (i = 0; i < ncolors; ++i) { |
687 (**cTab).ctTable[j].value = j; | 712 int j = firstcolor + i; |
688 (**cTab).ctTable[j].rgb.red = colors[i].r << 8 | colors[i].r; | 713 (**cTab).ctTable[j].value = j; |
689 (**cTab).ctTable[j].rgb.green = colors[i].g << 8 | colors[i].g; | 714 (**cTab).ctTable[j].rgb.red = colors[i].r << 8 | colors[i].r; |
690 (**cTab).ctTable[j].rgb.blue = colors[i].b << 8 | colors[i].b; | 715 (**cTab).ctTable[j].rgb.green = colors[i].g << 8 | colors[i].g; |
691 } | 716 (**cTab).ctTable[j].rgb.blue = colors[i].b << 8 | colors[i].b; |
692 // if ( (this->screen->flags & SDL_FULLSCREEN) == SDL_FULLSCREEN ) | 717 } |
693 { | 718 // if ( (this->screen->flags & SDL_FULLSCREEN) == SDL_FULLSCREEN ) |
694 GDevice **odisplay; | 719 { |
695 odisplay = GetGDevice(); | 720 GDevice **odisplay; |
696 SetGDevice(SDL_Display); | 721 odisplay = GetGDevice(); |
697 SetEntries(0, (**cTab).ctSize, (ColorSpec *)&(**cTab).ctTable); | 722 SetGDevice(SDL_Display); |
698 SetGDevice(odisplay); | 723 SetEntries(0, (**cTab).ctSize, (ColorSpec *) & (**cTab).ctTable); |
699 } | 724 SetGDevice(odisplay); |
700 return(1); | 725 } |
701 } | 726 return (1); |
702 | 727 } |
703 void ROM_VideoQuit(_THIS) | 728 |
704 { | 729 void |
705 int i; | 730 ROM_VideoQuit(_THIS) |
706 | 731 { |
707 /* Free current video mode */ | 732 int i; |
708 ROM_UnsetVideoMode(this, this->screen); | 733 |
709 if ( SDL_Window ) { | 734 /* Free current video mode */ |
710 DisposeWindow(SDL_Window); | 735 ROM_UnsetVideoMode(this, this->screen); |
711 SDL_Window = nil; | 736 if (SDL_Window) { |
712 } | 737 DisposeWindow(SDL_Window); |
713 | 738 SDL_Window = nil; |
714 /* Free palette and restore original one */ | 739 } |
715 if ( SDL_CTab != nil ) { | 740 |
716 DisposeHandle((Handle)SDL_CTab); | 741 /* Free palette and restore original one */ |
717 SDL_CTab = nil; | 742 if (SDL_CTab != nil) { |
718 } | 743 DisposeHandle((Handle) SDL_CTab); |
719 if ( SDL_CPal != nil ) { | 744 SDL_CTab = nil; |
720 DisposePalette(SDL_CPal); | 745 } |
721 SDL_CPal = nil; | 746 if (SDL_CPal != nil) { |
722 } | 747 DisposePalette(SDL_CPal); |
723 RestoreDeviceClut(GetMainDevice()); | 748 SDL_CPal = nil; |
724 | 749 } |
725 /* Free list of video modes */ | 750 RestoreDeviceClut(GetMainDevice()); |
726 if ( SDL_modelist != NULL ) { | 751 |
727 for ( i=0; SDL_modelist[i]; ++i ) { | 752 /* Free list of video modes */ |
728 SDL_free(SDL_modelist[i]); | 753 if (SDL_modelist != NULL) { |
729 } | 754 for (i = 0; SDL_modelist[i]; ++i) { |
730 SDL_free(SDL_modelist); | 755 SDL_free(SDL_modelist[i]); |
731 SDL_modelist = NULL; | 756 } |
732 } | 757 SDL_free(SDL_modelist); |
733 } | 758 SDL_modelist = NULL; |
734 | 759 } |
760 } | |
761 | |
762 /* vi: set ts=4 sw=4 expandtab: */ |