mirror of
https://github.com/libretro/scummvm.git
synced 2025-02-24 21:21:05 +00:00
TITANIC: Added CRawSurface class
This commit is contained in:
parent
60be24d973
commit
8a96db4d30
@ -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 \
|
||||
|
133
engines/titanic/support/raw_surface.cpp
Normal file
133
engines/titanic/support/raw_surface.cpp
Normal file
@ -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
|
67
engines/titanic/support/raw_surface.h
Normal file
67
engines/titanic/support/raw_surface.h
Normal file
@ -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 */
|
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user