Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
atari:xbios: Create function for Vsync and getting screen format.
  • Loading branch information
pmandin committed Nov 4, 2017
1 parent 7867cfa commit e56481f
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 11 deletions.
16 changes: 9 additions & 7 deletions src/video/xbios/SDL_xbios.c
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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
Expand Down
4 changes: 4 additions & 0 deletions src/video/xbios/SDL_xbios.h
Expand Up @@ -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 */
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions src/video/xbios/SDL_xbios_ctpci.c
Expand Up @@ -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;
}
Expand All @@ -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;
}
Expand Down
4 changes: 2 additions & 2 deletions src/video/xbios/SDL_xbios_f30.c
Expand Up @@ -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;
}
Expand All @@ -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;
}
Expand Down
14 changes: 14 additions & 0 deletions src/video/xbios/SDL_xbios_st.c
Expand Up @@ -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);
Expand All @@ -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;
Expand Down Expand Up @@ -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));
Expand Down

0 comments on commit e56481f

Please sign in to comment.