aboutsummaryrefslogtreecommitdiff
path: root/engines/kyra/kyra_lok.cpp
diff options
context:
space:
mode:
authorJohannes Schickel2008-12-16 17:40:34 +0000
committerJohannes Schickel2008-12-16 17:40:34 +0000
commit696ed52959e7853ff2039fb0ce1063cebb9a1cd2 (patch)
tree4e199ac773eb917ef0be0c8e5500ac36119d6138 /engines/kyra/kyra_lok.cpp
parent2706e527c214cfcc77502b3bdb639d5a341d3c1a (diff)
downloadscummvm-rg350-696ed52959e7853ff2039fb0ce1063cebb9a1cd2.tar.gz
scummvm-rg350-696ed52959e7853ff2039fb0ce1063cebb9a1cd2.tar.bz2
scummvm-rg350-696ed52959e7853ff2039fb0ce1063cebb9a1cd2.zip
Switched kyra1 to use the same input functionality as kyra2 and kyra3.
svn-id: r35393
Diffstat (limited to 'engines/kyra/kyra_lok.cpp')
-rw-r--r--engines/kyra/kyra_lok.cpp171
1 files changed, 46 insertions, 125 deletions
diff --git a/engines/kyra/kyra_lok.cpp b/engines/kyra/kyra_lok.cpp
index e7e0ff25e0..5829aeb10a 100644
--- a/engines/kyra/kyra_lok.cpp
+++ b/engines/kyra/kyra_lok.cpp
@@ -48,7 +48,6 @@ namespace Kyra {
KyraEngine_LoK::KyraEngine_LoK(OSystem *system, const GameFlags &flags)
: KyraEngine_v1(system, flags) {
- _skipFlag = false;
_seq_Forest = _seq_KallakWriting = _seq_KyrandiaLogo = _seq_KallakMalcolm =
_seq_MalcolmTree = _seq_WestwoodLogo = _seq_Demo1 = _seq_Demo2 = _seq_Demo3 =
@@ -220,8 +219,6 @@ Common::Error KyraEngine_LoK::init() {
memset(_flagsTable, 0, sizeof(_flagsTable));
- _abortWalkFlag = false;
- _abortWalkFlag2 = false;
_talkingCharNum = -1;
_charSayUnk3 = -1;
memset(_currSentenceColor, 0, 3);
@@ -247,12 +244,9 @@ Common::Error KyraEngine_LoK::init() {
assert(_movFacingTable);
_movFacingTable[0] = 8;
- _skipFlag = false;
-
_marbleVaseItem = -1;
memset(_foyerItemTable, -1, sizeof(_foyerItemTable));
_itemInHand = -1;
- _handleInput = false;
_currentRoom = 0xFFFF;
_scenePhasingFlag = 0;
@@ -279,8 +273,6 @@ Common::Error KyraEngine_LoK::init() {
_kyragemFadingState.gOffset = 0x13;
_kyragemFadingState.bOffset = 0x13;
- _mousePressFlag = false;
-
_menuDirectlyToLoad = false;
_lastMusicCommand = 0;
@@ -297,18 +289,23 @@ Common::Error KyraEngine_LoK::go() {
_abortIntroFlag = false;
if (_flags.isDemo) {
+ _seqPlayerFlag = true;
seq_demo();
+ _seqPlayerFlag = false;
} else {
setGameFlag(0xF3);
setGameFlag(0xFD);
if (_gameToLoad == -1) {
setGameFlag(0xEF);
+ _seqPlayerFlag = true;
seq_intro();
if (shouldQuit())
return Common::kNoError;
if (_skipIntroFlag && _abortIntroFlag)
resetGameFlag(0xEF);
+ _seqPlayerFlag = false;
}
+ _eventList.clear();
startup();
resetGameFlag(0xEF);
mainLoop();
@@ -403,9 +400,10 @@ void KyraEngine_LoK::startup() {
void KyraEngine_LoK::mainLoop() {
debugC(9, kDebugLevelMain, "KyraEngine_LoK::mainLoop()");
+ _eventList.clear();
+
while (!shouldQuit()) {
int32 frameTime = (int32)_system->getMillis();
- _skipFlag = false;
checkAutosave();
@@ -434,18 +432,24 @@ void KyraEngine_LoK::mainLoop() {
_brandonStatusBit0x20Flag = 0;
}
+ // FIXME: Why is this here?
_screen->showMouse();
- _gui->processButtonList(_buttonList, 0, 0);
+ int inputFlag = checkInput(_buttonList, true);
+ removeInputTop();
+
updateMousePointer();
_timer->update();
+ _sound->process();
updateTextFade();
- _handleInput = true;
- delay((frameTime + _gameSpeed) - _system->getMillis(), true, true);
- _handleInput = false;
+ if (inputFlag == 198 || inputFlag == 199)
+ processInput(_mouseX, _mouseY);
- _sound->process();
+ if (skipFlag())
+ resetSkipFlag();
+
+ delay((frameTime + _gameSpeed) - _system->getMillis(), true, true);
}
}
@@ -464,69 +468,9 @@ void KyraEngine_LoK::delay(uint32 amount, bool update, bool isMainLoop) {
uint32 start = _system->getMillis();
do {
- if (isMainLoop)
- _isSaveAllowed = true;
-
- while (_eventMan->pollEvent(event)) {
- _isSaveAllowed = false;
-
- switch (event.type) {
- case Common::EVENT_KEYDOWN:
- if (event.kbd.keycode >= '1' && event.kbd.keycode <= '9' &&
- (event.kbd.flags == Common::KBD_CTRL || event.kbd.flags == Common::KBD_ALT) && isMainLoop) {
- int saveLoadSlot = 9 - (event.kbd.keycode - '0') + 990;
-
- if (event.kbd.flags == Common::KBD_CTRL)
- loadGameStateCheck(saveLoadSlot);
- else {
- char savegameName[14];
- sprintf(savegameName, "Quicksave %d", event.kbd.keycode - '0');
- saveGameState(saveLoadSlot, savegameName, 0);
- }
- } else if (event.kbd.flags == Common::KBD_CTRL) {
- if (event.kbd.keycode == 'd')
- _debugger->attach();
- else if (event.kbd.keycode == 'q')
- quitGame();
- } else if (event.kbd.keycode == '.') {
- _skipFlag = true;
+ /*} else if (event.kbd.keycode == '.') {
} else if (event.kbd.keycode == Common::KEYCODE_RETURN || event.kbd.keycode == Common::KEYCODE_SPACE || event.kbd.keycode == Common::KEYCODE_ESCAPE) {
- _abortIntroFlag = true;
- _skipFlag = true;
- }
-
- break;
- case Common::EVENT_MOUSEMOVE:
- _animator->_updateScreen = true;
- break;
- case Common::EVENT_LBUTTONDOWN:
- _mousePressFlag = true;
- break;
- case Common::EVENT_LBUTTONUP:
- _mousePressFlag = false;
-
- if (_abortWalkFlag2)
- _abortWalkFlag = true;
-
- if (_handleInput) {
- _handleInput = false;
- processInput();
- _handleInput = true;
- } else
- _skipFlag = true;
-
- break;
- default:
- break;
- }
-
- if (isMainLoop)
- _isSaveAllowed = true;
- }
-
- if (_debugger->isAttached())
- _debugger->onFrame();
-
+ _abortIntroFlag = true;*/
if (update) {
_sprites->updateSceneAnims();
_animator->updateAllObjectShapes();
@@ -534,44 +478,33 @@ void KyraEngine_LoK::delay(uint32 amount, bool update, bool isMainLoop) {
updateMousePointer();
}
+ updateInput();
+
if (_currentCharacter && _currentCharacter->sceneId == 210 && update)
updateKyragemFading();
- if (_skipFlag && !_abortIntroFlag && !queryGameFlag(0xFE))
- _skipFlag = false;
-
- if (amount > 0 && !_skipFlag && !shouldQuit())
+ if (amount > 0 && !skipFlag() && !shouldQuit())
_system->delayMillis(10);
- if (_skipFlag)
- _sound->voiceStop();
- } while (!_skipFlag && _system->getMillis() < start + amount && !shouldQuit());
-}
-
-void KyraEngine_LoK::waitForEvent() {
- bool finished = false;
- Common::Event event;
-
- while (!finished && !shouldQuit()) {
- while (_eventMan->pollEvent(event)) {
- switch (event.type) {
- case Common::EVENT_KEYDOWN:
- finished = true;
- break;
- case Common::EVENT_LBUTTONDOWN:
- finished = true;
- _skipFlag = true;
- break;
- default:
- break;
+ // FIXME: Major hackery to allow skipping the intro
+ if (_seqPlayerFlag) {
+ for (Common::List<Event>::iterator i = _eventList.begin(); i != _eventList.end(); ++i) {
+ if (i->causedSkip) {
+ if (i->event.type == Common::EVENT_KEYDOWN && i->event.kbd.keycode == Common::KEYCODE_ESCAPE)
+ _abortIntroFlag = true;
+ else
+ i->causedSkip = false;
+ }
}
}
- if (_debugger->isAttached())
- _debugger->onFrame();
+ if (skipFlag())
+ _sound->voiceStop();
+ } while (!skipFlag() && _system->getMillis() < start + amount && !shouldQuit());
+}
- _system->delayMillis(10);
- }
+bool KyraEngine_LoK::skipFlag() const {
+ return KyraEngine_v1::skipFlag() || shouldQuit();
}
void KyraEngine_LoK::delayWithTicks(int ticks) {
@@ -586,7 +519,7 @@ void KyraEngine_LoK::delayWithTicks(int ticks) {
seq_playEnd();
}
- if (_skipFlag)
+ if (skipFlag())
break;
if (nextTime - _system->getMillis() >= 10)
@@ -676,13 +609,8 @@ void KyraEngine_LoK::resetBrandonPoisonFlags() {
#pragma mark - Input
#pragma mark -
-void KyraEngine_LoK::processInput() {
- Common::Point mouse = getMousePos();
- int xpos = mouse.x;
- int ypos = mouse.y;
-
+void KyraEngine_LoK::processInput(int xpos, int ypos) {
debugC(9, kDebugLevelMain, "KyraEngine_LoK::processInput(%d, %d)", xpos, ypos);
- _abortWalkFlag2 = false;
if (processInputHelper(xpos, ypos))
return;
@@ -698,20 +626,18 @@ void KyraEngine_LoK::processInput() {
// XXX _deathHandler specific
if (ypos <= 158) {
uint16 exit = 0xFFFF;
- if (xpos < 12) {
+
+ if (xpos < 12)
exit = _walkBlockWest;
- } else if (xpos >= 308) {
+ else if (xpos >= 308)
exit = _walkBlockEast;
- } else if (ypos >= 136) {
+ else if (ypos >= 136)
exit = _walkBlockSouth;
- } else if (ypos < 12) {
+ else if (ypos < 12)
exit = _walkBlockNorth;
- }
if (exit != 0xFFFF) {
- _abortWalkFlag2 = true;
handleSceneChange(xpos, ypos, 1, 1);
- _abortWalkFlag2 = false;
return;
} else {
int script = checkForNPCScriptRun(xpos, ypos);
@@ -722,19 +648,14 @@ void KyraEngine_LoK::processInput() {
if (_itemInHand != -1) {
if (ypos < 155) {
if (hasClickedOnExit(xpos, ypos)) {
- _abortWalkFlag2 = true;
handleSceneChange(xpos, ypos, 1, 1);
- _abortWalkFlag2 = false;
return;
}
dropItem(0, _itemInHand, xpos, ypos, 1);
}
} else {
- if (ypos <= 155) {
- _abortWalkFlag2 = true;
+ if (ypos <= 155)
handleSceneChange(xpos, ypos, 1, 1);
- _abortWalkFlag2 = false;
- }
}
}
}