home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 026.lha / tilt.c < prev    next >
C/C++ Source or Header  |  1987-04-02  |  2KB  |  130 lines

  1. /* :ts=8 bk=0
  2.  * tilt.c:    Something to make people giggle.
  3.  *
  4.  * by Leo L. Schwab            8702.23
  5.  *
  6.  * -=RJ Mical=- suggested that I should put my phone number in my PD stuff.
  7.  *    (415) 456-6565
  8.  */
  9.  
  10. #include <exec/types.h>
  11. #include <intuition/intuition.h>
  12.  
  13. #define    DEPTH        2
  14.  
  15.  
  16. extern void    *OpenLibrary(), *OpenWindow(), *OpenScreen();
  17.  
  18.  
  19. struct NewScreen scrdef = {
  20.     0, 0, 0, 0, DEPTH,    /*  Size filled in later  */
  21.     0, 1,
  22.     NULL,            /*  Modes filled in later  */
  23.     CUSTOMSCREEN,
  24.     NULL,
  25.     (UBYTE *) "Dink!",    /*  Title filled in later  */
  26.     NULL, NULL
  27. };
  28.  
  29. struct NewWindow windef = {
  30.     0, 30, 100, 10,
  31.     -1, -1,
  32.     NULL,
  33.     WINDOWDRAG | WINDOWDEPTH | SMART_REFRESH | ACTIVATE,
  34.     NULL, NULL,
  35.     (UBYTE *) "Tilt",
  36.     NULL, NULL,
  37.     0, 0, 0, 0,
  38.     WBENCHSCREEN
  39. };
  40.  
  41. char *msg = "\001\034\022T I L T !\0";
  42.  
  43. struct Screen    *scr;
  44. struct Window    *win;
  45. void        *IntuitionBase, *GfxBase;
  46.  
  47.  
  48. main ()
  49. {
  50.     struct Screen    *wb;
  51.     struct RastPort *rp;
  52.     struct BitMap    *wbm, *mbm;
  53.     long x, y, n;
  54.     register int i;
  55.  
  56.     openstuff ();
  57.  
  58.     wb = win -> WScreen;        /*  Workbench Screen  */
  59.     scrdef.LeftEdge    = wb -> LeftEdge;
  60.     scrdef.TopEdge    = wb -> TopEdge;
  61.     scrdef.Width    = wb -> Width;
  62.     scrdef.Height    = wb -> Height;
  63.     scrdef.ViewModes = wb -> ViewPort.Modes;
  64.     if (!(scr = OpenScreen (&scrdef)))
  65.         die ("Screen open failed.");
  66.     ScreenToBack (scr);
  67.  
  68.     rp = &scr -> RastPort;
  69.     mbm = rp -> BitMap;
  70.     wbm = win -> WScreen -> RastPort.BitMap;
  71.     BltBitMap (wbm, 0L, 0L, mbm, 0L, 0L,
  72.            (long) scrdef.Width, (long) scrdef.Height,
  73.            0xc0L, 0xffL, NULL);
  74.  
  75.     y = scrdef.Height-1;
  76.     for (i=0; i<40; i++) {
  77.         x = i << 4;
  78.         ScrollRaster (rp, 0L, i-20L, x, 0L, x+15L, y);
  79.     }
  80.  
  81.     x = scrdef.Width-1;
  82.     n = scrdef.Height/50;
  83.     for (i=0; i<50; i++) {
  84.         y = i * n;
  85.         ScrollRaster (rp, 25L-i, 0L, 0L, y, x, y+n-1);
  86.     }
  87.     ScreenToFront (scr);
  88.  
  89.     Delay (50L);
  90.     DisplayAlert (RECOVERY_ALERT, msg, 30L);
  91.     closestuff ();
  92. }
  93.  
  94.  
  95. openstuff ()
  96. {
  97.     if (!(IntuitionBase = OpenLibrary ("intuition.library", 0L))) {
  98.         puts ("Intuition missing.");
  99.         exit (100);
  100.     }
  101.  
  102.     if (!(GfxBase = OpenLibrary ("graphics.library", 0L))) {
  103.         puts ("Art shop closed.");
  104.         closestuff ();
  105.         exit (100);
  106.     }
  107.  
  108.     if (!(win = OpenWindow (&windef))) {
  109.         puts ("Window painted shut.");
  110.         closestuff ();
  111.         exit (100);
  112.     }
  113. }
  114.  
  115. die (str)
  116. char *str;
  117. {
  118.     puts (str);
  119.     closestuff ();
  120.     exit (100);
  121. }
  122.  
  123. closestuff ()
  124. {
  125.     if (scr)        CloseScreen (scr);
  126.     if (win)        CloseWindow (win);
  127.     if (GfxBase)        CloseLibrary (GfxBase);
  128.     if (IntuitionBase)    CloseLibrary (IntuitionBase);
  129. }
  130.