25#include "common/debug-channels.h"
26#include "common/array.h"
27#include "common/rect.h"
28#include "common/str.h"
29#include "common/hashmap.h"
30#include "common/hash-str.h"
31#include "common/func.h"
32#include "common/ptr.h"
33#include "common/scummsys.h"
34#include "common/keyboard.h"
36#include "engines/engine.h"
38#include "audio/mixer.h"
39#include "audio/softsynth/pcspk.h"
41#include "adl/console.h"
44#include "adl/detection.h"
49class SeekableReadStream;
57Common::Path getDiskImageName(
const AdlGameDescription &adlDesc,
byte volume);
58GameType getGameType(
const AdlGameDescription &desc);
59GameVersion getGameVersion(
const AdlGameDescription &desc);
69 kDebugChannelScript = 1,
80#define IDO_ACT_SAVE 0x0f
81#define IDO_ACT_LOAD 0x10
83#define IDI_CUR_ROOM 0xfc
84#define IDI_VOID_ROOM 0xfd
87#define IDI_WORD_SIZE 8
105 memset(connections, 0,
sizeof(connections));
109 byte connections[IDI_DIR_TOTAL];
123 byte numCond, numAct;
130 _cmd(cmd), _room(room), _verb(verb), _noun(noun), _ip(0) { }
140 byte op()
const {
return _cmd.script[_ip]; }
141 virtual kOpType getOpType()
const = 0;
143 byte arg(uint i)
const {
return _cmd.script[_ip + i]; }
144 virtual void next(uint numArgs) = 0;
146 bool isMatch()
const {
147 return (_cmd.room == IDI_ANY || _cmd.room == _room) &&
148 (_cmd.verb == IDI_ANY || _cmd.verb == _verb) &&
149 (_cmd.noun == IDI_ANY || _cmd.noun == _noun);
152 byte getNoun()
const {
return _noun; }
153 const Command &getCommand()
const {
return _cmd; }
160 const byte _room, _verb, _noun;
182 Item() : id(0), noun(0), region(0), room(0), picture(0), isShape(
false), state(0), description(0), isOnScreen(
false) { }
188 Time() : hours(12), minutes(0) { }
207 byte region, prevRegion;
214 State() : region(0), prevRegion(0), room(1), curPicture(0), moves(1), isDark(
false) { }
227#define OP_DEBUG_0(F) do { \
228 if (DebugMan.isDebugChannelEnabled(kDebugChannelScript) && op_debug(F)) \
232#define OP_DEBUG_1(F, P1) do { \
233 if (DebugMan.isDebugChannelEnabled(kDebugChannelScript) && op_debug(F, P1)) \
237#define OP_DEBUG_2(F, P1, P2) do { \
238 if (DebugMan.isDebugChannelEnabled(kDebugChannelScript) && op_debug(F, P1, P2)) \
242#define OP_DEBUG_3(F, P1, P2, P3) do { \
243 if (DebugMan.isDebugChannelEnabled(kDebugChannelScript) && op_debug(F, P1, P2, P3)) \
247#define OP_DEBUG_4(F, P1, P2, P3, P4) do { \
248 if (DebugMan.isDebugChannelEnabled(kDebugChannelScript) && op_debug(F, P1, P2, P3, P4)) \
258 void bell(uint count = 1)
const;
270 Common::Path getDiskImageName(
byte volume)
const {
return Adl::getDiskImageName(*_gameDescription, volume); }
271 GameType getGameType()
const {
return Adl::getGameType(*_gameDescription); }
272 GameVersion getGameVersion()
const {
return Adl::getGameVersion(*_gameDescription); }
273 Common::Language getLanguage()
const {
return Adl::getLanguage(*_gameDescription); }
274 virtual void gameLoop();
283 virtual void printMessage(uint idx);
284 virtual Common::String getItemDescription(
const Item &item)
const;
285 void delay(uint32 ms)
const;
289 byte inputKey(
bool showCursor =
true)
const;
290 void waitKey(uint32 ms = 0, Common::KeyCode keycode = Common::KEYCODE_INVALID)
const;
291 virtual void getInput(uint &verb, uint &noun);
298 void removeCommand(Commands &commands, uint idx);
299 Command &getCommand(Commands &commands, uint idx);
300 void removeMessage(uint idx);
301 void checkInput(
byte verb,
byte noun);
302 virtual bool isInputValid(
byte verb,
byte noun,
bool &is_any);
303 virtual bool isInputValid(
const Commands &commands,
byte verb,
byte noun,
bool &is_any);
304 virtual void applyRoomWorkarounds(
byte roomNr) { }
305 virtual void applyRegionWorkarounds() { }
307 virtual void setupOpcodeTables();
308 virtual void initState();
309 virtual void switchRoom(
byte roomNr);
310 virtual byte roomArg(
byte room)
const;
311 virtual void advanceClock() { }
314 void stopTextToSpeech()
const;
320 Opcode opcode(
int (T::*f)(ScriptEnv &)) {
324 virtual int o_isItemInRoom(ScriptEnv &e);
325 virtual int o_isMovesGT(ScriptEnv &e);
326 virtual int o_isVarEQ(ScriptEnv &e);
327 virtual int o_isCurPicEQ(ScriptEnv &e);
328 virtual int o_isItemPicEQ(ScriptEnv &e);
330 virtual int o_varAdd(ScriptEnv &e);
331 virtual int o_varSub(ScriptEnv &e);
332 virtual int o_varSet(ScriptEnv &e);
333 virtual int o_listInv(ScriptEnv &e);
334 virtual int o_moveItem(ScriptEnv &e);
335 virtual int o_setRoom(ScriptEnv &e);
336 virtual int o_setCurPic(ScriptEnv &e);
337 virtual int o_setPic(ScriptEnv &e);
338 virtual int o_printMsg(ScriptEnv &e);
339 virtual int o_setLight(ScriptEnv &e);
340 virtual int o_setDark(ScriptEnv &e);
341 virtual int o_save(ScriptEnv &e);
342 virtual int o_restore(ScriptEnv &e);
343 virtual int o_restart(ScriptEnv &e);
344 virtual int o_quit(ScriptEnv &e);
345 virtual int o_placeItem(ScriptEnv &e);
346 virtual int o_setItemPic(ScriptEnv &e);
347 virtual int o_resetPic(ScriptEnv &e);
348 virtual int o_takeItem(ScriptEnv &e);
349 virtual int o_dropItem(ScriptEnv &e);
350 virtual int o_setRoomPic(ScriptEnv &e);
352 virtual int goDirection(ScriptEnv &e, Direction D);
353 int o_goNorth(ScriptEnv &e) {
return goDirection(e, IDI_DIR_NORTH); }
354 int o_goSouth(ScriptEnv &e) {
return goDirection(e, IDI_DIR_SOUTH); }
355 int o_goEast(ScriptEnv &e) {
return goDirection(e, IDI_DIR_EAST); }
356 int o_goWest(ScriptEnv &e) {
return goDirection(e, IDI_DIR_WEST); }
357 int o_goUp(ScriptEnv &e) {
return goDirection(e, IDI_DIR_UP); }
358 int o_goDown(ScriptEnv &e) {
return goDirection(e, IDI_DIR_DOWN); }
364 bool playTones(
const Tones &tones,
bool isMusic,
bool allowSkip =
false)
const;
367 const Region &getRegion(uint i)
const;
368 Region &getRegion(uint i);
369 const Room &getRoom(uint i)
const;
370 Room &getRoom(uint i);
371 const Region &getCurRegion()
const;
372 Region &getCurRegion();
373 const Room &getCurRoom()
const;
375 const Item &getItem(uint i)
const;
376 Item &getItem(uint i);
377 byte getVar(uint i)
const;
378 void setVar(uint i,
byte value);
379 virtual void takeItem(
byte noun);
380 virtual void dropItem(
byte noun);
381 bool matchCommand(ScriptEnv &env)
const;
382 void doActions(ScriptEnv &env);
383 bool doOneCommand(
const Commands &commands,
byte verb,
byte noun);
384 void doAllCommands(
const Commands &commands,
byte verb,
byte noun);
385 virtual ScriptEnv *createScriptEnv(
const Command &cmd,
byte room,
byte verb,
byte noun);
396 bool op_debug(
const char *fmt, ...)
const;
400 GraphicsMan *_graphics;
408 PictureMap _pictures;
412 Commands _roomCommands;
413 Commands _globalCommands;
431 uint32 _verbErrorPos, _nounErrorPos;
438 uint thanksForPlaying;
445 bool _isRestarting, _isRestoring, _isQuitting;
446 bool _canSaveNow, _canRestoreNow;
450 const AdlGameDescription *_gameDescription;
453 mutable uint _scriptDelay;
454 mutable bool _scriptPaused;
457 virtual void runIntro() { }
458 virtual void init() = 0;
459 virtual void initGameState() = 0;
460 virtual void drawItems() = 0;
461 virtual void drawItem(Item &item,
const Common::Point &pos) = 0;
462 virtual void loadRoom(
byte roomNr) = 0;
463 virtual void showRoom() = 0;
464 virtual void switchRegion(
byte region) { }
465 void runScript(
const char *filename)
const;
466 void stopScript()
const;
467 void setScriptDelay(uint scriptDelay)
const { _scriptDelay = scriptDelay; }
475 byte convertKey(uint16 ascii)
const;
477 byte _saveVerb, _saveNoun, _restoreVerb, _restoreNoun;
Common::String getSaveStateName(int slot) const override
bool canSaveGameStateCurrently(Common::U32String *msg=nullptr) override
Common::Error saveGameState(int slot, const Common::String &desc, bool isAutosave=false) override
int getAutosaveSlot() const override
Definition: adl.h:268
Common::Error loadGameState(int slot) override
EngineFeature
Definition: engine.h:282
Language
Definition: language.h:45
Definition: algorithm.h:29
Definition: detection.h:71