aboutsummaryrefslogtreecommitdiff
path: root/engines/teenagent/teenagent.h
blob: 438f06d189de46153538fc31310f5314db824735 (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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
/* 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.
 *
 */

#ifndef TEENAGENT_TEENAGENT_H
#define TEENAGENT_TEENAGENT_H

#include "engines/engine.h"

#include "audio/mixer.h"

#include "common/random.h"
#include "common/array.h"

#include "gui/debugger.h"

#include "teenagent/console.h"
#include "teenagent/dialog.h"

struct ADGameDescription;

namespace Audio {
class AudioStream;
}

namespace Common {
struct Point;
}

/**
 * This is the namespace of the TeenAgent engine.
 *
 * Status of this engine: Complete
 *
 * Games using this engine:
 * - Teen Agent
 */
namespace TeenAgent {

struct Object;
struct UseHotspot;
class Scene;
class MusicPlayer;
class Resources;
class Inventory;

// Engine Debug Flags
enum {
	kDebugActor     = (1 << 0),
	kDebugAnimation = (1 << 1),
	kDebugCallbacks = (1 << 2),
	kDebugDialog    = (1 << 3),
	kDebugFont      = (1 << 4),
	kDebugInventory = (1 << 5),
	kDebugMusic     = (1 << 6),
	kDebugObject    = (1 << 7),
	kDebugPack      = (1 << 8),
	kDebugScene     = (1 << 9),
	kDebugSurface   = (1 << 10)
};

const uint16 kScreenWidth = 320;
const uint16 kScreenHeight = 200;

class TeenAgentEngine : public Engine {
public:
	TeenAgentEngine(OSystem *system, const ADGameDescription *gd);
	~TeenAgentEngine();

	virtual Common::Error run();
	virtual Common::Error loadGameState(int slot);
	virtual Common::Error saveGameState(int slot, const Common::String &desc);
	virtual bool canLoadGameStateCurrently() { return true; }
	virtual bool canSaveGameStateCurrently() { return !_sceneBusy; }
	virtual bool hasFeature(EngineFeature f) const;

	GUI::Debugger *getDebugger() { return console; }

	void init();

	enum Action { kActionNone, kActionExamine, kActionUse };

	void examine(const Common::Point &point, Object *object);
	void use(Object *object);
	inline void cancel() { _action = kActionNone; }

	bool processCallback(uint16 addr);
	inline Scene *getScene() { return scene; }

	bool showLogo();
	bool showCDLogo();
	bool showMetropolis();
	int skipEvents() const;

	Common::String parseMessage(uint16 addr);

	//event driven:
	void displayMessage(uint16 addr, byte color = textColorMark, uint16 x = 0, uint16 y = 0);
	void displayMessage(const Common::String &str, byte color = textColorMark, uint16 x = 0, uint16 y = 0);
	void displayAsyncMessage(uint16 addr, uint16 x, uint16 y, uint16 firstFrame, uint16 lastFrame, byte color = textColorMark);
	void displayAsyncMessageInSlot(uint16 addr, byte slot, uint16 firstFrame, uint16 lastFrame, byte color = textColorMark);
	void displayCredits(uint16 addr, uint16 timer = 0);
	void displayCutsceneMessage(uint16 addr, uint16 x, uint16 y);
	void moveTo(const Common::Point &dst, byte o, bool warp = false);
	void moveTo(uint16 x, uint16 y, byte o, bool warp = false);
	void moveTo(Object *obj);
	void moveRel(int16 x, int16 y, byte o, bool warp = false);
	void playActorAnimation(uint16 id, bool async = false, bool ignore = false);
	void playAnimation(uint16 id, byte slot, bool async = false, bool ignore = false, bool loop = false);
	void loadScene(byte id, const Common::Point &pos, byte o = 0);
	void loadScene(byte id, uint16 x, uint16 y, byte o = 0);
	void enableOn(bool enable = true);
	void setOns(byte id, byte value, byte sceneId = 0);
	void setLan(byte id, byte value, byte sceneId = 0);
	void setFlag(uint16 addr, byte value);
	byte getFlag(uint16 addr);
	void reloadLan();
	void rejectMessage();

	void playMusic(byte id); //schedules play
	void playSound(byte id, byte skipFrames);
	void playSoundNow(byte id);
	void enableObject(byte id, byte sceneId = 0);
	void disableObject(byte id, byte sceneId = 0);
	void hideActor();
	void showActor();
	void waitAnimation();
	void waitLanAnimationFrame(byte slot, uint16 frame);
	void setTimerCallback(uint16 addr, uint16 frames);
	void shakeScreen();
	void displayCredits();
	void fadeIn();
	void fadeOut();
	void wait(uint16 frames);

	Common::RandomSource _rnd;

	Resources *res;
	Scene *scene;
	Inventory *inventory;
	MusicPlayer *music;
	Dialog *dialog;
	Console *console;

	void setMusic(byte id);

private:
	void processObject();
	bool trySelectedObject();

	bool _sceneBusy;
	Action _action;
	Object *_dstObject;

	Audio::AudioStream *_musicStream;
	Audio::SoundHandle _musicHandle, _soundHandle;
	const ADGameDescription *_gameDescription;

	uint _markDelay, _gameDelay;

	Common::Array<Common::Array<UseHotspot> > _useHotspots;

	void fnIntro();
	void fnPoleClimbFail();
	void fnGotAnchor();
	void fnGetOutOfLake();
	void fnGuardDrinking();
	void fnEgoDefaultPosition();
	void fnEnterCave();
	void fnEgoScaredBySpider();
	void fnMoveToLadderAndLeaveCellar();
	void fnLeaveCellar();
	void fnPutRockInHole();
	void fnEgoBottomRightTurn();
	bool fnCheckingDrawers();
	void fnDrawerOpenMessage();
	bool fnRobotSafeAlreadyUnlockedCheck();
	void fnRobotSafeUnlockCheck();
	bool fnMansionIntrusionAttempt();
	void fnSecondMansionIntrusion();
	void fnThirdMansionIntrusion();
	void fnFourthMansionIntrusion();
	void fnFifthMansionIntrusion();
	void fnSixthMansionIntrusion();
	void fnTooDark();
	bool fnIsCookGone();
	void fnEgoSuspiciousPosition();
	void fnGivingFlowerToOldLady();
	void fnGiveAnotherFlowerToOldLady();
	void fnGivingFlowerToAnne();
	void fnGiveAnotherFlowerToAnne();
};

} // End of namespace TeenAgent

#endif