From d5cc42f1c233a45abb879818af503ec7b91c6f34 Mon Sep 17 00:00:00 2001 From: Walter van Niftrik Date: Thu, 3 Mar 2016 19:17:49 +0100 Subject: ADL: Make frame buffer linear --- engines/adl/hires1.cpp | 40 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 38 insertions(+), 2 deletions(-) (limited to 'engines/adl/hires1.cpp') diff --git a/engines/adl/hires1.cpp b/engines/adl/hires1.cpp index 54351911fc..04df01ecd4 100644 --- a/engines/adl/hires1.cpp +++ b/engines/adl/hires1.cpp @@ -216,10 +216,10 @@ void HiRes1Engine::drawPic(Common::ReadStream &stream, Common::Point pos) { y = 160; if (bNewLine) { - _display->drawPixel(x, y, 0x7f); + _display->putPixel(Common::Point(x, y), 0x7f); bNewLine = false; } else { - _display->drawLine(Common::Point(oldX, oldY), Common::Point(x, y), 0x7f); + drawLine(Common::Point(oldX, oldY), Common::Point(x, y), 0x7f); } oldX = x; @@ -455,6 +455,42 @@ uint HiRes1Engine::getEngineMessage(EngineMessage msg) { } } +void HiRes1Engine::drawLine(Common::Point p1, Common::Point p2, byte color) { + int16 deltaX = p2.x - p1.x; + byte dir = deltaX >> 8; + + if (deltaX < 0) + deltaX = -deltaX; + + int16 err = deltaX; + + int16 deltaY = p2.y - p1.y - 1; + dir >>= 1; + if (deltaY >= 0) { + deltaY = -deltaY - 2; + dir |= 0x80; + } + + int16 steps = deltaY - deltaX; + + err += deltaY + 1; + + while (1) { + _display->putPixel(p1, color); + + if (++steps == 0) + return; + + if (err < 0) { + p1.y += (dir & 0x80 ? 1 : -1); + err += deltaX; + } else { + p1.x += (dir & 0x40 ? -1 : 1); + err += deltaY + 1; + } + } +} + AdlEngine *HiRes1Engine__create(OSystem *syst, const AdlGameDescription *gd) { return new HiRes1Engine(syst, gd); } -- cgit v1.2.3