cc.h 7.44 KB
/*
 *  cc.h -- definitions, structures for Color Combiner Unit
 *
 *  This unit comprises the color combine lerps and the "alpha fixup"
 *  stuff for keying, and cvg * alpha.
 *
 *   Extra added bonus: texture edge circuit!
 *
 *  8/16/94  RJM
 */

#ifndef CLR_COMBO_INCLD
#define CLR_COMBO_INCLD


#define ONE_POINT_OH	0x100
#define ZERO		0x000

/*
 *   Red/Green/Blue Muxes
 */

typedef enum {
	CC_SUBA_COMBO_CLR	= 0,
	CC_SUBA_TEX_0		= 1,
	CC_SUBA_TEX_1		= 2,
	CC_SUBA_PRIM_CLR	= 3,
	CC_SUBA_SHADE_CLR	= 4,
	CC_SUBA_ENV_CLR		= 5,
	CC_SUBA_ONE		= 6,
	CC_SUBA_NOISE		= 7,
	CC_SUBA_ZERO		= 8,
	CC_SUBA_ZERO_LAST	= 15
} CCSubASel;

typedef enum {
	CC_SUBB_COMBO_CLR	= 0,
	CC_SUBB_TEX_0		= 1,
	CC_SUBB_TEX_1		= 2,
	CC_SUBB_PRIM_CLR	= 3,
	CC_SUBB_SHADE_CLR	= 4,
	CC_SUBB_ENV_CLR		= 5,
	CC_SUBB_CENTER		= 6,
	CC_SUBB_K4		= 7,
	CC_SUBB_ZERO		= 8,
	CC_SUBB_ZERO_LAST	= 15
} CCSubBSel;

typedef enum {
	CC_MULT_COMBO_CLR	= 0,
	CC_MULT_TEX_0		= 1,
	CC_MULT_TEX_1		= 2,
	CC_MULT_PRIM_CLR	= 3,
	CC_MULT_SHADE_CLR	= 4,
	CC_MULT_ENV_CLR		= 5,
	CC_MULT_SCALE		= 6,
	CC_MULT_COMBO_ALPHA	= 7,
	CC_MULT_T0_ALPHA	= 8,
	CC_MULT_T1_ALPHA	= 9,
	CC_MULT_PRIM_A		= 10,
	CC_MULT_SHADE_A		= 11,
	CC_MULT_ENV_A		= 12,
	CC_MULT_LODF		= 13,
	CC_MULT_PRIM_LODF	= 14,
	CC_MULT_K5		= 15,
	CC_MULT_ZERO		= 16,
	CC_M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D_ONE_ALPHA	= 6,
	CC_ADD_ZERO_ALPHA	= 7
} CCAddSel_A;




/********* ******* *** ** ******* **** ********** ***** ********
 *   Color Combiner Registers and Signals
 ********* ******* *** ** ******* **** ********** ***** ********/

