# HG changeset patch # User Patrice Mandin # Date 1253397539 0 # Node ID 1bf6585720e95b9f78731bf850e4be884e45c557 # Parent 89c7562eae9b736f14c46c9c94405c2bd433dde0 Use loop to allocate needed buffers, instead of code duplication. Add missing header. diff -r 89c7562eae9b -r 1bf6585720e9 src/video/xbios/SDL_xbios.c --- a/src/video/xbios/SDL_xbios.c Sat Sep 19 13:31:41 2009 +0000 +++ b/src/video/xbios/SDL_xbios.c Sat Sep 19 21:58:59 2009 +0000 @@ -613,7 +613,7 @@ 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 @@ 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 @@ } } #endif + if (flags & SDL_DOUBLEBUF) { + num_buffers = 2; + modeflags |= SDL_DOUBLEBUF; + } - /* Double buffer ? */ - if (flags & SDL_DOUBLEBUF) { - XBIOS_screensmem[1] = Atari_SysMalloc(new_screen_size, MX_STRAM); + /* 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 -r 89c7562eae9b -r 1bf6585720e9 src/video/xbios/SDL_xbios_milan.c --- a/src/video/xbios/SDL_xbios_milan.c Sat Sep 19 13:31:41 2009 +0000 +++ b/src/video/xbios/SDL_xbios_milan.c Sat Sep 19 21:58:59 2009 +0000 @@ -28,6 +28,7 @@ */ #include +#include #include "SDL_xbios.h" #include "SDL_xbios_milan.h"