atari:xbios: fixes centering also when surface is locked. SDL-1.2
authorPatrice Mandin <patmandin@gmail.com>
Sun, 24 Aug 2014 23:15:00 +0200
branchSDL-1.2
changeset 9116baafc044e241
parent 9111 54c4bea81a55
child 9119 8f68bee3fd50
atari:xbios: fixes centering also when surface is locked.
src/video/xbios/SDL_xbios.c
     1.1 --- a/src/video/xbios/SDL_xbios.c	Fri Aug 22 15:59:49 2014 +0200
     1.2 +++ b/src/video/xbios/SDL_xbios.c	Sun Aug 24 23:15:00 2014 +0200
     1.3 @@ -428,19 +428,15 @@
     1.4  	}
     1.5  	new_video_mode = SDL_xbiosmode[bpp][mode];
     1.6  
     1.7 -	modeflags = SDL_FULLSCREEN | SDL_PREALLOC;
     1.8 +	modeflags = SDL_FULLSCREEN | SDL_PREALLOC | SDL_HWPALETTE | SDL_HWSURFACE;
     1.9  
    1.10  	/* Allocate needed buffers: simple/double buffer and shadow surface */
    1.11  	new_depth = new_video_mode->depth;
    1.12  	if (new_depth == 4) {
    1.13  		SDL_Atari_C2pConvert = SDL_Atari_C2pConvert4;
    1.14  		new_depth=8;
    1.15 -		modeflags |= SDL_SWSURFACE|SDL_HWPALETTE;
    1.16  	} else if (new_depth == 8) {
    1.17  		SDL_Atari_C2pConvert = SDL_Atari_C2pConvert8;
    1.18 -		modeflags |= SDL_SWSURFACE|SDL_HWPALETTE;
    1.19 -	} else {
    1.20 -		modeflags |= SDL_HWSURFACE;
    1.21  	}
    1.22  
    1.23  	lineWidth = (*XBIOS_getLineWidth)(this, new_video_mode, width, new_depth);
    1.24 @@ -554,21 +550,6 @@
    1.25  	return;
    1.26  }
    1.27  
    1.28 -static void recalc_offset(_THIS)
    1.29 -{
    1.30 -	int offset_x;
    1.31 -
    1.32 -	offset_x = (XBIOS_current->width - this->screen->w)>>1;
    1.33 -	offset_x &= ~15;
    1.34 -
    1.35 -	this->offset_x = offset_x;
    1.36 -
    1.37 -	this->screen->offset = this->offset_y*this->screen->pitch +
    1.38 -				this->offset_x*this->screen->format->BytesPerPixel;
    1.39 -
    1.40 -	--XBIOS_recoffset;
    1.41 -}
    1.42 -
    1.43  static void XBIOS_UpdateRects(_THIS, int numrects, SDL_Rect *rects)
    1.44  {
    1.45  	SDL_Surface *surface;
    1.46 @@ -579,10 +560,6 @@
    1.47  		int i;
    1.48  		int doubleline = (XBIOS_current->flags & XBIOSMODE_DOUBLELINE ? 1 : 0);
    1.49  
    1.50 -		if (XBIOS_recoffset>0) {
    1.51 -			recalc_offset(this);
    1.52 -		}
    1.53 -
    1.54  		for (i=0;i<numrects;i++) {
    1.55  			Uint8 *source,*destination;
    1.56  			int x1,x2;
    1.57 @@ -622,27 +599,29 @@
    1.58  
    1.59  	if ((surface->flags & SDL_DOUBLEBUF) == SDL_DOUBLEBUF) {
    1.60  		XBIOS_fbnum ^= 1;
    1.61 -	}
    1.62 -	if (XBIOS_shadowscreen) {
    1.63 -		surface->pixels=((Uint8 *) XBIOS_shadowscreen) + surface->offset;
    1.64 -	} else {
    1.65 -		surface->pixels=((Uint8 *) XBIOS_screens[XBIOS_fbnum]) + surface->offset;
    1.66 +		if (!XBIOS_shadowscreen) {
    1.67 +			int src_offset = (surface->locked ? surface->offset : 0);
    1.68 +			surface->pixels=((Uint8 *) XBIOS_screens[XBIOS_fbnum]) + src_offset;
    1.69 +		}
    1.70  	}
    1.71  }
    1.72  
    1.73  static int XBIOS_FlipHWSurface(_THIS, SDL_Surface *surface)
    1.74  {
    1.75 +	int src_offset;
    1.76 +
    1.77  	if (XBIOS_current->flags & XBIOSMODE_C2P) {
    1.78  		int doubleline = (XBIOS_current->flags & XBIOSMODE_DOUBLELINE ? 1 : 0);
    1.79 -			
    1.80 -		if (XBIOS_recoffset>0) {
    1.81 -			recalc_offset(this);
    1.82 -		}
    1.83 +		int dst_offset;
    1.84 +
    1.85 +		src_offset = (surface->locked ? 0 : surface->offset);
    1.86 +		dst_offset = this->offset_y * XBIOS_pitch +
    1.87 +				(this->offset_x & ~15) * this->screen->format->BytesPerPixel;
    1.88  
    1.89  		/* Convert chunky to planar screen */
    1.90  		SDL_Atari_C2pConvert(
    1.91 -			surface->pixels,
    1.92 -			((Uint8 *) XBIOS_screens[XBIOS_fbnum]) + surface->offset,
    1.93 +			surface->pixels + src_offset,
    1.94 +			((Uint8 *) XBIOS_screens[XBIOS_fbnum]) + dst_offset,
    1.95  			surface->w,
    1.96  			surface->h,
    1.97  			doubleline,
    1.98 @@ -659,11 +638,10 @@
    1.99  
   1.100  	if ((surface->flags & SDL_DOUBLEBUF) == SDL_DOUBLEBUF) {
   1.101  		XBIOS_fbnum ^= 1;
   1.102 -	}
   1.103 -	if (XBIOS_shadowscreen) {
   1.104 -		surface->pixels=((Uint8 *) XBIOS_shadowscreen) + surface->offset;
   1.105 -	} else {
   1.106 -		surface->pixels=((Uint8 *) XBIOS_screens[XBIOS_fbnum]) + surface->offset;
   1.107 +		if (!XBIOS_shadowscreen) {
   1.108 +			src_offset = (surface->locked ? surface->offset : 0);
   1.109 +			surface->pixels=((Uint8 *) XBIOS_screens[XBIOS_fbnum]) + src_offset;
   1.110 +		}
   1.111  	}
   1.112  
   1.113  	return(0);