Skip to content

Commit

Permalink
MORTEVIELLE: Moved DROITE() into the ScreenSurface class
Browse files Browse the repository at this point in the history
  • Loading branch information
dreammaster authored and Strangerke committed Apr 6, 2012
1 parent 0992a95 commit 0a497bd
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 109 deletions.
68 changes: 0 additions & 68 deletions engines/mortevielle/droite.cpp

This file was deleted.

36 changes: 0 additions & 36 deletions engines/mortevielle/droite.h

This file was deleted.

33 changes: 33 additions & 0 deletions engines/mortevielle/graphics.cpp
Expand Up @@ -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
1 change: 1 addition & 0 deletions engines/mortevielle/graphics.h
Expand Up @@ -92,6 +92,7 @@ class ScreenSurface: public Graphics::Surface {
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);
Expand Down
1 change: 0 additions & 1 deletion engines/mortevielle/module.mk
Expand Up @@ -5,7 +5,6 @@ MODULE_OBJS := \
alert.o \
asm.o \
detection.o \
droite.o \
graphics.o \
keyboard.o \
level15.o \
Expand Down
10 changes: 6 additions & 4 deletions engines/mortevielle/mor.cpp
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 0a497bd

Please sign in to comment.