212,26 → 212,26 |
* @param y Y coord relative to viewport |
* @param color RGB color |
*/ |
static void putpixel(viewport_t *vport, unsigned int x, unsigned int y, int color) |
static void putpixel(int vp, unsigned int x, unsigned int y, int color) |
{ |
int dx = vport->x + x; |
int dy = vport->y + y; |
int dx = viewports[vp].x + x; |
int dy = viewports[vp].y + y; |
|
if (! (vport->paused && vport->dbdata)) |
if (! viewports[vp].paused) |
(*screen.rgb2scr)(&screen.fbaddress[POINTPOS(dx,dy)],color); |
|
if (vport->dbdata) { |
int dline = (y + vport->dboffset) % vport->height; |
int doffset = screen.pixelbytes * (dline * vport->width + x); |
(*screen.rgb2scr)(&vport->dbdata[doffset],color); |
if (viewports[vp].dbdata) { |
int dline = (y + viewports[vp].dboffset) % viewports[vp].height; |
int doffset = screen.pixelbytes * (dline * viewports[vp].width + x); |
(*screen.rgb2scr)(&viewports[vp].dbdata[doffset],color); |
} |
} |
|
/** Get pixel from viewport */ |
static int getpixel(viewport_t *vport, unsigned int x, unsigned int y) |
static int getpixel(int vp, unsigned int x, unsigned int y) |
{ |
int dx = vport->x + x; |
int dy = vport->y + y; |
int dx = viewports[vp].x + x; |
int dy = viewports[vp].y + y; |
|
return (*screen.scr2rgb)(&screen.fbaddress[POINTPOS(dx,dy)]); |
} |
242,7 → 242,7 |
(*screen.rgb2scr)(&mem[POINTPOS(x,y)],color); |
} |
|
static void draw_rectangle(viewport_t *vport, unsigned int sx, unsigned int sy, |
static void draw_rectangle(int vp, unsigned int sx, unsigned int sy, |
unsigned int width, unsigned int height, |
int color) |
{ |
256,20 → 256,20 |
for (x = 0; x < width; x++) |
putpixel_mem(tmpline, x, 0, color); |
|
if (!vport->paused) { |
if (!viewports[vp].paused) { |
/* Recompute to screen coords */ |
sx += vport->x; |
sy += vport->y; |
sx += viewports[vp].x; |
sy += viewports[vp].y; |
/* Copy the rest */ |
for (y = sy;y < sy+height; y++) |
memcpy(&screen.fbaddress[POINTPOS(sx,y)], tmpline, |
screen.pixelbytes * width); |
} |
if (vport->dbdata) { |
if (viewports[vp].dbdata) { |
for (y=sy;y < sy+height; y++) { |
int rline = (y + vport->dboffset) % vport->height; |
int rpos = (rline * vport->width + sx) * screen.pixelbytes; |
memcpy(&vport->dbdata[rpos], tmpline, screen.pixelbytes * width); |
int rline = (y + viewports[vp].dboffset) % viewports[vp].height; |
int rpos = (rline * viewports[vp].width + sx) * screen.pixelbytes; |
memcpy(&viewports[vp].dbdata[rpos], tmpline, screen.pixelbytes * width); |
} |
} |
|
276,9 → 276,11 |
} |
|
/** Fill viewport with background color */ |
static void clear_port(viewport_t *vport) |
static void clear_port(int vp) |
{ |
draw_rectangle(vport, 0, 0, vport->width, vport->height, vport->style.bg_color); |
viewport_t *vport = &viewports[vp]; |
|
draw_rectangle(vp, 0, 0, vport->width, vport->height, vport->style.bg_color); |
} |
|
/** Scroll unbuffered viewport up/down |
286,11 → 288,12 |
* @param vp Viewport to scroll |
* @param rows Positive number - scroll up, negative - scroll down |
*/ |
static void scroll_port_nodb(viewport_t *vport, int lines) |
static void scroll_port_nodb(int vp, int lines) |
{ |
int y; |
int startline; |
int endline; |
viewport_t *vport = &viewports[vp]; |
|
if (lines > 0) { |
for (y=vport->y; y < vport->y+vport->height - lines; y++) |
297,7 → 300,7 |
memcpy(&screen.fbaddress[POINTPOS(vport->x,y)], |
&screen.fbaddress[POINTPOS(vport->x,y + lines)], |
screen.pixelbytes * vport->width); |
draw_rectangle(vport, 0, vport->height - lines, |
draw_rectangle(vp, 0, vport->height - lines, |
vport->width, lines, vport->style.bg_color); |
} else if (lines < 0) { |
lines = -lines; |
305,66 → 308,67 |
memcpy(&screen.fbaddress[POINTPOS(vport->x,y)], |
&screen.fbaddress[POINTPOS(vport->x,y - lines)], |
screen.pixelbytes * vport->width); |
draw_rectangle(vport, 0, 0, vport->width, lines, vport->style.bg_color); |
draw_rectangle(vp, 0, 0, vport->width, lines, vport->style.bg_color); |
} |
} |
|
/** Refresh given viewport from double buffer */ |
static void refresh_viewport_db(viewport_t *vport) |
static void refresh_viewport_db(int vp) |
{ |
unsigned int y, srcy, srcoff, dsty, dstx; |
|
for (y = 0; y < vport->height; y++) { |
srcy = (y + vport->dboffset) % vport->height; |
srcoff = (vport->width * srcy) * screen.pixelbytes; |
for (y = 0; y < viewports[vp].height; y++) { |
srcy = (y + viewports[vp].dboffset) % viewports[vp].height; |
srcoff = (viewports[vp].width * srcy) * screen.pixelbytes; |
|
dstx = vport->x; |
dsty = vport->y + y; |
dstx = viewports[vp].x; |
dsty = viewports[vp].y + y; |
|
memcpy(&screen.fbaddress[POINTPOS(dstx,dsty)], |
&vport->dbdata[srcoff], |
vport->width*screen.pixelbytes); |
&viewports[vp].dbdata[srcoff], |
viewports[vp].width*screen.pixelbytes); |
} |
} |
|
/** Scroll viewport that has double buffering enabled */ |
static void scroll_port_db(viewport_t *vport, int lines) |
static void scroll_port_db(int vp, int lines) |
{ |
++vport->paused; |
++viewports[vp].paused; |
if (lines > 0) { |
draw_rectangle(vport, 0, 0, vport->width, lines, |
vport->style.bg_color); |
vport->dboffset += lines; |
vport->dboffset %= vport->height; |
draw_rectangle(vp, 0, 0, viewports[vp].width, lines, |
viewports[vp].style.bg_color); |
viewports[vp].dboffset += lines; |
viewports[vp].dboffset %= viewports[vp].height; |
} else if (lines < 0) { |
lines = -lines; |
draw_rectangle(vport, 0, vport->height-lines, |
vport->width, lines, |
vport->style.bg_color); |
draw_rectangle(vp, 0, viewports[vp].height-lines, |
viewports[vp].width, lines, |
viewports[vp].style.bg_color); |
|
if (vport->dboffset < lines) |
vport->dboffset += vport->height; |
vport->dboffset -= lines; |
if (viewports[vp].dboffset < lines) |
viewports[vp].dboffset += viewports[vp].height; |
viewports[vp].dboffset -= lines; |
} |
|
--vport->paused; |
--viewports[vp].paused; |
|
refresh_viewport_db(vport); |
refresh_viewport_db(vp); |
|
} |
|
/** Scrolls viewport given number of lines */ |
static void scroll_port(viewport_t *vport, int lines) |
static void scroll_port(int vp, int lines) |
{ |
if (vport->dbdata) |
scroll_port_db(vport, lines); |
if (viewports[vp].dbdata) |
scroll_port_db(vp, lines); |
else |
scroll_port_nodb(vport, lines); |
scroll_port_nodb(vp, lines); |
|
} |
|
static void invert_pixel(viewport_t *vport, unsigned int x, unsigned int y) |
static void invert_pixel(int vp,unsigned int x, unsigned int y) |
{ |
putpixel(vport, x, y, ~getpixel(vport, x, y)); |
putpixel(vp, x, y, ~getpixel(vp, x, y)); |
} |
|
|
379,7 → 383,7 |
* @param style Color of the character |
* @param transparent If false, print background color |
*/ |
static void draw_glyph(viewport_t *vport,__u8 glyph, unsigned int sx, unsigned int sy, |
static void draw_glyph(int vp,__u8 glyph, unsigned int sx, unsigned int sy, |
style_t style, int transparent) |
{ |
int i; |
390,15 → 394,15 |
glline = fb_font[glyph * FONT_SCANLINES + y]; |
for (i = 0; i < 8; i++) { |
if (glline & (1 << (7 - i))) |
putpixel(vport, sx + i, sy + y, style.fg_color); |
putpixel(vp, sx + i, sy + y, style.fg_color); |
else if (!transparent) |
putpixel(vport, sx + i, sy + y, style.bg_color); |
putpixel(vp, sx + i, sy + y, style.bg_color); |
} |
} |
} |
|
/** Invert character at given position */ |
static void invert_char(viewport_t *vport,unsigned int row, unsigned int col) |
static void invert_char(int vp,unsigned int row, unsigned int col) |
{ |
unsigned int x; |
unsigned int y; |
405,7 → 409,7 |
|
for (x = 0; x < COL_WIDTH; x++) |
for (y = 0; y < FONT_SCANLINES; y++) |
invert_pixel(vport, col * COL_WIDTH + x, row * FONT_SCANLINES + y); |
invert_pixel(vp, col * COL_WIDTH + x, row * FONT_SCANLINES + y); |
} |
|
/***************************************************************/ |
500,31 → 504,37 |
} |
|
/** Hide cursor if it is shown */ |
static void cursor_hide(viewport_t *vport) |
static void cursor_hide(int vp) |
{ |
viewport_t *vport = &viewports[vp]; |
|
if (vport->cursor_active && vport->cursor_shown) { |
invert_char(vport, vport->cur_row, vport->cur_col); |
invert_char(vp, vport->cur_row, vport->cur_col); |
vport->cursor_shown = 0; |
} |
} |
|
/** Show cursor if cursor showing is enabled */ |
static void cursor_print(viewport_t *vport) |
static void cursor_print(int vp) |
{ |
viewport_t *vport = &viewports[vp]; |
|
/* Do not check for cursor_shown */ |
if (vport->cursor_active) { |
invert_char(vport, vport->cur_row, vport->cur_col); |
invert_char(vp, vport->cur_row, vport->cur_col); |
vport->cursor_shown = 1; |
} |
} |
|
/** Invert cursor, if it is enabled */ |
static void cursor_blink(viewport_t *vport) |
static void cursor_blink(int vp) |
{ |
viewport_t *vport = &viewports[vp]; |
|
if (vport->cursor_shown) |
cursor_hide(vport); |
cursor_hide(vp); |
else |
cursor_print(vport); |
cursor_print(vp); |
} |
|
/** Draw character at given position relative to viewport |
535,15 → 545,16 |
* @param col Screen position relative to viewport |
* @param transparent If false, print background color with character |
*/ |
static void draw_char(viewport_t *vport, char c, unsigned int row, unsigned int col, |
style_t style, int transparent) |
static void draw_char(int vp, char c, unsigned int row, unsigned int col, style_t style, int transparent) |
{ |
viewport_t *vport = &viewports[vp]; |
|
/* Optimize - do not hide cursor if we are going to overwrite it */ |
if (vport->cursor_active && vport->cursor_shown && |
(vport->cur_col != col || vport->cur_row != row)) |
invert_char(vport, vport->cur_row, vport->cur_col); |
invert_char(vp, vport->cur_row, vport->cur_col); |
|
draw_glyph(vport, c, col * COL_WIDTH, row * FONT_SCANLINES, style, transparent); |
draw_glyph(vp, c, col * COL_WIDTH, row * FONT_SCANLINES, style, transparent); |
|
vport->cur_col = col; |
vport->cur_row = row; |
555,7 → 566,7 |
if (vport->cur_row >= vport->rows) |
vport->cur_row--; |
} |
cursor_print(vport); |
cursor_print(vp); |
} |
|
/** Draw text data to viewport |
563,22 → 574,23 |
* @param vp Viewport id |
* @param data Text data fitting exactly into viewport |
*/ |
static void draw_text_data(viewport_t *vport, keyfield_t *data) |
static void draw_text_data(int vp, keyfield_t *data) |
{ |
viewport_t *vport = &viewports[vp]; |
int i; |
char c; |
int col,row; |
|
clear_port(vport); |
clear_port(vp); |
for (i=0; i < vport->cols * vport->rows; i++) { |
if (data[i].character == ' ' && style_same(data[i].style,vport->style)) |
continue; |
col = i % vport->cols; |
row = i / vport->cols; |
draw_glyph(vport, data[i].character, col * COL_WIDTH, row * FONT_SCANLINES, |
draw_glyph(vp, data[i].character, col * COL_WIDTH, row * FONT_SCANLINES, |
data[i].style, style_same(data[i].style,vport->style)); |
} |
cursor_print(vport); |
cursor_print(vp); |
} |
|
|
620,7 → 632,7 |
return ENOMEM; |
|
ppm_draw(shm, size, 0, 0, pmap->width, pmap->height, |
(putpixel_cb_t)putpixel_pixmap, (void *)pm); |
putpixel_pixmap, pm); |
|
return pm; |
} |
713,7 → 725,7 |
} |
|
ppm_draw(shm, shm_size, IPC_GET_ARG1(*call), IPC_GET_ARG2(*call), |
vport->width - x, vport->height - y, (putpixel_cb_t)putpixel, vport); |
vport->width - x, vport->height - y, putpixel, vp); |
break; |
case FB_DRAW_TEXT_DATA: |
if (!interbuffer) { |
724,7 → 736,7 |
retval = EINVAL; |
break; |
} |
draw_text_data(vport, interbuffer); |
draw_text_data(vp, interbuffer); |
break; |
default: |
handled = 0; |
983,7 → 995,7 |
callid = async_get_call(&call); |
|
if (!callid) { |
cursor_blink(vport); |
cursor_blink(vp); |
anims_tick(); |
continue; |
} |
1013,11 → 1025,11 |
} |
ipc_answer_fast(callid,0,0,0); |
|
draw_char(vport, c, row, col, vport->style, IPC_GET_METHOD(call) == FB_TRANS_PUTCHAR); |
draw_char(vp, c, row, col, vport->style, IPC_GET_METHOD(call) == FB_TRANS_PUTCHAR); |
continue; /* msg already answered */ |
case FB_CLEAR: |
clear_port(vport); |
cursor_print(vport); |
clear_port(vp); |
cursor_print(vp); |
retval = 0; |
break; |
case FB_CURSOR_GOTO: |
1028,15 → 1040,15 |
break; |
} |
retval = 0; |
cursor_hide(vport); |
cursor_hide(vp); |
vport->cur_col = col; |
vport->cur_row = row; |
cursor_print(vport); |
cursor_print(vp); |
break; |
case FB_CURSOR_VISIBILITY: |
cursor_hide(vport); |
cursor_hide(vp); |
vport->cursor_active = IPC_GET_ARG1(call); |
cursor_print(vport); |
cursor_print(vp); |
retval = 0; |
break; |
case FB_GET_CSIZE: |
1048,9 → 1060,9 |
retval = EINVAL; |
break; |
} |
cursor_hide(vport); |
scroll_port(vport, i*FONT_SCANLINES); |
cursor_print(vport); |
cursor_hide(vp); |
scroll_port(vp, i*FONT_SCANLINES); |
cursor_print(vp); |
retval = 0; |
break; |
case FB_VIEWPORT_DB: |
1087,10 → 1099,10 |
retval = EADDRNOTAVAIL; |
break; |
} |
cursor_hide(vport); |
cursor_hide(vp); |
vp = i; |
vport = &viewports[vp]; |
cursor_print(vport); |
cursor_print(vp); |
retval = 0; |
break; |
case FB_VIEWPORT_CREATE: |