Ejemplo n.º 1
0
static int enter_graphics_mode (int which)
{
    int oldmode = current_vgamode;
    vga_setmode (TEXT);
    if (vga_setmode (which) < 0) {
	sleep(1);
	vga_setmode (TEXT);
	write_log ("SVGAlib doesn't like my video mode (%d). Giving up.\n", which);
	return 0;
    }
    current_vgamode = which;

    linear_mem = 0;
    if ((modeinfo.flags & CAPABLE_LINEAR) && ! currprefs.svga_no_linear) {
	int val = vga_setlinearaddressing ();
	int new_ul = val != -1 ? !need_dither : 0;
	if (using_linear == -1)
	    using_linear = new_ul;
	else
	    if (using_linear != new_ul) {
		leave_graphics_mode ();
		write_log ("SVGAlib feeling not sure about linear modes???\n");
		abort ();
	    }
	if (val != -1) {
	    linear_mem = (char *)vga_getgraphmem ();
	    write_log ("Using linear addressing: %p.\n", linear_mem);
	}
    }

    return post_enter_graphics ();
}
Ejemplo n.º 2
0
int main(void)
{
    vga_init();

    /* Create virtual screen. */
    vbuf = malloc(VWIDTH * VHEIGHT);
    gl_setcontextvirtual(VWIDTH, VHEIGHT, 1, 8, vbuf);

    /* Set Mode X-style 320x240x256. */
    vga_setmode(G320x240x256);
    gl_setrgbpalette();
    vga_clear();

    boxes();

    demo1();

    demo2();

    vga_setmode(G320x200x256);	/* Set linear 320x200x256. */
    gl_setrgbpalette();

    demo3();

    vga_setmode(TEXT);
    exit(0);
}
Ejemplo n.º 3
0
static int enter_graphics_mode_picasso (int which)
{
    int oldmode = current_vgamode;
    if (which == oldmode)
	return 1;

    vga_setmode (TEXT);
    if (vga_setmode (which) < 0) {
	sleep (1);
	vga_setmode (TEXT);
	write_log ("SVGAlib doesn't like my video mode (%d). Giving up.\n", which);
	exit (1);
    }
    current_vgamode = which;

    linear_mem = 0;
    if ((modeinfo.flags & CAPABLE_LINEAR) && ! currprefs.svga_no_linear) {
	int val = vga_setlinearaddressing ();
	if (val != -1) {
	    linear_mem = (char *)vga_getgraphmem ();
	    write_log ("Using linear addressing: %p.\n", linear_mem);
	}
    }

    keyboard_close ();
    mouse_close ();
    return post_enter_graphics ();
}
Ejemplo n.º 4
0
int main(int argc, char *argv[])
{
    vga_init();
    
    if(argc>=2) {
        timescale=atoi(argv[1]);
        if(timescale<1)timescale=1;
    }

    VGAMODE = vga_getdefaultmode();
    if (VGAMODE == -1)
	VGAMODE = G320x200x256;	/* Default mode. */

    if (!vga_hasmode(VGAMODE)) {
	printf("Mode not available.\n");
	exit(-1);
    }
    VIRTUAL = 0;		/* No virtual screen. */
    if (vga_getmodeinfo(VGAMODE)->colors == 16 ||
	(vga_getmodeinfo(VGAMODE)->flags & IS_MODEX))
	/* These modes are supported indirectly by vgagl. */
	VIRTUAL = 1;

    if (VIRTUAL) {
	/* Create virtual screen. */
	gl_setcontextvgavirtual(VGAMODE);
	backscreen = gl_allocatecontext();
	gl_getcontext(backscreen);
    }
    vga_setmode(VGAMODE);
    gl_setcontextvga(VGAMODE);	/* Physical screen context. */
    physicalscreen = gl_allocatecontext();
    gl_getcontext(physicalscreen);
    if (COLORS == 256)
	gl_setrgbpalette();

	if(argc==3)sleep(2);

    test();

    /* Now do the same with clipping enabled. */
    gl_clearscreen(0);
    gl_setclippingwindow(WIDTH / 4, HEIGHT / 4, WIDTH - WIDTH / 4 - 1,
			 HEIGHT - HEIGHT / 4 - 1);

    test();

    gl_disableclipping();
    if (COLORS == 256)
	/* Show the logo if using 256 color mode. */
	logotest();

    getchar();

    if (VIRTUAL)
	gl_freecontext(backscreen);
    vga_setmode(TEXT);
    exit(0);
}
Ejemplo n.º 5
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;
	}
