src/video/svga/SDL_svgavideo.c
changeset 205 13161d3d349d
parent 67 3647c809813d
child 226 bb72c418a1f9
     1.1 --- a/src/video/svga/SDL_svgavideo.c	Mon Oct 08 18:54:06 2001 +0000
     1.2 +++ b/src/video/svga/SDL_svgavideo.c	Sun Oct 14 19:49:02 2001 +0000
     1.3 @@ -145,7 +145,7 @@
     1.4  	device->SetHWAlpha = NULL;
     1.5  	device->LockHWSurface = SVGA_LockHWSurface;
     1.6  	device->UnlockHWSurface = SVGA_UnlockHWSurface;
     1.7 -	device->FlipHWSurface = NULL;
     1.8 +	device->FlipHWSurface = SVGA_FlipHWSurface;
     1.9  	device->FreeHWSurface = SVGA_FreeHWSurface;
    1.10  	device->SetCaption = NULL;
    1.11  	device->SetIcon = NULL;
    1.12 @@ -223,10 +223,7 @@
    1.13  	this->info.wm_available = 0;
    1.14  	this->info.hw_available = 1;
    1.15  	modeinfo = vga_getmodeinfo(vga_getcurrentmode());
    1.16 -	this->info.video_mem = (modeinfo->maxpixels/1024);
    1.17 -	if ( modeinfo->bytesperpixel > 0 ) {
    1.18 -		this->info.video_mem *= modeinfo->bytesperpixel;
    1.19 -	}
    1.20 +	this->info.video_mem = modeinfo->memory;
    1.21  	/* FIXME: Add hardware accelerated blit information */
    1.22  #if 0
    1.23  printf("Hardware accelerated blit: %savailable\n", modeinfo->haveblit ? "" : "not ");
    1.24 @@ -347,6 +344,7 @@
    1.25  	int mode;
    1.26  	int vgamode;
    1.27  	vga_modeinfo *modeinfo;
    1.28 +	int screenpage_len;
    1.29  
    1.30  	/* Try to set the requested linear video mode */
    1.31  	bpp = (bpp+7)/8-1;
    1.32 @@ -393,6 +391,34 @@
    1.33  	current->pitch = modeinfo->linewidth;
    1.34  	current->pixels = vga_getgraphmem();
    1.35  
    1.36 +	/* set double-buffering */
    1.37 +	if ( flags & SDL_DOUBLEBUF )
    1.38 +	{
    1.39 +	    /* length of one screen page in bytes */
    1.40 +	    screenpage_len=current->h*modeinfo->linewidth;
    1.41 +
    1.42 +	    /* if start address should be aligned */
    1.43 +	    if ( modeinfo->linewidth_unit )
    1.44 +	    {
    1.45 +		if ( screenpage_len % modeinfo->linewidth_unit )    
    1.46 +		{
    1.47 +		    screenpage_len += modeinfo->linewidth_unit - ( screenpage_len % modeinfo->linewidth_unit );
    1.48 +		}
    1.49 +	    }
    1.50 +
    1.51 +	    /* if we heve enough videomemory =  ak je dost videopamete  */
    1.52 +	    if ( modeinfo->memory > ( screenpage_len * 2 / 1024 ) )
    1.53 +	    {
    1.54 +		current->flags |= SDL_DOUBLEBUF;
    1.55 +		flip_page = 0;
    1.56 +		flip_offset[0] = 0;
    1.57 +		flip_offset[1] = screenpage_len;
    1.58 +		flip_address[0] = vga_getgraphmem();
    1.59 +		flip_address[1] = flip_address[0]+screenpage_len;
    1.60 +		SVGA_FlipHWSurface(this,current);
    1.61 +	    }
    1.62 +	} 
    1.63 +
    1.64  	/* Set the blit function */
    1.65  	this->UpdateRects = SVGA_DirectUpdate;
    1.66  
    1.67 @@ -416,9 +442,7 @@
    1.68  /* We need to wait for vertical retrace on page flipped displays */
    1.69  static int SVGA_LockHWSurface(_THIS, SDL_Surface *surface)
    1.70  {
    1.71 -	if ( (surface->flags & SDL_DOUBLEBUF) == SDL_DOUBLEBUF ) {
    1.72 -		vga_waitretrace();
    1.73 -	}
    1.74 +	/* The waiting is done in SVGA_FlipHWSurface() */
    1.75  	return(0);
    1.76  }
    1.77  static void SVGA_UnlockHWSurface(_THIS, SDL_Surface *surface)
    1.78 @@ -426,9 +450,12 @@
    1.79  	return;
    1.80  }
    1.81  
    1.82 -/* FIXME: How is this done with SVGAlib? */
    1.83  static int SVGA_FlipHWSurface(_THIS, SDL_Surface *surface)
    1.84  {
    1.85 +	vga_setdisplaystart(flip_offset[flip_page]);
    1.86 +	flip_page=!flip_page;
    1.87 +	surface->pixels=flip_address[flip_page];
    1.88 +	vga_waitretrace();
    1.89  	return(0);
    1.90  }
    1.91  
    1.92 @@ -487,3 +514,4 @@
    1.93  		this->screen->pixels = NULL;
    1.94  	}
    1.95  }
    1.96 +