diff options
-rw-r--r-- | engines/mortevielle/actions.cpp | 608 | ||||
-rw-r--r-- | engines/mortevielle/dialogs.cpp | 41 | ||||
-rw-r--r-- | engines/mortevielle/graphics.cpp | 6 | ||||
-rw-r--r-- | engines/mortevielle/menu.cpp | 34 | ||||
-rw-r--r-- | engines/mortevielle/mor.cpp | 408 | ||||
-rw-r--r-- | engines/mortevielle/mor.h | 17 | ||||
-rw-r--r-- | engines/mortevielle/mortevielle.cpp | 403 | ||||
-rw-r--r-- | engines/mortevielle/mortevielle.h | 44 | ||||
-rw-r--r-- | engines/mortevielle/mouse.cpp | 22 | ||||
-rw-r--r-- | engines/mortevielle/outtext.cpp | 32 | ||||
-rw-r--r-- | engines/mortevielle/speech.cpp | 8 | ||||
-rw-r--r-- | engines/mortevielle/var_mor.cpp | 30 | ||||
-rw-r--r-- | engines/mortevielle/var_mor.h | 28 |
13 files changed, 828 insertions, 853 deletions
diff --git a/engines/mortevielle/actions.cpp b/engines/mortevielle/actions.cpp index 1c3314fe90..174af9fd1a 100644 --- a/engines/mortevielle/actions.cpp +++ b/engines/mortevielle/actions.cpp @@ -44,7 +44,7 @@ namespace Mortevielle { void MortevielleEngine::fctMove() { if ((_coreVar._currPlace == ROOM26) && (_msg[4] == _menu._moveMenu[6])) { _coreVar._currPlace = LANDING; - g_caff = _coreVar._currPlace; + _caff = _coreVar._currPlace; afdes(); repon(2, _coreVar._currPlace); } @@ -61,26 +61,26 @@ void MortevielleEngine::fctMove() { tcoord(1); - if (g_num == 0) + if (_num == 0) return; - if (g_num == 1) { + if (_num == 1) { _coreVar._currPlace = OWN_ROOM; _menu.setDestinationMenuText(OWN_ROOM); - } else if (g_num == 7) { + } else if (_num == 7) { _coreVar._currPlace = ATTIC; _menu.setDestinationMenuText(ATTIC); } - if (g_num != 6) + if (_num != 6) _coreVar._currPlace = ROOM26; - if ((g_num > 1) && (g_num < 6)) - g_ment = g_num - 1; - else if (g_num > 7) - g_ment = g_num - 3; + if ((_num > 1) && (_num < 6)) + _ment = _num - 1; + else if (_num > 7) + _ment = _num - 3; - if (g_num != 6) + if (_num != 6) affrep(); else showMoveMenuAlert(); @@ -160,11 +160,11 @@ void MortevielleEngine::fctMove() { gotoManorBack(); else if (menuChoice == 17) { if ((_coreVar._wellObjectId != 120) && (_coreVar._wellObjectId != 140)) - g_crep = 997; + _crep = 997; else if (_coreVar._wellObjectId == 120) - g_crep = 181; + _crep = 181; else if (_coreVar._faithScore > 80) { - g_crep = 1505; + _crep = 1505; loseGame(); } else { _coreVar._currPlace = INSIDE_WELL; @@ -182,19 +182,19 @@ void MortevielleEngine::fctMove() { * @remarks Originally called 'tprendre' */ void MortevielleEngine::fctTake() { - if (g_caff > 99) { - int cx = g_caff; + if (_caff > 99) { + int cx = _caff; avpoing(cx); - if (g_crep != 139) { + if (_crep != 139) { if (_currBitIndex > 0) _coreVar._faithScore += 3; if (_obpart) { if (_coreVar._currPlace == PURPLE_ROOM) _coreVar._purpleRoomObjectId = 0; if (_coreVar._currPlace == ATTIC) { - if (_coreVar._atticBallHoleObjectId == g_caff) + if (_coreVar._atticBallHoleObjectId == _caff) _coreVar._atticBallHoleObjectId = 0; - if (_coreVar._atticRodHoleObjectId == g_caff) + if (_coreVar._atticRodHoleObjectId == _caff) _coreVar._atticRodHoleObjectId = 0; } if (_coreVar._currPlace == CELLAR) @@ -209,12 +209,12 @@ void MortevielleEngine::fctTake() { _obpart = false; affrep(); } else { - _tabdon[kAcha + ((_mchai - 1) * 10) + g_cs - 1] = 0; + _tabdon[kAcha + ((_mchai - 1) * 10) + _cs - 1] = 0; tsuiv(); - ++g_dobj; - if (g_dobj > 6) { + ++_dobj; + if (_dobj > 6) { _coreVar._faithScore += 2; - g_dobj = 0; + _dobj = 0; } } } @@ -225,35 +225,35 @@ void MortevielleEngine::fctTake() { tfleche(); if ((_anyone) || (_keyPressedEsc)) return; - if (g_caff == 3) { + if (_caff == 3) { tcoord(2); - if (g_num == 1) { - g_crep = 152; + if (_num == 1) { + _crep = 152; return; } } tcoord(5); - if ((g_num == 0) || ((g_num == 1) && (_coreVar._currPlace == CRYPT))) { + if ((_num == 0) || ((_num == 1) && (_coreVar._currPlace == CRYPT))) { tcoord(8); - if (g_num != 0) { + if (_num != 0) { if (_currBitIndex > 0) _coreVar._faithScore += 3; - g_crep = 997; + _crep = 997; if ((_coreVar._currPlace == PURPLE_ROOM) && (_coreVar._purpleRoomObjectId != 0)) avpoing(_coreVar._purpleRoomObjectId); - if ((_coreVar._currPlace == ATTIC) && (g_num == 1) && (_coreVar._atticBallHoleObjectId != 0)) { + if ((_coreVar._currPlace == ATTIC) && (_num == 1) && (_coreVar._atticBallHoleObjectId != 0)) { avpoing(_coreVar._atticBallHoleObjectId); - if ((g_crep != 997) && (g_crep != 139)) + if ((_crep != 997) && (_crep != 139)) aniof(2, 7); } - if ((_coreVar._currPlace == ATTIC) && (g_num == 2) && (_coreVar._atticRodHoleObjectId != 0)) { + if ((_coreVar._currPlace == ATTIC) && (_num == 2) && (_coreVar._atticRodHoleObjectId != 0)) { avpoing(_coreVar._atticRodHoleObjectId); - if ((g_crep != 997) && (g_crep != 139)) + if ((_crep != 997) && (_crep != 139)) aniof(2, 6); } if ((_coreVar._currPlace == CELLAR) && (_coreVar._cellarObjectId != 0)) { avpoing(_coreVar._cellarObjectId); - if ((g_crep != 997) && (g_crep != 139)) + if ((_crep != 997) && (_crep != 139)) aniof(2, 2); } if ((_coreVar._currPlace == CRYPT) && (_coreVar._cryptObjectId != 0)) @@ -261,40 +261,40 @@ void MortevielleEngine::fctTake() { if ((_coreVar._currPlace == SECRET_PASSAGE) && (_coreVar._secretPassageObjectId != 0)) { avpoing(_coreVar._secretPassageObjectId); - if ((g_crep != 997) && (g_crep != 139)) { - g_crep = 182; + if ((_crep != 997) && (_crep != 139)) { + _crep = 182; aniof(2, 1); } } if ((_coreVar._currPlace == WELL) && (_coreVar._wellObjectId != 0)) { avpoing(_coreVar._wellObjectId); - if ((g_crep != 997) && (g_crep != 139)) + if ((_crep != 997) && (_crep != 139)) aniof(2, 1); } - if ((g_crep != 997) && (g_crep != 182) && (g_crep != 139)) - g_crep = 999; + if ((_crep != 997) && (_crep != 182) && (_crep != 139)) + _crep = 999; } } else { - if ( ((_coreVar._currPlace == OWN_ROOM) && (g_num == 3)) - || ((_coreVar._currPlace == GREEN_ROOM) && (g_num == 4)) - || ((_coreVar._currPlace == PURPLE_ROOM) && (g_num == 1)) - || ((_coreVar._currPlace == DARKBLUE_ROOM) && (g_num == 3)) - || ((_coreVar._currPlace == BLUE_ROOM) && (g_num == 6)) - || ((_coreVar._currPlace == RED_ROOM) && (g_num == 2)) - || ((_coreVar._currPlace == BATHROOM) && (g_num == 6)) - || ((_coreVar._currPlace == GREEN_ROOM2) && (g_num == 4)) - || ((_coreVar._currPlace == ROOM9) && (g_num == 4)) - || ((_coreVar._currPlace == DINING_ROOM) && (g_num > 2)) - || ((_coreVar._currPlace == BUREAU) && (g_num == 7)) - || ((_coreVar._currPlace == KITCHEN) && (g_num == 6)) - || ((_coreVar._currPlace == ATTIC) && (g_num > 4)) + if ( ((_coreVar._currPlace == OWN_ROOM) && (_num == 3)) + || ((_coreVar._currPlace == GREEN_ROOM) && (_num == 4)) + || ((_coreVar._currPlace == PURPLE_ROOM) && (_num == 1)) + || ((_coreVar._currPlace == DARKBLUE_ROOM) && (_num == 3)) + || ((_coreVar._currPlace == BLUE_ROOM) && (_num == 6)) + || ((_coreVar._currPlace == RED_ROOM) && (_num == 2)) + || ((_coreVar._currPlace == BATHROOM) && (_num == 6)) + || ((_coreVar._currPlace == GREEN_ROOM2) && (_num == 4)) + || ((_coreVar._currPlace == ROOM9) && (_num == 4)) + || ((_coreVar._currPlace == DINING_ROOM) && (_num > 2)) + || ((_coreVar._currPlace == BUREAU) && (_num == 7)) + || ((_coreVar._currPlace == KITCHEN) && (_num == 6)) + || ((_coreVar._currPlace == ATTIC) && (_num > 4)) || ((_coreVar._currPlace > ATTIC) && (_coreVar._currPlace != INSIDE_WELL)) ) - g_crep = 997; + _crep = 997; else if (_coreVar._currPlace == INSIDE_WELL) { - g_crep = 1504; + _crep = 1504; loseGame(); } else - g_crep = 120; + _crep = 120; } } /** @@ -319,7 +319,7 @@ void MortevielleEngine::fctInventoryTake() { _coreVar._sjer[cy] = chr(0); modinv(); avpoing(cz); - g_crep = 998; + _crep = 998; clearScreenType2(); } @@ -334,12 +334,12 @@ void MortevielleEngine::fctLift() { if ((_anyone) || (_keyPressedEsc)) return; tcoord(3); - if (g_num == 0) { + if (_num == 0) { tcoord(8); - if (g_num != 0) { + if (_num != 0) { if (_currBitIndex > 0) ++_coreVar._faithScore; - g_crep = 997; + _crep = 997; if ((_coreVar._currPlace == PURPLE_ROOM) && (_coreVar._purpleRoomObjectId != 0)) treg(_coreVar._purpleRoomObjectId); } @@ -352,9 +352,9 @@ void MortevielleEngine::fctLift() { tmpPlace = 14; else if (_coreVar._currPlace == MOUNTAIN) tmpPlace = 15; - g_crep = _tabdon[asoul + (tmpPlace << 3) + (g_num - 1)]; - if (g_crep == 255) - g_crep = 997; + _crep = _tabdon[asoul + (tmpPlace << 3) + (_num - 1)]; + if (_crep == 255) + _crep = 997; } /** @@ -362,16 +362,16 @@ void MortevielleEngine::fctLift() { * @remarks Originally called 'tlire' */ void MortevielleEngine::fctRead() { - if (g_caff > 99) - st4(g_caff); + if (_caff > 99) + st4(_caff); else { if (!_syn) ecr3(getEngineString(S_READ)); tfleche(); if (!(_anyone) && !(_keyPressedEsc)) { tcoord(4); - if (g_num != 0) - g_crep = 107; + if (_num != 0) + _crep = 107; } } } @@ -382,7 +382,7 @@ void MortevielleEngine::fctRead() { */ void MortevielleEngine::fctSelfRead() { if (_coreVar._selectedObjectId == 0) - g_crep = 186; + _crep = 186; else st4(_coreVar._selectedObjectId); } @@ -394,8 +394,8 @@ void MortevielleEngine::fctSelfRead() { void MortevielleEngine::fctLook() { int cx; - if (g_caff > 99) { - g_crep = 103; + if (_caff > 99) { + _crep = 103; return; } if (!_syn) @@ -404,35 +404,35 @@ void MortevielleEngine::fctLook() { if ((_anyone) || (_keyPressedEsc)) return; tcoord(5); - if (g_num == 0) { + if (_num == 0) { tcoord(8); - g_crep = 131; - if (g_num != 0) { + _crep = 131; + if (_num != 0) { if (_coreVar._currPlace == ATTIC) { - if (g_num == 1) { - g_crep = 164; + if (_num == 1) { + _crep = 164; if (_coreVar._atticRodHoleObjectId != 0) treg(_coreVar._atticRodHoleObjectId); else if (_coreVar._atticBallHoleObjectId != 0) treg(_coreVar._atticBallHoleObjectId); } else { - g_crep = 193; + _crep = 193; if (_coreVar._atticRodHoleObjectId != 0) treg(_coreVar._atticRodHoleObjectId); } } if (_coreVar._currPlace == CELLAR) { - g_crep = 164; + _crep = 164; if (_coreVar._cellarObjectId != 0) treg(_coreVar._cellarObjectId); } if (_coreVar._currPlace == SECRET_PASSAGE) { - g_crep = 174; + _crep = 174; if (_coreVar._secretPassageObjectId != 0) treg(_coreVar._secretPassageObjectId); } if (_coreVar._currPlace == WELL) { - g_crep = 131; + _crep = 131; if (_coreVar._wellObjectId != 0) treg(_coreVar._wellObjectId); } @@ -446,22 +446,22 @@ void MortevielleEngine::fctLook() { cx -= 4; if (_coreVar._currPlace == ROOM26) cx = 21; - g_crep = _tabdon[arega + (cx * 7) + g_num - 1]; - if ((_coreVar._currPlace == ATTIC) && (g_num == 8)) - g_crep = 126; + _crep = _tabdon[arega + (cx * 7) + _num - 1]; + if ((_coreVar._currPlace == ATTIC) && (_num == 8)) + _crep = 126; if (_coreVar._currPlace == MOUNTAIN) - g_crep = 103; - if (g_crep == 255) - g_crep = 131; - if ((_coreVar._currPlace == GREEN_ROOM) && (g_num == 1)) + _crep = 103; + if (_crep == 255) + _crep = 131; + if ((_coreVar._currPlace == GREEN_ROOM) && (_num == 1)) treg(144); - if ((_coreVar._currPlace == BLUE_ROOM) && (g_num == 3)) + if ((_coreVar._currPlace == BLUE_ROOM) && (_num == 3)) treg(147); - if ((_coreVar._currPlace == GREEN_ROOM2) && (g_num == 3)) + if ((_coreVar._currPlace == GREEN_ROOM2) && (_num == 3)) treg(149); - if ((_coreVar._currPlace == 9) && (g_num == 2)) + if ((_coreVar._currPlace == 9) && (_num == 2)) treg(30); - if ((_coreVar._currPlace == DINING_ROOM) && (g_num == 3)) + if ((_coreVar._currPlace == DINING_ROOM) && (_num == 3)) treg(31); } @@ -473,7 +473,7 @@ void MortevielleEngine::fctSelftLook() { if (_coreVar._selectedObjectId != 0) treg(_coreVar._selectedObjectId); else - g_crep = 186; + _crep = 186; } /** @@ -483,8 +483,8 @@ void MortevielleEngine::fctSelftLook() { void MortevielleEngine::fctSearch() { const byte r[14] = {123, 104, 123, 131, 131, 123, 104, 131, 123, 123, 106, 123, 123, 107}; - if (g_caff > 99) { - st7(g_caff); + if (_caff > 99) { + st7(_caff); return; } @@ -496,49 +496,49 @@ void MortevielleEngine::fctSearch() { return; if (_coreVar._currPlace == INSIDE_WELL) { - g_crep = 1504; + _crep = 1504; loseGame(); return; } tcoord(6); - if (g_num == 0) { + if (_num == 0) { tcoord(7); - if (g_num != 0) { + if (_num != 0) { int cx = 0; do { ++cx; - } while ((cx <= 6) && (g_num != ord(_touv[cx]))); - if (g_num != ord(_touv[cx])) - g_crep = 187; + } while ((cx <= 6) && (_num != ord(_touv[cx]))); + if (_num != ord(_touv[cx])) + _crep = 187; else { if (_currBitIndex > 0) _coreVar._faithScore += 3; rechai(_mchai); if (_mchai != 0) { - g_cs = 0; - g_is = 0; + _cs = 0; + _is = 0; _heroSearching = true; _menu.setSearchMenu(); tsuiv(); } else - g_crep = 997; + _crep = 997; } } else { tcoord(8); - g_crep = 997; - if (g_num != 0) { + _crep = 997; + if (_num != 0) { if (_currBitIndex > 0) _coreVar._faithScore += 3; if ((_coreVar._currPlace != WELL) && (_coreVar._currPlace != SECRET_PASSAGE) && (_coreVar._currPlace != ATTIC)) { if (_coreVar._currPlace == PURPLE_ROOM) { - g_crep = 123; + _crep = 123; if (_coreVar._purpleRoomObjectId != 0) treg(_coreVar._purpleRoomObjectId); } if (_coreVar._currPlace == CRYPT) { - g_crep = 123; + _crep = 123; if (_coreVar._cryptObjectId != 0) treg(_coreVar._cryptObjectId); } @@ -548,24 +548,24 @@ void MortevielleEngine::fctSearch() { } else { if (_currBitIndex > 0) _coreVar._faithScore += 3; - g_crep = 997; + _crep = 997; if (_coreVar._currPlace < CELLAR) - g_crep = r[_coreVar._currPlace]; + _crep = r[_coreVar._currPlace]; - if ((_coreVar._currPlace == TOILETS) && (g_num == 2)) - g_crep = 162; + if ((_coreVar._currPlace == TOILETS) && (_num == 2)) + _crep = 162; if (_coreVar._currPlace == KITCHEN) { - if ((g_num == 3) || (g_num == 4)) - g_crep = 162; - else if (g_num == 5) - g_crep = 159; + if ((_num == 3) || (_num == 4)) + _crep = 162; + else if (_num == 5) + _crep = 159; } if (_coreVar._currPlace == MOUNTAIN) - g_crep = 104; + _crep = 104; else if (_coreVar._currPlace == CRYPT) - g_crep = 155; + _crep = 155; } } @@ -577,7 +577,7 @@ void MortevielleEngine::fctSelfSearch() { if (_coreVar._selectedObjectId != 0) st7(_coreVar._selectedObjectId); else - g_crep = 186; + _crep = 186; } /** @@ -588,16 +588,16 @@ void MortevielleEngine::fctOpen() { if (!_syn) ecr3(getEngineString(S_OPEN)); - if (g_caff == ROOM26) { - if (g_ment != 0) { + if (_caff == ROOM26) { + if (_ment != 0) { _msg[4] = OPCODE_ENTER; _syn = true; } else - g_crep = 997; + _crep = 997; return; } - if (g_caff == 15) { + if (_caff == 15) { showMoveMenuAlert(); return; } @@ -607,38 +607,38 @@ void MortevielleEngine::fctOpen() { return; tcoord(7); - if (g_num != 0) { + if (_num != 0) { if (_currBitIndex > 0) _coreVar._faithScore += 2; - ++g_iouv; + ++_iouv; int tmpPlace = 0; do { ++tmpPlace; - } while (!((tmpPlace > 6) || (ord(_touv[tmpPlace]) == 0) || (ord(_touv[tmpPlace]) == g_num))); - if (ord(_touv[tmpPlace]) != g_num) { - if (!( ((g_num == 3) && ((_coreVar._currPlace == OWN_ROOM) || (_coreVar._currPlace == 9) || (_coreVar._currPlace == BLUE_ROOM) || (_coreVar._currPlace == BATHROOM))) - || ((g_num == 4) && ((_coreVar._currPlace == GREEN_ROOM) || (_coreVar._currPlace == PURPLE_ROOM) || (_coreVar._currPlace == RED_ROOM))) - || ((_coreVar._currPlace == DARKBLUE_ROOM) && (g_num == 5)) - || ((g_num == 6) && ((_coreVar._currPlace == BATHROOM) || (_coreVar._currPlace == DINING_ROOM) || (_coreVar._currPlace == GREEN_ROOM2) || (_coreVar._currPlace == ATTIC))) - || ((_coreVar._currPlace == GREEN_ROOM2) && (g_num == 2)) - || ((_coreVar._currPlace == KITCHEN) && (g_num == 7))) ) { + } while (!((tmpPlace > 6) || (ord(_touv[tmpPlace]) == 0) || (ord(_touv[tmpPlace]) == _num))); + if (ord(_touv[tmpPlace]) != _num) { + if (!( ((_num == 3) && ((_coreVar._currPlace == OWN_ROOM) || (_coreVar._currPlace == 9) || (_coreVar._currPlace == BLUE_ROOM) || (_coreVar._currPlace == BATHROOM))) + || ((_num == 4) && ((_coreVar._currPlace == GREEN_ROOM) || (_coreVar._currPlace == PURPLE_ROOM) || (_coreVar._currPlace == RED_ROOM))) + || ((_coreVar._currPlace == DARKBLUE_ROOM) && (_num == 5)) + || ((_num == 6) && ((_coreVar._currPlace == BATHROOM) || (_coreVar._currPlace == DINING_ROOM) || (_coreVar._currPlace == GREEN_ROOM2) || (_coreVar._currPlace == ATTIC))) + || ((_coreVar._currPlace == GREEN_ROOM2) && (_num == 2)) + || ((_coreVar._currPlace == KITCHEN) && (_num == 7))) ) { if ( ((_coreVar._currPlace > DINING_ROOM) && (_coreVar._currPlace < CELLAR)) || ((_coreVar._currPlace > RED_ROOM) && (_coreVar._currPlace < DINING_ROOM)) || (_coreVar._currPlace == OWN_ROOM) || (_coreVar._currPlace == PURPLE_ROOM) || (_coreVar._currPlace == BLUE_ROOM)) { if (getRandomNumber(1, 4) == 3) _speechManager.startSpeech(7, 9, 1); } - _touv[tmpPlace] = chr(g_num); - aniof(1, g_num); + _touv[tmpPlace] = chr(_num); + aniof(1, _num); } tmpPlace = _coreVar._currPlace; if (_coreVar._currPlace == CRYPT) tmpPlace = CELLAR; - g_crep = _tabdon[aouvr + (tmpPlace * 7) + g_num - 1]; - if (g_crep == 254) - g_crep = 999; + _crep = _tabdon[aouvr + (tmpPlace * 7) + _num - 1]; + if (_crep == 254) + _crep = 999; } else - g_crep = 18; + _crep = 18; } } @@ -648,7 +648,7 @@ void MortevielleEngine::fctOpen() { */ void MortevielleEngine::fctPlace() { if (_coreVar._selectedObjectId == 0) { - g_crep = 186; + _crep = 186; return; } @@ -657,25 +657,25 @@ void MortevielleEngine::fctPlace() { tfleche(); if (_keyPressedEsc) - g_crep = 998; + _crep = 998; if ((_anyone) || (_keyPressedEsc)) return; tcoord(8); - if (g_num != 0) { - g_crep = 999; - if (g_caff == 13) { - if (g_num == 1) { + if (_num != 0) { + _crep = 999; + if (_caff == 13) { + if (_num == 1) { if (_coreVar._atticBallHoleObjectId != 0) { - g_crep = 188; + _crep = 188; } else { _coreVar._atticBallHoleObjectId = _coreVar._selectedObjectId; if (_coreVar._selectedObjectId == 141) aniof(1, 7); } } else if (_coreVar._atticRodHoleObjectId != 0) { - g_crep = 188; + _crep = 188; } else { _coreVar._atticRodHoleObjectId = _coreVar._selectedObjectId; if (_coreVar._selectedObjectId == 159) @@ -683,9 +683,9 @@ void MortevielleEngine::fctPlace() { } } - if (g_caff == 14) { + if (_caff == 14) { if (_coreVar._cellarObjectId != 0) { - g_crep = 188; + _crep = 188; } else { _coreVar._cellarObjectId = _coreVar._selectedObjectId; if (_coreVar._selectedObjectId == 151) { @@ -729,49 +729,49 @@ void MortevielleEngine::fctPlace() { alertTxt = getString(577); Alert::show(alertTxt, 1); aniof(2, 1); - g_crep = 166; + _crep = 166; } affrep(); } else { aniof(2, 1); - g_crep = 166; + _crep = 166; } return; } } } - if (g_caff == 16) { + if (_caff == 16) { if (_coreVar._cryptObjectId == 0) _coreVar._cryptObjectId = _coreVar._selectedObjectId; else - g_crep = 188; + _crep = 188; } - if (g_caff == 17) { + if (_caff == 17) { if (_coreVar._secretPassageObjectId != 0) { - g_crep = 188; + _crep = 188; } else if (_coreVar._selectedObjectId == 143) { _coreVar._secretPassageObjectId = 143; aniof(1, 1); } else { - g_crep = 1512; + _crep = 1512; loseGame(); } } - if (g_caff == 24) { + if (_caff == 24) { if (_coreVar._wellObjectId != 0) { - g_crep = 188; + _crep = 188; } else if ((_coreVar._selectedObjectId == 140) || (_coreVar._selectedObjectId == 120)) { _coreVar._wellObjectId = _coreVar._selectedObjectId; aniof(1, 1); } else { - g_crep = 185; + _crep = 185; } } - if (g_crep != 188) + if (_crep != 188) maivid(); } } @@ -781,8 +781,8 @@ void MortevielleEngine::fctPlace() { * @remarks Originally called 'ttourner' */ void MortevielleEngine::fctTurn() { - if (g_caff > 99) { - g_crep = 149; + if (_caff > 99) { + _crep = 149; return; } if (!_syn) @@ -791,8 +791,8 @@ void MortevielleEngine::fctTurn() { if ((_anyone) || (_keyPressedEsc)) return; tcoord(9); - if (g_num != 0) { - g_crep = 997; + if (_num != 0) { + _crep = 997; if ((_coreVar._currPlace == ATTIC) && (_coreVar._atticRodHoleObjectId == 159) && (_coreVar._atticBallHoleObjectId == 141)) { repon(2, 167); _speechManager.startSpeech(7, 9, 1); @@ -800,7 +800,7 @@ void MortevielleEngine::fctTurn() { if (answer == 1) _endGame = true; else - g_crep = 168; + _crep = 168; } if ((_coreVar._currPlace == SECRET_PASSAGE) && (_coreVar._secretPassageObjectId == 143)) { repon(2, 175); @@ -811,7 +811,7 @@ void MortevielleEngine::fctTurn() { _coreVar._currPlace = CRYPT; affrep(); } else - g_crep = 176; + _crep = 176; } } } @@ -826,11 +826,11 @@ void MortevielleEngine::fctSelfHide() { tfleche(); if (!(_anyone) && !(_keyPressedEsc)) { tcoord(10); - if (g_num == 0) + if (_num == 0) _hiddenHero = false; else { _hiddenHero = true; - g_crep = 999; + _crep = 999; } } } @@ -841,21 +841,21 @@ void MortevielleEngine::fctSelfHide() { */ void MortevielleEngine::fctAttach() { if (_coreVar._selectedObjectId == 0) - g_crep = 186; + _crep = 186; else { if (!_syn) ecr3(getEngineString(S_TIE)); tfleche(); if (!(_anyone) && !(_keyPressedEsc)) { tcoord(8); - g_crep = 997; - if ((g_num != 0) && (_coreVar._currPlace == WELL)) { - g_crep = 999; + _crep = 997; + if ((_num != 0) && (_coreVar._currPlace == WELL)) { + _crep = 999; if ((_coreVar._selectedObjectId == 120) || (_coreVar._selectedObjectId == 140)) { _coreVar._wellObjectId = _coreVar._selectedObjectId; aniof(1, 1); } else - g_crep = 185; + _crep = 185; maivid(); } } @@ -870,36 +870,36 @@ void MortevielleEngine::fctClose() { if (!_syn) ecr3(getEngineString(S_CLOSE)); - if (g_caff < ROOM26) { + if (_caff < ROOM26) { tfleche(); if (_keyPressedEsc) - g_crep = 998; + _crep = 998; if ((_anyone) || (_keyPressedEsc)) return; tcoord(7); - if (g_num != 0) { + if (_num != 0) { int cx = 0; do { ++cx; - } while ((cx <= 6) && (g_num != ord(_touv[cx]))); - if (g_num == ord(_touv[cx])) { - aniof(2, g_num); - g_crep = 998; + } while ((cx <= 6) && (_num != ord(_touv[cx]))); + if (_num == ord(_touv[cx])) { + aniof(2, _num); + _crep = 998; _touv[cx] = chr(0); - --g_iouv; - if (g_iouv < 0) - g_iouv = 0; + --_iouv; + if (_iouv < 0) + _iouv = 0; int chai = 9999; rechai(chai); if (_mchai == chai) _mchai = 0; } else { - g_crep = 187; + _crep = 187; } } } - if (g_caff == ROOM26) - g_crep = 999; + if (_caff == ROOM26) + _crep = 999; } /** @@ -919,9 +919,9 @@ void MortevielleEngine::fctKnock() { tfleche(); if (!(_anyone) && !(_keyPressedEsc)) { if ((_coreVar._currPlace < MOUNTAIN) && (_coreVar._currPlace != LANDING)) - g_crep = 133; + _crep = 133; else - g_crep = 997; + _crep = 997; } return; @@ -931,12 +931,12 @@ void MortevielleEngine::fctKnock() { int rand = (getRandomNumber(0, 8)) - 4; _speechManager.startSpeech(11, rand, 1); int p; - ecfren(p, rand, _coreVar._faithScore, g_ment); - int l = g_ment; + ecfren(p, rand, _coreVar._faithScore, _ment); + int l = _ment; if (l != 0) { if (p != -500) { if (rand > p) - g_crep = 190; + _crep = 190; else { becfren(l); getKnockAnswer(); @@ -945,8 +945,8 @@ void MortevielleEngine::fctKnock() { getKnockAnswer(); } - if (g_ment == 8) - g_crep = 190; + if (_ment == 8) + _crep = 190; } } @@ -958,12 +958,12 @@ void MortevielleEngine::fctSelfPut() { if (!_syn) ecr3(getEngineString(S_POSE)); if (_coreVar._selectedObjectId == 0) - g_crep = 186; + _crep = 186; else { - if (g_caff > 99) { - g_crep = 999; + if (_caff > 99) { + _crep = 999; ajchai(); - if (g_crep != 192) + if (_crep != 192) maivid(); return; } @@ -971,74 +971,74 @@ void MortevielleEngine::fctSelfPut() { if ((_anyone) || (_keyPressedEsc)) return; tcoord(7); - g_crep = 124; - if (g_num != 0) { + _crep = 124; + if (_num != 0) { int chai; rechai(chai); if (chai == 0) - g_crep = 997; + _crep = 997; else { int cx = 0; do { ++cx; - } while ((cx <= 6) && (g_num != ord(_touv[cx]))); - if (g_num != ord(_touv[cx])) - g_crep = 187; + } while ((cx <= 6) && (_num != ord(_touv[cx]))); + if (_num != ord(_touv[cx])) + _crep = 187; else { _mchai = chai; - g_crep = 999; + _crep = 999; } } } else { tcoord(8); - if (g_num != 0) { - g_crep = 998; - if (g_caff == PURPLE_ROOM) { + if (_num != 0) { + _crep = 998; + if (_caff == PURPLE_ROOM) { if (_coreVar._purpleRoomObjectId != 0) - g_crep = 188; + _crep = 188; else _coreVar._purpleRoomObjectId = _coreVar._selectedObjectId; } - if (g_caff == ATTIC) { - if (g_num == 1) { + if (_caff == ATTIC) { + if (_num == 1) { if (_coreVar._atticBallHoleObjectId != 0) - g_crep = 188; + _crep = 188; else _coreVar._atticBallHoleObjectId = _coreVar._selectedObjectId; } else if (_coreVar._atticRodHoleObjectId != 0) { - g_crep = 188; + _crep = 188; } else { _coreVar._atticRodHoleObjectId = _coreVar._selectedObjectId; } } - if (g_caff == CRYPT) { + if (_caff == CRYPT) { if (_coreVar._cryptObjectId != 0) - g_crep = 188; + _crep = 188; else _coreVar._cryptObjectId = _coreVar._selectedObjectId; } - if (g_caff == WELL) - g_crep = 185; - if ((g_caff == CELLAR) || (g_caff == SECRET_PASSAGE)) - g_crep = 124; + if (_caff == WELL) + _crep = 185; + if ((_caff == CELLAR) || (_caff == SECRET_PASSAGE)) + _crep = 124; } else { - g_crep = 124; - if (g_caff == WELL) { + _crep = 124; + if (_caff == WELL) { tcoord(5); - if (g_num != 0) - g_crep = 185; + if (_num != 0) + _crep = 185; } } } - if (g_caff == INSIDE_WELL) - g_crep = 185; - if ((g_crep == 999) || (g_crep == 185) || (g_crep == 998)) { - if (g_crep == 999) + if (_caff == INSIDE_WELL) + _crep = 185; + if ((_crep == 999) || (_crep == 185) || (_crep == 998)) { + if (_crep == 999) ajchai(); - if (g_crep != 192) + if (_crep != 192) maivid(); } } @@ -1050,17 +1050,17 @@ void MortevielleEngine::fctSelfPut() { */ void MortevielleEngine::fctListen() { if (_coreVar._currPlace != ROOM26) - g_crep = 101; + _crep = 101; else { if (_currBitIndex != 0) ++_coreVar._faithScore; int p, rand; - ecfren(p, rand, _coreVar._faithScore, g_ment); - int l = g_ment; + ecfren(p, rand, _coreVar._faithScore, _ment); + int l = _ment; if (l != 0) { if (p != -500) { if (rand > p) - g_crep = 101; + _crep = 101; else { becfren(l); int j, h, m; @@ -1068,16 +1068,16 @@ void MortevielleEngine::fctListen() { rand = getRandomNumber(1, 100); if ((h >= 0) && (h < 8)) { if (rand > 30) - g_crep = 101; + _crep = 101; else - g_crep = 178; + _crep = 178; } else if (rand > 70) - g_crep = 101; + _crep = 101; else - g_crep = 178; + _crep = 178; } } else - g_crep = 178; + _crep = 178; } } } @@ -1088,11 +1088,11 @@ void MortevielleEngine::fctListen() { */ void MortevielleEngine::fctEat() { if ((_coreVar._currPlace > LANDING) && (_coreVar._currPlace < ROOM26)) { - g_crep = 148; + _crep = 148; } else { tsort(); _coreVar._currPlace = DINING_ROOM; - g_caff = 10; + _caff = 10; debloc(_coreVar._currPlace); _menu.setDestinationMenuText(_coreVar._currPlace); @@ -1114,11 +1114,11 @@ void MortevielleEngine::fctEat() { h = 1; } - g_jh += h; - g_crep = 135; + _jh += h; + _crep = 135; prepareRoom(); } else { - g_crep = 134; + _crep = 134; } } } @@ -1133,50 +1133,50 @@ void MortevielleEngine::fctEnter() { _menu.setDestinationMenuText(_coreVar._currPlace); } else if (_coreVar._currPlace == LANDING) showMoveMenuAlert(); - else if (g_ment == 0) - g_crep = 997; - else if ((g_ment == 9) && (_coreVar._selectedObjectId != 136)) { - g_crep = 189; + else if (_ment == 0) + _crep = 997; + else if ((_ment == 9) && (_coreVar._selectedObjectId != 136)) { + _crep = 189; _coreVar._teauto[8] = '*'; } else { int z = 0; if (!_blo) - z = t11(g_ment); + z = t11(_ment); if (z != 0) { - if ((g_ment == 3) || (g_ment == 7)) - g_crep = 179; + if ((_ment == 3) || (_ment == 7)) + _crep = 179; else { - g_x = (getRandomNumber(0, 10)) - 5; - _speechManager.startSpeech(7, g_x, 1); + _x = (getRandomNumber(0, 10)) - 5; + _speechManager.startSpeech(7, _x, 1); aniof(1, 1); - g_x = convertBitIndexToCharacterIndex(z); + _x = convertBitIndexToCharacterIndex(z); ++_coreVar._faithScore; _coreVar._currPlace = LANDING; _msg[3] = MENU_DISCUSS; - _msg[4] = _menu._discussMenu[g_x]; + _msg[4] = _menu._discussMenu[_x]; _syn = true; - if (g_ment == 9) { + if (_ment == 9) { _col = true; - g_caff = 70; + _caff = 70; afdes(); - repon(2, g_caff); + repon(2, _caff); } else _col = false; - debloc(g_ment); - g_ment = 0; + debloc(_ment); + _ment = 0; } } else { - g_x = (getRandomNumber(0, 10)) - 5; - _speechManager.startSpeech(7, g_x, 1); + _x = (getRandomNumber(0, 10)) - 5; + _speechManager.startSpeech(7, _x, 1); aniof(1, 1); - _coreVar._currPlace = g_ment; + _coreVar._currPlace = _ment; affrep(); debloc(_coreVar._currPlace); _menu.setDestinationMenuText(_coreVar._currPlace); - g_ment = 0; - g_mpers = 0; + _ment = 0; + _savedBitIndex = 0; _currBitIndex = 0; } } @@ -1190,7 +1190,7 @@ void MortevielleEngine::fctSleep() { int z, j, h, m; if ((_coreVar._currPlace > LANDING) && (_coreVar._currPlace < ROOM26)) { - g_crep = 148; + _crep = 148; return; } if (_coreVar._currPlace != OWN_ROOM) { @@ -1214,10 +1214,10 @@ void MortevielleEngine::fctSleep() { z = (7 - h) * 2; if (m == 30) --z; - g_jh += z; + _jh += z; h = 7; } - g_jh += 2; + _jh += 2; ++h; if (h > 23) h = 0; @@ -1225,8 +1225,8 @@ void MortevielleEngine::fctSleep() { answer = Alert::show(getEngineString(S_YES_NO), 1); _anyone = false; } while (answer != 1); - g_crep = 998; - g_num = 0; + _crep = 998; + _num = 0; } /** @@ -1236,14 +1236,14 @@ void MortevielleEngine::fctSleep() { void MortevielleEngine::fctForce() { if (!_syn) ecr3(getEngineString(S_SMASH)); - if (g_caff < 25) + if (_caff < 25) tfleche(); if ((!_anyone) && (!_keyPressedEsc)) { if (_coreVar._currPlace != ROOM26) - g_crep = 997; + _crep = 997; else { - g_crep = 143; + _crep = 143; _coreVar._faithScore += 2; } } @@ -1255,9 +1255,9 @@ void MortevielleEngine::fctForce() { */ void MortevielleEngine::fctLeave() { tsort(); - g_crep = 0; + _crep = 0; if ((_coreVar._currPlace == MOUNTAIN) || (_coreVar._currPlace == MANOR_FRONT) || (_coreVar._currPlace == MANOR_BACK) || (_coreVar._currPlace == WELL)) - g_crep = 997; + _crep = 997; else { int nextPlace = OWN_ROOM; @@ -1269,18 +1269,18 @@ void MortevielleEngine::fctLeave() { nextPlace = LANDING; else if (_coreVar._currPlace == CRYPT) { nextPlace = SECRET_PASSAGE; - g_crep = 176; + _crep = 176; } else if (_coreVar._currPlace == SECRET_PASSAGE) nextPlace = t23coul(); else if (_coreVar._currPlace == INSIDE_WELL) nextPlace = WELL; - if (g_crep != 997) + if (_crep != 997) _coreVar._currPlace = nextPlace; - g_caff = nextPlace; - if (g_crep == 0) - g_crep = nextPlace; + _caff = nextPlace; + if (_crep == 0) + _crep = nextPlace; debloc(nextPlace); _menu.setDestinationMenuText(nextPlace); } @@ -1291,22 +1291,22 @@ void MortevielleEngine::fctLeave() { * @remarks Originally called 'tattendre' */ void MortevielleEngine::fctWait() { - g_mpers = 0; + _savedBitIndex = 0; clearScreenType3(); int answer; do { - ++g_jh; + ++_jh; prepareRoom(); if (!_blo) t11(_coreVar._currPlace); - if ((_currBitIndex != 0) && (g_mpers == 0)) { - g_crep = 998; + if ((_currBitIndex != 0) && (_savedBitIndex == 0)) { + _crep = 998; if ((_coreVar._currPlace == ATTIC) || (_coreVar._currPlace == CELLAR)) - cavegre(); + initCaveOrCellar(); if ((_coreVar._currPlace > OWN_ROOM) && (_coreVar._currPlace < DINING_ROOM)) _anyone = true; - g_mpers = _currBitIndex; + _savedBitIndex = _currBitIndex; if (!_anyone) prepareRoom(); return; @@ -1314,7 +1314,7 @@ void MortevielleEngine::fctWait() { repon(2, 102); answer = Alert::show(getEngineString(S_YES_NO), 1); } while (answer != 2); - g_crep = 998; + _crep = 998; if (!_anyone) prepareRoom(); } @@ -1326,11 +1326,11 @@ void MortevielleEngine::fctWait() { void MortevielleEngine::fctSound() { if (!_syn) ecr3(getEngineString(S_PROBE2)); - if (g_caff < 27) { + if (_caff < 27) { tfleche(); if (!(_anyone) && (!_keyPressedEsc)) - g_crep = 145; - g_num = 0; + _crep = 145; + _num = 0; } } @@ -1353,10 +1353,10 @@ void MortevielleEngine::fctDiscuss() { do { ++cx; } while (_menu._discussMenu[cx] != _msg[4]); - g_caff = 69 + cx; + _caff = 69 + cx; afdes(); - repon(2, g_caff); - suj = g_caff + 60; + repon(2, _caff); + suj = _caff + 60; } tkey1(false); mennor(); @@ -1404,7 +1404,7 @@ void MortevielleEngine::fctDiscuss() { CHECK_QUIT; _mouse.getMousePosition(x, y, c); - x *= (3 - g_res); + x *= (3 - _res); if (x > 319) cx = 41; else @@ -1467,7 +1467,7 @@ void MortevielleEngine::fctDiscuss() { if (_col) { _col = false; _coreVar._currPlace = 15; - if (g_iouv > 0) + if (_iouv > 0) max = 8; else max = 4; @@ -1477,10 +1477,10 @@ void MortevielleEngine::fctDiscuss() { suj = 138; _coreVar._faithScore += (3 * (_coreVar._faithScore / 10)); } - } else if (_nbrep[g_caff - 69] < _nbrepm[g_caff - 69]) { - suj = _tabdon[arep + (ix << 3) + (g_caff - 70)]; + } else if (_nbrep[_caff - 69] < _nbrepm[_caff - 69]) { + suj = _tabdon[arep + (ix << 3) + (_caff - 70)]; _coreVar._faithScore += _tabdon[arcf + ix]; - ++_nbrep[g_caff - 69]; + ++_nbrep[_caff - 69]; } else { _coreVar._faithScore += 3; suj = 139; @@ -1518,7 +1518,7 @@ void MortevielleEngine::fctDiscuss() { _col = false; _coreVar._currPlace = LANDING; } - g_ctrm = 0; + _controlMenu = 0; _mouse.hideMouse(); hirs(); drawRightFrame(); @@ -1537,17 +1537,17 @@ void MortevielleEngine::fctDiscuss() { * @remarks Originally called 'tsentir' */ void MortevielleEngine::fctSmell() { - g_crep = 119; - if (g_caff < ROOM26) { + _crep = 119; + if (_caff < ROOM26) { if (!_syn) ecr3(getEngineString(S_SMELL)); tfleche(); if (!(_anyone) && !(_keyPressedEsc)) - if (g_caff == 16) - g_crep = 153; - } else if (g_caff == 123) - g_crep = 110; - g_num = 0; + if (_caff == 16) + _crep = 153; + } else if (_caff == 123) + _crep = 110; + _num = 0; } /** @@ -1555,13 +1555,13 @@ void MortevielleEngine::fctSmell() { * @remarks Originally called 'tgratter' */ void MortevielleEngine::fctScratch() { - g_crep = 155; - if (g_caff < 27) { + _crep = 155; + if (_caff < 27) { if (!_syn) ecr3(getEngineString(S_SCRATCH)); tfleche(); } - g_num = 0; + _num = 0; } /** @@ -1578,7 +1578,7 @@ void MortevielleEngine::endGame() { repon(9, 1509); tkey1(false); _mouse.hideMouse(); - g_caff = 70; + _caff = 70; taffich(); hirs(); premtet(); @@ -1588,7 +1588,7 @@ void MortevielleEngine::endGame() { repon(9, 1509); repon(2, 142); tkey1(false); - g_caff = 32; + _caff = 32; afdes(); repon(6, 34); repon(2, 35); diff --git a/engines/mortevielle/dialogs.cpp b/engines/mortevielle/dialogs.cpp index b14af53b00..1f97ee0fe6 100644 --- a/engines/mortevielle/dialogs.cpp +++ b/engines/mortevielle/dialogs.cpp @@ -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 diff --git a/engines/mortevielle/graphics.cpp b/engines/mortevielle/graphics.cpp index 2e9e0195a6..42dd3c7cc7 100644 --- a/engines/mortevielle/graphics.cpp +++ b/engines/mortevielle/graphics.cpp @@ -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; } diff --git a/engines/mortevielle/menu.cpp b/engines/mortevielle/menu.cpp index 1b030935cb..5bc0940f6c 100644 --- a/engines/mortevielle/menu.cpp +++ b/engines/mortevielle/menu.cpp @@ -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; diff --git a/engines/mortevielle/mor.cpp b/engines/mortevielle/mor.cpp index 4c1d4dedf9..85e34b6680 100644 --- a/engines/mortevielle/mor.cpp +++ b/engines/mortevielle/mor.cpp @@ -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) { diff --git a/engines/mortevielle/mor.h b/engines/mortevielle/mor.h index 30b0cafb47..667883ccf4 100644 --- a/engines/mortevielle/mor.h +++ b/engines/mortevielle/mor.h @@ -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 diff --git a/engines/mortevielle/mortevielle.cpp b/engines/mortevielle/mortevielle.cpp index 05d6e05a56..536fe09114 100644 --- a/engines/mortevielle/mortevielle.cpp +++ b/engines/mortevielle/mortevielle.cpp @@ -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 diff --git a/engines/mortevielle/mortevielle.h b/engines/mortevielle/mortevielle.h index 69cb12ab67..924e92b3d4 100644 --- a/engines/mortevielle/mortevielle.h +++ b/engines/mortevielle/mortevielle.h @@ -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; diff --git a/engines/mortevielle/mouse.cpp b/engines/mortevielle/mouse.cpp index bd7e489aa9..e18090e1dd 100644 --- a/engines/mortevielle/mouse.cpp +++ b/engines/mortevielle/mouse.cpp @@ -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': diff --git a/engines/mortevielle/outtext.cpp b/engines/mortevielle/outtext.cpp index 8a3ecb8041..92831ec2f4 100644 --- a/engines/mortevielle/outtext.cpp +++ b/engines/mortevielle/outtext.cpp @@ -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; } } diff --git a/engines/mortevielle/speech.cpp b/engines/mortevielle/speech.cpp index d8731f96ac..5b9e8415dc 100644 --- a/engines/mortevielle/speech.cpp +++ b/engines/mortevielle/speech.cpp @@ -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: diff --git a/engines/mortevielle/var_mor.cpp b/engines/mortevielle/var_mor.cpp index 6fc0593d65..a451cb651f 100644 --- a/engines/mortevielle/var_mor.cpp +++ b/engines/mortevielle/var_mor.cpp @@ -34,36 +34,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 -----------------------*/ /*---------------------------------------------------------------------------*/ diff --git a/engines/mortevielle/var_mor.h b/engines/mortevielle/var_mor.h index 9ac807aa95..ddde25a464 100644 --- a/engines/mortevielle/var_mor.h +++ b/engines/mortevielle/var_mor.h @@ -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 |