ScummVM API documentation
sprites.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_SPRITES_H
23 #define MADS_SPRITES_H
24 
25 #include "common/scummsys.h"
26 #include "common/array.h"
27 #include "mads/assets.h"
28 #include "mads/msurface.h"
29 
30 namespace MADS {
31 
32 enum SpriteFlags {
33  IMG_STATIC = 0, // Item should remain fixed on the screen
34  IMG_UPDATE = 1, // Item needs to be redrawn
35  IMG_ERASE = -1, // Erase image and remove it
36  IMG_REFRESH = -2, // Full refresh
37  IMG_OVERPRINT = -3, // Interface overprint
38  IMG_DELTA = -4, // Delta change
39  IMG_FULL_UPDATE = -5, // Interface refresh
40  IMG_UPDATE_ONLY = -20 // Update the active screen area only
41 };
42 
43 class MADSEngine;
44 
45 struct BGR8 {
46  uint8 b, g, r;
47 };
48 
49 typedef struct {
50  int32 x; // x position relative to GrBuff(0, 0)
51  int32 y; // y position relative to GrBuff(0, 0)
52  int32 scale_x; // x scale factor (can be negative for reverse draw)
53  int32 scale_y; // y scale factor (can't be negative)
54  uint8* depth_map; // depth code array for destination (doesn't care if srcDepth is 0)
55  BGR8* Pal; // palette for shadow draw (doesn't care if SHADOW bit is not set in Src.encoding)
56  uint8* ICT; // Inverse Color Table (doesn't care if SHADOW bit is not set in Src.encoding)
57  uint8 depth; // depth code for source (0 if no depth processing)
58 } DrawRequestX;
59 
60 typedef struct {
61  uint32 Pack;
62  uint32 Stream;
63  long hot_x;
64  long hot_y;
65  uint32 Width;
66  uint32 Height;
67  uint32 Comp;
68  uint32 Reserved[8];
69  uint8* data;
70 } RendCell;
71 
72 #define SS_HEADER_NUM_FIELDS 14
74  uint32 header;
75  uint32 size;
76  uint32 packing;
77  uint32 frameRate;
78  uint32 pixSpeed;
79  uint32 maxWidth;
80  uint32 maxHeight;
81  uint32 reserved3;
82  uint32 reserved4;
83  uint32 reserved5;
84  uint32 reserved6;
85  uint32 reserved7;
86  uint32 reserved8;
87  uint32 count;
88 };
89 
90 #define SF_HEADER_NUM_FIELDS 15
92  uint32 pack;
93  uint32 stream;
94  uint32 x;
95  uint32 y;
96  uint32 width;
97  uint32 height;
98  uint32 comp;
99  uint32 reserved1;
100  uint32 reserved2;
101  uint32 reserved3;
102  uint32 reserved4;
103  uint32 reserved5;
104  uint32 reserved6;
105  uint32 reserved7;
106  uint32 reserved8;
107 };
108 
109 class MSprite : public MSurface {
110 private:
111  void loadSprite(Common::SeekableReadStream *source, const Common::Array<RGB6> &palette);
112 public:
113  MSprite();
115  const Common::Rect &bounds);
116  ~MSprite() override;
117 
118  Common::Point _offset;
119  int _transparencyIndex;
120 
121  byte getTransparencyIndex() const;
122 };
123 
125 public:
126  int _spritesIndex;
127  int _frameNumber;
128  Common::Point _position;
129  int _depth;
130  int _scale;
131 };
132 
133 class SpriteSlot : public SpriteSlotSubset {
134 private:
135  static MADSEngine *_vm;
136  friend class SpriteSlots;
137 public:
138  SpriteFlags _flags;
139  int _seqIndex;
140 public:
141  SpriteSlot();
142  SpriteSlot(SpriteFlags type, int seqIndex);
143 
144  void setup(int dirtyAreaIndex);
145  bool operator==(const SpriteSlotSubset &other) const;
146  void copy(const SpriteSlotSubset &other);
147 };
148 
149 class SpriteSlots : public Common::Array<SpriteSlot> {
150 private:
151  MADSEngine *_vm;
152 public:
153  SpriteSlots(MADSEngine *vm);
154 
159  void reset(bool flag = true);
160 
165  void deleteEntry(int index);
166 
170  void setDirtyAreas();
171 
175  void fullRefresh(bool clearAll = false);
176 
180  int deleteTimer(int seqIndex);
181 
185  int add();
186 
190  void drawBackground();
191 
195  void drawSprites(MSurface *s);
196 
197  void cleanUp();
198 };
199 
200 class SpriteSets : public Common::Array<SpriteAsset *> {
201 private:
202  MADSEngine *_vm;
203 public:
204  SpriteAsset *_uiSprites;
205 public:
209  SpriteSets(MADSEngine *vm) : _vm(vm), _uiSprites(nullptr) {}
210 
214  ~SpriteSets();
215 
219  void clear();
220 
224  int add(SpriteAsset *asset, int idx = 0);
225 
229  int addSprites(const Common::Path &resName, int flags = 0);
230 
234  void remove(int idx);
235 
236  SpriteAsset *&operator[](int idx);
237 };
238 
239 } // End of namespace MADS
240 
241 #endif /* MADS_SPRITES_H */
Definition: sprites.h:45
Definition: array.h:52
Definition: rect.h:144
Definition: path.h:52
Definition: stream.h:745
Out copy(In first, In last, Out dst)
Definition: algorithm.h:52
Definition: sprites.h:73
Definition: sprites.h:91
Definition: sprites.h:133
SpriteSets(MADSEngine *vm)
Definition: sprites.h:209
Definition: sprites.h:60
Definition: sprites.h:49
Definition: rect.h:45
Definition: sprites.h:124
Definition: mads.h:87
Definition: assets.h:61
Definition: sprites.h:149
Definition: action.h:28
Definition: msurface.h:172
Definition: sprites.h:200
Definition: sprites.h:109