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