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  for (auto state : kStates) {
417  if ((s_rndn >= state.m_rangeMin)
418  && (s_rndn <= state.m_rangeMax)) {
419  curGState = &state;
420  break;
421  }
422  }
423 
424  if ((curGState->m_drawIfs) && (s_ifsIncr<=0)) {
425  s_recayIfs = 5;
426  s_ifsIncr = 11;
427  }
428 
429  if ((!curGState->m_drawIfs) && (s_ifsIncr>0) && (s_decayIfs<=0))
430  s_decayIfs = 100;
431 
432  if (!curGState->m_drawScope)
433  s_stopLines = 0xf000 & 5;
434 
435  if (!curGState->m_drawScope) {
436  s_stopLines = 0;
437  s_lineMode = DRAWLINES;
438  }
439 
440  // if (goomvar % 1 == 0)
441  {
442  s_lockVar = 50;
443  guint32 newvit = STOP_SPEED + 1 - (4.0F * log10f(s_speedVar+1));
444  // retablir le zoom avant..
445  // Pseudo-random is good enough. Don't need a true random.
446  // NOLINTNEXTLINE(cert-msc30-c,cert-msc50-cpp)
447  if ((s_zfd.reverse) && (!(cycle % 13)) && (rand () % 5 == 0)) {
448  s_zfd.reverse = false;
449  s_zfd.vitesse = STOP_SPEED - 2;
450  s_lockVar = 75;
451  }
452  if (iRAND (10) == 0) {
453  s_zfd.reverse = true;
454  s_lockVar = 100;
455  }
456 
457  if (iRAND (10) == 0)
458  s_zfd.vitesse = STOP_SPEED - 1;
459  if (iRAND (12) == 0)
460  s_zfd.vitesse = STOP_SPEED + 1;
461 
462  // changement de milieu..
463  switch (iRAND (25)) {
464  case 0:
465  case 3:
466  case 6:
467  s_zfd.middleY = c_resoly - 1;
468  s_zfd.middleX = resolx / 2;
469  break;
470  case 1:
471  case 4:
472  s_zfd.middleX = resolx - 1;
473  break;
474  case 2:
475  case 5:
476  s_zfd.middleX = 1;
477  break;
478  default:
479  s_zfd.middleY = c_resoly / 2;
480  s_zfd.middleX = resolx / 2;
481  }
482 
483  if ((s_zfd.mode == WATER_MODE)
484  || (s_zfd.mode == YONLY_MODE)
485  || (s_zfd.mode == AMULETTE_MODE)) {
486  s_zfd.middleX = resolx / 2;
487  s_zfd.middleY = c_resoly / 2;
488  }
489 
490  guint32 vtmp = iRAND (15);
491  switch (vtmp) {
492  case 0:
493 
494  // NOLINTNEXTLINE(misc-redundant-expression)
495  s_zfd.vPlaneEffect = iRAND (3) - iRAND (3);
496  // NOLINTNEXTLINE(misc-redundant-expression)
497  s_zfd.hPlaneEffect = iRAND (3) - iRAND (3);
498  break;
499  case 3:
500  s_zfd.vPlaneEffect = 0;
501  // NOLINTNEXTLINE(misc-redundant-expression)
502  s_zfd.hPlaneEffect = iRAND (8) - iRAND (8);
503  break;
504  case 4:
505  case 5:
506  case 6:
507  case 7:
508  // NOLINTNEXTLINE(misc-redundant-expression)
509  s_zfd.vPlaneEffect = iRAND (5) - iRAND (5);
510  s_zfd.hPlaneEffect = -s_zfd.vPlaneEffect;
511  break;
512  case 8:
513  s_zfd.hPlaneEffect = 5 + iRAND (8);
514  s_zfd.vPlaneEffect = -s_zfd.hPlaneEffect;
515  break;
516  case 9:
517  s_zfd.vPlaneEffect = 5 + iRAND (8);
518  s_zfd.hPlaneEffect = -s_zfd.hPlaneEffect;
519  break;
520  case 13:
521  s_zfd.hPlaneEffect = 0;
522  // NOLINTNEXTLINE(misc-redundant-expression)
523  s_zfd.vPlaneEffect = iRAND (10) - iRAND (10);
524  break;
525  case 14:
526  // NOLINTNEXTLINE(misc-redundant-expression)
527  s_zfd.hPlaneEffect = iRAND (10) - iRAND (10);
528  // NOLINTNEXTLINE(misc-redundant-expression)
529  s_zfd.vPlaneEffect = iRAND (10) - iRAND (10);
530  break;
531  default:
532  if (vtmp < 10) {
533  s_zfd.vPlaneEffect = 0;
534  s_zfd.hPlaneEffect = 0;
535  }
536  }
537 
538  if (iRAND (5) != 0)
539  s_zfd.noisify = 0;
540  else {
541  s_zfd.noisify = iRAND (2) + 1;
542  s_lockVar *= 2;
543  }
544 
545  if (s_zfd.mode == AMULETTE_MODE) {
546  s_zfd.vPlaneEffect = 0;
547  s_zfd.hPlaneEffect = 0;
548  s_zfd.noisify = 0;
549  }
550 
551  if ((s_zfd.middleX == 1) || (s_zfd.middleX == (int)resolx - 1)) {
552  s_zfd.vPlaneEffect = 0;
553  s_zfd.hPlaneEffect = iRAND (2) ? 0 : s_zfd.hPlaneEffect;
554  }
555 
556  if (newvit < (guint32)s_zfd.vitesse) // on accelere
557  {
558  pzfd = &s_zfd;
559  if (((newvit < STOP_SPEED - 7) &&
560  (s_zfd.vitesse < STOP_SPEED - 6) &&
561  (cycle % 3 == 0)) || (iRAND (40) == 0)) {
562  s_zfd.vitesse = STOP_SPEED - iRAND (2) + iRAND (2);
563  s_zfd.reverse = !s_zfd.reverse;
564  }
565  else {
566  s_zfd.vitesse = (newvit + s_zfd.vitesse * 7) / 8;
567  }
568  s_lockVar += 50;
569  }
570  }
571 
572  if (s_lockVar > 150) {
573  s_switchIncr = SWITCHINCR;
574  s_switchMult = 1.0F;
575  }
576  }
577  // mode mega-lent
578  if (iRAND (700) == 0) {
579  pzfd = &s_zfd;
580  s_zfd.vitesse = STOP_SPEED - 1;
581  s_zfd.pertedec = 8;
582  s_zfd.sqrtperte = 16;
583  s_goomVar = 1;
584  s_lockVar += 50;
585  s_switchIncr = SWITCHINCR;
586  s_switchMult = 1.0F;
587  }
588  }
589 
590  /*
591  * gros frein si la musique est calme
592  */
593  if ((s_speedVar < 1) && (s_zfd.vitesse < STOP_SPEED - 4) && (cycle % 16 == 0)) {
594  pzfd = &s_zfd;
595  s_zfd.vitesse += 3;
596  s_zfd.pertedec = 8;
597  s_zfd.sqrtperte = 16;
598  s_goomVar = 0;
599  }
600 
601  /*
602  * baisser regulierement la vitesse...
603  */
604  if ((cycle % 73 == 0) && (s_zfd.vitesse < STOP_SPEED - 5)) {
605  pzfd = &s_zfd;
606  s_zfd.vitesse++;
607  }
608 
609  /*
610  * arreter de decrémenter au bout d'un certain temps
611  */
612  if ((cycle % 101 == 0) && (s_zfd.pertedec == 7)) {
613  pzfd = &s_zfd;
614  s_zfd.pertedec = 8;
615  s_zfd.sqrtperte = 16;
616  }
617 
618  /*
619  * Permet de forcer un effet.
620  */
621  if ((forceMode > 0) && (forceMode <= NB_FX)) {
622  pzfd = &s_zfd;
623  pzfd->mode = forceMode - 1;
624  }
625 
626  if (forceMode == -1) {
627  pzfd = nullptr;
628  }
629 
630  /*
631  * Changement d'effet de zoom !
632  */
633  if (pzfd != nullptr) {
634  static int s_exvit = 128;
635 
636  s_nombreCddc = 0;
637 
638  s_switchIncr = SWITCHINCR;
639 
640  int dif = s_zfd.vitesse - s_exvit;
641  if (dif < 0)
642  dif = -dif;
643 
644  if (dif > 2) {
645  s_switchIncr *= (dif + 2) / 2;
646  }
647  s_exvit = s_zfd.vitesse;
648  s_switchMult = 1.0F;
649 
650  if (((s_accelVar > s_goomLimit) && (s_totalGoom < 2)) || (forceMode > 0)) {
651  s_switchIncr = 0;
652  s_switchMult = SWITCHMULT;
653  }
654  }
655  else {
656  if (s_nombreCddc > TIME_BTW_CHG) {
657  pzfd = &s_zfd;
658  s_nombreCddc = 0;
659  }
660  else
661  s_nombreCddc++;
662  }
663 
664 #ifdef VERBOSE
665  if (pzfd) {
666  printf ("GOOM: pzfd->mode = %d\n", pzfd->mode);
667  }
668 #endif
669 
670  // Zoom here !
671  zoomFilterFastRGB (p1 + c_offset, p2 + c_offset, pzfd, resolx, c_resoly, s_switchIncr, s_switchMult);
672 
673  /*
674  * Affichage tentacule
675  */
676 
677  if (s_goomLimit!=0)
678  tentacle_update((gint32*)(p2 + c_offset), (gint32*)(p1 + c_offset), resolx, c_resoly, data, (float)s_accelVar/s_goomLimit, curGState->m_drawTentacle);
679  else
681 
682 /*
683  {
684  static char title[1024];
685  static int displayTitle = 0;
686  char text[255];
687 
688  if (fps > 0) {
689  int i;
690  if (speedvar>0) {
691  for (i=0;i<speedvar;i++)
692  text[i]='*';
693  text[i]=0;
694  goom_draw_text (p1 + c_offset,resolx,c_resoly, 10, 50, text, 1.0F, 0);
695  }
696  if (accelvar>0) {
697  for (i=0;i<accelvar;i++) {
698  if (i==goomlimit)
699  text[i]='o';
700  else
701  text[i]='*';
702  }
703  text[i]=0;
704  goom_draw_text (p1 + c_offset,resolx,c_resoly, 10, 62, text, 1.0F, 0);
705  }
706  if (agoom==20)
707  goom_draw_text (p1 + c_offset,resolx,c_resoly,10, 80, "GOOM",1.0F, 0);
708  else if (agoom)
709  goom_draw_text (p1 + c_offset,resolx,c_resoly,10, 80, "goom",1.0F, 0);
710  if (abiggoom==200)
711  goom_draw_text (p1 + c_offset,resolx,c_resoly,10, 100, "BGOOM",1.0F, 0);
712  else if (abiggoom)
713  goom_draw_text (p1 + c_offset,resolx,c_resoly,10, 100, "bgoom",1.0F, 0);
714  }
715 
716  update_message (message);
717 
718  if (fps > 0) {
719  sprintf (text, "%2.f fps", fps);
720  goom_draw_text (p1 + c_offset,resolx,c_resoly, 10, 24, text, 1, 0);
721  }
722 
723  if (songTitle != NULL) {
724  sprintf (title, songTitle); // la flemme d'inclure string.h :)
725  displayTitle = 200;
726  }
727 
728  if (displayTitle) {
729  goom_draw_text (p1 + c_offset,resolx,c_resoly, resolx / 2, c_resoly / 2 + 7, title, ((float) (190 - displayTitle) / 10.0F), 1);
730  displayTitle--;
731  if (displayTitle < 4)
732  goom_draw_text (p2 + c_offset,resolx,c_resoly, resolx / 2, c_resoly / 2 + 7, title, ((float) (190 - displayTitle) / 10.0F), 1);
733  }
734  }
735 */
736 
737  /*
738  * arret demande
739  */
740  if ((s_stopLines & 0xf000)||(!curGState->m_drawScope)) {
741  float param1 = NAN;
742  float param2 = NAN;
743  float amplitude = NAN;
744  int couleur = 0;
745  int mode = 0;
746 
747  choose_a_goom_line (&param1, &param2, &couleur, &mode, &amplitude,1);
748  couleur = GML_BLACK;
749 
750  goom_lines_switch_to (gmline1, mode, param1, amplitude, couleur);
751  goom_lines_switch_to (gmline2, mode, param2, amplitude, couleur);
752  s_stopLines &= 0x0fff;
753  }
754 
755  /*
756  * arret aleatore.. changement de mode de ligne..
757  */
758  if (s_lineMode != DRAWLINES) {
759  s_lineMode--;
760  if (s_lineMode == -1)
761  s_lineMode = 0;
762  }
763  else
764  if ((cycle%80==0)&&(iRAND(5)==0)&&s_lineMode)
765  s_lineMode--;
766 
767  if ((cycle % 120 == 0)
768  && (iRAND (4) == 0)
769  && (curGState->m_drawScope)) {
770  if (s_lineMode == 0)
771  s_lineMode = DRAWLINES;
772  else if (s_lineMode == DRAWLINES) {
773  float param1 = NAN;
774  float param2 = NAN;
775  float amplitude = NAN;
776  int couleur1 = 0;
777  int couleur2 = 0;
778  int mode = 0;
779 
780  s_lineMode--;
781  choose_a_goom_line (&param1, &param2, &couleur1, &mode, &amplitude,s_stopLines);
782 
783  couleur2 = 5-couleur1;
784  if (s_stopLines) {
785  s_stopLines--;
786  if (iRAND(2))
787  couleur2=couleur1 = GML_BLACK;
788  }
789 
790  goom_lines_switch_to (gmline1, mode, param1, amplitude, couleur1);
791  goom_lines_switch_to (gmline2, mode, param2, amplitude, couleur2);
792  }
793  }
794 
795  /*
796  * si on est dans un goom : afficher les lignes...
797  */
798  if ((s_lineMode != 0) || (s_aGoom > 15)) {
800 
801  goom_lines_draw (gmline1, data[0], p2 + c_offset);
802  goom_lines_draw (gmline2, data[1], p2 + c_offset);
803 
804  if (((cycle % 121) == 9) && (iRAND (3) == 1)
805  && ((s_lineMode == 0) || (s_lineMode == DRAWLINES))) {
806  float param1 = NAN;
807  float param2 = NAN;
808  float amplitude = NAN;
809  int couleur1 = 0;
810  int couleur2 = 0;
811  int mode = 0;
812 
813  choose_a_goom_line (&param1, &param2, &couleur1, &mode, &amplitude, s_stopLines);
814  couleur2 = 5-couleur1;
815 
816  if (s_stopLines) {
817  s_stopLines--;
818  if (iRAND(2))
819  couleur2=couleur1 = GML_BLACK;
820  }
821  goom_lines_switch_to (gmline1, mode, param1, amplitude, couleur1);
822  goom_lines_switch_to (gmline2, mode, param2, amplitude, couleur2);
823  }
824  }
825 
826  guint32 *return_val = p1;
827  tmp = p1;
828  p1 = p2;
829  p2 = tmp;
830 
831  // affichage et swappage des buffers..
832  cycle++;
833 
834  // toute les 2 secondes : vérifier si le taux de goom est correct
835  // et le modifier sinon..
836  if (!(cycle % 64)) {
837  if (s_speedVar<1)
838  s_goomLimit /= 2;
839  if (s_totalGoom > 4) {
840  s_goomLimit++;
841  }
842  if (s_totalGoom > 7) {
843  s_goomLimit*=4/3;
844  s_goomLimit+=2;
845  }
846  if ((s_totalGoom == 0) && (s_goomLimit > 1))
847  s_goomLimit--;
848  if ((s_totalGoom == 1) && (s_goomLimit > 1))
849  s_goomLimit--;
850  s_totalGoom = 0;
851  }
852  return return_val;
853 }
854 
855 void goom_close () {
856  if (pixel != nullptr)
857  free (pixel);
858  if (back != nullptr)
859  free (back);
860  pixel = back = nullptr;
861  RAND_CLOSE ();
862  release_ifs ();
865  tentacle_free();
866 }
867 
868 
869 void choose_a_goom_line (float *param1, float *param2, int *couleur, int *mode, float *amplitude, int far) {
870  *mode = iRAND (3);
871  *amplitude = 1.0F;
872  switch (*mode) {
873  case GML_CIRCLE:
874  if (far) {
875  *param1 = *param2 = 0.47F;
876  *amplitude = 0.8F;
877  break;
878  }
879  if (iRAND (3) == 0) {
880  *param1 = *param2 = 0;
881  *amplitude = 3.0F;
882  }
883  else if (iRAND (2)) {
884  *param1 = 0.40F * c_resoly;
885  *param2 = 0.22F * c_resoly;
886  }
887  else {
888  *param1 = *param2 = c_resoly * 0.35;
889  }
890  break;
891  case GML_HLINE:
892  if (iRAND (4) || far) {
893  *param1 = c_resoly / 7.0F;
894  *param2 = 6.0F * c_resoly / 7.0F;
895  }
896  else {
897  *param1 = *param2 = c_resoly / 2.0F;
898  *amplitude = 2.0F;
899  }
900  break;
901  case GML_VLINE:
902  if (iRAND (3) || far) {
903  *param1 = resolx / 7.0F;
904  *param2 = 6.0F * resolx / 7.0F;
905  }
906  else {
907  *param1 = *param2 = resolx / 2.0F;
908  *amplitude = 1.5F;
909  }
910  break;
911  }
912 
913  *couleur = iRAND (6);
914 }
915 
916 /*
917 void goom_set_font (int ***chars, int *width, int *height) {
918  if (chars == nullptr)
919  return ;
920 }
921 */
922 
923 /*
924 void update_message (char *message) {
925 
926  static int nbl;
927  static char msg2 [0x800];
928  static int affiche = 0;
929  static int longueur;
930  int fin = 0;
931 
932  if (message) {
933  int i=1,j=0;
934  sprintf (msg2,message);
935  for (j=0;msg2[j];j++)
936  if (msg2[j]=='\n')
937  i++;
938  nbl = i;
939  affiche = resoly + nbl * 25 + 105;
940  longueur = strlen (msg2);
941  }
942  if (affiche) {
943  int i = 0;
944  char *msg=malloc(longueur+1);
945  char *ptr = msg;
946  int pos;
947  float ecart;
948  message = msg;
949  sprintf (msg,msg2);
950 
951  while (!fin) {
952  while (1) {
953  if (*ptr == 0) {
954  fin = 1;
955  break;
956  }
957  if (*ptr == '\n') {
958  *ptr = 0;
959  break;
960  }
961  ++ptr;
962  }
963  pos = affiche - (nbl-i)*25;
964  pos += 6.0*(cos((double)pos/20.0));
965  pos -= 80;
966  ecart = (1.0+2.0*sin((double)pos/20.0));
967  if ((fin) && (2 * pos < (int)resoly))
968  pos = (int)resoly / 2;
969  pos += 7;
970 
971  goom_draw_text(p1 + c_offset,resolx,c_resoly, resolx/2, pos, message, ecart, 1);
972  message = ++ptr;
973  i++;
974  }
975  affiche --;
976  free (msg);
977  }
978 }
979 */
980 
982 {
983  static std::random_device rd;
984  static std::mt19937 mt(rd());
985  return mt();
986 }
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:157
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:145
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:732
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:194
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:98
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:464
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:203
tentacle_update
void tentacle_update(int *buf, int *back, int W, int H, GoomDualData &data, float rapport, int drawit)
Definition: tentacle3d.cpp:142
ifs.h
ZoomFilterData::hypercosEffect
bool hypercosEffect
Definition: filters.h:23
goom_rand
guint32 goom_rand(void)
Definition: goom_core.cpp:981
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:869
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:855
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