22 #ifndef MYST_SCRIPTS_H 23 #define MYST_SCRIPTS_H 25 #include "common/ptr.h" 26 #include "common/scummsys.h" 27 #include "common/util.h" 29 #include "mohawk/myst_state.h" 35 #define DECLARE_OPCODE(x) void x(uint16 var, const ArgumentsArray &args) 37 class MohawkEngine_Myst;
65 void runScript(
const MystScript &script,
MystArea *invokingResource =
nullptr);
66 void runOpcode(uint16 op, uint16 var = 0,
const ArgumentsArray &args = ArgumentsArray());
69 void setInvokingResource(
MystArea *resource) { _invokingResource = resource; }
76 bool isScriptRunning()
const;
78 virtual void disablePersistentScripts() = 0;
79 virtual void runPersistentScripts() = 0;
81 virtual uint16 getVar(uint16 var);
82 virtual void toggleVar(uint16 var);
83 virtual bool setVarValue(uint16 var, uint16 value);
85 MystStack getStackId()
const {
return _stackId; }
86 virtual uint16 getMap() {
return 0; }
89 void animatedUpdate(
const ArgumentsArray &args, uint16 delay);
90 void soundWaitStop()
const;
93 DECLARE_OPCODE(o_toggleVar);
94 DECLARE_OPCODE(o_setVar);
95 DECLARE_OPCODE(o_changeCardSwitch4);
96 DECLARE_OPCODE(o_changeCardSwitchLtR);
97 DECLARE_OPCODE(o_changeCardSwitchRtL);
98 DECLARE_OPCODE(o_takePage);
99 DECLARE_OPCODE(o_redrawCard);
100 DECLARE_OPCODE(o_goToDest);
101 DECLARE_OPCODE(o_goToDestForward);
102 DECLARE_OPCODE(o_goToDestRight);
103 DECLARE_OPCODE(o_goToDestLeft);
104 DECLARE_OPCODE(o_goToDestUp);
105 DECLARE_OPCODE(o_triggerMovie);
106 DECLARE_OPCODE(o_toggleVarNoRedraw);
107 DECLARE_OPCODE(o_drawAreaState);
108 DECLARE_OPCODE(o_redrawAreaForVar);
109 DECLARE_OPCODE(o_changeCardDirectional);
110 DECLARE_OPCODE(o_changeCardPush);
111 DECLARE_OPCODE(o_changeCardPop);
112 DECLARE_OPCODE(o_enableAreas);
113 DECLARE_OPCODE(o_disableAreas);
114 DECLARE_OPCODE(o_directionalUpdate);
115 DECLARE_OPCODE(o_toggleAreasActivation);
116 DECLARE_OPCODE(o_playSound);
117 DECLARE_OPCODE(o_stopSoundBackground);
118 DECLARE_OPCODE(o_playSoundBlocking);
119 DECLARE_OPCODE(o_copyBackBufferToScreen);
120 DECLARE_OPCODE(o_copyImageToBackBuffer);
121 DECLARE_OPCODE(o_changeBackgroundSound);
122 DECLARE_OPCODE(o_soundPlaySwitch);
123 DECLARE_OPCODE(o_copyImageToScreen);
124 DECLARE_OPCODE(o_soundResumeBackground);
125 DECLARE_OPCODE(o_changeCard);
126 DECLARE_OPCODE(o_drawImageChangeCard);
127 DECLARE_OPCODE(o_changeMainCursor);
128 DECLARE_OPCODE(o_hideCursor);
129 DECLARE_OPCODE(o_showCursor);
130 DECLARE_OPCODE(o_delay);
131 DECLARE_OPCODE(o_changeStack);
132 DECLARE_OPCODE(o_changeCardPlaySoundDirectional);
133 DECLARE_OPCODE(o_directionalUpdatePlaySound);
134 DECLARE_OPCODE(o_saveMainCursor);
135 DECLARE_OPCODE(o_restoreMainCursor);
136 DECLARE_OPCODE(o_soundWaitStop);
137 DECLARE_OPCODE(o_exitMap);
140 DECLARE_OPCODE(o_quit);
150 #define REGISTER_OPCODE(op, cls, method) \ 152 op, #method, new Common::Functor2Mem<uint16, const ArgumentsArray &, void, cls>(this, &cls::method) \ 155 #define OVERRIDE_OPCODE(op, cls, method) \ 157 op, #method, new Common::Functor2Mem<uint16, const ArgumentsArray &, void, cls>(this, &cls::method) \ 160 void registerOpcode(uint16 op,
const char *name, OpcodeProcMyst *command);
161 void overrideOpcode(uint16 op,
const char *name, OpcodeProcMyst *command);
164 uint16 _savedMapCardId;
165 uint16 _savedCursorId;
169 static const MystStack _stackMap[];
170 static const uint16 _startCard[];
172 void setupCommonOpcodes();
175 T *getInvokingResource()
const;
179 MystOpcode(uint16 o, OpcodeProcMyst *p,
const char *d) : op(o), proc(p), desc(d) {}
189 int32 _scriptNestingLevel;
191 const MystStack _stackId;
193 Common::String describeCommand(
const MystOpcode &command, uint16 var,
const ArgumentsArray &args);
197 T *MystScriptParser::getInvokingResource()
const {
198 T *resource =
dynamic_cast<T *
>(_invokingResource);
201 error(
"Invoking resource has unexpected type");
209 #undef DECLARE_OPCODE
Definition: myst_state.h:128
Definition: myst_scripts.h:47
Definition: myst_scripts.h:60
void NORETURN_PRE error(MSVC_PRINTF const char *s,...) GCC_PRINTF(1
Definition: myst_areas.h:59