Updated for Watcom C++ and LCC compilers
authorSam Lantinga <slouken@libsdl.org>
Thu, 28 Feb 2002 00:28:26 +0000
changeset 2882f5a6062db86
parent 287 e4bd0cf95506
child 289 77b6110c797d
Updated for Watcom C++ and LCC compilers
include/begin_code.h
src/video/SDL_stretch.c
test/testsprite.c
     1.1 --- a/include/begin_code.h	Wed Feb 27 16:15:34 2002 +0000
     1.2 +++ b/include/begin_code.h	Thu Feb 28 00:28:26 2002 +0000
     1.3 @@ -67,7 +67,7 @@
     1.4     packing set to an alternate value, say for loading structures from disk.
     1.5     The packing is reset to the previous value in close_code.h
     1.6   */
     1.7 -#if defined(_MSC_VER) || defined(__MWERKS__) || defined(__WATCOMC__) || defined(__BORLANDC__)
     1.8 +#if defined(_MSC_VER) || defined(__MWERKS__) || defined(__BORLANDC__)
     1.9  #ifdef _MSC_VER
    1.10  #pragma warning(disable: 4103)
    1.11  #endif
    1.12 @@ -86,8 +86,12 @@
    1.13  #define SDL_INLINE_OKAY
    1.14  #else
    1.15  /* Add any special compiler-specific cases here */
    1.16 -#if defined(_MSC_VER) || defined(__BORLANDC__)
    1.17 +#if defined(_MSC_VER) || defined(__BORLANDC__) || \
    1.18 +    defined(__DMC__) || defined(__SC__) || \
    1.19 +    defined(__WATCOMC__) || defined(__LCC__)
    1.20 +#ifndef __inline__
    1.21  #define __inline__	__inline
    1.22 +#endif
    1.23  #define SDL_INLINE_OKAY
    1.24  #else
    1.25  #if !defined(__MRC__) && !defined(_SGI_SOURCE)
    1.26 @@ -106,3 +110,11 @@
    1.27  #define __inline__
    1.28  #endif
    1.29  
    1.30 +/* Apparently this is needed by several Windows compilers */
    1.31 +#ifndef NULL
    1.32 +#ifdef __cplusplus
    1.33 +#define NULL 0
    1.34 +#else
    1.35 +#define NULL ((void *)0)
    1.36 +#endif
    1.37 +#endif /* NULL */
     2.1 --- a/src/video/SDL_stretch.c	Wed Feb 27 16:15:34 2002 +0000
     2.2 +++ b/src/video/SDL_stretch.c	Thu Feb 28 00:28:26 2002 +0000
     2.3 @@ -39,8 +39,9 @@
     2.4     into the general blitting mechanism.
     2.5  */
     2.6  
     2.7 -#if (defined(WIN32) && !defined(__FREEBCC__) && !defined(_M_ALPHA) && !defined(_WIN32_WCE)) || \
     2.8 -    defined(i386) && defined(__GNUC__) && defined(USE_ASMBLIT) 
     2.9 +#if (defined(WIN32) && !defined(_M_ALPHA) && !defined(_WIN32_WCE) && \
    2.10 +     !defined(__WATCOMC__) && !defined(__LCC__) && !defined(__FREEBCC__)) || \
    2.11 +    (defined(i386) && defined(__GNUC__) && defined(USE_ASMBLIT))
    2.12  #define USE_ASM_STRETCH
    2.13  #endif
    2.14  
     3.1 --- a/test/testsprite.c	Wed Feb 27 16:15:34 2002 +0000
     3.2 +++ b/test/testsprite.c	Thu Feb 28 00:28:26 2002 +0000
     3.3 @@ -1,4 +1,3 @@
     3.4 -
     3.5  /* Simple program:  Move N sprites around on the screen as fast as possible */
     3.6  
     3.7  #include <stdio.h>
     3.8 @@ -18,6 +17,7 @@
     3.9  SDL_Rect *positions;
    3.10  SDL_Rect *velocities;
    3.11  int sprites_visible;
    3.12 +Uint16 sprite_w, sprite_h;
    3.13  
    3.14  int LoadSprite(SDL_Surface *screen, char *file)
    3.15  {
    3.16 @@ -66,12 +66,12 @@
    3.17  		position = &positions[i];
    3.18  		velocity = &velocities[i];
    3.19  		position->x += velocity->x;
    3.20 -		if ( (position->x < 0) || (position->x >= screen->w) ) {
    3.21 +		if ( (position->x < 0) || (position->x >= (screen->w - sprite_w)) ) {
    3.22  			velocity->x = -velocity->x;
    3.23  			position->x += velocity->x;
    3.24  		}
    3.25  		position->y += velocity->y;
    3.26 -		if ( (position->y < 0) || (position->y >= screen->h) ) {
    3.27 +		if ( (position->y < 0) || (position->y >= (screen->h - sprite_w)) ) {
    3.28  			velocity->y = -velocity->y;
    3.29  			position->y += velocity->y;
    3.30  		}
    3.31 @@ -209,10 +209,12 @@
    3.32  	sprite_rects += numsprites;
    3.33  	velocities = sprite_rects;
    3.34  	sprite_rects += numsprites;
    3.35 +	sprite_w = sprite->w;
    3.36 +	sprite_h = sprite->h;
    3.37  	srand(time(NULL));
    3.38  	for ( i=0; i<numsprites; ++i ) {
    3.39 -		positions[i].x = rand()%screen->w;
    3.40 -		positions[i].y = rand()%screen->h;
    3.41 +		positions[i].x = rand()%(screen->w - sprite_w);
    3.42 +		positions[i].y = rand()%(screen->h - sprite_h);
    3.43  		positions[i].w = sprite->w;
    3.44  		positions[i].h = sprite->h;
    3.45  		velocities[i].x = 0;
    3.46 @@ -285,5 +287,6 @@
    3.47  		printf("%2.2f frames per second\n",
    3.48  					((double)frames*1000)/(now-then));
    3.49  	}
    3.50 +	SDL_Quit();
    3.51  	return(0);
    3.52  }