/*
 *	gemobpr.c
 *	GEM Jaguar Object Processor Definations
 *	Defines object list for screen & mouse
 *
 *	Copyright 1993 ATARI Corp.
 */
#include "jagobj.h"
#include "alloc.h"
#include "portab.h"

#define WHI 0xffff
#define BL0 (0xF800>>1)&0xfbdf
#define BL1 (0xF81E>>1)&0xfbdf
#define BL2 (0xF03E>>1)&0xfbdf
#define BL3 (0x783E>>1)&0xfbdf
#define BL4 (0x003E>>1)&0xfbdf
#define BL5 (0x03FE>>1)&0xfbdf
#define BL6 (0x07FE>>1)&0xfbdf
#define BL7 (0x07DF>>1)&0xfbdf
#define BL8 (0x07C6>>1)&0xfbdf
#define BL9 (0x5FC0>>1)&0xfbdf

char 		*memcpy(char *, char *, long);

extern	long	*v_bas_ad;	/* screen base address */
extern	WORD	dram_fuji[];

int cursor_data[]={WHI,WHI,000,000,000,000,000,000,000,000,000,000,000,000,000,000,
				   WHI,BL0,WHI,000,000,000,000,000,000,000,000,000,000,000,000,000,
				   WHI,BL0,BL1,WHI,000,000,000,000,000,000,000,000,000,000,000,000,
				   WHI,BL1,BL1,BL2,WHI,000,000,000,000,000,000,000,000,000,000,000,
				   WHI,BL2,BL2,BL3,BL3,WHI,000,000,000,000,000,000,000,000,000,000,
				   WHI,BL3,BL3,BL4,BL4,BL4,WHI,000,000,000,000,000,000,000,000,000,
				   WHI,BL4,BL4,BL5,WHI,WHI,000,000,000,000,000,000,000,000,000,000,
				   WHI,BL5,WHI,BL6,BL7,WHI,000,000,000,000,000,000,000,000,000,000,
				   WHI,BL0,WHI,BL7,BL8,WHI,000,000,000,000,000,000,000,000,000,000,
				   WHI,WHI,000,WHI,BL8,BL9,WHI,000,000,000,000,000,000,000,000,000,
				   000,000,000,WHI,BL9,BL9,WHI,000,000,000,000,000,000,000,000,000,
				   000,000,000,000,WHI,WHI,000,000,000,000,000,000,000,000,000,000};

/*
 *	our object list, bottom to top; C format, of course
 */

STOPOBJ stop_obj = {
	T_STOPOBJ,		/* type 			*/
	{ 0L, 0L },		/* data				*/
	0,			/* bal				*/
	0L			/* where (will be filled in)	*/
};

/*
 *	This is our bus hog screen object
 */

#define BHW	96			/* was 40 */
#define BHH 200			/* was 120 */

SBITMOBJ bushog_obj = {
	T_SBITMOBJ,		/* type				*/
#if SYLVESTER
	SCRNTOP + 30,		/* ypos				*/
#else
	SCRNTOP + 34,		/* ypos				*/
#endif
	BHH,			/* height			*/
	(ULONG)&stop_obj,	/* link				*/
	0L,			/* data				*/
#if SYLVESTER
	0,
#else
	32,			/* xpos				*/
#endif
	4,			/* depth			*/
	1,			/* pitch			*/
	BHW,		/* dwidth			*/
	BHW,		/* iwidth			*/
	0,			/* index			*/
	0,			/* reflect			*/
	0,			/* rmw				*/
	1,			/* trans			*/
	0,			/* release			*/
	0,			/* firstpix			*/
	0,			/* unused			*/
	15,			/* hscale			*/
	15,			/* vscale			*/
	15,			/* remainder		*/
	0,			/* bal				*/
	0L			/* where (will be filled in)	*/
};

/*
 *	This is our mouse pointer
 */
