/*
 * G B A S I C S
 *
 * Demonstrate the four basic steps
 * in Learn C graphics programming.
 *
 */

#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
#include <graph.h>
#include <math.h>

#define MODE_ERR        0

int
main(void)
{
	struct videoconfig vidconfig;   /* video configuration data */
	short x_org, y_org;             /* logical origin */


	/*----- Step 1: Set the Video mode -----*/

	/*
	 * Try to set a medium resolution color mode.
	 */
	if (_setvideomode(_MRES16COLOR) == MODE_ERR)
		if (_setvideomode(_MRES4COLOR) == MODE_ERR) {
			fprintf(stderr,
				"No medium res color support\n");
			exit (1);
		}


	/*-- Step 2: Get the Video Configuration Parameters --*/

	/*
	 * Update video configuration members of
	 * vidconfig structure.
	 */
	_getvideoconfig(&vidconfig);


	/*----- Step 3: Your Program Application -----*/

	/*
	 * Display information about the current video configuration.
	 */
	switch (vidconfig.mode) {
	case _MRES16COLOR:
		puts("Nice -- graphics and 16 colors, too!");
		break;
	case _MRES4COLOR:
		puts("Tough break -- only four colors.");
		break;
	default:
		/* huh? */
		break;
	}

	/*
	 * Halt and wait for a keypress.
	 */
	fprintf(stderr, "\n\tPress a key...");
	if (getch() == '\0')
		getch();


	/*----- Step 4: Restore the Original Video Environment -----*/

	/*
	 * Restore the original video mode and
	 * return control to the operating system.
	 */
	_setvideomode(_DEFAULTMODE);
	return (0);
}
