aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVladimir Menshakov2009-11-17 21:42:56 +0000
committerVladimir Menshakov2009-11-17 21:42:56 +0000
commit43f23ee523b05d77a61d4a0335edcc89d6ca1229 (patch)
tree6e763bcc7ccb02490ce5175ed6145953e372d5f8
parentf2a704cb4f3e719cd4b08fc803fc5fe4a99a2fd7 (diff)
downloadscummvm-rg350-43f23ee523b05d77a61d4a0335edcc89d6ca1229.tar.gz
scummvm-rg350-43f23ee523b05d77a61d4a0335edcc89d6ca1229.tar.bz2
scummvm-rg350-43f23ee523b05d77a61d4a0335edcc89d6ca1229.zip
added SurfaceList, ported overlay to it, fixed many z-order issues. (found meaning of the flags in overlay resources)
svn-id: r45960
-rw-r--r--engines/teenagent/module.mk1
-rw-r--r--engines/teenagent/scene.cpp10
-rw-r--r--engines/teenagent/scene.h4
-rw-r--r--engines/teenagent/surface.cpp20
-rw-r--r--engines/teenagent/surface.h11
-rw-r--r--engines/teenagent/surface_list.cpp77
-rw-r--r--engines/teenagent/surface_list.h50
7 files changed, 143 insertions, 30 deletions
diff --git a/engines/teenagent/module.mk b/engines/teenagent/module.mk
index d178266372..2c04c99376 100644
--- a/engines/teenagent/module.mk
+++ b/engines/teenagent/module.mk
@@ -10,6 +10,7 @@ MODULE_OBJS := \
animation.o \
font.o \
surface.o \
+ surface_list.o \
actor.o \
callbacks.o \
inventory.o \
diff --git a/engines/teenagent/scene.cpp b/engines/teenagent/scene.cpp
index 3a76ea9da8..034475760b 100644
--- a/engines/teenagent/scene.cpp
+++ b/engines/teenagent/scene.cpp
@@ -442,7 +442,7 @@ void Scene::init(int id, const Common::Point &pos) {
sub_hack = 2;
}
}
- on.load(stream, Surface::kTypeOn, sub_hack);
+ on.load(stream, SurfaceList::kTypeOn, sub_hack);
delete stream;
loadOns();
@@ -649,9 +649,9 @@ bool Scene::render(OSystem *system) {
}
}
- if (on.pixels != NULL && on.y + on.h < actor_animation_position.bottom && debug_features.feature[DebugFeatures::kShowOn]) {
+ if (debug_features.feature[DebugFeatures::kShowOn]) {
if (_id != 16 || getOns(16)[0] != 0) {
- on.render(surface); //do not render boat on isle. I double checked all callbacks, there's no code switching off the boat :(
+ on.render(surface, actor_animation_position.bottom, false); //do not render boat on isle. I double checked all callbacks, there's no code switching off the boat :(
}
}
@@ -710,9 +710,9 @@ bool Scene::render(OSystem *system) {
}
//render on
- if (on.pixels != NULL && on.y + on.h >= actor_animation_position.bottom && debug_features.feature[DebugFeatures::kShowOn]) {
+ if (debug_features.feature[DebugFeatures::kShowOn]) {
if (_id != 16 || getOns(16)[0] != 0) {
- on.render(surface); //do not render boat on isle. I double checked all callbacks, there's no code switching off the boat :(
+ on.render(surface, actor_animation_position.bottom, true); //do not render boat on isle. I double checked all callbacks, there's no code switching off the boat :(
}
}
diff --git a/engines/teenagent/scene.h b/engines/teenagent/scene.h
index 72b33a1728..ab26d4a4e7 100644
--- a/engines/teenagent/scene.h
+++ b/engines/teenagent/scene.h
@@ -30,6 +30,8 @@
#include "common/system.h"
#include "common/list.h"
#include "teenagent/objects.h"
+#include "teenagent/surface.h"
+#include "teenagent/surface_list.h"
namespace TeenAgent {
@@ -176,7 +178,7 @@ private:
int _id;
Graphics::Surface background;
- Surface on;
+ SurfaceList on;
Surface *ons;
uint32 ons_count;
Animation actor_animation, animation[4], custom_animation[4];
diff --git a/engines/teenagent/surface.cpp b/engines/teenagent/surface.cpp
index 19c642896b..83715cbb07 100644
--- a/engines/teenagent/surface.cpp
+++ b/engines/teenagent/surface.cpp
@@ -30,29 +30,13 @@
namespace TeenAgent {
Surface::Surface() : x(0), y(0) {
- memset(flags, 0, sizeof(flags));
}
-void Surface::load(Common::SeekableReadStream *stream, Type type, int sub_hack) {
+void Surface::load(Common::SeekableReadStream *stream, Type type) {
//debug(0, "load()");
free();
x = y = 0;
- memset(flags, 0, sizeof(flags));
-
- if (type == kTypeOn) {
- byte fn = stream->readByte();
- if (stream->eos())
- return;
-
- byte i;
- for (i = 0; i < fn - sub_hack; ++i) {
- flags[i] = stream->readUint16LE();
- debug(0, "flags[%u] = %u (0x%04x)", i, flags[i], flags[i]);
- }
- for(; i < fn; ++i)
- debug(0, "*hack* skipping flag %04x", stream->readUint16LE());
- }
uint16 w_ = stream->readUint16LE();
uint16 h_ = stream->readUint16LE();
@@ -78,7 +62,7 @@ void Surface::load(Common::SeekableReadStream *stream, Type type, int sub_hack)
stream->read(pixels, w_ * h_);
}
-Common::Rect Surface::render(Graphics::Surface *surface, int dx, int dy, bool mirror, Common::Rect src_rect) {
+Common::Rect Surface::render(Graphics::Surface *surface, int dx, int dy, bool mirror, Common::Rect src_rect) const {
if (src_rect.isEmpty()) {
src_rect = Common::Rect(0, 0, w, h);
} else if (src_rect.right > w)
diff --git a/engines/teenagent/surface.h b/engines/teenagent/surface.h
index 732e39073d..d740fc4007 100644
--- a/engines/teenagent/surface.h
+++ b/engines/teenagent/surface.h
@@ -22,8 +22,8 @@
* $Id$
*/
-#ifndef TAGET_SURFACE_H
-#define TAGET_SURFACE_H
+#ifndef TEENAGENT_SURFACE_H
+#define TEENAGENT_SURFACE_H
#include "graphics/surface.h"
#include "common/stream.h"
@@ -33,14 +33,13 @@ namespace TeenAgent {
class Pack;
class Surface : public Graphics::Surface {
public:
- enum Type {kTypeOn, kTypeOns, kTypeLan};
+ enum Type {kTypeOns, kTypeLan};
- uint16 flags[255];
uint16 x, y;
Surface();
- void load(Common::SeekableReadStream *stream, Type type, int sub_hack = 0);
- Common::Rect render(Graphics::Surface *surface, int dx = 0, int dy = 0, bool mirror = false, Common::Rect src_rect = Common::Rect());
+ void load(Common::SeekableReadStream *stream, Type type);
+ Common::Rect render(Graphics::Surface *surface, int dx = 0, int dy = 0, bool mirror = false, Common::Rect src_rect = Common::Rect()) const;
bool empty() const { return pixels == NULL; }
};
diff --git a/engines/teenagent/surface_list.cpp b/engines/teenagent/surface_list.cpp
new file mode 100644
index 0000000000..2f426d14f8
--- /dev/null
+++ b/engines/teenagent/surface_list.cpp
@@ -0,0 +1,77 @@
+/* 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.
+ *
+ * $URL$
+ * $Id$
+ */
+
+#include "teenagent/surface.h"
+#include "teenagent/surface_list.h"
+
+namespace TeenAgent {
+
+SurfaceList::SurfaceList() : surfaces(NULL) {}
+
+void SurfaceList::load(Common::SeekableReadStream *stream, Type type, int sub_hack) {
+ free();
+
+ byte fn = stream->readByte();
+ if (stream->eos() || fn == 0)
+ return;
+
+ debug(0, "loading %u surfaces from list (skip %d)", fn, sub_hack);
+
+ surfaces_n = fn - sub_hack;
+ surfaces = new Surface[surfaces_n];
+
+ byte i;
+ for (i = 0; i < surfaces_n; ++i) {
+ uint offset = stream->readUint16LE();
+ uint pos = stream->pos();
+ stream->seek(offset);
+ surfaces[i].load(stream, Surface::kTypeOns);
+ stream->seek(pos);
+ }
+ //for(; i < fn; ++i)
+ // debug(0, "*hack* skipping flag %04x", stream->readUint16LE());
+}
+
+void SurfaceList::free() {
+ delete[] surfaces;
+ surfaces = NULL;
+ surfaces_n = 0;
+}
+
+Common::Rect SurfaceList::render(Graphics::Surface *surface, int horizont, bool second_pass) const {
+ Common::Rect dirty;
+ for(uint i = 0; i < surfaces_n; ++i) {
+ const Surface &s = surfaces[i];
+ if (second_pass) {
+ if (s.y + s.h >= horizont)
+ dirty.extend(s.render(surface));
+ } else {
+ if (s.y + s.h < horizont)
+ dirty.extend(s.render(surface));
+ }
+ }
+ return dirty;
+}
+
+}
diff --git a/engines/teenagent/surface_list.h b/engines/teenagent/surface_list.h
new file mode 100644
index 0000000000..089c3d3cab
--- /dev/null
+++ b/engines/teenagent/surface_list.h
@@ -0,0 +1,50 @@
+/* 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.
+ *
+ * $URL$
+ * $Id$
+ */
+
+#ifndef TEENAGENT_SURFACE_LIST_H__
+#define TEENAGENT_SURFACE_LIST_H__
+
+#include "common/stream.h"
+
+namespace TeenAgent {
+class Surface;
+
+class SurfaceList {
+public:
+ enum Type { kTypeOn };
+
+ SurfaceList();
+ void load(Common::SeekableReadStream *stream, Type type, int sub_hack = 0);
+ void free();
+ Common::Rect render(Graphics::Surface *surface, int horizont, bool second_pass) const;
+
+protected:
+ Surface * surfaces;
+ uint surfaces_n;
+};
+
+}
+
+#endif
+