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