2002-04-21 17:46:42 +00:00
|
|
|
/* ScummVM - Scumm Interpreter
|
|
|
|
* Copyright (C) 2001 Ludvig Strigeus
|
2003-03-06 21:46:56 +00:00
|
|
|
* Copyright (C) 2001-2003 The ScummVM project
|
2002-04-21 17:46:42 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*
|
|
|
|
* $Header$
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2002-08-24 10:41:32 +00:00
|
|
|
#include "sdl-common.h"
|
2002-09-08 01:08:12 +00:00
|
|
|
#include "common/scaler.h"
|
2002-09-19 17:03:24 +00:00
|
|
|
#include "common/util.h"
|
2002-09-08 01:08:12 +00:00
|
|
|
#include "common/engine.h" // Only #included for error() and warning()
|
2001-11-05 19:21:49 +00:00
|
|
|
|
2002-12-13 17:21:23 +00:00
|
|
|
class OSystem_SDL : public OSystem_SDL_Common {
|
2002-04-12 21:26:59 +00:00
|
|
|
public:
|
2002-12-13 17:21:23 +00:00
|
|
|
OSystem_SDL();
|
2002-09-27 13:05:54 +00:00
|
|
|
|
2002-04-12 21:26:59 +00:00
|
|
|
// Set colors of the palette
|
|
|
|
void set_palette(const byte *colors, uint start, uint num);
|
2001-10-09 14:30:12 +00:00
|
|
|
|
2002-04-12 21:26:59 +00:00
|
|
|
// Update the dirty areas of the screen
|
|
|
|
void update_screen();
|
2002-03-09 13:48:02 +00:00
|
|
|
|
2002-04-12 21:26:59 +00:00
|
|
|
// Set a parameter
|
2002-05-04 09:55:10 +00:00
|
|
|
uint32 property(int param, Property *value);
|
2002-04-11 17:19:16 +00:00
|
|
|
|
2002-08-24 10:41:32 +00:00
|
|
|
protected:
|
2002-11-23 00:13:52 +00:00
|
|
|
SDL_Surface *_hwscreen; // hardware screen
|
2002-03-10 07:48:01 +00:00
|
|
|
|
2002-09-19 16:06:51 +00:00
|
|
|
ScalerProc *_scaler_proc;
|
|
|
|
|
|
|
|
virtual void load_gfx_mode();
|
|
|
|
virtual void unload_gfx_mode();
|
2002-04-13 12:43:02 +00:00
|
|
|
void hotswap_gfx_mode();
|
2002-04-12 21:26:59 +00:00
|
|
|
};
|
2002-03-10 07:48:01 +00:00
|
|
|
|
2002-08-24 10:41:32 +00:00
|
|
|
OSystem_SDL_Common *OSystem_SDL_Common::create() {
|
2002-12-13 17:21:23 +00:00
|
|
|
return new OSystem_SDL();
|
2002-03-10 07:48:01 +00:00
|
|
|
}
|
|
|
|
|
2002-12-13 17:21:23 +00:00
|
|
|
OSystem_SDL::OSystem_SDL()
|
|
|
|
: _hwscreen(0), _scaler_proc(0)
|
2002-11-13 14:38:49 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2002-12-13 17:21:23 +00:00
|
|
|
void OSystem_SDL::set_palette(const byte *colors, uint start, uint num) {
|
2002-04-12 21:26:59 +00:00
|
|
|
const byte *b = colors;
|
|
|
|
uint i;
|
2002-09-28 16:19:28 +00:00
|
|
|
SDL_Color *base = _currentPalette + start;
|
2002-09-19 16:06:51 +00:00
|
|
|
for(i = 0; i < num; i++) {
|
2002-06-14 04:31:17 +00:00
|
|
|
base[i].r = b[0];
|
|
|
|
base[i].g = b[1];
|
|
|
|
base[i].b = b[2];
|
|
|
|
b += 4;
|
2002-03-10 07:48:01 +00:00
|
|
|
}
|
|
|
|
|
2002-09-28 16:19:28 +00:00
|
|
|
if (start < _paletteDirtyStart)
|
|
|
|
_paletteDirtyStart = start;
|
2002-04-15 17:45:52 +00:00
|
|
|
|
2002-09-28 16:19:28 +00:00
|
|
|
if (start + num > _paletteDirtyEnd)
|
|
|
|
_paletteDirtyEnd = start + num;
|
2002-04-12 21:26:59 +00:00
|
|
|
}
|
2002-03-10 07:48:01 +00:00
|
|
|
|
2002-12-13 17:21:23 +00:00
|
|
|
void OSystem_SDL::load_gfx_mode() {
|
2002-09-28 16:19:28 +00:00
|
|
|
_forceFull = true;
|
2003-01-12 14:18:05 +00:00
|
|
|
_mode_flags = DF_UPDATE_EXPAND_1_PIXEL;
|
2002-04-13 12:43:02 +00:00
|
|
|
|
2002-11-23 00:13:52 +00:00
|
|
|
_tmpscreen = NULL;
|
2002-12-13 17:21:23 +00:00
|
|
|
_tmpScreenWidth = (_screenWidth + 3);
|
2002-06-14 04:31:17 +00:00
|
|
|
|
2002-04-13 12:43:02 +00:00
|
|
|
switch(_mode) {
|
2002-04-12 21:26:59 +00:00
|
|
|
case GFX_2XSAI:
|
2002-09-28 16:19:28 +00:00
|
|
|
_scaleFactor = 2;
|
2002-09-19 16:06:51 +00:00
|
|
|
_scaler_proc = _2xSaI;
|
2002-04-13 04:39:04 +00:00
|
|
|
break;
|
2002-04-12 21:26:59 +00:00
|
|
|
case GFX_SUPER2XSAI:
|
2002-09-28 16:19:28 +00:00
|
|
|
_scaleFactor = 2;
|
2002-09-19 16:06:51 +00:00
|
|
|
_scaler_proc = Super2xSaI;
|
2002-04-13 04:39:04 +00:00
|
|
|
break;
|
2002-04-12 21:26:59 +00:00
|
|
|
case GFX_SUPEREAGLE:
|
2002-09-28 16:19:28 +00:00
|
|
|
_scaleFactor = 2;
|
2002-09-19 16:06:51 +00:00
|
|
|
_scaler_proc = SuperEagle;
|
2002-04-12 21:26:59 +00:00
|
|
|
break;
|
2002-04-24 07:42:29 +00:00
|
|
|
case GFX_ADVMAME2X:
|
2002-09-28 16:19:28 +00:00
|
|
|
_scaleFactor = 2;
|
2002-09-19 16:06:51 +00:00
|
|
|
_scaler_proc = AdvMame2x;
|
2002-04-24 07:42:29 +00:00
|
|
|
break;
|
2003-01-15 02:11:37 +00:00
|
|
|
case GFX_TV2X:
|
|
|
|
_scaleFactor = 2;
|
|
|
|
_scaler_proc = TV2x;
|
|
|
|
break;
|
2003-03-02 16:36:52 +00:00
|
|
|
case GFX_DOTMATRIX:
|
|
|
|
_scaleFactor = 2;
|
|
|
|
_scaler_proc = DotMatrix;
|
|
|
|
break;
|
2001-12-27 17:51:58 +00:00
|
|
|
|
2002-04-12 21:26:59 +00:00
|
|
|
case GFX_DOUBLESIZE:
|
2002-09-28 16:19:28 +00:00
|
|
|
_scaleFactor = 2;
|
2002-09-19 16:06:51 +00:00
|
|
|
_scaler_proc = Normal2x;
|
2002-04-12 21:26:59 +00:00
|
|
|
break;
|
2001-11-06 20:00:47 +00:00
|
|
|
|
2002-04-12 21:26:59 +00:00
|
|
|
case GFX_TRIPLESIZE:
|
2002-04-13 12:43:02 +00:00
|
|
|
if (_full_screen) {
|
|
|
|
warning("full screen in useless in triplesize mode, reverting to normal mode");
|
|
|
|
goto normal_mode;
|
|
|
|
}
|
2002-09-28 16:19:28 +00:00
|
|
|
_scaleFactor = 3;
|
2002-09-19 16:06:51 +00:00
|
|
|
_scaler_proc = Normal3x;
|
2002-04-13 12:43:02 +00:00
|
|
|
break;
|
|
|
|
|
2002-04-12 21:26:59 +00:00
|
|
|
case GFX_NORMAL:
|
2002-04-13 12:43:02 +00:00
|
|
|
normal_mode:;
|
2002-09-28 16:19:28 +00:00
|
|
|
_scaleFactor = 1;
|
2002-09-19 16:06:51 +00:00
|
|
|
_scaler_proc = Normal1x;
|
2002-04-12 21:26:59 +00:00
|
|
|
break;
|
2002-10-14 11:02:27 +00:00
|
|
|
default:
|
|
|
|
error("unknown gfx mode");
|
|
|
|
_scaleFactor = 1;
|
|
|
|
_scaler_proc = NULL;
|
2001-11-06 20:00:47 +00:00
|
|
|
}
|
2002-06-14 04:31:17 +00:00
|
|
|
|
2002-10-14 11:02:27 +00:00
|
|
|
//
|
|
|
|
// Create the surface that contains the 8 bit game data
|
|
|
|
//
|
2002-09-28 16:19:28 +00:00
|
|
|
_screen = SDL_CreateRGBSurface(SDL_SWSURFACE, _screenWidth, _screenHeight, 8, 0, 0, 0, 0);
|
|
|
|
if (_screen == NULL)
|
2002-10-14 11:02:27 +00:00
|
|
|
error("_screen failed");
|
2002-05-04 00:11:57 +00:00
|
|
|
|
2002-10-14 11:02:27 +00:00
|
|
|
//
|
|
|
|
// Create the surface that contains the scaled graphics in 16 bit mode
|
|
|
|
//
|
2002-11-23 00:13:52 +00:00
|
|
|
_hwscreen = SDL_SetVideoMode(_screenWidth * _scaleFactor, _screenHeight * _scaleFactor, 16,
|
2002-09-19 16:06:51 +00:00
|
|
|
_full_screen ? (SDL_FULLSCREEN|SDL_SWSURFACE) : SDL_SWSURFACE
|
|
|
|
);
|
2002-11-23 00:13:52 +00:00
|
|
|
if (_hwscreen == NULL)
|
|
|
|
error("_hwscreen failed");
|
2002-09-19 16:06:51 +00:00
|
|
|
|
2002-10-14 11:02:27 +00:00
|
|
|
//
|
|
|
|
// Create the surface used for the graphics in 16 bit before scaling, and also the overlay
|
|
|
|
//
|
|
|
|
|
|
|
|
// Distinguish 555 and 565 mode
|
2002-11-23 00:13:52 +00:00
|
|
|
if (_hwscreen->format->Rmask == 0x7C00)
|
2002-09-19 16:06:51 +00:00
|
|
|
Init_2xSaI(555);
|
|
|
|
else
|
|
|
|
Init_2xSaI(565);
|
2002-10-14 11:02:27 +00:00
|
|
|
|
|
|
|
// Need some extra bytes around when using 2xSaI
|
2003-03-06 18:30:44 +00:00
|
|
|
uint16 *tmp_screen = (uint16 *)calloc(_tmpScreenWidth * (_screenHeight + 3), sizeof(uint16));
|
2002-11-23 00:13:52 +00:00
|
|
|
_tmpscreen = SDL_CreateRGBSurfaceFrom(tmp_screen,
|
2003-03-06 18:30:44 +00:00
|
|
|
_tmpScreenWidth, _screenHeight + 3, 16, _tmpScreenWidth * 2,
|
2002-11-23 00:13:52 +00:00
|
|
|
_hwscreen->format->Rmask,
|
|
|
|
_hwscreen->format->Gmask,
|
|
|
|
_hwscreen->format->Bmask,
|
|
|
|
_hwscreen->format->Amask);
|
2002-09-19 16:06:51 +00:00
|
|
|
|
2002-11-23 00:13:52 +00:00
|
|
|
if (_tmpscreen == NULL)
|
|
|
|
error("_tmpscreen failed");
|
2003-03-06 18:30:44 +00:00
|
|
|
|
2002-06-25 12:43:15 +00:00
|
|
|
// keyboard cursor control, some other better place for it?
|
2002-09-28 16:19:28 +00:00
|
|
|
km.x_max = _screenWidth * _scaleFactor - 1;
|
|
|
|
km.y_max = _screenHeight * _scaleFactor - 1;
|
2002-07-16 11:09:28 +00:00
|
|
|
km.delay_time = 25;
|
|
|
|
km.last_time = 0;
|
2002-04-12 21:26:59 +00:00
|
|
|
}
|
2001-11-06 20:00:47 +00:00
|
|
|
|
2002-12-13 17:21:23 +00:00
|
|
|
void OSystem_SDL::unload_gfx_mode() {
|
2002-09-28 16:19:28 +00:00
|
|
|
if (_screen) {
|
|
|
|
SDL_FreeSurface(_screen);
|
|
|
|
_screen = NULL;
|
2002-08-24 10:41:32 +00:00
|
|
|
}
|
2001-11-06 20:00:47 +00:00
|
|
|
|
2002-11-23 00:13:52 +00:00
|
|
|
if (_hwscreen) {
|
|
|
|
SDL_FreeSurface(_hwscreen);
|
|
|
|
_hwscreen = NULL;
|
2002-08-24 10:41:32 +00:00
|
|
|
}
|
|
|
|
|
2002-11-23 00:13:52 +00:00
|
|
|
if (_tmpscreen) {
|
|
|
|
free(_tmpscreen->pixels);
|
|
|
|
SDL_FreeSurface(_tmpscreen);
|
|
|
|
_tmpscreen = NULL;
|
2002-04-12 21:26:59 +00:00
|
|
|
}
|
2001-11-05 19:21:49 +00:00
|
|
|
}
|
|
|
|
|
2002-12-13 17:21:23 +00:00
|
|
|
void OSystem_SDL::hotswap_gfx_mode() {
|
2003-01-13 18:59:53 +00:00
|
|
|
if (!_screen)
|
|
|
|
return;
|
2002-11-23 00:13:52 +00:00
|
|
|
|
|
|
|
// Keep around the old _screen & _tmpscreen so we can restore the screen data
|
|
|
|
// after the mode switch.
|
|
|
|
SDL_Surface *old_screen = _screen;
|
|
|
|
SDL_Surface *old_tmpscreen = _tmpscreen;
|
|
|
|
|
|
|
|
// Release the HW screen surface
|
|
|
|
SDL_FreeSurface(_hwscreen);
|
|
|
|
|
|
|
|
// Setup the new GFX mode
|
|
|
|
load_gfx_mode();
|
|
|
|
|
|
|
|
// reset palette
|
|
|
|
SDL_SetColors(_screen, _currentPalette, 0, 256);
|
|
|
|
|
|
|
|
// Restore old screen content
|
|
|
|
SDL_BlitSurface(old_screen, NULL, _screen, NULL);
|
|
|
|
SDL_BlitSurface(old_tmpscreen, NULL, _tmpscreen, NULL);
|
|
|
|
|
|
|
|
// Free the old surfaces
|
|
|
|
SDL_FreeSurface(old_screen);
|
|
|
|
free(old_tmpscreen->pixels);
|
|
|
|
SDL_FreeSurface(old_tmpscreen);
|
|
|
|
|
|
|
|
// Finally, blit everything to the screen
|
|
|
|
update_screen();
|
|
|
|
}
|
|
|
|
|
2002-12-13 17:21:23 +00:00
|
|
|
void OSystem_SDL::update_screen() {
|
2002-11-23 00:13:52 +00:00
|
|
|
assert(_hwscreen != NULL);
|
2002-09-29 18:19:57 +00:00
|
|
|
|
|
|
|
// If the shake position changed, fill the dirty area with blackness
|
|
|
|
if (_currentShakePos != _newShakePos) {
|
2003-03-06 18:30:44 +00:00
|
|
|
SDL_Rect blackrect = {0, 0, _screenWidth * _scaleFactor, _newShakePos * _scaleFactor};
|
2002-11-23 00:13:52 +00:00
|
|
|
SDL_FillRect(_hwscreen, &blackrect, 0);
|
2002-05-10 15:33:02 +00:00
|
|
|
|
2002-09-29 18:19:57 +00:00
|
|
|
_currentShakePos = _newShakePos;
|
|
|
|
|
|
|
|
_forceFull = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Make sure the mouse is drawn, if it should be drawn.
|
2002-04-12 21:26:59 +00:00
|
|
|
draw_mouse();
|
|
|
|
|
2002-09-19 16:06:51 +00:00
|
|
|
// Check whether the palette was changed in the meantime and update the
|
|
|
|
// screen surface accordingly.
|
2002-09-28 16:19:28 +00:00
|
|
|
if (_paletteDirtyEnd != 0) {
|
|
|
|
SDL_SetColors(_screen, _currentPalette + _paletteDirtyStart,
|
|
|
|
_paletteDirtyStart,
|
|
|
|
_paletteDirtyEnd - _paletteDirtyStart);
|
2002-06-14 04:31:17 +00:00
|
|
|
|
2002-09-28 16:19:28 +00:00
|
|
|
_paletteDirtyEnd = 0;
|
2002-04-15 17:45:52 +00:00
|
|
|
|
2002-09-28 16:19:28 +00:00
|
|
|
_forceFull = true;
|
2002-04-15 17:45:52 +00:00
|
|
|
}
|
|
|
|
|
2002-09-19 16:06:51 +00:00
|
|
|
// Force a full redraw if requested
|
2002-09-28 16:19:28 +00:00
|
|
|
if (_forceFull) {
|
|
|
|
_num_dirty_rects = 1;
|
2002-05-04 00:11:57 +00:00
|
|
|
|
2002-09-27 13:05:54 +00:00
|
|
|
_dirty_rect_list[0].x = 0;
|
|
|
|
_dirty_rect_list[0].y = 0;
|
2002-09-28 16:19:28 +00:00
|
|
|
_dirty_rect_list[0].w = _screenWidth;
|
|
|
|
_dirty_rect_list[0].h = _screenHeight;
|
2002-05-04 00:11:57 +00:00
|
|
|
}
|
2002-04-15 17:45:52 +00:00
|
|
|
|
2002-09-19 16:06:51 +00:00
|
|
|
// Only draw anything if necessary
|
2002-09-28 16:19:28 +00:00
|
|
|
if (_num_dirty_rects > 0) {
|
2003-03-06 18:30:44 +00:00
|
|
|
|
2002-05-10 15:33:02 +00:00
|
|
|
SDL_Rect *r;
|
|
|
|
uint32 srcPitch, dstPitch;
|
2002-09-28 16:19:28 +00:00
|
|
|
SDL_Rect *last_rect = _dirty_rect_list + _num_dirty_rects;
|
2003-03-06 18:30:44 +00:00
|
|
|
|
2002-09-19 16:06:51 +00:00
|
|
|
// Convert appropriate parts of the 8bpp image into 16bpp
|
2003-03-18 13:31:37 +00:00
|
|
|
SDL_Rect dst;
|
2002-12-13 17:21:23 +00:00
|
|
|
if (!_overlayVisible) {
|
2002-09-28 16:19:28 +00:00
|
|
|
for(r = _dirty_rect_list; r != last_rect; ++r) {
|
2002-05-10 15:33:02 +00:00
|
|
|
dst = *r;
|
2002-09-19 16:06:51 +00:00
|
|
|
dst.x++; // Shift rect by one since 2xSai needs to acces the data around
|
|
|
|
dst.y++; // any pixel to scale it, and we want to avoid mem access crashes.
|
2003-03-18 13:31:37 +00:00
|
|
|
if (_scaler_proc == Normal1x) {
|
|
|
|
if (SDL_BlitSurface(_screen, r, _hwscreen, &dst) != 0)
|
|
|
|
error("SDL_BlitSurface failed: %s", SDL_GetError());
|
|
|
|
} else {
|
|
|
|
if (SDL_BlitSurface(_screen, r, _tmpscreen, &dst) != 0)
|
|
|
|
error("SDL_BlitSurface failed: %s", SDL_GetError());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
for(r = _dirty_rect_list; r != last_rect; ++r) {
|
|
|
|
dst = *r;
|
|
|
|
if (SDL_BlitSurface(_tmpscreen, r, _hwscreen, &dst) != 0)
|
2002-05-10 15:33:02 +00:00
|
|
|
error("SDL_BlitSurface failed: %s", SDL_GetError());
|
2002-05-04 00:11:57 +00:00
|
|
|
}
|
2002-04-12 21:26:59 +00:00
|
|
|
}
|
2003-03-06 18:30:44 +00:00
|
|
|
|
2003-03-18 13:31:37 +00:00
|
|
|
if (_scaler_proc != Normal1x) {
|
|
|
|
SDL_LockSurface(_tmpscreen);
|
|
|
|
SDL_LockSurface(_hwscreen);
|
|
|
|
|
|
|
|
srcPitch = _tmpscreen->pitch;
|
|
|
|
dstPitch = _hwscreen->pitch;
|
|
|
|
|
|
|
|
for(r = _dirty_rect_list; r != last_rect; ++r) {
|
|
|
|
register int dst_y = r->y + _currentShakePos;
|
|
|
|
register int dst_h = 0;
|
|
|
|
if (dst_y < _screenHeight) {
|
|
|
|
dst_h = r->h;
|
|
|
|
if (dst_h > _screenHeight - dst_y)
|
|
|
|
dst_h = _screenHeight - dst_y;
|
|
|
|
|
|
|
|
dst_y *= _scaleFactor;
|
|
|
|
|
|
|
|
_scaler_proc((byte *)_tmpscreen->pixels + (r->x * 2 + 2) + (r->y + 1) * srcPitch, srcPitch, NULL,
|
|
|
|
(byte *)_hwscreen->pixels + r->x * 2 * _scaleFactor + dst_y * dstPitch, dstPitch, r->w, dst_h);
|
|
|
|
}
|
2002-09-19 16:06:51 +00:00
|
|
|
|
2003-03-18 13:31:37 +00:00
|
|
|
r->x *= _scaleFactor;
|
|
|
|
r->y = dst_y;
|
|
|
|
r->w *= _scaleFactor;
|
|
|
|
r->h = dst_h * _scaleFactor;
|
|
|
|
}
|
|
|
|
|
|
|
|
SDL_UnlockSurface(_tmpscreen);
|
|
|
|
SDL_UnlockSurface(_hwscreen);
|
2002-05-10 15:33:02 +00:00
|
|
|
}
|
2002-09-28 16:19:28 +00:00
|
|
|
|
2002-09-29 18:19:57 +00:00
|
|
|
// Readjust the dirty rect list in case we are doing a full update.
|
|
|
|
// This is necessary if shaking is active.
|
|
|
|
if (_forceFull) {
|
|
|
|
_dirty_rect_list[0].y = 0;
|
|
|
|
_dirty_rect_list[0].h = _screenHeight * _scaleFactor;
|
|
|
|
}
|
|
|
|
|
2002-09-28 16:19:28 +00:00
|
|
|
// Finally, blit all our changes to the screen
|
2002-11-23 00:13:52 +00:00
|
|
|
SDL_UpdateRects(_hwscreen, _num_dirty_rects, _dirty_rect_list);
|
2002-05-10 15:33:02 +00:00
|
|
|
}
|
2002-05-09 18:23:33 +00:00
|
|
|
|
2002-09-28 16:19:28 +00:00
|
|
|
_num_dirty_rects = 0;
|
|
|
|
_forceFull = false;
|
2002-03-17 13:00:11 +00:00
|
|
|
}
|
2001-11-11 16:54:45 +00:00
|
|
|
|
2002-12-13 17:21:23 +00:00
|
|
|
uint32 OSystem_SDL::property(int param, Property *value) {
|
2002-08-24 10:41:32 +00:00
|
|
|
if (param == PROP_TOGGLE_FULLSCREEN) {
|
2002-11-23 00:13:52 +00:00
|
|
|
assert(_hwscreen != 0);
|
2002-04-13 12:43:02 +00:00
|
|
|
_full_screen ^= true;
|
2002-12-08 14:08:51 +00:00
|
|
|
#ifdef MACOSX
|
|
|
|
// On OS X, SDL_WM_ToggleFullScreen is currently not implemented. Worse,
|
|
|
|
// it still always returns -1. So we simply don't call it at all and
|
|
|
|
// use hotswap_gfx_mode() directly to switch to fullscreen mode.
|
|
|
|
hotswap_gfx_mode();
|
|
|
|
#else
|
2002-11-23 00:13:52 +00:00
|
|
|
if (!SDL_WM_ToggleFullScreen(_hwscreen)) {
|
2002-10-14 11:02:27 +00:00
|
|
|
// if ToggleFullScreen fails, achieve the same effect with hotswap gfx mode
|
2002-04-13 12:43:02 +00:00
|
|
|
hotswap_gfx_mode();
|
|
|
|
}
|
2002-12-08 14:08:51 +00:00
|
|
|
#endif
|
2002-12-13 17:44:04 +00:00
|
|
|
return 1;
|
|
|
|
} else if (param == PROP_SET_GFX_MODE) {
|
2003-03-02 16:36:52 +00:00
|
|
|
if (value->gfx_mode >= 9)
|
2002-12-13 17:44:04 +00:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
_mode = value->gfx_mode;
|
|
|
|
hotswap_gfx_mode();
|
|
|
|
|
2002-04-13 12:43:02 +00:00
|
|
|
return 1;
|
2002-04-11 17:19:16 +00:00
|
|
|
}
|
2002-12-13 17:44:04 +00:00
|
|
|
|
2002-08-24 10:41:32 +00:00
|
|
|
return OSystem_SDL_Common::property(param, value);
|
2002-06-04 18:18:44 +00:00
|
|
|
}
|
2002-09-19 16:06:51 +00:00
|
|
|
|