#ifndef VESA_HH
#define VESA_HH

#include "video.hh"	//My abstract base class
#include "bitmap.hh"

class VESA : public Video
{
   public:
      VESA(void);
      ~VESA(void);
      UBYTE SetResolution(BYTE theMode, UWORD viewport);
      UBYTE GetNrOfPages(void);
      void SetDrawPage(unsigned int thePage);
      void SetVisiblePage(unsigned int thePage);
      void ClearScreen(UBYTE theColor);
      void ClearVideoMemory(UBYTE theColor);
      void ScrollX(WORD direction);
      void ScrollY(WORD direction);
      void SetScrollingSpeed(UWORD ySpeed);
      void ClearScrollingY(void);
      void ClearScrollingX(void);
      void PutPixel(WORD x, WORD y, UBYTE color);
      UBYTE GetPixel(WORD x, WORD y);
      void V_Line(WORD x, WORD top_y, WORD len, UBYTE color);
      void H_Line(WORD left_x, WORD y, WORD len, UBYTE color);
      void Box(WORD x1, WORD y1, WORD x2, WORD y2, UBYTE color);
      void FilledBox(WORD x1, WORD y1, WORD x2, WORD y2, UBYTE color);
      void Circle(WORD x, WORD y, WORD r, UBYTE color);
      void FilledCircle(WORD x, WORD y, WORD r, UBYTE color);
      void Line(WORD x1, WORD y1, WORD x2, WORD y2, UBYTE color);
      void DrawAnySizeBitmap(WORD x, WORD y, Bitmap *myBitmap);
      void DrawAlignedBitmap(WORD x, WORD y, Bitmap *myBitmap);
      void GetAnySizeRAMBitmap(WORD x, WORD y, WORD theWidth, WORD theHeight, Bitmap *mySrc, Bitmap *myDst);
      void GetAlignedRAMBitmap(WORD x, WORD y, WORD theWidth, WORD theHeight, Bitmap *mySrc, Bitmap *myDst);
      WORD ScaleBitmap(Bitmap* srcBmp, Bitmap* dstBmp, int newXSize, int newYSize);
      WORD ScaleBitmapX(Bitmap* srcBmp, Bitmap* dstBmp, int newXSize);
      WORD ScaleBitmapY(Bitmap* srcBmp, Bitmap* dstBmp, int newYSize);
      void ConvLin2PlanBitmap(Bitmap *myBitmap);
      void DrawCompiledBitmap(WORD x,WORD y,Bitmap *myBitmap);
      UBYTE CompileBitmap(Bitmap *myBitmap);
      void DrawWideBitmap(WORD y, Bitmap *myBitmap);
      void GetWideScreenBitmap(WORD y, WORD height, Bitmap *myBitmap);
      void GetAlignedScreenBitmap(WORD x, WORD y, WORD width, WORD height, Bitmap *myBitmap);
      void GetAnySizeScreenBitmap(WORD x, WORD y, Bitmap *myBitmap);
   private:
      UBYTE AllocRLEBitmap(Bitmap *myBitmap);
      void SetBank(WORD theBank);
      WORD GetCurrentBank(WORD x, WORD y);
      WORD nrOfBanks; //Number of pages required to fill up the screen
      DWORD nrOfBytesInLastBank; //This will be zero if width*height/65536 is even.
      DWORD alignedBankSize; //aligned bank size is 65536 / 4
      UBYTE activeBank; //Contains the number of the active bank
      DWORD *rowY; ////Will hold offset values for all rows in Y in page 0.
      UWORD myFirstDisplPixInScanLine; //Used for scrolling and page flipping
      UWORD myFirstDisplScanLine; //Used for scrolling and page flipping
      UWORD firstDisplayedScanLineInPage1; //First line to be seen in page 1.
      UWORD myFirstDisplPixInScanLineInPage1; //First start pixel pos. in page 1.
      
      //These new values must be calculated because of eventual
      //bank switching. 
      DWORD *offsetY; //Holds the new y-offsets depending on which bank to use.
      DWORD *offsetX; //Same here but for X values
      UWORD nrOfPages; //The numbers of pages to filp between.
      DWORD theCurrentDrawingPage; //The page we should draw on.
      DWORD theCurrentVisiblePage; //The page visible to the user.
      UWORD scrollYSpeed;
};
#endif

