aboutsummaryrefslogtreecommitdiff
path: root/engines/mortevielle
diff options
context:
space:
mode:
authorStrangerke2012-03-19 07:44:56 +0100
committerStrangerke2012-04-06 08:23:30 +0200
commit1c283507ee0dab8f960bdbe249f837a95c4b6e2b (patch)
tree6cbde0e1bccca2f01a19a69f1ad3494a4edeca10 /engines/mortevielle
parentfc14ffbcb53aedfb23ac7ecc862d2bf9a454fb73 (diff)
downloadscummvm-rg350-1c283507ee0dab8f960bdbe249f837a95c4b6e2b.tar.gz
scummvm-rg350-1c283507ee0dab8f960bdbe249f837a95c4b6e2b.tar.bz2
scummvm-rg350-1c283507ee0dab8f960bdbe249f837a95c4b6e2b.zip
MORTEVIELLE: Some more renaming, introduce MouseHandler
Diffstat (limited to 'engines/mortevielle')
-rw-r--r--engines/mortevielle/actions.cpp40
-rw-r--r--engines/mortevielle/dialogs.cpp46
-rw-r--r--engines/mortevielle/dialogs.h2
-rw-r--r--engines/mortevielle/graphics.cpp4
-rw-r--r--engines/mortevielle/menu.cpp12
-rw-r--r--engines/mortevielle/mor.cpp1457
-rw-r--r--engines/mortevielle/mor.h10
-rw-r--r--engines/mortevielle/mortevielle.cpp1390
-rw-r--r--engines/mortevielle/mortevielle.h10
-rw-r--r--engines/mortevielle/mouse.cpp36
-rw-r--r--engines/mortevielle/mouse.h38
-rw-r--r--engines/mortevielle/outtext.cpp4
-rw-r--r--engines/mortevielle/ovd1.cpp2
-rw-r--r--engines/mortevielle/saveload.cpp8
14 files changed, 1532 insertions, 1527 deletions
diff --git a/engines/mortevielle/actions.cpp b/engines/mortevielle/actions.cpp
index 944ac9fc2f..7949d93b38 100644
--- a/engines/mortevielle/actions.cpp
+++ b/engines/mortevielle/actions.cpp
@@ -700,12 +700,12 @@ void MortevielleEngine::fctPlace() {
Alert::show(alertTxt, 1);
bool enterPassageFl = KnowledgeCheck::show();
- hideMouse();
+ _mouse.hideMouse();
hirs();
drawRightFrame();
clearScreenType2();
clearScreenType3();
- showMouse();
+ _mouse.showMouse();
tinke();
drawClock();
if (_currBitIndex != 0)
@@ -1357,10 +1357,10 @@ void MortevielleEngine::fctDiscuss() {
}
tkey1(false);
mennor();
- hideMouse();
+ _mouse.hideMouse();
hirs();
premtet();
- sparl(0, suj);
+ startDialog(suj);
hirs();
for (int ix = 1; ix <= 46; ++ix)
te[ix] = false;
@@ -1371,7 +1371,7 @@ void MortevielleEngine::fctDiscuss() {
}
lib[46] = lib[45];
lib[45] = ' ';
- showMouse();
+ _mouse.showMouse();
do {
choi = 0;
icm = 0;
@@ -1397,10 +1397,10 @@ void MortevielleEngine::fctDiscuss() {
writetp(lib[46], 0);
tou = '\0';
do {
- moveMouse(f, tou);
+ _mouse.moveMouse(f, tou);
CHECK_QUIT;
- getMousePos_(x, y, c);
+ _mouse.getMousePos_(x, y, c);
x *= (3 - g_res);
if (x > 319)
cx = 41;
@@ -1482,11 +1482,11 @@ void MortevielleEngine::fctDiscuss() {
g_s._faithScore += 3;
suj = 139;
}
- hideMouse();
+ _mouse.hideMouse();
hirs();
premtet();
- sparl(0, suj);
- showMouse();
+ startDialog(suj);
+ _mouse.showMouse();
if ((suj == 84) || (suj == 86)) {
g_s._pourc[5] = '*';
g_s._teauto[7] = '*';
@@ -1500,26 +1500,26 @@ void MortevielleEngine::fctDiscuss() {
g_s._pourc[8] = '*';
g_s._teauto[32] = '*';
}
- hideMouse();
+ _mouse.hideMouse();
hirs();
- showMouse();
+ _mouse.showMouse();
}
} while ((choi != 46) && (suj != 138));
if (_col) {
g_s._faithScore += (3 * (g_s._faithScore / 10));
- hideMouse();
+ _mouse.hideMouse();
hirs();
premtet();
- sparl(0, 138);
- showMouse();
+ startDialog(138);
+ _mouse.showMouse();
_col = false;
g_s._currPlace = LANDING;
}
g_ctrm = 0;
- hideMouse();
+ _mouse.hideMouse();
hirs();
drawRightFrame();
- showMouse();
+ _mouse.showMouse();
showPeoplePresent(_currBitIndex);
tinke();
drawClock();
@@ -1574,13 +1574,13 @@ void MortevielleEngine::endGame() {
clearScreenType3();
repon(9, 1509);
tkey1(false);
- hideMouse();
+ _mouse.hideMouse();
g_caff = 70;
taffich();
hirs();
premtet();
- sparl(0, 141);
- showMouse();
+ startDialog(141);
+ _mouse.showMouse();
clearScreenType1();
repon(9, 1509);
repon(2, 142);
diff --git a/engines/mortevielle/dialogs.cpp b/engines/mortevielle/dialogs.cpp
index dbbd8c5896..f1faee0daa 100644
--- a/engines/mortevielle/dialogs.cpp
+++ b/engines/mortevielle/dialogs.cpp
@@ -44,7 +44,6 @@ int Alert::show(const Common::String &msg, int n) {
int coldep, esp, i, caseNumb, quoi, ix;
Common::String st, chaine;
int limit[3][3];
- char dumi;
Common::String s[3];
int cx, cy, nbcol, lignNumb;
bool newaff, test, test1, test2, test3, dum;
@@ -55,9 +54,9 @@ int Alert::show(const Common::String &msg, int n) {
memset(&limit[0][0], 0, sizeof(int) * 3 * 3);
int do_alert_result;
- hideMouse();
+ g_vm->_mouse.hideMouse();
while (g_vm->keyPressed())
- dumi = g_vm->getChar();
+ g_vm->getChar();
g_vm->setMouseClick(false);
decodeAlertDetails(msg, caseNumb, lignNumb, nbcol, chaine, cas);
@@ -101,16 +100,16 @@ int Alert::show(const Common::String &msg, int n) {
limit[2][1] = ((uint)(320 + ((uint)esp >> 1)) >> 1) * g_res;
limit[2][2] = (limit[2][1]) + 40;
}
- showMouse();
+ g_vm->_mouse.showMouse();
quoi = 0;
dum = false;
do {
- dumi = '\377';
- moveMouse(dum, dumi);
+ char dummyKey = '\377';
+ g_vm->_mouse.moveMouse(dum, dummyKey);
CHECK_QUIT0;
- cx = x_s;
- cy = y_s;
+ cx = g_vm->_mouse.x_s;
+ cy = g_vm->_mouse.y_s;
test = (cy > 95) && (cy < 105);
newaff = false;
if (test) {
@@ -125,7 +124,7 @@ int Alert::show(const Common::String &msg, int n) {
else
ix = 2;
if (ix != quoi) {
- hideMouse();
+ g_vm->_mouse.hideMouse();
if (quoi != 0) {
setPosition(quoi, coldep, esp);
@@ -142,12 +141,12 @@ int Alert::show(const Common::String &msg, int n) {
g_vm->_screenSurface.drawString(tmp2, 1);
quoi = ix;
- showMouse();
+ g_vm->_mouse.showMouse();
}
}
}
if ((quoi != 0) && ! newaff) {
- hideMouse();
+ g_vm->_mouse.hideMouse();
setPosition(quoi, coldep, esp);
Common::String tmp3(" ");
@@ -156,13 +155,13 @@ int Alert::show(const Common::String &msg, int n) {
g_vm->_screenSurface.drawString(tmp3, 0);
quoi = 0;
- showMouse();
+ 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])));
} while (!g_vm->getMouseClick());
g_vm->setMouseClick(false);
- hideMouse();
+ g_vm->_mouse.hideMouse();
if (!test3) {
quoi = n;
setPosition(n, coldep, esp);
@@ -172,7 +171,7 @@ int Alert::show(const Common::String &msg, int n) {
g_vm->_screenSurface.drawString(tmp4, 1);
}
charecr(50, (NUM_LINES + 1) << 4);
- showMouse();
+ g_vm->_mouse.showMouse();
/* Restore the background area */
g_vm->_screenSurface.copyFrom(g_vm->_backgroundSurface, 0, 0);
@@ -299,9 +298,9 @@ bool KnowledgeCheck::show() {
int correctCount = 0;
for (int indx = 0; indx < 10; ++indx) {
- hideMouse();
+ g_vm->_mouse.hideMouse();
hirs();
- showMouse();
+ g_vm->_mouse.showMouse();
int dialogHeight;
if (g_res == 1)
dialogHeight = 29;
@@ -355,11 +354,11 @@ bool KnowledgeCheck::show() {
do {
g_vm->setMouseClick(false);
bool flag;
- moveMouse(flag, key);
+ g_vm->_mouse.moveMouse(flag, key);
CHECK_QUIT0;
currChoice = 1;
- while (coor[currChoice]._enabled && !isMouseIn(coor[currChoice]))
+ while (coor[currChoice]._enabled && !g_vm->_mouse.isMouseIn(coor[currChoice]))
++currChoice;
if (coor[currChoice]._enabled) {
if ((prevChoice != 0) && (prevChoice != currChoice)) {
@@ -425,7 +424,7 @@ void f3f8::checkForF8(int SpeechNum, bool drawAni50Fl) {
teskbd();
do {
g_vm->_speechManager.startSpeech(SpeechNum, 0, 0);
- waitForF3F8(g_key);
+ g_key = waitForF3F8();
CHECK_QUIT;
if (g_vm->_newGraphicalDevice != g_vm->_currGraphicalDevice) {
@@ -440,11 +439,16 @@ void f3f8::checkForF8(int SpeechNum, bool drawAni50Fl) {
* Alert function - Loop until F3 or F8 is pressed
* @remarks Originally called 'atf3f8'
*/
-void f3f8::waitForF3F8(int &key) {
+int f3f8::waitForF3F8() {
+ int key;
+
do {
key = testou();
- CHECK_QUIT;
+ if (g_vm->shouldQuit())
+ return key;
} while ((key != 61) && (key != 66));
+
+ return key;
}
void f3f8::aff50(bool drawAni50Fl) {
diff --git a/engines/mortevielle/dialogs.h b/engines/mortevielle/dialogs.h
index eaab56d7e2..40109c894b 100644
--- a/engines/mortevielle/dialogs.h
+++ b/engines/mortevielle/dialogs.h
@@ -54,7 +54,7 @@ class f3f8 {
public:
static void draw();
static void checkForF8(int SpeechNum, bool drawAni50Fl);
- static void waitForF3F8(int &key);
+ static int waitForF3F8();
static void aff50(bool drawAni50Fl);
static void ani50();
};
diff --git a/engines/mortevielle/graphics.cpp b/engines/mortevielle/graphics.cpp
index 1c26a5cea1..dc63e05c22 100644
--- a/engines/mortevielle/graphics.cpp
+++ b/engines/mortevielle/graphics.cpp
@@ -1056,7 +1056,7 @@ void ScreenSurface::drawString(const Common::String &l, int command) {
if (l == "")
return;
- hideMouse();
+ g_vm->_mouse.hideMouse();
pt = _textPos;
if (g_res == 2)
@@ -1094,7 +1094,7 @@ void ScreenSurface::drawString(const Common::String &l, int command) {
g_vm->_screenSurface.writeCharacter(Common::Point(pt.x, pt.y), ord(l[x - 1]), cecr);
pt.x += i;
}
- showMouse();
+ g_vm->_mouse.showMouse();
}
/**
diff --git a/engines/mortevielle/menu.cpp b/engines/mortevielle/menu.cpp
index a28df25634..3f5db6de9a 100644
--- a/engines/mortevielle/menu.cpp
+++ b/engines/mortevielle/menu.cpp
@@ -169,7 +169,7 @@ void Menu::displayMenu() {
int pt, x, y, color, msk, num_letr;
- hideMouse();
+ g_vm->_mouse.hideMouse();
g_vm->_screenSurface.fillRect(7, Common::Rect(0, 0, 639, 10));
col = 28 * g_res;
@@ -203,7 +203,7 @@ void Menu::displayMenu() {
} while (y != 9);
col += 48 * g_res;
} while (num_letr != 6);
- showMouse();
+ g_vm->_mouse.showMouse();
}
/**
@@ -310,7 +310,7 @@ void Menu::menuDown(int ii) {
// Draw the menu
xco = g_menuConstants[ii - 1][0];
nb_lig = g_menuConstants[ii - 1][3];
- hideMouse();
+ g_vm->_mouse.hideMouse();
sauvecr(10, (g_menuConstants[ii - 1][1] + 1) << 1);
xco = xco << 3;
if (g_res == 1)
@@ -376,7 +376,7 @@ void Menu::menuDown(int ii) {
g_vm->_screenSurface.putxy(xco, g_vm->_screenSurface._textPos.y + 8);
} while (cx != nb_lig);
_multiTitle = true;
- showMouse();
+ g_vm->_mouse.showMouse();
}
/**
@@ -417,8 +417,8 @@ void Menu::mdn() {
if (!_menuActive)
return;
- int x = x_s;
- int y = y_s;
+ int x = g_vm->_mouse.x_s;
+ int y = g_vm->_mouse.y_s;
if (!g_vm->getMouseClick()) {
if ((x == g_xprec) && (y == g_yprec))
return;
diff --git a/engines/mortevielle/mor.cpp b/engines/mortevielle/mor.cpp
index 5bba9c5aed..439d9255e2 100644
--- a/engines/mortevielle/mor.cpp
+++ b/engines/mortevielle/mor.cpp
@@ -53,20 +53,6 @@ void copcha() {
} while (i != acha + 390);
}
-/**
- * Engine function : Is mouse in a given rect?
- * @remarks Originally called 'dans_rect'
- */
-bool isMouseIn(rectangle r) {
- int x, y, c;
-
- getMousePos_(x, y, c);
- if ((x > r._x1) && (x < r._x2) && (y > r._y1) && (y < r._y2))
- return true;
-
- return false;
-}
-
void outbloc(int n, pattern p, nhom *pal) {
int ad = n * 404 + 0xd700;
@@ -124,15 +110,15 @@ void pictout(int seg, int dep, int x, int y) {
}
void sauvecr(int y, int dy) {
- hideMouse();
+ g_vm->_mouse.hideMouse();
s_sauv(g_vm->_currGraphicalDevice, y, dy);
- showMouse();
+ g_vm->_mouse.showMouse();
}
void charecr(int y, int dy) {
- hideMouse();
+ g_vm->_mouse.hideMouse();
s_char(g_vm->_currGraphicalDevice, y, dy);
- showMouse();
+ g_vm->_mouse.showMouse();
}
void adzon() {
@@ -224,10 +210,10 @@ void modif(int &nu) {
void dessine(int ad, int x, int y) {
- hideMouse();
+ g_vm->_mouse.hideMouse();
writepal(g_numpal);
pictout(ad, 0, x, y);
- showMouse();
+ g_vm->_mouse.showMouse();
}
/**
@@ -239,17 +225,9 @@ void drawRightFrame() {
if (g_vm->_currGraphicalDevice == MODE_HERCULES) {
g_mem[0x7000 * 16 + 14] = 15;
}
- hideMouse();
+ g_vm->_mouse.hideMouse();
pictout(0x73a2, 0, 0, 0);
- showMouse();
-}
-
-/**
- * Set Text Color
- * @remarks Originally called 'text_color'
- */
-void MortevielleEngine::setTextColor(int col) {
- _textColor = col;
+ g_vm->_mouse.showMouse();
}
/* NIVEAU 13 */
@@ -273,77 +251,6 @@ void initouv() {
g_touv[cx] = chr(0);
}
-/**
- * Engine function - Clear Screen - Type 1
- * @remarks Originally called 'clsf1'
- */
-void clearScreenType1() {
- hideMouse();
- g_vm->_screenSurface.fillRect(0, Common::Rect(0, 11, 514, 175));
- showMouse();
-}
-
-/**
- * Engine function - Clear Screen - Type 2
- * @remarks Originally called 'clsf2'
- */
-void clearScreenType2() {
- hideMouse();
- if (g_vm->_largestClearScreen) {
- g_vm->_screenSurface.fillRect(0, Common::Rect(1, 176, 633, 199));
- g_vm->_screenSurface.drawBox(0, 175, 634, 24, 15);
- g_vm->_largestClearScreen = false;
- } else {
- g_vm->_screenSurface.fillRect(0, Common::Rect(1, 176, 633, 190));
- g_vm->_screenSurface.drawBox(0, 175, 634, 15, 15);
- }
- showMouse();
-}
-
-/**
- * Engine function - Clear Screen - Type 3
- * @remarks Originally called 'clsf3'
- */
-void clearScreenType3() {
- hideMouse();
- g_vm->_screenSurface.fillRect(0, Common::Rect(1, 192, 633, 199));
- g_vm->_screenSurface.drawBox(0, 191, 634, 8, 15);
- showMouse();
-}
-
-/**
- * Engine function - Clear Screen - Type 10
- * @remarks Originally called 'clsf10'
- */
-void clearScreenType10() {
- int co, cod;
- Common::String st;
-
- hideMouse();
- if (g_res == 1) {
- co = 634;
- cod = 534;
- } else {
- co = 600;
- cod = 544;
- }
- g_vm->_screenSurface.fillRect(15, Common::Rect(cod, 93, co, 98));
- if (g_s._faithScore < 33)
- st = g_vm->getEngineString(S_COOL);
- else if (g_s._faithScore < 66)
- st = g_vm->getEngineString(S_LOURDE);
- else if (g_s._faithScore > 65)
- st = g_vm->getEngineString(S_MALSAINE);
-
- co = 580 - (g_vm->_screenSurface.getStringWidth(st) / 2);
- g_vm->_screenSurface.putxy(co, 92);
- g_vm->_screenSurface.drawString(st, 4);
-
- g_vm->_screenSurface.fillRect(15, Common::Rect(560, 24, 610, 86));
- /* rempli(69,12,32,5,255);*/
- showMouse();
-}
-
void ecr2(Common::String str_) {
// Some dead code was present in the original: removed
g_vm->_screenSurface.putxy(8, 177);
@@ -358,7 +265,7 @@ void ecr2(Common::String str_) {
g_vm->_screenSurface.drawString(copy(str_, tlig, tlig << 1), 5);
} else {
g_vm->_largestClearScreen = true;
- clearScreenType2();
+ g_vm->clearScreenType2();
g_vm->_screenSurface.putxy(8, 176);
g_vm->_screenSurface.drawString(copy(str_, 1, (tlig - 1)), 5);
g_vm->_screenSurface.putxy(8, 182);
@@ -369,36 +276,11 @@ void ecr2(Common::String str_) {
}
void ecr3(Common::String text) {
- clearScreenType3();
+ g_vm->clearScreenType3();
g_vm->_screenSurface.putxy(8, 192);
g_vm->_screenSurface.drawString(text, 5);
}
-/**
- * Prepare screen - Type 1!
- * @remarks Originally called 'ecrf1'
- */
-void MortevielleEngine::prepareScreenType1() {
- // Large drawing
- _screenSurface.drawBox(0, 11, 512, 163, 15);
-}
-
-/**
- * Prepare room - Type 2!
- * @remarks Originally called 'ecrf2'
- */
-void MortevielleEngine::prepareScreenType2() {
- setTextColor(5);
-}
-
-/**
- * Prepare room - Type 3!
- * @remarks Originally called 'ecrf7'
- */
-void MortevielleEngine::prepareScreenType3() {
- setTextColor(4);
-}
-
void stop() {
hirs();
g_vm->_currGraphicalDevice = MODE_AMSTRAD1512;
@@ -416,31 +298,6 @@ void paint_rect(int x, int y, int dx, int dy) {
g_vm->_screenSurface.fillRect(co, Common::Rect(x, y, x + dx, y + dy));
}
-/**
- * Engine function - Update hour
- * @remarks Originally called 'calch'
- */
-void MortevielleEngine::updateHour(int &day, int &hour, int &minute) {
- int newHour = readclock();
- int th = g_jh + ((newHour - g_mh) / g_t);
- minute = ((th % 2) + _currHalfHour) * 30;
- hour = ((uint)th >> 1) + _currHour;
- if (minute == 60) {
- minute = 0;
- ++hour;
- }
- day = (hour / 24) + _currDay;
- hour = hour - ((day - _currDay) * 24);
-}
-
-/**
- * Engine function - Convert character index to bit index
- * @remarks Originally called 'conv'
- */
-int convertCharacterIndexToBitIndex(int characterIndex) {
- return 128 >> (characterIndex - 1);
-}
-
/* NIVEAU 12 */
void modobj(int m) {
Common::String strp = Common::String(' ');
@@ -461,14 +318,14 @@ void repon(int f, int m) {
else
g_vm->_largestClearScreen = false;
- clearScreenType2();
+ g_vm->clearScreenType2();
displayStr(tmpStr, 8, 176, 85, 3, 5);
} else {
modif(m);
switch (f) {
case 2:
case 8:
- clearScreenType2();
+ g_vm->clearScreenType2();
g_vm->prepareScreenType2();
text1(8, 182, 103, m);
if ((m == 68) || (m == 69))
@@ -505,261 +362,6 @@ void repon(int f, int m) {
}
}
-/**
- * Engine function - Reset presence in other rooms
- * @remarks Originally called 't5'
- */
-void MortevielleEngine::resetPresenceInRooms(int roomId) {
- if (roomId == DINING_ROOM)
- _blo = false;
-
- if (roomId != GREEN_ROOM) {
- _roomPresenceLuc = false;
- _roomPresenceIda = false;
- }
-
- if (roomId != PURPLE_ROOM)
- _purpleRoomPresenceLeo = false;
-
- if (roomId != DARKBLUE_ROOM) {
- _roomPresenceGuy = false;
- _roomPresenceEva = false;
- }
-
- if (roomId != BLUE_ROOM)
- _roomPresenceMax = false;
- if (roomId != RED_ROOM)
- _roomPresenceBob = false;
- if (roomId != GREEN_ROOM2)
- _roomPresencePat = false;
- if (roomId != TOILETS)
- _toiletsPresenceBobMax = false;
- if (roomId != BATHROOM)
- _bathRoomPresenceBobMax = false;
- if (roomId != ROOM9)
- _room9PresenceLeo = false;
-}
-
-/**
- * Engine function - Show the people present in the given room
- * @remarks Originally called 'affper'
- */
-void MortevielleEngine::showPeoplePresent(int bitIndex) {
- int xp = 580 - (_screenSurface.getStringWidth("LEO") / 2);
-
- for (int i = 1; i <= 8; ++i)
- _menu.disableMenuItem(_menu._discussMenu[i]);
-
- clearScreenType10();
- if ((bitIndex & 128) == 128) {
- _screenSurface.putxy(xp, 24);
- _screenSurface.drawString("LEO", 4);
- _menu.enableMenuItem(_menu._discussMenu[1]);
- }
- if ((bitIndex & 64) == 64) {
- _screenSurface.putxy(xp, 32);
- _screenSurface.drawString("PAT", 4);
- _menu.enableMenuItem(_menu._discussMenu[2]);
- }
- if ((bitIndex & 32) == 32) {
- _screenSurface.putxy(xp, 40);
- _screenSurface.drawString("GUY", 4);
- _menu.enableMenuItem(_menu._discussMenu[3]);
- }
- if ((bitIndex & 16) == 16) {
- _screenSurface.putxy(xp, 48);
- _screenSurface.drawString("EVA", 4);
- _menu.enableMenuItem(_menu._discussMenu[4]);
- }
- if ((bitIndex & 8) == 8) {
- _screenSurface.putxy(xp, 56);
- _screenSurface.drawString("BOB", 4);
- _menu.enableMenuItem(_menu._discussMenu[5]);
- }
- if ((bitIndex & 4) == 4) {
- _screenSurface.putxy(xp, 64);
- _screenSurface.drawString("LUC", 4);
- _menu.enableMenuItem(_menu._discussMenu[6]);
- }
- if ((bitIndex & 2) == 2) {
- _screenSurface.putxy(xp, 72);
- _screenSurface.drawString("IDA", 4);
- _menu.enableMenuItem(_menu._discussMenu[7]);
- }
- if ((bitIndex & 1) == 1) {
- _screenSurface.putxy(xp, 80);
- _screenSurface.drawString("MAX", 4);
- _menu.enableMenuItem(_menu._discussMenu[8]);
- }
- _currBitIndex = bitIndex;
-}
-
-/**
- * Engine function - Select random characters
- * @remarks Originally called 'choix'
- */
-int MortevielleEngine::selectCharacters(int min, int max) {
- bool invertSelection = false;
- int rand = getRandomNumber(min, max);
-
- if (rand > 4) {
- rand = 8 - rand;
- invertSelection = true;
- }
-
- int i = 0;
- int retVal = 0;
- while (i < rand) {
- int charIndex = getRandomNumber(1, 8);
- int charBitIndex = convertCharacterIndexToBitIndex(charIndex);
- if ((retVal & charBitIndex) != charBitIndex) {
- ++i;
- retVal |= charBitIndex;
- }
- }
- if (invertSelection)
- retVal = 255 - retVal;
-
- return retVal;
-}
-
-/**
- * Engine function - Get Presence Statistics - Green Room
- * @remarks Originally called 'cpl1'
- */
-int MortevielleEngine::getPresenceStatsGreenRoom() {
- int day, hour, minute;
- int retVal = 0;
-
- updateHour(day, hour, minute);
- // The original uses an || instead of an &&, resulting
- // in an always true condition. Based on the other tests,
- // and on other scenes, we use an && instead.
- if ((hour > 7) && (hour < 11))
- retVal = 25;
- else if ((hour > 10) && (hour < 14))
- retVal = 35;
- else if ((hour > 13) && (hour < 16))
- retVal = 50;
- else if ((hour > 15) && (hour < 18))
- retVal = 5;
- else if ((hour > 17) && (hour < 22))
- retVal = 35;
- else if ((hour > 21) && (hour < 24))
- retVal = 50;
- else if ((hour >= 0) && (hour < 8))
- retVal = 70;
-
- _menu.mdn();
-
- return retVal;
-}
-/**
- * Engine function - Get Presence Statistics - Purple Room
- * @remarks Originally called 'cpl2'
- */
-int MortevielleEngine::getPresenceStatsPurpleRoom() {
- int day, hour, minute;
- int retVal = 0;
-
- updateHour(day, hour, minute);
- if ((hour > 7) && (hour < 11))
- retVal = -2;
- else if (hour == 11)
- retVal = 100;
- else if ((hour > 11) && (hour < 23))
- retVal = 10;
- else if (hour == 23)
- retVal = 20;
- else if ((hour >= 0) && (hour < 8))
- retVal = 50;
-
- return retVal;
-}
-
-/**
- * Engine function - Get Presence Statistics - Toilets
- * @remarks Originally called 'cpl3'
- */
-int MortevielleEngine::getPresenceStatsToilets() {
- int day, hour, minute;
- int retVal = 0;
-
- updateHour(day, hour, minute);
- if (((hour > 8) && (hour < 10)) || ((hour > 19) && (hour < 24)))
- retVal = 34;
- else if (((hour > 9) && (hour < 20)) || ((hour >= 0) && (hour < 9)))
- retVal = 0;
-
- return retVal;
-}
-
-/**
- * Engine function - Get Presence Statistics - Blue Room
- * @remarks Originally called 'cpl5'
- */
-int MortevielleEngine::getPresenceStatsBlueRoom() {
- int day, hour, minute;
- int retVal = 0;
-
- updateHour(day, hour, minute);
- if ((hour > 6) && (hour < 10))
- retVal = 0;
- else if (hour == 10)
- retVal = 100;
- else if ((hour > 10) && (hour < 24))
- retVal = 15;
- else if ((hour >= 0) && (hour < 7))
- retVal = 50;
-
- return retVal;
-}
-
-/**
- * Engine function - Get Presence Statistics - Red Room
- * @remarks Originally called 'cpl6'
- */
-int MortevielleEngine::getPresenceStatsRedRoom() {
- int day, hour, minute;
- int retVal = 0;
-
- updateHour(day, hour, minute);
- if (((hour > 7) && (hour < 13)) || ((hour > 17) && (hour < 20)))
- retVal = -2;
- else if (((hour > 12) && (hour < 17)) || ((hour > 19) && (hour < 24)))
- retVal = 35;
- else if (hour == 17)
- retVal = 100;
- else if ((hour >= 0) && (hour < 8))
- retVal = 60;
-
- return retVal;
-}
-
-/**
- * Shows the "you are alone" message in the status area
- * on the right hand side of the screen
- * @remarks Originally called 'person'
- */
-void MortevielleEngine::displayAloneText() {
- for (int cf = 1; cf <= 8; ++cf)
- _menu.disableMenuItem(_menu._discussMenu[cf]);
-
- Common::String sYou = getEngineString(S_YOU);
- Common::String sAre = getEngineString(S_ARE);
- Common::String sAlone = getEngineString(S_ALONE);
-
- clearScreenType10();
- _screenSurface.putxy(580 - (_screenSurface.getStringWidth(sYou) / 2), 30);
- _screenSurface.drawString(sYou, 4);
- _screenSurface.putxy(580 - (_screenSurface.getStringWidth(sAre) / 2), 50);
- _screenSurface.drawString(sAre, 4);
- _screenSurface.putxy(580 - (_screenSurface.getStringWidth(sAlone) / 2), 70);
- _screenSurface.drawString(sAlone, 4);
-
- _currBitIndex = 0;
-}
-
int chlm() {
int retval = getRandomNumber(1, 2);
if (retval == 2)
@@ -782,7 +384,7 @@ void drawClock() {
const int rg = 9;
int h, co;
- hideMouse();
+ g_vm->_mouse.hideMouse();
paint_rect(570, 118, 20, 10);
paint_rect(578, 114, 6, 18);
@@ -803,7 +405,7 @@ void drawClock() {
h = 12;
g_vm->_screenSurface.drawLine(((uint)x >> 1) * g_res, y, ((uint)(x + cv[0][h - 1]) >> 1) * g_res, y + cv[1][h - 1], co);
- showMouse();
+ g_vm->_mouse.showMouse();
g_vm->_screenSurface.putxy(568, 154);
if (g_vm->_hour > 11)
@@ -832,391 +434,6 @@ void debloc(int roomId) {
g_mpers = g_vm->_currBitIndex;
}
-/**
- * Engine function - Get Presence Statistics - Room Bureau
- * @remarks Originally called 'cpl10'
- */
-int MortevielleEngine::getPresenceStatsDiningRoom(int &hour) {
- int day, minute;
-
- int retVal = 0;
- updateHour(day, hour, minute);
- if (((hour > 7) && (hour < 11)) || ((hour > 11) && (hour < 14)) || ((hour > 18) && (hour < 21)))
- retVal = 100;
- else if ((hour == 11) || ((hour > 20) && (hour < 24)))
- retVal = 45;
- else if (((hour > 13) && (hour < 17)) || (hour == 18))
- retVal = 35;
- else if (hour == 17)
- retVal = 60;
- else if ((hour >= 0) && (hour < 8))
- retVal = 5;
-
- return retVal;
-}
-
-/**
- * Engine function - Get Presence Statistics - Room Bureau
- * @remarks Originally called 'cpl11'
- */
-int MortevielleEngine::getPresenceStatsBureau(int &hour) {
- int day, minute;
- int retVal = 0;
-
- updateHour(day, hour, minute);
- if (((hour > 8) && (hour < 12)) || ((hour > 20) && (hour < 24)))
- retVal = 25;
- else if (((hour > 11) && (hour < 14)) || ((hour > 18) && (hour < 21)))
- retVal = 5;
- else if ((hour > 13) && (hour < 17))
- retVal = 55;
- else if ((hour > 16) && (hour < 19))
- retVal = 45;
- else if ((hour >= 0) && (hour < 9))
- retVal = 0;
-
- return retVal;
-}
-
-/**
- * Engine function - Get Presence Statistics - Room Kitchen
- * @remarks Originally called 'cpl12'
- */
-int MortevielleEngine::getPresenceStatsKitchen() {
- int day, hour, minute;
- int retVal = 0;
-
- updateHour(day, hour, minute);
- if (((hour > 8) && (hour < 15)) || ((hour > 16) && (hour < 22)))
- retVal = 55;
- else if (((hour > 14) && (hour < 17)) || ((hour > 21) && (hour < 24)))
- retVal = 25;
- else if ((hour >= 0) && (hour < 5))
- retVal = 0;
- else if ((hour > 4) && (hour < 9))
- retVal = 15;
-
- return retVal;
-}
-
-/**
- * Engine function - Get Presence Statistics - Room Attic
- * @remarks Originally called 'cpl13'
- */
-int MortevielleEngine::getPresenceStatsAttic() {
- return 0;
-}
-
-/**
- * Engine function - Get Presence Statistics - Room Landing
- * @remarks Originally called 'cpl15'
- */
-int MortevielleEngine::getPresenceStatsLanding() {
- int day, hour, minute;
- int retVal = 0;
-
- updateHour(day, hour, minute);
- if ((hour > 7) && (hour < 12))
- retVal = 25;
- else if ((hour > 11) && (hour < 14))
- retVal = 0;
- else if ((hour > 13) && (hour < 18))
- retVal = 10;
- else if ((hour > 17) && (hour < 20))
- retVal = 55;
- else if ((hour > 19) && (hour < 22))
- retVal = 5;
- else if ((hour > 21) && (hour < 24))
- retVal = 15;
- else if ((hour >= 0) && (hour < 8))
- retVal = -15;
-
- return retVal;
-}
-
-/**
- * Engine function - Get Presence Statistics - Room Chapel
- * @remarks Originally called 'cpl20'
- */
-int MortevielleEngine::getPresenceStatsChapel(int &hour) {
- int day, minute;
- int retVal = 0;
-
- updateHour(day, hour, minute);
- if (hour == 10)
- retVal = 65;
- else if ((hour > 10) && (hour < 21))
- retVal = 5;
- else if ((hour > 20) && (hour < 24))
- retVal = -15;
- else if ((hour >= 0) && (hour < 5))
- retVal = -300;
- else if ((hour > 4) && (hour < 10))
- retVal = -5;
-
- return retVal;
-}
-
-/**
- * Engine function - Check who is in the Green Room
- * @remarks Originally called 'quelq1'
- */
-void MortevielleEngine::setPresenceGreenRoom(int roomId) {
- int rand = getRandomNumber(1, 2);
- if (roomId == GREEN_ROOM) {
- if (rand == 1)
- _roomPresenceLuc = true;
- else
- _roomPresenceIda = true;
- } else if (roomId == DARKBLUE_ROOM) {
- if (rand == 1)
- _roomPresenceGuy = true;
- else
- _roomPresenceEva = true;
- }
-
- _currBitIndex = 10;
-}
-
-/**
- * Engine function - Check who is in the Purple Room
- * @remarks Originally called 'quelq2'
- */
-void MortevielleEngine::setPresencePurpleRoom() {
- if (_place == PURPLE_ROOM)
- _purpleRoomPresenceLeo = true;
- else
- _room9PresenceLeo = true;
-
- _currBitIndex = 10;
-}
-
-/**
- * Engine function - Check who is in the Blue Room
- * @remarks Originally called 'quelq5'
- */
-void MortevielleEngine::setPresenceBlueRoom() {
- _roomPresenceMax = true;
- _currBitIndex = 10;
-}
-
-/**
- * Engine function - Check who is in the Red Room
- * @remarks Originally called 'quelq6'
- */
-void MortevielleEngine::setPresenceRedRoom(int roomId) {
- if (roomId == RED_ROOM)
- _roomPresenceBob = true;
- else if (roomId == GREEN_ROOM2)
- _roomPresencePat = true;
-
- _currBitIndex = 10;
-}
-
-/**
- * Engine function - Check who is in the Dining Room
- * @remarks Originally called 'quelq10'
- */
-int MortevielleEngine::setPresenceDiningRoom(int hour) {
- int retVal = 0;
-
- if ((hour >= 0) && (hour < 8))
- retVal = chlm();
- else {
- int min = 0, max = 0;
- if ((hour > 7) && (hour < 10)) {
- min = 5;
- max = 7;
- } else if ((hour > 9) && (hour < 12)) {
- min = 1;
- max = 4;
- } else if (((hour > 11) && (hour < 15)) || ((hour > 18) && (hour < 21))) {
- min = 6;
- max = 8;
- } else if (((hour > 14) && (hour < 19)) || ((hour > 20) && (hour < 24))) {
- min = 1;
- max = 5;
- }
- retVal = selectCharacters(min, max);
- }
- showPeoplePresent(retVal);
-
- return retVal;
-}
-
-/**
- * Engine function - Check who is in the Bureau
- * @remarks Originally called 'quelq11'
- */
-int MortevielleEngine::setPresenceBureau(int hour) {
- int retVal = 0;
-
- if ((hour >= 0) && (hour < 8))
- retVal = chlm();
- else {
- int min = 0, max = 0;
- if (((hour > 7) && (hour < 10)) || ((hour > 20) && (hour < 24))) {
- min = 1;
- max = 3;
- } else if (((hour > 9) && (hour < 12)) || ((hour > 13) && (hour < 19))) {
- min = 1;
- max = 4;
- } else if (((hour > 11) && (hour < 14)) || ((hour > 18) && (hour < 21))) {
- min = 1;
- max = 2;
- }
- retVal = selectCharacters(min, max);
- }
- showPeoplePresent(retVal);
-
- return retVal;
-}
-
-/**
- * Engine function - Check who is in the Kitchen
- * @remarks Originally called 'quelq12'
- */
-int MortevielleEngine::setPresenceKitchen() {
- int retVal = chlm();
- showPeoplePresent(retVal);
-
- return retVal;
-}
-
-/**
- * Engine function - Check who is in the Landing
- * @remarks Originally called 'quelq15'
- */
-int MortevielleEngine::setPresenceLanding() {
- bool test = false;
- int rand = 0;
- do {
- rand = getRandomNumber(1, 8);
- test = (((rand == 1) && (_purpleRoomPresenceLeo || _room9PresenceLeo)) ||
- ((rand == 2) && _roomPresencePat) ||
- ((rand == 3) && _roomPresenceGuy) ||
- ((rand == 4) && _roomPresenceEva) ||
- ((rand == 5) && _roomPresenceBob) ||
- ((rand == 6) && _roomPresenceLuc) ||
- ((rand == 7) && _roomPresenceIda) ||
- ((rand == 8) && _roomPresenceMax));
- } while (test);
-
- int retVal = convertCharacterIndexToBitIndex(rand);
- showPeoplePresent(retVal);
-
- return retVal;
-}
-
-/**
- * Engine function - Check who is in the chapel
- * @remarks Originally called 'quelq20'
- */
-int MortevielleEngine::setPresenceChapel(int hour) {
- int retVal = 0;
-
- if (((hour >= 0) && (hour < 10)) || ((hour > 18) && (hour < 24)))
- retVal = chlm();
- else {
- int min = 0, max = 0;
- if ((hour > 9) && (hour < 12)) {
- min = 3;
- max = 7;
- } else if ((hour > 11) && (hour < 18)) {
- min = 1;
- max = 2;
- } else if (hour == 18) {
- min = 2;
- max = 4;
- }
- retVal = selectCharacters(min, max);
- }
- showPeoplePresent(retVal);
-
- return retVal;
-}
-
-/**
- * Engine function - Get the answer after you known a door
- * @remarks Originally called 'frap'
- */
-void MortevielleEngine::getKnockAnswer() {
- int day, hour, minute;
-
- updateHour(day, hour, minute);
- if ((hour >= 0) && (hour < 8))
- g_crep = 190;
- else {
- if (getRandomNumber(1, 100) > 70)
- g_crep = 190;
- else
- g_crep = 147;
- }
-}
-
-/**
- * Engine function - Get Room Presence Bit Index
- * @remarks Originally called 'nouvp'
- */
-int MortevielleEngine::getPresenceBitIndex(int roomId) {
- int bitIndex = 0;
- if (roomId == GREEN_ROOM) {
- if (_roomPresenceLuc)
- bitIndex = 4; // LUC
- if (_roomPresenceIda)
- bitIndex = 2; // IDA
- } else if ( ((roomId == PURPLE_ROOM) && (_purpleRoomPresenceLeo))
- || ((roomId == ROOM9) && (_room9PresenceLeo)))
- bitIndex = 128; // LEO
- else if (roomId == DARKBLUE_ROOM) {
- if (_roomPresenceGuy)
- bitIndex = 32; // GUY
- if (_roomPresenceEva)
- bitIndex = 16; // EVA
- } else if ((roomId == BLUE_ROOM) && (_roomPresenceMax))
- bitIndex = 1; // MAX
- else if ((roomId == RED_ROOM) && (_roomPresenceBob))
- bitIndex = 8; // BOB
- else if ((roomId == GREEN_ROOM2) && (_roomPresencePat))
- bitIndex = 64; // PAT
- else if ( ((roomId == TOILETS) && (_toiletsPresenceBobMax))
- || ((roomId == BATHROOM) && (_bathRoomPresenceBobMax)) )
- bitIndex = 9; // BOB + MAX
-
- if (bitIndex != 9)
- showPeoplePresent(bitIndex);
-
- return bitIndex;
-}
-
-/**
- * Engine function - Convert bit index to character index
- * @remarks Originally called 'tip'
- */
-int convertBitIndexToCharacterIndex(int bitIndex) {
- int retVal = 0;
-
- if (bitIndex == 128)
- retVal = 1;
- else if (bitIndex == 64)
- retVal = 2;
- else if (bitIndex == 32)
- retVal = 3;
- else if (bitIndex == 16)
- retVal = 4;
- else if (bitIndex == 8)
- retVal = 5;
- else if (bitIndex == 4)
- retVal = 6;
- else if (bitIndex == 2)
- retVal = 7;
- else if (bitIndex == 1)
- retVal = 8;
-
- return retVal;
-}
-
-
void ecfren(int &p, int &rand, int cf, int roomId) {
if (roomId == OWN_ROOM)
g_vm->displayAloneText();
@@ -1337,198 +554,6 @@ void resetVariables() {
init_nbrepm();
}
-/**
- * Engine function - initGame
- * @remarks Originally called 'dprog'
- */
-void MortevielleEngine::initGame() {
- _place = MANOR_FRONT;
- g_jh = 0;
- if (!g_s._alreadyEnteredManor)
- _blo = true;
- g_t = kTime1;
- g_mh = readclock();
-}
-
-/**
- * Engine function - Set Random Presence - Green Room
- * @remarks Originally called 'pl1'
- */
-void MortevielleEngine::setRandomPresenceGreenRoom(int cf) {
- if ( ((_place == GREEN_ROOM) && (!_roomPresenceLuc) && (!_roomPresenceIda))
- || ((_place == DARKBLUE_ROOM) && (!_roomPresenceGuy) && (!_roomPresenceEva)) ) {
- int p = getPresenceStatsGreenRoom();
- int rand;
- phaz(rand, p, cf);
-
- if (rand > p)
- displayAloneText();
- else
- setPresenceGreenRoom(_place);
- }
-}
-
-/**
- * Engine function - Set Random Presence - Purple Room
- * @remarks Originally called 'pl2'
- */
-void MortevielleEngine::setRandomPresencePurpleRoom(int cf) {
- if (!_purpleRoomPresenceLeo) {
- int p = getPresenceStatsPurpleRoom();
- int rand;
- phaz(rand, p, cf);
-
- if (rand > p)
- displayAloneText();
- else
- setPresencePurpleRoom();
- }
-}
-
-/**
- * Engine function - Set Random Presence - Blue Room
- * @remarks Originally called 'pl5'
- */
-void MortevielleEngine::setRandomPresenceBlueRoom(int cf) {
- if (!_roomPresenceMax) {
- int p = getPresenceStatsBlueRoom();
- int rand;
-
- phaz(rand, p, cf);
-
- if (rand > p)
- displayAloneText();
- else
- setPresenceBlueRoom();
- }
-}
-
-/**
- * Engine function - Set Random Presence - Red Room
- * @remarks Originally called 'pl6'
- */
-void MortevielleEngine::setRandomPresenceRedRoom(int cf) {
- if ( ((_place == RED_ROOM) && (!_roomPresenceBob))
- || ((_place == GREEN_ROOM2) && (!_roomPresencePat)) ) {
- int p = getPresenceStatsRedRoom();
- int rand;
-
- phaz(rand, p, cf);
-
- if (rand > p)
- displayAloneText();
- else
- setPresenceRedRoom(_place);
- }
-}
-
-/**
- * Engine function - Set Random Presence - Room 9
- * @remarks Originally called 'pl9'
- */
-void MortevielleEngine::setRandomPresenceRoom9(int cf) {
- if (!_room9PresenceLeo) {
- cf = -10;
- int p, rand;
- phaz(rand, p, cf);
-
- if (rand > p)
- displayAloneText();
- else
- setPresencePurpleRoom();
- }
-}
-
-/**
- * Engine function - Set Random Presence - Dining Room
- * @remarks Originally called 'pl10'
- */
-void MortevielleEngine::setRandomPresenceDiningRoom(int cf) {
- int h, rand;
- int p = getPresenceStatsDiningRoom(h);
- phaz(rand, p, cf);
-
- if (rand > p)
- displayAloneText();
- else
- setPresenceDiningRoom(h);
-}
-
-/**
- * Engine function - Set Random Presence - Bureau
- * @remarks Originally called 'pl11'
- */
-void MortevielleEngine::setRandomPresenceBureau(int cf) {
- int h, rand;
-
- int p = getPresenceStatsBureau(h);
- phaz(rand, p, cf);
- if (rand > p)
- displayAloneText();
- else
- setPresenceBureau(h);
-}
-
-/**
- * Engine function - Set Random Presence - Kitchen
- * @remarks Originally called 'pl12'
- */
-void MortevielleEngine::setRandomPresenceKitchen(int cf) {
- int p, rand;
-
- p = getPresenceStatsKitchen();
- phaz(rand, p, cf);
- if (rand > p)
- displayAloneText();
- else
- setPresenceKitchen();
-}
-
-/**
- * Engine function - Set Random Presence - Attic / Cellar
- * @remarks Originally called 'pl13'
- */
-void MortevielleEngine::setRandomPresenceAttic(int cf) {
- int p, rand;
-
- p = getPresenceStatsAttic();
- phaz(rand, p, cf);
- if (rand > p)
- displayAloneText();
- else
- setPresenceKitchen();
-}
-
-/**
- * Engine function - Set Random Presence - Landing
- * @remarks Originally called 'pl15'
- */
-void MortevielleEngine::setRandomPresenceLanding(int cf) {
- int p, rand;
-
- p = getPresenceStatsLanding();
- phaz(rand, p, cf);
- if (rand > p)
- displayAloneText();
- else
- setPresenceLanding();
-}
-
-/**
- * Engine function - Set Random Presence - Chapel
- * @remarks Originally called 'pl20'
- */
-void MortevielleEngine::setRandomPresenceChapel(int cf) {
- int h, rand;
-
- int p = getPresenceStatsChapel(h);
- phaz(rand, p, cf);
- if (rand > p)
- displayAloneText();
- else
- setPresenceChapel(h);
-}
-
int t11(int roomId) {
int retVal = 0;
int p, rand;
@@ -1593,7 +618,7 @@ void cavegre() {
g_s._faithScore += 2;
if (g_s._faithScore > 69)
g_s._faithScore += (g_s._faithScore / 10);
- clearScreenType3();
+ g_vm->clearScreenType3();
g_vm->prepareScreenType2();
ecr3(g_vm->getEngineString(S_SOMEONE_ENTERS));
int rand = (getRandomNumber(0, 4)) - 2;
@@ -1602,7 +627,7 @@ void cavegre() {
// The original was doing here a useless loop.
// It has been removed
- clearScreenType3();
+ g_vm->clearScreenType3();
g_vm->displayAloneText();
}
@@ -1636,43 +661,12 @@ void aniof(int ouf, int num) {
g_vm->prepareScreenType1();
}
-/**
- * Start music or speech
- * @remarks Originally called 'musique'
- */
-void MortevielleEngine::startMusicOrSpeech(int so) {
- if (so == 0) {
- /* musik(0) */
- ;
- } else if ((g_prebru == 0) && (!g_s._alreadyEnteredManor)) {
- // Type 1: Speech
- _speechManager.startSpeech(10, 1, 1);
- ++g_prebru;
- } else {
- if (((g_s._currPlace == MOUNTAIN) || (g_s._currPlace == MANOR_FRONT) || (g_s._currPlace == MANOR_BACK)) && (getRandomNumber(1, 3) == 2))
- // Type 1: Speech
- _speechManager.startSpeech(9, getRandomNumber(2, 4), 1);
- else if ((g_s._currPlace == CHAPEL) && (getRandomNumber(1, 2) == 1))
- // Type 1: Speech
- _speechManager.startSpeech(8, 1, 1);
- else if ((g_s._currPlace == WELL) && (getRandomNumber(1, 2) == 2))
- // Type 1: Speech
- _speechManager.startSpeech(12, 1, 1);
- else if (g_s._currPlace == INSIDE_WELL)
- // Type 1: Speech
- _speechManager.startSpeech(13, 1, 1);
- else
- // Type 2 : music
- _speechManager.startSpeech(getRandomNumber(1, 17), 1, 2);
- }
-}
-
/* NIVEAU 9 */
void dessin(int ad) {
if (ad != 0)
dessine(g_ades, ((ad % 160) * 2), (ad / 160));
else {
- clearScreenType1();
+ g_vm->clearScreenType1();
if (g_caff > 99) {
dessine(g_ades, 60, 33);
g_vm->_screenSurface.drawBox(118, 32, 291, 121, 15); // Medium box
@@ -1762,7 +756,7 @@ void tinke() {
g_vm->_minute = 30;
drawClock();
}
- if (y_s < 12)
+ if (g_vm->_mouse.y_s < 12)
return;
if (!g_vm->_blo) {
@@ -1834,12 +828,12 @@ void tinke() {
g_vm->_brt = true;
g_hdb = readclock();
if (getRandomNumber(1, 5) < 5) {
- clearScreenType3();
+ g_vm->clearScreenType3();
g_vm->prepareScreenType2();
ecr3(g_vm->getEngineString(S_HEAR_NOISE));
int rand = (getRandomNumber(0, 4)) - 2;
g_vm->_speechManager.startSpeech(1, rand, 1);
- clearScreenType3();
+ g_vm->clearScreenType3();
}
}
}
@@ -1862,7 +856,7 @@ void tinke() {
void fenat(char ans) {
int coul;
- hideMouse();
+ g_vm->_mouse.hideMouse();
if (g_vm->_currGraphicalDevice == MODE_CGA)
coul = 2;
else if (g_vm->_currGraphicalDevice == MODE_HERCULES)
@@ -1872,7 +866,7 @@ void fenat(char ans) {
g_vm->_screenSurface.writeCharacter(Common::Point(306, 193), ord(ans), coul);
g_vm->_screenSurface.drawBox(300, 191, 16, 8, 15);
- showMouse();
+ g_vm->_mouse.showMouse();
}
@@ -1887,14 +881,14 @@ void tkey1(bool d) {
bool quest = false;
int x, y, c;
- hideMouse();
+ g_vm->_mouse.hideMouse();
fenat('K');
// Wait for release from any key or mouse button
while (g_vm->keyPressed())
g_key = testou();
do {
- getMousePos_(x, y, c);
+ g_vm->_mouse.getMousePos_(x, y, c);
g_vm->keyPressed();
} while (c != 0);
@@ -1903,13 +897,13 @@ void tkey1(bool d) {
if (d)
tinke();
quest = g_vm->keyPressed();
- getMousePos_(x, y, c);
+ g_vm->_mouse.getMousePos_(x, y, c);
CHECK_QUIT;
} while (!(quest || (c != 0) || (d && g_vm->_anyone)));
if (quest)
testou();
g_vm->setMouseClick(false);
- showMouse();
+ g_vm->_mouse.showMouse();
}
/* NIVEAU 7 */
@@ -1929,30 +923,6 @@ void affrep() {
g_crep = g_s._currPlace;
}
-/**
- * Engine function - You lose!
- * @remarks Originally called 'tperd'
- */
-void MortevielleEngine::loseGame() {
- initouv();
- g_ment = 0;
- g_iouv = 0;
- g_mchai = 0;
- _menu.unsetSearchMenu();
- if (!_blo)
- t11(MANOR_FRONT);
-
- _loseGame = true;
- clearScreenType1();
- _screenSurface.drawBox(60, 35, 400, 50, 15);
- repon(9, g_crep);
- clearScreenType2();
- clearScreenType3();
- _col = false;
- _syn = false;
- _okdes = false;
-}
-
void tsort() {
if ((g_iouv > 0) && (g_s._currPlace != 0)) {
@@ -2000,30 +970,6 @@ void st4(int ob) {
}
}
-/**
- * Engine function - Check inventory for a given object
- * @remarks Originally called 'cherjer'
- */
-bool MortevielleEngine::checkInventory(int objectId) {
- bool retVal = false;
- for (int i = 1; i <= 6; ++i)
- retVal = (retVal || (ord(g_s._sjer[i]) == objectId));
-
- if (g_s._selectedObjectId == objectId)
- retVal = true;
-
- return retVal;
-}
-
-/**
- * Engine function - Display Dining Room
- * @remarks Originally called 'st1sama'
- */
-void MortevielleEngine::displayDiningRoom() {
- g_s._currPlace = DINING_ROOM;
- affrep();
-}
-
void modinv() {
int r;
Common::String nomp;
@@ -2047,38 +993,6 @@ void modinv() {
}
}
-void sparl(float adr, float rep) {
- const int haut[9] = { 0, 0, 1, -3, 6, -2, 2, 7, -1 };
- int key, repint;
-
- repint = abs((int)rep);
- hideMouse();
- Common::String tmpStr = deline(repint + kDialogStringIndex);
- displayStr(tmpStr, 230, 4, 65, 24, 5);
- f3f8::draw();
-
- key = 0;
- do {
- g_vm->_speechManager.startSpeech(repint, haut[g_caff - 69], 0);
- f3f8::waitForF3F8(key);
- CHECK_QUIT;
- } while (key != 66);
- hirs();
- showMouse();
-}
-
-/**
- * Engine function - End of Search: reset globals
- * @remarks Originally called 'finfouill'
- */
-void endSearch() {
- g_vm->_heroSearching = false;
- g_vm->_obpart = false;
- g_cs = 0;
- g_is = 0;
- g_vm->_menu.unsetSearchMenu();
-}
-
void mennor() {
g_vm->_menu.menuUp(g_msg[3]);
}
@@ -2115,92 +1029,6 @@ void ajjer(int ob) {
g_crep = 139;
}
-/**
- * Engine function - Go to Dining room
- * @remarks Originally called 't1sama'
- */
-void MortevielleEngine::gotoDiningRoom() {
- int day, hour, minute;
-
- updateHour(day, hour, minute);
- if ((hour < 5) && (g_s._currPlace > ROOM18)) {
- if (!checkInventory(137)) { //You don't have the keys, and it's late
- g_crep = 1511;
- loseGame();
- } else
- displayDiningRoom();
- } else if (!g_s._alreadyEnteredManor) { //Is it your first time?
- _currBitIndex = 255; // Everybody is present
- showPeoplePresent(_currBitIndex);
- g_caff = 77;
- afdes();
- _screenSurface.drawBox(223, 47, 155, 91, 15);
- repon(2, 33);
- tkey1(false);
- mennor();
- hideMouse();
- hirs();
- premtet();
- sparl(0, 140);
- drawRightFrame();
- drawClock();
- showMouse();
- g_s._currPlace = OWN_ROOM;
- affrep();
- resetPresenceInRooms(DINING_ROOM);
- if (!_blo)
- minute = t11(OWN_ROOM);
- _currBitIndex = 0;
- g_mpers = 0;
- g_s._alreadyEnteredManor = true;
- } else
- displayDiningRoom();
-}
-
-/**
- * Engine function - Check Manor distance (in the mountains)
- * @remarks Originally called 't1neig'
- */
-void MortevielleEngine::checkManorDistance() {
- ++_manorDistance;
- if (_manorDistance > 2) {
- g_crep = 1506;
- loseGame();
- } else {
- _okdes = true;
- g_s._currPlace = MOUNTAIN;
- affrep();
- }
-}
-
-/**
- * Engine function - Go to Manor front
- * @remarks Originally called 't1deva'
- */
-void MortevielleEngine::gotoManorFront() {
- _manorDistance = 0;
- g_s._currPlace = MANOR_FRONT;
- affrep();
-}
-
-/**
- * Engine function - Go to Manor back
- * @remarks Originally called 't1derr'
- */
-void MortevielleEngine::gotoManorBack() {
- g_s._currPlace = MANOR_BACK;
- affrep();
-}
-
-/**
- * Engine function - Dead : Flooded in Well
- * @remarks Originally called 't1deau'
- */
-void MortevielleEngine::floodedInWell() {
- g_crep = 1503;
- loseGame();
-}
-
void tctrm() {
repon(2, (3000 + g_ctrm));
g_ctrm = 0;
@@ -2211,7 +1039,7 @@ void quelquun() {
if (g_vm->_menu._menuDisplayed)
g_vm->_menu.eraseMenu();
- endSearch();
+ g_vm->endSearch();
g_crep = 997;
L1:
if (!g_vm->_hiddenHero) {
@@ -2231,7 +1059,7 @@ L1:
g_s._faithScore += 3 * (g_s._faithScore / 10);
tsort();
g_vm->_menu.setDestinationMenuText(LANDING);
- int cx = convertBitIndexToCharacterIndex(g_vm->_currBitIndex);
+ int cx = g_vm->convertBitIndexToCharacterIndex(g_vm->_currBitIndex);
g_caff = 69 + cx;
g_crep = g_caff;
g_msg[3] = MENU_DISCUSS;
@@ -2247,7 +1075,7 @@ L1:
repon(2, 136);
int rand = (getRandomNumber(0, 4)) - 2;
g_vm->_speechManager.startSpeech(3, rand, 1);
- clearScreenType2();
+ g_vm->clearScreenType2();
g_vm->displayAloneText();
debloc(21);
affrep();
@@ -2278,7 +1106,7 @@ void tsuiv() {
g_s._faithScore += 2;
} else {
affrep();
- endSearch();
+ g_vm->endSearch();
if (cx > 9)
g_crep = 131;
}
@@ -2297,11 +1125,11 @@ void tfleche() {
touch = '\0';
do {
- moveMouse(qust, touch);
+ g_vm->_mouse.moveMouse(qust, touch);
CHECK_QUIT;
if (g_vm->getMouseClick())
- inRect = (x_s < 256 * g_res) && (y_s < 176) && (y_s > 12);
+ inRect = (g_vm->_mouse.x_s < 256 * g_res) && (g_vm->_mouse.y_s < 176) && (g_vm->_mouse.y_s > 12);
tinke();
} while (!(qust || inRect || g_vm->_anyone));
@@ -2313,8 +1141,8 @@ void tfleche() {
g_vm->_keyPressedEsc = true;
if (inRect) {
- g_x = x_s;
- g_y = y_s;
+ g_x = g_vm->_mouse.x_s;
+ g_y = g_vm->_mouse.y_s;
}
}
@@ -2463,221 +1291,4 @@ void aldepl() {
Alert::show(g_vm->getEngineString(S_USE_DEP_MENU), 1);
}
-/**
- * Engine function - Change Graphical Device
- * @remarks Originally called 'change_gd'
- */
-void MortevielleEngine::changeGraphicalDevice(int newDevice) {
- hideMouse();
- _currGraphicalDevice = newDevice;
- hirs();
- initMouse();
- showMouse();
- drawRightFrame();
- tinke();
- drawClock();
- if (_currBitIndex != 0)
- showPeoplePresent(_currBitIndex);
- else
- displayAloneText();
- clearScreenType2();
- clearScreenType3();
- g_maff = 68;
- afdes();
- repon(2, g_crep);
- _menu.displayMenu();
-}
-
-/**
- * Called when a savegame has been loaded.
- * @remarks Originally called 'antegame'
- */
-void MortevielleEngine::gameLoaded() {
- hideMouse();
- _menu._menuDisplayed = false;
- _loseGame = true;
- _anyone = false;
- _okdes = true;
- _col = false;
- _hiddenHero = false;
- _brt = false;
- g_maff = 68;
- g_mnumo = OPCODE_NONE;
- g_prebru = 0;
- g_x = 0;
- g_y = 0;
- g_num = 0;
- g_hdb = 0;
- g_hfb = 0;
- g_cs = 0;
- g_is = 0;
- g_ment = 0;
- _syn = true;
- _heroSearching = true;
- g_mchai = 0;
- _manorDistance = 0;
- initouv();
- g_iouv = 0;
- g_dobj = 0;
- affrep();
- _hintPctMessage = deline(580);
-
- _okdes = false;
- _endGame = true;
- _loseGame = false;
- _heroSearching = false;
-
- displayAloneText();
- tinke();
- drawClock();
- afdes();
- repon(2, g_crep);
- clearScreenType3();
- _endGame = false;
- _menu.setDestinationMenuText(g_s._currPlace);
- modinv();
- if (g_s._selectedObjectId != 0)
- modobj(g_s._selectedObjectId + 400);
- showMouse();
-}
-
-/**
- * Engine function - Handle OpCodes
- * @remarks Originally called 'tsitu'
- */
-void MortevielleEngine::handleOpcode() {
- if (!_col)
- clearScreenType2();
- _syn = false;
- _keyPressedEsc = false;
- if (!_anyone) {
- if (_brt) {
- if ((g_msg[3] == MENU_MOVE) || (g_msg[4] == OPCODE_LEAVE) || (g_msg[4] == OPCODE_SLEEP) || (g_msg[4] == OPCODE_EAT)) {
- g_ctrm = 4;
- mennor();
- return;
- }
- }
- if (g_msg[3] == MENU_MOVE)
- fctMove();
- if (g_msg[3] == MENU_DISCUSS)
- fctDiscuss();
- if (g_msg[3] == MENU_INVENTORY)
- fctInventoryTake();
- if (g_msg[4] == OPCODE_ATTACH)
- fctAttach();
- if (g_msg[4] == OPCODE_WAIT)
- fctWait();
- if (g_msg[4] == OPCODE_FORCE)
- fctForce();
- if (g_msg[4] == OPCODE_SLEEP)
- fctSleep();
- if (g_msg[4] == OPCODE_LISTEN)
- fctListen();
- if (g_msg[4] == OPCODE_ENTER)
- fctEnter();
- if (g_msg[4] == OPCODE_CLOSE)
- fctClose();
- if (g_msg[4] == OPCODE_SEARCH)
- fctSearch();
- if (g_msg[4] == OPCODE_KNOCK)
- fctKnock();
- if (g_msg[4] == OPCODE_SCRATCH)
- fctScratch();
- if (g_msg[4] == OPCODE_READ)
- fctRead();
- if (g_msg[4] == OPCODE_EAT)
- fctEat();
- if (g_msg[4] == OPCODE_PLACE)
- fctPlace();
- if (g_msg[4] == OPCODE_OPEN)
- fctOpen();
- if (g_msg[4] == OPCODE_TAKE)
- fctTake();
- if (g_msg[4] == OPCODE_LOOK)
- fctLook();
- if (g_msg[4] == OPCODE_SMELL)
- fctSmell();
- if (g_msg[4] == OPCODE_SOUND)
- fctSound();
- if (g_msg[4] == OPCODE_LEAVE)
- fctLeave();
- if (g_msg[4] == OPCODE_LIFT)
- fctLift();
- if (g_msg[4] == OPCODE_TURN)
- fctTurn();
- if (g_msg[4] == OPCODE_SSEARCH)
- fctSelfSearch();
- if (g_msg[4] == OPCODE_SREAD)
- fctSelfRead();
- if (g_msg[4] == OPCODE_SPUT)
- fctSelfPut();
- if (g_msg[4] == OPCODE_SLOOK)
- fctSelftLook();
- _hiddenHero = false;
-
- if (g_msg[4] == OPCODE_SHIDE)
- fctSelfHide();
- } else {
- if (_anyone) {
- quelquun();
- _anyone = false;
- mennor();
- return;
- }
- }
- int hour, day, minute;
- updateHour(day, hour, minute);
- if ((((hour == 12) || (hour == 13) || (hour == 19)) && (g_s._currPlace != 10)) ||
- ((hour > 0) && (hour < 6) && (g_s._currPlace != 0)))
- ++g_s._faithScore;
- if (((g_s._currPlace < CRYPT) || (g_s._currPlace > MOUNTAIN)) && (g_s._currPlace != INSIDE_WELL)
- && (g_s._currPlace != OWN_ROOM) && (g_s._selectedObjectId != 152) && (!_loseGame)) {
- if ((g_s._faithScore > 99) && (hour > 8) && (hour < 16)) {
- g_crep = 1501;
- loseGame();
- }
- if ((g_s._faithScore > 99) && (hour > 0) && (hour < 9)) {
- g_crep = 1508;
- loseGame();
- }
- if ((day > 1) && (hour > 8) && (!_loseGame)) {
- g_crep = 1502;
- loseGame();
- }
- }
- mennor();
-}
-
-/**
- * Engine function - Transform time into a char
- * @remarks Originally called 'tmaj3'
- */
-void MortevielleEngine::hourToChar() {
- int day, hour, minute;
-
- g_vm->updateHour(day, hour, minute);
- if (minute == 30)
- minute = 1;
- hour += day * 24;
- minute += hour * 2;
- g_s._fullHour = chr(minute);
-}
-
-/**
- * Engine function - extract time from a char
- * @remarks Originally called 'theure'
- */
-void MortevielleEngine::charToHour() {
- int fullHour = ord(g_s._fullHour);
- int tmpHour = fullHour % 48;
- g_vm->_currDay = fullHour / 48;
- g_vm->_currHalfHour = tmpHour % 2;
- g_vm->_currHour = tmpHour / 2;
- g_vm->_hour = g_vm->_currHour;
- if (g_vm->_currHalfHour == 1)
- g_vm->_minute = 30;
- else
- g_vm->_minute = 0;
-}
} // End of namespace Mortevielle
diff --git a/engines/mortevielle/mor.h b/engines/mortevielle/mor.h
index 528039c6ba..0cd467c177 100644
--- a/engines/mortevielle/mor.h
+++ b/engines/mortevielle/mor.h
@@ -42,9 +42,7 @@ static const int _actionMenu[12] = { OPCODE_NONE,
OPCODE_PLACE, OPCODE_OPEN, OPCODE_LEAVE
};
-/* NIVEAU 15 */
extern void copcha();
-extern bool isMouseIn(rectangle r);
extern void outbloc(int n, pattern p, nhom *pal);
extern void writepal(int n);
extern void pictout(int seg, int dep, int x, int y);
@@ -60,15 +58,10 @@ extern void drawRightFrame();
/* NIVEAU 13 */
extern void text1(int x, int y, int nb, int m);
extern void initouv();
-extern void clearScreenType1();
-extern void clearScreenType2();
-extern void clearScreenType3();
-extern void clearScreenType10();
extern void ecr2(Common::String str_);
extern void ecr3(Common::String text);
extern void stop();
extern void paint_rect(int x, int y, int dx, int dy);
-extern int convertCharacterIndexToBitIndex(int characterIndex);
/* NIVEAU 12 */
extern void modobj(int m);
extern void repon(int f, int m);
@@ -78,7 +71,6 @@ extern void drawClock();
* NIVEAU 11 *
*************/
extern void debloc(int roomId);
-extern int convertBitIndexToCharacterIndex(int bitIndex);
extern void ecfren(int &p, int &rand, int cf, int roomId);
extern void becfren(int roomId);
/* NIVEAU 10 */
@@ -105,8 +97,6 @@ extern void tsort();
extern void st4(int ob);
extern void displayDiningRoom();
extern void modinv();
-extern void sparl(float adr, float rep);
-extern void endSearch();
extern void mennor();
extern void premtet();
/* NIVEAU 5 */
diff --git a/engines/mortevielle/mortevielle.cpp b/engines/mortevielle/mortevielle.cpp
index 3667a135c1..f376e57d8d 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);
- x_s = event.mouse.x;
- y_s = event.mouse.y / 2;
+ g_vm->_mouse.x_s = event.mouse.x;
+ g_vm->_mouse.y_s = event.mouse.y / 2;
if (event.type == Common::EVENT_LBUTTONDOWN)
_mouseClick = true;
@@ -550,7 +550,7 @@ void MortevielleEngine::mainGame() {
initGame();
hirs();
drawRightFrame();
- showMouse();
+ g_vm->_mouse.showMouse();
// Loop to play the game
do {
@@ -603,7 +603,7 @@ void MortevielleEngine::handleAction() {
do {
_menu.mdn();
tinke();
- moveMouse(funct, inkey);
+ g_vm->_mouse.moveMouse(funct, inkey);
CHECK_QUIT;
temps = temps + 1;
} while (!((_menu._menuSelected) || (temps > lim) || (funct) || (_anyone)));
@@ -652,7 +652,7 @@ void MortevielleEngine::handleAction() {
g_mnumo = g_msg[4];
if (!_anyone) {
if ((_heroSearching) || (_obpart)) {
- if (y_s < 12)
+ if (g_vm->_mouse.y_s < 12)
return;
if ((g_msg[4] == OPCODE_SOUND) || (g_msg[4] == OPCODE_LIFT)) {
@@ -705,4 +705,1384 @@ void MortevielleEngine::loadPlaces() {
f.close();
}
+/**
+ * Set Text Color
+ * @remarks Originally called 'text_color'
+ */
+void MortevielleEngine::setTextColor(int col) {
+ _textColor = col;
+}
+
+/**
+ * Prepare screen - Type 1!
+ * @remarks Originally called 'ecrf1'
+ */
+void MortevielleEngine::prepareScreenType1() {
+ // Large drawing
+ _screenSurface.drawBox(0, 11, 512, 163, 15);
+}
+
+/**
+ * Prepare room - Type 2!
+ * @remarks Originally called 'ecrf2'
+ */
+void MortevielleEngine::prepareScreenType2() {
+ setTextColor(5);
+}
+
+/**
+ * Prepare room - Type 3!
+ * @remarks Originally called 'ecrf7'
+ */
+void MortevielleEngine::prepareScreenType3() {
+ setTextColor(4);
+}
+
+/**
+ * Engine function - Update hour
+ * @remarks Originally called 'calch'
+ */
+void MortevielleEngine::updateHour(int &day, int &hour, int &minute) {
+ int newHour = readclock();
+ int th = g_jh + ((newHour - g_mh) / g_t);
+ minute = ((th % 2) + _currHalfHour) * 30;
+ hour = ((uint)th >> 1) + _currHour;
+ if (minute == 60) {
+ minute = 0;
+ ++hour;
+ }
+ day = (hour / 24) + _currDay;
+ hour = hour - ((day - _currDay) * 24);
+}
+
+/**
+ * Engine function - Convert character index to bit index
+ * @remarks Originally called 'conv'
+ */
+int MortevielleEngine::convertCharacterIndexToBitIndex(int characterIndex) {
+ return 128 >> (characterIndex - 1);
+}
+
+/**
+ * Engine function - Convert bit index to character index
+ * @remarks Originally called 'tip'
+ */
+int MortevielleEngine::convertBitIndexToCharacterIndex(int bitIndex) {
+ int retVal = 0;
+
+ if (bitIndex == 128)
+ retVal = 1;
+ else if (bitIndex == 64)
+ retVal = 2;
+ else if (bitIndex == 32)
+ retVal = 3;
+ else if (bitIndex == 16)
+ retVal = 4;
+ else if (bitIndex == 8)
+ retVal = 5;
+ else if (bitIndex == 4)
+ retVal = 6;
+ else if (bitIndex == 2)
+ retVal = 7;
+ else if (bitIndex == 1)
+ retVal = 8;
+
+ return retVal;
+}
+
+/**
+ * Engine function - Reset presence in other rooms
+ * @remarks Originally called 't5'
+ */
+void MortevielleEngine::resetPresenceInRooms(int roomId) {
+ if (roomId == DINING_ROOM)
+ _blo = false;
+
+ if (roomId != GREEN_ROOM) {
+ _roomPresenceLuc = false;
+ _roomPresenceIda = false;
+ }
+
+ if (roomId != PURPLE_ROOM)
+ _purpleRoomPresenceLeo = false;
+
+ if (roomId != DARKBLUE_ROOM) {
+ _roomPresenceGuy = false;
+ _roomPresenceEva = false;
+ }
+
+ if (roomId != BLUE_ROOM)
+ _roomPresenceMax = false;
+ if (roomId != RED_ROOM)
+ _roomPresenceBob = false;
+ if (roomId != GREEN_ROOM2)
+ _roomPresencePat = false;
+ if (roomId != TOILETS)
+ _toiletsPresenceBobMax = false;
+ if (roomId != BATHROOM)
+ _bathRoomPresenceBobMax = false;
+ if (roomId != ROOM9)
+ _room9PresenceLeo = false;
+}
+
+/**
+ * Engine function - Show the people present in the given room
+ * @remarks Originally called 'affper'
+ */
+void MortevielleEngine::showPeoplePresent(int bitIndex) {
+ int xp = 580 - (_screenSurface.getStringWidth("LEO") / 2);
+
+ for (int i = 1; i <= 8; ++i)
+ _menu.disableMenuItem(_menu._discussMenu[i]);
+
+ clearScreenType10();
+ if ((bitIndex & 128) == 128) {
+ _screenSurface.putxy(xp, 24);
+ _screenSurface.drawString("LEO", 4);
+ _menu.enableMenuItem(_menu._discussMenu[1]);
+ }
+ if ((bitIndex & 64) == 64) {
+ _screenSurface.putxy(xp, 32);
+ _screenSurface.drawString("PAT", 4);
+ _menu.enableMenuItem(_menu._discussMenu[2]);
+ }
+ if ((bitIndex & 32) == 32) {
+ _screenSurface.putxy(xp, 40);
+ _screenSurface.drawString("GUY", 4);
+ _menu.enableMenuItem(_menu._discussMenu[3]);
+ }
+ if ((bitIndex & 16) == 16) {
+ _screenSurface.putxy(xp, 48);
+ _screenSurface.drawString("EVA", 4);
+ _menu.enableMenuItem(_menu._discussMenu[4]);
+ }
+ if ((bitIndex & 8) == 8) {
+ _screenSurface.putxy(xp, 56);
+ _screenSurface.drawString("BOB", 4);
+ _menu.enableMenuItem(_menu._discussMenu[5]);
+ }
+ if ((bitIndex & 4) == 4) {
+ _screenSurface.putxy(xp, 64);
+ _screenSurface.drawString("LUC", 4);
+ _menu.enableMenuItem(_menu._discussMenu[6]);
+ }
+ if ((bitIndex & 2) == 2) {
+ _screenSurface.putxy(xp, 72);
+ _screenSurface.drawString("IDA", 4);
+ _menu.enableMenuItem(_menu._discussMenu[7]);
+ }
+ if ((bitIndex & 1) == 1) {
+ _screenSurface.putxy(xp, 80);
+ _screenSurface.drawString("MAX", 4);
+ _menu.enableMenuItem(_menu._discussMenu[8]);
+ }
+ _currBitIndex = bitIndex;
+}
+
+/**
+ * Engine function - Select random characters
+ * @remarks Originally called 'choix'
+ */
+int MortevielleEngine::selectCharacters(int min, int max) {
+ bool invertSelection = false;
+ int rand = getRandomNumber(min, max);
+
+ if (rand > 4) {
+ rand = 8 - rand;
+ invertSelection = true;
+ }
+
+ int i = 0;
+ int retVal = 0;
+ while (i < rand) {
+ int charIndex = getRandomNumber(1, 8);
+ int charBitIndex = convertCharacterIndexToBitIndex(charIndex);
+ if ((retVal & charBitIndex) != charBitIndex) {
+ ++i;
+ retVal |= charBitIndex;
+ }
+ }
+ if (invertSelection)
+ retVal = 255 - retVal;
+
+ return retVal;
+}
+
+/**
+ * Engine function - Get Presence Statistics - Green Room
+ * @remarks Originally called 'cpl1'
+ */
+int MortevielleEngine::getPresenceStatsGreenRoom() {
+ int day, hour, minute;
+ int retVal = 0;
+
+ updateHour(day, hour, minute);
+ // The original uses an || instead of an &&, resulting
+ // in an always true condition. Based on the other tests,
+ // and on other scenes, we use an && instead.
+ if ((hour > 7) && (hour < 11))
+ retVal = 25;
+ else if ((hour > 10) && (hour < 14))
+ retVal = 35;
+ else if ((hour > 13) && (hour < 16))
+ retVal = 50;
+ else if ((hour > 15) && (hour < 18))
+ retVal = 5;
+ else if ((hour > 17) && (hour < 22))
+ retVal = 35;
+ else if ((hour > 21) && (hour < 24))
+ retVal = 50;
+ else if ((hour >= 0) && (hour < 8))
+ retVal = 70;
+
+ _menu.mdn();
+
+ return retVal;
+}
+/**
+ * Engine function - Get Presence Statistics - Purple Room
+ * @remarks Originally called 'cpl2'
+ */
+int MortevielleEngine::getPresenceStatsPurpleRoom() {
+ int day, hour, minute;
+ int retVal = 0;
+
+ updateHour(day, hour, minute);
+ if ((hour > 7) && (hour < 11))
+ retVal = -2;
+ else if (hour == 11)
+ retVal = 100;
+ else if ((hour > 11) && (hour < 23))
+ retVal = 10;
+ else if (hour == 23)
+ retVal = 20;
+ else if ((hour >= 0) && (hour < 8))
+ retVal = 50;
+
+ return retVal;
+}
+
+/**
+ * Engine function - Get Presence Statistics - Toilets
+ * @remarks Originally called 'cpl3'
+ */
+int MortevielleEngine::getPresenceStatsToilets() {
+ int day, hour, minute;
+ int retVal = 0;
+
+ updateHour(day, hour, minute);
+ if (((hour > 8) && (hour < 10)) || ((hour > 19) && (hour < 24)))
+ retVal = 34;
+ else if (((hour > 9) && (hour < 20)) || ((hour >= 0) && (hour < 9)))
+ retVal = 0;
+
+ return retVal;
+}
+
+/**
+ * Engine function - Get Presence Statistics - Blue Room
+ * @remarks Originally called 'cpl5'
+ */
+int MortevielleEngine::getPresenceStatsBlueRoom() {
+ int day, hour, minute;
+ int retVal = 0;
+
+ updateHour(day, hour, minute);
+ if ((hour > 6) && (hour < 10))
+ retVal = 0;
+ else if (hour == 10)
+ retVal = 100;
+ else if ((hour > 10) && (hour < 24))
+ retVal = 15;
+ else if ((hour >= 0) && (hour < 7))
+ retVal = 50;
+
+ return retVal;
+}
+
+/**
+ * Engine function - Get Presence Statistics - Red Room
+ * @remarks Originally called 'cpl6'
+ */
+int MortevielleEngine::getPresenceStatsRedRoom() {
+ int day, hour, minute;
+ int retVal = 0;
+
+ updateHour(day, hour, minute);
+ if (((hour > 7) && (hour < 13)) || ((hour > 17) && (hour < 20)))
+ retVal = -2;
+ else if (((hour > 12) && (hour < 17)) || ((hour > 19) && (hour < 24)))
+ retVal = 35;
+ else if (hour == 17)
+ retVal = 100;
+ else if ((hour >= 0) && (hour < 8))
+ retVal = 60;
+
+ return retVal;
+}
+
+/**
+ * Shows the "you are alone" message in the status area
+ * on the right hand side of the screen
+ * @remarks Originally called 'person'
+ */
+void MortevielleEngine::displayAloneText() {
+ for (int cf = 1; cf <= 8; ++cf)
+ _menu.disableMenuItem(_menu._discussMenu[cf]);
+
+ Common::String sYou = getEngineString(S_YOU);
+ Common::String sAre = getEngineString(S_ARE);
+ Common::String sAlone = getEngineString(S_ALONE);
+
+ clearScreenType10();
+ _screenSurface.putxy(580 - (_screenSurface.getStringWidth(sYou) / 2), 30);
+ _screenSurface.drawString(sYou, 4);
+ _screenSurface.putxy(580 - (_screenSurface.getStringWidth(sAre) / 2), 50);
+ _screenSurface.drawString(sAre, 4);
+ _screenSurface.putxy(580 - (_screenSurface.getStringWidth(sAlone) / 2), 70);
+ _screenSurface.drawString(sAlone, 4);
+
+ _currBitIndex = 0;
+}
+
+/**
+ * Engine function - Get Presence Statistics - Room Bureau
+ * @remarks Originally called 'cpl10'
+ */
+int MortevielleEngine::getPresenceStatsDiningRoom(int &hour) {
+ int day, minute;
+
+ int retVal = 0;
+ updateHour(day, hour, minute);
+ if (((hour > 7) && (hour < 11)) || ((hour > 11) && (hour < 14)) || ((hour > 18) && (hour < 21)))
+ retVal = 100;
+ else if ((hour == 11) || ((hour > 20) && (hour < 24)))
+ retVal = 45;
+ else if (((hour > 13) && (hour < 17)) || (hour == 18))
+ retVal = 35;
+ else if (hour == 17)
+ retVal = 60;
+ else if ((hour >= 0) && (hour < 8))
+ retVal = 5;
+
+ return retVal;
+}
+
+/**
+ * Engine function - Get Presence Statistics - Room Bureau
+ * @remarks Originally called 'cpl11'
+ */
+int MortevielleEngine::getPresenceStatsBureau(int &hour) {
+ int day, minute;
+ int retVal = 0;
+
+ updateHour(day, hour, minute);
+ if (((hour > 8) && (hour < 12)) || ((hour > 20) && (hour < 24)))
+ retVal = 25;
+ else if (((hour > 11) && (hour < 14)) || ((hour > 18) && (hour < 21)))
+ retVal = 5;
+ else if ((hour > 13) && (hour < 17))
+ retVal = 55;
+ else if ((hour > 16) && (hour < 19))
+ retVal = 45;
+ else if ((hour >= 0) && (hour < 9))
+ retVal = 0;
+
+ return retVal;
+}
+
+/**
+ * Engine function - Get Presence Statistics - Room Kitchen
+ * @remarks Originally called 'cpl12'
+ */
+int MortevielleEngine::getPresenceStatsKitchen() {
+ int day, hour, minute;
+ int retVal = 0;
+
+ updateHour(day, hour, minute);
+ if (((hour > 8) && (hour < 15)) || ((hour > 16) && (hour < 22)))
+ retVal = 55;
+ else if (((hour > 14) && (hour < 17)) || ((hour > 21) && (hour < 24)))
+ retVal = 25;
+ else if ((hour >= 0) && (hour < 5))
+ retVal = 0;
+ else if ((hour > 4) && (hour < 9))
+ retVal = 15;
+
+ return retVal;
+}
+
+/**
+ * Engine function - Get Presence Statistics - Room Attic
+ * @remarks Originally called 'cpl13'
+ */
+int MortevielleEngine::getPresenceStatsAttic() {
+ return 0;
+}
+
+/**
+ * Engine function - Get Presence Statistics - Room Landing
+ * @remarks Originally called 'cpl15'
+ */
+int MortevielleEngine::getPresenceStatsLanding() {
+ int day, hour, minute;
+ int retVal = 0;
+
+ updateHour(day, hour, minute);
+ if ((hour > 7) && (hour < 12))
+ retVal = 25;
+ else if ((hour > 11) && (hour < 14))
+ retVal = 0;
+ else if ((hour > 13) && (hour < 18))
+ retVal = 10;
+ else if ((hour > 17) && (hour < 20))
+ retVal = 55;
+ else if ((hour > 19) && (hour < 22))
+ retVal = 5;
+ else if ((hour > 21) && (hour < 24))
+ retVal = 15;
+ else if ((hour >= 0) && (hour < 8))
+ retVal = -15;
+
+ return retVal;
+}
+
+/**
+ * Engine function - Get Presence Statistics - Room Chapel
+ * @remarks Originally called 'cpl20'
+ */
+int MortevielleEngine::getPresenceStatsChapel(int &hour) {
+ int day, minute;
+ int retVal = 0;
+
+ updateHour(day, hour, minute);
+ if (hour == 10)
+ retVal = 65;
+ else if ((hour > 10) && (hour < 21))
+ retVal = 5;
+ else if ((hour > 20) && (hour < 24))
+ retVal = -15;
+ else if ((hour >= 0) && (hour < 5))
+ retVal = -300;
+ else if ((hour > 4) && (hour < 10))
+ retVal = -5;
+
+ return retVal;
+}
+
+/**
+ * Engine function - Check who is in the Green Room
+ * @remarks Originally called 'quelq1'
+ */
+void MortevielleEngine::setPresenceGreenRoom(int roomId) {
+ int rand = getRandomNumber(1, 2);
+ if (roomId == GREEN_ROOM) {
+ if (rand == 1)
+ _roomPresenceLuc = true;
+ else
+ _roomPresenceIda = true;
+ } else if (roomId == DARKBLUE_ROOM) {
+ if (rand == 1)
+ _roomPresenceGuy = true;
+ else
+ _roomPresenceEva = true;
+ }
+
+ _currBitIndex = 10;
+}
+
+/**
+ * Engine function - Check who is in the Purple Room
+ * @remarks Originally called 'quelq2'
+ */
+void MortevielleEngine::setPresencePurpleRoom() {
+ if (_place == PURPLE_ROOM)
+ _purpleRoomPresenceLeo = true;
+ else
+ _room9PresenceLeo = true;
+
+ _currBitIndex = 10;
+}
+
+/**
+ * Engine function - Check who is in the Blue Room
+ * @remarks Originally called 'quelq5'
+ */
+void MortevielleEngine::setPresenceBlueRoom() {
+ _roomPresenceMax = true;
+ _currBitIndex = 10;
+}
+
+/**
+ * Engine function - Check who is in the Red Room
+ * @remarks Originally called 'quelq6'
+ */
+void MortevielleEngine::setPresenceRedRoom(int roomId) {
+ if (roomId == RED_ROOM)
+ _roomPresenceBob = true;
+ else if (roomId == GREEN_ROOM2)
+ _roomPresencePat = true;
+
+ _currBitIndex = 10;
+}
+
+/**
+ * Engine function - Check who is in the Dining Room
+ * @remarks Originally called 'quelq10'
+ */
+int MortevielleEngine::setPresenceDiningRoom(int hour) {
+ int retVal = 0;
+
+ if ((hour >= 0) && (hour < 8))
+ retVal = chlm();
+ else {
+ int min = 0, max = 0;
+ if ((hour > 7) && (hour < 10)) {
+ min = 5;
+ max = 7;
+ } else if ((hour > 9) && (hour < 12)) {
+ min = 1;
+ max = 4;
+ } else if (((hour > 11) && (hour < 15)) || ((hour > 18) && (hour < 21))) {
+ min = 6;
+ max = 8;
+ } else if (((hour > 14) && (hour < 19)) || ((hour > 20) && (hour < 24))) {
+ min = 1;
+ max = 5;
+ }
+ retVal = selectCharacters(min, max);
+ }
+ showPeoplePresent(retVal);
+
+ return retVal;
+}
+
+/**
+ * Engine function - Check who is in the Bureau
+ * @remarks Originally called 'quelq11'
+ */
+int MortevielleEngine::setPresenceBureau(int hour) {
+ int retVal = 0;
+
+ if ((hour >= 0) && (hour < 8))
+ retVal = chlm();
+ else {
+ int min = 0, max = 0;
+ if (((hour > 7) && (hour < 10)) || ((hour > 20) && (hour < 24))) {
+ min = 1;
+ max = 3;
+ } else if (((hour > 9) && (hour < 12)) || ((hour > 13) && (hour < 19))) {
+ min = 1;
+ max = 4;
+ } else if (((hour > 11) && (hour < 14)) || ((hour > 18) && (hour < 21))) {
+ min = 1;
+ max = 2;
+ }
+ retVal = selectCharacters(min, max);
+ }
+ showPeoplePresent(retVal);
+
+ return retVal;
+}
+
+/**
+ * Engine function - Check who is in the Kitchen
+ * @remarks Originally called 'quelq12'
+ */
+int MortevielleEngine::setPresenceKitchen() {
+ int retVal = chlm();
+ showPeoplePresent(retVal);
+
+ return retVal;
+}
+
+/**
+ * Engine function - Check who is in the Landing
+ * @remarks Originally called 'quelq15'
+ */
+int MortevielleEngine::setPresenceLanding() {
+ bool test = false;
+ int rand = 0;
+ do {
+ rand = getRandomNumber(1, 8);
+ test = (((rand == 1) && (_purpleRoomPresenceLeo || _room9PresenceLeo)) ||
+ ((rand == 2) && _roomPresencePat) ||
+ ((rand == 3) && _roomPresenceGuy) ||
+ ((rand == 4) && _roomPresenceEva) ||
+ ((rand == 5) && _roomPresenceBob) ||
+ ((rand == 6) && _roomPresenceLuc) ||
+ ((rand == 7) && _roomPresenceIda) ||
+ ((rand == 8) && _roomPresenceMax));
+ } while (test);
+
+ int retVal = convertCharacterIndexToBitIndex(rand);
+ showPeoplePresent(retVal);
+
+ return retVal;
+}
+
+/**
+ * Engine function - Check who is in the chapel
+ * @remarks Originally called 'quelq20'
+ */
+int MortevielleEngine::setPresenceChapel(int hour) {
+ int retVal = 0;
+
+ if (((hour >= 0) && (hour < 10)) || ((hour > 18) && (hour < 24)))
+ retVal = chlm();
+ else {
+ int min = 0, max = 0;
+ if ((hour > 9) && (hour < 12)) {
+ min = 3;
+ max = 7;
+ } else if ((hour > 11) && (hour < 18)) {
+ min = 1;
+ max = 2;
+ } else if (hour == 18) {
+ min = 2;
+ max = 4;
+ }
+ retVal = selectCharacters(min, max);
+ }
+ showPeoplePresent(retVal);
+
+ return retVal;
+}
+
+/**
+ * Engine function - Get the answer after you known a door
+ * @remarks Originally called 'frap'
+ */
+void MortevielleEngine::getKnockAnswer() {
+ int day, hour, minute;
+
+ updateHour(day, hour, minute);
+ if ((hour >= 0) && (hour < 8))
+ g_crep = 190;
+ else {
+ if (getRandomNumber(1, 100) > 70)
+ g_crep = 190;
+ else
+ g_crep = 147;
+ }
+}
+
+/**
+ * Engine function - Get Room Presence Bit Index
+ * @remarks Originally called 'nouvp'
+ */
+int MortevielleEngine::getPresenceBitIndex(int roomId) {
+ int bitIndex = 0;
+ if (roomId == GREEN_ROOM) {
+ if (_roomPresenceLuc)
+ bitIndex = 4; // LUC
+ if (_roomPresenceIda)
+ bitIndex = 2; // IDA
+ } else if ( ((roomId == PURPLE_ROOM) && (_purpleRoomPresenceLeo))
+ || ((roomId == ROOM9) && (_room9PresenceLeo)))
+ bitIndex = 128; // LEO
+ else if (roomId == DARKBLUE_ROOM) {
+ if (_roomPresenceGuy)
+ bitIndex = 32; // GUY
+ if (_roomPresenceEva)
+ bitIndex = 16; // EVA
+ } else if ((roomId == BLUE_ROOM) && (_roomPresenceMax))
+ bitIndex = 1; // MAX
+ else if ((roomId == RED_ROOM) && (_roomPresenceBob))
+ bitIndex = 8; // BOB
+ else if ((roomId == GREEN_ROOM2) && (_roomPresencePat))
+ bitIndex = 64; // PAT
+ else if ( ((roomId == TOILETS) && (_toiletsPresenceBobMax))
+ || ((roomId == BATHROOM) && (_bathRoomPresenceBobMax)) )
+ bitIndex = 9; // BOB + MAX
+
+ if (bitIndex != 9)
+ showPeoplePresent(bitIndex);
+
+ return bitIndex;
+}
+
+/**
+ * Engine function - initGame
+ * @remarks Originally called 'dprog'
+ */
+void MortevielleEngine::initGame() {
+ _place = MANOR_FRONT;
+ g_jh = 0;
+ if (!g_s._alreadyEnteredManor)
+ _blo = true;
+ g_t = kTime1;
+ g_mh = readclock();
+}
+
+/**
+ * Engine function - Set Random Presence - Green Room
+ * @remarks Originally called 'pl1'
+ */
+void MortevielleEngine::setRandomPresenceGreenRoom(int cf) {
+ if ( ((_place == GREEN_ROOM) && (!_roomPresenceLuc) && (!_roomPresenceIda))
+ || ((_place == DARKBLUE_ROOM) && (!_roomPresenceGuy) && (!_roomPresenceEva)) ) {
+ int p = getPresenceStatsGreenRoom();
+ int rand;
+ phaz(rand, p, cf);
+
+ if (rand > p)
+ displayAloneText();
+ else
+ setPresenceGreenRoom(_place);
+ }
+}
+
+/**
+ * Engine function - Set Random Presence - Purple Room
+ * @remarks Originally called 'pl2'
+ */
+void MortevielleEngine::setRandomPresencePurpleRoom(int cf) {
+ if (!_purpleRoomPresenceLeo) {
+ int p = getPresenceStatsPurpleRoom();
+ int rand;
+ phaz(rand, p, cf);
+
+ if (rand > p)
+ displayAloneText();
+ else
+ setPresencePurpleRoom();
+ }
+}
+
+/**
+ * Engine function - Set Random Presence - Blue Room
+ * @remarks Originally called 'pl5'
+ */
+void MortevielleEngine::setRandomPresenceBlueRoom(int cf) {
+ if (!_roomPresenceMax) {
+ int p = getPresenceStatsBlueRoom();
+ int rand;
+
+ phaz(rand, p, cf);
+
+ if (rand > p)
+ displayAloneText();
+ else
+ setPresenceBlueRoom();
+ }
+}
+
+/**
+ * Engine function - Set Random Presence - Red Room
+ * @remarks Originally called 'pl6'
+ */
+void MortevielleEngine::setRandomPresenceRedRoom(int cf) {
+ if ( ((_place == RED_ROOM) && (!_roomPresenceBob))
+ || ((_place == GREEN_ROOM2) && (!_roomPresencePat)) ) {
+ int p = getPresenceStatsRedRoom();
+ int rand;
+
+ phaz(rand, p, cf);
+
+ if (rand > p)
+ displayAloneText();
+ else
+ setPresenceRedRoom(_place);
+ }
+}
+
+/**
+ * Engine function - Set Random Presence - Room 9
+ * @remarks Originally called 'pl9'
+ */
+void MortevielleEngine::setRandomPresenceRoom9(int cf) {
+ if (!_room9PresenceLeo) {
+ cf = -10;
+ int p, rand;
+ phaz(rand, p, cf);
+
+ if (rand > p)
+ displayAloneText();
+ else
+ setPresencePurpleRoom();
+ }
+}
+
+/**
+ * Engine function - Set Random Presence - Dining Room
+ * @remarks Originally called 'pl10'
+ */
+void MortevielleEngine::setRandomPresenceDiningRoom(int cf) {
+ int h, rand;
+ int p = getPresenceStatsDiningRoom(h);
+ phaz(rand, p, cf);
+
+ if (rand > p)
+ displayAloneText();
+ else
+ setPresenceDiningRoom(h);
+}
+
+/**
+ * Engine function - Set Random Presence - Bureau
+ * @remarks Originally called 'pl11'
+ */
+void MortevielleEngine::setRandomPresenceBureau(int cf) {
+ int h, rand;
+
+ int p = getPresenceStatsBureau(h);
+ phaz(rand, p, cf);
+ if (rand > p)
+ displayAloneText();
+ else
+ setPresenceBureau(h);
+}
+
+/**
+ * Engine function - Set Random Presence - Kitchen
+ * @remarks Originally called 'pl12'
+ */
+void MortevielleEngine::setRandomPresenceKitchen(int cf) {
+ int p, rand;
+
+ p = getPresenceStatsKitchen();
+ phaz(rand, p, cf);
+ if (rand > p)
+ displayAloneText();
+ else
+ setPresenceKitchen();
+}
+
+/**
+ * Engine function - Set Random Presence - Attic / Cellar
+ * @remarks Originally called 'pl13'
+ */
+void MortevielleEngine::setRandomPresenceAttic(int cf) {
+ int p, rand;
+
+ p = getPresenceStatsAttic();
+ phaz(rand, p, cf);
+ if (rand > p)
+ displayAloneText();
+ else
+ setPresenceKitchen();
+}
+
+/**
+ * Engine function - Set Random Presence - Landing
+ * @remarks Originally called 'pl15'
+ */
+void MortevielleEngine::setRandomPresenceLanding(int cf) {
+ int p, rand;
+
+ p = getPresenceStatsLanding();
+ phaz(rand, p, cf);
+ if (rand > p)
+ displayAloneText();
+ else
+ setPresenceLanding();
+}
+
+/**
+ * Engine function - Set Random Presence - Chapel
+ * @remarks Originally called 'pl20'
+ */
+void MortevielleEngine::setRandomPresenceChapel(int cf) {
+ int h, rand;
+
+ int p = getPresenceStatsChapel(h);
+ phaz(rand, p, cf);
+ if (rand > p)
+ displayAloneText();
+ else
+ setPresenceChapel(h);
+}
+
+/**
+ * Start music or speech
+ * @remarks Originally called 'musique'
+ */
+void MortevielleEngine::startMusicOrSpeech(int so) {
+ if (so == 0) {
+ /* musik(0) */
+ ;
+ } else if ((g_prebru == 0) && (!g_s._alreadyEnteredManor)) {
+ // Type 1: Speech
+ _speechManager.startSpeech(10, 1, 1);
+ ++g_prebru;
+ } else {
+ if (((g_s._currPlace == MOUNTAIN) || (g_s._currPlace == MANOR_FRONT) || (g_s._currPlace == MANOR_BACK)) && (getRandomNumber(1, 3) == 2))
+ // Type 1: Speech
+ _speechManager.startSpeech(9, getRandomNumber(2, 4), 1);
+ else if ((g_s._currPlace == CHAPEL) && (getRandomNumber(1, 2) == 1))
+ // Type 1: Speech
+ _speechManager.startSpeech(8, 1, 1);
+ else if ((g_s._currPlace == WELL) && (getRandomNumber(1, 2) == 2))
+ // Type 1: Speech
+ _speechManager.startSpeech(12, 1, 1);
+ else if (g_s._currPlace == INSIDE_WELL)
+ // Type 1: Speech
+ _speechManager.startSpeech(13, 1, 1);
+ else
+ // Type 2 : music
+ _speechManager.startSpeech(getRandomNumber(1, 17), 1, 2);
+ }
+}
+
+/**
+ * Engine function - You lose!
+ * @remarks Originally called 'tperd'
+ */
+void MortevielleEngine::loseGame() {
+ initouv();
+ g_ment = 0;
+ g_iouv = 0;
+ g_mchai = 0;
+ _menu.unsetSearchMenu();
+ if (!_blo)
+ t11(MANOR_FRONT);
+
+ _loseGame = true;
+ clearScreenType1();
+ _screenSurface.drawBox(60, 35, 400, 50, 15);
+ repon(9, g_crep);
+ clearScreenType2();
+ clearScreenType3();
+ _col = false;
+ _syn = false;
+ _okdes = false;
+}
+
+/**
+ * Engine function - Check inventory for a given object
+ * @remarks Originally called 'cherjer'
+ */
+bool MortevielleEngine::checkInventory(int objectId) {
+ bool retVal = false;
+ for (int i = 1; i <= 6; ++i)
+ retVal = (retVal || (ord(g_s._sjer[i]) == objectId));
+
+ if (g_s._selectedObjectId == objectId)
+ retVal = true;
+
+ return retVal;
+}
+
+/**
+ * Engine function - Display Dining Room
+ * @remarks Originally called 'st1sama'
+ */
+void MortevielleEngine::displayDiningRoom() {
+ g_s._currPlace = DINING_ROOM;
+ affrep();
+}
+
+/**
+ * Engine function - Start non interactive Dialog
+ * @remarks Originally called 'sparl'
+ */
+void MortevielleEngine::startDialog(int16 rep) {
+ const int haut[9] = { 0, 0, 1, -3, 6, -2, 2, 7, -1 };
+ int key;
+
+ assert(rep >= 0);
+
+ _mouse.hideMouse();
+ Common::String dialogStr = deline(rep + kDialogStringIndex);
+ displayStr(dialogStr, 230, 4, 65, 24, 5);
+ f3f8::draw();
+
+ key = 0;
+ do {
+ _speechManager.startSpeech(rep, haut[g_caff - 69], 0);
+ key = f3f8::waitForF3F8();
+ CHECK_QUIT;
+ } while (key != 66);
+ hirs();
+ _mouse.showMouse();
+}
+
+/**
+ * Engine function - End of Search: reset globals
+ * @remarks Originally called 'finfouill'
+ */
+void MortevielleEngine::endSearch() {
+ _heroSearching = false;
+ _obpart = false;
+ g_cs = 0;
+ g_is = 0;
+ _menu.unsetSearchMenu();
+}
+
+/**
+ * Engine function - Go to Dining room
+ * @remarks Originally called 't1sama'
+ */
+void MortevielleEngine::gotoDiningRoom() {
+ int day, hour, minute;
+
+ updateHour(day, hour, minute);
+ if ((hour < 5) && (g_s._currPlace > ROOM18)) {
+ if (!checkInventory(137)) { //You don't have the keys, and it's late
+ g_crep = 1511;
+ loseGame();
+ } else
+ displayDiningRoom();
+ } else if (!g_s._alreadyEnteredManor) { //Is it your first time?
+ _currBitIndex = 255; // Everybody is present
+ showPeoplePresent(_currBitIndex);
+ g_caff = 77;
+ afdes();
+ _screenSurface.drawBox(223, 47, 155, 91, 15);
+ repon(2, 33);
+ tkey1(false);
+ mennor();
+ _mouse.hideMouse();
+ hirs();
+ premtet();
+ startDialog(140);
+ drawRightFrame();
+ drawClock();
+ _mouse.showMouse();
+ g_s._currPlace = OWN_ROOM;
+ affrep();
+ resetPresenceInRooms(DINING_ROOM);
+ if (!_blo)
+ minute = t11(OWN_ROOM);
+ _currBitIndex = 0;
+ g_mpers = 0;
+ g_s._alreadyEnteredManor = true;
+ } else
+ displayDiningRoom();
+}
+
+/**
+ * Engine function - Check Manor distance (in the mountains)
+ * @remarks Originally called 't1neig'
+ */
+void MortevielleEngine::checkManorDistance() {
+ ++_manorDistance;
+ if (_manorDistance > 2) {
+ g_crep = 1506;
+ loseGame();
+ } else {
+ _okdes = true;
+ g_s._currPlace = MOUNTAIN;
+ affrep();
+ }
+}
+
+/**
+ * Engine function - Go to Manor front
+ * @remarks Originally called 't1deva'
+ */
+void MortevielleEngine::gotoManorFront() {
+ _manorDistance = 0;
+ g_s._currPlace = MANOR_FRONT;
+ affrep();
+}
+
+/**
+ * Engine function - Go to Manor back
+ * @remarks Originally called 't1derr'
+ */
+void MortevielleEngine::gotoManorBack() {
+ g_s._currPlace = MANOR_BACK;
+ affrep();
+}
+
+/**
+ * Engine function - Dead : Flooded in Well
+ * @remarks Originally called 't1deau'
+ */
+void MortevielleEngine::floodedInWell() {
+ g_crep = 1503;
+ loseGame();
+}
+
+/**
+ * Engine function - Change Graphical Device
+ * @remarks Originally called 'change_gd'
+ */
+void MortevielleEngine::changeGraphicalDevice(int newDevice) {
+ _mouse.hideMouse();
+ _currGraphicalDevice = newDevice;
+ hirs();
+ _mouse.initMouse();
+ _mouse.showMouse();
+ drawRightFrame();
+ tinke();
+ drawClock();
+ if (_currBitIndex != 0)
+ showPeoplePresent(_currBitIndex);
+ else
+ displayAloneText();
+ clearScreenType2();
+ clearScreenType3();
+ g_maff = 68;
+ afdes();
+ repon(2, g_crep);
+ _menu.displayMenu();
+}
+
+/**
+ * Called when a savegame has been loaded.
+ * @remarks Originally called 'antegame'
+ */
+void MortevielleEngine::gameLoaded() {
+ _mouse.hideMouse();
+ _menu._menuDisplayed = false;
+ _loseGame = true;
+ _anyone = false;
+ _okdes = true;
+ _col = false;
+ _hiddenHero = false;
+ _brt = false;
+ g_maff = 68;
+ g_mnumo = OPCODE_NONE;
+ g_prebru = 0;
+ g_x = 0;
+ g_y = 0;
+ g_num = 0;
+ g_hdb = 0;
+ g_hfb = 0;
+ g_cs = 0;
+ g_is = 0;
+ g_ment = 0;
+ _syn = true;
+ _heroSearching = true;
+ g_mchai = 0;
+ _manorDistance = 0;
+ initouv();
+ g_iouv = 0;
+ g_dobj = 0;
+ affrep();
+ _hintPctMessage = deline(580);
+
+ _okdes = false;
+ _endGame = true;
+ _loseGame = false;
+ _heroSearching = false;
+
+ displayAloneText();
+ tinke();
+ drawClock();
+ afdes();
+ repon(2, g_crep);
+ clearScreenType3();
+ _endGame = false;
+ _menu.setDestinationMenuText(g_s._currPlace);
+ modinv();
+ if (g_s._selectedObjectId != 0)
+ modobj(g_s._selectedObjectId + 400);
+ _mouse.showMouse();
+}
+
+/**
+ * Engine function - Handle OpCodes
+ * @remarks Originally called 'tsitu'
+ */
+void MortevielleEngine::handleOpcode() {
+ if (!_col)
+ clearScreenType2();
+ _syn = false;
+ _keyPressedEsc = false;
+ if (!_anyone) {
+ if (_brt) {
+ if ((g_msg[3] == MENU_MOVE) || (g_msg[4] == OPCODE_LEAVE) || (g_msg[4] == OPCODE_SLEEP) || (g_msg[4] == OPCODE_EAT)) {
+ g_ctrm = 4;
+ mennor();
+ return;
+ }
+ }
+ if (g_msg[3] == MENU_MOVE)
+ fctMove();
+ if (g_msg[3] == MENU_DISCUSS)
+ fctDiscuss();
+ if (g_msg[3] == MENU_INVENTORY)
+ fctInventoryTake();
+ if (g_msg[4] == OPCODE_ATTACH)
+ fctAttach();
+ if (g_msg[4] == OPCODE_WAIT)
+ fctWait();
+ if (g_msg[4] == OPCODE_FORCE)
+ fctForce();
+ if (g_msg[4] == OPCODE_SLEEP)
+ fctSleep();
+ if (g_msg[4] == OPCODE_LISTEN)
+ fctListen();
+ if (g_msg[4] == OPCODE_ENTER)
+ fctEnter();
+ if (g_msg[4] == OPCODE_CLOSE)
+ fctClose();
+ if (g_msg[4] == OPCODE_SEARCH)
+ fctSearch();
+ if (g_msg[4] == OPCODE_KNOCK)
+ fctKnock();
+ if (g_msg[4] == OPCODE_SCRATCH)
+ fctScratch();
+ if (g_msg[4] == OPCODE_READ)
+ fctRead();
+ if (g_msg[4] == OPCODE_EAT)
+ fctEat();
+ if (g_msg[4] == OPCODE_PLACE)
+ fctPlace();
+ if (g_msg[4] == OPCODE_OPEN)
+ fctOpen();
+ if (g_msg[4] == OPCODE_TAKE)
+ fctTake();
+ if (g_msg[4] == OPCODE_LOOK)
+ fctLook();
+ if (g_msg[4] == OPCODE_SMELL)
+ fctSmell();
+ if (g_msg[4] == OPCODE_SOUND)
+ fctSound();
+ if (g_msg[4] == OPCODE_LEAVE)
+ fctLeave();
+ if (g_msg[4] == OPCODE_LIFT)
+ fctLift();
+ if (g_msg[4] == OPCODE_TURN)
+ fctTurn();
+ if (g_msg[4] == OPCODE_SSEARCH)
+ fctSelfSearch();
+ if (g_msg[4] == OPCODE_SREAD)
+ fctSelfRead();
+ if (g_msg[4] == OPCODE_SPUT)
+ fctSelfPut();
+ if (g_msg[4] == OPCODE_SLOOK)
+ fctSelftLook();
+ _hiddenHero = false;
+
+ if (g_msg[4] == OPCODE_SHIDE)
+ fctSelfHide();
+ } else {
+ if (_anyone) {
+ quelquun();
+ _anyone = false;
+ mennor();
+ return;
+ }
+ }
+ int hour, day, minute;
+ updateHour(day, hour, minute);
+ if ((((hour == 12) || (hour == 13) || (hour == 19)) && (g_s._currPlace != 10)) ||
+ ((hour > 0) && (hour < 6) && (g_s._currPlace != 0)))
+ ++g_s._faithScore;
+ if (((g_s._currPlace < CRYPT) || (g_s._currPlace > MOUNTAIN)) && (g_s._currPlace != INSIDE_WELL)
+ && (g_s._currPlace != OWN_ROOM) && (g_s._selectedObjectId != 152) && (!_loseGame)) {
+ if ((g_s._faithScore > 99) && (hour > 8) && (hour < 16)) {
+ g_crep = 1501;
+ loseGame();
+ }
+ if ((g_s._faithScore > 99) && (hour > 0) && (hour < 9)) {
+ g_crep = 1508;
+ loseGame();
+ }
+ if ((day > 1) && (hour > 8) && (!_loseGame)) {
+ g_crep = 1502;
+ loseGame();
+ }
+ }
+ mennor();
+}
+
+/**
+ * Engine function - Transform time into a char
+ * @remarks Originally called 'tmaj3'
+ */
+void MortevielleEngine::hourToChar() {
+ int day, hour, minute;
+
+ g_vm->updateHour(day, hour, minute);
+ if (minute == 30)
+ minute = 1;
+ hour += day * 24;
+ minute += hour * 2;
+ g_s._fullHour = chr(minute);
+}
+
+/**
+ * Engine function - extract time from a char
+ * @remarks Originally called 'theure'
+ */
+void MortevielleEngine::charToHour() {
+ int fullHour = ord(g_s._fullHour);
+ int tmpHour = fullHour % 48;
+ g_vm->_currDay = fullHour / 48;
+ g_vm->_currHalfHour = tmpHour % 2;
+ g_vm->_currHour = tmpHour / 2;
+ g_vm->_hour = g_vm->_currHour;
+ if (g_vm->_currHalfHour == 1)
+ g_vm->_minute = 30;
+ else
+ g_vm->_minute = 0;
+}
+
+/**
+ * Engine function - Clear Screen - Type 1
+ * @remarks Originally called 'clsf1'
+ */
+void MortevielleEngine::clearScreenType1() {
+ g_vm->_mouse.hideMouse();
+ g_vm->_screenSurface.fillRect(0, Common::Rect(0, 11, 514, 175));
+ g_vm->_mouse.showMouse();
+}
+
+/**
+ * Engine function - Clear Screen - Type 2
+ * @remarks Originally called 'clsf2'
+ */
+void MortevielleEngine::clearScreenType2() {
+ g_vm->_mouse.hideMouse();
+ if (g_vm->_largestClearScreen) {
+ g_vm->_screenSurface.fillRect(0, Common::Rect(1, 176, 633, 199));
+ g_vm->_screenSurface.drawBox(0, 175, 634, 24, 15);
+ g_vm->_largestClearScreen = false;
+ } else {
+ g_vm->_screenSurface.fillRect(0, Common::Rect(1, 176, 633, 190));
+ g_vm->_screenSurface.drawBox(0, 175, 634, 15, 15);
+ }
+ g_vm->_mouse.showMouse();
+}
+
+/**
+ * Engine function - Clear Screen - Type 3
+ * @remarks Originally called 'clsf3'
+ */
+void MortevielleEngine::clearScreenType3() {
+ g_vm->_mouse.hideMouse();
+ g_vm->_screenSurface.fillRect(0, Common::Rect(1, 192, 633, 199));
+ g_vm->_screenSurface.drawBox(0, 191, 634, 8, 15);
+ g_vm->_mouse.showMouse();
+}
+
+/**
+ * Engine function - Clear Screen - Type 10
+ * @remarks Originally called 'clsf10'
+ */
+void MortevielleEngine::clearScreenType10() {
+ int co, cod;
+ Common::String st;
+
+ g_vm->_mouse.hideMouse();
+ if (g_res == 1) {
+ co = 634;
+ cod = 534;
+ } else {
+ co = 600;
+ cod = 544;
+ }
+ g_vm->_screenSurface.fillRect(15, Common::Rect(cod, 93, co, 98));
+ if (g_s._faithScore < 33)
+ st = g_vm->getEngineString(S_COOL);
+ else if (g_s._faithScore < 66)
+ st = g_vm->getEngineString(S_LOURDE);
+ else if (g_s._faithScore > 65)
+ st = g_vm->getEngineString(S_MALSAINE);
+
+ co = 580 - (g_vm->_screenSurface.getStringWidth(st) / 2);
+ g_vm->_screenSurface.putxy(co, 92);
+ g_vm->_screenSurface.drawString(st, 4);
+
+ g_vm->_screenSurface.fillRect(15, Common::Rect(560, 24, 610, 86));
+ /* rempli(69,12,32,5,255);*/
+ g_vm->_mouse.showMouse();
+}
+
} // End of namespace Mortevielle
diff --git a/engines/mortevielle/mortevielle.h b/engines/mortevielle/mortevielle.h
index aeaf5e27d1..477415b317 100644
--- a/engines/mortevielle/mortevielle.h
+++ b/engines/mortevielle/mortevielle.h
@@ -34,6 +34,7 @@
#include "graphics/surface.h"
#include "mortevielle/graphics.h"
#include "mortevielle/menu.h"
+#include "mortevielle/mouse.h"
#include "mortevielle/saveload.h"
#include "mortevielle/sound.h"
#include "mortevielle/speech.h"
@@ -168,6 +169,7 @@ public:
SavegameManager _savegameManager;
SpeechManager _speechManager;
Menu _menu;
+ MouseHandler _mouse;
bool _quitGame; // Quit game flag. Originally called 'arret'
bool _endGame; // End game flag. Originally called 'solu'
@@ -289,6 +291,14 @@ public:
void hourToChar();
void changeGraphicalDevice(int newDevice);
+ void startDialog(int16 rep);
+ void endSearch();
+ int convertCharacterIndexToBitIndex(int characterIndex);
+ int convertBitIndexToCharacterIndex(int bitIndex);
+ void clearScreenType1();
+ void clearScreenType2();
+ void clearScreenType3();
+ void clearScreenType10();
};
diff --git a/engines/mortevielle/mouse.cpp b/engines/mortevielle/mouse.cpp
index 401a2b3f7b..c5f0e21802 100644
--- a/engines/mortevielle/mouse.cpp
+++ b/engines/mortevielle/mouse.cpp
@@ -36,21 +36,11 @@ namespace Mortevielle {
const int m_arrow = 0;
const int m_point_hand = 1;
-bool int_m, clic;
-
-int m_show,
- x_s,
- y_s,
- p_o_s,
- mouse_shwn;
-
-int s_s[12][6];
-
/**
* Initialize the mouse
* @remarks Originally called 'init_mouse'
*/
-void initMouse() {
+void MouseHandler::initMouse() {
registres reg;
mouse_shwn = 0;
@@ -81,7 +71,7 @@ void initMouse() {
* Hide the mouse
* @remarks Originally called 'hide_mouse'
*/
-void hideMouse() {
+void MouseHandler::hideMouse() {
--mouse_shwn;
if (mouse_shwn == 0) {
bool imp = odd(y_s);
@@ -173,7 +163,7 @@ void hideMouse() {
* Show mouse
* @remarks Originally called 'show_mouse'
*/
-void showMouse() {
+void MouseHandler::showMouse() {
int k, l;
mouse_shwn = mouse_shwn + 1;
@@ -258,7 +248,7 @@ void showMouse() {
* Set mouse position
* @remarks Originally called 'pos_mouse'
*/
-void setMousePos(int x, int y) {
+void MouseHandler::setMousePos(int x, int y) {
if (x > 314 * g_res)
x = 314 * g_res;
else if (x < 0)
@@ -278,7 +268,7 @@ void setMousePos(int x, int y) {
* Get mouse poisition
* @remarks Originally called 'read_pos_mouse'
*/
-void getMousePos_(int &x, int &y, int &c) {
+void MouseHandler::getMousePos_(int &x, int &y, int &c) {
x = g_vm->getMousePos().x;
y = g_vm->getMousePos().y;
c = g_vm->getMouseClick() ? 1 : 0;
@@ -288,7 +278,7 @@ void getMousePos_(int &x, int &y, int &c) {
* Move mouse
* @remarks Originally called 'mov_mouse'
*/
-void moveMouse(bool &funct, char &key) {
+void MouseHandler::moveMouse(bool &funct, char &key) {
bool p_key;
char in1, in2;
int cx, cy, cd;
@@ -443,4 +433,18 @@ void moveMouse(bool &funct, char &key) {
}
}
+/**
+ * Engine function : Is mouse in a given rect?
+ * @remarks Originally called 'dans_rect'
+ */
+bool MouseHandler::isMouseIn(rectangle r) {
+ int x, y, c;
+
+ getMousePos_(x, y, c);
+ if ((x > r._x1) && (x < r._x2) && (y > r._y1) && (y < r._y2))
+ return true;
+
+ return false;
+}
+
} // End of namespace Mortevielle
diff --git a/engines/mortevielle/mouse.h b/engines/mortevielle/mouse.h
index 532644a255..e9cc8af7c0 100644
--- a/engines/mortevielle/mouse.h
+++ b/engines/mortevielle/mouse.h
@@ -28,24 +28,30 @@
#ifndef MORTEVIELLE_MOUSE_H
#define MORTEVIELLE_MOUSE_H
+#include "mortevielle/var_mor.h"
+
namespace Mortevielle {
-extern bool int_m;
-
-extern int m_show,
- x_s,
- y_s,
- p_o_s,
- mouse_shwn;
-
-void initMouse();
-//extern void change_mouse(int t);
-//extern void dessine_souris(int xf, int yf);
-extern void hideMouse();
-extern void showMouse();
-extern void setMousePos(int x, int y);
-extern void getMousePos_(int &x, int &y, int &c);
-extern void moveMouse(bool &funct, char &key);
+class MouseHandler {
+protected:
+ int s_s[12][6];
+public:
+ bool int_m;
+
+ int m_show;
+ int x_s;
+ int y_s;
+ int p_o_s;
+ int mouse_shwn;
+
+ void initMouse();
+ void hideMouse();
+ void showMouse();
+ void setMousePos(int x, int y);
+ void getMousePos_(int &x, int &y, int &c);
+ void moveMouse(bool &funct, char &key);
+ bool isMouseIn(rectangle r);
+};
} // End of namespace Mortevielle
#endif
diff --git a/engines/mortevielle/outtext.cpp b/engines/mortevielle/outtext.cpp
index c93107cc13..1947e3d860 100644
--- a/engines/mortevielle/outtext.cpp
+++ b/engines/mortevielle/outtext.cpp
@@ -351,7 +351,7 @@ void taffich() {
}
g_vm->_okdes = true;
- hideMouse();
+ g_vm->_mouse.hideMouse();
lgt = 0;
Common::String filename;
@@ -450,7 +450,7 @@ void taffich() {
}
charani(filename, lgt, handle);
}
- showMouse();
+ g_vm->_mouse.showMouse();
if ((a < 27) && ((g_maff < 27) || (g_s._currPlace == LANDING)) && (g_msg[4] != OPCODE_ENTER)) {
if ((a == 13) || (a == 14))
g_vm->displayAloneText();
diff --git a/engines/mortevielle/ovd1.cpp b/engines/mortevielle/ovd1.cpp
index 9b0f72c8e0..1ac883f53e 100644
--- a/engines/mortevielle/ovd1.cpp
+++ b/engines/mortevielle/ovd1.cpp
@@ -134,7 +134,7 @@ void chartex() {
void dialpre() {
/* debug('o3 dialpre'); */
g_crep = 998;
- int_m = true;
+ g_vm->_mouse.int_m = true;
}
void music() {
diff --git a/engines/mortevielle/saveload.cpp b/engines/mortevielle/saveload.cpp
index d054308cf3..9458da38bc 100644
--- a/engines/mortevielle/saveload.cpp
+++ b/engines/mortevielle/saveload.cpp
@@ -119,7 +119,7 @@ void SavegameManager::loadSavegame(int n) {
* Load a saved game
*/
Common::Error SavegameManager::loadGame(int n) {
- hideMouse();
+ g_vm->_mouse.hideMouse();
maivid();
loadSavegame(n);
@@ -127,7 +127,7 @@ Common::Error SavegameManager::loadGame(int n) {
g_vm->charToHour();
g_vm->initGame();
g_vm->gameLoaded();
- showMouse();
+ g_vm->_mouse.showMouse();
return Common::kNoError;
}
@@ -138,7 +138,7 @@ Common::Error SavegameManager::saveGame(int n, const Common::String &saveName) {
Common::OutSaveFile *f;
int i;
- hideMouse();
+ g_vm->_mouse.hideMouse();
g_vm->hourToChar();
for (i = 0; i <= 389; ++i)
@@ -167,7 +167,7 @@ Common::Error SavegameManager::saveGame(int n, const Common::String &saveName) {
// Skipped: dialog asking to swap floppy
- showMouse();
+ g_vm->_mouse.showMouse();
return Common::kNoError;
}