aboutsummaryrefslogtreecommitdiff
path: root/engines/kyra/timer_mr.cpp
blob: 53865ba0e38a01423233b2cdf2ff112535bdcdf6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
/* 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_mr.h"
#include "kyra/timer.h"

namespace Kyra {

#define TimerV3(x) new Common::Functor1Mem<int, void, KyraEngine_MR>(this, &KyraEngine_MR::x)

void KyraEngine_MR::setupTimers() {
	debugC(9, kDebugLevelMain | kDebugLevelTimer, "KyraEngine_MR::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_MR::timerRestoreCommandLine(int arg) {
	debugC(9, kDebugLevelMain | kDebugLevelTimer, "KyraEngine_MR::timerRestoreCommandLine(%d)", arg);
	if (_shownMessage)
		_restoreCommandLine = true;
}

void KyraEngine_MR::timerRunSceneScript7(int arg) {
	debugC(9, kDebugLevelMain | kDebugLevelTimer, "KyraEngine_MR::timerRunSceneScript7(%d)", arg);
	_emc->init(&_sceneScriptState, &_sceneScriptData);
	_sceneScriptState.regs[1] = _mouseX;
	_sceneScriptState.regs[2] = _mouseY;
	_sceneScriptState.regs[3] = 0;
	_sceneScriptState.regs[4] = _itemInHand;
	_emc->start(&_sceneScriptState, 7);

	while (_emc->isValid(&_sceneScriptState))
		_emc->run(&_sceneScriptState);
}

void KyraEngine_MR::timerFleaDeath(int arg) {
	debugC(9, kDebugLevelMain | kDebugLevelTimer, "KyraEngine_MR::timerFleaDeath(%d)", arg);
	warning("STUB timerFleaDeath");
}

void KyraEngine_MR::setWalkspeed(uint8 speed) {
	debugC(9, kDebugLevelMain | kDebugLevelTimer, "KyraEngine_MR::setWalkspeed(%d)", speed);

	if (speed < 5)
		speed = 3;
	else
		speed = 5;

	_mainCharacter.walkspeed = speed;
}

void KyraEngine_MR::setCommandLineRestoreTimer(int secs) {
	debugC(9, kDebugLevelMain | kDebugLevelTimer, "KyraEngine_MR::setCommandLineRestoreTimer(%d)", secs);
	if (secs == -1)
		secs = 32000;
	_timer->setCountdown(0, secs*60);
}

void KyraEngine_MR::setNextIdleAnimTimer() {
	debugC(9, kDebugLevelMain | kDebugLevelTimer, "KyraEngine_MR::setNextIdleAnimTimer()");
	_nextIdleAnim = _system->getMillis() + _rnd.getRandomNumberRng(10, 15) * 1000;
}

} // end of namespace Kyra