Ejemplo n.º 6
0
int
main(int argc,char *argv[])
{
  int mode,c;

  vga_init();
  c=1;
  if(argc == 1)
    screen(10);     /* G640x480x256 */
  else
    c = 0;
  while(argc > 1)
    {
      argc--;
      c++;
      if(isdigit(*argv[c]))
	mode = atoi(argv[c]);
      else if(*argv[c] == 'G')
	mode = vga_getmodenumber(argv[c]);
      else
	{
	  printf("Unknown mode %s\n",argv[c]);
	  continue;
	}
      screen(mode);
    }
  vga_setmode(TEXT);
  return 0;
}
Ejemplo n.º 7
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());
    }
Ejemplo n.º 8
0
/* Note:  If we are terminated, this could be called in the middle of
   another SDL video routine -- notably UpdateRects.
*/
void SVGA_VideoQuit(_THIS)
{
	int i, j;

	/* Reset the console video mode */
	if ( this->screen && (this->screen->w && this->screen->h) ) {
		vga_setmode(TEXT);
	}
	keyboard_close();

	/* Free video mode lists */
	for ( i=0; i<NUM_MODELISTS; ++i ) {
		if ( SDL_modelist[i] != NULL ) {
			for ( j=0; SDL_modelist[i][j]; ++j )
				free(SDL_modelist[i][j]);
			free(SDL_modelist[i]);
			SDL_modelist[i] = NULL;
		}
		if ( SDL_vgamode[i] != NULL ) {
			free(SDL_vgamode[i]);
			SDL_vgamode[i] = NULL;
		}
	}
	if ( this->screen && (this->screen->flags & SDL_HWSURFACE) ) {
		/* Direct screen access, no memory buffer */
		this->screen->pixels = NULL;
	}
}
Ejemplo n.º 9
0
void Graphic::init_graph_mode()
{
#ifdef SVGALIB
  vga_init();
  int vga_mode=G640x480x16M;
  vga_setmode(vga_mode);
  gl_setcontextvga(vga_mode);
#endif

#if 0
  gl_setpalettecolor(BLUE, 0, 0, 63); // blue
  gl_setpalettecolor(BLACK, 0, 0, 0); // black
  gl_setpalettecolor(GREEN, 0, 63, 0);
  gl_setpalettecolor(RED, 63, 0, 0);
  gl_setpalettecolor(BROWN, 170/4, 85/4, 0);
  gl_setpalettecolor(MAGENTA, 170/4, 0, 170/4);
  gl_setpalettecolor(CYAN, 0, 170/4, 170/4);
  gl_setpalettecolor(GRAY, 48, 48, 48);

  gl_setpalettecolor(LIGHTBLACK, 85/4, 85/4, 85/4);
  gl_setpalettecolor(LIGHTBLUE, 85/4, 85/4, 255/4);
  gl_setpalettecolor(LIGHTGREEN, 85/4, 255/4, 85/4);
  gl_setpalettecolor(LIGHTCYAN, 85/4, 255/4, 255/4);
  gl_setpalettecolor(LIGHTRED, 25/45/4, 85/4, 85/4);
  gl_setpalettecolor(LIGHTMAGENTA, 255/4, 85/4, 255/4);
  gl_setpalettecolor(LIGHTBROWN, 255/4, 255/4, 85/4);
#endif
}
Ejemplo n.º 10
0
Graphic::~Graphic()
{
#ifdef SVGALIB
  vga_getch();
  vga_setmode(TEXT);
#endif
}
Ejemplo n.º 11
0
static int
SVGA_open(PSD psd)
{
	int		mode;
	vga_modeinfo *	modeinfo;

	vga_init();
	//mode = G640x480x256;
	mode = G640x480x16;
	vga_setmode(mode);
	modeinfo = vga_getmodeinfo(mode);

	psd->xres = modeinfo->width;
	psd->yres = modeinfo->height;
	psd->linelen = modeinfo->linewidth;
	psd->planes = 1;
	psd->bpp = modeinfo->bytesperpixel;	// FIXME??
	psd->ncolors = modeinfo->colors;
	psd->flags = PSF_SCREEN;
	psd->addr = 0;		// FIXME

	/* note: must change psd->pixtype here for truecolor systems*/
	psd->pixtype = PF_PALETTE;
	return 1;
}
Ejemplo n.º 12
0
static void timeout(int sig)
{
    keyboard_close();
    vga_setmode(TEXT);
    puts("Automatic termination after 60 seconds.");
    exit(1);
}
Ejemplo n.º 13
0
//! [1]
bool SvgalibScreen::initDevice()
{
    if (vga_init() != 0) {
        qCritical("SvgalibScreen::initDevice(): unable to initialize svgalib");
        return false;
    }

    int mode = vga_getdefaultmode();
    if (vga_setmode(mode) == -1) {
        qCritical("SvgalibScreen::initialize(): unable to set graphics mode");
        return false;
    }

    if (gl_setcontextvga(mode) != 0) {
        qCritical("SvgalibScreen::initDevice(): unable to set vga context");
        return false;
    }
    context = gl_allocatecontext();
    gl_getcontext(context);

    vga_modeinfo *modeinfo = vga_getmodeinfo(mode);
    if (modeinfo->flags & IS_LINEAR)
        QScreen::data = vga_getgraphmem();

    initColorMap();

    QScreenCursor::initSoftwareCursor();
    return true;
}
Ejemplo n.º 14
0
//
// This function is called to init the video driver for specific mode
//
static int config(uint32_t width, uint32_t height, uint32_t d_width,
                  uint32_t d_height, uint32_t flags, char *title,
                  uint32_t format) {
    int32_t req_w = width;// (d_width > 0 ? d_width : width);
    int32_t req_h = height;// (d_height > 0 ? d_height : height);
    uint16_t vid_mode = 0;
    int32_t req_bpp;

    uint32_t accflags;
    mp_msg(MSGT_VO,MSGL_V, "vo_svga: config(%i, %i, %i, %i, %08x, %s, %08x)\n", width, height,
           d_width, d_height, flags, title, format);
//Only RGB modes supported
    if (!IMGFMT_IS_RGB(format) && !IMGFMT_IS_BGR(format)) {
        assert(0);
        return -1;
    }
    req_bpp = IMGFMT_BGR_DEPTH(format);

    if( vo_dbpp!=0 && vo_dbpp!=req_bpp) {
        assert(0);
        return-1;
    }

    if(!force_vm) {
        mp_msg(MSGT_VO,MSGL_V, "vo_svga: Looking for the best resolution...\n");
        mp_msg(MSGT_VO,MSGL_V, "vo_svga: req_w: %d, req_h: %d, bpp: %d\n",req_w,req_h,req_bpp);
        vid_mode=find_best_svga_mode(req_w,req_h,req_bpp);
        if(vid_mode==0)
            return 1;
        modeinfo=vga_getmodeinfo(vid_mode);
    } else { //force_vm
        vid_mode=force_vm;
        if(vga_hasmode(vid_mode) == 0) {
            mp_msg(MSGT_VO,MSGL_ERR, MSGTR_LIBVO_SVGA_ForcedVidmodeNotAvailable,
                   vid_mode,vga_getmodename(vid_mode));
            return 1; //error;
        }
        modeinfo=vga_getmodeinfo(vid_mode);
        if( (modeinfo->width < req_w) || (modeinfo->height < req_h) ) {
            mp_msg(MSGT_VO,MSGL_ERR, MSGTR_LIBVO_SVGA_ForcedVidmodeTooSmall,
                   vid_mode,vga_getmodename(vid_mode));
            return 1;
        }
    }
    mode_bpp=bpp_from_vminfo(modeinfo);

    mp_msg(MSGT_VO,MSGL_INFO, MSGTR_LIBVO_SVGA_Vidmode,
           vid_mode,modeinfo->width,modeinfo->height,mode_bpp);

    if (vga_setmode(vid_mode) == -1) {
        mp_msg(MSGT_VO,MSGL_ERR, MSGTR_LIBVO_SVGA_VgasetmodeFailed,vid_mode);
        uninit();
        return 1; // error
    }
    /* set 332 palette for 8 bpp */
    if(mode_bpp==8) {
        int i;
        for(i=0; i<256; i++)
            vga_setpalette(i, ((i>>5)&7)*9, ((i>>2)&7)*9, (i&3)*21);
    }
Ejemplo n.º 15
0
static void _qdgdfv_shutdown(void)
{
    vga_setmode(TEXT);
    keyboard_close();

    printf("\x1b[H\x1b[J\n");
}
Ejemplo n.º 16
0
/*
 * Term hook
 * Nuke an old term
 */
static void term_nuke_svgalib(term *t)
{
	/* Only one term */
	(void) t;

	vga_setmode(TEXT);
}
Ejemplo n.º 17
0
static int _qdgdfv_startup(void)
{
    vga_init();

    _qdgdfv_scale = 1;

    /* only 320x200 supported by now */
    _qdgdfv_screen_x_size = 320;
    _qdgdfv_screen_y_size = 200;

    vga_setmode(G320x200x256);

    _qdgdfv_set_palette();

    keyboard_init();

    keyboard_translatekeys(TRANSLATE_CURSORKEYS);

    _qdgdfv_virtual_screen = (unsigned char *)
        qdgdfv_malloc(_qdgdfv_screen_x_size * _qdgdfv_screen_y_size);

    qdgdfv_clear_virtual_screen();

    /* svgalib runs always fullscreen */
    _qdgdfv_full_screen = 1;

    qdgdfv_logger("qdgdfv_startup", "SVGALIB driver startup");

    return 1;
}
Ejemplo n.º 18
0
int vga_changetiming(int pixelClock,
   		     int HDisplay,
   		     int HSyncStart,
                     int HSyncEnd,
                     int HTotal,
                     int VDisplay,
                     int VSyncStart,
                     int VSyncEnd,
                     int VTotal,
                     int flags) {
  if(current_timing){
     new_timing=*current_timing;
     new_timing.pixelClock+=pixelClock;
     new_timing.HDisplay+=HDisplay;
     new_timing.HSyncStart+=HSyncStart;
     new_timing.HSyncEnd+=HSyncEnd;
     new_timing.HTotal+=HTotal;
     new_timing.VDisplay+=VDisplay;
     new_timing.VSyncStart+=VSyncStart;
     new_timing.VSyncEnd+=VSyncEnd;
     new_timing.VTotal+=VTotal;
     force_timing=&new_timing;
     vga_setmode(CM|0x8000);
     force_timing=NULL;
  };
  
  return 1;
};
Ejemplo n.º 19
0
void VL_Startup()
{
	myint mode;
	
	vga_init(); /* TODO: maybe move into main or such? */
	
	if (MS_CheckParm("x2")) {
		mode = G640x400x256;
		vwidth = 640;
		vheight = 400;
	} else {
		mode = G320x200x256;
		vwidth = 320;
		vheight = 200;
	}

	if (gfxbuf == NULL) 
		gfxbuf = malloc(vwidth * vheight * 1);
		
	if (vga_hasmode(mode) == 0) 
		Quit("vga_hasmode failed!");
			
	if (vga_setmode(mode) != 0)
		Quit("vga_setmode failed!");
		
	if ((mode != G320x200x256) && (vga_setlinearaddressing() == -1))
		Quit("vga_setlinearaddressing failed!");
		
 	graphmem = vga_getgraphmem();
 	
 	keyboard_init();
	keyboard_seteventhandler(keyboard_handlerx);
}
Ejemplo n.º 20
0
static void leave_graphics_mode (void)
{
    keyboard_close ();
    mouse_close ();
    sleep (1); /* Maybe this will fix the "screen full of garbage" problem */
    current_vgamode = TEXT;
    vga_setmode (TEXT);
}
Ejemplo n.º 21
0
Archivo: draw.c Proyecto: descent/jmcce
void
screen_done (void)
{
#ifdef VGALIB
  if (!use_fb)
    vga_setmode (TEXT);
#endif
}
Ejemplo n.º 22
0
static int deinit_vidmode ()
{
	vga_setmode (TEXT);
	if (video_buffer)
		free (video_buffer);

	return err_OK;
}
Ejemplo n.º 23
0
void I_ShutdownGraphics(void)
{
	keyboard_close();
	if (usemouse)
		mouse_close();

	if (vga_getcurrentmode() != TEXT)
		vga_setmode(TEXT);
}
Ejemplo n.º 24
0
Archivo: draw.c Proyecto: descent/jmcce
/* use by signal usr2 (SIGACQ) handler -- acquire terminal */
void
screen_return (void)
{
#ifdef VGALIB
  if (!use_fb)
    vga_setmode (DEFAULT_VGA_MODE);
#endif
  active_console = 1;
}
Ejemplo n.º 25
0
void S9xTextMode ()
{
//    if (!text_mode)
    {
	keyboard_close ();
	vga_setmode (TEXT);
	text_mode = TRUE;
    }
}
Ejemplo n.º 26
0
void VID_Shutdown (void)
{
	if (!svgalib_inited)
		return;

	vga_setmode(TEXT);

	svgalib_inited = 0;
}
Ejemplo n.º 27
0
void VL_Shutdown()
{
	keyboard_close();
	
	if (gfxbuf != NULL) {
		free(gfxbuf);
		gfxbuf = NULL;
	}
	vga_setmode(TEXT);
}
Ejemplo n.º 28
0
Archivo: draw.c Proyecto: descent/jmcce
/* use by signal usr1 (SIGREL) handler -- relese terminal */
void
screen_flipaway (void)
{
#if 0
  if (!use_fb)
    vga_setmode (TEXT);
#endif
  screen_done ();
  active_console = 0;
}
Ejemplo n.º 29
0
void setup( void )
{
   vga_init();

   vga_setmode(G800x600x32K);
/*   gl_setcontextvga(G800x600x32K);*/

   vmc = SVGAMesaCreateContext(GL_TRUE);
   SVGAMesaMakeCurrent( vmc );
}
Ejemplo n.º 30
0
/* shut up the display */
void sysdep_display_close(void)
{
   /* close input */
   svga_input_close();
   
   /* close svgalib */
   vga_setmode(TEXT);
   
   /* close glide */
   CloseVScreen();
}