Beispiel #1
0
static int InitScreen( void )
/*===========================

    This routine selects the best video mode for a given adapter. */

{
    int                 mode;

    _getvideoconfig( &VC );
    switch( VC.adapter ) {
    case _VGA :
        mode = _VRES16COLOR;
    break;
    case _SVGA :
    mode = _SVRES256COLOR;
        break;
    case _MCGA :
        mode = _MRES256COLOR;
        break;
    case _EGA :
        if( VC.monitor == _MONO ) {
            mode = _ERESNOCOLOR;
        } else {
            mode = _ERESCOLOR;
        }
        break;
    case _CGA :
        mode = _MRES4COLOR;
        break;
    case _HERCULES :
        mode = _HERCMONO;
        break;
    default :
        return( 0 );          /* report insufficient hardware */
    }

    if( _setvideomode( mode ) == 0 ) {
        return( 0 );
    }
    mess_with_stride();
    _getvideoconfig( &VC );
    if( VC.numcolors < 4 ) {
        TextColour = 1;
        TextColour2 = 1;
        BorderColour = 1;
    } else {
        TextColour = 1;
        TextColour2 = 3;
        BorderColour = 2;
    }
    if( VC.adapter >= _MCGA ) {
        /* set up new colours */
        _remappalette( TextColour, 0x3f0000 );  /* light blue */
        _remappalette( TextColour2, 0x3f0000 ); /* light blue */
        _remappalette( BorderColour, _BLACK );  /* black      */
    }
    return( 1 );
}
Beispiel #2
0
void
main( int argc, char **argv )
   {
#if MS_CMDS
   struct videoconfig vc;
   short videomode;

   /* Save original foreground, background, and text position. */

   _getvideoconfig( &vc );
   oldfgd = _gettextcolor();
   oldbgd = _getbkcolor();

   if ( vc.mode != _TEXTC80 )
      {
      if ( _setvideomode( _TEXTC80 ) == 0 )
         {
	 _getvideoconfig( &vc );
	 prn_xprintf( stderr, "Failed to set color video mode\n" );
         }
      else
	 {
	 reset_mode = FALSE;
	 }
      }
   else
      {
      reset_mode = FALSE;
      }

#endif       /* MS_CMDS */

   bwb_init( argc, argv );

#if INTERACTIVE
   setjmp( mark );
#endif

   /* now set the number of colors available */

   * var_findnval( co, co->array_pos ) = (bnumber) vc.numcolors;

   /* main program loop */

   while( !feof( stdin ) )		/* condition !feof( stdin ) added in v1.11 */
      {
      bwb_mainloop();
      }

   }
Beispiel #3
0
static void _Radius( chartenv _WCI86FAR *env, short *xradius, short *yradius )
//=======================================================================

/*  Calculates the x and y radii.   */

{
    short               x1, y1;
    short               x2, y2;
    float               width;
    float               height;
    float               adj_height;
    struct videoconfig  vc;

    _getvideoconfig( &vc );
    x1 = env->datawindow.x1;
    x2 = env->datawindow.x2;
    y1 = env->datawindow.y1;
    y2 = env->datawindow.y2;
    if( env->chartstyle == _PG_PERCENT ) {      // leave room for labels
        x1 += 7 * _CharWidth;
        x2 -= 7 * _CharWidth;
        y1 += 3 * _CharHeight;
        y2 -= 3 * _CharHeight;
    }
    width = 0.9f * ( x2 - x1 );
    height = 0.9f * ( y2 - y1 );
    adj_height = width * ( 4 * vc.numypixels ) / ( 3 * vc.numxpixels );
    if( adj_height > height ) {
        width = height * ( 3 * vc.numxpixels ) / ( 4 * vc.numypixels );
    } else {
        height = adj_height;
    }
    *xradius = width / 2;
    *yradius = height / 2;
}
Beispiel #4
0
int main( int argc, char *argv[] )
//================================

//  Initialize graphics library and presentation graphics
//  system and then display several sample charts.

