MythTV  master
goom_core.cpp
Go to the documentation of this file.
1 #include "../config.h"
2 #ifdef HAVE_STDINT_H
3 #include <cstdint>
4 #endif
5 
6 #include <cinttypes>
7 #include <cstdio>
8 #include <cstdlib>
9 #include <cstring>
10 #include <random>
11 
12 #include "goom_core.h"
13 #include "goom_tools.h"
14 #include "filters.h"
15 #include "lines.h"
16 #include "ifs.h"
17 #include "tentacle3d.h"
18 //#include "gfontlib.h"
19 
20 //#define VERBOSE
21 
22 #define STOP_SPEED 128
23 
24 #define TIME_BTW_CHG 300
25 
29 static guint32 *pixel;
30 static guint32 *back;
31 static guint32 *p1, *p2, *tmp;
32 static guint32 cycle;
33 
34 struct GoomState {
35  int m_drawIfs;
38 
41 
44 };
45 
46 #define STATES_NB 8
47 #define STATES_RANGEMAX 510
48 const std::array<const GoomState,STATES_NB> kStates {{
49  {1,0,0,1,4, 000, 100},
50  {1,0,0,1,1, 101, 140}, // turned on drawScope
51  {1,0,0,1,2, 141, 200},
52  {0,1,0,1,2, 201, 260},
53  {0,1,0,1,0, 261, 330},
54  {0,1,1,1,4, 331, 400},
55  {0,0,1,1,5, 401, 450}, // turned on drawScope
56  {0,0,1,1,1, 451, 510}
57 }};
58 
60 
61 guint32 resolx, resoly, buffsize, c_black_height = 0, c_offset = 0, c_resoly = 0; /* avec prise en compte de ca */
62 
63 // effet de ligne..
64 static GMLine *gmline1 = nullptr;
65 static GMLine *gmline2 = nullptr;
66 
67 void choose_a_goom_line (float *param1, float *param2, int *couleur, int *mode, float *amplitude, int far);
68 
69 void goom_init (guint32 resx, guint32 resy, int cinemascope) {
70 #ifdef VERBOSE
71  printf ("GOOM: init (%d, %d);\n", resx, resy);
72 #endif
73  if (cinemascope)
74  c_black_height = resy / 5;
75  else
76  c_black_height = 0;
77 
78  resolx = resx;
79  resoly = resy;
80  buffsize = resx * resy;
81 
82  c_offset = c_black_height * resx;
83  c_resoly = resy - c_black_height * 2;
84 
85  pixel = (guint32 *) malloc (buffsize * sizeof (guint32) + 128);
86  back = (guint32 *) malloc (buffsize * sizeof (guint32) + 128);
87  //RAND_INIT ();
88  srand ((uintptr_t) pixel);
89  if (!rand_tab) rand_tab = (int *) malloc (NB_RAND * sizeof(int)) ;
90  rand_pos = 1 ;
91  while (rand_pos != 0) rand_tab [rand_pos++] = goom_rand () ;
92 
93  cycle = 0;
94 
95  p1 = (guint32 *) ((1 + ((uintptr_t) (pixel)) / 128) * 128);
96  p2 = (guint32 *) ((1 + ((uintptr_t) (back)) / 128) * 128);
97 
98  init_ifs (resx, c_resoly);
101 
102 // gfont_load ();
103 
104  tentacle_new ();
105 }
106 
107 
108 void goom_set_resolution (guint32 resx, guint32 resy, int cinemascope) {
109  free (pixel);
110  free (back);
111 
112  if (cinemascope)
113  c_black_height = resy / 8;
114  else
115  c_black_height = 0;
116 
117  c_offset = c_black_height * resx;
118  c_resoly = resy - c_black_height * 2;
119 
120  resolx = resx;
121  resoly = resy;
122  buffsize = resx * resy;
123 
124  pixel = (guint32 *) malloc (buffsize * sizeof (guint32) + 128);
125  memset (pixel, 0, buffsize * sizeof (guint32) + 128);
126  back = (guint32 *) malloc (buffsize * sizeof (guint32) + 128);
127  memset (back, 0, buffsize * sizeof (guint32) + 128);
128  p1 = (guint32 *) ((1 + ((uintptr_t) (pixel)) / 128) * 128);
129  p2 = (guint32 *) ((1 + ((uintptr_t) (back)) / 128) * 128);
130 
131  init_ifs (resx, c_resoly);
134 }
135 
136 
137 guint32 * goom_update (GoomDualData& data, int forceMode) {
138  static int s_lockVar = 0; // pour empecher de nouveaux changements
139  static int s_goomVar = 0; // boucle des gooms
140  static int s_totalGoom = 0; // nombre de gooms par seconds
141  static int s_aGoom = 0; // un goom a eu lieu..
142  static int s_aBigGoom = 0; // un big goom a eu lieu..
143  static int s_speedVar = 0; // vitesse des particules
144 
145  // duree de la transition entre afficher les lignes ou pas
146 #define DRAWLINES 80
147  static int s_lineMode = DRAWLINES; // l'effet lineaire a dessiner
148  static int s_nombreCddc = 0; // nombre de Cycle Depuis Dernier Changement
149  static int s_accelVar=0; // acceleration des particules
150  static int s_stopLines = 0;
151 
152  // des points
153  static int s_ifsIncr = 1; // dessiner l'ifs (0 = non: > = increment)
154  static int s_decayIfs = 0; // disparition de l'ifs
155  static int s_recayIfs = 0; // dédisparition de l'ifs
156 
157 #define SWITCHMULT (29.0F/30.0F)
158 #define SWITCHINCR 0x7f
159  static float s_switchMult = 1.0F;
160  static int s_switchIncr = SWITCHINCR;
161 
162  static char s_goomLimit = 2; // sensibilité du goom
163  static ZoomFilterData s_zfd = {
164  127, 8, 16,
165  1, 1, false, NORMAL_MODE,
166  0, 0, false, false, 0
167  };
168 
169  ZoomFilterData *pzfd = nullptr;
170 
171  /* test if the config has changed, update it if so */
172  guint32 pointWidth = (resolx * 2) / 5;
173  guint32 pointHeight = ((c_resoly) * 2) / 5;
174 
175  /* ! etude du signal ... */
176  int incvar = 0; // volume du son
177  for (int i = 0; i < 512; i++) {
178  if (incvar < data[0][i])
179  incvar = data[0][i];
180  }
181 
182  int i = s_accelVar;
183  s_accelVar = incvar / 1000;
184 
185  if (s_speedVar > 5) {
186  s_accelVar--;
187  if (s_speedVar > 20)
188  s_accelVar--;
189  if (s_speedVar > 40)
190  s_speedVar = 40;
191  }
192  s_accelVar--;
193 
194  i = s_accelVar - i;
195  if (i<0) i=-i;
196 
197  s_speedVar += (s_speedVar + i/2);
198  s_speedVar /= 2;
199  if ((s_speedVar) && (cycle%9==0)) {
200  s_speedVar -= 1;
201  }
202  if ((s_speedVar) && (cycle%5==0)) {
203  s_speedVar = (s_speedVar*7)/8;
204  }
205 
206  if (s_speedVar < 0)
207  s_speedVar = 0;
208  if (s_speedVar > 50)
209  s_speedVar = 50;
210 
211 
212  /* ! calcul du deplacement des petits points ... */
213 
214  // largfactor: elargissement de l'intervalle d'évolution
215  float largfactor = ((float) s_speedVar / 40.0F + (float) incvar / 50000.0F) / 1.5F;
216  if (largfactor > 1.5F)
217  largfactor = 1.5F;
218 
219  s_decayIfs--;
220  if (s_decayIfs > 0)
221  s_ifsIncr += 2;
222  if (s_decayIfs == 0)
223  s_ifsIncr = 0;
224 
225 
226  if (s_recayIfs) {
227  s_ifsIncr -= 2;
228  s_recayIfs--;
229  if ((s_recayIfs == 0)&&(s_ifsIncr<=0))
230  s_ifsIncr = 1;
231  }
232 
233  if (s_ifsIncr > 0)
234  ifs_update (p1 + c_offset, p2 + c_offset, resolx, c_resoly, s_ifsIncr);
235 
236  if (curGState->m_drawPoints) {
237  for (i = 1; i * 15 <= s_speedVar + 15; i++) {
238  static int s_loopVar = 0; // mouvement des points
239  s_loopVar += s_speedVar*2/3 + 1;
240 
242  ((pointWidth - 6.0F) * largfactor + 5.0F),
243  ((pointHeight - 6.0F) * largfactor + 5.0F),
244  i * 152.0F, 128.0F, s_loopVar + i * 2032);
246  ((pointWidth / 2.0F) * largfactor) / i + 10.0F * i,
247  ((pointHeight / 2.0F) * largfactor) / i + 10.0F * i,
248  96.0F, i * 80.0F, s_loopVar / i);
250  ((pointHeight / 3.0F + 5.0F) * largfactor) / i + 10.0F * i,
251  ((pointHeight / 3.0F + 5.0F) * largfactor) / i + 10.0F * i,
252  i + 122.0F, 134.0F, s_loopVar / i);
254  ((pointHeight / 3.0F) * largfactor + 20.0F),
255  ((pointHeight / 3.0F) * largfactor + 20.0F),
256  58.0F, i * 66.0F, s_loopVar / i);
258  (pointHeight * largfactor + 10.0F * i) / i,
259  (pointHeight * largfactor + 10.0F * i) / i,
260  66.0F, 74.0F, s_loopVar + i * 500); }
261  }
262 
263  // par défaut pas de changement de zoom
264  pzfd = nullptr;
265 
266  /*
267  * Test forceMode
268  */
269 #ifdef VERBOSE
270  if (forceMode != 0) {
271  printf ("forcemode = %d\n", forceMode);
272  }
273 #endif
274 
275 
276  // diminuer de 1 le temps de lockage
277  // note pour ceux qui n'ont pas suivis : le lockvar permet d'empecher un
278  // changement d'etat du plugins juste apres un autre changement d'etat. oki
279  //
280  // ?
281  if (--s_lockVar < 0)
282  s_lockVar = 0;
283 
284  // temps du goom
285  if (--s_aGoom < 0)
286  s_aGoom = 0;
287 
288  // temps du goom
289  if (--s_aBigGoom < 0)
290  s_aBigGoom = 0;
291 
292  if ((!s_aBigGoom) && (s_speedVar > 4) && (s_goomLimit > 4) &&
293  ((s_accelVar > s_goomLimit*9/8+7)||(s_accelVar < -s_goomLimit*9/8-7))) {
294  static int s_couleur =
295  (0xc0<<(ROUGE*8))
296  |(0xc0<<(VERT*8))
297  |(0xf0<<(BLEU*8))
298  |(0xf0<<(ALPHA*8));
299  s_aBigGoom = 100;
300  int size = resolx*c_resoly;
301  for (int j=0;j<size;j++)
302  (p1+c_offset)[j] = (~(p1+c_offset)[j]) | s_couleur;
303  }
304 
305  // on verifie qu'il ne se pas un truc interressant avec le son.
306  if ((s_accelVar > s_goomLimit) || (s_accelVar < -s_goomLimit) || (forceMode > 0)
307  || (s_nombreCddc > TIME_BTW_CHG)) {
308 
309 // if (nombreCDDC > 300) {
310 // }
311 
312  // UN GOOM !!! YAHOO !
313  s_totalGoom++;
314  s_aGoom = 20; // mais pdt 20 cycles, il n'y en aura plus.
315 
316  // changement eventuel de mode
317  if (iRAND(16) == 0)
318  {
319  switch (iRAND (32)) {
320  case 0:
321  case 10:
322  s_zfd.hypercosEffect = iRAND (2);
323  // Checked Fedora26 get-plugins-good sources.
324  // No break statement there.
325  [[clang::fallthrough]];
326  case 13:
327  case 20:
328  case 21:
329  s_zfd.mode = WAVE_MODE;
330  s_zfd.reverse = false;
331  s_zfd.waveEffect = (iRAND (3) == 0);
332  if (iRAND (2))
333  s_zfd.vitesse = (s_zfd.vitesse + 127) >> 1;
334  break;
335  case 1:
336  case 11:
337  s_zfd.mode = CRYSTAL_BALL_MODE;
338  s_zfd.waveEffect = false;
339  s_zfd.hypercosEffect = false;
340  break;
341  case 2:
342  case 12:
343  s_zfd.mode = AMULETTE_MODE;
344  s_zfd.waveEffect = false;
345  s_zfd.hypercosEffect = false;
346  break;
347  case 3:
348  s_zfd.mode = WATER_MODE;
349  s_zfd.waveEffect = false;
350  s_zfd.hypercosEffect = false;
351  break;
352  case 4:
353  case 14:
354  s_zfd.mode = SCRUNCH_MODE;
355  s_zfd.waveEffect = false;
356  s_zfd.hypercosEffect = false;
357  break;
358  case 5:
359  case 15:
360  case 22:
361  s_zfd.mode = HYPERCOS1_MODE;
362  s_zfd.waveEffect = false;
363  s_zfd.hypercosEffect = (iRAND (3) == 0);
364  break;
365  case 6:
366  case 16:
367  s_zfd.mode = HYPERCOS2_MODE;
368  s_zfd.waveEffect = false;
369  s_zfd.hypercosEffect = false;
370  break;
371  case 7:
372  case 17:
373  s_zfd.mode = CRYSTAL_BALL_MODE;
374  s_zfd.waveEffect = (iRAND (4) == 0);
375  s_zfd.hypercosEffect = iRAND (2);
376  break;
377  case 8:
378  case 18:
379  case 19:
380  s_zfd.mode = SCRUNCH_MODE;
381  s_zfd.waveEffect = true;
382  s_zfd.hypercosEffect = true;
383  break;
384  case 29:
385  case 30:
386  s_zfd.mode = YONLY_MODE;
387  break;
388  case 31:
389  case 32:
390  s_zfd.mode = SPEEDWAY_MODE;
391  break;
392  default:
393  s_zfd.mode = NORMAL_MODE;
394  s_zfd.waveEffect = false;
395  s_zfd.hypercosEffect = false;
396  }
397  }
398  }
399 
400  // tout ceci ne sera fait qu'en cas de non-blocage
401  if (s_lockVar == 0) {
402  // reperage de goom (acceleration forte de l'acceleration du volume)
403  // -> coup de boost de la vitesse si besoin..
404  if ((s_accelVar > s_goomLimit) || (s_accelVar < -s_goomLimit)) {
405  static int s_rndn = 0;
406  static int s_blocker = 0;
407  s_goomVar++;
408 
409  /* SELECTION OF THE GOOM STATE */
410  if ((!s_blocker)&&(iRAND(3))) {
411  s_rndn = iRAND(STATES_RANGEMAX);
412  s_blocker = 3;
413  }
414  else if (s_blocker) s_blocker--;
415 
416  (void)s_rndn; // Used in the lambda. Quiet warning.
417  auto goodstate = [&](auto state)
418  { return (s_rndn >= state.m_rangeMin) &&
419  (s_rndn <= state.m_rangeMax); };
420  const auto *it =
421  std::find_if(kStates.cbegin(), kStates.cend(), goodstate);
422  if (it != kStates.cend())
423  curGState = &(*it);
424 
425  if ((curGState->m_drawIfs) && (s_ifsIncr<=0)) {
426  s_recayIfs = 5;
427  s_ifsIncr = 11;
428  }
429 
430  if ((!curGState->m_drawIfs) && (s_ifsIncr>0) && (s_decayIfs<=0))
431  s_decayIfs = 100;
432 
433  if (!curGState->m_drawScope) {
434  s_stopLines = 0;
435  s_lineMode = DRAWLINES;
436  }
437 
438  // if (goomvar % 1 == 0)
439  {
440  s_lockVar = 50;
441  guint32 newvit = STOP_SPEED + 1 - (4.0F * log10f(s_speedVar+1));
442  // retablir le zoom avant..
443  // Pseudo-random is good enough. Don't need a true random.
444  // NOLINTNEXTLINE(cert-msc30-c,cert-msc50-cpp)
445  if ((s_zfd.reverse) && (!(cycle % 13)) && (rand () % 5 == 0)) {
446  s_zfd.reverse = false;
447  s_zfd.vitesse = STOP_SPEED - 2;
448  s_lockVar = 75;
449  }
450  if (iRAND (10) == 0) {
451  s_zfd.reverse = true;
452  s_lockVar = 100;
453  }
454 
455  if (iRAND (10) == 0)
456  s_zfd.vitesse = STOP_SPEED - 1;
457  if (iRAND (12) == 0)
458  s_zfd.vitesse = STOP_SPEED + 1;
459 
460  // changement de milieu..
461  switch (iRAND (25)) {
462  case 0:
463  case 3:
464  case 6:
465  s_zfd.middleY = c_resoly - 1;
466  s_zfd.middleX = resolx / 2;
467  break;
468  case 1:
469  case 4:
470  s_zfd.middleX = resolx - 1;
471  break;
472  case 2:
473  case 5:
474  s_zfd.middleX = 1;
475  break;
476  default:
477  s_zfd.middleY = c_resoly / 2;
478  s_zfd.middleX = resolx / 2;
479  }
480 
481  if ((s_zfd.mode == WATER_MODE)
482  || (s_zfd.mode == YONLY_MODE)
483  || (s_zfd.mode == AMULETTE_MODE)) {
484  s_zfd.middleX = resolx / 2;
485  s_zfd.middleY = c_resoly / 2;
486  }
487 
488  guint32 vtmp = iRAND (15);
489  switch (vtmp) {
490  case 0:
491 
492  // NOLINTNEXTLINE(misc-redundant-expression)
493  s_zfd.vPlaneEffect = iRAND (3) - iRAND (3);
494  // NOLINTNEXTLINE(misc-redundant-expression)
495  s_zfd.hPlaneEffect = iRAND (3) - iRAND (3);
496  break;
497  case 3:
498  s_zfd.vPlaneEffect = 0;
499  // NOLINTNEXTLINE(misc-redundant-expression)
500  s_zfd.hPlaneEffect = iRAND (8) - iRAND (8);
501  break;
502  case 4:
503  case 5:
504  case 6:
505  case 7:
506  // NOLINTNEXTLINE(misc-redundant-expression)
507  s_zfd.vPlaneEffect = iRAND (5) - iRAND (5);
508  s_zfd.hPlaneEffect = -s_zfd.vPlaneEffect;
509  break;
510  case 8:
511  s_zfd.hPlaneEffect = 5 + iRAND (8);
512  s_zfd.vPlaneEffect = -s_zfd.hPlaneEffect;
513  break;
514  case 9:
515  s_zfd.vPlaneEffect = 5 + iRAND (8);
516  s_zfd.hPlaneEffect = -s_zfd.hPlaneEffect;
517  break;
518  case 13:
519  s_zfd.hPlaneEffect = 0;
520  // NOLINTNEXTLINE(misc-redundant-expression)
521  s_zfd.vPlaneEffect = iRAND (10) - iRAND (10);
522  break;
523  case 14:
524  // NOLINTNEXTLINE(misc-redundant-expression)
525  s_zfd.hPlaneEffect = iRAND (10) - iRAND (10);
526  // NOLINTNEXTLINE(misc-redundant-expression)
527  s_zfd.vPlaneEffect = iRAND (10) - iRAND (10);
528  break;
529  default:
530  if (vtmp < 10) {
531  s_zfd.vPlaneEffect = 0;
532  s_zfd.hPlaneEffect = 0;
533  }
534  }
535 
536  if (iRAND (5) != 0)
537  s_zfd.noisify = 0;
538  else {
539  s_zfd.noisify = iRAND (2) + 1;
540  s_lockVar *= 2;
541  }
542 
543  if (s_zfd.mode == AMULETTE_MODE) {
544  s_zfd.vPlaneEffect = 0;
545  s_zfd.hPlaneEffect = 0;
546  s_zfd.noisify = 0;
547  }
548 
549  if ((s_zfd.middleX == 1) || (s_zfd.middleX == (int)resolx - 1)) {
550  s_zfd.vPlaneEffect = 0;
551  s_zfd.hPlaneEffect = iRAND (2) ? 0 : s_zfd.hPlaneEffect;
552  }
553 
554  if (newvit < (guint32)s_zfd.vitesse) // on accelere
555  {
556  pzfd = &s_zfd;
557  if (((newvit < STOP_SPEED - 7) &&
558  (s_zfd.vitesse < STOP_SPEED - 6) &&
559  (cycle % 3 == 0)) || (iRAND (40) == 0)) {
560  s_zfd.vitesse = STOP_SPEED - iRAND (2) + iRAND (2);
561  s_zfd.reverse = !s_zfd.reverse;
562  }
563  else {
564  s_zfd.vitesse = (newvit + s_zfd.vitesse * 7) / 8;
565  }
566  s_lockVar += 50;
567  }
568  }
569 
570  if (s_lockVar > 150) {
571  s_switchIncr = SWITCHINCR;
572  s_switchMult = 1.0F;
573  }
574  }
575  // mode mega-lent
576  if (iRAND (700) == 0) {
577  pzfd = &s_zfd;
578  s_zfd.vitesse = STOP_SPEED - 1;
579  s_zfd.pertedec = 8;
580  s_zfd.sqrtperte = 16;
581  s_goomVar = 1;
582  s_lockVar += 50;
583  s_switchIncr = SWITCHINCR;
584  s_switchMult = 1.0F;
585  }
586  }
587 
588  /*
589  * gros frein si la musique est calme
590  */
591  if ((s_speedVar < 1) && (s_zfd.vitesse < STOP_SPEED - 4) && (cycle % 16 == 0)) {
592  pzfd = &s_zfd;
593  s_zfd.vitesse += 3;
594  s_zfd.pertedec = 8;
595  s_zfd.sqrtperte = 16;
596  s_goomVar = 0;
597  }
598 
599  /*
600  * baisser regulierement la vitesse...
601  */
602  if ((cycle % 73 == 0) && (s_zfd.vitesse < STOP_SPEED - 5)) {
603  pzfd = &s_zfd;
604  s_zfd.vitesse++;
605  }
606 
607  /*
608  * arreter de decrémenter au bout d'un certain temps
609  */
610  if ((cycle % 101 == 0) && (s_zfd.pertedec == 7)) {
611  pzfd = &s_zfd;
612  s_zfd.pertedec = 8;
613  s_zfd.sqrtperte = 16;
614  }
615 
616  /*
617  * Permet de forcer un effet.
618  */
619  if ((forceMode > 0) && (forceMode <= NB_FX)) {
620  pzfd = &s_zfd;
621  pzfd->mode = forceMode - 1;
622  }
623 
624  if (forceMode == -1) {
625  pzfd = nullptr;
626  }
627 
628  /*
629  * Changement d'effet de zoom !
630  */
631  if (pzfd != nullptr) {
632  static int s_exvit = 128;
633 
634  s_nombreCddc = 0;
635 
636  s_switchIncr = SWITCHINCR;
637 
638  int dif = s_zfd.vitesse - s_exvit;
639  if (dif < 0)
640  dif = -dif;
641 
642  if (dif > 2) {
643  s_switchIncr *= (dif + 2) / 2;
644  }
645  s_exvit = s_zfd.vitesse;
646  s_switchMult = 1.0F;
647 
648  if (((s_accelVar > s_goomLimit) && (s_totalGoom < 2)) || (forceMode > 0)) {
649  s_switchIncr = 0;
650  s_switchMult = SWITCHMULT;
651  }
652  }
653  else {
654  if (s_nombreCddc > TIME_BTW_CHG) {
655  pzfd = &s_zfd;
656  s_nombreCddc = 0;
657  }
658  else
659  s_nombreCddc++;
660  }
661 
662 #ifdef VERBOSE
663  if (pzfd) {
664  printf ("GOOM: pzfd->mode = %d\n", pzfd->mode);
665  }
666 #endif
667 
668  // Zoom here !
669  zoomFilterFastRGB (p1 + c_offset, p2 + c_offset, pzfd, resolx, c_resoly, s_switchIncr, s_switchMult);
670 
671  /*
672  * Affichage tentacule
673  */
674 
675  if (s_goomLimit!=0)
676  tentacle_update((gint32*)(p2 + c_offset), (gint32*)(p1 + c_offset), resolx, c_resoly, data, (float)s_accelVar/s_goomLimit, curGState->m_drawTentacle);
677  else
679 
680 /*
681  {
682  static char title[1024];
683  static int displayTitle = 0;
684  char text[255];
685 
686  if (fps > 0) {
687  int i;
688  if (speedvar>0) {
689  for (i=0;i<speedvar;i++)
690  text[i]='*';
691  text[i]=0;
692  goom_draw_text (p1 + c_offset,resolx,c_resoly, 10, 50, text, 1.0F, 0);
693  }
694  if (accelvar>0) {
695  for (i=0;i<accelvar;i++) {
696  if (i==goomlimit)
697  text[i]='o';
698  else
699  text[i]='*';
700  }
701  text[i]=0;
702  goom_draw_text (p1 + c_offset,resolx,c_resoly, 10, 62, text, 1.0F, 0);
703  }
704  if (agoom==20)
705  goom_draw_text (p1 + c_offset,resolx,c_resoly,10, 80, "GOOM",1.0F, 0);
706  else if (agoom)
707  goom_draw_text (p1 + c_offset,resolx,c_resoly,10, 80, "goom",1.0F, 0);
708  if (abiggoom==200)
709  goom_draw_text (p1 + c_offset,resolx,c_resoly,10, 100, "BGOOM",1.0F, 0);
710  else if (abiggoom)
711  goom_draw_text (p1 + c_offset,resolx,c_resoly,10, 100, "bgoom",1.0F, 0);
712  }
713 
714  update_message (message);
715 
716  if (fps > 0) {
717  sprintf (text, "%2.f fps", fps);
718  goom_draw_text (p1 + c_offset,resolx,c_resoly, 10, 24, text, 1, 0);
719  }
720 
721  if (songTitle != NULL) {
722  sprintf (title, songTitle); // la flemme d'inclure string.h :)
723  displayTitle = 200;
724  }
725 
726  if (displayTitle) {
727  goom_draw_text (p1 + c_offset,resolx,c_resoly, resolx / 2, c_resoly / 2 + 7, title, ((float) (190 - displayTitle) / 10.0F), 1);
728  displayTitle--;
729  if (displayTitle < 4)
730  goom_draw_text (p2 + c_offset,resolx,c_resoly, resolx / 2, c_resoly / 2 + 7, title, ((float) (190 - displayTitle) / 10.0F), 1);
731  }
732  }
733 */
734 
735  /*
736  * arret demande
737  */
738  if ((s_stopLines & 0xf000)||(!curGState->m_drawScope)) {
739  float param1 = NAN;
740  float param2 = NAN;
741  float amplitude = NAN;
742  int couleur = 0;
743  int mode = 0;
744 
745  choose_a_goom_line (&param1, &param2, &couleur, &mode, &amplitude,1);
746  couleur = GML_BLACK;
747 
748  goom_lines_switch_to (gmline1, mode, param1, amplitude, couleur);
749  goom_lines_switch_to (gmline2, mode, param2, amplitude, couleur);
750  s_stopLines &= 0x0fff;
751  }
752 
753  /*
754  * arret aleatore.. changement de mode de ligne..
755  */
756  if (s_lineMode != DRAWLINES) {
757  s_lineMode--;
758  if (s_lineMode == -1)
759  s_lineMode = 0;
760  }
761  else
762  if ((cycle%80==0)&&(iRAND(5)==0)&&s_lineMode)
763  s_lineMode--;
764 
765  if ((cycle % 120 == 0)
766  && (iRAND (4) == 0)
767  && (curGState->m_drawScope)) {
768  if (s_lineMode == 0)
769  s_lineMode = DRAWLINES;
770  else if (s_lineMode == DRAWLINES) {
771  float param1 = NAN;
772  float param2 = NAN;
773  float amplitude = NAN;
774  int couleur1 = 0;
775  int couleur2 = 0;
776  int mode = 0;
777 
778  s_lineMode--;
779  choose_a_goom_line (&param1, &param2, &couleur1, &mode, &amplitude,s_stopLines);
780 
781  couleur2 = 5-couleur1;
782  if (s_stopLines) {
783  s_stopLines--;
784  if (iRAND(2))
785  couleur2=couleur1 = GML_BLACK;
786  }
787 
788  goom_lines_switch_to (gmline1, mode, param1, amplitude, couleur1);
789  goom_lines_switch_to (gmline2, mode, param2, amplitude, couleur2);
790  }
791  }
792 
793  /*
794  * si on est dans un goom : afficher les lignes...
795  */
796  if ((s_lineMode != 0) || (s_aGoom > 15)) {
798 
799  goom_lines_draw (gmline1, data[0], p2 + c_offset);
800  goom_lines_draw (gmline2, data[1], p2 + c_offset);
801 
802  if (((cycle % 121) == 9) && (iRAND (3) == 1)
803  && ((s_lineMode == 0) || (s_lineMode == DRAWLINES))) {
804  float param1 = NAN;
805  float param2 = NAN;
806  float amplitude = NAN;
807  int couleur1 = 0;
808  int couleur2 = 0;
809  int mode = 0;
810 
811  choose_a_goom_line (&param1, &param2, &couleur1, &mode, &amplitude, s_stopLines);
812  couleur2 = 5-couleur1;
813 
814  if (s_stopLines) {
815  s_stopLines--;
816  if (iRAND(2))
817  couleur2=couleur1 = GML_BLACK;
818  }
819  goom_lines_switch_to (gmline1, mode, param1, amplitude, couleur1);
820  goom_lines_switch_to (gmline2, mode, param2, amplitude, couleur2);
821  }
822  }
823 
824  guint32 *return_val = p1;
825  tmp = p1;
826  p1 = p2;
827  p2 = tmp;
828 
829  // affichage et swappage des buffers..
830  cycle++;
831 
832  // toute les 2 secondes : vérifier si le taux de goom est correct
833  // et le modifier sinon..
834  if (!(cycle % 64)) {
835  if (s_speedVar<1)
836  s_goomLimit /= 2;
837  if (s_totalGoom > 4) {
838  s_goomLimit++;
839  }
840  if (s_totalGoom > 7) {
841  s_goomLimit*=4/3;
842  s_goomLimit+=2;
843  }
844  if ((s_totalGoom == 0) && (s_goomLimit > 1))
845  s_goomLimit--;
846  if ((s_totalGoom == 1) && (s_goomLimit > 1))
847  s_goomLimit--;
848  s_totalGoom = 0;
849  }
850  return return_val;
851 }
852 
853 void goom_close () {
854  if (pixel != nullptr)
855  free (pixel);
856  if (back != nullptr)
857  free (back);
858  pixel = back = nullptr;
859  RAND_CLOSE ();
860  release_ifs ();
863  tentacle_free();
864 }
865 
866 
867 void choose_a_goom_line (float *param1, float *param2, int *couleur, int *mode, float *amplitude, int far) {
868  *mode = iRAND (3);
869  *amplitude = 1.0F;
870  switch (*mode) {
871  case GML_CIRCLE:
872  if (far) {
873  *param1 = *param2 = 0.47F;
874  *amplitude = 0.8F;
875  break;
876  }
877  if (iRAND (3) == 0) {
878  *param1 = *param2 = 0;
879  *amplitude = 3.0F;
880  }
881  else if (iRAND (2)) {
882  *param1 = 0.40F * c_resoly;
883  *param2 = 0.22F * c_resoly;
884  }
885  else {
886  *param1 = *param2 = c_resoly * 0.35;
887  }
888  break;
889  case GML_HLINE:
890  if (iRAND (4) || far) {
891  *param1 = c_resoly / 7.0F;
892  *param2 = 6.0F * c_resoly / 7.0F;
893  }
894  else {
895  *param1 = *param2 = c_resoly / 2.0F;
896  *amplitude = 2.0F;
897  }
898  break;
899  case GML_VLINE:
900  if (iRAND (3) || far) {
901  *param1 = resolx / 7.0F;
902  *param2 = 6.0F * resolx / 7.0F;
903  }
904  else {
905  *param1 = *param2 = resolx / 2.0F;
906  *amplitude = 1.5F;
907  }
908  break;
909  }
910 
911  *couleur = iRAND (6);
912 }
913 
914 /*
915 void goom_set_font (int ***chars, int *width, int *height) {
916  if (chars == nullptr)
917  return ;
918 }
919 */
920 
921 /*
922 void update_message (char *message) {
923 
924  static int nbl;
925  static char msg2 [0x800];
926  static int affiche = 0;
927  static int longueur;
928  int fin = 0;
929 
930  if (message) {
931  int i=1,j=0;
932  sprintf (msg2,message);
933  for (j=0;msg2[j];j++)
934  if (msg2[j]=='\n')
935  i++;
936  nbl = i;
937  affiche = resoly + nbl * 25 + 105;
938  longueur = strlen (msg2);
939  }
940  if (affiche) {
941  int i = 0;
942  char *msg=malloc(longueur+1);
943  char *ptr = msg;
944  int pos;
945  float ecart;
946  message = msg;
947  sprintf (msg,msg2);
948 
949  while (!fin) {
950  while (1) {
951  if (*ptr == 0) {
952  fin = 1;
953  break;
954  }
955  if (*ptr == '\n') {
956  *ptr = 0;
957  break;
958  }
959  ++ptr;
960  }
961  pos = affiche - (nbl-i)*25;
962  pos += 6.0*(cos((double)pos/20.0));
963  pos -= 80;
964  ecart = (1.0+2.0*sin((double)pos/20.0));
965  if ((fin) && (2 * pos < (int)resoly))
966  pos = (int)resoly / 2;
967  pos += 7;
968 
969  goom_draw_text(p1 + c_offset,resolx,c_resoly, resolx/2, pos, message, ecart, 1);
970  message = ++ptr;
971  i++;
972  }
973  affiche --;
974  free (msg);
975  }
976 }
977 */
978 
980 {
981  static std::random_device rd;
982  static std::mt19937 mt(rd());
983  return mt();
984 }
GoomDualData
std::array< GoomSingleData, 2 > GoomDualData
Definition: goom_core.h:12
buffsize
guint32 buffsize
Definition: goom_core.cpp:61
lines.h
VIOLET
const Color VIOLET
Definition: graphic.cpp:10
goom_lines_init
GMLine * goom_lines_init(int rx, int ry, int IDsrc, float paramS, int coulS, int IDdest, float paramD, int coulD)
Definition: lines.cpp:155
back
static guint32 * back
Definition: goom_core.cpp:30
gint32
#define gint32
Definition: goomconfig.h:38
ZoomFilterData::sqrtperte
unsigned char sqrtperte
Definition: filters.h:14
goom_lines_switch_to
void goom_lines_switch_to(GMLine *gml, int IDdest, float param, float amplitude, int col)
Definition: lines.cpp:143
GML_CIRCLE
#define GML_CIRCLE
Definition: lines.h:42
gmline2
static GMLine * gmline2
Definition: goom_core.cpp:65
GoomState::m_drawPoints
int m_drawPoints
Definition: goom_core.cpp:36
GML_BLACK
#define GML_BLACK
Definition: lines.h:59
ifs_update
void ifs_update(guint32 *data, const guint32 *back, int width, int height, int increment)
Definition: ifs_display.cpp:13
NORMAL_MODE
#define NORMAL_MODE
Definition: filters.h:29
ZoomFilterData::reverse
bool reverse
Definition: filters.h:16
pointFilter
void pointFilter(Uint *pix1, Color c, float t1, float t2, float t3, float t4, Uint cycle)
Definition: filters.cpp:730
ZoomFilterData::waveEffect
bool waveEffect
Definition: filters.h:22
pixel
static guint32 * pixel
--------------------------------------------------—**
Definition: goom_core.cpp:29
GMLine::power
float power
Definition: lines.h:37
goom_lines_free
void goom_lines_free(GMLine **l)
Definition: lines.cpp:192
GoomState::m_rangeMin
int m_rangeMin
Definition: goom_core.cpp:42
GoomState
Definition: goom_core.cpp:34
NB_RAND
#define NB_RAND
Definition: goom_tools.h:9
goom_set_resolution
void goom_set_resolution(guint32 resx, guint32 resy, int cinemascope)
Definition: goom_core.cpp:108
tmp
static guint32 * tmp
Definition: goom_core.cpp:31
GML_HLINE
#define GML_HLINE
Definition: lines.h:45
iRAND
#define iRAND(i)
Definition: goom_tools.h:33
resoly
guint32 resoly
Definition: goom_core.cpp:61
GML_RED
#define GML_RED
Definition: lines.h:54
goom_lines_set_res
void goom_lines_set_res(GMLine *gml, int rx, int ry)
Definition: lines.cpp:96
TIME_BTW_CHG
#define TIME_BTW_CHG
Definition: goom_core.cpp:24
filters.h
ZoomFilterData::vitesse
int vitesse
Definition: filters.h:11
if
if(query.exec() &&query.next())
Definition: mythplugins/mytharchive/mytharchivehelper/main.cpp:461
DRAWLINES
#define DRAWLINES
zoomFilterFastRGB
void zoomFilterFastRGB(Uint *pix1, Uint *pix2, ZoomFilterData *zf, Uint resx, Uint resy, int switchIncr, float switchMult)
Definition: filters.cpp:495
ZoomFilterData::noisify
char noisify
Definition: filters.h:25
resolx
guint32 resolx
Definition: goom_core.cpp:61
tentacle_free
void tentacle_free(void)
Definition: tentacle3d.cpp:20
tentacle_new
void tentacle_new(void)
Definition: tentacle3d.cpp:27
goom_lines_draw
void goom_lines_draw(GMLine *line, const GoomSingleData &data, unsigned int *p)
Definition: lines.cpp:201
tentacle_update
void tentacle_update(int *buf, int *back, int W, int H, GoomDualData &data, float rapport, int drawit)
Definition: tentacle3d.cpp:140
ifs.h
ZoomFilterData::hypercosEffect
bool hypercosEffect
Definition: filters.h:23
goom_rand
guint32 goom_rand(void)
Definition: goom_core.cpp:979
WAVE_MODE
#define WAVE_MODE
Definition: filters.h:30
STATES_RANGEMAX
#define STATES_RANGEMAX
Definition: goom_core.cpp:47
tentacle3d.h
GML_VLINE
#define GML_VLINE
Definition: lines.h:48
GoomState::m_drawIfs
int m_drawIfs
Definition: goom_core.cpp:35
goom_core.h
p2
static guint32 * p2
Definition: goom_core.cpp:31
ZoomFilterData::pertedec
unsigned char pertedec
Definition: filters.h:13
GML_VERT
#define GML_VERT
Definition: lines.h:57
GoomState::m_drawTentacle
int m_drawTentacle
Definition: goom_core.cpp:37
c_offset
guint32 c_offset
Definition: goom_core.cpp:61
CRYSTAL_BALL_MODE
#define CRYSTAL_BALL_MODE
Definition: filters.h:31
gmline1
static GMLine * gmline1
Definition: goom_core.cpp:64
SWITCHINCR
#define SWITCHINCR
NB_FX
#define NB_FX
Definition: goom_core.h:9
kStates
const std::array< const GoomState, STATES_NB > kStates
Definition: goom_core.cpp:48
GMLine
Definition: lines.h:22
goom_init
void goom_init(guint32 resx, guint32 resy, int cinemascope)
Definition: goom_core.cpp:69
RAND_CLOSE
#define RAND_CLOSE()
Definition: goom_tools.h:27
SCRUNCH_MODE
#define SCRUNCH_MODE
Definition: filters.h:32
choose_a_goom_line
void choose_a_goom_line(float *param1, float *param2, int *couleur, int *mode, float *amplitude, int far)
Definition: goom_core.cpp:867
SWITCHMULT
#define SWITCHMULT
p1
static guint32 * p1
Definition: goom_core.cpp:31
BLACK
const Color BLACK
Definition: graphic.cpp:3
GoomState::m_rangeMax
int m_rangeMax
Definition: goom_core.cpp:43
goom_update
guint32 * goom_update(GoomDualData &data, int forceMode)
Definition: goom_core.cpp:137
YONLY_MODE
#define YONLY_MODE
Definition: filters.h:37
goom_close
void goom_close()
Definition: goom_core.cpp:853
ZoomFilterData
Definition: filters.h:10
rand_pos
static unsigned short rand_pos
Definition: goom_tools.h:13
ZoomFilterData::middleX
int middleX
Definition: filters.h:15
BLEU
#define BLEU
Definition: goomconfig.h:11
ORANGE
const Color ORANGE
Definition: graphic.cpp:9
cycle
static guint32 cycle
Definition: goom_core.cpp:32
goom_tools.h
ROUGE
#define ROUGE
position des composantes
Definition: goomconfig.h:10
rand_tab
int * rand_tab
Definition: graphic.cpp:16
WATER_MODE
#define WATER_MODE
Definition: filters.h:34
HYPERCOS2_MODE
#define HYPERCOS2_MODE
Definition: filters.h:36
AMULETTE_MODE
#define AMULETTE_MODE
Definition: filters.h:33
c_resoly
guint32 c_resoly
Definition: goom_core.cpp:61
ZoomFilterData::vPlaneEffect
int vPlaneEffect
Definition: filters.h:20
ZoomFilterData::mode
char mode
Definition: filters.h:17
VERT
#define VERT
Definition: goomconfig.h:12
STOP_SPEED
#define STOP_SPEED
Definition: goom_core.cpp:22
release_ifs
void release_ifs()
Definition: ifs.cpp:528
guint32
#define guint32
Definition: goomconfig.h:35
GoomState::m_drawScope
int m_drawScope
Definition: goom_core.cpp:39
SPEEDWAY_MODE
#define SPEEDWAY_MODE
Definition: filters.h:38
c_black_height
guint32 c_black_height
Definition: goom_core.cpp:61
ZoomFilterData::hPlaneEffect
int hPlaneEffect
Definition: filters.h:19
HYPERCOS1_MODE
#define HYPERCOS1_MODE
Definition: filters.h:35
curGState
const GoomState * curGState
Definition: goom_core.cpp:59
WHITE
const Color WHITE
Definition: graphic.cpp:4
init_ifs
void init_ifs(int width, int height)
Definition: ifs.cpp:209
ALPHA
#define ALPHA
Definition: goomconfig.h:13
YELLOW
const Color YELLOW
Definition: graphic.cpp:8
GoomState::m_farScope
int m_farScope
Definition: goom_core.cpp:40
ZoomFilterData::middleY
int middleY
Definition: filters.h:15