inp010.c
2.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
#include <bstring.h>
#include <math.h>
#include <stdio.h>
#include "inp.h"
static void varyAlpha(void);
static void varyShadeAlpha(void);
static void printDitheredTrailingCycles(void);
int
main(int argc, char *argv[])
{
srandom(1);
printHeader();
varyAlpha();
varyShadeAlpha();
printDitheredTrailingCycles();
}
static void
varyAlpha(void)
{
cc_t cc;
cc_t *ccp = &cc;
int i, j;
printf("# Vary alpha outputs with noise\n");
bzero(ccp, sizeof(cc));
ccp->ncyc = 0; /* single cycle mode */
ccp->dither_en = 1; /* dithering mode */
/* Initialize (x,y,a,c) RGB selects to produce (0,0,0,0) */
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_ZERO;
/* Initialize (x,y,a) alpha selects to produce (0,0,0) */
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_TEX_1_ALPHA;
/* Vary high bits */
for (i = 0; i < 16; i++) {
ccp->tf_a = i << 5;
for (j = 0; j < 8; j++) {
ccp->noise = j << 6;
printf("# tf_a = 0x%x, noise = 0x%x\n",
ccp->tf_a, ccp->noise);
printVector(ccp, 1);
}
}
/* Monte Carlo */
for (i = 0; i < 100; i++) {
ccp->tf_a = random() & 0x1ff;
ccp->noise = random() & 0x1ff;
printf("# tf_a = 0x%x, noise = 0x%x\n", ccp->tf_a, ccp->noise);
printVector(ccp, 1);
}
}
static void
varyShadeAlpha(void)
{
cc_t cc;
cc_t *ccp = &cc;
int i, j;
printf("# Vary shade alpha inputs with noise\n");
bzero(ccp, sizeof(cc));
ccp->ncyc = 0; /* single cycle mode */
ccp->dither_en = 1; /* dithering mode */
/* Initialize (x,y,a,c) RGB selects to produce (0,0,0,0) */
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_ZERO;
/* Initialize (x,y,a) alpha selects to produce (0,0,0) */
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_SHADE_ALPHA;
/* Vary high bits */
for (i = 0; i < 16; i++) {
ccp->st_a = i << 4;
for (j = 0; j < 8; j++) {
ccp->noise = j << 6;
printf("# st_a = 0x%x, noise = 0x%x\n",
ccp->st_a, ccp->noise);
printVector(ccp, 1);
}
}
/* once more to force a clamp */
ccp->st_a = 0xff;
for (j = 0; j < 8; j++) {
ccp->noise = j << 6;
printf("# st_a = 0x%x, noise = 0x%x\n",
ccp->st_a, ccp->noise);
printVector(ccp, 1);
}
/* Monte Carlo */
for (i = 0; i < 100; i++) {
ccp->st_a = random() & 0xff;
ccp->noise = random() & 0x1ff;
printf("# st_a = 0x%x, noise = 0x%x\n", ccp->st_a, ccp->noise);
printVector(ccp, 1);
}
}
static void
printDitheredTrailingCycles(void)
{
cc_t cc;
cc_t *ccp = &cc;
int i;
bzero(ccp, sizeof(cc));
ccp->dither_en = 1; /* dithering mode */
printf("# Trailing cycles\n");
for (i = 0; i < 4; i++)
printVector(ccp, 0);
}