| 1 | /* config.h-- Configuration information for AGiliTy. */ |
| 2 | /* Copyright (C) 1996-1999,2001 Robert Masenten */ |
| 3 | /* This program may be redistributed under the terms of the |
| 4 | GNU General Public License, version 2; see agility.h for details. */ |
| 5 | /* |
| 6 | This file contains most of the configuration information |
| 7 | including the platform-dependent #define statements |
| 8 | It's in three major sections: |
| 9 | --Platform specific defines for various platforms, each |
| 10 | surrounded by "#ifdef <platform>" and "#endif" |
| 11 | --Various defaults |
| 12 | --Filename extensions |
| 13 | |
| 14 | Ideally, a port to a new platform should only need to modify this |
| 15 | file, the makefile, os_<whatever>.c, and possibly filename.c. (In |
| 16 | practice, you may also need to tweak the the high-level I/O code |
| 17 | in interface.c or the memory-allocation code in util.c. If you |
| 18 | find yourself needing to do more than that, get in touch with me.) */ |
| 19 | |
| 20 | #undef _WIN32 /* GARGLK */ |
| 21 | |
| 22 | |
| 23 | /* Default to PLAIN platform */ |
| 24 | /* At the moment, you can replace this with LINUX, HPUX, AMIGA, */ |
| 25 | /* MSDOS, SUN, or NEXT; some of these may require the correct os_... */ |
| 26 | /* file to work */ |
| 27 | /* (In particular, AMIGA requires David Kinder's os_amiga.c file) */ |
| 28 | /* The actual platform specific defines don't start until a few */ |
| 29 | /* lines down, past the #includes and the definition of global */ |
| 30 | #ifndef PLAIN |
| 31 | #define PLAIN |
| 32 | #endif |
| 33 | |
| 34 | |
| 35 | #if defined(__MSDOS__) || defined(_DOS) |
| 36 | /* These work under Borland C and Visual C++ 1.52, respectively */ |
| 37 | #ifndef MSDOS |
| 38 | #define MSDOS |
| 39 | #endif |
| 40 | #ifndef MSDOS32 |
| 41 | #define MSDOS16 |
| 42 | #endif |
| 43 | #endif |
| 44 | |
| 45 | /* ------------------------------------------------------------------- */ |
| 46 | /* PLATFORM SPECIFIC DEFINITIONS, ETC. */ |
| 47 | /* See agility.doc or porting.txt for more information. */ |
| 48 | /* Things you can currently define: */ |
| 49 | /* fix_ascii: 1=translate IBM character set, 0=don't */ |
| 50 | /* NEED_STR_CMP: define if strcasecmp() not defined on your system */ |
| 51 | /* NEED_STRN_CMP: define if strncasecmp() not defined on your system */ |
| 52 | /* HAVE_STRDUP: define if strdup() exists on your system */ |
| 53 | /* REPLACE_GETFILE: define if you replace the default get_user_file(). */ |
| 54 | /* REPLACE_MENU if you replace agt_menu(). */ |
| 55 | /* REPLACE_MAIN: define if you replace the default main(). */ |
| 56 | /* (replacements should be defined in the relevant os_<platform>.c file) */ |
| 57 | /* DA1,DA2,...DA6,DSS,pTTL: file name extensions for the various AGT |
| 58 | files */ |
| 59 | /* HAVE_SLEEP if your platform has the sleep() function */ |
| 60 | /* BUFF_SIZE is the maximum size of the buffer to use when reading |
| 61 | in files. Regardless, it will be made no bigger than the file |
| 62 | being read in and no smaller than the record size; thus setting |
| 63 | it to 0 will cause the smallest buffer to always be used and |
| 64 | setting this to 1MB will in practice always use a buffer the |
| 65 | sizs of the file. It defaults to 32K */ |
| 66 | /* CBUF_SIZE is the maximum size of the buffer used for reading in |
| 67 | the Master's Edition DA6 files; the size of the buffer in bytes |
| 68 | is twice this value (since an individual token is two bytes long). */ |
| 69 | /* DESCR_BUFFSIZE is the maximum size of the description text block before |
| 70 | the interpreter will read it from disk rather than storing it in |
| 71 | memory during play. At the moment this only affects AGX games; |
| 72 | original AGT games always use the disk. */ |
| 73 | /* DOHASH to use a hash table for dictionary searches; the only |
| 74 | reason not to have this would be memory */ |
| 75 | /* HASHBITS determines the size of the hash table: (2^HASHBITS)*sizeof(word); |
| 76 | the hash table must be at least as large as the dictionary. |
| 77 | In practice this means HASHBITS should be at least 12; |
| 78 | this is the current default. */ |
| 79 | /* MAXSTRUC The maximum size (in chars) which a single data structure can |
| 80 | be on this platform. This defaults to 1MB (i.e. no limit for |
| 81 | practical purposes). In practice I know of no game files that |
| 82 | require any structures bigger than about 30K. */ |
| 83 | /* LOWMEM Define this if you are low on memory. At the moment this |
| 84 | only saves a few K.*/ |
| 85 | /* PORTSTR Is the string describing this particular port. |
| 86 | e.g. #define PORTSTR "OrfDOS Port by R.J. Wright" */ |
| 87 | /* UNIX_IO if you have Unix-like low level file I/O functions. |
| 88 | (MS-DOS, for example, does). This speeds up the reading |
| 89 | of the large game data files on some platforms. If this is |
| 90 | defined, READFLAG, WRITEFLAG, and FILE_PERM also need to |
| 91 | be defined. (Giving the flags needed for opening a file for |
| 92 | reading or writing, and the file permissions to be given to newly |
| 93 | created files. */ |
| 94 | /* OPEN_AS_TEXT Define to cause text files to be opened as text files. */ |
| 95 | /* PREFIX_EXT Add filename extensions at the beginning of the name, |
| 96 | rather than at the end. */ |
| 97 | /* PATH_SEP, if defined, is a string containing all characters which |
| 98 | can be used to separate the path from the filename. */ |
| 99 | /* pathtest(s) is a macro that should check whether the given string |
| 100 | is an absolute path. If this is left undefined, then _all_ |
| 101 | paths will be treated as absolute. You don't need to define |
| 102 | this if you are replacing filename.c. */ |
| 103 | /* ------------------------------------------------------------------- */ |
| 104 | |
| 105 | /* force16 is used purely for debugging purposes, to make sure that |
| 106 | everything works okay even with 16-bit ints */ |
| 107 | /* #define force16 */ |
| 108 | |
| 109 | #define DOHASH |
| 110 | |
| 111 | /* This is intended for DJGPP */ |
| 112 | #ifdef MSDOS32 |
| 113 | #define HAVE_STRDUP |
| 114 | #define BUFF_SIZE (1024L*1024L) |
| 115 | #define INBUFF_SIZE (8*1024) /* Used by Magx */ |
| 116 | #define MAXSTRUC (4*1024L*1024L) /* If we're asking for over 4 MB, something |
| 117 | is wrong. */ |
| 118 | #define DESCR_BUFFSIZE (4*1025L*1024L) |
| 119 | #define CBUF_SIZE (20000L) |
| 120 | #define PORTSTR "DOS 386 Version" |
| 121 | #define READFLAG O_RDONLY |
| 122 | #define WRITEFLAG (O_WRONLY|O_CREAT|O_TRUNC) |
| 123 | #define FILE_PERM (S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH) |
| 124 | #include <unistd.h> |
| 125 | #ifndef MSDOS |
| 126 | #define MSDOS |
| 127 | #endif |
| 128 | #ifdef __DJGPP__ |
| 129 | #define REPLACE_BNW /* Enable picture and font support */ |
| 130 | #endif |
| 131 | #endif |
| 132 | |
| 133 | |
| 134 | |
| 135 | /* This works with Borland C; I don't know about other DOS C compilers */ |
| 136 | #ifdef MSDOS16 |
| 137 | #define strcasecmp(s1,s2) stricmp(s1,s2) |
| 138 | #define NEED_STRN_CMP |
| 139 | #define BUFF_SIZE (16*1024L) |
| 140 | #define INBUFF_SIZE (2*1024) /* Used by Magx */ |
| 141 | #define CBUF_SIZE (10000L) /* DOS file routines used signed ints, and |
| 142 | so can only handle 32K sized blocks */ |
| 143 | #define MAXSTRUC (64L*1024L) /* DOS 64K Limit */ |
| 144 | #define PORTSTR "DOS Version" |
| 145 | #define READFLAG (O_RDONLY | O_BINARY) |
| 146 | #define WRITEFLAG (O_WRONLY | O_BINARY | O_CREAT | O_TRUNC) |
| 147 | #define FILE_PERM (S_IWRITE | S_IREAD) |
| 148 | #define REPLACE_BNW |
| 149 | /* #define LOWMEM*/ |
| 150 | #define DOSFARDATA far |
| 151 | #define HASHBITS 13 |
| 152 | #ifndef MSDOS |
| 153 | #define MSDOS |
| 154 | #endif |
| 155 | #endif |
| 156 | |
| 157 | |
| 158 | /* This is common configuration information shared by both |
| 159 | DOS16 and DOS32 */ |
| 160 | #ifdef MSDOS |
| 161 | #define fnamecmp strcasecmp /* Case insensitive file name comparison */ |
| 162 | #define fix_ascii 0 /* DON'T translate IBM character set */ |
| 163 | #define HAVE_SLEEP |
| 164 | #define FAST_FIXSIGN |
| 165 | #define UNIX_IO |
| 166 | #define PATH_SEP ":\\" |
| 167 | #define pathtest(s) (s[0]=='\\' || strchr(s,':')!=NULL); |
| 168 | #undef PLAIN |
| 169 | #endif |
| 170 | |
| 171 | |
| 172 | |
| 173 | |
| 174 | #ifdef LINUX |
| 175 | #define LINUX_COLOR |
| 176 | #define fix_ascii 1 |
| 177 | /* #define HAVE_TPARAM */ |
| 178 | #define UNIX |
| 179 | #define HAVE_STRDUP |
| 180 | #define BUFF_SIZE (1024L*1024L) |
| 181 | #define INBUFF_SIZE (8*1024) /* Used by Magx */ |
| 182 | #define MAXSTRUC (4*1024L*1024L) /* If we're asking for over 4 MB, something |
| 183 | is wrong. */ |
| 184 | #define DESCR_BUFFSIZE (4*1025L*1024L) |
| 185 | #define CBUF_SIZE (20000L) |
| 186 | /* If you're compiling for a 32-bit platform, you can uncomment the following |
| 187 | for a modest performance increase. */ |
| 188 | /* #define FAST_FIXSIGN */ |
| 189 | #define PORTSTR "Linux Version" |
| 190 | #define REPLACE_BNW |
| 191 | #undef PLAIN |
| 192 | #endif |
| 193 | |
| 194 | |
| 195 | /* The following configuration was contributed by Alexander Lehmann */ |
| 196 | /* It was originally written for 0.3, but it should work for later */ |
| 197 | /* versions as well. */ |
| 198 | #ifdef HPUX |
| 199 | #define HAVE_TPARAM |
| 200 | #define UNIX |
| 201 | #define HAVE_STRDUP |
| 202 | #define BUFF_SIZE (1024L*1024L) |
| 203 | #define MAXSTRUCT (1024L*1024L) |
| 204 | #define DESCR_BUFFSIZE (1024L*1024L) |
| 205 | #define CBUF_SIZE (20000L) |
| 206 | #define FAST_FIXSIGN |
| 207 | #define PORTSTR "HP-UX Version" |
| 208 | #undef PLAIN |
| 209 | #endif |
| 210 | |
| 211 | |
| 212 | |
| 213 | #ifdef SUN |
| 214 | #define NO_TERMCAP_H |
| 215 | #define UNIX |
| 216 | #define BUFF_SIZE (1024L*1024L) |
| 217 | #define MAXSTRUC (1024L*1024L) |
| 218 | #define DESCR_BUFFSIZE (1024L*1024L) |
| 219 | #define CBUF_SIZE (20000L) |
| 220 | #define PORTSTR "UNIX Version" |
| 221 | #undef PLAIN |
| 222 | #endif |
| 223 | |
| 224 | |
| 225 | /* This can presumably be tweaked to support various flavors of BSD */ |
| 226 | #ifdef NEXT |
| 227 | #define NO_TERMCAP_H |
| 228 | #define UNIX |
| 229 | #define BSD_TERM |
| 230 | #define BUFF_SIZE (1024L*1024L) |
| 231 | #define MAXSTRUC (1024L*1024L) |
| 232 | #define DESCR_BUFFSIZE (1024L*1024L) |
| 233 | #define CBUF_SIZE (20000L) |
| 234 | #define PORTSTR "NEXT/BSD Version" |
| 235 | #define _POSIX_SOURCE |
| 236 | #include <time.h> |
| 237 | #include <sys/types.h> |
| 238 | #undef PLAIN |
| 239 | #endif |
| 240 | |
| 241 | |
| 242 | /* From David Kinder's Amiga port; you'll also need his os_amiga.c file */ |
| 243 | #ifdef AMIGA |
| 244 | #define NEED_STR_CMP |
| 245 | #define NEED_STRN_CMP |
| 246 | #undef HAVE_STRDUP |
| 247 | #define REPLACE_GETFILE |
| 248 | #define FAST_FIXSIGN |
| 249 | #define BUFF_SIZE (256L*1024L) |
| 250 | #define CBUF_SIZE (20000L) |
| 251 | #define UNIX_IO |
| 252 | #define PORTSTR "Amiga Version by David Kinder" |
| 253 | #define READFLAG O_RDONLY |
| 254 | #define WRITEFLAG (O_WRONLY|O_CREAT|O_TRUNC) |
| 255 | #define FILE_PERM 0 |
| 256 | #undef PLAIN |
| 257 | /* Fix for DICE compiler problem */ |
| 258 | #ifdef _DCC |
| 259 | #ifdef INT_MIN |
| 260 | #undef INT_MIN |
| 261 | #endif |
| 262 | #define INT_MIN -2147483647 |
| 263 | #endif |
| 264 | #endif |
| 265 | |
| 266 | |
| 267 | |
| 268 | |
| 269 | /* For David Kinder's Windows port; you will also need his source files */ |
| 270 | #ifdef _WIN32 |
| 271 | #define NEED_STR_CMP |
| 272 | #define NEED_STRN_CMP |
| 273 | #undef HAVE_STRDUP |
| 274 | #define REPLACE_GETFILE |
| 275 | #define FAST_FIXSIGN |
| 276 | #define BUFF_SIZE (256L*1024L) |
| 277 | #define CBUF_SIZE (20000L) |
| 278 | #define UNIX_IO |
| 279 | #define PORTSTR "Windows Version by David Kinder" |
| 280 | #define READFLAG O_RDONLY |
| 281 | #define WRITEFLAG (O_WRONLY|O_CREAT|O_TRUNC) |
| 282 | #define FILE_PERM 0 |
| 283 | #undef PLAIN |
| 284 | #endif |
| 285 | |
| 286 | |
| 287 | /* |
| 288 | * The Glk port is very similar to plain ASCII, to give it the best |
| 289 | * chance at success on multiple Glk platforms. The only basic change |
| 290 | * is to turn off IBM character translations; Glk works in ISO 8859 |
| 291 | * Latin-1, which can offer slightly closer translation of the IBM |
| 292 | * code page 437 characters that the simpler mappings in the core |
| 293 | * AGiliTy code. The os_glk.c module handles the translations. |
| 294 | */ |
| 295 | #ifdef GLK |
| 296 | /* |
| 297 | * Gargoyle expects a Unix-like system (including Windows with MinGW); |
| 298 | * strcasecmp() and strncasecmp() are POSIX, so can be assumed to exist. |
| 299 | */ |
| 300 | #if 0 |
| 301 | #define NEED_STR_CMP /* Inherited from PLAIN. */ |
| 302 | #define NEED_STRN_CMP /* Inherited from PLAIN. */ |
| 303 | #endif |
| 304 | #define BUFF_SIZE 0 /* Inherited from PLAIN. */ |
| 305 | #define CBUF_SIZE (5000L) /* Inherited from PLAIN. */ |
| 306 | #define INBUFF_SIZE (1024) /* Inherited from PLAIN. */ |
| 307 | #define fix_ascii 0 /* os_glk.c does translations. */ |
| 308 | #define MAXSTRUC (1024L*1024L) /* 32Kb from PLAIN is too small for |
| 309 | several games (including Soggy). */ |
| 310 | #define PORTSTR "Glk version" /* Identify ourselves discreetly. */ |
| 311 | #define REPLACE_GETFILE /* Override get_user_file. */ |
| 312 | #define REPLACE_MAIN /* Override main. */ |
| 313 | #define fnamecmp strcasecmp /* Case insensitive filename compare. */ |
| 314 | #undef PLAIN |
| 315 | |
| 316 | #if 0 |
| 317 | #ifdef __APPLE__ |
| 318 | #undef NEED_STR_CMP |
| 319 | #undef NEED_STRN_CMP |
| 320 | #endif /* __APPLE__ */ |
| 321 | #endif |
| 322 | |
| 323 | #endif |
| 324 | |
| 325 | |
| 326 | /* PLAIN should always come last, giving everyone else a chance |
| 327 | to #undef it. */ |
| 328 | #ifdef PLAIN /* This should work if nothing else does */ |
| 329 | #define NEED_STR_CMP |
| 330 | #define NEED_STRN_CMP |
| 331 | #define BUFF_SIZE 0 |
| 332 | #define CBUF_SIZE (5000L) |
| 333 | #define INBUFF_SIZE (1024) /* Used by Magx */ |
| 334 | #define MAXSTRUC (32L*1024L) /* IIRC, 32K is the minimum required by |
| 335 | the ANSI standard */ |
| 336 | #define PORTSTR "Pure ANSI C version" |
| 337 | #endif |
| 338 | |
| 339 | |
| 340 | /* __GNUC__ */ |
| 341 | |
| 342 | |
| 343 | /* ------------------------------------------------------------------- */ |
| 344 | /* DEFAULTS FOR "PLATFORM SPECIFIC" DEFINES */ |
| 345 | /* ------------------------------------------------------------------- */ |
| 346 | |
| 347 | #ifdef __POSIX__ |
| 348 | #ifndef UNIX |
| 349 | #define UNIX |
| 350 | #endif |
| 351 | #endif |
| 352 | |
| 353 | #ifdef UNIX |
| 354 | #define HAVE_SLEEP |
| 355 | #define UNIX_IO |
| 356 | #define READFLAG O_RDONLY |
| 357 | #define WRITEFLAG (O_WRONLY|O_CREAT|O_TRUNC) |
| 358 | #define FILE_PERM (S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH) |
| 359 | #define PATH_SEP "/" |
| 360 | #define pathtest(s) (s[0]=='/'); |
| 361 | #include <unistd.h> |
| 362 | #endif |
| 363 | |
| 364 | #if 0 |
| 365 | #ifdef __STRICT_ANSI__ |
| 366 | #define NEED_STR_CMP |
| 367 | #define NEED_STRN_CMP |
| 368 | #undef HAVE_STRDUP |
| 369 | #endif |
| 370 | #endif |
| 371 | |
| 372 | #ifndef fix_ascii |
| 373 | #define fix_ascii 1 /* Translate IBM character set by default */ |
| 374 | #endif |
| 375 | |
| 376 | #ifndef BUFF_SIZE |
| 377 | #ifdef LOWMEM |
| 378 | #define BUFF_SIZE 0 /* i.e. unbuffered */ |
| 379 | #else |
| 380 | #define BUFF_SIZE (32L*1024L) /* 32K */ |
| 381 | #endif |
| 382 | #endif /* BUFF_SIZE */ |
| 383 | |
| 384 | #ifndef MAXSTRUC |
| 385 | #define MAXSTRUC (1024L*1024L) |
| 386 | #endif |
| 387 | |
| 388 | #ifndef DESCR_BUFFSIZE |
| 389 | #define DESCR_BUFFSIZE 0 /* Always load descriptions from disk */ |
| 390 | #endif |
| 391 | |
| 392 | #ifndef HASHBITS |
| 393 | #ifdef LOWMEM |
| 394 | #define HASHBITS 12 /* 4K entries */ |
| 395 | #else |
| 396 | #define HASHBITS 13 /* 8K entries in hash table */ |
| 397 | #endif |
| 398 | #endif /* HASHBITS */ |
| 399 | |
| 400 | #ifndef fnamecmp /* Used to compare filenames */ |
| 401 | #define fnamecmp strcmp |
| 402 | #endif |
| 403 | |
| 404 | #ifndef fnamencmp /* Also used to compare filenames */ |
| 405 | #define fnamencmp strncmp |
| 406 | #endif |
| 407 | |
| 408 | /* If DOSFARDATA hasn't been defined, define it as the empty string. */ |
| 409 | #ifndef DOSFARDATA |
| 410 | #define DOSFARDATA |
| 411 | #endif |
| 412 | |
| 413 | /* ---------------------------------------------------------------------- */ |
| 414 | /* FILENAME EXTENSIONS */ |
| 415 | /* These are the various filename extensions for the different data files.*/ |
| 416 | /* ---------------------------------------------------------------------- */ |
| 417 | |
| 418 | /* The following are only used by the interpreter, agtout, and agt2agx */ |
| 419 | #ifndef DA1 |
| 420 | #define DA1 ".da1" /* General info (text file) */ |
| 421 | #define DA2 ".da2" /* Rooms */ |
| 422 | #define DA3 ".da3" /* Items */ |
| 423 | #define DA4 ".da4" /* Creatures */ |
| 424 | #define DA5 ".da5" /* Commands, headers */ |
| 425 | #define DA6 ".da6" /* Commands, code (Master's Ed only) */ |
| 426 | #define DSS ".d$$" /* Description strings */ |
| 427 | #define pHNT ".hnt" /* Popup hint file; not used yet. */ |
| 428 | #define pOPT ".opt" /* Interface specification file */ |
| 429 | #endif |
| 430 | |
| 431 | /* The following are only used by the Magx compiler */ |
| 432 | #ifndef pAGT |
| 433 | #define pAGT ".agt" |
| 434 | #define pDAT ".dat" |
| 435 | #define pMSG ".msg" |
| 436 | #define pCMD ".cmd" |
| 437 | #define pSTD ".std" |
| 438 | #define AGTpSTD "agt.std" /* Default error message file */ |
| 439 | #endif |
| 440 | |
| 441 | /* The following are used by both the interpreter and the compiler */ |
| 442 | #ifndef pAGX |
| 443 | #define pAGX ".agx" /* Extension for new Adventure Game eXecutable format */ |
| 444 | #define pTTL ".ttl" /* Title file */ |
| 445 | #define pINS ".ins" /* Instruction file */ |
| 446 | #define pVOC ".voc" /* Menu vocabulary file */ |
| 447 | #define pCFG ".cfg" /* Game configuration file */ |
| 448 | #define pEXT "." /* Separator between extension and base of filename */ |
| 449 | #endif |
| 450 | |
| 451 | |
| 452 | #ifndef pSAV |
| 453 | #define pSAV ".sav" /* Extension for save files */ |
| 454 | #endif |
| 455 | |
| 456 | #ifndef pSCR |
| 457 | #define pSCR ".scr" /* Script file */ |
| 458 | #endif |
| 459 | |
| 460 | #ifndef pLOG |
| 461 | #define pLOG ".log" /* LOG/REPLAY file */ |
| 462 | #endif |
| 463 | |
| 464 | |
| 465 | |
| 466 | |
| 467 | |
| 468 | /* Finally, two potentially platform dependent type defintions, |
| 469 | for binary and text files respectively. Don't change these |
| 470 | unless you are also changing filename.c */ |
| 471 | |
| 472 | typedef FILE* genfile; |
| 473 | typedef char* file_id_type; /* i.e. the filename */ |
| 474 | |
| 475 | #define NO_FILE_ID NULL |
| 476 | #define BAD_TEXTFILE NULL |
| 477 | #define BAD_BINFILE NULL |
| 478 | |
| 479 | #define textgetc(f) fgetc(f) |
| 480 | #define textungetc(f,c) ungetc(c,f) |
| 481 | #define textgets(f,s,n) fgets(s,n,f) |
| 482 | #define texteof(f) feof(f) |
| 483 | #define textputs(f,s) fputs(s,f) |
| 484 | |
| 485 | |
| 486 | #if 0 |
| 487 | int textgetc(genfile f); |
| 488 | void textungetc(genfile f, char c); |
| 489 | int texteof(genfile f); |
| 490 | void textgets(genfile f, char *buff, long leng); |
| 491 | void textputs(genfile f, const char *s); |
| 492 | #endif |
| 493 |