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

#include <intuition/intuition.h>
#include <dos/dos.h>

#include <clib/exec_protos.h>
#include <clib/intuition_protos.h>
#include <clib/graphics_protos.h>

#include "Fade.h"
#include "/main.h"
#include "//defs.h"

struct fPrefObject {
	LONG Delay;
};

extern struct fPrefObject nP;

#define BLANKMOUSE
#define CLONETOPSCREEN
#define FADESCREEN
#include "/utility.c"

LONG Blank( VOID *Prefs )
{
	struct fPrefObject *fP;
	struct Screen *FScr;
	LONG ToFrontCount = 0, RetVal;

	if( FadeWnd )
		fP = &nP;
	else
		fP = ( struct fPrefObject * )Prefs;

	if( FScr = cloneTopScreen( FALSE ))
	{
		BlankMousePointer( FScr );
		if( RetVal = fadeScreen( FScr, fP->Delay, getTopScreenMode()))
		{
			while( RetVal == OK )
			{
				WaitTOF();
				if(!( ++ToFrontCount % 60 ))
					ScreenToFront( FScr );
				if(!( ToFrontCount % 5 ))
					RetVal = ContinueBlanking();
			}
		}
		UnblankMousePointer();
		closeTopScreen( FScr );
	}
	else
		RetVal = FAILED;

	return RetVal;
}
