
/*    ADVENT.H    revised header for BDS c vers 1.43                    */

/*                Revised for Eco-C88 V2.72 by Bob Withers              */
/*                Defined all variables for driver routines and         */
/*                altered header to declare them external for           */
/*                all sub-modules.    BW - 09/14/85                     */

/*                Created ADVDBn.C files to contain all data base       */
/*                information.  This avoids the constant disk hits      */
/*                during the game and speeds things up nicely.          */
/*                BW - 05/10/90                                         */

/*                Ported code to the Sozobon V2.0 C compiler on the     */
/*                Atari ST.  Required reducing the size of some string  */
/*                literals to under 256 bytes and removal of all ANSI   */
/*                function prototypes.  BW - 08/21/92                   */

#ifndef ADVENT_H
#define ADVENT_H

#define IBM_PC                      0
#define ATARI_ST                    1

#define ANSI_PROTO                  0


#define NUL                         '\0'

#define MAXDIM(a)                   (sizeof(a) / sizeof(a[0]))

#define VOID                        void

#if IBM_PC
#define NEAR                        near
#define PASCAL                      pascal
#else
#define NEAR
#define PASCAL
#endif

#if ANSI_PROTO
#define PROTO(x)                    x
#define EXTRN
#else
#define PROTO(x)                    ()
#define EXTRN                       extern
#endif

#ifndef TRUE
#define TRUE                        1
#define FALSE                       0
#endif

typedef short                       SHORT;
typedef unsigned short              USHORT;
#if !ATARI_ST
typedef long                        LONG;
#endif
typedef unsigned long               ULONG;
typedef short                       BOOL;

#include <stdio.h>
#include <ctype.h>
#include <string.h>

#if IBM_PC
#include <stdlib.h>
#include <conio.h>
#endif

#define MAXLOC                      150
#define MAXOBJ                      100
#define WORDSIZE                    20

#define DWARFMAX                    7
#define MAXDIE                      3
#define MAXTRS                      79
#define MAXWRKSIZE                  800

#define READ_BIN                    "rb"
#define WRITE_BIN                   "wb"


#define VOCAB_OBJECT                1000
#define VOCAB_VERB                  2000
#define VOCAB_MSG                   3000

/*
        Object definitions
*/
#define KEYS                        1
#define LAMP                        2
#define GRATE                       3
#define CAGE                        4
#define ROD                         5
#define ROD2                        6
#define STEPS                       7
#define BIRD                        8
#define DOOR                        9
#define PILLOW                      10
#define SNAKE                       11
#define FISSURE                     12
#define TABLET                      13
#define CLAM                        14
#define OYSTER                      15
#define MAGAZINE                    16
#define DWARF                       17
#define KNIFE                       18
#define FOOD                        19
#define BOTTLE                      20
#define WATER                       21
#define OIL                         22
#define MIRROR                      23
#define PLANT                       24
#define PLANT2                      25
#define STALACTITE                  26
#define FIGURE                      27
#define AXE                         28
#define DRAWING                     29
#define PIRATE                      30
#define DRAGON                      31
#define CHASM                       32
#define TROLL                       33
#define TROLL2                      34
#define BEAR                        35
#define MESSAGE                     36
#define VOLCANO                     37
#define VEND                        38
#define BATTERIES                   39
#define CARPET                      40
#define NUGGET                      50
#define DIAMONDS                    51
#define SILVER                      52
#define JEWELS                      53
#define COINS                       54
#define CHEST                       55
#define EGGS                        56
#define TRIDENT                     57
#define VASE                        58
#define EMERALD                     59
#define PYRAMID                     60
#define PEARL                       61
#define RUG                         62
#define SPICES                      63
#define CHAIN                       64


/*  Verb definitions  */

#define NULLX                       21
#define BACK                        8
#define LOOK                        57
#define CAVE                        67
#define ENTRANCE                    64
#define DEPRESSION                  63


/*  Action verb definitions  */

