inp002.c 7.98 KB
#include <bstring.h>
#include <stdio.h>

#include "inp.h"

static void varyXMuxSelects(void);
static void varyYMuxSelects(void);
static void varyAMuxSelects(void);
static void varyCMuxSelects(void);
static void stepTexel(cc_t *);
static void stepTexelAlpha(cc_t *);
static void initTwoCycleMode(cc_t *);

int
main(int argc, char *argv[])
{
	printHeader();
	varyXMuxSelects();
	varyYMuxSelects();
	varyAMuxSelects();
	varyCMuxSelects();
	printTrailingCycles();
}

static void
varyXMuxSelects(void)
{
	cc_t cc;
	cc_t *ccp = &cc;

	initTwoCycleMode(ccp);

	printf("# Vary X MUX select in two cycle mode\n");

	/* Initialize mode 0,1 (y,a,c) selects to produce (0,.ff,0) */

	ccp->cc_y_sel_0_r = ccp->cc_y_sel_1_r = CC_SUBB_ZERO;
	ccp->cc_a_sel_0_r = ccp->cc_a_sel_1_r = CC_MULT_LODF;
	ccp->cc_c_sel_0_r = ccp->cc_c_sel_1_r = CC_ADD_ZERO;

	ccp->cc_y_sel_0_a = ccp->cc_y_sel_1_a = CC_SUBB_ZERO_ALPHA;
	ccp->cc_a_sel_0_a = ccp->cc_a_sel_1_a = CC_MULT_LODF_ALPHA;
	ccp->cc_c_sel_0_a = ccp->cc_c_sel_1_a = CC_ADD_ZERO_ALPHA;

	ccp->tf_lod_frac = 0xff;

	printf("# texel 1 on cycle 0, texel 0 on cycle 1 color and alpha selects\n");

	ccp->cc_x_sel_0_r = CC_SUBA_TEX_1;
	ccp->cc_x_sel_0_a = CC_SUBA_TEX_1_ALPHA;

	ccp->cc_x_sel_1_r = CC_SUBA_TEX_0;
	ccp->cc_x_sel_1_a = CC_SUBA_TEX_0_ALPHA;

	stepTexel(ccp);

	printf("# texel 1 on cycle 0, combined color on cycle 1 color and alpha selects\n");

	ccp->cc_x_sel_1_r = CC_SUBA_COMBO_CLR;
	ccp->cc_x_sel_1_a = CC_SUBA_COMBO_ALPHA;

	stepTexel(ccp);

	printf("# texel 1 on cycle 1, texel 0 on cycle 0 color and alpha selects\n");

	ccp->cc_x_sel_0_r = CC_SUBA_TEX_0;
	ccp->cc_x_sel_0_a = CC_SUBA_TEX_0_ALPHA;

	ccp->cc_x_sel_1_r = CC_SUBA_TEX_1;
	ccp->cc_x_sel_1_a = CC_SUBA_TEX_1_ALPHA;

	stepTexel(ccp);

	printf("# texel 1 on cycle 1, combined color on cycle 0 color and alpha selects\n");

	ccp->cc_x_sel_0_r = CC_SUBA_COMBO_CLR;
	ccp->cc_x_sel_0_a = CC_SUBA_COMBO_ALPHA;

	stepTexel(ccp);
}

static void
varyYMuxSelects(void)
{
	cc_t cc;
	cc_t *ccp = &cc;

	initTwoCycleMode(ccp);

	printf("# Vary Y MUX select in two cycle mode\n");

	/* Initialize mode 0, 1 (x,a,c) selects to produce (1,.ff,0) */

	ccp->cc_x_sel_0_r = ccp->cc_x_sel_1_r = CC_SUBA_ONE;
	ccp->cc_a_sel_0_r = ccp->cc_a_sel_1_r = CC_MULT_LODF;
	ccp->cc_c_sel_0_r = ccp->cc_c_sel_1_r = CC_ADD_ZERO;

	ccp->cc_x_sel_0_a = ccp->cc_x_sel_1_a = CC_SUBA_ONE_ALPHA;
	ccp->cc_a_sel_0_a = ccp->cc_a_sel_1_a = CC_MULT_LODF_ALPHA;
	ccp->cc_c_sel_0_a = ccp->cc_c_sel_1_a = CC_ADD_ZERO_ALPHA;

	ccp->tf_lod_frac = 0xff;

	printf("# texel 1 on cycle 0, texel 0 on cycle 1 color and alpha selects\n");

	ccp->cc_y_sel_0_r = CC_SUBB_TEX_1;
	ccp->cc_y_sel_0_a = CC_SUBB_TEX_1_ALPHA;

	ccp->cc_y_sel_1_r = CC_SUBB_TEX_0;
	ccp->cc_y_sel_1_a = CC_SUBB_TEX_0_ALPHA;

	stepTexel(ccp);

	printf("# texel 1 on cycle 0, combined color on cycle 1 color and alpha selects\n");

	ccp->cc_y_sel_1_r = CC_SUBB_COMBO_CLR;
	ccp->cc_y_sel_1_a = CC_SUBB_COMBO_ALPHA;

	stepTexel(ccp);

	printf("# texel 1 on cycle 1, texel 0 on cycle 0 color and alpha selects\n");

	ccp->cc_y_sel_0_r = CC_SUBB_TEX_0;
	ccp->cc_y_sel_0_a = CC_SUBB_TEX_0_ALPHA;

	ccp->cc_y_sel_1_r = CC_SUBB_TEX_1;
	ccp->cc_y_sel_1_a = CC_SUBB_TEX_1_ALPHA;

	stepTexel(ccp);

	printf("# texel 1 on cycle 1, combined color on cycle 0 color and alpha selects\n");

	ccp->cc_y_sel_0_r = CC_SUBB_COMBO_CLR;
	ccp->cc_y_sel_0_a = CC_SUBB_COMBO_ALPHA;

	stepTexel(ccp);
}

