;/*
sc RESOPT IGNORE=73 DATA=NEAR NMINC UCHAR CONSTLIB STREQ STRMERGE NOSTKCHK NOSTDIO OPTIMIZE OPTSIZE Generic.c
slink from LIB:c.o Generic.o to //Clients/Generic LIB LIB:sc.lib LIB:amiga.lib /lib/client.lib SC SD NOICONS STRIPDEBUG
delete Generic.o
quit

 Generic 1.0  (Client for BServer)

 Copyright © 1995 by Stefano Reksten of 3AM - The Three Amigos!!!
 All rights reserved.
*/

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

#include <proto/exec.h>
#include <proto/intuition.h>
#include <proto/graphics.h>
#include <clib/alib_protos.h>

#include "/include/client.h"

char *ver = "$VER: Generic 1.0 "__AMIGADATE__;

struct IntuitionBase *IntuitionBase;
struct GfxBase *GfxBase;
struct DisplayIDInformation *dinfo;

extern ULONG RangeSeed;

void Generic( void )
{
struct Screen *scr;
UWORD  swidth, sheight;
struct Rectangle *rect;
UBYTE brightness;

rect = GETTXTOSCANRECT(dinfo);

swidth = RECTANGLEWIDTH(rect);
sheight = RECTANGLEHEIGHT(rect);
brightness = GETBRIGHTNESS(dinfo);

if ( scr = OpenScreenTags( NULL,
	SA_DisplayID, DISPLAYID( dinfo ),
	SA_Width, swidth,
	SA_Height, sheight,
	SA_Depth, 2,
	TAG_END ) )
	{
	register struct ViewPort *vp = &(scr->ViewPort);
	register struct RastPort *rp = &(scr->RastPort);

	SpritesOff();

	SetRGB4( vp, 0, 0, 0, 0 );
	SetRGB4( vp, 1, 15*brightness/100, 15*brightness/100, 15*brightness/100 );

	while( STILL_BLANKING )
		{
		WaitTOF();
		}

	CloseScreen( scr );
	SpritesOn();
	}
else
	SendClientMsg( ACTION_FAILED );
}


void __main( void )
{
if ( IntuitionBase = (struct IntuitionBase *)OpenLibrary( "intuition.library", 37L ) )
	{
	if ( GfxBase = (struct GfxBase *)OpenLibrary( "graphics.library", 37L ) )
		{
		if ( dinfo = OpenCommunication() )
			{
			CurrentTime( &RangeSeed, &RangeSeed );
			Generic();
			CloseCommunication( dinfo );
			}
		CloseLibrary( (struct Library *)GfxBase );
		}
	CloseLibrary( (struct Library *)IntuitionBase );
	}
}
