diff options
Diffstat (limited to 'engines/teenagent')
-rw-r--r-- | engines/teenagent/surface.cpp | 56 | ||||
-rw-r--r-- | engines/teenagent/surface.h | 11 |
2 files changed, 34 insertions, 33 deletions
diff --git a/engines/teenagent/surface.cpp b/engines/teenagent/surface.cpp index 7cb1da30f5..6f6c028bbc 100644 --- a/engines/teenagent/surface.cpp +++ b/engines/teenagent/surface.cpp @@ -65,52 +65,52 @@ 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, Common::Rect src_rect, uint zoom) const { - if (src_rect.isEmpty()) { - src_rect = Common::Rect(0, 0, w, h); +Common::Rect Surface::render(Graphics::Surface *surface, int dx, int dy, bool mirror, Common::Rect srcRect, uint zoom) const { + if (srcRect.isEmpty()) { + srcRect = Common::Rect(0, 0, w, h); } - Common::Rect dst_rect(x + dx, y + dy, x + dx + zoom * src_rect.width() / 256, y + dy + zoom * src_rect.height() / 256); - if (dst_rect.left < 0) { - src_rect.left = -dst_rect.left; - dst_rect.left = 0; + Common::Rect dstRect(x + dx, y + dy, x + dx + zoom * srcRect.width() / 256, y + dy + zoom * srcRect.height() / 256); + if (dstRect.left < 0) { + srcRect.left = -dstRect.left; + dstRect.left = 0; } - if (dst_rect.right > surface->w) { - src_rect.right -= dst_rect.right - surface->w; - dst_rect.right = surface->w; + if (dstRect.right > surface->w) { + srcRect.right -= dstRect.right - surface->w; + dstRect.right = surface->w; } - if (dst_rect.top < 0) { - src_rect.top -= dst_rect.top; - dst_rect.top = 0; + if (dstRect.top < 0) { + srcRect.top -= dstRect.top; + dstRect.top = 0; } - if (dst_rect.bottom > surface->h) { - src_rect.bottom -= dst_rect.bottom - surface->h; - dst_rect.bottom = surface->h; + if (dstRect.bottom > surface->h) { + srcRect.bottom -= dstRect.bottom - surface->h; + dstRect.bottom = surface->h; } - if (src_rect.isEmpty() || dst_rect.isEmpty()) + if (srcRect.isEmpty() || dstRect.isEmpty()) return Common::Rect(); if (zoom == 256) { - const byte *src = (const byte *)getBasePtr(0, src_rect.top); - byte *dst_base = (byte *)surface->getBasePtr(dst_rect.left, dst_rect.top); + const byte *src = (const byte *)getBasePtr(0, srcRect.top); + byte *dstBase = (byte *)surface->getBasePtr(dstRect.left, dstRect.top); - for (int i = src_rect.top; i < src_rect.bottom; ++i) { - byte *dst = dst_base; - for (int j = src_rect.left; j < src_rect.right; ++j) { + for (int i = srcRect.top; i < srcRect.bottom; ++i) { + byte *dst = dstBase; + for (int j = srcRect.left; j < srcRect.right; ++j) { byte p = src[(mirror ? w - j - 1 : j)]; if (p != 0xff) *dst++ = p; else ++dst; } - dst_base += surface->pitch; + dstBase += surface->pitch; src += pitch; } } else { - byte *dst = (byte *)surface->getBasePtr(dst_rect.left, dst_rect.top); - for (int i = 0; i < dst_rect.height(); ++i) { - for (int j = 0; j < dst_rect.width(); ++j) { + byte *dst = (byte *)surface->getBasePtr(dstRect.left, dstRect.top); + for (int i = 0; i < dstRect.height(); ++i) { + for (int j = 0; j < dstRect.width(); ++j) { int px = j * 256 / zoom; - const byte *src = (const byte *)getBasePtr(src_rect.left + (mirror ? w - px - 1 : px), src_rect.top + i * 256 / zoom); + const byte *src = (const byte *)getBasePtr(srcRect.left + (mirror ? w - px - 1 : px), srcRect.top + i * 256 / zoom); byte p = *src; if (p != 0xff) dst[j] = p; @@ -118,7 +118,7 @@ Common::Rect Surface::render(Graphics::Surface *surface, int dx, int dy, bool mi dst += surface->pitch; } } - return dst_rect; + return dstRect; } } // End of namespace TeenAgent diff --git a/engines/teenagent/surface.h b/engines/teenagent/surface.h index 51368c6bee..3e591ed3e0 100644 --- a/engines/teenagent/surface.h +++ b/engines/teenagent/surface.h @@ -33,16 +33,17 @@ namespace TeenAgent { class Surface : public Graphics::Surface { public: - enum Type {kTypeOns, kTypeLan}; - - uint16 x, y; - Surface(); ~Surface(); + + enum Type {kTypeOns, kTypeLan}; + void load(Common::SeekableReadStream &, Type type); - Common::Rect render(Graphics::Surface *surface, int dx = 0, int dy = 0, bool mirror = false, Common::Rect src_rect = Common::Rect(), uint zoom = 256) const; + Common::Rect render(Graphics::Surface *surface, int dx = 0, int dy = 0, bool mirror = false, Common::Rect srcRect = Common::Rect(), uint zoom = 256) const; bool empty() const { return pixels == NULL; } + + uint16 x, y; }; } // End of namespace TeenAgent |