ScummVM API documentation
nsp.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 DARKSEED_NSP_H
23 #define DARKSEED_NSP_H
24 
25 #include "common/array.h"
26 #include "common/path.h"
27 #include "common/stream.h"
28 #include "common/scummsys.h"
29 #include "graphics/surface.h"
30 
31 namespace Darkseed {
32 
33 class Sprite {
34 public:
35  uint16 _width;
36  uint16 _height;
37  uint16 _pitch;
38  Common::Array<uint8> _pixels;
39 
40  Sprite(uint16 width, uint16 height, uint16 pitch);
41  bool loadData(Common::SeekableReadStream &readStream);
42  void draw(int x, int y, uint16 frameBottom = 0) const;
43  void draw(Graphics::Surface *dst, int x, int y, uint16 frameBottom = 0) const;
44  void drawScaled(int x, int y, int destWidth, int destHeight, bool flipX) const;
45 
46 private:
47  void clipToScreen(int x, int y, uint16 frameBottom, uint16 *clippedWidth, uint16 *clippedHeight) const;
48 };
49 
50 class Obt {
51 public:
52  uint8 _numFrames;
53  Common::Array<int32> _deltaX;
54  Common::Array<int32> _deltaY;
55  Common::Array<uint8> _frameNo;
56  Common::Array<uint8> _frameDuration;
57  Obt();
58  virtual ~Obt();
59 };
60 
61 class Nsp {
62  Common::Array<Sprite> _frames;
63  Common::Array<Obt> _animations;
64 
65 public:
66  bool load(const Common::Path &filename);
67  bool containsSpriteAt(int index) const {
68  return (int)_frames.size() > index;
69  }
70  const Sprite &getSpriteAt(int index) const;
71  const Obt &getAnimAt(int index);
72  int16 getTotalAnim() const {
73  return (int16)_animations.size();
74  }
75  int16 getMaxSpriteWidth();
76 
77 private:
78  bool load(Common::SeekableReadStream &readStream);
79  bool loadObt(const Common::Path &filename);
80 };
81 
82 } // namespace Darkseed
83 
84 #endif // DARKSEED_NSP_H
Definition: surface.h:67
Definition: path.h:52
Definition: stream.h:745
Definition: nsp.h:61
Definition: nsp.h:33
size_type size() const
Definition: array.h:315
Definition: adlib_worx.h:27
Definition: nsp.h:50