From 9dd65e5ef3cf88f882e6a7d35bd50cb7a1de838c Mon Sep 17 00:00:00 2001 From: Strangerke Date: Fri, 16 Aug 2013 19:23:29 +0200 Subject: MORTEVIELLE: Put resolution scaler in a const, remove some dead code related to it --- engines/mortevielle/actions.cpp | 2 +- engines/mortevielle/dialogs.cpp | 30 +++++++------------------ engines/mortevielle/graphics.cpp | 13 ++--------- engines/mortevielle/menu.cpp | 44 +++++++++++++++---------------------- engines/mortevielle/mortevielle.cpp | 3 --- engines/mortevielle/mortevielle.h | 2 +- engines/mortevielle/mouse.cpp | 22 +++++++++---------- engines/mortevielle/outtext.cpp | 6 +---- engines/mortevielle/utils.cpp | 44 ++++++++++++------------------------- 9 files changed, 56 insertions(+), 110 deletions(-) diff --git a/engines/mortevielle/actions.cpp b/engines/mortevielle/actions.cpp index 2035f4307f..c06f19dadc 100644 --- a/engines/mortevielle/actions.cpp +++ b/engines/mortevielle/actions.cpp @@ -1408,7 +1408,7 @@ void MortevielleEngine::fctDiscuss() { return; _mouse.getMousePosition(x, y, click); - x *= (3 - _resolutionScaler); + x *= (3 - kResolutionScaler); if (x > 319) cx = 41; else diff --git a/engines/mortevielle/dialogs.cpp b/engines/mortevielle/dialogs.cpp index 55e73538d3..b8d197da2a 100644 --- a/engines/mortevielle/dialogs.cpp +++ b/engines/mortevielle/dialogs.cpp @@ -71,10 +71,7 @@ int DialogManager::show(const Common::String &msg, int n) { while ((alertStr[i + 1] != '\174') && (alertStr[i + 1] != '\135')) { ++i; displayStr += alertStr[i]; - if (_vm->_resolutionScaler == 2) - curPos.x -= 3; - else - curPos.x -= 5; + curPos.x -= 3; } _vm->_screenSurface.putxy(curPos.x, _vm->_screenSurface._textPos.y); _vm->_screenSurface._textPos.y += 6; @@ -95,12 +92,12 @@ int DialogManager::show(const Common::String &msg, int n) { int limit[3][3]; memset(&limit[0][0], 0, sizeof(int) * 3 * 3); - limit[1][1] = ((uint)(coldep) / 2) * _vm->_resolutionScaler; + limit[1][1] = ((uint)(coldep) / 2) * kResolutionScaler; limit[1][2] = limit[1][1] + 40; if (caseNumb == 1) { limit[2][1] = limit[2][2]; } else { - limit[2][1] = ((uint)(320 + ((uint)esp >> 1)) / 2) * _vm->_resolutionScaler; + limit[2][1] = ((uint)(320 + ((uint)esp >> 1)) / 2) * kResolutionScaler; limit[2][2] = (limit[2][1]) + 40; } _vm->_mouse.showMouse(); @@ -221,10 +218,7 @@ void DialogManager::decodeAlertDetails(Common::String inputStr, int &choiceNumb, } choiceListStr = Common::String(inputStr.c_str() + i); - if (_vm->_resolutionScaler == 2) - col *= 6; - else - col *= 10; + col *= 6; } void DialogManager::setPosition(int ji, int coldep, int esp) { @@ -302,11 +296,7 @@ bool DialogManager::showKnowledgeCheck() { _vm->_mouse.hideMouse(); _vm->clearScreen(); _vm->_mouse.showMouse(); - int dialogHeight; - if (_vm->_resolutionScaler == 1) - dialogHeight = 29; - else - dialogHeight = 23; + int dialogHeight = 23; _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); @@ -335,7 +325,7 @@ bool DialogManager::showKnowledgeCheck() { } for (int j = 1; j <= lastOption - firstOption + 1; ++j) { - coor[j]._rect = Common::Rect(45 * _vm->_resolutionScaler, 27 + j * 8, (maxLength * 3 + 55) * _vm->_resolutionScaler, 34 + j * 8); + coor[j]._rect = Common::Rect(45 * kResolutionScaler, 27 + j * 8, (maxLength * 3 + 55) * kResolutionScaler, 34 + j * 8); coor[j]._enabled = true; while ((int)choiceArray[j].size() < maxLength) { @@ -343,11 +333,7 @@ bool DialogManager::showKnowledgeCheck() { } } coor[lastOption - firstOption + 2]._enabled = false; - int rep; - if (_vm->_resolutionScaler == 1) - rep = 10; - else - rep = 6; + int rep = 6; _vm->_screenSurface.drawBox(80, 33, 40 + (maxLength * rep), (lastOption - firstOption) * 8 + 16, 15); rep = 0; @@ -477,7 +463,7 @@ void DialogManager::displayIntroFrame2() { _vm->displayPicture(&_vm->_curAnim[_vm->_crep], 63, 12); _vm->_crep = _vm->getAnimOffset(2, 1); _vm->displayPicture(&_vm->_curAnim[_vm->_crep], 63, 12); - _vm->_largestClearScreen = (_vm->_resolutionScaler == 1); + _vm->_largestClearScreen = false; _vm->handleDescriptionText(2, kDialogStringIndex + 143); } diff --git a/engines/mortevielle/graphics.cpp b/engines/mortevielle/graphics.cpp index a15195f616..daf7926438 100644 --- a/engines/mortevielle/graphics.cpp +++ b/engines/mortevielle/graphics.cpp @@ -1015,11 +1015,6 @@ void ScreenSurface::writeCharacter(const Common::Point &pt, unsigned char ch, in * simulate the original 640x400 surface, all Y values have to be doubled */ void ScreenSurface::drawBox(int x, int y, int dx, int dy, int col) { - if (_vm->_resolutionScaler == 1) { - x = (uint)x >> 1; - dx = (uint)dx >> 1; - } - Graphics::Surface destSurface = lockArea(Common::Rect(x, y * 2, x + dx, (y + dy) * 2)); destSurface.hLine(0, 0, dx, col); @@ -1078,11 +1073,7 @@ void ScreenSurface::drawString(const Common::String &l, int command) { _vm->_mouse.hideMouse(); Common::Point pt = _textPos; - int charWidth; - if (_vm->_resolutionScaler == 2) - charWidth = 6; - else - charWidth = 10; + int charWidth = 6; int x = pt.x + charWidth * l.size(); int color = 0; @@ -1118,7 +1109,7 @@ void ScreenSurface::drawString(const Common::String &l, int command) { * Gets the width in pixels of the specified string */ int ScreenSurface::getStringWidth(const Common::String &s) { - int charWidth = (_vm->_resolutionScaler == 2) ? 6 : 10; + int charWidth = 6; return s.size() * charWidth; } diff --git a/engines/mortevielle/menu.cpp b/engines/mortevielle/menu.cpp index f815f48a31..9e03e83127 100644 --- a/engines/mortevielle/menu.cpp +++ b/engines/mortevielle/menu.cpp @@ -271,7 +271,7 @@ void Menu::displayMenu() { _vm->_mouse.hideMouse(); _vm->_screenSurface.fillRect(7, Common::Rect(0, 0, 639, 10)); - int col = 28 * _vm->_resolutionScaler; + int col = 28 * kResolutionScaler; for (int charNum = 0; charNum < 6; charNum++) { // One character after the other int idx = 0; @@ -293,7 +293,7 @@ void Menu::displayMenu() { ++idx; } } - col += 48 * _vm->_resolutionScaler; + col += 48 * kResolutionScaler; } _vm->_mouse.showMouse(); } @@ -370,16 +370,12 @@ void Menu::util(Common::Point pos) { int ymx = (menuConstants[_msg3 - 1][3] << 3) + 16; int dxcar = menuConstants[_msg3 - 1][2]; - int xmn = (menuConstants[_msg3 - 1][0] << 2) * _vm->_resolutionScaler; + int xmn = (menuConstants[_msg3 - 1][0] << 2) * kResolutionScaler; - int ix; - if (_vm->_resolutionScaler == 1) - ix = 5; - else - ix = 3; - int xmx = dxcar * ix * _vm->_resolutionScaler + xmn + 2; + int charWidth = 6; + int xmx = dxcar * charWidth + xmn + 2; if ((pos.x > xmn) && (pos.x < xmx) && (pos.y < ymx) && (pos.y > 15)) { - ix = (((uint)pos.y >> 3) - 1) + (_msg3 << 8); + int ix = (((uint)pos.y >> 3) - 1) + (_msg3 << 8); if (ix != _msg4) { invert(1); _msg4 = ix; @@ -402,11 +398,7 @@ void Menu::menuDown(int ii) { int minX = menuConstants[ii - 1][0] << 3; int lineNum = menuConstants[ii - 1][3]; _vm->_mouse.hideMouse(); - int deltaX; - if (_vm->_resolutionScaler == 1) - deltaX = 10; - else - deltaX = 6; + 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 @@ -512,24 +504,24 @@ void Menu::updateMenu() { _vm->_prevPos = curPos; bool tes = (curPos.y < 11) - && ((curPos.x >= (28 * _vm->_resolutionScaler) && curPos.x <= (28 * _vm->_resolutionScaler + 24)) - || (curPos.x >= (76 * _vm->_resolutionScaler) && curPos.x <= (76 * _vm->_resolutionScaler + 24)) - || ((curPos.x > 124 * _vm->_resolutionScaler) && (curPos.x < 124 * _vm->_resolutionScaler + 24)) - || ((curPos.x > 172 * _vm->_resolutionScaler) && (curPos.x < 172 * _vm->_resolutionScaler + 24)) - || ((curPos.x > 220 * _vm->_resolutionScaler) && (curPos.x < 220 * _vm->_resolutionScaler + 24)) - || ((curPos.x > 268 * _vm->_resolutionScaler) && (curPos.x < 268 * _vm->_resolutionScaler + 24))); + && ((curPos.x >= (28 * kResolutionScaler) && curPos.x <= (28 * kResolutionScaler + 24)) + || (curPos.x >= (76 * kResolutionScaler) && curPos.x <= (76 * kResolutionScaler + 24)) + || ((curPos.x > 124 * kResolutionScaler) && (curPos.x < 124 * kResolutionScaler + 24)) + || ((curPos.x > 172 * kResolutionScaler) && (curPos.x < 172 * kResolutionScaler + 24)) + || ((curPos.x > 220 * kResolutionScaler) && (curPos.x < 220 * kResolutionScaler + 24)) + || ((curPos.x > 268 * kResolutionScaler) && (curPos.x < 268 * kResolutionScaler + 24))); if (tes) { int ix; - if (curPos.x < 76 * _vm->_resolutionScaler) + if (curPos.x < 76 * kResolutionScaler) ix = MENU_INVENTORY; - else if (curPos.x < 124 * _vm->_resolutionScaler) + else if (curPos.x < 124 * kResolutionScaler) ix = MENU_MOVE; - else if (curPos.x < 172 * _vm->_resolutionScaler) + else if (curPos.x < 172 * kResolutionScaler) ix = MENU_ACTION; - else if (curPos.x < 220 * _vm->_resolutionScaler) + else if (curPos.x < 220 * kResolutionScaler) ix = MENU_SELF; - else if (curPos.x < 268 * _vm->_resolutionScaler) + else if (curPos.x < 268 * kResolutionScaler) ix = MENU_DISCUSS; else ix = MENU_FILE; diff --git a/engines/mortevielle/mortevielle.cpp b/engines/mortevielle/mortevielle.cpp index fa5683d127..e958d0bada 100644 --- a/engines/mortevielle/mortevielle.cpp +++ b/engines/mortevielle/mortevielle.cpp @@ -178,9 +178,6 @@ Common::ErrorCode MortevielleEngine::initialize() { // Set up an intermediate screen surface _screenSurface.create(SCREEN_WIDTH, SCREEN_HEIGHT, Graphics::PixelFormat::createFormatCLUT8()); - // Set the screen mode - _resolutionScaler = 2; - _txxFileFl = false; // Load texts from TXX files loadTexts(); diff --git a/engines/mortevielle/mortevielle.h b/engines/mortevielle/mortevielle.h index 443f588141..c9eebe1347 100644 --- a/engines/mortevielle/mortevielle.h +++ b/engines/mortevielle/mortevielle.h @@ -115,6 +115,7 @@ const int kMenuSelfStringIndex = 497; const int kMenuSayStringIndex = 502; const int kMaxPatt = 20; +const int kResolutionScaler = 2; /* 9 "A glance at the forbidden$", 18 "It's already open$", @@ -427,7 +428,6 @@ public: int _caff; int _crep; - int _resolutionScaler; byte _destinationArray[7][25]; byte *_curPict; diff --git a/engines/mortevielle/mouse.cpp b/engines/mortevielle/mouse.cpp index dfc9ccd706..9eb4e129c0 100644 --- a/engines/mortevielle/mouse.cpp +++ b/engines/mortevielle/mouse.cpp @@ -65,8 +65,8 @@ void MouseHandler::showMouse() { * @remarks Originally called 'pos_mouse' */ void MouseHandler::setMousePosition(Common::Point newPos) { - if (newPos.x > 314 * _vm->_resolutionScaler) - newPos.x = 314 * _vm->_resolutionScaler; + if (newPos.x > 314 * kResolutionScaler) + newPos.x = 314 * kResolutionScaler; else if (newPos.x < 0) newPos.x = 0; if (newPos.y > 199) @@ -138,16 +138,16 @@ void MouseHandler::moveMouse(bool &funct, char &key) { cy = 190; break; case '9': - cx = 315 * _vm->_resolutionScaler; + cx = 315 * kResolutionScaler; cy = 1; break; case '3': cy = 190; - cx = 315 * _vm->_resolutionScaler; + cx = 315 * kResolutionScaler; break; case '5': cy = 100; - cx = 155 * _vm->_resolutionScaler; + cx = 155 * kResolutionScaler; break; case ' ': case '\15': @@ -201,27 +201,27 @@ void MouseHandler::moveMouse(bool &funct, char &key) { } break; case 'I': - cx = _vm->_resolutionScaler * 32; + cx = kResolutionScaler * 32; cy = 8; break; case 'D': - cx = 80 * _vm->_resolutionScaler; + cx = 80 * kResolutionScaler; cy = 8; break; case 'A': - cx = 126 * _vm->_resolutionScaler; + cx = 126 * kResolutionScaler; cy = 8; break; case 'S': - cx = 174 * _vm->_resolutionScaler; + cx = 174 * kResolutionScaler; cy = 8; break; case 'P': - cx = 222 * _vm->_resolutionScaler; + cx = 222 * kResolutionScaler; cy = 8; break; case 'F': - cx = _vm->_resolutionScaler * 270; + cx = kResolutionScaler * 270; cy = 8; break; case '\23': diff --git a/engines/mortevielle/outtext.cpp b/engines/mortevielle/outtext.cpp index 824684862a..4629a47c36 100644 --- a/engines/mortevielle/outtext.cpp +++ b/engines/mortevielle/outtext.cpp @@ -53,7 +53,6 @@ int TextHandler::nextWord(int p, const char *ch, int &tab) { * @remarks Originally called 'afftex' */ void TextHandler::displayStr(Common::String inputStr, int x, int y, int dx, int dy, int typ) { - int tab; Common::String s; int i, j; @@ -61,10 +60,7 @@ void TextHandler::displayStr(Common::String inputStr, int x, int y, int dx, int inputStr += '$'; _vm->_screenSurface.putxy(x, y); - if (_vm->_resolutionScaler == 1) - tab = 10; - else - tab = 6; + int tab = 6; dx *= 6; dy *= 6; int xc = x; diff --git a/engines/mortevielle/utils.cpp b/engines/mortevielle/utils.cpp index 465de4e3f5..375b2ef4d9 100644 --- a/engines/mortevielle/utils.cpp +++ b/engines/mortevielle/utils.cpp @@ -1679,19 +1679,12 @@ void MortevielleEngine::clearVerbBar() { * @remarks Originally called 'clsf10' */ void MortevielleEngine::clearUpperRightPart() { - int x1, x2; Common::String st; _mouse.hideMouse(); - if (_resolutionScaler == 1) { - x2 = 634; - x1 = 534; - } else { - x2 = 600; - x1 = 544; - } + // Clear ambiance description - _screenSurface.fillRect(15, Common::Rect(x1, 93, x2, 98)); + _screenSurface.fillRect(15, Common::Rect(600, 93, 544, 98)); if (_coreVar._faithScore < 33) st = getEngineString(S_COOL); else if (_coreVar._faithScore < 66) @@ -1699,7 +1692,7 @@ void MortevielleEngine::clearUpperRightPart() { else if (_coreVar._faithScore > 65) st = getEngineString(S_MALSAINE); - x1 = 580 - (_screenSurface.getStringWidth(st) / 2); + int x1 = 580 - (_screenSurface.getStringWidth(st) / 2); _screenSurface.putxy(x1, 92); _screenSurface.drawString(st, 4); @@ -2170,7 +2163,7 @@ void MortevielleEngine::showTitleScreen() { draw(0, 0); Common::String cpr = "COPYRIGHT 1989 : LANKHOR"; - _screenSurface.putxy(104 + 72 * _resolutionScaler, 185); + _screenSurface.putxy(104 + 72 * kResolutionScaler, 185); _screenSurface.drawString(cpr, 0); } @@ -2370,9 +2363,9 @@ void MortevielleEngine::drawClock() { _screenSurface.drawRectangle(578, 114, 6, 18); if (_minute == 0) - _screenSurface.drawLine(((uint)x >> 1) * _resolutionScaler, y, ((uint)x >> 1) * _resolutionScaler, (y - rg), 1); + _screenSurface.drawLine(((uint)x >> 1) * kResolutionScaler, y, ((uint)x >> 1) * kResolutionScaler, (y - rg), 1); else - _screenSurface.drawLine(((uint)x >> 1) * _resolutionScaler, y, ((uint)x >> 1) * _resolutionScaler, (y + rg), 1); + _screenSurface.drawLine(((uint)x >> 1) * kResolutionScaler, y, ((uint)x >> 1) * kResolutionScaler, (y + rg), 1); int hour12 = _hour; if (hour12 > 12) @@ -2380,7 +2373,7 @@ void MortevielleEngine::drawClock() { if (hour12 == 0) hour12 = 12; - _screenSurface.drawLine(((uint)x >> 1) * _resolutionScaler, y, ((uint)(x + cv[0][hour12 - 1]) >> 1) * _resolutionScaler, y + cv[1][hour12 - 1], 1); + _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); @@ -2512,14 +2505,8 @@ int MortevielleEngine::getAnimOffset(int frameNum, int animNum) { * @remarks Originally called 'text1' */ void MortevielleEngine::displayTextInDescriptionBar(int x, int y, int nb, int mesgId) { - int co; - - if (_resolutionScaler == 1) - co = 10; - else - co = 6; Common::String tmpStr = getString(mesgId); - if ((y == 182) && ((int) tmpStr.size() * co > nb * 6)) + if ((y == 182) && ((int) tmpStr.size() > nb)) y = 176; _text.displayStr(tmpStr, x, y, nb, 20, _textColor); } @@ -2532,7 +2519,7 @@ void MortevielleEngine::handleDescriptionText(int f, int mesgId) { if ((mesgId > 499) && (mesgId < 563)) { Common::String tmpStr = getString(mesgId - 501 + kInventoryStringIndex); - if ((int) tmpStr.size() > ((58 + (_resolutionScaler - 1) * 37) << 1)) + if ((int) tmpStr.size() > ((58 + (kResolutionScaler - 1) * 37) << 1)) _largestClearScreen = true; else _largestClearScreen = false; @@ -2641,7 +2628,7 @@ void MortevielleEngine::resetOpenObjects() { void MortevielleEngine::displayTextBlock(Common::String text) { // Some dead code was present in the original: removed _screenSurface.putxy(8, 177); - int tlig = 59 + (_resolutionScaler - 1) * 36; + int tlig = 59 + (kResolutionScaler - 1) * 36; if ((int)text.size() < tlig) _screenSurface.drawString(text, 5); @@ -2867,10 +2854,7 @@ int MortevielleEngine::getPresence(int roomId) { * @remarks Originally called 'writetp' */ void MortevielleEngine::displayQuestionText(Common::String s, int cmd) { - if (_resolutionScaler == 2) - _screenSurface.drawString(s, cmd); - else - _screenSurface.drawString(copy(s, 1, 25), cmd); + _screenSurface.drawString(s, cmd); } /** @@ -3239,7 +3223,7 @@ void MortevielleEngine::displayStatusArrow() { return; if (getMouseClick()) - inRect = (_mouse._pos.x < 256 * _resolutionScaler) && (_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)); @@ -3296,10 +3280,10 @@ void MortevielleEngine::setCoordinates(int sx) { cy = 1; do { cb += 2; - sx = _tabdon[a + cb] * _resolutionScaler; + sx = _tabdon[a + cb] * kResolutionScaler; sy = _tabdon[(a + cb + 1)]; cb += 2; - ix = _tabdon[a + cb] * _resolutionScaler; + ix = _tabdon[a + cb] * kResolutionScaler; iy = _tabdon[(a + cb + 1)]; ++cy; } while (!(((_x >= sx) && (_x <= ix) && (_y >= sy) && (_y <= iy)) || (cy > ib))); -- cgit v1.2.3