22 #ifndef ASYLUM_RESOURCES_SCRIPT_H 23 #define ASYLUM_RESOURCES_SCRIPT_H 25 #include "common/array.h" 26 #include "common/func.h" 27 #include "common/serializer.h" 28 #include "common/stack.h" 29 #include "common/stream.h" 31 #include "asylum/shared.h" 35 #define MAX_ACTION_COMMANDS 161 37 #define DECLARE_OPCODE(name) \ 38 void Op##name(ScriptEntry *cmd) 40 #define IMPLEMENT_OPCODE(name) \ 41 void ScriptManager::Op##name(ScriptEntry *cmd) { \ 42 if (!_currentScript) error("[" #name "] No current script set"); \ 43 if (!_currentQueueEntry) error("[" #name "] Invalid current queue entry"); \ 44 if (!cmd) error("[" #name "] Invalid command parameter"); 49 #define ADD_OPCODE(name) { \ 50 Opcode *func = new Opcode(#name, new Common::Functor1Mem<ScriptEntry *, void, ScriptManager>(this, &ScriptManager::Op##name)); \ 51 _opcodes.push_back(func); \ 72 ResourceId soundResourceIdFrame;
74 ResourceId soundResourceId;
76 ResourceId paletteResourceId;
81 memset(&name, 0,
sizeof(name));
91 memset(&flagNums, 0,
sizeof(flagNums));
94 soundResourceIdFrame = kResourceNone;
96 soundResourceId = kResourceNone;
98 paletteResourceId = kResourceNone;
99 memset(&paths, 0,
sizeof(paths));
109 output +=
Common::String::format(
" flags=%d scriptIndex=%d scriptIndex2=%d type=%d\n", flags, scriptIndex, scriptIndex2, actionType);
110 output +=
Common::String::format(
" sound=%d polygon=%d palette=%d volume=%d\n", soundResourceId, polygonIndex, paletteResourceId, volume);
111 output +=
Common::String::format(
" field01=%d field02=%d field40=%d field44=%d\n", field01, field02, field_40, field_44);
112 output +=
Common::String::format(
" field7C=%d field84=%d field88=%d field90=%d\n", field_7C, soundResourceIdFrame, field_88, field_90);
146 void reset(uint32 count = 0);
152 void queueScript(int32 scriptIndex, ActorIndex actorIndex);
161 bool isInQueue(int32 scriptIndex)
const;
166 void removeFromQueue(uint32 entryIndex);
178 enum ObjectTransparency {
181 kObjectTransparencyOpaque
190 ActorIndex actorIndex;
207 s.syncAsSint32LE(scriptIndex);
208 s.syncAsSint32LE(currentLine);
209 s.syncAsUint32LE(actorIndex);
210 s.syncAsUint32LE(next);
211 s.syncAsUint32LE(prev);
216 ScriptQueueEntry entries[10];
225 for (uint32 i = 0; i <
ARRAYSIZE(entries); i++)
233 for (uint32 i = 0; i <
ARRAYSIZE(entries); i++)
234 entries[i].saveLoadWithSerializer(s);
236 s.syncAsUint32LE(first);
237 s.syncAsUint32LE(last);
259 opcode = kOpcodeReturn;
272 s.syncAsSint32LE(numLines);
273 s.syncAsSint32LE(opcode);
274 s.syncAsSint32LE(param1);
275 s.syncAsSint32LE(param2);
276 s.syncAsSint32LE(param3);
277 s.syncAsSint32LE(param4);
278 s.syncAsSint32LE(param5);
279 s.syncAsSint32LE(param6);
280 s.syncAsSint32LE(param7);
281 s.syncAsSint32LE(param8);
282 s.syncAsSint32LE(param9);
287 ScriptEntry commands[MAX_ACTION_COMMANDS];
299 for (int32 i = 0; i <
ARRAYSIZE(commands); i++)
300 commands[i].saveLoadWithSerializer(s);
302 s.syncAsSint32LE(field_1BAC);
303 s.syncAsSint32LE(field_1BB0);
304 s.syncAsSint32LE(counter);
317 Opcode(
const char *opcodeName, OpcodeFunctor *functor) {
337 bool _processNextEntry;
338 ScriptEntry *_lastProcessedCmd;
339 Script *_currentScript;
340 ScriptQueueEntry *_currentQueueEntry;
343 void enableObject(ScriptEntry *cmd, ObjectTransparency type);
344 void setActionFlag(ScriptEntry *cmd, ActionType flag);
345 void clearActionFlag(ScriptEntry *cmd, ActionType flag);
346 void jumpIfActionFlag(ScriptEntry *cmd, ActionType flag);
347 void setNextLine(int32 line);
351 DECLARE_OPCODE(Return);
352 DECLARE_OPCODE(SetGameFlag);
353 DECLARE_OPCODE(ClearGameFlag);
354 DECLARE_OPCODE(ToggleGameFlag);
355 DECLARE_OPCODE(JumpIfGameFlag);
356 DECLARE_OPCODE(HideCursor);
357 DECLARE_OPCODE(ShowCursor);
358 DECLARE_OPCODE(PlayAnimation);
359 DECLARE_OPCODE(MoveScenePosition);
360 DECLARE_OPCODE(HideActor);
361 DECLARE_OPCODE(ShowActor);
362 DECLARE_OPCODE(SetActorPosition);
363 DECLARE_OPCODE(SetSceneMotionStatus);
364 DECLARE_OPCODE(DisableActor);
365 DECLARE_OPCODE(EnableActor);
366 DECLARE_OPCODE(EnableObjects);
367 DECLARE_OPCODE(RemoveObject);
368 DECLARE_OPCODE(JumpActorSpeech);
369 DECLARE_OPCODE(JumpAndSetDirection);
370 DECLARE_OPCODE(JumpIfActorCoordinates);
372 DECLARE_OPCODE(ResetAnimation);
373 DECLARE_OPCODE(DisableObject);
374 DECLARE_OPCODE(JumpIfSoundPlayingAndPlaySound);
375 DECLARE_OPCODE(JumpIfActionFind);
376 DECLARE_OPCODE(SetActionFind);
377 DECLARE_OPCODE(ClearActionFind);
378 DECLARE_OPCODE(JumpIfActionGrab);
379 DECLARE_OPCODE(SetActionGrab);
380 DECLARE_OPCODE(ClearActionGrab);
381 DECLARE_OPCODE(JumpIfActionTalk);
382 DECLARE_OPCODE(SetActionTalk);
383 DECLARE_OPCODE(ClearActionTalk);
384 DECLARE_OPCODE(AddToInventory);
385 DECLARE_OPCODE(RemoveFromInventory);
386 DECLARE_OPCODE(JumpIfInventoryOmits);
387 DECLARE_OPCODE(RunEncounter);
388 DECLARE_OPCODE(JumpIfAction16);
389 DECLARE_OPCODE(SetAction16);
390 DECLARE_OPCODE(ClearAction16);
391 DECLARE_OPCODE(SelectInventoryItem);
392 DECLARE_OPCODE(JumpIfInventoryItemNotSelected);
393 DECLARE_OPCODE(ChangeScene);
394 DECLARE_OPCODE(Interact);
395 DECLARE_OPCODE(PlayMovie);
396 DECLARE_OPCODE(StopAllObjectsSounds);
397 DECLARE_OPCODE(StopProcessing);
398 DECLARE_OPCODE(ResumeProcessing);
399 DECLARE_OPCODE(ResetSceneRect);
400 DECLARE_OPCODE(ChangeMusicById);
401 DECLARE_OPCODE(StopMusic);
402 DECLARE_OPCODE(IncrementParam1);
403 DECLARE_OPCODE(SetVolume);
404 DECLARE_OPCODE(Jump);
405 DECLARE_OPCODE(RunPuzzle);
406 DECLARE_OPCODE(JumpIfAction8);
407 DECLARE_OPCODE(SetAction8);
408 DECLARE_OPCODE(ClearAction8);
409 DECLARE_OPCODE(CreatePalette);
410 DECLARE_OPCODE(IncrementParam2);
411 DECLARE_OPCODE(WaitUntilFramePlayed);
412 DECLARE_OPCODE(UpdateWideScreen);
413 DECLARE_OPCODE(JumpIfActor);
414 DECLARE_OPCODE(PlaySpeechScene);
415 DECLARE_OPCODE(PlaySpeech);
416 DECLARE_OPCODE(PlaySpeechScene2);
417 DECLARE_OPCODE(MoveScenePositionFromActor);
418 DECLARE_OPCODE(PaletteFade);
419 DECLARE_OPCODE(QueuePaletteFade);
420 DECLARE_OPCODE(PlaySoundUpdateObject);
421 DECLARE_OPCODE(ActorFaceTarget);
422 DECLARE_OPCODE(HideMatteBars);
423 DECLARE_OPCODE(ShowMatteBars);
424 DECLARE_OPCODE(JumpIfSoundPlaying);
425 DECLARE_OPCODE(ChangePlayer);
426 DECLARE_OPCODE(ChangeActorStatus);
427 DECLARE_OPCODE(StopSound);
428 DECLARE_OPCODE(JumpRandom);
429 DECLARE_OPCODE(ClearScreen);
430 DECLARE_OPCODE(Quit);
431 DECLARE_OPCODE(JumpObjectFrame);
432 DECLARE_OPCODE(DeleteGraphics);
433 DECLARE_OPCODE(SetActorField944);
434 DECLARE_OPCODE(SetScriptField1BB0);
435 DECLARE_OPCODE(OnScriptField1BB0);
436 DECLARE_OPCODE(WalkToActor);
437 DECLARE_OPCODE(SetResourcePalette);
438 DECLARE_OPCODE(SetObjectFrameIndexAndFlags);
439 DECLARE_OPCODE(SetObjectFlags);
440 DECLARE_OPCODE(SetActorActionIndex2);
441 DECLARE_OPCODE(UpdateTransparency);
442 DECLARE_OPCODE(QueueScript);
443 DECLARE_OPCODE(ProcessActor);
444 DECLARE_OPCODE(ClearActorFields);
445 DECLARE_OPCODE(SetObjectLastFrameIndex);
446 DECLARE_OPCODE(SetActionAreaFlags);
447 DECLARE_OPCODE(MorphActor);
448 DECLARE_OPCODE(ShowMenu);
449 DECLARE_OPCODE(UpdateGlobalFlags);
456 #endif // ASYLUM_RESOURCES_SCRIPT_H #define ARRAYSIZE(x)
Definition: util.h:91
static String format(MSVC_PRINTF const char *fmt,...) GCC_PRINTF(1
Definition: serializer.h:79
int32 actionType
flag (see ActionType enumeration)
Definition: script.h:68
Definition: serializer.h:308