Skip to content
Permalink
Browse files

Added double-buffering support for SVGAlib (thanks Kutak!)

  • Loading branch information
slouken committed Oct 14, 2001
1 parent 2e038f4 commit a17f219e3c2e932e2be679fb68c2fabb191e30a4
Showing with 47 additions and 9 deletions.
  1. +1 −0 docs.html
  2. +37 −9 src/video/svga/SDL_svgavideo.c
  3. +9 −0 src/video/svga/SDL_svgavideo.h
@@ -16,6 +16,7 @@ <H2>
Major changes since SDL 1.0.0:
</H2>
<UL>
<LI> 1.2.3: Added double-buffering support for SVGAlib (thanks Kutak!)
<LI> 1.2.3: Fixed crash when using double-buffering with DGA
<LI> 1.2.3: Fixed resuming a paused CD on Win2K (thanks Aragorn)
<LI> 1.2.3: Improved MacOS international keyboard handling (thanks Max!)
@@ -145,7 +145,7 @@ static SDL_VideoDevice *SVGA_CreateDevice(int devindex)
device->SetHWAlpha = NULL;
device->LockHWSurface = SVGA_LockHWSurface;
device->UnlockHWSurface = SVGA_UnlockHWSurface;
device->FlipHWSurface = NULL;
device->FlipHWSurface = SVGA_FlipHWSurface;
device->FreeHWSurface = SVGA_FreeHWSurface;
device->SetCaption = NULL;
device->SetIcon = NULL;
@@ -223,10 +223,7 @@ static void SVGA_UpdateVideoInfo(_THIS)
this->info.wm_available = 0;
this->info.hw_available = 1;
modeinfo = vga_getmodeinfo(vga_getcurrentmode());
this->info.video_mem = (modeinfo->maxpixels/1024);
if ( modeinfo->bytesperpixel > 0 ) {
this->info.video_mem *= modeinfo->bytesperpixel;
}
this->info.video_mem = modeinfo->memory;
/* FIXME: Add hardware accelerated blit information */
#if 0
printf("Hardware accelerated blit: %savailable\n", modeinfo->haveblit ? "" : "not ");
@@ -347,6 +344,7 @@ SDL_Surface *SVGA_SetVideoMode(_THIS, SDL_Surface *current,
int mode;
int vgamode;
vga_modeinfo *modeinfo;
int screenpage_len;

/* Try to set the requested linear video mode */
bpp = (bpp+7)/8-1;
@@ -393,6 +391,34 @@ SDL_Surface *SVGA_SetVideoMode(_THIS, SDL_Surface *current,
current->pitch = modeinfo->linewidth;
current->pixels = vga_getgraphmem();

/* set double-buffering */
if ( flags & SDL_DOUBLEBUF )
{
/* length of one screen page in bytes */
screenpage_len=current->h*modeinfo->linewidth;

/* if start address should be aligned */
if ( modeinfo->linewidth_unit )
{
if ( screenpage_len % modeinfo->linewidth_unit )
{
screenpage_len += modeinfo->linewidth_unit - ( screenpage_len % modeinfo->linewidth_unit );
}
}

/* if we heve enough videomemory = ak je dost videopamete */
if ( modeinfo->memory > ( screenpage_len * 2 / 1024 ) )
{
current->flags |= SDL_DOUBLEBUF;
flip_page = 0;
flip_offset[0] = 0;
flip_offset[1] = screenpage_len;
flip_address[0] = vga_getgraphmem();
flip_address[1] = flip_address[0]+screenpage_len;
SVGA_FlipHWSurface(this,current);
}
}

/* Set the blit function */
this->UpdateRects = SVGA_DirectUpdate;

@@ -416,19 +442,20 @@ static void SVGA_FreeHWSurface(_THIS, SDL_Surface *surface)
/* We need to wait for vertical retrace on page flipped displays */
static int SVGA_LockHWSurface(_THIS, SDL_Surface *surface)
{
if ( (surface->flags & SDL_DOUBLEBUF) == SDL_DOUBLEBUF ) {
vga_waitretrace();
}
/* The waiting is done in SVGA_FlipHWSurface() */
return(0);
}
static void SVGA_UnlockHWSurface(_THIS, SDL_Surface *surface)
{
return;
}

/* FIXME: How is this done with SVGAlib? */
static int SVGA_FlipHWSurface(_THIS, SDL_Surface *surface)
{
vga_setdisplaystart(flip_offset[flip_page]);
flip_page=!flip_page;
surface->pixels=flip_address[flip_page];
vga_waitretrace();
return(0);
}

@@ -487,3 +514,4 @@ void SVGA_VideoQuit(_THIS)
this->screen->pixels = NULL;
}
}

@@ -40,10 +40,19 @@ struct SDL_PrivateVideoData {
int SDL_nummodes[NUM_MODELISTS];
SDL_Rect **SDL_modelist[NUM_MODELISTS];
int *SDL_vgamode[NUM_MODELISTS];

/* information for double-buffering */
int flip_page;
int flip_offset[2];
Uint8 *flip_address[2];
};
/* Old variable names */
#define SDL_nummodes (this->hidden->SDL_nummodes)
#define SDL_modelist (this->hidden->SDL_modelist)
#define SDL_vgamode (this->hidden->SDL_vgamode)
#define flip_page (this->hidden->flip_page)
#define flip_offset (this->hidden->flip_offset)
#define flip_address (this->hidden->flip_address)

#endif /* _SDL_svgavideo_h */

0 comments on commit a17f219

Please sign in to comment.