aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStrangerke2013-06-25 20:40:06 +0200
committerStrangerke2013-06-25 20:40:06 +0200
commit785db3b190f5449c83fa3c235d65835e49307778 (patch)
treef20371a5104642fc2f9c6e2b4490c19c7e37ffde
parent16c814ee6ee68b4359a1924c3086a3efb492b130 (diff)
downloadscummvm-rg350-785db3b190f5449c83fa3c235d65835e49307778.tar.gz
scummvm-rg350-785db3b190f5449c83fa3c235d65835e49307778.tar.bz2
scummvm-rg350-785db3b190f5449c83fa3c235d65835e49307778.zip
MORTEVIELLE: Replace g_vm in ScreenSurface
-rw-r--r--engines/mortevielle/debugger.cpp1
-rw-r--r--engines/mortevielle/graphics.cpp30
-rw-r--r--engines/mortevielle/graphics.h12
-rw-r--r--engines/mortevielle/mortevielle.cpp2
4 files changed, 29 insertions, 16 deletions
diff --git a/engines/mortevielle/debugger.cpp b/engines/mortevielle/debugger.cpp
index b0b9dc7d2c..9c24954f83 100644
--- a/engines/mortevielle/debugger.cpp
+++ b/engines/mortevielle/debugger.cpp
@@ -46,6 +46,7 @@ bool Debugger::Cmd_resetParano(int argc, const char **argv) {
return true;
}
+
void Debugger::setParent(MortevielleEngine *vm) {
_vm = vm;
}
diff --git a/engines/mortevielle/graphics.cpp b/engines/mortevielle/graphics.cpp
index 5bf3aedc99..39a38c2580 100644
--- a/engines/mortevielle/graphics.cpp
+++ b/engines/mortevielle/graphics.cpp
@@ -917,7 +917,7 @@ void ScreenSurface::drawPicture(GfxSurface &surface, int x, int y) {
(x + surface.w) * 2, (y + surface.h) * 2));
// Get a lookup for the palette mapping
- const byte *paletteMap = &g_vm->_mem[0x7000 * 16 + 2];
+ const byte *paletteMap = &_vm->_mem[0x7000 * 16 + 2];
// Loop through writing
for (int yp = 0; yp < surface.h; ++yp) {
@@ -996,7 +996,7 @@ void ScreenSurface::writeCharacter(const Common::Point &pt, unsigned char ch, in
* simulate the original 640x400 surface, all Y values have to be doubled
*/
void ScreenSurface::drawBox(int x, int y, int dx, int dy, int col) {
- if (g_vm->_resolutionScaler == 1) {
+ if (_vm->_resolutionScaler == 1) {
x = (uint)x >> 1;
dx = (uint)dx >> 1;
}
@@ -1060,10 +1060,10 @@ void ScreenSurface::drawString(const Common::String &l, int command) {
if (l == "")
return;
- g_vm->_mouse.hideMouse();
+ _vm->_mouse.hideMouse();
pt = _textPos;
- if (g_vm->_resolutionScaler == 2)
+ if (_vm->_resolutionScaler == 2)
i = 6;
else
i = 10;
@@ -1073,7 +1073,7 @@ void ScreenSurface::drawString(const Common::String &l, int command) {
case 1:
case 3: {
cecr = 0;
- g_vm->_screenSurface.fillRect(15, Common::Rect(pt.x, pt.y, x, pt.y + 7));
+ _vm->_screenSurface.fillRect(15, Common::Rect(pt.x, pt.y, x, pt.y + 7));
}
break;
case 4:
@@ -1085,7 +1085,7 @@ void ScreenSurface::drawString(const Common::String &l, int command) {
case 0:
case 2: {
cecr = 15;
- g_vm->_screenSurface.fillRect(0, Common::Rect(pt.x, pt.y, x, pt.y + 7));
+ _vm->_screenSurface.fillRect(0, Common::Rect(pt.x, pt.y, x, pt.y + 7));
}
break;
default:
@@ -1095,17 +1095,17 @@ void ScreenSurface::drawString(const Common::String &l, int command) {
pt.x += 1;
pt.y += 1;
for (x = 1; (x <= (int)l.size()) && (l[x - 1] != 0); ++x) {
- g_vm->_screenSurface.writeCharacter(Common::Point(pt.x, pt.y), ord(l[x - 1]), cecr);
+ _vm->_screenSurface.writeCharacter(Common::Point(pt.x, pt.y), ord(l[x - 1]), cecr);
pt.x += i;
}
- g_vm->_mouse.showMouse();
+ _vm->_mouse.showMouse();
}
/**
* Gets the width in pixels of the specified string
*/
int ScreenSurface::getStringWidth(const Common::String &s) {
- int charWidth = (g_vm->_resolutionScaler == 2) ? 6 : 10;
+ int charWidth = (_vm->_resolutionScaler == 2) ? 6 : 10;
return s.size() * charWidth;
}
@@ -1129,7 +1129,7 @@ void ScreenSurface::drawLine(int x, int y, int xx, int yy, int coul) {
else
step = 1;
do {
- g_vm->_screenSurface.setPixel(Common::Point(abs((int)(a * i + b)), i), coul);
+ _vm->_screenSurface.setPixel(Common::Point(abs((int)(a * i + b)), i), coul);
i += step;
} while (i != yy);
} else {
@@ -1141,7 +1141,7 @@ void ScreenSurface::drawLine(int x, int y, int xx, int yy, int coul) {
else
step = 1;
do {
- g_vm->_screenSurface.setPixel(Common::Point(i, abs((int)(a * i + b))), coul);
+ _vm->_screenSurface.setPixel(Common::Point(i, abs((int)(a * i + b))), coul);
i = i + step;
} while (i != xx);
}
@@ -1154,11 +1154,15 @@ void ScreenSurface::drawLine(int x, int y, int xx, int yy, int coul) {
void ScreenSurface::drawRectangle(int x, int y, int dx, int dy) {
int co;
- if (g_vm->_currGraphicalDevice == MODE_CGA)
+ if (_vm->_currGraphicalDevice == MODE_CGA)
co = 3;
else
co = 11;
- g_vm->_screenSurface.fillRect(co, Common::Rect(x, y, x + dx, y + dy));
+ _vm->_screenSurface.fillRect(co, Common::Rect(x, y, x + dx, y + dy));
+}
+
+void ScreenSurface::setParent(MortevielleEngine *vm) {
+ _vm = vm;
}
diff --git a/engines/mortevielle/graphics.h b/engines/mortevielle/graphics.h
index 7bf39c3662..026950e127 100644
--- a/engines/mortevielle/graphics.h
+++ b/engines/mortevielle/graphics.h
@@ -34,10 +34,13 @@
#include "graphics/surface.h"
namespace Mortevielle {
+class MortevielleEngine;
class PaletteManager {
-public:
+private:
void setPalette(const int *palette, uint idx, uint size);
+
+public:
void setDefaultPalette();
};
@@ -74,7 +77,7 @@ public:
Common::Point _offset;
// Transparency palette index
int _transparency;
-public:
+
~GfxSurface();
void decode(const byte *pSrc);
@@ -82,11 +85,13 @@ public:
class ScreenSurface: public Graphics::Surface {
private:
+ MortevielleEngine *_vm;
+
Common::List<Common::Rect> _dirtyRects;
byte _fontData[FONT_NUM_CHARS * FONT_HEIGHT];
+
public:
Common::Point _textPos; // Original called xwhere/ywhere
-public:
void readFontData(Common::File &f, int dataSize);
Graphics::Surface lockArea(const Common::Rect &bounds);
void updateScreen();
@@ -101,6 +106,7 @@ public:
int getStringWidth(const Common::String &s);
void drawLine(int x, int y, int xx, int yy, int coul);
void drawRectangle(int x, int y, int dx, int dy);
+ void setParent(MortevielleEngine *vm);
// TODO: Refactor code to remove this method, for increased performance
void setPixel(const Common::Point &pt, int palIndex);
diff --git a/engines/mortevielle/mortevielle.cpp b/engines/mortevielle/mortevielle.cpp
index 86e7a12371..b651f43d74 100644
--- a/engines/mortevielle/mortevielle.cpp
+++ b/engines/mortevielle/mortevielle.cpp
@@ -75,6 +75,8 @@ MortevielleEngine::MortevielleEngine(OSystem *system, const ADGameDescription *g
_soundManager(_mixer) {
g_vm = this;
_debugger.setParent(this);
+ _screenSurface.setParent(this);
+
_lastGameFrame = 0;
_mouseClick = false;
_inMainGameLoop = false;