typedef struct cc
{
  /* R E Q U I R E D    by C-sim */
    char *label;  /* label must be first */
    char **argv;
    int argc;
    int gclk_old;

  /* I N P U T    signals (must be int) */

    int gclk;			/* rdp gates clock */

    int st_span;		/* start of span */
    int ncyc;			/* number of cycles mode */

    int key_en;			/* enable keying mode */
    int texture_edge_mode;	/* enable texture edge mode */
    int cvg_times_alpha;	/* modify pixel coverage with alpha */
    int alpha_cvg_select;	/* select source of pixel alpha */
    int dither_en;		/* enable dithering of alpha using noise */

    int cc_x_sel_0_r;		/* [3:0] cc mode */
    int cc_y_sel_0_r;		/* [3:0] */
    int cc_a_sel_0_r;		/* [4:0] */
    int cc_c_sel_0_r;		/* [2:0] */

    int cc_x_sel_0_a;		/* [2:0] cc mode */
    int cc_y_sel_0_a;		/* [2:0] */
    int cc_a_sel_0_a;		/* [2:0] */
    int cc_c_sel_0_a;		/* [2:0] */

    int cc_x_sel_1_r;		/* [3:0] cc mode */
    int cc_y_sel_1_r;		/* [3:0] */
    int cc_a_sel_1_r;		/* [4:0] */
    int cc_c_sel_1_r;		/* [2:0] */

    int cc_x_sel_1_a;		/* [2:0] cc mode */
    int cc_y_sel_1_a;		/* [2:0] */
    int cc_a_sel_1_a;		/* [2:0] */
    int cc_c_sel_1_a;		/* [2:0] */

    int st_r;			/* [7:0], shade value */
    int st_g;			/* [7:0], shade value */
    int st_b;			/* [7:0], shade value */
    int st_a;			/* [7:0], shade value */

    int tf_r;			/* [8:0], texel value */
    int tf_g;			/* [8:0], texel value */
    int tf_b;			/* [8:0], texel value */
    int tf_a;			/* [8:0], texel value */

    int tf_lod_frac;		/* [8:0], texel lod value */
    int tf_lge1;		/* texel lod >= 1.0 flag */

    int prim_lod_frac;		/* [8:0] primitive LOD fraction */

    int prim_r;			/* [7:0] primitive color */
    int prim_g;			/* [7:0] primitive color */
    int prim_b;			/* [7:0] primitive color */
    int prim_a;			/* [7:0] primitive color */

    int env_r;			/* [7:0] environment color */
    int env_g;			/* [7:0] environment color */
    int env_b;			/* [7:0] environment color */
    int env_a;			/* [7:0] environment color */

    int center_r;		/* [7:0] color keying center */
    int center_g;		/* [7:0] color keying center */
    int center_b;		/* [7:0] color keying center */

    int scale_r;		/* [7:0] color keying scale */
    int scale_g;		/* [7:0] color keying scale */
    int scale_b;		/* [7:0] color keying scale */

    int width_r;		/* [11:0] color keying width */
    int width_g;		/* [11:0] color keying width */
    int width_b;		/* [11:0] color keying width */

    int k4_coeff;		/* [8:0] color conversion coefficient */
    int k5_coeff;		/* [8:0] color conversion coefficient */

    int noise;			/* [8:0] color conversion coefficient */

    int cvg;			/* [3:0], 1.3, pixel coverage */

  /* O U T P U T   signals (must be int) */

    int shade_a;		/* [7:0], shade alpha delayed */
    int pixel_r;		/* [7:0], combined pixel, red */
    int pixel_g;		/* [7:0], combined pixel, green */
    int pixel_b;		/* [7:0], combined pixel, blue */
    int pixel_a;		/* [8:0], 1.8, combined pixel, alpha */

    int pixel_cvg;		/* [3:0], 1.3 */

  /* O T H E R    signals */

    unsigned int cycle: 1;		/* current cycle */
    unsigned int cycle_d1: 1;		/* cycle delayed */
    unsigned int cycle_d2: 1;		/* cycle delayed yet again */

    unsigned int cc_x_sel_r: 4;		/* sub a mux select, rgb */
    unsigned int cc_y_sel_r: 4;		/* sub b mux select, rgb */
    unsigned int cc_a_sel_r: 5;		/* mul mux select, rgb   */
    unsigned int cc_c_sel_r: 3;		/* adder mux select, rgb */

    unsigned int cc_x_sel_a: 3;		/* sub a mux select, a */
    unsigned int cc_y_sel_a: 3;		/* sub b mux select, a */
    unsigned int cc_a_sel_a: 3;		/* mul mux select, a   */
    unsigned int cc_c_sel_a: 3;		/* adder mux select, a */

    unsigned int st_a_d1: 8;		/* delayed shade alpha value */

    unsigned int tf_r_d1: 9;		/* delayed texture red value */
    unsigned int tf_g_d1: 9;		/* delayed texture red value */
    unsigned int tf_b_d1: 9;		/* delayed texture red value */
    unsigned int tf_a_d1: 9;		/* delayed texture red value */

    unsigned int tf_lod_frac_d1: 9;	/* [8:0], delayed texel lod value */
    unsigned int tf_lge1_d1: 1;		/* delayed texel lod >= 1.0 flag */

    unsigned int tf_lod_frac_d2: 9;	/* [8:0], (further) delayed lod value */
    unsigned int tf_lge1_d2: 1;		/* (further) delayed lod >= 1.0 flag */

    unsigned int suba_r: 9;	/* a input of red subtract, bypass keying */
    unsigned int suba_g: 9;	/* a input of grn subtract, bypass keying */
    unsigned int suba_b: 9;	/* a input of blu subtract, bypass keying */

    unsigned int cc_r: 17;	/* s8.8, to keying/clamp logic */
    unsigned int cc_g: 17;	/* s8.8, to keying/clamp logic */
    unsigned int cc_b: 17;	/* s8.8, to keying/clamp logic */
    unsigned int cc_a: 9;	/* s8.0, to keying/clamp logic */
} cc_t;



/*
 *  Function prototypes
 */

int cc(cc_t **pp0, cc_t **pp1);
int cc_init(cc_t *p0, cc_t *p1);


#endif /*  CLR_COMBO_INCLD  */