aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorStrangerke2012-03-06 08:29:06 +0100
committerStrangerke2012-04-06 08:22:51 +0200
commit8f2a33e29257490bd61a1ad96e06f2a4109e03c8 (patch)
treece81943a24e1fb6ab3b151ee02a7d88ab0f9d0be /engines
parentf9b793126d7995316687514ee15830da8f6e7d66 (diff)
downloadscummvm-rg350-8f2a33e29257490bd61a1ad96e06f2a4109e03c8.tar.gz
scummvm-rg350-8f2a33e29257490bd61a1ad96e06f2a4109e03c8.tar.bz2
scummvm-rg350-8f2a33e29257490bd61a1ad96e06f2a4109e03c8.zip
MORTEVIELLE: Some more renaming and refactoring
Diffstat (limited to 'engines')
-rw-r--r--engines/mortevielle/actions.cpp6
-rw-r--r--engines/mortevielle/graphics.cpp25
-rw-r--r--engines/mortevielle/mor.cpp96
-rw-r--r--engines/mortevielle/mor.h8
-rw-r--r--engines/mortevielle/mor2.cpp3
5 files changed, 73 insertions, 65 deletions
diff --git a/engines/mortevielle/actions.cpp b/engines/mortevielle/actions.cpp
index 0bcfd67046..be0407ca50 100644
--- a/engines/mortevielle/actions.cpp
+++ b/engines/mortevielle/actions.cpp
@@ -1149,7 +1149,7 @@ void fctEnter() {
parole(7, g_x, 1);
aniof(1, 1);
- tip(z, g_x);
+ g_x = convertBitIndexToCharacterIndex(z);
++g_s._faithScore;
g_s._currPlace = LANDING;
g_msg[3] = MENU_DISCUSS;
@@ -1599,7 +1599,7 @@ void MortevielleEngine::endGame() {
// Most likely the double call is useless, thus removed
//
// tkey1(false);
- inzon();
+ resetVariables();
}
/**
@@ -1611,7 +1611,7 @@ void MortevielleEngine::loseGame() {
musique(0);
tkey1(false);
maivid();
- inzon();
+ resetVariables();
dprog();
g_vh = 10;
g_vm__ = 0;
diff --git a/engines/mortevielle/graphics.cpp b/engines/mortevielle/graphics.cpp
index 775075c35f..f3737607de 100644
--- a/engines/mortevielle/graphics.cpp
+++ b/engines/mortevielle/graphics.cpp
@@ -1067,26 +1067,27 @@ void ScreenSurface::writeg(const Common::String &l, int c) {
switch (c) {
case 1:
- case 3 : {
+ case 3: {
cecr = 0;
g_vm->_screenSurface.fillRect(15, Common::Rect(pt.x, pt.y, x, pt.y + 7));
- }
- break;
- case 4 : {
+ }
+ break;
+ case 4:
cecr = 0;
- }
- break;
- case 5 : {
+ break;
+ case 5:
cecr = 15;
- }
- break;
+ break;
case 0:
- case 2 : {
+ case 2: {
cecr = 15;
g_vm->_screenSurface.fillRect(0, Common::Rect(pt.x, pt.y, x, pt.y + 7));
+ }
+ break;
+ default:
+ break;
}
- break;
- }
+
pt.x += 1;
pt.y += 1;
for (x = 1; (x <= (int)l.size()) && (l[x - 1] != 0); ++x) {
diff --git a/engines/mortevielle/mor.cpp b/engines/mortevielle/mor.cpp
index ef5800e993..b3ae537768 100644
--- a/engines/mortevielle/mor.cpp
+++ b/engines/mortevielle/mor.cpp
@@ -286,13 +286,12 @@ void updateHour(int &day, int &hour, int &minute) {
hour = hour - ((day - g_vj) * 24);
}
-void conv(int x, int &y) {
- int cx = 1;
- y = 128;
- while (cx < x) {
- y = (uint)y >> 1;
- ++cx;
- }
+/**
+ * Engine function - Convert character index to bit index
+ * @remarks Originally called 'conv'
+ */
+int convertCharacterIndexToBitIndex(int characterIndex) {
+ return 128 >> (characterIndex - 1);
}
/* NIVEAU 12 */
@@ -465,29 +464,29 @@ void showPeoplePresent(int per) {
g_ipers = per;
}
-void choix(int min, int max, int &per) {
- bool i;
- int cz;
-
+int selectCharacters(int min, int max) {
+ bool invertSelection = false;
int rand = getRandomNumber(min, max);
+
if (rand > 4) {
rand = 8 - rand;
- i = true;
- } else
- i = false;
+ invertSelection = true;
+ }
int cx = 0;
- per = 0;
+ int retVal = 0;
while (cx < rand) {
- int cy = getRandomNumber(1, 8);
- conv(cy, cz);
- if ((per & cz) != cz) {
+ int charIndex = getRandomNumber(1, 8);
+ int charBitIndex = convertCharacterIndexToBitIndex(charIndex);
+ if ((retVal & charBitIndex) != charBitIndex) {
++cx;
- per |= cz;
+ retVal |= charBitIndex;
}
}
- if (i)
- per = 255 - per;
+ if (invertSelection)
+ retVal = 255 - retVal;
+
+ return retVal;
}
int cpl1() {
@@ -852,7 +851,7 @@ int setPresenceDiningRoom(int hour) {
min = 1;
max = 5;
}
- choix(min, max, retVal);
+ retVal = selectCharacters(min, max);
}
showPeoplePresent(retVal);
@@ -880,7 +879,7 @@ int setPresenceBureau(int hour) {
min = 1;
max = 2;
}
- choix(min, max, retVal);
+ retVal = selectCharacters(min, max);
}
showPeoplePresent(retVal);
@@ -917,8 +916,7 @@ int setPresenceLanding() {
((rand == 8) && g_bh5));
} while (test);
- int retVal = 0;
- conv(rand, retVal);
+ int retVal = convertCharacterIndexToBitIndex(rand);
showPeoplePresent(retVal);
return retVal;
@@ -945,7 +943,7 @@ int setPresenceChapel(int hour) {
min = 2;
max = 4;
}
- choix(min, max, retVal);
+ retVal = selectCharacters(min, max);
}
showPeoplePresent(retVal);
@@ -994,25 +992,31 @@ void nouvp(int l, int &p) {
showPeoplePresent(p);
}
+/**
+ * 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;
-void tip(int ip, int &cx) {
- if (ip == 128)
- cx = 1;
- else if (ip == 64)
- cx = 2;
- else if (ip == 32)
- cx = 3;
- else if (ip == 16)
- cx = 4;
- else if (ip == 8)
- cx = 5;
- else if (ip == 4)
- cx = 6;
- else if (ip == 2)
- cx = 7;
- else if (ip == 1)
- cx = 8;
+ return retVal;
}
@@ -1084,7 +1088,11 @@ void phaz(int &rand, int &p, int cf) {
rand = getRandomNumber(1, 100);
}
-void inzon() {
+/**
+ * Engine function - When restarting the game, reset the main variables used by the engine
+ * @remarks Originally called 'inzon'
+ */
+void resetVariables() {
copcha();
g_s._ipre = false;
diff --git a/engines/mortevielle/mor.h b/engines/mortevielle/mor.h
index 066392c879..4e35e19652 100644
--- a/engines/mortevielle/mor.h
+++ b/engines/mortevielle/mor.h
@@ -55,13 +55,13 @@ extern void clsf10();
extern void stop();
extern void paint_rect(int x, int y, int dx, int dy);
extern void updateHour(int &day, int &hour, int &minute);
-extern void conv(int x, int &y);
+extern int convertCharacterIndexToBitIndex(int characterIndex);
/* NIVEAU 12 */
extern void modobj(int m);
extern void repon(int f, int m);
extern void t5(int cx);
extern void showPeoplePresent(int per);
-extern void choix(int min, int max, int &per);
+extern int selectCharacters(int min, int max);
extern int cpl1();
extern int cpl2();
extern int cpl3();
@@ -91,13 +91,13 @@ extern int setPresenceLanding();
extern int setPresenceChapel(int hour);
extern void frap();
extern void nouvp(int l, int &p);
-extern void tip(int ip, int &cx);
+extern int convertBitIndexToCharacterIndex(int bitIndex);
extern void ecfren(int &p, int &rand, int cf, int l);
extern void becfren(int l);
/* NIVEAU 10 */
extern void init_nbrepm();
extern void phaz(int &rand, int &p, int cf);
-extern void inzon();
+extern void resetVariables();
extern void dprog();
extern void pl1(int cf);
extern void pl2(int cf);
diff --git a/engines/mortevielle/mor2.cpp b/engines/mortevielle/mor2.cpp
index 8776336002..d026ccf080 100644
--- a/engines/mortevielle/mor2.cpp
+++ b/engines/mortevielle/mor2.cpp
@@ -586,8 +586,7 @@ L1:
g_s._faithScore += 3 * (g_s._faithScore / 10);
tsort();
tmlieu(15);
- int cx;
- tip(g_ipers, cx);
+ int cx = convertBitIndexToCharacterIndex(g_ipers);
g_caff = 69 + cx;
g_crep = g_caff;
g_msg[3] = MENU_DISCUSS;