kernel/eka/drivers/edisp/epoc/vga/vgatext.cpp
changeset 0 a41df078684a
equal deleted inserted replaced
-1:000000000000 0:a41df078684a
       
     1 // Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of the License "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // e32\drivers\edisp\epoc\vga\vgatext.cpp
       
    15 // Brutus display driver
       
    16 // 
       
    17 //
       
    18 
       
    19 #include "ws_std.h"
       
    20 
       
    21 const TUint KCharAttrib=0x17;		// white on blue
       
    22 
       
    23 #if 0
       
    24 #define __DEBUG_PRINT(a) RDebug::Print(a)
       
    25 #define __DEBUG_PRINT2(a,b) RDebug::Print(a,b)
       
    26 #else
       
    27 #define __DEBUG_PRINT(a)
       
    28 #define __DEBUG_PRINT2(a,b)
       
    29 #endif
       
    30 
       
    31 class CScreenDriverVgaText : public CScreenDriver
       
    32 	{
       
    33 public:
       
    34 	CScreenDriverVgaText();
       
    35 	virtual void Init(TSize &aScreenSize,TSize &aFontSize);
       
    36 	virtual void Blit(const TText *aBuffer,TInt aLength,const TPoint &aPosition);
       
    37 	virtual TBool ScrollUp(const TRect& aRect);
       
    38 	virtual void Clear(const TRect& aRect);
       
    39 
       
    40 	virtual void SetPixel(const TPoint& aPoint,TUint8 aColour);
       
    41 	virtual TInt GetPixel(const TPoint& aPoint);
       
    42 	virtual void SetWord(const TPoint& aPoint,TInt aWord);
       
    43 	virtual TInt GetWord(const TPoint& aPoint);
       
    44 	virtual void SetLine(const TPoint& aPoint,const TPixelLine& aPixelLine);
       
    45 	virtual void GetLine(const TPoint& aPoint,TPixelLine& aPixelLine);
       
    46 
       
    47 	virtual void SetPaletteEntry(TColorIndex anIndex,TUint8 aRed,TUint8 aGreen,TUint8 aBlue);
       
    48 	virtual void GetPaletteEntry(TColorIndex anIndex,TUint8 &aRed,TUint8 &aGreen,TUint8 &aBlue);
       
    49 	virtual void SetForegroundColor(TColorIndex anIndex);
       
    50 	virtual void SetBackgroundColor(TColorIndex anIndex);
       
    51 	virtual void GetAttributeColors(TColorIndex* anArray);
       
    52 	virtual TInt SetMode(TVideoMode aMode);
       
    53 public:
       
    54 	TInt iMode;
       
    55 	TUint16* iScreen;
       
    56 	TInt iSizeX;
       
    57 	TInt iSizeY;
       
    58 	friend class CScreenDriver;
       
    59 	};
       
    60 
       
    61 CScreenDriverVgaText::CScreenDriverVgaText()
       
    62 //
       
    63 // Constructor
       
    64 //
       
    65 	{
       
    66 	__DEBUG_PRINT(_L("CSD::Ctor"));
       
    67 	iMode=EMono;
       
    68 	}
       
    69 
       
    70 CScreenDriver* NewScreenDriverVgaText()
       
    71 //
       
    72 // Return the actual screen driver.
       
    73 //
       
    74 	{
       
    75 
       
    76 	__DEBUG_PRINT(_L("CSD::New"));
       
    77 
       
    78 	CScreenDriverVgaText* s=new CScreenDriverVgaText;
       
    79 	if (!s)
       
    80 		return NULL;
       
    81 	TScreenInfoV01 info;
       
    82 	TPckg<TScreenInfoV01> infoPckg(info);
       
    83 	UserSvr::ScreenInfo(infoPckg);
       
    84 	if (!info.iScreenAddressValid)
       
    85 		{
       
    86 		delete s;
       
    87 		return NULL;
       
    88 		}
       
    89 	s->iScreen = (TUint16*)(TUint32(info.iScreenAddress)+0x18000);
       
    90 	s->iSizeX=80;
       
    91 	s->iSizeY=25;
       
    92 	return s;
       
    93 	}
       
    94 
       
    95 void CScreenDriverVgaText::Init(TSize& aScreenSize, TSize& aFontSize)
       
    96 //
       
    97 // Report screen information
       
    98 //
       
    99 	{
       
   100 
       
   101 	__DEBUG_PRINT(_L("CSD::Init"));
       
   102 	aFontSize=TSize(8,10);
       
   103 	aScreenSize.iWidth=iSizeX;
       
   104 	aScreenSize.iHeight=iSizeY;
       
   105 
       
   106 	TInt i;
       
   107 	TUint16* p=iScreen;
       
   108 	for (i=0; i<iSizeX*iSizeY; ++i)
       
   109 		*p++=KCharAttrib<<8;
       
   110 	}
       
   111 
       
   112 TInt CScreenDriverVgaText::SetMode(TVideoMode /*aMode*/)
       
   113 //
       
   114 // Set the screen mode
       
   115 //
       
   116 	{
       
   117 	__DEBUG_PRINT(_L("CSD::SetMode"));
       
   118 	return(KErrNotSupported);
       
   119 	}
       
   120 
       
   121 void CScreenDriverVgaText::Blit(const TText* aBuf, TInt aLen, const TPoint& aPos)
       
   122 //
       
   123 // Write contiguous block of characters to some segment of a line on the display
       
   124 //
       
   125 	{
       
   126 	switch(iMode)
       
   127 		{
       
   128 		case EMono:
       
   129 			{
       
   130 			TUint16* pS=iScreen+aPos.iY*iSizeX+aPos.iX;
       
   131 			TUint8* pSB=(TUint8*)pS;
       
   132 			while(aLen--)
       
   133 				{
       
   134 				*pSB=(*aBuf++)&0xff;
       
   135 				pSB+=2;
       
   136 				}
       
   137 			break;
       
   138 			}
       
   139 		default:
       
   140 			break;
       
   141 		}
       
   142 	}
       
   143 
       
   144 TBool CScreenDriverVgaText::ScrollUp(const TRect& aRect)
       
   145 //
       
   146 // Scroll a rectangle of the screen up one character, don't update bottom line
       
   147 //
       
   148 	{
       
   149 
       
   150 	__DEBUG_PRINT(_L("CSD::ScrollUp"));
       
   151 	TUint16* pT=iScreen+aRect.iTl.iY*iSizeX+aRect.iTl.iX;
       
   152 	TUint16* pS=pT+iSizeX;
       
   153 	TUint16* pE=iScreen+aRect.iBr.iY*iSizeX;
       
   154 	TInt w=aRect.iBr.iX-aRect.iTl.iX;
       
   155 	if (w>0)
       
   156 		{
       
   157 		for (; pS<pE; pT+=iSizeX, pS+=iSizeX)
       
   158 			{
       
   159 			Mem::Copy(pT,pS,w*2);
       
   160 			}
       
   161 		}
       
   162 	return ETrue;
       
   163 	}
       
   164 
       
   165 void CScreenDriverVgaText::Clear(const TRect& aRect)
       
   166 //
       
   167 // Clear a rectangle of the screen, don't clear bottom line
       
   168 //
       
   169 	{
       
   170 
       
   171 __DEBUG_PRINT(_L("CSD::Clear"));
       
   172 	TUint16* pT=iScreen+aRect.iTl.iY*iSizeX+aRect.iTl.iX;
       
   173 	TUint16* pE=iScreen+aRect.iBr.iY*iSizeX;
       
   174 	TInt w=aRect.iBr.iX-aRect.iTl.iX;
       
   175 	if (w>0)
       
   176 		{
       
   177 		for (; pT<pE; pT+=iSizeX)
       
   178 			{
       
   179 			TInt i;
       
   180 			TUint16* pT2=pT;
       
   181 			for (i=w; i; --i)
       
   182 				*pT2++=KCharAttrib<<8;
       
   183 			}
       
   184 		}
       
   185 	}
       
   186 
       
   187 void CScreenDriverVgaText::SetPixel(const TPoint& /*aPoint*/, TUint8 /*aColour*/)
       
   188 	{
       
   189 	__DEBUG_PRINT(_L("CSD::SetPix"));
       
   190 	}
       
   191 
       
   192 TInt CScreenDriverVgaText::GetPixel(const TPoint& /*aPoint*/)
       
   193 	{
       
   194 	__DEBUG_PRINT(_L("CSD::GetPix"));
       
   195 	return 0;
       
   196 	}
       
   197 
       
   198 void CScreenDriverVgaText::SetWord(const TPoint& /*aPoint*/, TInt /*aWord*/)
       
   199 	{
       
   200 	__DEBUG_PRINT(_L("CSD::SetWord"));
       
   201 	}
       
   202 
       
   203 TInt CScreenDriverVgaText::GetWord(const TPoint& /*aPoint*/)
       
   204 	{
       
   205 	__DEBUG_PRINT(_L("CSD::GetWord"));
       
   206 	return 0;
       
   207 	}
       
   208 
       
   209 void CScreenDriverVgaText::SetLine(const TPoint& /*aPoint*/, const TPixelLine& /*aPixelLine*/)
       
   210 	{
       
   211 	__DEBUG_PRINT(_L("CSD::SetLine"));
       
   212 	}
       
   213 
       
   214 void CScreenDriverVgaText::GetLine(const TPoint& /*aPoint*/, TPixelLine& /*aPixelLine*/)
       
   215 	{
       
   216 	__DEBUG_PRINT(_L("CSD::GetLine"));
       
   217 	}
       
   218 
       
   219 void CScreenDriverVgaText::SetPaletteEntry(TColorIndex /*anIndex*/, TUint8 /*aRed*/, TUint8 /*aGreen*/, TUint8 /*aBlue*/)
       
   220 	{
       
   221 	}
       
   222 
       
   223 void CScreenDriverVgaText::GetPaletteEntry(TColorIndex /*anIndex*/, TUint8& /*aRed*/, TUint8& /*aGreen*/, TUint8& /*aBlue*/)
       
   224 	{
       
   225 	}
       
   226 
       
   227 void CScreenDriverVgaText::SetForegroundColor(TColorIndex /*anIndex*/)
       
   228 	{
       
   229 	}
       
   230 
       
   231 void CScreenDriverVgaText::SetBackgroundColor(TColorIndex /*anIndex*/)
       
   232 	{
       
   233 	}
       
   234 
       
   235 void CScreenDriverVgaText::GetAttributeColors(TColorIndex* /*anArray*/)
       
   236 	{
       
   237 	}
       
   238