common.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. //
  2. // Copyright (c) 2009, Wei Mingzhi <whistler_wmz@users.sf.net>.
  3. // All rights reserved.
  4. //
  5. // This file is part of SDLPAL.
  6. //
  7. // SDLPAL is free software: you can redistribute it and/or modify
  8. // it under the terms of the GNU General Public License as published by
  9. // the Free Software Foundation, either version 3 of the License, or
  10. // (at your option) any later version.
  11. //
  12. // This program is distributed in the hope that it will be useful,
  13. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. // GNU General Public License for more details.
  16. //
  17. // You should have received a copy of the GNU General Public License
  18. // along with this program. If not, see <http://www.gnu.org/licenses/>.
  19. //
  20. #ifndef _COMMON_H
  21. #define _COMMON_H
  22. //#define PAL_WIN95 1 // not valid for now
  23. //#define PAL_CLASSIC 1
  24. #ifdef __cplusplus
  25. extern "C"
  26. {
  27. #endif
  28. #include <stdio.h>
  29. #include <stdlib.h>
  30. #include <string.h>
  31. #include <time.h>
  32. #include <limits.h>
  33. #include <stdarg.h>
  34. #include <assert.h>
  35. #include "SDL.h"
  36. #include "SDL_endian.h"
  37. #ifdef _SDL_stdinc_h
  38. #define malloc SDL_malloc
  39. #define calloc SDL_calloc
  40. #define free SDL_free
  41. #define realloc SDL_realloc
  42. #endif
  43. #if SDL_BYTEORDER == SDL_LIL_ENDIAN
  44. #define SWAP16(X) (X)
  45. #define SWAP32(X) (X)
  46. #else
  47. #define SWAP16(X) SDL_Swap16(X)
  48. #define SWAP32(X) SDL_Swap32(X)
  49. #endif
  50. #ifndef max
  51. #define max(a, b) (((a) > (b)) ? (a) : (b))
  52. #endif
  53. #ifndef min
  54. #define min(a, b) (((a) < (b)) ? (a) : (b))
  55. #endif
  56. #if defined (__SYMBIAN32__)
  57. #undef _WIN32
  58. #undef SDL_INIT_JOYSTICK
  59. #define SDL_INIT_JOYSTICK 0
  60. #define PAL_HAS_MOUSE 1
  61. #define PAL_PREFIX "e:/data/pal/"
  62. #define PAL_SAVE_PREFIX "e:/data/pal/"
  63. #elif defined (GEKKO)
  64. #define PAL_HAS_JOYSTICKS 1
  65. #define PAL_HAS_MOUSE 0
  66. #define PAL_PREFIX "SD:/apps/sdlpal/"
  67. #define PAL_SAVE_PREFIX "SD:/apps/sdlpal/"
  68. #elif defined (PSP)
  69. #define PAL_HAS_JOYSTICKS 0
  70. #define PAL_PREFIX "ms0:/"
  71. #define PAL_SAVE_PREFIX "ms0:/PSP/SAVEDATA/SDLPAL/"
  72. #else
  73. #define PAL_HAS_JOYSTICKS 1
  74. #ifndef _WIN32_WCE
  75. #define PAL_ALLOW_KEYREPEAT 1
  76. #if SDL_MAJOR_VERSION == 1 && SDL_MINOR_VERSION <= 2
  77. #define PAL_HAS_CD 1
  78. #endif
  79. #if !defined (CYGWIN) && !defined (DINGOO) && !defined (GPH) && !defined (GEKKO)
  80. #define PAL_HAS_MP3 1
  81. #endif
  82. #endif
  83. #ifndef PAL_PREFIX
  84. #define PAL_PREFIX "./"
  85. #endif
  86. #ifndef PAL_SAVE_PREFIX
  87. #define PAL_SAVE_PREFIX "./"
  88. #endif
  89. #endif
  90. #ifndef SDL_INIT_CDROM
  91. #define SDL_INIT_CDROM 0
  92. #endif
  93. #ifdef _WIN32
  94. #include <windows.h>
  95. #if !defined(__BORLANDC__) && !defined(_WIN32_WCE)
  96. #include <io.h>
  97. #endif
  98. #define vsnprintf _vsnprintf
  99. #ifdef _MSC_VER
  100. #pragma warning (disable:4018)
  101. #pragma warning (disable:4028)
  102. #pragma warning (disable:4244)
  103. #pragma warning (disable:4305)
  104. #pragma warning (disable:4761)
  105. #pragma warning (disable:4996)
  106. #endif
  107. #ifndef _LPCBYTE_DEFINED
  108. #define _LPCBYTE_DEFINED
  109. typedef const BYTE *LPCBYTE;
  110. #endif
  111. #define PAL_HAS_NATIVEMIDI 1
  112. #else
  113. #include <unistd.h>
  114. #define CONST const
  115. #ifndef FALSE
  116. #define FALSE 0
  117. #endif
  118. #ifndef TRUE
  119. #define TRUE 1
  120. #endif
  121. #define VOID void
  122. typedef char CHAR;
  123. typedef short SHORT;
  124. typedef long LONG;
  125. typedef unsigned long ULONG, *PULONG;
  126. typedef unsigned short USHORT, *PUSHORT;
  127. typedef unsigned char UCHAR, *PUCHAR;
  128. typedef unsigned short WORD, *LPWORD;
  129. typedef unsigned int DWORD, *LPDWORD;
  130. typedef int INT, *LPINT, BOOL, *LPBOOL;
  131. typedef unsigned int UINT, *PUINT, UINT32, *PUINT32;
  132. typedef unsigned char BYTE, *LPBYTE;
  133. typedef CONST BYTE *LPCBYTE;
  134. typedef float FLOAT, *LPFLOAT;
  135. typedef void *LPVOID;
  136. typedef const void *LPCVOID;
  137. typedef CHAR *LPSTR;
  138. typedef const CHAR *LPCSTR;
  139. #endif
  140. #if defined (__SYMBIAN32__)
  141. #define PAL_LARGE static
  142. #else
  143. #define PAL_LARGE /* */
  144. #endif
  145. #ifdef __cplusplus
  146. }
  147. #endif
  148. #endif