static void
varyAMuxSelects(void)
{
	cc_t cc;
	cc_t *ccp = &cc;

	initTwoCycleMode(ccp);

	printf("# Vary A MUX select in two cycle mode\n");

	/* Initialize (x,y,c) selects to produce (1,0,0) */

	ccp->cc_x_sel_0_r = ccp->cc_x_sel_1_r = CC_SUBA_ONE;
	ccp->cc_y_sel_0_r = ccp->cc_y_sel_1_r = CC_SUBB_ZERO;
	ccp->cc_c_sel_0_r = ccp->cc_c_sel_1_r = CC_ADD_ZERO;

	ccp->cc_x_sel_0_a = ccp->cc_x_sel_1_a = CC_SUBA_ONE_ALPHA;
	ccp->cc_y_sel_0_a = ccp->cc_y_sel_1_a = CC_SUBB_ZERO_ALPHA;
	ccp->cc_c_sel_0_a = ccp->cc_c_sel_1_a = CC_ADD_ZERO_ALPHA;

	printf("# texel 1 on cycle 0, texel 0 on cycle 1 color and alpha selects\n");

	ccp->cc_a_sel_0_r = CC_MULT_TEX_1;
	ccp->cc_a_sel_0_a = CC_MULT_TEX_1_ALPHA;

	ccp->cc_a_sel_1_r = CC_MULT_TEX_0;
	ccp->cc_a_sel_1_a = CC_MULT_TEX_0_ALPHA;

	stepTexel(ccp);

	printf("# texel 1 on cycle 0, combined color on cycle 1 color and alpha selects\n");

	ccp->cc_a_sel_1_r = CC_MULT_COMBO_CLR;
	ccp->cc_a_sel_1_a = CC_MULT_COMBO_ALPHA;

	stepTexel(ccp);

	printf("# texel 1 on cycle 1, texel 0 on cycle 0 color and alpha selects\n");

	ccp->cc_a_sel_0_r = CC_MULT_TEX_0;
	ccp->cc_a_sel_0_a = CC_MULT_TEX_0_ALPHA;

	ccp->cc_a_sel_1_r = CC_MULT_TEX_1;
	ccp->cc_a_sel_1_a = CC_MULT_TEX_1_ALPHA;

	stepTexel(ccp);

	printf("# texel 1 on cycle 1, combined color on cycle 0 color and alpha selects\n");

	ccp->cc_a_sel_0_r = CC_MULT_COMBO_CLR;
	ccp->cc_a_sel_0_a = CC_MULT_COMBO_ALPHA;

	stepTexel(ccp);

	printf("# texel 1 alpha on cycle 0, texel 0 alpha on cycle 1 color and alpha selects\n");

	ccp->cc_a_sel_0_r = CC_MULT_T1_ALPHA;
	ccp->cc_a_sel_0_a = CC_MULT_TEX_1_ALPHA;

	ccp->cc_a_sel_1_r = CC_MULT_T0_ALPHA;
	ccp->cc_a_sel_1_a = CC_MULT_TEX_0_ALPHA;

	stepTexelAlpha(ccp);

	printf("# texel 1 alpha on cycle 0, combined alpha on cycle 1 color selects\n");

	ccp->cc_a_sel_1_r = CC_MULT_COMBO_ALPHA;

	stepTexelAlpha(ccp);

	printf("# texel 1 alpha on cycle 1, texel 0 on cycle 0 color and alpha selects\n");

	ccp->cc_a_sel_0_r = CC_MULT_T0_ALPHA;
	ccp->cc_a_sel_0_a = CC_MULT_TEX_0_ALPHA;

	ccp->cc_a_sel_1_r = CC_MULT_T1_ALPHA;
	ccp->cc_a_sel_1_a = CC_MULT_TEX_1_ALPHA;

	stepTexelAlpha(ccp);

	printf("# texel 1 alpha on cycle 1, combined alpha on cycle 0 color selects\n");

	ccp->cc_a_sel_0_r = CC_MULT_COMBO_ALPHA;

	stepTexelAlpha(ccp);
}

