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