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