ScummVM API documentation
video.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 * This file is dual-licensed.
22 * In addition to the GPLv3 license mentioned above, this code is also
23 * licensed under LGPL 2.1. See LICENSES/COPYING.LGPL file for the
24 * full text of the license.
25 *
26 */
27
28#ifndef GOB_VIDEO_H
29#define GOB_VIDEO_H
30
31#include "common/list.h"
32#include "common/rect.h"
33#include "common/ptr.h"
34
35#include "gob/gob.h"
36#include "gob/surface.h"
37
38namespace Gob {
39
40class Font {
41public:
42 Font(const byte *data);
43 ~Font();
44
45 uint8 getCharWidth (uint8 c) const;
46 uint8 getCharWidth () const;
47 uint8 getCharHeight() const;
48
49 bool hasChar(uint8 c) const;
50
51 bool isMonospaced() const;
52
53 void drawLetterRaw(Surface &surf, uint8 c, uint16 x, uint16 y,
54 uint32 color1, uint32 color2, bool transp) const;
55 void drawLetter(Surface &surf, uint8 c, uint16 x, uint16 y,
56 uint8 colorIndex1, uint8 colorIndex2, bool transp) const;
57
58 void drawString(const Common::String &str, int16 x, int16 y, uint8 colorIndex1, uint8 colorIndex2,
59 bool transp, Surface &dest) const;
60
61private:
62 const byte *_dataPtr;
63 const byte *_data;
64 const uint8 *_charWidths;
65
66 int8 _itemWidth;
67 int8 _itemHeight;
68 uint8 _startItem;
69 uint8 _endItem;
70 uint8 _itemSize;
71 int8 _bitWidth;
72
73 uint16 getCharCount() const;
74 const byte *getCharData(uint8 c) const;
75};
76
77class Video {
78public:
79#define GDR_VERSION 4
80
81#define PRIMARY_SURFACE 0x80
82#define RETURN_PRIMARY 0x01
83#define DISABLE_SPR_ALLOC 0x20
84#define SCUMMVM_CURSOR 0x100
85
86#include "common/pack-start.h" // START STRUCT PACKING
87
88 struct Color {
89 byte red;
90 byte green;
91 byte blue;
92 } PACKED_STRUCT;
93
94#include "common/pack-end.h" // END STRUCT PACKING
95
96 struct PalDesc {
97 Color *vgaPal;
98 uint32 highColorMap[256];
99 int16 *unused1;
100 int16 *unused2;
101 PalDesc() : vgaPal(nullptr), unused1(nullptr), unused2(nullptr) {
102 memset(highColorMap, 0, sizeof(highColorMap));
103 }
104 };
105
106 bool _doRangeClamp;
107
108 int16 _surfWidth;
109 int16 _surfHeight;
110
111 int16 _scrollOffsetX;
112 int16 _scrollOffsetY;
113
114 SurfacePtr _splitSurf;
115 int16 _splitHeight1;
116 int16 _splitHeight2;
117 int16 _splitStart;
118
119 int16 _screenDeltaX;
120 int16 _screenDeltaY;
121
122 void initPrimary(int16 mode);
123 SurfacePtr initSurfDesc(int16 width, int16 height, int16 flags = 0, byte bpp = 0);
124
125 void setSize(Graphics::PixelFormat *highColorFormat = nullptr);
126
127 void clearScreen();
128 void retrace(bool mouse = true);
129 void waitRetrace(bool mouse = true);
130 void sparseRetrace(int max);
131
132 void drawPackedSprite(byte *sprBuf, int16 width, int16 height,
133 int16 x, int16 y, int16 transp, Surface &dest);
134 void drawPackedSprite(const char *path, Surface &dest, int width = 320);
135
136 void setPalColor(byte *pal, byte red, byte green, byte blue) {
137 pal[0] = red << 2;
138 pal[1] = green << 2;
139 pal[2] = blue << 2;
140 }
141 void setPalColor(byte *pal, Color &color) {
142 setPalColor(pal, color.red, color.green, color.blue);
143 }
144 void setPalElem(int16 index, char red, char green, char blue,
145 int16 unused, int16 vidMode);
146 void setPalette(PalDesc *palDesc);
147 void setFullPalette(PalDesc *palDesc);
148 void setPalette(Color *palette);
149
150 void dirtyRectsClear();
151 void dirtyRectsAll();
152 void dirtyRectsAdd(int16 left, int16 top, int16 right, int16 bottom);
153 void dirtyRectsApply(int left, int top, int width, int height, int x, int y);
154
155 virtual char spriteUncompressor(byte *sprBuf, int16 srcWidth,
156 int16 srcHeight, int16 x, int16 y, int16 transp,
157 Surface &destDesc) = 0;
158
159 Video(class GobEngine *vm);
160 virtual ~Video();
161
162protected:
163 bool _dirtyAll;
164 Common::List<Common::Rect> _dirtyRects;
165
166 int _curSparse;
167 uint32 _lastSparse;
168
169 GobEngine *_vm;
170
171 void drawPacked(byte *sprBuf, int16 width, int16 height, int16 x, int16 y, byte transp, Surface &dest);
172};
173
174class Video_v1 : public Video {
175public:
176 char spriteUncompressor(byte *sprBuf, int16 srcWidth, int16 srcHeight,
177 int16 x, int16 y, int16 transp, Surface &destDesc) override;
178
179 Video_v1(GobEngine *vm);
180 ~Video_v1() override {}
181};
182
183class Video_v2 : public Video_v1 {
184public:
185 char spriteUncompressor(byte *sprBuf, int16 srcWidth, int16 srcHeight,
186 int16 x, int16 y, int16 transp, Surface &destDesc) override;
187
188 Video_v2(GobEngine *vm);
189 ~Video_v2() override {}
190};
191
192class Video_v6 : public Video_v2 {
193public:
194 char spriteUncompressor(byte *sprBuf, int16 srcWidth, int16 srcHeight,
195 int16 x, int16 y, int16 transp, Surface &destDesc) override;
196
197 Video_v6(GobEngine *vm);
198 ~Video_v6() override {}
199
200private:
201 Graphics::PixelFormat _highColorPackedSpriteFormat;
202
203 void drawPacked(const byte *sprBuf, int16 x, int16 y, Surface &surfDesc);
204 void drawYUVData(const byte *srcData, Surface &destDesc,
205 int16 width, int16 height, int16 x, int16 y);
206 void drawYUV(Surface &destDesc, int16 x, int16 y,
207 int16 dataWidth, int16 dataHeight, int16 width, int16 height,
208 const byte *dataY, const byte *dataU, const byte *dataV);
209};
210
211} // End of namespace Gob
212
213#endif // GOB_VIDEO_H
Definition: str.h:59
Definition: video.h:40
Definition: gob.h:166
Definition: surface.h:106
Definition: video.h:174
Definition: video.h:183
Definition: video.h:192
Definition: video.h:77
Definition: video.h:88
Definition: video.h:96
Definition: pixelformat.h:138