ScummVM API documentation
base-costume.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 SCUMM_BASE_COSTUME_H
23 #define SCUMM_BASE_COSTUME_H
24 
25 #include "common/scummsys.h"
26 #include "scumm/actor.h" // for CostumeData
27 
28 namespace Scumm {
29 
30 #include "common/pack-start.h" // START STRUCT PACKING
31 
32 struct CostumeInfo {
33  uint16 width, height;
34  int16 relX, relY;
35  int16 moveX, moveY;
36 } PACKED_STRUCT;
37 
38 #include "common/pack-end.h" // END STRUCT PACKING
39 
40 
41 extern const byte smallCostumeScaleTable[256];
42 extern const byte bigCostumeScaleTable[768];
43 
44 
45 class Actor;
46 class ScummEngine;
47 struct VirtScreen;
48 
50 protected:
51  ScummEngine *_vm;
52 
53 public:
54  BaseCostumeLoader(ScummEngine *vm) : _vm(vm) {}
55  virtual ~BaseCostumeLoader() {}
56 
57  virtual void loadCostume(int id) = 0;
58  virtual bool increaseAnims(Actor *a) = 0;
59  virtual void costumeDecodeData(Actor *a, int frame, uint usemask) = 0;
60 
61  virtual bool hasManyDirections(int id) { return false; }
62 };
63 
64 
69 public:
70  Common::Rect _clipOverride;
71  byte _actorID;
72 
73  byte _shadowMode;
74  byte *_shadowTable;
75 
76  int _actorX, _actorY;
77  byte _zbuf;
78  byte _scaleX, _scaleY;
79 
80  int _drawTop, _drawBottom;
81  byte _paletteNum;
82  bool _skipLimbs;
83  bool _actorDrawVirScr;
84 
85 
86 protected:
87  ScummEngine *_vm;
88 
89  // flag to enable AkosRenderer's behaviour in paintCelByleRLECommon() and byleRLEDecode()
90  bool _akosRendering;
91 
92  // Destination
93  Graphics::Surface _out;
94  int32 _numStrips;
95 
96  // Source pointer
97  const byte *_srcPtr;
98 
99  // current move offset
100  int _xMove, _yMove;
101 
102  // whether to draw the actor mirrored
103  bool _drawActorToRight;
104 
105  int _numBlocks;
106 
107  // width and height of cel to decode
108  int _width, _height;
109 
110  // actor _palette
111  uint16 _palette[256] = {};
112 
113 public:
114  struct ByleRLEData {
115  // Parameters for the original ("V1") costume codec.
116  int x;
117  int y;
118  const byte *scaleTable;
119  int skipWidth;
120  byte *destPtr;
121  const byte *maskPtr;
122  int scaleXStep;
123  byte mask, shr;
124  byte repColor;
125  byte repLen;
126  Common::Rect boundsRect;
127  int scaleXIndex, scaleYIndex;
128  int scaleIndexMask;
129  };
130 
131  BaseCostumeRenderer(ScummEngine *scumm, bool akosRendering = false) {
132  _actorID = 0;
133  _shadowMode = 0;
134  _shadowTable = nullptr;
135  _actorX = _actorY = 0;
136  _zbuf = 0;
137  _scaleX = _scaleY = 0;
138  _drawTop = _drawBottom = 0;
139 
140  _vm = scumm;
141  _akosRendering = akosRendering;
142 
143  _numStrips = -1;
144  _srcPtr = nullptr;
145  _xMove = _yMove = 0;
146  _drawActorToRight = false;
147  _width = _height = 0;
148  _skipLimbs = false;
149  _paletteNum = 0;
150  _actorDrawVirScr = false;
151  _numBlocks = 0;
152  }
153  virtual ~BaseCostumeRenderer() {}
154 
155  virtual void setPalette(uint16 *palette) = 0;
156  virtual void setFacing(const Actor *a) = 0;
157  virtual void setCostume(int costume, int shadow) = 0;
158 
159 
160  byte drawCostume(const VirtScreen &vs, int numStrips, const Actor *a, bool drawToBackBuf);
161 
162 protected:
163  virtual byte drawLimb(const Actor *a, int limb) = 0;
164 
165  byte paintCelByleRLECommon(
166  int xMoveCur,
167  int yMoveCur,
168  int numColors,
169  int scaletableSize,
170  bool amiOrPcEngCost,
171  bool c64Cost,
172  ByleRLEData &compData,
173  bool &decode);
174 
175  void byleRLEDecode(ByleRLEData &compData, int16 actorHitX = 0, int16 actorHitY = 0, bool *actorHitResult = nullptr, const uint8 *xmap = nullptr);
176 
177  void skipCelLines(ByleRLEData &compData, int num);
178 
179 private:
180  // helper function to be called from paintCelByleRLECommon
181  virtual void markAsDirty(const Common::Rect &rect, ByleRLEData &compData, bool &decode) {}
182 };
183 
184 } // End of namespace Scumm
185 
186 #endif
Definition: surface.h:67
Definition: base-costume.h:114
Definition: rect.h:524
Definition: scumm.h:511
Definition: gfx.h:185
Definition: base-costume.h:32
Definition: actor.h:100
Definition: base-costume.h:68
Definition: base-costume.h:49
Definition: actor.h:30