Update contrib.
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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
15 // Screen Driver for Text Window Server
17 // This is the screen driver for the simple text Window Server supplied as part of
18 // E32. It is required to run the text shell, E32 & F32 tests etc.
19 // This is a working generic implementation which you shouldn't need to alter, but
20 // you may customise it if required. e.g. Change the default display mode or colors.
21 // ASSUMPTIONS MADE BY THIS IMPLEMENTATION
22 // * The start of each character on the display is byte aligned.
30 #include <videodriver.h>
33 #define __DEBUG_PRINT(a) RDebug::Print(a)
34 #define __DEBUG_PRINT2(a,b) RDebug::Print(a,b)
36 #define __DEBUG_PRINT(a)
37 #define __DEBUG_PRINT2(a,b)
41 extern CScreenDriver* NewScreenDriverVgaText();
44 const TUint32 KHwAccBlockFill=1;
45 const TUint32 KHwAccBlockCopy=2;
47 inline TInt HwBlockFill(SRectOpInfo &a)
49 return UserSvr::HalFunction(EHalGroupDisplay, EDisplayHalBlockFill, &a, NULL);
52 inline TInt HwBlockCopy(SRectOpInfo &a)
54 return UserSvr::HalFunction(EHalGroupDisplay, EDisplayHalBlockCopy, &a, NULL);
58 * Main screen driver implementation class.
62 * The public API of this class is defined by the CScreenDriver class.
63 * You may want to add some private definitions to this.
65 class CScreenDriverTemplate : public CScreenDriver
68 CScreenDriverTemplate();
69 virtual void Init(TSize &aScreenSize,TSize &aFontSize);
70 virtual void Blit(const TText *aBuffer,TInt aLength,const TPoint &aPosition);
71 virtual TBool ScrollUp(const TRect& aRect);
72 virtual void Clear(const TRect& aRect);
74 virtual void SetPixel(const TPoint& aPoint,TUint8 aColour);
75 virtual TInt GetPixel(const TPoint& aPoint);
76 virtual void SetWord(const TPoint& aPoint,TInt aWord);
77 virtual TInt GetWord(const TPoint& aPoint);
78 virtual void SetLine(const TPoint& aPoint,const TPixelLine& aPixelLine);
79 virtual void GetLine(const TPoint& aPoint,TPixelLine& aPixelLine);
81 virtual void SetPaletteEntry(TColorIndex anIndex,TUint8 aRed,TUint8 aGreen,TUint8 aBlue);
82 virtual void GetPaletteEntry(TColorIndex anIndex,TUint8 &aRed,TUint8 &aGreen,TUint8 &aBlue);
83 virtual void SetForegroundColor(TColorIndex anIndex);
84 virtual void SetBackgroundColor(TColorIndex anIndex);
85 virtual void GetAttributeColors(TColorIndex* anArray);
86 virtual TInt SetMode(TVideoMode aMode);
88 TUint8* CharPosToScreenAddress(const TPoint& aCharPos);
89 TInt ColorToPixel(TInt aColorRgb);
97 TInt iScreenOffsetBetweenLines;
102 TInt iBackgroundPixel;
104 TUint32 iBackgroundFill;
107 static const TUint8 Reverse[256];
108 static const TUint8 Font[256][10];
109 friend class CScreenDriver;
114 * Table used to reverse the bits in a byte
116 * For example, index 0x03 (= 0000 0011 binary)
117 * returns 0xC0 (= 1100 0000 binary)
119 const TUint8 CScreenDriverTemplate::Reverse[256] =
121 0x00,0x80,0x40,0xC0,0x20,0xA0,0x60,0xE0,0x10,0x90,0x50,0xD0,0x30,0xB0,0x70,0xF0,
122 0x08,0x88,0x48,0xC8,0x28,0xA8,0x68,0xE8,0x18,0x98,0x58,0xD8,0x38,0xB8,0x78,0xF8,
123 0x04,0x84,0x44,0xC4,0x24,0xA4,0x64,0xE4,0x14,0x94,0x54,0xD4,0x34,0xB4,0x74,0xF4,
124 0x0C,0x8C,0x4C,0xCC,0x2C,0xAC,0x6C,0xEC,0x1C,0x9C,0x5C,0xDC,0x3C,0xBC,0x7C,0xFC,
125 0x02,0x82,0x42,0xC2,0x22,0xA2,0x62,0xE2,0x12,0x92,0x52,0xD2,0x32,0xB2,0x72,0xF2,
126 0x0A,0x8A,0x4A,0xCA,0x2A,0xAA,0x6A,0xEA,0x1A,0x9A,0x5A,0xDA,0x3A,0xBA,0x7A,0xFA,
127 0x06,0x86,0x46,0xC6,0x26,0xA6,0x66,0xE6,0x16,0x96,0x56,0xD6,0x36,0xB6,0x76,0xF6,
128 0x0E,0x8E,0x4E,0xCE,0x2E,0xAE,0x6E,0xEE,0x1E,0x9E,0x5E,0xDE,0x3E,0xBE,0x7E,0xFE,
129 0x01,0x81,0x41,0xC1,0x21,0xA1,0x61,0xE1,0x11,0x91,0x51,0xD1,0x31,0xB1,0x71,0xF1,
130 0x09,0x89,0x49,0xC9,0x29,0xA9,0x69,0xE9,0x19,0x99,0x59,0xD9,0x39,0xB9,0x79,0xF9,
131 0x05,0x85,0x45,0xC5,0x25,0xA5,0x65,0xE5,0x15,0x95,0x55,0xD5,0x35,0xB5,0x75,0xF5,
132 0x0D,0x8D,0x4D,0xCD,0x2D,0xAD,0x6D,0xED,0x1D,0x9D,0x5D,0xDD,0x3D,0xBD,0x7D,0xFD,
133 0x03,0x83,0x43,0xC3,0x23,0xA3,0x63,0xE3,0x13,0x93,0x53,0xD3,0x33,0xB3,0x73,0xF3,
134 0x0B,0x8B,0x4B,0xCB,0x2B,0xAB,0x6B,0xEB,0x1B,0x9B,0x5B,0xDB,0x3B,0xBB,0x7B,0xFB,
135 0x07,0x87,0x47,0xC7,0x27,0xA7,0x67,0xE7,0x17,0x97,0x57,0xD7,0x37,0xB7,0x77,0xF7,
136 0x0F,0x8F,0x4F,0xCF,0x2F,0xAF,0x6F,0xEF,0x1F,0x9F,0x5F,0xDF,0x3F,0xBF,0x7F,0xFF
142 * Define a font to be used
143 * This is an 8x10 Font taken from the MISA driver
147 const TInt KPixelsPerChar = 8; // character width in pixels
148 const TInt KLinesPerChar = 10; // character height in pixels
150 const TUint8 CScreenDriverTemplate::Font[256][10] =
152 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
153 {0x7E,0x81,0xA5,0x81,0xBD,0x99,0x81,0x7E,0x00,0x00},
154 {0x7E,0xFF,0xDB,0xFF,0xC3,0xE7,0xFF,0x7E,0x00,0x00},
155 {0x6C,0xFE,0xFE,0xFE,0x7C,0x38,0x10,0x00,0x00,0x00},
156 {0x10,0x38,0x7C,0xFE,0x7C,0x38,0x10,0x00,0x00,0x00},
157 {0x38,0x7C,0x38,0xFE,0xFE,0x7C,0x38,0x7C,0x00,0x00},
158 {0x10,0x10,0x38,0x7C,0xFE,0x7C,0x38,0x7C,0x00,0x00},
159 {0x00,0x00,0x18,0x3C,0x3C,0x18,0x00,0x00,0x00,0x00},
160 {0xFF,0xFF,0xE7,0xC3,0xC3,0xE7,0xFF,0xFF,0x00,0x00},
161 {0x00,0x3C,0x66,0x42,0x42,0x66,0x3C,0x00,0x00,0x00},
162 {0xFF,0xC3,0x99,0xBD,0xBD,0x99,0xC3,0xFF,0x00,0x00},
163 {0x0F,0x07,0x0F,0x7D,0xCC,0xCC,0xCC,0x78,0x00,0x00},
164 {0x3C,0x66,0x66,0x66,0x3C,0x18,0x7E,0x18,0x00,0x00},
165 {0x3F,0x33,0x3F,0x30,0x30,0x70,0xF0,0xE0,0x00,0x00},
166 {0x7F,0x63,0x7F,0x63,0x63,0x67,0xE6,0xC0,0x00,0x00},
167 {0x99,0x5A,0x3C,0xE7,0xE7,0x3C,0x5A,0x99,0x00,0x00},
169 {0x80,0xE0,0xF8,0xFE,0xF8,0xE0,0x80,0x00,0x00,0x00},
170 {0x02,0x0E,0x3E,0xFE,0x3E,0x0E,0x02,0x00,0x00,0x00},
171 {0x18,0x3C,0x7E,0x18,0x18,0x7E,0x3C,0x18,0x00,0x00},
172 {0x66,0x66,0x66,0x66,0x66,0x00,0x66,0x00,0x00,0x00},
173 {0x7F,0xDB,0xDB,0x7B,0x1B,0x1B,0x1B,0x00,0x00,0x00},
174 {0x3E,0x63,0x38,0x6C,0x6C,0x38,0xCC,0x78,0x00,0x00},
175 {0x00,0x00,0x00,0x00,0x7E,0x7E,0x7E,0x00,0x00,0x00},
176 {0x18,0x3C,0x7E,0x18,0x7E,0x3C,0x18,0xFF,0x00,0x00},
177 {0x18,0x3C,0x7E,0x18,0x18,0x18,0x18,0x00,0x00,0x00},
178 {0x18,0x18,0x18,0x18,0x7E,0x3C,0x18,0x00,0x00,0x00},
179 {0x00,0x18,0x0C,0xFE,0x0C,0x18,0x00,0x00,0x00,0x00},
180 {0x00,0x30,0x60,0xFE,0x60,0x30,0x00,0x00,0x00,0x00},
181 {0x00,0x00,0xC0,0xC0,0xC0,0xFE,0x00,0x00,0x00,0x00},
182 {0x00,0x24,0x66,0xFF,0x66,0x24,0x00,0x00,0x00,0x00},
183 {0x00,0x18,0x3C,0x7E,0xFF,0xFF,0x00,0x00,0x00,0x00},
184 {0x00,0xFF,0xFF,0x7E,0x3C,0x18,0x00,0x00,0x00,0x00},
186 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
187 {0x30,0x78,0x78,0x78,0x30,0x00,0x30,0x00,0x00,0x00}, // !
188 {0x6C,0x6C,0x6C,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
189 {0x6C,0x6C,0xFE,0x6C,0xFE,0x6C,0x6C,0x00,0x00,0x00}, //#
190 {0x30,0x7C,0xC0,0x78,0x0C,0xF8,0x30,0x00,0x00,0x00}, //$
191 {0x00,0xC6,0xCC,0x18,0x30,0x66,0xC6,0x00,0x00,0x00},
192 {0x38,0x6C,0x38,0x76,0xDC,0xCC,0x76,0x00,0x00,0x00},
193 {0x60,0x60,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
194 {0x18,0x30,0x60,0x60,0x60,0x30,0x18,0x00,0x00,0x00},
195 {0x60,0x30,0x18,0x18,0x18,0x30,0x60,0x00,0x00,0x00},
196 {0x00,0x66,0x3C,0xFF,0x3C,0x66,0x00,0x00,0x00,0x00},
197 {0x00,0x30,0x30,0xFC,0x30,0x30,0x00,0x00,0x00,0x00},
198 {0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x60,0x00,0x00},
199 {0x00,0x00,0x00,0xFC,0x00,0x00,0x00,0x00,0x00,0x00}, //-
200 {0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x00,0x00,0x00}, //.
201 {0x06,0x0C,0x18,0x30,0x60,0xC0,0x80,0x00,0x00,0x00}, ///
203 {0x7C,0xC6,0xCE,0xDE,0xF6,0xE6,0x7C,0x00,0x00,0x00}, //0
204 {0x30,0x70,0x30,0x30,0x30,0x30,0xFC,0x00,0x00,0x00},
205 {0x78,0xCC,0x0C,0x38,0x60,0xCC,0xFC,0x00,0x00,0x00},
206 {0x78,0xCC,0x0C,0x38,0x0C,0xCC,0x78,0x00,0x00,0x00},
207 {0x1C,0x3C,0x6C,0xCC,0xFE,0x0C,0x1E,0x00,0x00,0x00},
208 {0xFC,0xC0,0xF8,0x0C,0x0C,0xCC,0x78,0x00,0x00,0x00},
209 {0x38,0x60,0xC0,0xF8,0xCC,0xCC,0x78,0x00,0x00,0x00},
210 {0xFC,0xCC,0x0C,0x18,0x30,0x30,0x30,0x00,0x00,0x00},
211 {0x78,0xCC,0xCC,0x78,0xCC,0xCC,0x78,0x00,0x00,0x00},
212 {0x78,0xCC,0xCC,0x7C,0x0C,0x18,0x70,0x00,0x00,0x00}, //9
213 {0x00,0x30,0x30,0x00,0x00,0x30,0x30,0x00,0x00,0x00}, //:
214 {0x00,0x30,0x30,0x00,0x00,0x30,0x30,0x60,0x00,0x00}, //;
215 {0x18,0x30,0x60,0xC0,0x60,0x30,0x18,0x00,0x00,0x00}, //<
216 {0x00,0x00,0xFC,0x00,0x00,0xFC,0x00,0x00,0x00,0x00}, //=
217 {0x60,0x30,0x18,0x0C,0x18,0x30,0x60,0x00,0x00,0x00}, //>
218 {0x78,0xCC,0x0C,0x18,0x30,0x00,0x30,0x00,0x00,0x00}, //?
220 {0x7C,0xC6,0xDE,0xDE,0xDE,0xC0,0x78,0x00,0x00,0x00}, //@
221 {0x30,0x78,0xCC,0xCC,0xFC,0xCC,0xCC,0x00,0x00,0x00}, //A
222 {0xFC,0x66,0x66,0x7C,0x66,0x66,0xFC,0x00,0x00,0x00}, //B
223 {0x3C,0x66,0xC0,0xC0,0xC0,0x66,0x3C,0x00,0x00,0x00}, //C
224 {0xF8,0x6C,0x66,0x66,0x66,0x6C,0xF8,0x00,0x00,0x00}, //D
225 {0x7E,0x60,0x60,0x78,0x60,0x60,0x7E,0x00,0x00,0x00}, //E
226 {0x7E,0x60,0x60,0x78,0x60,0x60,0x60,0x00,0x00,0x00}, //F
227 {0x3C,0x66,0xC0,0xC0,0xCE,0x66,0x3E,0x00,0x00,0x00}, //G
228 {0xCC,0xCC,0xCC,0xFC,0xCC,0xCC,0xCC,0x00,0x00,0x00}, //H
229 {0x78,0x30,0x30,0x30,0x30,0x30,0x78,0x00,0x00,0x00}, //I
230 {0x1E,0x0C,0x0C,0x0C,0xCC,0xCC,0x78,0x00,0x00,0x00}, //J
231 {0xE6,0x66,0x6C,0x78,0x6C,0x66,0xE6,0x00,0x00,0x00}, //K
232 {0x60,0x60,0x60,0x60,0x60,0x60,0x7E,0x00,0x00,0x00}, //L
233 {0xC6,0xEE,0xFE,0xFE,0xD6,0xC6,0xC6,0x00,0x00,0x00}, //M
234 {0xC6,0xE6,0xF6,0xDE,0xCE,0xC6,0xC6,0x00,0x00,0x00}, //N
235 {0x38,0x6C,0xC6,0xC6,0xC6,0x6C,0x38,0x00,0x00,0x00}, //O
237 {0xFC,0x66,0x66,0x7C,0x60,0x60,0xF0,0x00,0x00,0x00}, //P
238 {0x78,0xCC,0xCC,0xCC,0xDC,0x78,0x1C,0x00,0x00,0x00}, //Q
239 {0xFC,0x66,0x66,0x7C,0x6C,0x66,0xE6,0x00,0x00,0x00}, //R
240 {0x78,0xCC,0xE0,0x70,0x1C,0xCC,0x78,0x00,0x00,0x00}, //S
241 {0xFC,0x30,0x30,0x30,0x30,0x30,0x30,0x00,0x00,0x00}, //T
242 {0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xFC,0x00,0x00,0x00}, //U
243 {0xCC,0xCC,0xCC,0xCC,0xCC,0x78,0x30,0x00,0x00,0x00}, //V
244 {0xC6,0xC6,0xC6,0xD6,0xFE,0xEE,0xC6,0x00,0x00,0x00}, //W
245 {0xC6,0xC6,0x6C,0x38,0x38,0x6C,0xC6,0x00,0x00,0x00}, //X
246 {0xCC,0xCC,0xCC,0x78,0x30,0x30,0x78,0x00,0x00,0x00}, //Y
247 {0xFE,0x06,0x0C,0x18,0x30,0x60,0xFE,0x00,0x00,0x00}, //Z
248 {0x78,0x60,0x60,0x60,0x60,0x60,0x78,0x00,0x00,0x00},
249 {0xC0,0x60,0x30,0x18,0x0C,0x06,0x02,0x00,0x00,0x00},
250 {0x78,0x18,0x18,0x18,0x18,0x18,0x78,0x00,0x00,0x00},
251 {0x10,0x38,0x6C,0xC6,0x00,0x00,0x00,0x00,0x00,0x00},
252 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0x00,0x00},
254 {0x30,0x30,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
255 {0x00,0x00,0x78,0x0C,0x7C,0xCC,0x76,0x00,0x00,0x00},
256 {0xE0,0x60,0x60,0x7C,0x66,0x66,0xDC,0x00,0x00,0x00},
257 {0x00,0x00,0x78,0xCC,0xC0,0xCC,0x78,0x00,0x00,0x00},
258 {0x1C,0x0C,0x0C,0x7C,0xCC,0xCC,0x76,0x00,0x00,0x00},
259 {0x00,0x00,0x78,0xCC,0xFC,0xC0,0x78,0x00,0x00,0x00},
260 {0x38,0x6C,0x60,0xF0,0x60,0x60,0xF0,0x00,0x00,0x00},
261 {0x00,0x00,0x76,0xCC,0xCC,0x7C,0x0C,0xF8,0x00,0x00},
262 {0xE0,0x60,0x6C,0x76,0x66,0x66,0xE6,0x00,0x00,0x00},
263 {0x30,0x00,0x70,0x30,0x30,0x30,0x78,0x00,0x00,0x00},
264 {0x0C,0x00,0x0C,0x0C,0x0C,0xCC,0xCC,0x78,0x00,0x00},
265 {0xE0,0x60,0x66,0x6C,0x78,0x6C,0xE6,0x00,0x00,0x00},
266 {0x70,0x30,0x30,0x30,0x30,0x30,0x78,0x00,0x00,0x00},
267 {0x00,0x00,0xCC,0xFE,0xFE,0xD6,0xC6,0x00,0x00,0x00},
268 {0x00,0x00,0xF8,0xCC,0xCC,0xCC,0xCC,0x00,0x00,0x00},
269 {0x00,0x00,0x78,0xCC,0xCC,0xCC,0x78,0x00,0x00,0x00},
271 {0x00,0x00,0xDC,0x66,0x66,0x7C,0x60,0xF0,0x00,0x00},
272 {0x00,0x00,0x76,0xCC,0xCC,0x7C,0x0C,0x1E,0x00,0x00},
273 {0x00,0x00,0xDC,0x76,0x66,0x60,0xF0,0x00,0x00,0x00},
274 {0x00,0x00,0x7C,0xC0,0x78,0x0C,0xF8,0x00,0x00,0x00},
275 {0x10,0x30,0x7C,0x30,0x30,0x34,0x18,0x00,0x00,0x00},
276 {0x00,0x00,0xCC,0xCC,0xCC,0xCC,0x76,0x00,0x00,0x00},
277 {0x00,0x00,0xCC,0xCC,0xCC,0x78,0x30,0x00,0x00,0x00},
278 {0x00,0x00,0xC6,0xD6,0xFE,0xFE,0x6C,0x00,0x00,0x00},
279 {0x00,0x00,0xC6,0x6C,0x38,0x6C,0xC6,0x00,0x00,0x00},
280 {0x00,0x00,0xCC,0xCC,0xCC,0x7C,0x0C,0xF8,0x00,0x00},
281 {0x00,0x00,0xFC,0x98,0x30,0x64,0xFC,0x00,0x00,0x00},
282 {0x1C,0x30,0x30,0xE0,0x30,0x30,0x1C,0x00,0x00,0x00},
283 {0x18,0x18,0x18,0x00,0x18,0x18,0x18,0x00,0x00,0x00},
284 {0xE0,0x30,0x30,0x1C,0x30,0x30,0xE0,0x00,0x00,0x00},
285 {0x76,0xDC,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
286 {0x00,0x10,0x38,0x6C,0xC6,0xC6,0xFE,0x00,0x00,0x00},
288 {0x3C,0x66,0x60,0x66,0x3C,0x0C,0x06,0x3C,0x00,0x00},
289 {0x00,0x66,0x00,0x66,0x66,0x66,0x3F,0x00,0x00,0x00},
290 {0x0E,0x00,0x3C,0x66,0x7E,0x60,0x3C,0x00,0x00,0x00},
291 {0x7E,0xC3,0x3C,0x06,0x3E,0x66,0x3F,0x00,0x00,0x00},
292 {0x66,0x00,0x3C,0x06,0x3E,0x66,0x3F,0x00,0x00,0x00},
293 {0x70,0x00,0x3C,0x06,0x3E,0x66,0x3F,0x00,0x00,0x00},
294 {0x18,0x18,0x3C,0x06,0x3E,0x66,0x3F,0x00,0x00,0x00},
295 {0x00,0x00,0x3C,0x60,0x60,0x3C,0x06,0x1C,0x00,0x00},
296 {0x7E,0xC3,0x3C,0x66,0x7E,0x60,0x3C,0x00,0x00,0x00},
297 {0x66,0x00,0x3C,0x66,0x7E,0x60,0x3C,0x00,0x00,0x00},
298 {0x70,0x00,0x3C,0x66,0x7E,0x60,0x3C,0x00,0x00,0x00},
299 {0x66,0x00,0x38,0x18,0x18,0x18,0x3C,0x00,0x00,0x00},
300 {0x7C,0xC6,0x38,0x18,0x18,0x18,0x3C,0x00,0x00,0x00},
301 {0x70,0x00,0x38,0x18,0x18,0x18,0x3C,0x00,0x00,0x00},
302 {0x63,0x1C,0x36,0x63,0x7F,0x63,0x63,0x00,0x00,0x00},
303 {0x18,0x18,0x00,0x3C,0x66,0x7E,0x66,0x00,0x00,0x00},
305 {0x0E,0x00,0x7E,0x30,0x3C,0x30,0x7E,0x00,0x00,0x00},
306 {0x00,0x00,0x7F,0x0C,0x7F,0xCC,0x7F,0x00,0x00,0x00},
307 {0x1F,0x36,0x66,0x7F,0x66,0x66,0x67,0x00,0x00,0x00},
308 {0x3C,0x66,0x00,0x3C,0x66,0x66,0x3C,0x00,0x00,0x00},
309 {0x00,0x66,0x00,0x3C,0x66,0x66,0x3C,0x00,0x00,0x00},
310 {0x00,0x70,0x00,0x3C,0x66,0x66,0x3C,0x00,0x00,0x00},
311 {0x3C,0x66,0x00,0x66,0x66,0x66,0x3F,0x00,0x00,0x00},
312 {0x00,0x70,0x00,0x66,0x66,0x66,0x3F,0x00,0x00,0x00},
313 {0x00,0x66,0x00,0x66,0x66,0x3E,0x06,0x7C,0x00,0x00},
314 {0xC3,0x18,0x3C,0x66,0x66,0x3C,0x18,0x00,0x00,0x00},
315 {0x66,0x00,0x66,0x66,0x66,0x66,0x3C,0x00,0x00,0x00},
316 {0x18,0x18,0x7E,0xC0,0xC0,0x7E,0x18,0x18,0x00,0x00},
317 {0x1C,0x36,0x32,0x78,0x30,0x73,0x7E,0x00,0x00,0x00}, //£
318 {0x66,0x66,0x3C,0x7E,0x18,0x7E,0x18,0x18,0x00,0x00},
319 {0xF8,0xCC,0xCC,0xFA,0xC6,0xCF,0xC6,0xC7,0x00,0x00},
320 {0x0E,0x1B,0x18,0x3C,0x18,0x18,0xD8,0x70,0x00,0x00},
322 {0x0E,0x00,0x3C,0x06,0x3E,0x66,0x3F,0x00,0x00,0x00},
323 {0x1C,0x00,0x38,0x18,0x18,0x18,0x3C,0x00,0x00,0x00},
324 {0x00,0x0E,0x00,0x3C,0x66,0x66,0x3C,0x00,0x00,0x00},
325 {0x00,0x0E,0x00,0x66,0x66,0x66,0x3F,0x00,0x00,0x00},
326 {0x00,0x7C,0x00,0x7C,0x66,0x66,0x66,0x00,0x00,0x00},
327 {0x7E,0x00,0x66,0x76,0x7E,0x6E,0x66,0x00,0x00,0x00},
328 {0x3C,0x6C,0x6C,0x3E,0x00,0x7E,0x00,0x00,0x00,0x00},
329 {0x38,0x6C,0x6C,0x38,0x00,0x7C,0x00,0x00,0x00,0x00},
330 {0x18,0x00,0x18,0x30,0x60,0x66,0x3C,0x00,0x00,0x00},
331 {0x00,0x00,0x00,0x7E,0x60,0x60,0x00,0x00,0x00,0x00},
332 {0x00,0x00,0x00,0x7E,0x06,0x06,0x00,0x00,0x00,0x00},
333 {0xC3,0xC6,0xCC,0xDE,0x33,0x66,0xCC,0x0F,0x00,0x00},
334 {0xC3,0xC6,0xCC,0xDB,0x37,0x6F,0xCF,0x03,0x00,0x00},
335 {0x18,0x18,0x00,0x18,0x18,0x18,0x18,0x00,0x00,0x00},
336 {0x00,0x33,0x66,0xCC,0x66,0x33,0x00,0x00,0x00,0x00},
337 {0x00,0xCC,0x66,0x33,0x66,0xCC,0x00,0x00,0x00,0x00},
339 {0x22,0x88,0x22,0x88,0x22,0x88,0x22,0x88,0x00,0x00},
340 {0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA},
341 {0xDB,0x77,0xDB,0xEE,0xDB,0x77,0xDB,0xEE,0xDB,0x77},
342 {0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18},
343 {0x18,0x18,0x18,0x18,0xF8,0x18,0x18,0x18,0x18,0x18},
344 {0x18,0x18,0xF8,0x18,0xF8,0x18,0x18,0x18,0x18,0x18},
345 {0x36,0x36,0x36,0x36,0xF6,0x36,0x36,0x36,0x36,0x36},
346 {0x00,0x00,0x00,0x00,0xFE,0x36,0x36,0x36,0x36,0x36},
347 {0x00,0x00,0xF8,0x18,0xF8,0x18,0x18,0x18,0x18,0x18},
348 {0x36,0x36,0xF6,0x06,0xF6,0x36,0x36,0x36,0x36,0x36},
349 {0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x36},
350 {0x00,0x00,0xFE,0x06,0xF6,0x36,0x36,0x36,0x36,0x36},
351 {0x36,0x36,0xF6,0x06,0xFE,0x00,0x00,0x00,0x00,0x00},
352 {0x36,0x36,0x36,0x36,0xFE,0x00,0x00,0x00,0x00,0x00},
353 {0x18,0x18,0xF8,0x18,0xF8,0x00,0x00,0x00,0x00,0x00},
354 {0x00,0x00,0x00,0x00,0xF8,0x18,0x18,0x18,0x18,0x18},
356 {0x18,0x18,0x18,0x18,0x1F,0x00,0x00,0x00,0x00,0x00},
357 {0x18,0x18,0x18,0x18,0xFF,0x00,0x00,0x00,0x00,0x00},
358 {0x00,0x00,0x00,0x00,0xFF,0x18,0x18,0x18,0x18,0x18},
359 {0x18,0x18,0x18,0x18,0x1F,0x18,0x18,0x18,0x18,0x18},
360 {0x00,0x00,0x00,0x00,0xFF,0x00,0x00,0x00,0x00,0x00},
361 {0x18,0x18,0x18,0x18,0xFF,0x18,0x18,0x18,0x18,0x18},
362 {0x18,0x18,0x1F,0x18,0x1F,0x18,0x18,0x18,0x18,0x18},
363 {0x36,0x36,0x36,0x36,0x37,0x36,0x36,0x36,0x36,0x36},
364 {0x36,0x36,0x37,0x30,0x3F,0x00,0x00,0x00,0x00,0x00},
365 {0x00,0x00,0x3F,0x30,0x37,0x36,0x36,0x36,0x36,0x36},
366 {0x36,0x36,0xF7,0x00,0xFF,0x00,0x00,0x00,0x00,0x00},
367 {0x00,0x00,0xFF,0x00,0xF7,0x36,0x36,0x36,0x36,0x36},
368 {0x36,0x36,0x37,0x30,0x37,0x36,0x36,0x36,0x36,0x36},
369 {0x00,0x00,0xFF,0x00,0xFF,0x00,0x00,0x00,0x00,0x00},
370 {0x36,0x36,0xF7,0x00,0xF7,0x36,0x36,0x36,0x36,0x36},
371 {0x18,0x18,0xFF,0x00,0xFF,0x00,0x00,0x00,0x00,0x00},
373 {0x36,0x36,0x36,0x36,0xFF,0x00,0x00,0x00,0x00,0x00},
374 {0x00,0x00,0xFF,0x00,0xFF,0x18,0x18,0x18,0x18,0x18},
375 {0x00,0x00,0x00,0x00,0xFF,0x36,0x36,0x36,0x36,0x36},
376 {0x36,0x36,0x36,0x36,0x3F,0x00,0x00,0x00,0x00,0x00},
377 {0x18,0x18,0x1F,0x18,0x1F,0x00,0x00,0x00,0x00,0x00},
378 {0x00,0x00,0x1F,0x18,0x1F,0x18,0x18,0x18,0x18,0x18},
379 {0x00,0x00,0x00,0x00,0x3F,0x36,0x36,0x36,0x36,0x36},
380 {0x36,0x36,0x36,0x36,0xFF,0x36,0x36,0x36,0x36,0x36},
381 {0x18,0x18,0xFF,0x18,0xFF,0x18,0x18,0x18,0x18,0x18},
382 {0x18,0x18,0x18,0x18,0xF8,0x00,0x00,0x00,0x00,0x00},
383 {0x00,0x00,0x00,0x00,0x1F,0x18,0x18,0x18,0x18,0x18},
384 {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0x00},
385 {0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0x00,0x00},
386 {0xF0,0xF0,0xF0,0xF0,0xF0,0xF0,0xF0,0xF0,0x00,0x00},
387 {0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x00,0x00},
388 {0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00},
390 {0x00,0x00,0x3B,0x6E,0x64,0x6E,0x3B,0x00,0x00,0x00},
391 {0x00,0x3C,0x66,0x7C,0x66,0x7C,0x60,0x60,0x00,0x00},
392 {0x00,0x7E,0x66,0x60,0x60,0x60,0x60,0x00,0x00,0x00},
393 {0x00,0x7F,0x36,0x36,0x36,0x36,0x36,0x00,0x00,0x00},
394 {0x7E,0x66,0x30,0x18,0x30,0x66,0x7E,0x00,0x00,0x00},
395 {0x00,0x00,0x3F,0x6C,0x6C,0x6C,0x38,0x00,0x00,0x00},
396 {0x00,0x33,0x33,0x33,0x33,0x3E,0x30,0x60,0x00,0x00},
397 {0x00,0x3B,0x6E,0x0C,0x0C,0x0C,0x0C,0x00,0x00,0x00},
398 {0x7E,0x18,0x3C,0x66,0x66,0x3C,0x18,0x7E,0x00,0x00},
399 {0x1C,0x36,0x63,0x7F,0x63,0x36,0x1C,0x00,0x00,0x00},
400 {0x1C,0x36,0x63,0x63,0x36,0x36,0x77,0x00,0x00,0x00},
401 {0x0E,0x18,0x0C,0x3E,0x66,0x66,0x3C,0x00,0x00,0x00},
402 {0x00,0x00,0x7E,0xDB,0xDB,0x7E,0x00,0x00,0x00,0x00},
403 {0x06,0x0C,0x7E,0xDB,0xDB,0x7E,0x60,0xC0,0x00,0x00},
404 {0x1C,0x60,0xC0,0xFC,0xC0,0x60,0x1C,0x00,0x00,0x00},
405 {0x3C,0x66,0x66,0x66,0x66,0x66,0x66,0x00,0x00,0x00},
407 {0x00,0x7E,0x00,0x7E,0x00,0x7E,0x00,0x00,0x00,0x00},
408 {0x18,0x18,0x7E,0x18,0x18,0x00,0x7E,0x00,0x00,0x00},
409 {0x30,0x18,0x0C,0x18,0x30,0x00,0x7E,0x00,0x00,0x00},
410 {0x0C,0x18,0x30,0x18,0x0C,0x00,0x7E,0x00,0x00,0x00},
411 {0x0E,0x1B,0x1B,0x18,0x18,0x18,0x18,0x18,0x00,0x00},
412 {0x18,0x18,0x18,0x18,0x18,0xD8,0xD8,0x70,0x00,0x00},
413 {0x18,0x18,0x00,0x7E,0x00,0x18,0x18,0x00,0x00,0x00},
414 {0x00,0x76,0xDC,0x00,0x76,0xDC,0x00,0x00,0x00,0x00},
415 {0x38,0x6C,0x6C,0x38,0x00,0x00,0x00,0x00,0x00,0x00},
416 {0x00,0x00,0x00,0x18,0x18,0x00,0x00,0x00,0x00,0x00},
417 {0x00,0x00,0x00,0x00,0x18,0x00,0x00,0x00,0x00,0x00},
418 {0x0F,0x0C,0x0C,0x0C,0xEC,0x6C,0x3C,0x1C,0x00,0x00},
419 {0x78,0x6C,0x6C,0x6C,0x6C,0x00,0x00,0x00,0x00,0x00},
420 {0x70,0x18,0x30,0x60,0x78,0x00,0x00,0x00,0x00,0x00},
421 {0x00,0x00,0x3C,0x3C,0x3C,0x3C,0x00,0x00,0x00,0x00},
422 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}
428 * A copy of the standard 256 color palette used by the SymbianOS.
429 * Each value is in the format 00000000bbbbbbbbggggggggrrrrrrrr
431 const TUint32 Palette256[256] =
433 0x00000000, 0x00000033, 0x00000066, 0x00000099, 0x000000cc, 0x000000ff,
434 0x00003300, 0x00003333, 0x00003366, 0x00003399, 0x000033cc, 0x000033ff,
435 0x00006600, 0x00006633, 0x00006666, 0x00006699, 0x000066cc, 0x000066ff,
436 0x00009900, 0x00009933, 0x00009966, 0x00009999, 0x000099cc, 0x000099ff,
437 0x0000cc00, 0x0000cc33, 0x0000cc66, 0x0000cc99, 0x0000cccc, 0x0000ccff,
438 0x0000ff00, 0x0000ff33, 0x0000ff66, 0x0000ff99, 0x0000ffcc, 0x0000ffff,
440 0x00330000, 0x00330033, 0x00330066, 0x00330099, 0x003300cc, 0x003300ff,
441 0x00333300, 0x00333333, 0x00333366, 0x00333399, 0x003333cc, 0x003333ff,
442 0x00336600, 0x00336633, 0x00336666, 0x00336699, 0x003366cc, 0x003366ff,
443 0x00339900, 0x00339933, 0x00339966, 0x00339999, 0x003399cc, 0x003399ff,
444 0x0033cc00, 0x0033cc33, 0x0033cc66, 0x0033cc99, 0x0033cccc, 0x0033ccff,
445 0x0033ff00, 0x0033ff33, 0x0033ff66, 0x0033ff99, 0x0033ffcc, 0x0033ffff,
447 0x00660000, 0x00660033, 0x00660066, 0x00660099, 0x006600cc, 0x006600ff,
448 0x00663300, 0x00663333, 0x00663366, 0x00663399, 0x006633cc, 0x006633ff,
449 0x00666600, 0x00666633, 0x00666666, 0x00666699, 0x006666cc, 0x006666ff,
450 0x00669900, 0x00669933, 0x00669966, 0x00669999, 0x006699cc, 0x006699ff,
451 0x0066cc00, 0x0066cc33, 0x0066cc66, 0x0066cc99, 0x0066cccc, 0x0066ccff,
452 0x0066ff00, 0x0066ff33, 0x0066ff66, 0x0066ff99, 0x0066ffcc, 0x0066ffff,
454 0x00111111, 0x00222222, 0x00444444, 0x00555555, 0x00777777,
455 0x00000011, 0x00000022, 0x00000044, 0x00000055, 0x00000077,
456 0x00001100, 0x00002200, 0x00004400, 0x00005500, 0x00007700,
457 0x00110000, 0x00220000, 0x00440000, 0x00550000, 0x00770000,
459 0x00880000, 0x00aa0000, 0x00bb0000, 0x00dd0000, 0x00ee0000,
460 0x00008800, 0x0000aa00, 0x0000bb00, 0x0000dd00, 0x0000ee00,
461 0x00000088, 0x000000aa, 0x000000bb, 0x000000dd, 0x000000ee,
462 0x00888888, 0x00aaaaaa, 0x00bbbbbb, 0x00dddddd, 0x00eeeeee,
464 0x00990000, 0x00990033, 0x00990066, 0x00990099, 0x009900cc, 0x009900ff,
465 0x00993300, 0x00993333, 0x00993366, 0x00993399, 0x009933cc, 0x009933ff,
466 0x00996600, 0x00996633, 0x00996666, 0x00996699, 0x009966cc, 0x009966ff,
467 0x00999900, 0x00999933, 0x00999966, 0x00999999, 0x009999cc, 0x009999ff,
468 0x0099cc00, 0x0099cc33, 0x0099cc66, 0x0099cc99, 0x0099cccc, 0x0099ccff,
469 0x0099ff00, 0x0099ff33, 0x0099ff66, 0x0099ff99, 0x0099ffcc, 0x0099ffff,
471 0x00cc0000, 0x00cc0033, 0x00cc0066, 0x00cc0099, 0x00cc00cc, 0x00cc00ff,
472 0x00cc3300, 0x00cc3333, 0x00cc3366, 0x00cc3399, 0x00cc33cc, 0x00cc33ff,
473 0x00cc6600, 0x00cc6633, 0x00cc6666, 0x00cc6699, 0x00cc66cc, 0x00cc66ff,
474 0x00cc9900, 0x00cc9933, 0x00cc9966, 0x00cc9999, 0x00cc99cc, 0x00cc99ff,
475 0x00cccc00, 0x00cccc33, 0x00cccc66, 0x00cccc99, 0x00cccccc, 0x00ccccff,
476 0x00ccff00, 0x00ccff33, 0x00ccff66, 0x00ccff99, 0x00ccffcc, 0x00ccffff,
478 0x00ff0000, 0x00ff0033, 0x00ff0066, 0x00ff0099, 0x00ff00cc, 0x00ff00ff,
479 0x00ff3300, 0x00ff3333, 0x00ff3366, 0x00ff3399, 0x00ff33cc, 0x00ff33ff,
480 0x00ff6600, 0x00ff6633, 0x00ff6666, 0x00ff6699, 0x00ff66cc, 0x00ff66ff,
481 0x00ff9900, 0x00ff9933, 0x00ff9966, 0x00ff9999, 0x00ff99cc, 0x00ff99ff,
482 0x00ffcc00, 0x00ffcc33, 0x00ffcc66, 0x00ffcc99, 0x00ffcccc, 0x00ffccff,
483 0x00ffff00, 0x00ffff33, 0x00ffff66, 0x00ffff99, 0x00ffffcc, 0x00ffffff
487 * Construct and return the new screen driver
489 EXPORT_C CScreenDriver* CScreenDriver::New()
491 __DEBUG_PRINT(_L("CSD::New"));
495 HAL::Get(HAL::EDisplayMode, mode);
497 return NewScreenDriverVgaText();
499 CScreenDriverTemplate *pS=new CScreenDriverTemplate;
500 if (pS->iScreenAddress)
511 * Implementation of the screen driver
515 CScreenDriverTemplate::CScreenDriverTemplate()
518 __DEBUG_PRINT(_L("CSD::Ctor"));
521 // Start in default mode the display driver is in
524 TInt r = HAL::Get(HAL::EDisplayMode, iDisplayMode);
527 __DEBUG_PRINT2(_L("EDisplayMode %d"), iDisplayMode);
529 iBitsPerPixel = iDisplayMode; //getbpp needs the current mode as its param
530 r = HAL::Get(HAL::EDisplayBitsPerPixel,iBitsPerPixel);
533 __DEBUG_PRINT2(_L("EDisplayBitsPerPixel %d"), iBitsPerPixel);
535 iIsPalettized = iDisplayMode; //ispalettized needs the current mode as its param
536 r = HAL::Get(HAL::EDisplayIsPalettized,iIsPalettized);
539 __DEBUG_PRINT2(_L("EDisplayIsPalettized %d"),iIsPalettized);
541 iIsMono = iDisplayMode; //ispalettized needs the current mode as its param
542 r = HAL::Get(HAL::EDisplayIsMono, iIsMono);
545 __DEBUG_PRINT2(_L("EDisplayIsMono %d"), iIsMono);
550 __DEBUG_PRINT2(_L("iMode is %d"),iMode);
552 // Obtain the screen info from HAL
554 r = HAL::Get(HAL::EDisplayMemoryAddress,iScreenAddress);
557 __DEBUG_PRINT2(_L("EDisplayMemoryAddress 0x%x"), iScreenAddress);
559 offset = iDisplayMode;
560 r = HAL::Get(HAL::EDisplayOffsetToFirstPixel,offset);
563 __DEBUG_PRINT2(_L("EDisplayOffsetToFirstPixel %d"),offset);
564 iScreenAddress += offset;
566 iScreenOffsetBetweenLines = iDisplayMode;
567 r = HAL::Get(HAL::EDisplayOffsetBetweenLines,iScreenOffsetBetweenLines);
570 __DEBUG_PRINT2(_L("EDisplayOffsetBetweenLines %d"), iScreenOffsetBetweenLines);
572 r = HAL::Get(HAL::EDisplayXPixels,iScreenWidth);
575 __DEBUG_PRINT2(_L("EDisplayXPixels %d"),iScreenWidth);
577 r = HAL::Get(HAL::EDisplayYPixels,iScreenHeight);
580 __DEBUG_PRINT2(_L("EDisplayYPixels %d"), iScreenHeight);
584 // Setup palette (this is the standard SymbianOS 256 colour palette)
585 for(TInt i=0; i<256; i++)
587 TInt entry = Palette256[i]+(i<<24);
588 HAL::Set(HAL::EDisplayPaletteEntry,entry); // Ignore error
590 __DEBUG_PRINT(_L("EColor256"));
592 else if(iMode==EGray16)
595 for(TInt i=0; i<16; i++)
597 TInt entry = i|(i<<4);
600 HAL::Set(HAL::EDisplayPaletteEntry,entry); // Ignore error
602 __DEBUG_PRINT(_L("EGray16"));
604 else if(iMode==EGray4)
607 for(TInt i=0; i<4; i++)
609 TInt entry = i|(i<<2);
613 HAL::Set(HAL::EDisplayPaletteEntry,entry); // Ignore error
615 __DEBUG_PRINT(_L("EGray4"));
617 else if(iMode==EMono)
621 HAL::Set(HAL::EDisplayPaletteEntry,entry); // Ignore error
623 HAL::Set(HAL::EDisplayPaletteEntry,entry); // Ignore error
624 __DEBUG_PRINT(_L("EMono"));
628 __DEBUG_PRINT(_L("unknown mode"));
633 // Initialise values used for drawing
635 if(iBitsPerPixel==12)
638 iPixelSize = iBitsPerPixel;
641 TInt KBackgroundColor = 0xff0000; // color in format 0xbbggrr
642 TInt KTextColor = 0xffffff; // color in format 0xbbggrr
644 if (( iBitsPerPixel == 24 ) || ( iBitsPerPixel == 32 ) )
647 // KTextColor = 0x00FFFF;//Text color yellow when 24ubpp
652 KBackgroundColor = 0xffffff; // color in format 0xbbggrr
653 KTextColor = 0x000000; // color in format 0xbbggrr
656 iBackgroundPixel = ColorToPixel(KBackgroundColor);
657 iBackgroundFill = iBackgroundPixel;
659 TInt shift = iPixelSize;
662 iBackgroundFill |= iBackgroundFill<<shift;
667 iTextPixel = ColorToPixel(KTextColor);
668 iTextFill = iTextPixel;
670 TInt shift = iPixelSize;
673 iTextFill |= iTextFill<<shift;
680 Mem::FillZ(&roi, sizeof(roi));
681 if (HwBlockFill(roi)==KErrNone)
682 iHwAcc |= KHwAccBlockFill;
683 if (HwBlockCopy(roi)==KErrNone)
684 iHwAcc |= KHwAccBlockCopy;
689 __DEBUG_PRINT(_L("CSD::Ctor done"));
694 iScreenAddress = NULL;
695 __DEBUG_PRINT2(_L("CSD::Ctor failed r=%d"),r);
699 void CScreenDriverTemplate::Init(TSize &aScreenSize,TSize &aFontSize)
701 // Initialise the screen driver and report screen information
705 __DEBUG_PRINT(_L("CSD::Init"));
707 aFontSize=TSize(KPixelsPerChar,KLinesPerChar);
708 aScreenSize.iWidth=iScreenWidth/KPixelsPerChar;
709 aScreenSize.iHeight=iScreenHeight/KLinesPerChar;
715 TInt CScreenDriverTemplate::SetMode(TVideoMode aMode)
720 * If you support multiple video modes then implement video mode switching
721 * here. After the mode switch the screen contents should appear as before.
722 * The current mode should be stored in iMode, and other member data updated
723 * as appropriate. I.e. iScreenAddress, iScreenWidth, iScreenHeight,
724 * iScreenOffsetBetweenLines, iBitsPerPixel and iPixelSize (See ctor code.)
727 __DEBUG_PRINT(_L("CSD::SetMode"));
728 return(aMode==iMode ? KErrNone : KErrNotSupported);
732 TUint8* CScreenDriverTemplate::CharPosToScreenAddress(const TPoint& aCharPos)
734 // Returns the screen address for the given character position
737 return (TUint8*)iScreenAddress +
738 aCharPos.iY * iScreenOffsetBetweenLines * KLinesPerChar +
739 ((aCharPos.iX * KPixelsPerChar * iPixelSize) >> 3);
742 void CScreenDriverTemplate::CalcColorMode()
745 //calculate the color mode
750 if (1 == iBitsPerPixel)
752 else if (2 == iBitsPerPixel)
754 else if (4 == iBitsPerPixel)
759 if (8 == iBitsPerPixel)
761 else if (4 == iBitsPerPixel)
762 iMode = EGray16; //we are color but color16 is not supported
769 if (12 == iBitsPerPixel)
771 else if (16 == iBitsPerPixel)
773 else if (24 == iBitsPerPixel)
775 else if (32 == iBitsPerPixel)
782 TInt CScreenDriverTemplate::ColorToPixel(TInt aColorRgb)
784 // Returns the pixel value which is closest to the given RGB value
787 TInt r = aColorRgb&0xFF;
788 TInt g = (aColorRgb>>8)&0xFF;
789 TInt b = (aColorRgb>>16)&0xFF;
794 return (r<<16)+(g<<8)+b;
797 return ((r>>3)<<11)+((g>>2)<<5)+(b>>3);
800 return ((r>>4)<<8)+((g>>4)<<4)+(b>>4);
805 TInt bestDif = KMaxTInt;
806 for(TInt i=0; i<256; i++)
808 TInt value = Palette256[i];
809 TInt dr = (value&0xFF)-r;
810 TInt dg = ((value>>8)&0xFF)-g;
811 TInt db = ((value>>16)&0xFF)-b;
812 TInt dif = dr*dr + dg*dg + db*db;
823 return (r*2+g*4+b)>>7;
826 return (r*2+g*4+b)>>9;
829 return (r*2+g*4+b)>>10;
836 void CScreenDriverTemplate::Blit(const TText *aBuffer, TInt aLength, const TPoint &aPosition)
838 // Write contiguous block of characters to some segment of a line on the display
844 // The start of each character on the display is byte aligned.
845 // i.e. KPixelsPerChar*iPixelSize%8 == 0
847 // Clip text to screen width
848 if(aLength+aPosition.iX > iScreenWidth/KPixelsPerChar)
849 aLength = iScreenWidth/KPixelsPerChar-aPosition.iX;
851 TUint8* screenPtr = CharPosToScreenAddress(aPosition);
852 TInt lineAddon = iScreenOffsetBetweenLines-((iPixelSize*KPixelsPerChar)>>3);
853 TInt bgPixel = iBackgroundPixel;
854 TInt textPixel = iTextPixel;
858 TUint8* pixelPtr = screenPtr;
859 screenPtr += (iPixelSize*KPixelsPerChar)>>3;
860 TInt character = (*aBuffer++)&0xff;
867 for(y=0; y<KLinesPerChar; y++)
869 TInt bitData = Font[character][y];
870 TInt bitMask = 1<<(KPixelsPerChar-1);
875 if(bitData & bitMask)
876 byte |= textPixel<<pixelShift;
878 byte |= bgPixel<<pixelShift;
883 *pixelPtr++ = (TUint8)byte;
890 pixelPtr += lineAddon;
895 for(y=0; y<KLinesPerChar; y++)
897 TInt bitData = Font[character][y];
898 TInt bitMask = 1<<(KPixelsPerChar-1);
902 if(bitData & bitMask)
908 if(bitData & bitMask)
909 byte |= textPixel<<2;
914 if(bitData & bitMask)
915 byte |= textPixel<<4;
920 if(bitData & bitMask)
921 byte |= textPixel<<6;
924 *pixelPtr++ = (TUint8)byte;
928 pixelPtr += lineAddon;
933 for(y=0; y<KLinesPerChar; y++)
935 TInt bitData = Font[character][y];
936 TInt bitMask = 1<<(KPixelsPerChar-1);
940 if(bitData & bitMask)
946 if(bitData & bitMask)
947 byte |= textPixel<<4;
950 *pixelPtr++ = (TUint8)byte;
954 pixelPtr += lineAddon;
959 for(y=0; y<KLinesPerChar; y++)
961 TInt bitData = Font[character][y];
962 TInt bitMask = 1<<(KPixelsPerChar-1);
965 if(bitData & bitMask)
966 *pixelPtr++ = (TUint8)textPixel;
968 *pixelPtr++ = (TUint8)bgPixel;
972 pixelPtr += lineAddon;
977 for(y=0; y<KLinesPerChar; y++)
979 TInt bitData = Font[character][y];
980 TInt bitMask = 1<<(KPixelsPerChar-1);
983 if(bitData & bitMask)
985 *pixelPtr++ = (TUint8)textPixel;
986 *pixelPtr++ = (TUint8)(textPixel>>8);
990 *pixelPtr++ = (TUint8)bgPixel;
991 *pixelPtr++ = (TUint8)(bgPixel>>8);
996 pixelPtr += lineAddon;
1001 for(y=0; y<KLinesPerChar; y++)
1003 TInt bitData = Font[character][y];
1004 TInt bitMask = 1<<(KPixelsPerChar-1);
1007 if(bitData & bitMask)
1009 *pixelPtr++ = (TUint8)textPixel;
1010 *pixelPtr++ = (TUint8)(textPixel>>8);
1011 *pixelPtr++ = (TUint8)(textPixel>>16);
1015 *pixelPtr++ = (TUint8)bgPixel;
1016 *pixelPtr++ = (TUint8)(bgPixel>>8);
1017 *pixelPtr++ = (TUint8)(bgPixel>>16);
1022 pixelPtr += lineAddon;
1027 for(y=0; y<KLinesPerChar; y++)
1029 TInt bitData = Font[character][y];
1030 TInt bitMask = 1<<(KPixelsPerChar-1);
1033 if(bitData & bitMask)
1035 *pixelPtr++ = (TUint8)textPixel;//Blue
1036 *pixelPtr++ = (TUint8)(textPixel>>8);//Green
1037 *pixelPtr++ = (TUint8)(textPixel>>16);//Red
1042 *pixelPtr++ = (TUint8)bgPixel;//Blue
1043 *pixelPtr++ = (TUint8)(bgPixel>>8);//Green
1044 *pixelPtr++ = (TUint8)(bgPixel>>16);//Red
1050 pixelPtr += lineAddon;
1059 TBool CScreenDriverTemplate::ScrollUp(const TRect& aRect)
1061 // Scroll a rectangle of the screen up one character, don't update bottom line
1064 __DEBUG_PRINT(_L("CSD::ScrollUp"));
1066 if (iHwAcc & KHwAccBlockCopy)
1069 roi.iX = KPixelsPerChar*aRect.iTl.iX;
1070 roi.iY = KLinesPerChar*aRect.iTl.iY;
1071 roi.iWidth = aRect.Width()*KPixelsPerChar;
1072 roi.iHeight = (aRect.Height()-1) * KLinesPerChar;
1074 roi.iSrcY = roi.iY + KLinesPerChar;
1078 TUint8* dstAddress = CharPosToScreenAddress(aRect.iTl);
1079 TUint8* srcAddress = dstAddress + iScreenOffsetBetweenLines * KLinesPerChar;
1080 TInt lines = (aRect.Height()-1) * KLinesPerChar;
1081 TInt bytesPerLine = (aRect.Width() * KPixelsPerChar * iPixelSize)>>3;
1085 Mem::Copy(dstAddress,srcAddress,bytesPerLine);
1086 srcAddress += iScreenOffsetBetweenLines;
1087 dstAddress += iScreenOffsetBetweenLines;
1095 void CScreenDriverTemplate::Clear(const TRect& aRect)
1097 // Clears a rectangular region with the background colour
1100 __DEBUG_PRINT(_L("CSD::Clear"));
1102 if (iHwAcc & KHwAccBlockFill)
1105 roi.iX = KPixelsPerChar*aRect.iTl.iX;
1106 roi.iY = KLinesPerChar*aRect.iTl.iY;
1107 roi.iWidth = aRect.Width()*KPixelsPerChar;
1108 roi.iHeight = aRect.Height() * KLinesPerChar;
1111 roi.iColor = iBackgroundFill;
1116 TUint8* dstAddress = CharPosToScreenAddress(aRect.iTl);
1117 TInt lines = aRect.Height() * KLinesPerChar;
1118 TInt bytesPerLine = (aRect.Width() * KPixelsPerChar * iPixelSize)>>3;
1125 TUint32 fillValue = iBackgroundFill;
1126 TUint8* ptr = dstAddress;
1127 TUint8* ptrLimit = ptr+bytesPerLine;
1130 *ptr++ = (TUint8)fillValue;//Blue
1131 *ptr++ = (TUint8)(fillValue<<8);//Green
1132 *ptr++ = (TUint8)(fillValue<<16);//Red
1135 dstAddress += iScreenOffsetBetweenLines;
1143 TUint32 fillValue = iBackgroundFill;
1144 TUint8* ptr = dstAddress;
1145 TUint8* ptrLimit = ptr+bytesPerLine;
1148 *ptr++ = (TUint8)fillValue;
1149 *ptr++ = (TUint8)(fillValue<<8);
1150 *ptr++ = (TUint8)(fillValue<<16);
1152 dstAddress += iScreenOffsetBetweenLines;
1160 TUint32 fillValue = iBackgroundFill;
1161 TUint8* ptr = dstAddress;
1162 TUint8* ptrLimit = ptr+bytesPerLine;
1165 *ptr++ = (TUint8)fillValue;
1166 *ptr++ = (TUint8)(fillValue<<8);
1168 dstAddress += iScreenOffsetBetweenLines;
1176 Mem::Fill(dstAddress,bytesPerLine,iBackgroundFill);
1177 dstAddress += iScreenOffsetBetweenLines;
1187 * You don't need to implement this function.
1189 void CScreenDriverTemplate::SetPixel(const TPoint& /*aPoint*/,TUint8 /*aColour*/)
1191 __DEBUG_PRINT(_L("CSD::SetPix"));
1196 * You don't need to implement this function.
1198 TInt CScreenDriverTemplate::GetPixel(const TPoint& /*aPoint*/)
1200 __DEBUG_PRINT(_L("CSD::GetPix"));
1206 * You don't need to implement this function.
1208 void CScreenDriverTemplate::SetWord(const TPoint& /*aPoint*/,TInt /*aWord*/)
1210 __DEBUG_PRINT(_L("CSD::SetWord"));
1215 * You don't need to implement this function.
1217 TInt CScreenDriverTemplate::GetWord(const TPoint& /*aPoint*/)
1219 __DEBUG_PRINT(_L("CSD::GetWord"));
1224 // You don't need to implement the following functions
1227 * You don't need to implement this function.
1229 void CScreenDriverTemplate::SetLine(const TPoint& /*aPoint*/,const TPixelLine& /*aPixelLine*/)
1231 __DEBUG_PRINT(_L("CSD::SetLine"));
1236 * You don't need to implement this function.
1238 void CScreenDriverTemplate::GetLine(const TPoint& /*aPoint*/,TPixelLine& /*aPixelLine*/)
1240 __DEBUG_PRINT(_L("CSD::GetLine"));
1245 * You don't need to implement this function.
1247 void CScreenDriverTemplate::SetPaletteEntry(TColorIndex /*anIndex*/,TUint8 /*aRed*/,TUint8 /*aGreen*/,TUint8 /*aBlue*/)
1253 * You don't need to implement this function.
1255 void CScreenDriverTemplate::GetPaletteEntry(TColorIndex /*anIndex*/,TUint8& /*aRed*/,TUint8& /*aGreen*/,TUint8& /*aBlue*/)
1261 * You don't need to implement this function.
1263 void CScreenDriverTemplate::SetForegroundColor(TColorIndex /*anIndex*/)
1269 * You don't need to implement this function.
1271 void CScreenDriverTemplate::SetBackgroundColor(TColorIndex /*anIndex*/)
1277 * You don't need to implement this function.
1279 void CScreenDriverTemplate::GetAttributeColors(TColorIndex* /*anArray*/)