1 /*
2  *  exult_constants.h - Some constants/macros that are used all over the code.
3  *
4  *  Copyright (C) 2000-2013  The Exult Team
5  *
6  *  This program is free software; you can redistribute it and/or modify
7  *  it under the terms of the GNU General Public License as published by
8  *  the Free Software Foundation; either version 2 of the License, or
9  *  (at your option) any later version.
10  *
11  *  This program is distributed in the hope that it will be useful,
12  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  *  GNU General Public License for more details.
15  *
16  *  You should have received a copy of the GNU General Public License
17  *  along with this program; if not, write to the Free Software
18  *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19  */
20 
21 #ifndef EXULT_CONSTANTS_H
22 #define EXULT_CONSTANTS_H
23 
24 /*
25  *  Sizes:
26  */
27 constexpr const int c_basetilesize = 8;       // A tile (shape) is 8x8 pixels.
28 constexpr const int c_tilesize = 8;   // A tile (shape) is 8x8 pixels.
29 constexpr const int c_num_tile_bytes = c_tilesize * c_tilesize;   // Total pixels per tile.
30 constexpr const int c_screen_tile_size = 320 / c_basetilesize; // Number of tiles in a 'screen'.
31 constexpr const int c_tiles_per_chunk = 16;   // A chunk is 16x16 tiles.
32 constexpr const int c_chunksize = 16 * 8;     // A chunk has 16 8x8 shapes.
33 constexpr const int c_num_schunks = 12;
34 constexpr const int c_num_chunks = 12 * 16;   // Total # of chunks in each dir.
35 constexpr const int c_chunks_per_schunk = 16; // # chunks in each superchunk.
36 constexpr const int c_tiles_per_schunk = 16 * 16; // # tiles in each superchunk.
37 // Total # tiles in each dir.:
38 constexpr const int c_num_tiles = c_tiles_per_chunk * c_num_chunks;
39 
40 constexpr const int c_fade_in_time = 30;  // Time for fade in
41 constexpr const int c_fade_out_time = 30; // Time for fade out
42 constexpr const int c_std_delay = 200;    // Standard animation delay.  May want to
43 //   make this settable!
44 
45 constexpr const int c_any_shapenum = -359;
46 constexpr const int c_any_qual = -359;
47 constexpr const int c_any_framenum = -359;
48 constexpr const int c_any_quantity = -359;
49 
50 // Maximum number of shapes:
51 constexpr const int c_max_shapes = 2048;
52 constexpr const int c_occsize = c_max_shapes / 8 + ((c_max_shapes % 8) != 0 ? 1 : 0);
53 
54 // Maximum number of global flags:
55 constexpr const int c_last_gflag = 2047;
56 
57 constexpr const int MOVE_NODROP = (1<<3);
58 constexpr const int MOVE_FLY = (1<<4);
59 constexpr const int MOVE_LEVITATE = (MOVE_FLY|MOVE_NODROP);
60 constexpr const int MOVE_WALK = (1<<5);
61 constexpr const int MOVE_SWIM = (1<<6);
62 constexpr const int MOVE_ALL_TERRAIN = ((1<<5)|(1<<6));
63 constexpr const int MOVE_ETHEREAL = (1<<7);
64 constexpr const int MOVE_ALL = (MOVE_FLY|MOVE_WALK|MOVE_SWIM|MOVE_ETHEREAL);
65 constexpr const int MOVE_MAPEDIT = (1<<8);
66 
67 //	Wrapping:
INCR_CHUNK(int x)68 constexpr inline int INCR_CHUNK(int x) {
69 	return (x + 1) % c_num_chunks;
70 }
DECR_CHUNK(int x)71 constexpr inline int DECR_CHUNK(int x) {
72 	return (x - 1 + c_num_chunks) % c_num_chunks;
73 }
INCR_TILE(int x)74 constexpr inline int INCR_TILE(int x) {
75 	return (x + 1) % c_num_tiles;
76 }
77 constexpr inline int DECR_TILE(int x, int amt = 1) {
78 	return (x - amt + c_num_tiles) % c_num_tiles;
79 }
80 // Return x - y with wrapping.
SUB_TILE(int x,int y)81 constexpr inline int SUB_TILE(int x, int y) {
82 	int delta = x - y;
83 	return delta < -c_num_tiles / 2 ? delta + c_num_tiles :
84 	       delta >= c_num_tiles / 2 ? delta - c_num_tiles : delta;
85 }
86 
87 // Debug
88 #ifdef DEBUG
89 #  define COUT(x)       do { std::cout << x << std::endl; std::cout.flush(); } while (0)
90 #  define CERR(x)       do { std::cerr << x << std::endl; std::cerr.flush(); } while (0)
91 #else
92 #  define COUT(x)       do { } while(0)
93 #  define CERR(x)       do { } while(0)
94 #endif
95 
96 enum Exult_Game {
97     NONE,
98     BLACK_GATE,
99     SERPENT_ISLE,
100     EXULT_DEVEL_GAME,       // One that we develop.
101     EXULT_MENU_GAME         // Game type for the exult menu
102 };
103 
104 // For the original released translations
105 enum Game_Language {
106     ENGLISH,
107 	FRENCH,                 // Black Gate only
108 	GERMAN,                 // Black Gate only
109 	SPANISH                 // Black Gate and Serpent Isle
110 };
111 #endif
112