home *** CD-ROM | disk | FTP | other *** search
/ Aminet 18 / aminetcdnumber181997.iso / Aminet / dev / misc / gms_dev.lha / GMS / Source / C / FadingDemo.c < prev    next >
Encoding:
C/C++ Source or Header  |  1997-02-16  |  3.1 KB  |  105 lines

  1. /*
  2. ** Fade Demo (OCS/ECS)
  3. ** -------------------
  4. ** There are three examples of fading in this program:  Palette to Colour,
  5. ** Colour to Palette, Colour Morph.
  6. **
  7. ** ColourToPalette() is called as soon as you run the executable, then you
  8. ** have to press the Left Mouse Button to see the rest of the fade sequence.
  9. **
  10. */
  11.  
  12. #include <proto/games.h>
  13. #include <proto/exec.h>
  14.  
  15. struct GMSBase *GMSBase;
  16. extern struct ExecBase *SysBase;
  17.  
  18. #define AMT_PLANES 5
  19.  
  20. UWORD  Palette[] = {
  21.        0x0000,0x0130,0x0FCB,0x0FA9,0x0D88,0x0965,0x0644,0x0211,
  22.        0x0400,0x0444,0x0FF0,0x0432,0x0CC0,0x0150,0x0501,0x0880,
  23.        0x0261,0x0271,0x0382,0x0492,0x05A3,0x05B4,0x0677,0x06C4,
  24.        0x0788,0x09AA,0x0BCC,0x0801,0x0901,0x0A02,0x0701,0x0601
  25.        };
  26.  
  27. struct GameScreen GameScreen = {
  28.        GSV1,                /* Structure version */
  29.        0,0,0,               /* Screen_Mem1,2,3 */
  30.        0,                   /* ScreenLink */
  31.        0,                   /* Adress of palette */
  32.        0,                   /* Address of rasterlist */
  33.        0,                   /* Amount of colours */
  34.        320,256,             /* Screen Width and Height */
  35.        0,0,0,               /* Picture Width/8 and Height */
  36.        AMT_PLANES,          /* Amount of bitplanes */
  37.        0,0,                 /* X/Y screen offset */
  38.        0,0,                 /* X/Y picture offset */
  39.        0,                   /* Special attributes */
  40.        LORES|COL12BIT,      /* Screen mode */
  41.        ILBM,                /* Screen type */
  42.        };
  43.  
  44. struct Picture Picture = {
  45.        PCV1,                /* Version header */
  46.        0,                   /* Destination */
  47.        320,0,256,           /* Width, Height */
  48.        AMT_PLANES,          /* Amount of Planes */
  49.        32,                  /* Amount of colours */
  50.        &Palette,            /* Palette */
  51.        LORES|COL12BIT,      /* Screen mode */
  52.        INTERLEAVED,         /* Destination */
  53.        0,                   /* Parameters */
  54.        "GAMESLIB:data/IFF.Pic320"
  55.        };
  56.  
  57. struct GameScreen *OurScreen = &GameScreen;
  58. struct Picture *LoadingPic = &Picture;
  59.  
  60. /*=========================================================================*/
  61.  
  62. void main(void)
  63. {
  64.    UWORD FState = 0;
  65.  
  66.    GMSBase = (struct GMSBase *) OpenLibrary("games.library", 0);
  67.  
  68.    SetUserPrefs(0);
  69.  
  70.    if (AddScreen(OurScreen) == NULL) {
  71.  
  72.       LoadingPic->Data = OurScreen->MemPtr1;
  73.       if (LoadPic(LoadingPic) == NULL) {
  74.          ShowScreen(OurScreen);
  75.  
  76.          do { WaitVBL();
  77.               WaitSVBL();            
  78.               FState = ColourToPalette(OurScreen,FState,1,0,32,&Palette,0x000);
  79.             }
  80.          while (FState != NULL);
  81.  
  82.          WaitLMB();
  83.  
  84.          do { WaitSVBL();
  85.               WaitVBL();
  86.               FState = PaletteToColour(OurScreen,FState,1,0,32,&Palette,0xFFF);
  87.             }
  88.          while (FState != NULL);
  89.  
  90.          WaitTime(30);
  91.  
  92.          do { WaitSVBL();
  93.               WaitVBL();
  94.               FState = ColourMorph(OurScreen,FState,1,0,32,0xFFF,0x000);
  95.             }
  96.          while (FState != NULL);
  97.  
  98.          WaitTime(30);
  99.       }
  100.       DeleteScreen(OurScreen);
  101.    }
  102.    CloseLibrary((struct Library *)GMSBase);
  103. }
  104.  
  105.