aboutsummaryrefslogtreecommitdiff
path: root/engines/titanic
diff options
context:
space:
mode:
authorPaul Gilbert2016-09-30 21:54:03 -0400
committerPaul Gilbert2016-09-30 21:54:03 -0400
commit09561bd36c9add746b6e426088ac67faaa069dfc (patch)
treedf559625565822b85362e548be2433d5aa69926c /engines/titanic
parent67acdb628bf371f04b7387c61dc0f669360abe40 (diff)
downloadscummvm-rg350-09561bd36c9add746b6e426088ac67faaa069dfc.tar.gz
scummvm-rg350-09561bd36c9add746b6e426088ac67faaa069dfc.tar.bz2
scummvm-rg350-09561bd36c9add746b6e426088ac67faaa069dfc.zip
TITANIC: Use CRawSurface in video surface getPixel
Diffstat (limited to 'engines/titanic')
-rw-r--r--engines/titanic/support/raw_surface.cpp54
-rw-r--r--engines/titanic/support/raw_surface.h18
-rw-r--r--engines/titanic/support/video_surface.cpp10
3 files changed, 44 insertions, 38 deletions
diff --git a/engines/titanic/support/raw_surface.cpp b/engines/titanic/support/raw_surface.cpp
index 044bdb59c1..8328ad1e88 100644
--- a/engines/titanic/support/raw_surface.cpp
+++ b/engines/titanic/support/raw_surface.cpp
@@ -25,32 +25,32 @@
namespace Titanic {
-CRawSurface::CRawSurface(Graphics::Surface *surface, TransparencyMode transMode) {
+CRawSurface::CRawSurface(const Graphics::Surface *surface, TransparencyMode transMode) {
_width = surface->w;
_pixelsBaseP = (byte *)surface->getPixels();
_pixelsP = nullptr;
_pitch = 0;
- _fieldC = 0;
- _field10 = false;
- _field18 = 0;
- _field1C = 0xFF;
+ _runLength = 0;
+ _flag = false;
+ _flag1 = false;
+ _flag2 = true;
switch (transMode) {
case TRANS_MASK0:
case TRANS_ALPHA0:
- _field1C = 0;
- _field18 = 0xFF;
+ _flag2 = false;
+ _flag1 = true;
break;
case TRANS_MASK255:
case TRANS_ALPHA255:
- _field1C = 0xFF;
- _field18 = 0;
+ _flag2 = true;
+ _flag1 = false;
break;
case TRANS_DEFAULT:
if ((_pixelsBaseP[0] == 0 && _pixelsBaseP[2] < 0x80) ||
(_pixelsBaseP[0] != 0 && _pixelsBaseP[1] < 0x80)) {
- _field18 = 0xFF;
- _field1C = 0;
+ _flag1 = true;
+ _flag2 = false;
}
break;
default:
@@ -75,55 +75,55 @@ void CRawSurface::skipPitch() {
}
int CRawSurface::moveX(int xp) {
- if (_fieldC) {
- if (!_field10) {
- --_fieldC;
+ if (_runLength) {
+ if (!_flag) {
+ --_runLength;
--_pitch;
++_pixelsP;
return 1;
}
} else {
while (!*_pixelsBaseP) {
- _fieldC = *++_pixelsBaseP;
+ _runLength = *++_pixelsBaseP;
++_pixelsBaseP;
- if (_fieldC) {
+ if (_runLength) {
_pixelsP = _pixelsBaseP;
- _pixelsBaseP += _fieldC;
- if (_fieldC & 1)
+ _pixelsBaseP += _runLength;
+ if (_runLength & 1)
++_pixelsBaseP;
- _field10 = 0;
+ _flag = false;
--_pitch;
- --_fieldC;
+ --_runLength;
return 1;
}
}
- _fieldC = *_pixelsBaseP++;
+ _runLength = *_pixelsBaseP++;
++_pixelsBaseP;
- _field10 = true;
+ _flag = true;
}
if (xp < 0 || xp > _pitch)
xp = _pitch;
- int len = MIN(_fieldC, xp);
+ int len = MIN(_runLength, xp);
_pitch -= len;
- _fieldC -= len;
+ _runLength -= len;
return len;
}
uint CRawSurface::getPixel() const {
- return _field18 ? 0xFF - *_pixelsP : *_pixelsP;
+ return _flag1 ? 0xFF - *_pixelsP : *_pixelsP;
}
bool CRawSurface::isPixelTransparent1() const {
- return _field18 ? *_pixelsP == 0xF0 : *_pixelsP == 0x10;
+ return _flag1 ? *_pixelsP == 0xF0 : *_pixelsP == 0x10;
}
bool CRawSurface::isPixelTransparent2() const {
- return _field18 ? *_pixelsP == 0xF0 : *_pixelsP == 0x10;
+ return _flag2 ? *_pixelsP == 0xF0 : *_pixelsP == 0x10;
}
void CRawSurface::resetPitch() {
diff --git a/engines/titanic/support/raw_surface.h b/engines/titanic/support/raw_surface.h
index c0d98ad4d0..69efc1e3db 100644
--- a/engines/titanic/support/raw_surface.h
+++ b/engines/titanic/support/raw_surface.h
@@ -34,18 +34,16 @@ enum TransparencyMode {
class CRawSurface {
private:
- byte *_pixelsBaseP;
- byte *_pixelsP;
+ const byte *_pixelsBaseP;
+ const byte *_pixelsP;
int _pitch;
- int _fieldC;
- bool _field10;
+ int _runLength;
+ bool _flag;
int _width;
- int _field18;
- int _field1C;
-private:
- int moveX(int xp);
+ bool _flag1;
+ bool _flag2;
public:
- CRawSurface(Graphics::Surface *surface, TransparencyMode transMode);
+ CRawSurface(const Graphics::Surface *surface, TransparencyMode transMode);
void setRow(int yp);
@@ -60,6 +58,8 @@ public:
bool isPixelTransparent2() const;
void resetPitch();
+
+ int moveX(int xp);
};
} // End of namespace Titanic
diff --git a/engines/titanic/support/video_surface.cpp b/engines/titanic/support/video_surface.cpp
index 63ad782722..166a954dc1 100644
--- a/engines/titanic/support/video_surface.cpp
+++ b/engines/titanic/support/video_surface.cpp
@@ -22,6 +22,7 @@
#include "titanic/support/video_surface.h"
#include "titanic/support/image_decoders.h"
+#include "titanic/support/raw_surface.h"
#include "titanic/support/screen_manager.h"
#include "titanic/titanic.h"
@@ -408,8 +409,13 @@ uint16 OSVideoSurface::getPixel(const Common::Point &pt) {
if (pt.x >= 0 && pt.y >= 0 && pt.x < getWidth() && pt.y < getHeight()) {
if (_transparencySurface) {
- const byte *pixelP = (const byte *)_transparencySurface->getBasePtr(pt.x, pt.y);
- if (*pixelP != 0xF0)
+ CRawSurface rawSurface(&_transparencySurface->rawSurface(), _transparencyMode);
+ rawSurface.setRow(_transBlitFlag ? pt.y : getHeight() - pt.y - 1);
+ rawSurface.resetPitch();
+ rawSurface.setCol(pt.x);
+ rawSurface.moveX(0);
+
+ if (rawSurface.isPixelTransparent2())
return getTransparencyColor();
}