/* This function writes the chunky pixels to the screen.
   In Amiga mode it calls WritePixelArray8() or WriteChunkyPixels()
   when 3.1 is detected. A special fast c2p version will be included
   later.
   In Merlin mode it will write the chunkypixels directly to the screen,
   same for Picasso, EGS and Retina, if I get the source for it.
   Please if you know how to program your gfxcard, try to replace the Merlin
   functions the card specific ones.
*/
XPutImage(
    Display*		display,
    Drawable		d,
    GC				gc,
    XImage*			image,
    int				src_x,
    int				src_y,
    int				dest_x,
    int				dest_y,
    unsigned int	width,
    unsigned int	height	   )
{
extern struct HRHandle *hrh;
extern UBYTE  *basemem,*memstart;
extern char *im_buff0,*im_buff1;
	struct IntuiMessage	*imsg;
	struct BitMap tempbm;

	ULONG				class;
/* don't do anything with 1 bitplanes, not possible at the moment anyway */
	if( image->depth == 1 )
	{
	}
	else if( image->depth == 8 )
	{
		/* Standard 8 Bit Bitmap (chunky pixels) */
		switch (gfxcard)
		{
			case AMIGA:
	 			if(GfxBase->LibNode.lib_Version>39)
					WriteChunkyPixels( rp, offx, offy, offx+width-1, offy+height-1, image->data, width );
				else
				{
					CopyMemQuick(image->data,im_buff1,width*height);
    	    		WritePixelArray8(rp, offx, offy, offx+width-1, offy+height-1, im_buff1, temprp);
				}
				break;
/* The function here must have access to the chunkybuffer and copy it to the
   screen, visible or not. For the PicassoII it is something like:
   blitcopy(struct blit,screen)???
   All initialisation should have been done in the Open[Merlin][Picasso][Retina][EGS]
   function.
			case MERLIN:
				hrWriteRectPK8(&hrh->BitMap,image->data,0,0,width,height,1,width); /*MERLIN*/
				break;
			case EGS:
			case PICASSO:
			default:
				break;
		}
	}
	else if( image->depth == 16 )
	{
		/* Standard 16 Bit Bitmap (chunky pixels) */
		switch (gfxcard)
		{
			case MERLIN:
/*				hrWriteRectRGB(&hrh->BitMap,image->data,image->data,image->data,0,0,width,height,2,2*width);*/
				break;
			case EGS:
/* Function needed that copies a RGBA or ARGB buffer to a 16bit screen */
			case PICASSO:
			default:
				break;
		}
	}
	else if( image->depth >= 24 )
	{
		switch (gfxcard)
		{
			case MERLIN:
/*				hrWriteRectRGB(&hrh->BitMap,image->data,image->data,image->data,0,0,width,height,2,2*width);*/
				break;
			case EGS:
/* Function needed that copies a RGBA or ARGB buffer to a 24bit screen */
			case PICASSO:
			default:
				break;
		}
	}
}


XStoreColors(Display *theDisp,Colormap theCmap,XColor defs[], int xa_cmap_size)
{
	ULONG i;

	switch (gfxcard)
	{
/* I know I should use the function which set a whole colormap at once. */
		case AMIGA:
			for(i=0;i<xa_cmap_size;i++)
			{
				SetRGB32(vp,i,(ULONG )defs[i].red<<24,(ULONG )defs[i].green<<24,(ULONG )defs[i].blue<<24);
			}
			break;
		case MERLIN:
			for(i=0;i<xa_cmap_size;i++)
			{
				hrSetRGB32(hrh,i,(ULONG )defs[i].red<<24,(ULONG )defs[i].green<<24,(ULONG )defs[i].blue<<24);/*MERLIN*/
			}
			break;
/* Function needed for EGS/Picasso/Retina which set colormap entries */
		case EGS:
		case PICASSO:
		default:
			break;
	}
}
