home *** CD-ROM | disk | FTP | other *** search
- /*
- ** Sprite example
- ** --------------
- ** This example shows you how to set up a 16 colour OCS sprite with a
- ** doubled X axis (32 pixels width). Those with hardware experience will
- ** know that it takes 4 sprite banks to do this successfully in OCS, which
- ** leaves you with another 4 banks to do with what you will. You can do
- ** this same demo in AGA with just 2 banks used.
- **
- ** The sprite is attached to the mouse, so try moving it around a bit.
- */
-
- #include <exec/memory.h>
- #include <proto/games.h>
- #include <proto/exec.h>
-
- struct GMSBase *GMSBase;
- extern struct ExecBase *SysBase;
-
- UWORD Timer;
- APTR SprMemBase;
- ULONG ZBXY;
-
- struct Sprite Sprite0 = {
- SPV1, /* Version number */
- 0, /* Bank Number 0 */
- 0, /* Ptr to graphic */
- 100,100, /* Beginning X/Y positions */
- 0, /* Current frame */
- 16,21, /* Width, Height */
- 16, /* Amt of colours */
- 16, /* Colour start in palette */
- 2, /* Amt of planes */
- LORES, /* Resolution */
- 0, /* Position in relation to playfields */
- XLONG /* Special attributes */
- };
-
- UWORD Palette[] = {
- 0x000,0x000,0x000,0x000,0x000,0x000,0x000,0x000,
- 0x000,0x688,0x466,0x344,0xCC0,0x980,0x870,0x650,
- 0x1C2,0x050,0xB0B,0x606,0xF20,0x910,0xBBB,0xFFF,
- 0x0BF,0x068,0x568,0x9BF,0xFF0,0xEE0,0xBA0,0x540
- };
-
- struct GameScreen GameScreen = {
- GSV1, /* GameScreen Version */
- 0,0,0, /* Screen Memory 1,2,3 */
- 0, /* ScreenLink */
- &Palette, /* Address of Palette */
- 0, /* Address of RasterList */
- 32, /* Amount of colours */
- 320,256, /* Screen Width and Height */
- 320,320/8,256, /* Picture Width/8 and Height */
- 1, /* Amount of planes */
- 0,0, /* X/Y screen offset */
- 0,0, /* X/Y picture offset */
- SPRITES|NOSCRBDR, /* Special attributes */
- LORES|COL12BIT, /* Screen mode */
- INTERLEAVED /* Screen type */
- };
-
- struct GameScreen *OurScreen = &GameScreen;
- struct Sprite *Sparkie = &Sprite0;
-
- /*=========================================================================*/
-
- void main(void)
- {
- if (GMSBase = (struct GMSBase *) OpenLibrary("games.library",0)) {
- SetUserPrefs(0);
- Sparkie->Data = SmartLoad("GAMESLIB:data/Sparkie.raw",0,MEMF_CHIP);
-
- if (AddScreen(OurScreen) == NULL) {
- if (InitSprite(OurScreen,Sparkie) == ERR_OK) {
- UpdateSprite(OurScreen,Sparkie);
- ShowScreen(OurScreen);
-
- ZBXY = ReadMouse(JPORT1); /* Initialise the mouse port */
-
- while (!(ZBXY&MB_LMB)) {
-
- if (++Timer&0x1) {
- if (Sparkie->Frame == 5) Sparkie->Frame = 0;
- else Sparkie->Frame++;
- }
-
- ZBXY = ReadMouse(JPORT1);
- Sparkie->XPos += GetX(ZBXY);
- Sparkie->YPos += GetY(ZBXY);
- WaitSVBL();
- UpdateSprite(OurScreen, Sparkie);
- }
- FreeSprite(Sparkie);
- }
- DeleteScreen(OurScreen);
- }
- FreeMemBlock(Sparkie->Data);
- CloseLibrary((struct Library *)GMSBase);
- }
- }
-
-