From 4b9e71952c8384267251c31aae3fb5bcd34f7bff Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sat, 24 Mar 2012 22:00:28 +0100 Subject: MORTEVIELLE: More renaming and refactoring --- engines/mortevielle/actions.cpp | 2 +- engines/mortevielle/dialogs.cpp | 17 +- engines/mortevielle/keyboard.cpp | 71 ----- engines/mortevielle/keyboard.h | 38 --- engines/mortevielle/module.mk | 1 - engines/mortevielle/mortevielle.cpp | 306 +++++++++++---------- engines/mortevielle/mortevielle.h | 512 ++++++++++++++++++++---------------- engines/mortevielle/mouse.cpp | 8 - engines/mortevielle/mouse.h | 2 - engines/mortevielle/outtext.cpp | 33 ++- engines/mortevielle/outtext.h | 13 +- engines/mortevielle/var_mor.h | 70 ----- 12 files changed, 495 insertions(+), 578 deletions(-) delete mode 100644 engines/mortevielle/keyboard.cpp delete mode 100644 engines/mortevielle/keyboard.h (limited to 'engines/mortevielle') diff --git a/engines/mortevielle/actions.cpp b/engines/mortevielle/actions.cpp index 0247eca2e1..1a6614953d 100644 --- a/engines/mortevielle/actions.cpp +++ b/engines/mortevielle/actions.cpp @@ -1575,7 +1575,7 @@ void MortevielleEngine::endGame() { testKey(false); _mouse.hideMouse(); _caff = 70; - taffich(); + _text.taffich(); hirs(); premtet(); startDialog(141); diff --git a/engines/mortevielle/dialogs.cpp b/engines/mortevielle/dialogs.cpp index 19ff58071c..f04233d908 100644 --- a/engines/mortevielle/dialogs.cpp +++ b/engines/mortevielle/dialogs.cpp @@ -27,7 +27,6 @@ #include "common/str.h" #include "mortevielle/dialogs.h" -#include "mortevielle/keyboard.h" #include "mortevielle/mortevielle.h" #include "mortevielle/mouse.h" #include "mortevielle/outtext.h" @@ -307,7 +306,7 @@ bool KnowledgeCheck::show() { dialogHeight = 23; g_vm->_screenSurface.fillRect(15, Common::Rect(0, 14, 630, dialogHeight)); Common::String tmpStr = g_vm->getString(textIndexArr[indx]); - displayStr(tmpStr, 20, 15, 100, 2, 0); + g_vm->_text.displayStr(tmpStr, 20, 15, 100, 2, 0); if (indx != 9) { firstOption = textIndexArr[indx] + 1; @@ -324,7 +323,7 @@ bool KnowledgeCheck::show() { tmpStr = g_vm->getString(j); if ((int) tmpStr.size() > maxLength) maxLength = tmpStr.size(); - displayStr(tmpStr, 100, optionPosY, 100, 1, 0); + g_vm->_text.displayStr(tmpStr, 100, optionPosY, 100, 1, 0); choiceArray[prevChoice] = tmpStr; optionPosY += 8; } @@ -362,16 +361,16 @@ bool KnowledgeCheck::show() { if (coor[currChoice]._enabled) { if ((prevChoice != 0) && (prevChoice != currChoice)) { tmpStr = choiceArray[prevChoice] + '$'; - displayStr(tmpStr, 100, 27 + (prevChoice * 8), 100, 1, 0); + g_vm->_text.displayStr(tmpStr, 100, 27 + (prevChoice * 8), 100, 1, 0); } if (prevChoice != currChoice) { tmpStr = choiceArray[currChoice] + '$'; - displayStr(tmpStr, 100, 27 + (currChoice * 8), 100, 1, 1); + g_vm->_text.displayStr(tmpStr, 100, 27 + (currChoice * 8), 100, 1, 1); prevChoice = currChoice; } } else if (prevChoice != 0) { tmpStr = choiceArray[prevChoice] + '$'; - displayStr(tmpStr, 100, 27 + (prevChoice * 8), 100, 1, 0); + g_vm->_text.displayStr(tmpStr, 100, 27 + (prevChoice * 8), 100, 1, 0); prevChoice = 0; } } while (!((prevChoice != 0) && g_vm->getMouseClick())); @@ -420,7 +419,7 @@ void f3f8::draw() { * @remarks Originally called 'diver' */ void f3f8::checkForF8(int SpeechNum, bool drawAni50Fl) { - teskbd(); + g_vm->testKeyboard(); do { g_vm->_speechManager.startSpeech(SpeechNum, 0, 0); g_vm->_key = waitForF3F8(); @@ -442,7 +441,7 @@ int f3f8::waitForF3F8() { int key; do { - key = testou(); + key = g_vm->testou(); if (g_vm->shouldQuit()) return key; } while ((key != 61) && (key != 66)); @@ -453,7 +452,7 @@ int f3f8::waitForF3F8() { void f3f8::aff50(bool drawAni50Fl) { g_vm->_caff = 50; g_vm->_maff = 0; - taffich(); + g_vm->_text.taffich(); g_vm->draw(kAdrDes, 63, 12); if (drawAni50Fl) ani50(); diff --git a/engines/mortevielle/keyboard.cpp b/engines/mortevielle/keyboard.cpp deleted file mode 100644 index 699bd5a7bd..0000000000 --- a/engines/mortevielle/keyboard.cpp +++ /dev/null @@ -1,71 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * 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. - * - * 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, - * 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. - * - */ - -/* - * This code is based on original Mortville Manor DOS source code - * Copyright (c) 1988-1989 Lankhor - */ - -#include "mortevielle/mortevielle.h" -#include "mortevielle/keyboard.h" -#include "mortevielle/var_mor.h" - -namespace Mortevielle { - -char readkey1() { - char c = g_vm->getChar(); - - return c; -} - -int testou() { - char ch = g_vm->getChar(); - - switch (ch) { - case '\23' : - g_vm->_soundOff = !g_vm->_soundOff; - break; - case '\26' : - if ((g_vm->_c_zzz == 1) || (g_vm->_c_zzz == 2)) { - g_vm->decodeNumber(&g_vm->_cfiecBuffer[161 * 16], ((822 * 128) - (161 * 16)) / 64); - ++g_vm->_c_zzz; - - return 61; - } - break; - case '\33' : - if (g_vm->keyPressed()) - ch = g_vm->getChar(); - break; - default: - break; - } - - return ord(ch); -} - -void teskbd() { - if (g_vm->keyPressed()) - testou(); -} - -} // End of namespace Mortevielle diff --git a/engines/mortevielle/keyboard.h b/engines/mortevielle/keyboard.h deleted file mode 100644 index 7b2510fe06..0000000000 --- a/engines/mortevielle/keyboard.h +++ /dev/null @@ -1,38 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * 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. - * - * 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, - * 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. - * - */ - -/* - * This code is based on original Mortville Manor DOS source code - * Copyright (c) 1988-1989 Lankhor - */ - -#ifndef MORTEVIELLE_KEYBOARD_H -#define MORTEVIELLE_KEYBOARD_H - -namespace Mortevielle { - -extern char readkey1(); -extern int testou(); -extern void teskbd(); - -} // End of namespace Mortevielle -#endif diff --git a/engines/mortevielle/module.mk b/engines/mortevielle/module.mk index fe02e1114f..8cad2b8ad0 100644 --- a/engines/mortevielle/module.mk +++ b/engines/mortevielle/module.mk @@ -5,7 +5,6 @@ MODULE_OBJS := \ detection.o \ dialogs.o \ graphics.o \ - keyboard.o \ menu.o \ mortevielle.o \ mouse.o \ diff --git a/engines/mortevielle/mortevielle.cpp b/engines/mortevielle/mortevielle.cpp index 6d1a949516..fec14739c3 100644 --- a/engines/mortevielle/mortevielle.cpp +++ b/engines/mortevielle/mortevielle.cpp @@ -30,7 +30,6 @@ #include "graphics/pixelformat.h" #include "mortevielle/mortevielle.h" #include "mortevielle/dialogs.h" -#include "mortevielle/keyboard.h" #include "mortevielle/menu.h" #include "mortevielle/mouse.h" #include "mortevielle/outtext.h" @@ -208,10 +207,10 @@ Common::ErrorCode MortevielleEngine::initialise() { _soundOff = false; _largestClearScreen = false; - teskbd(); + testKeyboard(); showConfigScreen(); _newGraphicalDevice = _currGraphicalDevice; - teskbd(); + testKeyboard(); if (_newGraphicalDevice != _currGraphicalDevice) _currGraphicalDevice = _newGraphicalDevice; hirs(); @@ -693,7 +692,7 @@ void MortevielleEngine::handleAction() { handleOpcode(); if ((_controlMenu == 0) && (! _loseGame) && (! _endGame)) { - taffich(); + g_vm->_text.taffich(); if (_okdes) { _okdes = false; dessin(); @@ -1706,7 +1705,7 @@ void MortevielleEngine::startDialog(int16 rep) { _mouse.hideMouse(); Common::String dialogStr = getString(rep + kDialogStringIndex); - displayStr(dialogStr, 230, 4, 65, 24, 5); + _text.displayStr(dialogStr, 230, 4, 65, 24, 5); f3f8::draw(); key = 0; @@ -2512,8 +2511,8 @@ void MortevielleEngine::showTitleScreen() { hirs(); repon(7, 2035); _caff = 51; - taffich(); - teskbd(); + _text.taffich(); + testKeyboard(); if (_newGraphicalDevice != _currGraphicalDevice) _currGraphicalDevice = _newGraphicalDevice; hirs(); @@ -2898,7 +2897,7 @@ void MortevielleEngine::text1(int x, int y, int nb, int m) { Common::String tmpStr = getString(m); if ((y == 182) && ((int) tmpStr.size() * co > nb * 6)) y = 176; - displayStr(tmpStr, x, y, nb, 20, _textColor); + _text.displayStr(tmpStr, x, y, nb, 20, _textColor); } void MortevielleEngine::repon(int f, int m) { @@ -2911,7 +2910,7 @@ void MortevielleEngine::repon(int f, int m) { _largestClearScreen = false; clearScreenType2(); - displayStr(tmpStr, 8, 176, 85, 3, 5); + _text.displayStr(tmpStr, 8, 176, 85, 3, 5); } else { modif(m); switch (f) { @@ -2940,7 +2939,7 @@ void MortevielleEngine::repon(int f, int m) { i = 5; Common::String tmpStr = getString(m); - displayStr(tmpStr, 80, 40, 60, 25, i); + _text.displayStr(tmpStr, 80, 40, 60, 25, i); if (m == 180) _coreVar._pourc[6] = '*'; @@ -3288,7 +3287,7 @@ void MortevielleEngine::dessin() { } void MortevielleEngine::afdes() { - taffich(); + _text.taffich(); dessin(); _okdes = false; } @@ -3424,38 +3423,38 @@ void MortevielleEngine::getSearchDescription(int objId) { } void MortevielleEngine::mennor() { - g_vm->_menu.menuUp(g_vm->_msg[3]); + _menu.menuUp(_msg[3]); } void MortevielleEngine::premtet() { - g_vm->draw(kAdrDes, 10, 80); - g_vm->_screenSurface.drawBox(18, 79, 155, 91, 15); + draw(kAdrDes, 10, 80); + _screenSurface.drawBox(18, 79, 155, 91, 15); } void MortevielleEngine::ajchai() { - int cy = kAcha + ((g_vm->_mchai - 1) * 10) - 1; + int cy = kAcha + ((_mchai - 1) * 10) - 1; int cx = 0; do { ++cx; - } while ((cx <= 9) && (g_vm->_tabdon[cy + cx] != 0)); + } while ((cx <= 9) && (_tabdon[cy + cx] != 0)); - if (g_vm->_tabdon[cy + cx] == 0) - g_vm->_tabdon[cy + cx] = g_vm->_coreVar._selectedObjectId; + if (_tabdon[cy + cx] == 0) + _tabdon[cy + cx] = _coreVar._selectedObjectId; else - g_vm->_crep = 192; + _crep = 192; } void MortevielleEngine::ajjer(int ob) { int cx = 0; do { ++cx; - } while ((cx <= 5) && (ord(g_vm->_coreVar._sjer[cx]) != 0)); + } while ((cx <= 5) && (ord(_coreVar._sjer[cx]) != 0)); - if (ord(g_vm->_coreVar._sjer[cx]) == 0) { - g_vm->_coreVar._sjer[(cx)] = chr(ob); - g_vm->_menu.setInventoryText(); + if (ord(_coreVar._sjer[cx]) == 0) { + _coreVar._sjer[(cx)] = chr(ob); + _menu.setInventoryText(); } else - g_vm->_crep = 139; + _crep = 139; } /** @@ -3463,77 +3462,77 @@ void MortevielleEngine::ajjer(int ob) { * @remarks Originally called 'quelquun' */ void MortevielleEngine::interactNPC() { - if (g_vm->_menu._menuDisplayed) - g_vm->_menu.eraseMenu(); + if (_menu._menuDisplayed) + _menu.eraseMenu(); - g_vm->endSearch(); - g_vm->_crep = 997; + endSearch(); + _crep = 997; L1: - if (!g_vm->_hiddenHero) { - if (g_vm->_crep == 997) - g_vm->_crep = 138; - g_vm->repon(2, g_vm->_crep); - if (g_vm->_crep == 138) - g_vm->_speechManager.startSpeech(5, 2, 1); + if (!_hiddenHero) { + if (_crep == 997) + _crep = 138; + repon(2, _crep); + if (_crep == 138) + _speechManager.startSpeech(5, 2, 1); else - g_vm->_speechManager.startSpeech(4, 4, 1); + _speechManager.startSpeech(4, 4, 1); - if (g_vm->_iouv == 0) - g_vm->_coreVar._faithScore += 2; - else if (g_vm->_coreVar._faithScore < 50) - g_vm->_coreVar._faithScore += 4; + if (_iouv == 0) + _coreVar._faithScore += 2; + else if (_coreVar._faithScore < 50) + _coreVar._faithScore += 4; else - g_vm->_coreVar._faithScore += 3 * (g_vm->_coreVar._faithScore / 10); - g_vm->exitRoom(); - g_vm->_menu.setDestinationText(LANDING); - int cx = g_vm->convertBitIndexToCharacterIndex(g_vm->_currBitIndex); - g_vm->_caff = 69 + cx; - g_vm->_crep = g_vm->_caff; - g_vm->_msg[3] = MENU_DISCUSS; - g_vm->_msg[4] = g_vm->_menu._discussMenu[cx]; - g_vm->_syn = true; - g_vm->_col = true; + _coreVar._faithScore += 3 * (_coreVar._faithScore / 10); + exitRoom(); + _menu.setDestinationText(LANDING); + int cx = convertBitIndexToCharacterIndex(_currBitIndex); + _caff = 69 + cx; + _crep = _caff; + _msg[3] = MENU_DISCUSS; + _msg[4] = _menu._discussMenu[cx]; + _syn = true; + _col = true; } else { - if (g_vm->getRandomNumber(1, 3) == 2) { - g_vm->_hiddenHero = false; - g_vm->_crep = 137; + if (getRandomNumber(1, 3) == 2) { + _hiddenHero = false; + _crep = 137; goto L1; } else { - g_vm->repon(2, 136); - int rand = (g_vm->getRandomNumber(0, 4)) - 2; - g_vm->_speechManager.startSpeech(3, rand, 1); - g_vm->clearScreenType2(); - g_vm->displayAloneText(); - g_vm->resetRoomVariables(MANOR_FRONT); - g_vm->affrep(); + repon(2, 136); + int rand = (getRandomNumber(0, 4)) - 2; + _speechManager.startSpeech(3, rand, 1); + clearScreenType2(); + displayAloneText(); + resetRoomVariables(MANOR_FRONT); + affrep(); } } - if (g_vm->_menu._menuDisplayed) - g_vm->_menu.drawMenu(); + if (_menu._menuDisplayed) + _menu.drawMenu(); } void MortevielleEngine::tsuiv() { int tbcl; - int cy = kAcha + ((g_vm->_mchai - 1) * 10) - 1; + int cy = kAcha + ((_mchai - 1) * 10) - 1; int cx = 0; do { ++cx; - ++g_vm->_cs; - int cl = cy + g_vm->_cs; - tbcl = g_vm->_tabdon[cl]; - } while ((tbcl == 0) && (g_vm->_cs <= 9)); - - if ((tbcl != 0) && (g_vm->_cs < 11)) { - ++g_vm->_is; - g_vm->_caff = tbcl; - g_vm->_crep = g_vm->_caff + 400; - if (g_vm->_currBitIndex != 0) - g_vm->_coreVar._faithScore += 2; + ++_cs; + int cl = cy + _cs; + tbcl = _tabdon[cl]; + } while ((tbcl == 0) && (_cs <= 9)); + + if ((tbcl != 0) && (_cs < 11)) { + ++_is; + _caff = tbcl; + _crep = _caff + 400; + if (_currBitIndex != 0) + _coreVar._faithScore += 2; } else { - g_vm->affrep(); - g_vm->endSearch(); + affrep(); + endSearch(); if (cx > 9) - g_vm->_crep = 131; + _crep = 131; } } @@ -3541,7 +3540,7 @@ void MortevielleEngine::tfleche() { bool qust; char touch; - if (g_vm->_num == 9999) + if (_num == 9999) return; fenat(chr(152)); @@ -3550,24 +3549,24 @@ void MortevielleEngine::tfleche() { touch = '\0'; do { - g_vm->_mouse.moveMouse(qust, touch); + _mouse.moveMouse(qust, touch); CHECK_QUIT; - if (g_vm->getMouseClick()) - inRect = (g_vm->_mouse._pos.x < 256 * g_vm->_res) && (g_vm->_mouse._pos.y < 176) && (g_vm->_mouse._pos.y > 12); - g_vm->prepareRoom(); - } while (!(qust || inRect || g_vm->_anyone)); + if (getMouseClick()) + inRect = (_mouse._pos.x < 256 * _res) && (_mouse._pos.y < 176) && (_mouse._pos.y > 12); + prepareRoom(); + } while (!(qust || inRect || _anyone)); if (qust && (touch == '\103')) - Alert::show(g_vm->_hintPctMessage, 1); - } while (!((touch == '\73') || ((touch == '\104') && (g_vm->_x != 0) && (g_vm->_y != 0)) || (g_vm->_anyone) || (inRect))); + Alert::show(_hintPctMessage, 1); + } while (!((touch == '\73') || ((touch == '\104') && (_x != 0) && (_y != 0)) || (_anyone) || (inRect))); if (touch == '\73') - g_vm->_keyPressedEsc = true; + _keyPressedEsc = true; if (inRect) { - g_vm->_x = g_vm->_mouse._pos.x; - g_vm->_y = g_vm->_mouse._pos.y; + _x = _mouse._pos.x; + _y = _mouse._pos.y; } } @@ -3580,92 +3579,92 @@ void MortevielleEngine::setCoordinates(int sx) { int ib; - g_vm->_num = 0; - g_vm->_crep = 999; + _num = 0; + _crep = 999; int a = 0; int atdon = amzon + 3; int cy = 0; - while (cy < g_vm->_caff) { - a += g_vm->_tabdon[atdon]; + while (cy < _caff) { + a += _tabdon[atdon]; atdon += 4; ++cy; } - if (g_vm->_tabdon[atdon] == 0) { - g_vm->_crep = 997; + if (_tabdon[atdon] == 0) { + _crep = 997; return; } a += kFleche; int cb = 0; for (cy = 0; cy <= (sx - 2); ++cy) { - ib = (g_vm->_tabdon[a + cb] << 8) + g_vm->_tabdon[(a + cb + 1)]; + ib = (_tabdon[a + cb] << 8) + _tabdon[(a + cb + 1)]; cb += (ib * 4) + 2; } - ib = (g_vm->_tabdon[a + cb] << 8) + g_vm->_tabdon[(a + cb + 1)]; + ib = (_tabdon[a + cb] << 8) + _tabdon[(a + cb + 1)]; if (ib == 0) { - g_vm->_crep = 997; + _crep = 997; return; } cy = 1; do { cb += 2; - sx = g_vm->_tabdon[a + cb] * g_vm->_res; - sy = g_vm->_tabdon[(a + cb + 1)]; + sx = _tabdon[a + cb] * _res; + sy = _tabdon[(a + cb + 1)]; cb += 2; - ix = g_vm->_tabdon[a + cb] * g_vm->_res; - iy = g_vm->_tabdon[(a + cb + 1)]; + ix = _tabdon[a + cb] * _res; + iy = _tabdon[(a + cb + 1)]; ++cy; - } while (!(((g_vm->_x >= sx) && (g_vm->_x <= ix) && (g_vm->_y >= sy) && (g_vm->_y <= iy)) || (cy > ib))); + } while (!(((_x >= sx) && (_x <= ix) && (_y >= sy) && (_y <= iy)) || (cy > ib))); - if ((g_vm->_x >= sx) && (g_vm->_x <= ix) && (g_vm->_y >= sy) && (g_vm->_y <= iy)) { - g_vm->_num = cy - 1; + if ((_x >= sx) && (_x <= ix) && (_y >= sy) && (_y <= iy)) { + _num = cy - 1; return; } - g_vm->_crep = 997; + _crep = 997; } void MortevielleEngine::treg(int objId) { - int mdes = g_vm->_caff; - g_vm->_caff = objId; + int mdes = _caff; + _caff = objId; - if (((g_vm->_caff > 29) && (g_vm->_caff < 33)) || (g_vm->_caff == 144) || (g_vm->_caff == 147) || (g_vm->_caff == 149) || (g_vm->_msg[4] == OPCODE_SLOOK)) { - g_vm->afdes(); - if ((g_vm->_caff > 29) && (g_vm->_caff < 33)) - g_vm->repon(2, g_vm->_caff); + if (((_caff > 29) && (_caff < 33)) || (_caff == 144) || (_caff == 147) || (_caff == 149) || (_msg[4] == OPCODE_SLOOK)) { + afdes(); + if ((_caff > 29) && (_caff < 33)) + repon(2, _caff); else - g_vm->repon(2, g_vm->_caff + 400); - g_vm->testKey(true); - g_vm->_caff = mdes; - g_vm->_msg[3] = 0; - g_vm->_crep = 998; + repon(2, _caff + 400); + testKey(true); + _caff = mdes; + _msg[3] = 0; + _crep = 998; } else { - g_vm->_obpart = true; - g_vm->_crep = g_vm->_caff + 400; - g_vm->_menu.setSearchMenu(); + _obpart = true; + _crep = _caff + 400; + _menu.setSearchMenu(); } } void MortevielleEngine::avpoing(int &objId) { - g_vm->_crep = 999; - if (g_vm->_coreVar._selectedObjectId != 0) - g_vm->ajjer(g_vm->_coreVar._selectedObjectId); + _crep = 999; + if (_coreVar._selectedObjectId != 0) + ajjer(_coreVar._selectedObjectId); - if (g_vm->_crep != 139) { - g_vm->displayItemInHand(objId + 400); - g_vm->_coreVar._selectedObjectId = objId; + if (_crep != 139) { + displayItemInHand(objId + 400); + _coreVar._selectedObjectId = objId; objId = 0; } } void MortevielleEngine::rechai(int &ch) { - int tmpPlace = g_vm->_coreVar._currPlace; + int tmpPlace = _coreVar._currPlace; - if (g_vm->_coreVar._currPlace == CRYPT) + if (_coreVar._currPlace == CRYPT) tmpPlace = CELLAR; - ch = g_vm->_tabdon[achai + (tmpPlace * 7) + g_vm->_num - 1]; + ch = _tabdon[achai + (tmpPlace * 7) + _num - 1]; } /** @@ -3673,9 +3672,9 @@ void MortevielleEngine::rechai(int &ch) { * @remarks Originally called 't23coul' */ int MortevielleEngine::checkLeaveSecretPassage() { - if (!g_vm->checkInventory(143)) { - g_vm->_crep = 1512; - g_vm->loseGame(); + if (!checkInventory(143)) { + _crep = 1512; + loseGame(); } return CELLAR; @@ -3684,17 +3683,52 @@ int MortevielleEngine::checkLeaveSecretPassage() { void MortevielleEngine::fenat(char ans) { int coul; - g_vm->_mouse.hideMouse(); - if (g_vm->_currGraphicalDevice == MODE_CGA) + _mouse.hideMouse(); + if (_currGraphicalDevice == MODE_CGA) coul = 2; - else if (g_vm->_currGraphicalDevice == MODE_HERCULES) + else if (_currGraphicalDevice == MODE_HERCULES) coul = 1; else coul = 12; - g_vm->_screenSurface.writeCharacter(Common::Point(306, 193), ord(ans), coul); - g_vm->_screenSurface.drawBox(300, 191, 16, 8, 15); - g_vm->_mouse.showMouse(); + _screenSurface.writeCharacter(Common::Point(306, 193), ord(ans), coul); + _screenSurface.drawBox(300, 191, 16, 8, 15); + _mouse.showMouse(); +} + +/** + * Test Keyboard + * @remarks Originally called 'teskbd' + */ +void MortevielleEngine::testKeyboard() { + if (keyPressed()) + testou(); +} + +int MortevielleEngine::testou() { + char ch = getChar(); + + switch (ch) { + case '\23' : + _soundOff = !_soundOff; + break; + case '\26' : + if ((_c_zzz == 1) || (_c_zzz == 2)) { + decodeNumber(&_cfiecBuffer[161 * 16], ((822 * 128) - (161 * 16)) / 64); + ++_c_zzz; + + return 61; + } + break; + case '\33' : + if (keyPressed()) + ch = getChar(); + break; + default: + break; + } + + return ord(ch); } void MortevielleEngine::sauvecr(int y, int dy) { diff --git a/engines/mortevielle/mortevielle.h b/engines/mortevielle/mortevielle.h index 6e55bebd7e..514b929a22 100644 --- a/engines/mortevielle/mortevielle.h +++ b/engines/mortevielle/mortevielle.h @@ -38,9 +38,32 @@ #include "mortevielle/saveload.h" #include "mortevielle/sound.h" #include "mortevielle/speech.h" +#include "mortevielle/outtext.h" namespace Mortevielle { +/*---------------------------------------------------------------------------*/ +/*------------------- MEMORY MAP ------------------------*/ +/*---------------------------------------------------------------------------*/ +/* The following is a list of physical addresses in memory currently used + * by the game. + * + * Address + * ------- + * 5000:0 - Music data + * 6000:0 - Decompressed current image + * 7000:0+ - Compressed images + * 7000:2 - 16 words representing palette map + * 7000:4138 - width, height, x/y offset of decoded image + */ + +#define ord(v) ((int) v) +#define chr(v) ((unsigned char) v) +#define lo(v) ((v) & 0xff) +#define hi(v) (((v) >> 8) & 0xff) +#define swap(v) (((lo(v)) << 8) | ((hi(v)) >> 8)) +#define odd(v) (((v) % 2) == 1) + // Debug channels enum { kMortevielleCore = 1 << 0, @@ -73,12 +96,6 @@ enum DataType { kGameStrings = 1 }; -static const int _actionMenu[12] = { OPCODE_NONE, - OPCODE_SHIDE, OPCODE_ATTACH, OPCODE_FORCE, OPCODE_SLEEP, - OPCODE_ENTER, OPCODE_CLOSE, OPCODE_KNOCK, OPCODE_EAT, - OPCODE_PLACE, OPCODE_OPEN, OPCODE_LEAVE -}; - #define SCREEN_WIDTH 640 #define SCREEN_HEIGHT 400 #define SCREEN_ORIG_HEIGHT 200 @@ -101,6 +118,51 @@ const int arep = 1314; const int amzon = 1650; const int arega = 0; +const int kMaxTi = 7975; +const int kMaxTd = 600; + +const int kDescriptionStringIndex = 0; // Unused +const int kInventoryStringIndex = 186; +const int kQuestionStringIndex = 247; +const int kDialogStringIndex = 292; +const int kMenuPlaceStringIndex = 435; +const int kMenuActionStringIndex = 476; +const int kMenuSelfStringIndex = 497; +const int kMenuSayStringIndex = 502; +const int kSecretPassageQuestionStringIndex = 510; // Unusued? +const int kMaxPatt = 20; + +const int OPCODE_NONE = 0; +enum verbs {OPCODE_ATTACH = 0x301, OPCODE_WAIT = 0x302, OPCODE_FORCE = 0x303, OPCODE_SLEEP = 0x304, OPCODE_LISTEN = 0x305, + OPCODE_ENTER = 0x306, OPCODE_CLOSE = 0x307, OPCODE_SEARCH = 0x308, OPCODE_KNOCK = 0x309, OPCODE_SCRATCH = 0x30a, + OPCODE_READ = 0x30b, OPCODE_EAT = 0x30c, OPCODE_PLACE = 0x30d, OPCODE_OPEN = 0x30e, OPCODE_TAKE = 0x30f, + OPCODE_LOOK = 0x310, OPCODE_SMELL = 0x311, OPCODE_SOUND = 0x312, OPCODE_LEAVE = 0x313, OPCODE_LIFT = 0x314, + OPCODE_TURN = 0x315, OPCODE_SHIDE = 0x401, OPCODE_SSEARCH = 0x402, OPCODE_SREAD = 0x403, OPCODE_SPUT = 0x404, + OPCODE_SLOOK = 0x405}; + +static const int _actionMenu[12] = { OPCODE_NONE, + OPCODE_SHIDE, OPCODE_ATTACH, OPCODE_FORCE, OPCODE_SLEEP, + OPCODE_ENTER, OPCODE_CLOSE, OPCODE_KNOCK, OPCODE_EAT, + OPCODE_PLACE, OPCODE_OPEN, OPCODE_LEAVE +}; + +/* +9 "A glance at the forbidden$", +18 "It's already open$", +26 "A photograph$", +27 "The coat of arms$", +*/ +enum places { + OWN_ROOM = 0, GREEN_ROOM = 1, PURPLE_ROOM = 2, TOILETS = 3, DARKBLUE_ROOM = 4, + BLUE_ROOM = 5, RED_ROOM = 6, BATHROOM = 7, GREEN_ROOM2 = 8, ROOM9 = 9, + DINING_ROOM = 10, BUREAU = 11, KITCHEN = 12, ATTIC = 13, CELLAR = 14, + LANDING = 15, CRYPT = 16, SECRET_PASSAGE = 17, ROOM18 = 18, MOUNTAIN = 19, + CHAPEL = 20, MANOR_FRONT = 21, MANOR_BACK = 22, INSIDE_WELL = 23, WELL = 24, + DOOR = 25, ROOM26 = 26, ROOM27 = 27 +}; + +enum GraphicModes { MODE_AMSTRAD1512 = 0, MODE_CGA = 1, MODE_EGA = 2, MODE_HERCULES = 3, MODE_TANDY = 4 }; + struct nhom { byte _id; /* number between 0 and 32 */ byte _hom[4]; @@ -144,15 +206,79 @@ private: const ADGameDescription *_gameDescription; Common::Stack _keypresses; uint32 _lastGameFrame; - bool _mouseClick; Common::Point _mousePos; - bool _inMainGameLoop; // Flag when the main game loop is active Common::StringArray _engineStrings; Common::StringArray _gameStrings; Pattern _patternArr[15]; int _menuOpcode; + bool _mouseClick; + bool _inMainGameLoop; // Flag when the main game loop is active + bool _quitGame; // Quit game flag. Originally called 'arret' + bool _endGame; // End game flag. Originally called 'solu' + bool _loseGame; // Lose game flag. Originally called 'perdu' + bool _txxFileFl; // Flag used to determine if texts are from the original files or from a DAT file + bool _roomPresenceLuc; + bool _roomPresenceIda; + bool _purpleRoomPresenceLeo; + bool _roomPresenceGuy; + bool _roomPresenceEva; + bool _roomPresenceMax; + bool _roomPresenceBob; + bool _roomPresencePat; + bool _toiletsPresenceBobMax; + bool _bathRoomPresenceBobMax; + bool _room9PresenceLeo; + bool _hiddenHero; + bool _heroSearching; + bool _keyPressedEsc; + bool _reloadCFIEC; + bool _col; + bool _syn; + bool _obpart; + bool _anyone; + bool _brt; + + int _textColor; + int _place; + int _manorDistance; + int _currBitIndex; + int _currDay; + int _currHour; + int _currHalfHour; + int _day; + int _hour; + int _minute; + int _mchai; + int _controlMenu; + int _startHour; + int _endHour; + Common::Point _stdPal[91][17]; + t_pcga _cgaPal[91]; + + int _c_zzz; + int _ment; + int _iouv; + int _dobj; + int _num; + int _cs; + int _prebru; + int _t; + int _x; + int _y; + int _jh; + int _mh; + + + Common::String _hintPctMessage; + byte _cfiecBuffer[822 * 128]; + byte _touv[8]; + int _nbrep[9]; + int _nbrepm[9]; + uint16 _inpBuffer[kMaxTi + 1]; + Hint _ntpBuffer[kMaxTd + 1]; + Common::ErrorCode initialise(); Common::ErrorCode loadMortDat(); void readStaticStrings(Common::File &f, int dataSize, DataType dataType); @@ -164,8 +290,6 @@ private: void mainGame(); void playGame(); void handleAction(); - void cinq_huit(char &c, int &idx, byte &pt, bool &the_end); - void copcha(); void displayCGAPattern(int n, Pattern p, nhom *pal); void loadPalette(); void loadTexts(); @@ -177,7 +301,122 @@ private: void palette(int v1); int checkLeoMaxRandomPresence(); void interactNPC(); + void initCaveOrCellar(); + void displayControlMenu(); + void displayItemInHand(int objId); + void resetRoomVariables(int roomId); + int getPresenceStats(int &rand, int cf, int roomId); + void setPresenceFlags(int roomId); + void testKey(bool d); + void exitRoom(); + void getReadDescription(int objId); + void getSearchDescription(int objId); + int checkLeaveSecretPassage(); + void changeGraphicalDevice(int newDevice); + void startDialog(int16 rep); + void endSearch(); + int convertCharacterIndexToBitIndex(int characterIndex); + int convertBitIndexToCharacterIndex(int bitIndex); + void clearScreenType1(); + void clearScreenType2(); + void clearScreenType3(); + void clearScreenType10(); + int getRandomNumber(int minval, int maxval); + void showMoveMenuAlert(); + void showConfigScreen(); + void decodeNumber(byte *pStart, int count); + void resetVariables(); + void music(); + void drawRightFrame(); + void prepareRoom(); + void drawClock(); + void checkManorDistance(); + void gotoManorFront(); + void gotoManorBack(); + void gotoDiningRoom(); + bool checkInventory(int objectId); + void loseGame(); + void floodedInWell(); + void displayDiningRoom(); + void startMusicOrSpeech(int so); + void setTextColor(int col); + void prepareScreenType1(); + void prepareScreenType2(); + void prepareScreenType3(); + void updateHour(int &day, int &hour, int &minute); + void getKnockAnswer(); + int getPresenceStatsGreenRoom(); + int getPresenceStatsPurpleRoom(); + int getPresenceStatsToilets(); + int getPresenceStatsBlueRoom(); + int getPresenceStatsRedRoom(); + int getPresenceStatsDiningRoom(int &hour); + int getPresenceStatsBureau(int &hour); + int getPresenceStatsKitchen(); + int getPresenceStatsAttic(); + int getPresenceStatsLanding(); + int getPresenceStatsChapel(int &hour); + int getPresenceBitIndex(int roomId); + void setPresenceGreenRoom(int roomId); + void setPresencePurpleRoom(); + void setPresenceBlueRoom(); + void setPresenceRedRoom(int roomId); + int setPresenceDiningRoom(int hour); + int setPresenceBureau(int hour); + int setPresenceKitchen(); + int setPresenceLanding(); + int setPresenceChapel(int hour); + void setRandomPresenceGreenRoom(int cf); + void setRandomPresencePurpleRoom(int cf); + void setRandomPresenceBlueRoom(int cf); + void setRandomPresenceRedRoom(int cf); + void setRandomPresenceRoom9(int cf); + void setRandomPresenceDiningRoom(int cf); + void setRandomPresenceBureau(int cf); + void setRandomPresenceKitchen(int cf); + void setRandomPresenceAttic(int cf); + void setRandomPresenceLanding(int cf); + void setRandomPresenceChapel(int cf); + void loadPlaces(); + void resetPresenceInRooms(int roomId); + void showPeoplePresent(int bitIndex); + int selectCharacters(int min, int max); + void fctMove(); + void fctTake(); + void fctInventoryTake(); + void fctLift(); + void fctRead(); + void fctSelfRead(); + void fctLook(); + void fctSelftLook(); + void fctSearch(); + void fctSelfSearch(); + void fctOpen(); + void fctPlace(); + void fctTurn(); + void fctSelfHide(); + void fctAttach(); + void fctClose(); + void fctKnock(); + void fctSelfPut(); + void fctListen(); + void fctEat(); + void fctEnter(); + void fctSleep(); + void fctForce(); + void fctLeave(); + void fctWait(); + void fctSound(); + void fctDiscuss(); + void fctSmell(); + void fctScratch(); + void endGame(); + void askRestart(); + void delay(int amount); + void handleOpcode(); + void cinq_huit(char &c, int &idx, byte &pt, bool &the_end); + void copcha(); void adzon(); void text1(int x, int y, int nb, int m); void modif(int &nu); @@ -188,90 +427,45 @@ private: void ajchai(); void tfleche(); void setCoordinates(int sx); + void ecr2(Common::String text); + void ecr3(Common::String text); + void init_nbrepm(); + void aniof(int ouf, int num); + void dessin(); + void afdes(); + void tlu(int af, int ob); + void affrep(); + void mennor(); + void ajjer(int ob); + void tsuiv(); + void treg(int objId); + void avpoing(int &objId); + void rechai(int &ch); + void fenat(char ans); public: - Common::String _hintPctMessage; Common::Point _prevPos; - - byte _tabdon[4001]; - byte _cfiecBuffer[822 * 128]; - int _fxxBuffer[108]; - byte _touv[8]; int _msg[5]; - int _nbrep[9]; - int _nbrepm[9]; - uint16 _inpBuffer[kMaxTi + 1]; - Hint _ntpBuffer[kMaxTd + 1]; - - bool _roomPresenceLuc; - bool _roomPresenceIda; - bool _purpleRoomPresenceLeo; - bool _roomPresenceGuy; - bool _roomPresenceEva; - bool _roomPresenceMax; - bool _roomPresenceBob; - bool _roomPresencePat; - bool _toiletsPresenceBobMax; - bool _bathRoomPresenceBobMax; - bool _room9PresenceLeo; + int _fxxBuffer[108]; + byte _tabdon[4001]; bool _soundOff; - bool _largestClearScreen; - bool _hiddenHero; - bool _heroSearching; - bool _keyPressedEsc; - bool _reloadCFIEC; - bool _blo; - bool _col; - bool _syn; - bool _obpart; bool _okdes; - bool _anyone; - bool _brt; - - int _textColor; - int _currGraphicalDevice; - int _newGraphicalDevice; - int _place; - int _manorDistance; - int _currBitIndex; - int _savedBitIndex; - int _currDay; - int _currHour; - int _currHalfHour; - int _day; - int _hour; - int _minute; - int _mchai; + bool _largestClearScreen; + int _currGraphicalDevice; + int _newGraphicalDevice; float _addFix; + int _savedBitIndex; + int _numpal; + int _key; SaveStruct _coreVar, _saveStruct; - Common::Point _stdPal[91][17]; - t_pcga _cgaPal[91]; - int _key; - int _controlMenu; - int _startHour; - int _endHour; - int _c_zzz; - int ptr_word; - byte _v_lieu[7][25]; - byte _is; - int _numpal; - int _ment; - int _iouv; - int _caff; int _maff; - int _dobj; - int _num; - int _crep; - int _cs; int _res; - int _prebru; - int _t; - int _x; - int _y; - int _jh; - int _mh; + int _caff; + int _crep; + byte _is; + byte _v_lieu[7][25]; // TODO: Replace the following with proper implementations, or refactor out the code using them byte _mem[65536 * 16]; @@ -285,11 +479,7 @@ public: SpeechManager _speechManager; Menu _menu; MouseHandler _mouse; - - bool _quitGame; // Quit game flag. Originally called 'arret' - bool _endGame; // End game flag. Originally called 'solu' - bool _loseGame; // Lose game flag. Originally called 'perdu' - bool _txxFileFl; // Flag used to determine if texts are from the original files or from a DAT file + TextHandler _text; MortevielleEngine(OSystem *system, const ADGameDescription *gameDesc); ~MortevielleEngine(); @@ -302,165 +492,33 @@ public: uint32 getGameFlags() const; Common::Language getLanguage() const; - bool keyPressed(); int getChar(); + bool keyPressed(); Common::Point getMousePos() const { return _mousePos; } void setMousePos(const Common::Point &pt); bool getMouseClick() const { return _mouseClick; } void setMouseClick(bool v) { _mouseClick = v; } - void delay(int amount); Common::String getEngineString(int idx) const { return _engineStrings[idx]; } Common::String getGameString(int idx) const { return _gameStrings[idx]; } - void handleOpcode(); - void endGame(); - void askRestart(); void gameLoaded(); - - void fctMove(); - void fctTake(); - void fctInventoryTake(); - void fctLift(); - void fctRead(); - void fctSelfRead(); - void fctLook(); - void fctSelftLook(); - void fctSearch(); - void fctSelfSearch(); - void fctOpen(); - void fctPlace(); - void fctTurn(); - void fctSelfHide(); - void fctAttach(); - void fctClose(); - void fctKnock(); - void fctSelfPut(); - void fctListen(); - void fctEat(); - void fctEnter(); - void fctSleep(); - void fctForce(); - void fctLeave(); - void fctWait(); - void fctSound(); - void fctDiscuss(); - void fctSmell(); - void fctScratch(); - - int getPresenceStatsGreenRoom(); - int getPresenceStatsPurpleRoom(); - int getPresenceStatsToilets(); - int getPresenceStatsBlueRoom(); - int getPresenceStatsRedRoom(); - int getPresenceStatsDiningRoom(int &hour); - int getPresenceStatsBureau(int &hour); - int getPresenceStatsKitchen(); - int getPresenceStatsAttic(); - int getPresenceStatsLanding(); - int getPresenceStatsChapel(int &hour); - int getPresenceBitIndex(int roomId); - void setPresenceGreenRoom(int roomId); - void setPresencePurpleRoom(); - void setPresenceBlueRoom(); - void setPresenceRedRoom(int roomId); - int setPresenceDiningRoom(int hour); - int setPresenceBureau(int hour); - int setPresenceKitchen(); - int setPresenceLanding(); - int setPresenceChapel(int hour); - void setRandomPresenceGreenRoom(int cf); - void setRandomPresencePurpleRoom(int cf); - void setRandomPresenceBlueRoom(int cf); - void setRandomPresenceRedRoom(int cf); - void setRandomPresenceRoom9(int cf); - void setRandomPresenceDiningRoom(int cf); - void setRandomPresenceBureau(int cf); - void setRandomPresenceKitchen(int cf); - void setRandomPresenceAttic(int cf); - void setRandomPresenceLanding(int cf); - void setRandomPresenceChapel(int cf); - - void loadPlaces(); void initGame(); - void resetPresenceInRooms(int roomId); - void showPeoplePresent(int bitIndex); - int selectCharacters(int min, int max); void displayAloneText(); - - void checkManorDistance(); - void gotoManorFront(); - void gotoManorBack(); - void gotoDiningRoom(); - bool checkInventory(int objectId); - void loseGame(); - void floodedInWell(); - void displayDiningRoom(); - void startMusicOrSpeech(int so); - void setTextColor(int col); - void prepareScreenType1(); - void prepareScreenType2(); - void prepareScreenType3(); - void updateHour(int &day, int &hour, int &minute); - void getKnockAnswer(); + void draw(int ad, int x, int y); void charToHour(); void hourToChar(); - - void changeGraphicalDevice(int newDevice); - void startDialog(int16 rep); - void endSearch(); - int convertCharacterIndexToBitIndex(int characterIndex); - int convertBitIndexToCharacterIndex(int bitIndex); - void clearScreenType1(); - void clearScreenType2(); - void clearScreenType3(); - void clearScreenType10(); - int getRandomNumber(int minval, int maxval); - void showMoveMenuAlert(); - void showConfigScreen(); - void decodeNumber(byte *pStart, int count); Common::String getString(int num); - void resetVariables(); void setPal(int n); - void music(); - void draw(int ad, int x, int y); - void drawRightFrame(); - void prepareRoom(); - void drawClock(); Common::String copy(const Common::String &s, int idx, size_t size); - void hirs(); - void initCaveOrCellar(); - void displayControlMenu(); - void displayItemInHand(int objId); - void displayEmptyHand(); - void resetRoomVariables(int roomId); - int getPresenceStats(int &rand, int cf, int roomId); - void setPresenceFlags(int roomId); + void testKeyboard(); int getPresence(int roomId); - void testKey(bool d); - void exitRoom(); - void getReadDescription(int objId); - void getSearchDescription(int objId); - int checkLeaveSecretPassage(); + void displayEmptyHand(); - void pictout(int seg, int dep, int x, int y); - int animof(int ouf, int num); + void hirs(); + int testou(); void repon(int f, int m); - void ecr2(Common::String text); - void ecr3(Common::String text); - void init_nbrepm(); - void aniof(int ouf, int num); - void dessin(); - void afdes(); - void tlu(int af, int ob); - void affrep(); - void mennor(); - void ajjer(int ob); - void tsuiv(); - void treg(int objId); - void avpoing(int &objId); - void rechai(int &ch); - void fenat(char ans); - + int animof(int ouf, int num); + void pictout(int seg, int dep, int x, int y); void sauvecr(int y, int dy); void charecr(int y, int dy); diff --git a/engines/mortevielle/mouse.cpp b/engines/mortevielle/mouse.cpp index e18090e1dd..ff50e8b882 100644 --- a/engines/mortevielle/mouse.cpp +++ b/engines/mortevielle/mouse.cpp @@ -69,7 +69,6 @@ void MouseHandler::hideMouse() { case MODE_AMSTRAD1512: { bool imp = odd(_pos.y); for (int i = 0; i <= 3; ++i) { - _port[0x3dd] = 1 << i; int k = 0; j = 0; do { @@ -87,12 +86,8 @@ void MouseHandler::hideMouse() { break; } case MODE_EGA: { - _port[0x3c4] = 2; - _port[0x3ce] = 8; - _port[0x3cf] = 255; int i = 0; do { - _port[0x3c5] = 1 << i; int k = 0; j = 0; do { @@ -167,7 +162,6 @@ void MouseHandler::showMouse() { for (i = 0; i <= 3; ++i) { j = 0; imp = odd(_pos.y); - _port[0x3de] = i; k = 0; do { if (imp) { @@ -184,10 +178,8 @@ void MouseHandler::showMouse() { break; } case MODE_EGA: - _port[0x3ce] = 4; l = 0; do { - _port[0x3cf] = l; k = 0; j = 0; do { diff --git a/engines/mortevielle/mouse.h b/engines/mortevielle/mouse.h index b570f8913c..efbb52aa49 100644 --- a/engines/mortevielle/mouse.h +++ b/engines/mortevielle/mouse.h @@ -36,8 +36,6 @@ class MouseHandler { private: int s_s[12][6]; int _counter; - // TODO: Replace the following with proper implementations, or refactor out the code using them - int _port[0xfff]; public: Common::Point _pos; diff --git a/engines/mortevielle/outtext.cpp b/engines/mortevielle/outtext.cpp index 35d42251b1..f53a7b2804 100644 --- a/engines/mortevielle/outtext.cpp +++ b/engines/mortevielle/outtext.cpp @@ -35,10 +35,11 @@ namespace Mortevielle { -typedef unsigned char uchar; -const byte _rang[16] = {15, 14, 11, 7, 13, 12, 10, 6, 9, 5, 3, 1, 2, 4, 8, 0}; - -static int l_motsuiv(int p, const char *ch, int &tab) { +/** + * Next word + * @remarks Originally called 'l_motsuiv' + */ +int TextHandler::nextWord(int p, const char *ch, int &tab) { int c = p; while ((ch[p] != ' ') && (ch[p] != '$') && (ch[p] != '@')) @@ -51,7 +52,7 @@ static int l_motsuiv(int p, const char *ch, int &tab) { * Engine function - Display Text * @remarks Originally called 'afftex' */ -void displayStr(Common::String inputStr, int x, int y, int dx, int dy, int typ) { +void TextHandler::displayStr(Common::String inputStr, int x, int y, int dx, int dy, int typ) { int tab; Common::String s; int i, j; @@ -87,7 +88,7 @@ void displayStr(Common::String inputStr, int x, int y, int dx, int dy, int typ) s += ' '; xc += tab; ++p; - if (l_motsuiv(p, inputStr.c_str(), tab) + xc > xf) { + if (nextWord(p, inputStr.c_str(), tab) + xc > xf) { g_vm->_screenSurface.drawString(s, typ); s = ""; xc = x; @@ -123,7 +124,11 @@ void displayStr(Common::String inputStr, int x, int y, int dx, int dy, int typ) } } -void chardes(Common::String filename, int32 skipSize, int length) { +/** + * Load DES file + * @remarks Originally called 'chardes' + */ +void TextHandler::loadDesFile(Common::String filename, int32 skipSize, int length) { Common::File f; if (!f.open(filename)) error("Missing file %s", filename.c_str()); @@ -150,7 +155,11 @@ void chardes(Common::String filename, int32 skipSize, int length) { g_vm->_mem[0x7000 * 16 + i - remainingSkipSize] = g_vm->_mem[0x6000 * 16 + i]; } -void charani(Common::String filename, int32 skipSize, int length) { +/** + * Load ANI file + * @remarks Originally called 'charani' + */ +void TextHandler::loadAniFile(Common::String filename, int32 skipSize, int length) { Common::File f; if (!f.open(filename)) error("Missing file - %s", filename.c_str()); @@ -177,7 +186,9 @@ void charani(Common::String filename, int32 skipSize, int length) { g_vm->_mem[kAdrAni * 16 + i - remainingSkipSize] = g_vm->_mem[0x6000 * 16 + i]; } -void taffich() { +void TextHandler::taffich() { + static const byte _rang[16] = {15, 14, 11, 7, 13, 12, 10, 6, 9, 5, 3, 1, 2, 4, 8, 0}; + byte tran1[] = { 121, 121, 138, 139, 120 }; byte tran2[] = { 150, 150, 152, 152, 100, 110, 159, 100, 100 }; @@ -295,7 +306,7 @@ void taffich() { g_vm->_maff = a; npal = a + 37; } - chardes(filename, lgt, handle); + loadDesFile(filename, lgt, handle); if (g_vm->_currGraphicalDevice == MODE_HERCULES) { for (int i = 0; i <= 15; ++i) { int palh = READ_LE_UINT16(&g_vm->_mem[(0x7000 * 16) + ((i + 1) << 1)]); @@ -330,7 +341,7 @@ void taffich() { filename = "AZZ.mor"; handle = 1260; } - charani(filename, lgt, handle); + loadAniFile(filename, lgt, handle); } g_vm->_mouse.showMouse(); if ((a < 27) && ((g_vm->_maff < 27) || (g_vm->_coreVar._currPlace == LANDING)) && (g_vm->_msg[4] != OPCODE_ENTER)) { diff --git a/engines/mortevielle/outtext.h b/engines/mortevielle/outtext.h index d27ca3edc9..3664fd6fa5 100644 --- a/engines/mortevielle/outtext.h +++ b/engines/mortevielle/outtext.h @@ -35,10 +35,15 @@ namespace Mortevielle { const int kAdrAni = 0x7314; -extern void displayStr(Common::String inputStr, int x, int y, int dx, int dy, int typ); -extern void chardes(Common::String filename, int32 passe, int long_); -extern void charani(Common::String filename, int32 skipSize, int length); -extern void taffich(); +class TextHandler { +private: + int nextWord(int p, const char *ch, int &tab); +public: + void displayStr(Common::String inputStr, int x, int y, int dx, int dy, int typ); + void loadDesFile(Common::String filename, int32 passe, int long_); + void loadAniFile(Common::String filename, int32 skipSize, int length); + void taffich(); +}; } // End of namespace Mortevielle #endif diff --git a/engines/mortevielle/var_mor.h b/engines/mortevielle/var_mor.h index 3086f9eb20..0e12c5f953 100644 --- a/engines/mortevielle/var_mor.h +++ b/engines/mortevielle/var_mor.h @@ -33,76 +33,6 @@ namespace Mortevielle { -/*---------------------------------------------------------------------------*/ -/*------------------- MEMORY MAP ------------------------*/ -/*---------------------------------------------------------------------------*/ -/* The following is a list of physical addresses in memory currently used - * by the game. - * - * Address - * ------- - * 5000:0 - Music data - * 6000:0 - Decompressed current image - * 7000:0+ - Compressed images - * 7000:2 - 16 words representing palette map - * 7000:4138 - width, height, x/y offset of decoded image - */ - - -/*---------------------------------------------------------------------------*/ -/*------------------------- DEFINES ----------------------------------*/ -/*---------------------------------------------------------------------------*/ - -#define ord(v) ((int) v) -#define chr(v) ((unsigned char) v) -#define lo(v) ((v) & 0xff) -#define hi(v) (((v) >> 8) & 0xff) -#define swap(v) (((lo(v)) << 8) | ((hi(v)) >> 8)) -#define odd(v) (((v) % 2) == 1) - -/*---------------------------------------------------------------------------*/ -/*------------------------- CONSTANTS ----------------------------------*/ -/*---------------------------------------------------------------------------*/ - -const int kMaxTi = 7975; -const int kMaxTd = 600; - -const int kDescriptionStringIndex = 0; // Unused -const int kInventoryStringIndex = 186; -const int kQuestionStringIndex = 247; -const int kDialogStringIndex = 292; -const int kMenuPlaceStringIndex = 435; -const int kMenuActionStringIndex = 476; -const int kMenuSelfStringIndex = 497; -const int kMenuSayStringIndex = 502; -const int kSecretPassageQuestionStringIndex = 510; // Unusued? -const int kMaxPatt = 20; - -const int OPCODE_NONE = 0; -enum verbs {OPCODE_ATTACH = 0x301, OPCODE_WAIT = 0x302, OPCODE_FORCE = 0x303, OPCODE_SLEEP = 0x304, OPCODE_LISTEN = 0x305, - OPCODE_ENTER = 0x306, OPCODE_CLOSE = 0x307, OPCODE_SEARCH = 0x308, OPCODE_KNOCK = 0x309, OPCODE_SCRATCH = 0x30a, - OPCODE_READ = 0x30b, OPCODE_EAT = 0x30c, OPCODE_PLACE = 0x30d, OPCODE_OPEN = 0x30e, OPCODE_TAKE = 0x30f, - OPCODE_LOOK = 0x310, OPCODE_SMELL = 0x311, OPCODE_SOUND = 0x312, OPCODE_LEAVE = 0x313, OPCODE_LIFT = 0x314, - OPCODE_TURN = 0x315, OPCODE_SHIDE = 0x401, OPCODE_SSEARCH = 0x402, OPCODE_SREAD = 0x403, OPCODE_SPUT = 0x404, - OPCODE_SLOOK = 0x405}; - -/* -9 "A glance at the forbidden$", -18 "It's already open$", -26 "A photograph$", -27 "The coat of arms$", -*/ -enum places { - OWN_ROOM = 0, GREEN_ROOM = 1, PURPLE_ROOM = 2, TOILETS = 3, DARKBLUE_ROOM = 4, - BLUE_ROOM = 5, RED_ROOM = 6, BATHROOM = 7, GREEN_ROOM2 = 8, ROOM9 = 9, - DINING_ROOM = 10, BUREAU = 11, KITCHEN = 12, ATTIC = 13, CELLAR = 14, - LANDING = 15, CRYPT = 16, SECRET_PASSAGE = 17, ROOM18 = 18, MOUNTAIN = 19, - CHAPEL = 20, MANOR_FRONT = 21, MANOR_BACK = 22, INSIDE_WELL = 23, WELL = 24, - DOOR = 25, ROOM26 = 26, ROOM27 = 27 -}; - -enum GraphicModes { MODE_AMSTRAD1512 = 0, MODE_CGA = 1, MODE_EGA = 2, MODE_HERCULES = 3, MODE_TANDY = 4 }; - struct Rect { int _x1, _x2, _y1, _y2; bool _enabled; -- cgit v1.2.3