More cleanup; this will most likely be the last update
[tmpluginclone.git] / firespark.c
blob6a49e662a9f8da383e2de8937c1480e55f76ffe6
1 #include <windows.h>
2 #include <math.h>
3 #include <defs.h>
6 //-------------------------------------------------------------------------
7 // Function declarations
9 void sub_10001010();
10 void sub_10001040();
11 double tjsdf_getrandombits128();
12 signed int tjsf_drawFireSpark(int a1, int a2, int a3, int a4, int a5, int a6, int *a7);
13 // signed int tjsf_initFireSpark(int a2, int a3, int a4, int a6, char a7, int a8, int a9, ...);
14 signed int tjsf_finishFireSpark(int a1, int a2, int a3);
15 // signed int tjsf_changeFireSpark(int a1, int a2, int a3, int a4, int a5, int a6, signed int a7, int *a8);
17 //-------------------------------------------------------------------------
18 // Data declarations
20 char tjsgv_effect = 1; // weak
21 int tjsgv_maxgen = 500; // weak
22 int tjsgv_basevelocity = 5504; // weak
23 int tjsgv_velocityrange = 2359; // weak
24 int tjsgv_baselifetime = 1500; // weak
25 int tjsgv_lifetimerange = 2500; // weak
26 int tjsgv_basetop = 4294967246; // weak
27 int tjsgv_heightrange = 4294967246; // weak
28 int tjsgv_basesizew = 2; // weak
29 int tjsgv_sizewrange = 4; // weak
30 int tjsgv_basesizeh = 2; // weak
31 int tjsgv_sizehrange = 4; // weak
32 double tjsgv_windvariancecapability = 0.0003; // weak
33 double tjsgv_maxwindvelocity = 0.2; // weak
34 int tjsgv_samesize = 1; // weak
35 char byte_1000F084[32] =
37 0xFF,
38 0xFF,
39 0x00,
40 0xFF,
41 'À',
42 '\0',
43 0xFF,
44 '€',
45 '\0',
46 0xFF,
47 '@',
48 0x00,
49 0xFF,
50 ' ',
51 0x00,
52 'À',
53 0x00,
54 0x00,
55 0x00,
56 0x00,
57 0x00,
58 0x00,
59 0x00,
60 0x00,
61 0x00,
62 0x00,
63 0x00,
64 0x00,
65 0x00,
66 0x00,
67 0x00,
68 0x00
69 }; // idb
70 int dword_1000F0A4 = 7; // weak
71 int64_t tjsgdv_curtick = 0ll; // weak
72 int tjsgdv_maxgennew = 0; // weak
73 int tjsgv_inlayerbuffer = 0; // weak
74 int dword_10012A4C = 0; // weak
75 int tjsgv_inlayer = 0; // weak
76 int dword_10012A58 = 0; // weak
77 int tjsgv_inlayerheight = 0; // weak
78 int tjsgdv_curtime = 0; // weak
79 int tjsgv_transtime = 0; // weak
80 double tjsgv_directionbase = 0.0; // weak
81 int dword_10012A78[256] =
339 }; // idb
340 int tjsgdv_firesparkbuffer = 0; // weak
341 double tjsgv_directionrange = 0.0; // weak
342 int tjsgv_inlayerwidth = 0; // weak
343 char tjsgdv_istransitioning = 0; // weak
344 int tjsgdv_maxgenold = 0; // weak
345 int dword_10012E98 = 0; // weak
346 int tjsgv_inlayerpitch = 0; // weak
347 char tjsgdv_firesparkactive = 0; // weak
348 char tjsgv_pause = '\0'; // weak
349 int tjsgv_baseaccel = 0; // weak
350 int tjsgv_accelrange = 0; // weak
351 int tjsgv_windvelocity = 0; // weak
352 int tjsgdv_relatedwindvelocity = 0; // weak
353 int tjsgdv_fillcolor = 0; // weak
356 //----- (10001010) --------------------------------------------------------
357 void sub_10001010()
359 tjsgv_directionbase = 3.14159265368979 * 0.5;
362 //----- (10001040) --------------------------------------------------------
363 void sub_10001040()
365 tjsgv_directionrange = 3.14159265368979 * 0.15;
368 //----- (10001060) --------------------------------------------------------
369 double tjsdf_getrandombits128()
371 int64_t v2; // [esp+0h] [ebp-14h]
373 ("void ::TVPGetRandomBits128(void *)")((char *)&v2 + 4);
374 return (double)HIDWORD(v2) * 2.328306437080797e-10;
377 //----- (100014D0) --------------------------------------------------------
378 signed int tjsf_drawFireSpark(int this, int flag, int membername, int hint, int result, int numparams, int *param)
380 int v11; // eax
381 int64_t v15; // rdi
382 int v19; // ebp
383 int v20; // ebx
384 int *v21; // ecx
385 int v22; // esi
386 int v24; // edx
387 int v26; // eax
388 int v27; // eax
389 int64_t v28; // rax
390 int v29; // edi
391 int v30; // ebx
392 uint32_t *v32; // esi
393 int64_t v33; // rax
394 long double v34; // st7
395 int64_t v35; // rax
396 long double v36; // st7
397 int64_t v37; // rax
398 int *v46; // esi
399 unsigned int v47; // ecx
400 unsigned int v49; // edi
401 int v52; // eax
402 int v53; // edi
403 int v54; // eax
404 int v55; // edx
405 int v56; // eax
406 int v57; // ecx
407 int v58; // eax
408 int v59; // ebp
409 int v60; // edx
410 int v61; // eax
411 int v62; // ecx
412 int v63; // ebx
413 char *v64; // edx
414 int v65; // ebp
415 int v66; // ebx
416 double v71; // st7
417 int v73; // [esp+24h] [ebp-D4h]
418 signed int v74; // [esp+24h] [ebp-D4h]
419 int v76; // [esp+28h] [ebp-D0h]
420 signed int v79; // [esp+38h] [ebp-C0h]
421 int v80; // [esp+3Ch] [ebp-BCh]
422 int v81; // [esp+40h] [ebp-B8h]
423 int v82; // [esp+44h] [ebp-B4h]
424 int v83; // [esp+48h] [ebp-B0h]
425 long double v84; // [esp+4Ch] [ebp-ACh]
426 double v87; // [esp+5Ch] [ebp-9Ch]
427 int v88; // [esp+64h] [ebp-94h]
428 int v89; // [esp+68h] [ebp-90h]
429 int v91; // [esp+70h] [ebp-88h]
430 int v92; // [esp+74h] [ebp-84h]
431 int v93; // [esp+78h] [ebp-80h]
433 if ( membername )
434 return TJS_E_MEMBERNOTFOUND;
435 if ( numparams <= 0 )
437 v15 = ("tjs_uint64 ::TVPGetTickCount()")();
439 else
441 ("tTJSVariant::tTJSVariant()")(&v84);
442 v11 = ("iTJSDispatch2 * tTJSVariant::AsObjectNoAddRef() const")(param[0]);
443 if ( FIND_AND_GET_MEMBER(L"tick", v11, &v84) )
445 v15 = ("tTJSVariant::operator tjs_int() const")(&v84);
447 else
449 v15 = ("tjs_uint64 ::TVPGetTickCount()")();
451 ("tTJSVariant::~ tTJSVariant()")(&v84);
453 if ( tjsgv_pause || !tjsgv_effect )
455 tjsgdv_curtick = v15;
457 else
459 v79 = v15 - tjsgdv_curtick;
460 if ( (signed int)v15 - (signed int)tjsgdv_curtick >= 1 )
462 v19 = tjsgv_maxgen;
463 v20 = tjsgv_inlayerpitch;
464 v88 = tjsgv_inlayerbuffer;
465 v91 = tjsgv_inlayerwidth;
466 v82 = tjsgv_inlayerwidth;
467 v92 = tjsgv_inlayerheight;
468 v80 = tjsgv_inlayerheight;
469 v89 = tjsgv_inlayerpitch;
470 v81 = 0;
471 v83 = 0;
472 v73 = tjsgdv_firesparkbuffer;
473 v21 = (int *)(tjsgdv_firesparkbuffer + 64);
474 for (size_t i = 0; i < tjsgv_maxgen; i += 1)
476 if ( v21[3] )
478 v22 = v20 * v21[0] + v88 + 4 * v21[-1];
479 for (size_t j = 0; j < v21[2]; j += 1)
481 v24 = v21[1];
482 for (size_t k = 0; k < v24; k += 1)
484 ((uint32_t *)v22)[k] = tjsgdv_fillcolor;
486 v22 += v20;
488 v19 = tjsgv_maxgen;
489 v26 = v21[-1];
490 if ( v82 > v26 )
491 v82 = v21[-1];
492 if ( v80 > v21[0] )
493 v80 = v21[0];
494 v27 = v21[1] + v26;
495 if ( v81 < v27 )
496 v81 = v27;
497 if ( v83 < v21[0] + v21[2] )
498 v83 = v21[0] + v21[2];
500 v21 += 20;
502 if ( tjsgdv_istransitioning )
504 if ( (signed int)v15 - tjsgdv_curtime >= tjsgv_transtime )
506 tjsgdv_istransitioning = 0;
507 v19 = tjsgdv_maxgennew;
508 tjsgv_maxgen = tjsgdv_maxgennew;
509 if ( tjsgdv_maxgennew < 1 )
511 free(tjsgdv_firesparkbuffer);
512 tjsgdv_firesparkactive = 0;
513 //UPDATE: tjsgv_inlayer 0 0 tjsgv_inlayerwidth tjsgv_inlayerheight
514 return TJS_S_OK;
517 else
519 v28 = (int64_t)((double)(tjsgdv_maxgennew - tjsgdv_maxgenold)
520 * ((double)((signed int)v15 - tjsgdv_curtime)
521 / (double)tjsgv_transtime));
522 v19 = tjsgdv_maxgenold + v28;
523 tjsgv_maxgen = tjsgdv_maxgenold + v28;
526 v29 = dword_10012A58 + v79 * dword_10012E98;
527 v30 = v19;
528 if ( v29 & 0xFFFF0000 )
530 v29 >>= 16;
531 v32 = (uint32_t *)(v73 + 8);
532 for (size_t i = 0; i < v30; i += 1)
534 if ( !v32[17] )
536 v84 = tjsdf_getrandombits128() * tjsgv_directionrange + tjsgv_directionbase;
537 v87 = tjsdf_getrandombits128() * (double)tjsgv_velocityrange + (double)tjsgv_basevelocity;
538 v32[-2] = (int64_t)(tjsdf_getrandombits128() * (double)tjsgv_inlayerwidth);
539 v33 = (int64_t)(tjsdf_getrandombits128() * (double)tjsgv_heightrange + (double)tjsgv_basetop);
540 v34 = cos(v84);
541 v32[-1] = v33;
542 v35 = (int64_t)(v34 * v87);
543 v36 = sin(v84);
544 v32[0] = v35;
545 v32[1] = (int64_t)(v36 * v87);
546 v32[3] = 0;
547 v32[2] = 0;
548 v32[4] = (int64_t)(tjsdf_getrandombits128() * (double)tjsgv_lifetimerange + (double)tjsgv_baselifetime);
549 v32[10] = (int64_t)(tjsdf_getrandombits128() * (double)tjsgv_accelrange + (double)tjsgv_baseaccel);
550 if ( tjsgv_samesize )
552 v37 = (int64_t)(tjsdf_getrandombits128() * (double)tjsgv_sizewrange + (double)tjsgv_basesizew);
553 v32[12] = v37;
554 v32[11] = v37;
556 else
558 v32[11] = (int64_t)(tjsdf_getrandombits128() * (double)tjsgv_sizewrange + (double)tjsgv_basesizew);
559 v32[12] = (int64_t)(tjsdf_getrandombits128() * (double)tjsgv_sizehrange + (double)tjsgv_basesizeh);
561 v32[6] = v15;
562 v32[8] = v15;
563 v32[17] = 1;
564 --v29;
565 ++dword_10012A4C;
566 if ( v29 < 1 )
567 break;
569 v32 += 20;
571 v29 = (uint16_t)v29;
573 dword_10012A58 = v29;
574 v46 = (int *)(v73 + 8);
575 for (size_t i = 0; i < v30; i += 1)
577 if ( v46[17] )
579 v47 = v46[6];
580 v49 = v15 - v47;
581 if ( v49 <= v46[4] )
583 v52 = v46[0];
584 if ( tjsgv_windvelocity >= 0 )
586 if ( v52 < tjsgv_windvelocity )
587 v46[0] = v52 + v79 * tjsgdv_relatedwindvelocity;
589 else if ( v52 > tjsgv_windvelocity )
591 v46[0] = v52 + v79 * tjsgdv_relatedwindvelocity;
593 v53 = v46[12];
594 v54 = v46[2] + v79 * v46[0];
595 v76 = v46[12];
596 v46[2] = (uint16_t)v54;
597 v55 = (v54 >> 16) + v46[-2];
598 v56 = v79 * v46[1];
599 v57 = v46[3];
600 v46[-2] = v55;
601 v58 = v57 + v56;
602 v59 = v55;
603 LOWORD(v57) = v58;
604 v60 = (v58 >> 16) + v46[-1];
605 v61 = v46[11];
606 v46[3] = (uint16_t)v57;
607 v62 = v91;
608 v46[-1] = v60;
609 v63 = v60;
610 v74 = v61;
611 if ( v59 >= 0 )
613 if ( v59 < v62 )
615 if ( v59 > v62 - v61 )
616 v74 = v62 - v59;
618 else
620 v59 -= v62;
623 else
625 v59 += v62;
626 if ( v61 + v59 >= v62 )
628 v61 = v62 - v59;
629 v74 = v62 - v59;
631 if ( v61 < 1 )
632 goto LABEL_103;
634 if ( v60 >= 0 )
636 if ( v60 < v92 )
638 if ( v60 >= v92 - v53 )
640 v53 = v92 - v60;
641 v76 = v92 - v60;
643 goto LABEL_90;
646 else
648 v53 += v60;
649 v76 = v53;
650 if ( v53 >= 1 )
652 v63 = 0;
653 LABEL_90:
654 v93 = dword_10012A78[((signed int)((v49 << 15) / v46[4]) >> 7) & 0xFF];
655 v64 = (char *)(v89 * v63 + v88 + 4 * v59);
656 for (size_t i = 0; i < v53; i += 1)
658 if ( v74 > 0 )
660 memset32(v64, v93, v74);
661 v53 = v76;
663 v64 += v89;
665 v46[13] = v59;
666 v46[14] = v63;
667 v46[15] = v74;
668 v46[16] = v53;
669 if ( v82 > v59 )
670 v82 = v59;
671 if ( v80 > v63 )
672 v80 = v63;
673 v65 = v74 + v59;
674 if ( v81 < v65 )
675 v81 = v65;
676 v66 = v53 + v63;
677 if ( v83 < v66 )
678 v83 = v66;
679 goto LABEL_103;
683 else
685 v46[17] = 0;
686 --dword_10012A4C;
689 LABEL_103:
690 v46 += 20;
692 //UPDATE: tjsgv_inlayer v82 v80 (v81 - v82) (v83 - v80)
693 if ( (double)v79 * tjsgv_windvariancecapability > tjsdf_getrandombits128() )
695 v71 = tjsdf_getrandombits128();
696 tjsgv_windvelocity = (int64_t)((v71 * tjsgv_maxwindvelocity + v71 * tjsgv_maxwindvelocity - tjsgv_maxwindvelocity) * 65535.0);
697 tjsgdv_relatedwindvelocity = tjsgv_windvelocity >> 11;
699 tjsgdv_curtick = v15;
702 return TJS_S_OK;
705 //----- (10001EC0) --------------------------------------------------------
706 signed int tjsf_initFireSpark(int a2, int a3, int a4, int this, int flag, int membername, int hint, int result, signed int numparams, int *param)
708 int v15; // esi
709 int v42; // ebp
710 int v43; // edi
711 int v47; // eax
712 int v51; // esi
713 char v55; // bl
714 int v58; // eax
715 double v61; // st7
716 double v63; // st6
717 signed int v64; // esi
718 double v65; // st5
719 int v66; // ebx
720 char *v67; // eax
721 uint32_t *v69; // eax
722 char *v73; // [esp+B8h] [ebp-30h]
723 char *v77; // [esp+C4h] [ebp-24h]
724 int v79; // [esp+C8h] [ebp-20h]
725 char v80; // [esp+D0h] [ebp-18h]
726 char v81; // [esp+D4h] [ebp-14h]
727 char v82; // [esp+D8h] [ebp-10h]
728 int x; // ???
730 if ( membername )
731 return TJS_E_MEMBERNOTFOUND;
732 if ( numparams < 1 )
733 return TJS_E_BADPARAMCOUNT;
734 if ( tjsgdv_firesparkactive )
736 free(tjsgdv_firesparkbuffer);
737 tjsgdv_firesparkactive = 0;
739 tjsgv_inlayer = ("iTJSDispatch2 * tTJSVariant::AsObjectNoAddRef() const")(param[0]);
740 v15 = ("iTJSDispatch2 * tTJSVariant::AsObjectNoAddRef() const")(param[1]);
741 ("tTJSVariant::tTJSVariant()")(&v82);
742 if ( !FIND_AND_GET_MEMBER(L"imageWidth", tjsgv_inlayer, &v82) )
744 ("void ::TVPThrowExceptionMessage(const tjs_char *)")(L"invoking of Layer.imageWidth failed.");
746 tjsgv_inlayerwidth = ("tTJSVariant::operator tjs_int() const")(&v82);
747 if ( !FIND_AND_GET_MEMBER(L"imageHeight", tjsgv_inlayer, &v82) )
749 ("void ::TVPThrowExceptionMessage(const tjs_char *)")(L"invoking of Layer.imageHeight failed.");
751 tjsgv_inlayerheight = ("tTJSVariant::operator tjs_int() const")(&v82);
752 if ( !FIND_AND_GET_MEMBER(L"mainImageBufferForWrite", tjsgv_inlayer, &v82) )
754 ("void ::TVPThrowExceptionMessage(const tjs_char *)")(L"invoking of Layer.mainImageBufferForWrite failed.");
756 v77 = &v82;
757 tjsgv_inlayerbuffer = ("tTJSVariant::operator tjs_int() const")();
758 if ( !FIND_AND_GET_MEMBER(L"mainImageBufferPitch", tjsgv_inlayer, &v82) )
760 ("void ::TVPThrowExceptionMessage(const tjs_char *)")(L"invoking of Layer.mainImageBufferPitch failed.");
762 v73 = &v81;
763 tjsgv_inlayerpitch = ("tTJSVariant::operator tjs_int() const")();
764 tjsgdv_fillcolor = *(uint32_t *)tjsgv_inlayerbuffer;
765 if ( v15 )
767 if ( FIND_AND_GET_MEMBER(L"maxgen", v15, &v80) )
769 if ( ("tTJSVariant::operator tjs_int() const")(&v80) >= 500 )
771 tjsgv_maxgen = 500;
773 else
775 tjsgv_maxgen = ("tTJSVariant::operator tjs_int() const")(&v80);
778 if ( FIND_AND_GET_MEMBER(L"basevelocity", v15, &v80) )
780 tjsgv_basevelocity = (int64_t)("tTJSVariant::operator tTVReal() const")(&v80) * 65535.0;
782 if ( FIND_AND_GET_MEMBER(L"velocityrange", v15, &v80) )
784 tjsgv_velocityrange = (int64_t)("tTJSVariant::operator tTVReal() const")(&v80) * 65535.0;
786 if ( FIND_AND_GET_MEMBER(L"baselifetime", v15, &v80) )
788 tjsgv_baselifetime = ("tTJSVariant::operator tjs_int() const")(&v80);
790 if ( FIND_AND_GET_MEMBER(L"lifetimerange", v15, &v80) )
792 tjsgv_lifetimerange = ("tTJSVariant::operator tjs_int() const")(&v80);
794 if ( FIND_AND_GET_MEMBER(L"baseaccel", v15, &v80) )
796 tjsgv_baseaccel = ("tTJSVariant::operator tjs_int() const")(&v80);
798 if ( FIND_AND_GET_MEMBER(L"accelrange", v15, &v80) )
800 tjsgv_accelrange = ("tTJSVariant::operator tjs_int() const")(&v80);
802 if ( FIND_AND_GET_MEMBER(L"directionbase", v15, &v80) )
804 tjsgv_directionbase = ("tTJSVariant::operator tTVReal() const")(&v80);
806 if ( FIND_AND_GET_MEMBER(L"directionrange", v15, &v80) )
808 tjsgv_directionrange = ("tTJSVariant::operator tTVReal() const")(&v80);
810 if ( FIND_AND_GET_MEMBER(L"basetop", v15, &v80) )
812 tjsgv_basetop = ("tTJSVariant::operator tjs_int() const")(&v80);
814 if ( FIND_AND_GET_MEMBER(L"heightrange", v15, &v80) )
816 tjsgv_heightrange = ("tTJSVariant::operator tjs_int() const")(&v80);
818 if ( FIND_AND_GET_MEMBER(L"basesizew", v15, &v80) )
820 tjsgv_basesizew = ("tTJSVariant::operator tjs_int() const")(&v80);
822 if ( FIND_AND_GET_MEMBER(L"sizewrange", v15, &v80) )
824 tjsgv_sizewrange = ("tTJSVariant::operator tjs_int() const")(&v80);
826 if ( FIND_AND_GET_MEMBER(L"basesizeh", v15, &v80) )
828 tjsgv_basesizeh = ("tTJSVariant::operator tjs_int() const")(&v80);
830 if ( FIND_AND_GET_MEMBER(L"sizehrange", v15, &v80) )
832 tjsgv_sizehrange = ("tTJSVariant::operator tjs_int() const")(&v80);
834 if ( FIND_AND_GET_MEMBER(L"windvelocity", v15, &v80) )
836 tjsgv_windvelocity = ("tTJSVariant::operator tjs_int() const")(&v80);
838 if ( FIND_AND_GET_MEMBER(L"windvariancecapability", v15, &v80) )
840 tjsgv_windvariancecapability = ("tTJSVariant::operator tTVReal() const")(&v80);
842 if ( FIND_AND_GET_MEMBER(L"maxwindvelocity", v15, &v80) )
844 tjsgv_maxwindvelocity = ("tTJSVariant::operator tTVReal() const")(&v80);
846 if ( FIND_AND_GET_MEMBER(L"samesize", v15, &v80) )
848 tjsgv_samesize = ("tTJSVariant::operator tjs_int() const")(&v80);
850 if ( FIND_AND_GET_MEMBER(L"colortable", v15, &v80) )
852 ("tTJSString::tTJSString(const tTJSVariant &)")((signed int *)x, &v80);
853 ("tTJSString::tTJSString()")(x);
854 v42 = ("tjs_int tTJSString::length() const")(x);
855 v43 = 0;
856 for (size_t i = 0; i < v42; i += 1)
858 if ( ("tjs_char tTJSString::operator [](tjs_uint) const")(x, i) == 44 )
860 v47 = ("tjs_int64 tTJSString::AsInteger() const")(x);
861 if ( v47 < 0 )
863 if ( v43 % 3 >= 3 )
864 byte_1000F084[v43] = HIBYTE(tjsgdv_fillcolor);
865 else
866 byte_1000F084[v43] = (unsigned int)tjsgdv_fillcolor >> (16 - 8 * (v43 % 3));
868 else
870 byte_1000F084[v43] = v47;
872 ("tTJSString & tTJSString::operator =(const tjs_nchar *)")(x, "\0");
874 else if ( ("tjs_char tTJSString::operator [](tjs_uint) const")(x, i) != 32 )
876 v51 = ("tjs_char tTJSString::operator [](tjs_uint) const")(x, i);
877 ("void tTJSString::operator +=(tjs_char)")(x, v51);
880 ("tTJSString::tTJSString(const tjs_nchar *)")(x, "\0");
881 v55 = ("bool tTJSString::operator !=(const tTJSString &) const")(x);
882 ("tTJSString::~ tTJSString()")();
883 if ( v55 )
885 v58 = ("tjs_int64 tTJSString::AsInteger() const")(x);
886 if ( v58 < 0 )
888 if ( v43 % 3 >= 3 )
889 byte_1000F084[v43] = HIBYTE(tjsgdv_fillcolor);
890 else
891 byte_1000F084[v43] = (unsigned int)tjsgdv_fillcolor >> (16 - 8 * (v43 % 3));
893 else
895 byte_1000F084[v43] = v58;
897 ++v43;
899 dword_1000F0A4 = v43 / 3;
900 ("tTJSString::~ tTJSString()")();
901 ("tTJSString::~ tTJSString()")(x);
904 v61 = 0.0;
905 v63 = (double)(dword_1000F0A4 - 1);
906 dword_10012E98 = (tjsgv_maxgen << 16) / (tjsgv_baselifetime + tjsgv_lifetimerange);
907 for (int *i = dword_10012A78; (size_t)i < (size_t)&tjsgdv_firesparkbuffer; i += 1)
909 v64 = (int64_t)(v63 * v61);
910 v65 = v63 * v61 - (double)v64;
911 v66 = (uint8_t)byte_1000F084[3 * v64];
912 v79 = (uint8_t)byte_1000F084[(3 * v64) + 3] - v66;
913 i[-1] = ((uint8_t)byte_1000F084[(3 * v64) + 2]
914 + (unsigned int)(int64_t)((double)((uint8_t)byte_1000F084[(3 * v64) + 5]
915 - (uint8_t)byte_1000F084[(3 * v64) + 2])
916 * v65)) | ((v66 + (unsigned int)(int64_t)((double)v79 * v65)) << 16) | (((uint8_t)byte_1000F084[(3 * v64) + 1] + (unsigned int)(int64_t)((double)((uint8_t)byte_1000F084[(3 * v64) + 4] - (uint8_t)byte_1000F084[(3 * v64) + 1]) * v65)) << 8);
917 v61 += 0.00390625;
919 v67 = (char *)operator new(0x9C40u);
920 tjsgdv_firesparkbuffer = (int)v67;
921 v69 = v67 + 76;
922 for (size_t i = 0; i < tjsgv_maxgen; i += 1)
924 v69[0] = 0;
925 v69 += 20;
927 dword_10012A4C = 0;
928 dword_10012A58 = 0;
929 tjsgdv_curtick = ("tjs_uint64 ::TVPGetTickCount()")();
930 tjsgdv_firesparkactive = 1;
931 tjsgv_pause = 0;
932 ("tTJSVariant::~ tTJSVariant()")(&v80);
933 return TJS_S_OK;
936 //----- (10002DB0) --------------------------------------------------------
937 signed int tjsf_finishFireSpark(int this, int flag, int membername)
939 if ( membername )
940 return TJS_E_MEMBERNOTFOUND;
941 if ( tjsgdv_firesparkactive )
943 free(tjsgdv_firesparkbuffer);
944 tjsgdv_firesparkactive = 0;
946 return TJS_S_OK;
949 //----- (10002DE0) --------------------------------------------------------
950 signed int tjsf_changeFireSpark(int a1, int this, int flag, int membername, int hint, int result, signed int numparams, int *param)
952 int v11; // esi
953 char *v32; // [esp+34h] [ebp-1Ch]
954 int v33; // [esp+38h] [ebp-18h]
955 char v34; // [esp+3Ch] [ebp-14h]
957 if ( membername )
958 return TJS_E_MEMBERNOTFOUND;
959 if ( numparams < 1 )
960 return TJS_E_BADPARAMCOUNT;
961 if ( tjsgdv_firesparkactive )
963 v11 = ("iTJSDispatch2 * tTJSVariant::AsObjectNoAddRef() const")(param[0]);
964 ("tTJSVariant::tTJSVariant()")();
965 if ( FIND_AND_GET_MEMBER(L"maxgen", v11, &v33) )
967 if ( ("tTJSVariant::operator tjs_int() const")(&v33) >= 500 )
969 tjsgdv_maxgennew = 500;
971 else
973 tjsgdv_maxgennew = ("tTJSVariant::operator tjs_int() const")(&v33);
975 if ( !FIND_AND_GET_MEMBER(L"transtime", v11, &v33) )
977 tjsgv_transtime = 5000;
979 else
981 tjsgv_transtime = ("tTJSVariant::operator tjs_int() const")(&v33);
983 tjsgdv_maxgenold = tjsgv_maxgen;
984 tjsgdv_curtime = ("tjs_uint64 ::TVPGetTickCount()")();
985 tjsgdv_istransitioning = 1;
987 if ( FIND_AND_GET_MEMBER(L"pause", v11, &v33) )
989 tjsgv_pause = ("tTJSVariant::operator tjs_int() const")(&v33) != 0;
991 if ( FIND_AND_GET_MEMBER(L"effect", v11, &v33) )
993 tjsgv_effect = ("tTJSVariant::operator tjs_int() const")(&v33) != 0;
995 if ( FIND_AND_GET_MEMBER(L"layer", v11, &v33) )
997 tjsgv_inlayer = ("iTJSDispatch2 * tTJSVariant::AsObjectNoAddRef() const")(&v33);
998 if ( !FIND_AND_GET_MEMBER(L"imageWidth", tjsgv_inlayer, &v34) )
1000 ("void ::TVPThrowExceptionMessage(const tjs_char *)")(L"invoking of Layer.imageWidth failed.");
1002 tjsgv_inlayerwidth = ("tTJSVariant::operator tjs_int() const")(&v34);
1003 if ( !FIND_AND_GET_MEMBER(L"imageHeight", tjsgv_inlayer, &v34) )
1005 ("void ::TVPThrowExceptionMessage(const tjs_char *)")(L"invoking of Layer.imageHeight failed.");
1007 tjsgv_inlayerheight = ("tTJSVariant::operator tjs_int() const")(&v34);
1008 if ( !FIND_AND_GET_MEMBER(L"mainImageBufferForWrite", tjsgv_inlayer, &v34) )
1010 ("void ::TVPThrowExceptionMessage(const tjs_char *)")(L"invoking of Layer.mainImageBufferForWrite failed.");
1012 tjsgv_inlayerbuffer = ("tTJSVariant::operator tjs_int() const")(&v34);
1013 if ( !FIND_AND_GET_MEMBER(L"mainImageBufferPitch", tjsgv_inlayer, &v34) )
1015 ("void ::TVPThrowExceptionMessage(const tjs_char *)")(L"invoking of Layer.mainImageBufferPitch failed.");
1017 tjsgv_inlayerpitch = ("tTJSVariant::operator tjs_int() const")(&v34);
1019 ("tTJSVariant::~ tTJSVariant()")(&v33);
1021 return TJS_S_OK;