comparison src/video/xbios/SDL_xbios.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 a4566d07718f
children 604d73db6802
comparison
equal deleted inserted replaced
1335:c39265384763 1336:3692456e7b0f
137 return 1; 137 return 1;
138 } 138 }
139 139
140 static void XBIOS_DeleteDevice(SDL_VideoDevice *device) 140 static void XBIOS_DeleteDevice(SDL_VideoDevice *device)
141 { 141 {
142 free(device->hidden); 142 SDL_free(device->hidden);
143 free(device); 143 SDL_free(device);
144 } 144 }
145 145
146 static SDL_VideoDevice *XBIOS_CreateDevice(int devindex) 146 static SDL_VideoDevice *XBIOS_CreateDevice(int devindex)
147 { 147 {
148 SDL_VideoDevice *device; 148 SDL_VideoDevice *device;
149 149
150 /* Initialize all variables that we clean on shutdown */ 150 /* Initialize all variables that we clean on shutdown */
151 device = (SDL_VideoDevice *)malloc(sizeof(SDL_VideoDevice)); 151 device = (SDL_VideoDevice *)SDL_malloc(sizeof(SDL_VideoDevice));
152 if ( device ) { 152 if ( device ) {
153 memset(device, 0, (sizeof *device)); 153 SDL_memset(device, 0, (sizeof *device));
154 device->hidden = (struct SDL_PrivateVideoData *) 154 device->hidden = (struct SDL_PrivateVideoData *)
155 malloc((sizeof *device->hidden)); 155 SDL_malloc((sizeof *device->hidden));
156 device->gl_data = (struct SDL_PrivateGLData *) 156 device->gl_data = (struct SDL_PrivateGLData *)
157 malloc((sizeof *device->gl_data)); 157 SDL_malloc((sizeof *device->gl_data));
158 } 158 }
159 if ( (device == NULL) || (device->hidden == NULL) ) { 159 if ( (device == NULL) || (device->hidden == NULL) ) {
160 SDL_OutOfMemory(); 160 SDL_OutOfMemory();
161 if ( device ) { 161 if ( device ) {
162 free(device); 162 SDL_free(device);
163 } 163 }
164 return(0); 164 return(0);
165 } 165 }
166 memset(device->hidden, 0, (sizeof *device->hidden)); 166 SDL_memset(device->hidden, 0, (sizeof *device->hidden));
167 memset(device->gl_data, 0, sizeof(*device->gl_data)); 167 SDL_memset(device->gl_data, 0, sizeof(*device->gl_data));
168 168
169 /* Video functions */ 169 /* Video functions */
170 device->VideoInit = XBIOS_VideoInit; 170 device->VideoInit = XBIOS_VideoInit;
171 device->ListModes = XBIOS_ListModes; 171 device->ListModes = XBIOS_ListModes;
172 device->SetVideoMode = XBIOS_SetVideoMode; 172 device->SetVideoMode = XBIOS_SetVideoMode;
221 return; 221 return;
222 } 222 }
223 } 223 }
224 224
225 ++XBIOS_nummodes; 225 ++XBIOS_nummodes;
226 XBIOS_modelist = (xbiosmode_t *) realloc(XBIOS_modelist, XBIOS_nummodes * sizeof(xbiosmode_t)); 226 XBIOS_modelist = (xbiosmode_t *) SDL_realloc(XBIOS_modelist, XBIOS_nummodes * sizeof(xbiosmode_t));
227 227
228 /* Keep the list sorted: bpp, width, height */ 228 /* Keep the list sorted: bpp, width, height */
229 curpos=0; 229 curpos=0;
230 230
231 for(i=0; i<XBIOS_nummodes-1; i++) { 231 for(i=0; i<XBIOS_nummodes-1; i++) {
241 curpos++; 241 curpos++;
242 } 242 }
243 243
244 /* Push remaining modes further */ 244 /* Push remaining modes further */
245 for(i=XBIOS_nummodes-1; i>curpos; i--) { 245 for(i=XBIOS_nummodes-1; i>curpos; i--) {
246 memcpy(&XBIOS_modelist[i], &XBIOS_modelist[i-1], sizeof(xbiosmode_t)); 246 SDL_memcpy(&XBIOS_modelist[i], &XBIOS_modelist[i-1], sizeof(xbiosmode_t));
247 } 247 }
248 248
249 XBIOS_modelist[curpos].number = modecode; 249 XBIOS_modelist[curpos].number = modecode;
250 XBIOS_modelist[curpos].width = width; 250 XBIOS_modelist[curpos].width = width;
251 XBIOS_modelist[curpos].height = height; 251 XBIOS_modelist[curpos].height = height;
266 if (Getcookie(C__VDO, &XBIOS_cvdo) != C_FOUND) { 266 if (Getcookie(C__VDO, &XBIOS_cvdo) != C_FOUND) {
267 XBIOS_cvdo = VDO_ST << 16; 267 XBIOS_cvdo = VDO_ST << 16;
268 } 268 }
269 269
270 /* Allocate memory for old palette */ 270 /* Allocate memory for old palette */
271 XBIOS_oldpalette = (void *)malloc(256*sizeof(long)); 271 XBIOS_oldpalette = (void *)SDL_malloc(256*sizeof(long));
272 if ( !XBIOS_oldpalette ) { 272 if ( !XBIOS_oldpalette ) {
273 SDL_SetError("Unable to allocate memory for old palette\n"); 273 SDL_SetError("Unable to allocate memory for old palette\n");
274 return(-1); 274 return(-1);
275 } 275 }
276 276
424 j8 = j16 = 0; 424 j8 = j16 = 0;
425 for (i=0; i<XBIOS_nummodes; i++, current_mode++) { 425 for (i=0; i<XBIOS_nummodes; i++, current_mode++) {
426 switch (current_mode->depth) { 426 switch (current_mode->depth) {
427 case 4: 427 case 4:
428 case 8: 428 case 8:
429 SDL_modelist[0][j8] = malloc(sizeof(SDL_Rect)); 429 SDL_modelist[0][j8] = SDL_malloc(sizeof(SDL_Rect));
430 SDL_modelist[0][j8]->x = SDL_modelist[0][j8]->y = 0; 430 SDL_modelist[0][j8]->x = SDL_modelist[0][j8]->y = 0;
431 SDL_modelist[0][j8]->w = current_mode->width; 431 SDL_modelist[0][j8]->w = current_mode->width;
432 SDL_modelist[0][j8]->h = current_mode->height; 432 SDL_modelist[0][j8]->h = current_mode->height;
433 XBIOS_videomodes[0][j8]=current_mode; 433 XBIOS_videomodes[0][j8]=current_mode;
434 j8++; 434 j8++;
435 break; 435 break;
436 case 16: 436 case 16:
437 SDL_modelist[1][j16] = malloc(sizeof(SDL_Rect)); 437 SDL_modelist[1][j16] = SDL_malloc(sizeof(SDL_Rect));
438 SDL_modelist[1][j16]->x = SDL_modelist[1][j16]->y = 0; 438 SDL_modelist[1][j16]->x = SDL_modelist[1][j16]->y = 0;
439 SDL_modelist[1][j16]->w = current_mode->width; 439 SDL_modelist[1][j16]->w = current_mode->width;
440 SDL_modelist[1][j16]->h = current_mode->height; 440 SDL_modelist[1][j16]->h = current_mode->height;
441 XBIOS_videomodes[1][j16]=current_mode; 441 XBIOS_videomodes[1][j16]=current_mode;
442 j16++; 442 j16++;
548 548
549 if (XBIOS_shadowscreen == NULL) { 549 if (XBIOS_shadowscreen == NULL) {
550 SDL_SetError("Can not allocate %d KB for shadow buffer", new_screen_size>>10); 550 SDL_SetError("Can not allocate %d KB for shadow buffer", new_screen_size>>10);
551 return (NULL); 551 return (NULL);
552 } 552 }
553 memset(XBIOS_shadowscreen, 0, new_screen_size); 553 SDL_memset(XBIOS_shadowscreen, 0, new_screen_size);
554 } 554 }
555 555
556 /* Output buffer needs to be twice in size for the software double-line mode */ 556 /* Output buffer needs to be twice in size for the software double-line mode */
557 XBIOS_doubleline = SDL_FALSE; 557 XBIOS_doubleline = SDL_FALSE;
558 if (new_video_mode->doubleline) { 558 if (new_video_mode->doubleline) {
565 if (XBIOS_screensmem[0]==NULL) { 565 if (XBIOS_screensmem[0]==NULL) {
566 XBIOS_FreeBuffers(this); 566 XBIOS_FreeBuffers(this);
567 SDL_SetError("Can not allocate %d KB for frame buffer", new_screen_size>>10); 567 SDL_SetError("Can not allocate %d KB for frame buffer", new_screen_size>>10);
568 return (NULL); 568 return (NULL);
569 } 569 }
570 memset(XBIOS_screensmem[0], 0, new_screen_size); 570 SDL_memset(XBIOS_screensmem[0], 0, new_screen_size);
571 571
572 XBIOS_screens[0]=(void *) (( (long) XBIOS_screensmem[0]+256) & 0xFFFFFF00UL); 572 XBIOS_screens[0]=(void *) (( (long) XBIOS_screensmem[0]+256) & 0xFFFFFF00UL);
573 573
574 #ifdef HAVE_OPENGL 574 #ifdef HAVE_OPENGL
575 if (flags & SDL_OPENGL) { 575 if (flags & SDL_OPENGL) {
586 if (XBIOS_screensmem[1]==NULL) { 586 if (XBIOS_screensmem[1]==NULL) {
587 XBIOS_FreeBuffers(this); 587 XBIOS_FreeBuffers(this);
588 SDL_SetError("Can not allocate %d KB for double buffer", new_screen_size>>10); 588 SDL_SetError("Can not allocate %d KB for double buffer", new_screen_size>>10);
589 return (NULL); 589 return (NULL);
590 } 590 }
591 memset(XBIOS_screensmem[1], 0, new_screen_size); 591 SDL_memset(XBIOS_screensmem[1], 0, new_screen_size);
592 592
593 XBIOS_screens[1]=(void *) (( (long) XBIOS_screensmem[1]+256) & 0xFFFFFF00UL); 593 XBIOS_screens[1]=(void *) (( (long) XBIOS_screensmem[1]+256) & 0xFFFFFF00UL);
594 modeflags |= SDL_DOUBLEBUF; 594 modeflags |= SDL_DOUBLEBUF;
595 } 595 }
596 596
676 Vsetmode(new_video_mode->number); 676 Vsetmode(new_video_mode->number);
677 } 677 }
678 #endif 678 #endif
679 /* Set hardware palette to black in True Colour */ 679 /* Set hardware palette to black in True Colour */
680 if (new_depth == 16) { 680 if (new_depth == 16) {
681 memset(F30_palette, 0, sizeof(F30_palette)); 681 SDL_memset(F30_palette, 0, sizeof(F30_palette));
682 VsetRGB(0,256,F30_palette); 682 VsetRGB(0,256,F30_palette);
683 } 683 }
684 break; 684 break;
685 } 685 }
686 686
901 SDL_AtariGL_Quit(this, SDL_TRUE); 901 SDL_AtariGL_Quit(this, SDL_TRUE);
902 } 902 }
903 #endif 903 #endif
904 904
905 if (XBIOS_oldpalette) { 905 if (XBIOS_oldpalette) {
906 free(XBIOS_oldpalette); 906 SDL_free(XBIOS_oldpalette);
907 XBIOS_oldpalette=NULL; 907 XBIOS_oldpalette=NULL;
908 } 908 }
909 XBIOS_FreeBuffers(this); 909 XBIOS_FreeBuffers(this);
910 910
911 /* Free mode list */ 911 /* Free mode list */
912 for (j=0;j<NUM_MODELISTS;j++) { 912 for (j=0;j<NUM_MODELISTS;j++) {
913 for (i=0;i<SDL_NUMMODES;i++) { 913 for (i=0;i<SDL_NUMMODES;i++) {
914 if (SDL_modelist[j][i]!=NULL) { 914 if (SDL_modelist[j][i]!=NULL) {
915 free(SDL_modelist[j][i]); 915 SDL_free(SDL_modelist[j][i]);
916 SDL_modelist[j][i]=NULL; 916 SDL_modelist[j][i]=NULL;
917 } 917 }
918 } 918 }
919 } 919 }
920 920
921 if (XBIOS_modelist) { 921 if (XBIOS_modelist) {
922 free(XBIOS_modelist); 922 SDL_free(XBIOS_modelist);
923 XBIOS_nummodes=0; 923 XBIOS_nummodes=0;
924 XBIOS_modelist=NULL; 924 XBIOS_modelist=NULL;
925 } 925 }
926 926
927 this->screen->pixels = NULL; 927 this->screen->pixels = NULL;