From e56481f4cb32a7d9191f6e26d673dae511972537 Mon Sep 17 00:00:00 2001 From: Patrice Mandin Date: Sat, 4 Nov 2017 23:16:08 +0100 Subject: [PATCH] atari:xbios: Create function for Vsync and getting screen format. --- src/video/xbios/SDL_xbios.c | 16 +++++++++------- src/video/xbios/SDL_xbios.h | 4 ++++ src/video/xbios/SDL_xbios_ctpci.c | 4 ++-- src/video/xbios/SDL_xbios_f30.c | 4 ++-- src/video/xbios/SDL_xbios_st.c | 14 ++++++++++++++ 5 files changed, 31 insertions(+), 11 deletions(-) diff --git a/src/video/xbios/SDL_xbios.c b/src/video/xbios/SDL_xbios.c index f5e632065..9bd3eff15 100644 --- a/src/video/xbios/SDL_xbios.c +++ b/src/video/xbios/SDL_xbios.c @@ -408,8 +408,8 @@ static SDL_Surface *XBIOS_SetVideoMode(_THIS, SDL_Surface *current, int num_buffers; xbiosmode_t *new_video_mode; Uint32 new_screen_size; - Uint32 modeflags; - Uint32 lineWidth; + Uint32 modeflags, lineWidth; + Uint32 rmask, gmask, bmask, amask; /* Free current buffers */ XBIOS_FreeBuffers(this); @@ -481,7 +481,9 @@ static SDL_Surface *XBIOS_SetVideoMode(_THIS, SDL_Surface *current, } /* Allocate the new pixel format for the screen */ - if ( ! SDL_ReallocFormat(current, new_depth, 0, 0, 0, 0) ) { + (*XBIOS_getScreenFormat)(this, new_depth, &rmask, &gmask, &bmask, &amask); + + if ( ! SDL_ReallocFormat(current, new_depth, rmask, gmask, bmask, amask) ) { XBIOS_FreeBuffers(this); SDL_SetError("Couldn't allocate new pixel format for requested mode"); return(NULL); @@ -520,7 +522,7 @@ static SDL_Surface *XBIOS_SetVideoMode(_THIS, SDL_Surface *current, /* Now set the video mode */ (*XBIOS_setMode)(this, new_video_mode); - Vsync(); + (*XBIOS_vsync)(this); #endif this->UpdateRects = XBIOS_updRects; @@ -594,7 +596,7 @@ static void XBIOS_UpdateRects(_THIS, int numrects, SDL_Rect *rects) #ifndef DEBUG_VIDEO_XBIOS (*XBIOS_swapVbuffers)(this); - Vsync(); + (*XBIOS_vsync)(this); #endif XBIOS_fbnum ^= 1; @@ -633,7 +635,7 @@ static int XBIOS_FlipHWSurface(_THIS, SDL_Surface *surface) #ifndef DEBUG_VIDEO_XBIOS (*XBIOS_swapVbuffers)(this); - Vsync(); + (*XBIOS_vsync)(this); #endif XBIOS_fbnum ^= 1; @@ -659,7 +661,7 @@ static void XBIOS_VideoQuit(_THIS) #ifndef DEBUG_VIDEO_XBIOS (*XBIOS_restoreMode)(this); - Vsync(); + (*XBIOS_vsync)(this); #endif #if SDL_VIDEO_OPENGL diff --git a/src/video/xbios/SDL_xbios.h b/src/video/xbios/SDL_xbios.h index c127e8a85..de418acde 100644 --- a/src/video/xbios/SDL_xbios.h +++ b/src/video/xbios/SDL_xbios.h @@ -71,6 +71,8 @@ struct SDL_PrivateVideoData { void (*saveMode)(_THIS, SDL_PixelFormat *vformat); /* Save mode,palette,vbase change format if needed */ void (*setMode)(_THIS, xbiosmode_t *new_video_mode); /* Set mode */ void (*restoreMode)(_THIS); /* Restore system mode */ + void (*vsync)(_THIS); + void (*getScreenFormat)(_THIS, int bpp, Uint32 *rmask, Uint32 *gmask, Uint32 *bmask, Uint32 *amask); /* Get TrueColor screen format */ int (*getLineWidth)(_THIS, xbiosmode_t *new_video_mode, int width, int bpp); /* Return video mode pitch */ void (*swapVbuffers)(_THIS); /* Swap video buffers */ int (*allocVbuffers)(_THIS, int num_buffers, int bufsize); /* Allocate video buffers */ @@ -122,6 +124,8 @@ enum { #define XBIOS_saveMode (this->hidden->saveMode) #define XBIOS_setMode (this->hidden->setMode) #define XBIOS_restoreMode (this->hidden->restoreMode) +#define XBIOS_vsync (this->hidden->vsync) +#define XBIOS_getScreenFormat (this->hidden->getScreenFormat) #define XBIOS_getLineWidth (this->hidden->getLineWidth) #define XBIOS_swapVbuffers (this->hidden->swapVbuffers) #define XBIOS_allocVbuffers (this->hidden->allocVbuffers) diff --git a/src/video/xbios/SDL_xbios_ctpci.c b/src/video/xbios/SDL_xbios_ctpci.c index 492f44cdf..d3dc4fea1 100644 --- a/src/video/xbios/SDL_xbios_ctpci.c +++ b/src/video/xbios/SDL_xbios_ctpci.c @@ -293,7 +293,7 @@ static void updateRects(_THIS, int numrects, SDL_Rect *rects) if ((surface->flags & SDL_DOUBLEBUF) == SDL_DOUBLEBUF) { VsetScreen(-1L, -1L, VN_MAGIC, CMD_FLIPPAGE); - Vsync(); + (*XBIOS_vsync)(this); XBIOS_fbnum ^= 1; } @@ -316,7 +316,7 @@ static int flipHWSurface(_THIS, SDL_Surface *surface) if ((surface->flags & SDL_DOUBLEBUF) == SDL_DOUBLEBUF) { VsetScreen(-1L, -1L, VN_MAGIC, CMD_FLIPPAGE); - Vsync(); + (*XBIOS_vsync)(this); XBIOS_fbnum ^= 1; } diff --git a/src/video/xbios/SDL_xbios_f30.c b/src/video/xbios/SDL_xbios_f30.c index 68a89f852..0c1e1f9b6 100644 --- a/src/video/xbios/SDL_xbios_f30.c +++ b/src/video/xbios/SDL_xbios_f30.c @@ -346,7 +346,7 @@ static void updateRects_SV(_THIS, int numrects, SDL_Rect *rects) if ((surface->flags & SDL_DOUBLEBUF) == SDL_DOUBLEBUF) { Setscreen(-1,XBIOS_screens[XBIOS_fbnum],-1); - Vsync(); + (*XBIOS_vsync)(this); XBIOS_fbnum ^= 1; } @@ -369,7 +369,7 @@ static int flipHWSurface_SV(_THIS, SDL_Surface *surface) if ((surface->flags & SDL_DOUBLEBUF) == SDL_DOUBLEBUF) { Setscreen(-1,XBIOS_screens[XBIOS_fbnum],-1); - Vsync(); + (*XBIOS_vsync)(this); XBIOS_fbnum ^= 1; } diff --git a/src/video/xbios/SDL_xbios_st.c b/src/video/xbios/SDL_xbios_st.c index 969ace77c..65ab8a3a5 100644 --- a/src/video/xbios/SDL_xbios_st.c +++ b/src/video/xbios/SDL_xbios_st.c @@ -45,6 +45,8 @@ static void saveMode(_THIS, SDL_PixelFormat *vformat); static void setMode_ST(_THIS, xbiosmode_t *new_video_mode); static void setMode_STE(_THIS, xbiosmode_t *new_video_mode); static void restoreMode(_THIS); +static void vsync_ST(_THIS); +static void getScreenFormat(_THIS, int bpp, Uint32 *rmask, Uint32 *gmask, Uint32 *bmask, Uint32 *amask); static int getLineWidth(_THIS, xbiosmode_t *new_video_mode, int width, int bpp); static void swapVbuffers(_THIS); static int allocVbuffers(_THIS, int num_buffers, int bufsize); @@ -57,6 +59,8 @@ void SDL_XBIOS_VideoInit_ST(_THIS, unsigned long cookie_cvdo) XBIOS_saveMode = saveMode; XBIOS_setMode = setMode_ST; XBIOS_restoreMode = restoreMode; + XBIOS_vsync = vsync_ST; + XBIOS_getScreenFormat = getScreenFormat; XBIOS_getLineWidth = getLineWidth; XBIOS_swapVbuffers = swapVbuffers; XBIOS_allocVbuffers = allocVbuffers; @@ -142,6 +146,16 @@ static void restoreMode(_THIS) } } +static void vsync_ST(_THIS) +{ + Vsync(); +} + +static void getScreenFormat(_THIS, int bpp, Uint32 *rmask, Uint32 *gmask, Uint32 *bmask, Uint32 *amask) +{ + *rmask = *gmask = *bmask = *amask = 0; +} + static int getLineWidth(_THIS, xbiosmode_t *new_video_mode, int width, int bpp) { return (width * (((bpp==15) ? 16 : bpp)>>3));