sl@0
|
1 |
// Copyright (c) 1996-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 |
// bootldr\src\display\display.cpp
|
sl@0
|
15 |
//
|
sl@0
|
16 |
//
|
sl@0
|
17 |
|
sl@0
|
18 |
#define FILE_ID 0x44495350
|
sl@0
|
19 |
#define DEFINE_COLOURS
|
sl@0
|
20 |
|
sl@0
|
21 |
//
|
sl@0
|
22 |
// Defining ENABLE_TRANSFER_STATS will display simplistic average and point
|
sl@0
|
23 |
// transfer rates in bytes per second and provide an estimate of the length of
|
sl@0
|
24 |
// time remaining.
|
sl@0
|
25 |
//
|
sl@0
|
26 |
#define ENABLE_TRANSFER_STATS
|
sl@0
|
27 |
|
sl@0
|
28 |
#include "bootldr.h"
|
sl@0
|
29 |
#include <videodriver.h>
|
sl@0
|
30 |
#include <hal.h>
|
sl@0
|
31 |
|
sl@0
|
32 |
TUint8* Screen;
|
sl@0
|
33 |
TInt Screenwidth, Screenheight; // screen dimentions in pixels
|
sl@0
|
34 |
TInt XPos;
|
sl@0
|
35 |
TInt YPos;
|
sl@0
|
36 |
TUint Colours;
|
sl@0
|
37 |
TUint PixelSize = 1; // size of a pixel in bytes
|
sl@0
|
38 |
|
sl@0
|
39 |
TUint Progress[2];
|
sl@0
|
40 |
TUint Pixels[2];
|
sl@0
|
41 |
TUint Limit[2];
|
sl@0
|
42 |
TUint32 ProgressTime[2];
|
sl@0
|
43 |
TUint32 StartTime;
|
sl@0
|
44 |
|
sl@0
|
45 |
// Palette entries are in the platform's config.h
|
sl@0
|
46 |
const TUint16 Palette[16]= {
|
sl@0
|
47 |
KPaletteEntBlack | KPaletteEntPBS,
|
sl@0
|
48 |
KPaletteEntMidBlue, // 1
|
sl@0
|
49 |
KPaletteEntMidGreen, // 2
|
sl@0
|
50 |
KPaletteEntMidCyan, // 3
|
sl@0
|
51 |
KPaletteEntMidRed, // 4
|
sl@0
|
52 |
KPaletteEntMidMagenta, // 5
|
sl@0
|
53 |
KPaletteEntMidYellow, // 6
|
sl@0
|
54 |
KPaletteEntDimWhite, // 7
|
sl@0
|
55 |
KPaletteEntGray, // 8
|
sl@0
|
56 |
KPaletteEntBlue, // 9
|
sl@0
|
57 |
KPaletteEntGreen, // 10 A
|
sl@0
|
58 |
KPaletteEntCyan, // 11 B
|
sl@0
|
59 |
KPaletteEntRed, // 12 C
|
sl@0
|
60 |
KPaletteEntMagenta, // 13 D
|
sl@0
|
61 |
KPaletteEntYellow, // 14 E
|
sl@0
|
62 |
KPaletteEntWhite // 15 F
|
sl@0
|
63 |
};
|
sl@0
|
64 |
|
sl@0
|
65 |
const TUint KRgbBlack = 0x000000;
|
sl@0
|
66 |
//const TUint KRgbDarkGray = 0x555555;
|
sl@0
|
67 |
const TUint KRgbDarkRed = 0x800000;
|
sl@0
|
68 |
const TUint KRgbDarkGreen = 0x008000;
|
sl@0
|
69 |
const TUint KRgbDarkYellow = 0x808000;
|
sl@0
|
70 |
const TUint KRgbDarkBlue = 0x000080;
|
sl@0
|
71 |
const TUint KRgbDarkMagenta = 0x800080;
|
sl@0
|
72 |
const TUint KRgbDarkCyan = 0x008080;
|
sl@0
|
73 |
const TUint KRgbRed = 0xFF0000;
|
sl@0
|
74 |
//const TUint KRgbGreen = 0x00FF00;
|
sl@0
|
75 |
const TUint KRgbYellow = 0xFFFF00;
|
sl@0
|
76 |
const TUint KRgbBlue = 0x0000FF;
|
sl@0
|
77 |
const TUint KRgbMagenta = 0xFF00FF;
|
sl@0
|
78 |
const TUint KRgbCyan = 0x00FFFF;
|
sl@0
|
79 |
const TUint KRgbGray = 0xAAAAAA;
|
sl@0
|
80 |
const TUint KRgbWhite = 0xFFFFFF;
|
sl@0
|
81 |
|
sl@0
|
82 |
const TUint KRgbDimWhite = 0xCCCCCC;
|
sl@0
|
83 |
|
sl@0
|
84 |
const TUint32 Palette32[16] =
|
sl@0
|
85 |
{
|
sl@0
|
86 |
KRgbBlack, // 0
|
sl@0
|
87 |
KRgbDarkBlue, // 1
|
sl@0
|
88 |
KRgbDarkGreen, // 2
|
sl@0
|
89 |
KRgbDarkCyan, // 3
|
sl@0
|
90 |
KRgbDarkRed, // 4
|
sl@0
|
91 |
KRgbDarkMagenta, // 5
|
sl@0
|
92 |
KRgbDarkYellow, // 6
|
sl@0
|
93 |
KRgbDimWhite, // 7 KRgbDarkGray()
|
sl@0
|
94 |
KRgbGray, // 8
|
sl@0
|
95 |
KRgbBlue, // 9
|
sl@0
|
96 |
KRgbDarkGreen, // 10
|
sl@0
|
97 |
KRgbCyan, // 11
|
sl@0
|
98 |
KRgbRed, // 12
|
sl@0
|
99 |
KRgbMagenta, // 13
|
sl@0
|
100 |
KRgbYellow, // 14
|
sl@0
|
101 |
KRgbWhite // 15
|
sl@0
|
102 |
};
|
sl@0
|
103 |
|
sl@0
|
104 |
// KForeground, Kbackground and [I]Pcolour entries are indexes into the palette.
|
sl@0
|
105 |
// The progress bar colours are of the form "(foreground << 8) | background"
|
sl@0
|
106 |
const TUint8 KForeground = 15;
|
sl@0
|
107 |
const TUint8 KBackground = 9;
|
sl@0
|
108 |
const TUint PColour[2]={ 0xa08, 0xc08 }; // (10|8) and (12|8)
|
sl@0
|
109 |
const TUint IPColour[2]={ 0x809, 0x809 }; // (8|9) and (8|9)
|
sl@0
|
110 |
|
sl@0
|
111 |
#define NUM_FONTS 96
|
sl@0
|
112 |
#define FONT_HEIGHT 10
|
sl@0
|
113 |
#define FONT_WIDTH 8
|
sl@0
|
114 |
|
sl@0
|
115 |
#define SCREEN_SIZE (Screenheight*Screenwidth*PixelSize) // number of pixels (size in bytes)
|
sl@0
|
116 |
|
sl@0
|
117 |
#define MAX_COLUMN (Screenwidth/FONT_WIDTH) // chars per line e.g. 80 or 40
|
sl@0
|
118 |
#define MAX_ROW (Screenheight/FONT_HEIGHT) // lines per screen e.g. 48 or 24
|
sl@0
|
119 |
#define PROGRESSBAR0_ROW (MAX_ROW-1) // row in which to draw progress bar 0
|
sl@0
|
120 |
#define PROGRESSBAR1_ROW (MAX_ROW-2) // row in which to draw progress bar 1
|
sl@0
|
121 |
#define STATS_ROW (MAX_ROW-3) // DEBUGGING row in which to write eta/bps
|
sl@0
|
122 |
//
|
sl@0
|
123 |
// ascii character code - 32 == character index into bootldr table
|
sl@0
|
124 |
//
|
sl@0
|
125 |
extern const TUint8 Font[NUM_FONTS][FONT_HEIGHT] =
|
sl@0
|
126 |
{
|
sl@0
|
127 |
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
|
sl@0
|
128 |
{0x30,0x78,0x78,0x78,0x30,0x00,0x30,0x00,0x00,0x00}, //!
|
sl@0
|
129 |
{0x6C,0x6C,0x6C,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
|
sl@0
|
130 |
{0x6C,0x6C,0xFE,0x6C,0xFE,0x6C,0x6C,0x00,0x00,0x00}, //#
|
sl@0
|
131 |
{0x30,0x7C,0xC0,0x78,0x0C,0xF8,0x30,0x00,0x00,0x00}, //$
|
sl@0
|
132 |
{0x00,0xC6,0xCC,0x18,0x30,0x66,0xC6,0x00,0x00,0x00},
|
sl@0
|
133 |
{0x38,0x6C,0x38,0x76,0xDC,0xCC,0x76,0x00,0x00,0x00},
|
sl@0
|
134 |
{0x60,0x60,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
|
sl@0
|
135 |
{0x18,0x30,0x60,0x60,0x60,0x30,0x18,0x00,0x00,0x00},
|
sl@0
|
136 |
{0x60,0x30,0x18,0x18,0x18,0x30,0x60,0x00,0x00,0x00},
|
sl@0
|
137 |
{0x00,0x66,0x3C,0xFF,0x3C,0x66,0x00,0x00,0x00,0x00},
|
sl@0
|
138 |
{0x00,0x30,0x30,0xFC,0x30,0x30,0x00,0x00,0x00,0x00},
|
sl@0
|
139 |
{0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x60,0x00,0x00},
|
sl@0
|
140 |
{0x00,0x00,0x00,0xFC,0x00,0x00,0x00,0x00,0x00,0x00}, //-
|
sl@0
|
141 |
{0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x00,0x00,0x00}, //.
|
sl@0
|
142 |
{0x06,0x0C,0x18,0x30,0x60,0xC0,0x80,0x00,0x00,0x00}, ///
|
sl@0
|
143 |
|
sl@0
|
144 |
{0x7C,0xC6,0xCE,0xDE,0xF6,0xE6,0x7C,0x00,0x00,0x00}, //0
|
sl@0
|
145 |
{0x30,0x70,0x30,0x30,0x30,0x30,0xFC,0x00,0x00,0x00},
|
sl@0
|
146 |
{0x78,0xCC,0x0C,0x38,0x60,0xCC,0xFC,0x00,0x00,0x00},
|
sl@0
|
147 |
{0x78,0xCC,0x0C,0x38,0x0C,0xCC,0x78,0x00,0x00,0x00},
|
sl@0
|
148 |
{0x1C,0x3C,0x6C,0xCC,0xFE,0x0C,0x1E,0x00,0x00,0x00},
|
sl@0
|
149 |
{0xFC,0xC0,0xF8,0x0C,0x0C,0xCC,0x78,0x00,0x00,0x00},
|
sl@0
|
150 |
{0x38,0x60,0xC0,0xF8,0xCC,0xCC,0x78,0x00,0x00,0x00},
|
sl@0
|
151 |
{0xFC,0xCC,0x0C,0x18,0x30,0x30,0x30,0x00,0x00,0x00},
|
sl@0
|
152 |
{0x78,0xCC,0xCC,0x78,0xCC,0xCC,0x78,0x00,0x00,0x00},
|
sl@0
|
153 |
{0x78,0xCC,0xCC,0x7C,0x0C,0x18,0x70,0x00,0x00,0x00}, //9
|
sl@0
|
154 |
{0x00,0x30,0x30,0x00,0x00,0x30,0x30,0x00,0x00,0x00}, //:
|
sl@0
|
155 |
{0x00,0x30,0x30,0x00,0x00,0x30,0x30,0x60,0x00,0x00}, //;
|
sl@0
|
156 |
{0x18,0x30,0x60,0xC0,0x60,0x30,0x18,0x00,0x00,0x00}, //<
|
sl@0
|
157 |
{0x00,0x00,0xFC,0x00,0x00,0xFC,0x00,0x00,0x00,0x00}, //=
|
sl@0
|
158 |
{0x60,0x30,0x18,0x0C,0x18,0x30,0x60,0x00,0x00,0x00}, //>
|
sl@0
|
159 |
{0x78,0xCC,0x0C,0x18,0x30,0x00,0x30,0x00,0x00,0x00}, //?
|
sl@0
|
160 |
|
sl@0
|
161 |
{0x7C,0xC6,0xDE,0xDE,0xDE,0xC0,0x78,0x00,0x00,0x00}, //@
|
sl@0
|
162 |
{0x30,0x78,0xCC,0xCC,0xFC,0xCC,0xCC,0x00,0x00,0x00}, //A
|
sl@0
|
163 |
{0xFC,0x66,0x66,0x7C,0x66,0x66,0xFC,0x00,0x00,0x00}, //B
|
sl@0
|
164 |
{0x3C,0x66,0xC0,0xC0,0xC0,0x66,0x3C,0x00,0x00,0x00}, //C
|
sl@0
|
165 |
{0xF8,0x6C,0x66,0x66,0x66,0x6C,0xF8,0x00,0x00,0x00}, //D
|
sl@0
|
166 |
{0x7E,0x60,0x60,0x78,0x60,0x60,0x7E,0x00,0x00,0x00}, //E
|
sl@0
|
167 |
{0x7E,0x60,0x60,0x78,0x60,0x60,0x60,0x00,0x00,0x00}, //F
|
sl@0
|
168 |
{0x3C,0x66,0xC0,0xC0,0xCE,0x66,0x3E,0x00,0x00,0x00}, //G
|
sl@0
|
169 |
{0xCC,0xCC,0xCC,0xFC,0xCC,0xCC,0xCC,0x00,0x00,0x00}, //H
|
sl@0
|
170 |
{0x78,0x30,0x30,0x30,0x30,0x30,0x78,0x00,0x00,0x00}, //I
|
sl@0
|
171 |
{0x1E,0x0C,0x0C,0x0C,0xCC,0xCC,0x78,0x00,0x00,0x00}, //J
|
sl@0
|
172 |
{0xE6,0x66,0x6C,0x78,0x6C,0x66,0xE6,0x00,0x00,0x00}, //K
|
sl@0
|
173 |
{0x60,0x60,0x60,0x60,0x60,0x60,0x7E,0x00,0x00,0x00}, //L
|
sl@0
|
174 |
{0xC6,0xEE,0xFE,0xFE,0xD6,0xC6,0xC6,0x00,0x00,0x00}, //M
|
sl@0
|
175 |
{0xC6,0xE6,0xF6,0xDE,0xCE,0xC6,0xC6,0x00,0x00,0x00}, //N
|
sl@0
|
176 |
{0x38,0x6C,0xC6,0xC6,0xC6,0x6C,0x38,0x00,0x00,0x00}, //O
|
sl@0
|
177 |
|
sl@0
|
178 |
{0xFC,0x66,0x66,0x7C,0x60,0x60,0xF0,0x00,0x00,0x00}, //P
|
sl@0
|
179 |
{0x78,0xCC,0xCC,0xCC,0xDC,0x78,0x1C,0x00,0x00,0x00}, //Q
|
sl@0
|
180 |
{0xFC,0x66,0x66,0x7C,0x6C,0x66,0xE6,0x00,0x00,0x00}, //R
|
sl@0
|
181 |
{0x78,0xCC,0xE0,0x70,0x1C,0xCC,0x78,0x00,0x00,0x00}, //S
|
sl@0
|
182 |
{0xFC,0x30,0x30,0x30,0x30,0x30,0x30,0x00,0x00,0x00}, //T
|
sl@0
|
183 |
{0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xFC,0x00,0x00,0x00}, //U
|
sl@0
|
184 |
{0xCC,0xCC,0xCC,0xCC,0xCC,0x78,0x30,0x00,0x00,0x00}, //V
|
sl@0
|
185 |
{0xC6,0xC6,0xC6,0xD6,0xFE,0xEE,0xC6,0x00,0x00,0x00}, //W
|
sl@0
|
186 |
{0xC6,0xC6,0x6C,0x38,0x38,0x6C,0xC6,0x00,0x00,0x00}, //X
|
sl@0
|
187 |
{0xCC,0xCC,0xCC,0x78,0x30,0x30,0x78,0x00,0x00,0x00}, //Y
|
sl@0
|
188 |
{0xFE,0x06,0x0C,0x18,0x30,0x60,0xFE,0x00,0x00,0x00}, //Z
|
sl@0
|
189 |
{0x78,0x60,0x60,0x60,0x60,0x60,0x78,0x00,0x00,0x00},
|
sl@0
|
190 |
{0xC0,0x60,0x30,0x18,0x0C,0x06,0x02,0x00,0x00,0x00},
|
sl@0
|
191 |
{0x78,0x18,0x18,0x18,0x18,0x18,0x78,0x00,0x00,0x00},
|
sl@0
|
192 |
{0x10,0x38,0x6C,0xC6,0x00,0x00,0x00,0x00,0x00,0x00},
|
sl@0
|
193 |
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0x00,0x00},
|
sl@0
|
194 |
|
sl@0
|
195 |
{0x30,0x30,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
|
sl@0
|
196 |
{0x00,0x00,0x78,0x0C,0x7C,0xCC,0x76,0x00,0x00,0x00},
|
sl@0
|
197 |
{0xE0,0x60,0x60,0x7C,0x66,0x66,0xDC,0x00,0x00,0x00},
|
sl@0
|
198 |
{0x00,0x00,0x78,0xCC,0xC0,0xCC,0x78,0x00,0x00,0x00},
|
sl@0
|
199 |
{0x1C,0x0C,0x0C,0x7C,0xCC,0xCC,0x76,0x00,0x00,0x00},
|
sl@0
|
200 |
{0x00,0x00,0x78,0xCC,0xFC,0xC0,0x78,0x00,0x00,0x00},
|
sl@0
|
201 |
{0x38,0x6C,0x60,0xF0,0x60,0x60,0xF0,0x00,0x00,0x00},
|
sl@0
|
202 |
{0x00,0x00,0x76,0xCC,0xCC,0x7C,0x0C,0xF8,0x00,0x00},
|
sl@0
|
203 |
{0xE0,0x60,0x6C,0x76,0x66,0x66,0xE6,0x00,0x00,0x00},
|
sl@0
|
204 |
{0x30,0x00,0x70,0x30,0x30,0x30,0x78,0x00,0x00,0x00},
|
sl@0
|
205 |
{0x0C,0x00,0x0C,0x0C,0x0C,0xCC,0xCC,0x78,0x00,0x00},
|
sl@0
|
206 |
{0xE0,0x60,0x66,0x6C,0x78,0x6C,0xE6,0x00,0x00,0x00},
|
sl@0
|
207 |
{0x70,0x30,0x30,0x30,0x30,0x30,0x78,0x00,0x00,0x00},
|
sl@0
|
208 |
{0x00,0x00,0xCC,0xFE,0xFE,0xD6,0xC6,0x00,0x00,0x00},
|
sl@0
|
209 |
{0x00,0x00,0xF8,0xCC,0xCC,0xCC,0xCC,0x00,0x00,0x00},
|
sl@0
|
210 |
{0x00,0x00,0x78,0xCC,0xCC,0xCC,0x78,0x00,0x00,0x00},
|
sl@0
|
211 |
|
sl@0
|
212 |
{0x00,0x00,0xDC,0x66,0x66,0x7C,0x60,0xF0,0x00,0x00},
|
sl@0
|
213 |
{0x00,0x00,0x76,0xCC,0xCC,0x7C,0x0C,0x1E,0x00,0x00},
|
sl@0
|
214 |
{0x00,0x00,0xDC,0x76,0x66,0x60,0xF0,0x00,0x00,0x00},
|
sl@0
|
215 |
{0x00,0x00,0x7C,0xC0,0x78,0x0C,0xF8,0x00,0x00,0x00},
|
sl@0
|
216 |
{0x10,0x30,0x7C,0x30,0x30,0x34,0x18,0x00,0x00,0x00},
|
sl@0
|
217 |
{0x00,0x00,0xCC,0xCC,0xCC,0xCC,0x76,0x00,0x00,0x00},
|
sl@0
|
218 |
{0x00,0x00,0xCC,0xCC,0xCC,0x78,0x30,0x00,0x00,0x00},
|
sl@0
|
219 |
{0x00,0x00,0xC6,0xD6,0xFE,0xFE,0x6C,0x00,0x00,0x00},
|
sl@0
|
220 |
{0x00,0x00,0xC6,0x6C,0x38,0x6C,0xC6,0x00,0x00,0x00},
|
sl@0
|
221 |
{0x00,0x00,0xCC,0xCC,0xCC,0x7C,0x0C,0xF8,0x00,0x00},
|
sl@0
|
222 |
{0x00,0x00,0xFC,0x98,0x30,0x64,0xFC,0x00,0x00,0x00},
|
sl@0
|
223 |
{0x1C,0x30,0x30,0xE0,0x30,0x30,0x1C,0x00,0x00,0x00},
|
sl@0
|
224 |
{0x18,0x18,0x18,0x00,0x18,0x18,0x18,0x00,0x00,0x00},
|
sl@0
|
225 |
{0xE0,0x30,0x30,0x1C,0x30,0x30,0xE0,0x00,0x00,0x00},
|
sl@0
|
226 |
{0x76,0xDC,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
|
sl@0
|
227 |
{0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00},
|
sl@0
|
228 |
};
|
sl@0
|
229 |
|
sl@0
|
230 |
inline void ColourPixel(TInt aXPos, TInt aYPos, TUint aColour)
|
sl@0
|
231 |
/**
|
sl@0
|
232 |
colour a pixel on the screen
|
sl@0
|
233 |
@param aXPos pixel's X coordinate
|
sl@0
|
234 |
@param aYPos pixel's Y coordinate
|
sl@0
|
235 |
@param aColour chosen colour specified as a palette index
|
sl@0
|
236 |
*/
|
sl@0
|
237 |
{
|
sl@0
|
238 |
TUint8* pV = (TUint8*)Screen + (aYPos * (Screenwidth * PixelSize)) + (aXPos * PixelSize);
|
sl@0
|
239 |
|
sl@0
|
240 |
switch(PixelSize)
|
sl@0
|
241 |
{
|
sl@0
|
242 |
case 4:
|
sl@0
|
243 |
*(TUint32*)pV = Palette32[aColour];
|
sl@0
|
244 |
break;
|
sl@0
|
245 |
case 2:
|
sl@0
|
246 |
*pV++ = Palette[aColour] & 0xFF ;
|
sl@0
|
247 |
*pV = Palette[aColour] >> 8 ;
|
sl@0
|
248 |
break;
|
sl@0
|
249 |
case 1:
|
sl@0
|
250 |
*pV = aColour;
|
sl@0
|
251 |
break;
|
sl@0
|
252 |
default:
|
sl@0
|
253 |
// Kern::Fault("BOOTLDR colourpixel: Unsupported bpp", PixelSize);
|
sl@0
|
254 |
BOOT_FAULT();
|
sl@0
|
255 |
}
|
sl@0
|
256 |
}
|
sl@0
|
257 |
|
sl@0
|
258 |
#ifndef USE_ASM_DISPLAYCHAR
|
sl@0
|
259 |
void DisplayChar(TInt aChar, TInt aXPos, TInt aYPos, TUint aColours)
|
sl@0
|
260 |
/**
|
sl@0
|
261 |
Write a character to the framebuffer
|
sl@0
|
262 |
@param aChar Character to draw
|
sl@0
|
263 |
@param aXPos Character's column
|
sl@0
|
264 |
@param aYPos Character's row
|
sl@0
|
265 |
@param aColour Palette index specified (foreground << 8| background)
|
sl@0
|
266 |
*/
|
sl@0
|
267 |
{
|
sl@0
|
268 |
// Convert the ascii value into an index for the Font table
|
sl@0
|
269 |
TInt tmpChar = aChar - 32;
|
sl@0
|
270 |
|
sl@0
|
271 |
// Validate this is a valid font index
|
sl@0
|
272 |
if (tmpChar < 0 || tmpChar >= NUM_FONTS)
|
sl@0
|
273 |
return;
|
sl@0
|
274 |
|
sl@0
|
275 |
// Validate coordinates lie within range.
|
sl@0
|
276 |
if (aXPos > MAX_COLUMN-1 || aYPos > MAX_ROW-1)
|
sl@0
|
277 |
return;
|
sl@0
|
278 |
|
sl@0
|
279 |
// for each line of the font
|
sl@0
|
280 |
for (TUint line=0 ; line < FONT_HEIGHT ; line++)
|
sl@0
|
281 |
{
|
sl@0
|
282 |
TUint8 tmpLine = Font[tmpChar][line];
|
sl@0
|
283 |
TUint8 tmpMask = 0x80;
|
sl@0
|
284 |
// for each pixel of the line
|
sl@0
|
285 |
for (TUint pixel=0 ; pixel < FONT_WIDTH ; pixel++)
|
sl@0
|
286 |
{
|
sl@0
|
287 |
ColourPixel(aXPos * FONT_WIDTH + pixel,
|
sl@0
|
288 |
aYPos * FONT_HEIGHT + line,
|
sl@0
|
289 |
(tmpLine & tmpMask) ? aColours >> 8 : aColours & 0xFF);
|
sl@0
|
290 |
|
sl@0
|
291 |
// Shift the mask one bit downward to examine the next pixel
|
sl@0
|
292 |
tmpMask = tmpMask >> 1;
|
sl@0
|
293 |
}
|
sl@0
|
294 |
}
|
sl@0
|
295 |
|
sl@0
|
296 |
return;
|
sl@0
|
297 |
}
|
sl@0
|
298 |
#endif
|
sl@0
|
299 |
|
sl@0
|
300 |
|
sl@0
|
301 |
GLDEF_C void ClearScreen()
|
sl@0
|
302 |
/**
|
sl@0
|
303 |
Set all the pixels on the screen to the background
|
sl@0
|
304 |
*/
|
sl@0
|
305 |
{
|
sl@0
|
306 |
for (TInt y = 0 ; y<Screenheight ; y++)
|
sl@0
|
307 |
for (TInt x = 0 ; x<Screenwidth ; x++)
|
sl@0
|
308 |
ColourPixel(x, y, KBackground);
|
sl@0
|
309 |
|
sl@0
|
310 |
XPos=0;
|
sl@0
|
311 |
YPos=0;
|
sl@0
|
312 |
Colours=(KForeground<<8)|KBackground;
|
sl@0
|
313 |
}
|
sl@0
|
314 |
|
sl@0
|
315 |
void ScrollScreen()
|
sl@0
|
316 |
/**
|
sl@0
|
317 |
Move all the pixels in the scrolling text area up one line and fill the
|
sl@0
|
318 |
last line with the background colour
|
sl@0
|
319 |
*/
|
sl@0
|
320 |
{
|
sl@0
|
321 |
TUint8* pV=Screen;
|
sl@0
|
322 |
wordmove(pV, pV+(Screenwidth*PixelSize*FONT_HEIGHT), (Screenwidth*PixelSize*(Screenheight-(2*FONT_HEIGHT))-(Screenwidth*PixelSize*FONT_HEIGHT)));
|
sl@0
|
323 |
pV+=(Screenwidth*PixelSize*(Screenheight-(2*FONT_HEIGHT))-(Screenwidth*PixelSize*FONT_HEIGHT));
|
sl@0
|
324 |
|
sl@0
|
325 |
TInt StartLine = (Screenheight-(4*FONT_HEIGHT));
|
sl@0
|
326 |
for (TInt y = StartLine ; y<(StartLine+FONT_HEIGHT) ; y++)
|
sl@0
|
327 |
for (TInt x = 0 ; x<Screenwidth ; x++)
|
sl@0
|
328 |
ColourPixel(x, y, KBackground);
|
sl@0
|
329 |
}
|
sl@0
|
330 |
|
sl@0
|
331 |
void ScrollScreenDown()
|
sl@0
|
332 |
/**
|
sl@0
|
333 |
Move all the pixels in the scrolling text area down one line and fill the
|
sl@0
|
334 |
first line with the background colour
|
sl@0
|
335 |
*/
|
sl@0
|
336 |
{
|
sl@0
|
337 |
TUint8* pV=Screen;
|
sl@0
|
338 |
wordmove(pV+(Screenwidth*PixelSize*FONT_HEIGHT), pV, (Screenwidth*PixelSize*(Screenheight-(2*FONT_HEIGHT))-(Screenwidth*PixelSize*FONT_HEIGHT)));
|
sl@0
|
339 |
|
sl@0
|
340 |
for (TInt y = 0 ; y<FONT_HEIGHT ; y++)
|
sl@0
|
341 |
for (TInt x = 0 ; x<Screenwidth ; x++)
|
sl@0
|
342 |
ColourPixel(x, y, KBackground);
|
sl@0
|
343 |
|
sl@0
|
344 |
}
|
sl@0
|
345 |
|
sl@0
|
346 |
void CurDown()
|
sl@0
|
347 |
/**
|
sl@0
|
348 |
Move the cursor down the screen, scrolling the text area if necessary
|
sl@0
|
349 |
*/
|
sl@0
|
350 |
{
|
sl@0
|
351 |
if (++YPos==(MAX_ROW-3))
|
sl@0
|
352 |
{
|
sl@0
|
353 |
YPos=(MAX_ROW-4);
|
sl@0
|
354 |
ScrollScreen();
|
sl@0
|
355 |
}
|
sl@0
|
356 |
}
|
sl@0
|
357 |
|
sl@0
|
358 |
void CurUp()
|
sl@0
|
359 |
/**
|
sl@0
|
360 |
Move the cursor up the screen, scrolling the text area if necessary
|
sl@0
|
361 |
*/
|
sl@0
|
362 |
{
|
sl@0
|
363 |
if (--YPos<0)
|
sl@0
|
364 |
{
|
sl@0
|
365 |
YPos=0;
|
sl@0
|
366 |
ScrollScreenDown();
|
sl@0
|
367 |
}
|
sl@0
|
368 |
}
|
sl@0
|
369 |
|
sl@0
|
370 |
void CurRight()
|
sl@0
|
371 |
/**
|
sl@0
|
372 |
Move the cursor along the screen, scrolling the text area if necessary
|
sl@0
|
373 |
*/
|
sl@0
|
374 |
{
|
sl@0
|
375 |
if (++XPos==MAX_COLUMN)
|
sl@0
|
376 |
{
|
sl@0
|
377 |
XPos=0;
|
sl@0
|
378 |
CurDown();
|
sl@0
|
379 |
}
|
sl@0
|
380 |
}
|
sl@0
|
381 |
|
sl@0
|
382 |
void CurLeft()
|
sl@0
|
383 |
/**
|
sl@0
|
384 |
Move the cursor backwards along the screen, scrolling the text area if necessary
|
sl@0
|
385 |
*/
|
sl@0
|
386 |
{
|
sl@0
|
387 |
if (--XPos<0)
|
sl@0
|
388 |
{
|
sl@0
|
389 |
XPos=MAX_COLUMN-1;
|
sl@0
|
390 |
CurUp();
|
sl@0
|
391 |
}
|
sl@0
|
392 |
}
|
sl@0
|
393 |
|
sl@0
|
394 |
void SetPos(TInt X, TInt Y)
|
sl@0
|
395 |
/**
|
sl@0
|
396 |
Set the cursor to a point on the screen
|
sl@0
|
397 |
@param X Character's column
|
sl@0
|
398 |
@param Y Character's row
|
sl@0
|
399 |
*/
|
sl@0
|
400 |
{
|
sl@0
|
401 |
XPos=X;
|
sl@0
|
402 |
YPos=Y;
|
sl@0
|
403 |
}
|
sl@0
|
404 |
|
sl@0
|
405 |
void PutChar(TUint aChar)
|
sl@0
|
406 |
/**
|
sl@0
|
407 |
Write a character to the screen then moves the cursor to the next position,
|
sl@0
|
408 |
scrolling the screen if necessary
|
sl@0
|
409 |
@param aChar Character to write
|
sl@0
|
410 |
*/
|
sl@0
|
411 |
{
|
sl@0
|
412 |
switch (aChar)
|
sl@0
|
413 |
{
|
sl@0
|
414 |
case 0x08: CurLeft(); return; // BS '\b'
|
sl@0
|
415 |
case 0x09: CurRight(); return; // HT '\t'
|
sl@0
|
416 |
case 0x0a: CurDown(); return; // LF '\n'
|
sl@0
|
417 |
case 0x0b: CurUp(); return; // VT '\v'
|
sl@0
|
418 |
case 0x0c: ClearScreen(); return; // FF '\f'
|
sl@0
|
419 |
case 0x0d: XPos=0; return; // CR '\r'
|
sl@0
|
420 |
default: break;
|
sl@0
|
421 |
}
|
sl@0
|
422 |
DisplayChar(aChar,XPos,YPos,Colours);
|
sl@0
|
423 |
if (++XPos==MAX_COLUMN) // chars per line
|
sl@0
|
424 |
{
|
sl@0
|
425 |
XPos=0;
|
sl@0
|
426 |
if (++YPos==(MAX_ROW-3)) // lines per screen - 3 for progress bars & stats
|
sl@0
|
427 |
{
|
sl@0
|
428 |
YPos=(MAX_ROW-4); // lines per screen - 4
|
sl@0
|
429 |
ScrollScreen();
|
sl@0
|
430 |
}
|
sl@0
|
431 |
}
|
sl@0
|
432 |
}
|
sl@0
|
433 |
|
sl@0
|
434 |
GLDEF_C void PrintToScreen(TRefByValue<const TDesC> aFmt, ...)
|
sl@0
|
435 |
{
|
sl@0
|
436 |
VA_LIST list;
|
sl@0
|
437 |
VA_START(list,aFmt);
|
sl@0
|
438 |
|
sl@0
|
439 |
TBuf<0x100> aBuf;
|
sl@0
|
440 |
aBuf.AppendFormatList(aFmt,list);
|
sl@0
|
441 |
PutString(aBuf);
|
sl@0
|
442 |
//RDebug::RawPrint(aBuf);
|
sl@0
|
443 |
}
|
sl@0
|
444 |
|
sl@0
|
445 |
void PutString(const TDesC& aBuf)
|
sl@0
|
446 |
/**
|
sl@0
|
447 |
For each character in the given string write it to the screen
|
sl@0
|
448 |
@param aString String of characters to write
|
sl@0
|
449 |
*/
|
sl@0
|
450 |
{
|
sl@0
|
451 |
const TText* pS=aBuf.Ptr();
|
sl@0
|
452 |
const TText* pE=pS+aBuf.Length();
|
sl@0
|
453 |
if (pS!=pE)
|
sl@0
|
454 |
{
|
sl@0
|
455 |
while (pS<pE)
|
sl@0
|
456 |
PutChar(*pS++);
|
sl@0
|
457 |
}
|
sl@0
|
458 |
}
|
sl@0
|
459 |
|
sl@0
|
460 |
GLDEF_C void InitProgressBar(TInt aId, TUint aLimit, const TDesC& aBuf)
|
sl@0
|
461 |
/**
|
sl@0
|
462 |
Initialise a progress bar, writes a label and sets the pixels to the
|
sl@0
|
463 |
background colour
|
sl@0
|
464 |
@param aId configure Bar0 or Bar1
|
sl@0
|
465 |
@param aLimit Sets the upper bound of the value given to Update
|
sl@0
|
466 |
@param aTitle Label to place before the progress bar (7 characters wide)
|
sl@0
|
467 |
*/
|
sl@0
|
468 |
{
|
sl@0
|
469 |
const TText* aTitle=aBuf.Ptr();
|
sl@0
|
470 |
TInt line=aId ? PROGRESSBAR0_ROW : PROGRESSBAR1_ROW;
|
sl@0
|
471 |
Progress[aId]=0;
|
sl@0
|
472 |
if (aId==0)
|
sl@0
|
473 |
StartTime=0;
|
sl@0
|
474 |
|
sl@0
|
475 |
Pixels[aId]=0;
|
sl@0
|
476 |
Limit[aId]=aLimit;
|
sl@0
|
477 |
char c;
|
sl@0
|
478 |
TInt x=0;
|
sl@0
|
479 |
while ((c=*aTitle++)!=0 && x<7)
|
sl@0
|
480 |
{
|
sl@0
|
481 |
DisplayChar(c,x,line,Colours);
|
sl@0
|
482 |
++x;
|
sl@0
|
483 |
}
|
sl@0
|
484 |
if (x<7)
|
sl@0
|
485 |
x=7;
|
sl@0
|
486 |
for (; x<(MAX_COLUMN-1); ++x)
|
sl@0
|
487 |
DisplayChar(0x7f,x,line,IPColour[aId]);
|
sl@0
|
488 |
}
|
sl@0
|
489 |
|
sl@0
|
490 |
GLDEF_C void UpdateProgressBar(TInt aId, TUint aProgress)
|
sl@0
|
491 |
/**
|
sl@0
|
492 |
Update a progress bar filling in the bar to a new position
|
sl@0
|
493 |
If ENABLE_TRANSFER_STATS has been defined at build time the function will
|
sl@0
|
494 |
generate some simple statistics.
|
sl@0
|
495 |
@param aId update Bar0 or Bar1
|
sl@0
|
496 |
@param aProgress The point value between 0 and the given aLimit
|
sl@0
|
497 |
*/
|
sl@0
|
498 |
{
|
sl@0
|
499 |
TInt line=aId ? PROGRESSBAR0_ROW : PROGRESSBAR1_ROW;
|
sl@0
|
500 |
TUint old_pixels=Pixels[aId];
|
sl@0
|
501 |
|
sl@0
|
502 |
#ifdef ENABLE_TRANSFER_STATS
|
sl@0
|
503 |
// turn this on and get a few statistics as it loads
|
sl@0
|
504 |
if (aId==0) {
|
sl@0
|
505 |
if (StartTime == 0) {
|
sl@0
|
506 |
StartTime = User::NTickCount();
|
sl@0
|
507 |
ProgressTime[aId] = StartTime;
|
sl@0
|
508 |
}
|
sl@0
|
509 |
TUint avg_bps=0, bps=0, eta=0;
|
sl@0
|
510 |
TUint32 timenow = User::NTickCount();
|
sl@0
|
511 |
TUint32 delta_time = timenow - ProgressTime[aId];
|
sl@0
|
512 |
ProgressTime[aId] = timenow;
|
sl@0
|
513 |
if (delta_time) {
|
sl@0
|
514 |
bps = ((aProgress - Progress[aId]) * 1000) / delta_time; // delta bytes / delta milliseconds
|
sl@0
|
515 |
|
sl@0
|
516 |
delta_time = (timenow - StartTime); // milliseconds since started
|
sl@0
|
517 |
if (delta_time) {
|
sl@0
|
518 |
avg_bps = ((TUint64)aProgress * 1000) / delta_time;
|
sl@0
|
519 |
eta = (Limit[aId] - aProgress) / avg_bps;
|
sl@0
|
520 |
}
|
sl@0
|
521 |
}
|
sl@0
|
522 |
|
sl@0
|
523 |
TInt savedXPos=XPos, savedYPos=YPos;
|
sl@0
|
524 |
XPos=0;
|
sl@0
|
525 |
YPos=STATS_ROW;
|
sl@0
|
526 |
// Printf("C/s avg: %7d point: %7d ETA: %d ", avg_bps, bps, eta);
|
sl@0
|
527 |
PrintToScreen(_L("point: %7d ETA: %d "), bps, eta);
|
sl@0
|
528 |
XPos=savedXPos;
|
sl@0
|
529 |
YPos=savedYPos;
|
sl@0
|
530 |
}
|
sl@0
|
531 |
#endif
|
sl@0
|
532 |
|
sl@0
|
533 |
Progress[aId]=aProgress;
|
sl@0
|
534 |
Int64 prog64=aProgress;
|
sl@0
|
535 |
prog64*=(Screenwidth - (8*FONT_WIDTH)); // screenwidth in pixels - 8 characters
|
sl@0
|
536 |
prog64/=Limit[aId];
|
sl@0
|
537 |
TUint pixels=(TUint)prog64;
|
sl@0
|
538 |
if (pixels>old_pixels)
|
sl@0
|
539 |
{
|
sl@0
|
540 |
Pixels[aId]=pixels;
|
sl@0
|
541 |
|
sl@0
|
542 |
while (old_pixels<pixels)
|
sl@0
|
543 |
{
|
sl@0
|
544 |
for (TInt i=0; i<6; ++i)
|
sl@0
|
545 |
ColourPixel( old_pixels + (7*FONT_WIDTH), (line * FONT_HEIGHT) + 2 + i , (PColour[aId]>>8));
|
sl@0
|
546 |
|
sl@0
|
547 |
++old_pixels;
|
sl@0
|
548 |
}
|
sl@0
|
549 |
}
|
sl@0
|
550 |
}
|
sl@0
|
551 |
|
sl@0
|
552 |
void InitDisplay()
|
sl@0
|
553 |
/**
|
sl@0
|
554 |
Reads the properties of the screen from the HAL and configures the settings so
|
sl@0
|
555 |
this driver can colour in pixels.
|
sl@0
|
556 |
*/
|
sl@0
|
557 |
{
|
sl@0
|
558 |
TInt iDisplayMode;
|
sl@0
|
559 |
TInt iScreenAddress;
|
sl@0
|
560 |
TInt iBitsPerPixel;
|
sl@0
|
561 |
TInt iIsPalettized;
|
sl@0
|
562 |
TInt offset;
|
sl@0
|
563 |
|
sl@0
|
564 |
HAL::Get(HAL::EDisplayMode, iDisplayMode);
|
sl@0
|
565 |
iBitsPerPixel = iDisplayMode; //getbpp needs the current mode as its param
|
sl@0
|
566 |
HAL::Get(HAL::EDisplayBitsPerPixel, iBitsPerPixel);
|
sl@0
|
567 |
|
sl@0
|
568 |
iIsPalettized = iDisplayMode; //ispalettized needs the current mode as its param
|
sl@0
|
569 |
HAL::Get(HAL::EDisplayIsPalettized, iIsPalettized);
|
sl@0
|
570 |
|
sl@0
|
571 |
HAL::Get(HAL::EDisplayMemoryAddress, iScreenAddress);
|
sl@0
|
572 |
|
sl@0
|
573 |
offset = iDisplayMode;
|
sl@0
|
574 |
HAL::Get(HAL::EDisplayOffsetToFirstPixel, offset);
|
sl@0
|
575 |
iScreenAddress += offset;
|
sl@0
|
576 |
|
sl@0
|
577 |
// get the dimentions of the screen
|
sl@0
|
578 |
HAL::Get(HAL::EDisplayXPixels, Screenwidth);
|
sl@0
|
579 |
HAL::Get(HAL::EDisplayYPixels, Screenheight);
|
sl@0
|
580 |
|
sl@0
|
581 |
Screen = (TUint8 *)iScreenAddress;
|
sl@0
|
582 |
|
sl@0
|
583 |
#if 0
|
sl@0
|
584 |
RDebug::Printf("EDisplayMode %d", iDisplayMode);
|
sl@0
|
585 |
RDebug::Printf("EDisplayBitsPerPixel %d", iBitsPerPixel);
|
sl@0
|
586 |
RDebug::Printf("EDisplayIsPalettized %d", iIsPalettized);
|
sl@0
|
587 |
RDebug::Printf("EDisplayMemoryAddress 0x%x (after offset)", iScreenAddress);
|
sl@0
|
588 |
RDebug::Printf("EDisplayOffsetToFirstPixel %d",offset);
|
sl@0
|
589 |
RDebug::Printf("EDisplayXPixels %d",Screenwidth);
|
sl@0
|
590 |
RDebug::Printf("EDisplayYPixels %d", Screenheight);
|
sl@0
|
591 |
#endif
|
sl@0
|
592 |
|
sl@0
|
593 |
// get the bits per pixel to work out the size
|
sl@0
|
594 |
if (iBitsPerPixel == 32)
|
sl@0
|
595 |
{
|
sl@0
|
596 |
PixelSize = 4;
|
sl@0
|
597 |
}
|
sl@0
|
598 |
else if (iBitsPerPixel == 16)
|
sl@0
|
599 |
{
|
sl@0
|
600 |
PixelSize = 2;
|
sl@0
|
601 |
}
|
sl@0
|
602 |
else if (iBitsPerPixel == 8)
|
sl@0
|
603 |
{
|
sl@0
|
604 |
#if 0
|
sl@0
|
605 |
// derive where the palette is located - assumes when no offset to first
|
sl@0
|
606 |
// pixel the palette is at end of framebuffer.
|
sl@0
|
607 |
TUint8* pV;
|
sl@0
|
608 |
if(vidBuf().iOffsetToFirstPixel)
|
sl@0
|
609 |
pV=(TUint8*)(vidBuf().iVideoAddress);
|
sl@0
|
610 |
else
|
sl@0
|
611 |
pV=(TUint8*)(vidBuf().iVideoAddress)+SCREEN_SIZE;
|
sl@0
|
612 |
|
sl@0
|
613 |
// Kern::Printf("Screenbuffer 0x%x palette 0x%x (%dx%d)",Screen,pV,Screenwidth,Screenheight);
|
sl@0
|
614 |
PixelSize = 1;
|
sl@0
|
615 |
memcpy(pV,Palette,32);
|
sl@0
|
616 |
#endif
|
sl@0
|
617 |
}
|
sl@0
|
618 |
else
|
sl@0
|
619 |
{
|
sl@0
|
620 |
RDebug::Printf("BOOTLDR display: Unsupported bpp %d",iBitsPerPixel);
|
sl@0
|
621 |
BOOT_FAULT();
|
sl@0
|
622 |
}
|
sl@0
|
623 |
|
sl@0
|
624 |
ClearScreen();
|
sl@0
|
625 |
}
|