1 /**
2  * @file defs.h
3  *
4  * Global definitions and Macros.
5  */
6 
7 #define DMAXX					40
8 #define DMAXY					40
9 
10 #define LIGHTSIZE				6912 // 27 * 256
11 #define NO_LIGHT				-1
12 
13 #define GMENU_SLIDER			0x40000000
14 #define GMENU_ENABLED			0x80000000
15 
16 // must be unsigned to generate unsigned comparisons with pnum
17 #define MAX_PLRS				4
18 
19 #define MAX_CHARACTERS			99
20 #define MAX_LVLS				24
21 #define MAX_LVLMTYPES			24
22 #define MAX_SPELLS				52
23 #define MAX_SPELL_LEVEL			15
24 
25 #define MAX_CHUNKS				(MAX_LVLS + 5)
26 
27 // #define MAX_PATH				260
28 #define MAX_SEND_STR_LEN		80
29 
30 #define MAXDEAD					31
31 #define MAXDUNX					112
32 #define MAXDUNY					112
33 #define MAXITEMS				127
34 #define MAXBELTITEMS			8
35 #define MAXLIGHTS				32
36 #define MAXMISSILES				125
37 #define MAXMONSTERS				200
38 #define MAXOBJECTS				127
39 #define MAXPORTAL				4
40 
41 #define MAXQUESTS				24
42 #define MAXMULTIQUESTS			10
43 
44 #define MAXTHEMES				50
45 #define MAXTILES				2048
46 
47 #define MAXTRIGGERS				7
48 
49 #define MAXVISION				32
50 #define MDMAXX					40
51 #define MDMAXY					40
52 #define MAXCHARLEVEL			51
53 #define ITEMTYPES				43
54 
55 // number of inventory grid cells
56 #define NUM_INV_GRID_ELEM		40
57 #define INV_SLOT_SIZE_PX		28
58 
59 // Item indestructible durability
60 #define DUR_INDESTRUCTIBLE		255
61 
62 #define VOLUME_MIN				-1600
63 #define VOLUME_MAX				0
64 
65 #define NUM_TOWNERS				16
66 
67 // todo: enums
68 #define NUMLEVELS				25
69 #define WITCH_ITEMS				25
70 #define SMITH_ITEMS				25
71 #define SMITH_PREMIUM_ITEMS		15
72 #define STORE_LINES				104
73 
74 // from diablo 2 beta
75 #define MAXEXP					2000000000
76 #define MAXRESIST				75
77 
78 #define GOLD_SMALL_LIMIT		1000
79 #define GOLD_MEDIUM_LIMIT		2500
80 #define GOLD_MAX_LIMIT			5000
81 
82 #define PLR_NAME_LEN			32
83 
84 #define MAXPATHNODES			300
85 
86 #define MAX_PATH_LENGTH			25
87 
88 // 256 kilobytes + 3 bytes (demo leftover) for file magic (262147)
89 // final game uses 4-byte magic instead of 3
90 #define FILEBUFF				((256 * 1024) + 3)
91 
92 #define PMSG_COUNT				8
93 
94 #define GAME_ID					(gbIsHellfire ? (gbIsSpawn ? LOAD_BE32("HSHR") : LOAD_BE32("HRTL")) : (gbIsSpawn ? LOAD_BE32("DSHR") : LOAD_BE32("DRTL")))
95 
96 // Diablo uses a 256 color palette
97 // Entry 0-127 (0x00-0x7F) are level specific
98 // Entry 128-255 (0x80-0xFF) are global
99 
100 // standard palette for all levels
101 // 8 or 16 shades per color
102 // example (dark blue): PAL16_BLUE+14, PAL8_BLUE+7
103 // example (light red): PAL16_RED+2, PAL8_RED
104 // example (orange): PAL16_ORANGE+8, PAL8_ORANGE+4
105 #define PAL8_BLUE		128
106 #define PAL8_RED		136
107 #define PAL8_YELLOW		144
108 #define PAL8_ORANGE		152
109 #define PAL16_BEIGE		160
110 #define PAL16_BLUE		176
111 #define PAL16_YELLOW	192
112 #define PAL16_ORANGE	208
113 #define PAL16_RED		224
114 #define PAL16_GRAY		240
115 
116 // If defined, use 32-bit colors instead of 8-bit [Default -> Undefined]
117 //#define RGBMODE
118 
119 #ifndef RGBMODE
120 #define SCREEN_BPP		8
121 #else
122 #define SCREEN_BPP		32
123 #endif
124 
125 #define BUFFER_BORDER_LEFT		64
126 #define BUFFER_BORDER_TOP		160
127 #define BUFFER_BORDER_RIGHT	dvl::borderRight
128 #define BUFFER_BORDER_BOTTOM	16
129 
130 #define UI_OFFSET_Y		((Sint16)((gnScreenHeight - 480) / 2))
131 
132 #define TILE_WIDTH		64
133 #define TILE_HEIGHT		32
134 
135 #define PANEL_WIDTH     640
136 #define PANEL_HEIGHT    128
137 #define PANEL_TOP		(gnScreenHeight - PANEL_HEIGHT)
138 #define PANEL_LEFT		(gnScreenWidth - PANEL_WIDTH) / 2
139 #define PANEL_X			PANEL_LEFT
140 #define PANEL_Y			PANEL_TOP
141 
142 #define SPANEL_WIDTH	 320
143 #define SPANEL_HEIGHT	 352
144 #define PANELS_COVER (gnScreenWidth <= PANEL_WIDTH && gnScreenHeight <= SPANEL_HEIGHT + PANEL_HEIGHT)
145 
146 #define RIGHT_PANEL		(gnScreenWidth - SPANEL_WIDTH)
147 #define RIGHT_PANEL_X	RIGHT_PANEL
148 
149 #define DIALOG_TOP		((gnScreenHeight - PANEL_HEIGHT) / 2 - 18)
150 #define DIALOG_Y		DIALOG_TOP
151 
152 #define NIGHTMARE_TO_HIT_BONUS  85
153 #define HELL_TO_HIT_BONUS      120
154 
155 #define NIGHTMARE_AC_BONUS 50
156 #define HELL_AC_BONUS      80
157 
158 #define MemFreeDbg(p)       \
159 	{                       \
160 		void *p__p;         \
161 		p__p = p;           \
162 		p = NULL;           \
163 		mem_free_dbg(p__p); \
164 	}
165 
166 #undef assert
167 
168 #ifndef _DEBUG
169 #define assert(exp)
170 #define assurance(exp, value) if (!(exp)) return
171 #define commitment(exp, value) if (!(exp)) return false
172 #else
173 #define assert(exp) (void)((exp) || (assert_fail(__LINE__, __FILE__, #exp), 0))
174 #define assurance(exp, value) (void)((exp) || (app_fatal("%s: %s was %i", __func__, #exp, value), 0))
175 #define commitment(exp, value) (void)((exp) || (app_fatal("%s: %s was %i", __func__, #exp, value), 0))
176 #endif
177 
178 // To apply to certain functions which have local variables aligned by 1 for unknown yet reason
179 #if (_MSC_VER == 1200)
180 #define ALIGN_BY_1 __declspec(align(1))
181 #else
182 #define ALIGN_BY_1
183 #endif
184 
185 #define SwapLE32 SDL_SwapLE32
186 #define SwapLE16 SDL_SwapLE16
187 
188 #define ErrSdl() ErrDlg("SDL Error", SDL_GetError(), __FILE__, __LINE__)
189 
190 #ifdef _MSC_VER
191 #define strcasecmp _stricmp
192 #define strncasecmp _strnicmp
193 #endif
194 
195 #ifdef __has_attribute
196 #define DVL_HAVE_ATTRIBUTE(x) __has_attribute(x)
197 #else
198 #define DVL_HAVE_ATTRIBUTE(x) 0
199 #endif
200 
201 #if DVL_HAVE_ATTRIBUTE(always_inline) ||  (defined(__GNUC__) && !defined(__clang__))
202 #define DVL_ATTRIBUTE_ALWAYS_INLINE __attribute__((always_inline))
203 #else
204 #define DVL_ATTRIBUTE_ALWAYS_INLINE
205 #endif
206