aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStrangerke2012-03-20 07:05:25 +0100
committerStrangerke2012-04-06 08:23:32 +0200
commit2df7ebf1609d033628423870fba2217c855e75f3 (patch)
treeef84845edd5ad109696aba209cfd1146f58da4e2
parent1c283507ee0dab8f960bdbe249f837a95c4b6e2b (diff)
downloadscummvm-rg350-2df7ebf1609d033628423870fba2217c855e75f3.tar.gz
scummvm-rg350-2df7ebf1609d033628423870fba2217c855e75f3.tar.bz2
scummvm-rg350-2df7ebf1609d033628423870fba2217c855e75f3.zip
MORTEVIELLE: Refactor mouse class
-rw-r--r--engines/mortevielle/dialogs.cpp24
-rw-r--r--engines/mortevielle/menu.cpp45
-rw-r--r--engines/mortevielle/menu.h3
-rw-r--r--engines/mortevielle/mor.cpp8
-rw-r--r--engines/mortevielle/mortevielle.cpp6
-rw-r--r--engines/mortevielle/mortevielle.h2
-rw-r--r--engines/mortevielle/mouse.cpp105
-rw-r--r--engines/mortevielle/mouse.h14
-rw-r--r--engines/mortevielle/ovd1.cpp1
-rw-r--r--engines/mortevielle/var_mor.cpp6
-rw-r--r--engines/mortevielle/var_mor.h7
11 files changed, 90 insertions, 131 deletions
diff --git a/engines/mortevielle/dialogs.cpp b/engines/mortevielle/dialogs.cpp
index f1faee0daa..68d2852100 100644
--- a/engines/mortevielle/dialogs.cpp
+++ b/engines/mortevielle/dialogs.cpp
@@ -45,7 +45,8 @@ int Alert::show(const Common::String &msg, int n) {
Common::String st, chaine;
int limit[3][3];
Common::String s[3];
- int cx, cy, nbcol, lignNumb;
+ Common::Point curPos;
+ int nbcol, lignNumb;
bool newaff, test, test1, test2, test3, dum;
Common::String cas;
@@ -70,17 +71,17 @@ int Alert::show(const Common::String &msg, int n) {
i = 0;
g_vm->_screenSurface._textPos.y = 70;
do {
- cx = 320;
+ curPos.x = 320;
st = "";
while ((chaine[i + 1] != '\174') && (chaine[i + 1] != '\135')) {
++i;
st = st + chaine[i];
if (g_res == 2)
- cx -= 3;
+ curPos.x -= 3;
else
- cx -= 5;
+ curPos.x -= 5;
}
- g_vm->_screenSurface.putxy(cx, g_vm->_screenSurface._textPos.y);
+ g_vm->_screenSurface.putxy(curPos.x, g_vm->_screenSurface._textPos.y);
g_vm->_screenSurface._textPos.y += 6;
g_vm->_screenSurface.drawString(st, 4);
++i;
@@ -108,15 +109,14 @@ int Alert::show(const Common::String &msg, int n) {
g_vm->_mouse.moveMouse(dum, dummyKey);
CHECK_QUIT0;
- cx = g_vm->_mouse.x_s;
- cy = g_vm->_mouse.y_s;
- test = (cy > 95) && (cy < 105);
+ curPos = g_vm->_mouse._pos;
+ test = (curPos.y > 95) && (curPos.y < 105);
newaff = false;
if (test) {
- test1 = (cx > limit[1][1]) && (cx < limit[1][2]);
+ test1 = (curPos.x > limit[1][1]) && (curPos.x < limit[1][2]);
test2 = test1;
if (caseNumb > 1)
- test2 = test1 || ((cx > limit[2][1]) && (cx < limit[2][2]));
+ test2 = test1 || ((curPos.x > limit[2][1]) && (curPos.x < limit[2][2]));
if (test2) {
newaff = true;
if (test1)
@@ -157,8 +157,8 @@ int Alert::show(const Common::String &msg, int n) {
quoi = 0;
g_vm->_mouse.showMouse();
}
- test3 = (cy > 95) && (cy < 105) && (((cx > limit[1][1]) && (cx < limit[1][2]))
- || ((cx > limit[2][1]) && (cx < limit[2][2])));
+ test3 = (curPos.y > 95) && (curPos.y < 105) && (((curPos.x > limit[1][1]) && (curPos.x < limit[1][2]))
+ || ((curPos.x > limit[2][1]) && (curPos.x < limit[2][2])));
} while (!g_vm->getMouseClick());
g_vm->setMouseClick(false);
g_vm->_mouse.hideMouse();
diff --git a/engines/mortevielle/menu.cpp b/engines/mortevielle/menu.cpp
index 3f5db6de9a..e4f3702a7b 100644
--- a/engines/mortevielle/menu.cpp
+++ b/engines/mortevielle/menu.cpp
@@ -270,7 +270,7 @@ void Menu::invers(int ix) {
g_msg4 = OPCODE_NONE;
}
-void Menu::util(int x, int y) {
+void Menu::util(Common::Point pos) {
int ymx = (g_menuConstants[g_msg3 - 1][3] << 3) + 16;
int dxcar = g_menuConstants[g_msg3 - 1][2];
@@ -282,8 +282,8 @@ void Menu::util(int x, int y) {
else
ix = 3;
int xmx = dxcar * ix * g_res + xmn + 2;
- if ((x > xmn) && (x < xmx) && (y < ymx) && (y > 15)) {
- ix = (((uint)y >> 3) - 1) + (g_msg3 << 8);
+ if ((pos.x > xmn) && (pos.x < xmx) && (pos.y < ymx) && (pos.y > 15)) {
+ ix = (((uint)pos.y >> 3) - 1) + (g_msg3 << 8);
if (ix != g_msg4) {
invers(1);
g_msg4 = ix;
@@ -417,35 +417,32 @@ void Menu::mdn() {
if (!_menuActive)
return;
- int x = g_vm->_mouse.x_s;
- int y = g_vm->_mouse.y_s;
+ Common::Point curPos = g_vm->_mouse._pos;
if (!g_vm->getMouseClick()) {
- if ((x == g_xprec) && (y == g_yprec))
+ if (curPos == g_vm->_prevPos)
return;
- else {
- g_xprec = x;
- g_yprec = y;
- }
+ else
+ g_vm->_prevPos = curPos;
- bool tes = (y < 11)
- && ((x >= (28 * g_res) && x <= (28 * g_res + 24))
- || (x >= (76 * g_res) && x <= (76 * g_res + 24))
- || ((x > 124 * g_res) && (x < 124 * g_res + 24))
- || ((x > 172 * g_res) && (x < 172 * g_res + 24))
- || ((x > 220 * g_res) && (x < 220 * g_res + 24))
- || ((x > 268 * g_res) && (x < 268 * g_res + 24)));
+ bool tes = (curPos.y < 11)
+ && ((curPos.x >= (28 * g_res) && curPos.x <= (28 * g_res + 24))
+ || (curPos.x >= (76 * g_res) && curPos.x <= (76 * g_res + 24))
+ || ((curPos.x > 124 * g_res) && (curPos.x < 124 * g_res + 24))
+ || ((curPos.x > 172 * g_res) && (curPos.x < 172 * g_res + 24))
+ || ((curPos.x > 220 * g_res) && (curPos.x < 220 * g_res + 24))
+ || ((curPos.x > 268 * g_res) && (curPos.x < 268 * g_res + 24)));
if (tes) {
int ix;
- if (x < 76 * g_res)
+ if (curPos.x < 76 * g_res)
ix = MENU_INVENTORY;
- else if (x < 124 * g_res)
+ else if (curPos.x < 124 * g_res)
ix = MENU_MOVE;
- else if (x < 172 * g_res)
+ else if (curPos.x < 172 * g_res)
ix = MENU_ACTION;
- else if (x < 220 * g_res)
+ else if (curPos.x < 220 * g_res)
ix = MENU_SELF;
- else if (x < 268 * g_res)
+ else if (curPos.x < 268 * g_res)
ix = MENU_DISCUSS;
else
ix = MENU_FILE;
@@ -458,8 +455,8 @@ void Menu::mdn() {
g_msg4 = OPCODE_NONE;
}
} else { // Not in the MenuTitle line
- if ((y > 11) && (_multiTitle))
- util(x, y);
+ if ((curPos.y > 11) && (_multiTitle))
+ util(curPos);
}
} else { // There was a click
if ((g_msg3 == MENU_FILE) && (g_msg4 != OPCODE_NONE)) {
diff --git a/engines/mortevielle/menu.h b/engines/mortevielle/menu.h
index adfe35981e..ccf5bd8954 100644
--- a/engines/mortevielle/menu.h
+++ b/engines/mortevielle/menu.h
@@ -28,13 +28,14 @@
#ifndef MORTEVIELLE_MENU_H
#define MORTEVIELLE_MENU_H
+#include "common/rect.h"
#include "common/str.h"
namespace Mortevielle {
class Menu {
private:
- void util(int x, int y);
+ void util(Common::Point pos);
void invers(int ix);
void menuDown(int ii);
public:
diff --git a/engines/mortevielle/mor.cpp b/engines/mortevielle/mor.cpp
index 439d9255e2..041841fcca 100644
--- a/engines/mortevielle/mor.cpp
+++ b/engines/mortevielle/mor.cpp
@@ -756,7 +756,7 @@ void tinke() {
g_vm->_minute = 30;
drawClock();
}
- if (g_vm->_mouse.y_s < 12)
+ if (g_vm->_mouse._pos.y < 12)
return;
if (!g_vm->_blo) {
@@ -1129,7 +1129,7 @@ void tfleche() {
CHECK_QUIT;
if (g_vm->getMouseClick())
- inRect = (g_vm->_mouse.x_s < 256 * g_res) && (g_vm->_mouse.y_s < 176) && (g_vm->_mouse.y_s > 12);
+ inRect = (g_vm->_mouse._pos.x < 256 * g_res) && (g_vm->_mouse._pos.y < 176) && (g_vm->_mouse._pos.y > 12);
tinke();
} while (!(qust || inRect || g_vm->_anyone));
@@ -1141,8 +1141,8 @@ void tfleche() {
g_vm->_keyPressedEsc = true;
if (inRect) {
- g_x = g_vm->_mouse.x_s;
- g_y = g_vm->_mouse.y_s;
+ g_x = g_vm->_mouse._pos.x;
+ g_y = g_vm->_mouse._pos.y;
}
}
diff --git a/engines/mortevielle/mortevielle.cpp b/engines/mortevielle/mortevielle.cpp
index f376e57d8d..4a8961f536 100644
--- a/engines/mortevielle/mortevielle.cpp
+++ b/engines/mortevielle/mortevielle.cpp
@@ -339,8 +339,8 @@ bool MortevielleEngine::handleEvents() {
case Common::EVENT_LBUTTONUP:
case Common::EVENT_MOUSEMOVE:
_mousePos = Common::Point(event.mouse.x, event.mouse.y / 2);
- g_vm->_mouse.x_s = event.mouse.x;
- g_vm->_mouse.y_s = event.mouse.y / 2;
+ g_vm->_mouse._pos.x = event.mouse.x;
+ g_vm->_mouse._pos.y = event.mouse.y / 2;
if (event.type == Common::EVENT_LBUTTONDOWN)
_mouseClick = true;
@@ -652,7 +652,7 @@ void MortevielleEngine::handleAction() {
g_mnumo = g_msg[4];
if (!_anyone) {
if ((_heroSearching) || (_obpart)) {
- if (g_vm->_mouse.y_s < 12)
+ if (g_vm->_mouse._pos.y < 12)
return;
if ((g_msg[4] == OPCODE_SOUND) || (g_msg[4] == OPCODE_LIFT)) {
diff --git a/engines/mortevielle/mortevielle.h b/engines/mortevielle/mortevielle.h
index 477415b317..e6df67024e 100644
--- a/engines/mortevielle/mortevielle.h
+++ b/engines/mortevielle/mortevielle.h
@@ -114,6 +114,7 @@ private:
void handleAction();
public:
Common::String _hintPctMessage;
+ Common::Point _prevPos;
bool _roomPresenceLuc;
bool _roomPresenceIda;
@@ -126,7 +127,6 @@ public:
bool _toiletsPresenceBobMax;
bool _bathRoomPresenceBobMax;
bool _room9PresenceLeo;
-
bool _soundOff;
bool _largestClearScreen;
bool _hiddenHero;
diff --git a/engines/mortevielle/mouse.cpp b/engines/mortevielle/mouse.cpp
index c5f0e21802..a898f22bbe 100644
--- a/engines/mortevielle/mouse.cpp
+++ b/engines/mortevielle/mouse.cpp
@@ -33,38 +33,15 @@
namespace Mortevielle {
-const int m_arrow = 0;
-const int m_point_hand = 1;
-
/**
* Initialize the mouse
* @remarks Originally called 'init_mouse'
*/
void MouseHandler::initMouse() {
- registres reg;
-
- mouse_shwn = 0;
- x_s = 0;
- y_s = 0;
- p_o_s = 0;
+ _counter = 0;
+ _pos = Common::Point(0, 0);
g_vm->setMouseClick(false);
- m_show = m_arrow;
- if ((READ_LE_UINT16(&g_mem[0xcc]) == 0) && (READ_LE_UINT16(&g_mem[0xce]) == 0))
- int_m = false;
-
- if (int_m) {
- reg._ax = 0;
- intr(0x33, reg);
- int_m = (reg._ax == -1);
- if (int_m) {
- reg._ax = 4;
- reg._cx = 0;
- reg._dx = 0;
-
- intr(0x33, reg);
- }
- }
}
/**
@@ -72,14 +49,13 @@ void MouseHandler::initMouse() {
* @remarks Originally called 'hide_mouse'
*/
void MouseHandler::hideMouse() {
- --mouse_shwn;
- if (mouse_shwn == 0) {
- bool imp = odd(y_s);
- int j = p_o_s;
+ --_counter;
+ if (_counter == 0) {
+ int j = 0;
switch (g_vm->_currGraphicalDevice) {
case MODE_CGA: {
int k = 0;
- j = ((uint)y_s >> 1) * 80 + ((uint)x_s >> 2);
+ j = ((uint)_pos.y >> 1) * 80 + ((uint)_pos.x >> 2);
do {
WRITE_LE_UINT16(&g_mem[0xb000 * 16 + j], s_s[0][k]);
WRITE_LE_UINT16(&g_mem[0xb800 * 16 + j + 2], s_s[1][k]);
@@ -90,11 +66,12 @@ void MouseHandler::hideMouse() {
} while (k < 5);
}
break;
- case MODE_AMSTRAD1512:
+ case MODE_AMSTRAD1512: {
+ bool imp = odd(_pos.y);
for (int i = 0; i <= 3; ++i) {
g_port[0x3dd] = 1 << i;
int k = 0;
- j = p_o_s;
+ j = 0;
do {
if (imp) {
WRITE_LE_UINT16(&g_mem[0xb800 * 16 + j], s_s[i][k]);
@@ -108,6 +85,7 @@ void MouseHandler::hideMouse() {
} while (k < 8);
}
break;
+ }
case MODE_EGA: {
g_port[0x3c4] = 2;
g_port[0x3ce] = 8;
@@ -116,7 +94,7 @@ void MouseHandler::hideMouse() {
do {
g_port[0x3c5] = 1 << i;
int k = 0;
- j = p_o_s;
+ j = 0;
do {
// Useless ?
// ps = mem[0xa000 * 16 + j];
@@ -133,7 +111,7 @@ void MouseHandler::hideMouse() {
}
break;
case MODE_HERCULES:
- j = ((uint)y_s >> 1) * 80 + ((uint)x_s >> 3);
+ j = ((uint)_pos.y >> 1) * 80 + ((uint)_pos.x >> 3);
for (int i = 0; i <= 5; ++i) {
for (int k = 0; k <= 3; ++k)
WRITE_LE_UINT16(&g_mem[0xb000 * 16 + k * 0x200 + j], s_s[i][k]);
@@ -141,7 +119,7 @@ void MouseHandler::hideMouse() {
}
break;
case MODE_TANDY: {
- j = ((uint)y_s >> 2) * 160 + ((uint)x_s >> 1);
+ j = ((uint)_pos.y >> 2) * 160 + ((uint)_pos.x >> 1);
int k = 0;
do {
for (int i = 0; i <= 3; ++i) {
@@ -166,16 +144,15 @@ void MouseHandler::hideMouse() {
void MouseHandler::showMouse() {
int k, l;
- mouse_shwn = mouse_shwn + 1;
- if (mouse_shwn != 1)
+ ++_counter;
+ if (_counter != 1)
return;
- int j = p_o_s;
- bool imp = odd(y_s);
- int i = x_s & 7;
+ int j = 0;
+ int i = _pos.x & 7;
switch (g_vm->_currGraphicalDevice) {
case MODE_CGA:
k = 0;
- j = ((uint)y_s >> 1) * 80 + ((uint)x_s >> 2);
+ j = ((uint)_pos.y >> 1) * 80 + ((uint)_pos.x >> 2);
do {
s_s[0][k] = READ_LE_UINT16(&g_mem[0xb800 * 16 + j]);
s_s[1][k] = READ_LE_UINT16(&g_mem[0xb800 * 16 + j + 2]);
@@ -185,10 +162,11 @@ void MouseHandler::showMouse() {
++k;
} while (k < 5);
break;
- case MODE_AMSTRAD1512:
+ case MODE_AMSTRAD1512: {
+ bool imp = odd(_pos.y);
for (i = 0; i <= 3; ++i) {
- j = p_o_s;
- imp = odd(y_s);
+ j = 0;
+ imp = odd(_pos.y);
g_port[0x3de] = i;
k = 0;
do {
@@ -204,13 +182,14 @@ void MouseHandler::showMouse() {
} while (k < 8);
}
break;
+ }
case MODE_EGA:
g_port[0x3ce] = 4;
l = 0;
do {
g_port[0x3cf] = l;
k = 0;
- j = p_o_s;
+ j = 0;
do {
s_s[l][k] = g_mem[0xa000 * 16 + j] + (g_mem[(0xa000 * 16) + j + 1] << 8);
j += 80;
@@ -220,7 +199,7 @@ void MouseHandler::showMouse() {
} while (l != 4);
break;
case MODE_HERCULES:
- j = ((uint)y_s >> 1) * 80 + ((uint)x_s >> 3);
+ j = ((uint)_pos.y >> 1) * 80 + ((uint)_pos.x >> 3);
for (i = 0; i <= 5; ++i) {
for (k = 0; k <= 3; ++k)
s_s[i][k] = READ_LE_UINT16(&g_mem[0xb000 * 16 + k * 0x200 + j]);
@@ -228,7 +207,7 @@ void MouseHandler::showMouse() {
}
break;
case MODE_TANDY:
- j = ((uint)y_s >> 2) * 160 + ((uint)x_s >> 1);
+ j = ((uint)_pos.y >> 2) * 160 + ((uint)_pos.x >> 1);
k = 0;
do {
for (i = 0; i <= 3; ++i) {
@@ -248,20 +227,20 @@ void MouseHandler::showMouse() {
* Set mouse position
* @remarks Originally called 'pos_mouse'
*/
-void MouseHandler::setMousePos(int x, int y) {
- if (x > 314 * g_res)
- x = 314 * g_res;
- else if (x < 0)
- x = 0;
- if (y > 199)
- y = 199;
- else if (y < 0)
- y = 0;
- if ((x == x_s) && (y == y_s))
+void MouseHandler::setMousePos(Common::Point newPos) {
+ if (newPos.x > 314 * g_res)
+ newPos.x = 314 * g_res;
+ else if (newPos.x < 0)
+ newPos.x = 0;
+ if (newPos.y > 199)
+ newPos.y = 199;
+ else if (newPos.y < 0)
+ newPos.y = 0;
+ if (newPos == _pos)
return;
// Set the new position
- g_vm->setMousePos(Common::Point(x, y));
+ g_vm->setMousePos(newPos);
}
/**
@@ -300,16 +279,16 @@ void MouseHandler::moveMouse(bool &funct, char &key) {
getMousePos_(cx, cy, cd);
switch (toupper(in1)) {
case '4':
- cx = cx - 8;
+ cx -= 8;
break;
case '2':
- cy = cy + 8;
+ cy += 8;
break;
case '6':
- cx = cx + 8;
+ cx += 8;
break;
case '8':
- cy = cy - 8;
+ cy -= 8;
break;
case '7':
cy = 1;
@@ -428,7 +407,7 @@ void MouseHandler::moveMouse(bool &funct, char &key) {
break;
}
- setMousePos(cx, cy);
+ setMousePos(Common::Point(cx, cy));
p_key = g_vm->keyPressed();
}
}
diff --git a/engines/mortevielle/mouse.h b/engines/mortevielle/mouse.h
index e9cc8af7c0..76a9991f44 100644
--- a/engines/mortevielle/mouse.h
+++ b/engines/mortevielle/mouse.h
@@ -33,21 +33,17 @@
namespace Mortevielle {
class MouseHandler {
-protected:
+private:
int s_s[12][6];
-public:
- bool int_m;
+ int _counter;
- int m_show;
- int x_s;
- int y_s;
- int p_o_s;
- int mouse_shwn;
+public:
+ Common::Point _pos;
void initMouse();
void hideMouse();
void showMouse();
- void setMousePos(int x, int y);
+ void setMousePos(Common::Point newPos);
void getMousePos_(int &x, int &y, int &c);
void moveMouse(bool &funct, char &key);
bool isMouseIn(rectangle r);
diff --git a/engines/mortevielle/ovd1.cpp b/engines/mortevielle/ovd1.cpp
index 1ac883f53e..2f86437b3f 100644
--- a/engines/mortevielle/ovd1.cpp
+++ b/engines/mortevielle/ovd1.cpp
@@ -134,7 +134,6 @@ void chartex() {
void dialpre() {
/* debug('o3 dialpre'); */
g_crep = 998;
- g_vm->_mouse.int_m = true;
}
void music() {
diff --git a/engines/mortevielle/var_mor.cpp b/engines/mortevielle/var_mor.cpp
index 495487c33e..f4a5d12955 100644
--- a/engines/mortevielle/var_mor.cpp
+++ b/engines/mortevielle/var_mor.cpp
@@ -105,8 +105,6 @@ int g_x,
g_menup,
g_mpers,
g_mnumo,
- g_xprec,
- g_yprec,
g_perdep,
g_prebru,
g_numpal,
@@ -176,10 +174,6 @@ Common::String copy(const Common::String &s, int idx, size_t size) {
int g_port[0xfff];
byte g_mem[65536 * 16];
-void intr(int intNum, registres &regs) {
- warning("STUBBED: Call to DOS interrupt #%d", intNum);
-}
-
/**
* Engine function - Get a random number between two values
* @remarks Originally called 'get_random_number' and 'hazard'
diff --git a/engines/mortevielle/var_mor.h b/engines/mortevielle/var_mor.h
index 19bde4088e..d71c0d7668 100644
--- a/engines/mortevielle/var_mor.h
+++ b/engines/mortevielle/var_mor.h
@@ -131,10 +131,6 @@ struct sav_chaine {
byte _fullHour;
};
-struct registres {
- int _ax, _bx, _cx, _dx, _bp, _si, _di, _ds, _es, _flags;
-};
-
struct ind {
int _indis;
byte _point;
@@ -210,8 +206,6 @@ extern int g_x,
g_menup,
g_mpers,
g_mnumo,
- g_xprec,
- g_yprec,
g_perdep,
g_prebru,
g_numpal,
@@ -264,7 +258,6 @@ extern byte g_mem[65536 * 16];
#define hires {}
extern void palette(int v1);
-extern void intr(int intNum, registres &regs);
extern int getRandomNumber(int minval, int maxval);
extern void s_char(int Gd, int y, int dy);