Rev 4153 | Rev 4327 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 4153 | Rev 4263 | ||
---|---|---|---|
Line 76... | Line 76... | ||
76 | /* Allow only 1 connection */ |
76 | /* Allow only 1 connection */ |
77 | static int client_connected = 0; |
77 | static int client_connected = 0; |
78 | 78 | ||
79 | static unsigned int scr_width; |
79 | static unsigned int scr_width; |
80 | static unsigned int scr_height; |
80 | static unsigned int scr_height; |
81 | static char *scr_addr; |
81 | static uint8_t *scr_addr; |
82 | 82 | ||
83 | static unsigned int style; |
83 | static unsigned int style; |
84 | 84 | ||
85 | static unsigned attr_to_ega_style(const attrs_t *a); |
85 | static unsigned attr_to_ega_style(const attrs_t *a); |
- | 86 | static uint8_t ega_glyph(wchar_t ch); |
|
86 | 87 | ||
87 | static void clrscr(void) |
88 | static void clrscr(void) |
88 | { |
89 | { |
89 | int i; |
90 | int i; |
90 | 91 | ||
Line 141... | Line 142... | ||
141 | for (i = 0; i < -rows * scr_width; i++) |
142 | for (i = 0; i < -rows * scr_width; i++) |
142 | ((short *)scr_addr)[i] = ((style << 8 ) + ' '); |
143 | ((short *)scr_addr)[i] = ((style << 8 ) + ' '); |
143 | } |
144 | } |
144 | } |
145 | } |
145 | 146 | ||
146 | static void printchar(char c, unsigned int row, unsigned int col) |
147 | static void printchar(wchar_t c, unsigned int row, unsigned int col) |
147 | { |
148 | { |
148 | scr_addr[(row * scr_width + col) * 2] = c; |
149 | scr_addr[(row * scr_width + col) * 2] = ega_glyph(c); |
149 | scr_addr[(row * scr_width + col) * 2 + 1] = style; |
150 | scr_addr[(row * scr_width + col) * 2 + 1] = style; |
150 | 151 | ||
151 | cursor_goto(row, col + 1); |
152 | cursor_goto(row, col + 1); |
152 | } |
153 | } |
153 | 154 | ||
- | 155 | /** Draw text data to viewport. |
|
- | 156 | * |
|
- | 157 | * @param vport Viewport id |
|
- | 158 | * @param data Text data. |
|
- | 159 | * @param x Leftmost column of the area. |
|
- | 160 | * @param y Topmost row of the area. |
|
- | 161 | * @param w Number of rows. |
|
- | 162 | * @param h Number of columns. |
|
- | 163 | */ |
|
154 | static void draw_text_data(keyfield_t *data) |
164 | static void draw_text_data(keyfield_t *data, unsigned int x, |
- | 165 | unsigned int y, unsigned int w, unsigned int h) |
|
155 | { |
166 | { |
- | 167 | unsigned int i, j; |
|
- | 168 | keyfield_t *field; |
|
156 | int i; |
169 | uint8_t *dp; |
- | 170 | ||
- | 171 | for (j = 0; j < h; j++) { |
|
- | 172 | for (i = 0; i < w; i++) { |
|
- | 173 | field = &data[j * w + i]; |
|
- | 174 | dp = &scr_addr[2 * ((y + j) * scr_width + (x + i))]; |
|
157 | 175 | ||
158 | for (i = 0; i < scr_width * scr_height; i++) { |
- | |
159 | scr_addr[i * 2] = data[i].character; |
176 | dp[0] = ega_glyph(field->character); |
160 | scr_addr[i * 2 + 1] = attr_to_ega_style(&data[i].attrs); |
177 | dp[1] = attr_to_ega_style(&field->attrs); |
- | 178 | } |
|
161 | } |
179 | } |
162 | } |
180 | } |
163 | 181 | ||
164 | static int save_screen(void) |
182 | static int save_screen(void) |
165 | { |
183 | { |
Line 229... | Line 247... | ||
229 | a->a.i.bg_color, a->a.i.flags); |
247 | a->a.i.bg_color, a->a.i.flags); |
230 | default: return INVERTED_COLOR; |
248 | default: return INVERTED_COLOR; |
231 | } |
249 | } |
232 | } |
250 | } |
233 | 251 | ||
- | 252 | static uint8_t ega_glyph(wchar_t ch) |
|
- | 253 | { |
|
- | 254 | if (ch >= 0 && ch < 128) |
|
- | 255 | return ch; |
|
- | 256 | ||
- | 257 | return '?'; |
|
- | 258 | } |
|
- | 259 | ||
234 | static void ega_client_connection(ipc_callid_t iid, ipc_call_t *icall) |
260 | static void ega_client_connection(ipc_callid_t iid, ipc_call_t *icall) |
235 | { |
261 | { |
236 | int retval; |
262 | int retval; |
237 | ipc_callid_t callid; |
263 | ipc_callid_t callid; |
238 | ipc_call_t call; |
264 | ipc_call_t call; |
239 | char c; |
265 | wchar_t c; |
240 | unsigned int row, col; |
266 | unsigned int row, col, w, h; |
241 | int bg_color, fg_color, attr; |
267 | int bg_color, fg_color, attr; |
242 | uint32_t bg_rgb, fg_rgb; |
268 | uint32_t bg_rgb, fg_rgb; |
243 | keyfield_t *interbuf = NULL; |
269 | keyfield_t *interbuf = NULL; |
244 | size_t intersize = 0; |
270 | size_t intersize = 0; |
245 | int i; |
271 | int i; |
Line 268... | Line 294... | ||
268 | continue; |
294 | continue; |
269 | } |
295 | } |
270 | retval = EINVAL; |
296 | retval = EINVAL; |
271 | break; |
297 | break; |
272 | case FB_DRAW_TEXT_DATA: |
298 | case FB_DRAW_TEXT_DATA: |
- | 299 | col = IPC_GET_ARG1(call); |
|
- | 300 | row = IPC_GET_ARG2(call); |
|
- | 301 | w = IPC_GET_ARG3(call); |
|
- | 302 | h = IPC_GET_ARG4(call); |
|
273 | if (!interbuf) { |
303 | if (!interbuf) { |
274 | retval = EINVAL; |
304 | retval = EINVAL; |
275 | break; |
305 | break; |
276 | } |
306 | } |
- | 307 | if (col + w > scr_width || row + h > scr_height) { |
|
- | 308 | retval = EINVAL; |
|
- | 309 | break; |
|
- | 310 | } |
|
277 | draw_text_data(interbuf); |
311 | draw_text_data(interbuf, col, row, w, h); |
278 | retval = 0; |
312 | retval = 0; |
279 | break; |
313 | break; |
280 | case FB_GET_CSIZE: |
314 | case FB_GET_CSIZE: |
281 | ipc_answer_2(callid, EOK, scr_height, scr_width); |
315 | ipc_answer_2(callid, EOK, scr_height, scr_width); |
282 | continue; |
316 | continue; |
Line 357... | Line 391... | ||
357 | } |
391 | } |
358 | retval = 0; |
392 | retval = 0; |
359 | break; |
393 | break; |
360 | 394 | ||
361 | default: |
395 | default: |
362 | retval = ENOENT; |
396 | retval = EINVAL; |
363 | } |
397 | } |
364 | ipc_answer_0(callid, retval); |
398 | ipc_answer_0(callid, retval); |
365 | } |
399 | } |
366 | } |
400 | } |
367 | 401 |