ScummVM API documentation
graphics.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 SNATCHER_GRAPHICS_H
23#define SNATCHER_GRAPHICS_H
24
25#include "common/func.h"
26#include "common/platform.h"
27#include "snatcher/info.h"
28#include "snatcher/resource.h"
29#include "snatcher/saveflags.h"
30
31class OSystem;
32
33namespace Common {
34class SeekableWriteStream;
35} // namespace Common
36
37namespace Graphics {
38struct PixelFormat;
39} // namespace Graphics
40
41namespace Snatcher {
42
43class Palette;
44class TransitionManager;
45class Animator;
46class SceneModule;
47class SoundEngine;
48class TextRenderer;
49
51public:
52 GraphicsEngine(const Graphics::PixelFormat *pxf, OSystem *system, Common::Platform platform, const VMInfo &vmstate, SoundEngine *snd, bool enableAspectRatioCorrection);
54
55 void runScript(ResourcePointer res, int func);
56 void enqueuePaletteEvent(ResourcePointer res);
57 bool enqueueDrawCommands(ResourcePointer res);
58 void initAnimations(ResourcePointer res, uint16 len, bool dontUpdate);
59
60 enum ScrollMode : uint8 {
61 kHorzA = 0,
62 kVertA = 1,
63 kHorzB = 2,
64 kVertB = 3,
65 kSingleStep = 4
66 };
67
68 void setScrollStep(uint8 mode, int16 step);
69 void transitionCommand(uint8 cmd);
70 bool transitionStateBusy() const;
71
72 void setTextFont(const uint8 *font, uint32 fontSize, const uint8 *charWidthTable, uint32 charWidthTableSize);
73 void printText(const uint8 *text);
74 void setTextPrintDelay(uint16 delay);
75 bool isTextInQueue() const;
76 void resetTextFields();
77 void clearTextInputLine();
78 uint8 getVerbAreaType() const;
79 bool isVerbsTabActive() const;
80
81 void updateSaveLoadDialog(SaveInfo &saveInfo);
82
83 void updateAnimations();
84 void updateText();
85 void nextFrame();
86
87 enum ResetType : uint16 {
88 kResetPalEvents = 1 << 0,
89 kResetSetDefaults = 1 << 1,
90 kResetSetDefaultsExt = 1 << 2,
91 kResetCopyCmds = 1 << 3,
92 kResetAnimations = 1 << 4,
93 kResetScrollState = 1 << 5
94 };
95
96 void reset(int mode);
97
98 void setVar(uint8 var, uint8 val);
99 uint8 getVar(uint8 var) const;
100
101 enum AnimParameters : int {
102 kAnimParaEnable = 0,
103 kAnimParaBlinkRate,
104 kAnimParaDrawFlags,
105 kAnimParaPosX,
106 kAnimParaPosY,
107 kAnimParaRelSpeedX,
108 kAnimParaRelSpeedY,
109 kAnimParaPalette,
110 kAnimParaTarget,
111 kAnimParaOvrTile,
112 kAnimParaF1c,
113 kAnimParaTimeStamp,
114 kAnimParaPhase,
115 kAnimParaControlFlags,
116 kAnimParaAllowFrameDrop,
117 kAnimParaFrameSeqCounter,
118 kAnimParaFrame,
119 kAnimParaFrameDelay,
120 kAnimParaActionTimer,
121 kAnimParaBlink,
122 kAnimParaBlinkCounter,
123 kAnimParaBlinkDuration,
124 kAnimParaAbsSpeedX,
125 kAnimParaAbsSpeedY,
126 kAnimParaScriptComFlags,
127 kAnimFreezeFlag
128 };
129
130 enum AnimFlags : int {
131 kAnimNone = 0,
132 kAnimPause = 1 << 0,
133 kAnimHide = 1 << 1,
134 kAnimAudioSync = 1 << 2
135 };
136
137 void setAnimParameter(uint8 animObjId, int param, int32 value);
138 void setAnimGroupParameter(uint8 animObjId, int groupOp, int32 value = 0);
139 int32 getAnimParameter(uint8 animObjId, int param) const;
140 uint8 getAnimScriptByte(uint8 animObjId, uint16 offset) const;
141 void addAnimParameterFlags(uint8 animObjId, int param, int flags);
142 void clearAnimParameterFlags(uint8 animObjId, int param, int flags);
143 bool testAnimParameterFlags(uint8 animObjId, int param, int flags) const;
144 void animCopySpec(uint8 srcAnimObjId, uint8 dstAnimObjId);
145
146 uint16 screenWidth() const;
147 uint16 screenHeight() const;
148 uint16 realScreenWidth() const;
149 uint16 realScreenHeight() const;
150
151 bool busy(int type) const;
152 uint16 frameCount() const;
153
154 void loadState(Common::SeekableReadStream *in, SaveFlags flags);
155 void saveState(Common::SeekableWriteStream *out, SaveFlags flags);
156 void postLoadProcess();
157
158 void createMouseCursor();
159
160 int displayBootLogoFrame(int frameNo);
161
162public:
163 struct GfxState {
164 GfxState(const VMInfo &vminfo) : vm(vminfo) {
165 memset(vars, 0, sizeof(vars));
166 frameCounter = 0;
167 }
168
169 uint8 getVar(uint8 var) const {
170 assert(var < ARRAYSIZE(vars));
171 return vars[var];
172 }
173
174 void setVar(uint8 var, uint8 val) {
175 assert(var < ARRAYSIZE(vars));
176 vars[var] = val;
177 }
178
179 bool testFlag(uint8 var, uint8 bit) const {
180 assert(var < ARRAYSIZE(vars));
181 return vars[var] & (1 << bit);
182 }
183
184 void setFlag(uint8 var, uint8 bit) {
185 assert(var < ARRAYSIZE(vars));
186 vars[var] |= (1 << bit);
187 }
188
189 void clearFlag(uint8 var, uint8 bit) {
190 assert(var < ARRAYSIZE(vars));
191 vars[var] &= ~(1 << bit);
192 }
193
194 uint16 frameCount() const {
195 return frameCounter;
196 }
197
198 void nextFrame() {
199 ++frameCounter;
200 }
201
202 uint32 getAudioSync() const {
203 return vm.audioSync;
204 }
205
206 uint16 getDropFrames() const {
207 return vm.dropFrames;
208 }
209
210 uint16 frameCount2() const {
211 return vm.frameCounter;
212 }
213
214 private:
215 uint8 vars[13];
216 uint16 frameCounter;
217 const VMInfo &vm;
218 };
219
220private:
221 void restoreDefaultsExt();
222 void restoreDefaults();
223
224 GfxState _state;
225 const uint8 _bpp;
226 uint8 _dataMode;
227 uint8 _verbAreaType;
228
229 uint8 *_animSaveLoadData;
230 Common::SharedPtr<const uint8> _animSaveLoadDataExt;
231 bool _trsNeedsUpdate;
232
233 uint8 *_screen;
234 Animator *_animator;
235 Palette *_palette;
236 TextRenderer *_text;
237 TransitionManager *_trs;
238 OSystem *_system;
239};
240
241} // End of namespace Snatcher
242
243#endif // SNATCHER_GRAPHICS_H
Definition: stream.h:745
Definition: stream.h:351
Definition: system.h:166
Definition: atari-screen.h:42
Definition: animator.h:33
Definition: graphics.h:50
Definition: palette.h:42
Definition: resource.h:52
Definition: sound.h:42
Definition: text.h:32
Definition: transition.h:36
Platform
Definition: platform.h:93
#define ARRAYSIZE(x)
Definition: util.h:114
Definition: algorithm.h:29
Definition: formatinfo.h:28
Definition: pixelformat.h:138
Definition: graphics.h:163
Definition: state.h:51
Definition: info.h:30