aboutsummaryrefslogtreecommitdiff
path: root/engines/teenagent/surface.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'engines/teenagent/surface.cpp')
-rw-r--r--engines/teenagent/surface.cpp70
1 files changed, 36 insertions, 34 deletions
diff --git a/engines/teenagent/surface.cpp b/engines/teenagent/surface.cpp
index 63312990ee..4db25bc749 100644
--- a/engines/teenagent/surface.cpp
+++ b/engines/teenagent/surface.cpp
@@ -21,6 +21,8 @@
#include "teenagent/surface.h"
#include "teenagent/pack.h"
+#include "teenagent/teenagent.h"
+
#include "common/stream.h"
#include "common/debug.h"
@@ -34,7 +36,7 @@ Surface::~Surface() {
}
void Surface::load(Common::SeekableReadStream &stream, Type type) {
- //debug(0, "load()");
+ debugC(0, kDebugSurface, "load()");
free();
x = y = 0;
@@ -44,71 +46,71 @@ void Surface::load(Common::SeekableReadStream &stream, Type type) {
if (type != kTypeLan) {
uint16 pos = stream.readUint16LE();
- x = pos % 320;
- y = pos / 320;
+ x = pos % kScreenWidth;
+ y = pos / kScreenWidth;
}
- //debug(0, "declared info: %ux%u (%04xx%04x) -> %u,%u", w_, h_, w_, h_, x, y);
+ debugC(0, kDebugSurface, "declared info: %ux%u (%04xx%04x) -> %u,%u", w_, h_, w_, h_, x, y);
if (stream.eos() || w_ == 0)
return;
if (w_ * h_ > stream.size()) {
- debug(0, "invalid surface %ux%u -> %u,%u", w_, h_, x, y);
+ debugC(0, kDebugSurface, "invalid surface %ux%u -> %u,%u", w_, h_, x, y);
return;
}
- //debug(0, "creating surface %ux%u -> %u,%u", w_, h_, x, y);
+ debugC(0, kDebugSurface, "creating surface %ux%u -> %u,%u", w_, h_, x, y);
create(w_, h_, Graphics::PixelFormat::createFormatCLUT8());
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;
@@ -116,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