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 / doublebuffer.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-09-11  |  2.7 KB  |  90 lines

  1. /*
  2. ** Double Buffer Demo
  3. ** ------------------
  4. ** This just shows how to double buffer the screen.
  5. **
  6. ** Compiles under SAS/C.
  7. */
  8.  
  9. #include <stdio.h>
  10. #include <stdlib.h>
  11.  
  12. #include <exec/types.h>
  13. #include <exec/memory.h>
  14. #include <games/games.h>
  15. #include <proto/games.h>
  16. #include <proto/exec.h>
  17.  
  18. #define AMT_PLANES 5
  19.  
  20. struct GMSBase *GMSBase;
  21.  
  22. UWORD  Palette[] = {
  23.        0x0000,0x0130,0x0FCB,0x0FA9,0x0D88,0x0965,0x0644,0x0211,
  24.        0x0400,0x0444,0x0FF0,0x0432,0x0CC0,0x0150,0x0501,0x0880,
  25.        0x0261,0x0271,0x0382,0x0492,0x05A3,0x05B4,0x0677,0x06C4,
  26.        0x0788,0x09AA,0x0BCC,0x0801,0x0901,0x0A02,0x0701,0x0601
  27.        };
  28.  
  29. struct GameScreen GameScreen = {
  30.        GSV1,                      /* Structure version */
  31.        0,0,0,                     /* Screen Mem - 1,2,3 */
  32.        0,                         /* ScreenLink */
  33.        &Palette,                  /* Address of palette */
  34.        0,                         /* Address of rasterlist */
  35.        32,                        /* Amt of colours in palette */
  36.        320,256,320,256,           /* Screen & Pic Height/Width */
  37.        AMT_PLANES,                /* Amt_Planes */
  38.        0,0,                       /* Top Of Screen, X/Y */
  39.        0,0,                       /* X/Y counters (for scrolling) */
  40.        DBLBUFFER,                 /* Special attributes */
  41.        LORES,                     /* Screen mode */
  42.        INTERLEAVED,               /* Screen type */
  43.        0                          /* Reserved */
  44.        };
  45.  
  46. struct Picture Picture = {
  47.        PCV1,                /* Version header */
  48.        0,                   /* Destination */
  49.        320,256,             /* Width, Height */
  50.        AMT_PLANES,          /* Amount of Planes */
  51.        32,                  /* Amount of colours */
  52.        &Palette,            /* Palette (remap) */
  53.        LORES|COL24BIT,      /* Screen mode */
  54.        INTERLEAVED,         /* Destination */
  55.        0                    /* Parameters */
  56.        };
  57.  
  58. struct GameScreen *OurScreen = &GameScreen;
  59. struct Picture *LoadingPic = &Picture;
  60.  
  61. /*=========================================================================*/
  62.  
  63. void main(void)
  64. {
  65.    struct GamesLibrary *GMSBase = (struct GamesLibrary *)
  66.        OpenLibrary("games.library", 0);
  67.    if (GMSBase == NULL) exit(FALSE);
  68.  
  69.    SetUserPri();
  70.  
  71.    if (Add_Screen(OurScreen) == NULL) {
  72.  
  73.       LoadingPic->Data = OurScreen->MemPtr1;
  74.       if (LoadPic("GAMESLIB:data/IFF.Pic320",LoadingPic) == NULL) {
  75.  
  76.         Show_Screen(OurScreen);
  77.  
  78.         while (!(Read_Mouse(JPORT1)&MB_LMB)) {
  79.           Wait_OSVBL();
  80.           SwapBuffers(OurScreen);
  81.         }
  82.       }
  83.       Delete_Screen(OurScreen);
  84.    }
  85.    CloseLibrary((struct Library *)GMSBase);
  86. }
  87.  
  88. /*=========================================================================*/
  89.  
  90.