home *** CD-ROM | disk | FTP | other *** search
/ The Fred Fish Collection 1.5 / ffcollection-1-5-1992-11.iso / ff_disks / 300-399 / ff374.lzh / PopArt / sorcery / anim.c next >
C/C++ Source or Header  |  1990-10-08  |  7KB  |  242 lines

  1.  
  2.  
  3.                   /*  anim  ---  animate a gadget...
  4.  
  5.          Thuy (my girlfriend.device) insists this means "animal."
  6.                            I don't know why  */
  7.  
  8.  
  9. #include <exec/memory.h>
  10. #include "stuff.h"
  11.  
  12. #ifndef POPLITE
  13. #include "anim.h"
  14. #endif
  15.  
  16. #define gadgedata(g) (((struct Image *) (g->GadgetRender))->ImageData)
  17. #define BIGDATA (save2SIZE*2)
  18. #define swilldefault    5
  19.  
  20.  
  21.                    extern struct Window   * win      ;
  22.                    extern ULONG             msgclass ;
  23.                    extern USHORT            msgcode  ;
  24.                    extern  int              gadcode  ;
  25.                    extern struct RastPort * reep     ;
  26.                    extern struct Gadget     TGads [] ;
  27.          struct Image vop = { 0, 0, 32, 24, 5, NL, 0x1f, 0, NL };
  28. #ifndef POPLITE
  29.      struct Image animage = { 0, 0, 32, 24, 5, NL, 0x1f, 0, NL };
  30.  
  31.                         static struct Gadget *gogo;
  32.                         static long swill = swilldefault;
  33. #endif
  34.  
  35.  
  36. anim (gaga)  struct Gadget *gaga;
  37. {
  38. #ifndef POPLITE
  39.     REG int zot;
  40.  
  41.     animage.ImageData = AllocMem ( BIGDATA, MEMF_CHIP | MEMF_PUBLIC );
  42.     ifn (animage.ImageData)  {  ALERT ("Low Chip Mem!  Look out!");  RET; }
  43.     gogo = gaga;
  44.  
  45.     if (gaga == &TGads [7])  {
  46.         swill = 4;
  47.         animage.Height = 20;
  48.         animage.Width  = 32;
  49.  
  50.         loop (zot = 3; --zot;)  popanim (ni_clon2), popanim (gadgedata (gaga));
  51.  
  52.         swill = 5;
  53.     }  /* animate block  */
  54.  
  55.     if (gaga == &TGads [3])  {
  56.         animage.Height = 24;
  57.         animage.Width  = 32;
  58.  
  59.         loop (zot = 4; zot--;)  {
  60.             popanim (new1);
  61.             popanim (new2);
  62.             popanim (new3);   }
  63.  
  64.         swill =  1;
  65.         popanim (gadgedata (gaga));
  66.     }  /* animate block  */
  67.  
  68.     if (gaga == &TGads [10])  {
  69.         animage.Height = ni_inc1HITE;
  70.         animage.Width  = ni_inc1WIDT;
  71.         animage.TopEdge  = 3;
  72.         animage.LeftEdge = 3;
  73.         swill = 6;
  74.         popanim (ni_inc1 ); popanim (ni_inc2 ); popanim (ni_inc3 );
  75.         popanim (ni_inc4 ); popanim (ni_inc5 ); popanim (ni_inc6 );
  76.         popanim (ni_inc7 ); popanim (ni_inc8 ); popanim (ni_inc9 );
  77.         popanim (ni_inc10);
  78.         animage.Height = 26;
  79.         animage.Width  = 38;
  80.         animage.LeftEdge = 0;
  81.         animage.TopEdge  = 0;
  82.         swill =  1;
  83.         popanim (gadgedata (gaga));  }
  84.  
  85.     if (gaga == &TGads [6])  {
  86.         animage.Height   = ni_ld1HITE;
  87.         animage.Width    = ni_ld1WIDT;
  88.         animage.TopEdge  =  5;
  89.         animage.LeftEdge =  3;
  90.         swill = 8;  popanim (ni_ld1 );  swill = 2;
  91.         popanim (ni_ld2 );  popanim (ni_ld3 );  popanim (ni_ld2 );
  92.         popanim (ni_ld3 );  popanim (ni_ld4 );  popanim (ni_ld3 );
  93.         popanim (ni_ld4 );  popanim (ni_ld5 );  popanim (ni_ld6 );
  94.         popanim (ni_ld3 );  popanim (ni_ld4 );  popanim (ni_ld6 );
  95.         popanim (ni_ld4 );  popanim (ni_ld7 );  popanim (ni_ld5 );
  96.         popanim (ni_ld6 );  popanim (ni_ld7 );
  97.         swill = 8;  popanim (ni_ld8 );
  98.         animage.Height   = 26;
  99.         animage.Width    = 38;
  100.         animage.LeftEdge = 0;
  101.         animage.TopEdge  = 0;
  102.         swill = 1;
  103.         popanim (gadgedata (gaga));  }
  104.  
  105. #endif
  106.  
  107.     if (gaga == &TGads [ 9])  {
  108.  
  109. #ifndef POPLITE
  110.  
  111.         extern USHORT ni_roll [], ni_seq [];
  112.  
  113.  
  114.         animage.Height = ni_roll1HITE;
  115.         animage.Width  = ni_roll1WIDT;
  116.         popanim (ni_roll1); popanim (ni_roll2); popanim (ni_roll3);
  117.         popanim (ni_roll4); popanim (ni_roll5); popanim (ni_roll6);
  118.         popanim (ni_roll7); popanim (ni_roll8);
  119.  
  120. #endif
  121.  
  122.         roll ();                             /*  WE ACTUALLY DO IT HERE!!!  */
  123.  
  124. #ifndef POPLITE
  125.  
  126.         animage.Height = 20;
  127.         popanim (ni_roll );
  128.         vop.PlanePick = 0x017;
  129.  
  130.         popChip (ni_seq, ni_roll1SIZE /* should be big enough... */,
  131.                     6, 20, 229, 121);
  132.  
  133.         vop.PlanePick = 0x01f;
  134. #endif
  135.  
  136.     }  /*  restore the seq gadget after roll clobbers it  */
  137.  
  138. #ifndef POPLITE
  139.  
  140.     if (gaga == &TGads [5])  {
  141.         animage.Height = 24;
  142.         animage.Width  = 32;
  143.         animage.LeftEdge = 3;
  144.         animage.TopEdge  = 0;
  145.         swill = 3;
  146.         popanim (save1 ); popanim (save2 ); popanim (save3 );
  147.         popanim (save4 ); popanim (save5 ); popanim (save6 );
  148.         popanim (save7 ); popanim (save8 ); popanim (save9 );
  149.         popanim (save10); popanim (save11); popanim (save12);
  150.         popanim (save13);
  151.         swill = 11;
  152.         popanim (save14);
  153.         swill =  1;
  154.         animage.Height = 26;
  155.         animage.Width  = 38;
  156.         animage.LeftEdge = 0;
  157.         animage.TopEdge  = 0;
  158.         popanim (gadgedata (gaga));  }
  159.  
  160.     if (gaga == &TGads[12])  {  extern int webefillin;
  161.         animage.Height = ni_fill1HITE;
  162.         animage.Width  = ni_fill1WIDT;
  163.         animage.TopEdge  = 3;
  164.         animage.LeftEdge = 3;
  165.         swill = 2;
  166.  
  167.         ifn (webefillin)  {
  168.             popanim (ni_fill1); popanim (ni_fill2); popanim (ni_fill3);
  169.             popanim (ni_fill4); popanim (ni_fill5); popanim (ni_fill6);
  170.             swill = 5;
  171.             popanim (ni_fill7);
  172.             swill = 1;
  173.             animage.TopEdge  = 0;
  174.             animage.LeftEdge = 0;
  175.             animage.Height = 26;
  176.             animage.Width  = 38;
  177.             popanim (gadgedata (gaga));  }
  178.         else  {
  179.             popanim (ni_fill7); popanim (ni_fill6); popanim (ni_fill5);
  180.             popanim (ni_fill4); popanim (ni_fill3); popanim (ni_fill2);
  181.             swill = 5;
  182.             popanim (ni_fill1);
  183.             swill = 1;
  184.             animage.TopEdge  = 0;
  185.             animage.LeftEdge = 0;
  186.             animage.Height = 26;
  187.             animage.Width  = 38;
  188.             popanim (gadgedata (gaga)); }  }
  189.  
  190.     swill = swilldefault;
  191.     FreeMem (animage.ImageData, BIGDATA);
  192. #endif
  193. }                          /*  now its a waste of code, now its a stub ...  */
  194.  
  195.  
  196. #ifndef POPLITE
  197. popanim (what)
  198.    void *what;
  199. {
  200.  
  201.     CopyMem (what, animage.ImageData, BIGDATA);
  202.     WaitTOF ();
  203.     Delay ((long) swill);
  204.     DrawImage (reep, &animage, (long) gogo->LeftEdge, (long) gogo->TopEdge);
  205.  
  206. }  /*  alright, alright, I'll put in a closing brace, you stupid compiler!
  207.         gad - even COBOL can handled a missing subroutine exit!!            */
  208. #endif
  209.  
  210.                                             void
  211. popChip (array, size, xsize, ysize, xx, yy)
  212.  USHORT *array; long size;
  213. {
  214.     REG    USHORT *myChip;
  215.     extern USHORT *imagine;
  216.  
  217.  
  218.     IFN ( myChip = (USHORT *) AllocMem (size, MEMF_CHIP | MEMF_CLEAR))
  219.         {  ALERT ("Can't do it - no chips left!");  return;  }
  220.  
  221.     CopyMem (array, myChip, size);
  222.     vop.ImageData = myChip;
  223.     vop.Width = xsize;
  224.     vop.Height = ysize;
  225.  
  226. #ifdef POPLITE
  227.  
  228.     if (imagine)
  229.         vop.Depth = 5,
  230.         vop.PlanePick = 0x1f;
  231.     else
  232.         vop.Depth = 1,
  233.         vop.PlanePick = 1;
  234.  
  235. #endif                                        slap bubble gum on the cracks...
  236.  
  237.     DrawImage (win->RPort, &vop, (long) xx, (long) yy);
  238.     FreeMem (myChip, size);
  239.  
  240. }
  241.  
  242.