comparison src/video/macdsp/SDL_dspvideo.c @ 1338:604d73db6802

Removed uses of stdlib.h and string.h
author Sam Lantinga <slouken@libsdl.org>
date Tue, 07 Feb 2006 09:29:18 +0000
parents 3692456e7b0f
children c71e05b4dc2e
comparison
equal deleted inserted replaced
1337:c687f06c7473 1338:604d73db6802
119 119
120 /* #define DSP_NO_SYNC_VBL */ 120 /* #define DSP_NO_SYNC_VBL */
121 121
122 #define DSP_NO_SYNC_OPENGL 122 #define DSP_NO_SYNC_OPENGL
123 123
124
125 #include <stdio.h>
126 #include <stdlib.h>
127 124
128 #if defined(__APPLE__) && defined(__MACH__) 125 #if defined(__APPLE__) && defined(__MACH__)
129 #include <Carbon/Carbon.h> 126 #include <Carbon/Carbon.h>
130 #include <DrawSprocket/DrawSprocket.h> 127 #include <DrawSprocket/DrawSprocket.h>
131 #elif TARGET_API_MAC_CARBON && (UNIVERSAL_INTERFACES_VERSION > 0x0335) 128 #elif TARGET_API_MAC_CARBON && (UNIVERSAL_INTERFACES_VERSION > 0x0335)
138 #include <DiskInit.h> 135 #include <DiskInit.h>
139 #include <QDOffscreen.h> 136 #include <QDOffscreen.h>
140 #include <DrawSprocket.h> 137 #include <DrawSprocket.h>
141 #endif 138 #endif
142 139
140 #include "SDL_stdlib.h"
141 #include "SDL_string.h"
143 #include "SDL_video.h" 142 #include "SDL_video.h"
144 #include "SDL_blit.h" 143 #include "SDL_blit.h"
145 #include "SDL_error.h" 144 #include "SDL_error.h"
146 #include "SDL_syswm.h" 145 #include "SDL_syswm.h"
147 #include "SDL_sysvideo.h" 146 #include "SDL_sysvideo.h"
263 SDL_OutOfMemory(); 262 SDL_OutOfMemory();
264 263
265 if ( device ) { 264 if ( device ) {
266 265
267 if (device->hidden) 266 if (device->hidden)
268 free (device->hidden); 267 SDL_free(device->hidden);
269 268
270 SDL_free(device); 269 SDL_free(device);
271 } 270 }
272 271
273 return(NULL); 272 return(NULL);
388 } 387 }
389 } 388 }
390 done: 389 done:
391 i++; /* i was not incremented before kicking out of the loop */ 390 i++; /* i was not incremented before kicking out of the loop */
392 391
393 mode_list = (SDL_Rect**) malloc (sizeof (SDL_Rect*) * (i+1)); 392 mode_list = (SDL_Rect**) SDL_malloc (sizeof (SDL_Rect*) * (i+1));
394 if (mode_list) { 393 if (mode_list) {
395 394
396 /* -dw- new stuff: build in reverse order so largest sizes list first */ 395 /* -dw- new stuff: build in reverse order so largest sizes list first */
397 for (j = i-1; j >= 0; j--) { 396 for (j = i-1; j >= 0; j--) {
398 mode_list [j] = (SDL_Rect*) malloc (sizeof (SDL_Rect)); 397 mode_list [j] = (SDL_Rect*) SDL_malloc (sizeof (SDL_Rect));
399 if (mode_list [j]) 398 if (mode_list [j])
400 memcpy (mode_list [j], &(temp_list [j]), sizeof (SDL_Rect)); 399 SDL_memcpy (mode_list [j], &(temp_list [j]), sizeof (SDL_Rect));
401 else { 400 else {
402 SDL_OutOfMemory (); 401 SDL_OutOfMemory ();
403 return NULL; 402 return NULL;
404 } 403 }
405 } 404 }
473 if ( (**device_list).gdNextGD == NULL ) { 472 if ( (**device_list).gdNextGD == NULL ) {
474 *device = main_device; 473 *device = main_device;
475 return 0; 474 return 0;
476 } 475 }
477 476
478 memset (&attrib, 0, sizeof (DSpContextAttributes)); 477 SDL_memset (&attrib, 0, sizeof (DSpContextAttributes));
479 478
480 /* These attributes are hopefully supported on all devices...*/ 479 /* These attributes are hopefully supported on all devices...*/
481 attrib.displayWidth = 640; 480 attrib.displayWidth = 640;
482 attrib.displayHeight = 480; 481 attrib.displayHeight = 480;
483 attrib.displayBestDepth = 8; 482 attrib.displayBestDepth = 8;
655 break; 654 break;
656 default: 655 default:
657 fmt = "Hardware surface could not be allocated in %s - unknown error"; 656 fmt = "Hardware surface could not be allocated in %s - unknown error";
658 break; 657 break;
659 } 658 }
660 sprintf(message, fmt, mem); 659 SDL_snprintf(message, SDL_arraysize(message), fmt, mem);
661 SDL_SetError(message); 660 SDL_SetError(message);
662 } 661 }
663 #endif // TARGET_API_MAC_OSX 662 #endif // TARGET_API_MAC_OSX
664 663
665 /* put up a dialog to verify display change */ 664 /* put up a dialog to verify display change */
733 732
734 if (front != dsp_back_buffer) 733 if (front != dsp_back_buffer)
735 DisposeGWorld (dsp_back_buffer); 734 DisposeGWorld (dsp_back_buffer);
736 735
737 if (current->hwdata) 736 if (current->hwdata)
738 free (current->hwdata); 737 SDL_free(current->hwdata);
739 738
740 DSpContext_SetState (dsp_context, kDSpContextState_Inactive ); 739 DSpContext_SetState (dsp_context, kDSpContextState_Inactive );
741 DSpContext_Release (dsp_context); 740 DSpContext_Release (dsp_context);
742 741
743 dsp_context = NULL; 742 dsp_context = NULL;
786 page_count = 2; 785 page_count = 2;
787 } else { 786 } else {
788 page_count = 1; 787 page_count = 1;
789 } 788 }
790 789
791 memset (&attrib, 0, sizeof (DSpContextAttributes)); 790 SDL_memset (&attrib, 0, sizeof (DSpContextAttributes));
792 attrib.displayWidth = width; 791 attrib.displayWidth = width;
793 attrib.displayHeight = height; 792 attrib.displayHeight = height;
794 attrib.displayBestDepth = bpp; 793 attrib.displayBestDepth = bpp;
795 attrib.backBufferBestDepth = bpp; 794 attrib.backBufferBestDepth = bpp;
796 attrib.displayDepthMask = kDSpDepthMask_All; 795 attrib.displayDepthMask = kDSpDepthMask_All;
865 if (!double_buf) { 864 if (!double_buf) {
866 865
867 /* single-buffer context */ 866 /* single-buffer context */
868 DSpContext_GetFrontBuffer (dsp_context, &dsp_back_buffer); 867 DSpContext_GetFrontBuffer (dsp_context, &dsp_back_buffer);
869 868
870 current->hwdata = (private_hwdata*) malloc (sizeof (private_hwdata)); 869 current->hwdata = (private_hwdata*) SDL_malloc (sizeof (private_hwdata));
871 if (current ->hwdata == NULL) { 870 if (current ->hwdata == NULL) {
872 SDL_OutOfMemory (); 871 SDL_OutOfMemory ();
873 return NULL; 872 return NULL;
874 } 873 }
875 current->hwdata->offscreen = dsp_back_buffer; 874 current->hwdata->offscreen = dsp_back_buffer;
883 current->flags |= SDL_DOUBLEBUF | SDL_SWSURFACE; /* only front buffer is in VRAM */ 882 current->flags |= SDL_DOUBLEBUF | SDL_SWSURFACE; /* only front buffer is in VRAM */
884 this->UpdateRects = DSp_DSpUpdate; 883 this->UpdateRects = DSp_DSpUpdate;
885 } 884 }
886 else if ( DSp_NewHWSurface(this, &dsp_back_buffer, bpp, width-1, height-1) == 0 ) { 885 else if ( DSp_NewHWSurface(this, &dsp_back_buffer, bpp, width-1, height-1) == 0 ) {
887 886
888 current->hwdata = (private_hwdata*) malloc (sizeof (private_hwdata)); 887 current->hwdata = (private_hwdata*) SDL_malloc (sizeof (private_hwdata));
889 if (current ->hwdata == NULL) { 888 if (current ->hwdata == NULL) {
890 SDL_OutOfMemory (); 889 SDL_OutOfMemory ();
891 return NULL; 890 return NULL;
892 } 891 }
893 892
894 memset (current->hwdata, 0, sizeof (private_hwdata)); 893 SDL_memset (current->hwdata, 0, sizeof (private_hwdata));
895 current->hwdata->offscreen = dsp_back_buffer; 894 current->hwdata->offscreen = dsp_back_buffer;
896 current->flags |= SDL_DOUBLEBUF | SDL_HWSURFACE; 895 current->flags |= SDL_DOUBLEBUF | SDL_HWSURFACE;
897 this->UpdateRects = DSp_DirectUpdate; /* hardware doesn't do update rects, must be page-flipped */ 896 this->UpdateRects = DSp_DirectUpdate; /* hardware doesn't do update rects, must be page-flipped */
898 } 897 }
899 else { 898 else {
1082 GWorldPtr temp; 1081 GWorldPtr temp;
1083 1082
1084 if ( DSp_NewHWSurface (this, &temp, surface->format->BitsPerPixel, surface->w, surface->h) < 0 ) 1083 if ( DSp_NewHWSurface (this, &temp, surface->format->BitsPerPixel, surface->w, surface->h) < 0 )
1085 return (-1); 1084 return (-1);
1086 1085
1087 surface->hwdata = (private_hwdata*) malloc (sizeof (private_hwdata)); 1086 surface->hwdata = (private_hwdata*) SDL_malloc (sizeof (private_hwdata));
1088 if (surface->hwdata == NULL) { 1087 if (surface->hwdata == NULL) {
1089 SDL_OutOfMemory (); 1088 SDL_OutOfMemory ();
1090 return -1; 1089 return -1;
1091 } 1090 }
1092 1091
1093 memset (surface->hwdata, 0, sizeof(private_hwdata)); 1092 SDL_memset (surface->hwdata, 0, sizeof(private_hwdata));
1094 surface->hwdata->offscreen = temp; 1093 surface->hwdata->offscreen = temp;
1095 surface->pitch = GetPixRowBytes (GetPortPixMap (temp)) & 0x3FFF; 1094 surface->pitch = GetPixRowBytes (GetPortPixMap (temp)) & 0x3FFF;
1096 surface->pixels = GetPixBaseAddr (GetPortPixMap (temp)); 1095 surface->pixels = GetPixBaseAddr (GetPortPixMap (temp));
1097 surface->flags |= SDL_HWSURFACE; 1096 surface->flags |= SDL_HWSURFACE;
1098 #ifdef DSP_TRY_CC_AND_AA 1097 #ifdef DSP_TRY_CC_AND_AA
1103 1102
1104 static void DSp_FreeHWSurface(_THIS, SDL_Surface *surface) 1103 static void DSp_FreeHWSurface(_THIS, SDL_Surface *surface)
1105 { 1104 {
1106 if (surface->hwdata->offscreen != NULL) 1105 if (surface->hwdata->offscreen != NULL)
1107 DisposeGWorld (surface->hwdata->offscreen); 1106 DisposeGWorld (surface->hwdata->offscreen);
1108 free (surface->hwdata); 1107 SDL_free(surface->hwdata);
1109 1108
1110 surface->pixels = NULL; 1109 surface->pixels = NULL;
1111 } 1110 }
1112 1111
1113 static int DSp_CheckHWBlit(_THIS, SDL_Surface *src, SDL_Surface *dest) 1112 static int DSp_CheckHWBlit(_THIS, SDL_Surface *src, SDL_Surface *dest)