Beispiel #1
0
/*
 * Basic graphics routines.
 */
void gfx_hline(int x1, int x2, int y, int color, int flags)
{
    int x;
    
    if (flags & GFX_XOR_PIXEL)
    {
        for (x = x1; x < x2; x++)
        {
            vga_setcolor(color ^ vga_getpixel(x, y));
            vga_drawpixel(x, y);
        }
    }
    else
    {
        vga_setcolor(color);
        for (x = x1; x < x2; x++)
            vga_drawpixel(x, y);
    }
}
Beispiel #2
0
void gfx_vline(int y1, int y2, int x, int color, int flags)
{
    int y;
    
    if (flags & GFX_XOR_PIXEL)
    {
        for (y = y1; y < y2; y++)
        {
            vga_setcolor(color ^ vga_getpixel(x, y));
            vga_drawpixel(x, y);
        }
    }
    else
    {
        vga_setcolor(color);
        for (y = y1; y < y2; y++)
            vga_drawpixel(x, y);
    }
}
Beispiel #3
0
void DrawBrick(int x, int y, int color) 
/* Disegna a video il mattone alle coordinate x, y, con uno dei colori */
/* definiti nell'enumerazione "colortype", attingendo a tutte le       */
/* informazioni di colore definite precedentemente.                    */ 
{
  int i;
  for(i=0;i<NUM_PIXEL_MATTONI;i++) {
    if(color == OMBRA) vga_setcolor(0);
    else vga_setcolor(MattColor[color][Mattoni[i].colortype]);
    vga_drawpixel(x+Mattoni[i].addx, y+Mattoni[i].addy);
  }
}
Beispiel #4
0
	int main(int argc, char *argv[])
	{
		
		int i;
		int oldmode;
		int mode = G320x200x256;
		int width, height, colors;

		//获得当前的模式
		oldmode = vga_getcurrentmode();

		//初始化
		vga_init();

		//判断是否支持该模式
		if(vga_hasmode(mode)) 
			vga_setmode(mode);
		else {
			printf("No such mode\n");
			exit(1);
		}
		//取得信息
		width = vga_getxdim();
		height = vga_getydim();
		colors = vga_getcolors();

		//绘图
		for(i=0; i<colors; i++){
			vga_setcolor(i);
			vga_drawline(0, i, width-1, i);
		}
			

		vga_setcolor(3);
		for(i=0; i<50; i++) vga_drawpixel(i*4, 20);

		vga_setcolor(4);
		vga_drawline(100, 100, 300, 200);

		vga_setcolor(5);
		vga_drawline(0, 0, width-1, 0);
		vga_drawline(0, height-1, width-1, height-1);
		vga_drawline(0, 0, 0, height-1);
		vga_drawline(width-1, 0, width-1, height-1);

		//等待按键
		while(!vga_getkey());

		//恢复原来的模式 
		vga_setmode(oldmode);

		return 0;
	}
Beispiel #5
0
static void
drawSquares(int const xmax, int const ymax)
{
    unsigned int const center_x = xmax/2;
    /* The column just to the left of the center (assuming
       even number of columns)
    */
    unsigned int const center_y = ymax/2;
    /* The line just above the center (assuming
       even number of lines)
    */

    int x;

    for (x = 0; x < 64; x++) {
        int y;
        for (y = 0; y < 64; y++) {
            /* Top 3 squares */
            vga_setrgbcolor(x * 4 + 3, y * 4 + 3, 0);
            vga_drawpixel(center_x - 32 - 32 - 64 + x, center_y - 80 + y);
            vga_setrgbcolor(x * 4 + 3, 0, y * 4 + 3);
            vga_drawpixel(center_x -  32 + x,          center_y - 80 + y);
            vga_setrgbcolor(0, x * 4 + 3, y * 4 + 3);
            vga_drawpixel(center_x + 32 + 32 + x,      center_y - 80 + y);

            /* Bottom 3 squares */
            vga_setrgbcolor(x * 4 + 3, y * 4 + 3, 255);
            vga_drawpixel(center_x - 32 - 32 - 64 + x, center_y + 16 + y);
            vga_setrgbcolor(x * 4 + 3, 255, y * 4 + 3);
            vga_drawpixel(center_x -  32 + x,          center_y + 16 + y);
            vga_setrgbcolor(255, x * 4 + 3, y * 4 + 3);
            vga_drawpixel(center_x + 32 + 32 + x,      center_y + 16 + y);
        }
    }
}
Beispiel #6
0
void gfx_puttextimage(char *textimage, int base, char * text2color, int xpar, int width, int height, int xdst, int ydst)
{
    int x, y, color;
    int xlate[256];

    for (x = 0; text2color[x]; x++)
        xlate[(int)text2color[x]] = x + base;
    for (y = 0; y < height; y++)
        for (x = 0; x < width; x++)
        {
            color = xlate[(int)*textimage++];
            if (color != xpar)
            {
                vga_setcolor(color);
                vga_drawpixel(x, y);
            }
        }
}
Beispiel #7
0
static void
SVGA_drawpixel(PSD psd,COORD x, COORD y, PIXELVAL c)
{
	unsigned char gline, line;

	if(gr_mode == MODE_SET) {
		vga_setegacolor(c);
		vga_drawpixel(x, y);
		return;
	}
	/*
	 * This fishery is required because vgalib doesn't support
	 * xor drawing mode without acceleration.
	 */
	vga_getscansegment(&gline, x, y, 1);
	line = c;
	line ^= gline;
	vga_drawscansegment(&line, x, y, 1);
}
Beispiel #8
0
void gfx_putimage(unsigned char *image, int xpar, int xsrc, int ysrc, int width, int height, int pitch, int xdst, int ydst)
{
    int x, y;

    image += ysrc * pitch + xsrc;
    for (y = 0; y < height; y++)
    {
        if (xpar >= 0)
        {
            for (x = 0; x < width; x++)
                if (image[x] != xpar)
                {
                    vga_setcolor(image[x]);
                    vga_drawpixel(x, y);
                }
        }
        else
            vga_drawscansegment(image, xdst, ydst + y, width);
        image += pitch;
    }
}
Beispiel #9
0
void PutPixel(unsigned int x, unsigned int y, unsigned char color) {
  vga_setcolor(color);
  vga_drawpixel(x, y);
}