Esempio n. 1
0
int ui_init(int *fd_keyboard, int *fd_mouse)
{
    int dac_shift, i, mouse_type, force_red;
    
    if (vga_init() == 0)
    {
        old_mode = vga_getcurrentmode();
        vga_setmode(G640x480x256);
        /*vga_setlinearaddressing();*/
        if (vga_ext_set(VGA_EXT_AVAILABLE, VGA_AVAIL_FLAGS) & VGA_CLUT8)
        {
            vga_ext_set(VGA_EXT_SET, VGA_CLUT8);
            dac_shift = 0;
        }
        else
            dac_shift = 2;
        force_red = 0xFF;
        for (i = 0; i < 255; i++)
            vga_setpalette(i,
                           i >> dac_shift,
                           (i & force_red) >> dac_shift,
                           (i & force_red) >> dac_shift);
        vga_setpalette(UI_LO_COLOR, 127 >> dac_shift, 0, 0); /* Save dim    red for UI */
        vga_setpalette(UI_HI_COLOR, 255 >> dac_shift, 0, 0); /* Save bright red for UI */
        vga = vga_getmodeinfo(vga_getcurrentmode());
    }
Esempio n. 2
0
void I_ShutdownGraphics(void)
{
	keyboard_close();
	if (usemouse)
		mouse_close();

	if (vga_getcurrentmode() != TEXT)
		vga_setmode(TEXT);
}
Esempio n. 3
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;
	}
Esempio n. 4
0
static void SVGA_UpdateVideoInfo(_THIS)
{
	vga_modeinfo *modeinfo;

	this->info.wm_available = 0;
	this->info.hw_available = 1;
	modeinfo = vga_getmodeinfo(vga_getcurrentmode());
	this->info.video_mem = modeinfo->memory;
	/* FIXME: Add hardware accelerated blit information */
#ifdef SVGALIB_DEBUG
	printf("Hardware accelerated blit: %savailable\n", modeinfo->haveblit ? "" : "not ");
#endif
}
Esempio n. 5
0
void get_graphics_line(char *value)
{	char *video_access;
	int  bpp;

	if (lbuf_addr == NULL)
		video_access = "";
	else
	if (lbuf_len < screen_size)
		video_access = " banked";
	else
		video_access = " linear";

	bpp = (ScrDepth < 8) ? ScrDepth : BytesPerPixel*8;		
	snprintf (value, 81, "Mode %d: %dx%d %dbpp%s, kbd: %s, bkgr: %s",
  	  vga_getcurrentmode(), ScrWidth, ScrHeight, bpp,
	   video_access, kbd_raw ? "raw" : "cooked",
          run_background ? "yes" : "no");
}
Esempio n. 6
0
void graph_end(void)
{
	int i;
	PIXMAP_INFO *xpm;

  if(vga_getcurrentmode() != TEXT)
			vga_setmode(TEXT);


	if (cm_pixels) free(cm_pixels);

	for (i=0; i<PaneCount; i++)
	{ xpm = all_panes[i];
     if (xpm != NULL)  free_pixmap(xpm);    
	}


}
Esempio n. 7
0
int graph_init_video(void)
{
  int 	rc = 0;
	int   screen_colours;
	vga_modeinfo *vminfo;
	
	if (tcgetpgrp(STDIN_FILENO) != getpid())
	{	fprintf(stderr, "Sorry, this application cannot start in background\n");
		return 0;
	}

	pltf = PLTF_SVGA;

  /*-----------------------------------------------------------*/     
	/* Checking libvga version, 1.4.0 and prior will return (-1) */
	/* Currently you need IOPERM for 1.9.x to run as a non-priv  */
	/* user, however set IOPERM upsets upsets previous versions  */
  /*-----------------------------------------------------------*/     
  if (vga_setmode(-1) >= 0x1900)	setenv("IOPERM", "1", 0);  

	rc = vga_init();
	if (rc != 0)
	{ fprintf(stderr, "Can't initialise SVGA library. \n"
     		    "Possible solution: log as root, and enter:\n"
		    "\tchown 0 ifrac\n"
		    "\tchmod 4755 ifrac\n");
	  return 0;
	}	

#ifdef SVGALIB_BACKGROUND_SUPPORT
  set_background_routines();
#else
	run_background = 0;
#endif

	if (!set_video_mode())
	{  fprintf(stderr, "Sorry, unable to set video mode. \n");
      	   return 0;		
	}

	vminfo = vga_getmodeinfo(vga_getcurrentmode());
	
	WndWidth = ScrWidth = vminfo->width;
	WndHeight = ScrHeight = vminfo->height;

	screen_colours = vminfo->colors;
	if (screen_colours < 16)
	{	fprintf (stderr,
		   "This application requires at least 16-colour mode\n");
		return 0;
	}	 

	ScrDepth = 0;
	while((screen_colours>>=1) != 0) ScrDepth++;

	if (ScrDepth <= 8)
	{  BytesPerPixel = 1;
	   stored_colours = 1;
	}
	else
	{  BytesPerPixel = vminfo->bytesperpixel;
	   stored_colours = 0;
	}
	
	scan_line_width = vminfo->linewidth;
	screen_size = scan_line_width * ScrHeight;

	if (ScrDepth < 8) 
		DirVideo = 0;
	else {
		vga_setpage(screen_page=0);

		if (DirVideo == 2 && (vminfo->flags & CAPABLE_LINEAR)) 
			lbuf_len = vga_setlinearaddressing();
	
		if (DirVideo > 0) 
			lbuf_addr = vga_getgraphmem();
	}
	
	return  1;
}