#define TAKE                        1
#define DROP                        2
#define SAY                         3
#define OPEN                        4
#define NOTHING                     5
#define LOCK                        6
#define ON                          7
#define OFF                         8
#define WAVE                        9
#define CALM                        10
#define WALK                        11
#define KILL                        12
#define POUR                        13
#define EAT                         14
#define DRINK                       15
#define RUB                         16
#define THROW                       17
#define QUIT                        18
#define FIND                        19
#define INVENTORY                   20
#define FEED                        21
#define FILL                        22
#define BLAST                       23
#define SCORE                       24
#define FOO                         25
#define BRIEF                       26
#define READ                        27
#define BREAK                       28
#define WAKE                        29
#define SUSPEND                     30
#define HOURS                       31
#define LOG                         32
#define SAVE                        33
#define RESTORE                     34
#define VERBOSE                     35


/*  Bits of array cond indicating location status  */

#define LIGHT                       1
#define WATOIL                      2
#define LIQUID                      4
#define NOPIRAT                     8
#define HINTC                       16
#define HINTB                       32
#define HINTS                       64
#define HINTM                       128
#define HINT                        240


/*  Adventure global variables  */

struct S_VocabTab
{
    char        *pWord;
    SHORT        sWord;
};
typedef struct S_VocabTab           VOCABTAB;

struct trav
{
    SHORT        tdest;
    SHORT        tverb;
    SHORT        tcond;
};
typedef struct trav                 TRAV;

struct travtab
{
    TRAV        *pTrav;                         /* trav array for location */
    SHORT        sTrav;                         /* # entries for location  */
};
typedef struct travtab              TRAVTAB;


#ifdef DRIVER
#define CLASS
#define INIT(x)                 = x
#else
#define CLASS                   extern
#define INIT(x)
#endif

#define NEARDATA                NEAR


/*  Database variables  */

CLASS TRAV *     NEARDATA pTravel;              /* travel array & count for */
CLASS SHORT      NEARDATA sTravCnt;             /* the current location     */
CLASS SHORT      NEARDATA actmsg[32]            /* action messages          */
#ifdef DRIVER
      = {
              0,  24,  29,   0,  33,   0,  33,  38,  38,  42,  /*  0 -  9 */
             14,  43, 110,  29, 110,  73,  75,  29,  13,  59,  /* 10 - 19 */
             59, 174, 109,  67,  13, 147, 155, 195, 146, 110,  /* 20 - 29 */
             13,  13                                           /* 30 - 31 */
        };
#else
         ;
#endif

struct S_Globs
{
    /*  English variables  */
    SHORT           verb;
    SHORT           object;
    SHORT           motion;

    /*  Play variables  */
    SHORT           brief_sw;
    SHORT           turns;
    SHORT           loc;
    SHORT           oldloc;
    SHORT           oldloc2;
    SHORT           newloc;
    SHORT           place[MAXOBJ];              /* object location    */
    SHORT           fixed[MAXOBJ];              /* second object loc  */
    SHORT           visited[MAXLOC];            /* >0 if has been here*/
    SHORT           prop[MAXOBJ];               /* status of object   */
    SHORT           tally;                      /* item counts        */
    SHORT           tally2;
    SHORT           limit;                      /* time limit         */
    SHORT           lmwarn;                     /* lamp warning flag  */
    BOOL            wzdark;
    BOOL            closing;
    BOOL            closed;
    SHORT           holding;                    /* count of held items*/
    SHORT           detail;                     /* LOOK count         */
    SHORT           knfloc;                     /* knife location     */
    SHORT           clock1;                     /* timing variables   */
    SHORT           clock2;
    SHORT           panic;
    SHORT           dloc[DWARFMAX];             /* dwarf locations    */
    SHORT           dflag;                      /* dwarf flag         */
    SHORT           dseen[DWARFMAX];            /* dwarf seen flag    */
    SHORT           odloc[DWARFMAX];            /* dwarf old locs     */
    SHORT           daltloc;                    /* alt appearance     */
    SHORT           dkill;                      /* dwarves killed     */
    SHORT           chloc;                      /* chest locations    */
    SHORT           chloc2;
    SHORT           bonus;                      /* to pass to end     */
    SHORT           numdie;                     /* number of deaths   */
    SHORT           object1;                    /* to help intrans.   */
    BOOL            gaveup;
    SHORT           foobar;                     /* fie fie foe foo... */
};

