#include <exec/types.h>
#include <intuition/intuition.h>
#include <graphics/rastport.h>
#include <graphics/sprite.h>
#include <graphics/gfxmacros.h>
#include <graphics/gels.h>
#include <graphics/view.h>
#include <exec/memory.h>

#define Y_BT_BORDER 183    /* set some constants to control the Vsprite */
#define Y_TP_BORDER 1      /* movement--quite arbitrary */
#define X_RT_BORDER 285
#define X_LF_BORDER 1

struct Screen *Scrn;
struct Window *wind;
struct VSprite vimp,vhead,vtail;
struct Bob bimp;
struct GelsInfo ginfo;

UWORD b_data[]= {           /* the image that defines the Vsprite */

     0x0000,0x0000,
     0x0000,0x0000,
     0x0000,0x0000,
     0x0000,0x0000,
     0x0000,0x0000,
     0x0000,0x0000,

     0xffff,0xffff,
     0xffff,0xffff,
     0xffff,0xffff,
     0xffff,0xffff,
     0xffff,0xffff,
     0xffff,0xffff,

     0xffff,0xffff,
     0xffff,0xffff,
     0xffff,0xffff,
     0xffff,0xffff,
     0xffff,0xffff,
     0xffff,0xffff,

     0xffff,0xffff,
     0xffff,0xffff,
     0xffff,0xffff,
     0xffff,0xffff,
     0xffff,0xffff,
     0xffff,0xffff,

     0x0000,0x0000,
     0x0000,0x0000,
     0x0000,0x0000,
     0x0000,0x0000,
     0x0000,0x0000,
     0x0000,0x0000,

     0xffff,0xffff,
     0xffff,0xffff,
     0xffff,0xffff,
     0xffff,0xffff,
     0xffff,0xffff,
     0xffff,0xffff};

main()
{
 SHORT x,y,w,h,d,i;
 USHORT mode;
 ULONG flags;
 UBYTE *name,c0,c1;
 VOID delay_func(),OpenAll();
 int xin=1,yin=1;

 OpenAll();
                         /* set up a Custom Screen */
 y=0;
 w=320;
 h=200;
 d=5;
 c0=0x00;
 c1=0x01;
 mode=NULL;

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

 ShowTitle(Scrn,FALSE);

 name=NULL;                  /* set up a window to serve as a backdrop */
 x=0;
 y=0;
 w=320;
 h=200;
 flags=ACTIVATE|SMART_REFRESH|BORDERLESS;
 c0=-1;
 c1=-1;

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

/* initialize the GelsInfo structure */

 g_init(wind,&vhead,&vtail,&ginfo);

/* initialize the Vsprite structure */

 vimp.Height=18;
 vimp.Width=2;
 vimp.Depth=2;
 vimp.ImageData=b_data;
 vimp.PlanePick=0x03;
 vimp.X=25;
 vimp.Y=25;

 vimp.Flags=0x0000;       /* to indicate that we're dealing with a Bob */

 vimp.VSBob=&bimp;       /* link the Bob and the Vsprite structures */
 bimp.BobVSprite=&vimp;

 SetRGB4(&(Scrn->ViewPort),29,15,0,0);
 SetRGB4(&(Scrn->ViewPort),30,15,15,15);
 SetRGB4(&(Scrn->ViewPort),31,0,0,15);

 AddBob(&bimp,wind->RPort);  /* add the Bob to the list */

 x=y=25;

 for(i=0;i<1000;i++) {        /* move the Bob around */
  if(x < X_LF_BORDER) {       /* change direction at the left hand border */
   x=X_LF_BORDER+1;
   xin=1;
   }
  else if( x > X_RT_BORDER) {            /*...and at the right one */
   x=X_RT_BORDER-1;
   xin=(-1);
   }
  else
   x+=xin;

  if(y < Y_TP_BORDER) {                  /* move down at the top */
   y=Y_TP_BORDER+1;
   yin=1;
   }
  else if(y > Y_BT_BORDER) {            /* move up at the bottom */
   y=Y_BT_BORDER-1;
   yin=(-1);
   }
  else
   y+=yin;

  vimp.X=x;
  vimp.Y=y;

  s_display(wind,Scrn,&vimp);

  }

 CloseWindow(wind);                       /* close down the window */
 CloseScreen(Scrn);                       /* and the screen */
}




 

