22 #ifndef RIVEN_SCRIPTS_H 23 #define RIVEN_SCRIPTS_H 25 #include "mohawk/riven_stack.h" 27 #include "common/str-array.h" 28 #include "common/ptr.h" 29 #include "common/textconsole.h" 31 #define DECLARE_OPCODE(x) void x(uint16 op, const ArgumentArray &args) 44 kMouseEnterScript = 3,
45 kMouseInsideScript = 4,
46 kMouseLeaveScript = 5,
52 kCardUpdateScript = 10
55 enum RivenCommandType {
56 kRivenCommandDrawBitmap = 1,
57 kRivenCommandChangeCard = 2,
58 kRivenCommandPlayScriptSLST = 3,
59 kRivenCommandPlaySound = 4,
60 kRivenCommandSetVariable = 7,
61 kRivenCommandSwitch = 8,
62 kRivenCommandEnableHotspot = 9,
63 kRivenCommandDisableHotspot = 10,
64 kRivenCommandStopSound = 12,
65 kRivenCommandChangeCursor = 13,
66 kRivenCommandDelay = 14,
67 kRivenCommandRunExternal = 17,
68 kRivenCommandTransition = 18,
69 kRivenCommandRefreshCard = 19,
70 kRivenCommandBeginScreenUpdate = 20,
71 kRivenCommandApplyScreenUpdate = 21,
72 kRivenCommandIncrementVariable = 24,
73 kRivenCommandChangeStack = 27,
74 kRivenCommandDisableMovie = 28,
75 kRivenCommandDisableAllMovies = 29,
76 kRivenCommandEnableMovie = 31,
77 kRivenCommandPlayMovieBlocking = 32,
78 kRivenCommandPlayMovie = 33,
79 kRivenCommandStopMovie = 34,
80 kRivenCommandUnk36 = 36,
81 kRivenCommandFadeAmbientSounds = 37,
82 kRivenCommandStoreMovieOpcode = 38,
83 kRivenCommandActivatePLST = 39,
84 kRivenCommandActivateSLST = 40,
85 kRivenCommandActivateMLSTAndPlay = 41,
86 kRivenCommandActivateBLST = 43,
87 kRivenCommandActivateFLST = 44,
88 kRivenCommandZipMode = 45,
89 kRivenCommandActivateMLST = 46,
90 kRivenCommandTimer = 1001
93 class MohawkEngine_Riven;
96 class RivenScriptManager;
114 void addCommand(RivenCommandPtr command);
128 void dumpScript(byte tabs);
131 void applyCardPatches(
MohawkEngine_Riven *vm, uint32 cardGlobalId, uint16 scriptType, uint16 hotspotId);
137 static const char *getTypeName(uint16 type);
144 RivenScriptPtr &
operator+=(RivenScriptPtr &lhs,
const RivenScriptPtr &rhs);
153 RivenScriptPtr script;
178 RivenScriptPtr readScriptFromData(uint16 *data, uint16 size);
181 RivenScriptPtr createScriptFromData(uint commandCount, ...);
188 RivenScriptPtr createScriptWithCommand(
RivenCommand *command);
194 void runScript(
const RivenScriptPtr &script,
bool queue);
197 bool hasQueuedScripts()
const;
200 void runQueuedScripts();
208 bool runningQueuedScripts()
const;
218 void stopAllScripts();
221 bool stoppingAllScripts()
const;
224 RivenScriptPtr script;
229 uint16 getStoredMovieOpcodeSlot() {
return _storedMovieOpcode.slot; }
230 uint32 getStoredMovieOpcodeTime() {
return _storedMovieOpcode.time; }
232 void runStoredMovieOpcode();
233 void clearStoredMovieOpcode();
239 bool _runningQueuedScripts;
240 bool _stoppingAllScripts;
258 virtual void dump(byte tabs) = 0;
261 virtual void execute() = 0;
264 virtual RivenCommandType getType()
const = 0;
290 void dump(byte tabs)
override;
291 void execute()
override;
292 RivenCommandType getType()
const override;
295 typedef void (
RivenSimpleCommand::*OpcodeProcRiven)(uint16 op,
const ArgumentArray &args);
297 OpcodeProcRiven proc;
305 void activateMLST(
const MLSTRecord &mlst)
const;
307 DECLARE_OPCODE(empty) {
warning (
"Unknown Opcode %04x", op); }
310 DECLARE_OPCODE(drawBitmap);
311 DECLARE_OPCODE(switchCard);
312 DECLARE_OPCODE(playScriptSLST);
313 DECLARE_OPCODE(playSound);
314 DECLARE_OPCODE(setVariable);
315 DECLARE_OPCODE(enableHotspot);
316 DECLARE_OPCODE(disableHotspot);
317 DECLARE_OPCODE(stopSound);
318 DECLARE_OPCODE(changeCursor);
319 DECLARE_OPCODE(delay);
320 DECLARE_OPCODE(runExternalCommand);
321 DECLARE_OPCODE(transition);
322 DECLARE_OPCODE(refreshCard);
323 DECLARE_OPCODE(beginScreenUpdate);
324 DECLARE_OPCODE(applyScreenUpdate);
325 DECLARE_OPCODE(incrementVariable);
326 DECLARE_OPCODE(disableMovie);
327 DECLARE_OPCODE(disableAllMovies);
328 DECLARE_OPCODE(enableMovie);
329 DECLARE_OPCODE(playMovieBlocking);
330 DECLARE_OPCODE(playMovie);
331 DECLARE_OPCODE(stopMovie);
332 DECLARE_OPCODE(unk_36);
333 DECLARE_OPCODE(fadeAmbientSounds);
334 DECLARE_OPCODE(storeMovieOpcode);
335 DECLARE_OPCODE(activatePLST);
336 DECLARE_OPCODE(activateSLST);
337 DECLARE_OPCODE(activateMLSTAndPlay);
338 DECLARE_OPCODE(activateBLST);
339 DECLARE_OPCODE(activateFLST);
340 DECLARE_OPCODE(zipMode);
341 DECLARE_OPCODE(activateMLST);
343 const RivenOpcode *_opcodes;
345 RivenCommandType _type;
346 ArgumentArray _arguments;
363 void dump(byte tabs)
override;
364 void execute()
override;
365 RivenCommandType getType()
const override;
366 void applyCardPatches(uint32 globalId,
int scriptType, uint16 hotspotId)
override;
373 RivenScriptPtr script;
390 bool byStackId,
bool byStackCardId);
396 void dump(byte tabs)
override;
397 void execute()
override;
398 RivenCommandType getType()
const override;
418 void dump(byte tabs)
override;
419 void execute()
override;
420 RivenCommandType getType()
const override;
428 #undef DECLARE_OPCODE Definition: riven_scripts.h:223
Definition: riven_scripts.h:357
void warning(MSVC_PRINTF const char *s,...) GCC_PRINTF(1
Definition: riven_scripts.h:387
Definition: riven_scripts.h:413
virtual void applyCardPatches(uint32 globalId, int scriptType, uint16 hotspotId)
Definition: riven_scripts.h:267
Definition: riven_scripts.h:164
Definition: algorithm.h:29
Definition: riven_scripts.h:108
Definition: riven_scripts.h:280
Definition: riven_scripts.h:252
Definition: riven_card.h:203
RivenScriptPtr & operator+=(RivenScriptPtr &lhs, const RivenScriptPtr &rhs)
Definition: riven_scripts.h:151