CLASS struct S_Globs            G;

/*  English variables  */

CLASS char       NEARDATA word1[WORDSIZE];
CLASS char       NEARDATA word2[WORDSIZE];


/*  Play variables  */

CLASS SHORT      NEARDATA game_restored     INIT(FALSE);
CLASS SHORT      NEARDATA saveflg           INIT(FALSE);
CLASS SHORT      NEARDATA dbgflg            INIT(FALSE);

CLASS SHORT      NEARDATA cond[MAXLOC]               /* location status    */
#ifdef DRIVER
      = {
              0,   5,   1,   5,   5,   1,   1,   5,  17,   1,  /*   0 -   9 */
              1,   0,   0,  32,   0,   0,   2,   0,   0,  64,  /*  10 -  19 */
              2,   2,   2,   0,   6,   0,   2,   0,   0,   0,  /*  20 -  29 */
              0,   2,   2,   0,   0,   0,   0,   0,   4,   0,  /*  30 -  39 */
              2,   0, 128, 128, 128, 128, 136, 136, 136, 128,  /*  40 -  49 */
            128, 128, 128, 136, 128, 136,   0,   8,   0,   2,  /*  50 -  59 */
              0,   0,   0,   0,   0,   0,   0,   0,   0,   0,  /*  60 -  69 */
              0,   0,   0,   0,   0,   0,   0,   0,   0,   2,  /*  70 -  79 */
            128, 128, 136,   0,   0,   8, 136, 128,   0,   2,  /*  80 -  89 */
              2,   0,   0,   0,   0,   4,   0,   0,   0,   0,  /*  90 -  99 */
              1,   0,   0,   0,   0,   0,   0,   0,   0,   0,  /* 100 - 109 */
              0,   0,   0,   4,   0,   1,   1,   0,   0,   0,  /* 110 - 119 */
              0,   0,   8,   8,   8,   8,   8,   8,   8,   8,  /* 120 - 129 */
              8,   0,   0,   0,   0,   0,   0,   0,   0,   0,  /* 130 - 139 */
              0,   0,   0,   0,   0,   0,   0,   0,   0,   0,  /* 140 - 149 */
        };
#else
         ;
#endif

CLASS SHORT      NEARDATA place[MAXOBJ]               /* object location    */
#ifdef DRIVER
      = {
              0,   3,   3,   8,  10,  11,   0,  14,  13,  94,  /*  0 -  9 */
             96,  19,  17, 101, 103,   0, 106,   0,   0,   3,  /* 10 - 19 */
              3,   0,   0, 109,  25,  23, 111,  35,   0,  97,  /* 20 - 29 */
              0, 119, 117, 117,   0, 130,   0, 126, 140,   0,  /* 30 - 39 */
             96,   0,   0,   0,   0,   0,   0,   0,   0,   0,  /* 40 - 49 */
             18,  27,  28,  29,  30,   0,  92,  95,  97, 100,  /* 50 - 59 */
            101,   0, 119, 127, 130,   0,   0,   0,   0,   0,  /* 60 - 69 */
              0,   0,   0,   0,   0,   0,   0,   0,   0,   0,  /* 70 - 79 */
              0,   0,   0,   0,   0,   0,   0,   0,   0,   0,  /* 80 - 89 */
              0,   0,   0,   0,   0,   0,   0,   0,   0,   0,  /* 90 - 99 */
        };
#else
         ;
#endif

