File:  [OS/2 SDKs] / os2sdk / demos / apps / setega / setega.c
Revision 1.1.1.2 (vendor branch): download - view: text, annotated - select for diffs
Thu Aug 9 12:26:06 2018 UTC (7 years, 9 months ago) by root
Branches: msft, MAIN
CVS tags: os2sdk-1988, HEAD
Microsoft OS/2 SDK 03-01-1988

 /*  Created by Microsoft Corp. 1987
 */
 /*** SETEGA.C	OS/2 demo program to switch EGA between 25- and 43- line modes
  *
  *   SETEGA accepts one parameter, which must be either "25" or "43".
  *   Too few or too many parameters, or a parameter other than the two
  *   specified above, will result in an error message and termination
  *   with no action taken.
  *
  *   This program will work only on machines equipped with a standard EGA.
  *
  *   SETEGA functions as follows:
  *
  *	 1) Check parameters
  *
  *	 2) Clear the screen, using the VioScrollUp function as described
  *	    in the CLRSCR example elsewhere in these bulletin boards
  *
  *	 3) Get current mode information using VioGetMode
  *
  *		 USHORT APIENTRY VioGetMode (
  *			PVIOMODEINFO,
  *			HVIO );
  *
  *	    This call fills a data structure of type
  *
  *		 struct VIOMODEINFO {
  *			USHORT cb;
  *			UCHAR  fbType;
  *			UCHAR  color;
  *			USHORT col;
  *			USHORT row;
  *			USHORT hres;
  *			USHORT vres;
			UCHAR  fmt_ID;
			UCHAR  attrib;
  *			};
  *
  *	    whose address we pass in the first parameter. The second
  *	    parameter is the VIO handle, a reserved word of zeros.
  *
  *	 4) We leave all these fields as they are except "row", the number
  *	    of alphanumeric rows for this mode. This is changed to the
  *	    value specified in our parameter.
  *
  *	 5) VioSetMode is now used to set the mode.
  *
  *		 USHORT APIENTRY VioSetMode (
  *			PVIOMODEINFO,
  *			HVIO );
  *
  *	    This call has the same parameters as VioGetMode.
  *	    We are now set to the desired mode.
  *
  *	 6) We then set the cursor to an appropriate size and shape. This is
  *	    done by filling in a structure of the type
  *
  *		 struct VIOSURSORINFO {
  *			USHORT yStart;
  *			USHORT cEnd;
  *			USHORT cx;
  *			USHORT attr;
  *			};
  *
  *	    with appropriate values, then calling VioSetCurType
  *
  *		 USHORT APIENTRY VioSetCurType (
  *			PVIOCURSORINFO,
  *			HVIO );
  *
  *	    where the second parameter is again the VIO handle, 0.
  *
  *	 7) Last, we set the cursor to the upper left hand corner of the
  *	    screen using VioSetCurPos.
  *
  *
  *   Compile using the -Lp option; this program may be bound for use under
  *   real mode.
  */

#define INCL_SUB

#include <os2def.h>
#include <bsesub.h>
#include <stdio.h>

void usage();

void main( argc, argv )
int  argc;
char *argv[];
{

    VIOMODEINFO modedata;

    VIOCURSORINFO cursordata;

    static char  buffer[2] = { 0x20, 0x07 };	 /* scrolling fill character */
						 /* for clearing the screen  */
    if( argc != 2 )
	usage(argv[0]);

    switch(atoi(argv[1])) {
	case 43:
	    VioScrollUp( 0, 0, -1, -1, -1, (char far *)buffer, 0 );
	    modedata.cb = sizeof( modedata );
	    VioGetMode( &modedata, 0 );
	    modedata.row = 43;
	    VioSetMode( &modedata, 0 );
	    cursordata.yStart = 7;
	    cursordata.cEnd = 7;
	    cursordata.cx = 1;
	    cursordata.attr = 0;
	    VioSetCurType( &cursordata, 0 );
	    VioSetCurPos( 0, 0, 0 );
	break;
	
	case 25:
	    VioScrollUp( 0, 0, -1, -1, -1, (char far *)buffer, 0 );
	    modedata.cb = sizeof( modedata );
	    VioGetMode( &modedata, 0 );
	    modedata.row = 25;
	    VioSetMode( &modedata, 0 );
	    cursordata.yStart = 12;
	    cursordata.cEnd = 13;
	    cursordata.cx = 1;
	    cursordata.attr = 0;
	    VioSetCurType( &cursordata, 0 );
	    VioSetCurPos( 0, 0, 0 );
	break;

	default:
	    usage(argv[0]);
	}
	exit(0);
}

void
usage(p)
char *p;
{
    printf( "usage: %s 25|43\n", p);
    exit(1);
}

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.