scummsys.h 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454
  1. /* ScummVM Tools
  2. *
  3. * ScummVM Tools is the legal property of its developers, whose
  4. * names are too numerous to list here. Please refer to the
  5. * COPYRIGHT file distributed with this source distribution.
  6. *
  7. * Additionally this file is based on the ScummVM source code.
  8. * Copyright information for the ScummVM source code is
  9. * available in the COPYRIGHT file of the ScummVM source
  10. * distribution.
  11. *
  12. * This program is free software; you can redistribute it and/or
  13. * modify it under the terms of the GNU General Public License
  14. * as published by the Free Software Foundation; either version 2
  15. * of the License, or (at your option) any later version.
  16. *
  17. * This program is distributed in the hope that it will be useful,
  18. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  20. * GNU General Public License for more details.
  21. *
  22. * You should have received a copy of the GNU General Public License
  23. * along with this program; if not, write to the Free Software
  24. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  25. */
  26. #ifndef COMMON_SCUMMSYS_H
  27. #define COMMON_SCUMMSYS_H
  28. #if defined(_WIN32_WCE) && _WIN32_WCE < 300
  29. #define NONSTANDARD_PORT
  30. #endif
  31. #if defined(NONSTANDARD_PORT)
  32. // Ports which need to perform #includes and #defines visible in
  33. // virtually all the source of ScummVM should do so by providing a
  34. // "portdefs.h" header file (and not by directly modifying this
  35. // header file).
  36. #include <portdefs.h>
  37. #else // defined(NONSTANDARD_PORT)
  38. #if defined(WIN32)
  39. #ifdef _MSC_VER
  40. // vsnprintf is already defined in Visual Studio 2008
  41. #if (_MSC_VER < 1500)
  42. #define vsnprintf _vsnprintf
  43. #endif
  44. #endif
  45. #if !defined(_WIN32_WCE)
  46. #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
  47. #define NOGDICAPMASKS
  48. #define OEMRESOURCE
  49. #define NONLS
  50. #define NOICONS
  51. #define NOMCX
  52. #define NOPROFILER
  53. #define NOKANJI
  54. #define NOSERVICE
  55. #define NOMETAFILE
  56. #define NOCOMM
  57. #define NOCRYPT
  58. #define NOIME
  59. #define NOATOM
  60. #define NOCTLMGR
  61. #define NOCLIPBOARD
  62. #define NOMEMMGR
  63. #define NOSYSMETRICS
  64. #define NOMENUS
  65. #define NOOPENFILE
  66. #define NOWH
  67. #define NOSOUND
  68. #define NODRAWTEXT
  69. #endif
  70. #if defined(ARRAYSIZE)
  71. // VS2005beta2 introduces new stuff in winnt.h
  72. #undef ARRAYSIZE
  73. #endif
  74. #endif
  75. #if defined(__QNXNTO__)
  76. #include <strings.h> /* For strcasecmp */
  77. #endif
  78. #include <stdio.h>
  79. #include <stdlib.h>
  80. #include <string.h>
  81. #include <stdarg.h>
  82. #include <assert.h>
  83. #include <ctype.h>
  84. #include <math.h>
  85. #endif
  86. // Use config.h, generated by configure
  87. #if defined(HAVE_CONFIG_H)
  88. #include "config.h"
  89. #endif
  90. // make sure we really are compiling for WIN32
  91. #ifndef WIN32
  92. #undef _MSC_VER
  93. #endif
  94. // In the following we configure various targets, in particular those
  95. // which can't use our "configure" tool and hence don't use config.h.
  96. //
  97. // Some #defines that occur here frequently:
  98. // SCUMM_LITTLE_ENDIAN
  99. // - Define this on a little endian target
  100. // SCUMM_BIG_ENDIAN
  101. // - Define this on a big endian target
  102. // SCUMM_NEED_ALIGNMENT
  103. // - Define this if your system has problems reading e.g. an int32 from an odd address
  104. // SCUMMVM_DONT_DEFINE_TYPES
  105. // - Define this if you need to provide your own typedefs, e.g. because your
  106. // system headers conflict with our typenames, or because you have odd
  107. // type requirements.
  108. // SMALL_SCREEN_DEVICE
  109. // - ...
  110. // ...
  111. // We define all types in config.h, so we don't want to typedef those types
  112. // here again!
  113. #ifdef HAVE_CONFIG_H
  114. #define SCUMMVM_DONT_DEFINE_TYPES
  115. #endif
  116. //
  117. // By default we try to use pragma push/pop to ensure various structs we use
  118. // are "packed". If your compiler doesn't support this pragma, you are in for
  119. // a problem. If you are lucky, there is a compiler switch, or another pragma,
  120. // doing the same thing -- in that case, try to modify common/pack-begin.h and
  121. // common/pack-end.h accordingly. Or maybe your port simply *always* packs
  122. // everything, in which case you could #undefine SCUMMVM_USE_PRAGMA_PACK.
  123. //
  124. // If neither is possible, tough luck. Try to contact the team, maybe we can
  125. // come up with a solution, though I wouldn't hold my breath on it :-/.
  126. //
  127. #define SCUMMVM_USE_PRAGMA_PACK
  128. #if defined(__SYMBIAN32__)
  129. #define scumm_stricmp strcasecmp
  130. #define scumm_strnicmp strncasecmp
  131. #define SCUMM_LITTLE_ENDIAN
  132. #define SCUMM_NEED_ALIGNMENT
  133. #define SMALL_SCREEN_DEVICE
  134. // Enable Symbians own datatypes
  135. // This is done for two reasons
  136. // a) uint is already defined by Symbians libc component
  137. // b) Symbian is using its "own" datatyping, and the Scummvm port
  138. // should follow this to ensure the best compability possible.
  139. #define SCUMMVM_DONT_DEFINE_TYPES
  140. typedef unsigned char byte;
  141. typedef unsigned char uint8;
  142. typedef signed char int8;
  143. typedef unsigned short int uint16;
  144. typedef signed short int int16;
  145. typedef unsigned long int uint32;
  146. typedef signed long int int32;
  147. #elif defined(_WIN32_WCE)
  148. #define scumm_stricmp stricmp
  149. #define scumm_strnicmp _strnicmp
  150. #define snprintf _snprintf
  151. #define SCUMM_LITTLE_ENDIAN
  152. #ifndef __GNUC__
  153. #define FORCEINLINE __forceinline
  154. #define NORETURN_PRE __declspec(noreturn)
  155. #endif
  156. #define PLUGIN_EXPORT __declspec(dllexport)
  157. #if _WIN32_WCE < 300
  158. #define SMALL_SCREEN_DEVICE
  159. #endif
  160. #elif defined(_MSC_VER)
  161. #define scumm_stricmp _stricmp
  162. #define scumm_strnicmp _strnicmp
  163. #define snprintf _snprintf
  164. #define SCUMM_LITTLE_ENDIAN
  165. #define FORCEINLINE __forceinline
  166. #define NORETURN_PRE __declspec(noreturn)
  167. #define PLUGIN_EXPORT __declspec(dllexport)
  168. #elif defined(__MINGW32__)
  169. #define scumm_stricmp stricmp
  170. #define scumm_strnicmp strnicmp
  171. #define SCUMM_LITTLE_ENDIAN
  172. #define PLUGIN_EXPORT __declspec(dllexport)
  173. #elif defined(POSIX)
  174. #define scumm_stricmp strcasecmp
  175. #define scumm_strnicmp strncasecmp
  176. #ifndef CONFIG_H
  177. /* need this for the SDL_BYTEORDER define */
  178. //#include <SDL_byteorder.h>
  179. #define SDL_BYTEORDER SDL_LIL_ENDIAN
  180. #if SDL_BYTEORDER == SDL_LIL_ENDIAN
  181. #define SCUMM_LITTLE_ENDIAN
  182. #elif SDL_BYTEORDER == SDL_BIG_ENDIAN
  183. #define SCUMM_BIG_ENDIAN
  184. #else
  185. #error Neither SDL_BIG_ENDIAN nor SDL_LIL_ENDIAN is set.
  186. #endif
  187. #endif
  188. // You need to set this manually if necessary
  189. // #define SCUMM_NEED_ALIGNMENT
  190. #if defined(__DECCXX) // Assume alpha architecture
  191. #define INVERSE_MKID
  192. #define SCUMM_NEED_ALIGNMENT
  193. #endif
  194. #elif defined(__PALMOS_TRAPS__) || defined (__PALMOS_ARMLET__)
  195. #ifdef __PALMOS_ARMLET__
  196. #include <extras_string.h>
  197. #endif
  198. #define SCUMM_LITTLE_ENDIAN
  199. #define scumm_stricmp stricmp
  200. #define scumm_strnicmp strnicmp
  201. #define SCUMM_NEED_ALIGNMENT
  202. #define STRINGBUFLEN 256
  203. extern const char *SCUMMVM_SAVEPATH;
  204. #if !defined(COMPILE_ZODIAC) && !defined(COMPILE_OS5)
  205. # define NEWGUI_256
  206. #else
  207. # undef UNUSED
  208. #endif
  209. #elif defined(__DC__)
  210. #define scumm_stricmp strcasecmp
  211. #define scumm_strnicmp strncasecmp
  212. #define SCUMM_LITTLE_ENDIAN
  213. #define SCUMM_NEED_ALIGNMENT
  214. #elif defined(__GP32__)
  215. #define scumm_stricmp stricmp
  216. #define scumm_strnicmp strnicmp
  217. #define SCUMM_LITTLE_ENDIAN
  218. #define SCUMM_NEED_ALIGNMENT
  219. // Override typenames. uint is already defined by system header files.
  220. #define SCUMMVM_DONT_DEFINE_TYPES
  221. typedef unsigned char byte;
  222. typedef unsigned char uint8;
  223. typedef signed char int8;
  224. typedef unsigned short int uint16;
  225. typedef signed short int int16;
  226. typedef unsigned long int uint32;
  227. typedef signed long int int32;
  228. #elif defined(__PLAYSTATION2__)
  229. #define scumm_stricmp strcasecmp
  230. #define scumm_strnicmp strncasecmp
  231. #define SCUMM_LITTLE_ENDIAN
  232. #define SCUMM_NEED_ALIGNMENT
  233. #elif defined(__N64__)
  234. #define scumm_stricmp strcasecmp
  235. #define scumm_strnicmp strncasecmp
  236. #define SCUMM_BIG_ENDIAN
  237. #define SCUMM_NEED_ALIGNMENT
  238. #define STRINGBUFLEN 256
  239. #define SCUMMVM_DONT_DEFINE_TYPES
  240. typedef unsigned char byte;
  241. typedef unsigned char uint8;
  242. typedef signed char int8;
  243. typedef unsigned short int uint16;
  244. typedef signed short int int16;
  245. typedef unsigned int uint32;
  246. typedef signed int int32;
  247. typedef unsigned long long uint64;
  248. typedef signed long long int64;
  249. #elif defined(__PSP__)
  250. #include <malloc.h>
  251. #define scumm_stricmp strcasecmp
  252. #define scumm_strnicmp strncasecmp
  253. #define SCUMM_LITTLE_ENDIAN
  254. #define SCUMM_NEED_ALIGNMENT
  255. #elif defined(__amigaos4__)
  256. #define scumm_stricmp strcasecmp
  257. #define scumm_strnicmp strncasecmp
  258. #define SCUMM_BIG_ENDIAN
  259. #define SCUMM_NEED_ALIGNMENT
  260. #elif defined (__DS__)
  261. #define scumm_stricmp stricmp
  262. #define scumm_strnicmp strnicmp
  263. #define SCUMM_NEED_ALIGNMENT
  264. #define SCUMM_LITTLE_ENDIAN
  265. #define SCUMMVM_DONT_DEFINE_TYPES
  266. #define STRINGBUFLEN 256
  267. // #define printf(fmt, ...) consolePrintf(fmt, ##__VA_ARGS__)
  268. #elif defined(__WII__)
  269. #define scumm_stricmp strcasecmp
  270. #define scumm_strnicmp strncasecmp
  271. #define SCUMM_BIG_ENDIAN
  272. #define SCUMM_NEED_ALIGNMENT
  273. #else
  274. #error No system type defined
  275. #endif
  276. //
  277. // GCC specific stuff
  278. //
  279. #if defined(__GNUC__)
  280. #define NORETURN_POST __attribute__((__noreturn__))
  281. #define PACKED_STRUCT __attribute__((__packed__))
  282. #define GCC_PRINTF(x,y) __attribute__((__format__(printf, x, y)))
  283. #if !defined(FORCEINLINE) && (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1))
  284. #define FORCEINLINE inline __attribute__((__always_inline__))
  285. #endif
  286. #else
  287. #define PACKED_STRUCT
  288. #define GCC_PRINTF(x,y)
  289. #endif
  290. //
  291. // Fallbacks / default values for various special macros
  292. //
  293. #ifndef FORCEINLINE
  294. #define FORCEINLINE inline
  295. #endif
  296. #ifndef PLUGIN_EXPORT
  297. #define PLUGIN_EXPORT
  298. #endif
  299. #ifndef NORETURN_PRE
  300. #define NORETURN_PRE
  301. #endif
  302. #ifndef NORETURN_POST
  303. #define NORETURN_POST
  304. #endif
  305. #ifndef STRINGBUFLEN
  306. #define STRINGBUFLEN 1024
  307. #endif
  308. #ifndef PI
  309. #define PI 3.14159265358979323846
  310. #endif
  311. #ifndef MAXPATHLEN
  312. #define MAXPATHLEN 256
  313. #endif
  314. //
  315. // Typedef our system types unless SCUMMVM_DONT_DEFINE_TYPES is set.
  316. //
  317. #ifndef SCUMMVM_DONT_DEFINE_TYPES
  318. typedef unsigned char byte;
  319. typedef unsigned char uint8;
  320. typedef signed char int8;
  321. typedef unsigned short uint16;
  322. typedef signed short int16;
  323. typedef unsigned int uint32;
  324. typedef signed int int32;
  325. typedef unsigned int uint;
  326. #endif
  327. //
  328. // Overlay color type (FIXME: shouldn't be declared here)
  329. //
  330. #if defined(NEWGUI_256)
  331. // 256 color only on PalmOS
  332. typedef byte OverlayColor;
  333. #else
  334. // 15/16 bit color mode everywhere else...
  335. typedef uint16 OverlayColor;
  336. #endif
  337. #endif