1 /* File: maid-grf.h */ 2 3 /* Purpose: Common header file for graphics ports */ 4 5 /* 6 * Copyright (c) 2002 Steven Fuerst 7 * 8 * This software may be copied and distributed for educational, research, and 9 * not for profit purposes provided that this copyright and statement are 10 * included in all such copies. 11 */ 12 13 14 /* 15 * List of callback types 16 */ 17 #define CALL_MAP_INFO 1 18 #define CALL_MAP_ERASE 2 19 #define CALL_PLAYER_MOVE 3 20 #define CALL_OBJECT_LIST 4 21 22 #define CALL_MAX 5 23 24 /* 25 * Callback type (Ignoring parameters) 26 */ 27 typedef void (*callback_type) (void); 28 29 /* 30 * Linked list for callbacks 31 */ 32 typedef struct callback_list callback_list; 33 34 struct callback_list 35 { 36 callback_type func; /* Function to call */ 37 callback_list *next; /* Next callback in list */ 38 vptr data; /* Data for callbacks so can use same function multiple times */ 39 }; 40 41 extern void set_callback(callback_type call_func, int number, vptr data); 42 extern void del_callback(int number, vptr data); 43 44 45 /* 46 * Number of blocks in the overhead map cache. 47 * 48 * This number must be bigger than the number of blocks 49 * required to remember the biggest dungeon level. 50 */ 51 #define MAP_CACHE (WILD_VIEW * WILD_VIEW * 2) 52 53 54 /* 55 * Constants used to pass information to users 56 * of the overhead map hooks. 57 */ 58 #define MAP_SEEN 0x01 /* GRID_SEEN equivalent */ 59 #define MAP_GLOW 0x02 /* CAVE_GLOW equivalent */ 60 #define MAP_LITE 0x04 /* GRID_LITE equivalent */ 61 #define MAP_ONCE 0x08 /* This block has ever been seen */ 62 63 /* 64 * Constants used to describe the state of monsters 65 * to users of the overhead map 66 */ 67 #define MONST_ASLEEP 0x01 68 #define MONST_FRIEND 0x02 69 #define MONST_PET 0x04 70 #define MONST_CONFUSED 0x08 71 #define MONST_FEAR 0x10 72 #define MONST_STUN 0x20 73 #define MONST_INVULN 0x40 74 75 76 /* 77 * Make an iterator, so we can scan the map quickly 78 */ 79 #define MAP_ITT_START(M) \ 80 do { \ 81 int _map_count;\ 82 \ 83 for (_map_count = 0; _map_count < MAP_CACHE; _map_count++) \ 84 { \ 85 int _map_i, _map_j; \ 86 \ 87 if (map_cache_x[_map_count] == -1) continue; \ 88 \ 89 if (map_grid[map_cache_y[_map_count]][map_cache_x[_map_count]] == -1)\ 90 continue; \ 91 \ 92 for (_map_i = 0; _map_i < WILD_BLOCK_SIZE; _map_i++) \ 93 { \ 94 for (_map_j = 0; _map_j < WILD_BLOCK_SIZE; _map_j++) \ 95 { \ 96 (M) = &map_cache[_map_count][_map_j][_map_i]; 97 98 99 #define MAP_ITT_END \ 100 } \ 101 } \ 102 } \ 103 } while (0) 104 105 /* Macro to extract location during iteration */ 106 #define MAP_GET_LOC(X, Y)\ 107 (((X) = _map_i + map_cache_x[_map_count] * WILD_BLOCK_SIZE), \ 108 ((Y) = _map_j + map_cache_y[_map_count] * WILD_BLOCK_SIZE)) 109 110 /* 111 * Map data structure 112 */ 113 typedef struct term_map term_map; 114 115 struct term_map 116 { 117 /* Information about what is at the grid */ 118 s16b object; 119 s16b monster; 120 s16b field; 121 byte terrain; 122 char unknown; 123 124 /* Location */ 125 u16b x; 126 u16b y; 127 128 /* Player-known flags */ 129 byte flags; 130 131 /* Monster flags */ 132 byte m_flags; 133 134 /* Rough measure of monster hp */ 135 byte m_hp; 136 137 /* Priority for overhead mini map */ 138 byte priority; 139 140 /* Map information about square */ 141 byte a; 142 char c; 143 byte ta; 144 char tc; 145 }; 146 147 typedef struct map_block map_block; 148 149 struct map_block 150 { 151 /* Save what it looks like */ 152 byte a; 153 char c; 154 155 byte ta; 156 char tc; 157 158 /* Save the cave info itself - used by the borg */ 159 #ifdef TERM_CAVE_MAP 160 s16b object; 161 s16b monster; 162 s16b field; 163 byte terrain; 164 165 /* unknown mimics or flavoured objects */ 166 char unknown; 167 168 /* Monster flags */ 169 byte m_flags; 170 171 /* Monster hp (scaled) */ 172 byte m_hp; 173 #endif /* TERM_CAVE_MAP */ 174 175 /* Borg-specific stuff */ 176 #ifdef ALLOW_BORG 177 u16b fear; /* fear value */ 178 179 u16b kill; /* Entry into "kill" list */ 180 u16b take; /* Entry into "take" list */ 181 u16b trap; /* MT - Entry into "trap" list */ 182 u16b m_effect; /* MT - Magic Effect, like glyphs */ 183 184 byte feat; /* Terrain feature */ 185 byte info; /* info flags */ 186 187 byte flow; /* "flow" data */ 188 byte cost; /* "cost" data */ 189 190 byte detect; /* Detection flags */ 191 byte xtra; /* search count */ 192 #endif /* ALLOW_BORG */ 193 194 /* We need to save the flags to get the refcounting right. */ 195 byte flags; 196 197 /* Priority of tile (For overhead map display) */ 198 byte priority; 199 }; 200 201 typedef map_block *map_blk_ptr; 202 typedef map_block **map_blk_ptr_ptr; 203 204 typedef void (*map_info_hook_type) (map_block *mb_ptr, const term_map *map, vptr data); 205 typedef void (*map_erase_hook_type) (vptr data); 206 typedef void (*player_move_hook_type) (int x, int y, vptr data); 207 208 209 /* 210 * This is used by the Borg and by ports that would 211 * like to access lists of objects 212 */ 213 #ifdef TERM_USE_LIST 214 215 /* 216 * Object List data structure 217 */ 218 typedef struct term_list term_list; 219 220 struct term_list 221 { 222 cptr o_name; /* Name */ 223 cptr xtra_name; /* Extra Name (Artifacts and ego items) */ 224 225 u32b kn_flags[4]; /* Known Flags */ 226 227 s32b cost; /* Object "base cost" */ 228 229 s16b k_idx; /* Kind index (zero if "unknown") */ 230 s16b weight; /* Item weight */ 231 232 s16b to_h; /* Bonus to hit */ 233 s16b to_d; /* Bonus to dam */ 234 s16b to_a; /* Bonus to ac */ 235 s16b ac; /* Armor class */ 236 byte dd; /* Damage dice */ 237 byte ds; /* Damage sides */ 238 239 byte number; /* Number of items */ 240 byte info; /* Special flags */ 241 242 s16b timeout; /* Timeout Counter */ 243 244 s16b pval; /* Particular value */ 245 246 byte tval; /* Item type (from kind) */ 247 }; 248 249 250 typedef struct list_item list_item; 251 252 struct list_item 253 { 254 cptr o_name; /* Name */ 255 cptr xtra_name; /* Extra Name (Artifacts and ego items) */ 256 257 u32b kn_flags[4]; /* Known Flags */ 258 259 s32b cost; /* Object "base cost" */ 260 261 s16b k_idx; /* Kind index (zero if "dead") */ 262 s16b weight; /* Item weight */ 263 264 s16b to_h; /* Bonus to hit */ 265 s16b to_d; /* Bonus to dam */ 266 s16b to_a; /* Bonus to ac */ 267 s16b ac; /* Armor class */ 268 byte dd; /* Damage dice */ 269 byte ds; /* Damage sides */ 270 271 byte number; /* Number of items */ 272 byte info; /* Special flags */ 273 274 s16b timeout; /* Timeout Counter */ 275 276 s16b pval; /* Particular value */ 277 byte tval; /* Item type (from kind) */ 278 279 /* Save the glyph to use */ 280 #ifdef TERM_OBJ_GLYPH 281 u16b feature_code; 282 #endif /* TERM_OBJ_GLYPH */ 283 284 #ifdef ALLOW_BORG 285 byte treat_as; /* Treat item as if it is in a different list */ 286 #endif /* ALLOW_BORG */ 287 }; 288 289 typedef void (*list_notice_hook_type) (byte, vptr data); 290 291 292 #endif /* TERM_USE_LIST */ 293 294 /* Extern Variables */ 295 extern byte gamma_table[256]; 296 extern map_blk_ptr_ptr *map_cache; 297 extern s16b *map_cache_refcount; 298 extern int *map_cache_x; 299 extern int *map_cache_y; 300 extern int **map_grid; 301 302 #ifdef TERM_USE_LIST 303 extern list_item *equipment; 304 extern int equip_num; 305 extern list_item *inventory; 306 extern int inven_num; 307 extern list_item *cur_list; 308 extern int cur_num; 309 #endif /* TERM_USE_LIST */ 310 311 /* Extern Functions */ 312 extern void build_gamma_table(int gamma); 313 extern cptr get_default_font(int term_num); 314 extern bool pick_graphics(int graphics, int *xsize, int *ysize, char *filename); 315 extern bool is_bigtiled(int x, int y); 316 extern void toggle_bigtile(void); 317 extern void map_get_player(int *x, int *y); 318 extern bool map_in_bounds(int x, int y); 319 extern map_block *map_loc(int dx, int dy); 320