aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorKamil Zbróg2013-11-14 14:44:24 +0000
committerKamil Zbróg2013-11-14 14:44:24 +0000
commit7b1fed7331df8e4f4071445626d1ca67a5e7ff7b (patch)
tree80f943e39bbcf07a44dca02e5eab0e910742f6d9 /engines
parent8cffaaaff303773d1da48c9756e616937f2eb5d0 (diff)
downloadscummvm-rg350-7b1fed7331df8e4f4071445626d1ca67a5e7ff7b.tar.gz
scummvm-rg350-7b1fed7331df8e4f4071445626d1ca67a5e7ff7b.tar.bz2
scummvm-rg350-7b1fed7331df8e4f4071445626d1ca67a5e7ff7b.zip
PRINCE: get/set mob data added
Diffstat (limited to 'engines')
-rw-r--r--engines/prince/common.h47
-rw-r--r--engines/prince/mob.cpp38
-rw-r--r--engines/prince/mob.h32
-rw-r--r--engines/prince/object.cpp8
-rw-r--r--engines/prince/prince.cpp31
-rw-r--r--engines/prince/prince.h2
-rw-r--r--engines/prince/script.cpp14
7 files changed, 154 insertions, 18 deletions
diff --git a/engines/prince/common.h b/engines/prince/common.h
new file mode 100644
index 0000000000..6dc1bad6a8
--- /dev/null
+++ b/engines/prince/common.h
@@ -0,0 +1,47 @@
+/* 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_COMMON_H
+#define PRINCE_COMMON_H
+
+namespace Prince {
+
+enum Direction {
+ LD = 0,
+ L = 1,
+ LG = 2,
+ PD = 3,
+ P = 4,
+ PG = 5,
+ GL = 6,
+ G = 7,
+ GP = 8,
+ DL = 9,
+ D = 10,
+ DP = 11
+};
+
+}
+
+#endif
+
+/* vim: set tabstop=4 noexpandtab: */
diff --git a/engines/prince/mob.cpp b/engines/prince/mob.cpp
index 3df7235d2d..c4bb607347 100644
--- a/engines/prince/mob.cpp
+++ b/engines/prince/mob.cpp
@@ -41,7 +41,16 @@ bool Mob::loadFromStream(Common::SeekableReadStream &stream) {
_rect.right = stream.readUint16LE();
_rect.bottom = stream.readUint16LE();
- stream.skip(6 * sizeof(uint16));
+ _mask = stream.readUint16LE();
+
+ _examPosition.x = stream.readUint16LE();
+ _examPosition.y = stream.readUint16LE();
+ _examDirection = (Direction)stream.readUint16LE();
+
+ _usePosition.x = stream.readByte();
+ _usePosition.y = stream.readByte();
+ _useDirection = (Direction)stream.readUint16LE();
+
uint32 nameOffset = stream.readUint32LE();
uint32 examTextOffset = stream.readUint32LE();
@@ -60,6 +69,33 @@ bool Mob::loadFromStream(Common::SeekableReadStream &stream) {
return true;
}
+void Mob::setData(AttrId dataId, uint16 value) {
+ switch (dataId) {
+ case ExamDir:
+ _examDirection = (Direction)value;
+ break;
+ case ExamX:
+ _examPosition.x = value;
+ break;
+ case ExamY:
+ _examPosition.y = value;
+ break;
+ default:
+ assert(false);
+ }
+}
+
+uint16 Mob::getData(AttrId dataId) {
+ switch (dataId) {
+ case Visible: return _visible;
+ case ExamDir: return _examDirection;
+ case ExamX: return _examPosition.x;
+ case ExamY: return _examPosition.y;
+ default:
+ assert(false);
+ }
+}
+
}
/* vim: set tabstop=4 noexpandtab: */
diff --git a/engines/prince/mob.h b/engines/prince/mob.h
index 7db059e485..36630eb6eb 100644
--- a/engines/prince/mob.h
+++ b/engines/prince/mob.h
@@ -27,6 +27,8 @@
#include "common/rect.h"
#include "common/str.h"
+#include "prince/common.h"
+
namespace Common {
class SeekableReadStream;
}
@@ -40,9 +42,39 @@ public:
bool loadFromStream(Common::SeekableReadStream &stream);
+ // Used instead of offset in setData and getData
+ enum AttrId {
+ Visible = 0,
+ Type = 2,
+ X1 = 4,
+ Y1 = 6,
+ X2 = 8,
+ Y2 = 10,
+ Mask = 12,
+ ExamX = 14,
+ ExamY = 16,
+ ExamDir = 18,
+ UseX = 20,
+ UseY = 21,
+ UseDir = 22,
+ Name = 24,
+ ExamText = 28
+ };
+
+ void setData(AttrId dataId, uint16 value);
+ uint16 getData(AttrId dataId);
+
bool _visible;
uint16 _type;
+ uint16 _mask;
Common::Rect _rect;
+
+ Common::Point _examPosition;
+ Direction _examDirection;
+
+ Common::Point _usePosition;
+ Direction _useDirection;
+
Common::String _name;
Common::String _examText;
};
diff --git a/engines/prince/object.cpp b/engines/prince/object.cpp
index c4d8438926..4148cdf854 100644
--- a/engines/prince/object.cpp
+++ b/engines/prince/object.cpp
@@ -36,9 +36,11 @@ Object::Object() : _surface(NULL), _x(0), _y(0), _z(0) {
}
Object::~Object() {
- _surface->free();
- delete _surface;
- _surface = NULL;
+ if (_surface) {
+ _surface->free();
+ delete _surface;
+ _surface = NULL;
+ }
}
void Object::loadSurface(Common::SeekableReadStream &stream) {
diff --git a/engines/prince/prince.cpp b/engines/prince/prince.cpp
index fdd9219b13..4a8fa9ae71 100644
--- a/engines/prince/prince.cpp
+++ b/engines/prince/prince.cpp
@@ -74,7 +74,7 @@ PrinceEngine::PrinceEngine(OSystem *syst, const PrinceGameDescription *gameDesc)
Engine(syst), _gameDescription(gameDesc), _graph(NULL), _script(NULL),
_locationNr(0), _debugger(NULL), _midiPlayer(NULL),
_cameraX(0), _newCameraX(0), _frameNr(0), _cursor1(NULL), _cursor2(NULL), _font(NULL),
- _walizkaBmp(NULL), _roomBmp(NULL), _voiceStream(NULL) {
+ _walizkaBmp(NULL), _roomBmp(NULL), _voiceStream(NULL), _cursorNr(0) {
// Debug/console setup
DebugMan.addDebugChannel(DebugChannel::kScript, "script", "Prince Script debug channel");
@@ -141,19 +141,36 @@ template <typename T>
bool loadResource(Common::Array<T> &array, const char *resourceName, bool required = true) {
Common::SeekableReadStream *stream = SearchMan.createReadStreamForMember(resourceName);
if (!stream) {
- if (required) {
+ if (required)
error("Can't load %s", resourceName);
- }
return false;
}
- typename Common::Array<T>::value_type t;
+ T t;
while (t.loadFromStream(*stream))
array.push_back(t);
delete stream;
return true;
}
+#if 0
+template <typename T>
+bool loadResource(T * array[], const char *resourceName, bool required = true) {
+ Common::SeekableReadStream *stream = SearchMan.createReadStreamForMember(resourceName);
+ if (!stream) {
+ if (required)
+ error("Can't load %s", resourceName);
+ return false;
+ }
+
+ T* t = new T();
+ while (t->loadFromStream(*stream))
+ array.push_back(t);
+
+ delete stream;
+ return true;
+}
+#endif
void PrinceEngine::init() {
@@ -539,8 +556,8 @@ void PrinceEngine::drawScreen() {
void PrinceEngine::mainLoop() {
- loadLocation(2);
- changeCursor(1);
+ loadLocation(4);
+ changeCursor(0);
while (!shouldQuit()) {
uint32 currentTime = _system->getMillis();
@@ -572,6 +589,8 @@ void PrinceEngine::mainLoop() {
if (shouldQuit())
return;
+ // TODO: Update all structures, animations, naks, heros etc.
+
//_script->step();
drawScreen();
diff --git a/engines/prince/prince.h b/engines/prince/prince.h
index 25fac64435..374048f285 100644
--- a/engines/prince/prince.h
+++ b/engines/prince/prince.h
@@ -149,7 +149,7 @@ private:
Audio::SoundHandle _soundHandle;
Common::SeekableReadStream *_voiceStream;
Common::Array<Mob> _mobList;
- Common::Array<Object *> _objectList;
+ Common::Array<Object *> _objList;
uint16 _cameraX;
uint16 _newCameraX;
diff --git a/engines/prince/script.cpp b/engines/prince/script.cpp
index 94fbcba688..7ad2df2a56 100644
--- a/engines/prince/script.cpp
+++ b/engines/prince/script.cpp
@@ -492,9 +492,9 @@ void Script::O_ORFLAG() {
}
void Script::O_SETMOBDATA() {
- uint16 mobId = readScript16bits();
- uint16 mobOffset = readScript16bits();
- uint16 value = readScript16bits();
+ uint16 mobId = readScriptValue();
+ uint16 mobOffset = readScriptValue();
+ uint16 value = readScriptValue();
debugScript("O_SETMOBDATA mobId %d, mobOffset %d, value %d", mobId, mobOffset, value);
}
@@ -537,10 +537,10 @@ void Script::O_WALKHERO() {
}
void Script::O_SETHERO() {
- uint16 hero = readScript16bits();
- uint16 x = readScript16bits();
- uint16 y = readScript16bits();
- uint16 dir = readScript16bits();
+ uint16 hero = readScriptValue();
+ uint16 x = readScriptValue();
+ uint16 y = readScriptValue();
+ uint16 dir = readScriptValue();
debugScript("O_SETHERO hero %d, x %d, y %d, dir %d", hero, x, y, dir);
}