CLASS SHORT      NEARDATA fixed[MAXOBJ]               /* second object loc  */
#ifdef DRIVER
      = {
              0,   0,   0,   9,   0,   0,   0,  15,   0,  -1,  /*  0 -  9 */
              0,  -1,  27,  -1,   0,   0,   0,  -1,   0,   0,  /* 10 - 19 */
              0,   0,   0,  -1,  -1,  67,  -1, 110,   0,  -1,  /* 20 - 29 */
             -1, 121, 122, 122,   0,  -1,  -1,  -1,  -1,   0,  /* 30 - 39 */
             -1,   0,   0,   0,   0,   0,   0,   0,   0,   0,  /* 40 - 49 */
              0,   0,   0,   0,   0,   0,   0,   0,   0,   0,  /* 50 - 59 */
              0,   0, 121,   0,  -1,   0,   0,   0,   0,   0,  /* 60 - 69 */
              0,   0,   0,   0,   0,   0,   0,   0,   0,   0,  /* 70 - 79 */
              0,   0,   0,   0,   0,   0,   0,   0,   0,   0,  /* 80 - 89 */
              0,   0,   0,   0,   0,   0,   0,   0,   0,   0,  /* 90 - 99 */
        };
#else
         ;
#endif

CLASS SHORT      NEARDATA prop[MAXOBJ]                /* status of object   */
#ifdef DRIVER
      = {
              0,   0,   0,   0,   0,   0,   0,   0,   0,   0,  /*  0 -  9 */
              0,   0,   0,   0,   0,   0,   0,   0,   0,   0,  /* 10 - 19 */
              0,   0,   0,   0,   0,   0,   0,   0,   0,   0,  /* 20 - 29 */
              0,   0,   0,   0,   0,   0,   0,   0,   0,   0,  /* 30 - 39 */
              0,   0,   0,   0,   0,   0,   0,   0,   0,   0,  /* 40 - 49 */
             -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  /* 50 - 59 */
             -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  /* 60 - 69 */
             -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  /* 70 - 79 */
             -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  /* 80 - 89 */
             -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  /* 90 - 99 */
        };
#else
         ;
#endif

CLASS SHORT      NEARDATA dloc[DWARFMAX]              /* dwarf locations    */
#ifdef DRIVER
      = {
              0,  19,  27,  33,  44,  64,   0                  /*  0 - 6  */
        };
#else
         ;
#endif


CLASS char       NEARDATA wrk[MAXWRKSIZE];

/*  endglobal  */

/*  function prototypes                                                     */

/*  advent.c  */
EXTRN int                main PROTO((int argc, char **argv));
EXTRN VOID        PASCAL restore PROTO((VOID));

/*  database.c  */
EXTRN VOID        PASCAL gettrav PROTO((SHORT loc));
EXTRN SHORT       PASCAL yes PROTO((SHORT msg1, SHORT msg2, SHORT msg3));
EXTRN VOID        PASCAL rspeak PROTO((SHORT msg));
EXTRN VOID        PASCAL pspeak PROTO((SHORT item, SHORT state));
EXTRN VOID        PASCAL desclg PROTO((SHORT loc));
EXTRN VOID        PASCAL descsh PROTO((SHORT loc));
EXTRN SHORT       PASCAL vocab PROTO((char *word, SHORT val));
EXTRN BOOL        PASCAL dark PROTO((VOID));
EXTRN BOOL        PASCAL here PROTO((SHORT item));
EXTRN BOOL        PASCAL toting PROTO((SHORT item));
EXTRN BOOL        PASCAL forced PROTO((SHORT atloc));
EXTRN BOOL        PASCAL pct PROTO((SHORT x));
EXTRN BOOL        PASCAL at PROTO((SHORT item));
EXTRN VOID        PASCAL dstroy PROTO((SHORT obj));
EXTRN VOID        PASCAL move PROTO((SHORT obj, SHORT where));
EXTRN VOID        PASCAL juggle PROTO((SHORT loc));
EXTRN VOID        PASCAL carry PROTO((SHORT obj, SHORT where));
EXTRN VOID        PASCAL drop PROTO((SHORT obj, SHORT where));
EXTRN SHORT       PASCAL put PROTO((SHORT obj, SHORT where, SHORT pval));
EXTRN SHORT       PASCAL dcheck PROTO((VOID));
EXTRN SHORT       PASCAL liq PROTO((VOID));
EXTRN SHORT       PASCAL liqloc PROTO((SHORT loc));
EXTRN SHORT       PASCAL liq2 PROTO((SHORT pbottle));
EXTRN VOID        PASCAL bug PROTO((SHORT n));

