aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorlukaslw2014-06-01 20:44:04 +0200
committerlukaslw2014-06-22 20:08:36 +0200
commit46ce47dbca3d046121b6aaa5f3cd4827e7bfe0a7 (patch)
treec13106b9217f8b5a0d7488157d8a7ef19979a5cb /engines
parent445229c196042e80de421d0f0e8fc7ba444dd144 (diff)
downloadscummvm-rg350-46ce47dbca3d046121b6aaa5f3cd4827e7bfe0a7.tar.gz
scummvm-rg350-46ce47dbca3d046121b6aaa5f3cd4827e7bfe0a7.tar.bz2
scummvm-rg350-46ce47dbca3d046121b6aaa5f3cd4827e7bfe0a7.zip
PRINCE: Parallax bitmaps loading, showParallax() implementation
Diffstat (limited to 'engines')
-rw-r--r--engines/prince/module.mk3
-rw-r--r--engines/prince/object.cpp2
-rw-r--r--engines/prince/prince.cpp37
-rw-r--r--engines/prince/prince.h6
-rw-r--r--engines/prince/pscr.cpp90
-rw-r--r--engines/prince/pscr.h53
6 files changed, 183 insertions, 8 deletions
diff --git a/engines/prince/module.mk b/engines/prince/module.mk
index 228e5990e2..ad5b20aeb1 100644
--- a/engines/prince/module.mk
+++ b/engines/prince/module.mk
@@ -18,7 +18,8 @@ MODULE_OBJS = \
decompress.o \
hero.o \
hero_set.o \
- cursor.o
+ cursor.o \
+ pscr.o
# This module can be built as a plugin
ifeq ($(ENABLE_PRINCE), DYNAMIC_PLUGIN)
diff --git a/engines/prince/object.cpp b/engines/prince/object.cpp
index 11c553ffbc..94d55b5716 100644
--- a/engines/prince/object.cpp
+++ b/engines/prince/object.cpp
@@ -80,7 +80,7 @@ bool Object::loadFromStream(Common::SeekableReadStream &stream) {
stream.seek(pos + 16);
- debug("Object x %d, y %d, z %d overlay %d", _x, _y, _z, _mask);
+ //debug("Object x %d, y %d, z %d overlay %d", _x, _y, _z, _mask);
return true;
}
diff --git a/engines/prince/prince.cpp b/engines/prince/prince.cpp
index afef9d4608..b19ac29d6b 100644
--- a/engines/prince/prince.cpp
+++ b/engines/prince/prince.cpp
@@ -115,6 +115,11 @@ PrinceEngine::~PrinceEngine() {
}
_objList.clear();
+ for (uint32 i = 0; i < _pscrList.size(); i++) {
+ delete _pscrList[i];
+ }
+ _pscrList.clear();
+
for (uint i = 0; i < _maskList.size(); i++) {
free(_maskList[i]._data);
}
@@ -251,8 +256,8 @@ bool AnimListItem::loadFromStream(Common::SeekableReadStream &stream) {
_nextAnim = stream.readUint16LE();
_flags = stream.readUint16LE();
- debug("AnimListItem type %d, fileNumber %d, x %d, y %d, flags %d", _type, _fileNumber, _x, _y, _flags);
- debug("startPhase %d, endPhase %d, loopPhase %d", _startPhase, _endPhase, _loopPhase);
+ //debug("AnimListItem type %d, fileNumber %d, x %d, y %d, flags %d", _type, _fileNumber, _x, _y, _flags);
+ //debug("startPhase %d, endPhase %d, loopPhase %d", _startPhase, _endPhase, _loopPhase);
// 32 byte aligment
stream.seek(pos + 32);
@@ -304,6 +309,12 @@ bool PrinceEngine::loadLocation(uint16 locationNr) {
loadZoom(_mainHero->_zoomBitmap, _mainHero->kZoomBitmapLen, "zoom");
loadShadow(_mainHero->_shadowBitmap, _mainHero->kShadowBitmapSize, "shadow", "shadow2");
+ for (uint32 i = 0; i < _pscrList.size(); i++) {
+ delete _pscrList[i];
+ }
+ _pscrList.clear();
+ Resource::loadResource(_pscrList, "pscr.lst", false);
+
_mobList.clear();
Resource::loadResource(_mobList, "mob.lst", false);
@@ -801,11 +812,11 @@ void PrinceEngine::showMask(int maskNr, const Graphics::Surface *originalRoomSur
}
}
-void PrinceEngine::showSprite(Graphics::Surface *backAnimSurface, int destX, int destY) {
- if (spriteCheck(backAnimSurface->w, backAnimSurface->h, destX, destY)) {
+void PrinceEngine::showSprite(const Graphics::Surface *spriteSurface, int destX, int destY) {
+ if (spriteCheck(spriteSurface->w, spriteSurface->h, destX, destY)) {
destX -= _picWindowX;
destY -= _picWindowY;
- _graph->drawTransparent(destX, destY, backAnimSurface);
+ _graph->drawTransparent(destX, destY, spriteSurface);
}
}
@@ -1063,6 +1074,20 @@ void PrinceEngine::showObjects() {
}
}
+void PrinceEngine::showParallax() {
+ if (!_pscrList.empty()) {
+ for (uint i = 0; i < _pscrList.size(); i++) {
+ const Graphics::Surface *pscrSurface = _pscrList[i]->getSurface();
+ int x = _pscrList[i]->_x - (_pscrList[i]->_step * _picWindowX / 4);
+ int y = _pscrList[i]->_y;
+ //int z = 1000;
+ if (spriteCheck(pscrSurface->w, pscrSurface->h, x, y)) {
+ showSprite(pscrSurface, x, y);
+ }
+ }
+ }
+}
+
void PrinceEngine::drawScreen() {
const Graphics::Surface *roomSurface = _roomBmp->getSurface();
Graphics::Surface visiblePart;
@@ -1096,6 +1121,8 @@ void PrinceEngine::drawScreen() {
insertMasks(&visiblePart);
}
+ showParallax();
+
clsMasks();
playNextFrame();
diff --git a/engines/prince/prince.h b/engines/prince/prince.h
index 1deb26f926..d30b51432d 100644
--- a/engines/prince/prince.h
+++ b/engines/prince/prince.h
@@ -45,6 +45,7 @@
#include "prince/mob.h"
#include "prince/object.h"
+#include "prince/pscr.h"
namespace Prince {
@@ -65,6 +66,7 @@ class Font;
class Hero;
class Animation;
class Room;
+class Pscr;
struct Text {
const char *_str;
@@ -268,9 +270,10 @@ private:
void showBackAnims();
void clearBackAnimList();
bool spriteCheck(int sprWidth, int sprHeight, int destX, int destY);
- void showSprite(Graphics::Surface *backAnimSurface, int destX, int destY);
+ void showSprite(const Graphics::Surface *spriteSurface, int destX, int destY);
void showSpriteShadow(Graphics::Surface *shadowSurface, int destX, int destY);
void showObjects();
+ void showParallax();
void makeShadowTable(int brightness);
uint32 getTextWidth(const char *s);
@@ -297,6 +300,7 @@ private:
Audio::SoundHandle _soundHandle[MAX_SAMPLES];
Animation *_zoom;
+ Common::Array<PScr *> _pscrList;
Common::Array<Mob> _mobList;
Common::Array<Object *> _objList;
Common::Array<Mask> _maskList;
diff --git a/engines/prince/pscr.cpp b/engines/prince/pscr.cpp
new file mode 100644
index 0000000000..7402e46e43
--- /dev/null
+++ b/engines/prince/pscr.cpp
@@ -0,0 +1,90 @@
+/* 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 "common/archive.h"
+#include "common/debug-channels.h"
+#include "common/debug.h"
+#include "common/stream.h"
+
+#include "graphics/surface.h"
+
+#include "prince/pscr.h"
+
+namespace Prince {
+
+PScr::PScr() :_file(0), _x(0), _y(0), _step(0), _addr(0), _len(0), _surface(NULL)
+{
+}
+
+PScr::~PScr() {
+ if (_surface) {
+ _surface->free();
+ delete _surface;
+ _surface = NULL;
+ }
+}
+
+void PScr::loadSurface(Common::SeekableReadStream &stream) {
+ //stream.skip(4);
+ int x = stream.readUint16LE();
+ int y = stream.readUint16LE();
+ int width = stream.readUint16LE();
+ int height = stream.readUint16LE();
+ debug("x: %d, y: %d", x, y);
+ debug("w: %d, h: %d", width, height);
+ _surface = new Graphics::Surface();
+ _surface->create(width, height, Graphics::PixelFormat::createFormatCLUT8());
+
+ for (int h = 0; h < _surface->h; h++) {
+ stream.read(_surface->getBasePtr(0, h), _surface->w);
+ }
+}
+
+bool PScr::loadFromStream(Common::SeekableReadStream &stream) {
+ int32 pos = stream.pos();
+ uint16 file = stream.readUint16LE();
+ if (file == 0xFFFF)
+ return false;
+ _file = file;
+ _x = stream.readUint16LE();
+ _y = stream.readUint16LE();
+ _step = stream.readUint16LE();
+ _addr = stream.readUint32LE();
+
+ const Common::String pscrStreamName = Common::String::format("PS%02d", _file);
+ Common::SeekableReadStream *pscrStream = SearchMan.createReadStreamForMember(pscrStreamName);
+ if (!pscrStream) {
+ error("Can't load %s", pscrStreamName.c_str());
+ return false;
+ }
+
+ loadSurface(*pscrStream);
+ delete pscrStream;
+
+ stream.seek(pos + 12); // size of PScrList struct
+
+ debug("Parallex nr %d, x %d, y %d, step %d", _file, _x, _y, _step);
+
+ return true;
+}
+
+} \ No newline at end of file
diff --git a/engines/prince/pscr.h b/engines/prince/pscr.h
new file mode 100644
index 0000000000..3564a571e7
--- /dev/null
+++ b/engines/prince/pscr.h
@@ -0,0 +1,53 @@
+/* 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 PRINCE_PSCR_H
+#define PRINCE_PSCR_H
+
+#include "image/image_decoder.h"
+#include "graphics/surface.h"
+
+namespace Prince {
+
+class PScr {
+public:
+ PScr();
+ ~PScr();
+
+ int16 _file;
+ int16 _x;
+ int16 _y;
+ int16 _step;
+ int32 _addr;
+ byte _len;
+
+ bool loadFromStream(Common::SeekableReadStream &stream);
+ const Graphics::Surface *getSurface() const { return _surface; }
+private:
+ void loadSurface(Common::SeekableReadStream &stream);
+ Graphics::Surface *_surface;
+};
+
+}
+
+#endif
+