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 
11 #include "goom_core.h"
12 #include "goom_tools.h"
13 #include "filters.h"
14 #include "lines.h"
15 #include "ifs.h"
16 #include "tentacle3d.h"
17 //#include "gfontlib.h"
18 
19 //#define VERBOSE
20 
21 #define STOP_SPEED 128
22 
23 #define TIME_BTW_CHG 300
24 
28 static guint32 *pixel;
29 static guint32 *back;
30 static guint32 *p1, *p2, *tmp;
31 static guint32 cycle;
32 
33 struct GoomState {
34  int m_drawIfs;
37 
40 
43 };
44 
45 #define STATES_NB 8
46 #define STATES_RANGEMAX 510
48  {1,0,0,1,4, 000, 100},
49  {1,0,0,1,1, 101, 140}, // turned on drawScope
50  {1,0,0,1,2, 141, 200},
51  {0,1,0,1,2, 201, 260},
52  {0,1,0,1,0, 261, 330},
53  {0,1,1,1,4, 331, 400},
54  {0,0,1,1,5, 401, 450}, // turned on drawScope
55  {0,0,1,1,1, 451, 510}
56 };
57 
59 
60 guint32 resolx, resoly, buffsize, c_black_height = 0, c_offset = 0, c_resoly = 0; /* avec prise en compte de ca */
61 
62 // effet de ligne..
63 static GMLine *gmline1 = nullptr;
64 static GMLine *gmline2 = nullptr;
65 
66 void choose_a_goom_line (float *param1, float *param2, int *couleur, int *mode, float *amplitude, int far);
67 
68 void goom_init (guint32 resx, guint32 resy, int cinemascope) {
69 #ifdef VERBOSE
70  printf ("GOOM: init (%d, %d);\n", resx, resy);
71 #endif
72  if (cinemascope)
73  c_black_height = resy / 5;
74  else
75  c_black_height = 0;
76 
77  resolx = resx;
78  resoly = resy;
79  buffsize = resx * resy;
80 
81  c_offset = c_black_height * resx;
82  c_resoly = resy - c_black_height * 2;
83 
84  pixel = (guint32 *) malloc (buffsize * sizeof (guint32) + 128);
85  back = (guint32 *) malloc (buffsize * sizeof (guint32) + 128);
86  //RAND_INIT ();
87  srand ((uintptr_t) pixel);
88  if (!rand_tab) rand_tab = (int *) malloc (NB_RAND * sizeof(int)) ;
89  rand_pos = 1 ;
90  // Pseudo-random is good enough. Don't need a true random.
91  // NOLINTNEXTLINE(cert-msc30-c,cert-msc50-cpp)
92  while (rand_pos != 0) rand_tab [rand_pos++] = rand () ;
93 
94  cycle = 0;
95 
96  p1 = (guint32 *) ((1 + ((uintptr_t) (pixel)) / 128) * 128);
97  p2 = (guint32 *) ((1 + ((uintptr_t) (back)) / 128) * 128);
98 
99  init_ifs (resx, c_resoly);
102 
103 // gfont_load ();
104 
105  tentacle_new ();
106 }
107 
108 
109 void goom_set_resolution (guint32 resx, guint32 resy, int cinemascope) {
110  free (pixel);
111  free (back);
112 
113  if (cinemascope)
114  c_black_height = resy / 8;
115  else
116  c_black_height = 0;
117 
118  c_offset = c_black_height * resx;
119  c_resoly = resy - c_black_height * 2;
120 
121  resolx = resx;
122  resoly = resy;
123  buffsize = resx * resy;
124 
125  pixel = (guint32 *) malloc (buffsize * sizeof (guint32) + 128);
126  memset (pixel, 0, buffsize * sizeof (guint32) + 128);
127  back = (guint32 *) malloc (buffsize * sizeof (guint32) + 128);
128  memset (back, 0, buffsize * sizeof (guint32) + 128);
129  p1 = (guint32 *) ((1 + ((uintptr_t) (pixel)) / 128) * 128);
130  p2 = (guint32 *) ((1 + ((uintptr_t) (back)) / 128) * 128);
131 
132  init_ifs (resx, c_resoly);
135 }
136 
137 
138 guint32 * goom_update (gint16 data[2][512], int forceMode) {
139  static int s_lockVar = 0; // pour empecher de nouveaux changements
140  static int s_goomVar = 0; // boucle des gooms
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_loopVar = 0; // mouvement des points
145  static int s_speedVar = 0; // vitesse des particules
146 
147  // duree de la transition entre afficher les lignes ou pas
148 #define DRAWLINES 80
149  static int s_lineMode = DRAWLINES; // l'effet lineaire a dessiner
150  static int s_nombreCddc = 0; // nombre de Cycle Depuis Dernier Changement
151  static int s_accelVar=0; // acceleration des particules
152  static int s_stopLines = 0;
153 
154  // des points
155  static int s_ifsIncr = 1; // dessiner l'ifs (0 = non: > = increment)
156  static int s_decayIfs = 0; // disparition de l'ifs
157  static int s_recayIfs = 0; // dédisparition de l'ifs
158 
159 #define SWITCHMULT (29.0F/30.0F)
160 #define SWITCHINCR 0x7f
161  static float s_switchMult = 1.0F;
162  static int s_switchIncr = SWITCHINCR;
163 
164  static char s_goomLimit = 2; // sensibilité du goom
165  static ZoomFilterData s_zfd = {
166  127, 8, 16,
167  1, 1, false, NORMAL_MODE,
168  0, 0, false, false, 0
169  };
170 
171  ZoomFilterData *pzfd = nullptr;
172 
173  /* test if the config has changed, update it if so */
174  guint32 pointWidth = (resolx * 2) / 5;
175  guint32 pointHeight = ((c_resoly) * 2) / 5;
176 
177  /* ! etude du signal ... */
178  int incvar = 0; // volume du son
179  for (int i = 0; i < 512; i++) {
180  if (incvar < data[0][i])
181  incvar = data[0][i];
182  }
183 
184  int i = s_accelVar;
185  s_accelVar = incvar / 1000;
186 
187  if (s_speedVar > 5) {
188  s_accelVar--;
189  if (s_speedVar > 20)
190  s_accelVar--;
191  if (s_speedVar > 40)
192  s_speedVar = 40;
193  }
194  s_accelVar--;
195 
196  i = s_accelVar - i;
197  if (i<0) i=-i;
198 
199  s_speedVar += (s_speedVar + i/2);
200  s_speedVar /= 2;
201  if ((s_speedVar) && (cycle%9==0)) {
202  s_speedVar -= 1;
203  }
204  if ((s_speedVar) && (cycle%5==0)) {
205  s_speedVar = (s_speedVar*7)/8;
206  }
207 
208  if (s_speedVar < 0)
209  s_speedVar = 0;
210  if (s_speedVar > 50)
211  s_speedVar = 50;
212 
213 
214  /* ! calcul du deplacement des petits points ... */
215 
216  // largfactor: elargissement de l'intervalle d'évolution
217  float largfactor = ((float) s_speedVar / 40.0F + (float) incvar / 50000.0F) / 1.5F;
218  if (largfactor > 1.5F)
219  largfactor = 1.5F;
220 
221  s_decayIfs--;
222  if (s_decayIfs > 0)
223  s_ifsIncr += 2;
224  if (s_decayIfs == 0)
225  s_ifsIncr = 0;
226 
227 
228  if (s_recayIfs) {
229  s_ifsIncr -= 2;
230  s_recayIfs--;
231  if ((s_recayIfs == 0)&&(s_ifsIncr<=0))
232  s_ifsIncr = 1;
233  }
234 
235  if (s_ifsIncr > 0)
236  ifs_update (p1 + c_offset, p2 + c_offset, resolx, c_resoly, s_ifsIncr);
237 
238  if (curGState->m_drawPoints) {
239  for (i = 1; i * 15 <= s_speedVar + 15; i++) {
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  s_goomVar++;
409 
410  /* SELECTION OF THE GOOM STATE */
411  if ((!s_blocker)&&(iRAND(3))) {
412  s_rndn = iRAND(STATES_RANGEMAX);
413  s_blocker = 3;
414  }
415  else if (s_blocker) s_blocker--;
416 
417  for (int j=0;j<STATES_NB;j++) {
418  if ((s_rndn >= states[j].m_rangeMin)
419  && (s_rndn <= states[j].m_rangeMax))
420  curGState = states+j;
421  }
422 
423  if ((curGState->m_drawIfs) && (s_ifsIncr<=0)) {
424  s_recayIfs = 5;
425  s_ifsIncr = 11;
426  }
427 
428  if ((!curGState->m_drawIfs) && (s_ifsIncr>0) && (s_decayIfs<=0))
429  s_decayIfs = 100;
430 
431  if (!curGState->m_drawScope)
432  s_stopLines = 0xf000 & 5;
433 
434  if (!curGState->m_drawScope) {
435  s_stopLines = 0;
436  s_lineMode = DRAWLINES;
437  }
438 
439  // if (goomvar % 1 == 0)
440  {
441  s_lockVar = 50;
442  guint32 newvit = STOP_SPEED + 1 - (4.0F * log10f(s_speedVar+1));
443  // retablir le zoom avant..
444  // Pseudo-random is good enough. Don't need a true random.
445  // NOLINTNEXTLINE(cert-msc30-c,cert-msc50-cpp)
446  if ((s_zfd.reverse) && (!(cycle % 13)) && (rand () % 5 == 0)) {
447  s_zfd.reverse = false;
448  s_zfd.vitesse = STOP_SPEED - 2;
449  s_lockVar = 75;
450  }
451  if (iRAND (10) == 0) {
452  s_zfd.reverse = true;
453  s_lockVar = 100;
454  }
455 
456  if (iRAND (10) == 0)
457  s_zfd.vitesse = STOP_SPEED - 1;
458  if (iRAND (12) == 0)
459  s_zfd.vitesse = STOP_SPEED + 1;
460 
461  // changement de milieu..
462  switch (iRAND (25)) {
463  case 0:
464  case 3:
465  case 6:
466  s_zfd.middleY = c_resoly - 1;
467  s_zfd.middleX = resolx / 2;
468  break;
469  case 1:
470  case 4:
471  s_zfd.middleX = resolx - 1;
472  break;
473  case 2:
474  case 5:
475  s_zfd.middleX = 1;
476  break;
477  default:
478  s_zfd.middleY = c_resoly / 2;
479  s_zfd.middleX = resolx / 2;
480  }
481 
482  if ((s_zfd.mode == WATER_MODE)
483  || (s_zfd.mode == YONLY_MODE)
484  || (s_zfd.mode == AMULETTE_MODE)) {
485  s_zfd.middleX = resolx / 2;
486  s_zfd.middleY = c_resoly / 2;
487  }
488 
489  guint32 vtmp = iRAND (15);
490  switch (vtmp) {
491  case 0:
492 
493  // NOLINTNEXTLINE(misc-redundant-expression)
494  s_zfd.vPlaneEffect = iRAND (3) - iRAND (3);
495  // NOLINTNEXTLINE(misc-redundant-expression)
496  s_zfd.hPlaneEffect = iRAND (3) - iRAND (3);
497  break;
498  case 3:
499  s_zfd.vPlaneEffect = 0;
500  // NOLINTNEXTLINE(misc-redundant-expression)
501  s_zfd.hPlaneEffect = iRAND (8) - iRAND (8);
502  break;
503  case 4:
504  case 5:
505  case 6:
506  case 7:
507  // NOLINTNEXTLINE(misc-redundant-expression)
508  s_zfd.vPlaneEffect = iRAND (5) - iRAND (5);
509  s_zfd.hPlaneEffect = -s_zfd.vPlaneEffect;
510  break;
511  case 8:
512  s_zfd.hPlaneEffect = 5 + iRAND (8);
513  s_zfd.vPlaneEffect = -s_zfd.hPlaneEffect;
514  break;
515  case 9:
516  s_zfd.vPlaneEffect = 5 + iRAND (8);
517  s_zfd.hPlaneEffect = -s_zfd.hPlaneEffect;
518  break;
519  case 13:
520  s_zfd.hPlaneEffect = 0;
521  // NOLINTNEXTLINE(misc-redundant-expression)
522  s_zfd.vPlaneEffect = iRAND (10) - iRAND (10);
523  break;
524  case 14:
525  // NOLINTNEXTLINE(misc-redundant-expression)
526  s_zfd.hPlaneEffect = iRAND (10) - iRAND (10);
527  // NOLINTNEXTLINE(misc-redundant-expression)
528  s_zfd.vPlaneEffect = iRAND (10) - iRAND (10);
529  break;
530  default:
531  if (vtmp < 10) {
532  s_zfd.vPlaneEffect = 0;
533  s_zfd.hPlaneEffect = 0;
534  }
535  }
536 
537  if (iRAND (5) != 0)
538  s_zfd.noisify = 0;
539  else {
540  s_zfd.noisify = iRAND (2) + 1;
541  s_lockVar *= 2;
542  }
543 
544  if (s_zfd.mode == AMULETTE_MODE) {
545  s_zfd.vPlaneEffect = 0;
546  s_zfd.hPlaneEffect = 0;
547  s_zfd.noisify = 0;
548  }
549 
550  if ((s_zfd.middleX == 1) || (s_zfd.middleX == (int)resolx - 1)) {
551  s_zfd.vPlaneEffect = 0;
552  s_zfd.hPlaneEffect = iRAND (2) ? 0 : s_zfd.hPlaneEffect;
553  }
554 
555  if (newvit < (guint32)s_zfd.vitesse) // on accelere
556  {
557  pzfd = &s_zfd;
558  if (((newvit < STOP_SPEED - 7) &&
559  (s_zfd.vitesse < STOP_SPEED - 6) &&
560  (cycle % 3 == 0)) || (iRAND (40) == 0)) {
561  s_zfd.vitesse = STOP_SPEED - iRAND (2) + iRAND (2);
562  s_zfd.reverse = !s_zfd.reverse;
563  }
564  else {
565  s_zfd.vitesse = (newvit + s_zfd.vitesse * 7) / 8;
566  }
567  s_lockVar += 50;
568  }
569  }
570 
571  if (s_lockVar > 150) {
572  s_switchIncr = SWITCHINCR;
573  s_switchMult = 1.0F;
574  }
575  }
576  // mode mega-lent
577  if (iRAND (700) == 0) {
578  pzfd = &s_zfd;
579  s_zfd.vitesse = STOP_SPEED - 1;
580  s_zfd.pertedec = 8;
581  s_zfd.sqrtperte = 16;
582  s_goomVar = 1;
583  s_lockVar += 50;
584  s_switchIncr = SWITCHINCR;
585  s_switchMult = 1.0F;
586  }
587  }
588 
589  /*
590  * gros frein si la musique est calme
591  */
592  if ((s_speedVar < 1) && (s_zfd.vitesse < STOP_SPEED - 4) && (cycle % 16 == 0)) {
593  pzfd = &s_zfd;
594  s_zfd.vitesse += 3;
595  s_zfd.pertedec = 8;
596  s_zfd.sqrtperte = 16;
597  s_goomVar = 0;
598  }
599 
600  /*
601  * baisser regulierement la vitesse...
602  */
603  if ((cycle % 73 == 0) && (s_zfd.vitesse < STOP_SPEED - 5)) {
604  pzfd = &s_zfd;
605  s_zfd.vitesse++;
606  }
607 
608  /*
609  * arreter de decrémenter au bout d'un certain temps
610  */
611  if ((cycle % 101 == 0) && (s_zfd.pertedec == 7)) {
612  pzfd = &s_zfd;
613  s_zfd.pertedec = 8;
614  s_zfd.sqrtperte = 16;
615  }
616 
617  /*
618  * Permet de forcer un effet.
619  */
620  if ((forceMode > 0) && (forceMode <= NB_FX)) {
621  pzfd = &s_zfd;
622  pzfd->mode = forceMode - 1;
623  }
624 
625  if (forceMode == -1) {
626  pzfd = nullptr;
627  }
628 
629  /*
630  * Changement d'effet de zoom !
631  */
632  if (pzfd != nullptr) {
633  static int s_exvit = 128;
634 
635  s_nombreCddc = 0;
636 
637  s_switchIncr = SWITCHINCR;
638 
639  int dif = s_zfd.vitesse - s_exvit;
640  if (dif < 0)
641  dif = -dif;
642 
643  if (dif > 2) {
644  s_switchIncr *= (dif + 2) / 2;
645  }
646  s_exvit = s_zfd.vitesse;
647  s_switchMult = 1.0F;
648 
649  if (((s_accelVar > s_goomLimit) && (s_totalGoom < 2)) || (forceMode > 0)) {
650  s_switchIncr = 0;
651  s_switchMult = SWITCHMULT;
652  }
653  }
654  else {
655  if (s_nombreCddc > TIME_BTW_CHG) {
656  pzfd = &s_zfd;
657  s_nombreCddc = 0;
658  }
659  else
660  s_nombreCddc++;
661  }
662 
663 #ifdef VERBOSE
664  if (pzfd) {
665  printf ("GOOM: pzfd->mode = %d\n", pzfd->mode);
666  }
667 #endif
668 
669  // Zoom here !
670  zoomFilterFastRGB (p1 + c_offset, p2 + c_offset, pzfd, resolx, c_resoly, s_switchIncr, s_switchMult);
671 
672  /*
673  * Affichage tentacule
674  */
675 
676  if (s_goomLimit!=0)
677  tentacle_update((gint32*)(p2 + c_offset), (gint32*)(p1 + c_offset), resolx, c_resoly, data, (float)s_accelVar/s_goomLimit, curGState->m_drawTentacle);
678  else
680 
681 /*
682  {
683  static char title[1024];
684  static int displayTitle = 0;
685  char text[255];
686 
687  if (fps > 0) {
688  int i;
689  if (speedvar>0) {
690  for (i=0;i<speedvar;i++)
691  text[i]='*';
692  text[i]=0;
693  goom_draw_text (p1 + c_offset,resolx,c_resoly, 10, 50, text, 1.0F, 0);
694  }
695  if (accelvar>0) {
696  for (i=0;i<accelvar;i++) {
697  if (i==goomlimit)
698  text[i]='o';
699  else
700  text[i]='*';
701  }
702  text[i]=0;
703  goom_draw_text (p1 + c_offset,resolx,c_resoly, 10, 62, text, 1.0F, 0);
704  }
705  if (agoom==20)
706  goom_draw_text (p1 + c_offset,resolx,c_resoly,10, 80, "GOOM",1.0F, 0);
707  else if (agoom)
708  goom_draw_text (p1 + c_offset,resolx,c_resoly,10, 80, "goom",1.0F, 0);
709  if (abiggoom==200)
710  goom_draw_text (p1 + c_offset,resolx,c_resoly,10, 100, "BGOOM",1.0F, 0);
711  else if (abiggoom)
712  goom_draw_text (p1 + c_offset,resolx,c_resoly,10, 100, "bgoom",1.0F, 0);
713  }
714 
715  update_message (message);
716 
717  if (fps > 0) {
718  sprintf (text, "%2.f fps", fps);
719  goom_draw_text (p1 + c_offset,resolx,c_resoly, 10, 24, text, 1, 0);
720  }
721 
722  if (songTitle != NULL) {
723  sprintf (title, songTitle); // la flemme d'inclure string.h :)
724  displayTitle = 200;
725  }
726 
727  if (displayTitle) {
728  goom_draw_text (p1 + c_offset,resolx,c_resoly, resolx / 2, c_resoly / 2 + 7, title, ((float) (190 - displayTitle) / 10.0F), 1);
729  displayTitle--;
730  if (displayTitle < 4)
731  goom_draw_text (p2 + c_offset,resolx,c_resoly, resolx / 2, c_resoly / 2 + 7, title, ((float) (190 - displayTitle) / 10.0F), 1);
732  }
733  }
734 */
735 
736  /*
737  * arret demande
738  */
739  if ((s_stopLines & 0xf000)||(!curGState->m_drawScope)) {
740  float param1 = NAN;
741  float param2 = NAN;
742  float amplitude = NAN;
743  int couleur = 0;
744  int mode = 0;
745 
746  choose_a_goom_line (&param1, &param2, &couleur, &mode, &amplitude,1);
747  couleur = GML_BLACK;
748 
749  goom_lines_switch_to (gmline1, mode, param1, amplitude, couleur);
750  goom_lines_switch_to (gmline2, mode, param2, amplitude, couleur);
751  s_stopLines &= 0x0fff;
752  }
753 
754  /*
755  * arret aleatore.. changement de mode de ligne..
756  */
757  if (s_lineMode != DRAWLINES) {
758  s_lineMode--;
759  if (s_lineMode == -1)
760  s_lineMode = 0;
761  }
762  else
763  if ((cycle%80==0)&&(iRAND(5)==0)&&s_lineMode)
764  s_lineMode--;
765 
766  if ((cycle % 120 == 0)
767  && (iRAND (4) == 0)
768  && (curGState->m_drawScope)) {
769  if (s_lineMode == 0)
770  s_lineMode = DRAWLINES;
771  else if (s_lineMode == DRAWLINES) {
772  float param1 = NAN;
773  float param2 = NAN;
774  float amplitude = NAN;
775  int couleur1 = 0;
776  int couleur2 = 0;
777  int mode = 0;
778 
779  s_lineMode--;
780  choose_a_goom_line (&param1, &param2, &couleur1, &mode, &amplitude,s_stopLines);
781 
782  couleur2 = 5-couleur1;
783  if (s_stopLines) {
784  s_stopLines--;
785  if (iRAND(2))
786  couleur2=couleur1 = GML_BLACK;
787  }
788 
789  goom_lines_switch_to (gmline1, mode, param1, amplitude, couleur1);
790  goom_lines_switch_to (gmline2, mode, param2, amplitude, couleur2);
791  }
792  }
793 
794  /*
795  * si on est dans un goom : afficher les lignes...
796  */
797  if ((s_lineMode != 0) || (s_aGoom > 15)) {
799 
800  goom_lines_draw (gmline1, data[0], p2 + c_offset);
801  goom_lines_draw (gmline2, data[1], p2 + c_offset);
802 
803  if (((cycle % 121) == 9) && (iRAND (3) == 1)
804  && ((s_lineMode == 0) || (s_lineMode == DRAWLINES))) {
805  float param1 = NAN;
806  float param2 = NAN;
807  float amplitude = NAN;
808  int couleur1 = 0;
809  int couleur2 = 0;
810  int mode = 0;
811 
812  choose_a_goom_line (&param1, &param2, &couleur1, &mode, &amplitude, s_stopLines);
813  couleur2 = 5-couleur1;
814 
815  if (s_stopLines) {
816  s_stopLines--;
817  if (iRAND(2))
818  couleur2=couleur1 = GML_BLACK;
819  }
820  goom_lines_switch_to (gmline1, mode, param1, amplitude, couleur1);
821  goom_lines_switch_to (gmline2, mode, param2, amplitude, couleur2);
822  }
823  }
824 
825  guint32 *return_val = p1;
826  tmp = p1;
827  p1 = p2;
828  p2 = tmp;
829 
830  // affichage et swappage des buffers..
831  cycle++;
832 
833  // toute les 2 secondes : vérifier si le taux de goom est correct
834  // et le modifier sinon..
835  if (!(cycle % 64)) {
836  if (s_speedVar<1)
837  s_goomLimit /= 2;
838  if (s_totalGoom > 4) {
839  s_goomLimit++;
840  }
841  if (s_totalGoom > 7) {
842  s_goomLimit*=4/3;
843  s_goomLimit+=2;
844  }
845  if ((s_totalGoom == 0) && (s_goomLimit > 1))
846  s_goomLimit--;
847  if ((s_totalGoom == 1) && (s_goomLimit > 1))
848  s_goomLimit--;
849  s_totalGoom = 0;
850  }
851  return return_val;
852 }
853 
854 void goom_close () {
855  if (pixel != nullptr)
856  free (pixel);
857  if (back != nullptr)
858  free (back);
859  pixel = back = nullptr;
860  RAND_CLOSE ();
861  release_ifs ();
864  tentacle_free();
865 }
866 
867 
868 void choose_a_goom_line (float *param1, float *param2, int *couleur, int *mode, float *amplitude, int far) {
869  *mode = iRAND (3);
870  *amplitude = 1.0F;
871  switch (*mode) {
872  case GML_CIRCLE:
873  if (far) {
874  *param1 = *param2 = 0.47F;
875  *amplitude = 0.8F;
876  break;
877  }
878  if (iRAND (3) == 0) {
879  *param1 = *param2 = 0;
880  *amplitude = 3.0F;
881  }
882  else if (iRAND (2)) {
883  *param1 = 0.40F * c_resoly;
884  *param2 = 0.22F * c_resoly;
885  }
886  else {
887  *param1 = *param2 = c_resoly * 0.35;
888  }
889  break;
890  case GML_HLINE:
891  if (iRAND (4) || far) {
892  *param1 = c_resoly / 7.0F;
893  *param2 = 6.0F * c_resoly / 7.0F;
894  }
895  else {
896  *param1 = *param2 = c_resoly / 2.0F;
897  *amplitude = 2.0F;
898  }
899  break;
900  case GML_VLINE:
901  if (iRAND (3) || far) {
902  *param1 = resolx / 7.0F;
903  *param2 = 6.0F * resolx / 7.0F;
904  }
905  else {
906  *param1 = *param2 = resolx / 2.0F;
907  *amplitude = 1.5F;
908  }
909  break;
910  }
911 
912  *couleur = iRAND (6);
913 }
914 
915 /*
916 void goom_set_font (int ***chars, int *width, int *height) {
917  if (chars == nullptr)
918  return ;
919 }
920 */
921 
922 /*
923 void update_message (char *message) {
924 
925  static int nbl;
926  static char msg2 [0x800];
927  static int affiche = 0;
928  static int longueur;
929  int fin = 0;
930 
931  if (message) {
932  int i=1,j=0;
933  sprintf (msg2,message);
934  for (j=0;msg2[j];j++)
935  if (msg2[j]=='\n')
936  i++;
937  nbl = i;
938  affiche = resoly + nbl * 25 + 105;
939  longueur = strlen (msg2);
940  }
941  if (affiche) {
942  int i = 0;
943  char *msg=malloc(longueur+1);
944  char *ptr = msg;
945  int pos;
946  float ecart;
947  message = msg;
948  sprintf (msg,msg2);
949 
950  while (!fin) {
951  while (1) {
952  if (*ptr == 0) {
953  fin = 1;
954  break;
955  }
956  if (*ptr == '\n') {
957  *ptr = 0;
958  break;
959  }
960  ++ptr;
961  }
962  pos = affiche - (nbl-i)*25;
963  pos += 6.0*(cos((double)pos/20.0));
964  pos -= 80;
965  ecart = (1.0+2.0*sin((double)pos/20.0));
966  if ((fin) && (2 * pos < (int)resoly))
967  pos = (int)resoly / 2;
968  pos += 7;
969 
970  goom_draw_text(p1 + c_offset,resolx,c_resoly, resolx/2, pos, message, ecart, 1);
971  message = ++ptr;
972  i++;
973  }
974  affiche --;
975  free (msg);
976  }
977 }
978 */
buffsize
guint32 buffsize
Definition: goom_core.cpp:60
lines.h
VIOLET
const Color VIOLET
Definition: graphic.cpp:10
goom_update
guint32 * goom_update(gint16 data[2][512], int forceMode)
Definition: goom_core.cpp:138
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:156
back
static guint32 * back
Definition: goom_core.cpp:29
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:144
GML_CIRCLE
#define GML_CIRCLE
Definition: lines.h:41
gmline2
static GMLine * gmline2
Definition: goom_core.cpp:64
GoomState::m_drawPoints
int m_drawPoints
Definition: goom_core.cpp:35
GML_BLACK
#define GML_BLACK
Definition: lines.h:58
ifs_update
void ifs_update(guint32 *data, const guint32 *back, int width, int height, int increment)
Definition: ifs_display.cpp:11
NORMAL_MODE
#define NORMAL_MODE
Definition: filters.h:29
gint16
#define gint16
Definition: goomconfig.h:37
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:729
STATES_NB
#define STATES_NB
Definition: goom_core.cpp:45
ZoomFilterData::waveEffect
bool waveEffect
Definition: filters.h:22
pixel
static guint32 * pixel
--------------------------------------------------—**
Definition: goom_core.cpp:28
GMLine::power
float power
Definition: lines.h:36
goom_lines_free
void goom_lines_free(GMLine **l)
Definition: lines.cpp:193
GoomState::m_rangeMin
int m_rangeMin
Definition: goom_core.cpp:41
GoomState
Definition: goom_core.cpp:33
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:109
tmp
static guint32 * tmp
Definition: goom_core.cpp:30
GML_HLINE
#define GML_HLINE
Definition: lines.h:44
iRAND
#define iRAND(i)
Definition: goom_tools.h:33
resoly
guint32 resoly
Definition: goom_core.cpp:60
GML_RED
#define GML_RED
Definition: lines.h:53
goom_lines_set_res
void goom_lines_set_res(GMLine *gml, int rx, int ry)
Definition: lines.cpp:97
TIME_BTW_CHG
#define TIME_BTW_CHG
Definition: goom_core.cpp:23
filters.h
ZoomFilterData::vitesse
int vitesse
Definition: filters.h:11
if
if(query.exec() &&query.next())
Definition: mythplugins/mytharchive/mytharchivehelper/main.cpp:458
DRAWLINES
#define DRAWLINES
zoomFilterFastRGB
void zoomFilterFastRGB(Uint *pix1, Uint *pix2, ZoomFilterData *zf, Uint resx, Uint resy, int switchIncr, float switchMult)
Definition: filters.cpp:491
ZoomFilterData::noisify
char noisify
Definition: filters.h:25
resolx
guint32 resolx
Definition: goom_core.cpp:60
tentacle_free
void tentacle_free(void)
Definition: tentacle3d.cpp:23
tentacle_new
void tentacle_new(void)
Definition: tentacle3d.cpp:30
curGState
GoomState * curGState
Definition: goom_core.cpp:58
ifs.h
ZoomFilterData::hypercosEffect
bool hypercosEffect
Definition: filters.h:23
WAVE_MODE
#define WAVE_MODE
Definition: filters.h:30
STATES_RANGEMAX
#define STATES_RANGEMAX
Definition: goom_core.cpp:46
tentacle3d.h
GML_VLINE
#define GML_VLINE
Definition: lines.h:47
GoomState::m_drawIfs
int m_drawIfs
Definition: goom_core.cpp:34
goom_core.h
p2
static guint32 * p2
Definition: goom_core.cpp:30
ZoomFilterData::pertedec
unsigned char pertedec
Definition: filters.h:13
GML_VERT
#define GML_VERT
Definition: lines.h:56
GoomState::m_drawTentacle
int m_drawTentacle
Definition: goom_core.cpp:36
c_offset
guint32 c_offset
Definition: goom_core.cpp:60
CRYSTAL_BALL_MODE
#define CRYSTAL_BALL_MODE
Definition: filters.h:31
gmline1
static GMLine * gmline1
Definition: goom_core.cpp:63
SWITCHINCR
#define SWITCHINCR
NB_FX
#define NB_FX
Definition: goom_core.h:7
GMLine
Definition: lines.h:20
goom_init
void goom_init(guint32 resx, guint32 resy, int cinemascope)
Definition: goom_core.cpp:68
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:868
SWITCHMULT
#define SWITCHMULT
p1
static guint32 * p1
Definition: goom_core.cpp:30
BLACK
const Color BLACK
Definition: graphic.cpp:3
states
states
Definition: mythmiscutil.cpp:1245
GoomState::m_rangeMax
int m_rangeMax
Definition: goom_core.cpp:42
YONLY_MODE
#define YONLY_MODE
Definition: filters.h:37
goom_close
void goom_close()
Definition: goom_core.cpp:854
tentacle_update
void tentacle_update(int *buf, int *back, int W, int H, short data[2][512], float rapport, int drawit)
Definition: tentacle3d.cpp:149
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:31
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:60
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:21
release_ifs
void release_ifs()
Definition: ifs.cpp:526
guint32
#define guint32
Definition: goomconfig.h:35
GoomState::m_drawScope
int m_drawScope
Definition: goom_core.cpp:38
SPEEDWAY_MODE
#define SPEEDWAY_MODE
Definition: filters.h:38
c_black_height
guint32 c_black_height
Definition: goom_core.cpp:60
goom_lines_draw
void goom_lines_draw(GMLine *line, const gint16 data[512], unsigned int *p)
Definition: lines.cpp:202
ZoomFilterData::hPlaneEffect
int hPlaneEffect
Definition: filters.h:19
HYPERCOS1_MODE
#define HYPERCOS1_MODE
Definition: filters.h:35
WHITE
const Color WHITE
Definition: graphic.cpp:4
init_ifs
void init_ifs(int width, int height)
Definition: ifs.cpp:205
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:39
ZoomFilterData::middleY
int middleY
Definition: filters.h:15