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