ResidualVM logo ResidualVM website - Forums - Contact us BuildBot - Doxygen - Wiki curved edge

myst3/script.h

Go to the documentation of this file.
00001 /* ResidualVM - A 3D game interpreter
00002  *
00003  * ResidualVM is the legal property of its developers, whose names
00004  * are too numerous to list here. Please refer to the AUTHORS
00005  * file distributed with this source distribution.
00006  *
00007  * This program is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU General Public License
00009  * as published by the Free Software Foundation; either version 2
00010  * of the License, or (at your option) any later version.
00011  *
00012  * This program is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU General Public License
00018  * along with this program; if not, write to the Free Software
00019  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00020  *
00021  */
00022 
00023 #ifndef SCRIPT_H_
00024 #define SCRIPT_H_
00025 
00026 #include "common/array.h"
00027 
00028 namespace Myst3 {
00029 
00030 class Myst3Engine;
00031 class Puzzles;
00032 struct Opcode;
00033 
00034 #define DECLARE_OPCODE(x) void x(Context &c, const Opcode &cmd)
00035 
00036 class Script {
00037 public:
00038     Script(Myst3Engine *vm);
00039     virtual ~Script();
00040 
00041     bool run(const Common::Array<Opcode> *script);
00042     void runSingleOp(const Opcode &op);
00043 
00044     const Common::String describeOpcode(const Opcode &opcode);
00045 
00046 private:
00047     struct Context {
00048         bool endScript;
00049         bool result;
00050         const Common::Array<Opcode> *script;
00051         Common::Array<Opcode>::const_iterator op;
00052         Common::Array<Opcode>::const_iterator whileStart;
00053     };
00054 
00055     typedef void (Script::*CommandProc)(Context &c, const Opcode &cmd);
00056 
00057     enum ArgumentType {
00058         kUnknown   = 'u',
00059         kVar       = 'v',
00060         kValue     = 'i',
00061         kEvalValue = 'e',
00062         kCondition = 'c'
00063     };
00064 
00065     struct Command {
00066         Command() : op(0), proc(nullptr), desc(nullptr), signature(nullptr)  { }
00067         Command(uint16 o, CommandProc p, const char *d, const char *s) : op(o), proc(p), desc(d), signature(s) { }
00068 
00069         uint16 op;
00070         CommandProc proc;
00071         const char *desc;
00072         const char *signature;
00073     };
00074 
00075     Myst3Engine *_vm;
00076     Puzzles *_puzzles;
00077 
00078     Common::Array<Command> _commands;
00079 
00080     const Command &findCommand(uint16 op);
00081     const Command &findCommandByProc(CommandProc proc);
00082     const Common::String describeCommand(uint16 op);
00083     const Common::String describeArgument(char type, int16 value);
00084 
00085     void shiftCommands(uint16 base, int32 value);
00086 
00087     void runOp(Context &c, const Opcode &op);
00088     void goToElse(Context &c);
00089 
00090     void runScriptForVarDrawTicksHelper(uint16 var, int32 startValue, int32 endValue, uint16 script, int32 numTicks);
00091 
00092     DECLARE_OPCODE(badOpcode);
00093     DECLARE_OPCODE(uselessOpcode);
00094 
00095     DECLARE_OPCODE(nodeCubeInit);
00096     DECLARE_OPCODE(nodeCubeInitIndex);
00097     DECLARE_OPCODE(nodeFrameInit);
00098     DECLARE_OPCODE(nodeFrameInitCond);
00099     DECLARE_OPCODE(nodeFrameInitIndex);
00100     DECLARE_OPCODE(nodeMenuInit);
00101     DECLARE_OPCODE(stopWholeScript);
00102     DECLARE_OPCODE(spotItemAdd);
00103     DECLARE_OPCODE(spotItemAddCond);
00104     DECLARE_OPCODE(spotItemAddCondFade);
00105     DECLARE_OPCODE(spotItemAddMenu);
00106     DECLARE_OPCODE(movieInitLooping);
00107     DECLARE_OPCODE(movieInitCondLooping);
00108     DECLARE_OPCODE(movieInitCond);
00109     DECLARE_OPCODE(movieInitPreloadLooping);
00110     DECLARE_OPCODE(movieInitCondPreloadLooping);
00111     DECLARE_OPCODE(movieInitCondPreload);
00112     DECLARE_OPCODE(movieInitFrameVar);
00113     DECLARE_OPCODE(movieInitFrameVarPreload);
00114     DECLARE_OPCODE(movieInitOverrridePosition);
00115     DECLARE_OPCODE(movieInitScriptedPosition);
00116     DECLARE_OPCODE(movieInitCondScriptedPosition);
00117     DECLARE_OPCODE(movieRemove);
00118     DECLARE_OPCODE(movieRemoveAll);
00119     DECLARE_OPCODE(movieSetLooping);
00120     DECLARE_OPCODE(movieSetNotLooping);
00121     DECLARE_OPCODE(waterEffectSetSpeed);
00122     DECLARE_OPCODE(waterEffectSetAttenuation);
00123     DECLARE_OPCODE(waterEffectSetWave);
00124     DECLARE_OPCODE(shakeEffectSet);
00125     DECLARE_OPCODE(sunspotAdd);
00126     DECLARE_OPCODE(sunspotAddIntensity);
00127     DECLARE_OPCODE(sunspotAddVarIntensity);
00128     DECLARE_OPCODE(sunspotAddIntensityColor);
00129     DECLARE_OPCODE(sunspotAddVarIntensityColor);
00130     DECLARE_OPCODE(sunspotAddIntensityRadius);
00131     DECLARE_OPCODE(sunspotAddVarIntensityRadius);
00132     DECLARE_OPCODE(sunspotAddIntColorRadius);
00133     DECLARE_OPCODE(sunspotAddVarIntColorRadius);
00134     DECLARE_OPCODE(inventoryAddFront);
00135     DECLARE_OPCODE(inventoryAddBack);
00136     DECLARE_OPCODE(inventoryRemove);
00137     DECLARE_OPCODE(inventoryReset);
00138     DECLARE_OPCODE(inventoryAddSaavChapter);
00139     DECLARE_OPCODE(varSetZero);
00140     DECLARE_OPCODE(varSetOne);
00141     DECLARE_OPCODE(varSetTwo);
00142     DECLARE_OPCODE(varSetOneHundred);
00143     DECLARE_OPCODE(varSetValue);
00144     DECLARE_OPCODE(varToggle);
00145     DECLARE_OPCODE(varSetOneIfNotZero);
00146     DECLARE_OPCODE(varOpposite);
00147     DECLARE_OPCODE(varAbsolute);
00148     DECLARE_OPCODE(varDereference);
00149     DECLARE_OPCODE(varReferenceSetZero);
00150     DECLARE_OPCODE(varReferenceSetValue);
00151     DECLARE_OPCODE(varRandRange);
00152     DECLARE_OPCODE(polarToRectSimple);
00153     DECLARE_OPCODE(polarToRect);
00154     DECLARE_OPCODE(varSetDistanceToZone);
00155     DECLARE_OPCODE(varSetMinDistanceToZone);
00156     DECLARE_OPCODE(varRemoveBits);
00157     DECLARE_OPCODE(varToggleBits);
00158     DECLARE_OPCODE(varCopy);
00159     DECLARE_OPCODE(varSetBitsFromVar);
00160     DECLARE_OPCODE(varSetBits);
00161     DECLARE_OPCODE(varApplyMask);
00162     DECLARE_OPCODE(varSwap);
00163     DECLARE_OPCODE(varIncrement);
00164     DECLARE_OPCODE(varIncrementMax);
00165     DECLARE_OPCODE(varIncrementMaxLooping);
00166     DECLARE_OPCODE(varAddValueMaxLooping);
00167     DECLARE_OPCODE(varDecrement);
00168     DECLARE_OPCODE(varDecrementMin);
00169     DECLARE_OPCODE(varDecrementMinLooping);
00170     DECLARE_OPCODE(varAddValueMax);
00171     DECLARE_OPCODE(varSubValueMin);
00172     DECLARE_OPCODE(varZeroRange);
00173     DECLARE_OPCODE(varCopyRange);
00174     DECLARE_OPCODE(varSetRange);
00175     DECLARE_OPCODE(varIncrementMaxTen);
00176     DECLARE_OPCODE(varAddValue);
00177     DECLARE_OPCODE(varArrayAddValue);
00178     DECLARE_OPCODE(varAddVarValue);
00179     DECLARE_OPCODE(varSubValue);
00180     DECLARE_OPCODE(varSubVarValue);
00181     DECLARE_OPCODE(varModValue);
00182     DECLARE_OPCODE(varMultValue);
00183     DECLARE_OPCODE(varMultVarValue);
00184     DECLARE_OPCODE(varDivValue);
00185     DECLARE_OPCODE(varDivVarValue);
00186     DECLARE_OPCODE(varCrossMultiplication);
00187     DECLARE_OPCODE(varMinValue);
00188     DECLARE_OPCODE(varClipValue);
00189     DECLARE_OPCODE(varClipChangeBound);
00190     DECLARE_OPCODE(varAbsoluteSubValue);
00191     DECLARE_OPCODE(varAbsoluteSubVar);
00192     DECLARE_OPCODE(varRatioToPercents);
00193     DECLARE_OPCODE(varRotateValue3);
00194     DECLARE_OPCODE(ifElse);
00195     DECLARE_OPCODE(ifCondition);
00196     DECLARE_OPCODE(ifCond1AndCond2);
00197     DECLARE_OPCODE(ifCond1OrCond2);
00198     DECLARE_OPCODE(ifOneVarSetInRange);
00199     DECLARE_OPCODE(ifVarEqualsValue);
00200     DECLARE_OPCODE(ifVarNotEqualsValue);
00201     DECLARE_OPCODE(ifVar1EqualsVar2);
00202     DECLARE_OPCODE(ifVar1NotEqualsVar2);
00203     DECLARE_OPCODE(ifVarSupEqValue);
00204     DECLARE_OPCODE(ifVarInfEqValue);
00205     DECLARE_OPCODE(ifVarInRange);
00206     DECLARE_OPCODE(ifVarNotInRange);
00207     DECLARE_OPCODE(ifVar1SupEqVar2);
00208     DECLARE_OPCODE(ifVar1SupVar2);
00209     DECLARE_OPCODE(ifVar1InfEqVar2);
00210     DECLARE_OPCODE(ifVarHasAllBitsSet);
00211     DECLARE_OPCODE(ifVarHasNoBitsSet);
00212     DECLARE_OPCODE(ifVarHasSomeBitsSet);
00213     DECLARE_OPCODE(ifHeadingInRange);
00214     DECLARE_OPCODE(ifPitchInRange);
00215     DECLARE_OPCODE(ifHeadingPitchInRect);
00216     DECLARE_OPCODE(ifMouseIsInRect);
00217     DECLARE_OPCODE(leverDrag);
00218     DECLARE_OPCODE(leverDragPositions);
00219     DECLARE_OPCODE(leverDragXY);
00220     DECLARE_OPCODE(itemDrag);
00221     DECLARE_OPCODE(runScriptWhileDragging);
00222     DECLARE_OPCODE(chooseNextNode);
00223     DECLARE_OPCODE(goToNodeTransition);
00224     DECLARE_OPCODE(goToNodeTrans2);
00225     DECLARE_OPCODE(goToNodeTrans1);
00226     DECLARE_OPCODE(goToRoomNode);
00227     DECLARE_OPCODE(zipToNode);
00228     DECLARE_OPCODE(zipToRoomNode);
00229     DECLARE_OPCODE(drawTransition);
00230     DECLARE_OPCODE(reloadNode);
00231     DECLARE_OPCODE(redrawFrame);
00232     DECLARE_OPCODE(moviePlay);
00233     DECLARE_OPCODE(moviePlaySynchronized);
00234     DECLARE_OPCODE(moviePlayFullFrame);
00235     DECLARE_OPCODE(moviePlayFullFrameTrans);
00236     DECLARE_OPCODE(moviePlayChangeNode);
00237     DECLARE_OPCODE(moviePlayChangeNodeTrans);
00238     DECLARE_OPCODE(lookAt);
00239     DECLARE_OPCODE(lookAtInXFrames);
00240     DECLARE_OPCODE(lookAtMovieStart);
00241     DECLARE_OPCODE(lookAtMovieStartInXFrames);
00242     DECLARE_OPCODE(cameraLimitMovement);
00243     DECLARE_OPCODE(cameraFreeMovement);
00244     DECLARE_OPCODE(cameraLookAt);
00245     DECLARE_OPCODE(cameraLookAtVar);
00246     DECLARE_OPCODE(cameraGetLookAt);
00247     DECLARE_OPCODE(lookAtMovieStartImmediate);
00248     DECLARE_OPCODE(cameraSetFOV);
00249     DECLARE_OPCODE(changeNode);
00250     DECLARE_OPCODE(changeNodeRoom);
00251     DECLARE_OPCODE(changeNodeRoomAge);
00252 
00253     DECLARE_OPCODE(drawXTicks);
00254     DECLARE_OPCODE(drawWhileCond);
00255     DECLARE_OPCODE(whileStart);
00256     DECLARE_OPCODE(whileEnd);
00257     DECLARE_OPCODE(runScriptWhileCond);
00258     DECLARE_OPCODE(runScriptWhileCondEachXFrames);
00259     DECLARE_OPCODE(runScriptForVar);
00260     DECLARE_OPCODE(runScriptForVarEachXFrames);
00261     DECLARE_OPCODE(runScriptForVarStartVar);
00262     DECLARE_OPCODE(runScriptForVarStartVarEachXFrames);
00263     DECLARE_OPCODE(runScriptForVarEndVar);
00264     DECLARE_OPCODE(runScriptForVarEndVarEachXFrames);
00265     DECLARE_OPCODE(runScriptForVarStartEndVar);
00266     DECLARE_OPCODE(runScriptForVarStartEndVarEachXFrames);
00267     DECLARE_OPCODE(drawFramesForVar);
00268     DECLARE_OPCODE(drawFramesForVarEachTwoFrames);
00269     DECLARE_OPCODE(drawFramesForVarStartEndVarEachTwoFrames);
00270     DECLARE_OPCODE(runScript);
00271     DECLARE_OPCODE(runScriptWithVar);
00272     DECLARE_OPCODE(runCommonScript);
00273     DECLARE_OPCODE(runCommonScriptWithVar);
00274     DECLARE_OPCODE(runPuzzle1);
00275     DECLARE_OPCODE(runPuzzle2);
00276     DECLARE_OPCODE(runPuzzle3);
00277     DECLARE_OPCODE(runPuzzle4);
00278     DECLARE_OPCODE(ambientLoadNode);
00279     DECLARE_OPCODE(ambientReloadCurrentNode);
00280     DECLARE_OPCODE(ambientPlayCurrentNode);
00281     DECLARE_OPCODE(ambientApply);
00282     DECLARE_OPCODE(ambientApplyWithFadeDelay);
00283     DECLARE_OPCODE(soundPlayBadClick);
00284     DECLARE_OPCODE(soundPlayBlocking);
00285     DECLARE_OPCODE(soundPlay);
00286     DECLARE_OPCODE(soundPlayVolume);
00287     DECLARE_OPCODE(soundPlayVolumeDirection);
00288     DECLARE_OPCODE(soundPlayVolumeDirectionAtt);
00289     DECLARE_OPCODE(soundStopEffect);
00290     DECLARE_OPCODE(soundFadeOutEffect);
00291     DECLARE_OPCODE(soundPlayLooping);
00292     DECLARE_OPCODE(soundPlayFadeInOut);
00293     DECLARE_OPCODE(soundChooseNext);
00294     DECLARE_OPCODE(soundRandomizeNext);
00295     DECLARE_OPCODE(soundChooseNextAfterOther);
00296     DECLARE_OPCODE(soundRandomizeNextAfterOther);
00297     DECLARE_OPCODE(ambientSetFadeOutDelay);
00298     DECLARE_OPCODE(ambientAddSound1);
00299     DECLARE_OPCODE(ambientAddSound2);
00300     DECLARE_OPCODE(ambientAddSound3);
00301     DECLARE_OPCODE(ambientAddSound4);
00302     DECLARE_OPCODE(ambientAddSound5);
00303     DECLARE_OPCODE(ambientSetCue1);
00304     DECLARE_OPCODE(ambientSetCue2);
00305     DECLARE_OPCODE(ambientSetCue3);
00306     DECLARE_OPCODE(ambientSetCue4);
00307     DECLARE_OPCODE(runAmbientScriptNode);
00308     DECLARE_OPCODE(runAmbientScriptNodeRoomAge);
00309     DECLARE_OPCODE(runSoundScriptNode);
00310     DECLARE_OPCODE(runSoundScriptNodeRoom);
00311     DECLARE_OPCODE(runSoundScriptNodeRoomAge);
00312     DECLARE_OPCODE(soundStopMusic);
00313     DECLARE_OPCODE(movieSetStartupSound);
00314     DECLARE_OPCODE(movieSetStartupSoundVolume);
00315     DECLARE_OPCODE(movieSetStartupSoundVolumeH);
00316     DECLARE_OPCODE(drawOneFrame);
00317     DECLARE_OPCODE(cursorHide);
00318     DECLARE_OPCODE(cursorShow);
00319     DECLARE_OPCODE(cursorSet);
00320     DECLARE_OPCODE(cursorLock);
00321     DECLARE_OPCODE(cursorUnlock);
00322     DECLARE_OPCODE(dialogOpen);
00323     DECLARE_OPCODE(newGame);
00324 };
00325 
00326 } // End of namespace Myst3
00327 
00328 #endif // SCRIPT_H_


Generated on Sat Feb 16 2019 05:01:03 for ResidualVM by doxygen 1.7.1
curved edge   curved edge