From 62c4c0922556a0ac95a60b760d2c49d3f186f85f Mon Sep 17 00:00:00 2001 From: D G Turner Date: Sat, 7 Jul 2012 17:04:42 +0100 Subject: TEENAGENT: Enable commented out debug statements. Commented out code is not good practice. Will change these statements to using debugflags instead in a future commit. --- engines/teenagent/surface.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'engines/teenagent/surface.cpp') diff --git a/engines/teenagent/surface.cpp b/engines/teenagent/surface.cpp index 63312990ee..45049ab076 100644 --- a/engines/teenagent/surface.cpp +++ b/engines/teenagent/surface.cpp @@ -34,7 +34,7 @@ Surface::~Surface() { } void Surface::load(Common::SeekableReadStream &stream, Type type) { - //debug(0, "load()"); + debug(0, "load()"); free(); x = y = 0; @@ -48,7 +48,7 @@ void Surface::load(Common::SeekableReadStream &stream, Type type) { y = pos / 320; } - //debug(0, "declared info: %ux%u (%04xx%04x) -> %u,%u", w_, h_, w_, h_, x, y); + debug(0, "declared info: %ux%u (%04xx%04x) -> %u,%u", w_, h_, w_, h_, x, y); if (stream.eos() || w_ == 0) return; @@ -57,7 +57,7 @@ void Surface::load(Common::SeekableReadStream &stream, Type type) { return; } - //debug(0, "creating surface %ux%u -> %u,%u", w_, h_, x, y); + debug(0, "creating surface %ux%u -> %u,%u", w_, h_, x, y); create(w_, h_, Graphics::PixelFormat::createFormatCLUT8()); stream.read(pixels, w_ * h_); -- cgit v1.2.3 From 0e6ba29ede4d5d226e1d81ac5c3174dcab7a48f1 Mon Sep 17 00:00:00 2001 From: D G Turner Date: Sun, 8 Jul 2012 00:36:05 +0100 Subject: TEENAGENT: Migrate engine to using debugflags. This required some restructuring of the header dependencies. --- engines/teenagent/surface.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'engines/teenagent/surface.cpp') diff --git a/engines/teenagent/surface.cpp b/engines/teenagent/surface.cpp index 45049ab076..fa67f28096 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; @@ -48,16 +50,16 @@ void Surface::load(Common::SeekableReadStream &stream, Type type) { y = pos / 320; } - 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_); -- cgit v1.2.3 From be4be025b97f0dc58f90dff749002400579e75e9 Mon Sep 17 00:00:00 2001 From: D G Turner Date: Sat, 28 Jul 2012 07:31:41 +0100 Subject: TEENAGENT: Add constant values for screen width and height. It is unlikely these will be changed, but the symbols make the code more readable. --- engines/teenagent/surface.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'engines/teenagent/surface.cpp') diff --git a/engines/teenagent/surface.cpp b/engines/teenagent/surface.cpp index fa67f28096..7cb1da30f5 100644 --- a/engines/teenagent/surface.cpp +++ b/engines/teenagent/surface.cpp @@ -46,8 +46,8 @@ void Surface::load(Common::SeekableReadStream &stream, Type type) { if (type != kTypeLan) { uint16 pos = stream.readUint16LE(); - x = pos % 320; - y = pos / 320; + x = pos % screenWidth; + y = pos / screenWidth; } debugC(0, kDebugSurface, "declared info: %ux%u (%04xx%04x) -> %u,%u", w_, h_, w_, h_, x, y); -- cgit v1.2.3 From 5d1143a9e0cf8014f9894f514fb641ff7d92a01b Mon Sep 17 00:00:00 2001 From: D G Turner Date: Mon, 24 Sep 2012 16:10:06 +0100 Subject: TEENAGENT: Cleanup Surface class. This removes the underscores in various variables as per project coding standard. --- engines/teenagent/surface.cpp | 56 +++++++++++++++++++++---------------------- 1 file changed, 28 insertions(+), 28 deletions(-) (limited to 'engines/teenagent/surface.cpp') 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 -- cgit v1.2.3 From c92ff8db3385e1586c9758fce2343e213a49b5df Mon Sep 17 00:00:00 2001 From: D G Turner Date: Tue, 9 Oct 2012 09:14:44 +0100 Subject: TEENAGENT: Fix constant naming to comply with Coding Conventions. Adding missing CamelCase k-prefixes. --- engines/teenagent/surface.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'engines/teenagent/surface.cpp') diff --git a/engines/teenagent/surface.cpp b/engines/teenagent/surface.cpp index 6f6c028bbc..4db25bc749 100644 --- a/engines/teenagent/surface.cpp +++ b/engines/teenagent/surface.cpp @@ -46,8 +46,8 @@ void Surface::load(Common::SeekableReadStream &stream, Type type) { if (type != kTypeLan) { uint16 pos = stream.readUint16LE(); - x = pos % screenWidth; - y = pos / screenWidth; + x = pos % kScreenWidth; + y = pos / kScreenWidth; } debugC(0, kDebugSurface, "declared info: %ux%u (%04xx%04x) -> %u,%u", w_, h_, w_, h_, x, y); -- cgit v1.2.3