#include <exec/types.h>
#include <intuition/intuition.h>
#include <graphics/sprite.h>

struct Screen *Scrn;
struct Window *wind;
struct SimpleSprite imp;

UWORD imp_data[]= {
   0,0,
   0x0fc3,0x0000,
   0x3ff3,0x0000,
   0x30c3,0x0000,
   0x0000,0x3c03,
   0x0000,0x3fc3,
   0x0000,0x03c3,
   0xc033,0xc033,
   0xffc0,0xffc0,
   0x3f03,0x3f03,
   0,0 };

main()
{
 SHORT x,y,w,h,d,s_id,k,xmove,ymove,n,i;
 USHORT mode;
 ULONG flags;
 UBYTE *name,c0,c1;
 VOID delay_func(),OpenAll();

  OpenAll();

/*  ============= Open a hi-res custom screen ============== */

 y=0;
 w=640;
 h=200;
 d=3;
 c0=0x00;
 c1=0x01;
 mode=HIRES;

 Scrn=(struct Screen *)
         make_screen(y,w,h,d,c0,c1,mode,NULL);

 ShowTitle(Scrn,FALSE);

/* =============== Open a backdrop window =========== */

 name=NULL;
 x=0;
 y=0;
 w=640;
 h=200;
 flags=ACTIVATE|SMART_REFRESH|BORDERLESS|BACKDROP;
 c0=-1;
 c1=-1;

 wind=(struct Window *)
        make_window(x,y,w,h,name,flags,c0,c1,Scrn,NULL);

/* Create & Play with a simple hardware sprite */

if((s_id=GetSprite(&imp,-1))==-1)

exit();

imp.x=0;
imp.y=0;
imp.height=9;

switch(s_id)     {
  case 0:
  case 1: k=16;
          break;
  case 2:
  case 3: k=20;
          break;
  case 4:
  case 5: k=24;
          break;
  case 6:
  case 7: k=28;
          break;

}


SetRGB4(&Scrn->ViewPort,k+1,12,3,8);
SetRGB4(&Scrn->ViewPort,k+2,13,13,13);
SetRGB4(&Scrn->ViewPort,k+3,4,4,15);

ChangeSprite(&Scrn->ViewPort,&imp,&imp_data);

MoveSprite(0,&imp,30,0);

xmove=1;
ymove=1;

for(n=0;n<4;n++)  {
   i=0;
   while(i++< 185)  {
     MoveSprite(0,&imp,imp.x+xmove,imp.y+ymove);
     WaitTOF();
    }
   ymove=-ymove;
   xmove=-xmove;
  }

FreeSprite(s_id);

/* ===== Close down the window! then the screen! ===== */

CloseScreen(Scrn);

}

VOID delay_func(factor)

int factor;
/* This function will cause a specified delay */
{
 int loop;

 for(loop=0;loop<factor*1000;loop++)
   ;

 return;
}




