atari:xbios: Create function for Vsync and getting screen format. SDL-1.2
authorPatrice Mandin <patmandin@gmail.com>
Sat, 04 Nov 2017 23:16:08 +0100
branchSDL-1.2
changeset 116809517c54ab59c
parent 11624 5de87f16eda5
child 11681 462d7ea5d108
atari:xbios: Create function for Vsync and getting screen format.
src/video/xbios/SDL_xbios.c
src/video/xbios/SDL_xbios.h
src/video/xbios/SDL_xbios_ctpci.c
src/video/xbios/SDL_xbios_f30.c
src/video/xbios/SDL_xbios_st.c
     1.1 --- a/src/video/xbios/SDL_xbios.c	Sat Oct 14 17:54:44 2017 +0200
     1.2 +++ b/src/video/xbios/SDL_xbios.c	Sat Nov 04 23:16:08 2017 +0100
     1.3 @@ -408,8 +408,8 @@
     1.4  	int num_buffers;
     1.5  	xbiosmode_t *new_video_mode;
     1.6  	Uint32 new_screen_size;
     1.7 -	Uint32 modeflags;
     1.8 -	Uint32 lineWidth;
     1.9 +	Uint32 modeflags, lineWidth;
    1.10 +	Uint32 rmask, gmask, bmask, amask;
    1.11  
    1.12  	/* Free current buffers */
    1.13  	XBIOS_FreeBuffers(this);
    1.14 @@ -481,7 +481,9 @@
    1.15  	}
    1.16  
    1.17  	/* Allocate the new pixel format for the screen */
    1.18 -	if ( ! SDL_ReallocFormat(current, new_depth, 0, 0, 0, 0) ) {
    1.19 +	(*XBIOS_getScreenFormat)(this, new_depth, &rmask, &gmask, &bmask, &amask);
    1.20 +
    1.21 +	if ( ! SDL_ReallocFormat(current, new_depth, rmask, gmask, bmask, amask) ) {
    1.22  		XBIOS_FreeBuffers(this);
    1.23  		SDL_SetError("Couldn't allocate new pixel format for requested mode");
    1.24  		return(NULL);
    1.25 @@ -520,7 +522,7 @@
    1.26  	/* Now set the video mode */
    1.27  	(*XBIOS_setMode)(this, new_video_mode);
    1.28  
    1.29 -	Vsync();
    1.30 +	(*XBIOS_vsync)(this);
    1.31  #endif
    1.32  
    1.33  	this->UpdateRects = XBIOS_updRects;
    1.34 @@ -594,7 +596,7 @@
    1.35  #ifndef DEBUG_VIDEO_XBIOS
    1.36  		(*XBIOS_swapVbuffers)(this);
    1.37  
    1.38 -		Vsync();
    1.39 +		(*XBIOS_vsync)(this);
    1.40  #endif
    1.41  
    1.42  		XBIOS_fbnum ^= 1;
    1.43 @@ -633,7 +635,7 @@
    1.44  #ifndef DEBUG_VIDEO_XBIOS
    1.45  		(*XBIOS_swapVbuffers)(this);
    1.46  
    1.47 -		Vsync();
    1.48 +		(*XBIOS_vsync)(this);
    1.49  #endif
    1.50  
    1.51  		XBIOS_fbnum ^= 1;
    1.52 @@ -659,7 +661,7 @@
    1.53  #ifndef DEBUG_VIDEO_XBIOS
    1.54  	(*XBIOS_restoreMode)(this);
    1.55  
    1.56 -	Vsync();
    1.57 +	(*XBIOS_vsync)(this);
    1.58  #endif
    1.59  
    1.60  #if SDL_VIDEO_OPENGL
     2.1 --- a/src/video/xbios/SDL_xbios.h	Sat Oct 14 17:54:44 2017 +0200
     2.2 +++ b/src/video/xbios/SDL_xbios.h	Sat Nov 04 23:16:08 2017 +0100
     2.3 @@ -71,6 +71,8 @@
     2.4  	void (*saveMode)(_THIS, SDL_PixelFormat *vformat);	/* Save mode,palette,vbase change format if needed */
     2.5  	void (*setMode)(_THIS, xbiosmode_t *new_video_mode);	/* Set mode */
     2.6  	void (*restoreMode)(_THIS);	/* Restore system mode */
     2.7 +	void (*vsync)(_THIS);
     2.8 +	void (*getScreenFormat)(_THIS, int bpp, Uint32 *rmask, Uint32 *gmask, Uint32 *bmask, Uint32 *amask);	/* Get TrueColor screen format */
     2.9  	int (*getLineWidth)(_THIS, xbiosmode_t *new_video_mode, int width, int bpp);	/* Return video mode pitch */
    2.10  	void (*swapVbuffers)(_THIS);	/* Swap video buffers */
    2.11  	int (*allocVbuffers)(_THIS, int num_buffers, int bufsize);	/* Allocate video buffers */
    2.12 @@ -122,6 +124,8 @@
    2.13  #define XBIOS_saveMode		(this->hidden->saveMode)
    2.14  #define XBIOS_setMode		(this->hidden->setMode)
    2.15  #define XBIOS_restoreMode	(this->hidden->restoreMode)
    2.16 +#define XBIOS_vsync			(this->hidden->vsync)
    2.17 +#define XBIOS_getScreenFormat	(this->hidden->getScreenFormat)
    2.18  #define XBIOS_getLineWidth	(this->hidden->getLineWidth)
    2.19  #define XBIOS_swapVbuffers	(this->hidden->swapVbuffers)
    2.20  #define XBIOS_allocVbuffers	(this->hidden->allocVbuffers)
     3.1 --- a/src/video/xbios/SDL_xbios_ctpci.c	Sat Oct 14 17:54:44 2017 +0200
     3.2 +++ b/src/video/xbios/SDL_xbios_ctpci.c	Sat Nov 04 23:16:08 2017 +0100
     3.3 @@ -293,7 +293,7 @@
     3.4  
     3.5  	if ((surface->flags & SDL_DOUBLEBUF) == SDL_DOUBLEBUF) {
     3.6  		VsetScreen(-1L, -1L, VN_MAGIC, CMD_FLIPPAGE);
     3.7 -		Vsync();
     3.8 +		(*XBIOS_vsync)(this);
     3.9  
    3.10  		XBIOS_fbnum ^= 1;
    3.11  	}
    3.12 @@ -316,7 +316,7 @@
    3.13  
    3.14  	if ((surface->flags & SDL_DOUBLEBUF) == SDL_DOUBLEBUF) {
    3.15  		VsetScreen(-1L, -1L, VN_MAGIC, CMD_FLIPPAGE);
    3.16 -		Vsync();
    3.17 +		(*XBIOS_vsync)(this);
    3.18  
    3.19  		XBIOS_fbnum ^= 1;
    3.20  	}
     4.1 --- a/src/video/xbios/SDL_xbios_f30.c	Sat Oct 14 17:54:44 2017 +0200
     4.2 +++ b/src/video/xbios/SDL_xbios_f30.c	Sat Nov 04 23:16:08 2017 +0100
     4.3 @@ -346,7 +346,7 @@
     4.4  
     4.5  	if ((surface->flags & SDL_DOUBLEBUF) == SDL_DOUBLEBUF) {
     4.6  		Setscreen(-1,XBIOS_screens[XBIOS_fbnum],-1);
     4.7 -		Vsync();
     4.8 +		(*XBIOS_vsync)(this);
     4.9  
    4.10  		XBIOS_fbnum ^= 1;
    4.11  	}
    4.12 @@ -369,7 +369,7 @@
    4.13  
    4.14   	if ((surface->flags & SDL_DOUBLEBUF) == SDL_DOUBLEBUF) {
    4.15  		Setscreen(-1,XBIOS_screens[XBIOS_fbnum],-1);
    4.16 -		Vsync();
    4.17 +		(*XBIOS_vsync)(this);
    4.18  
    4.19  		XBIOS_fbnum ^= 1;
    4.20  	}
     5.1 --- a/src/video/xbios/SDL_xbios_st.c	Sat Oct 14 17:54:44 2017 +0200
     5.2 +++ b/src/video/xbios/SDL_xbios_st.c	Sat Nov 04 23:16:08 2017 +0100
     5.3 @@ -45,6 +45,8 @@
     5.4  static void setMode_ST(_THIS, xbiosmode_t *new_video_mode);
     5.5  static void setMode_STE(_THIS, xbiosmode_t *new_video_mode);
     5.6  static void restoreMode(_THIS);
     5.7 +static void vsync_ST(_THIS);
     5.8 +static void getScreenFormat(_THIS, int bpp, Uint32 *rmask, Uint32 *gmask, Uint32 *bmask, Uint32 *amask);
     5.9  static int getLineWidth(_THIS, xbiosmode_t *new_video_mode, int width, int bpp);
    5.10  static void swapVbuffers(_THIS);
    5.11  static int allocVbuffers(_THIS, int num_buffers, int bufsize);
    5.12 @@ -57,6 +59,8 @@
    5.13  	XBIOS_saveMode = saveMode;
    5.14  	XBIOS_setMode = setMode_ST;
    5.15  	XBIOS_restoreMode = restoreMode;
    5.16 +	XBIOS_vsync = vsync_ST;
    5.17 +	XBIOS_getScreenFormat = getScreenFormat;
    5.18  	XBIOS_getLineWidth = getLineWidth;
    5.19  	XBIOS_swapVbuffers = swapVbuffers;
    5.20  	XBIOS_allocVbuffers = allocVbuffers;
    5.21 @@ -142,6 +146,16 @@
    5.22  	}
    5.23  }
    5.24  
    5.25 +static void vsync_ST(_THIS)
    5.26 +{
    5.27 +	Vsync();
    5.28 +}
    5.29 +
    5.30 +static void getScreenFormat(_THIS, int bpp, Uint32 *rmask, Uint32 *gmask, Uint32 *bmask, Uint32 *amask)
    5.31 +{
    5.32 +	*rmask = *gmask = *bmask = *amask = 0;
    5.33 +}
    5.34 +
    5.35  static int getLineWidth(_THIS, xbiosmode_t *new_video_mode, int width, int bpp)
    5.36  {
    5.37  	return (width * (((bpp==15) ? 16 : bpp)>>3));