home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / vol_100 / 159_01 / advent.h < prev    next >
C/C++ Source or Header  |  1990-05-04  |  14KB  |  463 lines

  1.  
  2. /*    ADVENT.H    revised header for BDS c vers 1.43   */
  3.  
  4. /*                Revised for Eco-C88 V2.72 by Bob Withers
  5.                   Defined all variables for driver routines and
  6.                   altered header to declare them external for
  7.                   all sub-modules.    BW - 09/14/85
  8. */
  9.  
  10. #define NUL                '\0'
  11.  
  12. #define MAXDIM(a)            (sizeof(a) / sizeof(a[0]))
  13.  
  14. #define VOID                void
  15. #define NEAR                near
  16. #define PASCAL                pascal
  17.  
  18. #ifndef TRUE
  19. #define TRUE                1
  20. #define FALSE                0
  21. #endif
  22.  
  23. typedef short                SHORT;
  24. typedef unsigned short            USHORT;
  25. typedef long                LONG;
  26. typedef unsigned long            ULONG;
  27. typedef short                BOOL;
  28.  
  29. #include <stdio.h>
  30. #include <stdlib.h>
  31. #include <ctype.h>
  32. #include <string.h>
  33.  
  34. #define MAXLOC                150
  35. #define MAXOBJ                100
  36. #define WORDSIZE            20
  37.  
  38. #define DWARFMAX            7
  39. #define MAXDIE                3
  40. #define MAXTRS                79
  41.  
  42. #define READ_BIN            "rb"
  43. #define WRITE_BIN            "wb"
  44.  
  45.  
  46. #define VOCAB_OBJECT            1000
  47. #define VOCAB_VERB            2000
  48. #define VOCAB_MSG            3000
  49.  
  50. /*
  51.         Object definitions
  52. */
  53. #define KEYS                1
  54. #define LAMP                2
  55. #define GRATE                3
  56. #define CAGE                4
  57. #define ROD                5
  58. #define ROD2                6
  59. #define STEPS                7
  60. #define BIRD                8
  61. #define DOOR                9
  62. #define PILLOW                10
  63. #define SNAKE                11
  64. #define FISSURE             12
  65. #define TABLET                13
  66. #define CLAM                14
  67. #define OYSTER                15
  68. #define MAGAZINE            16
  69. #define DWARF                17
  70. #define KNIFE                18
  71. #define FOOD                19
  72. #define BOTTLE                20
  73. #define WATER                21
  74. #define OIL                22
  75. #define MIRROR                23
  76. #define PLANT                24
  77. #define PLANT2                25
  78. #define STALACTITE            26
  79. #define FIGURE                27
  80. #define AXE                28
  81. #define DRAWING             29
  82. #define PIRATE                30
  83. #define DRAGON                31
  84. #define CHASM                32
  85. #define TROLL                33
  86. #define TROLL2                34
  87. #define BEAR                35
  88. #define MESSAGE             36
  89. #define VOLCANO             37
  90. #define VEND                38
  91. #define BATTERIES            39
  92. #define CARPET                40
  93. #define NUGGET                50
  94. #define DIAMONDS            51
  95. #define SILVER                52
  96. #define JEWELS                53
  97. #define COINS                54
  98. #define CHEST                55
  99. #define EGGS                56
  100. #define TRIDENT             57
  101. #define VASE                58
  102. #define EMERALD             59
  103. #define PYRAMID             60
  104. #define PEARL                61
  105. #define RUG                62
  106. #define SPICES                63
  107. #define CHAIN                64
  108.  
  109. /*
  110.         Verb definitions
  111. */
  112. #define NULLX                21
  113. #define BACK                8
  114. #define LOOK                57
  115. #define CAVE                67
  116. #define ENTRANCE            64
  117. #define DEPRESSION            63
  118.  
  119. /*
  120.         Action verb definitions
  121. */
  122. #define TAKE                1
  123. #define DROP                2
  124. #define SAY                3
  125. #define OPEN                4
  126. #define NOTHING             5
  127. #define LOCK                6
  128. #define ON                7
  129. #define OFF                8
  130. #define WAVE                9
  131. #define CALM                10
  132. #define WALK                11
  133. #define KILL                12
  134. #define POUR                13
  135. #define EAT                14
  136. #define DRINK                15
  137. #define RUB                16
  138. #define THROW                17
  139. #define QUIT                18
  140. #define FIND                19
  141. #define INVENTORY            20
  142. #define FEED                21
  143. #define FILL                22
  144. #define BLAST                23
  145. #define SCORE                24
  146. #define FOO                25
  147. #define BRIEF                26
  148. #define READ                27
  149. #define BREAK                28
  150. #define WAKE                29
  151. #define SUSPEND             30
  152. #define HOURS                31
  153. #define LOG                32
  154. #define SAVE                33
  155. #define RESTORE             34
  156. #define VERBOSE             35
  157.  
  158. /*
  159.         Bits of array cond
  160.         indicating location status
  161. */
  162. #define LIGHT                1
  163. #define WATOIL                2
  164. #define LIQUID                4
  165. #define NOPIRAT             8
  166. #define HINTC                16
  167. #define HINTB                32
  168. #define HINTS                64
  169. #define HINTM                128
  170. #define HINT                240
  171.  
  172. /*
  173.         Adventure global variables
  174. */
  175.  
  176. struct S_VocabTab
  177. {
  178.     char    *pWord;
  179.     SHORT     sWord;
  180. };
  181. typedef struct S_VocabTab        VOCABTAB;
  182.  
  183. struct trav
  184. {
  185.     SHORT     tdest;
  186.     SHORT     tverb;
  187.     SHORT     tcond;
  188. };
  189. typedef struct trav            TRAV;
  190.  
  191. struct travtab
  192. {
  193.     TRAV    *pTrav;             // trav array for location
  194.     SHORT     sTrav;             // # entries for location
  195. };
  196. typedef struct travtab            TRAVTAB;
  197.  
  198.  
  199. #ifdef DRIVER
  200. #define CLASS
  201. #define INIT(x)         = x
  202. #else
  203. #define CLASS            extern
  204. #define INIT(x)
  205. #endif
  206.  
  207. #define NEARDATA        NEAR
  208.  
  209. CLASS SHORT  brief_sw;
  210. /*
  211.         Database variables
  212. */
  213. CLASS TRAV *     NEARDATA pTravel;        /* travel array & count for */
  214. CLASS SHORT     NEARDATA sTravCnt;        /* the current location     */
  215. CLASS SHORT     NEARDATA actmsg[32]              /* action messages */
  216. #ifdef DRIVER
  217.       = {
  218.           0,  24,  29,   0,  33,   0,  33,    38,  38,  42,  /*  0 -    9 */
  219.          14,  43, 110,  29, 110,  73,  75,    29,  13,  59,  /* 10 - 19 */
  220.          59, 174, 109,  67,  13, 147, 155, 195, 146, 110,  /* 20 - 29 */
  221.          13,  13                           /* 30 - 31 */
  222.     };
  223. #else
  224.      ;
  225. #endif
  226.  
  227. /*
  228.         English variables
  229. */
  230. CLASS SHORT     NEARDATA verb;
  231. CLASS SHORT     NEARDATA object;
  232. CLASS SHORT     NEARDATA motion;
  233. CLASS char     NEARDATA word1[WORDSIZE];
  234. CLASS char     NEARDATA word2[WORDSIZE];
  235.  
  236. /*
  237.         Play variables
  238. */
  239. CLASS SHORT     NEARDATA turns        INIT(0);
  240. CLASS SHORT     NEARDATA loc           INIT(1);
  241. CLASS SHORT     NEARDATA oldloc       INIT(1);
  242. CLASS SHORT     NEARDATA oldloc2       INIT(1);
  243. CLASS SHORT     NEARDATA newloc       INIT(3);
  244. CLASS SHORT     NEARDATA cond[MAXLOC]             /* location status    */
  245. #ifdef DRIVER
  246.       = {
  247.           0,   5,    1,   5,   5,   1,   1,     5,  17,   1,  /*   0 -   9 */
  248.           1,   0,    0,  32,   0,   0,   2,     0,   0,  64,  /*  10 -  19 */
  249.           2,   2,    2,   0,   6,   0,   2,     0,   0,   0,  /*  20 -  29 */
  250.           0,   2,    2,   0,   0,   0,   0,     0,   4,   0,  /*  30 -  39 */
  251.           2,   0, 128, 128, 128, 128, 136, 136, 136, 128,  /*  40 -  49 */
  252.         128, 128, 128, 136, 128, 136,   0,     8,   0,   2,  /*  50 -  59 */
  253.           0,   0,    0,   0,   0,   0,   0,     0,   0,   0,  /*  60 -  69 */
  254.           0,   0,    0,   0,   0,   0,   0,     0,   0,   2,  /*  70 -  79 */
  255.         128, 128, 136,   0,   0,   8, 136, 128,   0,   2,  /*  80 -  89 */
  256.           2,   0,    0,   0,   0,   4,   0,     0,   0,   0,  /*  90 -  99 */
  257.           1,   0,    0,   0,   0,   0,   0,     0,   0,   0,  /* 100 - 109 */
  258.           0,   0,    0,   4,   0,   1,   1,     0,   0,   0,  /* 110 - 119 */
  259.           0,   0,    8,   8,   8,   8,   8,     8,   8,   8,  /* 120 - 129 */
  260.           8,   0,    0,   0,   0,   0,   0,     0,   0,   0,  /* 130 - 139 */
  261.           0,   0,    0,   0,   0,   0,   0,     0,   0,   0,  /* 140 - 149 */
  262.     };
  263. #else
  264.      ;
  265. #endif
  266.  
  267. CLASS SHORT     NEARDATA place[MAXOBJ]           /* object location    */
  268. #ifdef DRIVER
  269.       = {
  270.           0,   3,    3,   8,  10,  11,   0,    14,  13,  94,  /*  0 -    9 */
  271.          96,  19,  17, 101, 103,   0, 106,     0,   0,   3,  /* 10 - 19 */
  272.           3,   0,    0, 109,  25,  23, 111,    35,   0,  97,  /* 20 - 29 */
  273.           0, 119, 117, 117,   0, 130,   0, 126, 140,   0,  /* 30 - 39 */
  274.          96,   0,    0,   0,   0,   0,   0,     0,   0,   0,  /* 40 - 49 */
  275.          18,  27,  28,  29,  30,   0,  92,    95,  97, 100,  /* 50 - 59 */
  276.         101,   0, 119, 127, 130,   0,   0,     0,   0,   0,  /* 60 - 69 */
  277.           0,   0,    0,   0,   0,   0,   0,     0,   0,   0,  /* 70 - 79 */
  278.           0,   0,    0,   0,   0,   0,   0,     0,   0,   0,  /* 80 - 89 */
  279.           0,   0,    0,   0,   0,   0,   0,     0,   0,   0,  /* 90 - 99 */
  280.     };
  281. #else
  282.      ;
  283. #endif
  284.  
  285. CLASS SHORT     NEARDATA fixed[MAXOBJ]           /* second object loc  */
  286. #ifdef DRIVER
  287.       = {
  288.           0,   0,    0,   9,   0,   0,   0,    15,   0,  -1,  /*  0 -    9 */
  289.           0,  -1,  27,  -1,   0,   0,   0,    -1,   0,   0,  /* 10 - 19 */
  290.           0,   0,    0,  -1,  -1,  67,  -1, 110,   0,  -1,  /* 20 - 29 */
  291.          -1, 121, 122, 122,   0,  -1,  -1,    -1,  -1,   0,  /* 30 - 39 */
  292.          -1,   0,    0,   0,   0,   0,   0,     0,   0,   0,  /* 40 - 49 */
  293.           0,   0,    0,   0,   0,   0,   0,     0,   0,   0,  /* 50 - 59 */
  294.           0,   0, 121,   0,  -1,   0,   0,     0,   0,   0,  /* 60 - 69 */
  295.           0,   0,    0,   0,   0,   0,   0,     0,   0,   0,  /* 70 - 79 */
  296.           0,   0,    0,   0,   0,   0,   0,     0,   0,   0,  /* 80 - 89 */
  297.           0,   0,    0,   0,   0,   0,   0,     0,   0,   0,  /* 90 - 99 */
  298.     };
  299. #else
  300.      ;
  301. #endif
  302.  
  303. CLASS SHORT     NEARDATA visited[MAXLOC];         /* >0 if has been here*/
  304. CLASS SHORT     NEARDATA prop[MAXOBJ]              /* status of object   */
  305. #ifdef DRIVER
  306.       = {
  307.           0,   0,    0,   0,   0,   0,   0,     0,   0,   0,  /*  0 -    9 */
  308.           0,   0,    0,   0,   0,   0,   0,     0,   0,   0,  /* 10 - 19 */
  309.           0,   0,    0,   0,   0,   0,   0,     0,   0,   0,  /* 20 - 29 */
  310.           0,   0,    0,   0,   0,   0,   0,     0,   0,   0,  /* 30 - 39 */
  311.           0,   0,    0,   0,   0,   0,   0,     0,   0,   0,  /* 40 - 49 */
  312.          -1,  -1,  -1,  -1,  -1,  -1,  -1,    -1,  -1,  -1,  /* 50 - 59 */
  313.          -1,  -1,  -1,  -1,  -1,  -1,  -1,    -1,  -1,  -1,  /* 60 - 69 */
  314.          -1,  -1,  -1,  -1,  -1,  -1,  -1,    -1,  -1,  -1,  /* 70 - 79 */
  315.          -1,  -1,  -1,  -1,  -1,  -1,  -1,    -1,  -1,  -1,  /* 80 - 89 */
  316.          -1,  -1,  -1,  -1,  -1,  -1,  -1,    -1,  -1,  -1,  /* 90 - 99 */
  317.     };
  318. #else
  319.      ;
  320. #endif
  321.  
  322. CLASS SHORT     NEARDATA tally        INIT(15);   /* item counts         */
  323. CLASS SHORT     NEARDATA tally2       INIT(0);
  324. CLASS SHORT     NEARDATA limit        INIT(100);  /* time limit         */
  325. CLASS SHORT     NEARDATA lmwarn       INIT(0);    /* lamp warning flag  */
  326. CLASS BOOL     NEARDATA wzdark       INIT(FALSE);
  327. CLASS BOOL     NEARDATA closing       INIT(FALSE);
  328. CLASS BOOL     NEARDATA closed       INIT(FALSE);
  329. CLASS SHORT     NEARDATA holding       INIT(0);    /* count of held items*/
  330. CLASS SHORT     NEARDATA detail       INIT(0);    /* LOOK count         */
  331. CLASS SHORT     NEARDATA knfloc       INIT(0);    /* knife location     */
  332. CLASS SHORT     NEARDATA clock1       INIT(30);   /* timing variables   */
  333. CLASS SHORT     NEARDATA clock2       INIT(50);
  334. CLASS SHORT     NEARDATA panic        INIT(0);
  335. CLASS SHORT     NEARDATA dloc[DWARFMAX]          /* dwarf locations    */
  336. #ifdef DRIVER
  337.       = {
  338.           0,  19,  27,  33,  44,  64,   0               /*  0 - 6  */
  339.     };
  340. #else
  341.      ;
  342. #endif
  343.  
  344. CLASS SHORT     NEARDATA dflag        INIT(0);    /* dwarf flag         */
  345. CLASS SHORT     NEARDATA dseen[DWARFMAX];           /* dwarf seen flag    */
  346. CLASS SHORT     NEARDATA odloc[DWARFMAX];           /* dwarf old locs     */
  347. CLASS SHORT     NEARDATA daltloc       INIT(18);   /* alt appearance     */
  348. CLASS SHORT     NEARDATA dkill        INIT(0);    /* dwarves killed     */
  349. CLASS SHORT     NEARDATA chloc        INIT(114);  /* chest locations    */
  350. CLASS SHORT     NEARDATA chloc2       INIT(140);
  351. CLASS SHORT     NEARDATA bonus        INIT(0);    /* to pass to end     */
  352. CLASS SHORT     NEARDATA numdie       INIT(0);    /* number of deaths   */
  353. CLASS SHORT     NEARDATA object1;               /* to help intrans.   */
  354. CLASS BOOL     NEARDATA gaveup       INIT(FALSE);
  355. CLASS SHORT     NEARDATA foobar       INIT(0);    /* fie fie foe foo... */
  356. CLASS BOOL     NEARDATA saveflg       INIT(FALSE);/* game being saved?  */
  357. CLASS SHORT     NEARDATA dbgflg;               /* game in restart?   */
  358.  
  359.  
  360. CLASS char     NEARDATA lastglob;               /* to get space req.  */
  361.  
  362. /*  endglobal  */
  363.  
  364. /*  function prototypes                             */
  365.  
  366. /*  advent.c  */
  367. int               main(int argc, char **argv);
  368. VOID        PASCAL restore(VOID);
  369.  
  370. /*  database.c    */
  371. VOID        PASCAL gettrav(SHORT loc);
  372. SHORT        PASCAL yes(SHORT msg1, SHORT msg2, SHORT msg3);
  373. VOID        PASCAL rspeak(SHORT msg);
  374. VOID        PASCAL pspeak(SHORT item, SHORT state);
  375. VOID        PASCAL desclg(SHORT loc);
  376. VOID        PASCAL descsh(SHORT loc);
  377. SHORT        PASCAL vocab(char *word, SHORT val);
  378. BOOL        PASCAL dark(VOID);
  379. BOOL        PASCAL here(SHORT item);
  380. BOOL        PASCAL toting(SHORT item);
  381. BOOL        PASCAL forced(SHORT atloc);
  382. BOOL        PASCAL pct(SHORT x);
  383. BOOL        PASCAL at(SHORT item);
  384. VOID        PASCAL dstroy(SHORT obj);
  385. VOID        PASCAL move(SHORT obj, SHORT where);
  386. VOID        PASCAL juggle(SHORT loc);
  387. VOID        PASCAL carry(SHORT obj, SHORT where);
  388. VOID        PASCAL drop(SHORT obj, SHORT where);
  389. SHORT        PASCAL put(SHORT obj, SHORT where, SHORT pval);
  390. SHORT        PASCAL dcheck(VOID);
  391. SHORT        PASCAL liq(VOID);
  392. SHORT        PASCAL liqloc(SHORT loc);
  393. SHORT        PASCAL liq2(SHORT pbottle);
  394. VOID        PASCAL bug(SHORT n);
  395.  
  396. /*  verb.c  */
  397. VOID        PASCAL trverb(VOID);
  398. VOID        PASCAL vtake(VOID);
  399. VOID        PASCAL vdrop(VOID);
  400. VOID        PASCAL vopen(VOID);
  401. VOID        PASCAL vsay(VOID);
  402. VOID        PASCAL von(VOID);
  403. VOID        PASCAL voff(VOID);
  404. VOID        PASCAL vwave(VOID);
  405. VOID        PASCAL vkill(VOID);
  406. VOID        PASCAL vpour(VOID);
  407. VOID        PASCAL veat(VOID);
  408. VOID        PASCAL vdrink(VOID);
  409. VOID        PASCAL vthrow(VOID);
  410. VOID        PASCAL vfind(VOID);
  411. VOID        PASCAL vfill(VOID);
  412. VOID        PASCAL vfeed(VOID);
  413. VOID        PASCAL vread(VOID);
  414. VOID        PASCAL vblast(VOID);
  415. VOID        PASCAL vbreak(VOID);
  416. VOID        PASCAL vwake(VOID);
  417. VOID        PASCAL actspk(SHORT verb);
  418. VOID        PASCAL needobj(VOID);
  419.  
  420. /*  english.c  */
  421. BOOL        PASCAL english(VOID);
  422. BOOL        PASCAL analyze(char *word, SHORT *type, SHORT *value);
  423. VOID        PASCAL getin(VOID);
  424. VOID        PASCAL getword(char **buff, char *word);
  425. VOID        PASCAL skipspc(char **buff);
  426.  
  427. /*  turn.c  */
  428. VOID        PASCAL turn(VOID);
  429. VOID        PASCAL describe(VOID);
  430. VOID        PASCAL descitem(VOID);
  431. VOID        PASCAL domove(VOID);
  432. VOID        PASCAL goback(VOID);
  433. VOID        PASCAL dotrav(VOID);
  434. VOID        PASCAL badmove(VOID);
  435. VOID        PASCAL spcmove(SHORT rdest);
  436. VOID        PASCAL dwarfend(VOID);
  437. VOID        PASCAL normend(VOID);
  438. VOID        PASCAL score(VOID);
  439. VOID        PASCAL death(VOID);
  440. VOID        PASCAL doobj(VOID);
  441. VOID        PASCAL trobj(VOID);
  442. char *        PASCAL probj(SHORT object);
  443. VOID        PASCAL dwarves(VOID);
  444. VOID        PASCAL dopirate(VOID);
  445. BOOL        PASCAL stimer(VOID);
  446.  
  447. /*  itverb.c  */
  448. VOID        PASCAL itverb(VOID);
  449. VOID        PASCAL ivtake(VOID);
  450. VOID        PASCAL ivopen(VOID);
  451. VOID        PASCAL ivkill(VOID);
  452. VOID        PASCAL iveat(VOID);
  453. VOID        PASCAL ivdrink(VOID);
  454. VOID        PASCAL ivquit(VOID);
  455. VOID        PASCAL ivfill(VOID);
  456. VOID        PASCAL ivfoo(VOID);
  457. VOID        PASCAL ivread(VOID);
  458. VOID        PASCAL inventory(VOID);
  459. VOID        PASCAL addobj(SHORT obj);
  460.  
  461. /*  saveadv.c  */
  462. VOID        PASCAL saveadv(VOID);
  463.