inp008.c 4.06 KB

/**************************************************************************
 *                                                                        *
 *               Copyright (C) 1994, Silicon Graphics, Inc.               *
 *                                                                        *
 *  These coded instructions, statements, and computer programs  contain  *
 *  unpublished  proprietary  information of Silicon Graphics, Inc., and  *
 *  are protected by Federal copyright  law.  They  may not be disclosed  *
 *  to  third  parties  or copied or duplicated in any form, in whole or  *
 *  in part, without the prior written consent of Silicon Graphics, Inc.  *
 *                                                                        *
 *************************************************************************/


#include <bstring.h>
#include <stdio.h>
#include <math.h>

#include <mbi.h>	/* from software-land */

#include "inp.h"

static void fillRect(void);
static void texRectFlip(void);
static void texRect(void);
static void printTrailingCycles(void);

int
main(int argc, char *argv[])
{
	printHeader();
	resetFifo();
	initFifo();
	resetFifo();
	fillRect();
	texRectFlip();
	texRect();
	printTrailingCycles();
}

static void
doFILLRECT(vector_t *vp, int invert)
{
	printf("#  FILLRECT\n");

	vp->xbus_cs_valid = 1;

	vp->gfillr.cmd = G_FILLRECT;
	vp->gfillr.x0 = 0x000	^ (invert ? 0x3ff : 0x000);
	vp->gfillr.x0frac = 0x0	^ (invert ? 0x3: 0x0);
	vp->gfillr.y0 = 0x3ff	^ (invert ? 0x3ff : 0x000);
	vp->gfillr.y0frac = 0x3	^ (invert ? 0x3: 0x0);
	vp->gfillr.pad	= 0;
	vp->gfillr.x1 = 0x000	^ (invert ? 0x3ff : 0x000);
	vp->gfillr.x1frac = 0x0	^ (invert ? 0x3: 0x0);
	vp->gfillr.y1 = 0x3ff	^ (invert ? 0x3ff : 0x000);
	vp->gfillr.y1frac = 0x3	^ (invert ? 0x3: 0x0);
	printVector(vp, 1);
}

static void
doTEXRECTFLIP(vector_t *vp, int invert)
{
	printf("#  TEXRECTFLIP\n");

	vp->xbus_cs_valid = 1;

	vp->gtexr.cmd = G_TEXRECTFLIP;
	vp->gtexr.xl = 0x000 ^ (invert ? 0xfff : 0x000);
	vp->gtexr.yl = 0xfff ^ (invert ? 0xfff : 0x000);
	vp->gtexr.tile = 0x0 ^ (invert ? 0x7 : 0x0);
	vp->gtexr.xh = 0x000 ^ (invert ? 0xfff : 0x000);
	vp->gtexr.yh = 0xfff ^ (invert ? 0xfff : 0x000);
	printVector(vp, 1);

	vp->data[0] =  0x0000ffff ^ (invert ? 0xffffffff : 0x00000000);
	vp->data[1] =  0x0000ffff ^ (invert ? 0xffffffff : 0x00000000);
	printVector(vp, 1);
}

static void
doTEXRECT(vector_t *vp, int invert)
{
	printf("#  TEXRECT\n");

	vp->xbus_cs_valid = 1;

	vp->gtexr.cmd = G_TEXRECT;
	vp->gtexr.xl = 0x000 ^ (invert ? 0xfff : 0x000);
	vp->gtexr.yl = 0xfff ^ (invert ? 0xfff : 0x000);
	vp->gtexr.tile = 0x0 ^ (invert ? 0x7 : 0x0);
	vp->gtexr.xh = 0x000 ^ (invert ? 0xfff : 0x000);
	vp->gtexr.yh = 0xfff ^ (invert ? 0xfff : 0x000);
	printVector(vp, 1);

	vp->data[0] =  0x0000ffff ^ (invert ? 0xffffffff : 0x00000000);
	vp->data[1] =  0x0000ffff ^ (invert ? 0xffffffff : 0x00000000);
	printVector(vp, 1);
}

static void
fillRect(void)
{
	int i, j, k;
	vector_t v;
	vector_t *vp = &v;

	bzero(vp, sizeof(*vp));

	vp->reset_l = 1;

	for (i = 0; i < 2; i++) {
		vp->copy_fill = i;
		for (j = 0; j < 2; j++) {
			doFILLRECT(vp, j);
			for (k = 0; k < 22; k++) {
				vp->xbus_cs_valid = 0;
				vp->data64 = 0;
				printVector(vp, 1);
			}
		}
	}
}

static void
texRectFlip(void)
{
	int i, j, k;
	vector_t v;
	vector_t *vp = &v;

	bzero(vp, sizeof(*vp));

	vp->reset_l = 1;

	for (i = 0; i < 2; i++) {
		vp->copy_fill = i;
		for (j = 0; j < 2; j++) {
			doTEXRECTFLIP(vp, j);
			for (k = 0; k < 22; k++) {
				vp->xbus_cs_valid = 0;
				vp->data64 = 0;
				printVector(vp, 1);
			}
		}
	}
}

static void
texRect(void)
{
	int i, j, k;
	vector_t v;
	vector_t *vp = &v;

	bzero(vp, sizeof(*vp));

	vp->reset_l = 1;

	for (i = 0; i < 2; i++) {
		vp->copy_fill = i;
		for (j = 0; j < 2; j++) {
			doTEXRECT(vp, j);
			for (k = 0; k < 22; k++) {
				vp->xbus_cs_valid = 0;
				vp->data64 = 0;
				printVector(vp, 1);
			}
		}
	}
}

static void
printTrailingCycles(void)
{
	int i;
	vector_t v;
	vector_t *vp = &v;

	printf("# Trailing cycles\n");

	bzero(vp, sizeof(*vp));

	vp->reset_l = 1;

	for (i = 0; i < 3; i++)
		printVector(vp, 0);
}