ScummVM API documentation
background.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 #ifndef DRAGONS_BACKGROUND_H
22 #define DRAGONS_BACKGROUND_H
23 
24 #include "common/rect.h"
25 #include "common/system.h"
26 #include "dragons/bigfile.h"
27 #include "dragons/dragonrms.h"
28 #include "dragons/screen.h"
29 
30 namespace Dragons {
31 class PriorityLayer;
32 class Background;
33 
34 void drawTileToSurface(Graphics::Surface *surface, byte *palette, byte *tile, uint32 x, uint32 y);
35 
37 private:
38  BigfileArchive *_bigFileArchive;
39  DragonRMS *_dragonRMS;
40 public:
41  BackgroundResourceLoader(BigfileArchive *bigFileArchive, DragonRMS *dragonRMS);
42  Background *load(uint32 sceneId);
43  Background *load(const char *filename);
44 };
45 
46 typedef struct {
47  int16 _y;
48  int16 _priority;
49 } ScaleBand;
50 
51 class ScaleLayer {
52 public:
53  ScaleLayer();
54  ~ScaleLayer();
55  void load(Common::SeekableReadStream &stream);
56  uint16 getScale(uint16 y);
57  void backup();
58  void restore();
59  void clearAll();
60  void setValue(uint8 index, int16 y, int16 value);
61 
62 private:
63  ScaleBand _bands[32];
64  ScaleBand *_savedBands;
65 };
66 
67 struct TileMap {
68  uint16 w;
69  uint16 h;
70  uint32 size;
71  byte *map;
72  uint16 tileIndexOffset;
73 
74  TileMap() {
75  w = 0;
76  h = 0;
77  size = 0;
78  map = nullptr;
79  tileIndexOffset = 0;
80  }
81 };
82 
83 class Background {
84 private:
85  byte *_data;
86  byte *_tileDataOffset;
87  TileMap _tileMap[4];
88  PriorityLayer *_priorityLayer;
89  ScaleLayer _scaleLayer;
90  byte _palette[512];
91  Graphics::Surface *_layerSurface[3];
92  Common::Point *_points2;
93  uint8 _layerPriority[3];
94  Common::Point _layerOffset[3];
95  AlphaBlendMode _layerAlphaMode[3];
96 
97 public:
98  Background();
99  ~Background();
100 
101  bool load(byte *dataStart, uint32 size);
102  uint16 getWidth();
103  uint16 getHeight();
104  Graphics::Surface *getBgLayer() { return _layerSurface[0]; }
105  Graphics::Surface *getMgLayer() { return _layerSurface[1]; }
106  Graphics::Surface *getFgLayer() { return _layerSurface[2]; }
107  uint8 getBgLayerPriority() { return _layerPriority[0]; }
108  uint8 getMgLayerPriority() { return _layerPriority[1]; }
109  uint8 getFgLayerPriority() { return _layerPriority[2]; }
110 
111  void setBgLayerPriority(uint8 newPriority) { _layerPriority[0] = newPriority; }
112  void setMgLayerPriority(uint8 newPriority) { _layerPriority[1] = newPriority; }
113  void setFgLayerPriority(uint8 newPriority) { _layerPriority[2] = newPriority; }
114 
115  int16 getPriorityAtPoint(Common::Point pos);
116  Common::Point getPoint2(uint32 pointIndex);
117  byte *getPalette() { return _palette; }
118 
119  void overlayPriorityTileMap(byte *data, int16 x, int16 y, int16 w, int16 h);
120  void restorePriorityTileMap(int16 x, int16 y, int16 w, int16 h);
121  void overlayImage(uint16 layerNum, byte *data, int16 x, int16 y, int16 w, int16 h);
122  void restoreTiles(uint16 layerNum, int16 x, int16 y, int16 w, int16 h);
123  void setPalette(byte *newPalette);
124  void setLayerOffset(uint8 layerNumber, Common::Point offset);
125  Common::Point getLayerOffset(uint8 layerNumber);
126  ScaleLayer *getScaleLayer() { return &_scaleLayer; }
127 
128  Dragons::AlphaBlendMode getLayerAlphaMode(uint8 layerNumber);
129  void setLayerAlphaMode(uint8 layerNumber, Dragons::AlphaBlendMode mode);
130 
131 private:
132  Common::Point *loadPoints(Common::SeekableReadStream &stream);
133  Graphics::Surface *initGfxLayer(TileMap &tileMap);
134  void loadGfxLayer(Graphics::Surface *surface, TileMap &tileMap, byte *tiles);
135 
136 };
137 
139 public:
140  void load(TileMap &tileMap, byte *tiles);
141  int16 getPriority(Common::Point pos);
142  void overlayTileMap(byte *data, int16 x, int16 y, int16 w, int16 h);
143  void restoreTileMap(int16 x, int16 y, int16 w, int16 h);
144 protected:
145  int16 _width, _height;
146  int16 _mapWidth, _mapHeight;
147  byte *_map, *_values;
148  byte *_mapBase;
149 };
150 
151 } // End of namespace Dragons
152 
153 #endif //DRAGONS_BACKGROUND_H
Definition: background.h:46
Definition: background.h:36
Definition: surface.h:67
Definition: bigfile.h:42
Definition: stream.h:745
Definition: background.h:51
Definition: dragonrms.h:42
Definition: background.h:67
Definition: rect.h:45
Definition: actor.h:26
Definition: background.h:138
Definition: background.h:83