#include <intuition/intuition.h>
#include <intuition/screens.h>
#include <graphics/gfx.h>
#include <graphics/gfxbase.h>

#ifdef LATTICE
#include <clib/intuition_protos.h>
#include <clib/graphics_protos.h>
#endif

struct NewScreen myscreen = {
  0,0, 640,512, 2, 0,1, HIRES|LACE, CUSTOMSCREEN,
  NULL, NULL, NULL, NULL
};

struct Library *IntuitionBase=NULL;
struct GfxBase *GfxBase=NULL;

void SetOverscan(register struct Screen *screen )
{
 WORD anzzeilen = GfxBase->NormalDisplayRows;
 WORD x=screen->Width,y=screen->Height;
 struct ViewPort *vp=&(screen->ViewPort);

 if(anzzeilen>300) anzzeilen>>=1;
 x -= 320;  if(vp->Modes & HIRES) x -= 320;
 y -= anzzeilen;
 if(vp->Modes & LACE)  y -= anzzeilen;
 x >>=1; if(x<0) x=0; y >>=1; if(y<0) y=0;

 if(vp->Modes & HAM)
 {
  if(GfxBase->ActiView->DxOffset-x < 96)
   x=GfxBase->ActiView->DxOffset-96;
 }
 vp->DxOffset = -x; vp->DyOffset = -y;
 MakeScreen(screen);
 RethinkDisplay();
}

main()
{
  struct Screen *s;

  IntuitionBase=OpenLibrary("intuition.library",0);
  GfxBase=(struct GfxBase *)OpenLibrary("graphics.library",0);

  if( (s=OpenScreen(&myscreen)) ) {
    Delay( 200 );
    SetOverscan( s );
    Delay( 200 );
    CloseScreen( s );
  }

  CloseLibrary( (struct Library *)GfxBase );
  CloseLibrary( IntuitionBase );
}
