home *** CD-ROM | disk | FTP | other *** search
/ Frozen Fish 2: PC / frozenfish_august_1995.bin / bbs / d03xx / d0358.lha / Blob / Blob.c < prev    next >
C/C++ Source or Header  |  1990-06-12  |  7KB  |  293 lines

  1. /* The Blob V1.1 by Guido Wegener of CLUSTER */
  2. /* this program is Freeware, look at Blob.doc to get more information */
  3. /* or look at any mirror to get a good laugh */
  4. #include "math.h"
  5. #include "exec/types.h"
  6. #include "functions.h"
  7. #include "intuition/intuition.h"
  8. #include "graphics/gfxbase.h"
  9. #include "graphics/gfx.h"
  10. #include "graphics/sprite.h"
  11. #include "hardware/custom.h"
  12. #include "hardware/dmabits.h"
  13. #include "stdio.h"
  14. #include "exec/memory.h"
  15. #define ABS(a) ((a<0) ? -a : a)
  16. #define DROPMAXANZ 50     /* I don't think that I'm going to tell you what this means, go away !
  17.                              By the way, WHO reads source-files ??? No REMs this time, sorry. */
  18.  
  19. struct IntuitionBase *IntuitionBase;
  20. struct GfxBase *GfxBase;
  21. struct Screen wbs;
  22. struct ViewPort *vpo;
  23. struct NewWindow MyNewWindow=
  24.  {
  25.   0,0,404,10,
  26.   -1,-1,
  27.   CLOSEWINDOW,
  28.   WINDOWCLOSE | WINDOWDRAG | WINDOWDEPTH | SMART_REFRESH | NOCAREREFRESH,
  29.   NULL,NULL,
  30.   (UBYTE *)"The BLOB by Guido Wegener of CLUSTER",
  31.   NULL,NULL,
  32.   0,0,0,0,
  33.   WBENCHSCREEN
  34.  };
  35. #define TANZ 56
  36. char *texts[]=
  37.  { 
  38.   "The late night movie starts ...",
  39.   "Is it BLOOD ???",
  40.   "No, it's the slime of BLOB...",
  41.   "Blob, the alien Amiga-eating monster !",
  42.   "Welcome",
  43.   "I don't think.",
  44.   "Do not be alarmed.",
  45.   "Be very, very frightened, user.",
  46.   "Since I've got no license for using",
  47.   "the name Blob, I will have to mention",
  48.   "the movie (I know of two Blob-movies).",
  49.   "Both are a little bit slimy !",
  50.   "You can run more than one Blob at a time",
  51.   "by typing 'run Blob' more than once.",
  52.   "Don't forget pressing return, lamer.",
  53.   "Well, let's mention me !",
  54.   "I'm Guido Wegener of CLUSTER !",
  55.   "In other words ...",
  56.   "the mega-man of the 10^6-group !",
  57.   "Will I ever stop typing ???",
  58.   "     NO !     ",
  59.   "Greetings and thanx to :",
  60.   "AndrΘ, Martin, Philipp, Martin,",
  61.   "Stefan, Martin, Addison Wesley",
  62.   "(you know, the reference manuals),",
  63.   "Scientific American and ...",
  64.   "my beloved Amiga 500 with 1MByte and",
  65.   "2nd drive and Kick 1.2 !",
  66.   "Ok, AndrΘ ! Daddy's beloved Amiga.",
  67.   "Look out for other CLUSTER proggies !",
  68.   "This one was written on Feb.,2,1990.",
  69.   "Maybe I will produce other movies later.",
  70.   "What about Rocky Horror Picture Show",
  71.   "(Kiss me Amiga) or Little Shop of",
  72.   "Horrors (the all-eating mouse-pointer).",
  73.   "You can exit this proggy by kilcking..",
  74.   "<=- here !",
  75.   "Nice of you not doing it !",
  76.   "This is line 39 (just for counting 'em)",
  77.   "Hey guy, there's slime on ya screen !",
  78.   "This program is freeware !",
  79.   "For copy-conditions read Blob.Doc !",
  80.   "Just for information :",
  81.   "The cheaper one of the two Blob movies",
  82.   "is the better one !",
  83.   "Let's panic !",
  84.   "Love is hate !",
  85.   "Freedom is slavery !",
  86.   "Ignorance is strength !",
  87.   "I think I'll stop here ...",
  88.   "but I don't !",
  89.   "OK, I will !",
  90.   "Soon ...",
  91.   "This is the end ...",
  92.   "Over and out ...",
  93.   "RESTART"
  94.  };
  95.   
  96. struct Window *MyWindow;
  97. UWORD *sprite_data;
  98. UBYTE drop[10][25]=  /* the shape of the drops ... */
  99.  {
  100.   1,1,1,2,2,2,3,3,3,4,4,4,5,5,6,6,7,7,6,6,5,4,3,2,1,
  101.   1,1,2,2,3,4,5,5,4,3,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  102.   1,1,1,1,2,2,2,3,3,4,4,3,2,0,0,0,0,0,0,0,0,0,0,0,0,
  103.   1,1,2,3,3,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  104.   1,1,1,1,1,2,2,2,2,3,3,3,4,4,4,5,5,3,2,0,0,0,0,0,0,
  105.   1,1,1,2,2,3,4,5,5,4,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  106.   1,1,1,2,2,2,3,3,3,4,4,5,5,4,2,0,0,0,0,0,0,0,0,0,0,
  107.   1,1,1,1,2,2,3,4,4,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  108.   1,1,1,1,1,2,2,2,3,3,3,4,4,5,5,6,6,4,2,0,0,0,0,0,0,
  109.   1,1,1,2,2,3,3,4,4,5,6,7,7,6,4,2,0,0,0,0,0,0,0,0,0
  110.  };
  111. float dropy[DROPMAXANZ],drops[DROPMAXANZ],dropp[DROPMAXANZ];
  112. int x[350];
  113. long int warsch=100;
  114.  
  115. main()
  116.  {
  117.   BOOL succ;
  118.   long int spriten;
  119.   struct SimpleSprite sprite;
  120.   long int colr,count=0;
  121.   int i,closed=0,ctext=0;
  122.   int rndrnd;
  123.   VOID *mess; 
  124.  
  125.   IntuitionBase=(struct IntuitionBase *)OpenLibrary("intuition.library",0L);
  126.   if(!IntuitionBase)
  127.    {
  128.     puts("Intu");
  129.     exit(20);
  130.    }
  131.   GfxBase=(struct GfxBase *)OpenLibrary("graphics.library",0L);
  132.   if(!GfxBase)
  133.    {
  134.     puts("Gfx");
  135.     CloseLibrary(IntuitionBase);
  136.     exit(20);
  137.    }
  138.  
  139.   sprite_data=AllocMem(32*255L,MEMF_CHIP | MEMF_CLEAR);
  140.   if(!sprite_data)
  141.    {
  142.     puts("No Mem !");
  143.     CloseLibrary(GfxBase);
  144.     CloseLibrary(IntuitionBase);
  145.     exit(20);
  146.    }
  147.     
  148.   rndrnd=VBeamPos();
  149.   for(i=0;i<rndrnd;i++)RangeRand(5L);
  150.   succ=GetScreenData((CPTR)&wbs,(long int)sizeof(struct Screen),WBENCHSCREEN,NULL);  
  151.   if(!succ)
  152.    {
  153.     puts("Not found !");
  154.     FreeMem(sprite_data,32*255L);
  155.     CloseLibrary(GfxBase);
  156.     CloseLibrary(IntuitionBase);
  157.     exit(20);
  158.    }
  159.   vpo=&(wbs.ViewPort);
  160.   for(i=0;i<DROPMAXANZ;i++)
  161.    {
  162.     dropy[i]=0;
  163.     drops[i]=0;
  164.     dropp[i]=0;
  165.    }
  166.   newdrop();   
  167.   
  168.   spriten=GetSprite(&sprite,-1L);
  169.   if(spriten==-1)
  170.    {
  171.     puts("No free sprite !");
  172.     FreeMem(sprite_data,32*255L);
  173.     CloseLibrary(GfxBase);
  174.     CloseLibrary(IntuitionBase);
  175.     exit(20);
  176.    }
  177.   MyNewWindow.TopEdge=spriten*10;
  178.   MyWindow=OpenWindow(&MyNewWindow);
  179.   if(!MyWindow)
  180.    {
  181.     puts("Can't open Window !");
  182.     FreeSprite(spriten);
  183.     FreeMem(sprite_data,32*255L);
  184.     CloseLibrary(GfxBase);
  185.     CloseLibrary(IntuitionBase);
  186.     exit();
  187.    }
  188.  
  189.   colr=16+((spriten&0x06)<<1);
  190.   SetRGB4(vpo,colr+1,11L,0L,0L);
  191.   SetRGB4(vpo,colr+2,10L,5L,5L);
  192.   SetRGB4(vpo,colr+3,15L,1L,1L);
  193.   sprite.x=10+RangeRand(200L);
  194.   sprite.y=0;
  195.   sprite.height=255;
  196.   ChangeSprite(NULL,&sprite,sprite_data);
  197.   while(!closed)
  198.    {
  199.     mess=GetMsg(MyWindow->UserPort);
  200.     if(mess)
  201.      {
  202.       closed=1;
  203.       ReplyMsg(mess);
  204.      }
  205.     WaitTOF();
  206.     if(!RangeRand(warsch))newdrop();
  207.     movedrops();
  208.     drawdrops();
  209.     ChangeSprite(NULL,&sprite,sprite_data);
  210.     count++;
  211.     if((count%65)==0)
  212.      {
  213.       SetWindowTitles(MyWindow,texts[ctext],-1L);
  214.       ctext=(ctext+1)%TANZ;
  215.      }
  216.     if(!RangeRand(40L)&&warsch>25)
  217.      {
  218.       warsch--;
  219.      }
  220.    }
  221.  
  222.   CloseWindow(MyWindow);
  223.   FreeSprite(spriten);
  224.   FreeMem(sprite_data,32*255L);
  225.   CloseLibrary(GfxBase);
  226.   CloseLibrary(IntuitionBase);
  227.  }
  228.  
  229. newdrop()
  230.  {
  231.   int i;
  232.   
  233.   for(i=0;i<DROPMAXANZ;i++)
  234.    {
  235.     if(drops[i]==0)
  236.       {
  237.        dropy[i]=0;
  238.        dropp[i]=RangeRand(10L);
  239.        drops[i]=(float)RangeRand(17L)/15;
  240.        i=DROPMAXANZ;
  241.       }
  242.     }
  243.  }
  244.  
  245. movedrops()
  246.  {
  247.   register int i;
  248.   
  249.   for(i=0;i<DROPMAXANZ;i++)
  250.    {
  251.     dropy[i]+=drops[i];
  252.     if(dropy[i]>300)drops[i]=0;
  253.    }
  254.  }
  255.  
  256. drawdrops()
  257.  {
  258.   register int i,j;
  259.   register int *po;
  260.   
  261.   po=x;
  262.   for(i=0;i<350;i++)
  263.    {
  264.     *(po++)=0;
  265.    }
  266.   for(i=0;i<DROPMAXANZ;i++)
  267.    {
  268.     if(drops[i])
  269.      {
  270.       for(j=0;j<25;j++)
  271.        {
  272.         x[j+(int)dropy[i]]+=(int)drop[(int)dropp[i]][j];
  273.        }
  274.      }
  275.    }
  276.   
  277.   for(i=0;i<255;i++)
  278.    {
  279.     if(x[i+50]>15)
  280.      {
  281.       sprite_data[i*2+2]=0xffff;
  282.       sprite_data[i*2+3]=0x7ffe;
  283.      }
  284.     else
  285.      {
  286.       sprite_data[i*2+2]= ((1 << x[i+50])-1) << (7-x[i+50]/2); /* <=- It's so simple, it just doesn't need any REMarks, does it ?  */
  287.       if(x[i+50]<2)x[i+50]=2;
  288.       sprite_data[i*2+3]= ((1 << (x[i+50]-2))-1) << (8-x[i+50]/2); /* I told you to go away ! */
  289.      }
  290.    }
  291.  }
  292.  
  293.