diff options
Diffstat (limited to 'engines/mortevielle')
24 files changed, 733 insertions, 638 deletions
diff --git a/engines/mortevielle/actions.cpp b/engines/mortevielle/actions.cpp index b68dd48b0f..556475d515 100644 --- a/engines/mortevielle/actions.cpp +++ b/engines/mortevielle/actions.cpp @@ -8,12 +8,12 @@ * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. - + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. @@ -40,7 +40,7 @@ namespace Mortevielle { * @remarks Originally called 'taller' */ void MortevielleEngine::fctMove() { - int oldMenu = (_menu._moveMenu[6]._menuId << 8) | _menu._moveMenu[6]._actionId; + int oldMenu = (_menu->_moveMenu[6]._menuId << 8) | _menu->_moveMenu[6]._actionId; if ((_coreVar._currPlace == ROOM26) && (_currAction == oldMenu)) { _coreVar._currPlace = LANDING; _caff = _coreVar._currPlace; @@ -65,10 +65,10 @@ void MortevielleEngine::fctMove() { if (_num == 1) { _coreVar._currPlace = OWN_ROOM; - _menu.setDestinationText(OWN_ROOM); + _menu->setDestinationText(OWN_ROOM); } else if (_num == 7) { _coreVar._currPlace = ATTIC; - _menu.setDestinationText(ATTIC); + _menu->setDestinationText(ATTIC); } else if (_num != 6) _coreVar._currPlace = ROOM26; @@ -85,10 +85,10 @@ void MortevielleEngine::fctMove() { } exitRoom(); int menuChoice = 1; - oldMenu = (_menu._moveMenu[menuChoice]._menuId << 8) | _menu._moveMenu[menuChoice]._actionId; + oldMenu = (_menu->_moveMenu[menuChoice]._menuId << 8) | _menu->_moveMenu[menuChoice]._actionId; while (oldMenu != _currAction) { ++menuChoice; - oldMenu = (_menu._moveMenu[menuChoice]._menuId << 8) | _menu._moveMenu[menuChoice]._actionId; + oldMenu = (_menu->_moveMenu[menuChoice]._menuId << 8) | _menu->_moveMenu[menuChoice]._actionId; } switch (_coreVar._currPlace) { @@ -97,14 +97,14 @@ void MortevielleEngine::fctMove() { gotoManorFront(); else if (menuChoice == 2) checkManorDistance(); - _menu.setDestinationText(_coreVar._currPlace); + _menu->setDestinationText(_coreVar._currPlace); return; case INSIDE_WELL: if (menuChoice == 1) floodedInWell(); else if (menuChoice == 2) gotoManorBack(); - _menu.setDestinationText(_coreVar._currPlace); + _menu->setDestinationText(_coreVar._currPlace); return; case BUREAU: if (menuChoice == 1) @@ -193,7 +193,7 @@ void MortevielleEngine::fctMove() { if ((menuChoice < 5) || (menuChoice == 13) || (menuChoice == 14)) prepareDisplayText(); resetRoomVariables(_coreVar._currPlace); - _menu.setDestinationText(_coreVar._currPlace); + _menu->setDestinationText(_coreVar._currPlace); } /** @@ -208,23 +208,32 @@ void MortevielleEngine::fctTake() { if (_currBitIndex > 0) _coreVar._faithScore += 3; if (_obpart) { - if (_coreVar._currPlace == PURPLE_ROOM) + switch (_coreVar._currPlace) { + case PURPLE_ROOM: _coreVar._purpleRoomObjectId = 0; - if (_coreVar._currPlace == ATTIC) { + break; + case ATTIC: if (_coreVar._atticBallHoleObjectId == _caff) _coreVar._atticBallHoleObjectId = 0; if (_coreVar._atticRodHoleObjectId == _caff) _coreVar._atticRodHoleObjectId = 0; - } - if (_coreVar._currPlace == CELLAR) + break; + case CELLAR: _coreVar._cellarObjectId = 0; - if (_coreVar._currPlace == CRYPT) + break; + case CRYPT: _coreVar._cryptObjectId = 0; - if (_coreVar._currPlace == SECRET_PASSAGE) + break; + case SECRET_PASSAGE: _coreVar._secretPassageObjectId = 0; - if (_coreVar._currPlace == WELL) + break; + case WELL: _coreVar._wellObjectId = 0; - _menu.unsetSearchMenu(); + break; + default: + break; + } + _menu->unsetSearchMenu(); _obpart = false; prepareDisplayText(); } else { @@ -258,38 +267,54 @@ void MortevielleEngine::fctTake() { if (_currBitIndex > 0) _coreVar._faithScore += 3; _crep = 997; - if ((_coreVar._currPlace == PURPLE_ROOM) && (_coreVar._purpleRoomObjectId != 0)) - putInHand(_coreVar._purpleRoomObjectId); - if ((_coreVar._currPlace == ATTIC) && (_num == 1) && (_coreVar._atticBallHoleObjectId != 0)) { - putInHand(_coreVar._atticBallHoleObjectId); - if ((_crep != 997) && (_crep != 139)) - displayAnimFrame(2, 7); - } - if ((_coreVar._currPlace == ATTIC) && (_num == 2) && (_coreVar._atticRodHoleObjectId != 0)) { - putInHand(_coreVar._atticRodHoleObjectId); - if ((_crep != 997) && (_crep != 139)) - displayAnimFrame(2, 6); - } - if ((_coreVar._currPlace == CELLAR) && (_coreVar._cellarObjectId != 0)) { - putInHand(_coreVar._cellarObjectId); - if ((_crep != 997) && (_crep != 139)) - displayAnimFrame(2, 2); - } - if ((_coreVar._currPlace == CRYPT) && (_coreVar._cryptObjectId != 0)) - putInHand(_coreVar._cryptObjectId); - - if ((_coreVar._currPlace == SECRET_PASSAGE) && (_coreVar._secretPassageObjectId != 0)) { - putInHand(_coreVar._secretPassageObjectId); - if ((_crep != 997) && (_crep != 139)) { - _crep = 182; - displayAnimFrame(2, 1); + + switch (_coreVar._currPlace) { + case PURPLE_ROOM: + if (_coreVar._purpleRoomObjectId != 0) + putInHand(_coreVar._purpleRoomObjectId); + break; + case ATTIC: + if ((_num == 1) && (_coreVar._atticBallHoleObjectId != 0)) { + putInHand(_coreVar._atticBallHoleObjectId); + if ((_crep != 997) && (_crep != 139)) + displayAnimFrame(2, 7); + } else if ((_num == 2) && (_coreVar._atticRodHoleObjectId != 0)) { + putInHand(_coreVar._atticRodHoleObjectId); + if ((_crep != 997) && (_crep != 139)) + displayAnimFrame(2, 6); } + break; + case CELLAR: + if (_coreVar._cellarObjectId != 0) { + putInHand(_coreVar._cellarObjectId); + if ((_crep != 997) && (_crep != 139)) + displayAnimFrame(2, 2); + } + break; + case CRYPT: + if (_coreVar._cryptObjectId != 0) + putInHand(_coreVar._cryptObjectId); + break; + case SECRET_PASSAGE: + if (_coreVar._secretPassageObjectId != 0) { + putInHand(_coreVar._secretPassageObjectId); + if ((_crep != 997) && (_crep != 139)) { + _crep = 182; + displayAnimFrame(2, 1); + } + } + break; + case WELL: + if (_coreVar._wellObjectId != 0) { + putInHand(_coreVar._wellObjectId); + if ((_crep != 997) && (_crep != 139)) + displayAnimFrame(2, 1); + } + break; + default: + break; } - if ((_coreVar._currPlace == WELL) && (_coreVar._wellObjectId != 0)) { - putInHand(_coreVar._wellObjectId); - if ((_crep != 997) && (_crep != 139)) - displayAnimFrame(2, 1); - } + if ((_crep != 997) && (_crep != 182) && (_crep != 139)) _crep = 999; } @@ -325,7 +350,7 @@ void MortevielleEngine::fctInventoryTake() { int oldMenu = 0; do { ++inventIndex; - oldMenu = (_menu._inventoryMenu[inventIndex]._menuId << 8) | _menu._inventoryMenu[inventIndex]._actionId; + oldMenu = (_menu->_inventoryMenu[inventIndex]._menuId << 8) | _menu->_inventoryMenu[inventIndex]._actionId; } while (oldMenu != _currAction); int cz = 0; int cy = 0; @@ -336,7 +361,7 @@ void MortevielleEngine::fctInventoryTake() { } while (cz != inventIndex); cz = _coreVar._inventory[cy]; _coreVar._inventory[cy] = 0; - _menu.setInventoryText(); + _menu->setInventoryText(); putInHand(cz); _crep = 998; clearDescriptionBar(); @@ -456,13 +481,24 @@ void MortevielleEngine::fctLook() { } return; } + int cx = _coreVar._currPlace; - if (_coreVar._currPlace == CHAPEL) + switch (_coreVar._currPlace) { + case CHAPEL: cx = 17; - if ((_coreVar._currPlace > MANOR_FRONT) && (_coreVar._currPlace < DOOR)) + break; + case MANOR_BACK: + case INSIDE_WELL: + case WELL: cx -= 4; - if (_coreVar._currPlace == ROOM26) + break; + case ROOM26: cx = 21; + break; + default: + break; + } + _crep = _tabdon[kArega + (cx * 7) + _num - 1]; if ((_coreVar._currPlace == ATTIC) && (_num == 8)) _crep = 126; @@ -536,7 +572,7 @@ void MortevielleEngine::fctSearch() { if (_curSearchObjId != 0) { _searchCount = 0; _heroSearching = true; - _menu.setSearchMenu(); + _menu->setSearchMenu(); prepareNextObject(); } else _crep = 997; @@ -607,7 +643,7 @@ void MortevielleEngine::fctOpen() { if (_caff == ROOM26) { if (_roomDoorId != OWN_ROOM) { - _currAction = _menu._opcodeEnter; + _currAction = _menu->_opcodeEnter; _syn = true; } else _crep = 997; @@ -663,11 +699,11 @@ void MortevielleEngine::fctOpen() { || (_coreVar._currPlace == PURPLE_ROOM) || (_coreVar._currPlace == BLUE_ROOM)) { if (getRandomNumber(1, 4) == 3) - _soundManager.startSpeech(7, 9, 1); + _soundManager->startSpeech(7, 9, 1); } _openObjects[i] = _num; displayAnimFrame(1, _num); - _soundManager.waitSpeech(); + _soundManager->waitSpeech(); } int tmpPlace = _coreVar._currPlace; if (_coreVar._currPlace == CRYPT) @@ -731,21 +767,21 @@ void MortevielleEngine::fctPlace() { displayAnimFrame(1, 1); handleDescriptionText(2, 165); displayEmptyHand(); - _soundManager.startSpeech(6, -9, 1); + _soundManager->startSpeech(6, -9, 1); // Do you want to enter the hidden passage? - int answer = _dialogManager.show(getEngineString(S_YES_NO)); + int answer = _dialogManager->show(getEngineString(S_YES_NO)); if (answer == 1) { Common::String alertTxt = getString(582); - _dialogManager.show(alertTxt); + _dialogManager->show(alertTxt); - bool enterPassageFl = _dialogManager.showKnowledgeCheck(); - _mouse.hideMouse(); + bool enterPassageFl = _dialogManager->showKnowledgeCheck(); + _mouse->hideMouse(); clearScreen(); drawRightFrame(); clearDescriptionBar(); clearVerbBar(); - _mouse.showMouse(); + _mouse->showMouse(); prepareRoom(); drawClock(); if (_currBitIndex != 0) @@ -753,18 +789,18 @@ void MortevielleEngine::fctPlace() { else displayAloneText(); - _menu.displayMenu(); + _menu->displayMenu(); if (enterPassageFl) { _coreVar._currPlace = SECRET_PASSAGE; - _menu.setDestinationText(SECRET_PASSAGE); + _menu->setDestinationText(SECRET_PASSAGE); } else { - _menu.setDestinationText(_coreVar._currPlace); + _menu->setDestinationText(_coreVar._currPlace); setPal(14); drawPicture(); displayAnimFrame(1, 2); displayAnimFrame(1, 1); alertTxt = getString(577); - _dialogManager.show(alertTxt); + _dialogManager->show(alertTxt); displayAnimFrame(2, 1); _crep = 166; } @@ -832,8 +868,8 @@ void MortevielleEngine::fctTurn() { _crep = 997; if ((_coreVar._currPlace == ATTIC) && (_coreVar._atticRodHoleObjectId == 159) && (_coreVar._atticBallHoleObjectId == 141)) { handleDescriptionText(2, 167); - _soundManager.startSpeech(7, 9, 1); - int answer = _dialogManager.show(getEngineString(S_YES_NO)); + _soundManager->startSpeech(7, 9, 1); + int answer = _dialogManager->show(getEngineString(S_YES_NO)); if (answer == 1) _endGame = true; else @@ -842,8 +878,8 @@ void MortevielleEngine::fctTurn() { if ((_coreVar._currPlace == SECRET_PASSAGE) && (_coreVar._secretPassageObjectId == 143)) { handleDescriptionText(2, 175); clearVerbBar(); - _soundManager.startSpeech(6, -9, 1); - int answer = _dialogManager.show(getEngineString(S_YES_NO)); + _soundManager->startSpeech(6, -9, 1); + int answer = _dialogManager->show(getEngineString(S_YES_NO)); if (answer == 1) { _coreVar._currPlace = CRYPT; prepareDisplayText(); @@ -949,7 +985,7 @@ void MortevielleEngine::fctKnock() { displayTextInVerbBar(getEngineString(S_HIT)); if (_coreVar._currPlace == LANDING) { - _dialogManager.show(getEngineString(S_BEFORE_USE_DEP_MENU)); + _dialogManager->show(getEngineString(S_BEFORE_USE_DEP_MENU)); return; } @@ -967,7 +1003,7 @@ void MortevielleEngine::fctKnock() { if (_coreVar._currPlace == ROOM26) { int rand = (getRandomNumber(0, 8)) - 4; - _soundManager.startSpeech(11, rand, 1); + _soundManager->startSpeech(11, rand, 1); int pres = getPresenceStats(rand, _coreVar._faithScore, _roomDoorId); if (_roomDoorId != OWN_ROOM) { if (pres != -500) { @@ -1132,7 +1168,7 @@ void MortevielleEngine::fctEat() { _coreVar._currPlace = DINING_ROOM; _caff = DINING_ROOM; resetRoomVariables(_coreVar._currPlace); - _menu.setDestinationText(_coreVar._currPlace); + _menu->setDestinationText(_coreVar._currPlace); int day, hour, minute; updateHour(day, hour, minute); @@ -1168,7 +1204,7 @@ void MortevielleEngine::fctEat() { void MortevielleEngine::fctEnter() { if ((_coreVar._currPlace == MANOR_FRONT) || (_coreVar._currPlace == MANOR_BACK)) { gotoDiningRoom(); - _menu.setDestinationText(_coreVar._currPlace); + _menu->setDestinationText(_coreVar._currPlace); } else if (_coreVar._currPlace == LANDING) showMoveMenuAlert(); else if (_roomDoorId == OWN_ROOM) @@ -1178,22 +1214,22 @@ void MortevielleEngine::fctEnter() { _coreVar._availableQuestion[8] = '*'; } else { int pres = 0; - if (!_blo) + if (!_outsideOnlyFl) pres = getPresence(_roomDoorId); if (pres != 0) { if ((_roomDoorId == TOILETS) || (_roomDoorId == BATHROOM)) _crep = 179; else { int randVal = (getRandomNumber(0, 10)) - 5; - _soundManager.startSpeech(7, randVal, 1); + _soundManager->startSpeech(7, randVal, 1); displayAnimFrame(1, 1); - _soundManager.waitSpeech(); + _soundManager->waitSpeech(); int charIndex = convertBitIndexToCharacterIndex(pres); ++_coreVar._faithScore; _coreVar._currPlace = LANDING; _currMenu = MENU_DISCUSS; - _currAction = (_menu._discussMenu[charIndex]._menuId << 8) | _menu._discussMenu[charIndex]._actionId; + _currAction = (_menu->_discussMenu[charIndex]._menuId << 8) | _menu->_discussMenu[charIndex]._actionId; _syn = true; if (_roomDoorId == JULIA_ROOM) { _col = true; @@ -1207,14 +1243,14 @@ void MortevielleEngine::fctEnter() { } } else { int randVal = (getRandomNumber(0, 10)) - 5; - _soundManager.startSpeech(7, randVal, 1); + _soundManager->startSpeech(7, randVal, 1); displayAnimFrame(1, 1); - _soundManager.waitSpeech(); + _soundManager->waitSpeech(); _coreVar._currPlace = _roomDoorId; prepareDisplayText(); resetRoomVariables(_coreVar._currPlace); - _menu.setDestinationText(_coreVar._currPlace); + _menu->setDestinationText(_coreVar._currPlace); _roomDoorId = OWN_ROOM; _savedBitIndex = 0; _currBitIndex = 0; @@ -1237,7 +1273,7 @@ void MortevielleEngine::fctSleep() { prepareDisplayText(); drawPictureWithText(); resetRoomVariables(_coreVar._currPlace); - _menu.setDestinationText(_coreVar._currPlace); + _menu->setDestinationText(_coreVar._currPlace); } clearVerbBar(); clearDescriptionBar(); @@ -1261,7 +1297,7 @@ void MortevielleEngine::fctSleep() { if (hour > 23) hour = 0; prepareRoom(); - answer = _dialogManager.show(getEngineString(S_YES_NO)); + answer = _dialogManager->show(getEngineString(S_YES_NO)); _anyone = false; } while (answer != 1); _crep = 998; @@ -1321,7 +1357,7 @@ void MortevielleEngine::fctLeave() { if (_crep == 0) _crep = nextPlace; resetRoomVariables(nextPlace); - _menu.setDestinationText(nextPlace); + _menu->setDestinationText(nextPlace); } } @@ -1337,7 +1373,7 @@ void MortevielleEngine::fctWait() { do { ++_currentHourCount; prepareRoom(); - if (!_blo) + if (!_outsideOnlyFl) getPresence(_coreVar._currPlace); if ((_currBitIndex != 0) && (_savedBitIndex == 0)) { _crep = 998; @@ -1351,7 +1387,7 @@ void MortevielleEngine::fctWait() { return; } handleDescriptionText(2, 102); - answer = _dialogManager.show(getEngineString(S_YES_NO)); + answer = _dialogManager->show(getEngineString(S_YES_NO)); } while (answer != 2); _crep = 998; if (!_anyone) @@ -1394,7 +1430,7 @@ void MortevielleEngine::fctDiscuss() { int oldMenu; do { ++cx; - oldMenu = (_menu._discussMenu[cx]._menuId << 8) | _menu._discussMenu[cx]._actionId; + oldMenu = (_menu->_discussMenu[cx]._menuId << 8) | _menu->_discussMenu[cx]._actionId; } while (oldMenu != _currAction); _caff = 69 + cx; drawPictureWithText(); @@ -1403,7 +1439,7 @@ void MortevielleEngine::fctDiscuss() { } testKey(false); menuUp(); - _mouse.hideMouse(); + _mouse->hideMouse(); clearScreen(); drawDiscussionBox(); startDialog(displId); @@ -1417,13 +1453,13 @@ void MortevielleEngine::fctDiscuss() { } lib[46] = lib[45]; lib[45] = ' '; - _mouse.showMouse(); + _mouse->showMouse(); do { choice = 0; int posX = 0; int posY = 0; for (int icm = 1; icm < 43; icm++) { - _screenSurface.putxy(posX, posY); + _screenSurface->putxy(posX, posY); if (_coreVar._availableQuestion[icm] == '*') { // If question already asked, write it in reverse video if (questionAsked[icm]) @@ -1438,17 +1474,17 @@ void MortevielleEngine::fctDiscuss() { } else posY += 8; } - _screenSurface.putxy(320, 176); + _screenSurface->putxy(320, 176); displayQuestionText(lib[46], 0); char retKey = '\0'; bool click; do { bool dummyFl; - _mouse.moveMouse(dummyFl, retKey); + _mouse->moveMouse(dummyFl, retKey); if (shouldQuit()) return; - _mouse.getMousePosition(x, y, click); + _mouse->getMousePosition(x, y, click); x *= (3 - kResolutionScaler); if (x > 319) cx = 41; @@ -1462,7 +1498,7 @@ void MortevielleEngine::fctDiscuss() { posX = 320; else posX = 0; - _screenSurface.putxy(posX, posY); + _screenSurface->putxy(posX, posY); if (questionAsked[choice]) displayQuestionText(lib[choice], 0); else @@ -1481,7 +1517,7 @@ void MortevielleEngine::fctDiscuss() { posX = 320; else posX = 0; - _screenSurface.putxy(posX, posY); + _screenSurface->putxy(posX, posY); if (questionAsked[choice]) displayQuestionText(lib[choice], 0); else @@ -1494,7 +1530,7 @@ void MortevielleEngine::fctDiscuss() { posX = 320; else posX = 0; - _screenSurface.putxy(posX, posY); + _screenSurface->putxy(posX, posY); if (questionAsked[ix]) displayQuestionText(lib[ix], 0); else @@ -1533,11 +1569,11 @@ void MortevielleEngine::fctDiscuss() { _coreVar._faithScore += 3; displId = 139; } - _mouse.hideMouse(); + _mouse->hideMouse(); clearScreen(); drawDiscussionBox(); startDialog(displId); - _mouse.showMouse(); + _mouse->showMouse(); if ((displId == 84) || (displId == 86)) { _coreVar._pctHintFound[5] = '*'; _coreVar._availableQuestion[7] = '*'; @@ -1551,32 +1587,32 @@ void MortevielleEngine::fctDiscuss() { _coreVar._pctHintFound[8] = '*'; _coreVar._availableQuestion[32] = '*'; } - _mouse.hideMouse(); + _mouse->hideMouse(); clearScreen(); - _mouse.showMouse(); + _mouse->showMouse(); } } while ((choice != 46) && (displId != 138)); if (_col) { _coreVar._faithScore += (3 * (_coreVar._faithScore / 10)); - _mouse.hideMouse(); + _mouse->hideMouse(); clearScreen(); drawDiscussionBox(); startDialog(138); - _mouse.showMouse(); + _mouse->showMouse(); _col = false; _coreVar._currPlace = LANDING; } _controlMenu = 0; - _mouse.hideMouse(); + _mouse->hideMouse(); clearScreen(); drawRightFrame(); - _mouse.showMouse(); + _mouse->showMouse(); showPeoplePresent(_currBitIndex); prepareRoom(); drawClock(); prepareDisplayText(); /* chech;*/ - _menu.setDestinationText(_coreVar._currPlace); + _menu->setDestinationText(_coreVar._currPlace); clearVerbBar(); } @@ -1625,13 +1661,13 @@ void MortevielleEngine::endGame() { clearVerbBar(); handleDescriptionText(9, 1509); testKey(false); - _mouse.hideMouse(); + _mouse->hideMouse(); _caff = 70; - _text.taffich(); + _text->taffich(); clearScreen(); drawDiscussionBox(); startDialog(141); - _mouse.showMouse(); + _mouse->showMouse(); clearUpperLeftPart(); handleDescriptionText(9, 1509); handleDescriptionText(2, 142); @@ -1667,7 +1703,7 @@ void MortevielleEngine::askRestart() { _day = 0; handleDescriptionText(2, 180); - int answer = _dialogManager.show(getEngineString(S_YES_NO)); + int answer = _dialogManager->show(getEngineString(S_YES_NO)); _quitGame = (answer != 1); } diff --git a/engines/mortevielle/configure.engine b/engines/mortevielle/configure.engine new file mode 100644 index 0000000000..a7fb2ccda6 --- /dev/null +++ b/engines/mortevielle/configure.engine @@ -0,0 +1,3 @@ +# This file is included from the main "configure" script +# add_engine [name] [desc] [build-by-default] [subengines] [base games] [deps] +add_engine mortevielle "Mortevielle" yes diff --git a/engines/mortevielle/debugger.cpp b/engines/mortevielle/debugger.cpp index 4ef5151c81..b2c99b894a 100644 --- a/engines/mortevielle/debugger.cpp +++ b/engines/mortevielle/debugger.cpp @@ -8,12 +8,12 @@ * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. - + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. @@ -25,10 +25,11 @@ namespace Mortevielle { -Debugger::Debugger() : GUI::Debugger() { - DCmd_Register("continue", WRAP_METHOD(Debugger, Cmd_Exit)); - DCmd_Register("show_questions", WRAP_METHOD(Debugger, Cmd_showAllQuestions)); - DCmd_Register("reset_parano", WRAP_METHOD(Debugger, Cmd_resetParano)); +Debugger::Debugger(MortevielleEngine *vm) : GUI::Debugger() { + _vm = vm; + registerCmd("continue", WRAP_METHOD(Debugger, cmdExit)); + registerCmd("show_questions", WRAP_METHOD(Debugger, Cmd_showAllQuestions)); + registerCmd("reset_parano", WRAP_METHOD(Debugger, Cmd_resetParano)); } bool Debugger::Cmd_showAllQuestions(int argc, const char **argv) { @@ -52,8 +53,4 @@ bool Debugger::Cmd_resetParano(int argc, const char **argv) { return true; } -void Debugger::setParent(MortevielleEngine *vm) { - _vm = vm; -} - } // End of namespace Mortevielle diff --git a/engines/mortevielle/debugger.h b/engines/mortevielle/debugger.h index 9041d90110..66f5afef9d 100644 --- a/engines/mortevielle/debugger.h +++ b/engines/mortevielle/debugger.h @@ -8,12 +8,12 @@ * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. - + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. @@ -39,9 +39,8 @@ protected: bool Cmd_resetParano(int argc, const char **argv); public: - Debugger(); + Debugger(MortevielleEngine *vm); virtual ~Debugger() {} - void setParent(MortevielleEngine *vm); }; } // End of namespace Mortevielle diff --git a/engines/mortevielle/detection.cpp b/engines/mortevielle/detection.cpp index ee9cb40c99..b6c27e6b12 100644 --- a/engines/mortevielle/detection.cpp +++ b/engines/mortevielle/detection.cpp @@ -8,12 +8,12 @@ * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. - + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. diff --git a/engines/mortevielle/detection_tables.h b/engines/mortevielle/detection_tables.h index 8d0cd5630c..3e1e5aaefe 100644 --- a/engines/mortevielle/detection_tables.h +++ b/engines/mortevielle/detection_tables.h @@ -8,12 +8,12 @@ * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. - + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. diff --git a/engines/mortevielle/dialogs.cpp b/engines/mortevielle/dialogs.cpp index 9a2ade60ab..89098fabe5 100644 --- a/engines/mortevielle/dialogs.cpp +++ b/engines/mortevielle/dialogs.cpp @@ -8,12 +8,12 @@ * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. - + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. @@ -35,15 +35,19 @@ namespace Mortevielle { +DialogManager::DialogManager(MortevielleEngine *vm) { + _vm = vm; +} + /** * Alert function - Show * @remarks Originally called 'do_alert' */ int DialogManager::show(const Common::String &msg) { // Make a copy of the current screen surface for later restore - _vm->_backgroundSurface.copyFrom(_vm->_screenSurface); + _vm->_backgroundSurface.copyFrom(*_vm->_screenSurface); - _vm->_mouse.hideMouse(); + _vm->_mouse->hideMouse(); while (_vm->keyPressed()) _vm->getChar(); @@ -63,7 +67,7 @@ int DialogManager::show(const Common::String &msg) { } else { drawAlertBox(8, 7, colNumb); int i = 0; - _vm->_screenSurface._textPos.y = 70; + _vm->_screenSurface->_textPos.y = 70; do { curPos.x = 320; Common::String displayStr = ""; @@ -72,9 +76,9 @@ int DialogManager::show(const Common::String &msg) { displayStr += alertStr[i]; curPos.x -= 3; } - _vm->_screenSurface.putxy(curPos.x, _vm->_screenSurface._textPos.y); - _vm->_screenSurface._textPos.y += 6; - _vm->_screenSurface.drawString(displayStr, 4); + _vm->_screenSurface->putxy(curPos.x, _vm->_screenSurface->_textPos.y); + _vm->_screenSurface->_textPos.y += 6; + _vm->_screenSurface->drawString(displayStr, 4); ++i; } while (alertStr[i] != ']'); } @@ -99,17 +103,17 @@ int DialogManager::show(const Common::String &msg) { limit[2][1] = ((uint)(320 + ((uint)esp >> 1)) / 2) * kResolutionScaler; limit[2][2] = (limit[2][1]) + 40; } - _vm->_mouse.showMouse(); + _vm->_mouse->showMouse(); int id = 0; bool dummyFl = false; bool test3; do { char dummyKey = '\377'; - _vm->_mouse.moveMouse(dummyFl, dummyKey); + _vm->_mouse->moveMouse(dummyFl, dummyKey); if (_vm->shouldQuit()) return 0; - curPos = _vm->_mouse._pos; + curPos = _vm->_mouse->_pos; bool newaff = false; if ((curPos.y > 95) && (curPos.y < 105)) { bool test1 = (curPos.x > limit[1][1]) && (curPos.x < limit[1][2]); @@ -125,56 +129,56 @@ int DialogManager::show(const Common::String &msg) { else ix = 2; if (ix != id) { - _vm->_mouse.hideMouse(); + _vm->_mouse->hideMouse(); if (id != 0) { setPosition(id, coldep, esp); Common::String tmpStr(" "); tmpStr += buttonStr[id]; tmpStr += " "; - _vm->_screenSurface.drawString(tmpStr, 0); + _vm->_screenSurface->drawString(tmpStr, 0); } setPosition(ix, coldep, esp); Common::String tmp2 = " "; tmp2 += buttonStr[ix]; tmp2 += " "; - _vm->_screenSurface.drawString(tmp2, 1); + _vm->_screenSurface->drawString(tmp2, 1); id = ix; - _vm->_mouse.showMouse(); + _vm->_mouse->showMouse(); } } } if ((id != 0) && !newaff) { - _vm->_mouse.hideMouse(); + _vm->_mouse->hideMouse(); setPosition(id, coldep, esp); Common::String tmp3(" "); tmp3 += buttonStr[id]; tmp3 += " "; - _vm->_screenSurface.drawString(tmp3, 0); + _vm->_screenSurface->drawString(tmp3, 0); id = 0; - _vm->_mouse.showMouse(); + _vm->_mouse->showMouse(); } test3 = (curPos.y > 95) && (curPos.y < 105) && (((curPos.x > limit[1][1]) && (curPos.x < limit[1][2])) || ((curPos.x > limit[2][1]) && (curPos.x < limit[2][2]))); } while (!_vm->getMouseClick()); _vm->setMouseClick(false); - _vm->_mouse.hideMouse(); + _vm->_mouse->hideMouse(); if (!test3) { id = 1; setPosition(1, coldep, esp); Common::String tmp4(" "); tmp4 += buttonStr[1]; tmp4 += " "; - _vm->_screenSurface.drawString(tmp4, 1); + _vm->_screenSurface->drawString(tmp4, 1); } - _vm->_mouse.showMouse(); + _vm->_mouse->showMouse(); /* Restore the background area */ - _vm->_screenSurface.copyFrom(_vm->_backgroundSurface, 0, 0); + _vm->_screenSurface->copyFrom(_vm->_backgroundSurface, 0, 0); return id; } @@ -221,7 +225,7 @@ void DialogManager::decodeAlertDetails(Common::String inputStr, int &choiceNumb, } void DialogManager::setPosition(int ji, int coldep, int esp) { - _vm->_screenSurface.putxy(coldep + (40 + esp) * (ji - 1), 98); + _vm->_screenSurface->putxy(coldep + (40 + esp) * (ji - 1), 98); } /** @@ -235,9 +239,9 @@ void DialogManager::drawAlertBox(int firstLine, int lineNum, int width) { int y = (firstLine - 1) * 8; int xx = x + width; int yy = y + (lineNum * 8); - _vm->_screenSurface.fillRect(15, Common::Rect(x, y, xx, yy)); - _vm->_screenSurface.fillRect(0, Common::Rect(x, y + 2, xx, y + 4)); - _vm->_screenSurface.fillRect(0, Common::Rect(x, yy - 4, xx, yy - 2)); + _vm->_screenSurface->fillRect(15, Common::Rect(x, y, xx, yy)); + _vm->_screenSurface->fillRect(0, Common::Rect(x, y + 2, xx, y + 4)); + _vm->_screenSurface->fillRect(0, Common::Rect(x, yy - 4, xx, yy - 2)); } /** @@ -259,13 +263,13 @@ void DialogManager::setButtonText(Common::String c, int coldep, int nbcase, Comm while (str[l].size() < 3) str[l] += ' '; - _vm->_screenSurface.putxy(x, 98); + _vm->_screenSurface->putxy(x, 98); Common::String tmp(" "); tmp += str[l]; tmp += " "; - _vm->_screenSurface.drawString(tmp, 0); + _vm->_screenSurface->drawString(tmp, 0); x += esp + 40; } } @@ -288,17 +292,17 @@ bool DialogManager::showKnowledgeCheck() { Common::String choiceArray[15]; - int currChoice, prevChoice; + int currChoice; int correctCount = 0; for (int indx = 0; indx < 10; ++indx) { - _vm->_mouse.hideMouse(); + _vm->_mouse->hideMouse(); _vm->clearScreen(); - _vm->_mouse.showMouse(); + _vm->_mouse->showMouse(); int dialogHeight = 23; - _vm->_screenSurface.fillRect(15, Common::Rect(0, 14, 630, dialogHeight)); + _vm->_screenSurface->fillRect(15, Common::Rect(0, 14, 630, dialogHeight)); Common::String tmpStr = _vm->getString(textIndexArr[indx]); - _vm->_text.displayStr(tmpStr, 20, 15, 100, 2, 0); + _vm->_text->displayStr(tmpStr, 20, 15, 100, 2, 0); int firstOption; int lastOption; @@ -313,12 +317,12 @@ bool DialogManager::showKnowledgeCheck() { int optionPosY = 35; int maxLength = 0; - prevChoice = 1; + int prevChoice = 1; for (int j = firstOption; j <= lastOption; ++j, ++prevChoice) { tmpStr = _vm->getString(j); if ((int) tmpStr.size() > maxLength) maxLength = tmpStr.size(); - _vm->_text.displayStr(tmpStr, 100, optionPosY, 100, 1, 0); + _vm->_text->displayStr(tmpStr, 100, optionPosY, 100, 1, 0); choiceArray[prevChoice] = tmpStr; optionPosY += 8; } @@ -333,7 +337,7 @@ bool DialogManager::showKnowledgeCheck() { } coor[lastOption - firstOption + 2]._enabled = false; int rep = 6; - _vm->_screenSurface.drawBox(80, 33, 40 + (maxLength * rep), (lastOption - firstOption) * 8 + 16, 15); + _vm->_screenSurface->drawBox(80, 33, 40 + (maxLength * rep), (lastOption - firstOption) * 8 + 16, 15); rep = 0; prevChoice = 0; @@ -342,26 +346,26 @@ bool DialogManager::showKnowledgeCheck() { _vm->setMouseClick(false); bool flag; char key; - _vm->_mouse.moveMouse(flag, key); + _vm->_mouse->moveMouse(flag, key); if (_vm->shouldQuit()) return false; currChoice = 1; - while (coor[currChoice]._enabled && !_vm->_mouse.isMouseIn(coor[currChoice]._rect)) + while (coor[currChoice]._enabled && !_vm->_mouse->isMouseIn(coor[currChoice]._rect)) ++currChoice; if (coor[currChoice]._enabled) { if ((prevChoice != 0) && (prevChoice != currChoice)) { tmpStr = choiceArray[prevChoice] + '$'; - _vm->_text.displayStr(tmpStr, 100, 27 + (prevChoice * 8), 100, 1, 0); + _vm->_text->displayStr(tmpStr, 100, 27 + (prevChoice * 8), 100, 1, 0); } if (prevChoice != currChoice) { tmpStr = choiceArray[currChoice] + '$'; - _vm->_text.displayStr(tmpStr, 100, 27 + (currChoice * 8), 100, 1, 1); + _vm->_text->displayStr(tmpStr, 100, 27 + (currChoice * 8), 100, 1, 1); prevChoice = currChoice; } } else if (prevChoice != 0) { tmpStr = choiceArray[prevChoice] + '$'; - _vm->_text.displayStr(tmpStr, 100, 27 + (prevChoice * 8), 100, 1, 0); + _vm->_text->displayStr(tmpStr, 100, 27 + (prevChoice * 8), 100, 1, 0); prevChoice = 0; } } while (!((prevChoice != 0) && _vm->getMouseClick())); @@ -391,17 +395,17 @@ void DialogManager::drawF3F8() { Common::String f8 = _vm->getEngineString(S_F8); // Write the F3 and F8 text strings - _vm->_screenSurface.putxy(3, 44); - _vm->_screenSurface.drawString(f3, 5); - _vm->_screenSurface._textPos.y = 51; - _vm->_screenSurface.drawString(f8, 5); + _vm->_screenSurface->putxy(3, 44); + _vm->_screenSurface->drawString(f3, 5); + _vm->_screenSurface->_textPos.y = 51; + _vm->_screenSurface->drawString(f8, 5); // Get the width of the written text strings - int f3Width = _vm->_screenSurface.getStringWidth(f3); - int f8Width = _vm->_screenSurface.getStringWidth(f8); + int f3Width = _vm->_screenSurface->getStringWidth(f3); + int f8Width = _vm->_screenSurface->getStringWidth(f8); // Write out the bounding box - _vm->_screenSurface.drawBox(0, 42, MAX(f3Width, f8Width) + 6, 18, 7); + _vm->_screenSurface->drawBox(0, 42, MAX(f3Width, f8Width) + 6, 18, 7); } /** @@ -412,7 +416,7 @@ void DialogManager::drawF3F8() { void DialogManager::checkForF8(int SpeechNum, bool drawFrame2Fl) { _vm->testKeyboard(); do { - _vm->_soundManager.startSpeech(SpeechNum, 0, 0); + _vm->_soundManager->startSpeech(SpeechNum, 0, 0); _vm->_key = waitForF3F8(); if (_vm->shouldQuit()) return; @@ -442,7 +446,7 @@ int DialogManager::waitForF3F8() { void DialogManager::displayIntroScreen(bool drawFrame2Fl) { _vm->_caff = 50; _vm->_maff = 0; - _vm->_text.taffich(); + _vm->_text->taffich(); _vm->draw(63, 12); if (drawFrame2Fl) displayIntroFrame2(); @@ -466,7 +470,4 @@ void DialogManager::displayIntroFrame2() { _vm->handleDescriptionText(2, kDialogStringIndex + 143); } -void DialogManager::setParent(MortevielleEngine *vm) { - _vm = vm; -} } // End of namespace Mortevielle diff --git a/engines/mortevielle/dialogs.h b/engines/mortevielle/dialogs.h index 3f30851960..abd8ee2493 100644 --- a/engines/mortevielle/dialogs.h +++ b/engines/mortevielle/dialogs.h @@ -8,12 +8,12 @@ * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. - + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. @@ -51,7 +51,8 @@ private: void drawAlertBox(int firstLine, int lineNum, int width); void setButtonText(Common::String c, int coldep, int nbcase, Common::String *str, int esp); public: - void setParent(MortevielleEngine *vm); + DialogManager(MortevielleEngine *vm); + int show(const Common::String &msg); void drawF3F8(); void checkForF8(int SpeechNum, bool drawFrame2Fl); diff --git a/engines/mortevielle/graphics.cpp b/engines/mortevielle/graphics.cpp index daf7926438..553c1a759e 100644 --- a/engines/mortevielle/graphics.cpp +++ b/engines/mortevielle/graphics.cpp @@ -8,12 +8,12 @@ * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. - + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. @@ -881,6 +881,10 @@ GfxSurface::~GfxSurface() { * Screen surface *-------------------------------------------------------------------------*/ +ScreenSurface::ScreenSurface(MortevielleEngine *vm) { + _vm = vm; +} + /** * Called to populate the font data from the passed file */ @@ -1070,7 +1074,7 @@ void ScreenSurface::drawString(const Common::String &l, int command) { if (l == "") return; - _vm->_mouse.hideMouse(); + _vm->_mouse->hideMouse(); Common::Point pt = _textPos; int charWidth = 6; @@ -1082,11 +1086,11 @@ void ScreenSurface::drawString(const Common::String &l, int command) { case 0: case 2: color = 15; - _vm->_screenSurface.fillRect(0, Common::Rect(pt.x, pt.y, x, pt.y + 7)); + _vm->_screenSurface->fillRect(0, Common::Rect(pt.x, pt.y, x, pt.y + 7)); break; case 1: case 3: - _vm->_screenSurface.fillRect(15, Common::Rect(pt.x, pt.y, x, pt.y + 7)); + _vm->_screenSurface->fillRect(15, Common::Rect(pt.x, pt.y, x, pt.y + 7)); break; case 5: color = 15; @@ -1099,10 +1103,10 @@ void ScreenSurface::drawString(const Common::String &l, int command) { pt.x += 1; pt.y += 1; for (x = 1; (x <= (int)l.size()) && (l[x - 1] != 0); ++x) { - _vm->_screenSurface.writeCharacter(Common::Point(pt.x, pt.y), l[x - 1], color); + _vm->_screenSurface->writeCharacter(Common::Point(pt.x, pt.y), l[x - 1], color); pt.x += charWidth; } - _vm->_mouse.showMouse(); + _vm->_mouse->showMouse(); } /** @@ -1133,7 +1137,7 @@ void ScreenSurface::drawLine(int x, int y, int xx, int yy, int coul) { else step = 1; do { - _vm->_screenSurface.setPixel(Common::Point(abs((int)(a * i + b)), i), coul); + _vm->_screenSurface->setPixel(Common::Point(abs((int)(a * i + b)), i), coul); i += step; } while (i != yy); } else { @@ -1145,7 +1149,7 @@ void ScreenSurface::drawLine(int x, int y, int xx, int yy, int coul) { else step = 1; do { - _vm->_screenSurface.setPixel(Common::Point(i, abs((int)(a * i + b))), coul); + _vm->_screenSurface->setPixel(Common::Point(i, abs((int)(a * i + b))), coul); i = i + step; } while (i != xx); } @@ -1156,12 +1160,7 @@ void ScreenSurface::drawLine(int x, int y, int xx, int yy, int coul) { * @remarks Originally called 'paint_rect' */ void ScreenSurface::drawRectangle(int x, int y, int dx, int dy) { - _vm->_screenSurface.fillRect(11, Common::Rect(x, y, x + dx, y + dy)); + _vm->_screenSurface->fillRect(11, Common::Rect(x, y, x + dx, y + dy)); } -void ScreenSurface::setParent(MortevielleEngine *vm) { - _vm = vm; -} - - } // End of namespace Mortevielle diff --git a/engines/mortevielle/graphics.h b/engines/mortevielle/graphics.h index e31f5da29a..d29d9b2d8d 100644 --- a/engines/mortevielle/graphics.h +++ b/engines/mortevielle/graphics.h @@ -8,12 +8,12 @@ * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. - + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. @@ -91,6 +91,8 @@ private: byte _fontData[FONT_NUM_CHARS * FONT_HEIGHT]; public: + ScreenSurface(MortevielleEngine *vm); + Common::Point _textPos; // Original called xwhere/ywhere void readFontData(Common::File &f, int dataSize); Graphics::Surface lockArea(const Common::Rect &bounds); @@ -106,7 +108,6 @@ public: int getStringWidth(const Common::String &s); void drawLine(int x, int y, int xx, int yy, int coul); void drawRectangle(int x, int y, int dx, int dy); - void setParent(MortevielleEngine *vm); // TODO: Refactor code to remove this method, for increased performance void setPixel(const Common::Point &pt, int palIndex); diff --git a/engines/mortevielle/menu.cpp b/engines/mortevielle/menu.cpp index 641a527c98..c0b81b252a 100644 --- a/engines/mortevielle/menu.cpp +++ b/engines/mortevielle/menu.cpp @@ -2,18 +2,18 @@ * * ScummVM is the legal property of its developers, whose names * are too numerous to list here. Please refer to the COPYRIGHT - * file _distributed with this source _distribution. + * file distributed with this source distribution. * - * This program is free software; you can re_distribute it and/or + * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. - - * This program is _distributed in the hope that it will be useful, + * + * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. @@ -48,14 +48,34 @@ const byte menuConstants[8][4] = { {62, 46, 13, 10} }; -Menu::Menu() { +Menu::Menu(MortevielleEngine *vm) { + _vm = vm; _opcodeAttach = _opcodeWait = _opcodeForce = _opcodeSleep = OPCODE_NONE; _opcodeListen = _opcodeEnter = _opcodeClose = _opcodeSearch = OPCODE_NONE; _opcodeKnock = _opcodeScratch = _opcodeRead = _opcodeEat = OPCODE_NONE; _opcodePlace = _opcodeOpen = _opcodeTake = _opcodeLook = OPCODE_NONE; _opcodeSmell = _opcodeSound = _opcodeLeave = _opcodeLift = OPCODE_NONE; _opcodeTurn = _opcodeSHide = _opcodeSSearch = _opcodeSRead = OPCODE_NONE; - _opcodeSPut = _opcodeSLook = OPCODE_NONE; + _opcodeSPut = _opcodeSLook = _msg3 = _msg4 = OPCODE_NONE; + + _menuActive = false; + _menuSelected = false; + _multiTitle = false; + _menuDisplayed = false; + for (int i = 0; i < 9; i++) { + _discussMenu[i]._menuId = MENU_NONE; + _discussMenu[i]._actionId = 0; + _inventoryMenu[i]._menuId = MENU_NONE; + _inventoryMenu[i]._actionId = 0; + } + for (int i = 0; i < 8; i++) { + _moveMenu[i]._menuId = MENU_NONE; + _moveMenu[i]._actionId = 0; + } + for (int i = 0; i < 12; i++) { + _actionMenu[i]._menuId = MENU_NONE; + _actionMenu[i]._actionId = 0; + } } void Menu::readVerbNums(Common::File &f, int dataSize) { @@ -121,19 +141,19 @@ void Menu::readVerbNums(Common::File &f, int dataSize) { _actionMenu[1]._actionId = _opcodeSHide & 0xFF; _actionMenu[2]._menuId = _opcodeAttach >> 8; - _actionMenu[2]._actionId = _opcodeAttach & 0xFF; + _actionMenu[2]._actionId = _opcodeAttach & 0xFF; _actionMenu[3]._menuId = _opcodeForce >> 8; - _actionMenu[3]._actionId = _opcodeForce & 0xFF; + _actionMenu[3]._actionId = _opcodeForce & 0xFF; _actionMenu[4]._menuId = _opcodeSleep >> 8; _actionMenu[4]._actionId = _opcodeSleep & 0xFF; _actionMenu[5]._menuId = _opcodeEnter >> 8; - _actionMenu[5]._actionId = _opcodeEnter & 0xFF; + _actionMenu[5]._actionId = _opcodeEnter & 0xFF; _actionMenu[6]._menuId = _opcodeClose >> 8; - _actionMenu[6]._actionId = _opcodeClose & 0xFF; + _actionMenu[6]._actionId = _opcodeClose & 0xFF; _actionMenu[7]._menuId = _opcodeKnock >> 8; _actionMenu[7]._actionId = _opcodeKnock & 0xFF; @@ -295,8 +315,8 @@ void Menu::enableMenuItem(MenuItem item) { } void Menu::displayMenu() { - _vm->_mouse.hideMouse(); - _vm->_screenSurface.fillRect(7, Common::Rect(0, 0, 639, 10)); + _vm->_mouse->hideMouse(); + _vm->_screenSurface->fillRect(7, Common::Rect(0, 0, 639, 10)); int col = 28 * kResolutionScaler; for (int charNum = 0; charNum < 6; charNum++) { @@ -310,9 +330,9 @@ void Menu::displayMenu() { uint msk = 0x80; for (int pt = 0; pt <= 7; ++pt) { if ((_charArr[charNum][idx] & msk) != 0) { - _vm->_screenSurface.setPixel(Common::Point(x + 1, y + 1), 0); - _vm->_screenSurface.setPixel(Common::Point(x, y + 1), 0); - _vm->_screenSurface.setPixel(Common::Point(x, y), 9); + _vm->_screenSurface->setPixel(Common::Point(x + 1, y + 1), 0); + _vm->_screenSurface->setPixel(Common::Point(x, y + 1), 0); + _vm->_screenSurface->setPixel(Common::Point(x, y), 9); } msk >>= 1; ++x; @@ -322,7 +342,7 @@ void Menu::displayMenu() { } col += 48 * kResolutionScaler; } - _vm->_mouse.showMouse(); + _vm->_mouse->showMouse(); } /** @@ -348,7 +368,7 @@ void Menu::invert(int indx) { int menuIndex = _msg4 & 0xFF; - _vm->_screenSurface.putxy(menuConstants[_msg3 - 1][0] << 3, (menuIndex + 1) << 3); + _vm->_screenSurface->putxy(menuConstants[_msg3 - 1][0] << 3, (menuIndex + 1) << 3); Common::String str; switch (_msg3) { @@ -388,7 +408,7 @@ void Menu::invert(int indx) { break; } if ((str[0] != '*') && (str[0] != '<')) - _vm->_screenSurface.drawString(str, indx); + _vm->_screenSurface->drawString(str, indx); else _msg4 = OPCODE_NONE; } @@ -419,71 +439,71 @@ void Menu::util(Common::Point pos) { */ void Menu::menuDown(int ii) { // Make a copy of the current screen surface for later restore - _vm->_backgroundSurface.copyFrom(_vm->_screenSurface); + _vm->_backgroundSurface.copyFrom(*_vm->_screenSurface); // Draw the menu int minX = menuConstants[ii - 1][0] << 3; int lineNum = menuConstants[ii - 1][3]; - _vm->_mouse.hideMouse(); + _vm->_mouse->hideMouse(); int deltaX = 6; int maxX = minX + (menuConstants[ii - 1][2] * deltaX) + 6; if ((ii == 4) && (_vm->getLanguage() == Common::EN_ANY)) // Extra width needed for Self menu in English version maxX = 435; - _vm->_screenSurface.fillRect(15, Common::Rect(minX, 12, maxX, 10 + (menuConstants[ii - 1][1] << 1))); - _vm->_screenSurface.fillRect(0, Common::Rect(maxX, 12, maxX + 4, 10 + (menuConstants[ii - 1][1] << 1))); - _vm->_screenSurface.fillRect(0, Common::Rect(minX, 8 + (menuConstants[ii - 1][1] << 1), maxX + 4, 12 + (menuConstants[ii - 1][1] << 1))); - _vm->_screenSurface.putxy(minX, 16); + _vm->_screenSurface->fillRect(15, Common::Rect(minX, 12, maxX, 10 + (menuConstants[ii - 1][1] << 1))); + _vm->_screenSurface->fillRect(0, Common::Rect(maxX, 12, maxX + 4, 10 + (menuConstants[ii - 1][1] << 1))); + _vm->_screenSurface->fillRect(0, Common::Rect(minX, 8 + (menuConstants[ii - 1][1] << 1), maxX + 4, 12 + (menuConstants[ii - 1][1] << 1))); + _vm->_screenSurface->putxy(minX, 16); for (int i = 1; i <= lineNum; i++) { switch (ii) { case 1: if (_inventoryStringArray[i][0] != '*') - _vm->_screenSurface.drawString(_inventoryStringArray[i], 4); + _vm->_screenSurface->drawString(_inventoryStringArray[i], 4); break; case 2: if (_moveStringArray[i][0] != '*') - _vm->_screenSurface.drawString(_moveStringArray[i], 4); + _vm->_screenSurface->drawString(_moveStringArray[i], 4); break; case 3: if (_actionStringArray[i][0] != '*') - _vm->_screenSurface.drawString(_actionStringArray[i], 4); + _vm->_screenSurface->drawString(_actionStringArray[i], 4); break; case 4: if (_selfStringArray[i][0] != '*') - _vm->_screenSurface.drawString(_selfStringArray[i], 4); + _vm->_screenSurface->drawString(_selfStringArray[i], 4); break; case 5: if (_discussStringArray[i][0] != '*') - _vm->_screenSurface.drawString(_discussStringArray[i], 4); + _vm->_screenSurface->drawString(_discussStringArray[i], 4); break; case 6: - _vm->_screenSurface.drawString(_vm->getEngineString(S_SAVE_LOAD + i), 4); + _vm->_screenSurface->drawString(_vm->getEngineString(S_SAVE_LOAD + i), 4); break; case 7: { Common::String s = _vm->getEngineString(S_SAVE_LOAD + 1); s += ' '; s += (char)(48 + i); - _vm->_screenSurface.drawString(s, 4); + _vm->_screenSurface->drawString(s, 4); } break; case 8: if (i == 1) - _vm->_screenSurface.drawString(_vm->getEngineString(S_RESTART), 4); + _vm->_screenSurface->drawString(_vm->getEngineString(S_RESTART), 4); else { Common::String s = _vm->getEngineString(S_SAVE_LOAD + 2); s += ' '; s += (char)(47 + i); - _vm->_screenSurface.drawString(s, 4); + _vm->_screenSurface->drawString(s, 4); } break; default: break; } - _vm->_screenSurface.putxy(minX, _vm->_screenSurface._textPos.y + 8); + _vm->_screenSurface->putxy(minX, _vm->_screenSurface->_textPos.y + 8); } _multiTitle = true; - _vm->_mouse.showMouse(); + _vm->_mouse->showMouse(); } /** @@ -492,11 +512,11 @@ void Menu::menuDown(int ii) { void Menu::menuUp(int msgId) { if (_multiTitle) { /* Restore the background area */ - assert(_vm->_screenSurface.pitch == _vm->_backgroundSurface.pitch); + assert(_vm->_screenSurface->pitch == _vm->_backgroundSurface.pitch); // Get a pointer to the source and destination of the area to restore const byte *pSrc = (const byte *)_vm->_backgroundSurface.getBasePtr(0, 10); - Graphics::Surface destArea = _vm->_screenSurface.lockArea(Common::Rect(0, 10, SCREEN_WIDTH, SCREEN_HEIGHT)); + Graphics::Surface destArea = _vm->_screenSurface->lockArea(Common::Rect(0, 10, SCREEN_WIDTH, SCREEN_HEIGHT)); byte *pDest = (byte *)destArea.getPixels(); // Copy the data @@ -523,7 +543,7 @@ void Menu::updateMenu() { if (!_menuActive) return; - Common::Point curPos = _vm->_mouse._pos; + Common::Point curPos = _vm->_mouse->_pos; if (!_vm->getMouseClick()) { if (curPos == _vm->_prevPos) return; @@ -590,13 +610,9 @@ void Menu::updateMenu() { } } -void Menu::setParent(MortevielleEngine *vm) { - _vm = vm; -} - void Menu::initMenu() { Common::File f; - + bool menuLoaded = false; // First try to read it from mort.dat if useOriginalData() is false if (!_vm->useOriginalData()) { @@ -620,7 +636,7 @@ void Menu::initMenu() { desiredLanguageId = MORTDAT_LANG_ENGLISH; break; } - + // Validate the data file header char fileId[4]; f.read(fileId, 4); @@ -638,7 +654,7 @@ void Menu::initMenu() { // Read in the language byte languageId = f.readByte(); --dataSize; - + // If the language isn't correct, then skip the entire block if (languageId != desiredLanguageId) { f.skip(dataSize); diff --git a/engines/mortevielle/menu.h b/engines/mortevielle/menu.h index debf5b09b6..b3695fef28 100644 --- a/engines/mortevielle/menu.h +++ b/engines/mortevielle/menu.h @@ -8,12 +8,12 @@ * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. - + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. @@ -60,7 +60,7 @@ private: void menuDown(int ii); public: - Menu(); + Menu(MortevielleEngine *vm); bool _menuActive; bool _menuSelected; @@ -103,7 +103,6 @@ public: int _opcodeSLook; MenuItem _actionMenu[12]; - void setParent(MortevielleEngine *vm); void readVerbNums(Common::File &f, int dataSize); void setText(MenuItem item, Common::String name); void setDestinationText(int roomId); diff --git a/engines/mortevielle/module.mk b/engines/mortevielle/module.mk index a9f02c2a67..7188e36958 100644 --- a/engines/mortevielle/module.mk +++ b/engines/mortevielle/module.mk @@ -19,5 +19,5 @@ ifeq ($(ENABLE_MORTEVIELLE), DYNAMIC_PLUGIN) PLUGIN := 1 endif -# Include common rules +# Include common rules include $(srcdir)/rules.mk diff --git a/engines/mortevielle/mortevielle.cpp b/engines/mortevielle/mortevielle.cpp index d434150977..90d366ed7e 100644 --- a/engines/mortevielle/mortevielle.cpp +++ b/engines/mortevielle/mortevielle.cpp @@ -8,12 +8,12 @@ * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. - + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. @@ -47,17 +47,16 @@ namespace Mortevielle { MortevielleEngine *g_vm; MortevielleEngine::MortevielleEngine(OSystem *system, const MortevielleGameDescription *gameDesc): - Engine(system), _gameDescription(gameDesc), _randomSource("mortevielle"), - _soundManager(_mixer) { + Engine(system), _gameDescription(gameDesc), _randomSource("mortevielle") { g_vm = this; - _debugger.setParent(this); - _dialogManager.setParent(this); - _screenSurface.setParent(this); - _mouse.setParent(this); - _text.setParent(this); - _soundManager.setParent(this); - _savegameManager.setParent(this); - _menu.setParent(this); + _debugger = new Debugger(this); + _dialogManager = new DialogManager(this); + _screenSurface = new ScreenSurface(this); + _mouse = new MouseHandler(this); + _text = new TextHandler(this); + _soundManager = new SoundManager(this, _mixer); + _savegameManager = new SavegameManager(this); + _menu = new Menu(this); _lastGameFrame = 0; _mouseClick = false; @@ -84,7 +83,7 @@ MortevielleEngine::MortevielleEngine(OSystem *system, const MortevielleGameDescr _keyPressedEsc = false; _reloadCFIEC = false; - _blo = false; + _outsideOnlyFl = true; _col = false; _syn = false; _obpart = false; @@ -102,9 +101,62 @@ MortevielleEngine::MortevielleEngine(OSystem *system, const MortevielleGameDescr _curPict = nullptr; _curAnim = nullptr; _rightFramePict = nullptr; + + resetCoreVar(); + + _maff = 0; + _crep = 0; + + _minute = 0; + _curSearchObjId = 0; + _controlMenu = 0; + _startTime = 0; + _endTime = 0; + _roomDoorId = OWN_ROOM; + _openObjCount = 0; + _takeObjCount = 0; + _num = 0; + _searchCount = 0; + _introSpeechPlayed = false; + _inGameHourDuration = 0; + _x = 0; + _y = 0; + _currentHourCount = 0; + _currentTime = 0; + _cfiecBuffer = nullptr; + _cfiecBufferSize = 0; + for (int i = 0; i < 601; i++) { + _dialogHintArray[i]._hintId = 0; + _dialogHintArray[i]._point = 0; + } + _currMenu = OPCODE_NONE; + _currAction = OPCODE_NONE; + _menuOpcode = OPCODE_NONE; + _addFix = 0; + _currBitIndex = 0; + _currDay = 0; + _currHour = 10; + _currHalfHour = 0; + _hour = 10; + _key = 0; + _manorDistance = 0; + _numpal = 0; + _savedBitIndex = 0; + _endGame = false; + _loseGame = false; + _txxFileFl = false; } MortevielleEngine::~MortevielleEngine() { + delete _menu; + delete _savegameManager; + delete _soundManager; + delete _text; + delete _mouse; + delete _screenSurface; + delete _dialogManager; + delete _debugger; + free(_curPict); free(_curAnim); free(_rightFramePict); @@ -140,7 +192,7 @@ bool MortevielleEngine::canSaveGameStateCurrently() { * Load in a savegame at the specified slot number */ Common::Error MortevielleEngine::loadGameState(int slot) { - return _savegameManager.loadGame(slot); + return _savegameManager->loadGame(slot); } /** @@ -150,7 +202,7 @@ Common::Error MortevielleEngine::saveGameState(int slot, const Common::String &d if (slot == 0) return Common::kWritingFailed; - return _savegameManager.saveGame(slot, desc); + return _savegameManager->saveGame(slot, desc); } /** @@ -196,7 +248,7 @@ Common::ErrorCode MortevielleEngine::initialize() { DebugMan.addDebugChannel(kMortevielleGraphics, "graphics", "Graphics debugging"); // Set up an intermediate screen surface - _screenSurface.create(SCREEN_WIDTH, SCREEN_HEIGHT, Graphics::PixelFormat::createFormatCLUT8()); + _screenSurface->create(SCREEN_WIDTH, SCREEN_HEIGHT, Graphics::PixelFormat::createFormatCLUT8()); _txxFileFl = false; // Load texts from TXX files @@ -205,7 +257,7 @@ Common::ErrorCode MortevielleEngine::initialize() { // Load the mort.dat resource Common::ErrorCode result = loadMortDat(); if (result != Common::kNoError) { - _screenSurface.free(); + _screenSurface->free(); return result; } @@ -235,8 +287,8 @@ Common::ErrorCode MortevielleEngine::initialize() { testKeyboard(); clearScreen(); - _soundManager.loadNoise(); - _soundManager.loadAmbiantSounds(); + _soundManager->loadNoise(); + _soundManager->loadAmbiantSounds(); return Common::kNoError; } @@ -278,13 +330,13 @@ Common::ErrorCode MortevielleEngine::loadMortDat() { if (!strncmp(dataType, "FONT", 4)) { // Font resource - _screenSurface.readFontData(f, dataSize); + _screenSurface->readFontData(f, dataSize); } else if (!strncmp(dataType, "SSTR", 4)) { readStaticStrings(f, dataSize, kStaticStrings); } else if ((!strncmp(dataType, "GSTR", 4)) && (!_txxFileFl)) { readStaticStrings(f, dataSize, kGameStrings); } else if (!strncmp(dataType, "VERB", 4)) { - _menu.readVerbNums(f, dataSize); + _menu->readVerbNums(f, dataSize); } else { // Unknown section f.skip(dataSize); @@ -369,21 +421,21 @@ Common::Error MortevielleEngine::run() { showIntroduction(); else { _caff = 51; - _text.taffich(); + _text->taffich(); } // Either load the initial game state savegame, or the specified savegame number adzon(); resetVariables(); if (loadSlot != 0) - _savegameManager.loadSavegame(generateSaveFilename(loadSlot)); + _savegameManager->loadSavegame(generateSaveFilename(loadSlot)); // Run the main game loop mainGame(); // Cleanup (allocated in initialize()) - _screenSurface.free(); - free(_soundManager._cfiphBuffer); + _screenSurface->free(); + free(_soundManager->_cfiphBuffer); free(_cfiecBuffer); return Common::kNoError; @@ -393,13 +445,13 @@ Common::Error MortevielleEngine::run() { * Show the game introduction */ void MortevielleEngine::showIntroduction() { - _dialogManager.displayIntroScreen(false); - _dialogManager.checkForF8(142, false); + _dialogManager->displayIntroScreen(false); + _dialogManager->checkForF8(142, false); if (shouldQuit()) return; - _dialogManager.displayIntroFrame2(); - _dialogManager.checkForF8(143, true); + _dialogManager->displayIntroFrame2(); + _dialogManager->checkForF8(143, true); if (shouldQuit()) return; @@ -419,13 +471,13 @@ void MortevielleEngine::mainGame() { for (_crep = 1; _crep <= _x26KeyCount; ++_crep) decodeNumber(&_cfiecBuffer[161 * 16], (_cfiecBufferSize - (161 * 16)) / 64); - _menu.initMenu(); + _menu->initMenu(); charToHour(); initGame(); clearScreen(); drawRightFrame(); - _mouse.showMouse(); + _mouse->showMouse(); // Loop to play the game do { diff --git a/engines/mortevielle/mortevielle.h b/engines/mortevielle/mortevielle.h index 5ae94987a0..c3d1e4ae8b 100644 --- a/engines/mortevielle/mortevielle.h +++ b/engines/mortevielle/mortevielle.h @@ -8,12 +8,12 @@ * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. - + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. @@ -122,7 +122,6 @@ const int kMaxPatt = 20; const int kResolutionScaler = 2; /* -9 "A glance at the forbidden$", 18 "It's already open$", 26 "A photograph$" */ @@ -135,11 +134,6 @@ enum Places { DOOR = 25, ROOM26 = 26, COAT_ARMS = 27 }; -struct Pattern { - byte _tay, _tax; - byte _des[kMaxPatt + 1][kMaxPatt + 1]; -}; - struct SaveStruct { int _faithScore; byte _pctHintFound[11]; @@ -391,6 +385,7 @@ private: void prepareNextObject(); void putObject(); void resetObjectPlace(); + void resetCoreVar(); void drawDiscussionBox(); void displayNarrativePicture(int af, int ob); void menuUp(); @@ -407,7 +402,7 @@ public: int _charAnswerMax[9]; byte _tabdon[4001]; bool _soundOff; - bool _blo; + bool _outsideOnlyFl; bool _destinationOk; bool _largestClearScreen; float _addFix; @@ -427,17 +422,18 @@ public: byte *_curAnim; byte *_rightFramePict; - Debugger _debugger; - ScreenSurface _screenSurface; PaletteManager _paletteManager; GfxSurface _backgroundSurface; Common::RandomSource _randomSource; - SoundManager _soundManager; - SavegameManager _savegameManager; - Menu _menu; - MouseHandler _mouse; - TextHandler _text; - DialogManager _dialogManager; + + Debugger *_debugger; + ScreenSurface *_screenSurface; + SoundManager *_soundManager; + SavegameManager *_savegameManager; + Menu *_menu; + MouseHandler *_mouse; + TextHandler *_text; + DialogManager *_dialogManager; MortevielleEngine(OSystem *system, const MortevielleGameDescription *gameDesc); ~MortevielleEngine(); @@ -448,7 +444,7 @@ public: virtual Common::Error saveGameState(int slot, const Common::String &desc); virtual Common::Error run(); virtual void pauseEngineIntern(bool pause); - virtual GUI::Debugger *getDebugger() {return &_debugger;} + virtual GUI::Debugger *getDebugger() {return _debugger;} uint32 getGameFlags() const; Common::Language getLanguage() const; Common::Language getOriginalLanguage() const; diff --git a/engines/mortevielle/mouse.cpp b/engines/mortevielle/mouse.cpp index 9eb4e129c0..8f96ba3ef5 100644 --- a/engines/mortevielle/mouse.cpp +++ b/engines/mortevielle/mouse.cpp @@ -8,12 +8,12 @@ * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. - + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. @@ -33,14 +33,16 @@ namespace Mortevielle { +MouseHandler::MouseHandler(MortevielleEngine *vm) { + _vm = vm; +} + /** * Initialize the mouse * @remarks Originally called 'init_mouse' */ void MouseHandler::initMouse() { - _counter = 0; _pos = Common::Point(0, 0); - _vm->setMouseClick(false); } @@ -95,15 +97,13 @@ void MouseHandler::getMousePosition(int &x, int &y, bool &click) { * @remarks Originally called 'mov_mouse' */ void MouseHandler::moveMouse(bool &funct, char &key) { - bool p_key; - char in1, in2; int cx, cy; bool click; // Set defaults and check pending events funct = false; key = '\377'; - p_key = _vm->keyPressed(); + bool p_key = _vm->keyPressed(); // If mouse button clicked, return it if (_vm->getMouseClick()) @@ -114,7 +114,7 @@ void MouseHandler::moveMouse(bool &funct, char &key) { if (_vm->shouldQuit()) return; - in1 = _vm->getChar(); + char in1 = _vm->getChar(); getMousePosition(cx, cy, click); switch (toupper(in1)) { case '4': @@ -158,7 +158,7 @@ void MouseHandler::moveMouse(bool &funct, char &key) { p_key = _vm->keyPressed(); if (p_key) { - in2 = _vm->getChar(); + char in2 = _vm->getChar(); if ((in2 >= ';') && (in2 <= 'D')) { funct = true; @@ -266,8 +266,4 @@ bool MouseHandler::isMouseIn(Common::Rect r) { return false; } -void MouseHandler::setParent(MortevielleEngine *vm) { - _vm = vm; -} - } // End of namespace Mortevielle diff --git a/engines/mortevielle/mouse.h b/engines/mortevielle/mouse.h index 594031d816..0f28d50131 100644 --- a/engines/mortevielle/mouse.h +++ b/engines/mortevielle/mouse.h @@ -8,12 +8,12 @@ * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. - + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. @@ -36,12 +36,10 @@ class MortevielleEngine; class MouseHandler { private: MortevielleEngine *_vm; - - int _counter; public: Common::Point _pos; + MouseHandler(MortevielleEngine *vm); - void setParent(MortevielleEngine *vm); void initMouse(); void hideMouse(); void showMouse(); diff --git a/engines/mortevielle/outtext.cpp b/engines/mortevielle/outtext.cpp index d50f4005de..6a479c0859 100644 --- a/engines/mortevielle/outtext.cpp +++ b/engines/mortevielle/outtext.cpp @@ -8,12 +8,12 @@ * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. - + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. @@ -35,6 +35,10 @@ namespace Mortevielle { +TextHandler::TextHandler(MortevielleEngine *vm) { + _vm = vm; +} + /** * Next word * @remarks Originally called 'l_motsuiv' @@ -59,7 +63,7 @@ void TextHandler::displayStr(Common::String inputStr, int x, int y, int dx, int // Safeguard: add $ just in case inputStr += '$'; - _vm->_screenSurface.putxy(x, y); + _vm->_screenSurface->putxy(x, y); int tab = 6; dx *= 6; dy *= 6; @@ -73,19 +77,19 @@ void TextHandler::displayStr(Common::String inputStr, int x, int y, int dx, int while (!stringParsed) { switch (inputStr[p]) { case '@': - _vm->_screenSurface.drawString(s, typ); + _vm->_screenSurface->drawString(s, typ); s = ""; ++p; xc = x; yc += 6; - _vm->_screenSurface.putxy(xc, yc); + _vm->_screenSurface->putxy(xc, yc); break; case ' ': s += ' '; xc += tab; ++p; if (nextWord(p, inputStr.c_str(), tab) + xc > xf) { - _vm->_screenSurface.drawString(s, typ); + _vm->_screenSurface->drawString(s, typ); s = ""; xc = x; yc += 6; @@ -96,20 +100,20 @@ void TextHandler::displayStr(Common::String inputStr, int x, int y, int dx, int do { j = x; do { - _vm->_screenSurface.putxy(j, i); - _vm->_screenSurface.drawString(" ", 0); + _vm->_screenSurface->putxy(j, i); + _vm->_screenSurface->drawString(" ", 0); j += 6; } while (j <= xf); i += 6; } while (i <= yf); yc = y; } - _vm->_screenSurface.putxy(xc, yc); + _vm->_screenSurface->putxy(xc, yc); } break; case '$': stringParsed = true; - _vm->_screenSurface.drawString(s, typ); + _vm->_screenSurface->drawString(s, typ); break; default: s += inputStr[p]; @@ -218,7 +222,7 @@ void TextHandler::taffich() { } _vm->_destinationOk = true; - _vm->_mouse.hideMouse(); + _vm->_mouse->hideMouse(); drawingStartPos = 0; Common::String filename, altFilename; @@ -283,26 +287,22 @@ void TextHandler::taffich() { filename = "AXX.mor"; } else { // b == 50 // CHECKME: the size of AZZ.mor is 1280 for the DOS version - // and 1260 for the Amiga version. Maybe the 20 bytes - // are a filler (to get 10 blocks of 128 bytes), + // and 1260 for the Amiga version. Maybe the 20 bytes + // are a filler (to get 10 blocks of 128 bytes), // or the size should be variable. drawingSize = 1260; filename = "AZZ.mor"; } loadAniFile(filename, drawingStartPos, drawingSize); } - _vm->_mouse.showMouse(); - if ((a < COAT_ARMS) && ((_vm->_maff < COAT_ARMS) || (_vm->_coreVar._currPlace == LANDING)) && (_vm->_currAction != _vm->_menu._opcodeEnter)) { + _vm->_mouse->showMouse(); + if ((a < COAT_ARMS) && ((_vm->_maff < COAT_ARMS) || (_vm->_coreVar._currPlace == LANDING)) && (_vm->_currAction != _vm->_menu->_opcodeEnter)) { if ((a == ATTIC) || (a == CELLAR)) _vm->displayAloneText(); - else if (!_vm->_blo) + else if (!_vm->_outsideOnlyFl) _vm->getPresence(_vm->_coreVar._currPlace); _vm->_savedBitIndex = 0; } } -void TextHandler::setParent(MortevielleEngine *vm) { - _vm = vm; -} - } // End of namespace Mortevielle diff --git a/engines/mortevielle/outtext.h b/engines/mortevielle/outtext.h index 44868036d5..515bc9ece0 100644 --- a/engines/mortevielle/outtext.h +++ b/engines/mortevielle/outtext.h @@ -8,12 +8,12 @@ * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. - + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. @@ -38,7 +38,8 @@ private: MortevielleEngine *_vm; int nextWord(int p, const char *ch, int &tab); public: - void setParent(MortevielleEngine *vm); + TextHandler (MortevielleEngine *vm); + void displayStr(Common::String inputStr, int x, int y, int dx, int dy, int typ); void loadPictureFile(Common::String filename, Common::String altFilename, int32 skipSize, int length); void loadAniFile(Common::String filename, int32 skipSize, int length); diff --git a/engines/mortevielle/saveload.cpp b/engines/mortevielle/saveload.cpp index c14a03cd60..9f46940e1f 100644 --- a/engines/mortevielle/saveload.cpp +++ b/engines/mortevielle/saveload.cpp @@ -8,12 +8,12 @@ * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. - + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. @@ -37,7 +37,7 @@ namespace Mortevielle { static const char SAVEGAME_ID[4] = { 'M', 'O', 'R', 'T' }; -void SavegameManager::setParent(MortevielleEngine *vm) { +SavegameManager::SavegameManager(MortevielleEngine *vm) { _vm = vm; } @@ -116,16 +116,16 @@ bool SavegameManager::loadSavegame(const Common::String &filename) { * Load a saved game */ Common::Error SavegameManager::loadGame(const Common::String &filename) { - g_vm->_mouse.hideMouse(); + g_vm->_mouse->hideMouse(); g_vm->displayEmptyHand(); if (loadSavegame(filename)) { /* Initialization */ g_vm->charToHour(); g_vm->initGame(); g_vm->gameLoaded(); - g_vm->_mouse.showMouse(); + g_vm->_mouse->showMouse(); return Common::kNoError; - } else + } else return Common::kUnknownError; } @@ -136,7 +136,7 @@ Common::Error SavegameManager::saveGame(int n, const Common::String &saveName) { Common::OutSaveFile *f; int i; - g_vm->_mouse.hideMouse(); + g_vm->_mouse->hideMouse(); g_vm->hourToChar(); for (i = 0; i <= 389; ++i) @@ -165,7 +165,7 @@ Common::Error SavegameManager::saveGame(int n, const Common::String &saveName) { // Skipped: dialog asking to swap floppy - g_vm->_mouse.showMouse(); + g_vm->_mouse->showMouse(); return Common::kNoError; } @@ -191,7 +191,7 @@ void SavegameManager::writeSavegameHeader(Common::OutSaveFile *out, const Common // Create a thumbnail and save it Graphics::Surface *thumb = new Graphics::Surface(); - Graphics::Surface s = g_vm->_screenSurface.lockArea(Common::Rect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT)); + Graphics::Surface s = g_vm->_screenSurface->lockArea(Common::Rect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT)); ::createThumbnail(thumb, (const byte *)s.getPixels(), SCREEN_WIDTH, SCREEN_HEIGHT, thumbPalette); Graphics::saveThumbnail(*out, *thumb); diff --git a/engines/mortevielle/saveload.h b/engines/mortevielle/saveload.h index 79747e6889..a0de05b920 100644 --- a/engines/mortevielle/saveload.h +++ b/engines/mortevielle/saveload.h @@ -8,12 +8,12 @@ * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. - + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. @@ -56,7 +56,8 @@ private: void sync_save(Common::Serializer &sz); public: - void setParent(MortevielleEngine *vm); + SavegameManager(MortevielleEngine *vm); + bool loadSavegame(const Common::String &filename); Common::Error loadGame(const Common::String &filename); Common::Error saveGame(int n, const Common::String &saveName); diff --git a/engines/mortevielle/sound.cpp b/engines/mortevielle/sound.cpp index b670246726..23ca9d89b4 100644 --- a/engines/mortevielle/sound.cpp +++ b/engines/mortevielle/sound.cpp @@ -8,12 +8,12 @@ * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. - + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. @@ -55,7 +55,8 @@ namespace Mortevielle { const byte _tabdph[16] = {0, 10, 2, 0, 2, 10, 3, 0, 3, 7, 5, 0, 6, 7, 7, 10}; const byte _tabdbc[18] = {7, 23, 7, 14, 13, 9, 14, 9, 5, 12, 6, 12, 13, 4, 0, 4, 5, 9}; -SoundManager::SoundManager(Audio::Mixer *mixer) { +SoundManager::SoundManager(MortevielleEngine *vm, Audio::Mixer *mixer) { + _vm = vm; _mixer = mixer; _audioStream = nullptr; _ambiantNoiseBuf = nullptr; @@ -72,6 +73,8 @@ SoundManager::SoundManager(Audio::Mixer *mixer) { _queue[i]._rep = 0; } _buildingSentence = false; + _ptr_oct = 0; + _cfiphBuffer = nullptr; } SoundManager::~SoundManager() { @@ -88,13 +91,12 @@ int SoundManager::decodeMusic(const byte *PSrc, byte *PDest, int size) { static const int tab[16] = { -96, -72, -48, -32, -20, -12, -8, -4, 0, 4, 8, 12, 20, 32, 48, 72 }; uint seed = 128; - int v; int decompSize = 0; int skipSize = 0; for (int idx1 = 0; idx1 < size; ++idx1) { byte srcByte = *PSrc++; - v = tab[srcByte >> 4]; + int v = tab[srcByte >> 4]; seed += v; *PDest++ = seed & 0xff; @@ -201,7 +203,7 @@ void SoundManager::litph(tablint &t, int typ, int tempo) { } } else { // 2 debugC(5, kMortevielleSounds, "litph - vadson"); - const static int ambiantNoiseAdr[] = {0, 14020, + const static int ambiantNoiseAdr[] = {0, 14020, 14020, 18994, 18994, 19630, 19630, 22258, @@ -281,10 +283,6 @@ void SoundManager::playSong(const byte* buf, uint size, uint loops) { _mixer->stopHandle(songHandle); } -void SoundManager::setParent(MortevielleEngine *vm) { - _vm = vm; -} - void SoundManager::spfrac(int wor) { _queue[2]._rep = (uint)wor >> 12; if ((_soundType == 0) && (_queue[2]._code != 9)) { @@ -697,7 +695,7 @@ void SoundManager::handlePhoneme() { uint16 startPos = _cfiphBuffer[_phonemeNumb - 1] + deca[_soundType]; uint16 endPos = _cfiphBuffer[_phonemeNumb] + deca[_soundType]; int wordCount = endPos - startPos; - + startPos /= 2; endPos /= 2; assert((endPos - startPos) < 1711); diff --git a/engines/mortevielle/sound.h b/engines/mortevielle/sound.h index cc0567fd98..d913684935 100644 --- a/engines/mortevielle/sound.h +++ b/engines/mortevielle/sound.h @@ -8,12 +8,12 @@ * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. - + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. @@ -84,15 +84,13 @@ private: void litph(tablint &t, int typ, int tempo); public: - SoundManager(Audio::Mixer *mixer); + SoundManager(MortevielleEngine *vm, Audio::Mixer *mixer); ~SoundManager(); Audio::Mixer *_mixer; Audio::SoundHandle _soundHandle; uint16 *_cfiphBuffer; - void setParent(MortevielleEngine *vm); - int decodeMusic(const byte *PSrc, byte *PDest, int size); void playSong(const byte *buf, uint usize, uint loops); void loadAmbiantSounds(); diff --git a/engines/mortevielle/utils.cpp b/engines/mortevielle/utils.cpp index 7809143176..d5dec6a286 100644 --- a/engines/mortevielle/utils.cpp +++ b/engines/mortevielle/utils.cpp @@ -8,12 +8,12 @@ * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. - + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. @@ -50,9 +50,9 @@ bool MortevielleEngine::keyPressed() { if (g_system->getMillis() > (_lastGameFrame + GAME_FRAME_DELAY)) { _lastGameFrame = g_system->getMillis(); - _screenSurface.updateScreen(); + _screenSurface->updateScreen(); - _debugger.onFrame(); + _debugger->onFrame(); } // Delay briefly to keep CPU usage down @@ -92,8 +92,8 @@ bool MortevielleEngine::handleEvents() { case Common::EVENT_LBUTTONUP: case Common::EVENT_MOUSEMOVE: _mousePos = Common::Point(event.mouse.x, event.mouse.y / 2); - _mouse._pos.x = event.mouse.x; - _mouse._pos.y = event.mouse.y / 2; + _mouse->_pos.x = event.mouse.x; + _mouse->_pos.y = event.mouse.y / 2; if (event.type == Common::EVENT_LBUTTONDOWN) _mouseClick = true; @@ -121,8 +121,8 @@ void MortevielleEngine::addKeypress(Common::Event &evt) { // Check for debugger if ((evt.kbd.keycode == Common::KEYCODE_d) && (evt.kbd.flags & Common::KBD_CTRL)) { // Attach to the debugger - _debugger.attach(); - _debugger.onFrame(); + _debugger->attach(); + _debugger->onFrame(); } else if ((evt.kbd.keycode >= Common::KEYCODE_a) && (evt.kbd.keycode <= Common::KEYCODE_z)) { // Handle alphabetic keys if (evt.kbd.hasFlags(Common::KBD_CTRL)) @@ -208,7 +208,7 @@ void MortevielleEngine::initMouse() { CursorMan.replaceCursor(CURSOR_ARROW_DATA, 16, 16, 0, 0, 0xff); CursorMan.showMouse(true); - _mouse.initMouse(); + _mouse->initMouse(); } /** @@ -237,9 +237,9 @@ void MortevielleEngine::delay(int amount) { while (g_system->getMillis() < endTime) { if (g_system->getMillis() > (_lastGameFrame + GAME_FRAME_DELAY)) { _lastGameFrame = g_system->getMillis(); - _screenSurface.updateScreen(); + _screenSurface->updateScreen(); - _debugger.onFrame(); + _debugger->onFrame(); } g_system->delayMillis(10); @@ -258,11 +258,10 @@ void MortevielleEngine::handleAction() { clearVerbBar(); - bool handledOpcodeFl = false; _controlMenu = 0; if (!_keyPressedEsc) { - _menu.drawMenu(); - _menu._menuDisplayed = true; + _menu->drawMenu(); + _menu->_menuDisplayed = true; temps = 0; _key = 0; funct = false; @@ -270,28 +269,28 @@ void MortevielleEngine::handleAction() { _inMainGameLoop = true; do { - _menu.updateMenu(); + _menu->updateMenu(); prepareRoom(); - _mouse.moveMouse(funct, inkey); + _mouse->moveMouse(funct, inkey); if (shouldQuit()) return; ++temps; if (keyPressed() || _mouseClick) { - _soundManager._mixer->stopHandle(_soundManager._soundHandle); + _soundManager->_mixer->stopHandle(_soundManager->_soundHandle); } - } while (!((_menu._menuSelected) || (temps > lim) || (funct) || (_anyone))); + } while (!((_menu->_menuSelected) || (temps > lim) || (funct) || (_anyone))); _inMainGameLoop = false; - _menu.eraseMenu(); - _menu._menuDisplayed = false; - if (_menu._menuSelected && (_currMenu == MENU_SAVE)) { + _menu->eraseMenu(); + _menu->_menuDisplayed = false; + if (_menu->_menuSelected && (_currMenu == MENU_SAVE)) { Common::String saveName = Common::String::format("Savegame #%d", _currAction & 15); - _savegameManager.saveGame(_currAction & 15, saveName); + _savegameManager->saveGame(_currAction & 15, saveName); } - if (_menu._menuSelected && (_currMenu == MENU_LOAD)) - _savegameManager.loadGame((_currAction & 15) - 1); + if (_menu->_menuSelected && (_currMenu == MENU_LOAD)) + _savegameManager->loadGame((_currAction & 15) - 1); if (inkey == '\103') { /* F9 */ - temps = _dialogManager.show(_hintPctMessage); + temps = _dialogManager->show(_hintPctMessage); return; } else if (inkey == '\77') { if ((_menuOpcode != OPCODE_NONE) && ((_currMenu == MENU_ACTION) || (_currMenu == MENU_SELF))) { @@ -319,14 +318,15 @@ void MortevielleEngine::handleAction() { _menuOpcode = _currMenu; if ((_currMenu == MENU_ACTION) || (_currMenu == MENU_SELF)) _menuOpcode = _currAction; + bool handledOpcodeFl = false; if (!_anyone) { if ((_heroSearching) || (_obpart)) { - if (_mouse._pos.y < 12) + if (_mouse->_pos.y < 12) return; - if ((_currAction == _menu._opcodeSound) || (_currAction == _menu._opcodeLift)) { + if ((_currAction == _menu->_opcodeSound) || (_currAction == _menu->_opcodeLift)) { handledOpcodeFl = true; - if ((_currAction == _menu._opcodeLift) || (_obpart)) { + if ((_currAction == _menu->_opcodeLift) || (_obpart)) { endSearch(); _caff = _coreVar._currPlace; _crep = 998; @@ -341,7 +341,7 @@ void MortevielleEngine::handleAction() { handleOpcode(); if ((_controlMenu == 0) && (! _loseGame) && (! _endGame)) { - _text.taffich(); + _text->taffich(); if (_destinationOk) { _destinationOk = false; drawPicture(); @@ -389,7 +389,7 @@ void MortevielleEngine::setTextColor(int col) { */ void MortevielleEngine::prepareScreenType1() { // Large drawing - _screenSurface.drawBox(0, 11, 512, 164, 15); + _screenSurface->drawBox(0, 11, 512, 164, 15); } /** @@ -466,7 +466,7 @@ int MortevielleEngine::convertBitIndexToCharacterIndex(int bitIndex) { */ void MortevielleEngine::resetPresenceInRooms(int roomId) { if (roomId == DINING_ROOM) - _blo = false; + _outsideOnlyFl = false; if (roomId != GREEN_ROOM) { _roomPresenceLuc = false; @@ -500,51 +500,51 @@ void MortevielleEngine::resetPresenceInRooms(int roomId) { * @remarks Originally called 'affper' */ void MortevielleEngine::showPeoplePresent(int bitIndex) { - int xp = 580 - (_screenSurface.getStringWidth("LEO") / 2); + int xp = 580 - (_screenSurface->getStringWidth("LEO") / 2); for (int i = 1; i <= 8; ++i) - _menu.disableMenuItem(_menu._discussMenu[i]); + _menu->disableMenuItem(_menu->_discussMenu[i]); clearUpperRightPart(); if ((bitIndex & 128) == 128) { - _screenSurface.putxy(xp, 24); - _screenSurface.drawString("LEO", 4); - _menu.enableMenuItem(_menu._discussMenu[1]); + _screenSurface->putxy(xp, 24); + _screenSurface->drawString("LEO", 4); + _menu->enableMenuItem(_menu->_discussMenu[1]); } if ((bitIndex & 64) == 64) { - _screenSurface.putxy(xp, 32); - _screenSurface.drawString("PAT", 4); - _menu.enableMenuItem(_menu._discussMenu[2]); + _screenSurface->putxy(xp, 32); + _screenSurface->drawString("PAT", 4); + _menu->enableMenuItem(_menu->_discussMenu[2]); } if ((bitIndex & 32) == 32) { - _screenSurface.putxy(xp, 40); - _screenSurface.drawString("GUY", 4); - _menu.enableMenuItem(_menu._discussMenu[3]); + _screenSurface->putxy(xp, 40); + _screenSurface->drawString("GUY", 4); + _menu->enableMenuItem(_menu->_discussMenu[3]); } if ((bitIndex & 16) == 16) { - _screenSurface.putxy(xp, 48); - _screenSurface.drawString("EVA", 4); - _menu.enableMenuItem(_menu._discussMenu[4]); + _screenSurface->putxy(xp, 48); + _screenSurface->drawString("EVA", 4); + _menu->enableMenuItem(_menu->_discussMenu[4]); } if ((bitIndex & 8) == 8) { - _screenSurface.putxy(xp, 56); - _screenSurface.drawString("BOB", 4); - _menu.enableMenuItem(_menu._discussMenu[5]); + _screenSurface->putxy(xp, 56); + _screenSurface->drawString("BOB", 4); + _menu->enableMenuItem(_menu->_discussMenu[5]); } if ((bitIndex & 4) == 4) { - _screenSurface.putxy(xp, 64); - _screenSurface.drawString("LUC", 4); - _menu.enableMenuItem(_menu._discussMenu[6]); + _screenSurface->putxy(xp, 64); + _screenSurface->drawString("LUC", 4); + _menu->enableMenuItem(_menu->_discussMenu[6]); } if ((bitIndex & 2) == 2) { - _screenSurface.putxy(xp, 72); - _screenSurface.drawString("IDA", 4); - _menu.enableMenuItem(_menu._discussMenu[7]); + _screenSurface->putxy(xp, 72); + _screenSurface->drawString("IDA", 4); + _menu->enableMenuItem(_menu->_discussMenu[7]); } if ((bitIndex & 1) == 1) { - _screenSurface.putxy(xp, 80); - _screenSurface.drawString("MAX", 4); - _menu.enableMenuItem(_menu._discussMenu[8]); + _screenSurface->putxy(xp, 80); + _screenSurface->drawString("MAX", 4); + _menu->enableMenuItem(_menu->_discussMenu[8]); } _currBitIndex = bitIndex; } @@ -605,7 +605,7 @@ int MortevielleEngine::getPresenceStatsGreenRoom() { else if ((hour >= 0) && (hour < 8)) retVal = 70; - _menu.updateMenu(); + _menu->updateMenu(); return retVal; } @@ -698,19 +698,19 @@ int MortevielleEngine::getPresenceStatsRedRoom() { */ void MortevielleEngine::displayAloneText() { for (int i = 1; i <= 8; ++i) - _menu.disableMenuItem(_menu._discussMenu[i]); + _menu->disableMenuItem(_menu->_discussMenu[i]); Common::String sYou = getEngineString(S_YOU); Common::String sAre = getEngineString(S_ARE); Common::String sAlone = getEngineString(S_ALONE); clearUpperRightPart(); - _screenSurface.putxy(580 - (_screenSurface.getStringWidth(sYou) / 2), 30); - _screenSurface.drawString(sYou, 4); - _screenSurface.putxy(580 - (_screenSurface.getStringWidth(sAre) / 2), 50); - _screenSurface.drawString(sAre, 4); - _screenSurface.putxy(580 - (_screenSurface.getStringWidth(sAlone) / 2), 70); - _screenSurface.drawString(sAlone, 4); + _screenSurface->putxy(580 - (_screenSurface->getStringWidth(sYou) / 2), 30); + _screenSurface->drawString(sYou, 4); + _screenSurface->putxy(580 - (_screenSurface->getStringWidth(sAre) / 2), 50); + _screenSurface->drawString(sAre, 4); + _screenSurface->putxy(580 - (_screenSurface->getStringWidth(sAlone) / 2), 70); + _screenSurface->drawString(sAlone, 4); _currBitIndex = 0; } @@ -1080,7 +1080,7 @@ void MortevielleEngine::initGame() { _place = MANOR_FRONT; _currentHourCount = 0; if (!_coreVar._alreadyEnteredManor) - _blo = true; + _outsideOnlyFl = true; _inGameHourDuration = kTime1; _currentTime = readclock(); } @@ -1255,24 +1255,24 @@ void MortevielleEngine::startMusicOrSpeech(int so) { ; } else if ((!_introSpeechPlayed) && (!_coreVar._alreadyEnteredManor)) { // Type 1: Speech - _soundManager.startSpeech(10, 1, 1); + _soundManager->startSpeech(10, 1, 1); _introSpeechPlayed = true; } else { if (((_coreVar._currPlace == MOUNTAIN) || (_coreVar._currPlace == MANOR_FRONT) || (_coreVar._currPlace == MANOR_BACK)) && (getRandomNumber(1, 3) == 2)) // Type 1: Speech - _soundManager.startSpeech(9, getRandomNumber(2, 4), 1); + _soundManager->startSpeech(9, getRandomNumber(2, 4), 1); else if ((_coreVar._currPlace == CHAPEL) && (getRandomNumber(1, 2) == 1)) // Type 1: Speech - _soundManager.startSpeech(8, 1, 1); + _soundManager->startSpeech(8, 1, 1); else if ((_coreVar._currPlace == WELL) && (getRandomNumber(1, 2) == 2)) // Type 1: Speech - _soundManager.startSpeech(12, 1, 1); + _soundManager->startSpeech(12, 1, 1); else if (_coreVar._currPlace == INSIDE_WELL) // Type 1: Speech - _soundManager.startSpeech(13, 1, 1); + _soundManager->startSpeech(13, 1, 1); else // Type 2 : music - _soundManager.startSpeech(getRandomNumber(1, 17), 1, 2); + _soundManager->startSpeech(getRandomNumber(1, 17), 1, 2); } } @@ -1284,13 +1284,13 @@ void MortevielleEngine::loseGame() { resetOpenObjects(); _roomDoorId = OWN_ROOM; _curSearchObjId = 0; - _menu.unsetSearchMenu(); - if (!_blo) + _menu->unsetSearchMenu(); + if (!_outsideOnlyFl) getPresence(MANOR_FRONT); _loseGame = true; clearUpperLeftPart(); - _screenSurface.drawBox(60, 35, 400, 50, 15); + _screenSurface->drawBox(60, 35, 400, 50, 15); handleDescriptionText(9, _crep); clearDescriptionBar(); clearVerbBar(); @@ -1333,20 +1333,20 @@ void MortevielleEngine::startDialog(int16 rep) { assert(rep >= 0); - _mouse.hideMouse(); + _mouse->hideMouse(); Common::String dialogStr = getString(rep + kDialogStringIndex); - _text.displayStr(dialogStr, 230, 4, 65, 26, 5); - _dialogManager.drawF3F8(); + _text->displayStr(dialogStr, 230, 4, 65, 26, 5); + _dialogManager->drawF3F8(); key = 0; do { - _soundManager.startSpeech(rep, haut[_caff - 69], 0); - key = _dialogManager.waitForF3F8(); + _soundManager->startSpeech(rep, haut[_caff - 69], 0); + key = _dialogManager->waitForF3F8(); if (shouldQuit()) return; } while (key != 66); clearScreen(); - _mouse.showMouse(); + _mouse->showMouse(); } /** @@ -1357,7 +1357,7 @@ void MortevielleEngine::endSearch() { _heroSearching = false; _obpart = false; _searchCount = 0; - _menu.unsetSearchMenu(); + _menu->unsetSearchMenu(); } /** @@ -1379,21 +1379,21 @@ void MortevielleEngine::gotoDiningRoom() { showPeoplePresent(_currBitIndex); _caff = 77; drawPictureWithText(); - _screenSurface.drawBox(223, 47, 155, 92, 15); + _screenSurface->drawBox(223, 47, 155, 92, 15); handleDescriptionText(2, 33); testKey(false); menuUp(); - _mouse.hideMouse(); + _mouse->hideMouse(); clearScreen(); drawDiscussionBox(); startDialog(140); drawRightFrame(); drawClock(); - _mouse.showMouse(); + _mouse->showMouse(); _coreVar._currPlace = OWN_ROOM; prepareDisplayText(); resetPresenceInRooms(DINING_ROOM); - if (!_blo) + if (!_outsideOnlyFl) getPresence(OWN_ROOM); _currBitIndex = 0; _savedBitIndex = 0; @@ -1451,8 +1451,8 @@ void MortevielleEngine::floodedInWell() { * @remarks Originally called 'antegame' */ void MortevielleEngine::gameLoaded() { - _mouse.hideMouse(); - _menu._menuDisplayed = false; + _mouse->hideMouse(); + _menu->_menuDisplayed = false; _loseGame = true; _anyone = false; _destinationOk = true; @@ -1490,11 +1490,11 @@ void MortevielleEngine::gameLoaded() { handleDescriptionText(2, _crep); clearVerbBar(); _endGame = false; - _menu.setDestinationText(_coreVar._currPlace); - _menu.setInventoryText(); + _menu->setDestinationText(_coreVar._currPlace); + _menu->setInventoryText(); if (_coreVar._selectedObjectId != 0) displayItemInHand(_coreVar._selectedObjectId + 400); - _mouse.showMouse(); + _mouse->showMouse(); } /** @@ -1508,7 +1508,7 @@ void MortevielleEngine::handleOpcode() { _keyPressedEsc = false; if (!_anyone) { if (_uptodatePresence) { - if ((_currMenu == MENU_MOVE) || (_currAction == _menu._opcodeLeave) || (_currAction == _menu._opcodeSleep) || (_currAction == _menu._opcodeEat)) { + if ((_currMenu == MENU_MOVE) || (_currAction == _menu->_opcodeLeave) || (_currAction == _menu->_opcodeSleep) || (_currAction == _menu->_opcodeEat)) { _controlMenu = 4; menuUp(); return; @@ -1521,60 +1521,60 @@ void MortevielleEngine::handleOpcode() { fctDiscuss(); else if (_currMenu == MENU_INVENTORY) fctInventoryTake(); - else if (_currAction == _menu._opcodeAttach) + else if (_currAction == _menu->_opcodeAttach) fctAttach(); - else if (_currAction == _menu._opcodeWait) + else if (_currAction == _menu->_opcodeWait) fctWait(); - else if (_currAction == _menu._opcodeForce) + else if (_currAction == _menu->_opcodeForce) fctForce(); - else if (_currAction == _menu._opcodeSleep) + else if (_currAction == _menu->_opcodeSleep) fctSleep(); - else if (_currAction == _menu._opcodeListen) + else if (_currAction == _menu->_opcodeListen) fctListen(); - else if (_currAction == _menu._opcodeEnter) + else if (_currAction == _menu->_opcodeEnter) fctEnter(); - else if (_currAction == _menu._opcodeClose) + else if (_currAction == _menu->_opcodeClose) fctClose(); - else if (_currAction == _menu._opcodeSearch) + else if (_currAction == _menu->_opcodeSearch) fctSearch(); - else if (_currAction == _menu._opcodeKnock) + else if (_currAction == _menu->_opcodeKnock) fctKnock(); - else if (_currAction == _menu._opcodeScratch) + else if (_currAction == _menu->_opcodeScratch) fctScratch(); - else if (_currAction == _menu._opcodeRead) + else if (_currAction == _menu->_opcodeRead) fctRead(); - else if (_currAction == _menu._opcodeEat) + else if (_currAction == _menu->_opcodeEat) fctEat(); - else if (_currAction == _menu._opcodePlace) + else if (_currAction == _menu->_opcodePlace) fctPlace(); - else if (_currAction == _menu._opcodeOpen) + else if (_currAction == _menu->_opcodeOpen) fctOpen(); - else if (_currAction == _menu._opcodeTake) + else if (_currAction == _menu->_opcodeTake) fctTake(); - else if (_currAction == _menu._opcodeLook) + else if (_currAction == _menu->_opcodeLook) fctLook(); - else if (_currAction == _menu._opcodeSmell) + else if (_currAction == _menu->_opcodeSmell) fctSmell(); - else if (_currAction == _menu._opcodeSound) + else if (_currAction == _menu->_opcodeSound) fctSound(); - else if (_currAction == _menu._opcodeLeave) + else if (_currAction == _menu->_opcodeLeave) fctLeave(); - else if (_currAction == _menu._opcodeLift) + else if (_currAction == _menu->_opcodeLift) fctLift(); - else if (_currAction == _menu._opcodeTurn) + else if (_currAction == _menu->_opcodeTurn) fctTurn(); - else if (_currAction == _menu._opcodeSSearch) + else if (_currAction == _menu->_opcodeSSearch) fctSelfSearch(); - else if (_currAction == _menu._opcodeSRead) + else if (_currAction == _menu->_opcodeSRead) fctSelfRead(); - else if (_currAction == _menu._opcodeSPut) + else if (_currAction == _menu->_opcodeSPut) fctSelfPut(); - else if (_currAction == _menu._opcodeSLook) + else if (_currAction == _menu->_opcodeSLook) fctSelftLook(); _hiddenHero = false; - if (_currAction == _menu._opcodeSHide) + if (_currAction == _menu->_opcodeSHide) fctSelfHide(); } else if (_anyone) { interactNPC(); @@ -1640,9 +1640,9 @@ void MortevielleEngine::charToHour() { * @remarks Originally called 'clsf1' */ void MortevielleEngine::clearUpperLeftPart() { - _mouse.hideMouse(); - _screenSurface.fillRect(0, Common::Rect(0, 11, 514, 175)); - _mouse.showMouse(); + _mouse->hideMouse(); + _screenSurface->fillRect(0, Common::Rect(0, 11, 514, 175)); + _mouse->showMouse(); } /** @@ -1650,16 +1650,16 @@ void MortevielleEngine::clearUpperLeftPart() { * @remarks Originally called 'clsf2' */ void MortevielleEngine::clearDescriptionBar() { - _mouse.hideMouse(); + _mouse->hideMouse(); if (_largestClearScreen) { - _screenSurface.fillRect(0, Common::Rect(1, 176, 633, 199)); - _screenSurface.drawBox(0, 176, 634, 23, 15); + _screenSurface->fillRect(0, Common::Rect(1, 176, 633, 199)); + _screenSurface->drawBox(0, 176, 634, 23, 15); _largestClearScreen = false; } else { - _screenSurface.fillRect(0, Common::Rect(1, 176, 633, 190)); - _screenSurface.drawBox(0, 176, 634, 14, 15); + _screenSurface->fillRect(0, Common::Rect(1, 176, 633, 190)); + _screenSurface->drawBox(0, 176, 634, 14, 15); } - _mouse.showMouse(); + _mouse->showMouse(); } /** @@ -1667,10 +1667,10 @@ void MortevielleEngine::clearDescriptionBar() { * @remarks Originally called 'clsf3' */ void MortevielleEngine::clearVerbBar() { - _mouse.hideMouse(); - _screenSurface.fillRect(0, Common::Rect(1, 192, 633, 199)); - _screenSurface.drawBox(0, 191, 634, 8, 15); - _mouse.showMouse(); + _mouse->hideMouse(); + _screenSurface->fillRect(0, Common::Rect(1, 192, 633, 199)); + _screenSurface->drawBox(0, 191, 634, 8, 15); + _mouse->showMouse(); } /** @@ -1680,10 +1680,10 @@ void MortevielleEngine::clearVerbBar() { void MortevielleEngine::clearUpperRightPart() { Common::String st; - _mouse.hideMouse(); + _mouse->hideMouse(); // Clear ambiance description - _screenSurface.fillRect(15, Common::Rect(544, 93, 600, 98)); + _screenSurface->fillRect(15, Common::Rect(544, 93, 600, 98)); if (_coreVar._faithScore < 33) st = getEngineString(S_COOL); else if (_coreVar._faithScore < 66) @@ -1691,13 +1691,13 @@ void MortevielleEngine::clearUpperRightPart() { else if (_coreVar._faithScore > 65) st = getEngineString(S_MALSAINE); - int x1 = 580 - (_screenSurface.getStringWidth(st) / 2); - _screenSurface.putxy(x1, 92); - _screenSurface.drawString(st, 4); + int x1 = 580 - (_screenSurface->getStringWidth(st) / 2); + _screenSurface->putxy(x1, 92); + _screenSurface->drawString(st, 4); // Clear person list - _screenSurface.fillRect(15, Common::Rect(560, 24, 610, 86)); - _mouse.showMouse(); + _screenSurface->fillRect(15, Common::Rect(560, 24, 610, 86)); + _mouse->showMouse(); } /** @@ -1713,7 +1713,7 @@ int MortevielleEngine::getRandomNumber(int minval, int maxval) { * @remarks Originally called 'aldepl' */ void MortevielleEngine::showMoveMenuAlert() { - _dialogManager.show(getEngineString(S_USE_DEP_MENU)); + _dialogManager->show(getEngineString(S_USE_DEP_MENU)); } /** @@ -1888,24 +1888,18 @@ void MortevielleEngine::resetObjectPlace() { _tabdon[i] = _tabdon[i + 390]; } -/** - * Engine function - When restarting the game, reset the main variables used by the engine - * @remarks Originally called 'inzon' - */ -void MortevielleEngine::resetVariables() { - resetObjectPlace(); - - _coreVar._alreadyEnteredManor = false; - _coreVar._selectedObjectId = 0; - _coreVar._cellarObjectId = 0; - _coreVar._atticBallHoleObjectId = 0; - _coreVar._atticRodHoleObjectId = 0; - _coreVar._wellObjectId = 0; - _coreVar._secretPassageObjectId = 0; - _coreVar._purpleRoomObjectId = 136; - _coreVar._cryptObjectId = 141; - _coreVar._faithScore = getRandomNumber(4, 10); - _coreVar._currPlace = MANOR_FRONT; +void MortevielleEngine::resetCoreVar() { + _saveStruct._alreadyEnteredManor = _coreVar._alreadyEnteredManor = false; + _saveStruct._selectedObjectId = _coreVar._selectedObjectId = 0; + _saveStruct._cellarObjectId = _coreVar._cellarObjectId = 0; + _saveStruct._atticBallHoleObjectId = _coreVar._atticBallHoleObjectId = 0; + _saveStruct._atticRodHoleObjectId = _coreVar._atticRodHoleObjectId = 0; + _saveStruct._wellObjectId = _coreVar._wellObjectId = 0; + _saveStruct._secretPassageObjectId = _coreVar._secretPassageObjectId = 0; + _saveStruct._purpleRoomObjectId = _coreVar._purpleRoomObjectId = 136; + _saveStruct._cryptObjectId = _coreVar._cryptObjectId = 141; + _saveStruct._faithScore = _coreVar._faithScore = getRandomNumber(4, 10); + _saveStruct._currPlace = _coreVar._currPlace = MANOR_FRONT; for (int i = 2; i <= 6; ++i) _coreVar._inventory[i] = 0; @@ -1913,7 +1907,7 @@ void MortevielleEngine::resetVariables() { // Only object in inventory: a gun _coreVar._inventory[1] = 113; - _coreVar._fullHour = (unsigned char)20; + _saveStruct._fullHour = _coreVar._fullHour = (unsigned char)20; for (int i = 1; i <= 10; ++i) _coreVar._pctHintFound[i] = ' '; @@ -1931,6 +1925,14 @@ void MortevielleEngine::resetVariables() { _coreVar._availableQuestion[i] = ' '; _coreVar._availableQuestion[33] = '*'; +} +/** + * Engine function - When restarting the game, reset the main variables used by the engine + * @remarks Originally called 'inzon' + */ +void MortevielleEngine::resetVariables() { + resetObjectPlace(); + resetCoreVar(); for (int i = 1; i <= 8; ++i) _charAnswerCount[i] = 0; @@ -2074,10 +2076,10 @@ void MortevielleEngine::loadCFIPH() { error("Missing file - *cfiph.mor"); } - _soundManager._cfiphBuffer = (uint16 *)malloc(sizeof(uint16) * (f.size() / 2)); + _soundManager->_cfiphBuffer = (uint16 *)malloc(sizeof(uint16) * (f.size() / 2)); for (int i = 0; i < (f.size() / 2); ++i) - _soundManager._cfiphBuffer[i] = f.readUint16BE(); + _soundManager->_cfiphBuffer[i] = f.readUint16BE(); f.close(); } @@ -2102,10 +2104,10 @@ void MortevielleEngine::music() { f.read(compMusicBuf, size); f.close(); - int musicSize = _soundManager.decodeMusic(compMusicBuf, musicBuf, size); + int musicSize = _soundManager->decodeMusic(compMusicBuf, musicBuf, size); free(compMusicBuf); - _soundManager.playSong(musicBuf, musicSize, 5); + _soundManager->playSong(musicBuf, musicSize, 5); while (keyPressed()) getChar(); @@ -2120,14 +2122,14 @@ void MortevielleEngine::showTitleScreen() { clearScreen(); handleDescriptionText(7, 2035); _caff = 51; - _text.taffich(); + _text->taffich(); testKeyboard(); clearScreen(); draw(0, 0); Common::String cpr = "COPYRIGHT 1989 : LANKHOR"; - _screenSurface.putxy(104 + 72 * kResolutionScaler, 185); - _screenSurface.drawString(cpr, 0); + _screenSurface->putxy(104 + 72 * kResolutionScaler, 185); + _screenSurface->drawString(cpr, 0); } /** @@ -2135,10 +2137,10 @@ void MortevielleEngine::showTitleScreen() { * @remarks Originally called 'dessine' */ void MortevielleEngine::draw(int x, int y) { - _mouse.hideMouse(); + _mouse->hideMouse(); setPal(_numpal); displayPicture(_curPict, x, y); - _mouse.showMouse(); + _mouse->showMouse(); } /** @@ -2147,9 +2149,9 @@ void MortevielleEngine::draw(int x, int y) { */ void MortevielleEngine::drawRightFrame() { setPal(89); - _mouse.hideMouse(); + _mouse->hideMouse(); displayPicture(_rightFramePict, 0, 0); - _mouse.showMouse(); + _mouse->showMouse(); } /** @@ -2205,10 +2207,10 @@ void MortevielleEngine::prepareRoom() { _minute = 30; drawClock(); } - if (_mouse._pos.y < 12) + if (_mouse->_pos.y < 12) return; - if (!_blo) { + if (!_outsideOnlyFl) { if ((hour == 12) || ((hour > 18) && (hour < 21)) || ((hour >= 0) && (hour < 7))) _inGameHourDuration = kTime2; else @@ -2221,8 +2223,8 @@ void MortevielleEngine::prepareRoom() { int newTime = readclock(); if ((newTime - _currentTime) > _inGameHourDuration) { - bool activeMenu = _menu._menuActive; - _menu.eraseMenu(); + bool activeMenu = _menu->_menuActive; + _menu->eraseMenu(); _currentHourCount += ((newTime - _currentTime) / _inGameHourDuration); _currentTime = newTime; switch (_place) { @@ -2280,8 +2282,8 @@ void MortevielleEngine::prepareRoom() { prepareScreenType2(); displayTextInVerbBar(getEngineString(S_HEAR_NOISE)); int rand = (getRandomNumber(0, 4)) - 2; - _soundManager.startSpeech(1, rand, 1); - _soundManager.waitSpeech(); + _soundManager->startSpeech(1, rand, 1); + _soundManager->waitSpeech(); clearVerbBar(); } } @@ -2289,7 +2291,7 @@ void MortevielleEngine::prepareRoom() { } if (activeMenu) - _menu.drawMenu(); + _menu->drawMenu(); } } _endTime = readclock(); @@ -2315,15 +2317,15 @@ void MortevielleEngine::drawClock() { const int y = 123; const int rg = 9; - _mouse.hideMouse(); + _mouse->hideMouse(); - _screenSurface.drawRectangle(570, 118, 20, 10); - _screenSurface.drawRectangle(578, 114, 6, 18); + _screenSurface->drawRectangle(570, 118, 20, 10); + _screenSurface->drawRectangle(578, 114, 6, 18); if (_minute == 0) - _screenSurface.drawLine(((uint)x >> 1) * kResolutionScaler, y, ((uint)x >> 1) * kResolutionScaler, (y - rg), 1); + _screenSurface->drawLine(((uint)x >> 1) * kResolutionScaler, y, ((uint)x >> 1) * kResolutionScaler, (y - rg), 1); else - _screenSurface.drawLine(((uint)x >> 1) * kResolutionScaler, y, ((uint)x >> 1) * kResolutionScaler, (y + rg), 1); + _screenSurface->drawLine(((uint)x >> 1) * kResolutionScaler, y, ((uint)x >> 1) * kResolutionScaler, (y + rg), 1); int hour12 = _hour; if (hour12 > 12) @@ -2331,20 +2333,20 @@ void MortevielleEngine::drawClock() { if (hour12 == 0) hour12 = 12; - _screenSurface.drawLine(((uint)x >> 1) * kResolutionScaler, y, ((uint)(x + cv[0][hour12 - 1]) >> 1) * kResolutionScaler, y + cv[1][hour12 - 1], 1); - _mouse.showMouse(); - _screenSurface.putxy(568, 154); + _screenSurface->drawLine(((uint)x >> 1) * kResolutionScaler, y, ((uint)(x + cv[0][hour12 - 1]) >> 1) * kResolutionScaler, y + cv[1][hour12 - 1], 1); + _mouse->showMouse(); + _screenSurface->putxy(568, 154); if (_hour > 11) - _screenSurface.drawString("PM ", 1); + _screenSurface->drawString("PM ", 1); else - _screenSurface.drawString("AM ", 1); + _screenSurface->drawString("AM ", 1); - _screenSurface.putxy(550, 160); + _screenSurface->putxy(550, 160); if ((_day >= 0) && (_day <= 8)) { Common::String tmp = getEngineString(S_DAY); tmp.insertChar((char)(_day + 49), 0); - _screenSurface.drawString(tmp, 1); + _screenSurface->drawString(tmp, 1); } } @@ -2364,8 +2366,7 @@ Common::String MortevielleEngine::copy(const Common::String &s, int idx, size_t // Copy the substring into a temporary buffer char *tmp = new char[size + 1]; - strncpy(tmp, s.c_str() + idx - 1, size); - tmp[size] = '\0'; + Common::strlcpy(tmp, s.c_str() + idx - 1, size + 1); Common::String result(tmp); delete[] tmp; @@ -2377,7 +2378,7 @@ Common::String MortevielleEngine::copy(const Common::String &s, int idx, size_t * @remarks Originally called 'hirs' */ void MortevielleEngine::clearScreen() { - _screenSurface.clearScreen(); + _screenSurface->clearScreen(); } /** @@ -2392,8 +2393,8 @@ void MortevielleEngine::initCaveOrCellar() { prepareScreenType2(); displayTextInVerbBar(getEngineString(S_SOMEONE_ENTERS)); int rand = (getRandomNumber(0, 4)) - 2; - _soundManager.startSpeech(2, rand, 1); - _soundManager.waitSpeech(); + _soundManager->startSpeech(2, rand, 1); + _soundManager->waitSpeech(); // The original was doing here a useless loop. // It has been removed @@ -2417,7 +2418,7 @@ void MortevielleEngine::displayControlMenu() { void MortevielleEngine::displayPicture(const byte *pic, int x, int y) { GfxSurface surface; surface.decode(pic); - _screenSurface.drawPicture(surface, x, y); + _screenSurface->drawPicture(surface, x, y); } void MortevielleEngine::adzon() { @@ -2466,7 +2467,7 @@ void MortevielleEngine::displayTextInDescriptionBar(int x, int y, int nb, int me Common::String tmpStr = getString(mesgId); if ((y == 182) && ((int) tmpStr.size() > nb)) y = 176; - _text.displayStr(tmpStr, x, y, nb, 20, _textColor); + _text->displayStr(tmpStr, x, y, nb, 20, _textColor); } /** @@ -2483,7 +2484,7 @@ void MortevielleEngine::handleDescriptionText(int f, int mesgId) { _largestClearScreen = false; clearDescriptionBar(); - _text.displayStr(tmpStr, 8, 176, 85, 3, 5); + _text->displayStr(tmpStr, 8, 176, 85, 3, 5); } else { mapMessageId(mesgId); switch (f) { @@ -2512,7 +2513,7 @@ void MortevielleEngine::handleDescriptionText(int f, int mesgId) { i = 5; Common::String tmpStr = getString(mesgId); - _text.displayStr(tmpStr, 80, 40, 60, 25, i); + _text->displayStr(tmpStr, 80, 40, 60, 25, i); if (mesgId == 180) _coreVar._pctHintFound[6] = '*'; @@ -2585,32 +2586,32 @@ void MortevielleEngine::resetOpenObjects() { */ void MortevielleEngine::displayTextBlock(Common::String text) { // Some dead code was present in the original: removed - _screenSurface.putxy(8, 177); + _screenSurface->putxy(8, 177); int tlig = 59 + (kResolutionScaler - 1) * 36; if ((int)text.size() < tlig) - _screenSurface.drawString(text, 5); + _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); + _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; clearDescriptionBar(); - _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); + _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::displayTextInVerbBar(Common::String text) { clearVerbBar(); - _screenSurface.putxy(8, 192); - _screenSurface.drawString(text, 5); + _screenSurface->putxy(8, 192); + _screenSurface->drawString(text, 5); } /** @@ -2623,8 +2624,8 @@ void MortevielleEngine::displayItemInHand(int objId) { if (objId != 500) strp = getString(objId - 501 + kInventoryStringIndex); - _menu.setText(_menu._inventoryMenu[8], strp); - _menu.disableMenuItem(_menu._inventoryMenu[8]); + _menu->setText(_menu->_inventoryMenu[8], strp); + _menu->disableMenuItem(_menu->_inventoryMenu[8]); } /** @@ -2832,7 +2833,7 @@ int MortevielleEngine::getPresence(int roomId) { * @remarks Originally called 'writetp' */ void MortevielleEngine::displayQuestionText(Common::String s, int cmd) { - _screenSurface.drawString(s, cmd); + _screenSurface->drawString(s, cmd); } /** @@ -2856,7 +2857,7 @@ void MortevielleEngine::displayAnimFrame(int frameNum, int animId) { GfxSurface surface; surface.decode(&_curAnim[offset]); - _screenSurface.drawPicture(surface, 0, 12); + _screenSurface->drawPicture(surface, 0, 12); prepareScreenType1(); } @@ -2869,10 +2870,10 @@ void MortevielleEngine::drawPicture() { clearUpperLeftPart(); if (_caff > 99) { draw(60, 33); - _screenSurface.drawBox(118, 32, 291, 122, 15); // Medium box + _screenSurface->drawBox(118, 32, 291, 122, 15); // Medium box } else if (_caff > 69) { draw(112, 48); // Heads - _screenSurface.drawBox(222, 47, 155, 92, 15); + _screenSurface->drawBox(222, 47, 155, 92, 15); } else { draw(0, 12); prepareScreenType1(); @@ -2911,7 +2912,7 @@ void MortevielleEngine::drawPicture() { } void MortevielleEngine::drawPictureWithText() { - _text.taffich(); + _text->taffich(); drawPicture(); _destinationOk = false; } @@ -2925,7 +2926,7 @@ void MortevielleEngine::testKey(bool d) { int x, y; bool click; - _mouse.hideMouse(); + _mouse->hideMouse(); displayStatusInDescriptionBar('K'); // Wait for release from any key or mouse button @@ -2933,8 +2934,10 @@ void MortevielleEngine::testKey(bool d) { _key = gettKeyPressed(); do { - _mouse.getMousePosition(x, y, click); - keyPressed(); + _mouse->getMousePosition(x, y, click); + quest = keyPressed(); + if (quest && shouldQuit()) + return; } while (click); // Event loop @@ -2942,14 +2945,14 @@ void MortevielleEngine::testKey(bool d) { if (d) prepareRoom(); quest = keyPressed(); - _mouse.getMousePosition(x, y, click); + _mouse->getMousePosition(x, y, click); if (shouldQuit()) return; } while (!(quest || (click) || (d && _anyone))); if (quest) gettKeyPressed(); setMouseClick(false); - _mouse.showMouse(); + _mouse->showMouse(); } /** @@ -3060,7 +3063,7 @@ void MortevielleEngine::getSearchDescription(int objId) { * @remarks Originally called 'mennor' */ void MortevielleEngine::menuUp() { - _menu.menuUp(_currMenu); + _menu->menuUp(_currMenu); } /** @@ -3069,7 +3072,7 @@ void MortevielleEngine::menuUp() { */ void MortevielleEngine::drawDiscussionBox() { draw(10, 80); - _screenSurface.drawBox(18, 79, 155, 92, 15); + _screenSurface->drawBox(18, 79, 155, 92, 15); } /** @@ -3100,7 +3103,7 @@ void MortevielleEngine::addObjectToInventory(int objectId) { if (_coreVar._inventory[i] == 0) { _coreVar._inventory[i] = objectId; - _menu.setInventoryText(); + _menu->setInventoryText(); } else // Inventory is full _crep = 139; @@ -3111,8 +3114,8 @@ void MortevielleEngine::addObjectToInventory(int objectId) { * @remarks Originally called 'quelquun' */ void MortevielleEngine::interactNPC() { - if (_menu._menuDisplayed) - _menu.eraseMenu(); + if (_menu->_menuDisplayed) + _menu->eraseMenu(); endSearch(); _crep = 997; @@ -3122,9 +3125,9 @@ L1: _crep = 138; handleDescriptionText(2, _crep); if (_crep == 138) - _soundManager.startSpeech(5, 2, 1); + _soundManager->startSpeech(5, 2, 1); else - _soundManager.startSpeech(4, 4, 1); + _soundManager->startSpeech(4, 4, 1); if (_openObjCount == 0) _coreVar._faithScore += 2; @@ -3133,12 +3136,12 @@ L1: else _coreVar._faithScore += 3 * (_coreVar._faithScore / 10); exitRoom(); - _menu.setDestinationText(LANDING); + _menu->setDestinationText(LANDING); int charIdx = convertBitIndexToCharacterIndex(_currBitIndex); _caff = 69 + charIdx; _crep = _caff; _currMenu = MENU_DISCUSS; - _currAction = (_menu._discussMenu[charIdx]._menuId << 8) | _menu._discussMenu[charIdx]._actionId; + _currAction = (_menu->_discussMenu[charIdx]._menuId << 8) | _menu->_discussMenu[charIdx]._actionId; _syn = true; _col = true; } else { @@ -3149,15 +3152,15 @@ L1: } else { handleDescriptionText(2, 136); int rand = (getRandomNumber(0, 4)) - 2; - _soundManager.startSpeech(3, rand, 1); + _soundManager->startSpeech(3, rand, 1); clearDescriptionBar(); displayAloneText(); resetRoomVariables(MANOR_FRONT); prepareDisplayText(); } } - if (_menu._menuDisplayed) - _menu.drawMenu(); + if (_menu->_menuDisplayed) + _menu->drawMenu(); } /** @@ -3205,25 +3208,25 @@ void MortevielleEngine::displayStatusArrow() { touch = '\0'; do { - _mouse.moveMouse(qust, touch); + _mouse->moveMouse(qust, touch); if (shouldQuit()) return; if (getMouseClick()) - inRect = (_mouse._pos.x < 256 * kResolutionScaler) && (_mouse._pos.y < 176) && (_mouse._pos.y > 12); + inRect = (_mouse->_pos.x < 256 * kResolutionScaler) && (_mouse->_pos.y < 176) && (_mouse->_pos.y > 12); prepareRoom(); } while (!(qust || inRect || _anyone)); if (qust && (touch == '\103')) - _dialogManager.show(_hintPctMessage); + _dialogManager->show(_hintPctMessage); } while (!((touch == '\73') || ((touch == '\104') && (_x != 0) && (_y != 0)) || (_anyone) || (inRect))); if (touch == '\73') _keyPressedEsc = true; if (inRect) { - _x = _mouse._pos.x; - _y = _mouse._pos.y; + _x = _mouse->_pos.x; + _y = _mouse->_pos.y; } } @@ -3291,7 +3294,7 @@ void MortevielleEngine::displayLookScreen(int objId) { int mdes = _caff; _caff = objId; - if (((_caff > 29) && (_caff < 33)) || (_caff == 144) || (_caff == 147) || (_caff == 149) || (_currAction == _menu._opcodeSLook)) { + if (((_caff > 29) && (_caff < 33)) || (_caff == 144) || (_caff == 147) || (_caff == 149) || (_currAction == _menu->_opcodeSLook)) { drawPictureWithText(); if ((_caff > 29) && (_caff < 33)) handleDescriptionText(2, _caff); @@ -3304,7 +3307,7 @@ void MortevielleEngine::displayLookScreen(int objId) { } else { _obpart = true; _crep = _caff + 400; - _menu.setSearchMenu(); + _menu->setSearchMenu(); } } @@ -3356,10 +3359,10 @@ int MortevielleEngine::checkLeaveSecretPassage() { * @remarks Originally called 'fenat' */ void MortevielleEngine::displayStatusInDescriptionBar(char stat) { - _mouse.hideMouse(); - _screenSurface.writeCharacter(Common::Point(306, 193), stat, 12); - _screenSurface.drawBox(300, 191, 16, 8, 15); - _mouse.showMouse(); + _mouse->hideMouse(); + _screenSurface->writeCharacter(Common::Point(306, 193), stat, 12); + _screenSurface->drawBox(300, 191, 16, 8, 15); + _mouse->showMouse(); } /** |