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/nebular/core/palette.h"
30 
31 namespace MADS {
32 namespace Nebular {
33 
34 class RexNebularEngine;
35 class MSprite;
36 class DepthSurface;
37 
41 struct SpriteInfo {
42  MSprite *sprite;
43  int hotX, hotY;
44  int width, height;
45  int scaleX, scaleY;
46  uint8 encoding;
47  byte *inverseColorTable;
48  byte *palette;
49 };
50 
51 /*
52  * Base MADS surface class. This derivces from Graphics::Screen
53  * because it has logic we'll need for our own Screen class that
54  * derives from this one
55  */
56 class BaseSurface : public Graphics::Screen {
57 private:
61  int scaleValue(int value, int scale, int err);
62 protected:
63  static RexNebularEngine *_vm;
64 public:
68  static void setVm(RexNebularEngine *vm) {
69  _vm = vm;
70  }
71 
75  virtual void load(const Common::Path &resName) {
76  }
77 public:
82  free(); // Free the 0x0 surface allocated by Graphics::Screen
83  }
84 
88  BaseSurface(int width, int height) : Graphics::Screen(width, height) {
89  }
90 
94  ~BaseSurface() override {
95  }
96 
101  return Common::Rect(0, 0, this->w, this->h);
102  }
103 
107  inline byte *getPixels() {
108  return (byte *)Graphics::ManagedSurface::getPixels();
109  }
110 
114  inline const void *getPixels() const {
115  return (const byte *)Graphics::ManagedSurface::getPixels();
116  }
117 
121  byte *getBasePtr(int x, int y) {
122  return (byte *)Graphics::ManagedSurface::getBasePtr(x, y);
123  }
124 
128  inline const byte *getBasePtr(int x, int y) const {
129  return (const byte *)Graphics::ManagedSurface::getBasePtr(x, y);
130  }
131 
138  void drawSprite(const Common::Point &pt, SpriteInfo &info, const Common::Rect &clipRect);
139 
144  void scrollX(int xAmount);
145 
150  void scrollY(int yAmount);
151 
155  void translate(Common::Array<RGB6> &palette);
156 
160  void translate(byte map[PALETTE_COUNT]);
161 
165  BaseSurface *flipHorizontal() const;
166 
171  void copyRectTranslate(BaseSurface &srcSurface, const byte *paletteMap,
172  const Common::Point &destPos, const Common::Rect &srcRect);
173 
184  void copyFrom(BaseSurface &src, const Common::Point &destPos, int depth, DepthSurface *depthSurface,
185  int scale, bool flipped, int transparentColor = -1);
186 };
187 
188 class MSurface : public BaseSurface {
189 protected:
194  void addDirtyRect(const Common::Rect &r) override {
195  }
196 public:
197  MSurface() : BaseSurface() {
198  }
199  MSurface(int width, int height) : BaseSurface(width, height) {
200  }
201 };
202 
203 class DepthSurface : public MSurface {
204 public:
209 
213  DepthSurface() : MSurface(), _depthStyle(0) {
214  }
215 
219  int getDepth(const Common::Point &pt);
220 
223  int getDepthHighBit(const Common::Point &pt);
224 };
225 
226 } // namespace Nebular
227 } // namespace MADS
228 
229 #endif
Definition: screen.h:210
Definition: nebular.h:51
Common::Rect getBounds()
Definition: msurface.h:100
Definition: array.h:52
BaseSurface()
Definition: msurface.h:81
Definition: msurface.h:203
virtual void load(const Common::Path &resName)
Definition: msurface.h:75
const void * getBasePtr(int x, int y) const
Definition: managed_surface.h:252
Definition: rect.h:524
Definition: path.h:52
Definition: screen.h:47
Definition: sprites.h:110
const void * getPixels() const
Definition: msurface.h:114
Definition: msurface.h:56
int _depthStyle
Definition: msurface.h:208
Definition: msurface.h:41
DepthSurface()
Definition: msurface.h:213
void * getPixels()
Definition: managed_surface.h:271
Definition: formatinfo.h:28
Definition: rect.h:144
~BaseSurface() override
Definition: msurface.h:94
Definition: mps_installer.h:31
static void setVm(RexNebularEngine *vm)
Definition: msurface.h:68
BaseSurface(int width, int height)
Definition: msurface.h:88
const byte * getBasePtr(int x, int y) const
Definition: msurface.h:128
Definition: msurface.h:188
byte * getPixels()
Definition: msurface.h:107
byte * getBasePtr(int x, int y)
Definition: msurface.h:121
void addDirtyRect(const Common::Rect &r) override
Definition: msurface.h:194