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