home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 7 / Amiga Format AFCD07 (Dec 1996, Issue 91).iso / serious / shareware / programming / gamesmaster / source / c / fadingdemo.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-09-11  |  3.2 KB  |  110 lines

  1. /*
  2. ** Fade Demo
  3. ** ---------
  4. ** There are three examples of fading in this program:  Fade_To_White,
  5. ** Fade_To_Palette, and Fade_To_Black.
  6. **
  7. ** Fade_To_Palette 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. ** Compiles under SAS/C
  11. */
  12.  
  13. #include <stdio.h>
  14. #include <stdlib.h>
  15.  
  16. #include <exec/memory.h>
  17. #include <games/games.h>
  18. #include <proto/games.h>
  19. #include <proto/exec.h>
  20.  
  21. struct GMSBase *GMSBase;
  22.  
  23. #define AMT_PLANES 5
  24.  
  25. UWORD  Palette[] = {
  26.        0x0000,0x0130,0x0FCB,0x0FA9,0x0D88,0x0965,0x0644,0x0211,
  27.        0x0400,0x0444,0x0FF0,0x0432,0x0CC0,0x0150,0x0501,0x0880,
  28.        0x0261,0x0271,0x0382,0x0492,0x05A3,0x05B4,0x0677,0x06C4,
  29.        0x0788,0x09AA,0x0BCC,0x0801,0x0901,0x0A02,0x0701,0x0601
  30.        };
  31.  
  32. struct GameScreen GameScreen = {
  33.        GSV1,                /* Structure version */
  34.        0,0,0,               /* Screen_Mem1,2,3 */
  35.        0,                   /* ScreenLink */
  36.        0,                   /* Adress of palette */
  37.        0,                   /* Address of rasterlist */
  38.        0,                   /* Amount of colours */
  39.        320,256,320,256,     /* Screen & Pic Height/Width */
  40.        AMT_PLANES,          /* Amount of bitplanes */
  41.        0,0,                 /* Top Of Screen Offset, X/Y */
  42.        0,0,                 /* X/Y counters (for scrolling) */
  43.        0,                   /* Special attributes */
  44.        LORES,               /* Screen mode */
  45.        INTERLEAVED,         /* Screen type */
  46.        0                    /* Reserved */
  47.        };
  48.  
  49. struct Picture Picture = {
  50.        PCV1,                /* Version header */
  51.        0,                   /* Destination */
  52.        320,256,             /* Width, Height */
  53.        AMT_PLANES,          /* Amount of Planes */
  54.        32,                  /* Amount of colours */
  55.        &Palette,            /* Palette (remap) */
  56.        LORES,               /* Screen mode */
  57.        INTERLEAVED,         /* Destination */
  58.        0                    /* Parameters */
  59.        };
  60.  
  61. struct GameScreen *OurScreen = &GameScreen;
  62. struct Picture *LoadingPic = &Picture;
  63.  
  64. /*=========================================================================*/
  65.  
  66. void main(void)
  67. {
  68.    UWORD FadeState = 0;
  69.  
  70.    struct GamesLibrary *GMSBase = (struct GamesLibrary *)
  71.       OpenLibrary("games.library", 0);
  72.  
  73.    SetUserPri();
  74.  
  75.    if (Add_Screen(OurScreen) == NULL) {
  76.  
  77.       LoadingPic->Data = OurScreen->MemPtr1;
  78.       if (LoadPic("GAMESLIB:data/IFF.Pic320",LoadingPic) == NULL) {
  79.          Show_Screen(OurScreen);
  80.          Wait_Time(10);
  81.  
  82.          do { Wait_VBL();
  83.               Wait_OSVBL();            
  84.               FadeState = B12_FadeToPalette(OurScreen,FadeState,&Palette,00,32);
  85.             }
  86.          while (FadeState != NULL);
  87.  
  88.          Wait_LMB();
  89.  
  90.          do { Wait_OSVBL();
  91.               Wait_VBL();
  92.               FadeState = B12_FadeToWhite(OurScreen,FadeState,00,32);
  93.             }
  94.          while (FadeState != NULL);
  95.  
  96.          Wait_Time(30);
  97.  
  98.          do { Wait_OSVBL();
  99.           FadeState = B12_FadeToBlack(OurScreen,FadeState);
  100.         }
  101.      while (FadeState != NULL);
  102.  
  103.          Wait_Time(30);
  104.       }
  105.       Delete_Screen(OurScreen);
  106.    }
  107.    CloseLibrary((struct Library *)GMSBase);
  108. }
  109.  
  110.