ScummVM API documentation
sprite.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 // Sprite management module private header file
23 
24 #ifndef SAGA_SPRITE_H
25 #define SAGA_SPRITE_H
26 
27 namespace Saga {
28 
29 #define SPRITE_ZMAX 16
30 #define SPRITE_ZMASK 0x0F
31 
32 struct SpriteInfo {
33  ByteArray decodedBuffer;
34  int width;
35  int height;
36  int xAlign;
37  int yAlign;
38  byte keepMask;
39 
40  SpriteInfo() : width(0), height(0), xAlign(0), yAlign(0), keepMask(0) {
41  }
42 };
43 
45 
46 class Sprite {
47 public:
48  SpriteList _mainSprites;
49  SpriteList _saveReminderSprites;
50  SpriteList _arrowSprites;
51  SpriteList _inventorySprites;
52 
53  Sprite(SagaEngine *vm);
54  ~Sprite();
55 
56  // draw scaled sprite using background scene mask
57  void drawOccluded(SpriteList &spriteList, uint spriteNumber, const Point &screenCoord, int scale, int depth);
58 
59  // draw scaled sprite using background scene mask
60  void draw(SpriteList &spriteList, uint spriteNumber, const Point &screenCoord, int scale, bool clipToScene = false);
61 
62  // main function
63  void drawClip(const Point &spritePointer, int width, int height, const byte *spriteBuffer, bool clipToScene = false, byte keepMask = 0);
64 
65  void draw(SpriteList &spriteList, uint spriteNumber, const Rect &screenRect, int scale, bool clipToScene = false);
66 
67  void loadList(int resourceId, SpriteList &spriteList, byte keepMask = 0); // load or append spriteList
68  bool hitTest(SpriteList &spriteList, uint spriteNumber, const Point &screenCoord, int scale, const Point &testPoint);
69  void getScaledSpriteBuffer(SpriteList &spriteList, uint spriteNumber, int scale, int &width, int &height, int &xAlign, int &yAlign, const byte *&buffer);
70 
71 private:
72  void decodeRLEBuffer(const byte *inputBuffer, size_t inLength, size_t outLength);
73  void scaleBuffer(const byte *src, int width, int height, int scale, size_t outLength);
74 
75  SagaEngine *_vm;
76  ResourceContext *_spriteContext;
77  ByteArray _decodeBuf;
78 };
79 
80 } // End of namespace Saga
81 
82 #endif
Definition: resource.h:105
Definition: saga.h:497
Definition: rect.h:144
Definition: saga.h:464
Graphics::Surface * scale(const Graphics::Surface &srcImage, int xSize, int ySize)
Definition: actor.h:34
Definition: rect.h:45
Definition: sprite.h:46
Definition: sprite.h:32