Changeset dc033a1 in mainline for uspace/srv/fb/ega.c
- Timestamp:
- 2009-03-22T17:45:15Z (15 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 3fe00ee
- Parents:
- 0a5116db
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/fb/ega.c
r0a5116db rdc033a1 79 79 static unsigned int scr_width; 80 80 static unsigned int scr_height; 81 static char*scr_addr;81 static uint8_t *scr_addr; 82 82 83 83 static unsigned int style; … … 152 152 } 153 153 154 static void draw_text_data(keyfield_t *data) 155 { 156 int i; 157 158 for (i = 0; i < scr_width * scr_height; i++) { 159 scr_addr[i * 2] = data[i].character; 160 scr_addr[i * 2 + 1] = attr_to_ega_style(&data[i].attrs); 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 */ 163 static void draw_text_data(keyfield_t *data, unsigned int x, 164 unsigned int y, unsigned int w, unsigned int h) 165 { 166 unsigned int i, j; 167 keyfield_t *field; 168 uint8_t *dp; 169 170 for (j = 0; j < h; j++) { 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 175 dp[0] = field->character; 176 dp[1] = attr_to_ega_style(&field->attrs); 177 } 161 178 } 162 179 } … … 232 249 } 233 250 234 #define FB_WRITE_BUF_SIZE 256235 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 251 static void ega_client_connection(ipc_callid_t iid, ipc_call_t *icall) 274 252 { … … 277 255 ipc_call_t call; 278 256 char c; 279 unsigned int row, col ;257 unsigned int row, col, w, h; 280 258 int bg_color, fg_color, attr; 281 259 uint32_t bg_rgb, fg_rgb; … … 310 288 break; 311 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 294 if (!interbuf) { 313 295 retval = EINVAL; 314 296 break; 315 297 } 316 draw_text_data(interbuf); 298 if (col + w > scr_width || row + h > scr_height) { 299 retval = EINVAL; 300 break; 301 } 302 draw_text_data(interbuf, col, row, w, h); 317 303 retval = 0; 318 304 break; … … 335 321 retval = 0; 336 322 break; 337 case FB_WRITE:338 fb_write(callid, &call);339 340 /* Message already answered */341 continue;342 323 case FB_CURSOR_GOTO: 343 324 row = IPC_GET_ARG1(call);
Note:
See TracChangeset
for help on using the changeset viewer.