ScummVM API documentation
scriptopcodes.h
1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11 
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16 
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 #ifndef DRAGONS_SCRIPTOPCODES_H
23 #define DRAGONS_SCRIPTOPCODES_H
24 
25 #include "common/func.h"
26 #include "common/str.h"
27 
28 
29 namespace Dragons {
30 
31 #define DRAGONS_NUM_SCRIPT_OPCODES 0x23
32 class DragonsEngine;
33 
34 struct ScriptOpCall {
35  byte _op;
36  byte *_base;
37  byte *_code;
38  byte *_codeEnd;
39  int _field8;
40  int _result;
41 
42  ScriptOpCall(byte *start, uint32 length);
43  void skip(uint size);
44  byte readByte();
45  int16 readSint16();
46  uint32 readUint32();
47 };
48 
50 
51 class DragonFLG;
52 class SpecialOpcodes;
53 
55 public:
56  ScriptOpcodes(DragonsEngine *vm, DragonFLG *dragonFLG);
57  ~ScriptOpcodes();
58  void runScript(ScriptOpCall &scriptOpCall);
59  void runScript3(ScriptOpCall &scriptOpCall);
60  bool runScript4(ScriptOpCall &scriptOpCall);
61  void execOpcode(ScriptOpCall &scriptOpCall);
62  void executeScriptLoop(ScriptOpCall &scriptOpCall);
63  void loadTalkDialogEntries(ScriptOpCall &scriptOpCall);
64 
65  int16 _numDialogStackFramesToPop;
66  int16 _scriptTargetINI;
67  SpecialOpcodes *_specialOpCodes;
68 
69 protected:
70  DragonsEngine *_vm;
71  DragonFLG *_dragonFLG;
72  ScriptOpcode *_opcodes[DRAGONS_NUM_SCRIPT_OPCODES];
73  Common::String _opcodeNames[DRAGONS_NUM_SCRIPT_OPCODES];
74 
75  void initOpcodes();
76  void freeOpcodes();
77  void updateReturn(ScriptOpCall &scriptOpCall, uint16 size);
78 
79 
80  // Opcodes
81  void opUnk1(ScriptOpCall &scriptOpCall);
82  void opAddDialogChoice(ScriptOpCall &scriptOpCall);
83  void opPopDialogStack(ScriptOpCall &scriptOpCall);
84  void opExecuteScript(ScriptOpCall &scriptOpCall); //op 4
85  void opSetActorDirection(ScriptOpCall &scriptOpCall); //op 5
86  void opPerformActionOnObject(ScriptOpCall &scriptOpCall);
87  void opMoveObjectToScene(ScriptOpCall &scriptOpCall);
88  void opActorLoadSequence(ScriptOpCall &scriptOpCall);
89 
90  void opSetVariable(ScriptOpCall &scriptOpCall);
91  void opRunSpecialOpCode(ScriptOpCall &scriptOpCall); //op B
92  void opPlayOrStopSound(ScriptOpCall &scriptOpCall);
93  void opDelay(ScriptOpCall &scriptOpCall); //op D
94  void opMoveActorToPoint(ScriptOpCall &scriptOpCall);
95  void opMoveActorToXY(ScriptOpCall &scriptOpCall);
96  void opMoveActorToObject(ScriptOpCall &scriptOpCall);
97  void opUnk11FlickerTalk(ScriptOpCall &scriptOpCall);
98  void opLoadScene(ScriptOpCall &scriptOpCall);
99  void opIfStatement(ScriptOpCall &scriptOpCall);
100  void opIfElseStatement(ScriptOpCall &scriptOpCall);
101  void opUnk15PropertiesRelated(ScriptOpCall &scriptOpCall);
102  void opUnk16(ScriptOpCall &scriptOpCall);
103  void opWaitForActorSequenceToFinish(ScriptOpCall &scriptOpCall);
104  void opDialogAtPoint(ScriptOpCall &scriptOpCall);
105  void opExecuteObjectSceneScript(ScriptOpCall &scriptOpCall);
106  void opUpdatePaletteCycling(ScriptOpCall &scriptOpCall);
107  void opWaitForActorToFinishWalking(ScriptOpCall &scriptOpCall);
108  void opShowActor(ScriptOpCall &scriptOpCall);
109  void opHideActor(ScriptOpCall &scriptOpCall);
110  void opSetActorFlag0x1000(ScriptOpCall &scriptOpCall);
111  void opPlayMusic(ScriptOpCall &scriptOpCall);
112  void opPreLoadSceneData(ScriptOpCall &scriptOpCall);
113  void opPauseCurrentSpeechAndFetchNextDialog(ScriptOpCall &scriptOpCall);
114 
115  bool evaluateExpression(ScriptOpCall &scriptOpCall);
116  void setVariable(ScriptOpCall &scriptOpCall);
117  void opCode_Unk7(ScriptOpCall &scriptOpCall);
118 
119  void opCodeActorTalk(ScriptOpCall &scriptOpCall); // 0x22
120 
121  // misc
122  uint16 getINIField(uint32 iniIndex, uint16 fieldOffset);
123  void setINIField(uint32 iniIndex, uint16 fieldOffset, uint16 value);
124 };
125 
126 } // End of namespace Dragons
127 
128 #endif // DRAGONS_SCRIPTOPCODES_H
Definition: str.h:59
Definition: dragonflg.h:49
Definition: specialopcodes.h:37
Definition: scriptopcodes.h:34
Definition: actor.h:26
Definition: func.h:437
Definition: scriptopcodes.h:54
Definition: dragons.h:167