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

  1. /*
  2. ** Mirror Demo
  3. ** -----------
  4. ** Demo of the mirroring effect.  When this effect is combined with a
  5. ** decrease in palette values at the same line, you can create the illusion of
  6. ** water.
  7. ** 
  8. ** Use the mouse to move the mirror around. LMB exits.
  9. */
  10.  
  11. #include <proto/exec.h>
  12. #include <proto/games.h>
  13.  
  14. struct GMSBase *GMSBase;
  15. extern struct ExecBase *SysBase;
  16.  
  17. #define AMT_PLANES 5
  18.  
  19. UWORD Palette[] =
  20. {
  21.      0x000,0x130,0xFCB,0xFA9,0xD88,0x965,0x644,0x211,
  22.      0x400,0x444,0xFF0,0x432,0xCC0,0x150,0x501,0x880,
  23.      0x261,0x271,0x382,0x492,0x5A3,0x5B4,0x677,0x6C4,
  24.      0x788,0x9AA,0xBCC,0x801,0x901,0xA02,0x701,0x601
  25. };
  26.  
  27. UWORD WaterPalette[] =
  28. {
  29.      0x000,0x010,0x765,0x754,0x644,0x432,0x322,0x100,
  30.      0x200,0x222,0x770,0x211,0x660,0x020,0x200,0x440,
  31.      0x130,0x130,0x141,0x241,0x251,0x252,0x333,0x362,
  32.      0x344,0x455,0x666,0x400,0x400,0x501,0x300,0x300
  33. };
  34.  
  35. ULONG RasterList[] =
  36. {
  37.      WAITLINE(190),
  38.      MIRROR,
  39.      NEWPALETTE(0,32,WaterPalette),
  40.      RASTEND
  41. };
  42.  
  43. struct GameScreen GameScreen =
  44. {
  45.      GSV1,            /* Structure version */
  46.      0,0,0,           /* Screen Memory 1,2,3 */
  47.      0,               /* Screen Link */
  48.      Palette,         /* Adress of palette */
  49.      RasterList,      /* Address of rasterlist */
  50.      0,               /* Amount of colours */
  51.      320,256,         /* Screeen Width, Height */
  52.      336,0,256,       /* Picture Width, ByteWidth, Height */
  53.      AMT_PLANES,      /* Amount of bitplanes */
  54.      0,0,             /* X/Y screen offset */
  55.      0,0,             /* X/Y picture offset */
  56.      HSCROLL|VSCROLL, /* Special attributes */
  57.      LORES|COL12BIT,  /* Screen mode */
  58.      0,               /* Screen type */
  59. };
  60.  
  61. struct Picture MirrorPic =
  62. {
  63.      PCV1,           /* Version header */
  64.      0,              /* Destination */
  65.      336,0,256,      /* Width, Height */
  66.      AMT_PLANES,     /* Amount of planes */
  67.      32,             /* Amount of colours */
  68.      Palette,        /* Palette */
  69.      LORES|COL12BIT, /* Screen mode */
  70.      0,              /* Screen type */
  71.      0,              /* Parameters */
  72.      "GAMESLIB:data/IFF.Pic336" 
  73. };
  74.  
  75. /*=========================================================================*/
  76.  
  77. void main(void)
  78. {
  79.    ULONG mouse;
  80.  
  81.    if (GMSBase = (struct GMSBase *) OpenLibrary("games.library", 0)) {
  82.       SetUserPrefs(0);
  83.       if (AddScreen(&GameScreen) == NULL)
  84.       {
  85.          MirrorPic.Data = GameScreen.MemPtr1;
  86.          MirrorPic.ScrType = GameScreen.ScrType;
  87.          LoadPic(&MirrorPic);
  88.  
  89.          ShowScreen(&GameScreen);
  90.          InitJoyPorts();
  91.  
  92.          do
  93.          {
  94.             mouse = ReadJoyPort(JPORT1,JT_ZBXY);
  95.             GameScreen.PicXOffset += (BYTE)(mouse >> 8);
  96.             GameScreen.PicYOffset += (BYTE)(mouse);
  97.             if (GameScreen.PicXOffset < 0) GameScreen.PicXOffset = 0;
  98.             if (GameScreen.PicXOffset > 16) GameScreen.PicXOffset = 16;
  99.             if (GameScreen.PicYOffset < 0) GameScreen.PicYOffset = 0;
  100.             if (GameScreen.PicYOffset > 255-190) GameScreen.PicYOffset = 255-190;
  101.             MovePicture(&GameScreen);
  102.             WaitSVBL();
  103.          } while (!(mouse & MB_LMB));
  104.  
  105.       DeleteScreen(&GameScreen);
  106.       }
  107.    CloseLibrary((struct Library *)GMSBase);
  108.    }
  109. }
  110.  
  111. /*=========================================================================*/
  112.