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  zfd.vPlaneEffect = iRAND (3) - iRAND (3);
484  zfd.hPlaneEffect = iRAND (3) - iRAND (3);
485  break;
486  case 3:
487  zfd.vPlaneEffect = 0;
488  zfd.hPlaneEffect = iRAND (8) - iRAND (8);
489  break;
490  case 4:
491  case 5:
492  case 6:
493  case 7:
494  zfd.vPlaneEffect = iRAND (5) - iRAND (5);
495  zfd.hPlaneEffect = -zfd.vPlaneEffect;
496  break;
497  case 8:
498  zfd.hPlaneEffect = 5 + iRAND (8);
499  zfd.vPlaneEffect = -zfd.hPlaneEffect;
500  break;
501  case 9:
502  zfd.vPlaneEffect = 5 + iRAND (8);
503  zfd.hPlaneEffect = -zfd.hPlaneEffect;
504  break;
505  case 13:
506  zfd.hPlaneEffect = 0;
507  zfd.vPlaneEffect = iRAND (10) - iRAND (10);
508  break;
509  case 14:
510  zfd.hPlaneEffect = iRAND (10) - iRAND (10);
511  zfd.vPlaneEffect = iRAND (10) - iRAND (10);
512  break;
513  default:
514  if (vtmp < 10) {
515  zfd.vPlaneEffect = 0;
516  zfd.hPlaneEffect = 0;
517  }
518  }
519 
520  if (iRAND (5) != 0)
521  zfd.noisify = 0;
522  else {
523  zfd.noisify = iRAND (2) + 1;
524  lockvar *= 2;
525  }
526 
527  if (zfd.mode == AMULETTE_MODE) {
528  zfd.vPlaneEffect = 0;
529  zfd.hPlaneEffect = 0;
530  zfd.noisify = 0;
531  }
532 
533  if ((zfd.middleX == 1) || (zfd.middleX == (int)resolx - 1)) {
534  zfd.vPlaneEffect = 0;
535  zfd.hPlaneEffect = iRAND (2) ? 0 : zfd.hPlaneEffect;
536  }
537 
538  if (newvit < (guint32)zfd.vitesse) // on accelere
539  {
540  pzfd = &zfd;
541  if (((newvit < STOP_SPEED - 7) &&
542  (zfd.vitesse < STOP_SPEED - 6) &&
543  (cycle % 3 == 0)) || (iRAND (40) == 0)) {
544  zfd.vitesse = STOP_SPEED - iRAND (2) + iRAND (2);
545  zfd.reverse = !zfd.reverse;
546  }
547  else {
548  zfd.vitesse = (newvit + zfd.vitesse * 7) / 8;
549  }
550  lockvar += 50;
551  }
552  }
553 
554  if (lockvar > 150) {
555  switchIncr = SWITCHINCR;
556  switchMult = 1.0F;
557  }
558  }
559  // mode mega-lent
560  if (iRAND (700) == 0) {
561  pzfd = &zfd;
562  zfd.vitesse = STOP_SPEED - 1;
563  zfd.pertedec = 8;
564  zfd.sqrtperte = 16;
565  goomvar = 1;
566  lockvar += 50;
567  switchIncr = SWITCHINCR;
568  switchMult = 1.0F;
569  }
570  }
571 
572  /*
573  * gros frein si la musique est calme
574  */
575  if ((speedvar < 1) && (zfd.vitesse < STOP_SPEED - 4) && (cycle % 16 == 0)) {
576  pzfd = &zfd;
577  zfd.vitesse += 3;
578  zfd.pertedec = 8;
579  zfd.sqrtperte = 16;
580  goomvar = 0;
581  }
582 
583  /*
584  * baisser regulierement la vitesse...
585  */
586  if ((cycle % 73 == 0) && (zfd.vitesse < STOP_SPEED - 5)) {
587  pzfd = &zfd;
588  zfd.vitesse++;
589  }
590 
591  /*
592  * arreter de decrémenter au bout d'un certain temps
593  */
594  if ((cycle % 101 == 0) && (zfd.pertedec == 7)) {
595  pzfd = &zfd;
596  zfd.pertedec = 8;
597  zfd.sqrtperte = 16;
598  }
599 
600  /*
601  * Permet de forcer un effet.
602  */
603  if ((forceMode > 0) && (forceMode <= NB_FX)) {
604  pzfd = &zfd;
605  pzfd->mode = forceMode - 1;
606  }
607 
608  if (forceMode == -1) {
609  pzfd = NULL;
610  }
611 
612  /*
613  * Changement d'effet de zoom !
614  */
615  if (pzfd != NULL) {
616  static int exvit = 128;
617  int dif;
618 
619  nombreCDDC = 0;
620 
621  switchIncr = SWITCHINCR;
622 
623  dif = zfd.vitesse - exvit;
624  if (dif < 0)
625  dif = -dif;
626 
627  if (dif > 2) {
628  switchIncr *= (dif + 2) / 2;
629  }
630  exvit = zfd.vitesse;
631  switchMult = 1.0F;
632 
633  if (((accelvar > goomlimit) && (totalgoom < 2)) || (forceMode > 0)) {
634  switchIncr = 0;
635  switchMult = SWITCHMULT;
636  }
637  }
638  else {
639  if (nombreCDDC > TIME_BTW_CHG) {
640  pzfd = &zfd;
641  nombreCDDC = 0;
642  }
643  else
644  nombreCDDC++;
645  }
646 
647 #ifdef VERBOSE
648  if (pzfd) {
649  printf ("GOOM: pzfd->mode = %d\n", pzfd->mode);
650  }
651 #endif
652 
653  // Zoom here !
654  zoomFilterFastRGB (p1 + c_offset, p2 + c_offset, pzfd, resolx, c_resoly, switchIncr, switchMult);
655 
656  /*
657  * Affichage tentacule
658  */
659 
660  if (goomlimit!=0)
661  tentacle_update((gint32*)(p2 + c_offset), (gint32*)(p1 + c_offset), resolx, c_resoly, data, (float)accelvar/goomlimit, curGState->drawTentacle);
662  else
664 
665 /*
666  {
667  static char title[1024];
668  static int displayTitle = 0;
669  char text[255];
670 
671  if (fps > 0) {
672  int i;
673  if (speedvar>0) {
674  for (i=0;i<speedvar;i++)
675  text[i]='*';
676  text[i]=0;
677  goom_draw_text (p1 + c_offset,resolx,c_resoly, 10, 50, text, 1.0F, 0);
678  }
679  if (accelvar>0) {
680  for (i=0;i<accelvar;i++) {
681  if (i==goomlimit)
682  text[i]='o';
683  else
684  text[i]='*';
685  }
686  text[i]=0;
687  goom_draw_text (p1 + c_offset,resolx,c_resoly, 10, 62, text, 1.0F, 0);
688  }
689  if (agoom==20)
690  goom_draw_text (p1 + c_offset,resolx,c_resoly,10, 80, "GOOM",1.0F, 0);
691  else if (agoom)
692  goom_draw_text (p1 + c_offset,resolx,c_resoly,10, 80, "goom",1.0F, 0);
693  if (abiggoom==200)
694  goom_draw_text (p1 + c_offset,resolx,c_resoly,10, 100, "BGOOM",1.0F, 0);
695  else if (abiggoom)
696  goom_draw_text (p1 + c_offset,resolx,c_resoly,10, 100, "bgoom",1.0F, 0);
697  }
698 
699  update_message (message);
700 
701  if (fps > 0) {
702  sprintf (text, "%2.f fps", fps);
703  goom_draw_text (p1 + c_offset,resolx,c_resoly, 10, 24, text, 1, 0);
704  }
705 
706  if (songTitle != NULL) {
707  sprintf (title, songTitle); // la flemme d'inclure string.h :)
708  displayTitle = 200;
709  }
710 
711  if (displayTitle) {
712  goom_draw_text (p1 + c_offset,resolx,c_resoly, resolx / 2, c_resoly / 2 + 7, title, ((float) (190 - displayTitle) / 10.0F), 1);
713  displayTitle--;
714  if (displayTitle < 4)
715  goom_draw_text (p2 + c_offset,resolx,c_resoly, resolx / 2, c_resoly / 2 + 7, title, ((float) (190 - displayTitle) / 10.0F), 1);
716  }
717  }
718 */
719 
720  /*
721  * arret demande
722  */
723  if ((stop_lines & 0xf000)||(!curGState->drawScope)) {
724  float param1, param2, amplitude;
725  int couleur;
726  int mode;
727 
728  choose_a_goom_line (&param1, &param2, &couleur, &mode, &amplitude,1);
729  couleur = GML_BLACK;
730 
731  goom_lines_switch_to (gmline1, mode, param1, amplitude, couleur);
732  goom_lines_switch_to (gmline2, mode, param2, amplitude, couleur);
733  stop_lines &= 0x0fff;
734  }
735 
736  /*
737  * arret aleatore.. changement de mode de ligne..
738  */
739  if (lineMode != DRAWLINES) {
740  lineMode--;
741  if (lineMode == -1)
742  lineMode = 0;
743  }
744  else
745  if ((cycle%80==0)&&(iRAND(5)==0)&&lineMode)
746  lineMode--;
747 
748  if ((cycle % 120 == 0)
749  && (iRAND (4) == 0)
750  && (curGState->drawScope)) {
751  if (lineMode == 0)
752  lineMode = DRAWLINES;
753  else if (lineMode == DRAWLINES) {
754  float param1, param2, amplitude;
755  int couleur1,couleur2;
756  int mode;
757 
758  lineMode--;
759  choose_a_goom_line (&param1, &param2, &couleur1, &mode, &amplitude,stop_lines);
760 
761  couleur2 = 5-couleur1;
762  if (stop_lines) {
763  stop_lines--;
764  if (iRAND(2))
765  couleur2=couleur1 = GML_BLACK;
766  }
767 
768  goom_lines_switch_to (gmline1, mode, param1, amplitude, couleur1);
769  goom_lines_switch_to (gmline2, mode, param2, amplitude, couleur2);
770  }
771  }
772 
773  /*
774  * si on est dans un goom : afficher les lignes...
775  */
776  if ((lineMode != 0) || (agoom > 15)) {
778 
779  goom_lines_draw (gmline1, data[0], p2 + c_offset);
780  goom_lines_draw (gmline2, data[1], p2 + c_offset);
781 
782  if (((cycle % 121) == 9) && (iRAND (3) == 1)
783  && ((lineMode == 0) || (lineMode == DRAWLINES))) {
784  float param1, param2, amplitude;
785  int couleur1,couleur2;
786  int mode;
787 
788  choose_a_goom_line (&param1, &param2, &couleur1, &mode, &amplitude, stop_lines);
789  couleur2 = 5-couleur1;
790 
791  if (stop_lines) {
792  stop_lines--;
793  if (iRAND(2))
794  couleur2=couleur1 = GML_BLACK;
795  }
796  goom_lines_switch_to (gmline1, mode, param1, amplitude, couleur1);
797  goom_lines_switch_to (gmline2, mode, param2, amplitude, couleur2);
798  }
799  }
800 
801  return_val = p1;
802  tmp = p1;
803  p1 = p2;
804  p2 = tmp;
805 
806  // affichage et swappage des buffers..
807  cycle++;
808 
809  // toute les 2 secondes : vérifier si le taux de goom est correct
810  // et le modifier sinon..
811  if (!(cycle % 64)) {
812  if (speedvar<1)
813  goomlimit /= 2;
814  if (totalgoom > 4) {
815  goomlimit++;
816  }
817  if (totalgoom > 7) {
818  goomlimit*=4/3;
819  goomlimit+=2;
820  }
821  if ((totalgoom == 0) && (goomlimit > 1))
822  goomlimit--;
823  if ((totalgoom == 1) && (goomlimit > 1))
824  goomlimit--;
825  totalgoom = 0;
826  }
827  return return_val;
828 }
829 
830 void goom_close () {
831  if (pixel != NULL)
832  free (pixel);
833  if (back != NULL)
834  free (back);
835  pixel = back = NULL;
836  RAND_CLOSE ();
837  release_ifs ();
840  tentacle_free();
841 }
842 
843 
844 void choose_a_goom_line (float *param1, float *param2, int *couleur, int *mode, float *amplitude, int far) {
845  *mode = iRAND (3);
846  *amplitude = 1.0F;
847  switch (*mode) {
848  case GML_CIRCLE:
849  if (far) {
850  *param1 = *param2 = 0.47F;
851  *amplitude = 0.8F;
852  break;
853  }
854  if (iRAND (3) == 0) {
855  *param1 = *param2 = 0;
856  *amplitude = 3.0F;
857  }
858  else if (iRAND (2)) {
859  *param1 = 0.40F * c_resoly;
860  *param2 = 0.22F * c_resoly;
861  }
862  else {
863  *param1 = *param2 = c_resoly * 0.35;
864  }
865  break;
866  case GML_HLINE:
867  if (iRAND (4) || far) {
868  *param1 = c_resoly / 7;
869  *param2 = 6.0F * c_resoly / 7.0F;
870  }
871  else {
872  *param1 = *param2 = c_resoly / 2.0F;
873  *amplitude = 2.0F;
874  }
875  break;
876  case GML_VLINE:
877  if (iRAND (3) || far) {
878  *param1 = resolx / 7.0F;
879  *param2 = 6.0F * resolx / 7.0F;
880  }
881  else {
882  *param1 = *param2 = resolx / 2.0F;
883  *amplitude = 1.5F;
884  }
885  break;
886  }
887 
888  *couleur = iRAND (6);
889 }
890 
891 /*
892 void goom_set_font (int ***chars, int *width, int *height) {
893  if (chars == NULL)
894  return ;
895 }
896 */
897 
898 /*
899 void update_message (char *message) {
900 
901  static int nbl;
902  static char msg2 [0x800];
903  static int affiche = 0;
904  static int longueur;
905  int fin = 0;
906 
907  if (message) {
908  int i=1,j=0;
909  sprintf (msg2,message);
910  for (j=0;msg2[j];j++)
911  if (msg2[j]=='\n')
912  i++;
913  nbl = i;
914  affiche = resoly + nbl * 25 + 105;
915  longueur = strlen (msg2);
916  }
917  if (affiche) {
918  int i = 0;
919  char *msg=malloc(longueur+1);
920  char *ptr = msg;
921  int pos;
922  float ecart;
923  message = msg;
924  sprintf (msg,msg2);
925 
926  while (!fin) {
927  while (1) {
928  if (*ptr == 0) {
929  fin = 1;
930  break;
931  }
932  if (*ptr == '\n') {
933  *ptr = 0;
934  break;
935  }
936  ++ptr;
937  }
938  pos = affiche - (nbl-i)*25;
939  pos += 6.0*(cos((double)pos/20.0));
940  pos -= 80;
941  ecart = (1.0+2.0*sin((double)pos/20.0));
942  if ((fin) && (2 * pos < (int)resoly))
943  pos = (int)resoly / 2;
944  pos += 7;
945 
946  goom_draw_text(p1 + c_offset,resolx,c_resoly, resolx/2, pos, message, ecart, 1);
947  message = ++ptr;
948  i++;
949  }
950  affiche --;
951  free (msg);
952  }
953 }
954 */
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:737
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:503
void goom_close()
Definition: goom_core.c:830
#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:844
#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