|
@@ -167,99 +167,99 @@ static void SdlVideoMakeDirty(int left,
|
|
|
}
|
|
|
_num_dirty_rects++;
|
|
|
}
|
|
|
|
|
|
static SDL_Color pal[256];
|
|
|
|
|
|
static void UpdatePalette(uint start, uint end) {
|
|
|
uint i;
|
|
|
byte *b;
|
|
|
|
|
|
for(i = start, b = _cur_palette + start * 3; i != end; i++, b += 3) {
|
|
|
pal[i].r = b[0];
|
|
|
pal[i].g = b[1];
|
|
|
pal[i].b = b[2];
|
|
|
pal[i].unused = b[3];
|
|
|
}
|
|
|
|
|
|
SDL_CALL SDL_SetColors(_sdl_screen, pal, start, end);
|
|
|
}
|
|
|
|
|
|
static void InitPalette(void) {
|
|
|
UpdatePalette(0, 256);
|
|
|
}
|
|
|
|
|
|
static void CheckPaletteAnim()
|
|
|
{
|
|
|
if(_pal_last_dirty != -1) {
|
|
|
UpdatePalette(_pal_first_dirty, _pal_last_dirty + 1);
|
|
|
_pal_last_dirty = -1;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
static void DrawSurfaceToScreen()
|
|
|
{
|
|
|
int n;
|
|
|
|
|
|
if ((n=_num_dirty_rects) != 0) {
|
|
|
_num_dirty_rects = 0;
|
|
|
if (n > MAX_DIRTY_RECTS)
|
|
|
SDL_CALL SDL_UpdateRect(_sdl_screen, 0, 0, 0, 0);
|
|
|
else {
|
|
|
SDL_CALL SDL_UpdateRects(_sdl_screen, n, _dirty_rects);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
static int CDECL compare_res(const void *pa, const void *pb)
|
|
|
{
|
|
|
int x = ((uint16*)pa)[0] - ((uint16*)pb)[0];
|
|
|
int x = ((const uint16*)pa)[0] - ((const uint16*)pb)[0];
|
|
|
if (x) return x;
|
|
|
return ((uint16*)pa)[1] - ((uint16*)pb)[1];
|
|
|
return ((const uint16*)pa)[1] - ((const uint16*)pb)[1];
|
|
|
}
|
|
|
|
|
|
static const uint16 default_resolutions[][2] = {
|
|
|
{640,480},
|
|
|
{800,600},
|
|
|
{1024,768},
|
|
|
{1152,864},
|
|
|
{1280,960},
|
|
|
{1280,1024},
|
|
|
{1400,1050},
|
|
|
{1600,1200},
|
|
|
};
|
|
|
|
|
|
static void GetVideoModes(void) {
|
|
|
int i;
|
|
|
SDL_Rect **modes;
|
|
|
|
|
|
modes = SDL_CALL SDL_ListModes(NULL, SDL_SWSURFACE + (_fullscreen ? SDL_FULLSCREEN : 0));
|
|
|
|
|
|
_all_modes = (int)modes == -1;
|
|
|
|
|
|
if(!modes) {
|
|
|
error("sdl: no modes available");
|
|
|
} else if((int) modes == -1) {
|
|
|
// all modes available, put some default ones here
|
|
|
memcpy(_resolutions, default_resolutions, sizeof(default_resolutions));
|
|
|
_num_resolutions = sizeof(default_resolutions) / (sizeof(uint16)*2);
|
|
|
} else {
|
|
|
int n = 0;
|
|
|
for(i = 0; modes[i]; i++) {
|
|
|
int w = modes[i]->w;
|
|
|
int h = modes[i]->h;
|
|
|
if (IS_INT_INSIDE(w, 640, MAX_SCREEN_WIDTH+1) &&
|
|
|
IS_INT_INSIDE(h, 480, MAX_SCREEN_HEIGHT+1) &&
|
|
|
w%8 == 0 && h%8 == 0) { // disable screen resolutions which are not multiples of 8
|
|
|
int j;
|
|
|
for (j = 0; j < n; ++j)
|
|
|
if (_resolutions[j][0] == w && _resolutions[j][1] == h)
|
|
|
break;
|
|
|
if (j == n) {
|
|
|
_resolutions[n][0] = w;
|
|
|
_resolutions[n][1] = h;
|
|
|
if (++n == sizeof(_resolutions) / (sizeof(uint16)*2)) break;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
_num_resolutions = n;
|
|
|
qsort(_resolutions, n, sizeof(uint16)*2, compare_res);
|