Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
+
#ifdef WIN32
#define UINT8 WIN32API_UINT8
#define UINT16 WIN32API_UINT16
#undef boolean
#endif
-#define USE_DEVIL 0
-#ifndef USE_DEVIL
-# ifdef WIN32
-# define USE_DEVIL
-# endif
-#endif
-#if USE_DEVIL
- #include "IL/il.h"
- #include "IL/ilu.h"
- #include "IL/ilut.h"
- #include "Game.h"
-#else
-
- #include "Game.h"
- extern "C" {
- #include "zlib.h"
- #include "png.h"
+#include "Game.h"
+extern "C" {
+ #include "zlib.h"
+ #include "png.h"
+ #ifdef WIN32
+ #define INT32 INT32_jpeg
#include "jpeglib.h"
- }
+ #undef INT32
+ #else
+ #include "jpeglib.h"
+ #endif
+}
- static bool load_image(const char * fname, TGAImageRec & tex);
- static bool load_png(const char * fname, TGAImageRec & tex);
- static bool load_jpg(const char * fname, TGAImageRec & tex);
- static bool save_image(const char * fname);
- static bool save_png(const char * fname);
-#endif
+static bool load_image(const char * fname, TGAImageRec & tex);
+static bool load_png(const char * fname, TGAImageRec & tex);
+static bool load_jpg(const char * fname, TGAImageRec & tex);
+static bool save_image(const char * fname);
+static bool save_png(const char * fname);
+
+
+#include "openal_wrapper.h"
// ADDED GWC
#ifdef _MSC_VER
extern bool vblsync;
extern bool stillloading;
extern bool showpoints;
+extern bool showdamagebar;
extern bool alwaysblur;
extern bool immediate;
extern bool velocityblur;
#include "gamegl.h"
#include "MacCompatibility.h"
+
#ifdef WIN32
#include <shellapi.h>
#endif
-#include "fmod.h"
-
#include "res/resource.h"
using namespace std;
-#if USE_SDL
+
SDL_Rect **resolutions = NULL;
static SDL_Rect rect_1024_768 = { 0, 0, 1024, 768 };
static SDL_Rect rect_800_600 = { 0, 0, 800, 600 };
&rect_640_480,
NULL
};
-#endif
+
unsigned int resolutionDepths[8][2] = {0};
} POINT, *PPOINT;
#endif
-#if USE_SDL
+
#ifdef _MSC_VER
#pragma warning(push)
#undef MessageBox
#endif
#define MessageBox(hwnd,text,title,flags) STUBBED("msgbox")
-#endif
+
Point delta;
static char **_argv = NULL;
#endif
-#ifdef _WIN32
bool cmdline(const char *cmd)
{
for (int i = 1; i < _argc; i++)
return false;
}
-#else
-bool cmdline(const char *cmd)
-{
- for (int i = 1; i < _argc; i++)
- {
- char *arg = _argv[i];
- while (*arg == '-')
- arg++;
- if (stricmp(arg, cmd) == 0)
- return true;
- }
-
- return false;
-}
-#endif
// --------------------------------------------------------------------------
return g_button;
}
-#if !USE_SDL
-static void initSDLKeyTable(void) {}
-#else
+
#define MAX_SDLKEYS SDLK_LAST
static unsigned short KeyTable[MAX_SDLKEYS];
return;
}
}
-#endif
+
// --------------------------------------------------------------------------
texttoggle=1;
alwaysblur=0;
showpoints=0;
+ showdamagebar=0;
immediate=0;
velocityblur=0;
opstream << KeyToChar(game.attackkey);
opstream << "\nChat key:\n";
opstream << KeyToChar(game.chatkey);
+ opstream << "\nDamage bar:\n";
+ opstream << showdamagebar;
opstream.close();
}
if(ipstream){
ipstream.ignore(256,'\n');
ipstream >> string;
game.chatkey=CharToKey(string);
+ ipstream.ignore(256,'\n');
+ ipstream.ignore(256,'\n');
+ ipstream >> i;
+ showdamagebar = (i != 0);
ipstream.close();
if(detail>2)detail=2;
if(detail<0)detail=0;
if(screenwidth<0)screenwidth=640;
if(screenheight<0)screenheight=480;
-#if !USE_SDL // we'll take anything that works.
- if(screenwidth>3000)screenwidth=640;
- if(screenheight>3000)screenheight=480;
-#endif
+
}
if(kBitsPerPixel!=32&&kBitsPerPixel!=16){
kBitsPerPixel=16;
SetupDSpFullScreen();
-#if USE_SDL
+
if (!SDL_WasInit(SDL_INIT_VIDEO))
{
if (SDL_Init(SDL_INIT_VIDEO) == -1)
if (!cmdline("nomousegrab"))
SDL_WM_GrabInput(SDL_GRAB_ON);
-#endif
+
glClear( GL_COLOR_BUFFER_BIT );
swap_gl_buffers();
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glAlphaFunc( GL_GREATER, 0.5f);
-#if USE_DEVIL
- if (ilGetInteger(IL_VERSION_NUM) < IL_VERSION ||
- iluGetInteger(ILU_VERSION_NUM) < ILU_VERSION ||
- ilutGetInteger(ILUT_VERSION_NUM) < ILUT_VERSION)
- {
- ReportError("DevIL version is different...exiting!\n");
- return false;
- }
-
- ilInit();
- iluInit();
- ilutInit();
-
- ilutRenderer(ILUT_OPENGL);
-
- ilEnable(IL_ORIGIN_SET);
- ilOriginFunc(IL_ORIGIN_LOWER_LEFT);
-#endif
-
GLint width = kContextWidth;
GLint height = kContextHeight;
gMidPoint.h = width / 2;
static void DoMouse(Game & game)
{
-#if USE_SDL
+
if(mainmenu||(abs(game.deltah)<10*realmultiplier*1000&&abs(game.deltav)<10*realmultiplier*1000))
{
game.deltah *= usermousesensitivity;
else if (game.mousecoordv >= kContextHeight)
game.mousecoordv = kContextHeight - 1;
}
-#endif
+
}
AbsoluteTime currTime = UpTime ();
static int num_channels = 0;
- num_channels += FSOUND_GetChannelsPlaying();
+ num_channels += OPENAL_GetChannelsPlaying();
double deltaTime = (float) AbsoluteDeltaToDuration (currTime, start);
if (0 > deltaTime) // if negative microseconds
// game.Dispose();
-#if USE_DEVIL
- ilShutDown();
-#endif
-#if USE_SDL
+
+
SDL_Quit();
#define GL_FUNC(ret,fn,params,call,rt) p##fn = NULL;
#include "glstubs.h"
// cheat here...static destructors are calling glDeleteTexture() after
// the context is destroyed and libGL unloaded by SDL_Quit().
pglDeleteTextures = glDeleteTextures_doNothing;
-#endif
+
}
// --------------------------------------------------------------------------
-static bool g_focused = true;
-
-
static bool IsFocused()
{
- STUBBED("write me");
- return true;
+ return ((SDL_GetAppState() & SDL_APPINPUTFOCUS) != 0);
}
char *retval;
char *envr;
- char *ptr = strrchr((char *)argv0, '/');
+ const char *ptr = strrchr((char *)argv0, '/');
if (strchr(argv0, '/'))
{
retval = strdup(argv0);
if (retval)
- *(strrchr(retval, '/')) = '\0';
+ *((char *) strrchr(retval, '/')) = '\0';
return(retval);
}
if (!SetUp (game))
return 42;
- while (!gDone&&!game.quit&&(!game.tryquit||!game.registered))
+ while (!gDone&&!game.quit&&(!game.tryquit))
{
if (IsFocused())
{
gameFocused = true;
// check windows messages
- #if USE_SDL
+
game.deltah = 0;
game.deltav = 0;
SDL_Event e;
}
sdlEventProc(e, game);
}
- #endif
+
// game
DoUpdate(game);
// --------------------------------------------------------------------------
-#if !USE_SDL
- int resolutionID(int width, int height)
- {
- int whichres;
- whichres=-1;
- if(width==640 && height==480)whichres=0;
- if(width==800 && height==600)whichres=1;
- if(width==1024 && height==768)whichres=2;
- if(width==1280 && height==1024)whichres=3;
- if(width==1600 && height==1200)whichres=4;
- if(width==840 && height==524)whichres=5;
- if(width==1024 && height==640)whichres=6;
- if(width==1344 && height==840)whichres=7;
- if(width==1920 && height==1200)whichres=8;
-
- return whichres;
- }
- int closestResolution(int width, int height)
- {
- int whichres;
- whichres=-1;
- if(width>=640 && height>=480)whichres=0;
- if(width>=800 && height>=600)whichres=1;
- if(width>=1024 && height>=768)whichres=2;
- if(width>=1280 && height>=1024)whichres=3;
- if(width>=1600 && height>=1200)whichres=4;
- if(width==840 && height==524)whichres=5;
- if(width==1024 && height==640)whichres=6;
- if(width==1344 && height==840)whichres=7;
- if(width>=1920 && height>=1200)whichres=8;
-
- return whichres;
- }
-#endif
bool selectDetail(int & width, int & height, int & bpp, int & detail)
{
// currently with SDL, we just use whatever is requested
// and don't care. --ryan.
- #if !USE_SDL
- int whichres = closestResolution(width, height);
-
- while (true)
- {
- if(whichres<=0 || whichres>8){
- whichres = 0;
- width=640;
- height=480;
- }
- if(whichres==1){
- width=800;
- height=600;
- }
- if(whichres==2){
- width=1024;
- height=768;
- }
- if(whichres==3){
- width=1280;
- height=1024;
- }
- if(whichres==4){
- width=1600;
- height=1200;
- }
- if(whichres==5){
- width=840;
- height=524;
- }
- if(whichres==6){
- width=1024;
- height=640;
- }
- if(whichres==7){
- width=1344;
- height=840;
- }
- if(whichres==8){
- width=1920;
- height=1200;
- }
-
- if ((detail != 0) && (resolutionDepths[whichres][1] != 0))
- {
- break;
- }
- else if ((detail == 0) && (resolutionDepths[whichres][0] != 0))
- {
- break;
- }
- else if ((detail != 0) && (resolutionDepths[whichres][0] != 0))
- {
- res = false;
- detail = 0;
- break;
- }
- else
-
- if (0 == whichres)
- {
- break;
- }
-
- --whichres;
- }
-
- bpp = resolutionDepths[whichres][(detail != 0)];
- #endif
+
return res;
}
extern int channels[100];
- extern FSOUND_SAMPLE * samp[100];
- extern FSOUND_STREAM * strm[20];
+ extern OPENAL_SAMPLE * samp[100];
+ extern OPENAL_STREAM * strm[20];
- extern "C" void PlaySoundEx(int chan, FSOUND_SAMPLE *sptr, FSOUND_DSPUNIT *dsp, signed char startpaused)
+ extern "C" void PlaySoundEx(int chan, OPENAL_SAMPLE *sptr, OPENAL_DSPUNIT *dsp, signed char startpaused)
{
- const FSOUND_SAMPLE * currSample = FSOUND_GetCurrentSample(channels[chan]);
+ const OPENAL_SAMPLE * currSample = OPENAL_GetCurrentSample(channels[chan]);
if (currSample && currSample == samp[chan])
{
- if (FSOUND_GetPaused(channels[chan]))
+ if (OPENAL_GetPaused(channels[chan]))
{
- FSOUND_StopSound(channels[chan]);
- channels[chan] = FSOUND_FREE;
+ OPENAL_StopSound(channels[chan]);
+ channels[chan] = OPENAL_FREE;
}
- else if (FSOUND_IsPlaying(channels[chan]))
+ else if (OPENAL_IsPlaying(channels[chan]))
{
- int loop_mode = FSOUND_GetLoopMode(channels[chan]);
- if (loop_mode & FSOUND_LOOP_OFF)
+ int loop_mode = OPENAL_GetLoopMode(channels[chan]);
+ if (loop_mode & OPENAL_LOOP_OFF)
{
- channels[chan] = FSOUND_FREE;
+ channels[chan] = OPENAL_FREE;
}
}
}
else
{
- channels[chan] = FSOUND_FREE;
+ channels[chan] = OPENAL_FREE;
}
- channels[chan] = FSOUND_PlaySoundEx(channels[chan], sptr, dsp, startpaused);
+ channels[chan] = OPENAL_PlaySoundEx(channels[chan], sptr, dsp, startpaused);
if (channels[chan] < 0)
{
- channels[chan] = FSOUND_PlaySoundEx(FSOUND_FREE, sptr, dsp, startpaused);
+ channels[chan] = OPENAL_PlaySoundEx(OPENAL_FREE, sptr, dsp, startpaused);
}
}
- extern "C" void PlayStreamEx(int chan, FSOUND_STREAM *sptr, FSOUND_DSPUNIT *dsp, signed char startpaused)
+ extern "C" void PlayStreamEx(int chan, OPENAL_STREAM *sptr, OPENAL_DSPUNIT *dsp, signed char startpaused)
{
- const FSOUND_SAMPLE * currSample = FSOUND_GetCurrentSample(channels[chan]);
- if (currSample && currSample == FSOUND_Stream_GetSample(sptr))
+ const OPENAL_SAMPLE * currSample = OPENAL_GetCurrentSample(channels[chan]);
+ if (currSample && currSample == OPENAL_Stream_GetSample(sptr))
{
- FSOUND_StopSound(channels[chan]);
- FSOUND_Stream_Stop(sptr);
+ OPENAL_StopSound(channels[chan]);
+ OPENAL_Stream_Stop(sptr);
}
else
{
- FSOUND_Stream_Stop(sptr);
- channels[chan] = FSOUND_FREE;
+ OPENAL_Stream_Stop(sptr);
+ channels[chan] = OPENAL_FREE;
}
- channels[chan] = FSOUND_Stream_PlayEx(channels[chan], sptr, dsp, startpaused);
+ channels[chan] = OPENAL_Stream_PlayEx(channels[chan], sptr, dsp, startpaused);
if (channels[chan] < 0)
{
- channels[chan] = FSOUND_Stream_PlayEx(FSOUND_FREE, sptr, dsp, startpaused);
+ channels[chan] = OPENAL_Stream_PlayEx(OPENAL_FREE, sptr, dsp, startpaused);
}
}
+
bool LoadImage(const char * fname, TGAImageRec & tex)
{
bool res = true;
return false;
}
- #if USE_DEVIL
- ILstring f = strdup(ConvertFileName(fname));
- if (!f)
- {
- return false;
- }
-
- ILuint iid=0;
- ilGenImages(1, &iid);
- ilBindImage(iid);
- if (ilLoadImage(f))
- {
- //iluFlipImage();
- tex.sizeX = ilGetInteger(IL_IMAGE_WIDTH);
- tex.sizeY = ilGetInteger(IL_IMAGE_HEIGHT);
- tex.bpp = ilGetInteger(IL_IMAGE_BITS_PER_PIXEL);
- ILuint Bpp = ilGetInteger(IL_IMAGE_BYTES_PER_PIXEL),
- imageSize = tex.sizeX * tex.sizeY * Bpp;
- ILubyte *Data = ilGetData();
- memcpy(tex.data, Data, imageSize);
-
- // Truvision Targa files are stored as BGR colors
- // We want RGB so Blue and Red bytes are switched
- if (IL_TGA == ilGetInteger(IL_IMAGE_FORMAT))
- {
- // Loop Through The Image Data
- for (GLuint i = 0; i < int(imageSize); i += Bpp)
- {
- // Swaps The 1st And 3rd Bytes ('R'ed and 'B'lue)
- GLbyte temp; // Temporary Variable
- temp = tex.data[i]; // Temporarily Store The Value At Image Data 'i'
- tex.data[i] = tex.data[i + 2]; // Set The 1st Byte To The Value Of The 3rd Byte
- tex.data[i + 2] = temp; // Set The 3rd Byte To The Value In 'temp' (1st Byte Value)
- }
- }
- }
- else
- {
- res = false;
- }
- ilDeleteImages(1, &iid);
-/*
- if (tid)
- {
- GLuint texid = ilutGLLoadImage(f);
- *tid = texid;
- }
- else if (mip)
- {
- ilutGLBuildMipmaps()
- }
- else
- {
- ilutGLTexImage(0);
- }
-*/
- free(f);
- #else
+
res = load_image(fname, tex);
- //if (!res) printf("failed to load %s\n", fname);
- #endif
+
return res;
}
void ScreenShot(const char * fname)
{
- #if USE_DEVIL
- ILstring f = strdup(fname);
- if (!f)
- {
- return;
- }
-
- ILuint iid;
- ilGenImages(1, &iid);
- ilBindImage(iid);
- if (ilutGLScreen())
- {
- ilSaveImage(f);
- }
- ilDeleteImages(1, &iid);
-
- free(f);
- #else
+
save_image(fname);
- #endif
+
}
-#if !USE_DEVIL
+
static bool load_image(const char *file_name, TGAImageRec &tex)
{
- char *ptr = strrchr((char *)file_name, '.');
+ const char *ptr = strrchr((char *)file_name, '.');
if (ptr)
{
- if (stricmp(ptr+1, "png") == 0)
+ if (strcasecmp(ptr+1, "png") == 0)
return load_png(file_name, tex);
- else if (stricmp(ptr+1, "jpg") == 0)
+ else if (strcasecmp(ptr+1, "jpg") == 0)
return load_jpg(file_name, tex);
}
static bool save_image(const char *file_name)
{
- char *ptr = strrchr((char *)file_name, '.');
+ const char *ptr = strrchr((char *)file_name, '.');
if (ptr)
{
- if (stricmp(ptr+1, "png") == 0)
+ if (strcasecmp(ptr+1, "png") == 0)
return save_png(file_name);
}
return retval;
}
-#endif
+