/*
	
*/

#use engfontl.lib
#use engfnt2l.lib
#use vdriver.lib
#use op71l.lib						//	specify underlying LCD
#use op71hw.lib						//	specify high level graphics library

xdata xLocalBM[4096];

main() {
	auto struct _fontInfo fi, bigFi;	//	declare struct to hold font information
	auto unsigned x,y,z;
	auto unsigned long timeMark;

	outport(DCNTL,(inport(DCNTL)&0xf)|0x60);	//	setup 2 I/O wait and 1 mem wait states
	VdInit();
	glInit();		//	initialize the software and hardware modules

	op71BackLight(1);

	op71SetContrast(35);
	
	//	the following call is possible only for Deluxe versions of the
	//	compiler because it relies on the "xdata" construct to place
	//	the font bitmap in xmem

	glBlankScreen();		//	blank the screen

	glXFontInit(	//	initialize the font info structure needed later
		&fi,			//	pointer to the font info structure to fill
		6,				//	horizontal size (in pixels) of each character
		8,				//	vertical size (in pixels) of each character
		32,			//	beginning code of printable characters
		255,			//	ending code of printable characters
		engFont6x8	//	address of font bitmap in xmem
		);
		
	glXFontInit(	//	initialize the font info structure needed later
		&bigFi,		//	pointer to the font info structure to fill
		17,				//	horizontal size (in pixels) of each character
		35,				//	vertical size (in pixels) of each character
		32,			//	beginning code of printable characters
		127,			//	ending code of printable characters
		engFont17x35a	//	address of font bitmap in xmem
		);
	//	the following call works for both standard and deluxe versions of
	//	the compiler because the font bitmap is in root memory.
/*
	glFontInit(		//	initialize the font info structure needed later
		&fi,			//	pointer to the font info structure to fill
		6,				//	horizontal size (in pixels) of each character
		8,				//	vertical size (in pixels) of each character
		32,			//	beginning code of printable characters
		127,			//	ending code of printable characters
		engFont6x8R	//	address of font bitmap in root memory
		);
*/

	while (1) {

		glSetBrushType(GL_SET);
		
		z = 32;
		for (y = 0; y < 239-36; y += 35) {		//	display as many rows as we can
			for (x = 0; x < 319-18; x+=17) {		//	display as many columns as we can
				glPrintf(x,7+y,&bigFi,"%c",z);		//	display the next ASCII code
				++z;										//	increment ASCII code
				if (z > 127) z = 32;					//	is it time to wrap around?
				hitwd();									//	hit the watchdog
			}
		}

		timeMark = MS_TIMER;
		while (MS_TIMER - timeMark < 5000);		//	delay by 5000ms
		glBlankScreen();								//	blank the screen

		z = 32;
		for (y = 0; y < 239-8; y += 8) {
			glBuffLock();
			for (x = 0; x < 319-6; x+=6) {
				glPrintf(x,7+y,&fi,"%c",z);
				++z;
				if (z > 255) z = 32;
				hitwd();
			}
			glBuffUnlock();
		}

		glSetBrushType(GL_XOR);		//	set exclusive-or mode
		glXGetBitmap(100,100,100,100,xLocalBM);

		for (y = 5; y; --y) {
			glSetBrushType(GL_XOR);
			glXPutBitmap(100,100,100,100,xLocalBM);
			
			timeMark = MS_TIMER;
			while (MS_TIMER - timeMark < 500);
		}

		glSetBrushType(GL_SET);

		timeMark = MS_TIMER;
		while (MS_TIMER - timeMark < 5000);
		glBlankScreen();

		for (y = 1; y < 120-4; y+=4) {
			glPlotCircle(160,120,y);
		}
		
		timeMark = MS_TIMER;
		while (MS_TIMER - timeMark < 5000);
		glBlankScreen();

		for (y = 1; y < 120-4; y+=4) {
			glPlotPolygon(4,319-y,y,y,y,y,239-y,319-y,239-y);
		}
		
		timeMark = MS_TIMER;
		while (MS_TIMER - timeMark < 5000);
		glBlankScreen();

	}
	glPlotLine;
}