static void
varyCMuxSelects(void)
{
	cc_t cc;
	cc_t *ccp = &cc;

	initTwoCycleMode(ccp);

	printf("# Vary C MUX select in two cycle mode\n");

	/* Initialize mode 0,1 (x,y,a) selects to produce (0,0,0) */

	ccp->cc_x_sel_0_r = ccp->cc_x_sel_1_r = CC_SUBA_ZERO;
	ccp->cc_y_sel_0_r = ccp->cc_y_sel_1_r = CC_SUBB_ZERO;
	ccp->cc_a_sel_0_r = ccp->cc_a_sel_1_r = CC_MULT_ZERO;

	ccp->cc_x_sel_0_a = ccp->cc_x_sel_1_a = CC_SUBA_ZERO_ALPHA;
	ccp->cc_y_sel_0_a = ccp->cc_y_sel_1_a = CC_SUBB_ZERO_ALPHA;
	ccp->cc_a_sel_0_a = ccp->cc_a_sel_1_a = CC_MULT_ZERO_ALPHA;

	printf("# texel 1 on cycle 0, texel 0 on cycle 1 color and alpha selects\n");

	ccp->cc_c_sel_0_r = CC_ADD_TEX_1;
	ccp->cc_c_sel_0_a = CC_ADD_TEX_1_ALPHA;

	ccp->cc_c_sel_1_r = CC_ADD_TEX_0;
	ccp->cc_c_sel_1_a = CC_ADD_TEX_0_ALPHA;

	stepTexel(ccp);

	printf("# texel 1 on cycle 0, combined color on cycle 1 color and alpha selects\n");

	ccp->cc_c_sel_1_r = CC_ADD_COMBO_CLR;
	ccp->cc_c_sel_1_a = CC_ADD_COMBO_ALPHA;

	stepTexel(ccp);

	printf("# texel 1 on cycle 1, texel 0 on cycle 0 color and alpha selects\n");

	ccp->cc_c_sel_0_r = CC_ADD_TEX_0;
	ccp->cc_c_sel_0_a = CC_ADD_TEX_0_ALPHA;

	ccp->cc_c_sel_1_r = CC_ADD_TEX_1;
	ccp->cc_c_sel_1_a = CC_ADD_TEX_1_ALPHA;

	stepTexel(ccp);

	printf("# texel 1 on cycle 1, combined color on cycle 0 color and alpha selects\n");

	ccp->cc_c_sel_0_r = CC_ADD_COMBO_CLR;
	ccp->cc_c_sel_0_a = CC_ADD_COMBO_ALPHA;

	stepTexel(ccp);
}

static void
stepTexel(cc_t *ccp)
{
	int i;

	printVector(ccp, 1);

	for (i = 0; i < 9; i++) {
		printVector(ccp, 1);
		ccp->tf_a = 1 << i;
		printVector(ccp, 1);
	}
	ccp->tf_a = 0;

	for (i = 0; i < 9; i++) {
		printVector(ccp, 1);
		ccp->tf_b = 1 << i;
		printVector(ccp, 1);
	}
	ccp->tf_b = 0;

	for (i = 0; i < 9; i++) {
		printVector(ccp, 1);
		ccp->tf_g = 1 << i;
		printVector(ccp, 1);
	}
	ccp->tf_g = 0;

	for (i = 0; i < 9; i++) {
		printVector(ccp, 1);
		ccp->tf_r = 1 << i;
		printVector(ccp, 1);
	}
	ccp->tf_r = 0;
	printVector(ccp, 1);
}

static void
stepTexelAlpha(cc_t *ccp)
{
	int i;

	printVector(ccp, 1);

	for (i = 0; i < 9; i++) {
		printVector(ccp, 1);
		ccp->tf_a = 1 << i;
		printVector(ccp, 1);
	}
	printVector(ccp, 1);

	ccp->tf_a = 0;
}

static void
initTwoCycleMode(cc_t *ccp)
{

	bzero(ccp, sizeof(*ccp));

	ccp->ncyc = 1;			/* two cycle mode */
	ccp->st_span = 1;		/* set phase */

	printf("# Start two cycle mode\n");

	printVector(ccp, 0);

	ccp->st_span = 0;		/* allow clocking to begin */

	printVector(ccp, 0);
}