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,
98  kTinselDebugActions,
99  kTinselDebugSound,
100  kTinselDebugMusic,
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 #define TinselV1PSXJapan (TinselVersion == 1 && _vm->getPlatform() == Common::kPlatformPSX && _vm->getLanguage() == Common::JA_JPN)
136 
137 #define READ_16(v) (TinselV1Mac || TinselV1Saturn ? READ_BE_UINT16(v) : READ_LE_UINT16(v))
138 #define READ_32(v) (TinselV1Mac || TinselV1Saturn ? READ_BE_UINT32(v) : READ_LE_UINT32(v))
139 #define WRITE_16(p, v) (TinselV1Mac || TinselV1Saturn ? WRITE_BE_UINT16(p, v) : WRITE_LE_UINT16(p, v))
140 #define WRITE_32(p, v) (TinselV1Mac || TinselV1Saturn ? WRITE_BE_UINT32(p, v) : WRITE_LE_UINT32(p, v))
141 #define FROM_16(v) (TinselV1Mac || TinselV1Saturn ? FROM_BE_16(v) : FROM_LE_16(v))
142 #define FROM_32(v) (TinselV1Mac || TinselV1Saturn ? FROM_BE_32(v) : FROM_LE_32(v))
143 #define TO_32(v) (TinselV1Mac || TinselV1Saturn ? TO_BE_32(v) : TO_LE_32(v))
144 
145 // Global reference to the TinselEngine object
146 extern TinselEngine *_vm;
147 
148 class TinselEngine : public Engine {
149  int _gameId;
150  Common::KeyState _keyPressed;
151  Common::RandomSource _random;
152  Graphics::Surface _screenSurface;
153  Common::Point _mousePos;
154  uint8 _dosPlayerDir;
155 
156  static const char *const _sampleIndices[][3];
157  static const char *const _sampleFiles[][3];
158  static const char *const _textFiles[][3];
159  static const char *const _sceneFiles[];
160 
161 protected:
162 
163  // Engine APIs
164  void initializePath(const Common::FSNode &gamePath) override;
165  Common::Error run() override;
166  bool hasFeature(EngineFeature f) const override;
167  Common::Error loadGameState(int slot) override;
168 #if 0
169  Common::Error saveGameState(int slot, const Common::String &desc, bool isAutosave = false);
170 #endif
171  bool canLoadGameStateCurrently(Common::U32String *msg = nullptr) override;
172 #if 0
174 #endif
175 
176 public:
177  TinselEngine(OSystem *syst, const TinselGameDescription *gameDesc);
178  ~TinselEngine() override;
179  int getGameId() {
180  return _gameId;
181  }
182 
183  const TinselGameDescription *_gameDescription;
184  uint32 getGameID() const;
185  uint32 getFeatures() const;
186  Common::Language getLanguage() const;
187  uint16 getVersion() const;
188  Common::Platform getPlatform() const;
189  bool getIsADGFDemo() const;
190  bool isV1CD() const;
191 
192  const char *getSampleIndex(LANGUAGE lang);
193  const char *getSampleFile(LANGUAGE lang);
194  const char *getTextFile(LANGUAGE lang);
195  // Noir
196  const char *getSceneFile(LANGUAGE lang);
197 
198  MidiDriver *_driver;
199  SoundManager *_sound;
200  MidiMusicPlayer *_midiMusic;
201  PCMMusicPlayer *_pcmMusic;
202  Music *_music;
203  BMVPlayer *_bmv;
204  Background* _bg;
205  Font *_font;
206  Cursor *_cursor;
207  Actor *_actor;
208  Handle *_handle;
209  Config *_config;
210  Scroll *_scroll;
211  Dialogs *_dialogs;
212  Notebook *_notebook = nullptr;
213  SystemReel *_systemReel = nullptr;
214  Spriter *_spriter = nullptr;
215  bool _memoryManagerInitialized;
216 
217  KEYFPTR _keyHandler;
218 
221 
224 
225 
227  RectList _clipRects;
228 
229 private:
230  void NextGameCycle();
231  void CreateConstProcesses();
232  void RestartGame();
233  void RestartDrivers();
234  void ChopDrivers();
235  void ProcessKeyEvent(const Common::Event &event);
236  bool pollEvent();
237  void addPsxArchive(const char *indexFileName, const char *dataFileName);
238 
239 public:
240  const Common::String getTargetName() const { return _targetName; }
241  Common::String getSavegameFilename(int16 saveNum) const;
242  Common::SaveFileManager *getSaveFileMan() { return _saveFileMan; }
243  Graphics::Surface &screen() { return _screenSurface; }
244 
245  Common::Point getMousePosition() const { return _mousePos; }
246  void setMousePosition(Common::Point pt) {
247  // Clip mouse position to be within the screen coordinates
248  pt.x = CLIP<int16>(pt.x, 0, SCREEN_WIDTH - 1);
249  pt.y = CLIP<int16>(pt.y, 0, SCREEN_HEIGHT - 1);
250 
251  int yOffset = (TinselVersion >= 2) ? (g_system->getHeight() - _screenSurface.h) / 2 : 0;
252  g_system->warpMouse(pt.x, pt.y + yOffset);
253  _mousePos = pt;
254  }
255  void divertKeyInput(KEYFPTR fptr) { _keyHandler = fptr; }
256  int getRandomNumber(int maxNumber) { return _random.getRandomNumber(maxNumber); }
257  uint8 getKeyDirection() const { return _dosPlayerDir; }
258 };
259 
260 // Externally available methods
261 void CuttingScene(bool bCutting);
262 void CDChangeForRestore(int cdNumber);
263 void CdHasChanged();
264 
265 } // End of namespace Tinsel
266 
267 #endif /* TINSEL_TINSEL_H */
Definition: bmv.h:48
Definition: str.h:59
Definition: sound.h:47
Definition: surface.h:67
EngineFeature
Definition: engine.h:258
RectList _clipRects
Definition: tinsel.h:227
Definition: error.h:81
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:125
uint getRandomNumber(uint max)
Common::List< Common::EventType > _mouseButtons
Definition: tinsel.h:220
uint32 CustomEventType
Definition: events.h:204
Definition: actors.h:92
Definition: background.h:81
Definition: music.h:99
virtual int16 getHeight()=0
OSystem * g_system
Definition: mididrv.h:313
Definition: tinsel.h:148
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
T y
Definition: rect.h:49
Definition: ustr.h:57
Definition: atari-cursor.h:35
Definition: font.h:33
Definition: config.h:37
Definition: events.h:210
Definition: fs.h:69
T x
Definition: rect.h:48
Definition: actors.h:36
Definition: rect.h:144
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
Definition: keyboard.h:294
Definition: savefile.h:142
virtual void warpMouse(int x, int y)=0
Definition: system.h:164
void initializePath(const Common::FSNode &gamePath) override
Common::List< Common::Event > _keypresses
Definition: tinsel.h:223
Definition: engine.h:144
Platform
Definition: platform.h:93
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)