1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (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, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20  *
21  */
22 
23 #ifndef NUVIE_CORE_NUVIE_DEFS_H
24 #define NUVIE_CORE_NUVIE_DEFS_H
25 
26 #include "common/scummsys.h"
27 #include "ultima/nuvie/misc/sdl_compat.h"
28 
29 namespace Ultima {
30 namespace Nuvie {
31 
32 typedef int8 sint8;
33 typedef int16 sint16;
34 typedef int32 sint32;
35 
36 #define USE_BUTTON Shared::BUTTON_LEFT
37 #define WALK_BUTTON Shared::BUTTON_RIGHT
38 #define ACTION_BUTTON Shared::BUTTON_RIGHT
39 #define DRAG_BUTTON Shared::BUTTON_LEFT
40 
41 typedef uint8 nuvie_game_t; // Game type (1=u6,2=md,4=se)
42 
43 #define NUVIE_GAME_NONE  0
44 #define NUVIE_GAME_U6    1
45 #define NUVIE_GAME_MD    2
46 #define NUVIE_GAME_SE    4
47 
48 #define NUVIE_CONFIG_NAME_U6 "ultima6"
49 #define NUVIE_CONFIG_NAME_MD "martian"
50 #define NUVIE_CONFIG_NAME_SE "savage"
51 
52 #define NUVIE_STYLE_ORIG 0
53 #define NUVIE_STYLE_NEW  1
54 #define NUVIE_STYLE_ORIG_PLUS_CUTOFF_MAP 2
55 #define NUVIE_STYLE_ORIG_PLUS_FULL_MAP   3
56 
57 #define MAX(x, y)      ((x) > (y) ? (x) : (y))
58 #define MIN(x, y)      ((x) < (y) ? (x) : (y))
59 #define clamp_min(v, c)  (((v) < (c)) ? (c) : (v))
60 #define clamp_max(v, c)  (((v) > (c)) ? (c) : (v))
61 #define clamp(v, c1, c2) ( ((v) < (c1)) ? (c1) : (((v) > (c2)) ? (c2) : (v)) )
62 
63 #ifndef INT_MAX
64 #define INT_MAX 0x7fffffff
65 #endif
66 #ifndef UCHAR_MAX
67 #define UCHAR_MAX 0xff
68 #endif
69 #ifndef SHRT_MAX
70 #define SHRT_MAX 0x7fff
71 #endif
72 
73 //FIXME fix for future maps which will probably be 1024 wide starting at level 6..
74 #define WRAPPED_COORD(c,level) ((c)&((level)?255:1023))
75 #define WRAP_COORD(c,level) ((c)&=((level)?255:1023))
76 
77 #define MAP_SIDE_LENGTH(map_level) ((map_level > 0 && map_level < 6) ? 256 : 1024)
78 
79 /*
80  * on all levels, except level 0 (conveniently 'false') the map pitch is 256.
81  * to properly wrap, mask the coordinate with the relevant bit-mask.
82  * Another way to write this would be:
83 
84 const uint16 map_pitch[2] = { 1024, 256 }; // width of 0:surface plane, and 1:all other planes
85 #define WRAPPED_COORD(c,level) ((c)&(map_pitch[(level==0)?0:1]-1)) // mask high bit, wrap C to map_pitch
86 #define WRAP_COORD(c,level) ((c)&=(map_pitch[(level==0)?0:1]-1)) // modifies C
87 */
88 
89 #define NUVIE_DIR_N    0
90 #define NUVIE_DIR_E    1
91 #define NUVIE_DIR_S    2
92 #define NUVIE_DIR_W    3
93 
94 #define NUVIE_DIR_NE   4
95 #define NUVIE_DIR_SE   5
96 #define NUVIE_DIR_SW   6
97 #define NUVIE_DIR_NW   7
98 
99 #define NUVIE_DIR_NONE 8
100 
101 #define TRAMMEL_PHASE 1.75
102 #define FELUCCA_PHASE 1.1666666666666667
103 
104 enum DebugLevelType {
105 	LEVEL_EMERGENCY = 0,
106 	LEVEL_ALERT,
107 	LEVEL_CRITICAL,
108 	LEVEL_ERROR,
109 	LEVEL_WARNING,
110 	LEVEL_NOTIFICATION,
111 	LEVEL_INFORMATIONAL,
112 	LEVEL_DEBUGGING
113 };
114 
115 #ifdef WITHOUT_DEBUG
u6debug(bool no_header,const DebugLevelType level,const char * format,...)116 inline void u6debug(bool no_header, const DebugLevelType level, const char *format, ...) {}
117 #else
118 extern void u6debug(bool no_header, const DebugLevelType level, const char *format, ...);
119 #endif
120 
121 #ifdef DEBUG
122 #undef DEBUG
123 #endif
124 #define DEBUG u6debug
125 
126 #define U6PATH_DELIMITER '/'
127 
128 #define NUVIE_RAND_MAX 0x7fffffff // POSIX: 2^(31)-1
129 #define NUVIE_RAND() getRandom(NUVIE_RAND_MAX)
130 
131 #define MAXPATHLEN 256
132 
133 #define nuprint Game::get_game()->get_scroll()->print
134 
135 } // End of namespace Nuvie
136 } // End of namespace Ultima
137 
138 #endif
139