forked from scummvm/scummvm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdarkseed.h
288 lines (232 loc) · 7.17 KB
/
darkseed.h
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
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
/* 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 3 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, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef DARKSEED_H
#define DARKSEED_H
#include "common/error.h"
#include "common/fs.h"
#include "common/keyboard.h"
#include "common/random.h"
#include "common/scummsys.h"
#include "common/serializer.h"
#include "common/system.h"
#include "common/util.h"
#include "engines/engine.h"
#include "graphics/screen.h"
#include "darkseed/animation.h"
#include "darkseed/console.h"
#include "darkseed/cursor.h"
#include "darkseed/cutscene.h"
#include "darkseed/detection.h"
#include "darkseed/inventory.h"
#include "darkseed/menu.h"
#include "darkseed/nsp.h"
#include "darkseed/objects.h"
#include "darkseed/player.h"
#include "darkseed/room.h"
#include "darkseed/sound.h"
#include "darkseed/sprites.h"
#include "darkseed/tostext.h"
#include "darkseed/usecode.h"
namespace Darkseed {
struct DarkseedGameDescription;
enum DarkseedAction {
kDarkseedActionNone,
kDarkseedActionSelect,
kDarkseedActionChangeCommand,
kDarkseedActionTimeAdvance,
kDarkseedActionQuit
};
enum ActionMode : uint8 {
kPointerAction = 0,
kHandAction = 2,
kLookAction = 3,
kUseStickAction = 19,
kUseHammerAction = 27,
};
enum class FadeDirection : uint8 {
NONE,
IN,
OUT
};
class DarkseedEngine : public Engine {
const ADGameDescription *_gameDescription;
Common::RandomSource _randomSource;
Pic *_fullscreenPic = nullptr;
bool _timeAdvanceEventSelected = false;
uint8 _delbertspeech = 0;
int16 _yvec = 0; //delbert throw stick related.
bool _normalWorldSpritesLoaded = true;
bool _redrawFrame = true;
bool _restartGame = false;
bool _canSaveGame = false;
FadeDirection _fadeDirection = FadeDirection::NONE;
uint8 _fadeStepCounter = 0;
Pal _fadeTempPalette;
Pal _fadeTargetPalette;
protected:
// Engine APIs
Common::Error run() override;
public:
Pic _frame;
bool _ct_voice_status = false;
bool _isRightMouseClicked = false;
bool _isLeftMouseClicked = false;
Common::KeyCode _lastKeyPressed = Common::KeyCode::KEYCODE_INVALID;
Sound *_sound = nullptr;
Nsp _baseSprites;
Cursor _cursor;
Graphics::Screen *_screen = nullptr;
TosText *_tosText = nullptr;
Console *_console = nullptr;
Room *_room = nullptr;
int _actionMode = kPointerAction;
Player *_player = nullptr;
Sprites _sprites;
Objects _objectVar;
Inventory _inventory;
UseCode *_useCode = nullptr;
Cutscene _cutscene;
Animation *_animation = nullptr;
Menu _menu;
uint8 _currentDay = 1;
int _currentTimeInSeconds = 0x7e8e;
int _fttime = 0;
uint8 _previousRoomNumber = 0;
uint16 _targetRoomNumber = 0;
uint16 _headAcheMessageCounter = 0;
uint8 _headacheMessageIdx = 0;
int _sprite_y_scaling_threshold_maybe = 0xf0;
int _scaledWalkSpeed_maybe = 0;
uint16 _scaledSpriteWidth = 0;
uint16 _scaledSpriteHeight = 0;
int _frameBottom = 0;
// Unknown variables
bool _doorEnabled = false;
bool _useDoorTarget = false;
int16 _counter_2c85_888b = 0;
uint8 _targetPlayerDirection = 0; // related to changing rooms.
uint8 _systemTimerCounter = 0;
bool _debugShowWalkPath = false;
int _phoneStatus = 0;
int16 _soundTimer = 0;
bool _printedcomeheredawson = false;
void zeroMouseButtons();
void updateEvents();
void gotoNextMorning();
void playDayChangeCutscene();
void removeFullscreenPic();
void wait();
void waitForSpeech();
void waitForSpeechOrSfx();
void syncSoundSettings() override;
DarkseedEngine(OSystem *syst, const ADGameDescription *gameDesc);
~DarkseedEngine() override;
uint32 getFeatures() const;
/**
* Returns the game Id
*/
Common::String getGameId() const;
/**
* Gets a random number
*/
uint32 getRandomNumber(uint maxNum) {
return _randomSource.getRandomNumber(maxNum);
}
bool isDosVersion() const {
return _gameDescription->platform == Common::kPlatformDOS;
}
bool isCdVersion() const {
return getFeatures() & ADGF_CD;
}
bool isDosFloppy() const {
return isDosVersion() && !isCdVersion();
}
bool hasFeature(EngineFeature f) const override {
return
(f == kSupportsLoadingDuringRuntime) ||
(f == kSupportsSavingDuringRuntime) ||
(f == kSupportsReturnToLauncher);
};
bool canLoadGameStateCurrently(Common::U32String *msg) override {
return !_animation->_isPlayingAnimation_maybe && !_player->_isAutoWalkingToBed && !_player->_heroWaiting && !_cutscene.isPlaying();
}
bool canSaveGameStateCurrently(Common::U32String *msg) override {
return _canSaveGame && !_animation->_isPlayingAnimation_maybe && !_player->_isAutoWalkingToBed && !_player->_heroWaiting && !_cutscene.isPlaying() && !_menu.isOpen();
}
/**
* Uses a serializer to allow implementing savegame
* loading and saving using a single method
*/
Common::Error syncGame(Common::Serializer &s);
Common::Error saveGameStream(Common::WriteStream *stream, bool isAutosave = false) override {
Common::Serializer s(nullptr, stream);
return syncGame(s);
}
Common::Error loadGameStream(Common::SeekableReadStream *stream) override {
Common::Serializer s(stream, nullptr);
Common::Error syncResult = syncGame(s);
if (syncResult.getCode() == Common::kNoError) {
changeToRoom(_room->_roomNumber);
}
_canSaveGame = true;
return syncResult;
}
Common::Path getRoomFilePath(const Common::Path &filename) const;
Common::Path getPictureFilePath(const Common::Path &filename) const;
void fadeIn(const Pal &palette);
void fadeOut();
bool fadeStep();
void restartGame();
void newGame();
void updateDisplay();
void debugTeleportToRoom(int newRoomNumber, int entranceNumber);
void showFullscreenPic(const Common::Path &filename);
void drawFullscreenPic();
void lookCode(int objNum);
void handleObjCollision(int targetObjNum);
void playSound(uint8 sfxId, uint8 unk1, int16 unk2);
void nextFrame(int nspAminIdx);
void throwmikeinjail();
void runObjects();
void getPackageObj(int packageType);
void printTime();
void changeToRoom(int newRoomNumber, bool placeDirectly = false);
void waitxticks(int ticks);
void doCircles();
private:
void updateBaseSprites();
void gameLoop();
void handleInput();
void handlePointerAction();
void loadRoom(int roomNumber);
void gotoSleepInJail();
void updateHeadache();
void closeShops();
void initDelbertAtSide();
void movePlayerToDelbert();
void delbertThrowStick(int16 spriteNum);
void leavePackage();
void copyLine(const Graphics::Surface &surface, int16 x1, int16 x2, int16 y);
};
extern DarkseedEngine *g_engine;
#define SHOULD_QUIT ::Darkseed::g_engine->shouldQuit()
} // End of namespace Darkseed
#endif // DARKSEED_H