home *** CD-ROM | disk | FTP | other *** search
- /*
- ** Double Buffer Demo
- ** ------------------
- ** This just shows how to double buffer the screen.
- **
- ** Compiles under SAS/C.
- */
-
- #include <stdio.h>
- #include <stdlib.h>
-
- #include <exec/types.h>
- #include <exec/memory.h>
- #include <games/games.h>
- #include <games/gamesbase.h>
- #include <proto/games.h>
- #include <proto/exec.h>
-
- #define PicFile "GAMESLIB:data/Pic320.pak"
- #define AMT_PLANES 5
-
- struct GMSBase *GMSBase;
- APTR PicMemBase;
-
- UWORD ScreenPalette[] =
- {
- 0x0000,0x0A77,0x0B88,0x0866,0x0A98,0x0877,0x0B99,0x0CBB,
- 0x0ABB,0x0CCC,0x0333,0x0554,0x0556,0x0665,0x0788,0x0222,
- 0x0466,0x0345,0x0677,0x0888,0x0234,0x0322,0x0844,0x0733,
- 0x0632,0x0955,0x09AA,0x0022,0x0832,0x0943,0x0DCC,0x0DDD
- };
-
- struct GameScreen TheScreen =
- {
- "GSV1", /* Structure version */
- 0,0,0, /* Screen Mem - 1,2,3 */
- 0, /* ScreenLink */
- &ScreenPalette, /* Address of the screen palette */
- 0, /* Address of a colourlist */
- 32, /* Amt of colours in palette */
- 256,320,320/8, /* Screen Height, Width, Width/8 */
- 256,320,320/8, /* Pic Height, Width, Width/8 */
- AMT_PLANES, /* Amt_Planes */
- 0,0, /* Top Of Screen, X/Y */
- 0, /* Scroll buffer in pixels/8 */
- 0,0, /* X/Y counters (for scrolling) */
- DBLBUFFER|NOBURST, /* Special attributes */
- LORES, /* Screen mode */
- INTERLEAVED, /* Screen type */
- 0, /* Screen Is Being Displayed? */
- 0,0 /* Reserved area */
- };
-
- /*=========================================================================*/
-
- void main(void)
- {
- struct GamesLibrary *GMSBase = (struct GamesLibrary *)
- OpenLibrary("games.library", 0);
- if (GMSBase == NULL) exit(FALSE);
-
- SetUserPri();
-
- if (Add_Screen(&TheScreen) == NULL)
- {
- PicMemBase = QuickLoad (PicFile,0,MEMF_ANY);
-
- if (PicMemBase != NULL)
- {
- SmartUnpack(PicMemBase, (&TheScreen)->SS_MemPtr1, 0);
- FreeMemBlock(PicMemBase);
-
- Show_Screen(&TheScreen);
-
- do
- {
- Wait_OSVBL();
- SwapBuffers(&TheScreen);
- }
- while (!(Read_JoyStick(JPORT1) & JS_FIRE1));
- };
-
- Delete_Screen(&TheScreen);
- };
- CloseLibrary((struct Library *)GMSBase);
- }
-
- /*=========================================================================*/
-
-