diff --git a/engines/trecision/nl/3d/3dinc.h b/engines/trecision/nl/3d/3dinc.h index 73740b96247..98c948d9da6 100644 --- a/engines/trecision/nl/3d/3dinc.h +++ b/engines/trecision/nl/3d/3dinc.h @@ -218,7 +218,6 @@ void initSortPan(); int panCompare(const void *arg1, const void *arg2); void sortPanel(); void actorOrder(); -char waitKey(); } // End of namespace Trecision diff --git a/engines/trecision/nl/classes.cpp b/engines/trecision/nl/classes.cpp index ce7c5a2cd9a..0ee4fb1e76e 100644 --- a/engines/trecision/nl/classes.cpp +++ b/engines/trecision/nl/classes.cpp @@ -373,7 +373,7 @@ void doSystem() { /* doIdle */ /*-------------------------------------------------------------------------*/ void doIdle() { - char c = GetKey(); + char c = g_vm->GetKey(); switch (c) { // Quit case 'q': diff --git a/engines/trecision/nl/dialog.cpp b/engines/trecision/nl/dialog.cpp index f03fbbf9af2..c7d22eb4de5 100644 --- a/engines/trecision/nl/dialog.cpp +++ b/engines/trecision/nl/dialog.cpp @@ -38,7 +38,7 @@ int16 CurPos, LastPos; void DialogPrint(int x, int y, int c, const char *txt) { SDText curChoice; - curChoice.set(x, y, TextLength(txt, 0), 0, 0, 0, MAXX, MAXY, c, MASKCOL, txt); + curChoice.set(x, y, g_vm->TextLength(txt, 0), 0, 0, 0, MAXX, MAXY, c, MASKCOL, txt); curChoice.DText(); } @@ -241,7 +241,10 @@ void afterChoice(int numframe) { g_vm->_obj[oCHIAVI54]._mode |= OBJMODE_OBJSTATUS; g_vm->_obj[od54ALLA55]._mode |= OBJMODE_OBJSTATUS; break; + default: + break; } + // If the player chose to exit the dialog if (g_vm->_choice[_curChoice]._flag & DLGCHOICE_EXITDLG) { g_vm->_animMgr->stopFullMotion(); @@ -487,6 +490,9 @@ void afterChoice(int numframe) { case dFCRED: doEvent(MC_SYSTEM, ME_QUIT, MP_SYSTEM, 0, 0, 0, 0); break; + + default: + break; } return; } diff --git a/engines/trecision/nl/do.cpp b/engines/trecision/nl/do.cpp index 37d3f1bb67e..aa4201805ad 100644 --- a/engines/trecision/nl/do.cpp +++ b/engines/trecision/nl/do.cpp @@ -332,7 +332,6 @@ void doScript() { } } - /* -----------------26/11/97 10.38------------------- * GestioneATFrame * --------------------------------------------------*/ diff --git a/engines/trecision/nl/extern.h b/engines/trecision/nl/extern.h index 454842516f8..a7481e0ecba 100644 --- a/engines/trecision/nl/extern.h +++ b/engines/trecision/nl/extern.h @@ -50,8 +50,8 @@ extern struct SSortTable SortTable[]; /* VARIE */ /*-------------------------------------------------------------------------*/ extern uint32 TheTime; -extern uint32 CharacterSpeakTime; -extern uint32 SomeOneSpeakTime; +extern uint32 _characterSpeakTime; +extern uint32 _someoneSpeakTime; /*-------------------------------------------------------------------------*/ /* DIALOGHI */ diff --git a/engines/trecision/nl/globvar.cpp b/engines/trecision/nl/globvar.cpp index 5e58ff98ae4..b4e65c1dc4d 100644 --- a/engines/trecision/nl/globvar.cpp +++ b/engines/trecision/nl/globvar.cpp @@ -49,8 +49,8 @@ SSortTable SortTable[200]; /* VARIE */ /*-------------------------------------------------------------------------*/ uint32 TheTime; -uint32 CharacterSpeakTime; -uint32 SomeOneSpeakTime; +uint32 _characterSpeakTime; +uint32 _someoneSpeakTime; /*-------------------------------------------------------------------------*/ /* DIALOGHI */ diff --git a/engines/trecision/nl/ll/llinc.h b/engines/trecision/nl/ll/llinc.h index 364db0d700b..c4a5c25d9d6 100644 --- a/engines/trecision/nl/ll/llinc.h +++ b/engines/trecision/nl/ll/llinc.h @@ -106,7 +106,6 @@ extern uint8 TextStatus; int Compare(const void *p1, const void *p2); void RedrawRoom(); void FreeKey(); -uint16 TextLength(const char *text, uint16 num); bool DataSave(); bool DataLoad(); bool QuitGame(); diff --git a/engines/trecision/nl/ll/llmouse.cpp b/engines/trecision/nl/ll/llmouse.cpp index 0e59ff0ced3..7d2d9db3f29 100644 --- a/engines/trecision/nl/ll/llmouse.cpp +++ b/engines/trecision/nl/ll/llmouse.cpp @@ -20,6 +20,8 @@ * */ +#include + #include "common/scummsys.h" #include "common/translation.h" #include "common/config-manager.h" @@ -43,22 +45,6 @@ namespace Trecision { uint16 BlinkLastDTextChar = MASKCOL; -/*-----------------17/02/95 09.53------------------- - TextLength - Compute string length from character 0 to num ---------------------------------------------------*/ -uint16 TextLength(const char *text, uint16 num) { - if (text == nullptr) - return 0; - - uint16 len = (num == 0) ? strlen(text) : num; - - uint16 retVal = 0; - for (uint16 c = 0; c < len; c++) - retVal += g_vm->_font[(uint8)text[c] * 3 + 2]; - - return retVal; -} - void SDText::set(SDText org) { set(org.x, org.y, org.dx, org.dy, org._subtitleRect.left, org._subtitleRect.top, org._subtitleRect.right, org._subtitleRect.bottom, org.tcol, org.scol, org.text); } @@ -88,7 +74,7 @@ uint16 SDText::checkDText() { return 0; uint8 curLine = 0; - if (TextLength(text, 0) <= dx) { + if (g_vm->TextLength(text, 0) <= dx) { strcpy((char *)DTextLines[curLine], text); return CARHEI; } @@ -101,9 +87,9 @@ uint16 SDText::checkDText() { while (a < strlen(text)) { a++; if (text[a] == ' ') { - if (TextLength(text + curInit, a - curInit) <= dx) + if (g_vm->TextLength(text + curInit, a - curInit) <= dx) lastSpace = a; - else if (TextLength(text + curInit, lastSpace - curInit) <= dx) { + else if (g_vm->TextLength(text + curInit, lastSpace - curInit) <= dx) { uint16 b; for (b = curInit; b < lastSpace; b++) DTextLines[curLine][b - curInit] = text[b]; @@ -118,7 +104,7 @@ uint16 SDText::checkDText() { } else return 0; } else if (text[a] == '\0') { - if (TextLength(text + curInit, a - curInit) <= dx) { + if (g_vm->TextLength(text + curInit, a - curInit) <= dx) { uint16 b; for (b = curInit; b < a; b++) DTextLines[curLine][b - curInit] = text[b]; @@ -129,7 +115,7 @@ uint16 SDText::checkDText() { return tmpDy; } - if (TextLength(text + curInit, lastSpace - curInit) <= dx) { + if (g_vm->TextLength(text + curInit, lastSpace - curInit) <= dx) { uint16 b; for (b = curInit; b < lastSpace; b++) DTextLines[curLine][b - curInit] = text[b]; @@ -173,17 +159,17 @@ void SDText::DText(uint16 *frameBuffer) { uint16 curDy = checkDText(); for (uint16 b = 0; b < (curDy / CARHEI); b++) { - char *text = (char *)DTextLines[b]; - uint16 inc = (dx - TextLength(text, 0)) / 2; - uint16 len = strlen(text); + char *curText = (char *)DTextLines[b]; + uint16 inc = (dx - g_vm->TextLength(curText, 0)) / 2; + uint16 len = strlen(curText); if (len >= MAXCHARS) { - strcpy(text, g_vm->_sysText[kMessageError]); - len = strlen(text); + strcpy(curText, g_vm->_sysText[kMessageError]); + len = strlen(curText); } for (uint16 c = 0; c < len; c++) { - byte curChar = text[c]; /* legge prima parte del font */ + byte curChar = curText[c]; /* legge prima parte del font */ const uint16 charOffset = g_vm->_font[curChar * 3] + (uint16)(g_vm->_font[curChar * 3 + 1] << 8); uint16 fontDataOffset = 768; @@ -383,7 +369,7 @@ insave: for (;;) { g_vm->checkSystem(); - GetKey(); + g_vm->GetKey(); int16 mx = g_vm->_mouseX; int16 my = g_vm->_mouseY; @@ -400,7 +386,7 @@ insave: memset(g_vm->_screenBuffer + MAXX * a, 0, MAXX * 2); posx = ICONMARGSX + ((CurPos) * (ICONDX)) + ICONDX / 2; - LenText = TextLength(saveNames[CurPos].c_str(), 0); + LenText = g_vm->TextLength(saveNames[CurPos].c_str(), 0); posx = CLIP(posx - (LenText / 2), 2, MAXX - 2 - LenText); SText.set(posx, FIRSTLINE + ICONDY + 10, LenText, CARHEI, 0, 0, LenText, CARHEI, 0x7FFF, MASKCOL, saveNames[CurPos].c_str()); @@ -442,7 +428,7 @@ insave: for (;;) { g_vm->_keybInput = true; g_vm->checkSystem(); - ch = GetKey(); + ch = g_vm->GetKey(); FreeKey(); g_vm->_keybInput = false; @@ -470,7 +456,7 @@ insave: saveNames[CurPos] += '_'; // add blinking cursor posx = ICONMARGSX + ((CurPos) * (ICONDX)) + ICONDX / 2; - LenText = TextLength(saveNames[CurPos].c_str(), 0); + LenText = g_vm->TextLength(saveNames[CurPos].c_str(), 0); posx = CLIP(posx - (LenText / 2), 2, MAXX - 2 - LenText); SText.set(posx, FIRSTLINE + ICONDY + 10, LenText, CARHEI, 0, 0, LenText, CARHEI, 0x7FFF, MASKCOL, saveNames[CurPos].c_str()); @@ -580,8 +566,7 @@ bool DataLoad() { for (;;) { g_vm->checkSystem(); - - GetKey(); + g_vm->GetKey(); if (g_vm->_mouseY >= FIRSTLINE && g_vm->_mouseY < (FIRSTLINE + ICONDY) && @@ -595,7 +580,7 @@ bool DataLoad() { memset(g_vm->_screenBuffer + MAXX * a, 0, MAXX * 2); uint16 posX = ICONMARGSX + ((CurPos) * (ICONDX)) + ICONDX / 2; - uint16 lenText = TextLength(saveNames[CurPos].c_str(), 0); + uint16 lenText = g_vm->TextLength(saveNames[CurPos].c_str(), 0); if (posX - (lenText / 2) < 2) posX = 2; else @@ -697,7 +682,7 @@ bool QuitGame() { g_vm->checkSystem(); - char ch = waitKey(); + char ch = g_vm->waitKey(); bool exitFl = ((ch == 'y') || (ch == 'Y')); @@ -723,9 +708,7 @@ void DemoOver() { g_vm->_graphicsMgr->copyToScreen(0, 0, MAXX, TOP); FreeKey(); - - waitKey(); - + g_vm->waitKey(); g_vm->quitGame(); } diff --git a/engines/trecision/nl/proto.h b/engines/trecision/nl/proto.h index 0dfbbc12198..5ef6dc245f3 100644 --- a/engines/trecision/nl/proto.h +++ b/engines/trecision/nl/proto.h @@ -88,9 +88,8 @@ void CharacterContinueTalk(); void CharacterMute(); void SomeoneTalk(uint16 s, uint16 Person, uint16 NewAnim, bool FromSomeOneSay); void SomeoneContinueTalk(); -void SomeOneMute(); +void someoneMute(); void doString(); -char GetKey(); void soundtimefunct(); #endif diff --git a/engines/trecision/nl/string.cpp b/engines/trecision/nl/string.cpp index 9c06c914da9..441b04bf702 100644 --- a/engines/trecision/nl/string.cpp +++ b/engines/trecision/nl/string.cpp @@ -56,7 +56,7 @@ const char *dunno = "?"; /* PositionString */ /*-------------------------------------------------------------------------*/ void PositionString(uint16 x, uint16 y, const char *string, uint16 *posx, uint16 *posy, bool characterFl) { - uint16 lenText = TextLength(string, 0); + uint16 lenText = g_vm->TextLength(string, 0); if (lenText > 960) lenText = (lenText * 2 / 5); else if (lenText > 320) @@ -118,7 +118,7 @@ void ShowObjName(uint16 obj, bool showhide) { } g_vm->_lastObj = (obj | 0x8000); - uint16 lenText = TextLength(locsent.c_str(), 0); + uint16 lenText = g_vm->TextLength(locsent.c_str(), 0); posx = CLIP(320 - (lenText / 2), 2, MAXX - 2 - lenText); posy = MAXY - CARHEI; @@ -267,7 +267,7 @@ void CharacterTalkInAction(uint16 ss) { /*-------------------------------------------------------------------------*/ void CharacterContinueTalk() { g_vm->_flagSkipTalk = false; - CharacterSpeakTime = TheTime; + _characterSpeakTime = TheTime; substringagain = (CurSubString < (SubStringUsed - 1)); @@ -304,7 +304,7 @@ void CharacterMute() { g_vm->_flagSomeoneSpeaks = false; g_vm->_flagCharacterSpeak = false; g_vm->_flagSkipTalk = false; - CharacterSpeakTime = 0L; + _characterSpeakTime = 0L; g_vm->clearText(); g_vm->_lastObj = 0; @@ -348,7 +348,7 @@ void SomeoneTalk(uint16 s, uint16 Person, uint16 NewAnim, bool FromSomeOneSay) { void SomeoneContinueTalk() { uint16 posx, posy; - SomeOneSpeakTime = TheTime; + _someoneSpeakTime = TheTime; g_vm->_flagSkipTalk = false; substringagain = (CurSubString < (SubStringUsed - 1)); @@ -376,13 +376,13 @@ void SomeoneContinueTalk() { } /*-------------------------------------------------------------------------*/ -/* SomeOneMute */ +/* someoneMute */ /*-------------------------------------------------------------------------*/ -void SomeOneMute() { +void someoneMute() { g_vm->_flagCharacterSpeak = false; g_vm->_flagSkipTalk = false; g_vm->_flagSomeoneSpeaks = false; - SomeOneSpeakTime = 0L; + _someoneSpeakTime = 0; g_vm->clearText(); g_vm->_lastObj = 0; @@ -403,7 +403,7 @@ void doString() { case ME_CHARACTERSPEAKING: if (g_vm->_flagCharacterSpeak) { - if (g_vm->_flagSkipTalk || (TheTime > TalkTime + CharacterSpeakTime)) { + if (g_vm->_flagSkipTalk || (TheTime > TalkTime + _characterSpeakTime)) { if (substringagain) CharacterContinueTalk(); else @@ -422,14 +422,14 @@ void doString() { case ME_SOMEONEWAIT2MUTE: if (!g_vm->_curMessage->_u16Param1) - SomeOneMute(); + someoneMute(); else REEVENT; break; case ME_SOMEONESPEAKING: if (g_vm->_flagSomeoneSpeaks) { - if (g_vm->_flagSkipTalk || (TheTime >= (TalkTime + SomeOneSpeakTime))) { + if (g_vm->_flagSkipTalk || (TheTime >= (TalkTime + _someoneSpeakTime))) { if (substringagain) SomeoneContinueTalk(); else { diff --git a/engines/trecision/nl/sys/main.cpp b/engines/trecision/nl/sys/main.cpp index 52e89bf36a2..2fa335c7353 100644 --- a/engines/trecision/nl/sys/main.cpp +++ b/engines/trecision/nl/sys/main.cpp @@ -30,51 +30,6 @@ namespace Trecision { -/*-----------------16/01/97 20.53------------------- - GetKey ---------------------------------------------------*/ -char GetKey() { - Common::KeyCode key = g_vm->_curKey; - uint16 ascii = g_vm->_curAscii; - g_vm->_curKey = Common::KEYCODE_INVALID; - g_vm->_curAscii = 0; - - switch (key) { - case Common::KEYCODE_SPACE: - case Common::KEYCODE_ESCAPE: - case Common::KEYCODE_RETURN: - case Common::KEYCODE_CLEAR: - case Common::KEYCODE_BACKSPACE: - return key; - case Common::KEYCODE_F1: - case Common::KEYCODE_F2: - case Common::KEYCODE_F3: - case Common::KEYCODE_F4: - case Common::KEYCODE_F5: - case Common::KEYCODE_F6: - return 0x3B + key - Common::KEYCODE_F1; - default: - if (ascii) { - return ascii; - } - - return 0; - } -} - -/*-----------------17/01/97 11.17------------------- - waitKey ---------------------------------------------------*/ -char waitKey() { - while (g_vm->_curKey == Common::KEYCODE_INVALID) - g_vm->checkSystem(); - - Common::KeyCode t = g_vm->_curKey; - g_vm->_curKey = Common::KEYCODE_INVALID; - - return t; -} - /*-----------------17/01/97 11.18------------------- FreeKey --------------------------------------------------*/ diff --git a/engines/trecision/nl/sys/sound.cpp b/engines/trecision/nl/sys/sound.cpp index 1869b4d1a52..9a34364f193 100644 --- a/engines/trecision/nl/sys/sound.cpp +++ b/engines/trecision/nl/sys/sound.cpp @@ -29,6 +29,7 @@ #include "common/system.h" #include "audio/decoders/wave.h" #include "audio/audiostream.h" +#include "trecision/nl/extern.h" namespace Trecision { @@ -331,9 +332,8 @@ int32 Talk(const char *name) { Audio::SeekableAudioStream *speechStream = Audio::makeWAVStream(stream, DisposeAfterUse::YES); - extern uint32 CharacterSpeakTime; g_system->getMixer()->playStream(Audio::Mixer::kSpeechSoundType, &soundHandle[kSoundChannelSpeech], speechStream); - CharacterSpeakTime = ReadTime(); + _characterSpeakTime = ReadTime(); return TIME(speechStream->getLength().msecs()); } diff --git a/engines/trecision/trecision.h b/engines/trecision/trecision.h index 3c2eba391cb..8b4cb581857 100644 --- a/engines/trecision/trecision.h +++ b/engines/trecision/trecision.h @@ -105,6 +105,9 @@ public: // Utils char *getNextSentence(); void setRoom(uint16 r, bool b); + uint16 TextLength(const char *text, uint16 num); + char GetKey(); + char waitKey(); // Text void addText(uint16 x, uint16 y, const char *text, uint16 tcol, uint16 scol); diff --git a/engines/trecision/utils.cpp b/engines/trecision/utils.cpp index f69855289ea..b701d5a8287 100644 --- a/engines/trecision/utils.cpp +++ b/engines/trecision/utils.cpp @@ -108,11 +108,11 @@ void TrecisionEngine::drawString() { /* redrawString */ /*-------------------------------------------------------------------------*/ void TrecisionEngine::redrawString() { - if (!_flagDialogActive && !_flagDialogMenuActive && !_flagSomeoneSpeaks && !_flagscriptactive && g_vm->isCursorVisible()) { - if (isInventoryArea(g_vm->_mouseY)) + if (!_flagDialogActive && !_flagDialogMenuActive && !_flagSomeoneSpeaks && !_flagscriptactive && isCursorVisible()) { + if (isInventoryArea(_mouseY)) doEvent(MC_INVENTORY, ME_SHOWICONNAME, MP_DEFAULT, 0, 0, 0, 0); else { - CheckMask(g_vm->_mouseX, g_vm->_mouseY); + CheckMask(_mouseX, _mouseY); ShowObjName(_curObj, true); } } @@ -124,7 +124,7 @@ void TrecisionEngine::redrawString() { void StackText::doText() { curString.x = x; curString.y = y; - curString.dx = TextLength(text, 0); + curString.dx = g_vm->TextLength(text, 0); if ((y == MAXY - CARHEI) && (curString.dx > 600)) curString.dx = curString.dx * 3 / 5; else if ((y != MAXY - CARHEI) && (curString.dx > 960)) @@ -173,4 +173,66 @@ void TrecisionEngine::setRoom(uint16 r, bool b) { RegenRoom(); } +/*-----------------17/02/95 09.53------------------- + TextLength - Compute string length from character 0 to num +--------------------------------------------------*/ +uint16 TrecisionEngine::TextLength(const char *text, uint16 num) { + if (text == nullptr) + return 0; + + uint16 len = (num == 0) ? strlen(text) : num; + + uint16 retVal = 0; + for (uint16 c = 0; c < len; c++) + retVal += _font[(uint8)text[c] * 3 + 2]; + + return retVal; +} + +/*-----------------16/01/97 20.53------------------- + GetKey +--------------------------------------------------*/ +char TrecisionEngine::GetKey() { + Common::KeyCode key = _curKey; + uint16 ascii = _curAscii; + _curKey = Common::KEYCODE_INVALID; + _curAscii = 0; + + switch (key) { + case Common::KEYCODE_SPACE: + case Common::KEYCODE_ESCAPE: + case Common::KEYCODE_RETURN: + case Common::KEYCODE_CLEAR: + case Common::KEYCODE_BACKSPACE: + return key; + case Common::KEYCODE_F1: + case Common::KEYCODE_F2: + case Common::KEYCODE_F3: + case Common::KEYCODE_F4: + case Common::KEYCODE_F5: + case Common::KEYCODE_F6: + return 0x3B + key - Common::KEYCODE_F1; + default: + if (ascii) { + return ascii; + } + + return 0; + } +} + +/*-----------------17/01/97 11.17------------------- + waitKey +--------------------------------------------------*/ +char TrecisionEngine::waitKey() { + while (_curKey == Common::KEYCODE_INVALID) + checkSystem(); + + Common::KeyCode t = _curKey; + _curKey = Common::KEYCODE_INVALID; + + return t; +} + + } // End of namespace Trecision