/*  verb.c  */
EXTRN VOID        PASCAL trverb PROTO((VOID));
EXTRN VOID        PASCAL vtake PROTO((VOID));
EXTRN VOID        PASCAL vdrop PROTO((VOID));
EXTRN VOID        PASCAL vopen PROTO((VOID));
EXTRN VOID        PASCAL vsay PROTO((VOID));
EXTRN VOID        PASCAL von PROTO((VOID));
EXTRN VOID        PASCAL voff PROTO((VOID));
EXTRN VOID        PASCAL vwave PROTO((VOID));
EXTRN VOID        PASCAL vkill PROTO((VOID));
EXTRN VOID        PASCAL vpour PROTO((VOID));
EXTRN VOID        PASCAL veat PROTO((VOID));
EXTRN VOID        PASCAL vdrink PROTO((VOID));
EXTRN VOID        PASCAL vthrow PROTO((VOID));
EXTRN VOID        PASCAL vfind PROTO((VOID));
EXTRN VOID        PASCAL vfill PROTO((VOID));
EXTRN VOID        PASCAL vfeed PROTO((VOID));
EXTRN VOID        PASCAL vread PROTO((VOID));
EXTRN VOID        PASCAL vblast PROTO((VOID));
EXTRN VOID        PASCAL vbreak PROTO((VOID));
EXTRN VOID        PASCAL vwake PROTO((VOID));
EXTRN VOID        PASCAL actspk PROTO((SHORT verb));
EXTRN VOID        PASCAL needobj PROTO((VOID));

/*  english.c  */
EXTRN BOOL        PASCAL english PROTO((VOID));
EXTRN BOOL        PASCAL analyze PROTO((char *word, SHORT *type, SHORT *value));
EXTRN VOID        PASCAL getin PROTO((VOID));
EXTRN VOID        PASCAL getword PROTO((char **buff, char *word));
EXTRN VOID        PASCAL skipspc PROTO((char **buff));

/*  turn.c  */
EXTRN VOID        PASCAL turn PROTO((VOID));
EXTRN VOID        PASCAL describe PROTO((VOID));
EXTRN VOID        PASCAL descitem PROTO((VOID));
EXTRN VOID        PASCAL domove PROTO((VOID));
EXTRN VOID        PASCAL goback PROTO((VOID));
EXTRN VOID        PASCAL dotrav PROTO((VOID));
EXTRN VOID        PASCAL badmove PROTO((VOID));
EXTRN VOID        PASCAL spcmove PROTO((SHORT rdest));
EXTRN VOID        PASCAL dwarfend PROTO((VOID));
EXTRN VOID        PASCAL normend PROTO((VOID));
EXTRN VOID        PASCAL score PROTO((VOID));
EXTRN VOID        PASCAL death PROTO((VOID));
EXTRN VOID        PASCAL doobj PROTO((VOID));
EXTRN VOID        PASCAL trobj PROTO((VOID));
EXTRN char *      PASCAL probj PROTO((SHORT object));
EXTRN VOID        PASCAL dwarves PROTO((VOID));
EXTRN VOID        PASCAL dopirate PROTO((VOID));
EXTRN BOOL        PASCAL stimer PROTO((VOID));

/*  itverb.c  */
EXTRN VOID        PASCAL itverb PROTO((VOID));
EXTRN VOID        PASCAL ivtake PROTO((VOID));
EXTRN VOID        PASCAL ivopen PROTO((VOID));
EXTRN VOID        PASCAL ivkill PROTO((VOID));
EXTRN VOID        PASCAL iveat PROTO((VOID));
EXTRN VOID        PASCAL ivdrink PROTO((VOID));
EXTRN VOID        PASCAL ivquit PROTO((VOID));
EXTRN VOID        PASCAL ivfill PROTO((VOID));
EXTRN VOID        PASCAL ivfoo PROTO((VOID));
EXTRN VOID        PASCAL ivread PROTO((VOID));
EXTRN VOID        PASCAL inventory PROTO((VOID));
EXTRN VOID        PASCAL addobj PROTO((SHORT obj));

/*  saveadv.c  */
EXTRN VOID        PASCAL saveadv PROTO((VOID));

#endif  /* ADVENT_H */
