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 
38 namespace Gob {
39 
40 class Font {
41 public:
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 drawLetter(Surface &surf, uint8 c, uint16 x, uint16 y,
54  uint32 color1, uint32 color2, bool transp) const;
55 
56  void drawString(const Common::String &str, int16 x, int16 y, int16 color1, int16 color2,
57  bool transp, Surface &dest) const;
58 
59 private:
60  const byte *_dataPtr;
61  const byte *_data;
62  const uint8 *_charWidths;
63 
64  int8 _itemWidth;
65  int8 _itemHeight;
66  uint8 _startItem;
67  uint8 _endItem;
68  uint8 _itemSize;
69  int8 _bitWidth;
70 
71  uint16 getCharCount() const;
72  const byte *getCharData(uint8 c) const;
73 };
74 
75 class Video {
76 public:
77 #define GDR_VERSION 4
78 
79 #define PRIMARY_SURFACE 0x80
80 #define RETURN_PRIMARY 0x01
81 #define DISABLE_SPR_ALLOC 0x20
82 #define SCUMMVM_CURSOR 0x100
83 
84 #include "common/pack-start.h" // START STRUCT PACKING
85 
86  struct Color {
87  byte red;
88  byte green;
89  byte blue;
90  } PACKED_STRUCT;
91 
92 #include "common/pack-end.h" // END STRUCT PACKING
93 
94  struct PalDesc {
95  Color *vgaPal;
96  int16 *unused1;
97  int16 *unused2;
98  PalDesc() : vgaPal(0), unused1(0), unused2(0) {}
99  };
100 
101  bool _doRangeClamp;
102 
103  int16 _surfWidth;
104  int16 _surfHeight;
105 
106  int16 _scrollOffsetX;
107  int16 _scrollOffsetY;
108 
109  SurfacePtr _splitSurf;
110  int16 _splitHeight1;
111  int16 _splitHeight2;
112  int16 _splitStart;
113 
114  int16 _screenDeltaX;
115  int16 _screenDeltaY;
116 
117  void initPrimary(int16 mode);
118  SurfacePtr initSurfDesc(int16 width, int16 height, int16 flags = 0);
119 
120  void setSize();
121 
122  void clearScreen();
123  void retrace(bool mouse = true);
124  void waitRetrace(bool mouse = true);
125  void sparseRetrace(int max);
126 
127  void drawPackedSprite(byte *sprBuf, int16 width, int16 height,
128  int16 x, int16 y, int16 transp, Surface &dest);
129  void drawPackedSprite(const char *path, Surface &dest, int width = 320);
130 
131  void setPalColor(byte *pal, byte red, byte green, byte blue) {
132  pal[0] = red << 2;
133  pal[1] = green << 2;
134  pal[2] = blue << 2;
135  }
136  void setPalColor(byte *pal, Color &color) {
137  setPalColor(pal, color.red, color.green, color.blue);
138  }
139  void setPalElem(int16 index, char red, char green, char blue,
140  int16 unused, int16 vidMode);
141  void setPalette(PalDesc *palDesc);
142  void setFullPalette(PalDesc *palDesc);
143  void setPalette(Color *palette);
144 
145  void dirtyRectsClear();
146  void dirtyRectsAll();
147  void dirtyRectsAdd(int16 left, int16 top, int16 right, int16 bottom);
148  void dirtyRectsApply(int left, int top, int width, int height, int x, int y);
149 
150  virtual char spriteUncompressor(byte *sprBuf, int16 srcWidth,
151  int16 srcHeight, int16 x, int16 y, int16 transp,
152  Surface &destDesc) = 0;
153 
154  Video(class GobEngine *vm);
155  virtual ~Video();
156 
157 protected:
158  bool _dirtyAll;
159  Common::List<Common::Rect> _dirtyRects;
160 
161  int _curSparse;
162  uint32 _lastSparse;
163 
164  GobEngine *_vm;
165 
166  void drawPacked(byte *sprBuf, int16 width, int16 height, int16 x, int16 y, byte transp, Surface &dest);
167 };
168 
169 class Video_v1 : public Video {
170 public:
171  char spriteUncompressor(byte *sprBuf, int16 srcWidth, int16 srcHeight,
172  int16 x, int16 y, int16 transp, Surface &destDesc) override;
173 
174  Video_v1(GobEngine *vm);
175  ~Video_v1() override {}
176 };
177 
178 class Video_v2 : public Video_v1 {
179 public:
180  char spriteUncompressor(byte *sprBuf, int16 srcWidth, int16 srcHeight,
181  int16 x, int16 y, int16 transp, Surface &destDesc) override;
182 
183  Video_v2(GobEngine *vm);
184  ~Video_v2() override {}
185 };
186 
187 class Video_v6 : public Video_v2 {
188 public:
189  char spriteUncompressor(byte *sprBuf, int16 srcWidth, int16 srcHeight,
190  int16 x, int16 y, int16 transp, Surface &destDesc) override;
191 
192  Video_v6(GobEngine *vm);
193  ~Video_v6() override {}
194 
195 private:
196  void drawPacked(const byte *sprBuf, int16 x, int16 y, Surface &surfDesc);
197  void drawYUVData(const byte *srcData, Surface &destDesc,
198  int16 width, int16 height, int16 x, int16 y);
199  void drawYUV(Surface &destDesc, int16 x, int16 y,
200  int16 dataWidth, int16 dataHeight, int16 width, int16 height,
201  const byte *dataY, const byte *dataU, const byte *dataV);
202 };
203 
204 } // End of namespace Gob
205 
206 #endif // GOB_VIDEO_H
Definition: gob.h:163
Definition: str.h:59
Definition: video.h:178
Definition: video.h:40
Definition: video.h:169
Definition: video.h:86
Definition: anifile.h:40
Definition: video.h:94
Definition: surface.h:100
Definition: video.h:187
Definition: avi_frames.h:36