inp003.c 2.6 KB
#include <bstring.h>
#include <stdio.h>

#include "inp.h"

static void oneCycleMode(void);
static void twoCycleMode(void);

int
main(int argc, char *argv[])
{
	printHeader();
	oneCycleMode();
	twoCycleMode();
	printTrailingCycles();
}

static void
oneCycleMode(void)
{
	cc_t cc;
	cc_t *ccp = &cc;
	int i;

	bzero(ccp, sizeof(cc));

	ccp->ncyc = 0;			/* one cycle mode */

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

	ccp->cc_x_sel_0_r = CC_SUBA_ZERO;
	ccp->cc_y_sel_0_r = CC_SUBB_ZERO;
	ccp->cc_a_sel_0_r = CC_MULT_ZERO;
	ccp->cc_c_sel_0_r = CC_ADD_ZERO;

	ccp->cc_x_sel_0_a = CC_SUBA_ZERO_ALPHA;
	ccp->cc_y_sel_0_a = CC_SUBB_ZERO_ALPHA;
	ccp->cc_a_sel_0_a = CC_MULT_ZERO_ALPHA;
	ccp->cc_c_sel_0_a = CC_ADD_ZERO_ALPHA;

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

	ccp->cc_x_sel_1_r = CC_SUBA_ZERO;
	ccp->cc_y_sel_1_r = CC_SUBB_ZERO;
	ccp->cc_a_sel_1_r = CC_MULT_ZERO;
	ccp->cc_c_sel_1_r = CC_ADD_ONE;

	ccp->cc_x_sel_1_a = CC_SUBA_ZERO_ALPHA;
	ccp->cc_y_sel_1_a = CC_SUBB_ZERO_ALPHA;
	ccp->cc_a_sel_1_a = CC_MULT_ZERO_ALPHA;
	ccp->cc_c_sel_1_a = CC_ADD_ONE_ALPHA;

	printf("# Toggle start of span in one cycle mode\n");

	ccp->st_span = 0;	/* start of span off */

	printVector(ccp, 1);

	ccp->st_span = 1;	/* start of span on, remain in cycle 1 */

	printVector(ccp, 1);

	printVector(ccp, 1);

	ccp->st_span = 0;	/* start of span off, remain in cycle 1 */

	printVector(ccp, 1);	/* now use cycle 1 selects */
}

static void
twoCycleMode(void)
{
	cc_t cc;
	cc_t *ccp = &cc;
	int i;

	bzero(ccp, sizeof(cc));

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

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

	ccp->cc_x_sel_0_r = CC_SUBA_ZERO;
	ccp->cc_y_sel_0_r = CC_SUBB_ZERO;
	ccp->cc_a_sel_0_r = CC_MULT_ZERO;
	ccp->cc_c_sel_0_r = CC_ADD_ZERO;

	ccp->cc_x_sel_0_a = CC_SUBA_ZERO_ALPHA;
	ccp->cc_y_sel_0_a = CC_SUBB_ZERO_ALPHA;
	ccp->cc_a_sel_0_a = CC_MULT_ZERO_ALPHA;
	ccp->cc_c_sel_0_a = CC_ADD_ZERO_ALPHA;

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

	ccp->cc_x_sel_1_r = CC_SUBA_ZERO;
	ccp->cc_y_sel_1_r = CC_SUBB_ZERO;
	ccp->cc_a_sel_1_r = CC_MULT_ZERO;
	ccp->cc_c_sel_1_r = CC_ADD_ONE;

	ccp->cc_x_sel_1_a = CC_SUBA_ZERO_ALPHA;
	ccp->cc_y_sel_1_a = CC_SUBB_ZERO_ALPHA;
	ccp->cc_a_sel_1_a = CC_MULT_ZERO_ALPHA;
	ccp->cc_c_sel_1_a = CC_ADD_ONE_ALPHA;

	printf("# Toggle start of span in two cycle mode\n");

	ccp->st_span = 0;	/* start of span off */

	printVector(ccp, 1);

	ccp->st_span = 1;	/* start of span on, remain in cycle 0 */

	printVector(ccp, 1);

	ccp->st_span = 0;	/* start of span off, go to cycle 1 */

	printVector(ccp, 1);

	printVector(ccp, 1);	/* back to cycle 0 */
}