comparison src/video/riscos/SDL_riscosFullScreenVideo.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
196 ** SDL$<name>$BackBuffer >= 1 196 ** SDL$<name>$BackBuffer >= 1
197 */ 197 */
198 if (riscos_backbuffer == 3) 198 if (riscos_backbuffer == 3)
199 this->hidden->bank[0] = WIMP_CreateBuffer(width, height, bpp); 199 this->hidden->bank[0] = WIMP_CreateBuffer(width, height, bpp);
200 else 200 else
201 this->hidden->bank[0] = malloc(height * current->pitch); 201 this->hidden->bank[0] = SDL_malloc(height * current->pitch);
202 if (this->hidden->bank[0] == 0) 202 if (this->hidden->bank[0] == 0)
203 { 203 {
204 RISCOS_RestoreWimpMode(); 204 RISCOS_RestoreWimpMode();
205 SDL_SetError("Couldnt allocate memory for back buffer"); 205 SDL_SetError("Couldnt allocate memory for back buffer");
206 return (NULL); 206 return (NULL);
208 /* Surface updated in programs is now a software surface */ 208 /* Surface updated in programs is now a software surface */
209 current->flags &= ~SDL_HWSURFACE; 209 current->flags &= ~SDL_HWSURFACE;
210 } 210 }
211 211
212 /* Store address of allocated screen bank to be freed later */ 212 /* Store address of allocated screen bank to be freed later */
213 if (this->hidden->alloc_bank) free(this->hidden->alloc_bank); 213 if (this->hidden->alloc_bank) SDL_free(this->hidden->alloc_bank);
214 if (create_back_buffer) 214 if (create_back_buffer)
215 { 215 {
216 this->hidden->alloc_bank = this->hidden->bank[0]; 216 this->hidden->alloc_bank = this->hidden->bank[0];
217 if (riscos_backbuffer == 3) 217 if (riscos_backbuffer == 3)
218 { 218 {
221 } 221 }
222 } else 222 } else
223 this->hidden->alloc_bank = 0; 223 this->hidden->alloc_bank = 0;
224 224
225 // Clear both banks to black 225 // Clear both banks to black
226 memset(this->hidden->bank[0], 0, height * current->pitch); 226 SDL_memset(this->hidden->bank[0], 0, height * current->pitch);
227 memset(this->hidden->bank[1], 0, height * current->pitch); 227 SDL_memset(this->hidden->bank[1], 0, height * current->pitch);
228 228
229 this->hidden->current_bank = 0; 229 this->hidden->current_bank = 0;
230 current->pixels = this->hidden->bank[0]; 230 current->pixels = this->hidden->bank[0];
231 231
232 /* Have to set the screen here, so SetDeviceMode will pick it up */ 232 /* Have to set the screen here, so SetDeviceMode will pick it up */
314 num_modes = -regs.r[2]; 314 num_modes = -regs.r[2];
315 315
316 /* Video memory should be in r[5] */ 316 /* Video memory should be in r[5] */
317 this->info.video_mem = regs.r[5]/1024; 317 this->info.video_mem = regs.r[5]/1024;
318 318
319 enumInfo = (unsigned char *)malloc(-regs.r[7]); 319 enumInfo = (unsigned char *)SDL_malloc(-regs.r[7]);
320 if (enumInfo == NULL) 320 if (enumInfo == NULL)
321 { 321 {
322 SDL_OutOfMemory(); 322 SDL_OutOfMemory();
323 return; 323 return;
324 } 324 }
350 } 350 }
351 351
352 enum_ptr += blockInfo[0]; 352 enum_ptr += blockInfo[0];
353 } 353 }
354 354
355 free(enumInfo); 355 SDL_free(enumInfo);
356 356
357 /* Sort the mode lists */ 357 /* Sort the mode lists */
358 for ( j=0; j<NUM_MODELISTS; ++j ) { 358 for ( j=0; j<NUM_MODELISTS; ++j ) {
359 if ( SDL_nummodes[j] > 0 ) { 359 if ( SDL_nummodes[j] > 0 ) {
360 qsort(SDL_modelist[j], SDL_nummodes[j], sizeof *SDL_modelist[j], cmpmodes); 360 qsort(SDL_modelist[j], SDL_nummodes[j], sizeof *SDL_modelist[j], cmpmodes);
395 { 395 {
396 from = this->hidden->bank[0] + rects->x * xmult + rects->y * pitch; 396 from = this->hidden->bank[0] + rects->x * xmult + rects->y * pitch;
397 to = this->hidden->bank[1] + rects->x * xmult + rects->y * pitch; 397 to = this->hidden->bank[1] + rects->x * xmult + rects->y * pitch;
398 for (row = 0; row < rects->h; row++) 398 for (row = 0; row < rects->h; row++)
399 { 399 {
400 memcpy(to, from, rects->w * xmult); 400 SDL_memcpy(to, from, rects->w * xmult);
401 from += pitch; 401 from += pitch;
402 to += pitch; 402 to += pitch;
403 } 403 }
404 rects++; 404 rects++;
405 } 405 }
592 return(0); 592 return(0);
593 } 593 }
594 } 594 }
595 595
596 /* Set up the new video mode rectangle */ 596 /* Set up the new video mode rectangle */
597 mode = (SDL_Rect *)malloc(sizeof *mode); 597 mode = (SDL_Rect *)SDL_malloc(sizeof *mode);
598 if ( mode == NULL ) { 598 if ( mode == NULL ) {
599 SDL_OutOfMemory(); 599 SDL_OutOfMemory();
600 return(-1); 600 return(-1);
601 } 601 }
602 mode->x = 0; 602 mode->x = 0;
605 mode->h = h; 605 mode->h = h;
606 606
607 /* Allocate the new list of modes, and fill in the new mode */ 607 /* Allocate the new list of modes, and fill in the new mode */
608 next_mode = SDL_nummodes[index]; 608 next_mode = SDL_nummodes[index];
609 SDL_modelist[index] = (SDL_Rect **) 609 SDL_modelist[index] = (SDL_Rect **)
610 realloc(SDL_modelist[index], (1+next_mode+1)*sizeof(SDL_Rect *)); 610 SDL_realloc(SDL_modelist[index], (1+next_mode+1)*sizeof(SDL_Rect *));
611 if ( SDL_modelist[index] == NULL ) { 611 if ( SDL_modelist[index] == NULL ) {
612 SDL_OutOfMemory(); 612 SDL_OutOfMemory();
613 SDL_nummodes[index] = 0; 613 SDL_nummodes[index] = 0;
614 free(mode); 614 SDL_free(mode);
615 return(-1); 615 return(-1);
616 } 616 }
617 SDL_modelist[index][next_mode] = mode; 617 SDL_modelist[index][next_mode] = mode;
618 SDL_modelist[index][next_mode+1] = NULL; 618 SDL_modelist[index][next_mode+1] = NULL;
619 SDL_nummodes[index]++; 619 SDL_nummodes[index]++;
661 } 661 }
662 662
663 /** Store caption in case this is called before we create a window */ 663 /** Store caption in case this is called before we create a window */
664 void FULLSCREEN_SetWMCaption(_THIS, const char *title, const char *icon) 664 void FULLSCREEN_SetWMCaption(_THIS, const char *title, const char *icon)
665 { 665 {
666 strncpy(this->hidden->title, title, 255); 666 SDL_strncpy(this->hidden->title, title, 255);
667 this->hidden->title[255] = 0; 667 this->hidden->title[255] = 0;
668 } 668 }
669 669
670 /* Set screen mode 670 /* Set screen mode
671 * 671 *
770 770
771 this->hidden->current_bank = 0; 771 this->hidden->current_bank = 0;
772 this->screen->pixels = this->hidden->bank[0]; 772 this->screen->pixels = this->hidden->bank[0];
773 773
774 /* Copy back buffer to screen memory */ 774 /* Copy back buffer to screen memory */
775 memcpy(this->hidden->bank[1], this->hidden->bank[0], width * height * this->screen->format->BytesPerPixel); 775 SDL_memcpy(this->hidden->bank[1], this->hidden->bank[0], width * height * this->screen->format->BytesPerPixel);
776 776
777 FULLSCREEN_SetDeviceMode(this); 777 FULLSCREEN_SetDeviceMode(this);
778 return 1; 778 return 1;
779 } else 779 } else
780 RISCOS_RestoreWimpMode(); 780 RISCOS_RestoreWimpMode();