MythTV  master
ifs_display.c
Go to the documentation of this file.
1 #include "ifs.h"
2 #include "goomconfig.h"
3 
4 #ifdef MMX
5 #include "mmx.h"
6 #endif
7 
8 #include "goom_tools.h"
9 
10 /* NOLINTNEXTLINE(readability-non-const-parameter) */
11 void
12 ifs_update (guint32 * data, const guint32 * back, int width, int height,
13  int increment)
14 {
15  static int s_couleur = 0xc0c0c0c0;
16  static int s_v[4] = { 2, 4, 3, 2 };
17  static int s_col[4] = { 2, 4, 3, 2 };
18 
19 #define MOD_MER 0
20 #define MOD_FEU 1
21 #define MOD_MERVER 2
22  static int s_mode = MOD_MERVER;
23  static int s_justChanged = 0;
24  static int s_cycle = 0;
25  int cycle10;
26 
27  int nbpt;
28  IFSPoint *points;
29 
30  int couleursl = s_couleur;
31 
32  s_cycle++;
33  if (s_cycle >= 80)
34  s_cycle = 0;
35 
36  if (s_cycle < 40)
37  cycle10 = s_cycle / 10;
38  else
39  cycle10 = 7 - s_cycle / 10;
40 
41  {
42  unsigned char *tmp = (unsigned char *) &couleursl;
43 
44  for (int i = 0; i < 4; i++) {
45  *tmp = (*tmp) >> cycle10;
46  tmp++;
47  }
48  }
49 
50  points = draw_ifs (&nbpt);
51  nbpt--;
52 
53 #ifdef MMX
54  movd_m2r (couleursl, mm1);
55  punpckldq_r2r (mm1, mm1);
56  for (int i = 0; i < nbpt; i += increment) {
57  int x = points[i].x;
58  int y = points[i].y;
59 
60  if ((x < width) && (y < height) && (x > 0) && (y > 0)) {
61  int pos = x + (y * width);
62  movd_m2r (back[pos], mm0);
63  paddusb_r2r (mm1, mm0);
64  movd_r2m (mm0, data[pos]);
65  }
66  }
67  emms();/*__asm__ __volatile__ ("emms");*/
68 #else
69  for (int i = 0; i < nbpt; i += increment) {
70  int x = (int) points[i].x & 0x7fffffff;
71  int y = (int) points[i].y & 0x7fffffff;
72 
73  if ((x < width) && (y < height)) {
74  int pos = x + (int) (y * width);
75  int tra = 0;
76  unsigned char *bra = (unsigned char *) &back[pos];
77  unsigned char *dra = (unsigned char *) &data[pos];
78  unsigned char *cra = (unsigned char *) &couleursl;
79 
80  for (int j = 0; j < 4; j++) {
81  tra = *cra;
82  tra += *bra;
83  if (tra > 255)
84  tra = 255;
85  *dra = tra;
86  ++dra;
87  ++cra;
88  ++bra;
89  }
90  }
91  }
92 #endif /*MMX*/
93  s_justChanged--;
94 
95  s_col[ALPHA] = s_couleur >> (ALPHA * 8) & 0xff;
96  s_col[BLEU] = s_couleur >> (BLEU * 8) & 0xff;
97  s_col[VERT] = s_couleur >> (VERT * 8) & 0xff;
98  s_col[ROUGE] = s_couleur >> (ROUGE * 8) & 0xff;
99 
100  if (s_mode == MOD_MER) {
101  s_col[BLEU] += s_v[BLEU];
102  if (s_col[BLEU] > 255) {
103  s_col[BLEU] = 255;
104  s_v[BLEU] = -(RAND() % 4) - 1;
105  }
106  if (s_col[BLEU] < 32) {
107  s_col[BLEU] = 32;
108  s_v[BLEU] = (RAND() % 4) + 1;
109  }
110 
111  s_col[VERT] += s_v[VERT];
112  if (s_col[VERT] > 200) {
113  s_col[VERT] = 200;
114  s_v[VERT] = -(RAND() % 3) - 2;
115  }
116  if (s_col[VERT] > s_col[BLEU]) {
117  s_col[VERT] = s_col[BLEU];
118  s_v[VERT] = s_v[BLEU];
119  }
120  if (s_col[VERT] < 32) {
121  s_col[VERT] = 32;
122  s_v[VERT] = (RAND() % 3) + 2;
123  }
124 
125  s_col[ROUGE] += s_v[ROUGE];
126  if (s_col[ROUGE] > 64) {
127  s_col[ROUGE] = 64;
128  s_v[ROUGE] = -(RAND () % 4) - 1;
129  }
130  if (s_col[ROUGE] < 0) {
131  s_col[ROUGE] = 0;
132  s_v[ROUGE] = (RAND () % 4) + 1;
133  }
134 
135  s_col[ALPHA] += s_v[ALPHA];
136  if (s_col[ALPHA] > 0) {
137  s_col[ALPHA] = 0;
138  s_v[ALPHA] = -(RAND () % 4) - 1;
139  }
140  if (s_col[ALPHA] < 0) {
141  s_col[ALPHA] = 0;
142  s_v[ALPHA] = (RAND () % 4) + 1;
143  }
144 
145  if (((s_col[VERT] > 32) && (s_col[ROUGE] < s_col[VERT] + 40)
146  && (s_col[VERT] < s_col[ROUGE] + 20) && (s_col[BLEU] < 64)
147  && (RAND () % 20 == 0)) && (s_justChanged < 0)) {
148  s_mode = (RAND () % 3) ? MOD_FEU : MOD_MERVER;
149  s_justChanged = 250;
150  }
151  }
152  else if (s_mode == MOD_MERVER) {
153  s_col[BLEU] += s_v[BLEU];
154  if (s_col[BLEU] > 128) {
155  s_col[BLEU] = 128;
156  s_v[BLEU] = -(RAND () % 4) - 1;
157  }
158  if (s_col[BLEU] < 16) {
159  s_col[BLEU] = 16;
160  s_v[BLEU] = (RAND () % 4) + 1;
161  }
162 
163  s_col[VERT] += s_v[VERT];
164  if (s_col[VERT] > 200) {
165  s_col[VERT] = 200;
166  s_v[VERT] = -(RAND () % 3) - 2;
167  }
168  if (s_col[VERT] > s_col[ALPHA]) {
169  s_col[VERT] = s_col[ALPHA];
170  s_v[VERT] = s_v[ALPHA];
171  }
172  if (s_col[VERT] < 32) {
173  s_col[VERT] = 32;
174  s_v[VERT] = (RAND () % 3) + 2;
175  }
176 
177  s_col[ROUGE] += s_v[ROUGE];
178  if (s_col[ROUGE] > 128) {
179  s_col[ROUGE] = 128;
180  s_v[ROUGE] = -(RAND () % 4) - 1;
181  }
182  if (s_col[ROUGE] < 0) {
183  s_col[ROUGE] = 0;
184  s_v[ROUGE] = (RAND () % 4) + 1;
185  }
186 
187  s_col[ALPHA] += s_v[ALPHA];
188  if (s_col[ALPHA] > 255) {
189  s_col[ALPHA] = 255;
190  s_v[ALPHA] = -(RAND () % 4) - 1;
191  }
192  if (s_col[ALPHA] < 0) {
193  s_col[ALPHA] = 0;
194  s_v[ALPHA] = (RAND () % 4) + 1;
195  }
196 
197  if (((s_col[VERT] > 32) && (s_col[ROUGE] < s_col[VERT] + 40)
198  && (s_col[VERT] < s_col[ROUGE] + 20) && (s_col[BLEU] < 64)
199  && (RAND () % 20 == 0)) && (s_justChanged < 0)) {
200  s_mode = (RAND () % 3) ? MOD_FEU : MOD_MER;
201  s_justChanged = 250;
202  }
203  }
204  else if (s_mode == MOD_FEU) {
205 
206  s_col[BLEU] += s_v[BLEU];
207  if (s_col[BLEU] > 64) {
208  s_col[BLEU] = 64;
209  s_v[BLEU] = -(RAND () % 4) - 1;
210  }
211  if (s_col[BLEU] < 0) {
212  s_col[BLEU] = 0;
213  s_v[BLEU] = (RAND () % 4) + 1;
214  }
215 
216  s_col[VERT] += s_v[VERT];
217  if (s_col[VERT] > 200) {
218  s_col[VERT] = 200;
219  s_v[VERT] = -(RAND () % 3) - 2;
220  }
221  if (s_col[VERT] > s_col[ROUGE] + 20) {
222  s_col[VERT] = s_col[ROUGE] + 20;
223  s_v[VERT] = -(RAND () % 3) - 2;
224  s_v[ROUGE] = (RAND () % 4) + 1;
225  s_v[BLEU] = (RAND () % 4) + 1;
226  }
227  if (s_col[VERT] < 0) {
228  s_col[VERT] = 0;
229  s_v[VERT] = (RAND () % 3) + 2;
230  }
231 
232  s_col[ROUGE] += s_v[ROUGE];
233  if (s_col[ROUGE] > 255) {
234  s_col[ROUGE] = 255;
235  s_v[ROUGE] = -(RAND () % 4) - 1;
236  }
237  if (s_col[ROUGE] > s_col[VERT] + 40) {
238  s_col[ROUGE] = s_col[VERT] + 40;
239  s_v[ROUGE] = -(RAND () % 4) - 1;
240  }
241  if (s_col[ROUGE] < 0) {
242  s_col[ROUGE] = 0;
243  s_v[ROUGE] = (RAND () % 4) + 1;
244  }
245 
246  s_col[ALPHA] += s_v[ALPHA];
247  if (s_col[ALPHA] > 0) {
248  s_col[ALPHA] = 0;
249  s_v[ALPHA] = -(RAND () % 4) - 1;
250  }
251  if (s_col[ALPHA] < 0) {
252  s_col[ALPHA] = 0;
253  s_v[ALPHA] = (RAND () % 4) + 1;
254  }
255 
256  if (((s_col[ROUGE] < 64) && (s_col[VERT] > 32) && (s_col[VERT] < s_col[BLEU])
257  && (s_col[BLEU] > 32)
258  && (RAND () % 20 == 0)) && (s_justChanged < 0)) {
259  s_mode = (RAND () % 2) ? MOD_MER : MOD_MERVER;
260  s_justChanged = 250;
261  }
262  }
263 
264  s_couleur = (s_col[ALPHA] << (ALPHA * 8))
265  | (s_col[BLEU] << (BLEU * 8))
266  | (s_col[VERT] << (VERT * 8))
267  | (s_col[ROUGE] << (ROUGE * 8));
268 }
Definition: ifs.h:10
#define ROUGE
position des composantes
Definition: goomconfig.h:10
#define MOD_FEU
void ifs_update(guint32 *data, const guint32 *back, int width, int height, int increment)
Definition: ifs_display.c:12
static guint32 * tmp
Definition: goom_core.c:35
#define MOD_MERVER
#define guint32
Definition: goomconfig.h:35
gint32 x
Definition: ifs.h:12
gint32 y
Definition: ifs.h:12
#define BLEU
Definition: goomconfig.h:11
#define MOD_MER
static guint32 * back
Definition: goom_core.c:34
static int RAND(void)
Definition: goom_tools.h:22
#define VERT
Definition: goomconfig.h:12
#define ALPHA
Definition: goomconfig.h:13
IFSPoint * draw_ifs(int *nbPoints)
Definition: ifs.c:462