comparison src/video/wscons/SDL_wsconsvideo.c @ 1336:3692456e7b0f

Use SDL_ prefixed versions of C library functions. FIXME: Change #include <stdlib.h> to #include "SDL_stdlib.h" Change #include <string.h> to #include "SDL_string.h" Make sure nothing else broke because of this...
author Sam Lantinga <slouken@libsdl.org>
date Tue, 07 Feb 2006 06:59:48 +0000
parents c9b51268668f
children 604d73db6802
comparison
equal deleted inserted replaced
1335:c39265384763 1336:3692456e7b0f
94 return 1; 94 return 1;
95 } 95 }
96 96
97 static void WSCONS_DeleteDevice(SDL_VideoDevice *device) 97 static void WSCONS_DeleteDevice(SDL_VideoDevice *device)
98 { 98 {
99 free(device->hidden); 99 SDL_free(device->hidden);
100 free(device); 100 SDL_free(device);
101 } 101 }
102 102
103 static SDL_VideoDevice *WSCONS_CreateDevice(int devindex) 103 static SDL_VideoDevice *WSCONS_CreateDevice(int devindex)
104 { 104 {
105 SDL_VideoDevice *device; 105 SDL_VideoDevice *device;
106 106
107 /* Initialize all variables that we clean on shutdown */ 107 /* Initialize all variables that we clean on shutdown */
108 device = (SDL_VideoDevice *)malloc(sizeof(SDL_VideoDevice)); 108 device = (SDL_VideoDevice *)SDL_malloc(sizeof(SDL_VideoDevice));
109 if (device == NULL) { 109 if (device == NULL) {
110 SDL_OutOfMemory(); 110 SDL_OutOfMemory();
111 return 0; 111 return 0;
112 } 112 }
113 memset(device, 0, (sizeof *device)); 113 SDL_memset(device, 0, (sizeof *device));
114 device->hidden = 114 device->hidden =
115 (struct SDL_PrivateVideoData *)malloc((sizeof *device->hidden)); 115 (struct SDL_PrivateVideoData *)SDL_malloc((sizeof *device->hidden));
116 if (device->hidden == NULL) { 116 if (device->hidden == NULL) {
117 SDL_OutOfMemory(); 117 SDL_OutOfMemory();
118 free(device); 118 SDL_free(device);
119 return(0); 119 return(0);
120 } 120 }
121 memset(device->hidden, 0, (sizeof *device->hidden)); 121 SDL_memset(device->hidden, 0, (sizeof *device->hidden));
122 device->hidden->fd = -1; 122 device->hidden->fd = -1;
123 123
124 /* Set the function pointers */ 124 /* Set the function pointers */
125 device->VideoInit = WSCONS_VideoInit; 125 device->VideoInit = WSCONS_VideoInit;
126 device->ListModes = WSCONS_ListModes; 126 device->ListModes = WSCONS_ListModes;
157 int wsmode = WSDISPLAYIO_MODE_DUMBFB; 157 int wsmode = WSDISPLAYIO_MODE_DUMBFB;
158 size_t len, mapsize; 158 size_t len, mapsize;
159 int pagemask; 159 int pagemask;
160 int width, height; 160 int width, height;
161 161
162 devname = getenv("SDL_WSCONSDEV"); 162 devname = SDL_getenv("SDL_WSCONSDEV");
163 if (devname == NULL) { 163 if (devname == NULL) {
164 int activeVT; 164 int activeVT;
165 if (ioctl(STDIN_FILENO, VT_GETACTIVE, &activeVT) == -1) { 165 if (ioctl(STDIN_FILENO, VT_GETACTIVE, &activeVT) == -1) {
166 WSCONS_ReportError("Unable to determine active terminal: %s", 166 WSCONS_ReportError("Unable to determine active terminal: %s",
167 strerror(errno)); 167 strerror(errno));
168 return -1; 168 return -1;
169 } 169 }
170 snprintf(devnamebuf, sizeof(devnamebuf), WSCONSDEV_FORMAT, activeVT - 1); 170 SDL_snprintf(devnamebuf, sizeof(devnamebuf), WSCONSDEV_FORMAT, activeVT - 1);
171 devname = devnamebuf; 171 devname = devnamebuf;
172 } 172 }
173 173
174 private->fd = open(devname, O_RDWR | O_NONBLOCK, 0); 174 private->fd = open(devname, O_RDWR | O_NONBLOCK, 0);
175 if (private->fd == -1) { 175 if (private->fd == -1) {
209 WSCONS_ReportError("Displays with 8 bpp or less are not supported"); 209 WSCONS_ReportError("Displays with 8 bpp or less are not supported");
210 return -1; 210 return -1;
211 } 211 }
212 212
213 private->rotate = WSCONS_ROTATE_NONE; 213 private->rotate = WSCONS_ROTATE_NONE;
214 rotation = getenv("SDL_VIDEO_WSCONS_ROTATION"); 214 rotation = SDL_getenv("SDL_VIDEO_WSCONS_ROTATION");
215 if (rotation != NULL) { 215 if (rotation != NULL) {
216 if (strlen(rotation) == 0) { 216 if (SDL_strlen(rotation) == 0) {
217 private->shadowFB = 0; 217 private->shadowFB = 0;
218 private->rotate = WSCONS_ROTATE_NONE; 218 private->rotate = WSCONS_ROTATE_NONE;
219 printf("Not rotating, no shadow\n"); 219 printf("Not rotating, no shadow\n");
220 } else if (!strcmp(rotation, "NONE")) { 220 } else if (!SDL_strcmp(rotation, "NONE")) {
221 private->shadowFB = 1; 221 private->shadowFB = 1;
222 private->rotate = WSCONS_ROTATE_NONE; 222 private->rotate = WSCONS_ROTATE_NONE;
223 printf("Not rotating, but still using shadow\n"); 223 printf("Not rotating, but still using shadow\n");
224 } else if (!strcmp(rotation, "CW")) { 224 } else if (!SDL_strcmp(rotation, "CW")) {
225 private->shadowFB = 1; 225 private->shadowFB = 1;
226 private->rotate = WSCONS_ROTATE_CW; 226 private->rotate = WSCONS_ROTATE_CW;
227 printf("Rotating screen clockwise\n"); 227 printf("Rotating screen clockwise\n");
228 } else if (!strcmp(rotation, "CCW")) { 228 } else if (!SDL_strcmp(rotation, "CCW")) {
229 private->shadowFB = 1; 229 private->shadowFB = 1;
230 private->rotate = WSCONS_ROTATE_CCW; 230 private->rotate = WSCONS_ROTATE_CCW;
231 printf("Rotating screen counter clockwise\n"); 231 printf("Rotating screen counter clockwise\n");
232 } else if (!strcmp(rotation, "UD")) { 232 } else if (!SDL_strcmp(rotation, "UD")) {
233 private->shadowFB = 1; 233 private->shadowFB = 1;
234 private->rotate = WSCONS_ROTATE_UD; 234 private->rotate = WSCONS_ROTATE_UD;
235 printf("Rotating screen upside down\n"); 235 printf("Rotating screen upside down\n");
236 } else { 236 } else {
237 WSCONS_ReportError("\"%s\" is not a valid value for " 237 WSCONS_ReportError("\"%s\" is not a valid value for "
302 width = private->info.width; 302 width = private->info.width;
303 height = private->info.height; 303 height = private->info.height;
304 } 304 }
305 305
306 if (private->shadowFB) { 306 if (private->shadowFB) {
307 private->shadowmem = (Uint8 *)malloc(len); 307 private->shadowmem = (Uint8 *)SDL_malloc(len);
308 if (private->shadowmem == NULL) { 308 if (private->shadowmem == NULL) {
309 WSCONS_ReportError("No memory for shadow"); 309 WSCONS_ReportError("No memory for shadow");
310 return -1; 310 return -1;
311 } 311 }
312 private->fbstart = private->shadowmem; 312 private->fbstart = private->shadowmem;
314 } else { 314 } else {
315 private->fbstart = private->physmem; 315 private->fbstart = private->physmem;
316 private->fblinebytes = private->physlinebytes; 316 private->fblinebytes = private->physlinebytes;
317 } 317 }
318 318
319 private->SDL_modelist[0] = (SDL_Rect *)malloc(sizeof(SDL_Rect)); 319 private->SDL_modelist[0] = (SDL_Rect *)SDL_malloc(sizeof(SDL_Rect));
320 private->SDL_modelist[0]->w = width; 320 private->SDL_modelist[0]->w = width;
321 private->SDL_modelist[0]->h = height; 321 private->SDL_modelist[0]->h = height;
322 322
323 vformat->BitsPerPixel = private->info.depth; 323 vformat->BitsPerPixel = private->info.depth;
324 vformat->BytesPerPixel = private->info.depth / 8; 324 vformat->BytesPerPixel = private->info.depth / 8;
372 current->w = width; 372 current->w = width;
373 current->h = height; 373 current->h = height;
374 current->pitch = private->fblinebytes; 374 current->pitch = private->fblinebytes;
375 current->pixels = private->fbstart; 375 current->pixels = private->fbstart;
376 376
377 memset(private->fbstart, 0, private->fbmem_len); 377 SDL_memset(private->fbstart, 0, private->fbmem_len);
378 378
379 return current; 379 return current;
380 } 380 }
381 381
382 static int WSCONS_AllocHWSurface(_THIS, SDL_Surface *surface) 382 static int WSCONS_AllocHWSurface(_THIS, SDL_Surface *surface)
581 void WSCONS_VideoQuit(_THIS) 581 void WSCONS_VideoQuit(_THIS)
582 { 582 {
583 int mode = WSDISPLAYIO_MODE_EMUL; 583 int mode = WSDISPLAYIO_MODE_EMUL;
584 584
585 if (private->shadowmem != NULL) { 585 if (private->shadowmem != NULL) {
586 free(private->shadowmem); 586 SDL_free(private->shadowmem);
587 private->shadowmem = NULL; 587 private->shadowmem = NULL;
588 } 588 }
589 private->fbstart = NULL; 589 private->fbstart = NULL;
590 if (this->screen != NULL) { 590 if (this->screen != NULL) {
591 this->screen->pixels = NULL; 591 this->screen->pixels = NULL;
592 } 592 }
593 593
594 if (private->SDL_modelist[0] != NULL) { 594 if (private->SDL_modelist[0] != NULL) {
595 free(private->SDL_modelist[0]); 595 SDL_free(private->SDL_modelist[0]);
596 private->SDL_modelist[0] = NULL; 596 private->SDL_modelist[0] = NULL;
597 } 597 }
598 598
599 if (ioctl(private->fd, WSDISPLAYIO_SMODE, &mode) == -1) { 599 if (ioctl(private->fd, WSDISPLAYIO_SMODE, &mode) == -1) {
600 WSCONS_ReportError("ioctl SMODE"); 600 WSCONS_ReportError("ioctl SMODE");