home *** CD-ROM | disk | FTP | other *** search
/ YPA: Your Privacy Assured / YPA.ISO / other_goodies / games / fiveinline.lha / FiveInLine / Source / main.c < prev    next >
C/C++ Source or Header  |  1994-04-22  |  3KB  |  131 lines

  1. #include <exec/exec.h>
  2. #include <proto/exec.h>
  3.  
  4. #include <intuition/intuition.h>
  5. #include <intuition/gadgetclass.h>
  6. #include <proto/intuition.h>
  7.  
  8. #include <libraries/gadtools.h>
  9. #include <proto/gadtools.h>
  10.  
  11. #include <stdio.h>
  12. #include <dos.h>
  13. #include <string.h>
  14.  
  15. #include "fil.h"
  16.  
  17. UBYTE *version = "$VER: FiveInLine 2.2 21.04.94\n";
  18.  
  19. struct ReqToolsBase    *ReqToolsBase = NULL;
  20. APTR                VisualInfo = NULL;
  21. struct Screen        *Scr = NULL;
  22. struct Window        *mwWnd = NULL;
  23. struct Menu            *mwMenus = NULL;
  24. BOOL                startplayer = NULL;
  25. UBYTE                currentplayer = NULL;
  26. UWORD                offx = 0;
  27. UWORD                offy = 0;
  28. int                    boardsize = 15;
  29.  
  30. int main ( int argc, char *argv[] )
  31. {
  32.     BOOL    terminated = FALSE;
  33.     BOOL    running;
  34.     FLOAT    playlevel = LEVEL5;
  35.     int        amiga_old_row;
  36.     int        amiga_old_col = 0;
  37.     int        i;
  38.     char    *p;
  39.     char    beginyesno [ 3 ];
  40.     int        level;
  41.  
  42.     if ( argc == 0 ) {
  43.         argc = _WBArgc;
  44.         argv = _WBArgv;
  45.     }
  46.     
  47.     for ( i = 1; i < argc; i ++ ) {
  48.         if ( strnicmp ( argv [ i ], "BoardSize", 9) == 0) {
  49.             p = strchr ( argv [ i ], '=' );
  50.             p ++;
  51.             sscanf ( p, "%d", &boardsize );
  52.             if ( boardsize < 11 ) boardsize = 11;
  53.             else if ( boardsize > 31 ) boardsize = 31;
  54.         }
  55.         else if ( strnicmp ( argv [ i ], "UserBegins", 9) == 0) {
  56.             p = strchr ( argv [ i ], '=' );
  57.             p ++;
  58.             sscanf ( p, "%2s", &beginyesno );
  59.             if ( strnicmp ( beginyesno, "No", 2) == 0) {
  60.                 startplayer = FALSE;
  61.                 currentplayer = AMIGA;
  62.             }
  63.             else {
  64.                 startplayer = TRUE;
  65.                 currentplayer = HUMAN;
  66.             }
  67.         }
  68.         else if ( strnicmp ( argv [ i ], "PlayLevel", 9) == 0) {
  69.             p = strchr ( argv [ i ], '=' );
  70.             p ++;
  71.             sscanf ( p, "%d", &level );
  72.             switch ( level ) {
  73.                 case ( 1 ): 
  74.                     playlevel = LEVEL1;
  75.                     break;
  76.                 case ( 2 ): 
  77.                     playlevel = LEVEL2;
  78.                     break;
  79.                 case ( 3 ): 
  80.                     playlevel = LEVEL3;
  81.                     break;
  82.                 case ( 4 ): 
  83.                     playlevel = LEVEL4;
  84.                     break;
  85.                 case ( 5 ): 
  86.                     playlevel = LEVEL5;
  87.                     break;
  88.             }
  89.         }
  90.     }
  91.  
  92.     openreqtools ();
  93.     if ( ReqToolsBase != NULL ) {
  94.         if ( setupscreen () != NULL ) {
  95.             printf ( "Unable to access workbench screen.\n" );
  96.             return ( 10 );
  97.         }
  98.         else {    
  99.             if ( currentplayer == NULL ) startplayer = reqbegin ();
  100.  
  101.             if ( setupwindow () != NULL ) {
  102.                 printf ( "Unable to open window.\n" );
  103.                 return ( 10 );
  104.             }
  105.             else {
  106.             
  107.                 while ( ! terminated ) {
  108.                     running = initnewgame ();
  109.                     amiga_old_row = -1;
  110.  
  111.                     while ( running ) {
  112.                         if ( currentplayer == HUMAN ) {
  113.                             running = checkdrawgame ();
  114.                             if ( running ) 
  115.                                 running = handleidcmp ( &amiga_old_row, amiga_old_col, &terminated, &playlevel );
  116.                         }
  117.                         else {
  118.                             running = checkdrawgame ();
  119.                             if ( running )
  120.                                 running = amigamove ( &amiga_old_row, &amiga_old_col, playlevel );
  121.                         }
  122.                     }
  123.                     currentplayer = NULL;
  124.                 }
  125.             }            
  126.             closedownscreen ();
  127.         }
  128.     }
  129.     closereqtools ();
  130. }
  131.