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
28namespace Scumm {
29
30#include "common/pack-start.h" // START STRUCT PACKING
31
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
41extern const byte smallCostumeScaleTable[256];
42extern const byte bigCostumeScaleTable[768];
43
44
45class Actor;
46class ScummEngine;
47struct VirtScreen;
48
50protected:
51 ScummEngine *_vm;
52
53public:
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
69public:
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
86protected:
87 ScummEngine *_vm;
88
89 // flag to enable AkosRenderer's behaviour in paintCelByleRLECommon() and byleRLEDecode()
90 bool _akosRendering;
91
92 // Destination
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
113public:
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#ifdef SCUMM_OPTIMISED_CODE
130 int scaledHeight;
131#endif
132 };
133
134 BaseCostumeRenderer(ScummEngine *scumm, bool akosRendering = false) {
135 _actorID = 0;
136 _shadowMode = 0;
137 _shadowTable = nullptr;
138 _actorX = _actorY = 0;
139 _zbuf = 0;
140 _scaleX = _scaleY = 0;
141 _drawTop = _drawBottom = 0;
142
143 _vm = scumm;
144 _akosRendering = akosRendering;
145
146 _numStrips = -1;
147 _srcPtr = nullptr;
148 _xMove = _yMove = 0;
149 _drawActorToRight = false;
150 _width = _height = 0;
151 _skipLimbs = false;
152 _paletteNum = 0;
153 _actorDrawVirScr = false;
154 _numBlocks = 0;
155 }
156 virtual ~BaseCostumeRenderer() {}
157
158 virtual void setPalette(uint16 *palette) = 0;
159 virtual void setFacing(const Actor *a) = 0;
160 virtual void setCostume(int costume, int shadow) = 0;
161
162
163 byte drawCostume(const VirtScreen &vs, int numStrips, const Actor *a, bool drawToBackBuf);
164
165protected:
166 virtual byte drawLimb(const Actor *a, int limb) = 0;
167
168 byte paintCelByleRLECommon(
169 int xMoveCur,
170 int yMoveCur,
171 int numColors,
172 int scaletableSize,
173 bool amiOrPcEngCost,
174 bool c64Cost,
175 ByleRLEData &compData,
176 bool &decode);
177
178 void byleRLEDecode(ByleRLEData &compData, int16 actorHitX = 0, int16 actorHitY = 0, bool *actorHitResult = nullptr, const uint8 *xmap = nullptr);
179#ifdef SCUMM_OPTIMISED_CODE
180 void byleRLEDecodeFast(ByleRLEData &compData, const byte *xmap);
181#endif
182 void skipCelLines(ByleRLEData &compData, int num);
183
184private:
185 // helper functions to be called from paintCelByleRLECommon
186 virtual void clipBoundsRect(Common::Rect &boundsRect) {}
187 virtual void markAsDirty(const Common::Rect &rect, ByleRLEData &compData, bool &decode) {}
188};
189
190} // End of namespace Scumm
191
192#endif
Definition: actor.h:100
Definition: base-costume.h:49
Definition: base-costume.h:68
Definition: scumm.h:536
Definition: actor.h:30
Definition: rect.h:536
Definition: surface.h:67
Definition: base-costume.h:114
Definition: base-costume.h:32
Definition: gfx.h:185