ScummVM API documentation
function.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 MEDIASTATION_MEDIASCRIPT_FUNCTION_H
23 #define MEDIASTATION_MEDIASCRIPT_FUNCTION_H
24 
25 #include "common/array.h"
26 #include "common/hashmap.h"
27 
28 #include "mediastation/clients.h"
29 #include "mediastation/datafile.h"
30 #include "mediastation/mediascript/codechunk.h"
31 
32 namespace MediaStation {
33 
34 enum Platform {
35  kPlatformParamTokenUnknown = 0,
36  kPlatformParamTokenWindows = 0x76D,
37  kPlatformParakTokenMacintosh = 0x76E
38 };
39 
41 public:
42  ScriptFunction(Chunk &chunk);
43  ~ScriptFunction();
44 
46  Common::String decompile() const;
47  uint32 bytecodeSize() const { return _bytecodeSize; }
48 
49  uint _contextId = 0;
50  uint _id = 0;
51 
52 private:
53  byte *_bytecodeBuffer = nullptr;
54  uint32 _bytecodeSize = 0;
55 };
56 
57 namespace MazeMinigame {
58  class Maze;
59 } // End of namespace MazeMinigame
60 
61 namespace CheckersMinigame {
62  class Checkers;
63 } // End of namespace CheckersMinigame
64 
66 friend class Debugger;
67 
68 public:
69  FunctionManager() {};
70  virtual ~FunctionManager();
71 
72  virtual bool attemptToReadFromStream(Chunk &chunk, uint sectionType) override;
73  ScriptValue call(uint functionId, Common::Array<ScriptValue> &args);
74  ScriptFunction *getFunctionById(uint functionId);
75  void deleteFunctionsForContext(uint contextId);
76 
77  MazeMinigame::Maze *_maze = nullptr;
78  CheckersMinigame::Checkers *_checkers = nullptr;
79 
80  uint _scriptBlockCallDepth = 0;
81 
82 private:
84  uint32 _timedIntervalStartInMs = 0.0;
85 
86  void script_GetPlatform(Common::Array<ScriptValue> &args, ScriptValue &returnValue);
87  void script_Random(Common::Array<ScriptValue> &args, ScriptValue &returnValue);
88  void script_TimeOfDay(Common::Array<ScriptValue> &args, ScriptValue &returnValue);
89  void script_SquareRoot(Common::Array<ScriptValue> &args, ScriptValue &returnValue);
90  void script_GetUniqueRandom(Common::Array<ScriptValue> &args, ScriptValue &returnValue);
91  void script_CurrentRunTime(Common::Array<ScriptValue> &args, ScriptValue &returnValue);
92  void script_SetGammaCorrection(Common::Array<ScriptValue> &args, ScriptValue &returnValue);
93  void script_GetDefaultGammaCorrection(Common::Array<ScriptValue> &args, ScriptValue &returnValue);
94  void script_GetCurrentGammaCorrection(Common::Array<ScriptValue> &args, ScriptValue &returnValue);
95  void script_SetAudioVolume(Common::Array<ScriptValue> &args, ScriptValue &returnValue);
96  void script_GetAudioVolume(Common::Array<ScriptValue> &args, ScriptValue &returnValue);
97  void script_SystemLanguagePreference(Common::Array<ScriptValue> &args, ScriptValue &returnValue);
98  void script_SetRegistry(Common::Array<ScriptValue> &args, ScriptValue &returnValue);
99  void script_GetRegistry(Common::Array<ScriptValue> &args, ScriptValue &returnValue);
100  void script_SetProfile(Common::Array<ScriptValue> &args, ScriptValue &returnValue);
101  void script_DebugPrint(Common::Array<ScriptValue> &args, ScriptValue &returnValue);
102  void script_EffectTransition(Common::Array<ScriptValue> &args, ScriptValue &returnValue);
103 
104  // 101 Dalmatians.
105  void script_MazeGenerate(Common::Array<ScriptValue> &args, ScriptValue &returnValue);
106  void script_MazeApplyMoveMask(Common::Array<ScriptValue> &args, ScriptValue &returnValue);
107  void script_MazeSolve(Common::Array<ScriptValue> &args, ScriptValue &returnValue);
108  void script_BeginTimedInterval(Common::Array<ScriptValue> &args, ScriptValue &returnValue);
109  void script_EndTimedInterval(Common::Array<ScriptValue> &args, ScriptValue &returnValue);
110 
111  // Hercules.
112  void script_Checkers(Common::Array<ScriptValue> &args, ScriptValue &returnValue);
113 
114  // IBM/Crayola.
115  void script_Drawing(Common::Array<ScriptValue> &args, ScriptValue &returnValue);
116 
117  // Puzzle Castle.
118  void script_MoveSophie(Common::Array<ScriptValue> &args, ScriptValue &returnValue);
119 };
120 
121 } // End of namespace MediaStation
122 
123 #endif
Definition: str.h:59
Definition: actor.h:34
Definition: function.h:40
Definition: datafile.h:99
Definition: function.h:65
Definition: clients.h:31
Definition: hashmap.h:85
Definition: debugger.h:31
Definition: scriptvalue.h:35
Platform
Definition: platform.h:93