/* TextTest.c							*/
/*	This is a benchmark program for comparing the		*/
/*	FastText() routine with the standard Text() function	*/

#include "exec/types.h"
#include "intuition/intuition.h"

#include "functions.h"

#define	NL	NULL
#define	FAST	register

struct Window	*tW = NL;
struct RastPort	*tRp;		/* Graphics rendering area */

/*************************************************************************/

main()
{
FAST int	i,j,Loop;

static char str1[] =
 "abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";

    init_all();

    printf("Print 20 lines of 72 characters, 20 times\n");

    SetDrMd(tRp,JAM2);

    for ( Loop = 0; Loop<20; Loop++ ) {
	SetAPen(tRp,(long) Loop&3 );
	SetBPen(tRp,(long) Loop>>2 );

	for ( i=0; i<22; i++ ) {
	    Move(tRp,4L,16L+(long)(i<<3) );
	    Text(tRp,str1,72L);
	    }
	}

 printf("Print 20 lines of 72 characters, 1 char at a time.  Repeat 5 times\n");

    for ( Loop = 0; Loop<5; Loop++ ) {
	SetAPen(tRp,(long) Loop&3 );
	SetBPen(tRp,(long) Loop>>2 );

	for ( i=0; i<22; i++ ) {
	    Move(tRp,4L,16L+(long)(i<<3) );
	    str1[0] = 'a' + i;
	    for ( j=0; j<72; j++ ) {
		Text(tRp,str1,1L);
		}
	    }
	}

    printf("All Done\n");

    clear_all(0);
}


/**********************************************************************/

#define I_REV   31L
#define G_REV   31L

struct IntuitionBase *IntuitionBase;
struct GfxBase  { int b; } *GfxBase;

/* Used to open a Window   */
struct NewWindow TestWindow = {
    0,2,640,190,		/* LeftEdge,TopEdge,Width,Height */
    1,2,			/* DetailPen,BlockPen	*/
    MENUPICK | NEWSIZE | REFRESHWINDOW | ACTIVEWINDOW |
	MOUSEBUTTONS | RAWKEY | MOUSEMOVE,
    WINDOWDRAG | WINDOWSIZING | SMART_REFRESH | ACTIVATE | WINDOWDEPTH,
    NL,NL,(UBYTE *)"Testing",	/* FirstGadget, CheckMark, Title  */
    NL,				/* Screen ( Null)	*/
    NL,				/* BitMap		*/
    150,45,32767,32767,		/* MinW, MinH, MaxW, MaxH */
    WBENCHSCREEN };		/* Type			*/




/*********************************************************
* init_all()
*	Opens libraries and window for testing		*/
init_all()
{
    if ( ! (IntuitionBase = (struct IntuitionBase *)
	OpenLibrary("intuition.library",I_REV)) ||
	! (GfxBase =(struct GfxBase *)OpenLibrary("graphics.library",G_REV)) )
	{
	printf("Can't open libraries\n");
	exit(20);
	}

    if ( ! (tW =(struct Window *)OpenWindow(&TestWindow)) ) {
	printf("Can't open window\n");
	clear_all(21);
	}

   tRp = tW->RPort;
}





/*********************************************************
* clear_all()
*	Closes libraries and test window, then exits 	*/

clear_all(exitval)
int	exitval;
{
    if ( tW )	CloseWindow(tW);

    if ( GfxBase )	CloseLibrary(GfxBase);
    if ( IntuitionBase)	CloseLibrary(IntuitionBase);

    exit(exitval);
}
