Mercurial > sdl-ios-xcode
comparison src/video/riscos/SDL_riscosFullScreenVideo.c @ 1662:782fd950bd46 SDL-1.3
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
WARNING: None of the video drivers have been updated for the new API yet! The API is still under design and very fluid.
The code is now run through a consistent indent format:
indent -i4 -nut -nsc -br -ce
The headers are being converted to automatically generate doxygen documentation.
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Sun, 28 May 2006 13:04:16 +0000 |
parents | d910939febfa |
children | 4da1ee79c9af |
comparison
equal
deleted
inserted
replaced
1661:281d3f4870e5 | 1662:782fd950bd46 |
---|---|
45 #include "unixlib/local.h" | 45 #include "unixlib/local.h" |
46 | 46 |
47 /* Private structures */ | 47 /* Private structures */ |
48 typedef struct tagScreenModeBlock | 48 typedef struct tagScreenModeBlock |
49 { | 49 { |
50 int flags; // mode selector flags, bit 0 = 1, bit 1-7 format specifier, 8-31 reserved | 50 int flags; // mode selector flags, bit 0 = 1, bit 1-7 format specifier, 8-31 reserved |
51 int x_pixels; | 51 int x_pixels; |
52 int y_pixels; | 52 int y_pixels; |
53 int pixel_depth; // 2^pixel_depth = bpp,i.e. 0 = 1, 1 = 2, 4 = 16, 5 = 32 | 53 int pixel_depth; // 2^pixel_depth = bpp,i.e. 0 = 1, 1 = 2, 4 = 16, 5 = 32 |
54 int frame_rate; // -1 use first match | 54 int frame_rate; // -1 use first match |
55 int mode_vars[5]; // array of index, value pairs terminated by -1 | 55 int mode_vars[5]; // array of index, value pairs terminated by -1 |
56 } SCREENMODEBLOCK; | 56 } SCREENMODEBLOCK; |
57 | 57 |
58 | 58 |
59 /* Helper functions */ | 59 /* Helper functions */ |
60 void FULLSCREEN_SetDeviceMode(_THIS); | 60 void FULLSCREEN_SetDeviceMode (_THIS); |
61 int FULLSCREEN_SetMode(int width, int height, int bpp); | 61 int FULLSCREEN_SetMode (int width, int height, int bpp); |
62 void FULLSCREEN_SetupBanks(_THIS); | 62 void FULLSCREEN_SetupBanks (_THIS); |
63 | 63 |
64 /* SDL video device functions for fullscreen mode */ | 64 /* SDL video device functions for fullscreen mode */ |
65 static int FULLSCREEN_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors); | 65 static int FULLSCREEN_SetColors (_THIS, int firstcolor, int ncolors, |
66 static int FULLSCREEN_FlipHWSurface(_THIS, SDL_Surface *surface); | 66 SDL_Color * colors); |
67 void FULLSCREEN_SetWMCaption(_THIS, const char *title, const char *icon); | 67 static int FULLSCREEN_FlipHWSurface (_THIS, SDL_Surface * surface); |
68 extern int RISCOS_GetWmInfo(_THIS, SDL_SysWMinfo *info); | 68 void FULLSCREEN_SetWMCaption (_THIS, const char *title, const char *icon); |
69 extern int RISCOS_GetWmInfo (_THIS, SDL_SysWMinfo * info); | |
69 | 70 |
70 /* UpdateRects variants */ | 71 /* UpdateRects variants */ |
71 static void FULLSCREEN_UpdateRects(_THIS, int numrects, SDL_Rect *rects); | 72 static void FULLSCREEN_UpdateRects (_THIS, int numrects, SDL_Rect * rects); |
72 static void FULLSCREEN_UpdateRectsMemCpy(_THIS, int numrects, SDL_Rect *rects); | 73 static void FULLSCREEN_UpdateRectsMemCpy (_THIS, int numrects, |
73 static void FULLSCREEN_UpdateRects8bpp(_THIS, int numrects, SDL_Rect *rects); | 74 SDL_Rect * rects); |
74 static void FULLSCREEN_UpdateRects16bpp(_THIS, int numrects, SDL_Rect *rects); | 75 static void FULLSCREEN_UpdateRects8bpp (_THIS, int numrects, |
75 static void FULLSCREEN_UpdateRects32bpp(_THIS, int numrects, SDL_Rect *rects); | 76 SDL_Rect * rects); |
76 static void FULLSCREEN_UpdateRectsOS(_THIS, int numrects, SDL_Rect *rects); | 77 static void FULLSCREEN_UpdateRects16bpp (_THIS, int numrects, |
78 SDL_Rect * rects); | |
79 static void FULLSCREEN_UpdateRects32bpp (_THIS, int numrects, | |
80 SDL_Rect * rects); | |
81 static void FULLSCREEN_UpdateRectsOS (_THIS, int numrects, SDL_Rect * rects); | |
77 | 82 |
78 /* Local helper functions */ | 83 /* Local helper functions */ |
79 static int cmpmodes(const void *va, const void *vb); | 84 static int cmpmodes (const void *va, const void *vb); |
80 static int FULLSCREEN_AddMode(_THIS, int bpp, int w, int h); | 85 static int FULLSCREEN_AddMode (_THIS, int bpp, int w, int h); |
81 void FULLSCREEN_SetWriteBank(int bank); | 86 void FULLSCREEN_SetWriteBank (int bank); |
82 void FULLSCREEN_SetDisplayBank(int bank); | 87 void FULLSCREEN_SetDisplayBank (int bank); |
83 static void FULLSCREEN_DisableEscape(); | 88 static void FULLSCREEN_DisableEscape (); |
84 static void FULLSCREEN_EnableEscape(); | 89 static void FULLSCREEN_EnableEscape (); |
85 void FULLSCREEN_BuildModeList(_THIS); | 90 void FULLSCREEN_BuildModeList (_THIS); |
86 | 91 |
87 /* Following variable is set up in riskosTask.c */ | 92 /* Following variable is set up in riskosTask.c */ |
88 extern int riscos_backbuffer; /* Create a back buffer in system memory for full screen mode */ | 93 extern int riscos_backbuffer; /* Create a back buffer in system memory for full screen mode */ |
89 | 94 |
90 /* Following is used to create a sprite back buffer */ | 95 /* Following is used to create a sprite back buffer */ |
91 extern unsigned char *WIMP_CreateBuffer(int width, int height, int bpp); | 96 extern unsigned char *WIMP_CreateBuffer (int width, int height, int bpp); |
92 | 97 |
93 /* Fast assembler copy */ | 98 /* Fast assembler copy */ |
94 extern void RISCOS_Put32(void *to, int pixels, int pitch, int rows, void *from, int src_skip_bytes); | 99 extern void RISCOS_Put32 (void *to, int pixels, int pitch, int rows, |
95 | 100 void *from, int src_skip_bytes); |
96 SDL_Surface *FULLSCREEN_SetVideoMode(_THIS, SDL_Surface *current, | 101 |
97 int width, int height, int bpp, Uint32 flags) | 102 SDL_Surface * |
98 { | 103 FULLSCREEN_SetVideoMode (_THIS, SDL_Surface * current, |
99 _kernel_swi_regs regs; | 104 int width, int height, int bpp, Uint32 flags) |
100 Uint32 Rmask = 0; | 105 { |
101 Uint32 Gmask = 0; | 106 _kernel_swi_regs regs; |
102 Uint32 Bmask = 0; | 107 Uint32 Rmask = 0; |
103 int create_back_buffer = riscos_backbuffer; | 108 Uint32 Gmask = 0; |
104 | 109 Uint32 Bmask = 0; |
105 switch(bpp) | 110 int create_back_buffer = riscos_backbuffer; |
106 { | 111 |
107 case 8: | 112 switch (bpp) { |
108 flags |= SDL_HWPALETTE; | 113 case 8: |
109 break; | 114 flags |= SDL_HWPALETTE; |
110 | 115 break; |
111 case 15: | 116 |
112 case 16: | 117 case 15: |
113 Bmask = 0x00007c00; | 118 case 16: |
114 Gmask = 0x000003e0; | 119 Bmask = 0x00007c00; |
115 Rmask = 0x0000001f; | 120 Gmask = 0x000003e0; |
116 break; | 121 Rmask = 0x0000001f; |
117 | 122 break; |
118 case 32: | 123 |
119 Bmask = 0x00ff0000; | 124 case 32: |
120 Gmask = 0x0000ff00; | 125 Bmask = 0x00ff0000; |
121 Rmask = 0x000000ff; | 126 Gmask = 0x0000ff00; |
122 break; | 127 Rmask = 0x000000ff; |
123 | 128 break; |
124 default: | 129 |
125 SDL_SetError("Pixel depth not supported"); | 130 default: |
126 return NULL; | 131 SDL_SetError ("Pixel depth not supported"); |
127 break; | 132 return NULL; |
128 } | 133 break; |
129 | 134 } |
130 if (FULLSCREEN_SetMode(width, height, bpp) == 0) | 135 |
131 { | 136 if (FULLSCREEN_SetMode (width, height, bpp) == 0) { |
132 SDL_SetError("Couldn't set requested mode"); | 137 SDL_SetError ("Couldn't set requested mode"); |
133 return (NULL); | 138 return (NULL); |
134 } | 139 } |
135 | 140 |
136 /* printf("Setting mode %dx%d\n", width, height); */ | 141 /* printf("Setting mode %dx%d\n", width, height); */ |
137 | 142 |
138 /* Allocate the new pixel format for the screen */ | 143 /* Allocate the new pixel format for the screen */ |
139 if ( ! SDL_ReallocFormat(current, bpp, Rmask, Gmask, Bmask, 0) ) { | 144 if (!SDL_ReallocFormat (current, bpp, Rmask, Gmask, Bmask, 0)) { |
140 RISCOS_RestoreWimpMode(); | 145 RISCOS_RestoreWimpMode (); |
141 SDL_SetError("Couldn't allocate new pixel format for requested mode"); | 146 SDL_SetError |
142 return(NULL); | 147 ("Couldn't allocate new pixel format for requested mode"); |
143 } | 148 return (NULL); |
144 | 149 } |
145 /* Set up the new mode framebuffer */ | 150 |
146 current->w = width; | 151 /* Set up the new mode framebuffer */ |
147 this->hidden->height = current->h = height; | 152 current->w = width; |
148 | 153 this->hidden->height = current->h = height; |
149 regs.r[0] = -1; /* -1 for current screen mode */ | 154 |
150 | 155 regs.r[0] = -1; /* -1 for current screen mode */ |
151 /* Get screen width in bytes */ | 156 |
152 regs.r[1] = 6; // Screen Width in bytes | 157 /* Get screen width in bytes */ |
153 _kernel_swi(OS_ReadModeVariable, ®s, ®s); | 158 regs.r[1] = 6; // Screen Width in bytes |
154 | 159 _kernel_swi (OS_ReadModeVariable, ®s, ®s); |
155 current->pitch = regs.r[2]; | 160 |
156 | 161 current->pitch = regs.r[2]; |
157 if (flags & SDL_DOUBLEBUF) | 162 |
158 { | 163 if (flags & SDL_DOUBLEBUF) { |
159 regs.r[0] = 2; /* Screen area */ | 164 regs.r[0] = 2; /* Screen area */ |
160 _kernel_swi(OS_ReadDynamicArea, ®s, ®s); | 165 _kernel_swi (OS_ReadDynamicArea, ®s, ®s); |
161 | 166 |
162 /* Reg 1 has amount of memory currently used for display */ | 167 /* Reg 1 has amount of memory currently used for display */ |
163 regs.r[0] = 2; /* Screen area */ | 168 regs.r[0] = 2; /* Screen area */ |
164 regs.r[1] = (current->pitch * height * 2) - regs.r[1]; | 169 regs.r[1] = (current->pitch * height * 2) - regs.r[1]; |
165 if (_kernel_swi(OS_ChangeDynamicArea, ®s, ®s) != NULL) | 170 if (_kernel_swi (OS_ChangeDynamicArea, ®s, ®s) != NULL) { |
166 { | 171 /* Can't allocate enough screen memory for double buffer */ |
167 /* Can't allocate enough screen memory for double buffer */ | 172 flags &= ~SDL_DOUBLEBUF; |
168 flags &= ~SDL_DOUBLEBUF; | 173 } |
169 } | 174 } |
170 } | 175 |
171 | 176 current->flags = flags | SDL_FULLSCREEN | SDL_HWSURFACE | SDL_PREALLOC; |
172 current->flags = flags | SDL_FULLSCREEN | SDL_HWSURFACE | SDL_PREALLOC; | 177 |
173 | 178 |
174 | 179 /* Need to set display banks here for double buffering */ |
175 /* Need to set display banks here for double buffering */ | 180 if (flags & SDL_DOUBLEBUF) { |
176 if (flags & SDL_DOUBLEBUF) | 181 FULLSCREEN_SetWriteBank (0); |
177 { | 182 FULLSCREEN_SetDisplayBank (1); |
178 FULLSCREEN_SetWriteBank(0); | 183 |
179 FULLSCREEN_SetDisplayBank(1); | 184 create_back_buffer = 0; /* Don't need a back buffer for a double buffered display */ |
180 | 185 } |
181 create_back_buffer = 0; /* Don't need a back buffer for a double buffered display */ | 186 |
182 } | 187 FULLSCREEN_SetupBanks (this); |
183 | 188 |
184 FULLSCREEN_SetupBanks(this); | 189 if (create_back_buffer) { |
185 | 190 /* If not double buffered we may need to create a memory |
186 if (create_back_buffer) | |
187 { | |
188 /* If not double buffered we may need to create a memory | |
189 ** back buffer to simulate processing on other OSes. | 191 ** back buffer to simulate processing on other OSes. |
190 ** This is turned on by setting the enviromental variable | 192 ** This is turned on by setting the enviromental variable |
191 ** SDL$<name>$BackBuffer >= 1 | 193 ** SDL$<name>$BackBuffer >= 1 |
192 */ | 194 */ |
193 if (riscos_backbuffer == 3) | 195 if (riscos_backbuffer == 3) |
194 this->hidden->bank[0] = WIMP_CreateBuffer(width, height, bpp); | 196 this->hidden->bank[0] = WIMP_CreateBuffer (width, height, bpp); |
195 else | 197 else |
196 this->hidden->bank[0] = SDL_malloc(height * current->pitch); | 198 this->hidden->bank[0] = SDL_malloc (height * current->pitch); |
197 if (this->hidden->bank[0] == 0) | 199 if (this->hidden->bank[0] == 0) { |
198 { | 200 RISCOS_RestoreWimpMode (); |
199 RISCOS_RestoreWimpMode(); | 201 SDL_SetError ("Couldnt allocate memory for back buffer"); |
200 SDL_SetError("Couldnt allocate memory for back buffer"); | 202 return (NULL); |
201 return (NULL); | 203 } |
202 } | 204 /* Surface updated in programs is now a software surface */ |
203 /* Surface updated in programs is now a software surface */ | 205 current->flags &= ~SDL_HWSURFACE; |
204 current->flags &= ~SDL_HWSURFACE; | |
205 } | 206 } |
206 | 207 |
207 /* Store address of allocated screen bank to be freed later */ | 208 /* Store address of allocated screen bank to be freed later */ |
208 if (this->hidden->alloc_bank) SDL_free(this->hidden->alloc_bank); | 209 if (this->hidden->alloc_bank) |
209 if (create_back_buffer) | 210 SDL_free (this->hidden->alloc_bank); |
210 { | 211 if (create_back_buffer) { |
211 this->hidden->alloc_bank = this->hidden->bank[0]; | 212 this->hidden->alloc_bank = this->hidden->bank[0]; |
212 if (riscos_backbuffer == 3) | 213 if (riscos_backbuffer == 3) { |
213 { | 214 this->hidden->bank[0] += 60; /* Start of sprite data */ |
214 this->hidden->bank[0] += 60; /* Start of sprite data */ | 215 if (bpp == 8) |
215 if (bpp == 8) this->hidden->bank[0] += 2048; /* 8bpp sprite have palette first */ | 216 this->hidden->bank[0] += 2048; /* 8bpp sprite have palette first */ |
216 } | 217 } |
217 } else | 218 } else |
218 this->hidden->alloc_bank = 0; | 219 this->hidden->alloc_bank = 0; |
219 | 220 |
220 // Clear both banks to black | 221 // Clear both banks to black |
221 SDL_memset(this->hidden->bank[0], 0, height * current->pitch); | 222 SDL_memset (this->hidden->bank[0], 0, height * current->pitch); |
222 SDL_memset(this->hidden->bank[1], 0, height * current->pitch); | 223 SDL_memset (this->hidden->bank[1], 0, height * current->pitch); |
223 | 224 |
224 this->hidden->current_bank = 0; | 225 this->hidden->current_bank = 0; |
225 current->pixels = this->hidden->bank[0]; | 226 current->pixels = this->hidden->bank[0]; |
226 | 227 |
227 /* Have to set the screen here, so SetDeviceMode will pick it up */ | 228 /* Have to set the screen here, so SetDeviceMode will pick it up */ |
228 this->screen = current; | 229 this->screen = current; |
229 | 230 |
230 /* Reset device functions for the wimp */ | 231 /* Reset device functions for the wimp */ |
231 FULLSCREEN_SetDeviceMode(this); | 232 FULLSCREEN_SetDeviceMode (this); |
232 | 233 |
233 /* FULLSCREEN_DisableEscape(); */ | 234 /* FULLSCREEN_DisableEscape(); */ |
234 | 235 |
235 /* We're done */ | 236 /* We're done */ |
236 return(current); | 237 return (current); |
237 } | 238 } |
238 | 239 |
239 /* Reset any device functions that have been changed because we have run in WIMP mode */ | 240 /* Reset any device functions that have been changed because we have run in WIMP mode */ |
240 void FULLSCREEN_SetDeviceMode(_THIS) | 241 void |
241 { | 242 FULLSCREEN_SetDeviceMode (_THIS) |
242 /* Update rects is different if we have a backbuffer */ | 243 { |
243 | 244 /* Update rects is different if we have a backbuffer */ |
244 if (riscos_backbuffer && (this->screen->flags & SDL_DOUBLEBUF) == 0) | 245 |
245 { | 246 if (riscos_backbuffer && (this->screen->flags & SDL_DOUBLEBUF) == 0) { |
246 switch(riscos_backbuffer) | 247 switch (riscos_backbuffer) { |
247 { | 248 case 2: /* ARM code full word copy */ |
248 case 2: /* ARM code full word copy */ | 249 switch (this->screen->format->BytesPerPixel) { |
249 switch(this->screen->format->BytesPerPixel) | 250 case 1: /* 8bpp modes */ |
250 { | 251 this->UpdateRects = FULLSCREEN_UpdateRects8bpp; |
251 case 1: /* 8bpp modes */ | 252 break; |
252 this->UpdateRects = FULLSCREEN_UpdateRects8bpp; | 253 case 2: /* 15/16bpp modes */ |
253 break; | 254 this->UpdateRects = FULLSCREEN_UpdateRects16bpp; |
254 case 2: /* 15/16bpp modes */ | 255 break; |
255 this->UpdateRects = FULLSCREEN_UpdateRects16bpp; | 256 case 4: /* 32 bpp modes */ |
256 break; | 257 this->UpdateRects = FULLSCREEN_UpdateRects32bpp; |
257 case 4: /* 32 bpp modes */ | 258 break; |
258 this->UpdateRects = FULLSCREEN_UpdateRects32bpp; | 259 |
259 break; | 260 default: /* Just default to the memcpy routine */ |
260 | 261 this->UpdateRects = FULLSCREEN_UpdateRectsMemCpy; |
261 default: /* Just default to the memcpy routine */ | 262 break; |
262 this->UpdateRects = FULLSCREEN_UpdateRectsMemCpy; | 263 } |
263 break; | 264 break; |
264 } | 265 |
265 break; | 266 case 3: /* Use OS sprite plot routine */ |
266 | 267 this->UpdateRects = FULLSCREEN_UpdateRectsOS; |
267 case 3: /* Use OS sprite plot routine */ | 268 break; |
268 this->UpdateRects = FULLSCREEN_UpdateRectsOS; | 269 |
269 break; | 270 default: /* Old but safe memcpy */ |
270 | 271 this->UpdateRects = FULLSCREEN_UpdateRectsMemCpy; |
271 default: /* Old but safe memcpy */ | 272 break; |
272 this->UpdateRects = FULLSCREEN_UpdateRectsMemCpy; | 273 } |
273 break; | 274 } else |
274 } | 275 this->UpdateRects = FULLSCREEN_UpdateRects; /* Default do nothing implementation */ |
275 } else | 276 |
276 this->UpdateRects = FULLSCREEN_UpdateRects; /* Default do nothing implementation */ | 277 this->SetColors = FULLSCREEN_SetColors; |
277 | 278 |
278 this->SetColors = FULLSCREEN_SetColors; | 279 this->FlipHWSurface = FULLSCREEN_FlipHWSurface; |
279 | 280 |
280 this->FlipHWSurface = FULLSCREEN_FlipHWSurface; | 281 this->SetCaption = FULLSCREEN_SetWMCaption; |
281 | 282 this->SetIcon = NULL; |
282 this->SetCaption = FULLSCREEN_SetWMCaption; | 283 this->IconifyWindow = NULL; |
283 this->SetIcon = NULL; | 284 |
284 this->IconifyWindow = NULL; | 285 this->ShowWMCursor = RISCOS_ShowWMCursor; |
285 | 286 this->WarpWMCursor = FULLSCREEN_WarpWMCursor; |
286 this->ShowWMCursor = RISCOS_ShowWMCursor; | 287 |
287 this->WarpWMCursor = FULLSCREEN_WarpWMCursor; | 288 this->PumpEvents = FULLSCREEN_PumpEvents; |
288 | |
289 this->PumpEvents = FULLSCREEN_PumpEvents; | |
290 } | 289 } |
291 | 290 |
292 /* Query for the list of available video modes */ | 291 /* Query for the list of available video modes */ |
293 void FULLSCREEN_BuildModeList(_THIS) | 292 void |
294 { | 293 FULLSCREEN_BuildModeList (_THIS) |
295 _kernel_swi_regs regs; | 294 { |
296 char *enumInfo = NULL; | 295 _kernel_swi_regs regs; |
297 char *enum_ptr; | 296 char *enumInfo = NULL; |
298 int *blockInfo; | 297 char *enum_ptr; |
299 int j; | 298 int *blockInfo; |
300 int num_modes; | 299 int j; |
301 | 300 int num_modes; |
302 /* Find out how much space we need */ | 301 |
303 regs.r[0] = 2; /* Reason code */ | 302 /* Find out how much space we need */ |
304 regs.r[2] = 0; /* Number of modes to skip */ | 303 regs.r[0] = 2; /* Reason code */ |
305 regs.r[6] = 0; /* pointer to block or 0 for count */ | 304 regs.r[2] = 0; /* Number of modes to skip */ |
306 regs.r[7] = 0; /* Size of block in bytes */ | 305 regs.r[6] = 0; /* pointer to block or 0 for count */ |
307 _kernel_swi(OS_ScreenMode, ®s, ®s); | 306 regs.r[7] = 0; /* Size of block in bytes */ |
307 _kernel_swi (OS_ScreenMode, ®s, ®s); | |
308 | 308 |
309 num_modes = -regs.r[2]; | 309 num_modes = -regs.r[2]; |
310 | 310 |
311 /* Video memory should be in r[5] */ | 311 /* Video memory should be in r[5] */ |
312 this->info.video_mem = regs.r[5]/1024; | 312 this->info.video_mem = regs.r[5] / 1024; |
313 | 313 |
314 enumInfo = (unsigned char *)SDL_malloc(-regs.r[7]); | 314 enumInfo = (unsigned char *) SDL_malloc (-regs.r[7]); |
315 if (enumInfo == NULL) | 315 if (enumInfo == NULL) { |
316 { | 316 SDL_OutOfMemory (); |
317 SDL_OutOfMemory(); | 317 return; |
318 return; | 318 } |
319 } | 319 /* Read mode information into block */ |
320 /* Read mode information into block */ | 320 regs.r[2] = 0; |
321 regs.r[2] = 0; | 321 regs.r[6] = (int) enumInfo; |
322 regs.r[6] = (int)enumInfo; | 322 regs.r[7] = -regs.r[7]; |
323 regs.r[7] = -regs.r[7]; | 323 _kernel_swi (OS_ScreenMode, ®s, ®s); |
324 _kernel_swi(OS_ScreenMode, ®s, ®s); | 324 |
325 | 325 enum_ptr = enumInfo; |
326 enum_ptr = enumInfo; | 326 |
327 | 327 for (j = 0; j < num_modes; j++) { |
328 for (j =0; j < num_modes;j++) | 328 blockInfo = (int *) enum_ptr; |
329 { | 329 if ((blockInfo[1] & 255) == 1) { /* We understand this format */ |
330 blockInfo = (int *)enum_ptr; | 330 switch (blockInfo[4]) { |
331 if ((blockInfo[1] & 255) == 1) /* We understand this format */ | 331 case 3: /* 8 bits per pixel */ |
332 { | 332 FULLSCREEN_AddMode (this, 8, blockInfo[2], blockInfo[3]); |
333 switch(blockInfo[4]) | 333 break; |
334 { | 334 case 4: /* 15 bits per pixel */ |
335 case 3: /* 8 bits per pixel */ | 335 FULLSCREEN_AddMode (this, 15, blockInfo[2], blockInfo[3]); |
336 FULLSCREEN_AddMode(this, 8, blockInfo[2], blockInfo[3]); | 336 break; |
337 break; | 337 case 5: /* 32 bits per pixel */ |
338 case 4: /* 15 bits per pixel */ | 338 FULLSCREEN_AddMode (this, 32, blockInfo[2], blockInfo[3]); |
339 FULLSCREEN_AddMode(this, 15, blockInfo[2], blockInfo[3]); | 339 break; |
340 break; | 340 } |
341 case 5: /* 32 bits per pixel */ | 341 } |
342 FULLSCREEN_AddMode(this, 32, blockInfo[2], blockInfo[3]); | 342 |
343 break; | 343 enum_ptr += blockInfo[0]; |
344 } | 344 } |
345 } | 345 |
346 | 346 SDL_free (enumInfo); |
347 enum_ptr += blockInfo[0]; | 347 |
348 } | 348 /* Sort the mode lists */ |
349 | 349 for (j = 0; j < NUM_MODELISTS; ++j) { |
350 SDL_free(enumInfo); | 350 if (SDL_nummodes[j] > 0) { |
351 | 351 SDL_qsort (SDL_modelist[j], SDL_nummodes[j], |
352 /* Sort the mode lists */ | 352 sizeof *SDL_modelist[j], cmpmodes); |
353 for ( j=0; j<NUM_MODELISTS; ++j ) { | 353 } |
354 if ( SDL_nummodes[j] > 0 ) { | 354 } |
355 SDL_qsort(SDL_modelist[j], SDL_nummodes[j], sizeof *SDL_modelist[j], cmpmodes); | 355 } |
356 } | 356 |
357 } | 357 static int |
358 } | 358 FULLSCREEN_FlipHWSurface (_THIS, SDL_Surface * surface) |
359 | 359 { |
360 static int FULLSCREEN_FlipHWSurface(_THIS, SDL_Surface *surface) | 360 _kernel_swi_regs regs; |
361 { | 361 regs.r[0] = 19; |
362 _kernel_swi_regs regs; | 362 |
363 regs.r[0] = 19; | 363 FULLSCREEN_SetDisplayBank (this->hidden->current_bank); |
364 | 364 this->hidden->current_bank ^= 1; |
365 FULLSCREEN_SetDisplayBank(this->hidden->current_bank); | 365 FULLSCREEN_SetWriteBank (this->hidden->current_bank); |
366 this->hidden->current_bank ^= 1; | 366 surface->pixels = this->hidden->bank[this->hidden->current_bank]; |
367 FULLSCREEN_SetWriteBank(this->hidden->current_bank); | 367 |
368 surface->pixels = this->hidden->bank[this->hidden->current_bank]; | 368 /* Wait for Vsync */ |
369 | 369 _kernel_swi (OS_Byte, ®s, ®s); |
370 /* Wait for Vsync */ | 370 |
371 _kernel_swi(OS_Byte, ®s, ®s); | 371 return (0); |
372 | |
373 return(0); | |
374 } | 372 } |
375 | 373 |
376 /* Nothing to do if we are writing direct to hardware */ | 374 /* Nothing to do if we are writing direct to hardware */ |
377 static void FULLSCREEN_UpdateRects(_THIS, int numrects, SDL_Rect *rects) | 375 static void |
376 FULLSCREEN_UpdateRects (_THIS, int numrects, SDL_Rect * rects) | |
378 { | 377 { |
379 } | 378 } |
380 | 379 |
381 /* Safe but slower Memory copy from our allocated back buffer */ | 380 /* Safe but slower Memory copy from our allocated back buffer */ |
382 static void FULLSCREEN_UpdateRectsMemCpy(_THIS, int numrects, SDL_Rect *rects) | 381 static void |
383 { | 382 FULLSCREEN_UpdateRectsMemCpy (_THIS, int numrects, SDL_Rect * rects) |
384 int j; | 383 { |
385 char *to, *from; | 384 int j; |
386 int pitch = this->screen->pitch; | 385 char *to, *from; |
387 int row; | 386 int pitch = this->screen->pitch; |
388 int xmult = this->screen->format->BytesPerPixel; | 387 int row; |
389 for (j = 0; j < numrects; j++) | 388 int xmult = this->screen->format->BytesPerPixel; |
390 { | 389 for (j = 0; j < numrects; j++) { |
391 from = this->hidden->bank[0] + rects->x * xmult + rects->y * pitch; | 390 from = this->hidden->bank[0] + rects->x * xmult + rects->y * pitch; |
392 to = this->hidden->bank[1] + rects->x * xmult + rects->y * pitch; | 391 to = this->hidden->bank[1] + rects->x * xmult + rects->y * pitch; |
393 for (row = 0; row < rects->h; row++) | 392 for (row = 0; row < rects->h; row++) { |
394 { | 393 SDL_memcpy (to, from, rects->w * xmult); |
395 SDL_memcpy(to, from, rects->w * xmult); | 394 from += pitch; |
396 from += pitch; | 395 to += pitch; |
397 to += pitch; | 396 } |
398 } | 397 rects++; |
399 rects++; | 398 } |
400 } | |
401 } | 399 } |
402 | 400 |
403 /* Use optimized assembler memory copy. Deliberately copies extra columns if | 401 /* Use optimized assembler memory copy. Deliberately copies extra columns if |
404 necessary to ensure the rectangle is word aligned. */ | 402 necessary to ensure the rectangle is word aligned. */ |
405 static void FULLSCREEN_UpdateRects8bpp(_THIS, int numrects, SDL_Rect *rects) | 403 static void |
406 { | 404 FULLSCREEN_UpdateRects8bpp (_THIS, int numrects, SDL_Rect * rects) |
407 int j; | 405 { |
408 char *to, *from; | 406 int j; |
409 int pitch = this->screen->pitch; | 407 char *to, *from; |
410 int width_bytes; | 408 int pitch = this->screen->pitch; |
411 int src_skip_bytes; | 409 int width_bytes; |
412 | 410 int src_skip_bytes; |
413 for (j = 0; j < numrects; j++) | 411 |
414 { | 412 for (j = 0; j < numrects; j++) { |
415 from = this->hidden->bank[0] + rects->x + rects->y * pitch; | 413 from = this->hidden->bank[0] + rects->x + rects->y * pitch; |
416 to = this->hidden->bank[1] + rects->x + rects->y * pitch; | 414 to = this->hidden->bank[1] + rects->x + rects->y * pitch; |
417 width_bytes = rects->w; | 415 width_bytes = rects->w; |
418 if ((int)from & 3) | 416 if ((int) from & 3) { |
419 { | 417 int extra = ((int) from & 3); |
420 int extra = ((int)from & 3); | 418 from -= extra; |
421 from -= extra; | 419 to -= extra; |
422 to -= extra; | 420 width_bytes += extra; |
423 width_bytes += extra; | 421 } |
424 } | 422 if (width_bytes & 3) |
425 if (width_bytes & 3) width_bytes += 4 - (width_bytes & 3); | 423 width_bytes += 4 - (width_bytes & 3); |
426 src_skip_bytes = pitch - width_bytes; | 424 src_skip_bytes = pitch - width_bytes; |
427 | 425 |
428 RISCOS_Put32(to, (width_bytes >> 2), pitch, (int)rects->h, from, src_skip_bytes); | 426 RISCOS_Put32 (to, (width_bytes >> 2), pitch, (int) rects->h, from, |
429 rects++; | 427 src_skip_bytes); |
430 } | 428 rects++; |
429 } | |
431 } | 430 } |
432 | 431 |
433 /* Use optimized assembler memory copy. Deliberately copies extra columns if | 432 /* Use optimized assembler memory copy. Deliberately copies extra columns if |
434 necessary to ensure the rectangle is word aligned. */ | 433 necessary to ensure the rectangle is word aligned. */ |
435 static void FULLSCREEN_UpdateRects16bpp(_THIS, int numrects, SDL_Rect *rects) | 434 static void |
436 { | 435 FULLSCREEN_UpdateRects16bpp (_THIS, int numrects, SDL_Rect * rects) |
437 int j; | 436 { |
438 char *to, *from; | 437 int j; |
439 int pitch = this->screen->pitch; | 438 char *to, *from; |
440 int width_bytes; | 439 int pitch = this->screen->pitch; |
441 int src_skip_bytes; | 440 int width_bytes; |
442 | 441 int src_skip_bytes; |
443 for (j = 0; j < numrects; j++) | 442 |
444 { | 443 for (j = 0; j < numrects; j++) { |
445 from = this->hidden->bank[0] + (rects->x << 1) + rects->y * pitch; | 444 from = this->hidden->bank[0] + (rects->x << 1) + rects->y * pitch; |
446 to = this->hidden->bank[1] + (rects->x << 1) + rects->y * pitch; | 445 to = this->hidden->bank[1] + (rects->x << 1) + rects->y * pitch; |
447 width_bytes = (((int)rects->w) << 1); | 446 width_bytes = (((int) rects->w) << 1); |
448 if ((int)from & 3) | 447 if ((int) from & 3) { |
449 { | 448 from -= 2; |
450 from -= 2; | 449 to -= 2; |
451 to -= 2; | 450 width_bytes += 2; |
452 width_bytes += 2; | 451 } |
453 } | 452 if (width_bytes & 3) |
454 if (width_bytes & 3) width_bytes += 2; | 453 width_bytes += 2; |
455 src_skip_bytes = pitch - width_bytes; | 454 src_skip_bytes = pitch - width_bytes; |
456 | 455 |
457 RISCOS_Put32(to, (width_bytes >> 2), pitch, (int)rects->h, from, src_skip_bytes); | 456 RISCOS_Put32 (to, (width_bytes >> 2), pitch, (int) rects->h, from, |
458 rects++; | 457 src_skip_bytes); |
459 } | 458 rects++; |
459 } | |
460 } | 460 } |
461 | 461 |
462 /* Use optimized assembler memory copy. 32 bpp modes are always word aligned */ | 462 /* Use optimized assembler memory copy. 32 bpp modes are always word aligned */ |
463 static void FULLSCREEN_UpdateRects32bpp(_THIS, int numrects, SDL_Rect *rects) | 463 static void |
464 { | 464 FULLSCREEN_UpdateRects32bpp (_THIS, int numrects, SDL_Rect * rects) |
465 int j; | 465 { |
466 char *to, *from; | 466 int j; |
467 int pitch = this->screen->pitch; | 467 char *to, *from; |
468 int width; | 468 int pitch = this->screen->pitch; |
469 | 469 int width; |
470 for (j = 0; j < numrects; j++) | 470 |
471 { | 471 for (j = 0; j < numrects; j++) { |
472 from = this->hidden->bank[0] + (rects->x << 2) + rects->y * pitch; | 472 from = this->hidden->bank[0] + (rects->x << 2) + rects->y * pitch; |
473 to = this->hidden->bank[1] + (rects->x << 2) + rects->y * pitch; | 473 to = this->hidden->bank[1] + (rects->x << 2) + rects->y * pitch; |
474 width = (int)rects->w ; | 474 width = (int) rects->w; |
475 | 475 |
476 RISCOS_Put32(to, width, pitch, (int)rects->h, from, pitch - (width << 2)); | 476 RISCOS_Put32 (to, width, pitch, (int) rects->h, from, |
477 rects++; | 477 pitch - (width << 2)); |
478 } | 478 rects++; |
479 } | |
479 } | 480 } |
480 | 481 |
481 /* Use operating system sprite plots. Currently this is much slower than the | 482 /* Use operating system sprite plots. Currently this is much slower than the |
482 other variants however accelerated sprite plotting can be seen on the horizon | 483 other variants however accelerated sprite plotting can be seen on the horizon |
483 so this prepares for it. */ | 484 so this prepares for it. */ |
484 static void FULLSCREEN_UpdateRectsOS(_THIS, int numrects, SDL_Rect *rects) | 485 static void |
485 { | 486 FULLSCREEN_UpdateRectsOS (_THIS, int numrects, SDL_Rect * rects) |
486 _kernel_swi_regs regs; | 487 { |
487 _kernel_oserror *err; | 488 _kernel_swi_regs regs; |
488 int j; | 489 _kernel_oserror *err; |
489 int y; | 490 int j; |
490 | 491 int y; |
491 regs.r[0] = 28 + 512; | 492 |
492 regs.r[1] = (unsigned int)this->hidden->alloc_bank; | 493 regs.r[0] = 28 + 512; |
493 regs.r[2] = (unsigned int)this->hidden->alloc_bank+16; | 494 regs.r[1] = (unsigned int) this->hidden->alloc_bank; |
494 regs.r[5] = 0; | 495 regs.r[2] = (unsigned int) this->hidden->alloc_bank + 16; |
495 | 496 regs.r[5] = 0; |
496 for (j = 0; j < numrects; j++) | 497 |
497 { | 498 for (j = 0; j < numrects; j++) { |
498 y = this->screen->h - rects->y; /* top of clipping region */ | 499 y = this->screen->h - rects->y; /* top of clipping region */ |
499 _kernel_oswrch(24); /* Set graphics clip region */ | 500 _kernel_oswrch (24); /* Set graphics clip region */ |
500 _kernel_oswrch((rects->x << this->hidden->xeig) & 0xFF); /* left */ | 501 _kernel_oswrch ((rects->x << this->hidden->xeig) & 0xFF); /* left */ |
501 _kernel_oswrch(((rects->x << this->hidden->xeig) >> 8) & 0xFF); | 502 _kernel_oswrch (((rects->x << this->hidden->xeig) >> 8) & 0xFF); |
502 _kernel_oswrch(((y - rects->h) << this->hidden->yeig) & 0xFF); /* bottom */ | 503 _kernel_oswrch (((y - rects->h) << this->hidden->yeig) & 0xFF); /* bottom */ |
503 _kernel_oswrch((((y - rects->h) << this->hidden->yeig)>> 8) & 0xFF); | 504 _kernel_oswrch ((((y - rects->h) << this->hidden->yeig) >> 8) & 0xFF); |
504 _kernel_oswrch(((rects->x + rects->w - 1) << this->hidden->xeig) & 0xFF); /* right */ | 505 _kernel_oswrch (((rects->x + rects->w - 1) << this->hidden->xeig) & 0xFF); /* right */ |
505 _kernel_oswrch((((rects->x + rects->w - 1)<< this->hidden->xeig) >> 8) & 0xFF); | 506 _kernel_oswrch ((((rects->x + rects->w - |
506 _kernel_oswrch(((y-1) << this->hidden->yeig) & 0xFF); /* top */ | 507 1) << this->hidden->xeig) >> 8) & 0xFF); |
507 _kernel_oswrch((((y-1) << this->hidden->yeig) >> 8) & 0xFF); | 508 _kernel_oswrch (((y - 1) << this->hidden->yeig) & 0xFF); /* top */ |
508 | 509 _kernel_oswrch ((((y - 1) << this->hidden->yeig) >> 8) & 0xFF); |
509 regs.r[3] = 0; | 510 |
510 regs.r[4] = 0; | 511 regs.r[3] = 0; |
511 | 512 regs.r[4] = 0; |
512 if ((err = _kernel_swi(OS_SpriteOp, ®s, ®s)) != 0) | 513 |
513 { | 514 if ((err = _kernel_swi (OS_SpriteOp, ®s, ®s)) != 0) { |
514 printf("OS_SpriteOp failed \n%s\n",err->errmess); | 515 printf ("OS_SpriteOp failed \n%s\n", err->errmess); |
515 } | 516 } |
516 | 517 |
517 rects++; | 518 rects++; |
518 | 519 |
519 /* Reset to full screen clipping */ | 520 /* Reset to full screen clipping */ |
520 _kernel_oswrch(24); /* Set graphics clip region */ | 521 _kernel_oswrch (24); /* Set graphics clip region */ |
521 _kernel_oswrch(0); /* left */ | 522 _kernel_oswrch (0); /* left */ |
522 _kernel_oswrch(0); | 523 _kernel_oswrch (0); |
523 _kernel_oswrch(0); /* bottom */ | 524 _kernel_oswrch (0); /* bottom */ |
524 _kernel_oswrch(0); | 525 _kernel_oswrch (0); |
525 _kernel_oswrch(((this->screen->w-1) << this->hidden->xeig) & 0xFF); /* right */ | 526 _kernel_oswrch (((this->screen->w - 1) << this->hidden->xeig) & 0xFF); /* right */ |
526 _kernel_oswrch((((this->screen->w-1) << this->hidden->xeig) >> 8) & 0xFF); | 527 _kernel_oswrch ((((this->screen->w - |
527 _kernel_oswrch(((this->screen->h-1) << this->hidden->yeig) & 0xFF); /* top */ | 528 1) << this->hidden->xeig) >> 8) & 0xFF); |
528 _kernel_oswrch((((this->screen->h-1) << this->hidden->yeig) >> 8) & 0xFF); | 529 _kernel_oswrch (((this->screen->h - 1) << this->hidden->yeig) & 0xFF); /* top */ |
529 } | 530 _kernel_oswrch ((((this->screen->h - |
530 } | 531 1) << this->hidden->yeig) >> 8) & 0xFF); |
531 | 532 } |
532 | 533 } |
533 int FULLSCREEN_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors) | 534 |
534 { | 535 |
535 _kernel_swi_regs regs; | 536 int |
536 int palette[256]; | 537 FULLSCREEN_SetColors (_THIS, int firstcolor, int ncolors, SDL_Color * colors) |
537 | 538 { |
538 regs.r[0] = -1; | 539 _kernel_swi_regs regs; |
539 regs.r[1] = -1; | 540 int palette[256]; |
540 regs.r[2] = (int)palette; | 541 |
541 regs.r[3] = 1024; | 542 regs.r[0] = -1; |
542 regs.r[4] = 0; | 543 regs.r[1] = -1; |
543 _kernel_swi(ColourTrans_ReadPalette, ®s, ®s); | 544 regs.r[2] = (int) palette; |
544 | 545 regs.r[3] = 1024; |
545 while(ncolors--) | 546 regs.r[4] = 0; |
546 { | 547 _kernel_swi (ColourTrans_ReadPalette, ®s, ®s); |
547 palette[firstcolor] = ((colors->b) << 24) | ((colors->g) << 16) | ((colors->r) << 8); | 548 |
548 firstcolor++; | 549 while (ncolors--) { |
549 colors++; | 550 palette[firstcolor] = |
550 } | 551 ((colors->b) << 24) | ((colors->g) << 16) | ((colors->r) << 8); |
551 | 552 firstcolor++; |
552 regs.r[0] = -1; | 553 colors++; |
553 regs.r[1] = -1; | 554 } |
554 regs.r[2] = (int)palette; | 555 |
555 regs.r[3] = 0; | 556 regs.r[0] = -1; |
556 regs.r[4] = 0; | 557 regs.r[1] = -1; |
557 _kernel_swi(ColourTrans_WritePalette, ®s, ®s); | 558 regs.r[2] = (int) palette; |
558 | 559 regs.r[3] = 0; |
559 return(1); | 560 regs.r[4] = 0; |
560 } | 561 _kernel_swi (ColourTrans_WritePalette, ®s, ®s); |
561 | 562 |
562 | 563 return (1); |
563 static int cmpmodes(const void *va, const void *vb) | 564 } |
564 { | 565 |
565 SDL_Rect *a = *(SDL_Rect **)va; | 566 |
566 SDL_Rect *b = *(SDL_Rect **)vb; | 567 static int |
567 if(a->w == b->w) | 568 cmpmodes (const void *va, const void *vb) |
569 { | |
570 SDL_Rect *a = *(SDL_Rect **) va; | |
571 SDL_Rect *b = *(SDL_Rect **) vb; | |
572 if (a->w == b->w) | |
568 return b->h - a->h; | 573 return b->h - a->h; |
569 else | 574 else |
570 return b->w - a->w; | 575 return b->w - a->w; |
571 } | 576 } |
572 | 577 |
573 static int FULLSCREEN_AddMode(_THIS, int bpp, int w, int h) | 578 static int |
574 { | 579 FULLSCREEN_AddMode (_THIS, int bpp, int w, int h) |
575 SDL_Rect *mode; | 580 { |
576 int i, index; | 581 SDL_Rect *mode; |
577 int next_mode; | 582 int i, index; |
578 | 583 int next_mode; |
579 /* Check to see if we already have this mode */ | 584 |
580 if ( bpp < 8 ) { /* Not supported */ | 585 /* Check to see if we already have this mode */ |
581 return(0); | 586 if (bpp < 8) { /* Not supported */ |
582 } | 587 return (0); |
583 index = ((bpp+7)/8)-1; | 588 } |
584 for ( i=0; i<SDL_nummodes[index]; ++i ) { | 589 index = ((bpp + 7) / 8) - 1; |
585 mode = SDL_modelist[index][i]; | 590 for (i = 0; i < SDL_nummodes[index]; ++i) { |
586 if ( (mode->w == w) && (mode->h == h) ) { | 591 mode = SDL_modelist[index][i]; |
587 return(0); | 592 if ((mode->w == w) && (mode->h == h)) { |
588 } | 593 return (0); |
589 } | 594 } |
590 | 595 } |
591 /* Set up the new video mode rectangle */ | 596 |
592 mode = (SDL_Rect *)SDL_malloc(sizeof *mode); | 597 /* Set up the new video mode rectangle */ |
593 if ( mode == NULL ) { | 598 mode = (SDL_Rect *) SDL_malloc (sizeof *mode); |
594 SDL_OutOfMemory(); | 599 if (mode == NULL) { |
595 return(-1); | 600 SDL_OutOfMemory (); |
596 } | 601 return (-1); |
597 mode->x = 0; | 602 } |
598 mode->y = 0; | 603 mode->x = 0; |
599 mode->w = w; | 604 mode->y = 0; |
600 mode->h = h; | 605 mode->w = w; |
601 | 606 mode->h = h; |
602 /* Allocate the new list of modes, and fill in the new mode */ | 607 |
603 next_mode = SDL_nummodes[index]; | 608 /* Allocate the new list of modes, and fill in the new mode */ |
604 SDL_modelist[index] = (SDL_Rect **) | 609 next_mode = SDL_nummodes[index]; |
605 SDL_realloc(SDL_modelist[index], (1+next_mode+1)*sizeof(SDL_Rect *)); | 610 SDL_modelist[index] = (SDL_Rect **) |
606 if ( SDL_modelist[index] == NULL ) { | 611 SDL_realloc (SDL_modelist[index], |
607 SDL_OutOfMemory(); | 612 (1 + next_mode + 1) * sizeof (SDL_Rect *)); |
608 SDL_nummodes[index] = 0; | 613 if (SDL_modelist[index] == NULL) { |
609 SDL_free(mode); | 614 SDL_OutOfMemory (); |
610 return(-1); | 615 SDL_nummodes[index] = 0; |
611 } | 616 SDL_free (mode); |
612 SDL_modelist[index][next_mode] = mode; | 617 return (-1); |
613 SDL_modelist[index][next_mode+1] = NULL; | 618 } |
614 SDL_nummodes[index]++; | 619 SDL_modelist[index][next_mode] = mode; |
615 | 620 SDL_modelist[index][next_mode + 1] = NULL; |
616 return(0); | 621 SDL_nummodes[index]++; |
617 } | 622 |
618 | 623 return (0); |
619 void FULLSCREEN_SetWriteBank(int bank) | 624 } |
620 { | 625 |
621 _kernel_swi_regs regs; | 626 void |
622 regs.r[0] = 112; | 627 FULLSCREEN_SetWriteBank (int bank) |
623 regs.r[1] = bank+1; | 628 { |
624 _kernel_swi(OS_Byte, ®s, ®s); | 629 _kernel_swi_regs regs; |
625 } | 630 regs.r[0] = 112; |
626 | 631 regs.r[1] = bank + 1; |
627 void FULLSCREEN_SetDisplayBank(int bank) | 632 _kernel_swi (OS_Byte, ®s, ®s); |
628 { | 633 } |
629 _kernel_swi_regs regs; | 634 |
630 regs.r[0] = 113; | 635 void |
631 regs.r[1] = bank+1; | 636 FULLSCREEN_SetDisplayBank (int bank) |
632 _kernel_swi(OS_Byte, ®s, ®s); | 637 { |
638 _kernel_swi_regs regs; | |
639 regs.r[0] = 113; | |
640 regs.r[1] = bank + 1; | |
641 _kernel_swi (OS_Byte, ®s, ®s); | |
633 } | 642 } |
634 | 643 |
635 | 644 |
636 /** Disable special escape key processing */ | 645 /** Disable special escape key processing */ |
637 static void FULLSCREEN_DisableEscape() | 646 static void |
638 { | 647 FULLSCREEN_DisableEscape () |
639 _kernel_swi_regs regs; | 648 { |
640 regs.r[0] = 229; | 649 _kernel_swi_regs regs; |
641 regs.r[1] = 1; | 650 regs.r[0] = 229; |
642 regs.r[2] = 0; | 651 regs.r[1] = 1; |
643 _kernel_swi(OS_Byte, ®s, ®s); | 652 regs.r[2] = 0; |
644 | 653 _kernel_swi (OS_Byte, ®s, ®s); |
654 | |
645 } | 655 } |
646 | 656 |
647 /** Enable special escape key processing */ | 657 /** Enable special escape key processing */ |
648 static void FULLSCREEN_EnableEscape() | 658 static void |
649 { | 659 FULLSCREEN_EnableEscape () |
650 _kernel_swi_regs regs; | 660 { |
651 regs.r[0] = 229; | 661 _kernel_swi_regs regs; |
652 regs.r[1] = 0; | 662 regs.r[0] = 229; |
653 regs.r[2] = 0; | 663 regs.r[1] = 0; |
654 _kernel_swi(OS_Byte, ®s, ®s); | 664 regs.r[2] = 0; |
655 | 665 _kernel_swi (OS_Byte, ®s, ®s); |
666 | |
656 } | 667 } |
657 | 668 |
658 /** Store caption in case this is called before we create a window */ | 669 /** Store caption in case this is called before we create a window */ |
659 void FULLSCREEN_SetWMCaption(_THIS, const char *title, const char *icon) | 670 void |
660 { | 671 FULLSCREEN_SetWMCaption (_THIS, const char *title, const char *icon) |
661 SDL_strlcpy(this->hidden->title, title, SDL_arraysize(this->hidden->title)); | 672 { |
673 SDL_strlcpy (this->hidden->title, title, | |
674 SDL_arraysize (this->hidden->title)); | |
662 } | 675 } |
663 | 676 |
664 /* Set screen mode | 677 /* Set screen mode |
665 * | 678 * |
666 * Returns 1 if mode is set ok, otherwise 0 | 679 * Returns 1 if mode is set ok, otherwise 0 |
667 */ | 680 */ |
668 | 681 |
669 int FULLSCREEN_SetMode(int width, int height, int bpp) | 682 int |
670 { | 683 FULLSCREEN_SetMode (int width, int height, int bpp) |
671 SCREENMODEBLOCK smb; | 684 { |
672 _kernel_swi_regs regs; | 685 SCREENMODEBLOCK smb; |
673 | 686 _kernel_swi_regs regs; |
674 smb.flags = 1; | 687 |
675 smb.x_pixels = width; | 688 smb.flags = 1; |
676 smb.y_pixels = height; | 689 smb.x_pixels = width; |
677 smb.mode_vars[0] = -1; | 690 smb.y_pixels = height; |
678 | 691 smb.mode_vars[0] = -1; |
679 switch(bpp) | 692 |
680 { | 693 switch (bpp) { |
681 case 8: | 694 case 8: |
682 smb.pixel_depth = 3; | 695 smb.pixel_depth = 3; |
683 /* Note: Need to set ModeFlags to 128 and NColour variables to 255 get full 8 bit palette */ | 696 /* Note: Need to set ModeFlags to 128 and NColour variables to 255 get full 8 bit palette */ |
684 smb.mode_vars[0] = 0; smb.mode_vars[1] = 128; /* Mode flags */ | 697 smb.mode_vars[0] = 0; |
685 smb.mode_vars[2] = 3; smb.mode_vars[3] = 255; /* NColour (number of colours -1) */ | 698 smb.mode_vars[1] = 128; /* Mode flags */ |
686 smb.mode_vars[4] = -1; /* End of list */ | 699 smb.mode_vars[2] = 3; |
687 break; | 700 smb.mode_vars[3] = 255; /* NColour (number of colours -1) */ |
688 | 701 smb.mode_vars[4] = -1; /* End of list */ |
689 case 15: | 702 break; |
690 case 16: | 703 |
691 smb.pixel_depth = 4; | 704 case 15: |
692 break; | 705 case 16: |
693 | 706 smb.pixel_depth = 4; |
694 case 32: | 707 break; |
695 smb.pixel_depth = 5; | 708 |
696 break; | 709 case 32: |
697 | 710 smb.pixel_depth = 5; |
698 default: | 711 break; |
699 SDL_SetError("Pixel depth not supported"); | 712 |
700 return 0; | 713 default: |
701 break; | 714 SDL_SetError ("Pixel depth not supported"); |
702 } | 715 return 0; |
703 | 716 break; |
704 smb.frame_rate = -1; | 717 } |
705 | 718 |
706 regs.r[0] = 0; | 719 smb.frame_rate = -1; |
707 regs.r[1] = (int)&smb; | 720 |
708 | 721 regs.r[0] = 0; |
709 if (_kernel_swi(OS_ScreenMode, ®s, ®s) != 0) | 722 regs.r[1] = (int) &smb; |
710 { | 723 |
711 SDL_SetError("Couldn't set requested mode"); | 724 if (_kernel_swi (OS_ScreenMode, ®s, ®s) != 0) { |
712 return 0; | 725 SDL_SetError ("Couldn't set requested mode"); |
713 } | 726 return 0; |
714 | 727 } |
715 /* Turn cursor off*/ | 728 |
716 _kernel_oswrch(23);_kernel_oswrch(1);_kernel_oswrch(0); | 729 /* Turn cursor off */ |
717 _kernel_oswrch(0);_kernel_oswrch(0);_kernel_oswrch(0); | 730 _kernel_oswrch (23); |
718 _kernel_oswrch(0);_kernel_oswrch(0);_kernel_oswrch(0); | 731 _kernel_oswrch (1); |
719 _kernel_oswrch(0);_kernel_oswrch(0); | 732 _kernel_oswrch (0); |
720 | 733 _kernel_oswrch (0); |
721 return 1; | 734 _kernel_oswrch (0); |
735 _kernel_oswrch (0); | |
736 _kernel_oswrch (0); | |
737 _kernel_oswrch (0); | |
738 _kernel_oswrch (0); | |
739 _kernel_oswrch (0); | |
740 _kernel_oswrch (0); | |
741 | |
742 return 1; | |
722 } | 743 } |
723 | 744 |
724 /* Get Start addresses for the screen banks */ | 745 /* Get Start addresses for the screen banks */ |
725 void FULLSCREEN_SetupBanks(_THIS) | 746 void |
726 { | 747 FULLSCREEN_SetupBanks (_THIS) |
727 _kernel_swi_regs regs; | 748 { |
728 int block[5]; | 749 _kernel_swi_regs regs; |
729 block[0] = 148; /* Write screen start */ | 750 int block[5]; |
730 block[1] = 149; /* Display screen start */ | 751 block[0] = 148; /* Write screen start */ |
731 block[2] = 4; /* X eig factor */ | 752 block[1] = 149; /* Display screen start */ |
732 block[3] = 5; /* Y eig factor */ | 753 block[2] = 4; /* X eig factor */ |
733 block[4] = -1; /* End of list of variables to request */ | 754 block[3] = 5; /* Y eig factor */ |
734 | 755 block[4] = -1; /* End of list of variables to request */ |
735 regs.r[0] = (int)block; | 756 |
736 regs.r[1] = (int)block; | 757 regs.r[0] = (int) block; |
737 _kernel_swi(OS_ReadVduVariables, ®s, ®s); | 758 regs.r[1] = (int) block; |
738 | 759 _kernel_swi (OS_ReadVduVariables, ®s, ®s); |
739 this->hidden->bank[0] = (void *)block[0]; | 760 |
740 this->hidden->bank[1] = (void *)block[1]; | 761 this->hidden->bank[0] = (void *) block[0]; |
741 this->hidden->xeig = block[2]; | 762 this->hidden->bank[1] = (void *) block[1]; |
742 this->hidden->yeig = block[3]; | 763 this->hidden->xeig = block[2]; |
764 this->hidden->yeig = block[3]; | |
743 } | 765 } |
744 | 766 |
745 /* Toggle to full screen mode from the WIMP */ | 767 /* Toggle to full screen mode from the WIMP */ |
746 | 768 |
747 int FULLSCREEN_ToggleFromWimp(_THIS) | 769 int |
748 { | 770 FULLSCREEN_ToggleFromWimp (_THIS) |
749 int width = this->screen->w; | 771 { |
750 int height = this->screen->h; | 772 int width = this->screen->w; |
751 int bpp = this->screen->format->BitsPerPixel; | 773 int height = this->screen->h; |
752 | 774 int bpp = this->screen->format->BitsPerPixel; |
753 RISCOS_StoreWimpMode(); | 775 |
754 if (FULLSCREEN_SetMode(width, height, bpp)) | 776 RISCOS_StoreWimpMode (); |
755 { | 777 if (FULLSCREEN_SetMode (width, height, bpp)) { |
756 char *buffer = this->hidden->alloc_bank; /* This is start of sprite data */ | 778 char *buffer = this->hidden->alloc_bank; /* This is start of sprite data */ |
757 /* Support back buffer mode only */ | 779 /* Support back buffer mode only */ |
758 if (riscos_backbuffer == 0) riscos_backbuffer = 1; | 780 if (riscos_backbuffer == 0) |
759 | 781 riscos_backbuffer = 1; |
760 FULLSCREEN_SetupBanks(this); | 782 |
761 | 783 FULLSCREEN_SetupBanks (this); |
762 this->hidden->bank[0] = buffer + 60; /* Start of sprite data */ | 784 |
763 if (bpp == 8) this->hidden->bank[0] += 2048; /* 8bpp sprite have palette first */ | 785 this->hidden->bank[0] = buffer + 60; /* Start of sprite data */ |
764 | 786 if (bpp == 8) |
765 this->hidden->current_bank = 0; | 787 this->hidden->bank[0] += 2048; /* 8bpp sprite have palette first */ |
766 this->screen->pixels = this->hidden->bank[0]; | 788 |
767 | 789 this->hidden->current_bank = 0; |
768 /* Copy back buffer to screen memory */ | 790 this->screen->pixels = this->hidden->bank[0]; |
769 SDL_memcpy(this->hidden->bank[1], this->hidden->bank[0], width * height * this->screen->format->BytesPerPixel); | 791 |
770 | 792 /* Copy back buffer to screen memory */ |
771 FULLSCREEN_SetDeviceMode(this); | 793 SDL_memcpy (this->hidden->bank[1], this->hidden->bank[0], |
772 return 1; | 794 width * height * this->screen->format->BytesPerPixel); |
773 } else | 795 |
774 RISCOS_RestoreWimpMode(); | 796 FULLSCREEN_SetDeviceMode (this); |
775 | 797 return 1; |
776 return 0; | 798 } else |
777 } | 799 RISCOS_RestoreWimpMode (); |
800 | |
801 return 0; | |
802 } | |
803 | |
804 /* vi: set ts=4 sw=4 expandtab: */ |