V-Gears 0
Free Final Fantasy VII engine.
scummsys.h
Go to the documentation of this file.
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
27#ifndef COMMON_SCUMMSYS_H
28#define COMMON_SCUMMSYS_H
29
30
31#if defined(_WIN32_WCE) && _WIN32_WCE < 300
32 #define NONSTANDARD_PORT
33#endif
34
35#if defined(NONSTANDARD_PORT)
36
37 // Ports which need to perform #includes and #defines visible in
38 // virtually all the source of ScummVM should do so by providing a
39 // "portdefs.h" header file (and not by directly modifying this
40 // header file).
41 #include <portdefs.h>
42#else // defined(NONSTANDARD_PORT)
43
44 #if defined(WIN32)
45
46 #ifdef _MSC_VER
47 // vsnprintf is already defined in Visual Studio 2008
48 #if (_MSC_VER < 1500)
49 #define vsnprintf _vsnprintf
50 #endif
51 #endif
52
53 #if !defined(_WIN32_WCE)
54
55 #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
56 #define NOGDICAPMASKS
57 #define OEMRESOURCE
58 #define NONLS
59 #define NOICONS
60 #define NOMCX
61 #define NOPROFILER
62 #define NOKANJI
63 #define NOSERVICE
64 #define NOMETAFILE
65 #define NOCOMM
66 #define NOCRYPT
67 #define NOIME
68 #define NOATOM
69 #define NOCTLMGR
70 #define NOCLIPBOARD
71 #define NOMEMMGR
72 #define NOSYSMETRICS
73 #define NOMENUS
74 #define NOOPENFILE
75 #define NOWH
76 #define NOSOUND
77 #define NODRAWTEXT
78
79 #endif
80
81 #if defined(ARRAYSIZE)
82 // VS2005beta2 introduces new stuff in winnt.h
83 #undef ARRAYSIZE
84 #endif
85
86 #endif
87
88 #if defined(__QNXNTO__)
89 #include <strings.h> /* For strcasecmp */
90 #endif
91
92 #include <stdio.h>
93 #include <stdlib.h>
94 #include <string.h>
95 #include <stdarg.h>
96 #include <assert.h>
97 #include <ctype.h>
98 #include <math.h>
99
100#endif
101
102
103
104// Use config.h, generated by configure
105#if defined(HAVE_CONFIG_H)
106#include "config.h"
107#endif
108
109// make sure we really are compiling for WIN32
110#ifndef WIN32
111#undef _MSC_VER
112#endif
113
114
115// In the following we configure various targets, in particular those
116// which can't use our "configure" tool and hence don't use config.h.
117//
118// Some #defines that occur here frequently:
119// SCUMM_LITTLE_ENDIAN
120// - Define this on a little endian target
121// SCUMM_BIG_ENDIAN
122// - Define this on a big endian target
123// SCUMM_NEED_ALIGNMENT
124// - Define this if your system has problems reading e.g. an int32 from an odd address
125// SCUMMVM_DONT_DEFINE_TYPES
126// - Define this if you need to provide your own typedefs, e.g. because your
127// system headers conflict with our typenames, or because you have odd
128// type requirements.
129// SMALL_SCREEN_DEVICE
130// - ...
131// ...
132
133// We define all types in config.h, so we don't want to typedef those types
134// here again!
135#ifdef HAVE_CONFIG_H
136#define SCUMMVM_DONT_DEFINE_TYPES
137#endif
138
139
140//
141// By default we try to use pragma push/pop to ensure various structs we use
142// are "packed". If your compiler doesn't support this pragma, you are in for
143// a problem. If you are lucky, there is a compiler switch, or another pragma,
144// doing the same thing -- in that case, try to modify common/pack-begin.h and
145// common/pack-end.h accordingly. Or maybe your port simply *always* packs
146// everything, in which case you could #undefine SCUMMVM_USE_PRAGMA_PACK.
147//
148// If neither is possible, tough luck. Try to contact the team, maybe we can
149// come up with a solution, though I wouldn't hold my breath on it :-/.
150//
151#define SCUMMVM_USE_PRAGMA_PACK
152
153
154#if defined(__SYMBIAN32__)
155
156 #define scumm_stricmp strcasecmp
157 #define scumm_strnicmp strncasecmp
158
159 #define SCUMM_LITTLE_ENDIAN
160 #define SCUMM_NEED_ALIGNMENT
161
162 #define SMALL_SCREEN_DEVICE
163
164 // Enable Symbians own datatypes
165 // This is done for two reasons
166 // a) uint is already defined by Symbians libc component
167 // b) Symbian is using its "own" datatyping, and the Scummvm port
168 // should follow this to ensure the best compability possible.
169 #define SCUMMVM_DONT_DEFINE_TYPES
170 typedef unsigned char byte;
171
172 typedef unsigned char uint8;
173 typedef signed char int8;
174
175 typedef unsigned short int uint16;
176 typedef signed short int int16;
177
178 typedef unsigned long int uint32;
179 typedef signed long int int32;
180
181#elif defined(_WIN32_WCE)
182
183 #define scumm_stricmp stricmp
184 #define scumm_strnicmp _strnicmp
185 #define snprintf _snprintf
186
187 #define SCUMM_LITTLE_ENDIAN
188
189 #ifndef __GNUC__
190 #define FORCEINLINE __forceinline
191 #define NORETURN_PRE __declspec(noreturn)
192 #endif
193 #define PLUGIN_EXPORT __declspec(dllexport)
194
195 #if _WIN32_WCE < 300
196 #define SMALL_SCREEN_DEVICE
197 #endif
198
199#elif defined(_MSC_VER)
200
201 #define scumm_stricmp _stricmp
202 #define scumm_strnicmp _strnicmp
203 #define snprintf _snprintf
204
205 #define SCUMM_LITTLE_ENDIAN
206
207 #define FORCEINLINE __forceinline
208 #define NORETURN_PRE __declspec(noreturn)
209 #define PLUGIN_EXPORT __declspec(dllexport)
210
211
212#elif defined(__MINGW32__)
213
214 #define scumm_stricmp stricmp
215 #define scumm_strnicmp strnicmp
216
217 #define SCUMM_LITTLE_ENDIAN
218
219 #define PLUGIN_EXPORT __declspec(dllexport)
220
221#elif defined(POSIX)
222
223 #define scumm_stricmp strcasecmp
224 #define scumm_strnicmp strncasecmp
225
226 #ifndef CONFIG_H
227 /* need this for the SDL_BYTEORDER define */
228 //#include <SDL_byteorder.h>
229
230#define SDL_BYTEORDER SDL_LIL_ENDIAN
231
232 #if SDL_BYTEORDER == SDL_LIL_ENDIAN
233 #define SCUMM_LITTLE_ENDIAN
234 #elif SDL_BYTEORDER == SDL_BIG_ENDIAN
235 #define SCUMM_BIG_ENDIAN
236 #else
237 #error Neither SDL_BIG_ENDIAN nor SDL_LIL_ENDIAN is set.
238 #endif
239 #endif
240
241 // You need to set this manually if necessary
242// #define SCUMM_NEED_ALIGNMENT
243
244 #if defined(__DECCXX) // Assume alpha architecture
245 #define INVERSE_MKID
246 #define SCUMM_NEED_ALIGNMENT
247 #endif
248
249#elif defined(__PALMOS_TRAPS__) || defined (__PALMOS_ARMLET__)
250
251#ifdef __PALMOS_ARMLET__
252 #include <extras_string.h>
253#endif
254 #define SCUMM_LITTLE_ENDIAN
255
256 #define scumm_stricmp stricmp
257 #define scumm_strnicmp strnicmp
258
259 #define SCUMM_NEED_ALIGNMENT
260 #define STRINGBUFLEN 256
261
262 extern const char *SCUMMVM_SAVEPATH;
263
264 #if !defined(COMPILE_ZODIAC) && !defined(COMPILE_OS5)
265 # define NEWGUI_256
266 #else
267 # undef UNUSED
268 #endif
269
270#elif defined(__DC__)
271
272 #define scumm_stricmp strcasecmp
273 #define scumm_strnicmp strncasecmp
274
275 #define SCUMM_LITTLE_ENDIAN
276 #define SCUMM_NEED_ALIGNMENT
277
278#elif defined(__GP32__)
279
280 #define scumm_stricmp stricmp
281 #define scumm_strnicmp strnicmp
282
283 #define SCUMM_LITTLE_ENDIAN
284 #define SCUMM_NEED_ALIGNMENT
285
286 // Override typenames. uint is already defined by system header files.
287 #define SCUMMVM_DONT_DEFINE_TYPES
288 typedef unsigned char byte;
289
290 typedef unsigned char uint8;
291 typedef signed char int8;
292
293 typedef unsigned short int uint16;
294 typedef signed short int int16;
295
296 typedef unsigned long int uint32;
297 typedef signed long int int32;
298
299#elif defined(__PLAYSTATION2__)
300
301 #define scumm_stricmp strcasecmp
302 #define scumm_strnicmp strncasecmp
303
304 #define SCUMM_LITTLE_ENDIAN
305 #define SCUMM_NEED_ALIGNMENT
306
307#elif defined(__N64__)
308
309 #define scumm_stricmp strcasecmp
310 #define scumm_strnicmp strncasecmp
311
312 #define SCUMM_BIG_ENDIAN
313 #define SCUMM_NEED_ALIGNMENT
314
315 #define STRINGBUFLEN 256
316
317 #define SCUMMVM_DONT_DEFINE_TYPES
318 typedef unsigned char byte;
319
320 typedef unsigned char uint8;
321 typedef signed char int8;
322
323 typedef unsigned short int uint16;
324 typedef signed short int int16;
325
326 typedef unsigned int uint32;
327 typedef signed int int32;
328
329 typedef unsigned long long uint64;
330 typedef signed long long int64;
331
332#elif defined(__PSP__)
333
334 #include <malloc.h>
335
336 #define scumm_stricmp strcasecmp
337 #define scumm_strnicmp strncasecmp
338
339 #define SCUMM_LITTLE_ENDIAN
340 #define SCUMM_NEED_ALIGNMENT
341
342#elif defined(__amigaos4__)
343
344 #define scumm_stricmp strcasecmp
345 #define scumm_strnicmp strncasecmp
346
347 #define SCUMM_BIG_ENDIAN
348 #define SCUMM_NEED_ALIGNMENT
349
350#elif defined (__DS__)
351
352 #define scumm_stricmp stricmp
353 #define scumm_strnicmp strnicmp
354
355 #define SCUMM_NEED_ALIGNMENT
356 #define SCUMM_LITTLE_ENDIAN
357
358 #define SCUMMVM_DONT_DEFINE_TYPES
359
360 #define STRINGBUFLEN 256
361// #define printf(fmt, ...) consolePrintf(fmt, ##__VA_ARGS__)
362
363#elif defined(__WII__)
364
365 #define scumm_stricmp strcasecmp
366 #define scumm_strnicmp strncasecmp
367
368 #define SCUMM_BIG_ENDIAN
369 #define SCUMM_NEED_ALIGNMENT
370
371#else
372 #error No system type defined
373
374#endif
375
376
377//
378// GCC specific stuff
379//
380#if defined(__GNUC__)
381 #define NORETURN_POST __attribute__((__noreturn__))
382 #define PACKED_STRUCT __attribute__((__packed__))
383 #define GCC_PRINTF(x,y) __attribute__((__format__(printf, x, y)))
384
385 #if !defined(FORCEINLINE) && (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1))
386 #define FORCEINLINE inline __attribute__((__always_inline__))
387 #endif
388#else
389 #define PACKED_STRUCT
390 #define GCC_PRINTF(x,y)
391#endif
392
393
394//
395// Fallbacks / default values for various special macros
396//
397#ifndef FORCEINLINE
398#define FORCEINLINE inline
399#endif
400
401#ifndef PLUGIN_EXPORT
402#define PLUGIN_EXPORT
403#endif
404
405#ifndef NORETURN_PRE
406#define NORETURN_PRE
407#endif
408
409#ifndef NORETURN_POST
410#define NORETURN_POST
411#endif
412
413#ifndef STRINGBUFLEN
414#define STRINGBUFLEN 1024
415#endif
416
417#ifndef PI
418#define PI 3.14159265358979323846
419#endif
420
421#ifndef MAXPATHLEN
422#define MAXPATHLEN 256
423#endif
424
425
426//
427// Typedef our system types unless SCUMMVM_DONT_DEFINE_TYPES is set.
428//
429#ifndef SCUMMVM_DONT_DEFINE_TYPES
430 typedef unsigned char byte;
431 typedef unsigned char uint8;
432 typedef signed char int8;
433 typedef unsigned short uint16;
434 typedef signed short int16;
435 typedef unsigned int uint32;
436 typedef signed int int32;
437 typedef unsigned int uint;
438#endif
439
440
441
442//
443// Overlay color type (FIXME: shouldn't be declared here)
444//
445#if defined(NEWGUI_256)
446 // 256 color only on PalmOS
447 typedef byte OverlayColor;
448#else
449 // 15/16 bit color mode everywhere else...
451#endif
452
453
454#endif
unsigned short uint16
Definition: scummsys.h:433
unsigned char byte
Definition: scummsys.h:430
unsigned int uint32
Definition: scummsys.h:435
signed char int8
Definition: scummsys.h:432
signed short int16
Definition: scummsys.h:434
signed int int32
Definition: scummsys.h:436
unsigned int uint
Definition: scummsys.h:437
unsigned char uint8
Definition: scummsys.h:431
uint16 OverlayColor
Definition: scummsys.h:450