home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 7 Games / 07-Games.zip / MVTREK.ZIP / MAIN.C < prev    next >
Text File  |  1990-06-04  |  4KB  |  170 lines

  1. /*
  2.  *    main.c
  3.  *
  4.  *    visual star trek
  5.  *
  6.  *    BASIC version written by Tom Goerz and debugged by Dug Patrick
  7.  *        22-Dec-79, 13-Nov-80
  8.  *    C version written by Dug Patrick
  9.  *        05-Aug-84, 11-Mar-85
  10.  *
  11.  */
  12.  
  13. #include "vtrek.h"
  14. #include <os2.h>
  15.  
  16. char playership[] = " ? ";
  17. int rolines = 0;
  18.  
  19. main()
  20. {
  21.     int cmd, ch;
  22.     char str[44];
  23.  
  24. #ifdef AZTEC
  25.     int errortrap();
  26.     Sysvec[FLT_FAULT] = errortrap;
  27. #endif
  28.  
  29.         fflush(stdout);
  30.         cls();
  31.         fflush(stdout);
  32. printf("Welcome to ANSI VTREK!  This program was adopted from a UNIX based SYSTEM\n\r");
  33. printf("and ported to OS/2.  Additional modifications to the code in order to allow\n\r");
  34. printf("VTREK to run under the MAXIMUS BBS SYSTEM was developed and put into place\n\r");
  35. printf("by Steve Lesner.  It uses the MAXPIPE program written by Peter Fitzsimmons.\n\r");
  36. printf("\n\r");
  37. printf("The best way to get familiar with this program is to read the Instructions\n\r");
  38. printf("at least ONCE!  If you get loss anytime and forgot how to QUIT, REMEMBER\n\r");
  39. printf("that typing 'K' will kill your ship and quit the game and return to the BBS!\n\r");
  40. printf("\n\r");
  41.  
  42.         fflush(stdout);
  43.         printf("Do you have Ansi Graphics ON <Y/n> ? ");
  44.         fflush(stdout);
  45.         ch = getchar();
  46.         fflush(stdout);
  47.         fflush(stdin);
  48.         if (Toupper(ch) == 'N')
  49.             exit(1);
  50.         printf("\n\r");
  51.         fflush(stdout);
  52.         instructions();
  53.         fflush(stdout);
  54.     initvars();
  55.         fflush(stdout);
  56.     terminit();
  57.         fflush(stdout);
  58.     replot();
  59.  
  60.         fflush(stdout);
  61.     sprintf(str, "You have %.1f stardates to save the", lastdate - stardate);
  62.         fflush(stdout);
  63.     readout(ADDLINE, str);
  64.         fflush(stdout);
  65.     readout(ADDLINE, "Federation from the Klingon invasion.");
  66.  
  67.         fflush(stdout);
  68.     setcondition();
  69.  
  70.     while (numkling > 0) {
  71.             fflush(stdout);
  72.         switch (cmd = getcmd()) {
  73.  
  74.         case 'H' :        /* hyper-space */
  75.         hyperspace();
  76.         break;
  77.  
  78.         case 'S' :        /* short range scan */
  79.         srs();
  80.         break;
  81.  
  82.         case 'L' :        /* long range scan */
  83.         lrs();
  84.         break;
  85.  
  86.         case 'P' :        /* fire phasers */
  87.         phasers();
  88.         break;
  89.  
  90.         case 'T' :        /* fire photon torpedo */
  91.         torpedo();
  92.         break;
  93.  
  94.         case 'U' :        /* change shield level */
  95.         defense();
  96.         break;    
  97.  
  98.         case 'R' :        /* replot screen */
  99.         replot();
  100.         continue;
  101.  
  102.         case 'Q' :        /* move using impulse engines */
  103.         case 'W' :
  104.         case 'E' :
  105.         case 'A' :
  106.         case 'D' :
  107.         case 'Z' :
  108.         case 'X' :
  109.         case 'C' :
  110.         impulse(cmd);
  111.         break;
  112.  
  113.             case 'K' :          /* kill - commit suicide */
  114.                 fflush(stdout);
  115.                 prompt("Quit <y/N> ? ");
  116.                 fflush(stdout);
  117.                 ch = getchar();
  118.                 fflush(stdout);
  119.                 fflush(stdin);
  120.         if (Toupper(ch) == 'Y')
  121.             die();
  122.         break;
  123.  
  124.         case 'F' :        /* fix devices */
  125.         repdevices();
  126.         break;
  127.  
  128.         case 03 :        /* exit without warning */
  129.         case 04 :
  130.         die();
  131.         break;
  132.  
  133.         case '?' :        /* help */
  134.         help();
  135.                 fflush(stdout);
  136.                 readout(ADDLINE, "K = Kill & Quit      (Press RETURN)");
  137.                 ch = getchar();
  138.                 fflush(stdout);
  139.                 fflush(stdin);
  140.         break;
  141.  
  142.         default :        /* illegal command */
  143.         readout(ADDLINE, "Type '?' for help.");
  144.         break;
  145.         }
  146.  
  147.         fixdev(REL, RND, 5);
  148.         setcondition();
  149.         klingmove();
  150.  
  151.         if ((stardate += 0.1) > lastdate)
  152.         timeout();
  153.         plt_stat(ELEMENT, STARDATE);
  154.         plt_num(INFO);
  155.  
  156.         if (energy <= 0 && shields <= 0)
  157.         dead();
  158.     }
  159.  
  160.     win();
  161. }
  162.  
  163. #ifdef AZTEC
  164. errortrap(errcode, addr)
  165. int errcode, addr;
  166. {
  167. }
  168. #endif
  169. 
  170.