Beispiel #1
0
static void rk86_video_draw_cursor(int mode) {
    int x = cursor_x * char_width;
    int const y = cursor_y * (char_height + char_height_gap) + char_height;
    int const xx = x + char_width;
    for (x = x; x < xx; ++x)
        video_draw_pixel(x, y, mode);
}
Beispiel #2
0
// This function draws a character based on using a bitmap font.
// I wanted to make this function to be fast, so I manually moved out
// the invariants from the loops. The compiler may also do this but 
// the free version of XC32 1.0 only allows -O1 optimization.
void rk86_video_draw_char(int x, int y, int c) {
    char const* bitmap = rk86_font + (c & 0x7f) * 8;
    int offset_y = y * (char_height + char_height_gap);
    int const offset_x = x * char_width;
    int xx, yy, byte, mask;
    for (yy = 0; yy < char_height; ++yy, ++offset_y, ++bitmap) {
        byte = *bitmap;
        mask = 0x01 << (char_width - 1);
        for (xx = offset_x; mask != 0; ++xx, mask >>= 1)
            video_draw_pixel(xx, offset_y, !(byte & mask));
    }
}
Beispiel #3
0
static void misc_draw_screen(struct sysreq_misc_draw_screen *req)
{
	extern void video_draw_pixel(int x, int y, unsigned int clr);
	extern void video_draw_bitmap(int x, int y, int width, int height, int bpp, void * user_bitmap);
	extern void video_get_screen_resolution(int * width, int * height, int *bpp);

	if (req->type == SYSREQ_MISC_DRAW_SCREEN_BITMAP)
		video_draw_bitmap(req->x, req->y, req->bitmap.width, req->bitmap.height, req->bitmap.bpp, req->bitmap.buffer);
	else if (req->type == SYSREQ_MISC_DRAW_SCREEN_PIXEL)
		video_draw_pixel(req->x, req->y, req->pixel.clr);
	else if (req->type == SYSREQ_MISC_DRAW_GET_RESOLUTION)
		video_get_screen_resolution(&req->resolution.width, &req->resolution.height, &req->resolution.bpp);
}
Beispiel #4
0
static void video_draw_cursor(unsigned int x, unsigned int y, unsigned int length, unsigned int width, unsigned int clr)
{
	unsigned int	i;
	unsigned int	j;	
	unsigned int	end_x =(x + width);
	unsigned int	end_y =(y + length);

	for (i = x; i < end_x; i++)
	{
		for (j = y; j < end_y; j++)
		{
			video_draw_pixel(i, j, clr);	
		}
	}
}
Beispiel #5
0
void video_draw_line(unsigned char *rgb, unsigned int w, unsigned int h, unsigned int rowstride, unsigned int x0, unsigned int y0, unsigned int x1, unsigned int y1, unsigned char r, unsigned char g, unsigned char b) {
    // Bresenham algorithm

    x0 = CLAMP(0, x0, w-1);
    y0 = CLAMP(0, y0, h-1);
    x1 = CLAMP(0, x1, w-1);
    y1 = CLAMP(0, y1, h-1);

    int dx = abs((int)x1-(int)x0), sx = x0<x1 ? 1 : -1;
    int dy = abs((int)y1-(int)y0), sy = y0<y1 ? 1 : -1; 
    int err = (dx>dy ? dx : -dy)/2, e2;

    for(;;) {
        video_draw_pixel(rgb, rowstride, h, x0, y0, r, g, b);

        if(x0==x1 && y0==y1) break;
        e2 = err;
        if(e2 >-dx) { err -= dy; x0 += sx; }
        if(e2 < dy) { err += dx; y0 += sy; }
    }
}
Beispiel #6
0
void video_draw_circle(unsigned char *rgb, unsigned int w, unsigned int h, unsigned int rowstride, unsigned int xc, unsigned int yc, unsigned int ray, unsigned char r, unsigned char g, unsigned char b) {
    unsigned int x= ray, y= 0;//local coords     
    int          cd2= 0;    //current distance squared - radius squared

    video_draw_pixel(rgb, rowstride, h, xc-ray, yc, r, g, b);
    video_draw_pixel(rgb, rowstride, h, xc+ray, yc, r, g, b);
    video_draw_pixel(rgb, rowstride, h, xc, yc-ray, r, g, b);
    video_draw_pixel(rgb, rowstride, h, xc, yc+ray, r, g, b);
 
    while (x > y)    //only formulate 1/8 of circle
    {
        cd2-= (--x) - (++y);
        if (cd2 < 0) cd2+=x++;

        video_draw_pixel(rgb, rowstride, h, xc-x, yc-y, r, g, b);//upper left left
        video_draw_pixel(rgb, rowstride, h, xc-y, yc-x, r, g, b);//upper upper left
        video_draw_pixel(rgb, rowstride, h, xc+y, yc-x, r, g, b);//upper upper right
        video_draw_pixel(rgb, rowstride, h, xc+x, yc-y, r, g, b);//upper right right
        video_draw_pixel(rgb, rowstride, h, xc-x, yc+y, r, g, b);//lower left left
        video_draw_pixel(rgb, rowstride, h, xc-y, yc+x, r, g, b);//lower lower left
        video_draw_pixel(rgb, rowstride, h, xc+y, yc+x, r, g, b);//lower lower right
        video_draw_pixel(rgb, rowstride, h, xc+x, yc+y, r, g, b);//lower right right
     } 
}