BITMOBJ mouse_obj = {
	T_BITMOBJ,		/* type				*/
	100,		/* ypos				*/
	12,			/* height			*/
	(ULONG)&bushog_obj,	/* link				*/
	0L,			/* data				*/
	100,		/* xpos				*/
	4,			/* depth			*/
	1,			/* pitch			*/
	4,			/* dwidth			*/
	4,			/* iwidth			*/
	0,			/* index			*/
	0,			/* reflect			*/
	0,			/* rmw				*/
	1,			/* trans			*/
	0,			/* release			*/
	0,			/* firstpix			*/
	0,			/* unused			*/
	0,			/* bal				*/
	0L			/* where (will be filled in)	*/
};

/*
 *	This is our main screen object
 */
BITMOBJ scrn_obj = {
	T_BITMOBJ,		/* type				*/
#if SYLVESTER
	SCRNTOP + 30,		/* ypos				*/
#else
	SCRNTOP + 34,		/* ypos				*/
#endif
	200,			/* height			*/
	(ULONG)&mouse_obj,	/* link				*/
	0L,			/* data				*/
#if SYLVESTER
	0,
#else
	32,			/* xpos				*/
#endif
	4,			/* depth			*/
	1,			/* pitch			*/
	96,			/* dwidth			*/
	96,			/* iwidth			*/
	0,			/* index			*/
	0,			/* reflect			*/
	0,			/* rmw				*/
	0,			/* trans			*/
	0,			/* release			*/
	0,			/* firstpix			*/
	0,			/* unused			*/
	0,			/* bal				*/
	0L			/* where (will be filled in)	*/
};



/*
 * Someone who wrote the docs says we need this...
 */
BRAOBJ bra2_obj =  {
	T_BRAOBJ,
	(ULONG)&scrn_obj,
	25,
	1,
	(ULONG)&stop_obj,
	0L,
	0,
	0L
};

BRAOBJ bra1_obj =  {
	T_BRAOBJ,
	(ULONG)&bra2_obj,
	507,
	2,
	(ULONG)&stop_obj,
	0L,
	0,
	0L
};

BRAOBJ  cbra1_obj;	/* these are the DRAM copies of our objects 	*/
BRAOBJ  cbra2_obj;	/* since we can't mess with ROM data		*/
BITMOBJ cscrn_obj;
BITMOBJ cmouse_obj;
SBITMOBJ cbushog_obj;
STOPOBJ cstop_obj;

/*
 *	Create the Objects needed for JAZ
 */

	void
*init_objs(void)
{
	/*
	 * Copy object data to RAM so we can play with it ...
	 */

	memcpy((char *)&cbra1_obj, (char *)&bra1_obj, (long) sizeof(BRAOBJ));
	memcpy((char *)&cbra2_obj, (char *)&bra2_obj, (long) sizeof(BRAOBJ));
	memcpy((char *)&cscrn_obj, (char *)&scrn_obj, (long) sizeof(BITMOBJ));
	memcpy((char *)&cmouse_obj, (char *)&mouse_obj, (long) sizeof(BITMOBJ));
	memcpy((char *)&cbushog_obj, (char *)&bushog_obj, (long) sizeof(SBITMOBJ));
	memcpy((char *)&cstop_obj, (char *)&stop_obj, (long) sizeof(STOPOBJ));

  	cscrn_obj.data = (unsigned long) v_bas_ad;
  	cbushog_obj.data = (unsigned long) v_bas_ad;
/*  	cbushog_obj.data = (unsigned long) &dram_fuji;*/
  	cmouse_obj.data = (unsigned long) cursor_data;

	cbra1_obj.next = (unsigned long) &cbra2_obj;
	cbra1_obj.link = (unsigned long) &cstop_obj;
	cbra2_obj.next = (unsigned long) &cscrn_obj;
	cbra2_obj.link = (unsigned long) &cstop_obj;
	cscrn_obj.link = (unsigned long) &cmouse_obj;
	cmouse_obj.link = (unsigned long) &cbushog_obj;
	cbushog_obj.link = (unsigned long) &cstop_obj;

	cnvt_objlst(&cbra1_obj);

	return (void *) &cbra1_obj;
}
