Rev 4165 | Rev 4325 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 4165 | Rev 4167 | ||
---|---|---|---|
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 | 86 | ||
Line 149... | Line 149... | ||
149 | scr_addr[(row * scr_width + col) * 2 + 1] = style; |
149 | scr_addr[(row * scr_width + col) * 2 + 1] = style; |
150 | 150 | ||
151 | cursor_goto(row, col + 1); |
151 | cursor_goto(row, col + 1); |
152 | } |
152 | } |
153 | 153 | ||
- | 154 | /** Draw text data to viewport. |
|
- | 155 | * |
|
- | 156 | * @param vport Viewport id |
|
- | 157 | * @param data Text data. |
|
- | 158 | * @param x Leftmost column of the area. |
|
- | 159 | * @param y Topmost row of the area. |
|
- | 160 | * @param w Number of rows. |
|
- | 161 | * @param h Number of columns. |
|
- | 162 | */ |
|
154 | static void draw_text_data(keyfield_t *data) |
163 | static void draw_text_data(keyfield_t *data, unsigned int x, |
- | 164 | unsigned int y, unsigned int w, unsigned int h) |
|
155 | { |
165 | { |
- | 166 | unsigned int i, j; |
|
- | 167 | keyfield_t *field; |
|
156 | int i; |
168 | uint8_t *dp; |
157 | 169 | ||
- | 170 | for (j = 0; j < h; j++) { |
|
158 | for (i = 0; i < scr_width * scr_height; i++) { |
171 | for (i = 0; i < w; i++) { |
- | 172 | field = &data[j * w + i]; |
|
- | 173 | dp = &scr_addr[2 * ((y + j) * scr_width + (x + i))]; |
|
- | 174 | ||
159 | scr_addr[i * 2] = data[i].character; |
175 | dp[0] = field->character; |
160 | scr_addr[i * 2 + 1] = attr_to_ega_style(&data[i].attrs); |
176 | dp[1] = attr_to_ega_style(&field->attrs); |
- | 177 | } |
|
161 | } |
178 | } |
162 | } |
179 | } |
163 | 180 | ||
164 | static int save_screen(void) |
181 | static int save_screen(void) |
165 | { |
182 | { |
Line 229... | Line 246... | ||
229 | a->a.i.bg_color, a->a.i.flags); |
246 | a->a.i.bg_color, a->a.i.flags); |
230 | default: return INVERTED_COLOR; |
247 | default: return INVERTED_COLOR; |
231 | } |
248 | } |
232 | } |
249 | } |
233 | 250 | ||
234 | #define FB_WRITE_BUF_SIZE 256 |
- | |
235 | static char fb_write_buf[FB_WRITE_BUF_SIZE]; |
- | |
236 | - | ||
237 | static void fb_write(ipc_callid_t rid, ipc_call_t *request) |
- | |
238 | { |
- | |
239 | int row, col; |
- | |
240 | ipc_callid_t callid; |
- | |
241 | size_t len; |
- | |
242 | size_t i; |
- | |
243 | - | ||
244 | row = IPC_GET_ARG1(*request); |
- | |
245 | col = IPC_GET_ARG2(*request); |
- | |
246 | - | ||
247 | if ((col >= scr_width) || (row >= scr_height)) { |
- | |
248 | ipc_answer_0(callid, EINVAL); |
- | |
249 | ipc_answer_0(rid, EINVAL); |
- | |
250 | return; |
- | |
251 | } |
- | |
252 | - | ||
253 | if (!ipc_data_write_receive(&callid, &len)) { |
- | |
254 | ipc_answer_0(callid, EINVAL); |
- | |
255 | ipc_answer_0(rid, EINVAL); |
- | |
256 | return; |
- | |
257 | } |
- | |
258 | - | ||
259 | if (len > FB_WRITE_BUF_SIZE) |
- | |
260 | len = FB_WRITE_BUF_SIZE; |
- | |
261 | if (len >= scr_width - col) |
- | |
262 | len = scr_width - col; |
- | |
263 | - | ||
264 | (void) ipc_data_write_finalize(callid, fb_write_buf, len); |
- | |
265 | - | ||
266 | for (i = 0; i < len; i++) { |
- | |
267 | printchar(fb_write_buf[i], row, col++); |
- | |
268 | } |
- | |
269 | - | ||
270 | ipc_answer_1(rid, EOK, len); |
- | |
271 | } |
- | |
272 | - | ||
273 | static void ega_client_connection(ipc_callid_t iid, ipc_call_t *icall) |
251 | static void ega_client_connection(ipc_callid_t iid, ipc_call_t *icall) |
274 | { |
252 | { |
275 | int retval; |
253 | int retval; |
276 | ipc_callid_t callid; |
254 | ipc_callid_t callid; |
277 | ipc_call_t call; |
255 | ipc_call_t call; |
278 | char c; |
256 | char c; |
279 | unsigned int row, col; |
257 | unsigned int row, col, w, h; |
280 | int bg_color, fg_color, attr; |
258 | int bg_color, fg_color, attr; |
281 | uint32_t bg_rgb, fg_rgb; |
259 | uint32_t bg_rgb, fg_rgb; |
282 | keyfield_t *interbuf = NULL; |
260 | keyfield_t *interbuf = NULL; |
283 | size_t intersize = 0; |
261 | size_t intersize = 0; |
284 | int i; |
262 | int i; |
Line 307... | Line 285... | ||
307 | continue; |
285 | continue; |
308 | } |
286 | } |
309 | retval = EINVAL; |
287 | retval = EINVAL; |
310 | break; |
288 | break; |
311 | case FB_DRAW_TEXT_DATA: |
289 | case FB_DRAW_TEXT_DATA: |
- | 290 | col = IPC_GET_ARG1(call); |
|
- | 291 | row = IPC_GET_ARG2(call); |
|
- | 292 | w = IPC_GET_ARG3(call); |
|
- | 293 | h = IPC_GET_ARG4(call); |
|
312 | if (!interbuf) { |
294 | if (!interbuf) { |
313 | retval = EINVAL; |
295 | retval = EINVAL; |
314 | break; |
296 | break; |
315 | } |
297 | } |
- | 298 | if (col + w > scr_width || row + h > scr_height) { |
|
- | 299 | retval = EINVAL; |
|
- | 300 | break; |
|
- | 301 | } |
|
316 | draw_text_data(interbuf); |
302 | draw_text_data(interbuf, col, row, w, h); |
317 | retval = 0; |
303 | retval = 0; |
318 | break; |
304 | break; |
319 | case FB_GET_CSIZE: |
305 | case FB_GET_CSIZE: |
320 | ipc_answer_2(callid, EOK, scr_height, scr_width); |
306 | ipc_answer_2(callid, EOK, scr_height, scr_width); |
321 | continue; |
307 | continue; |
Line 332... | Line 318... | ||
332 | break; |
318 | break; |
333 | } |
319 | } |
334 | printchar(c, row, col); |
320 | printchar(c, row, col); |
335 | retval = 0; |
321 | retval = 0; |
336 | break; |
322 | break; |
337 | case FB_WRITE: |
- | |
338 | fb_write(callid, &call); |
- | |
339 | - | ||
340 | /* Message already answered */ |
- | |
341 | continue; |
- | |
342 | case FB_CURSOR_GOTO: |
323 | case FB_CURSOR_GOTO: |
343 | row = IPC_GET_ARG1(call); |
324 | row = IPC_GET_ARG1(call); |
344 | col = IPC_GET_ARG2(call); |
325 | col = IPC_GET_ARG2(call); |
345 | if (row >= scr_height || col >= scr_width) { |
326 | if (row >= scr_height || col >= scr_width) { |
346 | retval = EINVAL; |
327 | retval = EINVAL; |