aboutsummaryrefslogtreecommitdiff
path: root/engines/kyra
diff options
context:
space:
mode:
authorJohannes Schickel2008-03-16 14:32:49 +0000
committerJohannes Schickel2008-03-16 14:32:49 +0000
commitf0d54b451300088534071130e75c5a9a01bc89f5 (patch)
treed95a228af1db027e8d870f601885081db7aba08d /engines/kyra
parentc7175fac8dff38b8b49b30c42e3a57312cdb15ce (diff)
downloadscummvm-rg350-f0d54b451300088534071130e75c5a9a01bc89f5.tar.gz
scummvm-rg350-f0d54b451300088534071130e75c5a9a01bc89f5.tar.bz2
scummvm-rg350-f0d54b451300088534071130e75c5a9a01bc89f5.zip
Reworked skipFlag handling.
svn-id: r31143
Diffstat (limited to 'engines/kyra')
-rw-r--r--engines/kyra/kyra.cpp2
-rw-r--r--engines/kyra/kyra.h4
-rw-r--r--engines/kyra/kyra_v1.cpp1
-rw-r--r--engines/kyra/kyra_v1.h4
-rw-r--r--engines/kyra/kyra_v2.cpp67
-rw-r--r--engines/kyra/kyra_v2.h16
-rw-r--r--engines/kyra/scene_v2.cpp5
-rw-r--r--engines/kyra/sequences_v2.cpp41
-rw-r--r--engines/kyra/text_v2.cpp28
9 files changed, 98 insertions, 70 deletions
diff --git a/engines/kyra/kyra.cpp b/engines/kyra/kyra.cpp
index 57d3c37c39..7fd28dce05 100644
--- a/engines/kyra/kyra.cpp
+++ b/engines/kyra/kyra.cpp
@@ -53,8 +53,6 @@ KyraEngine::KyraEngine(OSystem *system, const GameFlags &flags)
_quitFlag = false;
- _skipFlag = false;
-
_trackMap = 0;
_trackMapSize = 0;
_lastMusicCommand = -1;
diff --git a/engines/kyra/kyra.h b/engines/kyra/kyra.h
index dbf0fdc680..b15e21df5b 100644
--- a/engines/kyra/kyra.h
+++ b/engines/kyra/kyra.h
@@ -163,7 +163,9 @@ protected:
bool textEnabled();
// game speed
- bool _skipFlag;
+ virtual bool skipFlag() const = 0;
+ virtual void resetSkipFlag(bool removeEvent = true) = 0;
+
uint16 _tickLength;
uint16 _gameSpeed;
diff --git a/engines/kyra/kyra_v1.cpp b/engines/kyra/kyra_v1.cpp
index f5b7f74946..a961807f10 100644
--- a/engines/kyra/kyra_v1.cpp
+++ b/engines/kyra/kyra_v1.cpp
@@ -48,6 +48,7 @@ namespace Kyra {
KyraEngine_v1::KyraEngine_v1(OSystem *system, const GameFlags &flags)
: KyraEngine(system, flags) {
+ _skipFlag = false;
_flags = flags;
_seq_Forest = _seq_KallakWriting = _seq_KyrandiaLogo = _seq_KallakMalcolm =
diff --git a/engines/kyra/kyra_v1.h b/engines/kyra/kyra_v1.h
index ac3f9960fe..fb336f5c65 100644
--- a/engines/kyra/kyra_v1.h
+++ b/engines/kyra/kyra_v1.h
@@ -292,6 +292,10 @@ protected:
void updateMousePointer(bool forceUpdate = false);
bool hasClickedOnExit(int xpos, int ypos);
+ bool _skipFlag;
+ bool skipFlag() const { return _skipFlag; }
+ void resetSkipFlag(bool removeEvent = true) { _skipFlag = false; }
+
// scene
// -> init
void loadSceneMsc();
diff --git a/engines/kyra/kyra_v2.cpp b/engines/kyra/kyra_v2.cpp
index 4c6ed10fdf..84c2cd1029 100644
--- a/engines/kyra/kyra_v2.cpp
+++ b/engines/kyra/kyra_v2.cpp
@@ -434,6 +434,8 @@ void KyraEngine_v2::runLoop() {
//if (queryGameFlag(0x1EE) && inputFlag)
// sub_13B19(inputFlag);
+
+ _system->delayMillis(10);
}
}
@@ -723,8 +725,21 @@ void KyraEngine_v2::updateMouse() {
void KyraEngine_v2::updateInput() {
Common::Event event;
- while (_eventMan->pollEvent(event))
- _eventList.push_back(event);
+ while (_eventMan->pollEvent(event)) {
+ switch (event.type) {
+ case Common::EVENT_QUIT:
+ _quitFlag = true;
+ break;
+
+ case Common::EVENT_LBUTTONUP:
+ _eventList.push_back(Event(event, true));
+ break;
+
+ default:
+ _eventList.push_back(event);
+ break;
+ }
+ }
}
int KyraEngine_v2::checkInput(Button *buttonList) {
@@ -738,15 +753,6 @@ int KyraEngine_v2::checkInput(Button *buttonList) {
switch (event.type) {
case Common::EVENT_KEYDOWN:
- if (event.kbd.keycode == Common::KEYCODE_RETURN) {
- // this doesn't make sure the mouse position is the same
- // as when RETURN was pressed, but it *should* work for now
- Common::Point pos = getMousePos();
- _mouseX = pos.x;
- _mouseY = pos.y;
- keys = 199;
- }
-
if (event.kbd.flags == Common::KBD_CTRL) {
if (event.kbd.keycode == 'd')
_debugger->attach();
@@ -762,10 +768,6 @@ int KyraEngine_v2::checkInput(Button *buttonList) {
breakLoop = true;
} break;
- case Common::EVENT_QUIT:
- _quitFlag = true;
- break;
-
default:
break;
}
@@ -779,7 +781,6 @@ int KyraEngine_v2::checkInput(Button *buttonList) {
_eventList.erase(_eventList.begin());
}
- _system->delayMillis(10);
return processButtonList(buttonList, keys | 0x8000);
}
@@ -788,6 +789,26 @@ void KyraEngine_v2::removeInputTop() {
_eventList.erase(_eventList.begin());
}
+bool KyraEngine_v2::skipFlag() const {
+ for (Common::List<Event>::const_iterator i = _eventList.begin(); i != _eventList.end(); ++i) {
+ if (i->causedSkip)
+ return true;
+ }
+ return false;
+}
+
+void KyraEngine_v2::resetSkipFlag(bool removeEvent) {
+ for (Common::List<Event>::iterator i = _eventList.begin(); i != _eventList.end(); ++i) {
+ if (i->causedSkip) {
+ if (removeEvent)
+ _eventList.erase(i);
+ else
+ i->causedSkip = false;
+ return;
+ }
+ }
+}
+
void KyraEngine_v2::delay(uint32 amount, bool updateGame, bool isMainLoop) {
uint32 start = _system->getMillis();
do {
@@ -796,11 +817,13 @@ void KyraEngine_v2::delay(uint32 amount, bool updateGame, bool isMainLoop) {
updateWithText();
else
update();
+ } else {
+ updateInput();
}
if (amount > 0 )
_system->delayMillis(amount > 10 ? 10 : amount);
- } while (!_skipFlag && _system->getMillis() < start + amount && !_quitFlag);
+ } while (!skipFlag() && _system->getMillis() < start + amount && !_quitFlag);
}
void KyraEngine_v2::cleanup() {
@@ -1500,9 +1523,9 @@ void KyraEngine_v2::processNewShapes(int unk1, int unk2) {
_scriptInterpreter->initScript(&_temporaryScriptState, &_temporaryScriptData);
_scriptInterpreter->startScript(&_temporaryScriptState, 1);
- _skipFlag = false;
+ resetSkipFlag();
- while (_scriptInterpreter->validScript(&_temporaryScriptState) && !_skipFlag) {
+ while (_scriptInterpreter->validScript(&_temporaryScriptState) && !skipFlag()) {
_temporaryScriptExecBit = false;
while (_scriptInterpreter->validScript(&_temporaryScriptState) && !_temporaryScriptExecBit)
_scriptInterpreter->runScript(&_temporaryScriptState);
@@ -1519,7 +1542,7 @@ void KyraEngine_v2::processNewShapes(int unk1, int unk2) {
uint32 delayEnd = _system->getMillis() + _newShapeDelay * _tickLength;
- while (!_skipFlag && _system->getMillis() < delayEnd) {
+ while (!skipFlag() && _system->getMillis() < delayEnd) {
// XXX skipFlag handling, unk1 seems to make a scene not skipable
if (_chatText)
@@ -1545,7 +1568,7 @@ void KyraEngine_v2::processNewShapes(int unk1, int unk2) {
updateCharacterAnim(0);
}
- _skipFlag = false;
+ resetSkipFlag();
_newShapeFlag = -1;
resetCharacterAnimDim();
@@ -1738,7 +1761,7 @@ void KyraEngine_v2::loadInvWsa(const char *filename, int run, int delayTime, int
_invWsa.timer = _system->getMillis();
if (run) {
- while (_invWsa.running && !_skipFlag && !_quitFlag) {
+ while (_invWsa.running && !skipFlag() && !_quitFlag) {
update();
//XXX delay?
}
diff --git a/engines/kyra/kyra_v2.h b/engines/kyra/kyra_v2.h
index 4f82556582..9365d3b8be 100644
--- a/engines/kyra/kyra_v2.h
+++ b/engines/kyra/kyra_v2.h
@@ -320,7 +320,21 @@ protected:
int _mouseX, _mouseY;
int _mouseState;
- Common::List<Common::Event> _eventList;
+
+ struct Event {
+ Common::Event event;
+ bool causedSkip;
+
+ Event() : event(), causedSkip(false) {}
+ Event(Common::Event e) : event(e), causedSkip(false) {}
+ Event(Common::Event e, bool skip) : event(e), causedSkip(skip) {}
+
+ operator Common::Event() const { return event; }
+ };
+ Common::List<Event> _eventList;
+
+ bool skipFlag() const;
+ void resetSkipFlag(bool removeEvent = true);
// gfx/animation specific
uint8 *_gamePlayBuffer;
diff --git a/engines/kyra/scene_v2.cpp b/engines/kyra/scene_v2.cpp
index 121b2a7dae..eda2122077 100644
--- a/engines/kyra/scene_v2.cpp
+++ b/engines/kyra/scene_v2.cpp
@@ -284,9 +284,8 @@ int KyraEngine_v2::trySceneChange(int *moveTable, int unk1, int updateChar) {
}
if (unk1) {
- // TODO: check this again
- int inputFlag = checkInput(0/*dword_324C5*/);
- if (inputFlag == 198 || inputFlag == 199) {
+ if (skipFlag()) {
+ resetSkipFlag(false);
running = false;
_unk4 = 1;
}
diff --git a/engines/kyra/sequences_v2.cpp b/engines/kyra/sequences_v2.cpp
index 24b09b9355..5dcae4f43e 100644
--- a/engines/kyra/sequences_v2.cpp
+++ b/engines/kyra/sequences_v2.cpp
@@ -74,7 +74,7 @@ void KyraEngine_v2::seq_playSequences(int startSeq, int endSeq) {
_seqEndTime = 0;
_menuChoice = 0;
- for (int seqNum = startSeq; seqNum <= endSeq && !((_skipFlag && allowSkip) || _quitFlag || (_abortIntroFlag && allowSkip) || _menuChoice); seqNum++) {
+ for (int seqNum = startSeq; seqNum <= endSeq && !((skipFlag() && allowSkip) || _quitFlag || (_abortIntroFlag && allowSkip) || _menuChoice); seqNum++) {
_screen->clearPage(0);
_screen->clearPage(8);
memcpy(_screen->getPalette(1), _screen->getPalette(0), 0x300);
@@ -127,7 +127,7 @@ void KyraEngine_v2::seq_playSequences(int startSeq, int endSeq) {
seq_sequenceCommand(_sequences[seqNum].startupCommand);
- if (!((_skipFlag && allowSkip) || _quitFlag || (_abortIntroFlag && allowSkip) || _menuChoice)) {
+ if (!((skipFlag() && allowSkip) || _quitFlag || (_abortIntroFlag && allowSkip) || _menuChoice)) {
_screen->copyPage(2, 0);
_screen->updateScreen();
}
@@ -161,7 +161,7 @@ void KyraEngine_v2::seq_playSequences(int startSeq, int endSeq) {
_seqWsaCurrentFrame = _sequences[seqNum].startFrame;
bool loop = true;
- while (loop && !((_skipFlag && allowSkip) || _quitFlag || (_abortIntroFlag && allowSkip) || _menuChoice)) {
+ while (loop && !((skipFlag() && allowSkip) || _quitFlag || (_abortIntroFlag && allowSkip) || _menuChoice)) {
_seqEndTime = _system->getMillis() + _seqFrameDelay * _tickLength;
if (_seqWsa || !_sequences[seqNum].callback)
@@ -185,16 +185,16 @@ void KyraEngine_v2::seq_playSequences(int startSeq, int endSeq) {
seq_processWSAs();
seq_processText();
- if ((_seqWsa || !_sequences[seqNum].callback) && !((_skipFlag && allowSkip) || _quitFlag || (_abortIntroFlag && allowSkip) || _menuChoice)) {
+ if ((_seqWsa || !_sequences[seqNum].callback) && !((skipFlag() && allowSkip) || _quitFlag || (_abortIntroFlag && allowSkip) || _menuChoice)) {
_screen->copyPage(2, 0);
_screen->updateScreen();
}
bool loop2 = true;
- while (loop2 && !((_skipFlag && allowSkip) || _quitFlag || (_abortIntroFlag && allowSkip) || _menuChoice)) {
+ while (loop2 && !((skipFlag() && allowSkip) || _quitFlag || (_abortIntroFlag && allowSkip) || _menuChoice)) {
if (_seqWsa) {
seq_processText();
- if (!((_skipFlag && allowSkip) || _quitFlag || (_abortIntroFlag && allowSkip) || _menuChoice)) {
+ if (!((skipFlag() && allowSkip) || _quitFlag || (_abortIntroFlag && allowSkip) || _menuChoice)) {
_screen->copyPage(2, 0);
_screen->updateScreen();
}
@@ -226,7 +226,7 @@ void KyraEngine_v2::seq_playSequences(int startSeq, int endSeq) {
} else {
_seqFrameDelay = _sequences[seqNum].frameDelay;
_seqEndTime = _system->getMillis() + _seqFrameDelay * _tickLength;
- while (!((_skipFlag && allowSkip) || _quitFlag || (_abortIntroFlag && allowSkip) || _menuChoice)) {
+ while (!((skipFlag() && allowSkip) || _quitFlag || (_abortIntroFlag && allowSkip) || _menuChoice)) {
uint32 starttime = _system->getMillis();
seq_processWSAs();
if (_sequences[seqNum].callback)
@@ -258,7 +258,7 @@ void KyraEngine_v2::seq_playSequences(int startSeq, int endSeq) {
dl = ct;
_seqEndTime = _system->getMillis() + dl;
- while (!((_skipFlag && allowSkip) || _quitFlag || (_abortIntroFlag && allowSkip) || _menuChoice)) {
+ while (!((skipFlag() && allowSkip) || _quitFlag || (_abortIntroFlag && allowSkip) || _menuChoice)) {
uint32 starttime = _system->getMillis();
seq_processWSAs();
@@ -281,16 +281,19 @@ void KyraEngine_v2::seq_playSequences(int startSeq, int endSeq) {
seq_resetAllTextEntries();
if (_flags.isDemo && seqNum == kSequenceDemoFisher) {
- _abortIntroFlag = _skipFlag = false;
+ _abortIntroFlag = false;
+ resetSkipFlag();
seqNum = kSequenceDemoVirgin;
} else if ((seqNum != kSequenceTitle && seqNum < kSequenceZanfaun &&
- (_abortIntroFlag || _skipFlag)) || seqNum == kSequenceZanfaun) {
- _abortIntroFlag = _skipFlag = false;
+ (_abortIntroFlag || skipFlag())) || seqNum == kSequenceZanfaun) {
+ _abortIntroFlag = false;
+ resetSkipFlag();
seqNum = kSequenceWestwood;
}
if (_menuChoice) {
- _abortIntroFlag = _skipFlag = false;
+ _abortIntroFlag = false;
+ resetSkipFlag();
if (_menuChoice == 2)
_menuChoice = 0;
}
@@ -2501,13 +2504,13 @@ void KyraEngine_v2::seq_displayScrollText(uint8 *data, const ScreenDim *d, int t
delayUntil(endTime);
- if ((cnt < 36) && ((d->sy + d->h) > (READ_LE_UINT16(&tmp[cnt * 11 + 2]) + tmp[cnt * 11 + 9])) && !_skipFlag) {
- _skipFlag=_skipFlag;
+ if ((cnt < 36) && ((d->sy + d->h) > (READ_LE_UINT16(&tmp[cnt * 11 + 2]) + tmp[cnt * 11 + 9])) && !skipFlag()) {
+ resetSkipFlag();
delay(_tickLength * 500);
cnt = 0;
}
- if (!cnt || _skipFlag)
+ if (!cnt || skipFlag())
loop = false;
}
@@ -2569,14 +2572,14 @@ void KyraEngine_v2::seq_showStarcraftLogo() {
_screen->fadeFromBlack();
for (int i = 1; i < endframe; i++) {
uint32 endTime = _system->getMillis() + 50;
- if (_skipFlag)
+ if (skipFlag())
break;
ci->displayFrame(i, 0);
_screen->copyPage(2, 0);
_screen->updateScreen();
delay(endTime - _system->getMillis());
}
- if(!_skipFlag) {
+ if(!skipFlag()) {
uint32 endTime = _system->getMillis() + 50;
ci->displayFrame(0, 0);
_screen->copyPage(2, 0);
@@ -2586,7 +2589,7 @@ void KyraEngine_v2::seq_showStarcraftLogo() {
_screen->fadeToBlack();
_screen->showMouse();
- _skipFlag = false;
+ resetSkipFlag();
delete ci;
}
@@ -2742,7 +2745,7 @@ void KyraEngine_v2::seq_makeBookAppear() {
do {
update();
- } while (_invWsa.timer > _system->getMillis() && !_skipFlag);
+ } while (_invWsa.timer > _system->getMillis() && !skipFlag());
}
closeInvWsa();
diff --git a/engines/kyra/text_v2.cpp b/engines/kyra/text_v2.cpp
index 675955d252..bd05672fc0 100644
--- a/engines/kyra/text_v2.cpp
+++ b/engines/kyra/text_v2.cpp
@@ -296,7 +296,7 @@ void KyraEngine_v2::objectChatWaitToFinish() {
bool running = true;
const uint32 endTime = _chatEndTime;
- _skipFlag = false;
+ resetSkipFlag();
while (running && !_quitFlag) {
if (!_scriptInterpreter->validScript(&_chatScriptState))
@@ -319,17 +319,9 @@ void KyraEngine_v2::objectChatWaitToFinish() {
while (_system->getMillis() < nextFrame && !_quitFlag) {
updateWithText();
- int inputFlag = checkInput(0);
- removeInputTop();
- if (inputFlag == 198 || inputFlag == 199) {
- //XXX
- _skipFlag = true;
- snd_stopVoice();
- }
-
const uint32 curTime = _system->getMillis();
- if ((textEnabled() && curTime > endTime) || (speechEnabled() && !textEnabled() && !snd_voiceIsPlaying()) || _skipFlag) {
- _skipFlag = false;
+ if ((textEnabled() && curTime > endTime) || (speechEnabled() && !textEnabled() && !snd_voiceIsPlaying()) || skipFlag()) {
+ resetSkipFlag();
nextFrame = curTime;
running = false;
}
@@ -634,25 +626,17 @@ void KyraEngine_v2::npcChatSequence(const char *str, int objectId, int vocHigh,
_chatVocHigh = _chatVocLow = -1;
}
- while (((textEnabled() && _chatEndTime > _system->getMillis()) || (speechEnabled() && snd_voiceIsPlaying())) && !(_quitFlag || _skipFlag)) {
+ while (((textEnabled() && _chatEndTime > _system->getMillis()) || (speechEnabled() && snd_voiceIsPlaying())) && !(_quitFlag || skipFlag())) {
if (!speechEnabled() && chatAnimEndTime > _system->getMillis() || speechEnabled() && snd_voiceIsPlaying()) {
_objectChatFinished = false;
- while (!_objectChatFinished && !_skipFlag) {
+ while (!_objectChatFinished && !skipFlag()) {
if (_currentTalkSections.TLKTim)
tim_processSequence(_currentTalkSections.TLKTim, 0);
else
_objectChatFinished = false;
updateWithText();
-
- int inputFlag = checkInput(0);
- removeInputTop();
- if (inputFlag == 198 || inputFlag == 199) {
- //XXX
- _skipFlag = true;
- snd_stopVoice();
- }
delay(10);
}
if (_currentTalkSections.TLKTim)
@@ -661,7 +645,7 @@ void KyraEngine_v2::npcChatSequence(const char *str, int objectId, int vocHigh,
updateWithText();
}
- _skipFlag = false;
+ resetSkipFlag();
if (_currentTalkSections.TLKTim) {
tim_releaseBuffer(_currentTalkSections.TLKTim);