ScummVM API documentation
msurface.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 MADS_MSURFACE_H
23 #define MADS_MSURFACE_H
24 
25 #include "common/scummsys.h"
26 #include "common/path.h"
27 #include "common/rect.h"
28 #include "graphics/screen.h"
29 #include "mads/palette.h"
30 
31 namespace MADS {
32 
33 class MADSEngine;
34 class MSprite;
35 class DepthSurface;
36 
40 struct SpriteInfo {
41  MSprite *sprite;
42  int hotX, hotY;
43  int width, height;
44  int scaleX, scaleY;
45  uint8 encoding;
46  byte *inverseColorTable;
47  byte *palette;
48 };
49 
50 /*
51  * Base MADS surface class. This derivces from Graphics::Screen
52  * because it has logic we'll need for our own Screen class that
53  * derives from this one
54  */
55 class BaseSurface : public Graphics::Screen {
56 private:
60  int scaleValue(int value, int scale, int err);
61 protected:
62  static MADSEngine *_vm;
63 public:
67  static void setVm(MADSEngine *vm) { _vm = vm; }
68 
72  virtual void load(const Common::Path &resName) {}
73 public:
78  free(); // Free the 0x0 surface allocated by Graphics::Screen
79  }
80 
84  BaseSurface(int width, int height) : Graphics::Screen(width, height) {}
85 
89  ~BaseSurface() override {}
90 
94  Common::Rect getBounds() { return Common::Rect(0, 0, this->w, this->h); }
95 
99  inline byte *getPixels() { return (byte *)Graphics::ManagedSurface::getPixels(); }
100 
104  inline const void *getPixels() const { return (const byte *)Graphics::ManagedSurface::getPixels(); }
105 
109  byte *getBasePtr(int x, int y) { return (byte *)Graphics::ManagedSurface::getBasePtr(x, y); }
110 
114  inline const byte *getBasePtr(int x, int y) const { return (const byte *)Graphics::ManagedSurface::getBasePtr(x, y); }
115 
122  void drawSprite(const Common::Point &pt, SpriteInfo &info, const Common::Rect &clipRect);
123 
128  void scrollX(int xAmount);
129 
134  void scrollY(int yAmount);
135 
139  void translate(Common::Array<RGB6> &palette);
140 
144  void translate(byte map[PALETTE_COUNT]);
145 
149  BaseSurface *flipHorizontal() const;
150 
155  void copyRectTranslate(BaseSurface &srcSurface, const byte *paletteMap,
156  const Common::Point &destPos, const Common::Rect &srcRect);
157 
168  void copyFrom(BaseSurface &src, const Common::Point &destPos, int depth, DepthSurface *depthSurface,
169  int scale, bool flipped, int transparentColor = -1);
170 };
171 
172 class MSurface : public BaseSurface {
173 protected:
178  void addDirtyRect(const Common::Rect &r) override {}
179 public:
180  MSurface() : BaseSurface() {}
181  MSurface(int width, int height) : BaseSurface(width, height) {}
182 };
183 
184 class DepthSurface : public MSurface {
185 public:
190 
194  DepthSurface() : MSurface(), _depthStyle(0) {}
195 
199  int getDepth(const Common::Point &pt);
200 
203  int getDepthHighBit(const Common::Point &pt);
204 };
205 
206 } // End of namespace MADS
207 
208 #endif /* MADS_MSURFACE_H */
Definition: msurface.h:55
int _depthStyle
Definition: msurface.h:189
BaseSurface()
Definition: msurface.h:77
Definition: array.h:52
const void * getBasePtr(int x, int y) const
Definition: managed_surface.h:250
Definition: rect.h:144
Definition: path.h:52
BaseSurface(int width, int height)
Definition: msurface.h:84
Common::Rect getBounds()
Definition: msurface.h:94
Definition: screen.h:48
Definition: screen.h:208
void addDirtyRect(const Common::Rect &r) override
Definition: msurface.h:178
Graphics::Surface * scale(const Graphics::Surface &srcImage, int xSize, int ySize)
void * getPixels()
Definition: managed_surface.h:269
Definition: msurface.h:184
Definition: formatinfo.h:28
Definition: rect.h:45
static void setVm(MADSEngine *vm)
Definition: msurface.h:67
DepthSurface()
Definition: msurface.h:194
virtual void load(const Common::Path &resName)
Definition: msurface.h:72
Definition: mads.h:87
const byte * getBasePtr(int x, int y) const
Definition: msurface.h:114
const void * getPixels() const
Definition: msurface.h:104
Definition: action.h:28
~BaseSurface() override
Definition: msurface.h:89
Definition: msurface.h:172
byte * getPixels()
Definition: msurface.h:99
Definition: msurface.h:40
byte * getBasePtr(int x, int y)
Definition: msurface.h:109
Definition: sprites.h:109