home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / vol_300 / 323_01 / tess.c < prev    next >
C/C++ Source or Header  |  1990-08-06  |  48KB  |  2,208 lines

  1. /*--------------------------------------------------------------------------*\
  2. | TESS.C                                                                     |
  3. \*--------------------------------------------------------------------------*/
  4.  
  5. /*
  6.   Beyond The Tesseract   V2.03   (C) 1990 David Lo
  7.  
  8.   TRS-80
  9.     1.0  : 05/29/83 :
  10.     1.7  : 03/16/86 :
  11.  
  12.   MS-DOS
  13.     2.0  : 10/01/88 :
  14.     2.01 : 03/  /89 :
  15.     2.02 : 10/04/89 : Fixed probability message,
  16.                       Got rid of title screen when game ends.
  17.     2.03 : 01/22/90 : Added hint for field puzzle.
  18.          : 02/05/90 : "look" without noun will finally print the current room.
  19. */
  20.  
  21. #include <ctype.h>
  22. #include <string.h>
  23. #include <stdio.h>
  24.  
  25. #include "adv-def.h"
  26. #include "parser.h"
  27. #include "tess-def.h"
  28.  
  29. /*------------------------------------------------------------*/
  30. /* on some PC clones (e.g. mine), scrolling the screen when printing a '\n'
  31.    with the conio.h routines (e.g. putch('\n') or cprintf('\n')) is much slower
  32.    than the stdio.h routines.
  33. */
  34. nl()  {  putchar('\n');  }
  35.  
  36. /*----------------------------*/
  37. /* if tty-mode, then using standard library functions for I/O, and ignore the
  38.    screen I/O functions
  39. */
  40. #ifdef tty
  41.  
  42. #define cprintf printf
  43. #define cputs printf
  44. #define prints puts
  45.  
  46. #define clrscr()
  47. #define clreol()
  48. #define gotoxy(x,y)
  49.  
  50. /* if non-tty-mode, use console IO library
  51. */
  52. #else
  53.  
  54. #include <conio.h>
  55.  
  56. prints( char *s )
  57. {
  58.   cputs( s );
  59.   nl();
  60. }
  61.  
  62. #endif
  63.  
  64. /*----------------------------*/
  65. int get_enter()
  66. {
  67.   int i=0, ch;
  68.  
  69.   while ((ch=getchar()) != '\n')
  70.     i+=ch;
  71.   return (i);
  72. }
  73.  
  74. /*----------------------------*/
  75. /* enter aux. object (e.g. Give XXX to AUX)
  76. */
  77. int InputNoun( char *prompt, char *noun )
  78. {
  79.   int nn;
  80.  
  81.   cprintf( prompt );
  82.   gets( noun );
  83.   nn = GetNounNum( noun );
  84.   resize_word( noun );
  85.   return( nn );
  86. }
  87.  
  88. /*------------------------------------------------------------*/
  89. /* Adventure dependent stuff
  90. */
  91.  
  92. int
  93.   print_room,         /* flag for updating room after command */
  94.  
  95.   curr_loc,           /* current location */
  96.   curr_lev,           /* current level */
  97.   level_loc [ 4 ],    /* current location for diff. levels */
  98.   zap,                /* flag set when game over */
  99.                       /*   1=quit   2=wrong password   3=right password */
  100.  
  101.   sleep_lev,          /* which level player was in when sleeping */
  102.  
  103.                       /* flags are 0=false/haven't done, 1=true/done */
  104.                       /* unless otherwise noted */
  105.  
  106.   cc,                 /* coil status: 0=normal  b1=cooled  b2=magnetized */
  107.   wa,                 /* water alien */
  108.   ep,                 /* eat pills */
  109.   dr,                 /* dice roll counter */
  110.   af,                 /* audio filter inserted */
  111.   gp,                 /* get password */
  112.   mi,                 /* message: bits 0,1,2,3 = parts found */
  113.   ti,                 /* think idea */
  114.   kp,                 /* kick projector */
  115.  
  116.   dc [ 3 ],           /* each dice roll, dc[i]<33 */
  117.   sum                 /* sum = sigma( dc ) < 100  */
  118.   ;
  119.  
  120. /*----------------------------*/
  121. InitAdv()
  122. {
  123.   int i;
  124.  
  125.   for ( i=1; i<MaxObjs; i++ )
  126.   {
  127.     obj[i].loc = obj[i].init_loc;
  128.   }
  129.  
  130.   level_loc[1] = 2;
  131.   level_loc[2] = 25;
  132.   level_loc[3] = 29;
  133.  
  134.   curr_lev = 1;
  135.   curr_loc = level_loc [ curr_lev ];
  136.  
  137.   zap = cc = wa = ep = dr = af = gp = mi = ti = kp = 0;
  138.  
  139.   for ( sum=0, i=0; i<3; i++ )
  140.     sum += (dc [i] = rand() & 31);
  141.  
  142.   print_room = 1;
  143. }
  144.  
  145. /*------------------------------------------------------------*/
  146. /* Message routines
  147. */
  148.  
  149. /*----------------------------*/
  150. PrintMess( int i )
  151. {
  152.   switch ( i )
  153.   {
  154.     case 1: prints("Nothing special happens."); break;
  155.     case 2: prints("That isn't possible."); break;
  156.     case 3: prints("Doesn't work."); break;
  157.     case 4: prints("Can't do that yet."); break;
  158.     case 5: prints("OK."); break;
  159.     case 6: prints("How?"); break;
  160.     case 7: cprintf("You have nothing to %s with.", cmd.verb ); nl(); break;
  161.   }
  162. }
  163.  
  164. not_happen() {  PrintMess( 1 );  }
  165. not_poss()   {  PrintMess( 2 );  }
  166. not_work()   {  PrintMess( 3 );  }
  167. not_yet()    {  PrintMess( 4 );  }
  168. ok()         {  PrintMess( 5 );  }
  169. how()        {  PrintMess( 6 );  }
  170.  
  171. /*------------------------------------------------------------*/
  172. /* Object routines
  173. */
  174.  
  175. /*----------------------------*/
  176. int CheckObjAttr( int nn, int mask )
  177. {
  178.   return ( obj [nn].attr & mask );
  179. }
  180.  
  181. #define CanGetObj(i) CheckObjAttr((i),1)
  182. #define CanLookObj(i) CheckObjAttr((i),4)
  183.  
  184. /*----------------------------*/
  185. CarryObj( int nn )
  186. {
  187.   obj [nn].loc = -curr_lev;
  188. }
  189.  
  190. int CarryingObj( int nn )
  191. {
  192.   return ( obj [nn].loc == -curr_lev );
  193. }
  194.  
  195. /*----------------------------*/
  196. WearObj( int nn )
  197. {
  198.   obj [nn].loc = -curr_lev - 3;
  199. }
  200.   
  201. int WearingObj( int nn )
  202. {
  203.   return ( obj [nn].loc == -curr_lev-3 );
  204. }
  205.  
  206. /*----------------------------*/
  207. int ObjOnPlayer( int nn )
  208. {
  209.   return ( CarryingObj(nn) || WearingObj(nn) );
  210. }
  211.  
  212. /*----------------------------*/
  213. DropObj( int nn )
  214. {
  215.   obj [nn].loc = curr_loc;
  216. }
  217.  
  218. int ObjInRoom( int nn )
  219. {
  220.   return ( obj [nn].loc == curr_loc );
  221. }
  222.  
  223. /*----------------------------*/
  224. JunkObj( int nn )
  225. {
  226.  obj [nn].loc = 0;
  227. }
  228.  
  229. /* replace object nn with object new_nn
  230. */
  231. ReplaceObj( int nn, int new_nn )
  232. {
  233.   obj [new_nn].loc = obj [nn].loc;
  234.   obj [nn].loc = 0;
  235. }
  236.  
  237. /*----------------------------*/
  238. /* See if an object is accessible.  This means the object is being
  239.    carried/worn, is in the same room, is a concept noun (e.g. north),
  240.    is part of the room (e.g. field), or is part of another object
  241.    (e.g. button).
  242. */
  243. int ObjIsPresent( int nn )
  244. {
  245.   if ( (nn>=o_north) && (nn<=o_invent) )   /* direction, "inventory" */
  246.     return (1);               /* always available */
  247.  
  248.   else if ( (nn>=o_buttons) && (nn<=o_four) )  /* buttons */
  249.     return ( ObjIsPresent(o_proj) );           /* on projector */
  250.  
  251.   else if ( (nn==o_liquid) && (obj[nn].loc==-8) )  /* contained fluid */
  252.     return ( ObjIsPresent(o_bottle) );             /* in Klein bottle */
  253.  
  254.   else
  255.     return ( ObjInRoom(nn) || CarryingObj(nn) || WearingObj(nn) );
  256. }
  257.  
  258. /*------------------------------------------------------------*/
  259. /* Room routines
  260. */
  261.  
  262. /*----------------------------*/
  263. /* predicates to return check whether the player in in a certain world
  264. */
  265. int InComplex( int rn )
  266. {
  267.   return ( rn==1 || rn==2 || rn==7 || rn==8 );
  268. }
  269.  
  270. int InMirrorWorld( int rn )
  271. {
  272.   return ( rn==4 || (rn>=9 && rn<=13) );
  273. }
  274.  
  275. int InMathWorld( int rn )
  276. {
  277.   return ( rn==3 || rn==5 || (rn>=14 && rn<=17) );
  278. }
  279.  
  280. int InSpectralWorld( int rn )
  281. {
  282.   return ( rn==6 || (rn>=18 && rn<=22) );
  283. }
  284.  
  285. int InDreamWorld( int rn )
  286. {
  287.   return ( curr_lev==2 || (rn>=23 && rn<=28) || rn==35 );
  288. }
  289.  
  290. int InBookWorld( int rn )
  291. {
  292.   return ( curr_lev==3 || (rn>=29 && rn<=34) );
  293. }
  294.  
  295. /*----------------------------*/
  296. PrintCurrRoom()
  297. {
  298.   static int stop_line=1;
  299.   int i,flag, len,currx;
  300.   char *s;
  301.  
  302. #ifndef tty
  303.   /* clear window area from previous time
  304.   */
  305.   for ( i=stop_line; i>=1; i-- )
  306.   {
  307.     gotoxy( 1, i );
  308.     clreol();
  309.   }
  310. #else
  311.   cprintf("------------------------------------------------------------------------------");
  312.   nl();
  313. #endif
  314.  
  315.   cprintf("You are %s.", room [ curr_loc ].name ); nl();
  316.  
  317.   prints("You see around you:");
  318.   clreol();
  319.   flag=0;
  320.   currx=0;
  321.   for ( i=1; i<MaxObjs; i++ )
  322.     if (ObjInRoom(i))
  323.     {
  324.       s = obj[i].name;
  325.       len = strlen(s);
  326.       if (currx+ len + 3 > 78 ) { currx=0; nl(); clreol(); }
  327.       cprintf("  %s.", s );
  328.       currx += len+3;
  329.       flag=1;
  330.     }
  331.   if (!flag)
  332.     prints("  Nothing special.");
  333.   else
  334.     { nl(); clreol(); }
  335.  
  336.   prints("Exits:");
  337.   clreol();
  338.   flag=0;
  339.   for ( i=0; i<MaxDirs; i++ )
  340.     if ( room [curr_loc].link [i] )
  341.     {
  342.       cprintf("  %s.", obj[i+1].name );
  343.       flag=1;
  344.     }
  345.   if (!flag) cprintf("  none.");
  346.   nl();
  347.  
  348. #ifdef tty
  349.   nl();
  350. #else
  351.   prints("------------------------------------------------------------------------------");
  352.   stop_line = wherey();  /* stop line is the line after the separator bar */
  353.   gotoxy( 1,25 );
  354. #endif
  355. }
  356.  
  357. /*----------------------------*/
  358. goto_new_lev( int lev )
  359. {
  360.   curr_lev = lev;
  361.   curr_loc = level_loc [curr_lev];
  362. }
  363.   
  364. goto_new_loc( int rn )
  365. {
  366.   curr_loc = rn;
  367.   level_loc [curr_lev] = curr_loc;
  368. }
  369.  
  370. /*------------------------------------------------------------*/
  371. /* Verb routines
  372. */
  373.  
  374. /*----------------------------*/
  375. do_go()
  376. {
  377.   int direct, new_room;
  378.  
  379.   switch ( cmd.nn )
  380.   {
  381.     case o_north:
  382.     case o_east:
  383.     case o_south:
  384.     case o_west:
  385.       direct = cmd.nn - 1;                       /* assumes NESW = 1234 */
  386.       new_room = room [curr_loc].link [direct];
  387.       if (new_room)
  388.       {
  389.         goto_new_loc( new_room );
  390.         print_room = 1;
  391.       }
  392.       else
  393.         prints("Can't go in that direction");
  394.       break;
  395.  
  396.     default:
  397. /*
  398.       if (isdigit(cmd.noun[0]))
  399.       {
  400.         new_room = atoi( cmd.noun );
  401.         if ( (new_room>=0) && (new_room<MaxLocs) )
  402.           goto_new_loc( new_room );
  403.         else
  404.           prints("Can't go there");
  405.       }
  406.       else
  407. */
  408.         prints("Use a direction or the stack");
  409.   }
  410. }
  411.  
  412. /*----------------------------*/
  413. do_dir()
  414. {
  415.   cmd.nn = cmd.vn;
  416.   cmd.vn = 6;
  417.   do_go();
  418. }
  419.  
  420. /*----------------------------*/
  421. do_inv()
  422. {
  423.   int flag, i, len,currx;
  424.   char s[80];
  425.  
  426.   prints("You are carrying:");
  427.   flag=0;
  428.   currx=0;
  429.   for ( i=1; i<MaxObjs; i++ )
  430.     if ( ObjOnPlayer(i) )
  431.     {
  432.       strcpy( s, obj[i].name );
  433.       if (WearingObj(i)) strcat( s, " (wearing)" );
  434.       len = strlen(s);
  435.       if (currx+ len + 3 > 78 ) { currx=0; nl(); }
  436.       cprintf("  %s.", s );
  437.       currx += len+3;
  438.       flag=1;
  439.     }
  440.  
  441.   if (!flag)
  442.     prints("  nothing.");
  443.   else
  444.     nl();
  445. }
  446.  
  447. /*----------------------------*/
  448. do_get()
  449. {
  450.   int where, attr, i, get_flag;
  451.   char s[16], *p;
  452.  
  453.   if (ObjOnPlayer(cmd.nn))
  454.     prints("You already have it.");
  455.  
  456.   else if (cmd.nn==o_invent)      /* get everything in room */
  457.   {
  458.     for ( i=o_invent+1; i<MaxObjs; i++ )
  459.       if ( ObjInRoom(i) && CanGetObj(i) )
  460.       {
  461.         cmd.nn=i;
  462.         cprintf( "--> get %s", obj[i].name ); nl();
  463.         do_get();
  464.       }
  465.   }
  466.  
  467.   else if (!CanGetObj(cmd.nn))      /* un-gettable object? */
  468.   {
  469.     if (cmd.nn==o_plant)    /* alien */
  470.       prints("The being is rooted in the 4th dimension.");
  471.  
  472.     else if (cmd.nn==o_group)
  473.       prints("The group has infinitely many reasons to stay where it is.");
  474.  
  475.     else if (cmd.nn==o_fluid)   /* fluid */
  476.       prints("It's too cold!");
  477.  
  478.     else
  479.       prints("Can't get that.");
  480.   }
  481.  
  482.   else  /* gettable object */
  483.   {
  484.     get_flag = 1;
  485.  
  486.     if (cmd.nn==o_liquid)   /* 4-D liquid */
  487.     {
  488.       how();
  489.       get_flag = 0;
  490.     }
  491.  
  492.     else if (cmd.nn==o_plasma)   /* plasma */
  493.     {
  494.       if (!CarryingObj(o_coil) || (cc!=3))   /* not have coil or not mag. bottle */
  495.       {
  496.         prints("Too hot to handle.");
  497.         get_flag = 0;
  498.       }
  499.       else
  500.         prints( "The magnetic field of the coil contained the plasma." );
  501.     }
  502.  
  503.     else if (cmd.nn==o_improb)   /* improbability */
  504.     {
  505.       get_flag = 0;
  506.       cprintf("What is the probability of getting this improbability? ");
  507.       gets( s );
  508.       p = strchr( s, '.' );  /* skip past decimal point */
  509.       if (!p)
  510.         printf("Probabilites are values between 0 and 1.\n");
  511.       else
  512.       {
  513.         p++;
  514.         i = atoi( p );
  515.         if (i!=sum && i*10!=sum)
  516.           prints("Wrong.");
  517.         else
  518.           get_flag = 1;
  519.       }
  520.     }
  521.  
  522.     if (get_flag)
  523.     {
  524.       CarryObj( cmd.nn );
  525.       ok();
  526.     }
  527.   }
  528. }
  529.   
  530. /*----------------------------*/
  531. do_drop()
  532. {
  533.   int where, i;
  534.  
  535.   if (ObjInRoom(cmd.nn))
  536.     prints("It's already here.");
  537.  
  538.   else if (cmd.nn==o_improb && curr_loc==16)
  539.     do_throw();
  540.  
  541.   else if (cmd.nn==o_invent)        /* drop everything */
  542.   {
  543.     for ( i=o_invent+1; i<MaxObjs; i++ )
  544.       if ( ObjOnPlayer(i) )
  545.       {
  546.         cmd.nn=i;
  547.         cprintf( "--> drop %s", obj[i].name ); nl();
  548.         do_drop();
  549.       }
  550.   }
  551.  
  552.   else if (cmd.nn>o_invent)
  553.   {
  554.     if (cmd.nn==o_coil)  /* drop coil, check for plasma as well */
  555.     {
  556.       if (CarryingObj(o_coil) && CarryingObj(o_plasma))
  557.         DropObj( o_plasma );
  558.     }
  559.  
  560.     if ( ObjOnPlayer( cmd.nn ))
  561.     {
  562.       DropObj(cmd.nn);
  563.       ok();
  564.     }
  565.   }
  566. }
  567.  
  568. /*----------------------------*/
  569. do_throw()
  570. {
  571.   char *s;
  572.  
  573.   if (ObjInRoom(cmd.nn))
  574.     prints("It's already here.");
  575.  
  576.   else if (cmd.nn==o_improb && curr_loc==16)
  577.   {
  578.     prints("The improbability's presence warps the fabric of the field.");
  579.     room [16].link [east] = 17 - room [16].link [east];
  580.     print_room = 1;
  581.     DropObj( cmd.nn );
  582.   }
  583.   else if (cmd.nn==o_cube)
  584.     do_roll();
  585.  
  586.   else if (cmd.nn==o_disk)
  587.   {
  588.     prints("With great skill (i.e. luck) you threw the disk into the next room.");
  589.     if (curr_loc==29)
  590.       obj [cmd.nn].loc = -7;
  591.     else
  592.       obj [cmd.nn].loc = room [curr_loc].link [south];
  593.   }
  594.  
  595.   else
  596.     do_drop();
  597. }
  598.  
  599. /*----------------------------*/
  600. do_break()
  601. {
  602.   if (cmd.nn==o_prism)
  603.   {
  604.     prints("The prism shatters along the lines and mysteriously");
  605.     prints("reorganizes itself into a tetrahedron.");
  606.     ReplaceObj( cmd.nn, o_tetra );
  607.   }
  608.  
  609.   else if (cmd.nn==o_tetra)
  610.     prints("It shatters, but quickly reforms itself.");
  611.  
  612.   else if (cmd.nn==o_zeta)
  613.     do_solve();
  614.  
  615.   else if (cmd.nn==o_proj)
  616.   {
  617.     if (!kp)
  618.     {
  619.       prints("With a few kicks and blows, both you and the projector felt better.");
  620.       kp = 1;
  621.     }
  622.     else
  623.       prints("Better not try that again, or you'll really break it.");
  624.   }
  625.  
  626.   else if (cmd.nn==o_bottle)
  627.     do_cut();
  628.  
  629.   else
  630.     prints("Violence is not necessary, most of the time.");
  631. }
  632.  
  633. /*----------------------------*/
  634. do_look()
  635. {
  636.   if (!cmd.nn)
  637.     print_room = 1;
  638.  
  639.   else if (!CanLookObj(cmd.nn))
  640.   {
  641.     cprintf("Looks like %s.", obj[cmd.nn].name );  nl();
  642.   }
  643.  
  644.   else
  645.   switch ( cmd.nn )
  646.   {
  647.     case o_mirror:
  648.       prints("You see the reflections of a mirror world.");
  649.       break;
  650.  
  651.     case o_crt:
  652.       prints("You see the images of a mathematical universe.");
  653.       break;
  654.  
  655.     case o_group:
  656.       prints("The group consists of converging parallel lines, alef-null,");
  657.       prints("the last prime number, 1/0, and uncountably many others.");
  658.       break;
  659.  
  660.     case o_hole:
  661.       prints("You see the lights of an electromagnetic continuum.");
  662.       break;
  663.  
  664.     case o_proj:
  665.       prints("You see a wide slot and 5 buttons.");
  666.       if (obj[o_disk].loc==-7)
  667.         prints("A disk is in the projector.");
  668.  
  669.     case o_buttons:
  670.       prints("The buttons are labelled zero to four.");
  671.       break;
  672.  
  673.     case o_chaos:
  674.       prints("It bears a slight resemblence to the current universe.");
  675.       break;
  676.  
  677.     case o_dust:
  678.       prints("It look like the remains of an exploded Julia set.");
  679.       break;
  680.  
  681.     case o_flake:
  682.       prints("It doesn't look like the coastline of Britain.");
  683.       break;
  684.  
  685.     case o_mount:
  686.       prints("It looks the same at all scales.");
  687.       break;
  688.  
  689.     case o_tomb:
  690.       prints("The epitaph reads: The Eternal Soul");
  691.       mi = mi | 1;
  692.       break;
  693.  
  694.     case o_stack:
  695.       prints("It's a Space-Time Activated Continuum Key.");
  696.       break;
  697.  
  698.     case o_audio:
  699.       prints("Looks like 2 speakers connected by a band.");
  700.       if (!af)
  701.         prints("There is a groove in the band.");
  702.       break;
  703.  
  704.     case o_book:
  705.       prints("The title is 'Interactive Adventures'.");
  706.       break;
  707.  
  708.     case o_bottle:
  709.       if (obj[o_liquid].loc==-8)
  710.         prints("It is full of some strange liquid.");
  711.       else
  712.         prints("It is an empty bottle with no inside or outside.");
  713.       break;
  714.  
  715.     case o_prism:
  716.       prints("You see flashes along deeply etched lines");
  717.       if (curr_loc==21)
  718.         prints("And embedded, distorted shapes resembling letters");
  719.       break;
  720.  
  721.     case o_appa:
  722.       prints("Looks like a device used for increasing the dimensions of");
  723.       prints("geometric and topological objects.");
  724.       break;
  725.  
  726.     case o_improb:
  727.       prints("It looks like a heart of gold.");
  728.       break;
  729.  
  730.     case o_zeta:
  731.       prints("It's a very vicious-looking integral.");
  732.       break;
  733.  
  734.     case o_cube:
  735.       prints("There are numbers on the sides.");
  736.       break;
  737.  
  738.     case o_coil:
  739.       prints("The ends of the coil are connected to form a loop.");
  740.       break;
  741.  
  742.     case o_sing:
  743.       prints("It is shaped like a narrow band.");
  744.       break;
  745.  
  746.     case o_disk:
  747.       prints("The title is: The Science and Beauty of a Geometric Nature");
  748.       break;
  749.  
  750.     case o_supp:
  751.       prints("It's an almost obvious fact.");
  752.       prints("It is not proven.");
  753.       break;
  754.  
  755.     case o_hypo:
  756.       prints("It's a complicated statement.");
  757.       prints("It is not proven.");
  758.       break;
  759.  
  760.     case o_lemma:
  761.       prints("It's a rather specialized fact.");
  762.       break;
  763.  
  764.     case o_theorem:
  765.       prints("It begins: The metaphysical existentialism of reality ...");
  766.       prints("The rest is incomprehensible to you.");
  767.       break;
  768.  
  769.     case o_axiom:
  770.       prints("It's the basis of a complex system.");
  771.       break;
  772.  
  773.     case o_post:
  774.       prints("It's a basic fact.");
  775.       break;
  776.  
  777.     case o_math:
  778.       prints("He looks almost asleep.");
  779.       break;
  780.  
  781.     case o_tetra:
  782.       if (curr_loc==22)
  783.       {
  784.         prints("Sharp letters form the message: Seeks the Exact");
  785.         mi = mi | 2;
  786.       }
  787.       else
  788.         prints("You see colorless letters.");
  789.       break;
  790.  
  791.     case o_func:
  792.       prints("The function has many sharp points, all of which are at (1/2+bi).");
  793.       break;
  794.  
  795.     case o_idea:
  796.       prints("The idea is very vague and not fully developed.");
  797.       break;
  798.  
  799.     case o_contra:
  800.       prints("It is true and false, but neither is correct, and both are right.");
  801.       break;
  802.  
  803.     case o_warr:
  804.       prints("It has expired.");
  805.       break;
  806.  
  807.     default:
  808.       cprintf("Looks like %s.", obj[cmd.nn].name );  nl();
  809.   }
  810. }
  811.  
  812. /*----------------------------*/
  813. do_read()
  814. {
  815.   if (cmd.nn==o_book)
  816.   {
  817.     prints("You are now reading an adventure ...");
  818.     goto_new_lev( 3 );
  819.     print_room = 1;
  820.   }
  821.   else
  822.     do_look();
  823. }
  824.  
  825. /*----------------------------*/
  826. do_use()
  827. {
  828.   switch ( cmd.nn )
  829.   {
  830.     case o_proj:
  831.       prints("Try the buttons.");
  832.       break;
  833.  
  834.     case o_stack:
  835.       prints("Try push or pop the stack, or scan something with it.");
  836.       break;
  837.  
  838.     case o_prism:
  839.       do_look();
  840.       break;
  841.  
  842.     case o_appa:
  843.       prints("Try to _y_ something with it");
  844.       break;
  845.  
  846.     case o_improb:
  847.       if (curr_loc==16) do_throw(); else how();
  848.       break;
  849.  
  850.     case o_func:
  851.       prints("");
  852.       break;
  853.  
  854.     case o_zeta:
  855.       prints("");
  856.       break;
  857.  
  858.     default:
  859.       how();
  860.       break;
  861.   }
  862. }
  863.  
  864. /*----------------------------*/
  865. do_touch()
  866. {
  867.   cprintf( "Feels just like a %s.", cmd.noun );  nl();
  868. }
  869.  
  870. /*----------------------------*/
  871. do_swing()
  872. {
  873.   if (cmd.nn==o_coil)
  874.     do_spin();
  875.   else
  876.     not_happen();
  877. }
  878.  
  879. /*----------------------------*/
  880. do_rub()
  881. {
  882.   do_touch();
  883. }
  884.  
  885. /*----------------------------*/
  886. do_push()
  887. {
  888.   int new_room;
  889.  
  890.   if (cmd.nn==o_stack)
  891.   {
  892.     if (curr_loc>3)
  893.       not_happen();
  894.     else if (gp)
  895.       do_scan();
  896.     else
  897.     {
  898.       prints("You are falling inwards ...");
  899.       goto_new_loc( curr_loc+3 );
  900.       print_room = 1;
  901.     }
  902.   }
  903.  
  904.   else if (obj[cmd.nn].loc==-7)
  905.   {
  906.     if (obj[o_disk].loc!=-7)
  907.       not_happen();
  908.     else if (!kp)
  909.       prints("The projector begins to start, fizzes and grinds, then stops.");
  910.     else
  911.     {
  912.       clrscr();
  913.       gotoxy( 1,25 );
  914.       prints("The lights dimmed for a while.");
  915.       new_room = cmd.nn + 17;
  916.       goto_new_loc( new_room );
  917.       room [29].link [north] = curr_loc;
  918.       print_room = 1;
  919.       DropObj( o_proj );
  920.  
  921.       if (new_room==30)
  922.       {
  923.         prints("The projector ejects the disk.");
  924.         DropObj( o_disk );
  925.       }
  926.     }
  927.   }
  928.  
  929.   else
  930.     not_happen();
  931. }
  932.  
  933. /*----------------------------*/
  934. do_pop()
  935. {
  936.   char *s;
  937.  
  938.   s = "You are falling outwards ...";
  939.  
  940.   if (gp)
  941.     do_scan();
  942.  
  943.   else if (cmd.nn==o_pills)
  944.     do_eat();
  945.  
  946.   else if (cmd.nn!=o_stack)
  947.     not_poss();
  948.  
  949.   else if (InComplex( curr_loc ))
  950.     prints("Can't transcend reality in this adventure.");
  951.  
  952.   else if (InMirrorWorld( curr_loc ))
  953.   {
  954.     goto_new_loc( 1 );
  955.     print_room = 1;
  956.     prints( s );
  957.   }
  958.  
  959.   else if (InMathWorld( curr_loc ))
  960.   {
  961.     goto_new_loc( 2 );
  962.     print_room = 1;
  963.     prints( s );
  964.   }
  965.  
  966.   else if (InSpectralWorld( curr_loc ))
  967.   {
  968.     goto_new_loc( 3 );
  969.     print_room = 1;
  970.     prints( s );
  971.   }
  972.  
  973.   else
  974.     not_happen();
  975. }
  976.  
  977. /*----------------------------*/
  978. do_spin()
  979. {
  980.   if (cmd.nn==o_coil)
  981.   {
  982.     if (curr_loc==18)
  983.     {
  984.       cc = cc | 2;
  985.       ok();
  986.     }
  987.     else
  988.       not_happen();
  989.   }
  990.  
  991.   else
  992.     not_happen();
  993. }
  994.  
  995. /*----------------------------*/
  996. do_roll()
  997. {
  998.   int n;
  999.  
  1000.   if (cmd.nn==o_cube)
  1001.   {
  1002.     n = dr % 4;
  1003.     cprintf("You rolled a ");
  1004.     if (n<3)
  1005.     {
  1006.       if (dc[n]<10)
  1007.         cprintf(".0%d", dc[n]);
  1008.       else
  1009.         cprintf(".%d", dc[n]);
  1010.     }
  1011.     else
  1012.       cprintf("+nnn");
  1013.     nl();
  1014.     dr++;
  1015.   }
  1016.   else
  1017.     not_happen();
  1018. }
  1019.  
  1020. /*----------------------------*/
  1021. do_wear()
  1022. {
  1023.   if (WearingObj(cmd.nn))
  1024.     prints("You're already wearing it.");
  1025.  
  1026.   else if (cmd.nn==o_audio)
  1027.   {
  1028.     WearObj( cmd.nn );
  1029.     ok();
  1030.   }
  1031.  
  1032.   else
  1033.     not_poss();
  1034. }
  1035.  
  1036. /*----------------------------*/
  1037. do_eat()
  1038. {
  1039.   if (cmd.nn==o_plant)
  1040.     prints("Don't consume higher lifeforms.");
  1041.  
  1042.   else if (cmd.nn==o_pills)
  1043.   {
  1044.     prints("Gulp!  Suddenly you feel a little drowsy.");
  1045.     ep=1;
  1046.     JunkObj( cmd.nn );
  1047.   }
  1048.  
  1049.   else
  1050.     prints("Can't eat that.");
  1051. }
  1052.  
  1053. /*----------------------------*/
  1054. do_taste()
  1055. {
  1056.   switch ( cmd.nn )
  1057.   {
  1058.     case o_pills:
  1059.       prints("It tastes like a drug.");
  1060.       break;
  1061.  
  1062.     case o_solid:
  1063.     case o_liquid:
  1064.       prints("The taste is quite orthogonal.");
  1065.       break;
  1066.  
  1067.     default:
  1068.       prints("Can't taste that.");
  1069.       break;
  1070.   }
  1071. }
  1072.  
  1073. /*----------------------------*/
  1074. do_drink()
  1075. {
  1076.   if (cmd.nn==o_fluid)
  1077.     prints("Too cold.");
  1078.  
  1079.   else if (cmd.nn==o_liquid)
  1080.     prints("You're too low dimensioned to drink it.");
  1081.  
  1082.   else
  1083.     prints("Can't drink that.");
  1084. }
  1085.  
  1086. /*----------------------------*/
  1087. do_remove()
  1088. {
  1089.   if (!WearingObj(cmd.nn))
  1090.     prints("You are not wearing it.");
  1091.  
  1092.   else
  1093.   {
  1094.     CarryObj( cmd.nn );
  1095.     ok();
  1096.   }
  1097. }
  1098.  
  1099. /*----------------------------*/
  1100. do_water()
  1101. {
  1102.   if ( !ObjIsPresent(o_liquid) &&
  1103.        (!CarryingObj(o_bottle) || obj[o_liquid].loc!=-8) )
  1104.     prints("Nothing to water with.");
  1105.  
  1106.   else if (cmd.nn!=o_plant)
  1107.     prints("Can't water that.");
  1108.  
  1109.   else
  1110.   {
  1111.     prints("Dendrites appear from hyperspace and absorbed the liquid.");
  1112.     prints("The being thanks you.");
  1113.     wa = 1;
  1114.     JunkObj( o_liquid );
  1115.   }
  1116. }
  1117.  
  1118. /*----------------------------*/
  1119. do_fill()
  1120. {
  1121.   if (cmd.nn==o_bottle)
  1122.   {
  1123.     if (curr_loc==obj[o_liquid].loc)
  1124.     {
  1125.       obj[o_liquid].loc = -8;
  1126.       ok();
  1127.     }
  1128.     else if (curr_loc==obj[o_fluid].loc)
  1129.       prints("The fluid flows in and then flows out by itself");
  1130.     else
  1131.       not_yet();
  1132.   }
  1133.  
  1134.   else
  1135.     how();
  1136. }
  1137.  
  1138. /*----------------------------*/
  1139. do_pour()
  1140. {
  1141.   if (cmd.nn==o_bottle || cmd.nn==o_liquid)
  1142.   {
  1143.     if (obj[o_liquid].loc!=-8)
  1144.       prints("Nothing to pour.");
  1145.  
  1146.     else if (curr_loc==obj[o_plant].loc)
  1147.     {
  1148.       cmd.nn=o_plant;
  1149.       do_water();
  1150.     }
  1151.  
  1152.     else
  1153.     {
  1154.       DropObj( o_liquid );
  1155.       ok();
  1156.     }
  1157.   }
  1158.  
  1159.   else
  1160.     not_work();
  1161. }
  1162.  
  1163. /*----------------------------*/
  1164. do_freeze()
  1165. {
  1166.   if (curr_loc!=obj[o_fluid].loc)
  1167.     not_yet();
  1168.  
  1169.   else if (cmd.nn==o_coil)
  1170.   {
  1171.     cc = cc | 1;
  1172.     ok();
  1173.   }
  1174.  
  1175.   else
  1176.     prints("You might damage it.");
  1177.  
  1178. }
  1179.  
  1180. /*----------------------------*/
  1181. do_melt()
  1182. {
  1183.   if (!ObjIsPresent(o_plasma))
  1184.     not_yet();
  1185.  
  1186.   else if (cmd.nn==o_solid)
  1187.   {
  1188.     prints("The plasma dissipates as the solid melts into a puddle of liquid.");
  1189.     JunkObj( o_plasma );
  1190.     JunkObj( o_solid );
  1191.     DropObj( o_liquid );
  1192.     if (curr_loc==obj[o_plant].loc)
  1193.     {
  1194.       cmd.nn=o_plant;
  1195.       do_water();
  1196.     }
  1197.   }
  1198.  
  1199.   else if (cmd.nn==o_tetra)
  1200.     prints("It melts, but quickly recrystalizes.");
  1201.  
  1202.   else
  1203.     not_work();
  1204. }
  1205.  
  1206. /*----------------------------*/
  1207. do_play()
  1208. {
  1209.   if (cmd.nn==o_cube)
  1210.     do_roll();
  1211.  
  1212.   else if (cmd.nn==o_disk)
  1213.     prints("You need something to play it.");
  1214.  
  1215.   else if (cmd.nn==o_proj)
  1216.     do_use();
  1217.  
  1218.   else
  1219.     not_happen();
  1220. }
  1221.  
  1222. /*----------------------------*/
  1223. do_insert()
  1224. {
  1225.   v_word noun;
  1226.   int nn;
  1227.  
  1228.   if (cmd.nn==o_sing)
  1229.   {
  1230.     nn = InputNoun( "Where? ", noun );
  1231.     if ( (!strcmp(noun,"groo") || !strcmp(noun,"band") || nn==o_audio)
  1232.          && ObjIsPresent(o_audio) )
  1233.     {
  1234.       af = 1;
  1235.       JunkObj( cmd.nn );
  1236.       prints("The singularity slides in with a click.");
  1237.     }
  1238.     else
  1239.       not_work();
  1240.   }
  1241.  
  1242.   else if (cmd.nn==o_disk)
  1243.   {
  1244.     nn = InputNoun( "Where? ", noun );
  1245.     if ( (!strcmp(noun,"slot") || nn==o_proj) && ObjIsPresent(o_proj) )
  1246.     {
  1247.       obj[cmd.nn].loc = -7;
  1248.       ok();
  1249.     }
  1250.     else
  1251.       not_work();
  1252.   }
  1253.  
  1254.   else
  1255.     not_work();
  1256. }
  1257.  
  1258. /*----------------------------*/
  1259. do_fix()
  1260. {
  1261.   if (cmd.nn==o_proj)
  1262.     prints("You don't know how to properly fix such a delicate instrument.");
  1263.  
  1264.   else
  1265.     prints("You don't know how.");
  1266. }
  1267.  
  1268. /*----------------------------*/
  1269. do__y_()
  1270. {
  1271.   if (!ObjIsPresent(o_appa))
  1272.     PrintMess( 7 );
  1273.  
  1274.   else switch ( cmd.nn )
  1275.   {
  1276.     case o_cube:
  1277.       if (dr<3)
  1278.         prints("You shouldn't do that yet.");
  1279.       else
  1280.       {
  1281.         prints("The hexahedron expands one dimension.");
  1282.         ReplaceObj( cmd.nn, o_solid );
  1283.       }
  1284.       break;
  1285.  
  1286.     case o_tetra:
  1287.       prints("It expands a dimension, but quickly collapses back.");
  1288.       break;
  1289.  
  1290.     case o_strip:
  1291.       prints("The moebius strip expands one dimension.");
  1292.       ReplaceObj( cmd.nn, o_bottle );
  1293.       break;
  1294.  
  1295.     case o_prism:
  1296.       prints("Object too unstable.");
  1297.       break;
  1298.  
  1299.     case o_bottle:
  1300.     case o_solid:
  1301.     case o_liquid:
  1302.       prints("Can't go any higher in this universe.");
  1303.       break;
  1304.  
  1305.     case o_appa:
  1306.       prints("Sorry, can't upgrade a product this way.");
  1307.       break;
  1308.  
  1309.     case o_plant:
  1310.       prints("The being is already high enough.");
  1311.       break;
  1312.  
  1313.     default:
  1314.       not_happen();
  1315.   }
  1316. }
  1317.  
  1318. /*----------------------------*/
  1319. do_prove()
  1320. {
  1321.   v_word noun;
  1322.   char *msg1;
  1323.   int nn;
  1324.  
  1325.   msg1 = "Somehow a contradiction keeps coming into the proof.";
  1326.  
  1327.   switch ( cmd.nn )
  1328.   {
  1329.     case o_lemma:
  1330.     case o_theorem:
  1331.     case o_axiom:
  1332.     case o_post:
  1333.       prints("It's already proven.");
  1334.       break;
  1335.  
  1336.     case o_supp:
  1337.       nn = InputNoun( "With what? ", noun );
  1338.       if (nn==o_post && ObjIsPresent(o_post))
  1339.       {
  1340.         if (ObjIsPresent(o_contra))
  1341.           prints( msg1 );
  1342.         else
  1343.         {
  1344.           prints("The postulate is now a lemma.");
  1345.           ReplaceObj( cmd.nn, o_lemma );
  1346.         }
  1347.       }
  1348.       else
  1349.         not_work();
  1350.       break;
  1351.  
  1352.     case o_hypo:
  1353.       nn = InputNoun( "With what? ", noun );
  1354.       if (nn==o_lemma && ObjIsPresent(o_lemma) && ObjIsPresent(o_axiom))
  1355.       {
  1356.         if (ObjIsPresent(o_contra))
  1357.           prints( msg1 );
  1358.         else
  1359.         {
  1360.           prints("The hypothesis is now a theorem.");
  1361.           ReplaceObj( cmd.nn, o_theorem );
  1362.           prints("Suddelnly, a hyper-spatial cliff passes by");
  1363.           prints("and the lemma leaps to its demise.");
  1364.           JunkObj( o_lemma );
  1365.         }
  1366.       }
  1367.       else
  1368.         prints("Hmmm, something seems to be missing from the proof.");
  1369.       break;
  1370.  
  1371.     case o_idea:
  1372.       prints("The idea developed into a contradiction.");
  1373.       ReplaceObj( cmd.nn, 52 );
  1374.       break;
  1375.  
  1376.     case o_contra:
  1377.       prints("You proved that the contradiction can't be proven.");
  1378.       break;
  1379.  
  1380.     default:
  1381.       not_poss();
  1382.   }
  1383. }
  1384.  
  1385. /*----------------------------*/
  1386. do_smell()
  1387. {
  1388.   prints("You smell nothing unusual.");
  1389. }
  1390.  
  1391. /*----------------------------*/
  1392. do_close()
  1393. {
  1394.   not_poss();
  1395. }
  1396.  
  1397. /*----------------------------*/
  1398. do_open()
  1399. {
  1400.   not_poss();
  1401. }
  1402.  
  1403. /*----------------------------*/
  1404. do_stop()
  1405. {
  1406.   if (!strcmp(cmd.sh_noun,"slee") || !strcmp(cmd.sh_noun,"drea"))
  1407.     do_wake();
  1408.  
  1409.   else if (!strcmp(cmd.sh_noun,"read"))
  1410.   {
  1411.     if (InBookWorld( curr_loc ))
  1412.     {
  1413.       goto_new_lev( 1 );
  1414.       print_room = 1;
  1415.       ok();
  1416.     }
  1417.     else
  1418.       prints("Reality is like a book that you can't stop reading.");
  1419.   }
  1420.   else
  1421.     not_work();
  1422. }
  1423.  
  1424. /*----------------------------*/
  1425. do_say()
  1426. {
  1427.   cprintf( "'%s'", cmd.noun ); nl();
  1428.   if (gp==0)
  1429.     not_happen();
  1430.  
  1431.   else
  1432.   {
  1433.     if (strcmp( cmd.noun,"tesseract" ))
  1434.       zap = 2; /* wrong password */
  1435.     else
  1436.       zap = 3; /* right password */
  1437.   }
  1438. }
  1439.  
  1440. /*----------------------------*/
  1441. do_quit()
  1442. {
  1443.   do_score();
  1444.   zap = 1;
  1445. }
  1446.  
  1447. /*----------------------------*/
  1448. do_help()
  1449. {
  1450.   if (cmd.nn>0)
  1451.     how();
  1452.  
  1453.   else if (curr_lev==2)
  1454.     prints("Use 'wake' to wake up from your dream.");
  1455.  
  1456.   else if (curr_lev==3)
  1457.     prints("Use 'stop reading' to stop reading the adventure.");
  1458.  
  1459.   else
  1460.     prints("Sorry, quasi-hyper-neo-mathematics is beyond me.");
  1461. }
  1462.  
  1463. /*----------------------------*/
  1464. do_listen()
  1465. {
  1466.   char *msg;
  1467.  
  1468.   msg = "Of Countless Tesseracts";
  1469.  
  1470.   if (curr_loc==19)
  1471.     prints("Sounds like radio waves from the Creation.");
  1472.  
  1473.   else if (curr_loc!=obj[o_plant].loc)
  1474.     prints("You hear nothing special.");
  1475.  
  1476.   else if (wa==0)
  1477.     prints("The being is whispering too softly.");
  1478.  
  1479.   else if (!WearingObj(o_audio))
  1480.     prints("You hear a harmonic song in a strange language.");
  1481.  
  1482.   else if (!af)
  1483.   {
  1484.     cprintf("You hear an %d-voiced fugue in a complex 1/f melody.", sum); nl();
  1485.     prints("But you are unable to follow even a single voice.");
  1486.   }
  1487.  
  1488.   else
  1489.   {
  1490.     cprintf("You hear the words: %s.", msg );  nl();
  1491.     mi = mi | 8;
  1492.   }
  1493. }
  1494.  
  1495. /*----------------------------*/
  1496. do_save()
  1497. {
  1498.   int i;
  1499.   FILE *f;
  1500.   char s[80];
  1501.  
  1502.   cprintf("Filename to save game to: ");
  1503.   gets( s );
  1504.   if (!*s) return;
  1505.  
  1506.   f=fopen(s,"w");
  1507.   if (f)
  1508.   {
  1509.     for ( i=1; i<MaxObjs; i++ )
  1510.       fprintf( f, "%d ", obj[i].loc );
  1511.  
  1512.     fprintf( f, "%d %d %d %d %d %d ",
  1513.       curr_lev, curr_loc,
  1514.       level_loc[1], level_loc[2], level_loc[3], sleep_lev );
  1515.  
  1516.     fprintf( f, "%d %d %d %d %d %d %d %d %d %d %d %d ",
  1517.       cc, wa, ep, dr, af, gp, mi, ti, kp, dc[0], dc[1], dc[2] );
  1518.  
  1519.     putc( '\n', f );
  1520.     fclose( f );
  1521.     prints("Game saved.");
  1522.   }
  1523.   else
  1524.   {
  1525.     cprintf("Unable to save game to %s", s); nl();
  1526.   }
  1527. }
  1528.  
  1529. /*----------------------------*/
  1530. do_load()
  1531. {
  1532.   int i;
  1533.   FILE *f;
  1534.   char s[80];
  1535.  
  1536.   cprintf("Filename to load game from: ");
  1537.   gets( s );
  1538.   if (!*s) return;
  1539.  
  1540.   f=fopen(s,"r");
  1541.   if (f)
  1542.   {
  1543.     for ( i=1; i<MaxObjs; i++ )
  1544.       fscanf( f, "%d ", &obj[i].loc );
  1545.  
  1546.     fscanf( f, "%d %d %d %d %d %d ",
  1547.       &curr_lev, &curr_loc,
  1548.       &level_loc[1], &level_loc[2], &level_loc[3], &sleep_lev );
  1549.  
  1550.     fscanf( f, "%d %d %d %d %d %d %d %d %d %d %d %d ",
  1551.       &cc, &wa, &ep, &dr, &af, &gp, &mi, &ti, &kp, &dc[0], &dc[1], &dc[2] );
  1552.  
  1553.     for ( sum=0, i=0; i<3; i++ )
  1554.       sum += dc[i];
  1555.  
  1556.     fclose( f );
  1557.     prints("Game loaded.");
  1558.     print_room = 1;
  1559.   }
  1560.   else
  1561.   {
  1562.     cprintf("Unable to load game from %s", s); nl();
  1563.   }
  1564. }
  1565.  
  1566. /*----------------------------*/
  1567. do_score()
  1568. {
  1569.   cprintf("You scored %d out of 15.", mi );  nl();
  1570. }
  1571.  
  1572. /*----------------------------*/
  1573. do_sleep()
  1574. {
  1575.   if (InDreamWorld( curr_loc ))
  1576.   {
  1577.     prints("A dream within a dream would have been quite poetic,");
  1578.     prints("But time did not allow for it.");
  1579.   }
  1580.  
  1581.   else if (ep==0)
  1582.     prints("You're not sleepy yet.");
  1583.  
  1584.   else
  1585.   {
  1586.     prints("As you sleep, you begin to have a strange dream ...");
  1587.     sleep_lev = curr_lev;
  1588.     goto_new_lev( 2 );
  1589.     print_room = 1;
  1590.   }
  1591. }
  1592.  
  1593. /*----------------------------*/
  1594. do_wake()
  1595. {
  1596.   if (cmd.nn!=o_math && cmd.nn>0)
  1597.     not_work();
  1598.  
  1599.   else if (!InDreamWorld( curr_loc ))
  1600.     prints("Reality is not a fragment of nightmares and dreams.");
  1601.  
  1602.   else if (cmd.nn!=o_math)
  1603.   {
  1604.     prints("Wow, that was some dream.");
  1605.     goto_new_lev( sleep_lev );
  1606.     print_room = 1;
  1607.   }
  1608.  
  1609.   else
  1610.   {
  1611.     if (!ObjInRoom(o_theorem))
  1612.       prints("He mumbles: bother me not, I'm contemplating the ultimate question");
  1613.     else
  1614.     {
  1615.       prints("He wakes up, looks at the theorem, an shouts:");
  1616.       prints("Eureka!  This proves that the universe doesn't exis...");
  1617.       goto_new_loc( 35 );
  1618.       print_room = 1;
  1619.       mi = mi | 4;
  1620.     }
  1621.   }
  1622. }
  1623.  
  1624. /*----------------------------*/
  1625. do_give()
  1626. {
  1627.   int nn;
  1628.   v_word noun;
  1629.  
  1630.   nn = InputNoun( "To whom? ", noun );
  1631.   if (!nn)
  1632.     not_work();
  1633.  
  1634.   else if (!ObjIsPresent(nn))
  1635.     not_yet();
  1636.  
  1637.   else if (nn==o_math)
  1638.   {
  1639.     if (cmd.nn==o_theorem)
  1640.     {
  1641.       DropObj( cmd.nn );
  1642.       cmd.nn=o_math;
  1643.       do_wake();
  1644.     }
  1645.     else
  1646.       prints("He mumbles: disturb me not with such unimportant things.");
  1647.   }
  1648.  
  1649.   else if (nn==o_plant)
  1650.   {
  1651.     if (cmd.nn==o_liquid)
  1652.       how();
  1653.     else if (cmd.nn==o_solid)
  1654.       prints("Plants don't eat solid nutrients.");
  1655.     else
  1656.       prints("The being doesn't need that.");
  1657.   }
  1658.  
  1659.   else
  1660.     not_work();
  1661. }
  1662.  
  1663. /*----------------------------*/
  1664. int stack_say( char *s )
  1665. {
  1666.   cprintf("Stack: ");
  1667.   if (*s) prints( s );
  1668.   return( 1 );
  1669. }
  1670.  
  1671. do_scan()
  1672. {
  1673.   char *s;
  1674.   int flag;
  1675.  
  1676.   s = "stack potential non-zero, pushing allowed.";
  1677.   flag = 0;
  1678.  
  1679.   if (!ObjOnPlayer(o_stack))
  1680.     PrintMess( 7 );
  1681.  
  1682.   else if (gp)
  1683.   {
  1684.     prints("Something has rendered the stack inoperative.");
  1685.     return;
  1686.   }
  1687.  
  1688.   else if (cmd.nn==0)
  1689.   {
  1690.     if (InMirrorWorld( curr_loc ) || InMathWorld( curr_loc ) ||
  1691.         InSpectralWorld( curr_loc ))
  1692.       flag = stack_say("stack level non-zero, popping allowed.");
  1693.  
  1694.     if (curr_loc<=3)
  1695.       flag = stack_say( s );
  1696.  
  1697.     if (curr_loc==18)
  1698.       flag = stack_say("magnetic field present.");
  1699.  
  1700.     if (curr_loc==obj[o_plant].loc)
  1701.       flag = stack_say("sonic harmony present.");
  1702.  
  1703.     if (curr_loc==16)
  1704.       flag = stack_say("field certainty probably not stable");
  1705.  
  1706.     if (!flag)
  1707.       stack_say("nothing special to report.");
  1708.   }
  1709.  
  1710.   else
  1711.   {
  1712.     stack_say( "" );
  1713.     switch ( cmd.nn )
  1714.     {
  1715.       case o_mirror:
  1716.       case o_crt:
  1717.       case o_hole:
  1718.         prints( s );
  1719.         break;
  1720.  
  1721.       case o_plant:
  1722.         cprintf("4-D.  ");
  1723.         if (!wa)
  1724.           prints("dehydrated.  weak audio output.");
  1725.         else
  1726.           prints("healthy.  strong audio output.");
  1727.         break;
  1728.  
  1729.       case o_stack:
  1730.         prints("Stack operational.");
  1731.         break;
  1732.  
  1733.       case o_audio:
  1734.         if (!af)
  1735.           prints("no filter.");
  1736.         else
  1737.           prints("filter active.");
  1738.         break;
  1739.  
  1740.       case o_pills:
  1741.         prints("edible.  barbiturate.");
  1742.         break;
  1743.  
  1744.       case o_fluid:
  1745.         prints("extremely cold.  superconductive.  superfluid.");
  1746.         break;
  1747.  
  1748.       case o_prism:
  1749.         prints("brittle.  light sensitive.");
  1750.         break;
  1751.  
  1752.       case o_coil:
  1753.         prints("composition = yttrium, barium, copper, oxygen.");
  1754.         if (cc)
  1755.         {
  1756.           cprintf("Stack: properties = ");
  1757.           if (cc & 1) cprintf("superconductive.  ");
  1758.           if (cc & 2) cprintf("magnetic.  ");
  1759.           if ((cc & 3)==3) cprintf("strong magnetic field present.");
  1760.           nl();
  1761.         }
  1762.         break;
  1763.  
  1764.       case o_plasma:
  1765.         prints("extremely hot.");
  1766.         break;
  1767.  
  1768.       case o_solid:
  1769.         prints("4-D.  solid.");
  1770.         break;
  1771.  
  1772.       case o_liquid:
  1773.         prints("4-D.  liquid.");
  1774.         break;
  1775.  
  1776.       case o_tetra:
  1777.         prints("color sensitive.  omni-stable.");
  1778.         break;
  1779.  
  1780.       default:
  1781.         prints("nothing special to report.");
  1782.         break;
  1783.  
  1784.     } /* switch */
  1785.   } /* else */
  1786. }
  1787.  
  1788. /*----------------------------*/
  1789. do_solve()
  1790. {
  1791.   int nn;
  1792.   v_word noun;
  1793.  
  1794.   if (cmd.nn==o_zeta)
  1795.   {
  1796.     nn = InputNoun("With what? ", noun );
  1797.     if (!nn)
  1798.       not_work();
  1799.  
  1800.     else if (!ObjIsPresent(nn))
  1801.       not_yet();
  1802.  
  1803.     else if (nn!=o_func)
  1804.       prints("Not difficult, although for someone like you it's too still hard.");
  1805.  
  1806.     else
  1807.     {
  1808.       prints("The function and the integral cancel out nicely");
  1809.       prints("and everything is reduced to a singularity.");
  1810.       ReplaceObj( cmd.nn, o_sing );
  1811.       JunkObj( o_func );
  1812.     }
  1813.   }
  1814.  
  1815.   else if (cmd.nn==o_func)
  1816.     prints("You are not really into great episodes of frustration.");
  1817.  
  1818.   else if (cmd.nn==o_improb)
  1819.     prints("It's improbable that you can solve it.");
  1820.  
  1821.   else
  1822.     not_work();
  1823. }
  1824.  
  1825. /*----------------------------*/
  1826. do_think()
  1827. {
  1828.   if (!InDreamWorld(curr_loc))
  1829.     prints("Therefore you are.");
  1830.  
  1831.   else if (curr_loc!=25)
  1832.     prints("This is not a good place to think.");
  1833.  
  1834.   else if (!ti)
  1835.   {
  1836.     prints("You thought of an idea.");
  1837.     CarryObj( o_idea );
  1838.     ti = 1;
  1839.   }
  1840.  
  1841.   else
  1842.     prints("You are out of ideas.");
  1843. }
  1844.  
  1845. /*----------------------------*/
  1846. do_burn()
  1847. {
  1848.   if (!ObjIsPresent(o_plasma))
  1849.     not_yet();
  1850.  
  1851.   else
  1852.     prints("Don't be a pyromaniac.");
  1853. }
  1854.  
  1855. /*----------------------------*/
  1856. do_evap()
  1857. {
  1858.   if (!ObjIsPresent(o_plasma))
  1859.     not_yet();
  1860.  
  1861.   else if (cmd.nn==o_fluid)
  1862.   {
  1863.     prints("The fluid evaporates.");
  1864.     JunkObj( cmd.nn );
  1865.   }
  1866.  
  1867.   else
  1868.     do_burn();
  1869. }
  1870.  
  1871. /*----------------------------*/
  1872. do_climb()
  1873. {
  1874.   if (cmd.nn==o_plant)
  1875.     prints("That isn't very polite, and besides, it's not a beanstalk.");
  1876.  
  1877.   else if (cmd.nn==o_mount)
  1878.     prints("There are no rivers on the mountain.");
  1879.  
  1880.   else
  1881.     not_poss();
  1882. }
  1883.  
  1884. /*----------------------------*/
  1885. do_cut()
  1886. {
  1887.   switch( cmd.nn )
  1888.   {
  1889.     case o_prism:
  1890.       prints("It's already pre-cut.");
  1891.       break;
  1892.  
  1893.     case o_tetra:
  1894.       prints("It is easily cut, but the cuts immediately reseal themselves.");
  1895.       break;
  1896.  
  1897.     case o_strip:
  1898.       prints("With some tricky cuts, you end up with a mobius strip again.");
  1899.       break;
  1900.  
  1901.     case o_bottle:
  1902.       prints("The bottle breaks into a mobius strip.");
  1903.       ReplaceObj( cmd.nn, o_strip );
  1904.       if (obj[o_liquid].loc==-8)
  1905.       {
  1906.         prints("The liquid in the bottle falls to the ground.");
  1907.         DropObj( o_liquid );
  1908.         if (curr_loc==obj[o_plant].loc)
  1909.         {
  1910.           cmd.nn=o_plant;
  1911.           do_water();
  1912.         }
  1913.       }
  1914.       break;
  1915.  
  1916.     case o_plant:
  1917.     case o_solid:
  1918.     case o_liquid:
  1919.       prints("Such low dimension cuts has no effect.");
  1920.       break;
  1921.  
  1922.     default:
  1923.       not_work();
  1924.   }
  1925. }
  1926.  
  1927. /*----------------------------*/
  1928. do_join()
  1929. {
  1930.   if (cmd.nn==o_group)
  1931.     prints("You're too finite.");
  1932.   else
  1933.     not_poss();
  1934. }
  1935.  
  1936. /*----------------------------*/
  1937. do_sing()
  1938. {
  1939.   if (curr_loc==obj[o_plant].loc)
  1940.     prints("Your singing can't possible compete with the hyper-melody.");
  1941.  
  1942.   else
  1943.     not_happen();
  1944. }
  1945.  
  1946. /*----------------------------*/
  1947. /*
  1948. */
  1949. DoCommand()
  1950. {
  1951.   if (cmd.vn<=6
  1952.       || (cmd.vn>=39 && cmd.vn<=48) || cmd.vn==50 || cmd.vn==52
  1953.       || cmd.vn==58 )
  1954.     goto branch; /* noun-less verbs */
  1955.  
  1956.   if (cmd.nn==0)     /* no noun given */
  1957.   {
  1958.     if (cmd.vn==11)  /* special case for cmd="look" */
  1959.       goto branch;
  1960.     else
  1961.     {
  1962.       cprintf("%s what?", cmd.verb ); nl();
  1963.       return;
  1964.     }
  1965.   }
  1966.  
  1967.   if (obj[cmd.nn].loc==-9)
  1968.   {
  1969.     prints("Be more specific in naming the object");
  1970.     return;
  1971.   }
  1972.  
  1973.   if (!ObjIsPresent(cmd.nn))
  1974.   {
  1975.     prints("That object is not here.");
  1976.     return;
  1977.   }
  1978.  
  1979. branch:
  1980.   switch ( cmd.vn )
  1981.   {
  1982.     case 1:
  1983.     case 2:
  1984.     case 3:
  1985.     case 4: do_dir(); break;
  1986.     case 5: do_inv(); break;
  1987.     case 6: do_go(); break;
  1988.     case 7: do_get(); break;
  1989.     case 8: do_drop(); break;
  1990.     case 9: do_throw(); break;
  1991.     case 10: do_break(); break;
  1992.     case 11: do_look(); break;
  1993.     case 12: do_read(); break;
  1994.     case 13: do_use(); break;
  1995.     case 14: do_touch(); break;
  1996.     case 15: do_swing(); break;
  1997.     case 16: do_rub(); break;
  1998.     case 17: do_push(); break;
  1999.     case 18: do_pop(); break;
  2000.     case 19: do_spin(); break;
  2001.     case 20: do_roll(); break;
  2002.     case 21: do_wear(); break;
  2003.     case 22: do_eat(); break;
  2004.     case 23: do_taste(); break;
  2005.     case 24: do_drink(); break;
  2006.     case 25: do_remove(); break;
  2007.     case 26: do_water(); break;
  2008.     case 27: do_fill(); break;
  2009.     case 28: do_pour(); break;
  2010.     case 29: do_freeze(); break;
  2011.     case 30: do_melt(); break;
  2012.     case 31: do_play(); break;
  2013.     case 32: do_insert(); break;
  2014.     case 33: do__y_(); break;
  2015.     case 34: do_prove(); break;
  2016.     case 35: do_fix(); break;
  2017.     case 36: do_smell(); break;
  2018.     case 37: do_close(); break;
  2019.     case 38: do_open();break;
  2020.     case 39: do_stop(); break;
  2021.     case 40: do_say(); break;
  2022.     case 41: do_quit(); break;
  2023.     case 42: do_help(); break;
  2024.     case 43: do_listen(); break;
  2025.     case 44: do_save(); break;
  2026.     case 45: do_load(); break;
  2027.     case 46: do_score(); break;
  2028.     case 47: do_sleep(); break;
  2029.     case 48: do_wake(); break;
  2030.     case 49: do_give(); break;
  2031.     case 50: do_scan(); break;
  2032.     case 51: do_solve(); break;
  2033.     case 52: do_think(); break;
  2034.     case 53: do_burn(); break;
  2035.     case 54: do_evap(); break;
  2036.     case 55: do_climb(); break;
  2037.     case 56: do_cut(); break;
  2038.     case 57: do_join(); break;
  2039.     case 58: do_sing(); break;
  2040.     default: cprintf( "I don't know how to %s.", cmd.verb );  nl();
  2041.   }
  2042. }
  2043.  
  2044. /*----------------------------*/
  2045. Ending( int n )
  2046. {
  2047.   switch ( n )
  2048.   {
  2049.     case 1:
  2050.       prints("Game Over");
  2051.       break;
  2052.  
  2053.     case 2:
  2054.       prints("Incorrect password.");
  2055.       prints("Self-destruct aborted.  Resuming Doomsday countdown.");
  2056.       prints("5\n4\n3\n2\n1\n\nEarth destro...");
  2057.       break;
  2058.  
  2059.     case 3:
  2060.       prints("Correct password.");
  2061.       prints("Self-destruct sequence completed.  Overriding Doomsday countdown.");
  2062.       prints("5\n4\n3\n2\n1\n\nKaboom...");
  2063.  
  2064.       if (!ObjIsPresent(24))
  2065.       {
  2066.         prints("The Doomsday complex is destroyed.\n");
  2067.         prints("You have given your life to save Earth.  Thank you.");
  2068.       }
  2069.       else
  2070.       {
  2071.         prints(
  2072.         "As the complex disintegrates around you, the stack, sensing your\n"
  2073.         "danger, overloads all it's circuits to regain a moment's control.\n"
  2074.         "With a final burst of energy, the stack implodes, projecting a\n"
  2075.         "stasis field around you that protects you from the destruction.\n"
  2076.         "...\n"
  2077.         "From the smoldering debris of the Doomsday complex you pick up the\n"
  2078.         "pieces of the stack and reflect on how as you risked your life to\n"
  2079.         "save Earth, the stack has given its own to save yours.  As you walk\n"
  2080.         "away, you solemnly swear to repair the stack, for the adventures that\n"
  2081.         "lie ahead.\n"
  2082.         );
  2083.       }
  2084.       break;
  2085.   }
  2086. }
  2087.  
  2088. /*----------------------------*/
  2089. /*
  2090. */
  2091. intro1()
  2092. {
  2093.   prints("               /*--------------/*       ------------------------------------");
  2094.   prints("             /  '            /  '        Beyond The Tesseract         V2.03 ");
  2095.   prints("           /   '|          /   '|                                           ");
  2096.   prints("        */----'---------*/    ' |        An abstract text adventure         ");
  2097.   prints("       '|    '  |      '|    '  |       ------------------------------------");
  2098.   prints("      ' |   '   |     ' |   '   |        This adventure is free software.   ");
  2099.   prints("     '  |  '   /*----'--|--'---/*        If you like this program, hate it, ");
  2100.   prints("    '   | '  /  '   '   | '  /  '        or really don't care at all, then  ");
  2101.   prints("   '    |' /   '   '    |' /   '         I would be happy to hear from you. ");
  2102.   prints("  '    /*/----'---'----/*/    '                                             ");
  2103.   prints(" '   /  '    '   '   /  '    '             David Lo                         ");
  2104.   prints("'  /   '|   '   '  /   '|   '              4516 Albert St.                  ");
  2105.   prints("*/----'----'----*/    ' |  '               Burnaby, B.C., Canada            ");
  2106.   prints("|    '  | '     |    '  | '                V5C 2G5                          ");
  2107.   prints("|   '   |'      |   '   |                  email c/o: dlo@idacom.cs.ubc.ca  ");
  2108.   prints("|  '   /*-------|--'---/*'                                                  ");
  2109.   prints("| '  /          | '  /                   Please share unmodified copies of  ");
  2110.   prints("|' /            |' /                     this adventure with everyone.      ");
  2111.   prints("*/--------------*/                      ------------------------------------");
  2112.   prints("                                         (C) 1990 David Lo                  ");
  2113. }
  2114.  
  2115. intro()
  2116. {
  2117.   int i,j,k;
  2118.  
  2119.   clrscr();
  2120.   intro1();
  2121.   prints("Press <Enter> to continue");
  2122.   i=get_enter();
  2123.   clrscr();
  2124.  
  2125.   prints("Scenario:");
  2126.   prints("  You have reached the final part of your mission.  You have gained access");
  2127.   prints("  to the complex, and all but the last procedure has been performed.  Now");
  2128.   prints("  comes a time of waiting, in which you must search for the hidden 12-word");
  2129.   prints("  message that will aid you at the final step.  But what choice will you");
  2130.   prints("  make when that time comes?");
  2131.  
  2132.   prints("");
  2133.   prints("Instructions:");
  2134.   prints("  This adventure recognizes the standard commands for moving (N,E,S,W),");
  2135.   prints("  taking inventory (I), maninpulating objects (GET, DROP, LOOK), and");
  2136.   prints("  saving games (SAVE, LOAD), as well as many others.  Use 2-word 'verb noun'");
  2137.   prints("  commands, such as 'use stack' or 'get all'.  Only the first four letters");
  2138.   prints("  of each word are significant.  The adventure recognizes about 200 words,");
  2139.   prints("  so if one word doesn't work, try another.");
  2140.  
  2141.   prints("");
  2142.   prints("Happy adventuring!");
  2143.   prints("");
  2144.  
  2145.   prints("Press <Enter> to begin");
  2146.   j=get_enter();
  2147.   clrscr();
  2148.   srand( i*i + j + k );
  2149. }
  2150.  
  2151. /*------------------------------------------------------------*/
  2152. main()
  2153. {
  2154.   int i, keep_playing;
  2155.  
  2156.   intro();
  2157.  
  2158.   do
  2159.   {
  2160.     InitAdv();
  2161.     clrscr(); gotoxy( 1,25 );
  2162.  
  2163.     do
  2164.     {
  2165.       gp = InComplex(curr_loc) && (mi==15);
  2166.  
  2167. #ifdef tty
  2168.       if (print_room)
  2169.       {
  2170.         PrintCurrRoom();
  2171.         print_room=0;
  2172.       }
  2173. #endif
  2174.  
  2175.       if (gp)
  2176.         prints("A voice echoes: audio link complete.  Enter password.");
  2177.  
  2178. #ifndef tty
  2179.       PrintCurrRoom();
  2180. #endif
  2181.  
  2182.       if (InDreamWorld( curr_loc ))
  2183.         printf("(sleeping) ");
  2184.       else if (InBookWorld( curr_loc ))
  2185.         printf("(reading) ");
  2186.  
  2187.       cprintf("Enter command: ");
  2188.       gets( cmd.cm );
  2189.       if (cmd.cm[0])
  2190.       {
  2191.         AnalyseCommand( &cmd );
  2192.         DoCommand();
  2193.         nl();
  2194.       }
  2195.     }
  2196.     while ( !zap );
  2197.  
  2198.     Ending( zap );
  2199.     nl();
  2200.     cprintf("Play again (y/n)? ");
  2201.     gets( cmd.cm );
  2202.     keep_playing = (tolower(cmd.cm[0])!='n');
  2203.     nl();
  2204.   }
  2205.   while ( keep_playing );
  2206.   clrscr();
  2207. }
  2208.