Mercurial > sdl-ios-xcode
comparison src/video/riscos/SDL_wimpvideo.c @ 1668:4da1ee79c9af SDL-1.3
more tweaking indent options
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Mon, 29 May 2006 04:04:35 +0000 |
parents | 782fd950bd46 |
children |
comparison
equal
deleted
inserted
replaced
1667:1fddae038bc8 | 1668:4da1ee79c9af |
---|---|
41 | 41 |
42 #include "kernel.h" | 42 #include "kernel.h" |
43 #include "swis.h" | 43 #include "swis.h" |
44 | 44 |
45 /* Initialization/Query functions */ | 45 /* Initialization/Query functions */ |
46 SDL_Rect **WIMP_ListModes (_THIS, SDL_PixelFormat * format, Uint32 flags); | 46 SDL_Rect **WIMP_ListModes(_THIS, SDL_PixelFormat * format, Uint32 flags); |
47 SDL_Surface *WIMP_SetVideoMode (_THIS, SDL_Surface * current, int width, | 47 SDL_Surface *WIMP_SetVideoMode(_THIS, SDL_Surface * current, int width, |
48 int height, int bpp, Uint32 flags); | 48 int height, int bpp, Uint32 flags); |
49 int WIMP_SetColors (_THIS, int firstcolor, int ncolors, SDL_Color * colors); | 49 int WIMP_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color * colors); |
50 void WIMP_SetWMCaption (_THIS, const char *title, const char *icon); | 50 void WIMP_SetWMCaption(_THIS, const char *title, const char *icon); |
51 | 51 |
52 | 52 |
53 extern unsigned char *WIMP_CreateBuffer (int width, int height, int bpp); | 53 extern unsigned char *WIMP_CreateBuffer(int width, int height, int bpp); |
54 extern void WIMP_PumpEvents (_THIS); | 54 extern void WIMP_PumpEvents(_THIS); |
55 extern void WIMP_PlotSprite (_THIS, int x, int y); | 55 extern void WIMP_PlotSprite(_THIS, int x, int y); |
56 extern void WIMP_SetupPlotInfo (_THIS); | 56 extern void WIMP_SetupPlotInfo(_THIS); |
57 extern void WIMP_SetFocus (int win); | 57 extern void WIMP_SetFocus(int win); |
58 | 58 |
59 /* etc. */ | 59 /* etc. */ |
60 static void WIMP_UpdateRects (_THIS, int numrects, SDL_Rect * rects); | 60 static void WIMP_UpdateRects(_THIS, int numrects, SDL_Rect * rects); |
61 | 61 |
62 /* RISC OS Wimp handling helpers */ | 62 /* RISC OS Wimp handling helpers */ |
63 void WIMP_ReadModeInfo (_THIS); | 63 void WIMP_ReadModeInfo(_THIS); |
64 unsigned int WIMP_SetupWindow (_THIS, SDL_Surface * surface); | 64 unsigned int WIMP_SetupWindow(_THIS, SDL_Surface * surface); |
65 void WIMP_SetDeviceMode (_THIS); | 65 void WIMP_SetDeviceMode(_THIS); |
66 void WIMP_DeleteWindow (_THIS); | 66 void WIMP_DeleteWindow(_THIS); |
67 | 67 |
68 /* FULLSCREEN function required for wimp/fullscreen toggling */ | 68 /* FULLSCREEN function required for wimp/fullscreen toggling */ |
69 extern int FULLSCREEN_SetMode (int width, int height, int bpp); | 69 extern int FULLSCREEN_SetMode(int width, int height, int bpp); |
70 | 70 |
71 /* Currently need to set this up here as it only works if you | 71 /* Currently need to set this up here as it only works if you |
72 start up in a Wimp mode */ | 72 start up in a Wimp mode */ |
73 extern int RISCOS_ToggleFullScreen (_THIS, int fullscreen); | 73 extern int RISCOS_ToggleFullScreen(_THIS, int fullscreen); |
74 | 74 |
75 extern int riscos_backbuffer; | 75 extern int riscos_backbuffer; |
76 extern int mouseInWindow; | 76 extern int mouseInWindow; |
77 extern int riscos_closeaction; | 77 extern int riscos_closeaction; |
78 | 78 |
79 /* Following needed to ensure window is shown immediately */ | 79 /* Following needed to ensure window is shown immediately */ |
80 extern int hasFocus; | 80 extern int hasFocus; |
81 extern void WIMP_Poll (_THIS, int waitTime); | 81 extern void WIMP_Poll(_THIS, int waitTime); |
82 | 82 |
83 SDL_Surface * | 83 SDL_Surface * |
84 WIMP_SetVideoMode (_THIS, SDL_Surface * current, | 84 WIMP_SetVideoMode(_THIS, SDL_Surface * current, |
85 int width, int height, int bpp, Uint32 flags) | 85 int width, int height, int bpp, Uint32 flags) |
86 { | 86 { |
87 Uint32 Rmask = 0; | 87 Uint32 Rmask = 0; |
88 Uint32 Gmask = 0; | 88 Uint32 Gmask = 0; |
89 Uint32 Bmask = 0; | 89 Uint32 Bmask = 0; |
90 char *buffer = NULL; | 90 char *buffer = NULL; |
114 Rmask = 0x000000ff; | 114 Rmask = 0x000000ff; |
115 bytesPerPixel = 4; | 115 bytesPerPixel = 4; |
116 break; | 116 break; |
117 | 117 |
118 default: | 118 default: |
119 SDL_SetError ("Pixel depth not supported"); | 119 SDL_SetError("Pixel depth not supported"); |
120 return NULL; | 120 return NULL; |
121 break; | 121 break; |
122 } | 122 } |
123 | 123 |
124 /* printf("Setting mode %dx%d\n", width, height);*/ | 124 /* printf("Setting mode %dx%d\n", width, height);*/ |
125 | 125 |
126 /* Allocate the new pixel format for the screen */ | 126 /* Allocate the new pixel format for the screen */ |
127 if (!SDL_ReallocFormat (current, bpp, Rmask, Gmask, Bmask, 0)) { | 127 if (!SDL_ReallocFormat(current, bpp, Rmask, Gmask, Bmask, 0)) { |
128 SDL_SetError | 128 SDL_SetError("Couldn't allocate new pixel format for requested mode"); |
129 ("Couldn't allocate new pixel format for requested mode"); | |
130 return (NULL); | 129 return (NULL); |
131 } | 130 } |
132 | 131 |
133 /* Set up the new mode framebuffer */ | 132 /* Set up the new mode framebuffer */ |
134 current->w = width; | 133 current->w = width; |
135 this->hidden->height = current->h = height; | 134 this->hidden->height = current->h = height; |
136 | 135 |
137 if (bpp == 15) | 136 if (bpp == 15) |
138 bpp = 16; | 137 bpp = 16; |
139 buffer = WIMP_CreateBuffer (width, height, bpp); | 138 buffer = WIMP_CreateBuffer(width, height, bpp); |
140 if (buffer == NULL) { | 139 if (buffer == NULL) { |
141 SDL_SetError ("Couldn't create sprite for video memory"); | 140 SDL_SetError("Couldn't create sprite for video memory"); |
142 return (NULL); | 141 return (NULL); |
143 } | 142 } |
144 | 143 |
145 this->hidden->bank[0] = buffer + 60; /* Start of sprite data */ | 144 this->hidden->bank[0] = buffer + 60; /* Start of sprite data */ |
146 if (bpp == 8) | 145 if (bpp == 8) |
148 | 147 |
149 this->hidden->bank[1] = buffer; /* Start of buffer */ | 148 this->hidden->bank[1] = buffer; /* Start of buffer */ |
150 | 149 |
151 /* Remember sprite buffer so it can be freed later */ | 150 /* Remember sprite buffer so it can be freed later */ |
152 if (this->hidden->alloc_bank) | 151 if (this->hidden->alloc_bank) |
153 SDL_free (this->hidden->alloc_bank); | 152 SDL_free(this->hidden->alloc_bank); |
154 this->hidden->alloc_bank = buffer; | 153 this->hidden->alloc_bank = buffer; |
155 | 154 |
156 current->pitch = width * bytesPerPixel; | 155 current->pitch = width * bytesPerPixel; |
157 if ((current->pitch & 3)) { | 156 if ((current->pitch & 3)) { |
158 /* Sprites are 32bit word aligned */ | 157 /* Sprites are 32bit word aligned */ |
159 current->pitch += (4 - (current->pitch & 3)); | 158 current->pitch += (4 - (current->pitch & 3)); |
160 } | 159 } |
161 | 160 |
162 current->flags = flags | SDL_PREALLOC; | 161 current->flags = flags | SDL_PREALLOC; |
163 | 162 |
164 WIMP_ReadModeInfo (this); | 163 WIMP_ReadModeInfo(this); |
165 | 164 |
166 SDL_memset (this->hidden->bank[0], 0, height * current->pitch); | 165 SDL_memset(this->hidden->bank[0], 0, height * current->pitch); |
167 | 166 |
168 this->hidden->current_bank = 0; | 167 this->hidden->current_bank = 0; |
169 current->pixels = this->hidden->bank[0]; | 168 current->pixels = this->hidden->bank[0]; |
170 | 169 |
171 | 170 |
172 if (WIMP_SetupWindow (this, current) == 0) { | 171 if (WIMP_SetupWindow(this, current) == 0) { |
173 SDL_SetError ("Unable to create window to display surface"); | 172 SDL_SetError("Unable to create window to display surface"); |
174 return NULL; | 173 return NULL; |
175 } | 174 } |
176 | 175 |
177 /* Reset device functions for the wimp */ | 176 /* Reset device functions for the wimp */ |
178 WIMP_SetDeviceMode (this); | 177 WIMP_SetDeviceMode(this); |
179 | 178 |
180 /* Needs to set up plot info after window has been created */ | 179 /* Needs to set up plot info after window has been created */ |
181 /* Not sure why, but plots don't work if I do it earlier */ | 180 /* Not sure why, but plots don't work if I do it earlier */ |
182 WIMP_SetupPlotInfo (this); | 181 WIMP_SetupPlotInfo(this); |
183 | 182 |
184 /* Poll until window is shown */ | 183 /* Poll until window is shown */ |
185 { | 184 { |
186 /* We wait until it gets the focus, but give up after 5 seconds | 185 /* We wait until it gets the focus, but give up after 5 seconds |
187 in case the focus is prevented in any way. | 186 in case the focus is prevented in any way. |
188 */ | 187 */ |
189 Uint32 now = SDL_GetTicks (); | 188 Uint32 now = SDL_GetTicks(); |
190 while (!hasFocus && SDL_GetTicks () - now < 5000) { | 189 while (!hasFocus && SDL_GetTicks() - now < 5000) { |
191 WIMP_Poll (this, 0); | 190 WIMP_Poll(this, 0); |
192 } | 191 } |
193 } | 192 } |
194 | 193 |
195 /* We're done */ | 194 /* We're done */ |
196 return (current); | 195 return (current); |
197 } | 196 } |
198 | 197 |
199 | 198 |
200 void | 199 void |
201 WIMP_ReadModeInfo (_THIS) | 200 WIMP_ReadModeInfo(_THIS) |
202 { | 201 { |
203 _kernel_swi_regs regs; | 202 _kernel_swi_regs regs; |
204 int vars[6]; | 203 int vars[6]; |
205 int vals[5]; | 204 int vals[5]; |
206 | 205 |
211 vars[4] = 12; /* Screen Depth - 1 */ | 210 vars[4] = 12; /* Screen Depth - 1 */ |
212 vars[5] = -1; /* Terminate list */ | 211 vars[5] = -1; /* Terminate list */ |
213 | 212 |
214 regs.r[0] = (int) vars; | 213 regs.r[0] = (int) vars; |
215 regs.r[1] = (int) vals; | 214 regs.r[1] = (int) vals; |
216 _kernel_swi (OS_ReadVduVariables, ®s, ®s); | 215 _kernel_swi(OS_ReadVduVariables, ®s, ®s); |
217 this->hidden->xeig = vals[0]; | 216 this->hidden->xeig = vals[0]; |
218 this->hidden->yeig = vals[1]; | 217 this->hidden->yeig = vals[1]; |
219 this->hidden->screen_bpp = 1 << vals[2]; | 218 this->hidden->screen_bpp = 1 << vals[2]; |
220 this->hidden->screen_width = vals[3] + 1; | 219 this->hidden->screen_width = vals[3] + 1; |
221 this->hidden->screen_height = vals[4] + 1; | 220 this->hidden->screen_height = vals[4] + 1; |
223 | 222 |
224 /* Set device function to call the correct versions for running | 223 /* Set device function to call the correct versions for running |
225 in a wimp window */ | 224 in a wimp window */ |
226 | 225 |
227 void | 226 void |
228 WIMP_SetDeviceMode (_THIS) | 227 WIMP_SetDeviceMode(_THIS) |
229 { | 228 { |
230 if (this->UpdateRects == WIMP_UpdateRects) | 229 if (this->UpdateRects == WIMP_UpdateRects) |
231 return; /* Already set up */ | 230 return; /* Already set up */ |
232 | 231 |
233 this->SetColors = WIMP_SetColors; | 232 this->SetColors = WIMP_SetColors; |
247 this->PumpEvents = WIMP_PumpEvents; | 246 this->PumpEvents = WIMP_PumpEvents; |
248 } | 247 } |
249 | 248 |
250 /* Setup the Window to display the surface */ | 249 /* Setup the Window to display the surface */ |
251 unsigned int | 250 unsigned int |
252 WIMP_SetupWindow (_THIS, SDL_Surface * surface) | 251 WIMP_SetupWindow(_THIS, SDL_Surface * surface) |
253 { | 252 { |
254 _kernel_swi_regs regs; | 253 _kernel_swi_regs regs; |
255 int window_data[23]; | 254 int window_data[23]; |
256 int *window_block = window_data + 1; | 255 int *window_block = window_data + 1; |
257 int x = (this->hidden->screen_width - surface->w) / 2; | 256 int x = (this->hidden->screen_width - surface->w) / 2; |
261 | 260 |
262 mouseInWindow = 0; | 261 mouseInWindow = 0; |
263 | 262 |
264 /* Always delete the window and recreate on a change */ | 263 /* Always delete the window and recreate on a change */ |
265 if (this->hidden->window_handle) | 264 if (this->hidden->window_handle) |
266 WIMP_DeleteWindow (this); | 265 WIMP_DeleteWindow(this); |
267 | 266 |
268 /* Setup window co-ordinates */ | 267 /* Setup window co-ordinates */ |
269 window_block[0] = x << xeig; | 268 window_block[0] = x << xeig; |
270 window_block[1] = y << yeig; | 269 window_block[1] = y << yeig; |
271 window_block[2] = window_block[0] + (surface->w << xeig); | 270 window_block[2] = window_block[0] + (surface->w << xeig); |
298 window_block[21] = 0; /* Number of icons */ | 297 window_block[21] = 0; /* Number of icons */ |
299 | 298 |
300 regs.r[1] = (unsigned int) (window_block); | 299 regs.r[1] = (unsigned int) (window_block); |
301 | 300 |
302 /* Create the window */ | 301 /* Create the window */ |
303 if (_kernel_swi (Wimp_CreateWindow, ®s, ®s) == NULL) { | 302 if (_kernel_swi(Wimp_CreateWindow, ®s, ®s) == NULL) { |
304 this->hidden->window_handle = window_data[0] = regs.r[0]; | 303 this->hidden->window_handle = window_data[0] = regs.r[0]; |
305 | 304 |
306 /* Show the window on the screen */ | 305 /* Show the window on the screen */ |
307 regs.r[1] = (unsigned int) window_data; | 306 regs.r[1] = (unsigned int) window_data; |
308 if (_kernel_swi (Wimp_OpenWindow, ®s, ®s) == NULL) { | 307 if (_kernel_swi(Wimp_OpenWindow, ®s, ®s) == NULL) { |
309 WIMP_SetFocus (this->hidden->window_handle); | 308 WIMP_SetFocus(this->hidden->window_handle); |
310 } else { | 309 } else { |
311 WIMP_DeleteWindow (this); | 310 WIMP_DeleteWindow(this); |
312 } | 311 } |
313 } | 312 } |
314 | 313 |
315 return this->hidden->window_handle; | 314 return this->hidden->window_handle; |
316 } | 315 } |
317 | 316 |
318 /* Destroy the Window */ | 317 /* Destroy the Window */ |
319 | 318 |
320 void | 319 void |
321 WIMP_DeleteWindow (_THIS) | 320 WIMP_DeleteWindow(_THIS) |
322 { | 321 { |
323 _kernel_swi_regs regs; | 322 _kernel_swi_regs regs; |
324 regs.r[1] = (unsigned int) &(this->hidden->window_handle); | 323 regs.r[1] = (unsigned int) &(this->hidden->window_handle); |
325 _kernel_swi (Wimp_DeleteWindow, ®s, ®s); | 324 _kernel_swi(Wimp_DeleteWindow, ®s, ®s); |
326 this->hidden->window_handle = 0; | 325 this->hidden->window_handle = 0; |
327 } | 326 } |
328 | 327 |
329 | 328 |
330 void | 329 void |
331 WIMP_UpdateRects (_THIS, int numrects, SDL_Rect * rects) | 330 WIMP_UpdateRects(_THIS, int numrects, SDL_Rect * rects) |
332 { | 331 { |
333 _kernel_swi_regs regs; | 332 _kernel_swi_regs regs; |
334 int update_block[12]; | 333 int update_block[12]; |
335 int xeig = this->hidden->xeig; | 334 int xeig = this->hidden->xeig; |
336 int yeig = this->hidden->yeig; | 335 int yeig = this->hidden->yeig; |
343 update_block[3] = update_block[1] + (rects[j].w << xeig); | 342 update_block[3] = update_block[1] + (rects[j].w << xeig); |
344 update_block[2] = update_block[4] - (rects[j].h << yeig); | 343 update_block[2] = update_block[4] - (rects[j].h << yeig); |
345 | 344 |
346 regs.r[1] = (int) update_block; | 345 regs.r[1] = (int) update_block; |
347 /* Update window can fail if called before first poll */ | 346 /* Update window can fail if called before first poll */ |
348 if (_kernel_swi (Wimp_UpdateWindow, ®s, ®s) == 0) { | 347 if (_kernel_swi(Wimp_UpdateWindow, ®s, ®s) == 0) { |
349 while (regs.r[0]) { | 348 while (regs.r[0]) { |
350 WIMP_PlotSprite (this, update_block[1], update_block[2]); | 349 WIMP_PlotSprite(this, update_block[1], update_block[2]); |
351 _kernel_swi (Wimp_GetRectangle, ®s, ®s); | 350 _kernel_swi(Wimp_GetRectangle, ®s, ®s); |
352 } | 351 } |
353 } | 352 } |
354 } | 353 } |
355 } | 354 } |
356 | 355 |
357 | 356 |
358 int | 357 int |
359 WIMP_SetColors (_THIS, int firstcolor, int ncolors, SDL_Color * colors) | 358 WIMP_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color * colors) |
360 { | 359 { |
361 unsigned int *pal = (unsigned int *) (this->hidden->bank[1] + 60); | 360 unsigned int *pal = (unsigned int *) (this->hidden->bank[1] + 60); |
362 int j; | 361 int j; |
363 SDL_Rect update; | 362 SDL_Rect update; |
364 | 363 |
370 pal[1] = *pal; | 369 pal[1] = *pal; |
371 pal += 2; | 370 pal += 2; |
372 colors++; | 371 colors++; |
373 } | 372 } |
374 | 373 |
375 WIMP_SetupPlotInfo (this); | 374 WIMP_SetupPlotInfo(this); |
376 | 375 |
377 /* Need to refresh the window */ | 376 /* Need to refresh the window */ |
378 update.x = 0; | 377 update.x = 0; |
379 update.y = 0; | 378 update.y = 0; |
380 update.w = SDL_VideoSurface->w; | 379 update.w = SDL_VideoSurface->w; |
381 update.h = SDL_VideoSurface->h; | 380 update.h = SDL_VideoSurface->h; |
382 WIMP_UpdateRects (this, 1, &update); | 381 WIMP_UpdateRects(this, 1, &update); |
383 | 382 |
384 return 1; | 383 return 1; |
385 } | 384 } |
386 | 385 |
387 void | 386 void |
388 WIMP_SetWMCaption (_THIS, const char *title, const char *icon) | 387 WIMP_SetWMCaption(_THIS, const char *title, const char *icon) |
389 { | 388 { |
390 _kernel_swi_regs regs; | 389 _kernel_swi_regs regs; |
391 | 390 |
392 SDL_strlcpy (this->hidden->title, title, | 391 SDL_strlcpy(this->hidden->title, title, |
393 SDL_arraysize (this->hidden->title)); | 392 SDL_arraysize(this->hidden->title)); |
394 | 393 |
395 if (RISCOS_GetWimpVersion () < 380) { | 394 if (RISCOS_GetWimpVersion() < 380) { |
396 int block[6]; | 395 int block[6]; |
397 | 396 |
398 regs.r[1] = (int) block; | 397 regs.r[1] = (int) block; |
399 _kernel_swi (Wimp_GetCaretPosition, ®s, ®s); | 398 _kernel_swi(Wimp_GetCaretPosition, ®s, ®s); |
400 if (block[0] == (int) this->hidden->window_handle) { | 399 if (block[0] == (int) this->hidden->window_handle) { |
401 regs.r[0] = -1; | 400 regs.r[0] = -1; |
402 _kernel_swi (Wimp_SetCaretPosition, ®s, ®s); | 401 _kernel_swi(Wimp_SetCaretPosition, ®s, ®s); |
403 } else { | 402 } else { |
404 regs.r[0] = this->hidden->window_handle; | 403 regs.r[0] = this->hidden->window_handle; |
405 regs.r[1] = -1; | 404 regs.r[1] = -1; |
406 regs.r[2] = -1; | 405 regs.r[2] = -1; |
407 regs.r[3] = -1; | 406 regs.r[3] = -1; |
408 _kernel_swi (Wimp_SetCaretPosition, ®s, ®s); | 407 _kernel_swi(Wimp_SetCaretPosition, ®s, ®s); |
409 } | 408 } |
410 regs.r[0] = block[0]; | 409 regs.r[0] = block[0]; |
411 regs.r[1] = block[1]; | 410 regs.r[1] = block[1]; |
412 regs.r[2] = block[2]; | 411 regs.r[2] = block[2]; |
413 regs.r[3] = block[3]; | 412 regs.r[3] = block[3]; |
414 regs.r[4] = block[4]; | 413 regs.r[4] = block[4]; |
415 regs.r[5] = block[5]; | 414 regs.r[5] = block[5]; |
416 _kernel_swi (Wimp_SetCaretPosition, ®s, ®s); | 415 _kernel_swi(Wimp_SetCaretPosition, ®s, ®s); |
417 } else { | 416 } else { |
418 regs.r[0] = this->hidden->window_handle; | 417 regs.r[0] = this->hidden->window_handle; |
419 regs.r[1] = 0x4b534154; /* "TASK" */ | 418 regs.r[1] = 0x4b534154; /* "TASK" */ |
420 regs.r[2] = 3; /* Redraw title */ | 419 regs.r[2] = 3; /* Redraw title */ |
421 _kernel_swi (Wimp_ForceRedraw, ®s, ®s); | 420 _kernel_swi(Wimp_ForceRedraw, ®s, ®s); |
422 } | 421 } |
423 } | 422 } |
424 | 423 |
425 void | 424 void |
426 WIMP_RefreshDesktop (_THIS) | 425 WIMP_RefreshDesktop(_THIS) |
427 { | 426 { |
428 int width = this->hidden->screen_width << this->hidden->xeig; | 427 int width = this->hidden->screen_width << this->hidden->xeig; |
429 int height = this->hidden->screen_height << this->hidden->yeig; | 428 int height = this->hidden->screen_height << this->hidden->yeig; |
430 _kernel_swi_regs regs; | 429 _kernel_swi_regs regs; |
431 regs.r[0] = -1; /* Whole screen */ | 430 regs.r[0] = -1; /* Whole screen */ |
432 regs.r[1] = 0; | 431 regs.r[1] = 0; |
433 regs.r[2] = 0; | 432 regs.r[2] = 0; |
434 regs.r[3] = width; | 433 regs.r[3] = width; |
435 regs.r[4] = height; | 434 regs.r[4] = height; |
436 _kernel_swi (Wimp_ForceRedraw, ®s, ®s); | 435 _kernel_swi(Wimp_ForceRedraw, ®s, ®s); |
437 } | 436 } |
438 | 437 |
439 /* Toggle to window from full screen */ | 438 /* Toggle to window from full screen */ |
440 int | 439 int |
441 WIMP_ToggleFromFullScreen (_THIS) | 440 WIMP_ToggleFromFullScreen(_THIS) |
442 { | 441 { |
443 int width = this->screen->w; | 442 int width = this->screen->w; |
444 int height = this->screen->h; | 443 int height = this->screen->h; |
445 int bpp = this->screen->format->BitsPerPixel; | 444 int bpp = this->screen->format->BitsPerPixel; |
446 char *buffer = NULL; | 445 char *buffer = NULL; |
452 | 451 |
453 if (this->hidden->bank[0] == this->hidden->alloc_bank | 452 if (this->hidden->bank[0] == this->hidden->alloc_bank |
454 || riscos_backbuffer == 0) { | 453 || riscos_backbuffer == 0) { |
455 /* Need to create a sprite for the screen and copy the data to it */ | 454 /* Need to create a sprite for the screen and copy the data to it */ |
456 char *data; | 455 char *data; |
457 buffer = WIMP_CreateBuffer (width, height, bpp); | 456 buffer = WIMP_CreateBuffer(width, height, bpp); |
458 data = buffer + 60; /* Start of sprite data */ | 457 data = buffer + 60; /* Start of sprite data */ |
459 if (bpp == 8) | 458 if (bpp == 8) |
460 data += 2048; /* 8bpp sprite have palette first */ | 459 data += 2048; /* 8bpp sprite have palette first */ |
461 | 460 |
462 if (buffer == NULL) | 461 if (buffer == NULL) |
463 return 0; | 462 return 0; |
464 SDL_memcpy (data, this->hidden->bank[0], | 463 SDL_memcpy(data, this->hidden->bank[0], |
465 width * height * this->screen->format->BytesPerPixel); | 464 width * height * this->screen->format->BytesPerPixel); |
466 } | 465 } |
467 /* else We've switch to full screen before so we already have a sprite */ | 466 /* else We've switch to full screen before so we already have a sprite */ |
468 | 467 |
469 old_bank[0] = this->hidden->bank[0]; | 468 old_bank[0] = this->hidden->bank[0]; |
470 old_bank[1] = this->hidden->bank[1]; | 469 old_bank[1] = this->hidden->bank[1]; |
479 this->hidden->bank[0] += 2048; /* 8bpp sprite have palette first */ | 478 this->hidden->bank[0] += 2048; /* 8bpp sprite have palette first */ |
480 | 479 |
481 this->hidden->current_bank = 0; | 480 this->hidden->current_bank = 0; |
482 this->screen->pixels = this->hidden->bank[0]; | 481 this->screen->pixels = this->hidden->bank[0]; |
483 | 482 |
484 RISCOS_RestoreWimpMode (); | 483 RISCOS_RestoreWimpMode(); |
485 WIMP_ReadModeInfo (this); | 484 WIMP_ReadModeInfo(this); |
486 if (WIMP_SetupWindow (this, this->screen)) { | 485 if (WIMP_SetupWindow(this, this->screen)) { |
487 WIMP_SetDeviceMode (this); | 486 WIMP_SetDeviceMode(this); |
488 WIMP_SetupPlotInfo (this); | 487 WIMP_SetupPlotInfo(this); |
489 | 488 |
490 if (riscos_backbuffer == 0) | 489 if (riscos_backbuffer == 0) |
491 riscos_backbuffer = 1; | 490 riscos_backbuffer = 1; |
492 | 491 |
493 if (buffer && old_alloc_bank) | 492 if (buffer && old_alloc_bank) |
494 SDL_free (old_alloc_bank); | 493 SDL_free(old_alloc_bank); |
495 | 494 |
496 return 1; | 495 return 1; |
497 } else { | 496 } else { |
498 /* Drop back to full screen mode on failure */ | 497 /* Drop back to full screen mode on failure */ |
499 this->hidden->bank[0] = old_bank[0]; | 498 this->hidden->bank[0] = old_bank[0]; |
500 this->hidden->bank[1] = old_bank[1]; | 499 this->hidden->bank[1] = old_bank[1]; |
501 this->hidden->alloc_bank = old_alloc_bank; | 500 this->hidden->alloc_bank = old_alloc_bank; |
502 if (buffer) | 501 if (buffer) |
503 SDL_free (buffer); | 502 SDL_free(buffer); |
504 | 503 |
505 RISCOS_StoreWimpMode (); | 504 RISCOS_StoreWimpMode(); |
506 FULLSCREEN_SetMode (width, height, bpp); | 505 FULLSCREEN_SetMode(width, height, bpp); |
507 } | 506 } |
508 | 507 |
509 return 0; | 508 return 0; |
510 } | 509 } |
511 | 510 |