2007-01-15 12:09:25 -08:00
|
|
|
/*
|
|
|
|
This file is part of Warzone 2100.
|
|
|
|
Copyright (C) 1999-2004 Eidos Interactive
|
|
|
|
Copyright (C) 2005-2007 Warzone Resurrection Project
|
|
|
|
|
|
|
|
Warzone 2100 is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
Warzone 2100 is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with Warzone 2100; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
*/
|
2006-09-25 09:46:28 -07:00
|
|
|
/*! \file frame.h
|
|
|
|
* \brief The framework library initialisation and shutdown routines.
|
2007-06-28 10:47:08 -07:00
|
|
|
*/
|
|
|
|
#ifndef _frame_h
|
|
|
|
#define _frame_h
|
|
|
|
|
2007-08-21 05:30:00 -07:00
|
|
|
#include "wzglobal.h"
|
2007-04-10 05:44:50 -07:00
|
|
|
|
2008-03-15 20:10:05 -07:00
|
|
|
#include "types.h"
|
|
|
|
|
2007-10-26 10:05:29 -07:00
|
|
|
// Provides the safer functions strlcpy and strlcat
|
|
|
|
#include "strlfuncs.h"
|
2008-03-15 10:36:50 -07:00
|
|
|
#include "printf_ext.h"
|
2007-10-26 10:05:29 -07:00
|
|
|
|
2007-04-10 10:36:16 -07:00
|
|
|
#include "macros.h"
|
2007-06-28 10:47:08 -07:00
|
|
|
#include "debug.h"
|
|
|
|
|
2008-03-15 20:10:05 -07:00
|
|
|
#include "i18n.h"
|
2007-06-28 10:47:08 -07:00
|
|
|
#include "treap.h"
|
|
|
|
#include "trig.h"
|
2008-03-15 04:40:35 -07:00
|
|
|
|
2008-01-02 09:08:29 -08:00
|
|
|
extern UDWORD selectedPlayer;
|
2008-02-11 08:23:20 -08:00
|
|
|
#define MAX_PLAYERS 8 /**< Maximum number of players in the game. */
|
2007-04-10 07:06:14 -07:00
|
|
|
|
2007-12-29 14:34:41 -08:00
|
|
|
/** Initialise the frame work library */
|
2006-11-03 17:11:26 -08:00
|
|
|
extern BOOL frameInitialise(
|
|
|
|
const char *pWindowName,// The text to appear in the window title bar
|
|
|
|
UDWORD width, // The display width
|
|
|
|
UDWORD height, // The display height
|
|
|
|
UDWORD bitDepth, // The display bit depth
|
|
|
|
BOOL fullScreen // Whether to start full screen or windowed
|
|
|
|
);
|
2007-06-28 10:47:08 -07:00
|
|
|
|
2007-12-29 14:34:41 -08:00
|
|
|
/** Shut down the framework library.
|
2007-06-28 10:47:08 -07:00
|
|
|
* This clears up all the Direct Draw stuff and ensures
|
|
|
|
* that Windows gets restored properly after Full screen mode.
|
|
|
|
*/
|
|
|
|
extern void frameShutDown(void);
|
|
|
|
|
2007-05-12 14:47:06 -07:00
|
|
|
typedef enum _focus_state
|
2007-06-28 10:47:08 -07:00
|
|
|
{
|
2007-05-12 14:47:06 -07:00
|
|
|
FOCUS_OUT, // Window does not have the focus
|
|
|
|
FOCUS_IN, // Window has got the focus
|
|
|
|
} FOCUS_STATE;
|
|
|
|
|
2008-01-05 05:50:34 -08:00
|
|
|
/*!
|
|
|
|
* Set the framerate limit
|
|
|
|
*
|
|
|
|
* \param fpsLimit Desired framerate
|
|
|
|
*/
|
|
|
|
extern void setFramerateLimit(int fpsLimit);
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* Get the framerate limit
|
|
|
|
*
|
|
|
|
* \return Desired framerate
|
|
|
|
*/
|
|
|
|
extern int getFramerateLimit(void);
|
2007-06-28 10:47:08 -07:00
|
|
|
|
2007-12-29 14:34:41 -08:00
|
|
|
/** Call this each cycle to allow the framework to deal with
|
2007-06-28 10:47:08 -07:00
|
|
|
* windows messages, and do general house keeping.
|
|
|
|
*/
|
2007-05-12 14:47:06 -07:00
|
|
|
extern void frameUpdate(void);
|
2007-06-28 10:47:08 -07:00
|
|
|
|
2007-12-29 14:34:41 -08:00
|
|
|
/** Set the current cursor from a Resource ID
|
2007-06-28 10:47:08 -07:00
|
|
|
* This is the same as calling:
|
|
|
|
* frameSetCursor(LoadCursor(MAKEINTRESOURCE(resID)));
|
|
|
|
* but with a bit of extra error checking.
|
|
|
|
*/
|
2006-11-03 17:11:26 -08:00
|
|
|
extern void frameSetCursorFromRes(SWORD resID);
|
2007-06-28 10:47:08 -07:00
|
|
|
|
2007-12-29 14:34:41 -08:00
|
|
|
/** Returns the current frame we're on - used to establish whats on screen. */
|
2007-05-12 16:41:29 -07:00
|
|
|
extern UDWORD frameGetFrameNumber(void);
|
2007-06-28 10:47:08 -07:00
|
|
|
|
2007-12-29 14:34:41 -08:00
|
|
|
/** Return average framerate of the last seconds. */
|
2006-08-27 12:01:34 -07:00
|
|
|
extern UDWORD frameGetAverageRate(void);
|
2007-06-28 10:47:08 -07:00
|
|
|
|
2008-03-16 05:39:08 -07:00
|
|
|
extern UDWORD HashString( const char *String );
|
|
|
|
extern UDWORD HashStringIgnoreCase( const char *String );
|
2007-06-28 10:47:08 -07:00
|
|
|
|
2006-08-12 03:45:49 -07:00
|
|
|
|
2008-03-25 07:41:04 -07:00
|
|
|
static inline WZ_DECL_CONST const char * bool2string(bool var)
|
|
|
|
{
|
|
|
|
return (var ? "true" : "false");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-08-12 03:45:49 -07:00
|
|
|
/* Endianness hacks */
|
2007-05-13 15:37:13 -07:00
|
|
|
// TODO Use SDL_SwapXXXX instead
|
2006-08-12 03:45:49 -07:00
|
|
|
|
|
|
|
#ifdef __BIG_ENDIAN__
|
2006-11-24 17:26:05 -08:00
|
|
|
static inline void endian_uword(UWORD *uword) {
|
2006-08-12 03:45:49 -07:00
|
|
|
UBYTE tmp, *ptr;
|
|
|
|
|
|
|
|
ptr = (UBYTE *) uword;
|
|
|
|
tmp = ptr[0];
|
|
|
|
ptr[0] = ptr[1];
|
|
|
|
ptr[1] = tmp;
|
|
|
|
}
|
2006-11-24 17:26:05 -08:00
|
|
|
#else
|
2007-12-27 15:55:34 -08:00
|
|
|
# define endian_uword(x) ((void) (x))
|
2006-11-24 17:26:05 -08:00
|
|
|
#endif
|
2006-08-12 03:45:49 -07:00
|
|
|
|
|
|
|
#ifdef __BIG_ENDIAN__
|
2006-11-24 17:26:05 -08:00
|
|
|
static inline void endian_sword(SWORD *sword) {
|
2006-08-12 03:45:49 -07:00
|
|
|
UBYTE tmp, *ptr;
|
|
|
|
|
|
|
|
ptr = (UBYTE *) sword;
|
|
|
|
tmp = ptr[0];
|
|
|
|
ptr[0] = ptr[1];
|
|
|
|
ptr[1] = tmp;
|
|
|
|
}
|
2006-11-24 17:26:05 -08:00
|
|
|
#else
|
2007-12-27 15:55:34 -08:00
|
|
|
# define endian_sword(x) ((void) (x))
|
2006-11-24 17:26:05 -08:00
|
|
|
#endif
|
2006-08-12 03:45:49 -07:00
|
|
|
|
|
|
|
#ifdef __BIG_ENDIAN__
|
2006-11-24 17:26:05 -08:00
|
|
|
static inline void endian_udword(UDWORD *udword) {
|
2006-08-12 03:45:49 -07:00
|
|
|
UBYTE tmp, *ptr;
|
|
|
|
|
|
|
|
ptr = (UBYTE *) udword;
|
|
|
|
tmp = ptr[0];
|
|
|
|
ptr[0] = ptr[3];
|
|
|
|
ptr[3] = tmp;
|
|
|
|
tmp = ptr[1];
|
|
|
|
ptr[1] = ptr[2];
|
|
|
|
ptr[2] = tmp;
|
|
|
|
}
|
2006-11-24 17:26:05 -08:00
|
|
|
#else
|
2007-12-27 15:55:34 -08:00
|
|
|
# define endian_udword(x) ((void) (x))
|
2006-11-24 17:26:05 -08:00
|
|
|
#endif
|
2006-08-12 03:45:49 -07:00
|
|
|
|
|
|
|
#ifdef __BIG_ENDIAN__
|
2006-11-24 17:26:05 -08:00
|
|
|
static inline void endian_sdword(SDWORD *sdword) {
|
2006-08-12 03:45:49 -07:00
|
|
|
UBYTE tmp, *ptr;
|
|
|
|
|
|
|
|
ptr = (UBYTE *) sdword;
|
|
|
|
tmp = ptr[0];
|
|
|
|
ptr[0] = ptr[3];
|
|
|
|
ptr[3] = tmp;
|
|
|
|
tmp = ptr[1];
|
|
|
|
ptr[1] = ptr[2];
|
|
|
|
ptr[2] = tmp;
|
|
|
|
}
|
2006-11-24 17:26:05 -08:00
|
|
|
#else
|
2007-12-27 15:55:34 -08:00
|
|
|
# define endian_sdword(x) ((void) (x))
|
2006-11-24 17:26:05 -08:00
|
|
|
#endif
|
2006-08-12 03:45:49 -07:00
|
|
|
|
|
|
|
#ifdef __BIG_ENDIAN__
|
2007-05-19 14:32:19 -07:00
|
|
|
static inline void endian_fract(float *fract) {
|
2006-08-12 03:45:49 -07:00
|
|
|
UBYTE tmp, *ptr;
|
|
|
|
|
|
|
|
ptr = (UBYTE *) fract;
|
|
|
|
tmp = ptr[0];
|
|
|
|
ptr[0] = ptr[3];
|
|
|
|
ptr[3] = tmp;
|
|
|
|
tmp = ptr[1];
|
|
|
|
ptr[1] = ptr[2];
|
|
|
|
ptr[2] = ptr[1];
|
|
|
|
}
|
2006-11-24 17:26:05 -08:00
|
|
|
#else
|
2007-12-27 15:55:34 -08:00
|
|
|
# define endian_fract(x) ((void) (x))
|
2006-11-24 17:26:05 -08:00
|
|
|
#endif
|
2006-08-12 03:45:49 -07:00
|
|
|
|
2007-03-29 02:45:11 -07:00
|
|
|
void setupExceptionHandler(const char * programCommand);
|
2006-08-12 03:45:49 -07:00
|
|
|
|
2007-06-28 10:47:08 -07:00
|
|
|
#endif
|