2021-03-24 09:14:53 +01:00
|
|
|
/* 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.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2021-04-22 22:25:37 +01:00
|
|
|
#include "trecision/graphics.h"
|
|
|
|
#include "trecision/nl/define.h"
|
2021-04-13 22:39:12 +01:00
|
|
|
#include "trecision/nl/proto.h"
|
2021-03-24 09:14:53 +01:00
|
|
|
#include "trecision/nl/message.h"
|
|
|
|
#include "trecision/trecision.h"
|
|
|
|
|
|
|
|
namespace Trecision {
|
|
|
|
|
2021-04-13 22:39:12 +01:00
|
|
|
void SScriptFrame::sendFrame() {
|
|
|
|
doEvent(_class, _event, MP_DEFAULT, _u16Param1, _u16Param2, _u8Param, _u32Param);
|
|
|
|
}
|
2021-04-22 00:34:38 +01:00
|
|
|
|
2021-04-08 22:25:19 +01:00
|
|
|
void TrecisionEngine::endScript() {
|
2021-03-24 09:14:53 +01:00
|
|
|
_curStack--;
|
|
|
|
if (_curStack == 0) {
|
|
|
|
_flagscriptactive = false;
|
2021-04-22 22:25:37 +01:00
|
|
|
showCursor();
|
2021-03-24 09:14:53 +01:00
|
|
|
redrawString();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-08 22:25:19 +01:00
|
|
|
void TrecisionEngine::playScript(uint16 id) {
|
2021-03-24 09:14:53 +01:00
|
|
|
_curStack++;
|
|
|
|
_flagscriptactive = true;
|
2021-04-22 22:25:37 +01:00
|
|
|
hideCursor();
|
2021-04-08 22:25:19 +01:00
|
|
|
_curScriptFrame[_curStack] = _script[id]._firstFrame;
|
2021-03-24 09:14:53 +01:00
|
|
|
|
2021-04-08 22:19:12 +01:00
|
|
|
SScriptFrame *curFrame = &_scriptFrame[_curScriptFrame[_curStack]];
|
2021-03-24 09:14:53 +01:00
|
|
|
// If the event is empty, terminate the script
|
2021-04-14 02:56:08 +03:00
|
|
|
if (curFrame->isEmptyEvent()) {
|
2021-04-08 22:25:19 +01:00
|
|
|
endScript();
|
2021-03-24 09:14:53 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool loop = true;
|
|
|
|
while (loop) {
|
|
|
|
loop = false;
|
2021-04-08 22:19:12 +01:00
|
|
|
curFrame = &_scriptFrame[_curScriptFrame[_curStack]];
|
|
|
|
SScriptFrame *nextFrame = &_scriptFrame[_curScriptFrame[_curStack] + 1];
|
2021-03-24 09:14:53 +01:00
|
|
|
curFrame->sendFrame();
|
2021-04-14 02:56:08 +03:00
|
|
|
if (curFrame->_noWait && !nextFrame->isEmptyEvent()) {
|
2021-04-08 22:19:12 +01:00
|
|
|
_curScriptFrame[_curStack]++;
|
2021-03-24 09:14:53 +01:00
|
|
|
loop = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-08 22:25:19 +01:00
|
|
|
void TrecisionEngine::evalScript() {
|
2021-04-08 22:19:12 +01:00
|
|
|
if (_characterQueue.testEmptyCharacterQueue4Script() && _gameQueue.testEmptyQueue(MC_DIALOG) && _flagScreenRefreshed) {
|
|
|
|
_curScriptFrame[_curStack]++;
|
2021-04-22 22:25:37 +01:00
|
|
|
hideCursor();
|
2021-03-24 09:14:53 +01:00
|
|
|
|
2021-04-08 22:19:12 +01:00
|
|
|
SScriptFrame *curFrame = &_scriptFrame[_curScriptFrame[_curStack]];
|
2021-04-14 02:56:08 +03:00
|
|
|
if (curFrame->isEmptyEvent()) {
|
2021-04-08 22:25:19 +01:00
|
|
|
endScript();
|
2021-03-24 09:14:53 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool loop = true;
|
|
|
|
while (loop) {
|
|
|
|
loop = false;
|
2021-04-08 22:19:12 +01:00
|
|
|
curFrame = &_scriptFrame[_curScriptFrame[_curStack]];
|
|
|
|
SScriptFrame *nextFrame = &_scriptFrame[_curScriptFrame[_curStack] + 1];
|
2021-03-24 09:14:53 +01:00
|
|
|
curFrame->sendFrame();
|
2021-04-14 02:56:08 +03:00
|
|
|
if (curFrame->_noWait && !nextFrame->isEmptyEvent()) {
|
2021-04-08 22:19:12 +01:00
|
|
|
_curScriptFrame[_curStack]++;
|
2021-03-24 09:14:53 +01:00
|
|
|
loop = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-25 23:33:23 +01:00
|
|
|
bool TrecisionEngine::quitGame() {
|
2021-04-22 22:25:37 +01:00
|
|
|
for (int a = 0; a < TOP; a++)
|
|
|
|
memcpy(_zBuffer + a * MAXX, _screenBuffer + MAXX * a, MAXX * 2);
|
|
|
|
|
|
|
|
for (int a = 0; a < TOP; a++)
|
|
|
|
memset(_screenBuffer + MAXX * a, 0, MAXX * 2);
|
|
|
|
|
|
|
|
SDText SText;
|
2021-04-27 00:15:53 +03:00
|
|
|
SText.set(
|
|
|
|
Common::Rect(0, TOP - 20, MAXX, CARHEI + (TOP - 20)),
|
|
|
|
Common::Rect(0, 0, MAXX, CARHEI),
|
|
|
|
MOUSECOL,
|
|
|
|
MASKCOL,
|
|
|
|
_sysText[kMessageConfirmExit]
|
|
|
|
);
|
2021-04-22 22:25:37 +01:00
|
|
|
SText.DText();
|
|
|
|
|
|
|
|
_graphicsMgr->copyToScreen(0, 0, MAXX, TOP);
|
|
|
|
|
2021-04-25 23:33:23 +01:00
|
|
|
freeKey();
|
2021-04-22 22:25:37 +01:00
|
|
|
|
|
|
|
checkSystem();
|
|
|
|
|
|
|
|
char ch = waitKey();
|
|
|
|
|
|
|
|
bool exitFl = ((ch == 'y') || (ch == 'Y'));
|
|
|
|
|
|
|
|
for (int a = 0; a < TOP; a++)
|
|
|
|
memcpy(_screenBuffer + MAXX * a, _zBuffer + a * MAXX, MAXX * 2);
|
|
|
|
|
|
|
|
_graphicsMgr->copyToScreen(0, 0, MAXX, TOP);
|
|
|
|
|
|
|
|
return exitFl;
|
|
|
|
}
|
|
|
|
|
2021-04-25 23:33:23 +01:00
|
|
|
void TrecisionEngine::demoOver() {
|
2021-04-22 22:25:37 +01:00
|
|
|
for (int a = 0; a < TOP; a++)
|
|
|
|
memset(_screenBuffer + MAXX * a, 0, MAXX * 2);
|
|
|
|
|
|
|
|
SDText SText;
|
2021-04-27 00:15:53 +03:00
|
|
|
SText.set(
|
|
|
|
Common::Rect(0, TOP - 20, MAXX, CARHEI + (TOP - 20)),
|
|
|
|
Common::Rect(0, 0, MAXX, CARHEI),
|
|
|
|
MOUSECOL,
|
|
|
|
MASKCOL,
|
|
|
|
_sysText[kMessageDemoOver]
|
2021-04-27 00:36:12 +03:00
|
|
|
);
|
2021-04-22 22:25:37 +01:00
|
|
|
SText.DText();
|
|
|
|
|
|
|
|
_graphicsMgr->copyToScreen(0, 0, MAXX, TOP);
|
|
|
|
|
2021-04-25 23:33:23 +01:00
|
|
|
freeKey();
|
2021-04-22 22:25:37 +01:00
|
|
|
waitKey();
|
|
|
|
quitGame();
|
|
|
|
}
|
|
|
|
|
2021-03-24 09:14:53 +01:00
|
|
|
} // End of namespace Trecision
|