aboutsummaryrefslogtreecommitdiff
path: root/engines/adl
diff options
context:
space:
mode:
authorWalter van Niftrik2016-03-05 22:10:54 +0100
committerWalter van Niftrik2016-03-09 10:03:13 +0100
commitf62c56e38475ccab0c94db949a14991e5423fc13 (patch)
tree3397a0a19dccaf33686ad5950234a370a5770f88 /engines/adl
parent6379fbc124b63221576206bed070fa2a91b99718 (diff)
downloadscummvm-rg350-f62c56e38475ccab0c94db949a14991e5423fc13.tar.gz
scummvm-rg350-f62c56e38475ccab0c94db949a14991e5423fc13.tar.bz2
scummvm-rg350-f62c56e38475ccab0c94db949a14991e5423fc13.zip
ADL: Clean up line drawing
Diffstat (limited to 'engines/adl')
-rw-r--r--engines/adl/hires1.cpp48
-rw-r--r--engines/adl/hires1.h4
2 files changed, 22 insertions, 30 deletions
diff --git a/engines/adl/hires1.cpp b/engines/adl/hires1.cpp
index d3e4c3ef52..1345489315 100644
--- a/engines/adl/hires1.cpp
+++ b/engines/adl/hires1.cpp
@@ -20,20 +20,11 @@
*
*/
-#include "common/scummsys.h"
-
-#include "common/config-manager.h"
+#include "common/system.h"
#include "common/debug.h"
-#include "common/debug-channels.h"
#include "common/error.h"
#include "common/file.h"
-#include "common/fs.h"
-#include "common/system.h"
-#include "common/events.h"
#include "common/stream.h"
-#include "graphics/palette.h"
-
-#include "engines/util.h"
#include "adl/hires1.h"
#include "adl/display.h"
@@ -208,7 +199,7 @@ void HiRes1Engine::runIntro() {
delay(2000);
}
-void HiRes1Engine::drawPic(Common::ReadStream &stream, Common::Point pos) {
+void HiRes1Engine::drawPic(Common::ReadStream &stream, const Common::Point &pos) {
byte x, y;
bool bNewLine = false;
byte oldX = 0, oldY = 0;
@@ -473,38 +464,39 @@ uint HiRes1Engine::getEngineMessage(EngineMessage msg) {
}
}
-void HiRes1Engine::drawLine(Common::Point p1, Common::Point p2, byte color) {
+void HiRes1Engine::drawLine(const Common::Point &p1, const Common::Point &p2, byte color) {
int16 deltaX = p2.x - p1.x;
- byte dir = deltaX >> 8;
+ int8 xStep = 1;
- if (deltaX < 0)
+ if (deltaX < 0) {
deltaX = -deltaX;
+ xStep = -1;
+ }
- int16 err = deltaX;
+ int16 deltaY = p2.y - p1.y;
+ int8 yStep = -1;
- int16 deltaY = p2.y - p1.y - 1;
- dir >>= 1;
- if (deltaY >= 0) {
- deltaY = -deltaY - 2;
- dir |= 0x80;
+ if (deltaY > 0) {
+ deltaY = -deltaY;
+ yStep = 1;
}
- int16 steps = deltaY - deltaX;
-
- err += deltaY + 1;
+ Common::Point p(p1);
+ int16 steps = deltaX - deltaY + 1;
+ int16 err = deltaX + deltaY;
while (1) {
- _display->putPixel(p1, color);
+ _display->putPixel(p, color);
- if (++steps == 0)
+ if (--steps == 0)
return;
if (err < 0) {
- p1.y += (dir & 0x80 ? 1 : -1);
+ p.y += yStep;
err += deltaX;
} else {
- p1.x += (dir & 0x40 ? -1 : 1);
- err += deltaY + 1;
+ p.x += xStep;
+ err += deltaY;
}
}
}
diff --git a/engines/adl/hires1.h b/engines/adl/hires1.h
index f5c6d5b3e4..12c3c9461f 100644
--- a/engines/adl/hires1.h
+++ b/engines/adl/hires1.h
@@ -45,9 +45,9 @@ private:
void initState();
void runIntro();
- void drawPic(Common::ReadStream &stream, Common::Point pos);
+ void drawPic(Common::ReadStream &stream, const Common::Point &pos);
void drawItems();
- void drawLine(Common::Point p1, Common::Point p2, byte color);
+ void drawLine(const Common::Point &p1, const Common::Point &p2, byte color);
void drawPic(byte pic, Common::Point pos);
};