Rev 1505 | Rev 1513 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1505 | Rev 1509 | ||
---|---|---|---|
Line 74... | Line 74... | ||
74 | unsigned int width, height; |
74 | unsigned int width, height; |
75 | 75 | ||
76 | /* Text support in window */ |
76 | /* Text support in window */ |
77 | unsigned int rows, cols; |
77 | unsigned int rows, cols; |
78 | /* Style for text printing */ |
78 | /* Style for text printing */ |
79 | int bgcolor, fgcolor; |
79 | style_t style; |
80 | /* Auto-cursor position */ |
80 | /* Auto-cursor position */ |
81 | int cursor_active, cur_col, cur_row; |
81 | int cursor_active, cur_col, cur_row; |
82 | int cursor_shown; |
82 | int cursor_shown; |
83 | } viewport_t; |
83 | } viewport_t; |
84 | 84 | ||
Line 189... | Line 189... | ||
189 | /** Fill line with color BGCOLOR */ |
189 | /** Fill line with color BGCOLOR */ |
190 | static void clear_line(int vp, unsigned int y) |
190 | static void clear_line(int vp, unsigned int y) |
191 | { |
191 | { |
192 | unsigned int x; |
192 | unsigned int x; |
193 | for (x = 0; x < viewports[vp].width; x++) |
193 | for (x = 0; x < viewports[vp].width; x++) |
194 | putpixel(vp, x, y, viewports[vp].bgcolor); |
194 | putpixel(vp, x, y, viewports[vp].style.bg_color); |
195 | } |
195 | } |
196 | 196 | ||
197 | /** Fill viewport with background color */ |
197 | /** Fill viewport with background color */ |
198 | static void clear_port(int vp) |
198 | static void clear_port(int vp) |
199 | { |
199 | { |
Line 237... | Line 237... | ||
237 | for (y=viewports[vp].y + viewports[vp].height-1; y >= viewports[vp].y + rows*FONT_SCANLINES; y--) |
237 | for (y=viewports[vp].y + viewports[vp].height-1; y >= viewports[vp].y + rows*FONT_SCANLINES; y--) |
238 | memcpy(&screen.fbaddress[POINTPOS(viewports[vp].x,y)], |
238 | memcpy(&screen.fbaddress[POINTPOS(viewports[vp].x,y)], |
239 | &screen.fbaddress[POINTPOS(viewports[vp].x,y - rows*FONT_SCANLINES)], |
239 | &screen.fbaddress[POINTPOS(viewports[vp].x,y - rows*FONT_SCANLINES)], |
240 | screen.pixelbytes * viewports[vp].width); |
240 | screen.pixelbytes * viewports[vp].width); |
241 | /* Clear first row */ |
241 | /* Clear first row */ |
242 | clear_line(0, viewports[vp].bgcolor); |
242 | clear_line(0, viewports[vp].style.bg_color); |
243 | for (y=1;y < rows*FONT_SCANLINES; y++) |
243 | for (y=1;y < rows*FONT_SCANLINES; y++) |
244 | memcpy(&screen.fbaddress[POINTPOS(viewports[vp].x,viewports[vp].y+y)], |
244 | memcpy(&screen.fbaddress[POINTPOS(viewports[vp].x,viewports[vp].y+y)], |
245 | &screen.fbaddress[POINTPOS(viewports[vp].x,viewports[vp].y)], |
245 | &screen.fbaddress[POINTPOS(viewports[vp].x,viewports[vp].y)], |
246 | screen.pixelbytes * viewports[vp].width); |
246 | screen.pixelbytes * viewports[vp].width); |
247 | } |
247 | } |
Line 251... | Line 251... | ||
251 | { |
251 | { |
252 | putpixel(vp, x, y, ~getpixel(vp, x, y)); |
252 | putpixel(vp, x, y, ~getpixel(vp, x, y)); |
253 | } |
253 | } |
254 | 254 | ||
255 | 255 | ||
256 | /** Draw one line of glyph at a given position */ |
- | |
257 | static void draw_glyph_line(int vp,unsigned int glline, unsigned int x, unsigned int y) |
- | |
258 | { |
- | |
259 | unsigned int i; |
- | |
260 | - | ||
261 | for (i = 0; i < 8; i++) |
- | |
262 | if (glline & (1 << (7 - i))) { |
- | |
263 | putpixel(vp, x + i, y, viewports[vp].fgcolor); |
- | |
264 | } else |
- | |
265 | putpixel(vp, x + i, y, viewports[vp].bgcolor); |
- | |
266 | } |
- | |
267 | - | ||
268 | /***************************************************************/ |
256 | /***************************************************************/ |
269 | /* Character-console functions */ |
257 | /* Character-console functions */ |
270 | 258 | ||
271 | /** Draw character at given position */ |
259 | /** Draw character at given position */ |
272 | static void draw_glyph(int vp,__u8 glyph, unsigned int sx, unsigned int sy) |
260 | static void draw_glyph(int vp,__u8 glyph, unsigned int sx, unsigned int sy, style_t style) |
273 | { |
261 | { |
- | 262 | int i; |
|
274 | unsigned int y; |
263 | unsigned int y; |
- | 264 | unsigned int glline; |
|
275 | 265 | ||
276 | for (y = 0; y < FONT_SCANLINES; y++) |
266 | for (y = 0; y < FONT_SCANLINES; y++) { |
277 | draw_glyph_line(vp ,fb_font[glyph * FONT_SCANLINES + y], sx, sy + y); |
267 | glline = fb_font[glyph * FONT_SCANLINES + y]; |
- | 268 | for (i = 0; i < 8; i++) { |
|
- | 269 | if (glline & (1 << (7 - i))) |
|
- | 270 | putpixel(vp, sx + i, sy + y, style.fg_color); |
|
- | 271 | else |
|
- | 272 | putpixel(vp, sx + i, sy + y, style.bg_color); |
|
- | 273 | } |
|
- | 274 | } |
|
278 | } |
275 | } |
279 | 276 | ||
280 | /** Invert character at given position */ |
277 | /** Invert character at given position */ |
281 | static void invert_char(int vp,unsigned int row, unsigned int col) |
278 | static void invert_char(int vp,unsigned int row, unsigned int col) |
282 | { |
279 | { |
Line 300... | Line 297... | ||
300 | for (y = 0; y < helenos_height; y++) |
297 | for (y = 0; y < helenos_height; y++) |
301 | for (x = 0; x < helenos_width; x++) { |
298 | for (x = 0; x < helenos_width; x++) { |
302 | byte = helenos_bits[rowbytes * y + x / 8]; |
299 | byte = helenos_bits[rowbytes * y + x / 8]; |
303 | byte >>= x % 8; |
300 | byte >>= x % 8; |
304 | if (byte & 1) |
301 | if (byte & 1) |
305 | putpixel(vp ,startx + x, starty + y, viewports[vp].fgcolor); |
302 | putpixel(vp ,startx + x, starty + y, viewports[vp].style.fg_color); |
306 | } |
303 | } |
307 | } |
304 | } |
308 | 305 | ||
309 | /***************************************************************/ |
306 | /***************************************************************/ |
310 | /* Stdout specific functions */ |
307 | /* Stdout specific functions */ |
Line 338... | Line 335... | ||
338 | viewports[i].height = height; |
335 | viewports[i].height = height; |
339 | 336 | ||
340 | viewports[i].rows = height / FONT_SCANLINES; |
337 | viewports[i].rows = height / FONT_SCANLINES; |
341 | viewports[i].cols = width / COL_WIDTH; |
338 | viewports[i].cols = width / COL_WIDTH; |
342 | 339 | ||
343 | viewports[i].bgcolor = DEFAULT_BGCOLOR; |
340 | viewports[i].style.bg_color = DEFAULT_BGCOLOR; |
344 | viewports[i].fgcolor = DEFAULT_FGCOLOR; |
341 | viewports[i].style.fg_color = DEFAULT_FGCOLOR; |
345 | 342 | ||
346 | viewports[i].cur_col = 0; |
343 | viewports[i].cur_col = 0; |
347 | viewports[i].cur_row = 0; |
344 | viewports[i].cur_row = 0; |
348 | viewports[i].cursor_active = 0; |
345 | viewports[i].cursor_active = 0; |
349 | 346 | ||
Line 435... | Line 432... | ||
435 | * @param vp Viewport identification |
432 | * @param vp Viewport identification |
436 | * @param c Character to print |
433 | * @param c Character to print |
437 | * @param row Screen position relative to viewport |
434 | * @param row Screen position relative to viewport |
438 | * @param col Screen position relative to viewport |
435 | * @param col Screen position relative to viewport |
439 | */ |
436 | */ |
440 | static void draw_char(int vp, char c, unsigned int row, unsigned int col) |
437 | static void draw_char(int vp, char c, unsigned int row, unsigned int col, style_t style) |
441 | { |
438 | { |
442 | viewport_t *vport = &viewports[vp]; |
439 | viewport_t *vport = &viewports[vp]; |
443 | 440 | ||
444 | /* Optimize - do not hide cursor if we are going to overwrite it */ |
441 | /* Optimize - do not hide cursor if we are going to overwrite it */ |
445 | if (vport->cursor_active && vport->cursor_shown && |
442 | if (vport->cursor_active && vport->cursor_shown && |
446 | (vport->cur_col != col || vport->cur_row != row)) |
443 | (vport->cur_col != col || vport->cur_row != row)) |
447 | invert_char(vp, vport->cur_row, vport->cur_col); |
444 | invert_char(vp, vport->cur_row, vport->cur_col); |
448 | 445 | ||
449 | draw_glyph(vp, c, col * COL_WIDTH, row * FONT_SCANLINES); |
446 | draw_glyph(vp, c, col * COL_WIDTH, row * FONT_SCANLINES, style); |
450 | 447 | ||
451 | vport->cur_col = col; |
448 | vport->cur_col = col; |
452 | vport->cur_row = row; |
449 | vport->cur_row = row; |
453 | 450 | ||
454 | vport->cur_col++; |
451 | vport->cur_col++; |
Line 467... | Line 464... | ||
467 | int i; |
464 | int i; |
468 | char c; |
465 | char c; |
469 | 466 | ||
470 | clear_port(vp); |
467 | clear_port(vp); |
471 | for (i=0; i < vport->cols * vport->rows; i++) { |
468 | for (i=0; i < vport->cols * vport->rows; i++) { |
472 | if (data[i].character == ' ') /* TODO: && data[i].style==vport->style */ |
469 | if (data[i].character == ' ' && style_same(data[i].style,vport->style)) |
473 | continue; |
470 | continue; |
474 | draw_char(vp, data[i].character, i/vport->rows, i % vport->cols); |
471 | draw_char(vp, data[i].character, i/vport->rows, i % vport->cols, |
- | 472 | data[i].style); |
|
475 | } |
473 | } |
476 | cursor_print(vp); |
474 | cursor_print(vp); |
477 | } |
475 | } |
478 | 476 | ||
479 | 477 | ||
Line 542... | Line 540... | ||
542 | retval = EINVAL; |
540 | retval = EINVAL; |
543 | break; |
541 | break; |
544 | } |
542 | } |
545 | ipc_answer_fast(callid,0,0,0); |
543 | ipc_answer_fast(callid,0,0,0); |
546 | 544 | ||
547 | draw_char(vp, c, row, col); |
545 | draw_char(vp, c, row, col, vport->style); |
548 | continue; /* msg already answered */ |
546 | continue; /* msg already answered */ |
549 | case FB_CLEAR: |
547 | case FB_CLEAR: |
550 | clear_port(vp); |
548 | clear_port(vp); |
551 | cursor_print(vp); |
549 | cursor_print(vp); |
552 | retval = 0; |
550 | retval = 0; |
Line 618... | Line 616... | ||
618 | } |
616 | } |
619 | viewports[i].initialized = 0; |
617 | viewports[i].initialized = 0; |
620 | retval = 0; |
618 | retval = 0; |
621 | break; |
619 | break; |
622 | case FB_SET_STYLE: |
620 | case FB_SET_STYLE: |
623 | vport->fgcolor = IPC_GET_ARG1(call); |
621 | vport->style.fg_color = IPC_GET_ARG1(call); |
624 | vport->bgcolor = IPC_GET_ARG2(call); |
622 | vport->style.bg_color = IPC_GET_ARG2(call); |
625 | retval = 0; |
623 | retval = 0; |
626 | break; |
624 | break; |
627 | case FB_GET_RESOLUTION: |
625 | case FB_GET_RESOLUTION: |
628 | ipc_answer_fast(callid, 0, screen.xres,screen.yres); |
626 | ipc_answer_fast(callid, 0, screen.xres,screen.yres); |
629 | continue; |
627 | continue; |