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-02-19 06:10:44 -08:00
|
|
|
#include <string.h>
|
|
|
|
|
2006-09-23 10:24:55 -07:00
|
|
|
#include "platform.h"
|
2006-03-17 17:59:59 -08:00
|
|
|
#include "macros.h"
|
|
|
|
|
2007-06-28 10:47:08 -07:00
|
|
|
#include "types.h"
|
|
|
|
#include "debug.h"
|
|
|
|
#include "mem.h"
|
|
|
|
|
|
|
|
#include "heap.h"
|
|
|
|
#include "treap.h"
|
2006-09-23 10:24:55 -07:00
|
|
|
#include "block.h"
|
|
|
|
|
2007-06-28 10:47:08 -07:00
|
|
|
#include "fractions.h"
|
|
|
|
#include "trig.h"
|
|
|
|
|
2007-03-31 08:34:35 -07:00
|
|
|
#include "gettext.h"
|
2006-06-03 16:46:03 -07:00
|
|
|
|
2007-06-28 10:47:08 -07: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
|
|
|
|
|
|
|
/* Shut down the framework library.
|
|
|
|
* This clears up all the Direct Draw stuff and ensures
|
|
|
|
* that Windows gets restored properly after Full screen mode.
|
|
|
|
*/
|
|
|
|
extern void frameShutDown(void);
|
|
|
|
|
|
|
|
/* The current status of the framework */
|
|
|
|
typedef enum _frame_status
|
|
|
|
{
|
|
|
|
FRAME_OK, // Everything normal
|
|
|
|
FRAME_KILLFOCUS, // The main app window has lost focus (might well want to pause)
|
|
|
|
FRAME_SETFOCUS, // The main app window has focus back
|
|
|
|
FRAME_QUIT, // The main app window has been told to quit
|
|
|
|
} FRAME_STATUS;
|
|
|
|
|
|
|
|
/* Call this each cycle to allow the framework to deal with
|
|
|
|
* windows messages, and do general house keeping.
|
|
|
|
*
|
|
|
|
* Returns FRAME_STATUS.
|
|
|
|
*/
|
|
|
|
extern FRAME_STATUS frameUpdate(void);
|
|
|
|
|
|
|
|
/* Set the current cursor from a Resource ID
|
|
|
|
* 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
|
|
|
|
|
|
|
/* Returns the current frame we're on - used to establish whats on screen */
|
|
|
|
extern UDWORD frameGetFrameNumber(void);
|
|
|
|
|
2006-08-27 12:01:34 -07:00
|
|
|
/**
|
|
|
|
* Average framerate of the last seconds
|
|
|
|
*
|
|
|
|
* \return Average framerate
|
|
|
|
*/
|
|
|
|
extern UDWORD frameGetAverageRate(void);
|
2007-06-28 10:47:08 -07:00
|
|
|
|
|
|
|
|
2006-12-31 12:29:24 -08:00
|
|
|
/**
|
|
|
|
* Set the framerate limit
|
|
|
|
*
|
|
|
|
* \param fpsLimit Desired framerate
|
|
|
|
*/
|
|
|
|
extern void setFramerateLimit(Uint32 fpsLimit);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the framerate limit
|
|
|
|
*
|
|
|
|
* \return Desired framerate
|
|
|
|
*/
|
|
|
|
extern Uint32 getFramerateLimit(void);
|
|
|
|
|
2007-06-28 10:47:08 -07:00
|
|
|
/* Load the file with name pointed to by pFileName into a memory buffer. */
|
2006-12-31 12:29:24 -08:00
|
|
|
extern BOOL loadFile(const char *pFileName, // The filename
|
2006-08-12 09:52:37 -07:00
|
|
|
char **ppFileData, // A buffer containing the file contents
|
2007-06-28 10:47:08 -07:00
|
|
|
UDWORD *pFileSize); // The size of this buffer
|
|
|
|
|
|
|
|
/* Save the data in the buffer into the given file */
|
|
|
|
extern BOOL saveFile(const char *pFileName, const char *pFileData, UDWORD fileSize);
|
|
|
|
|
|
|
|
// load a file from disk into a fixed memory buffer
|
2006-09-13 14:16:17 -07:00
|
|
|
BOOL loadFileToBuffer(const char *pFileName, char *pFileBuffer, UDWORD bufferSize, UDWORD *pSize);
|
2007-06-28 10:47:08 -07:00
|
|
|
|
|
|
|
// as above but returns quietly if no file found
|
2006-09-13 14:16:17 -07:00
|
|
|
BOOL loadFileToBufferNoError(const char *pFileName, char *pFileBuffer, UDWORD bufferSize,
|
2007-06-28 10:47:08 -07:00
|
|
|
UDWORD *pSize);
|
|
|
|
|
|
|
|
extern SDWORD ftol(float f);
|
|
|
|
|
2006-11-03 17:11:26 -08:00
|
|
|
UDWORD HashString( const char *String );
|
|
|
|
UDWORD HashStringIgnoreCase( const char *String );
|
2007-06-28 10:47:08 -07:00
|
|
|
|
2006-08-12 03:45:49 -07:00
|
|
|
|
|
|
|
/* Endianness hacks */
|
|
|
|
|
|
|
|
#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
|
|
|
|
# define endian_uword(x)
|
|
|
|
#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
|
|
|
|
# define endian_sword(x)
|
|
|
|
#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
|
|
|
|
# define endian_udword(x)
|
|
|
|
#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
|
|
|
|
# define endian_sdword(x)
|
|
|
|
#endif
|
2006-08-12 03:45:49 -07:00
|
|
|
|
|
|
|
#ifdef __BIG_ENDIAN__
|
2006-11-24 17:26:05 -08:00
|
|
|
static inline void endian_fract(FRACT *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
|
|
|
|
# define endian_fract(x)
|
|
|
|
#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
|