From 266ad8cf88cf7e9d5a15cf38c96f5671462ecf05 Mon Sep 17 00:00:00 2001 From: Patrice Mandin Date: Sat, 19 Sep 2009 21:58:59 +0000 Subject: [PATCH] Use loop to allocate needed buffers, instead of code duplication. Add missing header. --HG-- branch : SDL-1.2 extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/branches/SDL-1.2%403826 --- src/video/xbios/SDL_xbios.c | 33 +++++++++++++------------------ src/video/xbios/SDL_xbios_milan.c | 1 + 2 files changed, 15 insertions(+), 19 deletions(-) diff --git a/src/video/xbios/SDL_xbios.c b/src/video/xbios/SDL_xbios.c index f441f702c..70336bb27 100644 --- a/src/video/xbios/SDL_xbios.c +++ b/src/video/xbios/SDL_xbios.c @@ -613,7 +613,7 @@ static SDL_Surface *XBIOS_SetVideoMode(_THIS, SDL_Surface *current, int width, int height, int bpp, Uint32 flags) { int mode, new_depth; - int i; + int i, num_buffers; xbiosmode_t *new_video_mode; Uint32 new_screen_size; Uint32 modeflags; @@ -670,16 +670,8 @@ static SDL_Surface *XBIOS_SetVideoMode(_THIS, SDL_Surface *current, XBIOS_doubleline = SDL_TRUE; } - XBIOS_screensmem[0] = Atari_SysMalloc(new_screen_size, MX_STRAM); - - if (XBIOS_screensmem[0]==NULL) { - XBIOS_FreeBuffers(this); - SDL_SetError("Can not allocate %d KB for frame buffer", new_screen_size>>10); - return (NULL); - } - SDL_memset(XBIOS_screensmem[0], 0, new_screen_size); - - XBIOS_screens[0]=(void *) (( (long) XBIOS_screensmem[0]+256) & 0xFFFFFF00UL); + /* Double buffer ? */ + num_buffers = 1; #if SDL_VIDEO_OPENGL if (flags & SDL_OPENGL) { @@ -688,20 +680,23 @@ static SDL_Surface *XBIOS_SetVideoMode(_THIS, SDL_Surface *current, } } #endif - - /* Double buffer ? */ if (flags & SDL_DOUBLEBUF) { - XBIOS_screensmem[1] = Atari_SysMalloc(new_screen_size, MX_STRAM); + num_buffers = 2; + modeflags |= SDL_DOUBLEBUF; + } - if (XBIOS_screensmem[1]==NULL) { + /* Allocate buffers */ + for (i=0; i>10); + SDL_SetError("Can not allocate %d KB for buffer %d", new_screen_size>>10, i); return (NULL); } - SDL_memset(XBIOS_screensmem[1], 0, new_screen_size); + SDL_memset(XBIOS_screensmem[i], 0, new_screen_size); - XBIOS_screens[1]=(void *) (( (long) XBIOS_screensmem[1]+256) & 0xFFFFFF00UL); - modeflags |= SDL_DOUBLEBUF; + XBIOS_screens[i]=(void *) (( (long) XBIOS_screensmem[i]+256) & 0xFFFFFF00UL); } /* Allocate the new pixel format for the screen */ diff --git a/src/video/xbios/SDL_xbios_milan.c b/src/video/xbios/SDL_xbios_milan.c index 12c7c3e47..04ffd84ba 100644 --- a/src/video/xbios/SDL_xbios_milan.c +++ b/src/video/xbios/SDL_xbios_milan.c @@ -28,6 +28,7 @@ */ #include +#include #include "SDL_xbios.h" #include "SDL_xbios_milan.h"