ScummVM API documentation
3dck.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 FREESCAPE_GAMES_3DCK_H
23#define FREESCAPE_GAMES_3DCK_H
24
25#include "freescape/freescape.h"
26#include "freescape/language/execution_3dck16.h"
27
28namespace Freescape {
29
30class KitEngine : public FreescapeEngine {
31public:
32 KitEngine(OSystem *syst, const ADGameDescription *gd);
33
34 void initKeymaps(Common::Keymap *engineKeyMap, Common::Keymap *infoScreenKeyMap, const char *target) override;
35 void loadAssets() override;
36 void initGameState() override;
37 void gotoArea(uint16 areaID, int entranceID) override;
38 void checkIfStillInArea() override;
39 bool checkIfGameEnded() override;
40 void borderScreen() override {}
41 void drawBackground() override;
42 void drawUI() override;
43 bool handleInput(const Common::Event &event) override;
44 void updatePlayerMovement(float deltaTime) override;
45 void updateTimeVariables() override;
46 void updateScripts() override;
47 bool executeObjectConditions(GeometricObject *obj, bool shot, bool collided, bool activated) override;
48 void executeLocalGlobalConditions(bool shot, bool collided, bool timer) override {}
49 bool canLoadGameStateCurrently(Common::U32String *msg = nullptr) override { return false; }
50 bool canSaveGameStateCurrently(Common::U32String *msg = nullptr) override { return false; }
51
52private:
53 struct ObjectData;
54 struct ScriptState : FCLKit16ExecutionState {
55 ObjectData *object = nullptr;
56 uint16 area = 0;
57 byte events = 0;
58 };
59
60 struct ConditionData {
61 Common::String name;
62 FCLInstructionVector condition;
63 ScriptState script;
64 };
65
66 struct SensorData {
67 byte colors[2] = {};
68 uint16 interval = 0;
69 uint16 range = 0;
70 uint16 unknown = 0;
71 uint16 directions = 0;
72 };
73
74 struct ObjectData {
75 uint16 id = 0;
76 byte type = 0;
77 byte flags = 0;
78 uint16 state = 0;
79 Math::Vector3d origin, size, initialOrigin;
82 FCLInstructionVector condition;
83 SensorData sensor;
84 ScriptState script;
85 Common::Array<uint16> animatedObjects;
86 uint16 animator = 0;
87 };
88
89 struct AreaData {
91 Common::Array<uint16> objectOrder;
93 byte palette[16 * 3] = {};
94 byte skyExtraColor = 0;
95 };
96
97 struct ScriptEntry {
98 ScriptState *script;
99 bool resume;
100 ScriptEntry(ScriptState *s, bool r) : script(s), resume(r) {}
101 };
102
103 void loadAssetsDOS();
104 void loadAssetsAtari();
105 void loadPaletteAtari(Common::SeekableReadStream &file, byte *palette);
106 void updateBorderAtari();
107 void splitColorAtari(byte &color, byte &extraColor);
108 void loadWorld(Common::SeekableReadStream &file);
109 void loadSounds(Common::SeekableReadStream &file);
110 void playPendingSound();
111 Area *loadArea(Common::SeekableReadStream &file);
112 Object *loadObject(Common::SeekableReadStream &file, ObjectData &data);
114 void resetScripts();
115 void startScript(ScriptState &script);
116 void beginScriptFrame();
117 FCLExecutionResult executeCode(ScriptState &script, uint &budget);
118 void executeIfThenElse(const FCLInstruction &instruction, ScriptState &script);
119 void executeConditional(const FCLInstruction &instruction, ScriptState &script);
120 void executeSetVariable(const FCLInstruction &instruction, ScriptState &script);
121 void executeIncrementVariable(const FCLInstruction &instruction, ScriptState &script);
122 void executeDecrementVariable(const FCLInstruction &instruction, ScriptState &script);
123 void executeAndVariable(const FCLInstruction &instruction, ScriptState &script);
124 void executeOrVariable(const FCLInstruction &instruction, ScriptState &script);
125 void executeNotVariable(const FCLInstruction &instruction, ScriptState &script);
126 void executeVariableComparison(const FCLInstruction &instruction, ScriptState &script);
127 void executeObjectStatus(const FCLInstruction &instruction);
128 bool checkObjectStatus(const FCLInstruction &instruction);
129 void executeGetPosition(const FCLInstruction &instruction);
130 bool executeCall(const FCLInstruction &instruction, ScriptState &script);
131 bool executeGoto(const FCLInstruction &instruction);
132 void executeMode(const FCLInstruction &instruction);
133 bool executeDelay(const FCLInstruction &instruction);
134 void executeLoop(const FCLInstruction &instruction, ScriptState &script);
135 bool executeAgain(ScriptState &script, uint32 ip);
136 void executeStartAnim(const FCLInstruction &instruction);
137 void executeStopAnim(const FCLInstruction &instruction);
138 void executeTriggerAnim(const FCLInstruction &instruction);
139 void executeInclude(const FCLInstruction &instruction, ScriptState &script);
140 void executeRemove(const FCLInstruction &instruction, ScriptState &script);
141 bool executeWaitTrigger(ScriptState &script, uint32 ip);
142 void executeMove(const FCLInstruction &instruction, ScriptState &script);
143 void executeSound(const FCLInstruction &instruction);
144 void readSystemVariables();
145 void writeSystemVariables();
146 void setScriptVariable(byte index, uint32 value);
147 void setVariableResult(const FCLInstruction &instruction, ScriptState &script, uint32 value);
148 int32 getVariableOrConstant(int32 operand, Token::Type type) const;
149 void getObjectReference(const FCLInstruction &instruction, uint16 &area, uint16 &id) const;
150 ObjectData *scriptObject(uint16 area, uint16 id);
151 ObjectData *scriptAnimator(const FCLInstruction &instruction);
152 void collectObjects(uint16 area, uint16 id, Common::Array<uint16> &objects);
153 void setObjectStatus(uint16 area, uint16 id, Token::Type operation);
154 bool moveAnimation(ScriptState &script, Math::Vector3d movement, bool absolute);
155 void updateInteractions();
156 void interact(bool shot);
157 void printMessage(uint16 indicator, const Common::String &message);
158 void updateIndicators();
159 uint32 indicatorColor(byte color, int y) const;
160
162 Common::Array<ConditionData> _globalConditions;
163 Common::Array<uint16> _indicatorData;
164 Common::Array<uint16> _controlData;
165
166 byte _palette[256 * 3] = {};
167 uint16 _initialPlayerHeight;
168 uint16 _initialCondition = 0, _timerInterval = 0, _activationRange = 0;
169 uint32 _kitVariables[256] = {};
170 uint32 _changedVariables = 0;
171 uint32 _scriptTicks = 0, _timerTicks = 0, _delayUntil = 0;
172 int _lastScriptTick = 0;
173 bool _timerTriggered = false, _initialScriptPending = false;
174 bool _scriptFrameActive = false, _scriptDelayed = false;
175 int _pendingSound = -1;
176 byte _pendingInteractions = 0, _shootCooldown = 0, _activateCooldown = 0;
177 uint _scriptQueueIndex = 0;
178 Common::Array<ScriptEntry> _scriptQueue;
179 Common::Array<ScriptState *> _suspendedScripts;
180 Graphics::ManagedSurface _scriptSurface;
181 Graphics::ManagedSurface _borderPixels;
182};
183
184} // namespace Freescape
185
186#endif
Definition: keymap.h:66
Definition: stream.h:745
Definition: str.h:59
Definition: ustr.h:57
Definition: freescape.h:191
Definition: geometricobject.h:34
Definition: 3dck.h:30
bool canLoadGameStateCurrently(Common::U32String *msg=nullptr) override
Definition: 3dck.h:49
bool canSaveGameStateCurrently(Common::U32String *msg=nullptr) override
Definition: 3dck.h:50
Definition: managed_surface.h:51
Definition: system.h:166
Definition: area.h:36
Definition: advancedDetector.h:164
Definition: events.h:218
Definition: execution_3dck16.h:36