{
    int                 mode;

    if( argc == 2 ) {
        mode = atoi( argv[ 1 ] );
    } else {
        mode = _MAXRESMODE;
    }
    if( _setvideomode( mode ) == 0 ) {
        puts( "Cannot initialize video mode" );
        return( 1 );
    }
    _getvideoconfig( &vconfig );
    xmax = vconfig.numxpixels;
    ymax = vconfig.numypixels;
    xmid = xmax / 2;
    ymid = ymax / 2;
    _pg_initchart();
    simple_chart();
    press_key();
    _clearscreen( _GCLEARSCREEN );
    more_charts();
    press_key();
    _clearscreen( _GCLEARSCREEN );
    scatter_charts();
    press_key();
    _setvideomode( _DEFAULTMODE );
    return( 0 );
}
Beispiel #5
0
void main()
{   // initialize an organism, and then begin evolution
    // initialize video mode
    _setvideomode(_MAXRESMODE);
    _getvideoconfig(&vc);

    // set the special memory handler
    _set_new_handler(free_memory);

    // seed random number generator
    srand((unsigned)time(NULL));

    //CFile treeFile;
    //if (treeFile.Open("TREE.DAT", CFile::modeRead))
    //{   // file exists, so deserialize
    //CArchive treeArc(&treeFile, CArchive::load);
    //FoundingFather.Serialize(treeArc);
    //treeArc.Close();
    //treeFile.Close();
    //};  // if

    //FoundingFather.Dump(afxDump);
    FoundingFather.evolve();

    //if (treeFile.Open("TREE.DAT", CFile::modeCreate | CFile::modeWrite))
    //{   // now serialize the family tree
    //CArchive treeArc(&treeFile, CArchive::store);
    //FoundingFather.Serialize(treeArc);
    //treeArc.Close();
    //treeFile.Close();
    //};  // if

    _clearscreen(_GCLEARSCREEN);
    _setvideomode(_TEXTC80);
};  // void main()
Beispiel #6
0
Datei: main.c Projekt: badcodes/c
int main(int argc,char** argv) {
    int old_apage;
    int old_vpage;
    int new_apage;
    int new_vpage;
    struct videoconfig vc;
    int ret;
    if(argc==1) {
        cputs("用法:\n\tcread 文件名\n");
        return 0;
    }

//    set_video_mode(&vc);

//    ROWS=_setvideomoderows(_TEXTC80,_MAXTEXTROWS);
    _getvideoconfig(&vc);
    ROWS = vc.numtextrows;
    COLS = vc.numtextcols;

    old_apage = _getactivepage();
    old_vpage = _getvisualpage();
    if(vc.numvideopages>1) {
        if(old_apage >=1) {
            new_apage = 0;
        }
        else {
            new_apage = 1;
        }
    }
    else {
        new_apage = old_apage;
    }

    if(old_apage != new_apage) {
        _setvisualpage(new_apage);
        _setactivepage(new_apage);
        _clearscreen(_GCLEARSCREEN);
    }

    print_videoconfig(&vc);
    OUT_PRINTF_BEGIN
        "old_visualpage=%d\nold_active_page=%d\n",
        old_vpage,
        old_apage
    OUT_PRINTF_END
    new_vpage = _getvisualpage();
    new_apage = _getactivepage();
    OUT_PRINTF_BEGIN
        "new_visualpage=%d\nnew_active_page=%d\n",
        new_vpage,
        new_apage
    OUT_PRINTF_END

    ret = process(argc,argv); 

    _setactivepage(old_apage);
    _setvisualpage(old_vpage);
//  _setvideomode( _DEFAULTMODE );
    return ret;
}
Beispiel #7
0
Datei: main.c Projekt: badcodes/c
void set_video_mode(struct videoconfig* out) {
    int mode;
    struct videoconfig vc;
    _getvideoconfig( &vc );
    switch( vc.adapter ) {
    case _VGA :
    case _SVGA :
        mode = _VRES16COLOR;
        break;
    case _MCGA :
        mode = _MRES256COLOR;
        break;
    case _EGA :
        if( vc.monitor == _MONO ) {
            mode = _ERESNOCOLOR;
        } else {
            mode = _ERESCOLOR;
        }
        break;
    case _CGA :
        mode = _MRES4COLOR;
        break;
    case _HERCULES :
        mode = _HERCMONO;
        break;
    default :
        mode = -1;
        cputs( "No graphics adapter\n" );
        break;
    }
    if(mode == -1) {
        _getvideoconfig(out);
    }
    else if(_setvideomode( mode ) ) {
        _getvideoconfig( out );
    }
}
Beispiel #8
0
void Do_Demo2( short mode )
/*=========================

    This program draws bar and pie graphs for the
    data specified above. */

{
    if( !_setvideomode( mode ) ) return;
    _getvideoconfig( &VC ); /* fill videoconfig structure */
    TitleColour = ( VC.numcolors - 1 ) % 16;
    Title();
    BarGraph();
    PieGraph();
    Press_any_key();
}