MORTEVIELLE: More renaming, add a piece of code to improve CGA/EGA switching

This commit is contained in:
Strangerke 2012-03-23 23:26:27 +01:00
parent 0111cea7d7
commit cdcb8d3645
13 changed files with 828 additions and 853 deletions

File diff suppressed because it is too large Load Diff

View File

@ -76,7 +76,7 @@ int Alert::show(const Common::String &msg, int n) {
while ((chaine[i + 1] != '\174') && (chaine[i + 1] != '\135')) {
++i;
st = st + chaine[i];
if (g_res == 2)
if (g_vm->_res == 2)
curPos.x -= 3;
else
curPos.x -= 5;
@ -93,12 +93,12 @@ int Alert::show(const Common::String &msg, int n) {
esp = (uint)(nbcol - caseNumb * 40) >> 1;
coldep = 320 - ((uint)nbcol >> 1) + ((uint)esp >> 1);
setButtonText(cas, coldep, caseNumb, &s[0], esp);
limit[1][1] = ((uint)(coldep) >> 1) * g_res;
limit[1][1] = ((uint)(coldep) >> 1) * g_vm->_res;
limit[1][2] = limit[1][1] + 40;
if (caseNumb == 1) {
limit[2][1] = limit[2][2];
} else {
limit[2][1] = ((uint)(320 + ((uint)esp >> 1)) >> 1) * g_res;
limit[2][1] = ((uint)(320 + ((uint)esp >> 1)) >> 1) * g_vm->_res;
limit[2][2] = (limit[2][1]) + 40;
}
g_vm->_mouse.showMouse();
@ -218,7 +218,7 @@ void Alert::decodeAlertDetails(Common::String inputStr, int &choiceNumb, int &li
}
++i;
choiceListStr = g_vm->copy(inputStr, i, 30);
if (g_res == 2)
if (g_vm->_res == 2)
col *= 6;
else
col *= 10;
@ -302,7 +302,7 @@ bool KnowledgeCheck::show() {
g_vm->hirs();
g_vm->_mouse.showMouse();
int dialogHeight;
if (g_res == 1)
if (g_vm->_res == 1)
dialogHeight = 29;
else
dialogHeight = 23;
@ -331,8 +331,8 @@ bool KnowledgeCheck::show() {
}
for (int j = 1; j <= lastOption - firstOption + 1; ++j) {
coor[j]._x1 = 45 * g_res;
coor[j]._x2 = (maxLength * 3 + 55) * g_res;
coor[j]._x1 = 45 * g_vm->_res;
coor[j]._x2 = (maxLength * 3 + 55) * g_vm->_res;
coor[j]._y1 = 27 + j * 8;
coor[j]._y2 = 34 + j * 8;
coor[j]._enabled = true;
@ -342,7 +342,7 @@ bool KnowledgeCheck::show() {
}
}
coor[lastOption - firstOption + 2]._enabled = false;
if (g_res == 1)
if (g_vm->_res == 1)
rep = 10;
else
rep = 6;
@ -424,7 +424,7 @@ void f3f8::checkForF8(int SpeechNum, bool drawAni50Fl) {
teskbd();
do {
g_vm->_speechManager.startSpeech(SpeechNum, 0, 0);
g_key = waitForF3F8();
g_vm->_key = waitForF3F8();
CHECK_QUIT;
if (g_vm->_newGraphicalDevice != g_vm->_currGraphicalDevice) {
@ -432,7 +432,7 @@ void f3f8::checkForF8(int SpeechNum, bool drawAni50Fl) {
g_vm->hirs();
aff50(drawAni50Fl);
}
} while (g_key != 66); // keycode for F8
} while (g_vm->_key != 66); // keycode for F8
}
/**
@ -452,27 +452,26 @@ int f3f8::waitForF3F8() {
}
void f3f8::aff50(bool drawAni50Fl) {
g_caff = 50;
g_maff = 0;
g_vm->_caff = 50;
g_vm->_maff = 0;
taffich();
g_vm->draw(g_ades, 63, 12);
g_vm->draw(kAdrDes, 63, 12);
if (drawAni50Fl)
ani50();
else
repon(2, kDialogStringIndex + 142);
g_vm->repon(2, kDialogStringIndex + 142);
// Draw the f3/f8 dialog
draw();
}
void f3f8::ani50() {
g_crep = animof(1, 1);
pictout(kAdrAni, g_crep, 63, 12);
g_crep = animof(2, 1);
pictout(kAdrAni, g_crep, 63, 12);
g_vm->_largestClearScreen = (g_res == 1);
repon(2, kDialogStringIndex + 143);
g_vm->_crep = g_vm->animof(1, 1);
g_vm->pictout(kAdrAni, g_vm->_crep, 63, 12);
g_vm->_crep = g_vm->animof(2, 1);
g_vm->pictout(kAdrAni, g_vm->_crep, 63, 12);
g_vm->_largestClearScreen = (g_vm->_res == 1);
g_vm->repon(2, kDialogStringIndex + 143);
}
} // End of namespace Mortevielle

View File

@ -992,7 +992,7 @@ void ScreenSurface::writeCharacter(const Common::Point &pt, unsigned char ch, in
* simulate the original 640x400 surface, all Y values have to be doubled
*/
void ScreenSurface::drawBox(int x, int y, int dx, int dy, int col) {
if (g_res == 1) {
if (g_vm->_res == 1) {
x = (uint)x >> 1;
dx = (uint)dx >> 1;
}
@ -1059,7 +1059,7 @@ void ScreenSurface::drawString(const Common::String &l, int command) {
g_vm->_mouse.hideMouse();
pt = _textPos;
if (g_res == 2)
if (g_vm->_res == 2)
i = 6;
else
i = 10;
@ -1101,7 +1101,7 @@ void ScreenSurface::drawString(const Common::String &l, int command) {
* Gets the width in pixels of the specified string
*/
int ScreenSurface::getStringWidth(const Common::String &s) {
int charWidth = (g_res == 2) ? 6 : 10;
int charWidth = (g_vm->_res == 2) ? 6 : 10;
return s.size() * charWidth;
}

View File

@ -180,7 +180,7 @@ void Menu::displayMenu() {
g_vm->_mouse.hideMouse();
g_vm->_screenSurface.fillRect(7, Common::Rect(0, 0, 639, 10));
col = 28 * g_res;
col = 28 * g_vm->_res;
if (g_vm->_currGraphicalDevice == MODE_CGA)
color = 1;
else
@ -209,7 +209,7 @@ void Menu::displayMenu() {
} while (k != 3);
++y;
} while (y != 9);
col += 48 * g_res;
col += 48 * g_vm->_res;
} while (num_letr != 6);
g_vm->_mouse.showMouse();
}
@ -286,14 +286,14 @@ void Menu::util(Common::Point pos) {
int ymx = (_menuConstants[_msg3 - 1][3] << 3) + 16;
int dxcar = _menuConstants[_msg3 - 1][2];
int xmn = (_menuConstants[_msg3 - 1][0] << 2) * g_res;
int xmn = (_menuConstants[_msg3 - 1][0] << 2) * g_vm->_res;
int ix;
if (g_res == 1)
if (g_vm->_res == 1)
ix = 5;
else
ix = 3;
int xmx = dxcar * ix * g_res + xmn + 2;
int xmx = dxcar * ix * g_vm->_res + xmn + 2;
if ((pos.x > xmn) && (pos.x < xmx) && (pos.y < ymx) && (pos.y > 15)) {
ix = (((uint)pos.y >> 3) - 1) + (_msg3 << 8);
if (ix != _msg4) {
@ -325,7 +325,7 @@ void Menu::menuDown(int ii) {
g_vm->_mouse.hideMouse();
sauvecr(10, (_menuConstants[ii - 1][1] + 1) << 1);
xco = xco << 3;
if (g_res == 1)
if (g_vm->_res == 1)
cx = 10;
else
cx = 6;
@ -437,24 +437,24 @@ void Menu::mdn() {
g_vm->_prevPos = curPos;
bool tes = (curPos.y < 11)
&& ((curPos.x >= (28 * g_res) && curPos.x <= (28 * g_res + 24))
|| (curPos.x >= (76 * g_res) && curPos.x <= (76 * g_res + 24))
|| ((curPos.x > 124 * g_res) && (curPos.x < 124 * g_res + 24))
|| ((curPos.x > 172 * g_res) && (curPos.x < 172 * g_res + 24))
|| ((curPos.x > 220 * g_res) && (curPos.x < 220 * g_res + 24))
|| ((curPos.x > 268 * g_res) && (curPos.x < 268 * g_res + 24)));
&& ((curPos.x >= (28 * g_vm->_res) && curPos.x <= (28 * g_vm->_res + 24))
|| (curPos.x >= (76 * g_vm->_res) && curPos.x <= (76 * g_vm->_res + 24))
|| ((curPos.x > 124 * g_vm->_res) && (curPos.x < 124 * g_vm->_res + 24))
|| ((curPos.x > 172 * g_vm->_res) && (curPos.x < 172 * g_vm->_res + 24))
|| ((curPos.x > 220 * g_vm->_res) && (curPos.x < 220 * g_vm->_res + 24))
|| ((curPos.x > 268 * g_vm->_res) && (curPos.x < 268 * g_vm->_res + 24)));
if (tes) {
int ix;
if (curPos.x < 76 * g_res)
if (curPos.x < 76 * g_vm->_res)
ix = MENU_INVENTORY;
else if (curPos.x < 124 * g_res)
else if (curPos.x < 124 * g_vm->_res)
ix = MENU_MOVE;
else if (curPos.x < 172 * g_res)
else if (curPos.x < 172 * g_vm->_res)
ix = MENU_ACTION;
else if (curPos.x < 220 * g_res)
else if (curPos.x < 220 * g_vm->_res)
ix = MENU_SELF;
else if (curPos.x < 268 * g_res)
else if (curPos.x < 268 * g_vm->_res)
ix = MENU_DISCUSS;
else
ix = MENU_FILE;

View File

@ -44,147 +44,6 @@
namespace Mortevielle {
void pictout(int seg, int dep, int x, int y) {
GfxSurface surface;
surface.decode(&g_vm->_mem[seg * 16 + dep]);
if (g_vm->_currGraphicalDevice == MODE_HERCULES) {
g_vm->_mem[0x7000 * 16 + 2] = 0;
g_vm->_mem[0x7000 * 16 + 32] = 15;
}
if ((g_caff != 51) && (READ_LE_UINT16(&g_vm->_mem[0x7000 * 16 + 0x4138]) > 0x100))
WRITE_LE_UINT16(&g_vm->_mem[0x7000 * 16 + 0x4138], 0x100);
g_vm->_screenSurface.drawPicture(surface, x, y);
}
void adzon() {
Common::File f;
if (!f.open("don.mor"))
error("Missing file - don.mor");
f.read(g_vm->_tabdon, 7 * 256);
f.close();
if (!f.open("bmor.mor"))
error("Missing file - bmor.mor");
f.read(&g_vm->_tabdon[fleche], 1 * 1916);
f.close();
if (!f.open("dec.mor"))
error("Missing file - dec.mor");
f.read(&g_vm->_mem[0x73a2 * 16 + 0], 1 * 1664);
f.close();
}
/**
* Returns the offset within the compressed image data resource of the desired image
*/
int animof(int ouf, int num) {
int nani = g_vm->_mem[kAdrAni * 16 + 1];
int aux = num;
if (ouf != 1)
aux += nani;
int animof_result = (nani << 2) + 2 + READ_BE_UINT16(&g_vm->_mem[kAdrAni * 16 + (aux << 1)]);
return animof_result;
}
void modif(int &nu) {
if (nu == 26)
nu = 25;
else if ((nu > 29) && (nu < 36))
nu -= 4;
else if ((nu > 69) && (nu < 78))
nu -= 37;
else if ((nu > 99) && (nu < 194))
nu -= 59;
else if ((nu > 996) && (nu < 1000))
nu -= 862;
else if ((nu > 1500) && (nu < 1507))
nu -= 1363;
else if ((nu > 1507) && (nu < 1513))
nu -= 1364;
else if ((nu > 1999) && (nu < 2002))
nu -= 1851;
else if (nu == 2010)
nu = 151;
else if ((nu > 2011) && (nu < 2025))
nu -= 1860;
else if (nu == 2026)
nu = 165;
else if ((nu > 2029) && (nu < 2037))
nu -= 1864;
else if ((nu > 3000) && (nu < 3005))
nu -= 2828;
else if (nu == 4100)
nu = 177;
else if (nu == 4150)
nu = 178;
else if ((nu > 4151) && (nu < 4156))
nu -= 3973;
else if (nu == 4157)
nu = 183;
else if ((nu == 4160) || (nu == 4161))
nu -= 3976;
}
/* NIVEAU 13 */
void text1(int x, int y, int nb, int m) {
int co;
if (g_res == 1)
co = 10;
else
co = 6;
Common::String tmpStr = g_vm->getString(m);
if ((y == 182) && ((int) tmpStr.size() * co > nb * 6))
y = 176;
displayStr(tmpStr, x, y, nb, 20, g_vm->_textColor);
}
void initouv() {
for (int cx = 1; cx <= 7; ++cx)
g_vm->_touv[cx] = chr(0);
}
void ecr2(Common::String str_) {
// Some dead code was present in the original: removed
g_vm->_screenSurface.putxy(8, 177);
int tlig = 59 + (g_res - 1) * 36;
if ((int)str_.size() < tlig)
g_vm->_screenSurface.drawString(str_, 5);
else if ((int)str_.size() < (tlig << 1)) {
g_vm->_screenSurface.putxy(8, 176);
g_vm->_screenSurface.drawString(g_vm->copy(str_, 1, (tlig - 1)), 5);
g_vm->_screenSurface.putxy(8, 182);
g_vm->_screenSurface.drawString(g_vm->copy(str_, tlig, tlig << 1), 5);
} else {
g_vm->_largestClearScreen = true;
g_vm->clearScreenType2();
g_vm->_screenSurface.putxy(8, 176);
g_vm->_screenSurface.drawString(g_vm->copy(str_, 1, (tlig - 1)), 5);
g_vm->_screenSurface.putxy(8, 182);
g_vm->_screenSurface.drawString(g_vm->copy(str_, tlig, ((tlig << 1) - 1)), 5);
g_vm->_screenSurface.putxy(8, 190);
g_vm->_screenSurface.drawString(g_vm->copy(str_, tlig << 1, tlig * 3), 5);
}
}
void ecr3(Common::String text) {
g_vm->clearScreenType3();
g_vm->_screenSurface.putxy(8, 192);
g_vm->_screenSurface.drawString(text, 5);
}
void paint_rect(int x, int y, int dx, int dy) {
int co;
@ -206,59 +65,6 @@ void modobj(int m) {
g_vm->_menu.disableMenuItem(g_vm->_menu._inventoryMenu[8]);
}
void repon(int f, int m) {
if ((m > 499) && (m < 563)) {
Common::String tmpStr = g_vm->getString(m - 501 + kInventoryStringIndex);
if ((int) tmpStr.size() > ((58 + (g_res - 1) * 37) << 1))
g_vm->_largestClearScreen = true;
else
g_vm->_largestClearScreen = false;
g_vm->clearScreenType2();
displayStr(tmpStr, 8, 176, 85, 3, 5);
} else {
modif(m);
switch (f) {
case 2:
case 8:
g_vm->clearScreenType2();
g_vm->prepareScreenType2();
text1(8, 182, 103, m);
if ((m == 68) || (m == 69))
g_vm->_coreVar._teauto[40] = '*';
if ((m == 104) && (g_caff == 14)) {
g_vm->_coreVar._teauto[36] = '*';
if (g_vm->_coreVar._teauto[39] == '*') {
g_vm->_coreVar._pourc[3] = '*';
g_vm->_coreVar._teauto[38] = '*';
}
}
break;
case 1:
case 6:
case 9: {
int i;
if ((f == 1) || (f == 6))
i = 4;
else
i = 5;
Common::String tmpStr = g_vm->getString(m);
displayStr(tmpStr, 80, 40, 60, 25, i);
if (m == 180)
g_vm->_coreVar._pourc[6] = '*';
else if (m == 179)
g_vm->_coreVar._pourc[10] = '*';
}
break;
default:
break;
}
}
}
int chlm() {
int retval = g_vm->getRandomNumber(1, 2);
if (retval == 2)
@ -272,12 +78,12 @@ int chlm() {
*************/
void debloc(int roomId) {
g_num = 0;
g_x = 0;
g_y = 0;
g_vm->_num = 0;
g_vm->_x = 0;
g_vm->_y = 0;
if ((roomId != ROOM26) && (roomId != LANDING))
g_vm->resetPresenceInRooms(roomId);
g_mpers = g_vm->_currBitIndex;
g_vm->_savedBitIndex = g_vm->_currBitIndex;
}
void ecfren(int &p, int &rand, int cf, int roomId) {
@ -412,37 +218,20 @@ int t11(int roomId) {
return retVal;
}
void cavegre() {
g_vm->_coreVar._faithScore += 2;
if (g_vm->_coreVar._faithScore > 69)
g_vm->_coreVar._faithScore += (g_vm->_coreVar._faithScore / 10);
g_vm->clearScreenType3();
g_vm->prepareScreenType2();
ecr3(g_vm->getEngineString(S_SOMEONE_ENTERS));
int rand = (g_vm->getRandomNumber(0, 4)) - 2;
g_vm->_speechManager.startSpeech(2, rand, 1);
// The original was doing here a useless loop.
// It has been removed
g_vm->clearScreenType3();
g_vm->displayAloneText();
}
void writetp(Common::String s, int t) {
if (g_res == 2)
if (g_vm->_res == 2)
g_vm->_screenSurface.drawString(s, t);
else
g_vm->_screenSurface.drawString(g_vm->copy(s, 1, 25), t);
}
void aniof(int ouf, int num) {
if ((g_caff == 7) && ((num == 4) || (num == 5)))
if ((g_vm->_caff == 7) && ((num == 4) || (num == 5)))
return;
if ((g_caff == 10) && (num == 7))
if ((g_vm->_caff == 10) && (num == 7))
num = 6;
else if (g_caff == 12) {
else if (g_vm->_caff == 12) {
if (num == 3)
num = 4;
else if (num == 4)
@ -450,7 +239,7 @@ void aniof(int ouf, int num) {
}
int ad = kAdrAni;
int offset = animof(ouf, num);
int offset = g_vm->animof(ouf, num);
GfxSurface surface;
surface.decode(&g_vm->_mem[ad * 16 + offset]);
@ -462,39 +251,39 @@ void aniof(int ouf, int num) {
/* NIVEAU 9 */
void dessin(int ad) {
if (ad != 0)
g_vm->draw(g_ades, ((ad % 160) * 2), (ad / 160));
g_vm->draw(kAdrDes, ((ad % 160) * 2), (ad / 160));
else {
g_vm->clearScreenType1();
if (g_caff > 99) {
g_vm->draw(g_ades, 60, 33);
if (g_vm->_caff > 99) {
g_vm->draw(kAdrDes, 60, 33);
g_vm->_screenSurface.drawBox(118, 32, 291, 121, 15); // Medium box
} else if (g_caff > 69) {
g_vm->draw(g_ades, 112, 48); // Heads
} else if (g_vm->_caff > 69) {
g_vm->draw(kAdrDes, 112, 48); // Heads
g_vm->_screenSurface.drawBox(222, 47, 155, 91, 15);
} else {
g_vm->draw(g_ades, 0, 12);
g_vm->draw(kAdrDes, 0, 12);
g_vm->prepareScreenType1();
if ((g_caff < 30) || (g_caff > 32)) {
if ((g_vm->_caff < 30) || (g_vm->_caff > 32)) {
for (int cx = 1; cx <= 6; ++cx) {
if (ord(g_vm->_touv[cx]) != 0)
aniof(1, ord(g_vm->_touv[cx]));
}
if (g_caff == 13) {
if (g_vm->_caff == 13) {
if (g_vm->_coreVar._atticBallHoleObjectId == 141)
aniof(1, 7);
if (g_vm->_coreVar._atticRodHoleObjectId == 159)
aniof(1, 6);
} else if ((g_caff == 14) && (g_vm->_coreVar._cellarObjectId == 151))
} else if ((g_vm->_caff == 14) && (g_vm->_coreVar._cellarObjectId == 151))
aniof(1, 2);
else if ((g_caff == 17) && (g_vm->_coreVar._secretPassageObjectId == 143))
else if ((g_vm->_caff == 17) && (g_vm->_coreVar._secretPassageObjectId == 143))
aniof(1, 1);
else if ((g_caff == 24) && (g_vm->_coreVar._wellObjectId != 0))
else if ((g_vm->_caff == 24) && (g_vm->_coreVar._wellObjectId != 0))
aniof(1, 1);
}
if (g_caff < ROOM26)
if (g_vm->_caff < ROOM26)
g_vm->startMusicOrSpeech(1);
}
}
@ -533,7 +322,8 @@ void tkey1(bool d) {
// Wait for release from any key or mouse button
while (g_vm->keyPressed())
g_key = testou();
g_vm->_key = testou();
do {
g_vm->_mouse.getMousePosition(x, y, c);
g_vm->keyPressed();
@ -555,24 +345,24 @@ void tkey1(bool d) {
/* NIVEAU 7 */
void tlu(int af, int ob) {
g_caff = 32;
g_vm->_caff = 32;
afdes();
repon(6, ob + 4000);
repon(2, 999);
g_vm->repon(6, ob + 4000);
g_vm->repon(2, 999);
tkey1(true);
g_caff = af;
g_vm->_caff = af;
g_vm->_msg[3] = OPCODE_NONE;
g_crep = 998;
g_vm->_crep = 998;
}
void affrep() {
g_caff = g_vm->_coreVar._currPlace;
g_crep = g_vm->_coreVar._currPlace;
g_vm->_caff = g_vm->_coreVar._currPlace;
g_vm->_crep = g_vm->_coreVar._currPlace;
}
void tsort() {
if ((g_iouv > 0) && (g_vm->_coreVar._currPlace != 0)) {
if ((g_vm->_iouv > 0) && (g_vm->_coreVar._currPlace != 0)) {
if (g_vm->_coreVar._faithScore < 50)
g_vm->_coreVar._faithScore += 2;
else
@ -581,24 +371,24 @@ void tsort() {
for (int cx = 1; cx <= 7; ++cx)
g_vm->_touv[cx] = chr(0);
g_ment = 0;
g_iouv = 0;
g_vm->_ment = 0;
g_vm->_iouv = 0;
g_vm->_mchai = 0;
debloc(g_vm->_coreVar._currPlace);
}
void st4(int ob) {
g_crep = 997;
g_vm->_crep = 997;
switch (ob) {
case 114 :
g_crep = 109;
g_vm->_crep = 109;
break;
case 110 :
g_crep = 107;
g_vm->_crep = 107;
break;
case 158 :
g_crep = 113;
g_vm->_crep = 113;
break;
case 152:
case 153:
@ -610,7 +400,7 @@ void st4(int ob) {
case 157:
case 160:
case 161 :
tlu(g_caff, ob);
tlu(g_vm->_caff, ob);
break;
default:
break;
@ -645,7 +435,7 @@ void mennor() {
}
void premtet() {
g_vm->draw(g_ades, 10, 80);
g_vm->draw(kAdrDes, 10, 80);
g_vm->_screenSurface.drawBox(18, 79, 155, 91, 15);
}
@ -660,7 +450,7 @@ void ajchai() {
if (g_vm->_tabdon[cy + cx] == 0)
g_vm->_tabdon[cy + cx] = g_vm->_coreVar._selectedObjectId;
else
g_crep = 192;
g_vm->_crep = 192;
}
void ajjer(int ob) {
@ -673,32 +463,26 @@ void ajjer(int ob) {
g_vm->_coreVar._sjer[(cx)] = chr(ob);
modinv();
} else
g_crep = 139;
g_vm->_crep = 139;
}
void tctrm() {
repon(2, (3000 + g_ctrm));
g_ctrm = 0;
}
void quelquun() {
if (g_vm->_menu._menuDisplayed)
g_vm->_menu.eraseMenu();
g_vm->endSearch();
g_crep = 997;
g_vm->_crep = 997;
L1:
if (!g_vm->_hiddenHero) {
if (g_crep == 997)
g_crep = 138;
repon(2, g_crep);
if (g_crep == 138)
if (g_vm->_crep == 997)
g_vm->_crep = 138;
g_vm->repon(2, g_vm->_crep);
if (g_vm->_crep == 138)
g_vm->_speechManager.startSpeech(5, 2, 1);
else
g_vm->_speechManager.startSpeech(4, 4, 1);
if (g_iouv == 0)
if (g_vm->_iouv == 0)
g_vm->_coreVar._faithScore += 2;
else if (g_vm->_coreVar._faithScore < 50)
g_vm->_coreVar._faithScore += 4;
@ -707,8 +491,8 @@ L1:
tsort();
g_vm->_menu.setDestinationMenuText(LANDING);
int cx = g_vm->convertBitIndexToCharacterIndex(g_vm->_currBitIndex);
g_caff = 69 + cx;
g_crep = g_caff;
g_vm->_caff = 69 + cx;
g_vm->_crep = g_vm->_caff;
g_vm->_msg[3] = MENU_DISCUSS;
g_vm->_msg[4] = g_vm->_menu._discussMenu[cx];
g_vm->_syn = true;
@ -716,10 +500,10 @@ L1:
} else {
if (g_vm->getRandomNumber(1, 3) == 2) {
g_vm->_hiddenHero = false;
g_crep = 137;
g_vm->_crep = 137;
goto L1;
} else {
repon(2, 136);
g_vm->repon(2, 136);
int rand = (g_vm->getRandomNumber(0, 4)) - 2;
g_vm->_speechManager.startSpeech(3, rand, 1);
g_vm->clearScreenType2();
@ -740,22 +524,22 @@ void tsuiv() {
int cx = 0;
do {
++cx;
++g_cs;
cl = cy + g_cs;
++g_vm->_cs;
cl = cy + g_vm->_cs;
tbcl = g_vm->_tabdon[cl];
} while ((tbcl == 0) && (g_cs <= 9));
} while ((tbcl == 0) && (g_vm->_cs <= 9));
if ((tbcl != 0) && (g_cs < 11)) {
++g_vm->g_is;
g_caff = tbcl;
g_crep = g_caff + 400;
if ((tbcl != 0) && (g_vm->_cs < 11)) {
++g_vm->_is;
g_vm->_caff = tbcl;
g_vm->_crep = g_vm->_caff + 400;
if (g_vm->_currBitIndex != 0)
g_vm->_coreVar._faithScore += 2;
} else {
affrep();
g_vm->endSearch();
if (cx > 9)
g_crep = 131;
g_vm->_crep = 131;
}
}
@ -763,7 +547,7 @@ void tfleche() {
bool qust;
char touch;
if (g_num == 9999)
if (g_vm->_num == 9999)
return;
fenat(chr(152));
@ -776,20 +560,20 @@ void tfleche() {
CHECK_QUIT;
if (g_vm->getMouseClick())
inRect = (g_vm->_mouse._pos.x < 256 * g_res) && (g_vm->_mouse._pos.y < 176) && (g_vm->_mouse._pos.y > 12);
inRect = (g_vm->_mouse._pos.x < 256 * g_vm->_res) && (g_vm->_mouse._pos.y < 176) && (g_vm->_mouse._pos.y > 12);
g_vm->prepareRoom();
} while (!(qust || inRect || g_vm->_anyone));
if (qust && (touch == '\103'))
Alert::show(g_vm->_hintPctMessage, 1);
} while (!((touch == '\73') || ((touch == '\104') && (g_x != 0) && (g_y != 0)) || (g_vm->_anyone) || (inRect)));
} while (!((touch == '\73') || ((touch == '\104') && (g_vm->_x != 0) && (g_vm->_y != 0)) || (g_vm->_anyone) || (inRect)));
if (touch == '\73')
g_vm->_keyPressedEsc = true;
if (inRect) {
g_x = g_vm->_mouse._pos.x;
g_y = g_vm->_mouse._pos.y;
g_vm->_x = g_vm->_mouse._pos.x;
g_vm->_y = g_vm->_mouse._pos.y;
}
}
@ -798,23 +582,23 @@ void tcoord(int sx) {
int ib;
g_num = 0;
g_crep = 999;
g_vm->_num = 0;
g_vm->_crep = 999;
int a = 0;
int atdon = amzon + 3;
int cy = 0;
while (cy < g_caff) {
while (cy < g_vm->_caff) {
a += g_vm->_tabdon[atdon];
atdon += 4;
++cy;
}
if (g_vm->_tabdon[atdon] == 0) {
g_crep = 997;
g_vm->_crep = 997;
return;
}
a += fleche;
a += kFleche;
int cb = 0;
for (cy = 0; cy <= (sx - 2); ++cy) {
ib = (g_vm->_tabdon[a + cb] << 8) + g_vm->_tabdon[(a + cb + 1)];
@ -822,27 +606,27 @@ void tcoord(int sx) {
}
ib = (g_vm->_tabdon[a + cb] << 8) + g_vm->_tabdon[(a + cb + 1)];
if (ib == 0) {
g_crep = 997;
g_vm->_crep = 997;
return;
}
cy = 1;
do {
cb += 2;
sx = g_vm->_tabdon[a + cb] * g_res;
sx = g_vm->_tabdon[a + cb] * g_vm->_res;
sy = g_vm->_tabdon[(a + cb + 1)];
cb += 2;
ix = g_vm->_tabdon[a + cb] * g_res;
ix = g_vm->_tabdon[a + cb] * g_vm->_res;
iy = g_vm->_tabdon[(a + cb + 1)];
++cy;
} while (!(((g_x >= sx) && (g_x <= ix) && (g_y >= sy) && (g_y <= iy)) || (cy > ib)));
} while (!(((g_vm->_x >= sx) && (g_vm->_x <= ix) && (g_vm->_y >= sy) && (g_vm->_y <= iy)) || (cy > ib)));
if ((g_x >= sx) && (g_x <= ix) && (g_y >= sy) && (g_y <= iy)) {
g_num = cy - 1;
if ((g_vm->_x >= sx) && (g_vm->_x <= ix) && (g_vm->_y >= sy) && (g_vm->_y <= iy)) {
g_vm->_num = cy - 1;
return;
}
g_crep = 997;
g_vm->_crep = 997;
}
@ -850,51 +634,51 @@ void st7(int ob) {
switch (ob) {
case 116:
case 144:
g_crep = 104;
g_vm->_crep = 104;
break;
case 126:
case 111:
g_crep = 108;
g_vm->_crep = 108;
break;
case 132:
g_crep = 111;
g_vm->_crep = 111;
break;
case 142:
g_crep = 112;
g_vm->_crep = 112;
break;
default:
g_crep = 183;
g_vm->_crep = 183;
st4(ob);
}
}
void treg(int ob) {
int mdes = g_caff;
g_caff = ob;
int mdes = g_vm->_caff;
g_vm->_caff = ob;
if (((g_caff > 29) && (g_caff < 33)) || (g_caff == 144) || (g_caff == 147) || (g_caff == 149) || (g_vm->_msg[4] == OPCODE_SLOOK)) {
if (((g_vm->_caff > 29) && (g_vm->_caff < 33)) || (g_vm->_caff == 144) || (g_vm->_caff == 147) || (g_vm->_caff == 149) || (g_vm->_msg[4] == OPCODE_SLOOK)) {
afdes();
if ((g_caff > 29) && (g_caff < 33))
repon(2, g_caff);
if ((g_vm->_caff > 29) && (g_vm->_caff < 33))
g_vm->repon(2, g_vm->_caff);
else
repon(2, g_caff + 400);
g_vm->repon(2, g_vm->_caff + 400);
tkey1(true);
g_caff = mdes;
g_vm->_caff = mdes;
g_vm->_msg[3] = 0;
g_crep = 998;
g_vm->_crep = 998;
} else {
g_vm->_obpart = true;
g_crep = g_caff + 400;
g_vm->_crep = g_vm->_caff + 400;
g_vm->_menu.setSearchMenu();
}
}
void avpoing(int &ob) {
g_crep = 999;
g_vm->_crep = 999;
if (g_vm->_coreVar._selectedObjectId != 0)
ajjer(g_vm->_coreVar._selectedObjectId);
if (g_crep != 139) {
if (g_vm->_crep != 139) {
modobj(ob + 400);
g_vm->_coreVar._selectedObjectId = ob;
ob = 0;
@ -906,12 +690,12 @@ void rechai(int &ch) {
if (g_vm->_coreVar._currPlace == CRYPT)
tmpPlace = CELLAR;
ch = g_vm->_tabdon[achai + (tmpPlace * 7) + g_num - 1];
ch = g_vm->_tabdon[achai + (tmpPlace * 7) + g_vm->_num - 1];
}
int t23coul() {
if (!g_vm->checkInventory(143)) {
g_crep = 1512;
g_vm->_crep = 1512;
g_vm->loseGame();
}
@ -929,9 +713,9 @@ void st13(int ob) {
(ob == 110) || (ob == 153) || (ob == 154) || (ob == 155) ||
(ob == 156) || (ob == 157) || (ob == 144) || (ob == 158) ||
(ob == 150) || (ob == 152))
g_crep = 999;
g_vm->_crep = 999;
else
g_crep = 105;
g_vm->_crep = 105;
}
void sauvecr(int y, int dy) {

View File

@ -42,24 +42,11 @@ static const int _actionMenu[12] = { OPCODE_NONE,
OPCODE_PLACE, OPCODE_OPEN, OPCODE_LEAVE
};
extern void pictout(int seg, int dep, int x, int y);
extern void sauvecr(int y, int dy);
extern void charecr(int y, int dy);
extern void adzon();
extern int animof(int ouf, int num);
/* Niveau 14 suite */
extern void modif(int &nu);
/* NIVEAU 13 */
extern void text1(int x, int y, int nb, int m);
extern void initouv();
extern void ecr2(Common::String str_);
extern void ecr3(Common::String text);
extern void paint_rect(int x, int y, int dx, int dy);
/* NIVEAU 12 */
extern void modobj(int m);
extern void repon(int f, int m);
extern int chlm();
extern void drawClock();
/*************
* NIVEAU 11 *
*************/
@ -70,7 +57,6 @@ extern void becfren(int roomId);
extern void init_nbrepm();
extern void phaz(int &rand, int &p, int cf);
extern int t11(int roomId);
extern void cavegre();
extern void writetp(Common::String s, int t);
extern void aniof(int ouf, int num);
/* NIVEAU 9 */
@ -91,7 +77,6 @@ extern void premtet();
/* NIVEAU 5 */
extern void ajchai();
extern void ajjer(int ob);
extern void tctrm();
extern void quelquun();
extern void tsuiv();
extern void tfleche();
@ -104,5 +89,7 @@ extern int t23coul();
extern void maivid();
extern void st13(int ob);
extern void sauvecr(int y, int dy);
extern void charecr(int y, int dy);
} // End of namespace Mortevielle
#endif

View File

@ -175,7 +175,7 @@ Common::ErrorCode MortevielleEngine::initialise() {
// Set the screen mode
_currGraphicalDevice = MODE_EGA;
g_res = 2;
_res = 2;
_txxFileFl = false;
// Load texts from TXX files
@ -216,7 +216,6 @@ Common::ErrorCode MortevielleEngine::initialise() {
if (_newGraphicalDevice != _currGraphicalDevice)
_currGraphicalDevice = _newGraphicalDevice;
hirs();
g_ades = 0x7000;
return Common::kNoError;
}
@ -563,7 +562,7 @@ void MortevielleEngine::mainGame() {
if (_reloadCFIEC)
loadCFIEC();
for (g_crep = 1; g_crep <= _c_zzz; ++g_crep)
for (_crep = 1; _crep <= _c_zzz; ++_crep)
decodeNumber(&_cfiecBuffer[161 * 16], ((822 * 128) - (161 * 16)) / 64);
loadBRUIT5();
@ -613,12 +612,12 @@ void MortevielleEngine::handleAction() {
clearScreenType3();
oo = false;
g_ctrm = 0;
_controlMenu = 0;
if (!_keyPressedEsc) {
_menu.drawMenu();
_menu._menuDisplayed = true;
temps = 0;
g_key = 0;
_key = 0;
funct = false;
inkey = '.';
@ -654,8 +653,8 @@ void MortevielleEngine::handleAction() {
} else
return;
} else if (inkey == '\104') {
if ((g_x != 0) && (g_y != 0))
g_num = 9999;
if ((_x != 0) && (_y != 0))
_num = 9999;
return;
}
}
@ -667,8 +666,8 @@ void MortevielleEngine::handleAction() {
return;
if (temps > lim) {
repon(2, 141);
if (g_num == 9999)
g_num = 0;
if (_num == 9999)
_num = 0;
} else {
_menuOpcode = _msg[3];
if ((_msg[3] == MENU_ACTION) || (_msg[3] == MENU_SELF))
@ -682,8 +681,8 @@ void MortevielleEngine::handleAction() {
oo = true;
if ((_msg[4] == OPCODE_LIFT) || (_obpart)) {
endSearch();
g_caff = _coreVar._currPlace;
g_crep = 998;
_caff = _coreVar._currPlace;
_crep = 998;
} else
tsuiv();
mennor();
@ -694,18 +693,18 @@ void MortevielleEngine::handleAction() {
if (! oo)
handleOpcode();
if ((g_ctrm == 0) && (! _loseGame) && (! _endGame)) {
if ((_controlMenu == 0) && (! _loseGame) && (! _endGame)) {
taffich();
if (_okdes) {
_okdes = false;
dessin(0);
}
if ((!_syn) || (_col))
repon(2, g_crep);
repon(2, _crep);
}
} while (_syn);
if (g_ctrm != 0)
tctrm();
if (_controlMenu != 0)
displayControlMenu();
}
}
}
@ -767,7 +766,7 @@ void MortevielleEngine::prepareScreenType3() {
*/
void MortevielleEngine::updateHour(int &day, int &hour, int &minute) {
int newHour = readclock();
int th = g_jh + ((newHour - g_mh) / g_t);
int th = _jh + ((newHour - _mh) / _t);
minute = ((th % 2) + _currHalfHour) * 30;
hour = ((uint)th >> 1) + _currHour;
if (minute == 60) {
@ -1381,12 +1380,12 @@ void MortevielleEngine::getKnockAnswer() {
updateHour(day, hour, minute);
if ((hour >= 0) && (hour < 8))
g_crep = 190;
_crep = 190;
else {
if (getRandomNumber(1, 100) > 70)
g_crep = 190;
_crep = 190;
else
g_crep = 147;
_crep = 147;
}
}
@ -1431,11 +1430,11 @@ int MortevielleEngine::getPresenceBitIndex(int roomId) {
*/
void MortevielleEngine::initGame() {
_place = MANOR_FRONT;
g_jh = 0;
_jh = 0;
if (!_coreVar._alreadyEnteredManor)
_blo = true;
g_t = kTime1;
g_mh = readclock();
_t = kTime1;
_mh = readclock();
}
/**
@ -1625,10 +1624,10 @@ void MortevielleEngine::startMusicOrSpeech(int so) {
if (so == 0) {
/* musik(0) */
;
} else if ((g_prebru == 0) && (!_coreVar._alreadyEnteredManor)) {
} else if ((_prebru == 0) && (!_coreVar._alreadyEnteredManor)) {
// Type 1: Speech
_speechManager.startSpeech(10, 1, 1);
++g_prebru;
++_prebru;
} else {
if (((_coreVar._currPlace == MOUNTAIN) || (_coreVar._currPlace == MANOR_FRONT) || (_coreVar._currPlace == MANOR_BACK)) && (getRandomNumber(1, 3) == 2))
// Type 1: Speech
@ -1654,8 +1653,8 @@ void MortevielleEngine::startMusicOrSpeech(int so) {
*/
void MortevielleEngine::loseGame() {
initouv();
g_ment = 0;
g_iouv = 0;
_ment = 0;
_iouv = 0;
_mchai = 0;
_menu.unsetSearchMenu();
if (!_blo)
@ -1664,7 +1663,7 @@ void MortevielleEngine::loseGame() {
_loseGame = true;
clearScreenType1();
_screenSurface.drawBox(60, 35, 400, 50, 15);
repon(9, g_crep);
repon(9, _crep);
clearScreenType2();
clearScreenType3();
_col = false;
@ -1713,7 +1712,7 @@ void MortevielleEngine::startDialog(int16 rep) {
key = 0;
do {
_speechManager.startSpeech(rep, haut[g_caff - 69], 0);
_speechManager.startSpeech(rep, haut[_caff - 69], 0);
key = f3f8::waitForF3F8();
CHECK_QUIT;
} while (key != 66);
@ -1728,8 +1727,8 @@ void MortevielleEngine::startDialog(int16 rep) {
void MortevielleEngine::endSearch() {
_heroSearching = false;
_obpart = false;
g_cs = 0;
g_is = 0;
_cs = 0;
_is = 0;
_menu.unsetSearchMenu();
}
@ -1743,14 +1742,14 @@ void MortevielleEngine::gotoDiningRoom() {
updateHour(day, hour, minute);
if ((hour < 5) && (_coreVar._currPlace > ROOM18)) {
if (!checkInventory(137)) { //You don't have the keys, and it's late
g_crep = 1511;
_crep = 1511;
loseGame();
} else
displayDiningRoom();
} else if (!_coreVar._alreadyEnteredManor) { //Is it your first time?
_currBitIndex = 255; // Everybody is present
showPeoplePresent(_currBitIndex);
g_caff = 77;
_caff = 77;
afdes();
_screenSurface.drawBox(223, 47, 155, 91, 15);
repon(2, 33);
@ -1769,7 +1768,7 @@ void MortevielleEngine::gotoDiningRoom() {
if (!_blo)
minute = t11(OWN_ROOM);
_currBitIndex = 0;
g_mpers = 0;
_savedBitIndex = 0;
_coreVar._alreadyEnteredManor = true;
} else
displayDiningRoom();
@ -1782,7 +1781,7 @@ void MortevielleEngine::gotoDiningRoom() {
void MortevielleEngine::checkManorDistance() {
++_manorDistance;
if (_manorDistance > 2) {
g_crep = 1506;
_crep = 1506;
loseGame();
} else {
_okdes = true;
@ -1815,7 +1814,7 @@ void MortevielleEngine::gotoManorBack() {
* @remarks Originally called 't1deau'
*/
void MortevielleEngine::floodedInWell() {
g_crep = 1503;
_crep = 1503;
loseGame();
}
@ -1838,9 +1837,9 @@ void MortevielleEngine::changeGraphicalDevice(int newDevice) {
displayAloneText();
clearScreenType2();
clearScreenType3();
g_maff = 68;
_maff = 68;
afdes();
repon(2, g_crep);
repon(2, _crep);
_menu.displayMenu();
}
@ -1857,24 +1856,24 @@ void MortevielleEngine::gameLoaded() {
_col = false;
_hiddenHero = false;
_brt = false;
g_maff = 68;
_maff = 68;
_menuOpcode = 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;
_prebru = 0;
_x = 0;
_y = 0;
_num = 0;
_startHour = 0;
_endHour = 0;
_cs = 0;
_is = 0;
_ment = 0;
_syn = true;
_heroSearching = true;
_mchai = 0;
_manorDistance = 0;
initouv();
g_iouv = 0;
g_dobj = 0;
_iouv = 0;
_dobj = 0;
affrep();
_hintPctMessage = getString(580);
@ -1887,7 +1886,7 @@ void MortevielleEngine::gameLoaded() {
prepareRoom();
drawClock();
afdes();
repon(2, g_crep);
repon(2, _crep);
clearScreenType3();
_endGame = false;
_menu.setDestinationMenuText(_coreVar._currPlace);
@ -1909,7 +1908,7 @@ void MortevielleEngine::handleOpcode() {
if (!_anyone) {
if (_brt) {
if ((_msg[3] == MENU_MOVE) || (_msg[4] == OPCODE_LEAVE) || (_msg[4] == OPCODE_SLEEP) || (_msg[4] == OPCODE_EAT)) {
g_ctrm = 4;
_controlMenu = 4;
mennor();
return;
}
@ -1990,15 +1989,15 @@ void MortevielleEngine::handleOpcode() {
if (((_coreVar._currPlace < CRYPT) || (_coreVar._currPlace > MOUNTAIN)) && (_coreVar._currPlace != INSIDE_WELL)
&& (_coreVar._currPlace != OWN_ROOM) && (_coreVar._selectedObjectId != 152) && (!_loseGame)) {
if ((_coreVar._faithScore > 99) && (hour > 8) && (hour < 16)) {
g_crep = 1501;
_crep = 1501;
loseGame();
}
if ((_coreVar._faithScore > 99) && (hour > 0) && (hour < 9)) {
g_crep = 1508;
_crep = 1508;
loseGame();
}
if ((day > 1) && (hour > 8) && (!_loseGame)) {
g_crep = 1502;
_crep = 1502;
loseGame();
}
}
@ -2084,7 +2083,7 @@ void MortevielleEngine::clearScreenType10() {
Common::String st;
_mouse.hideMouse();
if (g_res == 1) {
if (_res == 1) {
co = 634;
cod = 534;
} else {
@ -2130,7 +2129,7 @@ void MortevielleEngine::showMoveMenuAlert() {
* @remarks Originally called 'dialpre'
*/
void MortevielleEngine::showConfigScreen() {
g_crep = 998;
_crep = 998;
}
/**
@ -2303,8 +2302,8 @@ void MortevielleEngine::setPal(int n) {
case MODE_EGA:
case MODE_AMSTRAD1512:
for (int i = 1; i <= 16; ++i) {
g_vm->_mem[(0x7000 * 16) + (2 * i)] = _stdPal[n][i].x;
g_vm->_mem[(0x7000 * 16) + (2 * i) + 1] = _stdPal[n][i].y;
_mem[(0x7000 * 16) + (2 * i)] = _stdPal[n][i].x;
_mem[(0x7000 * 16) + (2 * i) + 1] = _stdPal[n][i].y;
}
break;
case MODE_CGA: {
@ -2332,12 +2331,12 @@ void MortevielleEngine::setPal(int n) {
void MortevielleEngine::displayCGAPattern(int n, Pattern p, nhom *pal) {
int addr = n * 404 + 0xd700;
WRITE_LE_UINT16(&g_vm->_mem[0x6000 * 16 + addr], p._tax);
WRITE_LE_UINT16(&g_vm->_mem[0x6000 * 16 + addr + 2], p._tay);
WRITE_LE_UINT16(&_mem[0x6000 * 16 + addr], p._tax);
WRITE_LE_UINT16(&_mem[0x6000 * 16 + addr + 2], p._tay);
addr += 4;
for (int i = 0; i < p._tax; ++i) {
for (int j = 0; j < p._tay; ++j)
g_vm->_mem[(0x6000 * 16) + addr + j * p._tax + i] = pal[n]._hom[p._des[i + 1][j + 1]];
_mem[(0x6000 * 16) + addr + j * p._tax + i] = pal[n]._hom[p._des[i + 1][j + 1]];
}
}
@ -2443,7 +2442,7 @@ void MortevielleEngine::loadBRUIT5() {
if (!f.open("bruit5"))
error("Missing file - bruit5");
f.read(&g_vm->_mem[kAdrNoise5 * 16 + 0], 149 * 128);
f.read(&_mem[kAdrNoise5 * 16 + 0], 149 * 128);
f.close();
}
@ -2486,12 +2485,12 @@ void MortevielleEngine::music() {
if (!fic.open("mort.img"))
error("Missing file - mort.img");
fic.read(&g_vm->_mem[0x3800 * 16 + 0], 500);
fic.read(&g_vm->_mem[0x47a0 * 16 + 0], 123);
fic.read(&_mem[0x3800 * 16 + 0], 500);
fic.read(&_mem[0x47a0 * 16 + 0], 123);
fic.close();
_soundManager.decodeMusic(&g_vm->_mem[0x3800 * 16], &g_vm->_mem[0x5000 * 16], 623);
_addfix = (float)((kTempoMusic - 8)) / 256;
_soundManager.decodeMusic(&_mem[0x3800 * 16], &_mem[0x5000 * 16], 623);
_addFix = (float)((kTempoMusic - 8)) / 256;
_speechManager.cctable(_speechManager._tbi);
bool fin = false;
@ -2513,16 +2512,16 @@ void MortevielleEngine::music() {
void MortevielleEngine::showTitleScreen() {
hirs();
repon(7, 2035);
g_caff = 51;
_caff = 51;
taffich();
teskbd();
if (_newGraphicalDevice != _currGraphicalDevice)
_currGraphicalDevice = _newGraphicalDevice;
hirs();
draw(g_ades, 0, 0);
draw(kAdrDes, 0, 0);
Common::String cpr = "COPYRIGHT 1989 : LANKHOR";
_screenSurface.putxy(104 + 72 * g_res, 185);
_screenSurface.putxy(104 + 72 * _res, 185);
_screenSurface.drawString(cpr, 0);
}
@ -2544,7 +2543,7 @@ void MortevielleEngine::draw(int ad, int x, int y) {
void MortevielleEngine::drawRightFrame() {
setPal(89);
if (_currGraphicalDevice == MODE_HERCULES) {
g_vm->_mem[0x7000 * 16 + 14] = 15;
_mem[0x7000 * 16 + 14] = 15;
}
_mouse.hideMouse();
pictout(0x73a2, 0, 0, 0);
@ -2626,22 +2625,22 @@ void MortevielleEngine::prepareRoom() {
if (!_blo) {
if ((hour == 12) || ((hour > 18) && (hour < 21)) || ((hour >= 0) && (hour < 7)))
g_t = kTime2;
_t = kTime2;
else
g_t = kTime1;
_t = kTime1;
cf = _coreVar._faithScore;
if ((cf > 33) && (cf < 66))
g_t -= (g_t / 3);
_t -= (_t / 3);
if (cf > 65)
g_t -= ((g_t / 3) * 2);
_t -= ((_t / 3) * 2);
int nh = readclock();
if ((nh - g_mh) > g_t) {
if ((nh - _mh) > _t) {
bool activeMenu = _menu._menuActive;
_menu.eraseMenu();
g_jh += ((nh - g_mh) / g_t);
g_mh = nh;
_jh += ((nh - _mh) / _t);
_mh = nh;
switch (_place) {
case GREEN_ROOM:
case DARKBLUE_ROOM:
@ -2681,17 +2680,17 @@ void MortevielleEngine::prepareRoom() {
setRandomPresenceChapel(cf);
break;
}
if ((g_mpers != 0) && (_currBitIndex != 10))
g_mpers = _currBitIndex;
if ((_savedBitIndex != 0) && (_currBitIndex != 10))
_savedBitIndex = _currBitIndex;
if ((g_mpers == 0) && (_currBitIndex > 0)) {
if ((_savedBitIndex == 0) && (_currBitIndex > 0)) {
if ((_coreVar._currPlace == ATTIC) || (_coreVar._currPlace == CELLAR)) {
cavegre();
initCaveOrCellar();
} else if (_currBitIndex == 10) {
_currBitIndex = 0;
if (!_brt) {
_brt = true;
g_hdb = readclock();
_startHour = readclock();
if (getRandomNumber(1, 5) < 5) {
clearScreenType3();
prepareScreenType2();
@ -2708,11 +2707,11 @@ void MortevielleEngine::prepareRoom() {
_menu.drawMenu();
}
}
g_hfb = readclock();
if ((_brt) && ((g_hfb - g_hdb) > 17)) {
_endHour = readclock();
if ((_brt) && ((_endHour - _startHour) > 17)) {
getPresenceBitIndex(_place);
_brt = false;
g_hdb = 0;
_startHour = 0;
if ((_coreVar._currPlace > OWN_ROOM) && (_coreVar._currPlace < DINING_ROOM))
_anyone = true;
}
@ -2742,9 +2741,9 @@ void MortevielleEngine::drawClock() {
co = 1;
if (_minute == 0)
_screenSurface.drawLine(((uint)x >> 1) * g_res, y, ((uint)x >> 1) * g_res, (y - rg), co);
_screenSurface.drawLine(((uint)x >> 1) * _res, y, ((uint)x >> 1) * _res, (y - rg), co);
else
_screenSurface.drawLine(((uint)x >> 1) * g_res, y, ((uint)x >> 1) * g_res, (y + rg), co);
_screenSurface.drawLine(((uint)x >> 1) * _res, y, ((uint)x >> 1) * _res, (y + rg), co);
h = _hour;
if (h > 12)
@ -2752,7 +2751,7 @@ void MortevielleEngine::drawClock() {
if (h == 0)
h = 12;
_screenSurface.drawLine(((uint)x >> 1) * g_res, y, ((uint)(x + cv[0][h - 1]) >> 1) * g_res, y + cv[1][h - 1], co);
_screenSurface.drawLine(((uint)x >> 1) * _res, y, ((uint)(x + cv[0][h - 1]) >> 1) * _res, y + cv[1][h - 1], co);
_mouse.showMouse();
_screenSurface.putxy(568, 154);
@ -2797,7 +2796,233 @@ void MortevielleEngine::hirs() {
// method is deprecated in favour of clearing the screen
debugC(1, kMortevielleCore, "TODO: hirs is deprecated in favour of ScreenSurface::clearScreen");
g_vm->_screenSurface.clearScreen();
if (_currGraphicalDevice == MODE_CGA)
_res = 1;
else
_res = 2;
_screenSurface.clearScreen();
}
/**
* Init room : Cave or Cellar
* @remarks Originally called 'cavegre'
*/
void MortevielleEngine::initCaveOrCellar() {
_coreVar._faithScore += 2;
if (_coreVar._faithScore > 69)
_coreVar._faithScore += (_coreVar._faithScore / 10);
clearScreenType3();
prepareScreenType2();
ecr3(getEngineString(S_SOMEONE_ENTERS));
int rand = (getRandomNumber(0, 4)) - 2;
_speechManager.startSpeech(2, rand, 1);
// The original was doing here a useless loop.
// It has been removed
clearScreenType3();
displayAloneText();
}
/**
* Display control menu string
* @remarks Originally called 'tctrm'
*/
void MortevielleEngine::displayControlMenu() {
repon(2, (3000 + _controlMenu));
_controlMenu = 0;
}
void MortevielleEngine::pictout(int seg, int dep, int x, int y) {
GfxSurface surface;
surface.decode(&_mem[seg * 16 + dep]);
if (_currGraphicalDevice == MODE_HERCULES) {
_mem[0x7000 * 16 + 2] = 0;
_mem[0x7000 * 16 + 32] = 15;
}
if ((_caff != 51) && (READ_LE_UINT16(&_mem[0x7000 * 16 + 0x4138]) > 0x100))
WRITE_LE_UINT16(&_mem[0x7000 * 16 + 0x4138], 0x100);
_screenSurface.drawPicture(surface, x, y);
}
void MortevielleEngine::adzon() {
Common::File f;
if (!f.open("don.mor"))
error("Missing file - don.mor");
f.read(_tabdon, 7 * 256);
f.close();
if (!f.open("bmor.mor"))
error("Missing file - bmor.mor");
f.read(&_tabdon[kFleche], 1 * 1916);
f.close();
if (!f.open("dec.mor"))
error("Missing file - dec.mor");
f.read(&_mem[0x73a2 * 16 + 0], 1 * 1664);
f.close();
}
/**
* Returns the offset within the compressed image data resource of the desired image
*/
int MortevielleEngine::animof(int ouf, int num) {
int nani = _mem[kAdrAni * 16 + 1];
int aux = num;
if (ouf != 1)
aux += nani;
int animof_result = (nani << 2) + 2 + READ_BE_UINT16(&_mem[kAdrAni * 16 + (aux << 1)]);
return animof_result;
}
void MortevielleEngine::text1(int x, int y, int nb, int m) {
int co;
if (_res == 1)
co = 10;
else
co = 6;
Common::String tmpStr = getString(m);
if ((y == 182) && ((int) tmpStr.size() * co > nb * 6))
y = 176;
displayStr(tmpStr, x, y, nb, 20, _textColor);
}
void MortevielleEngine::repon(int f, int m) {
if ((m > 499) && (m < 563)) {
Common::String tmpStr = getString(m - 501 + kInventoryStringIndex);
if ((int) tmpStr.size() > ((58 + (_res - 1) * 37) << 1))
_largestClearScreen = true;
else
_largestClearScreen = false;
clearScreenType2();
displayStr(tmpStr, 8, 176, 85, 3, 5);
} else {
modif(m);
switch (f) {
case 2:
case 8:
clearScreenType2();
prepareScreenType2();
text1(8, 182, 103, m);
if ((m == 68) || (m == 69))
_coreVar._teauto[40] = '*';
if ((m == 104) && (_caff == 14)) {
_coreVar._teauto[36] = '*';
if (_coreVar._teauto[39] == '*') {
_coreVar._pourc[3] = '*';
_coreVar._teauto[38] = '*';
}
}
break;
case 1:
case 6:
case 9: {
int i;
if ((f == 1) || (f == 6))
i = 4;
else
i = 5;
Common::String tmpStr = getString(m);
displayStr(tmpStr, 80, 40, 60, 25, i);
if (m == 180)
_coreVar._pourc[6] = '*';
else if (m == 179)
_coreVar._pourc[10] = '*';
}
break;
default:
break;
}
}
}
void MortevielleEngine::modif(int &nu) {
if (nu == 26)
nu = 25;
else if ((nu > 29) && (nu < 36))
nu -= 4;
else if ((nu > 69) && (nu < 78))
nu -= 37;
else if ((nu > 99) && (nu < 194))
nu -= 59;
else if ((nu > 996) && (nu < 1000))
nu -= 862;
else if ((nu > 1500) && (nu < 1507))
nu -= 1363;
else if ((nu > 1507) && (nu < 1513))
nu -= 1364;
else if ((nu > 1999) && (nu < 2002))
nu -= 1851;
else if (nu == 2010)
nu = 151;
else if ((nu > 2011) && (nu < 2025))
nu -= 1860;
else if (nu == 2026)
nu = 165;
else if ((nu > 2029) && (nu < 2037))
nu -= 1864;
else if ((nu > 3000) && (nu < 3005))
nu -= 2828;
else if (nu == 4100)
nu = 177;
else if (nu == 4150)
nu = 178;
else if ((nu > 4151) && (nu < 4156))
nu -= 3973;
else if (nu == 4157)
nu = 183;
else if ((nu == 4160) || (nu == 4161))
nu -= 3976;
}
void MortevielleEngine::initouv() {
for (int cx = 1; cx <= 7; ++cx)
_touv[cx] = chr(0);
}
void MortevielleEngine::ecr2(Common::String text) {
// Some dead code was present in the original: removed
_screenSurface.putxy(8, 177);
int tlig = 59 + (_res - 1) * 36;
if ((int)text.size() < tlig)
_screenSurface.drawString(text, 5);
else if ((int)text.size() < (tlig << 1)) {
_screenSurface.putxy(8, 176);
_screenSurface.drawString(copy(text, 1, (tlig - 1)), 5);
_screenSurface.putxy(8, 182);
_screenSurface.drawString(copy(text, tlig, tlig << 1), 5);
} else {
_largestClearScreen = true;
clearScreenType2();
_screenSurface.putxy(8, 176);
_screenSurface.drawString(copy(text, 1, (tlig - 1)), 5);
_screenSurface.putxy(8, 182);
_screenSurface.drawString(copy(text, tlig, ((tlig << 1) - 1)), 5);
_screenSurface.putxy(8, 190);
_screenSurface.drawString(copy(text, tlig << 1, tlig * 3), 5);
}
}
void MortevielleEngine::ecr3(Common::String text) {
clearScreenType3();
_screenSurface.putxy(8, 192);
_screenSurface.drawString(text, 5);
}
} // End of namespace Mortevielle

View File

@ -81,13 +81,15 @@ enum DataType {
#define GAME_FRAME_DELAY (1000 / 50)
const int kAcha = 492;
const int kAdrDes = 0x7000;
const int kFleche = 1758;
const int asoul = 154;
const int aouvr = 282;
const int achai = 387;
const int arcf = 1272;
const int arep = 1314;
const int amzon = 1650;
const int fleche = 1758;
const int arega = 0;
struct nhom {
@ -164,6 +166,12 @@ private:
void showTitleScreen();
int readclock();
void palette(int v1);
void adzon();
void text1(int x, int y, int nb, int m);
void modif(int &nu);
void initouv();
public:
Common::String _hintPctMessage;
Common::Point _prevPos;
@ -210,6 +218,7 @@ public:
int _place;
int _manorDistance;
int _currBitIndex;
int _savedBitIndex;
int _currDay;
int _currHour;
int _currHalfHour;
@ -217,16 +226,35 @@ public:
int _hour;
int _minute;
int _mchai;
float _addfix;
float _addFix;
SaveStruct _coreVar, _saveStruct;
Common::Point _stdPal[91][17];
t_pcga _cgaPal[91];
int _key;
int _controlMenu;
int _startHour;
int _endHour;
int _c_zzz;
int ptr_word;
byte _v_lieu[7][25];
byte g_is;
byte _is;
int _numpal;
int _ment;
int _iouv;
int _caff;
int _maff;
int _dobj;
int _num;
int _crep;
int _cs;
int _res;
int _prebru;
int _t;
int _x;
int _y;
int _jh;
int _mh;
// TODO: Replace the following with proper implementations, or refactor out the code using them
byte _mem[65536 * 16];
@ -383,6 +411,16 @@ public:
void drawClock();
Common::String copy(const Common::String &s, int idx, size_t size);
void hirs();
void initCaveOrCellar();
void displayControlMenu();
void pictout(int seg, int dep, int x, int y);
int animof(int ouf, int num);
void repon(int f, int m);
void ecr2(Common::String text);
void ecr3(Common::String text);
};
extern MortevielleEngine *g_vm;

View File

@ -228,8 +228,8 @@ void MouseHandler::showMouse() {
* @remarks Originally called 'pos_mouse'
*/
void MouseHandler::setMousePosition(Common::Point newPos) {
if (newPos.x > 314 * g_res)
newPos.x = 314 * g_res;
if (newPos.x > 314 * g_vm->_res)
newPos.x = 314 * g_vm->_res;
else if (newPos.x < 0)
newPos.x = 0;
if (newPos.y > 199)
@ -299,16 +299,16 @@ void MouseHandler::moveMouse(bool &funct, char &key) {
cy = 190;
break;
case '9':
cx = 315 * g_res;
cx = 315 * g_vm->_res;
cy = 1;
break;
case '3':
cy = 190;
cx = 315 * g_res;
cx = 315 * g_vm->_res;
break;
case '5':
cy = 100;
cx = 155 * g_res;
cx = 155 * g_vm->_res;
break;
case ' ':
case '\15':
@ -362,27 +362,27 @@ void MouseHandler::moveMouse(bool &funct, char &key) {
}
break;
case 'I':
cx = g_res * 32;
cx = g_vm->_res * 32;
cy = 8;
break;
case 'D':
cx = 80 * g_res;
cx = 80 * g_vm->_res;
cy = 8;
break;
case 'A':
cx = 126 * g_res;
cx = 126 * g_vm->_res;
cy = 8;
break;
case 'S':
cx = 174 * g_res;
cx = 174 * g_vm->_res;
cy = 8;
break;
case 'P':
cx = 222 * g_res;
cx = 222 * g_vm->_res;
cy = 8;
break;
case 'F':
cx = g_res * 270;
cx = g_vm->_res * 270;
cy = 8;
break;
case '\23':

View File

@ -61,7 +61,7 @@ void displayStr(Common::String inputStr, int x, int y, int dx, int dy, int typ)
inputStr += '$';
g_vm->_screenSurface.putxy(x, y);
if (g_res == 1)
if (g_vm->_res == 1)
tab = 10;
else
tab = 6;
@ -186,13 +186,13 @@ void taffich() {
int32 lgt;
int alllum[16];
int a = g_caff;
int a = g_vm->_caff;
if ((a >= 153) && (a <= 161))
a = tran2[a - 153];
else if ((a >= 136) && (a <= 140))
a = tran1[a - 136];
int b = a;
if (g_maff == a)
if (g_vm->_maff == a)
return;
switch (a) {
@ -246,11 +246,11 @@ void taffich() {
m = 2010;
if (a == 32)
m = 2034;
if ((a == 17) && (g_maff == 14))
if ((a == 17) && (g_vm->_maff == 14))
m = 2018;
if (a > 99) {
if ((g_vm->g_is == 1) || (g_vm->g_is == 0))
if ((g_vm->_is == 1) || (g_vm->_is == 0))
m = 2031;
else
m = 2032;
@ -259,26 +259,26 @@ void taffich() {
if (((a > 69) && (a < 80)) || (a == 30) || (a == 31) || (a == 144) || (a == 147) || (a == 149))
m = 2030;
if (((a < 27) && (((g_maff > 69) && (!g_vm->_coreVar._alreadyEnteredManor)) || (g_maff > 99))) || ((g_maff > 29) && (g_maff < 33)))
if (((a < 27) && (((g_vm->_maff > 69) && (!g_vm->_coreVar._alreadyEnteredManor)) || (g_vm->_maff > 99))) || ((g_vm->_maff > 29) && (g_vm->_maff < 33)))
m = 2033;
g_maff = a;
g_vm->_maff = a;
if (a == 159)
a = 86;
else if (a > 140)
a = a - 67;
a -= 67;
else if (a > 137)
a = a - 66;
a -= 66;
else if (a > 99)
a = a - 64;
a -= 64;
else if (a > 69)
a = a - 42;
a -= 42;
else if (a > 29)
a = a - 5;
a -= 5;
else if (a == 26)
a = 24;
else if (a > 18)
a = a - 1;
--a;
npal = a;
for (cx = 0; cx <= (a - 1); ++cx)
@ -293,7 +293,7 @@ void taffich() {
lgt = handle;
handle = g_vm->_fxxBuffer[88];
}
g_maff = a;
g_vm->_maff = a;
npal = a + 37;
}
chardes(filename, lgt, handle);
@ -334,12 +334,12 @@ void taffich() {
charani(filename, lgt, handle);
}
g_vm->_mouse.showMouse();
if ((a < 27) && ((g_maff < 27) || (g_vm->_coreVar._currPlace == LANDING)) && (g_vm->_msg[4] != OPCODE_ENTER)) {
if ((a < 27) && ((g_vm->_maff < 27) || (g_vm->_coreVar._currPlace == LANDING)) && (g_vm->_msg[4] != OPCODE_ENTER)) {
if ((a == 13) || (a == 14))
g_vm->displayAloneText();
else if (!g_vm->_blo)
cx = t11(g_vm->_coreVar._currPlace);
g_mpers = 0;
g_vm->_savedBitIndex = 0;
}
}

View File

@ -128,7 +128,7 @@ void SpeechManager::cctable(tablint &t) {
tb[0] = 0;
for (int k = 0; k <= 255; ++k) {
tb[k + 1] = g_vm->_addfix + tb[k];
tb[k + 1] = g_vm->_addFix + tb[k];
t[255 - k] = abs((int)tb[k] + 1);
}
}
@ -554,17 +554,17 @@ void SpeechManager::startSpeech(int rep, int ht, int typ) {
return;
_phonemeNumb = rep;
g_haut = ht;
int haut = ht;
_typlec = typ;
if (_typlec != 0) {
for (int i = 0; i <= 500; ++i)
savph[i] = _cfiphBuffer[i];
tempo = kTempoNoise;
} else if (g_haut > 5)
} else if (haut > 5)
tempo = kTempoF;
else
tempo = kTempoM;
g_vm->_addfix = (float)((tempo - 8)) / 256;
g_vm->_addFix = (float)((tempo - 8)) / 256;
cctable(_tbi);
switch (typ) {
case 1:

View File

@ -33,36 +33,6 @@
namespace Mortevielle {
/*---------------------------------------------------------------------------*/
/*------------------------------ VARIABLES ------------------------------*/
/*---------------------------------------------------------------------------*/
int g_x,
g_y,
g_t,
g_jh,
g_mh,
g_cs,
g_hdb,
g_hfb,
g_key,
g_num,
g_res,
g_ment,
g_haut,
g_caff,
g_maff,
g_crep,
g_ades,
g_iouv,
g_ctrm,
g_dobj,
g_mlec,
g_mchai,
g_mpers,
g_perdep,
g_prebru;
/*---------------------------------------------------------------------------*/
/*-------------------- PROCEDURES AND FONCTIONS -----------------------*/
/*---------------------------------------------------------------------------*/

View File

@ -115,34 +115,6 @@ typedef int tfxx[108];
enum GraphicModes { MODE_AMSTRAD1512 = 0, MODE_CGA = 1, MODE_EGA = 2, MODE_HERCULES = 3, MODE_TANDY = 4 };
/*---------------------------------------------------------------------------*/
/*------------------------------ VARIABLES ------------------------------*/
/*---------------------------------------------------------------------------*/
extern int g_x,
g_y,
g_t,
g_jh,
g_mh,
g_cs,
g_hdb,
g_hfb,
g_key,
g_num,
g_res,
g_ment,
g_haut,
g_caff,
g_maff,
g_crep,
g_ades,
g_iouv,
g_ctrm,
g_dobj,
g_mpers,
g_perdep,
g_prebru;
} // End of namespace Mortevielle
#endif