home *** CD-ROM | disk | FTP | other *** search
/ 1,000 Games / Disc2.iso / MIND / WAKTAK / SCRN2.C < prev    next >
C/C++ Source or Header  |  1996-04-05  |  5KB  |  145 lines

  1. /**************************************************************************/
  2. /*                                                                        */
  3. /*                                  SCRN2.C                               */
  4. /*                          Parameter Entry Screen                        */
  5. /*                                (text mode)                             */
  6. /*                                                                        */
  7. /**************************************************************************/
  8.  
  9. #include <stdio.h>
  10. #include <string.h>
  11. #include <conio.h>
  12. #include <stdlib.h>
  13. #include "scrn2.h"
  14.  
  15. struct Parameters param_screen()
  16. {
  17.    char ans    [ANSWERLEN],
  18.         minstr [ANSWERLEN];
  19.    struct Parameters params;
  20.  
  21.       clrscr();
  22.       textbackground( H_COL );
  23.       textcolor( HTEXT_COL );
  24.       cprintf( TOP_MESSAGE );
  25.  
  26.       textbackground( BACKGROUND_COL );
  27.       textcolor( TEXT_COL );
  28.       printf( "\n" );
  29.       cprintf( "Name of word file to use (default is %s)? ", DEFAULTSTRF );
  30.       gets( params.filename );
  31.       if( !strlen( params.filename ) )
  32.            strcpy( params.filename, DEFAULTSTRF );
  33.       PRINT_STRIPE;
  34.       
  35.       textbackground( BACKGROUND_COL );
  36.       cprintf( "Maximum time for this run, in minutes (default is %s)? ",
  37.                DEFAULTSTRT );
  38.       gets( ans );
  39.       if( !strlen( ans ) )
  40.           params.maxtime = DEFAULTTIME;
  41.       else
  42.          params.maxtime = atoi( ans ) * SEC_PER_MIN;
  43.       if( params.maxtime < MINTIME )
  44.           params.maxtime = MINTIME;
  45.       PRINT_STRIPE;
  46.  
  47.       textbackground( BACKGROUND_COL );
  48.       cprintf( "Maximum number of words to display (default is %d)? ",
  49.                 DEFAULTWORDS );
  50.       gets( ans );
  51.       if( !strlen( ans ) )
  52.           params.maxwords = DEFAULTWORDS; 
  53.       else
  54.           params.maxwords = atoi( ans );
  55.       if( params.maxwords < MINWORDS )
  56.           params.maxwords = MINWORDS;
  57.       PRINT_STRIPE;
  58.       
  59.  
  60.       textbackground( BACKGROUND_COL );
  61.       cprintf( "Display frequency in \"speed units\" (default is %3.2f)? ",
  62.                 DEFAULTFREQ );
  63.       gets( ans );
  64.       if( !strlen( ans ) )
  65.           params.frequency = DEFAULTFREQ; 
  66.       else
  67.           params.frequency = atof( ans );
  68.       if( params.frequency < MINFREQ )
  69.           params.frequency = MINFREQ;
  70.       if( params.frequency > MAXFREQ )
  71.           params.frequency = MAXFREQ;
  72.       PRINT_STRIPE;
  73.  
  74.       textbackground( BACKGROUND_COL );
  75.       cprintf(
  76.       "Do you wish to skip the next screen and start immediately (default is NO)? " );
  77.       gets( ans );
  78.       if( *ans == 'y' || *ans == 'Y' )
  79.           params.cdnscr = OFF;
  80.       else
  81.           params.cdnscr = ON;
  82.       PRINT_STRIPE;
  83.  
  84.      /************************************/
  85.  
  86.       textbackground( BACKGROUND_COL );
  87.       textcolor( TEXT_COL2 );
  88.       cprintf( "\n\n" );
  89.       cprintf( "The parameters for this round are the following:" );
  90.       printf( "\n\nWord file to use is %s.\n", strupr( params.filename ) );
  91.  
  92.       if( params.maxtime == 1 * SEC_PER_MIN ) 
  93.           strcpy( minstr, "minute" );
  94.       else
  95.           strcpy( minstr, "minutes" );
  96.       printf( "Maximum time limit = %d %s.",
  97.                params.maxtime / SEC_PER_MIN, minstr );
  98.  
  99.       printf( "\nMaximum number of words to display = %d.", params.maxwords );
  100.  
  101.       printf( "\nRequested display frequency = %1.2f \"speed units\".",
  102.                params.frequency );
  103.       printf( "\nSelected  display frequency = %1.2f \"speed units\".",
  104.              FF / (int)(FF/params.frequency) );
  105.       textcolor( TEXT_COL3 ); //White
  106.       highvideo(); //HIGH INTENSITY
  107.       cprintf(
  108.       "                               Note: \"Speed units\" correspond to words/sec. at lower frequencies only." );
  109.       normvideo(); //NORMAL
  110.  
  111.  
  112. /*****************************final***************************************/
  113.  
  114.       textbackground( BACKGROUND_COL );
  115.       textcolor( TEXT_COL_FINAL );
  116.       _setcursortype( _NOCURSOR );     //Make cursor go away.
  117.       cprintf( "\n\n" );
  118.       cprintf( "                                     " );
  119.       cprintf( "Press a key to continue." );
  120.       getch( );
  121.       _setcursortype( _NORMALCURSOR ); //Hello, again, Mr. Cursor.
  122.  
  123.  
  124. /***************************************************************************/
  125.  
  126.       return( params );
  127.  
  128. }
  129.  
  130. struct Parameters set_defaults()
  131. {
  132.    struct Parameters DefaultParams;
  133.  
  134.       /* Initialize to default values defined in scrn2.h */
  135.       /****************************************************/
  136.       strcpy( DefaultParams.filename, DEFAULTSTRF );
  137.       DefaultParams.maxtime = DEFAULTTIME;
  138.       DefaultParams.maxwords = DEFAULTWORDS;
  139.       DefaultParams.frequency = DEFAULTFREQ;
  140.       DefaultParams.cdnscr = OFF;
  141.       /***************************************************/
  142.  
  143.       return( DefaultParams );
  144. }
  145.