os/kernelhwsrv/kernel/eka/drivers/edisp/epoc/vga/vgatext.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/kernelhwsrv/kernel/eka/drivers/edisp/epoc/vga/vgatext.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,238 @@
     1.4 +// Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// under the terms of the License "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +// e32\drivers\edisp\epoc\vga\vgatext.cpp
    1.18 +// Brutus display driver
    1.19 +// 
    1.20 +//
    1.21 +
    1.22 +#include "ws_std.h"
    1.23 +
    1.24 +const TUint KCharAttrib=0x17;		// white on blue
    1.25 +
    1.26 +#if 0
    1.27 +#define __DEBUG_PRINT(a) RDebug::Print(a)
    1.28 +#define __DEBUG_PRINT2(a,b) RDebug::Print(a,b)
    1.29 +#else
    1.30 +#define __DEBUG_PRINT(a)
    1.31 +#define __DEBUG_PRINT2(a,b)
    1.32 +#endif
    1.33 +
    1.34 +class CScreenDriverVgaText : public CScreenDriver
    1.35 +	{
    1.36 +public:
    1.37 +	CScreenDriverVgaText();
    1.38 +	virtual void Init(TSize &aScreenSize,TSize &aFontSize);
    1.39 +	virtual void Blit(const TText *aBuffer,TInt aLength,const TPoint &aPosition);
    1.40 +	virtual TBool ScrollUp(const TRect& aRect);
    1.41 +	virtual void Clear(const TRect& aRect);
    1.42 +
    1.43 +	virtual void SetPixel(const TPoint& aPoint,TUint8 aColour);
    1.44 +	virtual TInt GetPixel(const TPoint& aPoint);
    1.45 +	virtual void SetWord(const TPoint& aPoint,TInt aWord);
    1.46 +	virtual TInt GetWord(const TPoint& aPoint);
    1.47 +	virtual void SetLine(const TPoint& aPoint,const TPixelLine& aPixelLine);
    1.48 +	virtual void GetLine(const TPoint& aPoint,TPixelLine& aPixelLine);
    1.49 +
    1.50 +	virtual void SetPaletteEntry(TColorIndex anIndex,TUint8 aRed,TUint8 aGreen,TUint8 aBlue);
    1.51 +	virtual void GetPaletteEntry(TColorIndex anIndex,TUint8 &aRed,TUint8 &aGreen,TUint8 &aBlue);
    1.52 +	virtual void SetForegroundColor(TColorIndex anIndex);
    1.53 +	virtual void SetBackgroundColor(TColorIndex anIndex);
    1.54 +	virtual void GetAttributeColors(TColorIndex* anArray);
    1.55 +	virtual TInt SetMode(TVideoMode aMode);
    1.56 +public:
    1.57 +	TInt iMode;
    1.58 +	TUint16* iScreen;
    1.59 +	TInt iSizeX;
    1.60 +	TInt iSizeY;
    1.61 +	friend class CScreenDriver;
    1.62 +	};
    1.63 +
    1.64 +CScreenDriverVgaText::CScreenDriverVgaText()
    1.65 +//
    1.66 +// Constructor
    1.67 +//
    1.68 +	{
    1.69 +	__DEBUG_PRINT(_L("CSD::Ctor"));
    1.70 +	iMode=EMono;
    1.71 +	}
    1.72 +
    1.73 +CScreenDriver* NewScreenDriverVgaText()
    1.74 +//
    1.75 +// Return the actual screen driver.
    1.76 +//
    1.77 +	{
    1.78 +
    1.79 +	__DEBUG_PRINT(_L("CSD::New"));
    1.80 +
    1.81 +	CScreenDriverVgaText* s=new CScreenDriverVgaText;
    1.82 +	if (!s)
    1.83 +		return NULL;
    1.84 +	TScreenInfoV01 info;
    1.85 +	TPckg<TScreenInfoV01> infoPckg(info);
    1.86 +	UserSvr::ScreenInfo(infoPckg);
    1.87 +	if (!info.iScreenAddressValid)
    1.88 +		{
    1.89 +		delete s;
    1.90 +		return NULL;
    1.91 +		}
    1.92 +	s->iScreen = (TUint16*)(TUint32(info.iScreenAddress)+0x18000);
    1.93 +	s->iSizeX=80;
    1.94 +	s->iSizeY=25;
    1.95 +	return s;
    1.96 +	}
    1.97 +
    1.98 +void CScreenDriverVgaText::Init(TSize& aScreenSize, TSize& aFontSize)
    1.99 +//
   1.100 +// Report screen information
   1.101 +//
   1.102 +	{
   1.103 +
   1.104 +	__DEBUG_PRINT(_L("CSD::Init"));
   1.105 +	aFontSize=TSize(8,10);
   1.106 +	aScreenSize.iWidth=iSizeX;
   1.107 +	aScreenSize.iHeight=iSizeY;
   1.108 +
   1.109 +	TInt i;
   1.110 +	TUint16* p=iScreen;
   1.111 +	for (i=0; i<iSizeX*iSizeY; ++i)
   1.112 +		*p++=KCharAttrib<<8;
   1.113 +	}
   1.114 +
   1.115 +TInt CScreenDriverVgaText::SetMode(TVideoMode /*aMode*/)
   1.116 +//
   1.117 +// Set the screen mode
   1.118 +//
   1.119 +	{
   1.120 +	__DEBUG_PRINT(_L("CSD::SetMode"));
   1.121 +	return(KErrNotSupported);
   1.122 +	}
   1.123 +
   1.124 +void CScreenDriverVgaText::Blit(const TText* aBuf, TInt aLen, const TPoint& aPos)
   1.125 +//
   1.126 +// Write contiguous block of characters to some segment of a line on the display
   1.127 +//
   1.128 +	{
   1.129 +	switch(iMode)
   1.130 +		{
   1.131 +		case EMono:
   1.132 +			{
   1.133 +			TUint16* pS=iScreen+aPos.iY*iSizeX+aPos.iX;
   1.134 +			TUint8* pSB=(TUint8*)pS;
   1.135 +			while(aLen--)
   1.136 +				{
   1.137 +				*pSB=(*aBuf++)&0xff;
   1.138 +				pSB+=2;
   1.139 +				}
   1.140 +			break;
   1.141 +			}
   1.142 +		default:
   1.143 +			break;
   1.144 +		}
   1.145 +	}
   1.146 +
   1.147 +TBool CScreenDriverVgaText::ScrollUp(const TRect& aRect)
   1.148 +//
   1.149 +// Scroll a rectangle of the screen up one character, don't update bottom line
   1.150 +//
   1.151 +	{
   1.152 +
   1.153 +	__DEBUG_PRINT(_L("CSD::ScrollUp"));
   1.154 +	TUint16* pT=iScreen+aRect.iTl.iY*iSizeX+aRect.iTl.iX;
   1.155 +	TUint16* pS=pT+iSizeX;
   1.156 +	TUint16* pE=iScreen+aRect.iBr.iY*iSizeX;
   1.157 +	TInt w=aRect.iBr.iX-aRect.iTl.iX;
   1.158 +	if (w>0)
   1.159 +		{
   1.160 +		for (; pS<pE; pT+=iSizeX, pS+=iSizeX)
   1.161 +			{
   1.162 +			Mem::Copy(pT,pS,w*2);
   1.163 +			}
   1.164 +		}
   1.165 +	return ETrue;
   1.166 +	}
   1.167 +
   1.168 +void CScreenDriverVgaText::Clear(const TRect& aRect)
   1.169 +//
   1.170 +// Clear a rectangle of the screen, don't clear bottom line
   1.171 +//
   1.172 +	{
   1.173 +
   1.174 +__DEBUG_PRINT(_L("CSD::Clear"));
   1.175 +	TUint16* pT=iScreen+aRect.iTl.iY*iSizeX+aRect.iTl.iX;
   1.176 +	TUint16* pE=iScreen+aRect.iBr.iY*iSizeX;
   1.177 +	TInt w=aRect.iBr.iX-aRect.iTl.iX;
   1.178 +	if (w>0)
   1.179 +		{
   1.180 +		for (; pT<pE; pT+=iSizeX)
   1.181 +			{
   1.182 +			TInt i;
   1.183 +			TUint16* pT2=pT;
   1.184 +			for (i=w; i; --i)
   1.185 +				*pT2++=KCharAttrib<<8;
   1.186 +			}
   1.187 +		}
   1.188 +	}
   1.189 +
   1.190 +void CScreenDriverVgaText::SetPixel(const TPoint& /*aPoint*/, TUint8 /*aColour*/)
   1.191 +	{
   1.192 +	__DEBUG_PRINT(_L("CSD::SetPix"));
   1.193 +	}
   1.194 +
   1.195 +TInt CScreenDriverVgaText::GetPixel(const TPoint& /*aPoint*/)
   1.196 +	{
   1.197 +	__DEBUG_PRINT(_L("CSD::GetPix"));
   1.198 +	return 0;
   1.199 +	}
   1.200 +
   1.201 +void CScreenDriverVgaText::SetWord(const TPoint& /*aPoint*/, TInt /*aWord*/)
   1.202 +	{
   1.203 +	__DEBUG_PRINT(_L("CSD::SetWord"));
   1.204 +	}
   1.205 +
   1.206 +TInt CScreenDriverVgaText::GetWord(const TPoint& /*aPoint*/)
   1.207 +	{
   1.208 +	__DEBUG_PRINT(_L("CSD::GetWord"));
   1.209 +	return 0;
   1.210 +	}
   1.211 +
   1.212 +void CScreenDriverVgaText::SetLine(const TPoint& /*aPoint*/, const TPixelLine& /*aPixelLine*/)
   1.213 +	{
   1.214 +	__DEBUG_PRINT(_L("CSD::SetLine"));
   1.215 +	}
   1.216 +
   1.217 +void CScreenDriverVgaText::GetLine(const TPoint& /*aPoint*/, TPixelLine& /*aPixelLine*/)
   1.218 +	{
   1.219 +	__DEBUG_PRINT(_L("CSD::GetLine"));
   1.220 +	}
   1.221 +
   1.222 +void CScreenDriverVgaText::SetPaletteEntry(TColorIndex /*anIndex*/, TUint8 /*aRed*/, TUint8 /*aGreen*/, TUint8 /*aBlue*/)
   1.223 +	{
   1.224 +	}
   1.225 +
   1.226 +void CScreenDriverVgaText::GetPaletteEntry(TColorIndex /*anIndex*/, TUint8& /*aRed*/, TUint8& /*aGreen*/, TUint8& /*aBlue*/)
   1.227 +	{
   1.228 +	}
   1.229 +
   1.230 +void CScreenDriverVgaText::SetForegroundColor(TColorIndex /*anIndex*/)
   1.231 +	{
   1.232 +	}
   1.233 +
   1.234 +void CScreenDriverVgaText::SetBackgroundColor(TColorIndex /*anIndex*/)
   1.235 +	{
   1.236 +	}
   1.237 +
   1.238 +void CScreenDriverVgaText::GetAttributeColors(TColorIndex* /*anArray*/)
   1.239 +	{
   1.240 +	}
   1.241 +