diff options
author | Paul Gilbert | 2016-09-30 20:48:59 -0400 |
---|---|---|
committer | Paul Gilbert | 2016-09-30 20:48:59 -0400 |
commit | 8a96db4d3044063fbc4963bdc645f23343ae6cb6 (patch) | |
tree | 5e802476f7d166d95da054722813c184936746b6 | |
parent | 60be24d973e2a86493fd636fb152ffb31527275f (diff) | |
download | scummvm-rg350-8a96db4d3044063fbc4963bdc645f23343ae6cb6.tar.gz scummvm-rg350-8a96db4d3044063fbc4963bdc645f23343ae6cb6.tar.bz2 scummvm-rg350-8a96db4d3044063fbc4963bdc645f23343ae6cb6.zip |
TITANIC: Added CRawSurface class
-rw-r--r-- | engines/titanic/module.mk | 1 | ||||
-rw-r--r-- | engines/titanic/support/raw_surface.cpp | 133 | ||||
-rw-r--r-- | engines/titanic/support/raw_surface.h | 67 | ||||
-rw-r--r-- | engines/titanic/support/video_surface.h | 6 |
4 files changed, 202 insertions, 5 deletions
diff --git a/engines/titanic/module.mk b/engines/titanic/module.mk index 377a22fbf8..f1a6c751df 100644 --- a/engines/titanic/module.mk +++ b/engines/titanic/module.mk @@ -474,6 +474,7 @@ MODULE_OBJS := \ support/movie_range_info.o \ support/movie_manager.o \ support/credit_text.o \ + support/raw_surface.o \ support/rect.o \ support/screen_manager.o \ support/simple_file.o \ diff --git a/engines/titanic/support/raw_surface.cpp b/engines/titanic/support/raw_surface.cpp new file mode 100644 index 0000000000..044bdb59c1 --- /dev/null +++ b/engines/titanic/support/raw_surface.cpp @@ -0,0 +1,133 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/support/raw_surface.h" +#include "common/algorithm.h" + +namespace Titanic { + +CRawSurface::CRawSurface(Graphics::Surface *surface, TransparencyMode transMode) { + _width = surface->w; + _pixelsBaseP = (byte *)surface->getPixels(); + _pixelsP = nullptr; + _pitch = 0; + _fieldC = 0; + _field10 = false; + _field18 = 0; + _field1C = 0xFF; + + switch (transMode) { + case TRANS_MASK0: + case TRANS_ALPHA0: + _field1C = 0; + _field18 = 0xFF; + break; + case TRANS_MASK255: + case TRANS_ALPHA255: + _field1C = 0xFF; + _field18 = 0; + break; + case TRANS_DEFAULT: + if ((_pixelsBaseP[0] == 0 && _pixelsBaseP[2] < 0x80) || + (_pixelsBaseP[0] != 0 && _pixelsBaseP[1] < 0x80)) { + _field18 = 0xFF; + _field1C = 0; + } + break; + default: + break; + } +} + +void CRawSurface::setRow(int yp) { + for (int y = 0; y < yp; ++yp) { + resetPitch(); + skipPitch(); + } +} + +void CRawSurface::setCol(int xp) { + while (xp > 0) + xp -= moveX(xp); +} + +void CRawSurface::skipPitch() { + setCol(_pitch); +} + +int CRawSurface::moveX(int xp) { + if (_fieldC) { + if (!_field10) { + --_fieldC; + --_pitch; + ++_pixelsP; + return 1; + } + } else { + while (!*_pixelsBaseP) { + _fieldC = *++_pixelsBaseP; + ++_pixelsBaseP; + + if (_fieldC) { + _pixelsP = _pixelsBaseP; + _pixelsBaseP += _fieldC; + if (_fieldC & 1) + ++_pixelsBaseP; + + _field10 = 0; + --_pitch; + --_fieldC; + return 1; + } + } + + _fieldC = *_pixelsBaseP++; + ++_pixelsBaseP; + _field10 = true; + } + + if (xp < 0 || xp > _pitch) + xp = _pitch; + + int len = MIN(_fieldC, xp); + _pitch -= len; + _fieldC -= len; + return len; +} + +uint CRawSurface::getPixel() const { + return _field18 ? 0xFF - *_pixelsP : *_pixelsP; +} + +bool CRawSurface::isPixelTransparent1() const { + return _field18 ? *_pixelsP == 0xF0 : *_pixelsP == 0x10; +} + +bool CRawSurface::isPixelTransparent2() const { + return _field18 ? *_pixelsP == 0xF0 : *_pixelsP == 0x10; +} + +void CRawSurface::resetPitch() { + _pitch = _width; +} + +} // End of namespace Titanic diff --git a/engines/titanic/support/raw_surface.h b/engines/titanic/support/raw_surface.h new file mode 100644 index 0000000000..c0d98ad4d0 --- /dev/null +++ b/engines/titanic/support/raw_surface.h @@ -0,0 +1,67 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_RAW_SURFACE_H +#define TITANIC_RAW_SURFACE_H + +#include "graphics/surface.h" + +namespace Titanic { + +enum TransparencyMode { + TRANS_MASK0 = 0, TRANS_MASK255 = 1, TRANS_ALPHA0 = 2, + TRANS_ALPHA255 = 3, TRANS_DEFAULT = 4 +}; + +class CRawSurface { +private: + byte *_pixelsBaseP; + byte *_pixelsP; + int _pitch; + int _fieldC; + bool _field10; + int _width; + int _field18; + int _field1C; +private: + int moveX(int xp); +public: + CRawSurface(Graphics::Surface *surface, TransparencyMode transMode); + + void setRow(int yp); + + void setCol(int xp); + + void skipPitch(); + + uint getPixel() const; + + bool isPixelTransparent1() const; + + bool isPixelTransparent2() const; + + void resetPitch(); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_RAW_SURFACE_H */ diff --git a/engines/titanic/support/video_surface.h b/engines/titanic/support/video_surface.h index c21149333d..ad868d87ba 100644 --- a/engines/titanic/support/video_surface.h +++ b/engines/titanic/support/video_surface.h @@ -30,17 +30,13 @@ #include "titanic/support/direct_draw.h" #include "titanic/support/movie.h" #include "titanic/support/movie_range_info.h" +#include "titanic/support/raw_surface.h" #include "titanic/support/rect.h" #include "titanic/core/list.h" #include "titanic/core/resource_key.h" namespace Titanic { -enum TransparencyMode { - TRANS_MASK0 = 0, TRANS_MASK255 = 1, TRANS_ALPHA0 = 2, - TRANS_ALPHA255 = 3, TRANS_DEFAULT = 4 -}; - class CScreenManager; class CJPEGDecode; class CTargaDecode; |