ScummVM API documentation
tinsel.h
1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 #ifndef TINSEL_TINSEL_H
23 #define TINSEL_TINSEL_H
24 
25 #include "common/scummsys.h"
26 #include "common/system.h"
27 #include "common/error.h"
28 #include "common/events.h"
29 #include "common/keyboard.h"
30 #include "common/random.h"
31 #include "common/util.h"
32 
33 #include "engines/engine.h"
34 #include "gui/debugger.h"
35 
36 #include "tinsel/debugger.h"
37 #include "tinsel/graphics.h"
38 #include "tinsel/sound.h"
39 #include "tinsel/dw.h"
40 #include "tinsel/detection.h"
41 
52 namespace Tinsel {
53 
54 class BMVPlayer;
55 class Config;
56 class MidiDriver;
57 class MidiMusicPlayer;
58 class PCMMusicPlayer;
59 class Music;
60 class SoundManager;
61 class Background;
62 class Font;
63 class Cursor;
64 class Actor;
65 class Handle;
66 class Scroll;
67 class Dialogs;
68 class Notebook;
69 class SystemReel;
70 class Spriter;
71 
72 typedef Common::List<Common::Rect> RectList;
73 
74 enum TINSELAction {
75  kActionNone,
76  kActionWalkTo,
77  kActionAction,
78  kActionLook,
79  kActionEscape,
80  kActionOptionsDialog,
81  kActionInventory,
82  kActionNotebook,
83  kActionSave,
84  kActionLoad,
85  kActionQuit,
86  kActionPageUp,
87  kActionPageDown,
88  kActionHome,
89  kActionEnd,
90  kActionMoveUp,
91  kActionMoveDown,
92  kActionMoveLeft,
93  kActionMoveRight
94 };
95 
96 enum {
97  kTinselDebugAnimations = 1 << 0,
98  kTinselDebugActions = 1 << 1,
99  kTinselDebugSound = 1 << 2,
100  kTinselDebugMusic = 2 << 3
101 };
102 
103 // Just for development
104 #define NOIR_SKIP_INTRO 0
105 
106 #define DEBUG_BASIC 1
107 #define DEBUG_INTERMEDIATE 2
108 #define DEBUG_DETAILED 3
109 
110 enum TinselKeyDirection {
111  MSK_LEFT = 1, MSK_RIGHT = 2, MSK_UP = 4, MSK_DOWN = 8,
112  MSK_DIRECTION = MSK_LEFT | MSK_RIGHT | MSK_UP | MSK_DOWN
113 };
114 
115 typedef bool (*KEYFPTR)(const Common::KeyState &, const Common::CustomEventType &);
116 
117 #define SCREEN_WIDTH (_vm->screen().w) // PC screen dimensions
118 #define SCREEN_HEIGHT (_vm->screen().h)
119 #define SCRN_CENTER_X ((SCREEN_WIDTH - 1) / 2) // screen center x
120 #define SCRN_CENTER_Y ((SCREEN_HEIGHT - 1) / 2) // screen center y
121 #define UNUSED_LINES 48
122 #define EXTRA_UNUSED_LINES 3
123 //#define SCREEN_BOX_HEIGHT1 (SCREEN_HEIGHT - UNUSED_LINES)
124 //#define SCREEN_BOX_HEIGHT2 (SCREEN_BOX_HEIGHT1 - EXTRA_UNUSED_LINES)
125 #define SCREEN_BOX_HEIGHT1 SCREEN_HEIGHT
126 #define SCREEN_BOX_HEIGHT2 SCREEN_HEIGHT
127 
128 #define GAME_FRAME_DELAY (1000 / ONE_SECOND)
129 
130 #define TinselVersion (_vm->getVersion())
131 #define TinselV2Demo (TinselVersion == 2 && _vm->getIsADGFDemo())
132 #define TinselV1PSX (TinselVersion == 1 && _vm->getPlatform() == Common::kPlatformPSX)
133 #define TinselV1Mac (TinselVersion == 1 && _vm->getPlatform() == Common::kPlatformMacintosh)
134 #define TinselV1Saturn (TinselVersion == 1 && _vm->getPlatform() == Common::kPlatformSaturn)
135 
136 #define READ_16(v) (TinselV1Mac || TinselV1Saturn ? READ_BE_UINT16(v) : READ_LE_UINT16(v))
137 #define READ_32(v) (TinselV1Mac || TinselV1Saturn ? READ_BE_UINT32(v) : READ_LE_UINT32(v))
138 #define WRITE_32(p, v) (TinselV1Mac || TinselV1Saturn ? WRITE_BE_UINT32(p, v) : WRITE_LE_UINT32(p, v))
139 #define FROM_16(v) (TinselV1Mac || TinselV1Saturn ? FROM_BE_16(v) : FROM_LE_16(v))
140 #define FROM_32(v) (TinselV1Mac || TinselV1Saturn ? FROM_BE_32(v) : FROM_LE_32(v))
141 #define TO_32(v) (TinselV1Mac || TinselV1Saturn ? TO_BE_32(v) : TO_LE_32(v))
142 
143 // Global reference to the TinselEngine object
144 extern TinselEngine *_vm;
145 
146 class TinselEngine : public Engine {
147  int _gameId;
148  Common::KeyState _keyPressed;
149  Common::RandomSource _random;
150  Graphics::Surface _screenSurface;
151  Common::Point _mousePos;
152  uint8 _dosPlayerDir;
153 
154  static const char *const _sampleIndices[][3];
155  static const char *const _sampleFiles[][3];
156  static const char *const _textFiles[][3];
157  static const char *const _sceneFiles[];
158 
159 protected:
160 
161  // Engine APIs
162  void initializePath(const Common::FSNode &gamePath) override;
163  Common::Error run() override;
164  bool hasFeature(EngineFeature f) const override;
165  Common::Error loadGameState(int slot) override;
166 #if 0
167  Common::Error saveGameState(int slot, const Common::String &desc, bool isAutosave = false);
168 #endif
169  bool canLoadGameStateCurrently(Common::U32String *msg = nullptr) override;
170 #if 0
172 #endif
173 
174 public:
175  TinselEngine(OSystem *syst, const TinselGameDescription *gameDesc);
176  ~TinselEngine() override;
177  int getGameId() {
178  return _gameId;
179  }
180 
181  const TinselGameDescription *_gameDescription;
182  uint32 getGameID() const;
183  uint32 getFeatures() const;
184  Common::Language getLanguage() const;
185  uint16 getVersion() const;
186  Common::Platform getPlatform() const;
187  bool getIsADGFDemo() const;
188  bool isV1CD() const;
189 
190  const char *getSampleIndex(LANGUAGE lang);
191  const char *getSampleFile(LANGUAGE lang);
192  const char *getTextFile(LANGUAGE lang);
193  // Noir
194  const char *getSceneFile(LANGUAGE lang);
195 
196  MidiDriver *_driver;
197  SoundManager *_sound;
198  MidiMusicPlayer *_midiMusic;
199  PCMMusicPlayer *_pcmMusic;
200  Music *_music;
201  BMVPlayer *_bmv;
202  Background* _bg;
203  Font *_font;
204  Cursor *_cursor;
205  Actor *_actor;
206  Handle *_handle;
207  Config *_config;
208  Scroll *_scroll;
209  Dialogs *_dialogs;
210  Notebook *_notebook = nullptr;
211  SystemReel *_systemReel = nullptr;
212  Spriter *_spriter = nullptr;
213 
214  KEYFPTR _keyHandler;
215 
218 
221 
222 
224  RectList _clipRects;
225 
226 private:
227  void NextGameCycle();
228  void CreateConstProcesses();
229  void RestartGame();
230  void RestartDrivers();
231  void ChopDrivers();
232  void ProcessKeyEvent(const Common::Event &event);
233  bool pollEvent();
234 
235 public:
236  const Common::String getTargetName() const { return _targetName; }
237  Common::String getSavegameFilename(int16 saveNum) const;
238  Common::SaveFileManager *getSaveFileMan() { return _saveFileMan; }
239  Graphics::Surface &screen() { return _screenSurface; }
240 
241  Common::Point getMousePosition() const { return _mousePos; }
242  void setMousePosition(Common::Point pt) {
243  // Clip mouse position to be within the screen coordinates
244  pt.x = CLIP<int16>(pt.x, 0, SCREEN_WIDTH - 1);
245  pt.y = CLIP<int16>(pt.y, 0, SCREEN_HEIGHT - 1);
246 
247  int yOffset = (TinselVersion >= 2) ? (g_system->getHeight() - _screenSurface.h) / 2 : 0;
248  g_system->warpMouse(pt.x, pt.y + yOffset);
249  _mousePos = pt;
250  }
251  void divertKeyInput(KEYFPTR fptr) { _keyHandler = fptr; }
252  int getRandomNumber(int maxNumber) { return _random.getRandomNumber(maxNumber); }
253  uint8 getKeyDirection() const { return _dosPlayerDir; }
254 };
255 
256 // Externally available methods
257 void CuttingScene(bool bCutting);
258 void CDChangeForRestore(int cdNumber);
259 void CdHasChanged();
260 
261 } // End of namespace Tinsel
262 
263 #endif /* TINSEL_TINSEL_H */
Definition: bmv.h:48
Definition: str.h:59
Definition: sound.h:47
Definition: surface.h:67
EngineFeature
Definition: engine.h:253
RectList _clipRects
Definition: tinsel.h:224
Definition: error.h:84
Common::Error run() override
int16 h
Definition: surface.h:76
Definition: sysreel.h:51
Definition: random.h:44
Definition: handle.h:42
Definition: music.h:121
uint getRandomNumber(uint max)
Common::List< Common::EventType > _mouseButtons
Definition: tinsel.h:217
uint32 CustomEventType
Definition: events.h:193
Definition: actors.h:92
Definition: background.h:81
Definition: music.h:95
virtual int16 getHeight()=0
OSystem * g_system
Definition: mididrv.h:309
Definition: tinsel.h:146
Definition: cursor.h:40
Definition: scroll.h:51
virtual Common::Error saveGameState(int slot, const Common::String &desc, bool isAutosave=false)
Definition: notebook.h:60
Definition: ustr.h:57
Definition: atari-cursor.h:38
Definition: font.h:33
Definition: config.h:37
Definition: events.h:199
Definition: fs.h:69
Definition: actors.h:36
Definition: rect.h:45
bool hasFeature(EngineFeature f) const override
Common::Error loadGameState(int slot) override
const Common::String _targetName
Definition: engine.h:181
Definition: music.h:36
Definition: detection.h:69
Definition: dialogs.h:267
int16 x
Definition: rect.h:46
int16 y
Definition: rect.h:47
Definition: keyboard.h:294
Definition: savefile.h:142
virtual void warpMouse(int x, int y)=0
Definition: system.h:161
void initializePath(const Common::FSNode &gamePath) override
Common::List< Common::Event > _keypresses
Definition: tinsel.h:220
Definition: engine.h:144
Platform
Definition: platform.h:46
Common::SaveFileManager * _saveFileMan
Definition: engine.h:167
Definition: spriter.h:200
bool canLoadGameStateCurrently(Common::U32String *msg=nullptr) override
Language
Definition: language.h:45
virtual bool canSaveGameStateCurrently(Common::U32String *msg=nullptr)