[comp.sources.games] v05i094: tess - beyond the tesseract, an abstract adventure game, Part01/02

games@tekred.TEK.COM (12/08/88)

Submitted by: Viola lee <viola@idacom.cs.ubc.ca>
Comp.sources.games: Volume 5, Issue 94
Archive-name: tess/Part01

	[The following note is from the author. I added a simple Makefile
	 and man page. It compiles and runs OK on a Sun 3/60.  -br]

	[[This game is suitable for adventure-lovers who are tired of
	  the standard deserted-island/haunted-house/ghost-ship
	  adventures. This is the portable source version of the same
	  game that was posted on comp.binaries.ibm.pc a couple of
	  months ago.  It has been test-compiled with Sun cc, gcc
	  and several PC C compilers.  -Dennis Lo]]

#! /bin/sh
# This is a shell archive.  Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file".  To overwrite existing
# files, type "sh file -c".  You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g..  If this archive is complete, you
# will see the following message at the end:
#		"End of archive 1 (of 2)."
# Contents:  README MANIFEST Makefile parser.c tess.c
# Wrapped by billr@saab on Wed Dec  7 16:58:57 1988
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'README' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'README'\"
else
echo shar: Extracting \"'README'\" \(370 characters\)
sed "s/^X//" >'README' <<'END_OF_FILE'
XNAME:
X    BEYOND THE TESSERACT - an abstract text adventure by David Lo
X
XWARNING:
X    Knowledge of high school physics and math concepts is necessary to
X    play this adventure.
X
XFILES:
X    readme 	- this file
X    adv.doc	- philosophy
X    tess.doc	- documentation
X    tess.c	- main source file
X    tess-def.c	- adventure world definition
X    parser.c	- adventure parser
END_OF_FILE
if test 370 -ne `wc -c <'README'`; then
    echo shar: \"'README'\" unpacked with wrong size!
fi
# end of 'README'
fi
if test -f 'MANIFEST' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'MANIFEST'\"
else
echo shar: Extracting \"'MANIFEST'\" \(393 characters\)
sed "s/^X//" >'MANIFEST' <<'END_OF_FILE'
X   File Name		Archive #	Description
X-----------------------------------------------------------
X MANIFEST                   1	This shipping list
X Makefile                   1	
X README                     1	
X adv.doc                    2	
X parser.c                   1	
X tess-def.c                 2	
X tess.1                     2	
X tess.c                     1	
X tess.doc                   2	
END_OF_FILE
if test 393 -ne `wc -c <'MANIFEST'`; then
    echo shar: \"'MANIFEST'\" unpacked with wrong size!
fi
# end of 'MANIFEST'
fi
if test -f 'Makefile' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'Makefile'\"
else
echo shar: Extracting \"'Makefile'\" \(103 characters\)
sed "s/^X//" >'Makefile' <<'END_OF_FILE'
X# simple makefile for tess
X
XCFLAGS = -O
X
Xtess: tess.c tess-def.c parser.c
X	cc -o tess $(CFLAGS) tess.c
END_OF_FILE
if test 103 -ne `wc -c <'Makefile'`; then
    echo shar: \"'Makefile'\" unpacked with wrong size!
fi
# end of 'Makefile'
fi
if test -f 'parser.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'parser.c'\"
else
echo shar: Extracting \"'parser.c'\" \(3949 characters\)
sed "s/^X//" >'parser.c' <<'END_OF_FILE'
X/*------------------------------------------------------------*/
X/* Adventure Parser
X
X   Need to include the adv-world definition file before including this one.
X   This is because the vocabulary definitions depend on the adventure-world
X   objects.
X*/
X
X
X/*-------------------BEGIN Added by Dennis Lo 88/10/30 for portable version */
Xchar *strchr (str, ch)
X  char *str;
X  char ch;
X{
X  int l = strlen (str);
X
X  while (l-- >= 0)
X  {
X    if (*str == ch)
X      return (str);
X    str++;
X  } 
X  return ( (char *) 0);
X}
X
Xchar *strlwr (str)
X  char *str;
X{
X  char *orig = str;
X
X  for ( ; *str; str++)
X    if (*str >= 'A'  &&  *str <= 'Z')
X      *str = tolower (*str);
X  return (orig);
X}
X/*----------------------- END of additions for portable version. */
X
X
X
X
X#define v_sig 4               /* 1st 4 letters of vocab words significant */
X
X#define max_cmd_size 64                /* at most 63 chars per command */
X#define max_cmd_len max_cmd_size-1
X
X#define max_word_size 16               /* at most 15 chars per word in input */
X#define max_word_len max_word_size-1
X
Xtypedef char v_cmd [max_cmd_size ];
Xtypedef char v_word [max_word_size ];  /* a vocabulary (normal) word */
X
Xtypedef struct        /* a command */
X{
X  v_cmd
X    cm;               /* command entered */
X
X  v_word
X    verb,             /* verb part */
X    noun,             /* noun part */
X    sh_verb,          /* short form of verb and noun for comparison */
X    sh_noun;
X
X  int
X    vn,               /* verb # in vocab */
X    nn;               /* noun # in vocab */
X}
XCmdRec;
X
XCmdRec cmd;           /* global command structure */
X
X/*----------------------------*/
X/* Get the verb and the noun from a command of the form "verb noun".
X   If noun is omitted, a null string returned.
X
X   Will handle leading blanks, and too long strings.
X*/
XParseCommand( cm, verb, noun )
X  char *cm;
X  char *verb;
X  char *noun;
X{
X  char *p,*q;
X
X  *verb='\0'; *noun='\0';
X  while (*cm && *cm==' ') cm++;   /* skip leading blanks in command */
X
X  p = strchr( cm, ' ' );          /* find space delimiting verb */
X  q = strchr( cm, '\0');          /* get last char */
X
X  if (!p)   p = q;                /* if 1 word, set ptr */
X  strncat( verb, cm, min(p-cm, max_word_len) );
X
X  if (*p)                         /* if >1 word */
X  {
X    while (*p && *p==' ') p++;    /* skip lead blanks */
X    strncat( noun, p, min(q-p, max_word_len) );
X  }
X}
X
X/*----------------------------*/
X/* Make a string exactly v_sig characters long (plus null), truncating or
X   blank-padding if necessary
X*/
Xresize_word( s )
X  char *s;
X{
X  int i;
X
X  for ( i=strlen(s); i<v_sig; i++ )
X    *(s+i) = ' ';
X  *(s+v_sig)='\0';
X}
X
X/*----------------------------*/
X/* Return a word's vocabulary #, given the vocab array and it's size
X*/
Xint GetWordNum( w, voc )
X  char *w;
X  vocab_type *voc;
X{
X  int wn,i;
X  v_word sh_word;
X
X  strcpy( sh_word, w );
X  resize_word( sh_word );
X  for ( wn=0;  *voc->name;  voc++ )
X  {
X    if (!strcmp( sh_word, voc->name ))
X    {
X      wn = voc->num;
X      break;
X    }
X  }
X  return( wn );
X}
X
X/*----------------------------*/
X/*
X*/
Xint GetVerbNum( verb )
X  char *verb;
X{
X  return( GetWordNum( verb, v_verb ));
X}
X
Xint GetNounNum( noun )
X  char *noun;
X{
X  return( GetWordNum( noun, v_noun ));
X}
X
X/*----------------------------*/
X/* enter aux. object (e.g. Give XXX to AUX)
X*/
Xint InputNoun( prompt, noun )
X  char *prompt;
X  char *noun;
X{
X  int nn;
X
X  cprintf( prompt );
X  gets( noun );
X  nn = GetNounNum( noun );
X  resize_word( noun );
X  return( nn );
X}
X
X/*----------------------------*/
X/* Parse the command into the verb and noun, then find out the verb & noun #'s
X*/
XAnalyseCommand( cmd )
X  CmdRec *cmd;
X{
X  ParseCommand( cmd->cm,   cmd->verb, cmd->noun );
X  strlwr( cmd->verb );
X  strlwr( cmd->noun );
X  cmd->vn = GetVerbNum( cmd->verb );
X  cmd->nn = GetNounNum( cmd->noun );
X
X  strcpy( cmd->sh_verb, cmd->verb );
X  resize_word( cmd->sh_verb );
X  strcpy( cmd->sh_noun, cmd->noun );
X  resize_word( cmd->sh_noun );
X}
X
X
END_OF_FILE
if test 3949 -ne `wc -c <'parser.c'`; then
    echo shar: \"'parser.c'\" unpacked with wrong size!
