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