/* 

FULLSCR.C - Example program that shows how to do direct
	    screen access from 32-bit protected mode 

protected mode: cl386 fullscr.c screen.c

*/

#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <conio.h>
#include <time.h>
#include <dos.h>
#include <fcntl.h>
#include "screen.h"

void fail(char *s)	{ puts(s); exit(1); }

static unsigned short *p;
void fail2(char *s) { restore_screen(p); fail(s); }

#define BUFSZ		4000

main()
{
    time_t t1, t2;
    char msg[30];
	char *msg2 = (char *) 0;
	char *scr;
	char *scr2;
    int i;
	int f;
	int dummy;
	
	// initialization
	srand(100);		// fixed
    video_init();
	if (! (p = malloc(BUFSZ)))
		fail("insufficient memory");
	save_screen(p);
	
	// timing loop
    time(&t1);
    for (i=30000; i--; )
        wrt_str(rand() % 25, rand() % 80, rand() % 0xFF, "hello world!");
    time(&t2);

	// done
	restore_screen(p);
	strcpy(msg, "<<");
    strcat(ultoa(t2 - t1, msg + 2, 10), ">> seconds");
	puts(msg);
	return 0;
}

