aboutsummaryrefslogtreecommitdiff
path: root/engines/tinsel/tinsel.h
blob: 9820be7dddc6ec8bf6f0e85a620f746ca7709789 (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
/* 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$
 *
 */

#ifndef TINSEL_H
#define TINSEL_H

#include "common/scummsys.h"
#include "common/system.h"
#include "common/events.h"
#include "common/keyboard.h"
#include "common/util.h"

#include "sound/mididrv.h"
#include "sound/mixer.h"

#include "engines/engine.h"
#include "tinsel/debugger.h"
#include "tinsel/graphics.h"
#include "tinsel/sound.h"

namespace Tinsel {

class MusicPlayer;
class Scheduler;
class SoundManager;

enum TinselGameID {
	GID_DW1 = 0,
	GID_DW2 = 1
};

enum TinselGameFeatures {
	GF_DEMO = 1 << 0,
	GF_CD = 1 << 1,
	GF_FLOPPY = 1 << 2,
	GF_SCNFILES = 1 << 3,

	// The GF_USE_?FLAGS values specify how many country flags are displayed
	// in the subtitles options dialog.
	// None of these defined -> 1 language, in ENGLISH.TXT
	GF_USE_3FLAGS = 1 << 4,	// French, German, Spanish
	GF_USE_4FLAGS = 1 << 5,	// French, German, Spanish, Italian
	GF_USE_5FLAGS = 1 << 6	// All 5 flags
};

enum TinselEngineVersion {
	TINSEL_V0 = 0,	// Used in the DW1 demo only
	TINSEL_V1 = 1
};

struct TinselGameDescription;

enum TinselKeyDirection {
	MSK_LEFT = 1, MSK_RIGHT = 2, MSK_UP = 4, MSK_DOWN = 8,
	MSK_DIRECTION = MSK_LEFT | MSK_RIGHT | MSK_UP | MSK_DOWN
};

typedef bool (*KEYFPTR)(const Common::KeyState &);

class TinselEngine : public Engine {
	int _gameId;
	Common::KeyState _keyPressed;
	Common::RandomSource _random;
	Graphics::Surface _screenSurface;
	Common::Point _mousePos;
	uint8 _dosPlayerDir;
	Console *_console;
	Scheduler *_scheduler;

protected:

	int init();
	int go();

public:
	TinselEngine(OSystem *syst, const TinselGameDescription *gameDesc);
	virtual ~TinselEngine();
	int getGameId() {
		return _gameId;
	}

	const TinselGameDescription *_gameDescription;
	uint32 getGameID() const;
	uint32 getFeatures() const;
	Common::Language getLanguage() const;
	uint16 getVersion() const;
	Common::Platform getPlatform() const;

	MidiDriver *_driver;
	SoundManager *_sound;
	MusicPlayer *_music;

	KEYFPTR _keyHandler;
private:
	//MusicPlayer *_music;
	int _musicVolume;

	void NextGameCycle(void);
	void CreateConstProcesses(void);
	void RestartGame(void);
	void RestartDrivers(void);
	void ChopDrivers(void);
	void ProcessKeyEvent(const Common::Event &event);
	bool pollEvent();

public:
	const Common::String getTargetName() const { return _targetName; }
	Common::String getSavegameFilename(int16 saveNum) const;
	Common::SaveFileManager *getSaveFileMan() { return _saveFileMan; }
	Graphics::Surface &screen() { return _screenSurface; }

	Common::Point getMousePosition() const { return _mousePos; }
	void setMousePosition(const Common::Point &pt) {
		g_system->warpMouse(pt.x, pt.y);
		_mousePos = pt;
	}
	void divertKeyInput(KEYFPTR fptr) { _keyHandler = fptr; }
	int getRandomNumber(int maxNumber) { return _random.getRandomNumber(maxNumber); }
	uint8 getKeyDirection() const { return _dosPlayerDir; }
};

// Global reference to the TinselEngine object
extern TinselEngine *_vm;

} // End of namespace Tinsel

#endif /* TINSEL_H */