From 4685cc047d5908c110afb10422ae6f8f463f03fa Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Thu, 17 Apr 2008 14:26:50 +0000 Subject: Implemented kyra3 timer code. svn-id: r31536 --- engines/kyra/kyra_v3.cpp | 13 +++++-- engines/kyra/kyra_v3.h | 14 +++++--- engines/kyra/module.mk | 1 + engines/kyra/scene_v3.cpp | 4 +-- engines/kyra/timer_v3.cpp | 87 +++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 111 insertions(+), 8 deletions(-) create mode 100644 engines/kyra/timer_v3.cpp (limited to 'engines/kyra') diff --git a/engines/kyra/kyra_v3.cpp b/engines/kyra/kyra_v3.cpp index edf42dc3a3..e956f8cbdd 100644 --- a/engines/kyra/kyra_v3.cpp +++ b/engines/kyra/kyra_v3.cpp @@ -85,7 +85,7 @@ KyraEngine_v3::KyraEngine_v3(OSystem *system, const GameFlags &flags) : KyraEngi _lastCharPalLayer = -1; _charPalUpdate = false; _runFlag = false; - _unkInputFlag = false; + _unk5 = 0; _unkSceneScreenFlag1 = false; _noScriptEnter = true; _itemInHand = _handItemSet = -1; @@ -706,12 +706,20 @@ void KyraEngine_v3::showMessage(const char *string, uint8 c0, uint8 c1) { _text->printText(string, x, _commandLineY, c0, c1, 0); _screen->_curPage = pageBackUp; _screen->updateScreen(); - //setCommandLineRestoreTimer(7); + setCommandLineRestoreTimer(7); } _screen->showMouse(); } +void KyraEngine_v3::updateCommandLine() { + debugC(9, kDebugLevelMain, "KyraEngine_v3::updateCommandLine()"); + if (_restoreCommandLine) { + restoreCommandLine(); + _restoreCommandLine = false; + } +} + void KyraEngine_v3::restoreCommandLine() { debugC(9, kDebugLevelMain, "KyraEngine_v3::restoreCommandLine()"); int y = _inventoryState ? 144 : 188; @@ -910,6 +918,7 @@ void KyraEngine_v3::update() { musicUpdate(0); //XXX updateSpecialSceneScripts(); + updateCommandLine(); //XXX musicUpdate(0); diff --git a/engines/kyra/kyra_v3.h b/engines/kyra/kyra_v3.h index 5e95f9ce8e..f44529f38d 100644 --- a/engines/kyra/kyra_v3.h +++ b/engines/kyra/kyra_v3.h @@ -69,7 +69,6 @@ private: // run bool _runFlag; - bool _unkInputFlag; void runLoop(); void handleInput(int x, int y); @@ -130,8 +129,14 @@ private: MainMenu *_menu; // timer - void setupTimers() {} - void setWalkspeed(uint8) {} + void setupTimers(); + + void setWalkspeed(uint8); + void setCommandLineRestoreTimer(int secs); + + void timerRestoreCommandLine(int arg); + void timerRunSceneScript7(int arg); + void timerFleaDeath(int arg); // pathfinder bool lineIsPassable(int, int) { return false; } @@ -198,6 +203,7 @@ private: void loadInterface(); void showMessage(const char *string, uint8 c0, uint8 c1); + void updateCommandLine(); void restoreCommandLine(); int _commandLineY; @@ -394,7 +400,7 @@ private: uint8 *_gfxBackUpRect; uint8 *_paletteOverlay; - int _unk3, _unk4; + int _unk3, _unk4, _unk5; void loadCostPal(); void loadShadowShape(); diff --git a/engines/kyra/module.mk b/engines/kyra/module.mk index b2e011828c..f419137865 100644 --- a/engines/kyra/module.mk +++ b/engines/kyra/module.mk @@ -50,6 +50,7 @@ MODULE_OBJS := \ timer.o \ timer_v1.o \ timer_v2.o \ + timer_v3.o \ vqa.o \ wsamovie.o diff --git a/engines/kyra/scene_v3.cpp b/engines/kyra/scene_v3.cpp index 8d580d230d..26999627bb 100644 --- a/engines/kyra/scene_v3.cpp +++ b/engines/kyra/scene_v3.cpp @@ -150,14 +150,14 @@ void KyraEngine_v3::enterNewScene(uint16 sceneId, int facing, int unk1, int unk2 enterNewSceneUnk1(facing, unk2, unk3); musicUpdate(0); - //XXX setCommandLineRestoreTimer(-1); + setCommandLineRestoreTimer(-1); _sceneScriptState.regs[3] = 1; enterNewSceneUnk2(unk3); if (queryGameFlag(0)) { _runFlag = false; } else { if (!--_enterNewSceneLock) - _unkInputFlag = false; + _unk5 = 0; //XXX if (_itemInHand <= 0) { _itemInHand = -1; diff --git a/engines/kyra/timer_v3.cpp b/engines/kyra/timer_v3.cpp new file mode 100644 index 0000000000..f9e7c1a571 --- /dev/null +++ b/engines/kyra/timer_v3.cpp @@ -0,0 +1,87 @@ +/* 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. + * + * $URL$ + * $Id$ + * + */ + +#include "kyra/kyra_v3.h" +#include "kyra/timer.h" + +namespace Kyra { + +#define TimerV3(x) new Functor1Mem(this, &KyraEngine_v3::x) + +void KyraEngine_v3::setupTimers() { + debugC(9, kDebugLevelMain | kDebugLevelTimer, "KyraEngine_v3::setupTimers()"); + + _timer->addTimer(0, TimerV3(timerRestoreCommandLine), -1, 1); + for (int i = 1; i <= 3; ++i) + _timer->addTimer(i, TimerV3(timerRunSceneScript7), -1, 0); + _timer->addTimer(4, TimerV3(timerFleaDeath), -1, 0); + for (int i = 5; i <= 11; ++i) + _timer->addTimer(i, TimerV3(timerRunSceneScript7), -1, 0); + for (int i = 12; i <= 13; ++i) + _timer->addTimer(i, TimerV3(timerRunSceneScript7), 0, 0); +} + +void KyraEngine_v3::timerRestoreCommandLine(int arg) { + debugC(9, kDebugLevelMain | kDebugLevelTimer, "KyraEngine_v3::timerRestoreCommandLine(%d)", arg); + if (_shownMessage) + _restoreCommandLine = true; +} + +void KyraEngine_v3::timerRunSceneScript7(int arg) { + debugC(9, kDebugLevelMain | kDebugLevelTimer, "KyraEngine_v3::timerRunSceneScript7(%d)", arg); + _sceneScriptState.regs[1] = _mouseX; + _sceneScriptState.regs[2] = _mouseY; + _sceneScriptState.regs[3] = 0; + _sceneScriptState.regs[4] = _itemInHand; + _scriptInterpreter->startScript(&_sceneScriptState, 7); + + while (_scriptInterpreter->validScript(&_sceneScriptState)) + _scriptInterpreter->runScript(&_sceneScriptState); +} + +void KyraEngine_v3::timerFleaDeath(int arg) { + debugC(9, kDebugLevelMain | kDebugLevelTimer, "KyraEngine_v3::timerFleaDeath(%d)", arg); + warning("STUB timerFleaDeath"); +} + +void KyraEngine_v3::setWalkspeed(uint8 speed) { + debugC(9, kDebugLevelMain | kDebugLevelTimer, "KyraEngine_v3::setWalkspeed(%d)", speed); + + if (speed < 5) + speed = 3; + else + speed = 5; + + _mainCharacter.walkspeed = speed; +} + +void KyraEngine_v3::setCommandLineRestoreTimer(int secs) { + debugC(9, kDebugLevelMain | kDebugLevelTimer, "KyraEngine_v3::setCommandLineRestoreTimer(%d)", secs); + if (secs == -1) + secs = 32000; + _timer->setCountdown(0, secs*60); +} + +} // end of namespace Kyra -- cgit v1.2.3