diff options
author | Max Horn | 2002-12-13 17:21:23 +0000 |
---|---|---|
committer | Max Horn | 2002-12-13 17:21:23 +0000 |
commit | 1f4f7a51b1b1c13253de06c6bd642a3b8427c902 (patch) | |
tree | b8d8d5996bbc7985b165c94c9b30c6e23b44afca /backends/sdl | |
parent | 645c5418d6d3618a0cbab36a1a4c480d722246e0 (diff) | |
download | scummvm-rg350-1f4f7a51b1b1c13253de06c6bd642a3b8427c902.tar.gz scummvm-rg350-1f4f7a51b1b1c13253de06c6bd642a3b8427c902.tar.bz2 scummvm-rg350-1f4f7a51b1b1c13253de06c6bd642a3b8427c902.zip |
unified common code
svn-id: r5934
Diffstat (limited to 'backends/sdl')
-rw-r--r-- | backends/sdl/sdl-common.cpp | 102 | ||||
-rw-r--r-- | backends/sdl/sdl-common.h | 7 | ||||
-rw-r--r-- | backends/sdl/sdl.cpp | 182 | ||||
-rw-r--r-- | backends/sdl/sdl_gl.cpp | 174 |
4 files changed, 137 insertions, 328 deletions
diff --git a/backends/sdl/sdl-common.cpp b/backends/sdl/sdl-common.cpp index d415ddee94..fbaf3870a1 100644 --- a/backends/sdl/sdl-common.cpp +++ b/backends/sdl/sdl-common.cpp @@ -70,8 +70,9 @@ void OSystem_SDL_Common::set_timer(int timer, int (*callback)(int)) { } OSystem_SDL_Common::OSystem_SDL_Common() - : _screen(0), _screenWidth(0), _screenHeight(0), _cdrom(0), - _dirty_checksums(0), + : _screen(0), _screenWidth(0), _screenHeight(0), + _tmpscreen(0), _tmpScreenWidth(0), _overlayVisible(false), + _cdrom(0), _dirty_checksums(0), _mouseVisible(false), _mouseDrawn(false), _mouseData(0), _mouseHotspotX(0), _mouseHotspotY(0), _currentShakePos(0), _newShakePos(0) @@ -729,8 +730,6 @@ void OSystem_SDL_Common::draw_mouse() { int h = _mouseCurState.h; byte color; byte *src = _mouseData; // Image representing the mouse - byte *bak = _mouseBackup; // Surface used to backup the area obscured by the mouse - byte *dst; // Surface we are drawing into // clip the mouse rect, and addjust the src pointer accordingly if (x < 0) { @@ -743,6 +742,7 @@ void OSystem_SDL_Common::draw_mouse() { src -= y * _mouseCurState.w; y = 0; } + if (w > _screenWidth - x) w = _screenWidth - x; if (h > _screenHeight - y) @@ -760,32 +760,59 @@ void OSystem_SDL_Common::draw_mouse() { _mouseOldState.h = h; // Draw the mouse cursor; backup the covered area in "bak" - - if (SDL_LockSurface(_screen) == -1) + + if (SDL_LockSurface(_overlayVisible ? _tmpscreen : _screen) == -1) error("SDL_LockSurface failed: %s.\n", SDL_GetError()); // Mark as dirty add_dirty_rect(x, y, w, h); - dst = (byte *)_screen->pixels + y * _screenWidth + x; - while (h > 0) { - int width = w; - while (width > 0) { - *bak++ = *dst; - color = *src++; - if (color != 0xFF) // 0xFF = transparent, don't draw - *dst = color; - dst++; - width--; + if (!_overlayVisible) { + byte *bak = _mouseBackup; // Surface used to backup the area obscured by the mouse + byte *dst; // Surface we are drawing into + + dst = (byte *)_screen->pixels + y * _screenWidth + x; + while (h > 0) { + int width = w; + while (width > 0) { + *bak++ = *dst; + color = *src++; + if (color != 0xFF) // 0xFF = transparent, don't draw + *dst = color; + dst++; + width--; + } + src += _mouseCurState.w - w; + bak += MAX_MOUSE_W - w; + dst += _screenWidth - w; + h--; } - src += _mouseCurState.w - w; - bak += MAX_MOUSE_W - w; - dst += _screenWidth - w; - h--; + + } else { + uint16 *bak = (uint16*)_mouseBackup; // Surface used to backup the area obscured by the mouse + uint16 *dst; // Surface we are drawing into + + dst = (uint16 *)_tmpscreen->pixels + (y+1) * _tmpScreenWidth + (x+1); + while (h > 0) { + int width = w; + while (width > 0) { + *bak++ = *dst; + color = *src++; + if (color != 0xFF) // 0xFF = transparent, don't draw + *dst = RBGToColor(_currentPalette[color].r, _currentPalette[color].g, _currentPalette[color].b); + dst++; + width--; + } + src += _mouseCurState.w - w; + bak += MAX_MOUSE_W - w; + dst += _tmpScreenWidth - w; + h--; + } + } - SDL_UnlockSurface(_screen); - + SDL_UnlockSurface(_overlayVisible ? _tmpscreen : _screen); + // Finally, set the flag to indicate the mouse has been drawn _mouseDrawn = true; } @@ -795,28 +822,43 @@ void OSystem_SDL_Common::undraw_mouse() { return; _mouseDrawn = false; - if (SDL_LockSurface(_screen) == -1) + if (SDL_LockSurface(_overlayVisible ? _tmpscreen : _screen) == -1) error("SDL_LockSurface failed: %s.\n", SDL_GetError()); - byte *dst, *bak = _mouseBackup; const int old_mouse_x = _mouseOldState.x; const int old_mouse_y = _mouseOldState.y; const int old_mouse_w = _mouseOldState.w; const int old_mouse_h = _mouseOldState.h; int x, y; - // No need to do clipping here, since draw_mouse() did that already + if (!_overlayVisible) { + + byte *dst, *bak = _mouseBackup; + + // No need to do clipping here, since draw_mouse() did that already + dst = (byte *)_screen->pixels + old_mouse_y * _screenWidth + old_mouse_x; + for (y = 0; y < old_mouse_h; ++y, bak += MAX_MOUSE_W, dst += _screenWidth) { + for (x = 0; x < old_mouse_w; ++x) { + dst[x] = bak[x]; + } + } + + } else { - dst = (byte *)_screen->pixels + old_mouse_y * _screenWidth + old_mouse_x; - for (y = 0; y < old_mouse_h; ++y, bak += MAX_MOUSE_W, dst += _screenWidth) { - for (x = 0; x < old_mouse_w; ++x) { - dst[x] = bak[x]; + uint16 *dst, *bak = (uint16 *)_mouseBackup; + + // No need to do clipping here, since draw_mouse() did that already + dst = (uint16 *)_tmpscreen->pixels + (old_mouse_y+1) * _tmpScreenWidth + (old_mouse_x+1); + for (y = 0; y < old_mouse_h; ++y, bak += MAX_MOUSE_W, dst += _tmpScreenWidth) { + for (x = 0; x < old_mouse_w; ++x) { + dst[x] = bak[x]; + } } } add_dirty_rect(old_mouse_x, old_mouse_y, old_mouse_w, old_mouse_h); - SDL_UnlockSurface(_screen); + SDL_UnlockSurface(_overlayVisible ? _tmpscreen : _screen); } void OSystem_SDL_Common::stop_cdrom() { /* Stop CD Audio in 1/10th of a second */ diff --git a/backends/sdl/sdl-common.h b/backends/sdl/sdl-common.h index 26a058d2ee..a20628e25d 100644 --- a/backends/sdl/sdl-common.h +++ b/backends/sdl/sdl-common.h @@ -106,6 +106,8 @@ public: static OSystem *create(int gfx_mode, bool full_screen); protected: + typedef void ScalerProc(uint8 *srcPtr, uint32 srcPitch, uint8 *deltaPtr, + uint8 *dstPtr, uint32 dstPitch, int width, int height); OSystem_SDL_Common(); virtual ~OSystem_SDL_Common(); @@ -114,6 +116,11 @@ protected: SDL_Surface *_screen; int _screenWidth, _screenHeight; + // temporary screen (for scalers/overlay) + SDL_Surface *_tmpscreen; + int _tmpScreenWidth; + bool _overlayVisible; + // CD Audio SDL_CD *_cdrom; int cd_track, cd_num_loops, cd_start_frame, cd_end_frame; diff --git a/backends/sdl/sdl.cpp b/backends/sdl/sdl.cpp index 83bbbca3e4..1979872459 100644 --- a/backends/sdl/sdl.cpp +++ b/backends/sdl/sdl.cpp @@ -25,9 +25,9 @@ #include "common/util.h" #include "common/engine.h" // Only #included for error() and warning() -class OSystem_SDL_Normal : public OSystem_SDL_Common { +class OSystem_SDL : public OSystem_SDL_Common { public: - OSystem_SDL_Normal(); + OSystem_SDL(); // Set colors of the palette void set_palette(const byte *colors, uint start, uint num); @@ -50,36 +50,25 @@ public: virtual void colorToRBG(int16 color, uint8 &r, uint8 &g, uint8 &b); protected: - typedef void ScalerProc(uint8 *srcPtr, uint32 srcPitch, uint8 *deltaPtr, - uint8 *dstPtr, uint32 dstPitch, int width, int height); - - SDL_Surface *_tmpscreen; // temporary screen (for scalers/overlay) SDL_Surface *_hwscreen; // hardware screen - bool _overlay_visible; ScalerProc *_scaler_proc; - int TMP_SCREEN_WIDTH; - - virtual void draw_mouse(); - virtual void undraw_mouse(); - virtual void load_gfx_mode(); virtual void unload_gfx_mode(); void hotswap_gfx_mode(); }; OSystem_SDL_Common *OSystem_SDL_Common::create() { - return new OSystem_SDL_Normal(); + return new OSystem_SDL(); } -OSystem_SDL_Normal::OSystem_SDL_Normal() - : _tmpscreen(0), _hwscreen(0), _overlay_visible(false), - _scaler_proc(0), TMP_SCREEN_WIDTH(0) +OSystem_SDL::OSystem_SDL() + : _hwscreen(0), _scaler_proc(0) { } -void OSystem_SDL_Normal::set_palette(const byte *colors, uint start, uint num) { +void OSystem_SDL::set_palette(const byte *colors, uint start, uint num) { const byte *b = colors; uint i; SDL_Color *base = _currentPalette + start; @@ -97,121 +86,12 @@ void OSystem_SDL_Normal::set_palette(const byte *colors, uint start, uint num) { _paletteDirtyEnd = start + num; } -void OSystem_SDL_Normal::draw_mouse() { - if (!_overlay_visible) { - OSystem_SDL_Common::draw_mouse(); - } - - if (_mouseDrawn || !_mouseVisible) - return; - - int x = _mouseCurState.x - _mouseHotspotX; - int y = _mouseCurState.y - _mouseHotspotY; - int w = _mouseCurState.w; - int h = _mouseCurState.h; - byte color; - byte *src = _mouseData; // Image representing the mouse - uint16 *bak = (uint16*)_mouseBackup; // Surface used to backup the area obscured by the mouse - uint16 *dst; // Surface we are drawing into - - // clip the mouse rect, and addjust the src pointer accordingly - if (x < 0) { - w += x; - src -= x; - x = 0; - } - if (y < 0) { - h += y; - src -= y * _mouseCurState.w; - y = 0; - } - - // Quick check to see if anything has to be drawn at all - if (w <= 0 || h <= 0) - return; - - if (w > _screenWidth - x) - w = _screenWidth - x; - if (h > _screenHeight - y) - h = _screenHeight - y; - - // Store the bounding box so that undraw mouse can restore the area the - // mouse currently covers to its original content. - _mouseOldState.x = x; - _mouseOldState.y = y; - _mouseOldState.w = w; - _mouseOldState.h = h; - - // Draw the mouse cursor; backup the covered area in "bak" - - if (SDL_LockSurface(_tmpscreen) == -1) - error("SDL_LockSurface failed: %s.\n", SDL_GetError()); - - // Mark as dirty - add_dirty_rect(x, y, w, h); - - dst = (uint16 *)_tmpscreen->pixels + (y+1) * TMP_SCREEN_WIDTH + (x+1); - while (h > 0) { - int width = w; - while (width > 0) { - *bak++ = *dst; - color = *src++; - if (color != 0xFF) // 0xFF = transparent, don't draw - *dst = RBGToColor(_currentPalette[color].r, _currentPalette[color].g, _currentPalette[color].b); - dst++; - width--; - } - src += _mouseCurState.w - w; - bak += MAX_MOUSE_W - w; - dst += TMP_SCREEN_WIDTH - w; - h--; - } - - SDL_UnlockSurface(_tmpscreen); - - // Finally, set the flag to indicate the mouse has been drawn - _mouseDrawn = true; -} - -void OSystem_SDL_Normal::undraw_mouse() { - if (!_overlay_visible) { - OSystem_SDL_Common::undraw_mouse(); - } - - if (!_mouseDrawn) - return; - _mouseDrawn = false; - - if (SDL_LockSurface(_tmpscreen) == -1) - error("SDL_LockSurface failed: %s.\n", SDL_GetError()); - - uint16 *dst, *bak = (uint16 *)_mouseBackup; - const int old_mouse_x = _mouseOldState.x; - const int old_mouse_y = _mouseOldState.y; - const int old_mouse_w = _mouseOldState.w; - const int old_mouse_h = _mouseOldState.h; - int x, y; - - // No need to do clipping here, since draw_mouse() did that already - - dst = (uint16 *)_tmpscreen->pixels + (old_mouse_y+1) * TMP_SCREEN_WIDTH + (old_mouse_x+1); - for (y = 0; y < old_mouse_h; ++y, bak += MAX_MOUSE_W, dst += TMP_SCREEN_WIDTH) { - for (x = 0; x < old_mouse_w; ++x) { - dst[x] = bak[x]; - } - } - - add_dirty_rect(old_mouse_x, old_mouse_y, old_mouse_w, old_mouse_h); - - SDL_UnlockSurface(_tmpscreen); -} - -void OSystem_SDL_Normal::load_gfx_mode() { +void OSystem_SDL::load_gfx_mode() { _forceFull = true; _mode_flags = DF_WANT_RECT_OPTIM | DF_UPDATE_EXPAND_1_PIXEL; _tmpscreen = NULL; - TMP_SCREEN_WIDTH = (_screenWidth + 3); + _tmpScreenWidth = (_screenWidth + 3); switch(_mode) { case GFX_2XSAI: @@ -284,9 +164,9 @@ normal_mode:; Init_2xSaI(565); // Need some extra bytes around when using 2xSaI - uint16 *tmp_screen = (uint16*)calloc(TMP_SCREEN_WIDTH*(_screenHeight+3), sizeof(uint16)); + uint16 *tmp_screen = (uint16*)calloc(_tmpScreenWidth*(_screenHeight+3), sizeof(uint16)); _tmpscreen = SDL_CreateRGBSurfaceFrom(tmp_screen, - TMP_SCREEN_WIDTH, _screenHeight + 3, 16, TMP_SCREEN_WIDTH*2, + _tmpScreenWidth, _screenHeight + 3, 16, _tmpScreenWidth*2, _hwscreen->format->Rmask, _hwscreen->format->Gmask, _hwscreen->format->Bmask, @@ -303,7 +183,7 @@ normal_mode:; } -void OSystem_SDL_Normal::unload_gfx_mode() { +void OSystem_SDL::unload_gfx_mode() { if (_screen) { SDL_FreeSurface(_screen); _screen = NULL; @@ -321,7 +201,7 @@ void OSystem_SDL_Normal::unload_gfx_mode() { } } -void OSystem_SDL_Normal::hotswap_gfx_mode() { +void OSystem_SDL::hotswap_gfx_mode() { // Keep around the old _screen & _tmpscreen so we can restore the screen data @@ -351,7 +231,7 @@ void OSystem_SDL_Normal::hotswap_gfx_mode() { update_screen(); } -void OSystem_SDL_Normal::update_screen() { +void OSystem_SDL::update_screen() { assert(_hwscreen != NULL); @@ -398,7 +278,7 @@ void OSystem_SDL_Normal::update_screen() { SDL_Rect *last_rect = _dirty_rect_list + _num_dirty_rects; // Convert appropriate parts of the 8bpp image into 16bpp - if (!_overlay_visible) { + if (!_overlayVisible) { SDL_Rect dst; for(r = _dirty_rect_list; r != last_rect; ++r) { dst = *r; @@ -453,7 +333,7 @@ void OSystem_SDL_Normal::update_screen() { _forceFull = false; } -uint32 OSystem_SDL_Normal::property(int param, Property *value) { +uint32 OSystem_SDL::property(int param, Property *value) { if (param == PROP_TOGGLE_FULLSCREEN) { assert(_hwscreen != 0); @@ -475,37 +355,37 @@ uint32 OSystem_SDL_Normal::property(int param, Property *value) { return OSystem_SDL_Common::property(param, value); } -int16 OSystem_SDL_Normal::RBGToColor(uint8 r, uint8 g, uint8 b) +int16 OSystem_SDL::RBGToColor(uint8 r, uint8 g, uint8 b) { return SDL_MapRGB(_tmpscreen->format, r, g, b); } -void OSystem_SDL_Normal::colorToRBG(int16 color, uint8 &r, uint8 &g, uint8 &b) +void OSystem_SDL::colorToRBG(int16 color, uint8 &r, uint8 &g, uint8 &b) { SDL_GetRGB(color, _tmpscreen->format, &r, &g, &b); } -void OSystem_SDL_Normal::show_overlay() +void OSystem_SDL::show_overlay() { // hide the mouse undraw_mouse(); - _overlay_visible = true; + _overlayVisible = true; clear_overlay(); } -void OSystem_SDL_Normal::hide_overlay() +void OSystem_SDL::hide_overlay() { // hide the mouse undraw_mouse(); - _overlay_visible = false; + _overlayVisible = false; _forceFull = true; } -void OSystem_SDL_Normal::clear_overlay() +void OSystem_SDL::clear_overlay() { - if (!_overlay_visible) + if (!_overlayVisible) return; // hide the mouse @@ -523,9 +403,9 @@ void OSystem_SDL_Normal::clear_overlay() _forceFull = true; } -void OSystem_SDL_Normal::grab_overlay(int16 *buf, int pitch) +void OSystem_SDL::grab_overlay(int16 *buf, int pitch) { - if (!_overlay_visible) + if (!_overlayVisible) return; if (_tmpscreen == NULL) @@ -537,20 +417,20 @@ void OSystem_SDL_Normal::grab_overlay(int16 *buf, int pitch) if (SDL_LockSurface(_tmpscreen) == -1) error("SDL_LockSurface failed: %s.\n", SDL_GetError()); - int16 *src = (int16 *)_tmpscreen->pixels + TMP_SCREEN_WIDTH + 1; + int16 *src = (int16 *)_tmpscreen->pixels + _tmpScreenWidth + 1; int h = _screenHeight; do { memcpy(buf, src, _screenWidth*2); - src += TMP_SCREEN_WIDTH; + src += _tmpScreenWidth; buf += pitch; } while (--h); SDL_UnlockSurface(_tmpscreen); } -void OSystem_SDL_Normal::copy_rect_overlay(const int16 *buf, int pitch, int x, int y, int w, int h) +void OSystem_SDL::copy_rect_overlay(const int16 *buf, int pitch, int x, int y, int w, int h) { - if (!_overlay_visible) + if (!_overlayVisible) return; if (_tmpscreen == NULL) @@ -574,10 +454,10 @@ void OSystem_SDL_Normal::copy_rect_overlay(const int16 *buf, int pitch, int x, i if (SDL_LockSurface(_tmpscreen) == -1) error("SDL_LockSurface failed: %s.\n", SDL_GetError()); - int16 *dst = (int16 *)_tmpscreen->pixels + (y+1) * TMP_SCREEN_WIDTH + (x+1); + int16 *dst = (int16 *)_tmpscreen->pixels + (y+1) * _tmpScreenWidth + (x+1); do { memcpy(dst, buf, w*2); - dst += TMP_SCREEN_WIDTH; + dst += _tmpScreenWidth; buf += pitch; } while (--h); diff --git a/backends/sdl/sdl_gl.cpp b/backends/sdl/sdl_gl.cpp index 504810c711..6675f11d01 100644 --- a/backends/sdl/sdl_gl.cpp +++ b/backends/sdl/sdl_gl.cpp @@ -32,9 +32,9 @@ int glGetColorTable(int, int, int, void *) { return 0; } #include "fb2opengl.h" -class OSystem_SDL_Normal : public OSystem_SDL_Common { +class OSystem_SDL_OpenGL : public OSystem_SDL_Common { public: - OSystem_SDL_Normal() : _tmpscreen(0), _overlay_visible(false) { _glScreenStart = 0; _glBilinearFilter = true; } + OSystem_SDL_OpenGL() { _glScreenStart = 0; _glBilinearFilter = true; } // Set colors of the palette void set_palette(const byte *colors, uint start, uint num); @@ -60,27 +60,16 @@ protected: SDL_Surface *tmpSurface; // Used for black rectangles blitting SDL_Rect tmpBlackRect; // Black rectangle at end of the GL screen - typedef void ScalerProc(uint8 *srcPtr, uint32 srcPitch, uint8 *deltaPtr, - uint8 *dstPtr, uint32 dstPitch, int width, int height); - - SDL_Surface *_tmpscreen; // temporary screen (for scalers/overlay) - bool _overlay_visible; - - virtual void draw_mouse(); - virtual void undraw_mouse(); - virtual void load_gfx_mode(); virtual void unload_gfx_mode(); void hotswap_gfx_mode(); - - int TMP_SCREEN_WIDTH; }; OSystem_SDL_Common *OSystem_SDL_Common::create() { - return new OSystem_SDL_Normal(); + return new OSystem_SDL_OpenGL(); } -void OSystem_SDL_Normal::set_palette(const byte *colors, uint start, uint num) { +void OSystem_SDL_OpenGL::set_palette(const byte *colors, uint start, uint num) { const byte *b = colors; uint i; SDL_Color *base = _currentPalette + start; @@ -98,116 +87,7 @@ void OSystem_SDL_Normal::set_palette(const byte *colors, uint start, uint num) { _paletteDirtyEnd = start + num; } -void OSystem_SDL_Normal::draw_mouse() { - if (!_overlay_visible) { - OSystem_SDL_Common::draw_mouse(); - } - - if (_mouseDrawn || !_mouseVisible) - return; - - int x = _mouseCurState.x - _mouseHotspotX; - int y = _mouseCurState.y - _mouseHotspotY; - int w = _mouseCurState.w; - int h = _mouseCurState.h; - byte color; - byte *src = _mouseData; // Image representing the mouse - uint16 *bak = (uint16*)_mouseBackup; // Surface used to backup the area obscured by the mouse - uint16 *dst; // Surface we are drawing into - - // clip the mouse rect, and addjust the src pointer accordingly - if (x < 0) { - w += x; - src -= x; - x = 0; - } - if (y < 0) { - h += y; - src -= y * _mouseCurState.w; - y = 0; - } - - // Quick check to see if anything has to be drawn at all - if (w <= 0 || h <= 0) - return; - - if (w > _screenWidth - x) - w = _screenWidth - x; - if (h > _screenHeight - y) - h = _screenHeight - y; - - // Store the bounding box so that undraw mouse can restore the area the - // mouse currently covers to its original content. - _mouseOldState.x = x; - _mouseOldState.y = y; - _mouseOldState.w = w; - _mouseOldState.h = h; - - // Draw the mouse cursor; backup the covered area in "bak" - - if (SDL_LockSurface(_tmpscreen) == -1) - error("SDL_LockSurface failed: %s.\n", SDL_GetError()); - - // Mark as dirty - add_dirty_rect(x, y, w, h); - - dst = (uint16 *)_tmpscreen->pixels + (y+1) * TMP_SCREEN_WIDTH + (x+1); - while (h > 0) { - int width = w; - while (width > 0) { - *bak++ = *dst; - color = *src++; - if (color != 0xFF) // 0xFF = transparent, don't draw - *dst = RBGToColor(_currentPalette[color].r, _currentPalette[color].g, _currentPalette[color].b); - dst++; - width--; - } - src += _mouseCurState.w - w; - bak += MAX_MOUSE_W - w; - dst += TMP_SCREEN_WIDTH - w; - h--; - } - - SDL_UnlockSurface(_tmpscreen); - - // Finally, set the flag to indicate the mouse has been drawn - _mouseDrawn = true; -} - -void OSystem_SDL_Normal::undraw_mouse() { - if (!_overlay_visible) { - OSystem_SDL_Common::undraw_mouse(); - } - - if (!_mouseDrawn) - return; - _mouseDrawn = false; - - if (SDL_LockSurface(_tmpscreen) == -1) - error("SDL_LockSurface failed: %s.\n", SDL_GetError()); - - uint16 *dst, *bak = (uint16 *)_mouseBackup; - const int old_mouse_x = _mouseOldState.x; - const int old_mouse_y = _mouseOldState.y; - const int old_mouse_w = _mouseOldState.w; - const int old_mouse_h = _mouseOldState.h; - int x, y; - - // No need to do clipping here, since draw_mouse() did that already - - dst = (uint16 *)_tmpscreen->pixels + (old_mouse_y+1) * TMP_SCREEN_WIDTH + (old_mouse_x+1); - for (y = 0; y < old_mouse_h; ++y, bak += MAX_MOUSE_W, dst += TMP_SCREEN_WIDTH) { - for (x = 0; x < old_mouse_w; ++x) { - dst[x] = bak[x]; - } - } - - add_dirty_rect(old_mouse_x, old_mouse_y, old_mouse_w, old_mouse_h); - - SDL_UnlockSurface(_tmpscreen); -} - -void OSystem_SDL_Normal::load_gfx_mode() { +void OSystem_SDL_OpenGL::load_gfx_mode() { uint32 Rmask, Gmask, Bmask, Amask; // I have to force 16 bit color depth with 565 ordering // SDL_SetVideoMode sometimes doesn't accept your color depth definition @@ -221,7 +101,7 @@ void OSystem_SDL_Normal::load_gfx_mode() { _scaleFactor = 2; _tmpscreen = NULL; - TMP_SCREEN_WIDTH = (_screenWidth + 3); + _tmpScreenWidth = (_screenWidth + 3); // // Create the surface that contains the 8 bit game data @@ -251,9 +131,9 @@ void OSystem_SDL_Normal::load_gfx_mode() { // // Need some extra bytes around when using 2xSaI - uint16 *tmp_screen = (uint16*)calloc(TMP_SCREEN_WIDTH*(_screenHeight+3),sizeof(uint16)); + uint16 *tmp_screen = (uint16*)calloc(_tmpScreenWidth*(_screenHeight+3),sizeof(uint16)); _tmpscreen = SDL_CreateRGBSurfaceFrom(tmp_screen, - TMP_SCREEN_WIDTH, _screenHeight + 3, 16, TMP_SCREEN_WIDTH*2, + _tmpScreenWidth, _screenHeight + 3, 16, _tmpScreenWidth*2, Rmask, Gmask, Bmask, @@ -284,7 +164,7 @@ void OSystem_SDL_Normal::load_gfx_mode() { } -void OSystem_SDL_Normal::unload_gfx_mode() { +void OSystem_SDL_OpenGL::unload_gfx_mode() { if (_screen) { SDL_FreeSurface(_screen); _screen = NULL; @@ -297,7 +177,7 @@ void OSystem_SDL_Normal::unload_gfx_mode() { } } -void OSystem_SDL_Normal::update_screen() { +void OSystem_SDL_OpenGL::update_screen() { // If the shake position changed, fill the dirty area with blackness if (_currentShakePos != _newShakePos) { @@ -343,7 +223,7 @@ void OSystem_SDL_Normal::update_screen() { SDL_Rect *last_rect = _dirty_rect_list + _num_dirty_rects; // Convert appropriate parts of the 8bpp image into 16bpp - if (!_overlay_visible) { + if (!_overlayVisible) { SDL_Rect dst; for(r = _dirty_rect_list; r != last_rect; ++r) { dst = *r; @@ -370,7 +250,7 @@ void OSystem_SDL_Normal::update_screen() { _forceFull = false; } -void OSystem_SDL_Normal::hotswap_gfx_mode() { +void OSystem_SDL_OpenGL::hotswap_gfx_mode() { /* We allocate a screen sized bitmap which contains a "backup" * of the screen data during the change. Then we draw that to * the new screen right after it's setup. @@ -393,7 +273,7 @@ void OSystem_SDL_Normal::hotswap_gfx_mode() { update_screen(); } -uint32 OSystem_SDL_Normal::property(int param, Property *value) { +uint32 OSystem_SDL_OpenGL::property(int param, Property *value) { if (param == PROP_TOGGLE_FULLSCREEN) { _full_screen ^= true; @@ -460,27 +340,27 @@ uint32 OSystem_SDL_Normal::property(int param, Property *value) { } -void OSystem_SDL_Normal::show_overlay() +void OSystem_SDL_OpenGL::show_overlay() { // hide the mouse undraw_mouse(); - _overlay_visible = true; + _overlayVisible = true; clear_overlay(); } -void OSystem_SDL_Normal::hide_overlay() +void OSystem_SDL_OpenGL::hide_overlay() { // hide the mouse undraw_mouse(); - _overlay_visible = false; + _overlayVisible = false; _forceFull = true; } -void OSystem_SDL_Normal::clear_overlay() +void OSystem_SDL_OpenGL::clear_overlay() { - if (!_overlay_visible) + if (!_overlayVisible) return; // hide the mouse @@ -499,9 +379,9 @@ void OSystem_SDL_Normal::clear_overlay() _forceFull = true; } -void OSystem_SDL_Normal::grab_overlay(int16 *buf, int pitch) +void OSystem_SDL_OpenGL::grab_overlay(int16 *buf, int pitch) { - if (!_overlay_visible) + if (!_overlayVisible) return; if (_tmpscreen == NULL) @@ -513,20 +393,20 @@ void OSystem_SDL_Normal::grab_overlay(int16 *buf, int pitch) if (SDL_LockSurface(_tmpscreen) == -1) error("SDL_LockSurface failed: %s.\n", SDL_GetError()); - int16 *src = (int16 *)_tmpscreen->pixels + TMP_SCREEN_WIDTH + 1; + int16 *src = (int16 *)_tmpscreen->pixels + _tmpScreenWidth + 1; int h = _screenHeight; do { memcpy(buf, src, _screenWidth*2); - src += TMP_SCREEN_WIDTH; + src += _tmpScreenWidth; buf += pitch; } while (--h); SDL_UnlockSurface(_tmpscreen); } -void OSystem_SDL_Normal::copy_rect_overlay(const int16 *buf, int pitch, int x, int y, int w, int h) +void OSystem_SDL_OpenGL::copy_rect_overlay(const int16 *buf, int pitch, int x, int y, int w, int h) { - if (!_overlay_visible) + if (!_overlayVisible) return; if (_tmpscreen == NULL) @@ -550,10 +430,10 @@ void OSystem_SDL_Normal::copy_rect_overlay(const int16 *buf, int pitch, int x, i if (SDL_LockSurface(_tmpscreen) == -1) error("SDL_LockSurface failed: %s.\n", SDL_GetError()); - int16 *dst = (int16 *)_tmpscreen->pixels + (y+1) * TMP_SCREEN_WIDTH + (x+1); + int16 *dst = (int16 *)_tmpscreen->pixels + (y+1) * _tmpScreenWidth + (x+1); do { memcpy(dst, buf, w*2); - dst += TMP_SCREEN_WIDTH; + dst += _tmpScreenWidth; buf += pitch; } while (--h); |