From 2fb94dfa01e7673358aef3ef67022f29e74c1b3b Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 12 Feb 2012 23:05:08 +1100 Subject: MORTEVIELLE: Moved DROITE() into the ScreenSurface class --- engines/mortevielle/droite.cpp | 68 ---------------------------------------- engines/mortevielle/droite.h | 36 --------------------- engines/mortevielle/graphics.cpp | 33 +++++++++++++++++++ engines/mortevielle/graphics.h | 1 + engines/mortevielle/module.mk | 1 - engines/mortevielle/mor.cpp | 10 +++--- 6 files changed, 40 insertions(+), 109 deletions(-) delete mode 100644 engines/mortevielle/droite.cpp delete mode 100644 engines/mortevielle/droite.h diff --git a/engines/mortevielle/droite.cpp b/engines/mortevielle/droite.cpp deleted file mode 100644 index fc52ff7bd3..0000000000 --- a/engines/mortevielle/droite.cpp +++ /dev/null @@ -1,68 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This code is based on original Mortville Manor DOS source code - * Copyright (c) 1988-1989 Lankhor - */ - -#include "mortevielle/droite.h" -#include "mortevielle/graphics.h" -#include "mortevielle/mortevielle.h" -#include "mortevielle/var_mor.h" - -namespace Mortevielle { - -void droite(int x, int y, int xx, int yy, int coul) { - int step, i; - float a, b; - float xr, yr, xro, yro; - - xr = x; - yr = y; - xro = xx; - yro = yy; - - if (abs(y - yy) > abs(x - xx)) { - a = (float)((x - xx)) / (y - yy); - b = (yr * xro - yro * xr) / (y - yy); - i = y; - if (y > yy) step = -1; - else step = 1; - do { - g_vm->_screenSurface.setPixel(Common::Point(abs((int)(a * i + b)), i), coul); - i = i + step; - } while (!(i == yy)); - } else { - a = (float)((y - yy)) / (x - xx); - b = ((yro * xr) - (yr * xro)) / (x - xx); - i = x; - if (x > xx) step = -1; - else step = 1; - do { - g_vm->_screenSurface.setPixel(Common::Point(i, abs((int)(a * i + b))), coul); - i = i + step; - } while (!(i == xx)); - } -} - -} // End of namespace Mortevielle diff --git a/engines/mortevielle/droite.h b/engines/mortevielle/droite.h deleted file mode 100644 index 6017f481cd..0000000000 --- a/engines/mortevielle/droite.h +++ /dev/null @@ -1,36 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This code is based on original Mortville Manor DOS source code - * Copyright (c) 1988-1989 Lankhor - */ - -#ifndef MORTEVIELLE_DROITE_H -#define MORTEVIELLE_DROITE_H - -namespace Mortevielle { - -extern void droite(int x, int y, int xx, int yy, int coul); - -} // End of namespace Mortevielle -#endif diff --git a/engines/mortevielle/graphics.cpp b/engines/mortevielle/graphics.cpp index bdf6c86daa..0fab9de965 100644 --- a/engines/mortevielle/graphics.cpp +++ b/engines/mortevielle/graphics.cpp @@ -1097,4 +1097,37 @@ int ScreenSurface::getStringWidth(const Common::String &s) { return s.size() * charWidth; } +void ScreenSurface::droite(int x, int y, int xx, int yy, int coul) { + int step, i; + float a, b; + float xr, yr, xro, yro; + + xr = x; + yr = y; + xro = xx; + yro = yy; + + if (abs(y - yy) > abs(x - xx)) { + a = (float)((x - xx)) / (y - yy); + b = (yr * xro - yro * xr) / (y - yy); + i = y; + if (y > yy) step = -1; + else step = 1; + do { + g_vm->_screenSurface.setPixel(Common::Point(abs((int)(a * i + b)), i), coul); + i = i + step; + } while (!(i == yy)); + } else { + a = (float)((y - yy)) / (x - xx); + b = ((yro * xr) - (yr * xro)) / (x - xx); + i = x; + if (x > xx) step = -1; + else step = 1; + do { + g_vm->_screenSurface.setPixel(Common::Point(i, abs((int)(a * i + b))), coul); + i = i + step; + } while (!(i == xx)); + } +} + } // End of namespace Mortevielle diff --git a/engines/mortevielle/graphics.h b/engines/mortevielle/graphics.h index 1daad5720b..1aab4cf34b 100644 --- a/engines/mortevielle/graphics.h +++ b/engines/mortevielle/graphics.h @@ -92,6 +92,7 @@ public: void putxy(int x, int y) { _textPos = Common::Point(x, y); } void writeg(const Common::String &l, int c); int getStringWidth(const Common::String &s); + void droite(int x, int y, int xx, int yy, int coul); // TODO: Refactor code to remove this method, for increased performance void setPixel(const Common::Point &pt, int palIndex); diff --git a/engines/mortevielle/module.mk b/engines/mortevielle/module.mk index 0688fd5ac0..67ca57dbb4 100644 --- a/engines/mortevielle/module.mk +++ b/engines/mortevielle/module.mk @@ -5,7 +5,6 @@ MODULE_OBJS := \ alert.o \ asm.o \ detection.o \ - droite.o \ graphics.o \ keyboard.o \ level15.o \ diff --git a/engines/mortevielle/mor.cpp b/engines/mortevielle/mor.cpp index 05fe6c2a8c..895e18362d 100644 --- a/engines/mortevielle/mor.cpp +++ b/engines/mortevielle/mor.cpp @@ -30,7 +30,7 @@ #include "common/system.h" #include "common/textconsole.h" #include "mortevielle/alert.h" -#include "mortevielle/droite.h" +#include "mortevielle/graphics.h" #include "mortevielle/level15.h" #include "mortevielle/menu.h" #include "mortevielle/mor.h" @@ -616,12 +616,14 @@ void pendule() { if ((gd == cga) || (gd == her)) co = 0; else co = 1; - if (min == 0) droite(((uint)x >> 1)*res, y, ((uint)x >> 1)*res, (y - rg), co); - else droite(((uint)x >> 1)*res, y, ((uint)x >> 1)*res, (y + rg), co); + if (min == 0) + g_vm->_screenSurface.droite(((uint)x >> 1)*res, y, ((uint)x >> 1)*res, (y - rg), co); + else + g_vm->_screenSurface.droite(((uint)x >> 1)*res, y, ((uint)x >> 1)*res, (y + rg), co); h = heu; if (h > 12) h = h - 12; if (h == 0) h = 12; - droite(((uint)x >> 1)*res, y, ((uint)(x + cv[1][h]) >> 1)*res, y + cv[2][h], co); + g_vm->_screenSurface.droite(((uint)x >> 1)*res, y, ((uint)(x + cv[1][h]) >> 1)*res, y + cv[2][h], co); show_mouse(); g_vm->_screenSurface.putxy(568, 154); if (heu > 11) -- cgit v1.2.3