comparison src/video/wscons/SDL_wsconsvideo.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
49 }; 49 };
50 50
51 #define min(a,b) ((a)<(b)?(a):(b)) 51 #define min(a,b) ((a)<(b)?(a):(b))
52 52
53 /* Initialization/Query functions */ 53 /* Initialization/Query functions */
54 static int WSCONS_VideoInit (_THIS, SDL_PixelFormat * vformat); 54 static int WSCONS_VideoInit(_THIS, SDL_PixelFormat * vformat);
55 static SDL_Rect **WSCONS_ListModes (_THIS, SDL_PixelFormat * format, 55 static SDL_Rect **WSCONS_ListModes(_THIS, SDL_PixelFormat * format,
56 Uint32 flags); 56 Uint32 flags);
57 static SDL_Surface *WSCONS_SetVideoMode (_THIS, SDL_Surface * current, 57 static SDL_Surface *WSCONS_SetVideoMode(_THIS, SDL_Surface * current,
58 int width, int height, int bpp, 58 int width, int height, int bpp,
59 Uint32 flags); 59 Uint32 flags);
60 static int WSCONS_SetColors (_THIS, int firstcolor, int ncolors, 60 static int WSCONS_SetColors(_THIS, int firstcolor, int ncolors,
61 SDL_Color * colors); 61 SDL_Color * colors);
62 static void WSCONS_VideoQuit (_THIS); 62 static void WSCONS_VideoQuit(_THIS);
63 63
64 /* Hardware surface functions */ 64 /* Hardware surface functions */
65 static int WSCONS_AllocHWSurface (_THIS, SDL_Surface * surface); 65 static int WSCONS_AllocHWSurface(_THIS, SDL_Surface * surface);
66 static int WSCONS_LockHWSurface (_THIS, SDL_Surface * surface); 66 static int WSCONS_LockHWSurface(_THIS, SDL_Surface * surface);
67 static void WSCONS_UnlockHWSurface (_THIS, SDL_Surface * surface); 67 static void WSCONS_UnlockHWSurface(_THIS, SDL_Surface * surface);
68 static void WSCONS_FreeHWSurface (_THIS, SDL_Surface * surface); 68 static void WSCONS_FreeHWSurface(_THIS, SDL_Surface * surface);
69 69
70 /* etc. */ 70 /* etc. */
71 static WSCONS_bitBlit WSCONS_blit16; 71 static WSCONS_bitBlit WSCONS_blit16;
72 static WSCONS_bitBlit WSCONS_blit16blocked; 72 static WSCONS_bitBlit WSCONS_blit16blocked;
73 static void WSCONS_UpdateRects (_THIS, int numrects, SDL_Rect * rects); 73 static void WSCONS_UpdateRects(_THIS, int numrects, SDL_Rect * rects);
74 74
75 void 75 void
76 WSCONS_ReportError (char *fmt, ...) 76 WSCONS_ReportError(char *fmt, ...)
77 { 77 {
78 char message[200]; 78 char message[200];
79 va_list vaArgs; 79 va_list vaArgs;
80 80
81 message[199] = '\0'; 81 message[199] = '\0';
82 82
83 va_start (vaArgs, fmt); 83 va_start(vaArgs, fmt);
84 vsnprintf (message, 199, fmt, vaArgs); 84 vsnprintf(message, 199, fmt, vaArgs);
85 va_end (vaArgs); 85 va_end(vaArgs);
86 86
87 SDL_SetError (message); 87 SDL_SetError(message);
88 fprintf (stderr, "WSCONS error: %s\n", message); 88 fprintf(stderr, "WSCONS error: %s\n", message);
89 } 89 }
90 90
91 /* WSCONS driver bootstrap functions */ 91 /* WSCONS driver bootstrap functions */
92 92
93 static int 93 static int
94 WSCONS_Available (void) 94 WSCONS_Available(void)
95 { 95 {
96 return 1; 96 return 1;
97 } 97 }
98 98
99 static void 99 static void
100 WSCONS_DeleteDevice (SDL_VideoDevice * device) 100 WSCONS_DeleteDevice(SDL_VideoDevice * device)
101 { 101 {
102 SDL_free (device->hidden); 102 SDL_free(device->hidden);
103 SDL_free (device); 103 SDL_free(device);
104 } 104 }
105 105
106 static SDL_VideoDevice * 106 static SDL_VideoDevice *
107 WSCONS_CreateDevice (int devindex) 107 WSCONS_CreateDevice(int devindex)
108 { 108 {
109 SDL_VideoDevice *device; 109 SDL_VideoDevice *device;
110 110
111 /* Initialize all variables that we clean on shutdown */ 111 /* Initialize all variables that we clean on shutdown */
112 device = (SDL_VideoDevice *) SDL_malloc (sizeof (SDL_VideoDevice)); 112 device = (SDL_VideoDevice *) SDL_malloc(sizeof(SDL_VideoDevice));
113 if (device == NULL) { 113 if (device == NULL) {
114 SDL_OutOfMemory (); 114 SDL_OutOfMemory();
115 return 0; 115 return 0;
116 } 116 }
117 SDL_memset (device, 0, (sizeof *device)); 117 SDL_memset(device, 0, (sizeof *device));
118 device->hidden = 118 device->hidden =
119 (struct SDL_PrivateVideoData *) SDL_malloc ((sizeof *device->hidden)); 119 (struct SDL_PrivateVideoData *) SDL_malloc((sizeof *device->hidden));
120 if (device->hidden == NULL) { 120 if (device->hidden == NULL) {
121 SDL_OutOfMemory (); 121 SDL_OutOfMemory();
122 SDL_free (device); 122 SDL_free(device);
123 return (0); 123 return (0);
124 } 124 }
125 SDL_memset (device->hidden, 0, (sizeof *device->hidden)); 125 SDL_memset(device->hidden, 0, (sizeof *device->hidden));
126 device->hidden->fd = -1; 126 device->hidden->fd = -1;
127 127
128 /* Set the function pointers */ 128 /* Set the function pointers */
129 device->VideoInit = WSCONS_VideoInit; 129 device->VideoInit = WSCONS_VideoInit;
130 device->ListModes = WSCONS_ListModes; 130 device->ListModes = WSCONS_ListModes;
151 }; 151 };
152 152
153 #define WSCONSDEV_FORMAT "/dev/ttyC%01x" 153 #define WSCONSDEV_FORMAT "/dev/ttyC%01x"
154 154
155 int 155 int
156 WSCONS_VideoInit (_THIS, SDL_PixelFormat * vformat) 156 WSCONS_VideoInit(_THIS, SDL_PixelFormat * vformat)
157 { 157 {
158 char devnamebuf[30]; 158 char devnamebuf[30];
159 char *devname; 159 char *devname;
160 char *rotation; 160 char *rotation;
161 int wstype; 161 int wstype;
162 int wsmode = WSDISPLAYIO_MODE_DUMBFB; 162 int wsmode = WSDISPLAYIO_MODE_DUMBFB;
163 size_t len, mapsize; 163 size_t len, mapsize;
164 int pagemask; 164 int pagemask;
165 int width, height; 165 int width, height;
166 166
167 devname = SDL_getenv ("SDL_WSCONSDEV"); 167 devname = SDL_getenv("SDL_WSCONSDEV");
168 if (devname == NULL) { 168 if (devname == NULL) {
169 int activeVT; 169 int activeVT;
170 if (ioctl (STDIN_FILENO, VT_GETACTIVE, &activeVT) == -1) { 170 if (ioctl(STDIN_FILENO, VT_GETACTIVE, &activeVT) == -1) {
171 WSCONS_ReportError ("Unable to determine active terminal: %s", 171 WSCONS_ReportError("Unable to determine active terminal: %s",
172 strerror (errno)); 172 strerror(errno));
173 return -1; 173 return -1;
174 } 174 }
175 SDL_snprintf (devnamebuf, sizeof (devnamebuf), WSCONSDEV_FORMAT, 175 SDL_snprintf(devnamebuf, sizeof(devnamebuf), WSCONSDEV_FORMAT,
176 activeVT - 1); 176 activeVT - 1);
177 devname = devnamebuf; 177 devname = devnamebuf;
178 } 178 }
179 179
180 private->fd = open (devname, O_RDWR | O_NONBLOCK, 0); 180 private->fd = open(devname, O_RDWR | O_NONBLOCK, 0);
181 if (private->fd == -1) { 181 if (private->fd == -1) {
182 WSCONS_ReportError ("open %s: %s", devname, strerror (errno)); 182 WSCONS_ReportError("open %s: %s", devname, strerror(errno));
183 return -1; 183 return -1;
184 } 184 }
185 if (ioctl (private->fd, WSDISPLAYIO_GINFO, &private->info) == -1) { 185 if (ioctl(private->fd, WSDISPLAYIO_GINFO, &private->info) == -1) {
186 WSCONS_ReportError ("ioctl WSDISPLAY_GINFO: %s", strerror (errno)); 186 WSCONS_ReportError("ioctl WSDISPLAY_GINFO: %s", strerror(errno));
187 return -1; 187 return -1;
188 } 188 }
189 if (ioctl (private->fd, WSDISPLAYIO_GTYPE, &wstype) == -1) { 189 if (ioctl(private->fd, WSDISPLAYIO_GTYPE, &wstype) == -1) {
190 WSCONS_ReportError ("ioctl WSDISPLAY_GTYPE: %s", strerror (errno)); 190 WSCONS_ReportError("ioctl WSDISPLAY_GTYPE: %s", strerror(errno));
191 return -1; 191 return -1;
192 } 192 }
193 if (ioctl (private->fd, WSDISPLAYIO_LINEBYTES, &private->physlinebytes) == 193 if (ioctl(private->fd, WSDISPLAYIO_LINEBYTES, &private->physlinebytes) ==
194 -1) { 194 -1) {
195 WSCONS_ReportError ("ioctl WSDISPLAYIO_LINEBYTES: %s", 195 WSCONS_ReportError("ioctl WSDISPLAYIO_LINEBYTES: %s",
196 strerror (errno)); 196 strerror(errno));
197 return -1; 197 return -1;
198 } 198 }
199 if (private->info.depth > 8) { 199 if (private->info.depth > 8) {
200 if (wstype == WSDISPLAY_TYPE_SUN24 || 200 if (wstype == WSDISPLAY_TYPE_SUN24 ||
201 wstype == WSDISPLAY_TYPE_SUNCG12 || 201 wstype == WSDISPLAY_TYPE_SUNCG12 ||
210 private->redMask = 0x1f << 11; 210 private->redMask = 0x1f << 11;
211 private->greenMask = 0x3f << 5; 211 private->greenMask = 0x3f << 5;
212 private->blueMask = 0x1f; 212 private->blueMask = 0x1f;
213 #endif 213 #endif
214 } else { 214 } else {
215 WSCONS_ReportError ("Unknown video hardware"); 215 WSCONS_ReportError("Unknown video hardware");
216 return -1; 216 return -1;
217 } 217 }
218 } else { 218 } else {
219 WSCONS_ReportError ("Displays with 8 bpp or less are not supported"); 219 WSCONS_ReportError("Displays with 8 bpp or less are not supported");
220 return -1; 220 return -1;
221 } 221 }
222 222
223 private->rotate = WSCONS_ROTATE_NONE; 223 private->rotate = WSCONS_ROTATE_NONE;
224 rotation = SDL_getenv ("SDL_VIDEO_WSCONS_ROTATION"); 224 rotation = SDL_getenv("SDL_VIDEO_WSCONS_ROTATION");
225 if (rotation != NULL) { 225 if (rotation != NULL) {
226 if (SDL_strlen (rotation) == 0) { 226 if (SDL_strlen(rotation) == 0) {
227 private->shadowFB = 0; 227 private->shadowFB = 0;
228 private->rotate = WSCONS_ROTATE_NONE; 228 private->rotate = WSCONS_ROTATE_NONE;
229 printf ("Not rotating, no shadow\n"); 229 printf("Not rotating, no shadow\n");
230 } else if (!SDL_strcmp (rotation, "NONE")) { 230 } else if (!SDL_strcmp(rotation, "NONE")) {
231 private->shadowFB = 1; 231 private->shadowFB = 1;
232 private->rotate = WSCONS_ROTATE_NONE; 232 private->rotate = WSCONS_ROTATE_NONE;
233 printf ("Not rotating, but still using shadow\n"); 233 printf("Not rotating, but still using shadow\n");
234 } else if (!SDL_strcmp (rotation, "CW")) { 234 } else if (!SDL_strcmp(rotation, "CW")) {
235 private->shadowFB = 1; 235 private->shadowFB = 1;
236 private->rotate = WSCONS_ROTATE_CW; 236 private->rotate = WSCONS_ROTATE_CW;
237 printf ("Rotating screen clockwise\n"); 237 printf("Rotating screen clockwise\n");
238 } else if (!SDL_strcmp (rotation, "CCW")) { 238 } else if (!SDL_strcmp(rotation, "CCW")) {
239 private->shadowFB = 1; 239 private->shadowFB = 1;
240 private->rotate = WSCONS_ROTATE_CCW; 240 private->rotate = WSCONS_ROTATE_CCW;
241 printf ("Rotating screen counter clockwise\n"); 241 printf("Rotating screen counter clockwise\n");
242 } else if (!SDL_strcmp (rotation, "UD")) { 242 } else if (!SDL_strcmp(rotation, "UD")) {
243 private->shadowFB = 1; 243 private->shadowFB = 1;
244 private->rotate = WSCONS_ROTATE_UD; 244 private->rotate = WSCONS_ROTATE_UD;
245 printf ("Rotating screen upside down\n"); 245 printf("Rotating screen upside down\n");
246 } else { 246 } else {
247 WSCONS_ReportError ("\"%s\" is not a valid value for " 247 WSCONS_ReportError("\"%s\" is not a valid value for "
248 "SDL_VIDEO_WSCONS_ROTATION", rotation); 248 "SDL_VIDEO_WSCONS_ROTATION", rotation);
249 return -1; 249 return -1;
250 } 250 }
251 } 251 }
252 252
253 switch (private->info.depth) { 253 switch (private->info.depth) {
256 case 8: 256 case 8:
257 len = private->physlinebytes * private->info.height; 257 len = private->physlinebytes * private->info.height;
258 break; 258 break;
259 case 16: 259 case 16:
260 if (private->physlinebytes == private->info.width) { 260 if (private->physlinebytes == private->info.width) {
261 len = private->info.width * private->info.height * sizeof (short); 261 len = private->info.width * private->info.height * sizeof(short);
262 } else { 262 } else {
263 len = private->physlinebytes * private->info.height; 263 len = private->physlinebytes * private->info.height;
264 } 264 }
265 if (private->rotate == WSCONS_ROTATE_NONE || 265 if (private->rotate == WSCONS_ROTATE_NONE ||
266 private->rotate == WSCONS_ROTATE_UD) { 266 private->rotate == WSCONS_ROTATE_UD) {
269 private->blitFunc = WSCONS_blit16blocked; 269 private->blitFunc = WSCONS_blit16blocked;
270 } 270 }
271 break; 271 break;
272 case 32: 272 case 32:
273 if (private->physlinebytes == private->info.width) { 273 if (private->physlinebytes == private->info.width) {
274 len = private->info.width * private->info.height * sizeof (int); 274 len = private->info.width * private->info.height * sizeof(int);
275 } else { 275 } else {
276 len = private->physlinebytes * private->info.height; 276 len = private->physlinebytes * private->info.height;
277 } 277 }
278 break; 278 break;
279 default: 279 default:
280 WSCONS_ReportError ("unsupported depth %d", private->info.depth); 280 WSCONS_ReportError("unsupported depth %d", private->info.depth);
281 return -1; 281 return -1;
282 } 282 }
283 283
284 if (private->shadowFB && private->blitFunc == NULL) { 284 if (private->shadowFB && private->blitFunc == NULL) {
285 WSCONS_ReportError 285 WSCONS_ReportError
286 ("Using software buffer, but no blitter function is " 286 ("Using software buffer, but no blitter function is "
287 "available for this %d bpp.", private->info.depth); 287 "available for this %d bpp.", private->info.depth);
288 return -1; 288 return -1;
289 } 289 }
290 290
291 if (ioctl (private->fd, WSDISPLAYIO_SMODE, &wsmode) == -1) { 291 if (ioctl(private->fd, WSDISPLAYIO_SMODE, &wsmode) == -1) {
292 WSCONS_ReportError ("ioctl SMODE"); 292 WSCONS_ReportError("ioctl SMODE");
293 return -1; 293 return -1;
294 } 294 }
295 295
296 pagemask = getpagesize () - 1; 296 pagemask = getpagesize() - 1;
297 mapsize = ((int) len + pagemask) & ~pagemask; 297 mapsize = ((int) len + pagemask) & ~pagemask;
298 private->physmem = (Uint8 *) mmap (NULL, mapsize, 298 private->physmem = (Uint8 *) mmap(NULL, mapsize,
299 PROT_READ | PROT_WRITE, MAP_SHARED, 299 PROT_READ | PROT_WRITE, MAP_SHARED,
300 private->fd, (off_t) 0); 300 private->fd, (off_t) 0);
301 if (private->physmem == (Uint8 *) MAP_FAILED) { 301 if (private->physmem == (Uint8 *) MAP_FAILED) {
302 private->physmem = NULL; 302 private->physmem = NULL;
303 WSCONS_ReportError ("mmap: %s", strerror (errno)); 303 WSCONS_ReportError("mmap: %s", strerror(errno));
304 return -1; 304 return -1;
305 } 305 }
306 private->fbmem_len = len; 306 private->fbmem_len = len;
307 307
308 if (private->rotate == WSCONS_ROTATE_CW || 308 if (private->rotate == WSCONS_ROTATE_CW ||
316 316
317 this->info.current_w = width; 317 this->info.current_w = width;
318 this->info.current_h = height; 318 this->info.current_h = height;
319 319
320 if (private->shadowFB) { 320 if (private->shadowFB) {
321 private->shadowmem = (Uint8 *) SDL_malloc (len); 321 private->shadowmem = (Uint8 *) SDL_malloc(len);
322 if (private->shadowmem == NULL) { 322 if (private->shadowmem == NULL) {
323 WSCONS_ReportError ("No memory for shadow"); 323 WSCONS_ReportError("No memory for shadow");
324 return -1; 324 return -1;
325 } 325 }
326 private->fbstart = private->shadowmem; 326 private->fbstart = private->shadowmem;
327 private->fblinebytes = width * ((private->info.depth + 7) / 8); 327 private->fblinebytes = width * ((private->info.depth + 7) / 8);
328 } else { 328 } else {
329 private->fbstart = private->physmem; 329 private->fbstart = private->physmem;
330 private->fblinebytes = private->physlinebytes; 330 private->fblinebytes = private->physlinebytes;
331 } 331 }
332 332
333 private->SDL_modelist[0] = (SDL_Rect *) SDL_malloc (sizeof (SDL_Rect)); 333 private->SDL_modelist[0] = (SDL_Rect *) SDL_malloc(sizeof(SDL_Rect));
334 private->SDL_modelist[0]->w = width; 334 private->SDL_modelist[0]->w = width;
335 private->SDL_modelist[0]->h = height; 335 private->SDL_modelist[0]->h = height;
336 336
337 vformat->BitsPerPixel = private->info.depth; 337 vformat->BitsPerPixel = private->info.depth;
338 vformat->BytesPerPixel = private->info.depth / 8; 338 vformat->BytesPerPixel = private->info.depth / 8;
339 339
340 if (WSCONS_InitKeyboard (this) == -1) { 340 if (WSCONS_InitKeyboard(this) == -1) {
341 return -1; 341 return -1;
342 } 342 }
343 343
344 return 0; 344 return 0;
345 } 345 }
346 346
347 SDL_Rect ** 347 SDL_Rect **
348 WSCONS_ListModes (_THIS, SDL_PixelFormat * format, Uint32 flags) 348 WSCONS_ListModes(_THIS, SDL_PixelFormat * format, Uint32 flags)
349 { 349 {
350 if (format->BitsPerPixel == private->info.depth) { 350 if (format->BitsPerPixel == private->info.depth) {
351 return private->SDL_modelist; 351 return private->SDL_modelist;
352 } else { 352 } else {
353 return NULL; 353 return NULL;
354 } 354 }
355 } 355 }
356 356
357 SDL_Surface * 357 SDL_Surface *
358 WSCONS_SetVideoMode (_THIS, SDL_Surface * current, 358 WSCONS_SetVideoMode(_THIS, SDL_Surface * current,
359 int width, int height, int bpp, Uint32 flags) 359 int width, int height, int bpp, Uint32 flags)
360 { 360 {
361 if (width != private->SDL_modelist[0]->w || 361 if (width != private->SDL_modelist[0]->w ||
362 height != private->SDL_modelist[0]->h) { 362 height != private->SDL_modelist[0]->h) {
363 WSCONS_ReportError ("Requested video mode %dx%d not supported.", 363 WSCONS_ReportError("Requested video mode %dx%d not supported.",
364 width, height); 364 width, height);
365 return NULL; 365 return NULL;
366 } 366 }
367 if (bpp != private->info.depth) { 367 if (bpp != private->info.depth) {
368 WSCONS_ReportError ("Requested video depth %d bpp not supported.", 368 WSCONS_ReportError("Requested video depth %d bpp not supported.",
369 bpp); 369 bpp);
370 return NULL; 370 return NULL;
371 } 371 }
372 372
373 if (!SDL_ReallocFormat (current, 373 if (!SDL_ReallocFormat(current,
374 bpp, 374 bpp,
375 private->redMask, 375 private->redMask,
376 private->greenMask, private->blueMask, 0)) { 376 private->greenMask, private->blueMask, 0)) {
377 WSCONS_ReportError ("Couldn't allocate new pixel format"); 377 WSCONS_ReportError("Couldn't allocate new pixel format");
378 return NULL; 378 return NULL;
379 } 379 }
380 380
381 current->flags &= SDL_FULLSCREEN; 381 current->flags &= SDL_FULLSCREEN;
382 if (private->shadowFB) { 382 if (private->shadowFB) {
387 current->w = width; 387 current->w = width;
388 current->h = height; 388 current->h = height;
389 current->pitch = private->fblinebytes; 389 current->pitch = private->fblinebytes;
390 current->pixels = private->fbstart; 390 current->pixels = private->fbstart;
391 391
392 SDL_memset (private->fbstart, 0, private->fbmem_len); 392 SDL_memset(private->fbstart, 0, private->fbmem_len);
393 393
394 return current; 394 return current;
395 } 395 }
396 396
397 static int 397 static int
398 WSCONS_AllocHWSurface (_THIS, SDL_Surface * surface) 398 WSCONS_AllocHWSurface(_THIS, SDL_Surface * surface)
399 { 399 {
400 return -1; 400 return -1;
401 } 401 }
402 static void 402 static void
403 WSCONS_FreeHWSurface (_THIS, SDL_Surface * surface) 403 WSCONS_FreeHWSurface(_THIS, SDL_Surface * surface)
404 { 404 {
405 } 405 }
406 406
407 static int 407 static int
408 WSCONS_LockHWSurface (_THIS, SDL_Surface * surface) 408 WSCONS_LockHWSurface(_THIS, SDL_Surface * surface)
409 { 409 {
410 return 0; 410 return 0;
411 } 411 }
412 412
413 static void 413 static void
414 WSCONS_UnlockHWSurface (_THIS, SDL_Surface * surface) 414 WSCONS_UnlockHWSurface(_THIS, SDL_Surface * surface)
415 { 415 {
416 } 416 }
417 417
418 static void 418 static void
419 WSCONS_blit16 (Uint8 * byte_src_pos, 419 WSCONS_blit16(Uint8 * byte_src_pos,
420 int srcRightDelta, 420 int srcRightDelta,
421 int srcDownDelta, 421 int srcDownDelta,
422 Uint8 * byte_dst_pos, int dst_linebytes, int width, int height) 422 Uint8 * byte_dst_pos, int dst_linebytes, int width, int height)
423 { 423 {
424 int w; 424 int w;
425 Uint16 *src_pos = (Uint16 *) byte_src_pos; 425 Uint16 *src_pos = (Uint16 *) byte_src_pos;
426 Uint16 *dst_pos = (Uint16 *) byte_dst_pos; 426 Uint16 *dst_pos = (Uint16 *) byte_dst_pos;
427 427
441 441
442 #define BLOCKSIZE_W 32 442 #define BLOCKSIZE_W 32
443 #define BLOCKSIZE_H 32 443 #define BLOCKSIZE_H 32
444 444
445 static void 445 static void
446 WSCONS_blit16blocked (Uint8 * byte_src_pos, 446 WSCONS_blit16blocked(Uint8 * byte_src_pos,
447 int srcRightDelta, 447 int srcRightDelta,
448 int srcDownDelta, 448 int srcDownDelta,
449 Uint8 * byte_dst_pos, 449 Uint8 * byte_dst_pos,
450 int dst_linebytes, int width, int height) 450 int dst_linebytes, int width, int height)
451 { 451 {
452 int w; 452 int w;
453 Uint16 *src_pos = (Uint16 *) byte_src_pos; 453 Uint16 *src_pos = (Uint16 *) byte_src_pos;
454 Uint16 *dst_pos = (Uint16 *) byte_dst_pos; 454 Uint16 *dst_pos = (Uint16 *) byte_dst_pos;
455 455
456 while (height > 0) { 456 while (height > 0) {
457 Uint16 *src = src_pos; 457 Uint16 *src = src_pos;
458 Uint16 *dst = dst_pos; 458 Uint16 *dst = dst_pos;
459 for (w = width; w > 0; w -= BLOCKSIZE_W) { 459 for (w = width; w > 0; w -= BLOCKSIZE_W) {
460 WSCONS_blit16 ((Uint8 *) src, 460 WSCONS_blit16((Uint8 *) src,
461 srcRightDelta, 461 srcRightDelta,
462 srcDownDelta, 462 srcDownDelta,
463 (Uint8 *) dst, 463 (Uint8 *) dst,
464 dst_linebytes, 464 dst_linebytes,
465 min (w, BLOCKSIZE_W), min (height, BLOCKSIZE_H)); 465 min(w, BLOCKSIZE_W), min(height, BLOCKSIZE_H));
466 src += srcRightDelta * BLOCKSIZE_W; 466 src += srcRightDelta * BLOCKSIZE_W;
467 dst += BLOCKSIZE_W; 467 dst += BLOCKSIZE_W;
468 } 468 }
469 dst_pos = 469 dst_pos =
470 (Uint16 *) ((Uint8 *) dst_pos + dst_linebytes * BLOCKSIZE_H); 470 (Uint16 *) ((Uint8 *) dst_pos + dst_linebytes * BLOCKSIZE_H);
472 height -= BLOCKSIZE_H; 472 height -= BLOCKSIZE_H;
473 } 473 }
474 } 474 }
475 475
476 static void 476 static void
477 WSCONS_UpdateRects (_THIS, int numrects, SDL_Rect * rects) 477 WSCONS_UpdateRects(_THIS, int numrects, SDL_Rect * rects)
478 { 478 {
479 int width = private->SDL_modelist[0]->w; 479 int width = private->SDL_modelist[0]->w;
480 int height = private->SDL_modelist[0]->h; 480 int height = private->SDL_modelist[0]->h;
481 int bytesPerPixel = (private->info.depth + 7) / 8; 481 int bytesPerPixel = (private->info.depth + 7) / 8;
482 int i; 482 int i;
484 if (!private->shadowFB) { 484 if (!private->shadowFB) {
485 return; 485 return;
486 } 486 }
487 487
488 if (private->info.depth != 16) { 488 if (private->info.depth != 16) {
489 WSCONS_ReportError ("Shadow copy only implemented for 16 bpp"); 489 WSCONS_ReportError("Shadow copy only implemented for 16 bpp");
490 return; 490 return;
491 } 491 }
492 492
493 for (i = 0; i < numrects; i++) { 493 for (i = 0; i < numrects; i++) {
494 int x1, y1, x2, y2; 494 int x1, y1, x2, y2;
566 sha_y1 = y2 - 1; 566 sha_y1 = y2 - 1;
567 shadowRightDelta = -width; 567 shadowRightDelta = -width;
568 shadowDownDelta = 1; 568 shadowDownDelta = 1;
569 break; 569 break;
570 default: 570 default:
571 WSCONS_ReportError ("Unknown rotation"); 571 WSCONS_ReportError("Unknown rotation");
572 return; 572 return;
573 } 573 }
574 574
575 src_start = 575 src_start =
576 private->shadowmem + (sha_y1 * width + sha_x1) * bytesPerPixel; 576 private->shadowmem + (sha_y1 * width + sha_x1) * bytesPerPixel;
577 dst_start = 577 dst_start =
578 private->physmem + scr_y1 * private->physlinebytes + 578 private->physmem + scr_y1 * private->physlinebytes +
579 scr_x1 * bytesPerPixel; 579 scr_x1 * bytesPerPixel;
580 580
581 private->blitFunc (src_start, 581 private->blitFunc(src_start,
582 shadowRightDelta, 582 shadowRightDelta,
583 shadowDownDelta, 583 shadowDownDelta,
584 dst_start, 584 dst_start,
585 private->physlinebytes, 585 private->physlinebytes,
586 scr_x2 - scr_x1, scr_y2 - scr_y1); 586 scr_x2 - scr_x1, scr_y2 - scr_y1);
587 } 587 }
588 } 588 }
589 589
590 int 590 int
591 WSCONS_SetColors (_THIS, int firstcolor, int ncolors, SDL_Color * colors) 591 WSCONS_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color * colors)
592 { 592 {
593 return 0; 593 return 0;
594 } 594 }
595 595
596 /* 596 /*
597 * Note: If we are terminated, this could be called in the middle of 597 * Note: If we are terminated, this could be called in the middle of
598 * another SDL video routine -- notably UpdateRects. 598 * another SDL video routine -- notably UpdateRects.
599 */ 599 */
600 void 600 void
601 WSCONS_VideoQuit (_THIS) 601 WSCONS_VideoQuit(_THIS)
602 { 602 {
603 int mode = WSDISPLAYIO_MODE_EMUL; 603 int mode = WSDISPLAYIO_MODE_EMUL;
604 604
605 if (private->shadowmem != NULL) { 605 if (private->shadowmem != NULL) {
606 SDL_free (private->shadowmem); 606 SDL_free(private->shadowmem);
607 private->shadowmem = NULL; 607 private->shadowmem = NULL;
608 } 608 }
609 private->fbstart = NULL; 609 private->fbstart = NULL;
610 if (this->screen != NULL) { 610 if (this->screen != NULL) {
611 this->screen->pixels = NULL; 611 this->screen->pixels = NULL;
612 } 612 }
613 613
614 if (private->SDL_modelist[0] != NULL) { 614 if (private->SDL_modelist[0] != NULL) {
615 SDL_free (private->SDL_modelist[0]); 615 SDL_free(private->SDL_modelist[0]);
616 private->SDL_modelist[0] = NULL; 616 private->SDL_modelist[0] = NULL;
617 } 617 }
618 618
619 if (ioctl (private->fd, WSDISPLAYIO_SMODE, &mode) == -1) { 619 if (ioctl(private->fd, WSDISPLAYIO_SMODE, &mode) == -1) {
620 WSCONS_ReportError ("ioctl SMODE"); 620 WSCONS_ReportError("ioctl SMODE");
621 } 621 }
622 622
623 WSCONS_ReleaseKeyboard (this); 623 WSCONS_ReleaseKeyboard(this);
624 624
625 if (private->fd != -1) { 625 if (private->fd != -1) {
626 close (private->fd); 626 close(private->fd);
627 private->fd = -1; 627 private->fd = -1;
628 } 628 }
629 } 629 }
630 630
631 /* vi: set ts=4 sw=4 expandtab: */ 631 /* vi: set ts=4 sw=4 expandtab: */