Mercurial > sdl-ios-xcode
comparison src/video/riscos/SDL_riscosvideo.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 |
---|---|
46 #include "swis.h" | 46 #include "swis.h" |
47 | 47 |
48 #define RISCOSVID_DRIVER_NAME "riscos" | 48 #define RISCOSVID_DRIVER_NAME "riscos" |
49 | 49 |
50 /* Initialization/Query functions */ | 50 /* Initialization/Query functions */ |
51 static int RISCOS_VideoInit (_THIS, SDL_PixelFormat * vformat); | 51 static int RISCOS_VideoInit(_THIS, SDL_PixelFormat * vformat); |
52 static void RISCOS_VideoQuit (_THIS); | 52 static void RISCOS_VideoQuit(_THIS); |
53 | 53 |
54 static SDL_Rect **RISCOS_ListModes (_THIS, SDL_PixelFormat * format, | 54 static SDL_Rect **RISCOS_ListModes(_THIS, SDL_PixelFormat * format, |
55 Uint32 flags); | 55 Uint32 flags); |
56 static SDL_Surface *RISCOS_SetVideoMode (_THIS, SDL_Surface * current, | 56 static SDL_Surface *RISCOS_SetVideoMode(_THIS, SDL_Surface * current, |
57 int width, int height, int bpp, | 57 int width, int height, int bpp, |
58 Uint32 flags); | 58 Uint32 flags); |
59 | 59 |
60 int RISCOS_GetWmInfo (_THIS, SDL_SysWMinfo * info); | 60 int RISCOS_GetWmInfo(_THIS, SDL_SysWMinfo * info); |
61 | 61 |
62 int RISCOS_ToggleFullScreen (_THIS, int fullscreen); | 62 int RISCOS_ToggleFullScreen(_THIS, int fullscreen); |
63 /* Mouse checking */ | 63 /* Mouse checking */ |
64 void RISCOS_CheckMouseMode (_THIS); | 64 void RISCOS_CheckMouseMode(_THIS); |
65 extern SDL_GrabMode RISCOS_GrabInput (_THIS, SDL_GrabMode mode); | 65 extern SDL_GrabMode RISCOS_GrabInput(_THIS, SDL_GrabMode mode); |
66 | 66 |
67 /* Fullscreen mode functions */ | 67 /* Fullscreen mode functions */ |
68 extern SDL_Surface *FULLSCREEN_SetVideoMode (_THIS, SDL_Surface * current, | 68 extern SDL_Surface *FULLSCREEN_SetVideoMode(_THIS, SDL_Surface * current, |
69 int width, int height, int bpp, | 69 int width, int height, int bpp, |
70 Uint32 flags); | 70 Uint32 flags); |
71 extern void FULLSCREEN_BuildModeList (_THIS); | 71 extern void FULLSCREEN_BuildModeList(_THIS); |
72 extern void FULLSCREEN_SetDeviceMode (_THIS); | 72 extern void FULLSCREEN_SetDeviceMode(_THIS); |
73 extern int FULLSCREEN_ToggleFromWimp (_THIS); | 73 extern int FULLSCREEN_ToggleFromWimp(_THIS); |
74 | 74 |
75 /* Wimp mode functions */ | 75 /* Wimp mode functions */ |
76 extern SDL_Surface *WIMP_SetVideoMode (_THIS, SDL_Surface * current, | 76 extern SDL_Surface *WIMP_SetVideoMode(_THIS, SDL_Surface * current, |
77 int width, int height, int bpp, | 77 int width, int height, int bpp, |
78 Uint32 flags); | 78 Uint32 flags); |
79 extern void WIMP_DeleteWindow (_THIS); | 79 extern void WIMP_DeleteWindow(_THIS); |
80 extern int WIMP_ToggleFromFullScreen (_THIS); | 80 extern int WIMP_ToggleFromFullScreen(_THIS); |
81 | 81 |
82 /* Hardware surface functions - common to WIMP and FULLSCREEN */ | 82 /* Hardware surface functions - common to WIMP and FULLSCREEN */ |
83 static int RISCOS_AllocHWSurface (_THIS, SDL_Surface * surface); | 83 static int RISCOS_AllocHWSurface(_THIS, SDL_Surface * surface); |
84 static int RISCOS_LockHWSurface (_THIS, SDL_Surface * surface); | 84 static int RISCOS_LockHWSurface(_THIS, SDL_Surface * surface); |
85 static void RISCOS_UnlockHWSurface (_THIS, SDL_Surface * surface); | 85 static void RISCOS_UnlockHWSurface(_THIS, SDL_Surface * surface); |
86 static void RISCOS_FreeHWSurface (_THIS, SDL_Surface * surface); | 86 static void RISCOS_FreeHWSurface(_THIS, SDL_Surface * surface); |
87 | 87 |
88 /* RISC OS driver bootstrap functions */ | 88 /* RISC OS driver bootstrap functions */ |
89 | 89 |
90 static int | 90 static int |
91 RISCOS_Available (void) | 91 RISCOS_Available(void) |
92 { | 92 { |
93 return (1); | 93 return (1); |
94 } | 94 } |
95 | 95 |
96 static void | 96 static void |
97 RISCOS_DeleteDevice (SDL_VideoDevice * device) | 97 RISCOS_DeleteDevice(SDL_VideoDevice * device) |
98 { | 98 { |
99 SDL_free (device->hidden); | 99 SDL_free(device->hidden); |
100 SDL_free (device); | 100 SDL_free(device); |
101 } | 101 } |
102 | 102 |
103 static SDL_VideoDevice * | 103 static SDL_VideoDevice * |
104 RISCOS_CreateDevice (int devindex) | 104 RISCOS_CreateDevice(int devindex) |
105 { | 105 { |
106 SDL_VideoDevice *device; | 106 SDL_VideoDevice *device; |
107 | 107 |
108 /* Initialize all variables that we clean on shutdown */ | 108 /* Initialize all variables that we clean on shutdown */ |
109 device = (SDL_VideoDevice *) SDL_malloc (sizeof (SDL_VideoDevice)); | 109 device = (SDL_VideoDevice *) SDL_malloc(sizeof(SDL_VideoDevice)); |
110 if (device) { | 110 if (device) { |
111 SDL_memset (device, 0, (sizeof *device)); | 111 SDL_memset(device, 0, (sizeof *device)); |
112 device->hidden = (struct SDL_PrivateVideoData *) | 112 device->hidden = (struct SDL_PrivateVideoData *) |
113 SDL_malloc ((sizeof *device->hidden)); | 113 SDL_malloc((sizeof *device->hidden)); |
114 } | 114 } |
115 if ((device == NULL) || (device->hidden == NULL)) { | 115 if ((device == NULL) || (device->hidden == NULL)) { |
116 SDL_OutOfMemory (); | 116 SDL_OutOfMemory(); |
117 if (device) { | 117 if (device) { |
118 SDL_free (device); | 118 SDL_free(device); |
119 } | 119 } |
120 return (0); | 120 return (0); |
121 } | 121 } |
122 SDL_memset (device->hidden, 0, (sizeof *device->hidden)); | 122 SDL_memset(device->hidden, 0, (sizeof *device->hidden)); |
123 | 123 |
124 /* Set the function pointers */ | 124 /* Set the function pointers */ |
125 device->VideoInit = RISCOS_VideoInit; | 125 device->VideoInit = RISCOS_VideoInit; |
126 device->VideoQuit = RISCOS_VideoQuit; | 126 device->VideoQuit = RISCOS_VideoQuit; |
127 | 127 |
151 /* Can't get Toggle screen to work if program starts up in Full screen mode so | 151 /* Can't get Toggle screen to work if program starts up in Full screen mode so |
152 disable it here and re-enable it when a wimp screen is chosen */ | 152 disable it here and re-enable it when a wimp screen is chosen */ |
153 device->ToggleFullScreen = NULL; /*RISCOS_ToggleFullScreen; */ | 153 device->ToggleFullScreen = NULL; /*RISCOS_ToggleFullScreen; */ |
154 | 154 |
155 /* Set other entries for fullscreen mode */ | 155 /* Set other entries for fullscreen mode */ |
156 FULLSCREEN_SetDeviceMode (device); | 156 FULLSCREEN_SetDeviceMode(device); |
157 | 157 |
158 /* Mouse pointer needs to use the WIMP ShowCursor version so | 158 /* Mouse pointer needs to use the WIMP ShowCursor version so |
159 that it doesn't modify the pointer until the SDL Window is | 159 that it doesn't modify the pointer until the SDL Window is |
160 entered or the application goes full screen */ | 160 entered or the application goes full screen */ |
161 device->ShowWMCursor = WIMP_ShowWMCursor; | 161 device->ShowWMCursor = WIMP_ShowWMCursor; |
168 RISCOS_Available, RISCOS_CreateDevice | 168 RISCOS_Available, RISCOS_CreateDevice |
169 }; | 169 }; |
170 | 170 |
171 | 171 |
172 int | 172 int |
173 RISCOS_VideoInit (_THIS, SDL_PixelFormat * vformat) | 173 RISCOS_VideoInit(_THIS, SDL_PixelFormat * vformat) |
174 { | 174 { |
175 _kernel_swi_regs regs; | 175 _kernel_swi_regs regs; |
176 int vars[4], vals[3]; | 176 int vars[4], vals[3]; |
177 | 177 |
178 if (RISCOS_InitTask () == 0) { | 178 if (RISCOS_InitTask() == 0) { |
179 SDL_SetError ("Unable to start task"); | 179 SDL_SetError("Unable to start task"); |
180 return 0; | 180 return 0; |
181 } | 181 } |
182 | 182 |
183 vars[0] = 9; /* Log base 2 bpp */ | 183 vars[0] = 9; /* Log base 2 bpp */ |
184 vars[1] = 11; /* XWndLimit - num x pixels -1 */ | 184 vars[1] = 11; /* XWndLimit - num x pixels -1 */ |
185 vars[2] = 12; /* YWndLimit - num y pixels -1 */ | 185 vars[2] = 12; /* YWndLimit - num y pixels -1 */ |
186 vars[3] = -1; /* Terminate list */ | 186 vars[3] = -1; /* Terminate list */ |
187 regs.r[0] = (int) vars; | 187 regs.r[0] = (int) vars; |
188 regs.r[1] = (int) vals; | 188 regs.r[1] = (int) vals; |
189 | 189 |
190 _kernel_swi (OS_ReadVduVariables, ®s, ®s); | 190 _kernel_swi(OS_ReadVduVariables, ®s, ®s); |
191 vformat->BitsPerPixel = (1 << vals[0]); | 191 vformat->BitsPerPixel = (1 << vals[0]); |
192 | 192 |
193 /* Determine the current screen size */ | 193 /* Determine the current screen size */ |
194 this->info.current_w = vals[1] + 1; | 194 this->info.current_w = vals[1] + 1; |
195 this->info.current_h = vals[2] + 1; | 195 this->info.current_h = vals[2] + 1; |
234 | 234 |
235 /* Note: If we are terminated, this could be called in the middle of | 235 /* Note: If we are terminated, this could be called in the middle of |
236 another SDL video routine -- notably UpdateRects. | 236 another SDL video routine -- notably UpdateRects. |
237 */ | 237 */ |
238 void | 238 void |
239 RISCOS_VideoQuit (_THIS) | 239 RISCOS_VideoQuit(_THIS) |
240 { | 240 { |
241 RISCOS_ExitTask (); | 241 RISCOS_ExitTask(); |
242 | 242 |
243 if (this->hidden->alloc_bank) | 243 if (this->hidden->alloc_bank) |
244 SDL_free (this->hidden->alloc_bank); | 244 SDL_free(this->hidden->alloc_bank); |
245 this->hidden->alloc_bank = 0; | 245 this->hidden->alloc_bank = 0; |
246 } | 246 } |
247 | 247 |
248 | 248 |
249 SDL_Rect ** | 249 SDL_Rect ** |
250 RISCOS_ListModes (_THIS, SDL_PixelFormat * format, Uint32 flags) | 250 RISCOS_ListModes(_THIS, SDL_PixelFormat * format, Uint32 flags) |
251 { | 251 { |
252 if (flags & SDL_FULLSCREEN) { | 252 if (flags & SDL_FULLSCREEN) { |
253 /* Build mode list when first required. */ | 253 /* Build mode list when first required. */ |
254 if (SDL_nummodes[0] == 0) | 254 if (SDL_nummodes[0] == 0) |
255 FULLSCREEN_BuildModeList (this); | 255 FULLSCREEN_BuildModeList(this); |
256 | 256 |
257 return (SDL_modelist[((format->BitsPerPixel + 7) / 8) - 1]); | 257 return (SDL_modelist[((format->BitsPerPixel + 7) / 8) - 1]); |
258 } else | 258 } else |
259 return (SDL_Rect **) - 1; | 259 return (SDL_Rect **) - 1; |
260 } | 260 } |
261 | 261 |
262 | 262 |
263 /* Set up video mode */ | 263 /* Set up video mode */ |
264 SDL_Surface * | 264 SDL_Surface * |
265 RISCOS_SetVideoMode (_THIS, SDL_Surface * current, | 265 RISCOS_SetVideoMode(_THIS, SDL_Surface * current, |
266 int width, int height, int bpp, Uint32 flags) | 266 int width, int height, int bpp, Uint32 flags) |
267 { | 267 { |
268 if (flags & SDL_FULLSCREEN) { | 268 if (flags & SDL_FULLSCREEN) { |
269 RISCOS_StoreWimpMode (); | 269 RISCOS_StoreWimpMode(); |
270 /* Dump wimp window on switch to full screen */ | 270 /* Dump wimp window on switch to full screen */ |
271 if (this->hidden->window_handle) | 271 if (this->hidden->window_handle) |
272 WIMP_DeleteWindow (this); | 272 WIMP_DeleteWindow(this); |
273 | 273 |
274 return FULLSCREEN_SetVideoMode (this, current, width, height, bpp, | 274 return FULLSCREEN_SetVideoMode(this, current, width, height, bpp, |
275 flags); | 275 flags); |
276 } else { | 276 } else { |
277 RISCOS_RestoreWimpMode (); | 277 RISCOS_RestoreWimpMode(); |
278 return WIMP_SetVideoMode (this, current, width, height, bpp, flags); | 278 return WIMP_SetVideoMode(this, current, width, height, bpp, flags); |
279 } | 279 } |
280 } | 280 } |
281 | 281 |
282 | 282 |
283 /* We don't actually allow hardware surfaces other than the main one */ | 283 /* We don't actually allow hardware surfaces other than the main one */ |
284 static int | 284 static int |
285 RISCOS_AllocHWSurface (_THIS, SDL_Surface * surface) | 285 RISCOS_AllocHWSurface(_THIS, SDL_Surface * surface) |
286 { | 286 { |
287 return (-1); | 287 return (-1); |
288 } | 288 } |
289 static void | 289 static void |
290 RISCOS_FreeHWSurface (_THIS, SDL_Surface * surface) | 290 RISCOS_FreeHWSurface(_THIS, SDL_Surface * surface) |
291 { | 291 { |
292 return; | 292 return; |
293 } | 293 } |
294 | 294 |
295 /* We need to wait for vertical retrace on page flipped displays */ | 295 /* We need to wait for vertical retrace on page flipped displays */ |
296 static int | 296 static int |
297 RISCOS_LockHWSurface (_THIS, SDL_Surface * surface) | 297 RISCOS_LockHWSurface(_THIS, SDL_Surface * surface) |
298 { | 298 { |
299 return (0); | 299 return (0); |
300 } | 300 } |
301 | 301 |
302 static void | 302 static void |
303 RISCOS_UnlockHWSurface (_THIS, SDL_Surface * surface) | 303 RISCOS_UnlockHWSurface(_THIS, SDL_Surface * surface) |
304 { | 304 { |
305 return; | 305 return; |
306 } | 306 } |
307 | 307 |
308 | 308 |
309 int | 309 int |
310 RISCOS_GetWmInfo (_THIS, SDL_SysWMinfo * info) | 310 RISCOS_GetWmInfo(_THIS, SDL_SysWMinfo * info) |
311 { | 311 { |
312 SDL_VERSION (&(info->version)); | 312 SDL_VERSION(&(info->version)); |
313 info->wimpVersion = RISCOS_GetWimpVersion (); | 313 info->wimpVersion = RISCOS_GetWimpVersion(); |
314 info->taskHandle = RISCOS_GetTaskHandle (); | 314 info->taskHandle = RISCOS_GetTaskHandle(); |
315 info->window = this->hidden->window_handle; | 315 info->window = this->hidden->window_handle; |
316 | 316 |
317 return 1; | 317 return 1; |
318 } | 318 } |
319 | 319 |
320 /* Toggle full screen mode. | 320 /* Toggle full screen mode. |
321 Returns 1 if successful otherwise 0 | 321 Returns 1 if successful otherwise 0 |
322 */ | 322 */ |
323 | 323 |
324 int | 324 int |
325 RISCOS_ToggleFullScreen (_THIS, int fullscreen) | 325 RISCOS_ToggleFullScreen(_THIS, int fullscreen) |
326 { | 326 { |
327 if (fullscreen) { | 327 if (fullscreen) { |
328 return FULLSCREEN_ToggleFromWimp (this); | 328 return FULLSCREEN_ToggleFromWimp(this); |
329 } else { | 329 } else { |
330 return WIMP_ToggleFromFullScreen (this); | 330 return WIMP_ToggleFromFullScreen(this); |
331 } | 331 } |
332 | 332 |
333 return 0; | 333 return 0; |
334 } | 334 } |
335 | 335 |