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
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (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, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20  *
21  */
22 
23 #ifndef FULLPIPE_GFX_H
24 #define FULLPIPE_GFX_H
25 
26 #include "common/ptr.h"
27 
28 namespace Graphics {
29 	struct Surface;
30 	struct TransparentSurface;
31 }
32 
33 namespace Fullpipe {
34 
35 class DynamicPhase;
36 class Movement;
37 struct PicAniInfo;
38 
39 typedef Common::Array<int32> Palette;
40 typedef Common::Point Dims;
41 
42 typedef Common::SharedPtr<Graphics::TransparentSurface> TransSurfacePtr;
43 
44 struct Bitmap {
45 	int _x;
46 	int _y;
47 	int _width;
48 	int _height;
49 	int _type;
50 	int _dataSize;
51 	int _flags;
52 	int _flipping;
53 	TransSurfacePtr _surface;
54 
55 	Bitmap();
56 	Bitmap(const Bitmap &src);
57 	~Bitmap();
58 
59 	void load(Common::ReadStream *s);
60 	void decode(byte *pixels, const Palette &palette);
61 	void putDib(int x, int y, const Palette &palette, byte alpha);
62 	bool putDibRB(byte *pixels, const Palette &palette);
63 	void putDibCB(byte *pixels, const Palette &palette);
64 
65 	void colorFill(uint32 *dest, int len, int32 color);
66 	void paletteFill(uint32 *dest, byte *src, int len, const Palette &palette);
67 	void copierKeyColor(uint32 *dest, byte *src, int len, int keyColor, const Palette &palette, bool cb05_format);
68 	void copier(uint32 *dest, byte *src, int len, const Palette &palette, bool cb05_format);
69 
70 	/** ownership of returned object is transferred to caller */
71 	Bitmap *reverseImage(bool flip = true) const;
72 	/** ownership of returned object is transferred to caller */
73 	Bitmap *flipVertical() const;
74 
75 	void drawShaded(int type, int x, int y, const Palette &palette, int alpha);
76 	void drawRotated(int x, int y, int angle, const Palette &palette, int alpha);
77 
78 	bool isPixelHitAtPos(int x, int y);
79 
80 private:
81 	Bitmap operator=(const Bitmap &);
82 };
83 
84 class Picture : public MemoryObject {
85 public:
86 	Picture();
87 	virtual ~Picture();
88 
89 	void freePicture();
90 	void freePixelData();
91 
92 	virtual bool load(MfcArchive &file);
93 	void setAOIDs();
94 	virtual void init();
95 	void getDibInfo();
96 	const Bitmap *getPixelData();
97 	virtual void draw(int x, int y, int style, int angle);
98 	void drawRotated(int x, int y, int angle);
99 
getAlpha()100 	byte getAlpha() { return (byte)_alpha; }
setAlpha(byte alpha)101 	void setAlpha(byte alpha) { _alpha = alpha; }
102 
getDimensions()103 	Dims getDimensions() const { return Dims(_width, _height); }
104 	bool isPointInside(int x, int y);
105 	bool isPixelHitAtPos(int x, int y);
106 	int getPixelAtPos(int x, int y);
107 	int getPixelAtPosEx(int x, int y);
108 
getConvertedBitmap()109 	const Bitmap *getConvertedBitmap() const { return _convertedBitmap.get(); }
getPaletteData()110 	const Palette &getPaletteData() const { return _paletteData; }
111 	void setPaletteData(const Palette &pal);
112 
113 	void copyMemoryObject2(Picture &src);
114 
115 	int _x, _y;
116 
117 protected:
118 	Common::Rect _rect;
119 	Common::ScopedPtr<Bitmap> _convertedBitmap;
120 	int _field_44;
121 	int _width;
122 	int _height;
123 	Common::ScopedPtr<Bitmap> _bitmap;
124 	int _field_54;
125 	Common::ScopedPtr<MemoryObject2> _memoryObject2;
126 	int _alpha;
127 	Palette _paletteData;
128 
129 	void displayPicture();
130 };
131 
132 class BigPicture : public Picture {
133   public:
BigPicture()134 	BigPicture() {}
~BigPicture()135 	virtual ~BigPicture() {}
136 
137 	virtual bool load(MfcArchive &file);
138 	virtual void draw(int x, int y, int style, int angle);
139 };
140 
141 class GameObject : public CObject {
142   public:
143 	int16 _odelay;
144 	int _field_8;
145 	int16 _flags;
146 	int16 _id;
147 	Common::String _objectName;
148 	int _ox;
149 	int _oy;
150 	int _priority;
151 	int _field_20;
152 
153   public:
154 	GameObject();
155 	GameObject(GameObject *src);
156 
157 	virtual Common::String toXML();
158 	virtual bool load(MfcArchive &file);
159 	void setOXY(int x, int y);
160 	void renumPictures(Common::Array<StaticANIObject *> *lst);
161 	void renumPictures(Common::Array<PictureObject *> *lst);
setFlags(int16 flags)162 	void setFlags(int16 flags) { _flags = flags; }
clearFlags()163 	void clearFlags() { _flags = 0; }
getName()164 	Common::String getName() { return _objectName; }
165 
166 	bool getPicAniInfo(PicAniInfo &info);
167 	bool setPicAniInfo(const PicAniInfo &info);
168 };
169 
170 class PictureObject : public GameObject {
171 public:
172 	PictureObject();
173 
174 	PictureObject(PictureObject *src);
175 
176 	virtual bool load(MfcArchive &file, bool bigPicture);
load(MfcArchive & file)177 	virtual bool load(MfcArchive &file) { assert(0); return false; } // Disable base class
178 
getDimensions()179 	Dims getDimensions() const { return _picture->getDimensions(); }
180 	void draw();
181 	void drawAt(int x, int y);
182 
183 	bool setPicAniInfo(const PicAniInfo &picAniInfo);
184 	bool isPointInside(int x, int y);
185 	bool isPixelHitAtPos(int x, int y);
186 	void setOXY2();
187 
188 	Common::SharedPtr<Picture> _picture;
189 
190 private:
191 	Common::Array<GameObject> _pictureObject2List;
192 	int _ox2;
193 	int _oy2;
194 };
195 
196 class Background : public CObject {
197 public:
198 	/** list items are owned */
199 	Common::Array<PictureObject *> _picObjList;
200 
201 	Common::String _bgname;
202 	int _x;
203 	int _y;
204 	int16 _messageQueueId;
205 	Palette _palette;
206 	/** list items are owned */
207 	Common::Array<BigPicture *> _bigPictureArray;
208 	uint _bigPictureXDim;
209 	uint _bigPictureYDim;
210 
211 public:
212 	Background();
213 	virtual ~Background();
214 
215 	virtual bool load(MfcArchive &file);
216 	void addPictureObject(PictureObject *pct);
217 
getBigPicture(int x,int y)218 	BigPicture *getBigPicture(int x, int y) { return _bigPictureArray[y * _bigPictureXDim + x]; }
219 };
220 
221 struct ShadowsItem {
222 	int width;
223 	int height;
224 	DynamicPhase *dynPhase;
225 };
226 
227 typedef Common::Array<ShadowsItem> ShadowsItemArray;
228 
229 class Shadows : public CObject {
230 	int _sceneId;
231 	int _staticAniObjectId;
232 	int _movementId;
233 	ShadowsItemArray _items;
234 
235   public:
236 	Shadows();
237 	virtual bool load(MfcArchive &file);
238 	void init();
239 
240 	void initMovement(Movement *mov);
241 	DynamicPhase *findSize(int width, int height);
242 };
243 
244 } // End of namespace Fullpipe
245 
246 #endif /* FULLPIPE_GFX_H */
247