aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVladimir Menshakov2009-11-15 10:49:57 +0000
committerVladimir Menshakov2009-11-15 10:49:57 +0000
commitcae613cb05b5537519e0e811adc4610d3aef0eda (patch)
tree8b04fccd486cd217773a602bd8aea0f06dfa45cf
parent73a8d06cf46cdddb8bef87ee8bb01d9a5bb5854b (diff)
downloadscummvm-rg350-cae613cb05b5537519e0e811adc4610d3aef0eda.tar.gz
scummvm-rg350-cae613cb05b5537519e0e811adc4610d3aef0eda.tar.bz2
scummvm-rg350-cae613cb05b5537519e0e811adc4610d3aef0eda.zip
implemented src_rect for surface blitting, added proper animation frames.
svn-id: r45915
-rw-r--r--engines/teenagent/actor.cpp48
-rw-r--r--engines/teenagent/scene.cpp2
-rw-r--r--engines/teenagent/surface.cpp21
-rw-r--r--engines/teenagent/surface.h2
4 files changed, 54 insertions, 19 deletions
diff --git a/engines/teenagent/actor.cpp b/engines/teenagent/actor.cpp
index eac02ca1e8..26b092339a 100644
--- a/engines/teenagent/actor.cpp
+++ b/engines/teenagent/actor.cpp
@@ -36,9 +36,31 @@ Common::Rect Actor::render(Graphics::Surface *surface, const Common::Point &posi
const uint8 frames_up[] = {18, 19, 20, 21, 22, 23, 24, 25, };
const uint8 frames_down[] = {10, 11, 12, 13, 14, 15, 16, 17, };
- const uint8 frames_head_left_right[] = {39, 26, 27, 28, 29, 30, 31, };
- const uint8 frames_head_up[] = { 41, 37, 38, };
- const uint8 frames_head_down[] = {40, 32, 33, 34, 35, 36};
+ const uint8 frames_head_left_right[] = {
+ 0x27, 0x1a, 0x1b,
+ 0x27, 0x1c, 0x1d,
+ 0x27, 0x1a,
+ 0x27, 0x1e, 0x1f,
+ 0x27, 0x1a, 0x1b,
+ 0x27, 0x1c,
+ 0x27, 0x1e,
+ 0x27, 0x1a,
+ };
+
+ const uint8 frames_head_up[] = {
+ 0x29, 0x25, 0x29, 0x29,
+ 0x26, 0x29, 0x26, 0x29,
+ 0x29, 0x25, 0x29, 0x25,
+ 0x29, 0x29, 0x29, 0x25,
+ 0x25, 0x29, 0x29, 0x26
+ };
+ const uint8 frames_head_down[] = {
+ 0x20, 0x21, 0x22, 0x23,
+ 0x28, 0x24, 0x28, 0x28,
+ 0x24, 0x28, 0x20, 0x21,
+ 0x20, 0x23, 0x28, 0x20,
+ 0x28, 0x28, 0x20, 0x28
+ };
Surface *s = NULL, *head = NULL;
@@ -94,6 +116,15 @@ Common::Rect Actor::render(Graphics::Surface *surface, const Common::Point &posi
return Common::Rect();
}
index += delta_frame;
+ if (s == NULL) {
+ warning("no surface, skipping");
+ return Common::Rect();
+ }
+
+ Common::Rect dirty;
+ Common::Rect clip(0, 0, s->w, s->h);
+ if (head != NULL)
+ clip.top = head->h;
int xp = position.x - dx, yp = position.y - dy;
if (xp < 0)
@@ -103,15 +134,12 @@ Common::Rect Actor::render(Graphics::Surface *surface, const Common::Point &posi
if (yp < 0)
yp = 0;
- if (yp + s->h > 200)
- yp = 200 - s->h;
-
- Common::Rect dirty;
+ if (yp + clip.top + clip.height() > 200)
+ yp = 200 - clip.top - clip.height();
- if (s)
- dirty = s->render(surface, xp, yp, orientation == Object::kActorLeft);
+ dirty = s->render(surface, xp, yp + clip.top, orientation == Object::kActorLeft, clip);
- if (head)
+ if (head != NULL)
dirty.extend(head->render(surface, xp, yp, orientation == Object::kActorLeft));
return dirty;
diff --git a/engines/teenagent/scene.cpp b/engines/teenagent/scene.cpp
index 0da2b5014f..2f7c8efb82 100644
--- a/engines/teenagent/scene.cpp
+++ b/engines/teenagent/scene.cpp
@@ -668,7 +668,7 @@ bool Scene::render(OSystem *system) {
} else
busy = true;
} else
- actor_animation_position = teenagent.render(surface, position, orientation, 0, false);
+ actor_animation_position = teenagent.render(surface, position, orientation, 0, true);
}
}
diff --git a/engines/teenagent/surface.cpp b/engines/teenagent/surface.cpp
index 47e1db300c..7896d040f3 100644
--- a/engines/teenagent/surface.cpp
+++ b/engines/teenagent/surface.cpp
@@ -75,15 +75,22 @@ void Surface::load(Common::SeekableReadStream *stream, Type type) {
stream->read(pixels, w_ * h_);
}
-Common::Rect Surface::render(Graphics::Surface *surface, int dx, int dy, bool mirror) {
- assert(x + dx + w <= surface->w);
- assert(y + dy + h <= surface->h);
-
- byte *src = (byte *)pixels;
+Common::Rect Surface::render(Graphics::Surface *surface, int dx, int dy, bool mirror, Common::Rect src_rect) {
+ if (src_rect.isEmpty()) {
+ src_rect = Common::Rect(0, 0, w, h);
+ } else if (src_rect.right > w)
+ src_rect.right = w;
+ else if (src_rect.bottom < h)
+ src_rect.bottom = h;
+
+ assert(x + dx + src_rect.width() <= surface->w);
+ assert(y + dy + src_rect.height() <= surface->h);
+
+ byte *src = (byte *)getBasePtr(src_rect.left, src_rect.top);
byte *dst = (byte *)surface->getBasePtr(dx + x, dy + y);
- for (int i = 0; i < h; ++i) {
- for (int j = 0; j < w; ++j) {
+ for (int i = src_rect.top; i < src_rect.bottom; ++i) {
+ for (int j = src_rect.left; j < src_rect.right; ++j) {
byte p = src[j];
if (p != 0xff)
dst[mirror? w - j - 1: j] = p;
diff --git a/engines/teenagent/surface.h b/engines/teenagent/surface.h
index 15c6d7eaa2..e18c101fc8 100644
--- a/engines/teenagent/surface.h
+++ b/engines/teenagent/surface.h
@@ -40,7 +40,7 @@ public:
Surface();
void load(Common::SeekableReadStream *stream, Type type);
- Common::Rect render(Graphics::Surface *surface, int dx = 0, int dy = 0, bool mirror = false);
+ Common::Rect render(Graphics::Surface *surface, int dx = 0, int dy = 0, bool mirror = false, Common::Rect src_rect = Common::Rect());
bool empty() const { return pixels == NULL; }
};