//===========================================================================//
// File:	L4V16.hpp                                                           //
// Project: MUNGA           Brick: Applications-specific controls module     //
// Contents: Interface specification for 16-bit video display                //
//---------------------------------------------------------------------------//
//   Date    Who  Modification                                               //
// --------  ---  -----------------------------------------------------------//
// 02/08/95  CPB  Initial coding.                                            //
//---------------------------------------------------------------------------//
// Copyright (C) 1995, Virtual World Entertainment, Inc. All rights reserved //
//                      PROPRIETARY and CONFIDENTIAL                         //
//===========================================================================//

#if !defined(L4VB8_HPP)
#	define L4VB8_HPP

#	if !defined(GRAPH2D_HPP)
#		include <graph2d.hpp>
#	endif

	//########################################################################
	//######################### Video8BitBuffered ###########################
	//########################################################################
	//
	// X/Y values passed to these routines are assumed to be in
	// the VIDEO DISPLAY COORDINATE SYSTEM, with (0,0) at the top left.
	//
	class Video8BitBuffered :
		public GraphicsDisplay
	{
	public:
		Video8BitBuffered(int x, int y);
		Video8BitBuffered(PixelMap8 *pixel_map);

		~Video8BitBuffered();

		Logical
			TestInstance() const;

		void
			ShowInstance(char *indent);

		void
			DrawPoint(
				int color,
				int bitmask,
				Enumeration operation,
				int x, int y
			);

		void
			DrawLine(
				int color,
				int bitmask,
				Enumeration operation,
				int x1, int y1,
				int x2, int y2,
				Logical include_last_pixel
			);

		void
			DrawFilledRectangle(
				int color,
            int bitmask,
				Enumeration operation,
				int x1, int y1,
				int x2, int y2
			);

		void
			DrawText(
				int color,
				int bitmask,
				Enumeration operation,
				Logical opaque,
				int rotation,
				Enumeration fontNumber,
				Logical vertical,
				GraphicsDisplay::Justification justification,
				Rectangle2D	*clippingRectanglePtr,
				char *stringPointer
			);

		void
			DrawBitMap(
				int color,
				int bitmask,
				Enumeration operation,
				int rotation,
				int x, int y,
				BitMap *bitmap,
				int sx1, int sy1, int sx2, int sy2	// these are SOURCE coordinates
			);

		void
			DrawBitMapOpaque(
				int color,
				int background,
				int bitmask,
				Enumeration operation,
				int rotation,
				int x, int y,
				BitMap *bitmap,
				int sx1, int sy1, int sx2, int sy2	// these are SOURCE coordinates
			);

		void
			DrawPixelMap8(
         	int *translation_table,
				int bitmask,
				Enumeration operation,
				Logical opaque,
				int rotation,
				int x, int y,
				PixelMap8	*pixelmap,
				int sx1, int sy1, int sx2, int sy2	// these are SOURCE coordinates
			);

		void
			DrawPixelMap8SingleColor(
				int color,
				int bitmask,
				Enumeration operation,
				int rotation,
				int x, int y,
				PixelMap8	*pixelmap,
				int sx1, int sy1, int sx2, int sy2	// these are SOURCE coordinates
			);

	protected:
		void
			MarkChangedLines(int screenTop, int screenBottom);

		void
			buildDestPointer(
				int x, int y,
				Byte **pixelPointer
			);

		Logical
			valid,
			createdPixelmap;
		int
			width,
			height,
			maximumX,
			maximumY;

	public:
		PixelMap8
			*pixelBuffer;
	protected:
		Word
			*changedLine;
	};


	//########################################################################
	//########################## L4BytePort ##############################
	//########################################################################
	//
	// X/Y values passed to these routines are assumed to be in
	// the GRAPHICS COORDINATE SYSTEM, with (0,0) at the bottom left.
	//
	class L4BytePort :
		public GraphicsPort
	{
	public:
		L4BytePort(
			Video8BitBuffered *graphics_display,
			const char *name,
			int rotation
		);

		~L4BytePort();

		Logical
			TestInstance() const;

		void
			ShowInstance(char *indent);

		void
			DrawPoint(
				int color,
				Enumeration operation,
				int x, int y
			);

		void
			DrawLine(
				int color,
				Enumeration operation,
				int x1, int y1,
				int x2, int y2,
				Logical include_last_pixel
			);

		void
			DrawFilledRectangle(
				int color,
				Enumeration operation,
				int x1, int y1,
				int x2, int y2
			);

		void
			DrawText(
				int color,
				Enumeration operation,
				Logical opaque,
				int rotation,
				Enumeration fontNumber,
				Logical vertical,
				GraphicsDisplay::Justification justification,
				Rectangle2D	*clippingRectanglePtr,
				char *stringPointer
			);

		void
			DrawBitMap(
				int color,
				Enumeration operation,
				int rotation,
				int x, int y,
				BitMap *bitmap,
				int sx1, int sy1, int sx2, int sy2	// these are SOURCE coordinates
			);

		void
			DrawBitMapOpaque(
				int color,
            int background,
				Enumeration operation,
				int rotation,
				int x, int y,
				BitMap *bitmap,
				int sx1, int sy1, int sx2, int sy2	// these are SOURCE coordinates
			);

		void
			DrawPixelMap8(
				Enumeration operation,
				Logical opaque,
				int rotation,
				int x, int y,
				PixelMap8	*pixelmap,
				int sx1, int sy1, int sx2, int sy2	// these are SOURCE coordinates
			);

		void
			DrawPixelMap8SingleColor(
         	int color,
				Enumeration operation,
				int rotation,
				int x, int y,
				PixelMap8	*pixelmap,
				int sx1, int sy1, int sx2, int sy2	// these are SOURCE coordinates
			);
	protected:
		void
			convertPortPair(
				int *xp,
				int *yp,
				int x,
				int y
			);

		//------------------------------------------------------------
		// Protected data
		//------------------------------------------------------------
		int
			baseRotation,
			maximumX,
			maximumY;
	};

#endif
