Commit bae3b1e1 authored by Sam Lantinga's avatar Sam Lantinga

Updated for Watcom C++ and LCC compilers

--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%40289
parent 89c31763
...@@ -67,7 +67,7 @@ ...@@ -67,7 +67,7 @@
packing set to an alternate value, say for loading structures from disk. packing set to an alternate value, say for loading structures from disk.
The packing is reset to the previous value in close_code.h The packing is reset to the previous value in close_code.h
*/ */
#if defined(_MSC_VER) || defined(__MWERKS__) || defined(__WATCOMC__) || defined(__BORLANDC__) #if defined(_MSC_VER) || defined(__MWERKS__) || defined(__BORLANDC__)
#ifdef _MSC_VER #ifdef _MSC_VER
#pragma warning(disable: 4103) #pragma warning(disable: 4103)
#endif #endif
...@@ -86,8 +86,12 @@ ...@@ -86,8 +86,12 @@
#define SDL_INLINE_OKAY #define SDL_INLINE_OKAY
#else #else
/* Add any special compiler-specific cases here */ /* Add any special compiler-specific cases here */
#if defined(_MSC_VER) || defined(__BORLANDC__) #if defined(_MSC_VER) || defined(__BORLANDC__) || \
defined(__DMC__) || defined(__SC__) || \
defined(__WATCOMC__) || defined(__LCC__)
#ifndef __inline__
#define __inline__ __inline #define __inline__ __inline
#endif
#define SDL_INLINE_OKAY #define SDL_INLINE_OKAY
#else #else
#if !defined(__MRC__) && !defined(_SGI_SOURCE) #if !defined(__MRC__) && !defined(_SGI_SOURCE)
...@@ -106,3 +110,11 @@ ...@@ -106,3 +110,11 @@
#define __inline__ #define __inline__
#endif #endif
/* Apparently this is needed by several Windows compilers */
#ifndef NULL
#ifdef __cplusplus
#define NULL 0
#else
#define NULL ((void *)0)
#endif
#endif /* NULL */
...@@ -39,8 +39,9 @@ static char rcsid = ...@@ -39,8 +39,9 @@ static char rcsid =
into the general blitting mechanism. into the general blitting mechanism.
*/ */
#if (defined(WIN32) && !defined(__FREEBCC__) && !defined(_M_ALPHA) && !defined(_WIN32_WCE)) || \ #if (defined(WIN32) && !defined(_M_ALPHA) && !defined(_WIN32_WCE) && \
defined(i386) && defined(__GNUC__) && defined(USE_ASMBLIT) !defined(__WATCOMC__) && !defined(__LCC__) && !defined(__FREEBCC__)) || \
(defined(i386) && defined(__GNUC__) && defined(USE_ASMBLIT))
#define USE_ASM_STRETCH #define USE_ASM_STRETCH
#endif #endif
......
/* Simple program: Move N sprites around on the screen as fast as possible */ /* Simple program: Move N sprites around on the screen as fast as possible */
#include <stdio.h> #include <stdio.h>
...@@ -18,6 +17,7 @@ SDL_Rect *sprite_rects; ...@@ -18,6 +17,7 @@ SDL_Rect *sprite_rects;
SDL_Rect *positions; SDL_Rect *positions;
SDL_Rect *velocities; SDL_Rect *velocities;
int sprites_visible; int sprites_visible;
Uint16 sprite_w, sprite_h;
int LoadSprite(SDL_Surface *screen, char *file) int LoadSprite(SDL_Surface *screen, char *file)
{ {
...@@ -66,12 +66,12 @@ void MoveSprites(SDL_Surface *screen, Uint32 background) ...@@ -66,12 +66,12 @@ void MoveSprites(SDL_Surface *screen, Uint32 background)
position = &positions[i]; position = &positions[i];
velocity = &velocities[i]; velocity = &velocities[i];
position->x += velocity->x; position->x += velocity->x;
if ( (position->x < 0) || (position->x >= screen->w) ) { if ( (position->x < 0) || (position->x >= (screen->w - sprite_w)) ) {
velocity->x = -velocity->x; velocity->x = -velocity->x;
position->x += velocity->x; position->x += velocity->x;
} }
position->y += velocity->y; position->y += velocity->y;
if ( (position->y < 0) || (position->y >= screen->h) ) { if ( (position->y < 0) || (position->y >= (screen->h - sprite_w)) ) {
velocity->y = -velocity->y; velocity->y = -velocity->y;
position->y += velocity->y; position->y += velocity->y;
} }
...@@ -209,10 +209,12 @@ int main(int argc, char *argv[]) ...@@ -209,10 +209,12 @@ int main(int argc, char *argv[])
sprite_rects += numsprites; sprite_rects += numsprites;
velocities = sprite_rects; velocities = sprite_rects;
sprite_rects += numsprites; sprite_rects += numsprites;
sprite_w = sprite->w;
sprite_h = sprite->h;
srand(time(NULL)); srand(time(NULL));
for ( i=0; i<numsprites; ++i ) { for ( i=0; i<numsprites; ++i ) {
positions[i].x = rand()%screen->w; positions[i].x = rand()%(screen->w - sprite_w);
positions[i].y = rand()%screen->h; positions[i].y = rand()%(screen->h - sprite_h);
positions[i].w = sprite->w; positions[i].w = sprite->w;
positions[i].h = sprite->h; positions[i].h = sprite->h;
velocities[i].x = 0; velocities[i].x = 0;
...@@ -285,5 +287,6 @@ int main(int argc, char *argv[]) ...@@ -285,5 +287,6 @@ int main(int argc, char *argv[])
printf("%2.2f frames per second\n", printf("%2.2f frames per second\n",
((double)frames*1000)/(now-then)); ((double)frames*1000)/(now-then));
} }
SDL_Quit();
return(0); return(0);
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment