diff options
Diffstat (limited to 'common/scummsys.h')
-rw-r--r-- | common/scummsys.h | 308 |
1 files changed, 83 insertions, 225 deletions
diff --git a/common/scummsys.h b/common/scummsys.h index 6554c70163..b691250419 100644 --- a/common/scummsys.h +++ b/common/scummsys.h @@ -18,9 +18,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * $URL$ - * $Id$ - * */ #ifndef COMMON_SCUMMSYS_H @@ -47,6 +44,9 @@ #if (_MSC_VER < 1500) #define vsnprintf _vsnprintf #endif + // FIXME: Is this actually necessary for WinCE or Windows? + // If yes, please add corresponding comments. Otherwise, let's get rid of it! + #define snprintf _snprintf #endif #if !defined(_WIN32_WCE) @@ -110,11 +110,6 @@ #include "config.h" #endif -// make sure we really are compiling for WIN32 -#ifndef WIN32 -#undef _MSC_VER -#endif - // In the following we configure various targets, in particular those // which can't use our "configure" tool and hence don't use config.h. @@ -126,20 +121,10 @@ // - Define this on a big endian target // SCUMM_NEED_ALIGNMENT // - Define this if your system has problems reading e.g. an int32 from an odd address -// SCUMMVM_DONT_DEFINE_TYPES -// - Define this if you need to provide your own typedefs, e.g. because your -// system headers conflict with our typenames, or because you have odd -// type requirements. // SMALL_SCREEN_DEVICE // - ... // ... -// We define all types in config.h, so we don't want to typedef those types -// here again! -#ifdef HAVE_CONFIG_H -#define SCUMMVM_DONT_DEFINE_TYPES -#endif - // // By default we try to use pragma push/pop to ensure various structs we use @@ -154,82 +139,36 @@ // #define SCUMMVM_USE_PRAGMA_PACK +// +// Determine the host endianess and whether memory alignment is required. +// +#if !defined(HAVE_CONFIG_H) -#if defined(__SYMBIAN32__) - - #define scumm_stricmp strcasecmp - #define scumm_strnicmp strncasecmp - - #define SCUMM_LITTLE_ENDIAN - #define SCUMM_NEED_ALIGNMENT - - #define SMALL_SCREEN_DEVICE - - // Enable Symbians own datatypes - // This is done for two reasons - // a) uint is already defined by Symbians libc component - // b) Symbian is using its "own" datatyping, and the Scummvm port - // should follow this to ensure the best compability possible. - #define SCUMMVM_DONT_DEFINE_TYPES - typedef unsigned char byte; - - typedef unsigned char uint8; - typedef signed char int8; - - typedef unsigned short int uint16; - typedef signed short int int16; - - typedef unsigned long int uint32; - typedef signed long int int32; - -#elif defined(_WIN32_WCE) - - #define scumm_stricmp stricmp - #define scumm_strnicmp _strnicmp - #define snprintf _snprintf - - #define SCUMM_LITTLE_ENDIAN - - #ifndef __GNUC__ - #define FORCEINLINE __forceinline - #define NORETURN_PRE __declspec(noreturn) - #endif - #define PLUGIN_EXPORT __declspec(dllexport) - - #if _WIN32_WCE < 300 - #define SMALL_SCREEN_DEVICE - #endif - -#elif defined(_MSC_VER) - - #define scumm_stricmp stricmp - #define scumm_strnicmp _strnicmp - #define snprintf _snprintf - - #define SCUMM_LITTLE_ENDIAN - - #define FORCEINLINE __forceinline - #define NORETURN_PRE __declspec(noreturn) - #define PLUGIN_EXPORT __declspec(dllexport) - - -#elif defined(__MINGW32__) + #if defined(__DC__) || \ + defined(__DS__) || \ + defined(__GP32__) || \ + defined(IPHONE) || \ + defined(__PLAYSTATION2__) || \ + defined(__PSP__) || \ + defined(__SYMBIAN32__) - #define scumm_stricmp stricmp - #define scumm_strnicmp strnicmp + #define SCUMM_LITTLE_ENDIAN + #define SCUMM_NEED_ALIGNMENT - #define SCUMM_LITTLE_ENDIAN + #elif defined(_WIN32_WCE) || defined(_MSC_VER) || defined(__MINGW32__) - #define PLUGIN_EXPORT __declspec(dllexport) + #define SCUMM_LITTLE_ENDIAN -#elif defined(UNIX) + #elif defined(__amigaos4__) || defined(__N64__) || defined(__WII__) - #define scumm_stricmp strcasecmp - #define scumm_strnicmp strncasecmp + #define SCUMM_BIG_ENDIAN + #define SCUMM_NEED_ALIGNMENT - #ifndef CONFIG_H - /* need this for the SDL_BYTEORDER define */ - #include <SDL_byteorder.h> + #elif defined(SDL_BACKEND) + // On SDL based ports, we try to use SDL_BYTEORDER to determine the + // endianess. We explicitly do this as the *last* thing we try, so that + // platform specific settings have precedence. + #include <SDL_endian.h> #if SDL_BYTEORDER == SDL_LIL_ENDIAN #define SCUMM_LITTLE_ENDIAN @@ -238,171 +177,96 @@ #else #error Neither SDL_BIG_ENDIAN nor SDL_LIL_ENDIAN is set. #endif + + #else + + #error No system type defined, host endianess unknown. + #endif +#endif - // You need to set this manually if necessary -// #define SCUMM_NEED_ALIGNMENT + +// +// Some more system specific settings. +// TODO/FIXME: All of these should be moved to backend specific files (such as portdefs.h) +// +#if defined(DINGUX) // Very BAD hack following, used to avoid triggering an assert in uClibc dingux library // "toupper" when pressing keyboard function keys. - #if defined(DINGUX) #undef toupper #define toupper(c) (((c & 0xFF) >= 97) && ((c & 0xFF) <= 122) ? ((c & 0xFF) - 32) : (c & 0xFF)) - #endif - -#elif defined(__DC__) - - #define scumm_stricmp strcasecmp - #define scumm_strnicmp strncasecmp - - #define SCUMM_LITTLE_ENDIAN - #define SCUMM_NEED_ALIGNMENT - -#elif defined(__GP32__) - - #define scumm_stricmp stricmp - #define scumm_strnicmp strnicmp - - #define SCUMM_LITTLE_ENDIAN - #define SCUMM_NEED_ALIGNMENT - - // Override typenames. uint is already defined by system header files. - #define SCUMMVM_DONT_DEFINE_TYPES - typedef unsigned char byte; - - typedef unsigned char uint8; - typedef signed char int8; - - typedef unsigned short int uint16; - typedef signed short int int16; - - typedef unsigned long int uint32; - typedef signed long int int32; - -#elif defined(__PLAYSTATION2__) - - #define scumm_stricmp strcasecmp - #define scumm_strnicmp strncasecmp - - #define SCUMM_LITTLE_ENDIAN - #define SCUMM_NEED_ALIGNMENT - -#elif defined(__N64__) - - #define scumm_stricmp strcasecmp - #define scumm_strnicmp strncasecmp - - #define SCUMM_BIG_ENDIAN - #define SCUMM_NEED_ALIGNMENT - - #define STRINGBUFLEN 256 - - #define SCUMMVM_DONT_DEFINE_TYPES - typedef unsigned char byte; - - typedef unsigned char uint8; - typedef signed char int8; - - typedef unsigned short int uint16; - typedef signed short int int16; - - typedef unsigned int uint32; - typedef signed int int32; - - typedef unsigned long long uint64; - typedef signed long long int64; #elif defined(__PSP__) #include <malloc.h> #include "backends/platform/psp/memory.h" - #define scumm_stricmp strcasecmp - #define scumm_strnicmp strncasecmp - - #define SCUMM_LITTLE_ENDIAN - #define SCUMM_NEED_ALIGNMENT - /* to make an efficient, inlined memcpy implementation */ #define memcpy(dst, src, size) psp_memcpy(dst, src, size) -#elif defined(__amigaos4__) - - #define scumm_stricmp strcasecmp - #define scumm_strnicmp strncasecmp - - #define SCUMM_BIG_ENDIAN - #define SCUMM_NEED_ALIGNMENT - -#elif defined (__DS__) - - #define scumm_stricmp stricmp - #define scumm_strnicmp strnicmp - - #define SCUMM_NEED_ALIGNMENT - #define SCUMM_LITTLE_ENDIAN - - #define SCUMMVM_DONT_DEFINE_TYPES - - #define STRINGBUFLEN 256 -// #define printf(fmt, ...) consolePrintf(fmt, ##__VA_ARGS__) - -#elif defined(__WII__) - - #define scumm_stricmp strcasecmp - #define scumm_strnicmp strncasecmp - - #define SCUMM_BIG_ENDIAN - #define SCUMM_NEED_ALIGNMENT - -#else - #error No system type defined - #endif // -// GCC specific stuff +// Fallbacks / default values for various special macros // -#if defined(__GNUC__) - #define NORETURN_POST __attribute__((__noreturn__)) - #define PACKED_STRUCT __attribute__((__packed__)) - #define GCC_PRINTF(x,y) __attribute__((__format__(printf, x, y))) - - #if !defined(FORCEINLINE) && (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1)) - #define FORCEINLINE inline __attribute__((__always_inline__)) +#ifndef GCC_PRINTF + #if defined(__GNUC__) || defined(__INTEL_COMPILER) + #define GCC_PRINTF(x,y) __attribute__((__format__(__printf__, x, y))) + #else + #define GCC_PRINTF(x,y) #endif -#elif defined(__INTEL_COMPILER) - #define NORETURN_POST __attribute__((__noreturn__)) - #define PACKED_STRUCT __attribute__((__packed__)) - #define GCC_PRINTF(x,y) __attribute__((__format__(printf, x, y))) -#else - #define PACKED_STRUCT - #define GCC_PRINTF(x,y) #endif +#ifndef PACKED_STRUCT + #if defined(__GNUC__) || defined(__INTEL_COMPILER) + #define PACKED_STRUCT __attribute__((__packed__)) + #else + #define PACKED_STRUCT + #endif +#endif -// -// Fallbacks / default values for various special macros -// #ifndef FORCEINLINE -#define FORCEINLINE inline + #if defined(_MSC_VER) + #define FORCEINLINE __forceinline + #elif (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1)) + #define FORCEINLINE inline __attribute__((__always_inline__)) + #else + #define FORCEINLINE inline + #endif #endif #ifndef PLUGIN_EXPORT -#define PLUGIN_EXPORT + #if defined(_MSC_VER) || defined(_WIN32_WCE) || defined(__MINGW32__) + #define PLUGIN_EXPORT __declspec(dllexport) + #else + #define PLUGIN_EXPORT + #endif #endif #ifndef NORETURN_PRE -#define NORETURN_PRE + #if defined(_MSC_VER) + #define NORETURN_PRE __declspec(noreturn) + #else + #define NORETURN_PRE + #endif #endif #ifndef NORETURN_POST -#define NORETURN_POST + #if defined(__GNUC__) || defined(__INTEL_COMPILER) + #define NORETURN_POST __attribute__((__noreturn__)) + #else + #define NORETURN_POST + #endif #endif #ifndef STRINGBUFLEN -#define STRINGBUFLEN 1024 + #if defined(__N64__) || defined(__DS__) + #define STRINGBUFLEN 256 + #else + #define STRINGBUFLEN 1024 + #endif #endif #ifndef MAXPATHLEN @@ -411,9 +275,10 @@ // -// Typedef our system types unless SCUMMVM_DONT_DEFINE_TYPES is set. +// Typedef our system types unless they have already been defined by config.h, +// or SCUMMVM_DONT_DEFINE_TYPES is set. // -#ifndef SCUMMVM_DONT_DEFINE_TYPES +#if !defined(HAVE_CONFIG_H) && !defined(SCUMMVM_DONT_DEFINE_TYPES) typedef unsigned char byte; typedef unsigned char uint8; typedef signed char int8; @@ -425,18 +290,11 @@ #endif - // // Overlay color type (FIXME: shouldn't be declared here) // -#if defined(NEWGUI_256) - // 256 color only on PalmOS - typedef byte OverlayColor; -#else - // 15/16 bit color mode everywhere else... - typedef uint16 OverlayColor; -#endif +typedef uint16 OverlayColor; -#include "common/forbidden.h" +#include "common/forbidden.h" #endif |