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