/****************************************
*
*	Name		BootPicture
*	Version		1.50
*	Date		6 May 1996
*	Compiler	SAS C/C++ 6.55
*	Code		Wojciech Jeczmien  email: jeczmien@panda.bg.univ.gda.pl
*	Further code	Tak Tang           email: tst92@ecs.soton.ac.uk
*	Picture         Michael Becker     email: nf198@fim.uni-erlangen.de
*
****************************************/


/*** Definitions ***/

#define IM_WIDTH	403
#define IM_HEIGHT	258
#define IM_DEPTH	4
#define IM_NUMCOLS	(1 << IM_DEPTH)
#define IM_LACE		1
#define IM_NAME		"MacOS_ECS"
#define IM_DELAY	50
#define BPVER	"1.50"
#define BPDATE	"06.05.96"

/*** Header files ***/

#include <string.h>
#include <stdlib.h>
#include <intuition/intuition.h>
#include <intuition/intuitionbase.h>
#include <graphics/gfxbase.h>
#include <proto/intuition.h>
#include <proto/graphics.h>
#include <proto/dos.h>


/*** External data structures ***/

extern struct Image im;
extern UWORD cmap[];
extern USHORT sprite_data[4];


/*** Local data structures ***/

char verstag[]="$VER: BootPicture " BPVER " (" BPDATE ")\0";
char title[]="BootPicture " IM_NAME;


/*** Main Program ***/

void main()
{
	struct Screen *scr;
	struct Window *mywin;
	int scr_ntsc= (GfxBase->DisplayFlags & NTSC)?(IM_LACE?56:28):0;

	if (!(scr=OpenScreenTags(NULL,
		SA_Left, 320 - (IM_WIDTH / 2) ,
		SA_Top,  (IM_LACE?256:128) - (IM_HEIGHT / 2) - scr_ntsc,
		SA_Width,IM_WIDTH,
		SA_Height,IM_HEIGHT,
		SA_Depth,IM_DEPTH,
		SA_Title,title,
		SA_Quiet,TRUE,
		SA_ShowTitle,FALSE,
		SA_Type,CUSTOMSCREEN,
		SA_DisplayID, IM_LACE?HIRESLACE_KEY:HIRES_KEY,
		SA_Draggable,FALSE,
		TAG_DONE )))
			exit(0);

	if (!(mywin=OpenWindowTags(NULL,
		WA_Left,0,
		WA_Top,0,
		WA_Width,IM_WIDTH,
		WA_Height,IM_HEIGHT,
		WA_Flags,WFLG_SMART_REFRESH | WFLG_BORDERLESS | ACTIVATE | WFLG_RMBTRAP,
		WA_CustomScreen,scr,
		TAG_DONE))) {
			CloseScreen(scr);
			exit(0);
	}

	SetPointer(mywin,sprite_data, 0, 0, 0, 0);

	LoadRGB4(&scr->ViewPort,cmap,IM_NUMCOLS); /* -- ECS */
	/*LoadRGB32(&scr->ViewPort,cmap); -- AGA */

	DrawImage(mywin->RPort,&im,0,0);

	/* Wait until screen is not frontmost */
	while (TRUE){
		Delay(IM_DELAY);
		if (strcmp(IntuitionBase->FirstScreen->DefaultTitle,title))
			break;
	}

	/* Close windows and screens */
	CloseWindow(mywin);
	CloseScreen(scr);
} // main

/*** End of program ***/
