home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 013.lha / fish / atest.c < prev    next >
C/C++ Source or Header  |  1986-11-10  |  3KB  |  163 lines

  1. /* atest.c */
  2. /***************************************************************/
  3. #include "fishes.h"
  4. #include <stdio.h>
  5.  
  6. #define WIDTH   320
  7. #define HEIGHT  200 
  8. #define DEPTH 3 
  9.  
  10. short bpdata[] =
  11.    {
  12.    0x000, 0x5ef, 0x128, 0xd81, 0x326, 0x203, 0x086, 0x044,
  13.    0x5ef, 0x633, 0x855, 0x857, 0x065, 0x669, 0x223, 0x547
  14.    };
  15.  
  16. struct GelsInfo *GInfo;
  17. struct VSprite *head, *tail;
  18. struct collTable *boom;
  19. struct BitMap   bitmap[2];
  20.  
  21. show(screen,view,vp,rp,window)
  22. struct Screen *screen;
  23. struct View *view;
  24. struct ViewPort *vp;
  25. struct RastPort *rp;
  26. struct Window *window;
  27. {
  28.     short dispIndex;
  29.     short i, i2, j,k;
  30.     struct IntuiMessage *message;
  31.     struct AnimOb *animKey;
  32.     struct BitMap *OldI_BitMap;        
  33.  
  34.     OldI_BitMap = rp->BitMap;
  35.  
  36.     if ((boom = (struct collTable *)AllocMem(sizeof
  37.         (struct collTable),MEMF_PUBLIC+MEMF_CLEAR )) == 0)
  38.         {
  39.             exit(1);
  40.         }
  41.  
  42.     if ((head = (struct VSprite *)AllocMem(sizeof(struct VSprite),
  43.         MEMF_PUBLIC+MEMF_CLEAR )) == 0)
  44.         {
  45.             exit(1);
  46.         }
  47.  
  48.     if ((tail = (struct VSprite *)AllocMem(sizeof(struct VSprite),
  49.         MEMF_PUBLIC+MEMF_CLEAR )) == 0)
  50.         {
  51.             exit(1);
  52.         }
  53.  
  54.     if ((GInfo = (struct GelsInfo *)AllocMem(sizeof(struct GelsInfo),
  55.         MEMF_PUBLIC+MEMF_CLEAR )) == 0)
  56.         {
  57.             exit(1);
  58.         }
  59.  
  60.     GInfo->nextLine = 0;
  61.     GInfo->lastColor = 0;
  62.     GInfo->leftmost = 0;
  63.     GInfo->topmost = 0;
  64.     GInfo->rightmost = WIDTH -1;
  65.     GInfo->bottommost = HEIGHT - 1;
  66.     GInfo->collHandler = boom;
  67.     GInfo->sprRsrvd = -1;
  68.     rp->GelsInfo = GInfo;
  69.     InitGels(head,tail,GInfo);
  70.     
  71.  
  72.     LoadRGB4(vp,bpdata,16);
  73.     SetRast(rp,0);
  74.  
  75.     for(i=0; i<2; i++)
  76.     {    
  77.         InitBitMap(&bitmap[i],DEPTH,WIDTH,HEIGHT);
  78.         for(j=0; j<DEPTH; j++)
  79.         {    
  80.            if ((bitmap[i].Planes[j] = (PLANEPTR)AllocRaster(WIDTH,HEIGHT)) == 0)
  81.            {
  82.               exit(2);
  83.            }
  84.            else
  85.            {
  86.                BltClear(bitmap[i].Planes[j],RASSIZE(WIDTH,HEIGHT),0);
  87.            }
  88.         }
  89.     };
  90.  
  91.     rp->Flags = DBUFFER;
  92.     rp->Mask = -1;        
  93.  
  94.     vp->RasInfo->BitMap = &bitmap[1];
  95.     rp->BitMap = &bitmap[1];
  96.     SetRast(rp,0);
  97.  
  98.     vp->RasInfo->BitMap = &bitmap[0];
  99.     rp->BitMap = &bitmap[0];
  100.     SetRast(rp,0);
  101.  
  102.     animinit(&animKey,vp,rp);
  103.  
  104.     dispIndex = 0;
  105.  
  106. restart:
  107.     while((message = (struct IntuiMessage *)GetMsg(window->UserPort)) == NULL)
  108.         {
  109.         Animate(&animKey, rp);
  110.         SortGList(rp);
  111.         WaitTOF();
  112.         DrawGList(rp,vp); 
  113.         vp->RasInfo->BitMap = &bitmap[dispIndex]; 
  114.         WaitTOF();
  115.            MakeScreen(screen);    
  116.         WaitBlit();
  117.         RethinkDisplay();
  118.         dispIndex ^= 1;
  119.         rp->BitMap = &bitmap[dispIndex];
  120.  
  121.         }
  122.     switch(message->Class)
  123.         {
  124.         case CLOSEWINDOW:ReplyMsg(message);
  125.                       free_anim_obj(rp);        
  126.                       for (i = 0; i < 2; i++){
  127.                           for (j = 0; j < DEPTH; j++)
  128.                             {
  129.                             FreeMem(bitmap[i].Planes[j],RASSIZE(WIDTH,HEIGHT)); 
  130.                             };
  131.                         };    
  132.                         FreeMem(boom,sizeof(struct collTable));
  133.                         FreeMem(head,sizeof(struct VSprite));
  134.                         FreeMem(tail,sizeof(struct VSprite));
  135.                         FreeMem(GInfo,sizeof(struct GelsInfo));
  136.                         vp->RasInfo->BitMap = OldI_BitMap;
  137.                         rp->BitMap = OldI_BitMap; 
  138.                         return;
  139.        } 
  140.    ReplyMsg(message);
  141.    goto restart;
  142.               
  143.  
  144. }
  145.  
  146. main()
  147. {
  148.   startgfx(400,80,50,100,2,0,show,"CATHY'S FISH",SMART_REFRESH);
  149.  
  150. }
  151.  
  152. delay()
  153. {
  154.     int i;
  155.     int x;
  156.     for(i = 0; i<10000; i++)
  157.     {
  158.         x += i;
  159.     }
  160. }
  161.     
  162.  
  163.