fi
# end of 'parser.c'
fi
if test -f 'tess.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'tess.c'\"
else
echo shar: Extracting \"'tess.c'\" \(45562 characters\)
sed "s/^X//" >'tess.c' <<'END_OF_FILE'
X/*
X  Beyond The Tesseract   V2.0p   By David Lo :
X
X    TRS-80 version 1.7 : 5/29/83  3/16/86 (Level II BASIC)
X    MS-DOS version 2.0 : 9/1/88   10/1/88 (Turbo C 1.5)
X*/
X
X/*
X    Portable version      V2.0p  By Dennis Lo  10/30/88
X
X    This version can compile with Datalight C 2.20, Microsoft C 5.0,
X    QuickC 1.0, Turbo C 1.5, Unix cc (SunOs 3.?), and GNU cc.
X
X    - Changed ANSI-style function parameter declarations to K & R-style.
X    - Removed #include <string.h> and added the string routines
X      strlwr() and strchr() in parser.c so that it will compile with
X      compilers that don't have them (like my Datalight C 2.20).
X    - In ding(), split up the huge prints string into one prints()
X      per line.
X    - Moved the #include "parser.c" and "tess-def.c" to after the
X      #include "conio.h"/#define printc code, because parser.c uses
X      one cprintf().
X    - Changed enumerations in tess-def.c to #defines because Unix cc
X      insisted enums are not ints.
X    - In main(), changed the tolower() call to a compare of both 'n' and
X      'N' since tolower() doesn't work if the input is already in lower 
X      case (only on Unix).
X*/
X
X/****** Define tty for 'dumb terminal' mode.  Else the 'full-screen' mode
X        will use Turbo-C screen manipulation library routines.  ******/
X#define tty
X
X
X#include <ctype.h>
X/*#include <string.h>*/
X#include <stdio.h>
X
X#define max(a,b) (((a) > (b)) ? (a) : (b))
X#define min(a,b) (((a) < (b)) ? (a) : (b))
X
X/*------------------------------------------------------------*/
X/* on some PC clones (e.g. mine), scrolling the screen when printing a '\n'
X   with the conio.h routines (e.g. putch('\n') or cprintf('\n')) is much slower
X   than the stdio.h routines.
X*/
Xnl()  {  putchar('\n');  }
X
X/*----------------------------*/
Xint get_enter()
X{
X  int i=0, ch;
X
X  while ((ch=getchar()) != '\n')
X    i+=ch;
X  return (i);
X}
X
X/*----------------------------*/
X/* if tty-mode, then using standard library functions for I/O, and ignore the
X   screen I/O functions
X*/
X#ifdef tty
X
X#  define cprintf printf
X#  define cputs printf
X#  define prints puts
X
X#  define clrscr()
X#  define clreol()
X# define gotoxy(x,y)
X
X/* if non-tty-mode, use console IO library
X*/
X#else
X
X#  include <conio.h>
X
X  prints( s )
X    char *s;
X  {
X    cputs( s );
X    nl();
X  }
X
X#endif
X
X
X#include "tess-def.c"
X#include "parser.c"
X
X
X/*------------------------------------------------------------*/
X/* Adventure dependent stuff
X*/
X
Xint
X  print_room,         /* flag for updating room after command */
X
X  curr_loc,           /* current location */
X  curr_lev,           /* current level */
X  level_loc [ 4 ],    /* current location for diff. levels */
X  zap,                /* flag set when game over */
X                      /*   1=quit   2=wrong password   3=right password */
X
X  sleep_lev,          /* which level player was in when sleeping */
X
X                      /* flags are 0=false/haven't done, 1=true/done */
X                      /* unless otherwise noted */
X
X  cc,                 /* coil status: 0=normal  b1=cooled  b2=magnetized */
X  wa,                 /* water alien */
X  ep,                 /* eat pills */
X  dr,                 /* dice roll counter */
X  af,                 /* audio filter inserted */
X  gp,                 /* get password */
X  mi,                 /* message: bits 0,1,2,3 = parts found */
X  ti,                 /* think idea */
X  kp,                 /* kick projector */
X
X  dc [ 3 ],           /* each dice roll, dc[i]<33 */
X  sum                 /* sum = sigma( dc ) < 100  */
X  ;
X
X/*----------------------------*/
XInitAdv()
X{
X  int i;
X
X  for ( i=1; i<MaxObjs; i++ )
X  {
X    obj[i].loc = obj[i].init_loc;
X  }
X
X  level_loc[1] = 2;
X  level_loc[2] = 25;
X  level_loc[3] = 29;
X
X  curr_lev = 1;
X  curr_loc = level_loc [ curr_lev ];
X
X  zap = cc = wa = ep = dr = af = gp = mi = ti = kp = 0;
X
X  for ( sum=0, i=0; i<3; i++ )
X    sum += (dc [i] = rand() & 31);
X
X  print_room = 1;
X}
X
X/*------------------------------------------------------------*/
X/* Message routines
X*/
X
X/*----------------------------*/
XPrintMess( i )
X  int i;
X{
X  switch ( i )
X  {
X    case 1: prints("Nothing special happens."); break;
X    case 2: prints("That isn't possible."); break;
X    case 3: prints("Doesn't work."); break;
X    case 4: prints("Can't do that yet."); break;
X    case 5: prints("OK."); break;
X    case 6: prints("How?"); break;
X    case 7: cprintf("You have nothing to %s with.", cmd.verb ); nl(); break;
X  }
X}
X
Xnot_happen() {  PrintMess( 1 );  }
Xnot_poss()   {  PrintMess( 2 );  }
Xnot_work()   {  PrintMess( 3 );  }
Xnot_yet()    {  PrintMess( 4 );  }
Xok()         {  PrintMess( 5 );  }
Xhow()        {  PrintMess( 6 );  }
X
X/*------------------------------------------------------------*/
X/* Object routines
X*/
X
X/*----------------------------*/
Xint CheckObjAttr( nn, mask )
X  int nn;
X  int mask;
X{
X  return ( obj [nn].attr & mask );
X}
X
X#define CanGetObj(i) CheckObjAttr((i),1)
X#define CanLookObj(i) CheckObjAttr((i),4)
X
X/*----------------------------*/
XCarryObj( nn )
X  int nn;
X{
X  obj [nn].loc = -curr_lev;
X}
X
Xint CarryingObj( nn )
X  int nn;
X{
X  return ( obj [nn].loc == -curr_lev );
X}
X
X/*----------------------------*/
XWearObj( nn )
X  int nn;
X{
X  obj [nn].loc = -curr_lev - 3;
X}
X  
Xint WearingObj( nn )
X  int nn;
X{
X  return ( obj [nn].loc == -curr_lev-3 );
X}
X
X/*----------------------------*/
Xint ObjOnPlayer( nn )
X  int nn;
X{
X  return ( CarryingObj(nn) || WearingObj(nn) );
X}
X
X/*----------------------------*/
XDropObj( nn )
X  int nn;
X{
X  obj [nn].loc = curr_loc;
X}
X
Xint ObjInRoom( nn )
X  int nn;
X{
X  return ( obj [nn].loc == curr_loc );
X}
X
X/*----------------------------*/
XJunkObj( nn )
X  int nn;
X{
X  obj [nn].loc = 0;
X}
X
X/* replace object nn with object new_nn
X*/
XReplaceObj( nn, new_nn )
X  int nn;
X  int new_nn;
X{
X  obj [new_nn].loc = obj [nn].loc;
X  obj [nn].loc = 0;
X}
X
X/*----------------------------*/
X/* See if an object is accessible.  This means the object is being
X   carried/worn, is in the same room, is a concept noun (e.g. north),
X   is part of the room (e.g. field), or is part of another object
X   (e.g. button).
X*/
Xint ObjIsPresent( nn )
X  int nn;
X{
X  if ( (nn>=o_north) && (nn<=o_invent) ) /* direction, "inventory" */
X    return (1);               /* always available */
X
X  else if ( (nn>=o_buttons) && (nn<=o_four) )  /* buttons */
X    return ( ObjIsPresent(o_proj) );           /* on projector */
X
X  else if ( (nn==o_liquid) && (obj[nn].loc==-8) )  /* contained fluid */
X    return ( ObjIsPresent(o_bottle) );             /* in Klein bottle */
X
X  else
X    return ( ObjInRoom(nn) || CarryingObj(nn) || WearingObj(nn) );
X}
X
X/*------------------------------------------------------------*/
X/* Room routines
X*/
X
X/*----------------------------*/
X/* predicates to return check whether the player in in a certain world
X*/
Xint InComplex( rn )
X  int rn;
X{
X  return ( rn==1 || rn==2 || rn==7 || rn==8 );
X}
X
Xint InMirrorWorld( rn )
X  int rn;
X{
X  return ( rn==4 || (rn>=9 && rn<=13) );
X}
X
Xint InMathWorld( rn )
X  int rn;
X{
X  return ( rn==3 || rn==5 || (rn>=14 && rn<=17) );
X}
X
Xint InSpectralWorld( rn )
X  int rn;
X{
X  return ( rn==6 || (rn>=18 && rn<=22) );
X}
X
Xint InDreamWorld( rn )
X  int rn;
X{
X  return ( curr_lev==2 || (rn>=23 && rn<=28) || rn==35 );
X}
X
Xint InBookWorld( rn )
X  int rn;
X{
X  return ( curr_lev==3 || (rn>=29 && rn<=34) );
X}
X
X/*----------------------------*/
XPrintCurrRoom()
X{
X  int i,flag, len,currx;
X  char *s;
X
X#ifndef tty
X  static int stop_line=1;
X  /* clear window area from previous time
X  */
X  for ( i=stop_line; i>=1; i-- )
X  {
X    gotoxy( 1, i );
X    clreol();
X  }
X#endif
X
X  cprintf("You are %s.", room [ curr_loc ].name ); nl();
X
X  prints("You see around you:");
X  clreol();
X  flag=0;
X  currx=0;
X  for ( i=1; i<MaxObjs; i++ )
X    if (ObjInRoom(i))
X    {
X      s = obj[i].name;
X      len = strlen(s);
X      if (currx+ len + 3 > 78 ) { currx=0; nl(); clreol(); }
X      cprintf("  %s.", s );
X      currx += len+3;
X      flag=1;
X    }
X  if (!flag)
X    prints("  Nothing special.");
X  else
X    { nl(); clreol(); }
X
X  prints("Exits:");
X  clreol();
X  flag=0;
X  for ( i=0; i<MaxDirs; i++ )
X    if ( room [curr_loc].link [i] )
X    {
X      cprintf("  %s.", obj[i+1].name );
X      flag=1;
X    }
X  if (!flag) cprintf("  none.");
X  nl();
X
X#ifdef tty
X  nl();
X#else
X  prints
X("__________________________________________________________________________");
X  stop_line = wherey();  /* stop line is the line after the separator bar */
X  gotoxy( 1,25 );
X#endif
X}
X
X/*----------------------------*/
Xgoto_new_lev( lev )
X  int lev;
X{
X  curr_lev = lev;
X  curr_loc = level_loc [curr_lev];
X}
X  
Xgoto_new_loc( rn )
X  int rn;
X{
X  curr_loc = rn;
X  level_loc [curr_lev] = curr_loc;
X}
X
X/*------------------------------------------------------------*/
X/* Verb routines
X*/
X
X/*----------------------------*/
Xdo_go()
X{
X  int direct, new_room;
X
X  switch ( cmd.nn )
X  {
X    case o_north:
X    case o_east:
X    case o_south:
X    case o_west:
X      direct = cmd.nn - 1;                       /* assumes NESW = 1234 */
X      new_room = room [curr_loc].link [direct];
X      if (new_room)
X      {
X        goto_new_loc( new_room );
X        print_room = 1;
X      }
X      else
X        prints("Can't go in that direction");
X      break;
X
X    default:
X/*
X      if (isdigit(cmd.noun[0]))
X      {
X        new_room = atoi( cmd.noun );
X        if ( (new_room>=0) && (new_room<MaxLocs) )
X          goto_new_loc( new_room );
X        else
X          prints("Can't go there");
X      }
X      else
X*/
X        prints("Use a direction or the stack");
X  }
X}
X
X/*----------------------------*/
Xdo_dir()
X{
X  cmd.nn = cmd.vn;
X  cmd.vn = 6;
X  do_go();
X}
X
X/*----------------------------*/
Xdo_inv()
X{
X  int flag, i, len,currx;
X  char s[80];
X
X  prints("You are carrying:");
X  flag=0;
X  currx=0;
X  for ( i=1; i<MaxObjs; i++ )
X    if ( ObjOnPlayer(i) )
X    {
X      strcpy( s, obj[i].name );
X      if (WearingObj(i)) strcat( s, " (wearing)" );
X      len = strlen(s);
X      if (currx+ len + 3 > 78 ) { currx=0; nl(); }
X      cprintf("  %s.", s );
X      currx += len+3;
X      flag=1;
X    }
X
X  if (!flag)
X    prints("  nothing.");
X  else
X    nl();
X}
X
X/*----------------------------*/
Xdo_get()
X{
X  int where, attr, i, get_flag;
X  char s[16], *p;
X
X  if (ObjOnPlayer(cmd.nn))
X    prints("You already have it.");
X
X  else if (cmd.nn==o_invent)      /* get everything in room */
X  {
X    for ( i=o_invent+1; i<MaxObjs; i++ )
X      if ( ObjInRoom(i) && CanGetObj(i) )
X      {
X        cmd.nn=i;
X        cprintf( "--> get %s", obj[i].name ); nl();
X        do_get();
X      }
X  }
X
X  else if (!CanGetObj(cmd.nn))      /* un-gettable object? */
X  {
X    if (cmd.nn==o_plant)    /* alien */
X      prints("The being is rooted in the 4th dimension.");
X
X    else if (cmd.nn==o_group)
X      prints("The group has infinitely many reasons to stay where it is.");
X
X    else if (cmd.nn==o_fluid)   /* fluid */
X      prints("It's too cold!");
X
X    else
X      prints("Can't get that.");
X  }
X
X  else  /* gettable object */
X  {
X    get_flag = 1;
X
X    if (cmd.nn==o_liquid)   /* 4-D liquid */
X    {
X      how();
X      get_flag = 0;
X    }
X
X    else if (cmd.nn==o_plasma)   /* plasma */
X    {
X      if (!CarryingObj(o_coil) || (cc!=3))
X      /* not have coil or not mag. bottle */
X      {
X        prints("Too hot to handle.");
X        get_flag = 0;
X      }
X      else
X        prints( "The magnetic field of the coil contained the plasma." );
X    }
X
X    else if (cmd.nn==o_improb)   /* improbability */
X    {
X      cprintf("What is the probability of getting this improbability? ");
X      gets( s );
X      p = strchr( s, '.' );  /* skip past decimal point */
X      if (p) p++;
X      i = atoi( p );
X      if (i!=sum && i*10!=sum)
X      {
X        prints("Wrong.");
X        get_flag = 0;
X      }
X    }
X
X    if (get_flag)
X    {
X      CarryObj( cmd.nn );
X      ok();
X    }
X  }
X}
X  
X/*----------------------------*/
Xdo_drop()
X{
X  int where, i;
X
X  if (ObjInRoom(cmd.nn))
X    prints("It's already here.");
X
X  else if (cmd.nn==o_improb && curr_loc==16)
X    do_throw();
X
X  else if (cmd.nn==o_invent)        /* drop everything */
X  {
X    for ( i=o_invent+1; i<MaxObjs; i++ )
X      if ( ObjOnPlayer(i) )
X      {
X        cmd.nn=i;
X        cprintf( "--> drop %s", obj[i].name ); nl();
X        do_drop();
X      }
X  }
X
X  else if (cmd.nn>o_invent)
X  {
X    if (cmd.nn==o_coil)  /* drop coil, check for plasma as well */
X    {
X      if (CarryingObj(o_coil) && CarryingObj(o_plasma))
X        DropObj( o_plasma );
X    }
X
X    if ( ObjOnPlayer( cmd.nn ))
X    {
X      DropObj(cmd.nn);
X      ok();
X    }
X  }
X}
X
X/*----------------------------*/
Xdo_throw()
X{
X  char *s;
X
X  if (ObjInRoom(cmd.nn))
X    prints("It's already here.");
X
X  else if (cmd.nn==o_improb && curr_loc==16)
X  {
X    prints("The improbability's presence warps the fabric of the field.");
X    room [16].link [east] = 17 - room [16].link [east];
X    print_room = 1;
X    DropObj( cmd.nn );
X  }
X  else if (cmd.nn==o_cube)
X    do_roll();
X
X  else if (cmd.nn==o_disk)
X  {
X    prints
X    ("With great skill (i.e. luck) you threw the disk into the next room.");
X    if (curr_loc==29)
X      obj [cmd.nn].loc = -7;
X    else
X      obj [cmd.nn].loc = room [curr_loc].link [south];
X  }
X
X  else
X    do_drop();
X}
X
X/*----------------------------*/
Xdo_break()
X{
X  if (cmd.nn==o_prism)
X  {
X    prints("The prism shatters along the lines and mysteriously");
X    prints("reorganizes itself into a tetrahedron.");
X    ReplaceObj( cmd.nn, o_tetra );
X  }
X
X  else if (cmd.nn==o_tetra)
X    prints("It shatters, but quickly reforms itself.");
X
X  else if (cmd.nn==o_zeta)
X    do_solve();
X
X  else if (cmd.nn==o_proj)
X  {
X    if (!kp)
X    {
X      prints
X      ("With a few kicks and blows, both you and the projector felt better.");
X      kp = 1;
X    }
X    else
X      prints("Better not try that again, or you'll really break it.");
X  }
X
X  else
X    prints("Violence is not necessary, most of the time.");
X}
X
X/*----------------------------*/
Xdo_look()
X{
X  if (!cmd.nn)
X    print_room = 1;
X
X  else if (!CanLookObj(cmd.nn))
X  {
X    cprintf("Looks like %s.", obj[cmd.nn].name );  nl();
X  }
X
X  else
X  switch ( cmd.nn )
X  {
X    case o_mirror:
X      prints("You see the reflections of a mirror world.");
X      break;
X
X    case o_crt:
X      prints("You see the images of a mathematical universe.");
X      break;
X
X    case o_group:
X      prints("The group consists of converging parallel lines, alef-null,");
X      prints("the last prime number, 1/0, and uncountably many others.");
X      break;
X
X    case o_hole:
X      prints("You see the lights of an electromagnetic continuum.");
X      break;
X
X    case o_proj:
X      prints("You see a wide slot and 5 buttons.");
X      if (obj[o_disk].loc==-7)
X        prints("A disk is in the projector.");
X
X    case o_buttons:
X      prints("The buttons are labelled zero to four.");
X      break;
X
X    case o_chaos:
X      prints("It bears a slight resemblence to the current universe.");
X      break;
X
X    case o_dust:
X      prints("It look like the remains of an exploded Julia set.");
X      break;
X
X    case o_flake:
X      prints("It doesn't look like the coastline of Britain.");
X      break;
X
X    case o_mount:
X      prints("It looks the same at all scales.");
X      break;
X
X    case o_tomb:
X      prints("The epitaph reads: The Eternal Soul");
X      mi = mi | 1;
X      break;
X
X    case o_stack:
X      prints("It's a Space-Time Activated Continuum Key.");
X      break;
X
X    case o_audio:
X      prints("Looks like 2 speakers connected by a band.");
X      if (!af)
X        prints("There is a groove in the band.");
X      break;
X
X    case o_book:
X      prints("The title is 'Interactive Adventures'.");
X      break;
X
X    case o_bottle:
X      if (obj[o_liquid].loc==-8)
X        prints("It is full of some strange liquid.");
X      else
X        prints("It is an empty bottle with no inside or outside.");
X      break;
X
X    case o_prism:
X      prints("You see flashes along deeply etched lines");
X      if (curr_loc==21)
X        prints("And embedded, distorted shapes resembling letters");
X      break;
X
X    case o_appa:
X      prints("Looks like a device used for increasing the dimensions of");
X      prints("geometric and topological objects.");
X      break;
X
X    case o_improb:
X      prints("It looks like a heart of gold.");
X      break;
X
X    case o_zeta:
X      prints("It's a very vicious-looking integral.");
X      break;
X
X    case o_cube:
X      prints("There are changing numbers on the sides.");
X      break;
X
X    case o_coil:
X      prints("The ends of the coil are connected to form a loop.");
X      break;
X
X    case o_sing:
X      prints("It is shaped like a narrow band.");
X      break;
X
X    case o_disk:
X      prints("The title is: The Science and Beauty of a Geometric Nature");
X      break;
X
X    case o_supp:
X      prints("It's an almost obvious fact.");
X      prints("It is not proven.");
X      break;
X
X    case o_hypo:
X      prints("It's a complicated statement.");
X      prints("It is not proven.");
X      break;
X
X    case o_lemma:
X      prints("It's a rather specialized fact.");
X      break;
X
X    case o_theorem:
X      prints("It begins: The metaphysical existentialism of reality ...");
X      prints("The rest is incomprehensible to you.");
X      break;
X
X    case o_axiom:
X      prints("It's the basis of a complex system.");
X      break;
X
X    case o_post:
X      prints("It's a basic fact.");
X      break;
X
X    case o_math:
X      prints("He looks almost asleep.");
X      break;
X
X    case o_tetra:
X      if (curr_loc==22)
X      {
X        prints("Sharp letters form the message: Seeks the Exact");
X        mi = mi | 2;
X      }
X      else
X        prints("You see colorless letters.");
X      break;
X
X    case o_func:
X      prints
X      ("The function has many sharp points, all of which are at (1/2+bi).");
X      break;
X
X    case o_idea:
X      prints("The idea is very vague and not fully developed.");
X      break;
X
X    case o_contra:
X      prints
X      ("It is true and false, but neither is correct, and both are right.");
X      break;
X
X    case o_warr:
X      prints("It has expired.");
X      break;
X
X    default:
X      cprintf("Looks like %s.", obj[cmd.nn].name );  nl();
X  }
X}
X
X/*----------------------------*/
Xdo_read()
X{
X  if (cmd.nn==o_book)
X  {
X    prints("You are now reading an adventure ...");
X    goto_new_lev( 3 );
X    print_room = 1;
X  }
X  else
X    do_look();
X}
X
X/*----------------------------*/
Xdo_use()
X{
X  switch ( cmd.nn )
X  {
X    case o_proj:
X      prints("Try the buttons.");
X      break;
X
X    case o_stack:
X      prints("Try push or pop the stack, or scan something with it.");
X      break;
X
X    case o_prism:
X      do_look();
X      break;
X
X    case o_appa:
X      prints("Try to _y_ something with it");
X      break;
X
X    case o_improb:
X      if (curr_loc==16) do_throw(); else how();
X      break;
X
X    default:
X      how();
X      break;
X  }
X}
X
X/*----------------------------*/
Xdo_touch()
X{
X  cprintf( "Feels just like a %s.", cmd.noun );  nl();
X}
X
X/*----------------------------*/
Xdo_swing()
X{
X  if (cmd.nn==o_coil)
X    do_spin();
X  else
X    not_happen();
X}
X
X/*----------------------------*/
Xdo_rub()
X{
X  do_touch();
X}
X
X/*----------------------------*/
Xdo_push()
X{
X  int new_room;
X
X  if (cmd.nn==o_stack)
X  {
X    if (curr_loc>3)
X      not_happen();
X    else if (gp)
X      do_scan();
X    else
X    {
X      prints("You are falling inwards ...");
X      goto_new_loc( curr_loc+3 );
X      print_room = 1;
X    }
X  }
X
X  else if (obj[cmd.nn].loc==-7)
X  {
X    if (obj[o_disk].loc!=-7)
X      not_happen();
X    else if (!kp)
X      prints("The projector begins to start, fizzes and grinds, then stops.");
X    else
X    {
X      clrscr();
X      gotoxy( 1,25 );
X      prints("The lights dimmed for a while.");
X      new_room = cmd.nn + 17;
X      goto_new_loc( new_room );
X      room [29].link [north] = curr_loc;
X      print_room = 1;
X      DropObj( o_proj );
X
X      if (new_room==30)
X      {
X        prints("The projector ejects the disk.");
X        DropObj( o_disk );
X      }
X    }
X  }
X
X  else
X    not_happen();
X}
X
X/*----------------------------*/
Xdo_pop()
X{
X  char *s;
X
X  s = "You are falling outwards ...";
X
X  if (gp)
X    do_scan();
X
X  else if (cmd.nn==o_pills)
X    do_eat();
X
X  else if (cmd.nn!=o_stack)
X    not_poss();
X
X  else if (InComplex( curr_loc ))
X    prints("Can't transcend reality in this adventure.");
X
X  else if (InMirrorWorld( curr_loc ))
X  {
X    goto_new_loc( 1 );
X    print_room = 1;
X    prints( s );
X  }
X
X  else if (InMathWorld( curr_loc ))
X  {
X    goto_new_loc( 2 );
X    print_room = 1;
X    prints( s );
X  }
X
X  else if (InSpectralWorld( curr_loc ))
X  {
X    goto_new_loc( 3 );
X    print_room = 1;
X    prints( s );
X  }
X
X  else
X    not_happen();
X}
X
X/*----------------------------*/
Xdo_spin()
X{
X  if (cmd.nn==o_coil)
X  {
X    if (curr_loc==18)
X    {
X      cc = cc | 2;
X      ok();
X    }
X    else
X      not_happen();
X  }
X
X  else
X    not_happen();
X}
X
X/*----------------------------*/
Xdo_roll()
X{
X  int n;
X
X  if (cmd.nn==o_cube)
X  {
X    n = dr % 4;
X    cprintf("You rolled a ");
X    if (n<3)
X      cprintf("%d.", dc[n]);
X    else
X      cprintf("+nnn.");
X    nl();
X    dr++;
X  }
X  else
X    not_happen();
X}
X
X/*----------------------------*/
Xdo_wear()
X{
X  if (WearingObj(cmd.nn))
X    prints("You're already wearing it.");
X
X  else if (cmd.nn==o_audio)
X  {
X    WearObj( cmd.nn );
X    ok();
X  }
X
X  else
X    not_poss();
X}
X
X/*----------------------------*/
Xdo_eat()
X{
X  if (cmd.nn==o_plant)
X    prints("Don't consume higher lifeforms.");
X
X  else if (cmd.nn==o_pills)
X  {
X    prints("Gulp!  Suddenly you feel a little drowsy.");
X    ep=1;
X    JunkObj( cmd.nn );
X  }
X
X  else
X    prints("Can't eat that.");
X}
X
X/*----------------------------*/
Xdo_taste()
X{
X  switch ( cmd.nn )
X  {
X    case o_pills:
X      prints("It tastes like a drug.");
X      break;
X
X    case o_solid:
X    case o_liquid:
X      prints("The taste is quite orthogonal.");
X      break;
X
X    default:
X      prints("Can't taste that.");
X      break;
X  }
X}
X
X/*----------------------------*/
Xdo_drink()
X{
X  if (cmd.nn==o_fluid)
X    prints("Too cold.");
X
X  else if (cmd.nn==o_liquid)
X    prints("You're too low dimensioned to drink it.");
X
X  else
X    prints("Can't drink that.");
X}
X
X/*----------------------------*/
Xdo_remove()
X{
X  if (!WearingObj(cmd.nn))
X    prints("You are not wearing it.");
X
X  else
X  {
X    CarryObj( cmd.nn );
X    ok();
X  }
X}
X
X/*----------------------------*/
Xdo_water()
X{
X  if ( !ObjIsPresent(o_liquid) &&
X       (!CarryingObj(o_bottle) || obj[o_liquid].loc!=-8) )
X    prints("Nothing to water with.");
X
X  else if (cmd.nn!=o_plant)
X    prints("Can't water that.");
X
X  else
X  {
X    prints("Dendrites appear from hyperspace and absorbed the liquid.");
X    prints("The being thanks you.");
X    wa = 1;
X    JunkObj( o_liquid );
X  }
X}
X
X/*----------------------------*/
Xdo_fill()
X{
X  if (cmd.nn==o_bottle)
X  {
X    if (curr_loc==obj[o_liquid].loc)
X    {
X      obj[o_liquid].loc = -8;
X      ok();
X    }
X    else if (curr_loc==obj[o_fluid].loc)
X      prints("The fluid flows in and then flows out by itself");
X  }
X
X  else
X    how();
X}
X
X/*----------------------------*/
Xdo_pour()
X{
X  if (cmd.nn==o_bottle || cmd.nn==o_liquid)
X  {
X    if (obj[o_liquid].loc!=-8)
X      prints("Nothing to pour.");
X
X    else if (curr_loc==obj[o_plant].loc)
X    {
X      cmd.nn=o_plant;
X      do_water();
X    }
X
X    else
X    {
X      DropObj( o_liquid );
X      ok();
X    }
X  }
X
X  else
X    not_work();
X}
X
X/*----------------------------*/
Xdo_freeze()
X{
X  if (curr_loc!=obj[o_fluid].loc)
X    not_yet();
X
X  else if (cmd.nn==o_coil)
X  {
X    cc = cc | 1;
X    ok();
X  }
X
X  else
X    prints("You might damage it.");
X
X}
X
X/*----------------------------*/
Xdo_melt()
X{
X  if (!ObjIsPresent(o_plasma))
X    not_yet();
X
X  else if (cmd.nn==o_solid)
X  {
X    prints
X    ("The plasma dissipates as the solid melts into a puddle of liquid.");
X    JunkObj( o_plasma );
X    JunkObj( o_solid );
X    DropObj( o_liquid );
X    if (curr_loc==obj[o_plant].loc)
X    {
X      cmd.nn=o_plant;
X      do_water();
X    }
X  }
X
X  else if (cmd.nn==o_tetra)
X    prints("It melts, but quickly recrystalizes.");
X
X  else
X    not_work();
X}
X
X/*----------------------------*/
Xdo_play()
X{
X  if (cmd.nn==o_cube)
X    do_roll();
X
X  else if (cmd.nn==o_disk)
X    prints("You need something to play it.");
X
X  else if (cmd.nn==o_proj)
X    do_use();
X
X  else
X    not_happen();
X}
X
X/*----------------------------*/
Xdo_insert()
X{
X  v_word noun;
X  int nn;
X
X  if (cmd.nn==o_sing)
X  {
X    nn = InputNoun( "Where? ", noun );
X    if ( (!strcmp(noun,"groo") || !strcmp(noun,"band") || nn==o_audio)
X         && ObjIsPresent(o_audio) )
X    {
X      af = 1;
X      JunkObj( cmd.nn );
X      prints("The singularity slides in with a click.");
X    }
X    else
X      not_work();
X  }
X
X  else if (cmd.nn==o_disk)
X  {
X    nn = InputNoun( "Where? ", noun );
X    if ( (!strcmp(noun,"slot") || nn==o_proj) && ObjIsPresent(o_proj) )
X    {
X      obj[cmd.nn].loc = -7;
X      ok();
X    }
X    else
X      not_work();
X  }
X
X  else
X    not_work();
X}
X
X/*----------------------------*/
Xdo_fix()
X{
X  if (cmd.nn==o_proj)
X    prints("You don't know how to properly fix such a delicate instrument.");
X
X  else
X    prints("You don't know how.");
X}
X
X/*----------------------------*/
Xdo__y_()
X{
X  if (!ObjIsPresent(o_appa))
X    PrintMess( 7 );
X
X  else switch ( cmd.nn )
X  {
X    case o_cube:
X      if (dr<3)
X        prints("You shouldn't do that yet.");
X      else
X      {
X        prints("The hexahedron expands one dimension.");
X        ReplaceObj( cmd.nn, o_solid );
X      }
X      break;
X
X    case o_tetra:
X      prints("It expands a dimension, but quickly collapses back.");
X      break;
X
X    case o_strip:
X      prints("The moebius strip expands one dimension.");
X      ReplaceObj( cmd.nn, o_bottle );
X      break;
X
X    case o_prism:
X      prints("Object too unstable.");
X      break;
X
X    case o_bottle:
X    case o_solid:
X    case o_liquid:
X      prints("Can't go any higher in this universe.");
X      break;
X
X    case o_appa:
X      prints("Sorry, can't upgrade a product this way.");
X      break;
X
X    case o_plant:
X      prints("The being is already high enough.");
X      break;
X
X    default:
X      not_happen();
X  }
X}
X
X/*----------------------------*/
Xdo_prove()
X{
X  v_word noun;
X  char *msg1;
X  int nn;
X
X  msg1 = "Somehow a contradiction keeps coming into the proof.";
X
X  switch ( cmd.nn )
X  {
X    case o_lemma:
X    case o_theorem:
X    case o_axiom:
X    case o_post:
X      prints("It's already proven.");
X      break;
X
X    case o_supp:
X      nn = InputNoun( "With what? ", noun );
X      if (nn==o_post && ObjIsPresent(o_post))
X      {
X        if (ObjIsPresent(o_contra))
X          prints( msg1 );
X        else
X        {
X          prints("The postulate is now a lemma.");
X          ReplaceObj( cmd.nn, o_lemma );
X        }
X      }
X      else
X        not_work();
X      break;
X
X    case o_hypo:
X      nn = InputNoun( "With what? ", noun );
X      if (nn==o_lemma && ObjIsPresent(o_lemma) && ObjIsPresent(o_axiom))
X      {
X        if (ObjIsPresent(o_contra))
X          prints( msg1 );
X        else
X        {
X          prints("The hypothesis is now a theorem.");
X          ReplaceObj( cmd.nn, o_theorem );
X          prints("Suddelnly, a hyper-spatial cliff passes by");
X          prints("and the lemma leaps to its demise.");
X          JunkObj( o_lemma );
X        }
X      }
X      else
X        prints("Hmmm, something seems to be missing from the proof.");
X      break;
X
X    case o_idea:
X      prints("The idea developed into a contradiction.");
X      ReplaceObj( cmd.nn, 52 );
X      break;
X
X    case o_contra:
X      prints("You proved that the contradiction can't be proven.");
X      break;
X
X    default:
X      not_poss();
X  }
X}
X
X/*----------------------------*/
Xdo_smell()
X{
X  prints("You smell nothing unusual.");
X}
X
X/*----------------------------*/
Xdo_close()
X{
X  not_poss();
X}
X
X/*----------------------------*/
Xdo_open()
X{
X  not_poss();
X}
X
X/*----------------------------*/
Xdo_stop()
X{
X  if (!strcmp(cmd.sh_noun,"slee") || !strcmp(cmd.sh_noun,"drea"))
X    do_wake();
X
X  else if (!strcmp(cmd.sh_noun,"read"))
X  {
X    if (InBookWorld( curr_loc ))
X    {
X      goto_new_lev( 1 );
X      print_room = 1;
X      ok();
X    }
X    else
X      prints("Reality is like a book that you can't stop reading.");
X  }
X  else
X    not_work();
X}
X
X/*----------------------------*/
Xdo_say()
X{
X  cprintf( "'%s'", cmd.noun ); nl();
X  if (gp==0)
X    not_happen();
X
X  else
X  {
X    if (strcmp( cmd.noun,"tesseract" ))
X      zap = 2; /* wrong password */
X    else
X      zap = 3; /* right password */
X  }
X}
X
X/*----------------------------*/
Xdo_quit()
X{
X  do_score();
X  zap = 1;
X}
X
X/*----------------------------*/
Xdo_help()
X{
X  if (cmd.nn>0)
X    how();
X
X  else if (curr_lev==2)
X    prints("Use 'wake' to wake up from your dream.");
X
X  else if (curr_lev==3)
X    prints("Use 'stop reading' to stop reading the adventure.");
X
X  else
X    prints("Sorry, quasi-hyper-neo-mathematics is beyond me.");
X}
X
X/*----------------------------*/
Xdo_listen()
X{
X  char *msg;
X
X  msg = "Of Countless Tesseracts";
X
X  if (curr_loc==19)
X    prints("Sounds like radio waves from the Creation.");
X
X  else if (curr_loc!=obj[o_plant].loc)
X    prints("You hear nothing special.");
X
X  else if (wa==0)
X    prints("The being is whispering too softly.");
X
X  else if (!WearingObj(o_audio))
X    prints("You hear a harmonic song in a strange language.");
X
X  else if (!af)
X  {
X    cprintf("You hear an %d00-voiced fugue in a complex 1/f melody.", sum);
X    nl();
X    prints("But you are unable to follow even a single voice.");
X  }
X
X  else
X  {
X    cprintf("You hear the words: %s.", msg );  nl();
X    mi = mi | 8;
X  }
X}
X
X/*----------------------------*/
Xdo_save()
X{
X  int i;
X  FILE *f;
X  char s[80];
X
X  cprintf("Filename to save game to: ");
X  gets( s );
X  if (!*s) return;
X
X  f=fopen(s,"w");
X  if (f)
X  {
X    for ( i=1; i<MaxObjs; i++ )
X      fprintf( f, "%d ", obj[i].loc );
X
X    fprintf( f, "%d %d %d %d %d %d ",
X      curr_lev, curr_loc,
X      level_loc[1], level_loc[2], level_loc[3], sleep_lev );
X
X    fprintf( f, "%d %d %d %d %d %d %d %d %d %d %d %d ",
X      cc, wa, ep, dr, af, gp, mi, ti, kp, dc[0], dc[1], dc[2] );
X
X    putc( '\n', f );
X    fclose( f );
X    prints("Game saved.");
X  }
X  else
X  {
X    cprintf("Unable to save game to %s", s); nl();
X  }
X}
X
X/*----------------------------*/
Xdo_load()
X{
X  int i;
X  FILE *f;
X  char s[80];
X
X  cprintf("Filename to load game from: ");
X  gets( s );
X  if (!*s) return;
X
X  f=fopen(s,"r");
X  if (f)
X  {
X    for ( i=1; i<MaxObjs; i++ )
X      fscanf( f, "%d ", &obj[i].loc );
X
X    fscanf( f, "%d %d %d %d %d %d ",
X      &curr_lev, &curr_loc,
X      &level_loc[1], &level_loc[2], &level_loc[3], &sleep_lev );
X
X    fscanf( f, "%d %d %d %d %d %d %d %d %d %d %d %d ",
X      &cc, &wa, &ep, &dr, &af, &gp, &mi, &ti, &kp, &dc[0], &dc[1], &dc[2] );
X
X    for ( sum=0, i=0; i<3; i++ )
X      sum += dc[i];
X
X    fclose( f );
X    prints("Game loaded.");
X    print_room = 1;
X  }
X  else
X  {
X    cprintf("Unable to load game from %s", s); nl();
X  }
X}
X
X/*----------------------------*/
Xdo_score()
X{
X  cprintf("You scored %d out of 15.", mi );  nl();
X}
X
X/*----------------------------*/
Xdo_sleep()
X{
X  if (InDreamWorld( curr_loc ))
X  {
X    prints("A dream within a dream would have been quite poetic,");
X    prints("But time did not allow for it.");
X  }
X
X  else if (ep==0)
X    prints("You're not sleepy yet.");
X
X  else
X  {
X    prints("As you sleep, you begin to have a strange dream ...");
X    sleep_lev = curr_lev;
X    goto_new_lev( 2 );
X    print_room = 1;
X  }
X}
X
X/*----------------------------*/
Xdo_wake()
X{
X  if (cmd.nn!=o_math && cmd.nn>0)
X    not_work();
X
X  else if (!InDreamWorld( curr_loc ))
X    prints("Reality is not a fragment of nightmares and dreams.");
X
X  else if (cmd.nn!=o_math)
X  {
X    prints("Wow, that was some dream.");
X    goto_new_lev( sleep_lev );
X    print_room = 1;
X  }
X
X  else
X  {
X    if (!ObjInRoom(o_theorem))
X      prints
X      ("He mumbles: bother me not, I'm contemplating the ultimate question");
X    else
X    {
X      prints("He wakes up, looks at the theorem, an shouts:");
X      prints("Eureka!  This proves that the universe doesn't exis...");
X      goto_new_loc( 35 );
X      print_room = 1;
X      mi = mi | 4;
X    }
X  }
X}
X
X/*----------------------------*/
Xdo_give()
X{
X  int nn;
X  v_word noun;
X
X  nn = InputNoun( "To whom? ", noun );
X  if (!nn)
X    not_work();
X
X  else if (!ObjIsPresent(nn))
X    not_yet();
X
X  else if (nn==o_math)
X  {
X    if (cmd.nn==o_theorem)
X    {
X      DropObj( cmd.nn );
X      cmd.nn=o_math;
X      do_wake();
X    }
X    else
X      prints("He mumbles: disturb me not with such unimportant things.");
X  }
X
X  else if (nn==o_plant)
X  {
X    if (cmd.nn==o_liquid)
X      how();
X    else if (cmd.nn==o_solid)
X      prints("Plants don't eat solid nutrients.");
X    else
X      prints("The being doesn't need that.");
X  }
X
X  else
X    not_work();
X}
X
X/*----------------------------*/
Xint stack_say( s )
X  char *s;
X{
X  cprintf("Stack: ");
X  if (*s) prints( s );
X  return( 1 );
X}
X
Xdo_scan()
X{
X  char *s;
X  int flag;
X
X  s = "stack potential non-zero, pushing allowed.";
X  flag = 0;
X
X  if (!ObjOnPlayer(o_stack))
X    PrintMess( 7 );
X
X  else if (gp)
X  {
X    prints("Something has rendered the stack inoperative.");
X    return;
X  }
X
X  else if (cmd.nn==0)
X  {
X    if (InMirrorWorld( curr_loc ) || InMathWorld( curr_loc ) ||
X        InSpectralWorld( curr_loc ))
X      flag = stack_say("stack level non-zero, popping allowed.");
X
X    if (curr_loc<=3)
X      flag = stack_say( s );
X
X    if (curr_loc==18)
X      flag = stack_say("magnetic field present.");
X
X    if (curr_loc==obj[o_plant].loc)
X      flag = stack_say("sonic harmony present.");
X
X    if (!flag)
X      stack_say("nothing special to report.");
X  }
X
X  else
X  {
X    stack_say( "" );
X    switch ( cmd.nn )
X    {
X      case o_mirror:
X      case o_crt:
X      case o_hole:
X        prints( s );
X        break;
X
X      case o_plant:
X        cprintf("4-D.  ");
X        if (!wa)
X          prints("dehydrated.  weak audio output.");
X        else
X          prints("healthy.  strong audio output.");
X        break;
X
X      case o_stack:
X        prints("Stack operational.");
X        break;
X
X      case o_audio:
X        if (!af)
X          prints("no filter.");
X        else
X          prints("filter active.");
X        break;
X
X      case o_pills:
X        prints("edible.  barbiturate.");
X        break;
X
X      case o_fluid:
X        prints("extremely cold.  superconductive.  superfluid.");
X        break;
X
X      case o_prism:
X        prints("brittle.  light sensitive.");
X        break;
X
X      case o_coil:
X        prints("composition = yttrium, barium, copper, oxygen.");
X        if (cc)
X        {
X          cprintf("Stack: properties = ");
X          if (cc & 1) cprintf("superconductive.  ");
X          if (cc & 2) cprintf("magnetic.  ");
X          if ((cc & 3)==3) cprintf("strong magnetic field present.");
X          nl();
X        }
X        break;
X
X      case o_plasma:
X        prints("extremely hot.");
X        break;
X
X      case o_solid:
X        prints("4-D.  solid.");
X        break;
X
X      case o_liquid:
X        prints("4-D.  liquid.");
X        break;
X
X      case o_tetra:
X        prints("color sensitive.  omni-stable.");
X        break;
X
X      default:
X        prints("nothing special to report.");
X        break;
X
X    } /* switch */
X  } /* else */
X}
X
X/*----------------------------*/
Xdo_solve()
X{
X  int nn;
X  v_word noun;
X
X  if (cmd.nn==o_zeta)
X  {
X    nn = InputNoun("With what? ", noun );
X    if (!nn)
X      not_work();
X
X    else if (!ObjIsPresent(nn))
X      not_yet();
X
X    else if (nn!=o_func)
X      prints
X      ("Not difficult, although for someone like you it's too still hard.");
X
X    else
X    {
X      prints("The function and the integral cancel out nicely");
X      prints("and everything is reduced to a singularity.");
X      ReplaceObj( cmd.nn, o_sing );
X      JunkObj( o_func );
X    }
X  }
X
X  else if (cmd.nn==o_func)
X    prints("You are not really into great episodes of frustration.");
X
X  else if (cmd.nn==o_improb)
X    prints("It's improbable that you can solve it.");
X
X  else
X    not_work();
X}
X
X/*----------------------------*/
Xdo_think()
X{
X  if (!InDreamWorld(curr_loc))
X    prints("Therefore you are.");
X
X  else if (curr_loc!=25)
X    prints("This is not a good place to think.");
X
X  else if (!ti)
X  {
X    prints("You thought of an idea.");
X    CarryObj( o_idea );
X    ti = 1;
X  }
X
X  else
X    prints("You are out of ideas.");
X}
X
X/*----------------------------*/
Xdo_burn()
X{
X  if (!ObjIsPresent(o_plasma))
X    not_yet();
X
X  else
X    prints("Don't be a pyromaniac.");
X}
X
X/*----------------------------*/
Xdo_evap()
X{
X  if (!ObjIsPresent(o_plasma))
X    not_yet();
X
X  else if (cmd.nn==o_fluid)
X  {
X    prints("The fluid evaporates.");
X    JunkObj( cmd.nn );
X  }
X
X  else
X    do_burn();
X}
X
X/*----------------------------*/
Xdo_climb()
X{
X  if (cmd.nn==o_plant)
X    prints("That isn't very polite, and besides, it's not a beanstalk.");
X
X  else if (cmd.nn==o_mount)
X    prints("There are no rivers on the mountain.");
X
X  else
X    not_poss();
X}
X
X/*----------------------------*/
Xdo_cut()
X{
X  switch( cmd.nn )
X  {
X    case o_prism:
X      prints("It's already pre-cut.");
X      break;
X
X    case o_tetra:
X      prints("It is easily cut, but the cuts immediately reseal themselves.");
X      break;
X
X    case o_strip:
X      prints("With some tricky cuts, you end up with a mobius strip again.");
X      break;
X
X    case o_bottle:
X      prints("The bottle breaks into a mobius strip.");
X      ReplaceObj( cmd.nn, o_strip );
X      if (obj[o_liquid].loc==-8)
X      {
X        prints("The liquid in the bottle falls to the ground.");
X        DropObj( o_liquid );
X        if (curr_loc==obj[o_plant].loc)
X        {
X          cmd.nn=o_plant;
X          do_water();
X        }
X      }
X      break;
X
X    case o_plant:
X    case o_solid:
X    case o_liquid:
X      prints("Such low dimension cuts has no effect.");
X      break;
X
X    default:
X      not_work();
X  }
X}
X
X/*----------------------------*/
Xdo_join()
X{
X  if (cmd.nn==o_group)
X    prints("You're too finite.");
X  else
X    not_poss();
X}
X
X/*----------------------------*/
Xdo_sing()
X{
X  if (curr_loc==obj[o_plant].loc)
X    prints("Your singing can't possible compete with the hyper-melody.");
X
X  else
X    not_happen();
X}
X
X/*----------------------------*/
X/*
X*/
XDoCommand()
X{
X  if (cmd.vn<=6
X      || (cmd.vn>=39 && cmd.vn<=48) || cmd.vn==50 || cmd.vn==52
X      || cmd.vn==58 )
X    goto branch; /* single verbs */
X
X  if (obj[cmd.nn].loc==-9)
X  {
X    prints("Be more specific in naming the object");
X    return;
X  }
X
X  if (!ObjIsPresent(cmd.nn))
X  {
X    prints("That object is not here.");
X    return;
X  }
X
Xbranch:
X  switch ( cmd.vn )
X  {
X    case 1:
X    case 2:
X    case 3:
X    case 4: do_dir(); break;
X    case 5: do_inv(); break;
X    case 6: do_go(); break;
X    case 7: do_get(); break;
X    case 8: do_drop(); break;
X    case 9: do_throw(); break;
X    case 10: do_break(); break;
X    case 11: do_look(); break;
X    case 12: do_read(); break;
X    case 13: do_use(); break;
X    case 14: do_touch(); break;
X    case 15: do_swing(); break;
X    case 16: do_rub(); break;
X    case 17: do_push(); break;
X    case 18: do_pop(); break;
X    case 19: do_spin(); break;
X    case 20: do_roll(); break;
X    case 21: do_wear(); break;
X    case 22: do_eat(); break;
X    case 23: do_taste(); break;
X    case 24: do_drink(); break;
X    case 25: do_remove(); break;
X    case 26: do_water(); break;
X    case 27: do_fill(); break;
X    case 28: do_pour(); break;
X    case 29: do_freeze(); break;
X    case 30: do_melt(); break;
X    case 31: do_play(); break;
X    case 32: do_insert(); break;
X    case 33: do__y_(); break;
X    case 34: do_prove(); break;
X    case 35: do_fix(); break;
X    case 36: do_smell(); break;
X    case 37: do_close(); break;
X    case 38: do_open();break;
X    case 39: do_stop(); break;
X    case 40: do_say(); break;
X    case 41: do_quit(); break;
X    case 42: do_help(); break;
X    case 43: do_listen(); break;
X    case 44: do_save(); break;
X    case 45: do_load(); break;
X    case 46: do_score(); break;
X    case 47: do_sleep(); break;
X    case 48: do_wake(); break;
X    case 49: do_give(); break;
X    case 50: do_scan(); break;
X    case 51: do_solve(); break;
X    case 52: do_think(); break;
X    case 53: do_burn(); break;
X    case 54: do_evap(); break;
X    case 55: do_climb(); break;
X    case 56: do_cut(); break;
X    case 57: do_join(); break;
X    case 58: do_sing(); break;
X    default: cprintf( "I don't know how to %s.", cmd.verb );  nl();
X  }
X}
X
X/*----------------------------*/
XEnding( n )
X  int n;
X{
X  switch ( n )
X  {
X    case 1:
X      prints("Game Over");
X      break;
X
X    case 2:
X      prints("Incorrect password.");
X      prints("Self-destruct aborted.  Resuming Doomsday countdown.");
X      prints("5\n4\n3\n2\n1\n\nEarth destro...");
X      break;
X
X    case 3:
X      prints("Correct password.");
X      prints
X      ("Self-destruct sequence completed.  Overriding Doomsday countdown.");
X      prints("5\n4\n3\n2\n1\n\nKaboom...");
X
X      if (!ObjIsPresent(24))
X      {
X        prints("The Doomsday complex is destroyed.\n");
X        prints("You have given your life to save Earth.  Thank you.");
X      }
X      else
X      {
X        prints(
X        "As the complex disintegrates around you, the stack, sensing your\n");
X        prints(
X        "danger, overloads all it's circuits to regain a moment's control.\n");
X        prints(
X        "With a final burst of energy, the stack implodes, projecting a\n");
X        prints(
X        "stasis field around you that protects you from the destruction.\n");
X        prints(
X        "...\n");
X        prints(
X     "From the smoldering debris of the Doomsday complex you pick up the\n");
X        prints(
X        "pieces of the stack and reflect on how as you risked your life to\n");
X        prints(
X     "save Earth, the stack has given its own to save yours.  As you walk\n");
X        prints(
X        "away, you solemnly swear to repair the stack, for the adventures\n");
X        prints(
X        "that lie ahead.\n"
X        );
X      }
X      break;
X  }
X}
X
X/*----------------------------*/
X/*
X*/
Xintro1()
X{
X  prints(
X"               /*--------------/*      ------------------------------------");
X  prints(
X"             /  '            /  '           Beyond The Tesseract   V2.0p");
X  prints(
X"           /   '|          /   '|      ------------------------------------");
X  prints(
X"        */----'---------*/    ' |          An abstract text adventure by");
X  prints(
X"       '|    '  |      '|    '  |            David Lo   4516 Albert St.");
X  prints(
X"      ' |   '   |     ' |   '   |                       Burnaby, B.C.");
X  prints(
X"     '  |  '   /*----'--|--'---/*                       V5C 2G5   Canada");
X  prints(
X"    '   | '  /  '   '   | '  /  '        email c/o: viola@idacom.cs.ubc.ca");
X  prints(
X"   '    |' /   '   '    |' /   '       ------------------------------------");
X  prints(
X"  '    /*/----'---'----/*/    '         This is FreeShareAnythingWare.");
X  prints(
X" '   /  '    '   '   /  '    '          If you like this program, hate it,");
X  prints(
X"'  /   '|   '   '  /   '|   '           or really don't care at all, then");
X  prints(
X"*/----'----'----*/    ' |  '            I would be happy to hear from you");
X  prints(
X"|    '  | '     |    '  | '             (a letter, a post-it note, etc).");
X  prints(
X"|   '   |'      |   '   |'");
X  prints(
X"|  '   /*-------|--'---/*               Please share unmodified copies of");
X  prints(
X"| '  /          | '  /                  this adventure with everyone.");
X  prints(
X"|' /            |' /                   ------------------------------------");
X  prints(
X"*/--------------*/                            'Set the software free'");
X  prints("");
X}
X
Xintro()
X{
X  int i,j,k;
X
X  clrscr();
X  intro1();
X  prints("Press <Enter> to continue");
X  i=get_enter();
X  clrscr();
X
X  prints("Scenario:");
X  prints(
X"  You have reached the final part of your mission.  You have gained access");
X  prints(
X"  to the complex, and all but the last procedure has been performed.  Now");
X  prints(
X"  comes a time of waiting, in which you must search for the hidden 12-word");
X  prints(
X"  message that will aid you at the final step.  But what choice will you");
X  prints(
X"  make when that time comes?");
X
X  prints("");
X  prints("Instructions:");
X  prints(
X"  This adventure recognizes the standard commands for moving (N,E,S,W),");
X  prints(
X"  taking inventory (I), maninpulating objects (GET, DROP, LOOK), and");
X  prints(
X"  saving games (SAVE, LOAD), as well as many others. Use 2-word 'verb noun'");
X  prints(
X"  commands, such as 'use stack' or 'get all'.  Only the first four letters");
X  prints(
X"  of each word are significant.  The adventure recognizes about 200 words,");
X  prints(
X"  so if one word doesn't work, try another.");
X
X  prints("");
X  prints("Happy adventuring!");
X  prints("");
X
X  prints("Press <Enter> to begin");
X  j=get_enter();
X  clrscr();
X  srand( i*i + j + k );
X}
X
X/*------------------------------------------------------------*/
Xmain()
X{
X  int i, keep_playing;
X
X  intro();
X
X  do
X  {
X    InitAdv();
X    clrscr(); gotoxy( 1,25 );
X
X    do
X    {
X      gp = InComplex(curr_loc) && (mi==15);
X
X#ifdef tty
X      if (print_room)
X      {
X        PrintCurrRoom();
X        print_room=0;
X      }
X#endif
X
X      if (gp)
X        prints("A voice echoes: audio link complete.  Enter password.");
X
X#ifndef tty
X      PrintCurrRoom();
X#endif
X
X      if (InDreamWorld( curr_loc ))
X        printf("(sleeping) ");
X      else if (InBookWorld( curr_loc ))
X        printf("(reading) ");
X
X      cprintf("Enter command: ");
X      gets( cmd.cm );
X      if (cmd.cm[0])
X      {
X        AnalyseCommand( &cmd );
X        DoCommand();
X        nl();
X      }
X    }
X    while ( !zap );
X
X    Ending( zap );
X    nl();
X    cprintf("Play again (y/n)? ");
X    gets( cmd.cm );
X    keep_playing = (cmd.cm[0]!='n' && cmd.cm[0] !='N');
X    nl();
X  }
X  while ( keep_playing );
X  clrscr();
X  intro1();
X}
X
END_OF_FILE
if test 45562 -ne `wc -c <'tess.c'`; then
    echo shar: \"'tess.c'\" unpacked with wrong size!
fi
# end of 'tess.c'
fi
echo shar: End of archive 1 \(of 2\).
cp /dev/null ark1isdone
MISSING=""
for I in 1 2 ; do
    if test ! -f ark${I}isdone ; then
	MISSING="${MISSING} ${I}"
    fi
done
if test "${MISSING}" = "" ; then
    echo You have unpacked both archives.
    rm -f ark[1-9]isdone
else
    echo You still need to unpack the following archives:
    echo "        " ${MISSING}
fi
##  End of shell archive.
exit 0