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