1 /* Copyright (C) 1995-2002 FSGames. Ported by Sean Ford and Yan Shosh 2 * 3 * This program is free software; you can redistribute it and/or modify 4 * it under the terms of the GNU General Public License as published by 5 * the Free Software Foundation; either version 2 of the License, or 6 * (at your option) any later version. 7 * 8 * This program is distributed in the hope that it will be useful, 9 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 * GNU General Public License for more details. 12 * 13 * You should have received a copy of the GNU General Public License 14 * along with this program; if not, write to the Free Software 15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 16 */ 17 #ifndef __BASE_H 18 #define __BASE_H 19 20 // BASE definitions (perhaps this should be broken up some more 21 22 /* ChangeLog 23 buffers: 7/31/02: *C++ style includes for string and fstream 24 : *deleted some redundant headers 25 : *added math.h,ctype.h 26 */ 27 28 #include <stdio.h> 29 #include <stdlib.h> 30 #include <string> 31 #include <fstream> 32 #include <math.h> 33 #include <ctype.h> 34 #include "sounds.h" 35 #include "input.h" 36 #include "util.h" 37 #include "parser.h" 38 #include "SDL.h" 39 #include "pal32.h" 40 #include "pixdefs.h" 41 #include "soundob.h" // sound defines 42 43 class video; 44 class screen; 45 class viewscreen; 46 class pixie; 47 class pixieN; 48 49 class walker; 50 class living; 51 class weap; 52 class treasure; 53 class effect; 54 55 class oblink; 56 class text; 57 class loader; 58 class statistics; 59 class command; 60 class guy; 61 class radar; 62 63 class soundob; 64 class smoother; 65 class packfile; 66 67 class oblink 68 { 69 public: oblink()70 oblink() : ob(NULL), next(NULL) {} 71 walker *ob; 72 oblink *next; 73 }; 74 75 #define GLAD_VER "3.8K" 76 77 #define DIFFICULTY_SETTINGS 3 78 79 unsigned long random(unsigned long x); 80 81 #define VIDEO_ADDRESS 0xA000 82 #define VIDEO_LINEAR ( (VIDEO_ADDRESS) << 4) 83 84 #define DPMI_INT 0x31 85 struct meminfo 86 { 87 unsigned LargestBlockAvail; 88 unsigned MaxUnlockedPage; 89 unsigned LargestLockablePage; 90 unsigned LinAddrSpace; 91 unsigned NumFreePagesAvail; 92 unsigned NumPhysicalPagesFree; 93 unsigned TotalPhysicalPages; 94 unsigned FreeLinAddrSpace; 95 unsigned SizeOfPageFile; 96 unsigned Reserved[3]; 97 }; 98 99 extern screen * myscreen; // global, availible to anyone 100 extern smoother * mysmoother; // global, availible to anyone 101 extern packfile * pixpack; 102 103 #define MAX_LEVELS 500 // Maximum number of scenarios allowed .. 104 105 #define GRID_SIZE 16 106 107 #define PROT_MODE 1 // comment this out when not in protected mode 108 #ifdef PROT_MODE 109 #define init_sound(x,y,z) while (0) 110 //#define play_sound(x) while (0) 111 #endif 112 113 // Used for the help-text system: 114 #define MAX_LINES 100 // maximum number of lines in helpfile 115 #define HELP_WIDTH 100 // maximum length of display line 116 short fill_help_array(char somearray[HELP_WIDTH][MAX_LINES], FILE *infile); 117 short read_help(char *somefile,screen *myscreen); 118 short read_scenario(screen *myscreen); 119 char* read_one_line(FILE *infile, short length); 120 121 //color defines: 122 #define DEFAULT_TEXT_COLOR 88 123 124 #define WHITE 24 125 #define BLACK 160 126 #define GREY 23 127 #define YELLOW 88 128 #define RED 40 129 #define DARK_BLUE 72 130 #define LIGHT_BLUE 120 131 #define DARK_GREEN 63 132 #define LIGHT_GREEN 56 133 134 // Color cycling: 135 #define WATER_START 208 136 #define WATER_END 223 137 #define ORANGE_START 224 138 #define ORANGE_END 231 139 140 // Random defines: 141 //#define PROFILING 142 //#include "profiler.h" 143 #define CHEAT_MODE 1 // set to 0 for no cheats.. 144 // Picture Object class defs 145 146 // HP BAR COLOR DEFINES 147 #define BAR_BACK_COLOR 11 148 #define BOX_COLOR 0 149 #define LOW_HP_COLOR 42 150 #define MID_HP_COLOR 237 151 #define HIGH_HP_COLOR 61 152 #define MAX_HP_COLOR 56 // When hp's are over max :) 153 154 // MP BAR COLOR DEFINES 155 #define LOW_MP_COLOR 42 156 #define MID_MP_COLOR 108 157 #define HIGH_MP_COLOR 72 158 #define MAX_MP_COLOR 64 // When mp's are over max :) 159 160 // Generators are limited by this number 161 #define MAXOBS 150 162 163 // Zardus: PORT: this shouldn't be neccessary anymore thanx to SDL 164 // // Define scan codes 165 //#define SCAN_UP_LEFT 71 166 //#define SCAN_UP 72 167 //#define SCAN_UP_RIGHT 73 168 //#define SCAN_LEFT 75 169 //#define SCAN_RIGHT 77 170 //#define SCAN_DOWN_LEFT 79 171 //#define SCAN_DOWN 80 172 //#define SCAN_DOWN_RIGHT 81 173 174 175 //Screen window boundaries, two player 176 #define T_LEFT_ONE 0 177 #define T_UP_ONE 0 178 #define T_LEFT_TWO 164 179 #define T_UP_TWO 0 180 #define T_WIDTH 156 181 #define T_HEIGHT 200 182 183 // Act types 184 #define ACT_RANDOM 0 185 #define ACT_FIRE 1 186 #define ACT_CONTROL 2 187 #define ACT_GUARD 3 188 #define ACT_GENERATE 4 189 #define ACT_DIE 5 190 #define ACT_SIT 6 191 192 // Team types 193 194 // //#define MY_TEAM 0 195 // #define ELF_TEAM 1 196 // #define KNIGHT_TEAM 2 197 // #define MAX_TEAM 2 198 199 #define MAX_TEAM 7 200 201 // Other screen-type things 202 #define NUM_SPECIALS 6 203 204 // Animation Types : Livings 205 #define ANI_WALK 0 206 #define ANI_ATTACK 1 207 #define ANI_TELE_OUT 2 208 #define ANI_SKEL_GROW 3 209 #define ANI_TELE_IN 3 210 #define ANI_SLIME_SPLIT 4 211 212 // Animations types : weapons 213 #define ANI_GROW 1 // Trees have no attack animation 214 #define ANI_GLOWGROW 1 // Neither do sparkles 215 #define ANI_GLOWPULSE 2 // sparkles cycling 216 217 // These are for effect objects .. 218 #define ANI_EXPAND_8 1 //1 219 #define ANI_DOOR_OPEN 1 // Door openning 220 #define ANI_SCARE 1 // 2 ghost scare 221 #define ANI_BOMB 1 // 3 thief's bomb 222 #define ANI_EXPLODE 1 // 4 223 #define ANI_SPIN 1 // for the marker 224 225 // Orders 226 #define ORDER_LIVING 0 227 #define ORDER_WEAPON 1 228 #define ORDER_TREASURE 2 229 #define ORDER_GENERATOR 3 230 #define ORDER_FX 4 231 #define ORDER_SPECIAL 5 232 #define ORDER_BUTTON1 6 233 234 // Living familes 235 #define FAMILY_SOLDIER 0 236 #define FAMILY_ELF 1 237 #define FAMILY_ARCHER 2 238 #define FAMILY_MAGE 3 239 #define FAMILY_SKELETON 4 240 #define FAMILY_CLERIC 5 241 #define FAMILY_FIREELEMENTAL 6 242 #define FAMILY_FAERIE 7 243 #define FAMILY_SLIME 8 244 #define FAMILY_SMALL_SLIME 9 245 #define FAMILY_MEDIUM_SLIME 10 246 #define FAMILY_THIEF 11 247 #define FAMILY_GHOST 12 248 #define FAMILY_DRUID 13 249 #define FAMILY_ORC 14 250 #define FAMILY_BIG_ORC 15 251 #define FAMILY_BARBARIAN 16 252 #define FAMILY_ARCHMAGE 17 253 #define FAMILY_GOLEM 18 254 #define FAMILY_GIANT_SKELETON 19 255 #define FAMILY_TOWER1 20 256 #define NUM_FAMILIES 21 // # of families; make sure to change the 257 // SIZE_FAMILIES in loader.cpp as well 258 // (or your code will act weird) 259 260 #define PIX(a,b) (NUM_FAMILIES*a+b) 261 262 //Weapon familes 263 #define FAMILY_KNIFE 0 264 #define FAMILY_ROCK 1 265 #define FAMILY_ARROW 2 266 #define FAMILY_FIREBALL 3 267 #define FAMILY_TREE 4 268 #define FAMILY_METEOR 5 269 #define FAMILY_SPRINKLE 6 270 #define FAMILY_BONE 7 271 #define FAMILY_BLOOD 8 272 #define FAMILY_BLOB 9 273 #define FAMILY_FIRE_ARROW 10 274 #define FAMILY_LIGHTNING 11 275 #define FAMILY_GLOW 12 276 #define FAMILY_WAVE 13 277 #define FAMILY_WAVE2 14 278 #define FAMILY_WAVE3 15 279 #define FAMILY_CIRCLE_PROTECTION 16 280 #define FAMILY_HAMMER 17 281 #define FAMILY_DOOR 18 282 #define FAMILY_BOULDER 19 283 284 // Treasure families 285 #define FAMILY_STAIN 0 286 #define FAMILY_DRUMSTICK 1 287 #define FAMILY_GOLD_BAR 2 288 #define FAMILY_SILVER_BAR 3 289 #define FAMILY_MAGIC_POTION 4 290 #define FAMILY_INVIS_POTION 5 291 #define FAMILY_INVULNERABLE_POTION 6 292 #define FAMILY_FLIGHT_POTION 7 293 #define FAMILY_EXIT 8 294 #define FAMILY_TELEPORTER 9 295 #define FAMILY_LIFE_GEM 10 // generated upon death 296 #define FAMILY_KEY 11 297 #define FAMILY_SPEED_POTION 12 298 #define MAX_TREASURE 12 // # of biggest treasure.. 299 300 // Generator families 301 #define FAMILY_TENT 0 // skeletons 302 #define FAMILY_TOWER 1 // mages 303 #define FAMILY_BONES 2 // ghosts 304 #define FAMILY_TREEHOUSE 3 // elves :) 305 306 // FX families 307 //#define FAMILY_STAIN 0 308 #define FAMILY_EXPAND 0 309 #define FAMILY_GHOST_SCARE 1 310 #define FAMILY_BOMB 2 311 #define FAMILY_EXPLOSION 3 // Bombs, etc. 312 #define FAMILY_FLASH 4 // Used for teleporter effects 313 #define FAMILY_MAGIC_SHIELD 5 // revolving protective shield 314 #define FAMILY_KNIFE_BACK 6 // Returning blade 315 #define FAMILY_BOOMERANG 7 // Circling boomerang 316 #define FAMILY_CLOUD 8 // purple poison cloud 317 #define FAMILY_MARKER 9 // Marker for Mages Teleport 318 #define FAMILY_CHAIN 10 // 'Chain lightning' effect 319 #define FAMILY_DOOR_OPEN 11 // The open door 320 321 // Special families 322 #define FAMILY_RESERVED_TEAM 0 323 324 // Button graphic families 325 #define FAMILY_NORMAL1 0 326 #define FAMILY_PLUS 1 327 #define FAMILY_MINUS 2 328 329 // Facings 330 #define FACE_UP 0 331 #define FACE_UP_RIGHT 1 332 #define FACE_RIGHT 2 333 #define FACE_DOWN_RIGHT 3 334 #define FACE_DOWN 4 335 #define FACE_DOWN_LEFT 5 336 #define FACE_LEFT 6 337 #define FACE_UP_LEFT 7 338 #define NUM_FACINGS 8 339 340 // Stats defines 341 #define COMMAND_WALK 1 342 #define COMMAND_FIRE 2 343 #define COMMAND_RANDOM_WALK 3 // walk random dir .. 344 #define COMMAND_DIE 4 // bug fixing .. 345 #define COMMAND_FOLLOW 5 346 #define COMMAND_RUSH 6 // Rush your enemy! 347 #define COMMAND_MULTIDO 7 // Do <com1> commands in one round 348 #define COMMAND_QUICK_FIRE 8 // Fires with no busy or animation 349 #define COMMAND_SET_WEAPON 9 // set weapon type 350 #define COMMAND_RESET_WEAPON 10 // restores weapon to default 351 #define COMMAND_SEARCH 11 // use right-hand rule to find foe 352 #define COMMAND_ATTACK 12 // attack / move to a close, current foe 353 #define COMMAND_RIGHT_WALK 13 // use right-hand rule ONLY; no direct walk 354 #define COMMAND_UNCHARM 14 // recover from being 'charmed' 355 #define REGEN (long) 4000 // used to calculate time between heals 356 357 #define STANDARD_TEXT_TIME 75 // how many cycles to display text? 358 #define TEXT_1 "text.pix" // standard text pixie 359 360 #define DONT_DELETE 1 361 362 #ifndef PROT_MODE 363 // sound 364 extern "C" short init_sound(char *filename, short speed, short which); 365 extern "C" void play_sound(short which); 366 #endif 367 368 //most of these are graphlib and are being ported to video 369 void load_map_data(unsigned char **whereto); 370 char* get_cfg_item(char *section, char *item); 371 short get_pix_directory(); 372 short get_pix_directory(char *whereto); // copies to whereto, returns OKAY.. 373 374 // Functions in game.cpp 375 short load_team_list(char * filename, screen *myscreen); 376 short load_saved_game(char *filename, screen *myscreen); 377 short save_game(char *filename, screen *myscreen); 378 379 #define NORMAL_MODE 0 // #defines for walkputbuffer mode type 380 #define INVISIBLE_MODE 1 // 381 #define PHANTOM_MODE 2 // 382 #define OUTLINE_MODE 3 // 383 384 #define SHIFT_LIGHTER 0 // #defines for phantomputbuffer 385 #define SHIFT_DARKER 1 // 386 #define SHIFT_LEFT 2 // 387 #define SHIFT_RIGHT 3 // 388 #define SHIFT_RIGHT_RANDOM 4 // shifts right 1 or 2 spaces (whole image) 389 #define SHIFT_RANDOM 5 // shifts 1 or 2 right (on pixel x pixel basis) 390 #define SHIFT_BLOCKY 6 // courtroom style 391 392 393 #define SCEN_TYPE_CAN_EXIT (char) 1 // make these go by power of 2, 1,2,4,8 394 #define SCEN_TYPE_GEN_EXIT (char) 2 395 #define SCEN_TYPE_SAVE_ALL (char) 4 // save named npc's 396 397 #define OUTLINE_NAMED 7 // #defines for outline colors 398 #define OUTLINE_INVULNERABLE 224 // 399 #define OUTLINE_FLYING 208 // 400 #define OUTLINE_INVISIBLE query_team_color() // 401 402 #define ACTION_FOLLOW (char) 1 403 404 unsigned char * read_pixie_file(const char * filename); 405 406 // Some stuff for palette 407 typedef struct 408 { 409 char r, g, b; 410 } 411 rgb; 412 413 typedef rgb palette[256]; 414 415 void set_vga_palette(palette p); 416 rgb set_rgb(char r, char g, char b); 417 short read_palette(FILE *f, palette p); 418 419 420 #endif 421 422