ScummVM API documentation
akos.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_AKOS_H
23#define SCUMM_AKOS_H
24
25#include "scumm/base-costume.h"
26#include "scumm/he/wiz_he.h"
27
28namespace Scumm {
29
30#define AKOS_BYLE_RLE_CODEC 1
31#define AKOS_CDAT_RLE_CODEC 5
32#define AKOS_RUN_MAJMIN_CODEC 16
33#define AKOS_TRLE_CODEC 32
34
35#define AKOS_AUXD_TYPE_EMPTY_FRAME 0x0000
36#define AKOS_AUXD_TYPE_DRLE_FRAME 0x0001
37#define AKOS_AUXD_TYPE_SRLE_FRAME 0x0010
38#define AKOS_AUXD_TYPE_WRLE_FRAME 0x0020
39
40struct CostumeData;
41struct AkosHeader;
42struct AkosOffset;
43
45protected:
46 const byte *_akos = nullptr;
47
48public:
50
51 void loadCostume(int id) override;
52 bool increaseAnims(Actor *a) override;
53 void costumeDecodeData(Actor *a, int frame, uint useMask) override;
54
55 //void animateLimb(int limb, int f);
56 bool hasManyDirections(int id) override {
57 loadCostume(id);
58 return hasManyDirections();
59 }
60
61protected:
62 bool hasManyDirections();
63};
64
66protected:
67 uint16 _codec = 0;
68
69 bool _useBompPalette;
70
71 // pointer to various parts of the costume resource
72 const AkosHeader *_akhd; // Header
73
74 const byte *_akpl; // Color lookup table for the costume
75 const byte *_akci; // AKOS Cel Info block, containing:
76 // - Cel width;
77 // - Cel height;
78 // - Cel x coordinate;
79 // - Cel y coordinate;
80 // - Cel x relative coordinate;
81 // - Cel y relative coordinate.
82
83 const byte *_aksq; // Costume sequence table, containing:
84 // - A sequence of N bytes containing animation commands.
85
86 const AkosOffset *_akof; // Cel offset table, containing:
87 // - Offset starting from the cel data block to the start of cel data;
88 // - Offset starting from the cel info block to the start of cel header.
89
90 const byte *_akcd; // Cel data block (contains the codec specific data)
91
92 const byte *_akct; // Sequence condition table (HE specific)
93 const byte *_rgbs; // Raw costume RGB colors (HE specific)
94 const uint8 *_xmap; // shadow color table (HE specific)
95
96
97public:
98 AkosRenderer(ScummEngine *scumm) : BaseCostumeRenderer(scumm, true) {
99 _useBompPalette = false;
100 _akhd = nullptr;
101 _akpl = nullptr;
102 _akci = nullptr;
103 _aksq = nullptr;
104 _akof = nullptr;
105 _akcd = nullptr;
106 _akct = nullptr;
107 _rgbs = nullptr;
108 _xmap = nullptr;
109 }
110
111 bool _actorHitMode = false;
112 int16 _actorHitX = 0, _actorHitY = 0;
113 bool _actorHitResult = false;
114
115 void setPalette(uint16 *_palette) override;
116 void setFacing(const Actor *a) override;
117 void setCostume(int costume, int shadow) override;
118
119protected:
120 byte drawLimb(const Actor *a, int limb) override;
121
122 byte paintCelByleRLE(int xMoveCur, int yMoveCur);
123 byte paintCelCDATRLE(int xMoveCur, int yMoveCur);
124 byte paintCelMajMin(int xMoveCur, int yMoveCur);
125 byte paintCelTRLE(int actor, int drawToBack, int celX, int celY, int celWidth, int celHeight, byte tcolor, const byte *shadowTablePtr, int32 specialRenderFlags);
126
127#if defined(ENABLE_HE)
128 byte hePaintCel(
129 int actor, int drawToBack, int celX, int celY, int celWidth, int celHeight, byte tcolor, bool allowFlip, const byte *shadowTablePtr,
130 void (*drawPtr)(ScummEngine *vm, Wiz *wiz, WizRawPixel *, int, int, Common::Rect *, const byte *, int, int, Common::Rect *, byte, const byte *shadowTablePtr, const WizRawPixel *conversionTable, int32 specialRenderFlags),
131 const WizRawPixel *conversionTable,
132 int32 specialRenderFlags);
133#endif
134
135private:
136 void majMinCodecDecompress(byte *dest, int32 pitch, const byte *src, int32 t_width, int32 t_height, int32 dir, int32 numSkipBefore, int32 numSkipAfter, byte transparency, int maskLeft, int maskTop, int zBuf);
137
138 void markRectAsDirty(Common::Rect rect);
139 void clipBoundsRect(Common::Rect &boundsRect) override;
140 void markAsDirty(const Common::Rect &rect, ByleRLEData &compData, bool &decode) override;
141};
142
143enum AkosSequenceCodes {
144 // Auxiliary uSweat tokens:
145 AKC_ExtendBit = 0x80,
146 AKC_ExtendWordBit = 0x8000,
147 AKC_CelMask = 0x0FFF,
148
149 // Opcode uSweat tokens:
150 AKC_CommandMask = 0xC000,
151
152 AKC_EmptyCel = (AKC_CommandMask | 0x0001),
153
154 AKC_SetVar = (AKC_CommandMask | 0x0010),
155 AKC_StartSound = (AKC_CommandMask | 0x0015),
156 AKC_IfSoundInVarRunningGoTo = (AKC_CommandMask | 0x0016),
157 AKC_IfNotSoundInVarRunningGoTo = (AKC_CommandMask | 0x0017),
158 AKC_IfSoundRunningGoTo = (AKC_CommandMask | 0x0018),
159 AKC_IfNotSoundRunningGoTo = (AKC_CommandMask | 0x0019),
160
161 AKC_DrawMany = (AKC_CommandMask | 0x0020),
162 AKC_CondDrawMany = (AKC_CommandMask | 0x0021),
163 AKC_CondRelativeOffsetDrawMany = (AKC_CommandMask | 0x0022),
164 AKC_RelativeOffsetDrawMany = (AKC_CommandMask | 0x0025),
165
166 AKC_GoToState = (AKC_CommandMask | 0x0030),
167 AKC_IfVarGoTo = (AKC_CommandMask | 0x0031),
168
169 AKC_AddVar = (AKC_CommandMask | 0x0040),
170 AKC_SoftSound = (AKC_CommandMask | 0x0042),
171 AKC_SoftVarSound = (AKC_CommandMask | 0x0044),
172 AKC_SetUserCondition = (AKC_CommandMask | 0x0045),
173 AKC_SetVarToUserCondition = (AKC_CommandMask | 0x0046),
174 AKC_SetTalkCondition = (AKC_CommandMask | 0x0047),
175 AKC_SetVarToTalkCondition = (AKC_CommandMask | 0x0048),
176 AKC_StartScript = (AKC_CommandMask | 0x0050),
177
178 AKC_IncVar = (AKC_CommandMask | 0x0060),
179 AKC_StartSound_SpecialCase = (AKC_CommandMask | 0x0061),
180
181 AKC_IfVarEQJump = (AKC_CommandMask | 0x0070),
182 AKC_IfVarNEJump = (AKC_CommandMask | 0x0071),
183 AKC_IfVarLTJump = (AKC_CommandMask | 0x0072),
184 AKC_IfVarLEJump = (AKC_CommandMask | 0x0073),
185 AKC_IfVarGTJump = (AKC_CommandMask | 0x0074),
186 AKC_IfVarGEJump = (AKC_CommandMask | 0x0075),
187
188 AKC_StartAnim = (AKC_CommandMask | 0x0080),
189 AKC_StartVarAnim = (AKC_CommandMask | 0x0081),
190 AKC_SetVarRandom = (AKC_CommandMask | 0x0082),
191 AKC_SetActorZClipping = (AKC_CommandMask | 0x0083),
192 AKC_StartActorAnim = (AKC_CommandMask | 0x0084),
193 AKC_SetActorVar = (AKC_CommandMask | 0x0085),
194 AKC_HideActor = (AKC_CommandMask | 0x0086),
195 AKC_SetDrawOffs = (AKC_CommandMask | 0x0087),
196 AKC_JumpToOffsetInVar = (AKC_CommandMask | 0x0088),
197 AKC_SoundStuff = (AKC_CommandMask | 0x0089),
198 AKC_Flip = (AKC_CommandMask | 0x008A),
199 AKC_StartActionOn = (AKC_CommandMask | 0x008B),
200 AKC_StartScriptVar = (AKC_CommandMask | 0x008C),
201 AKC_StartSoundVar = (AKC_CommandMask | 0x008D),
202 AKC_DisplayAuxFrame = (AKC_CommandMask | 0x008E),
203
204 AKC_IfVarEQDo = (AKC_CommandMask | 0x0090),
205 AKC_IfVarNEDo = (AKC_CommandMask | 0x0091),
206 AKC_IfVarLTDo = (AKC_CommandMask | 0x0092),
207 AKC_IfVarLEDo = (AKC_CommandMask | 0x0093),
208 AKC_IfVarGTDo = (AKC_CommandMask | 0x0094),
209 AKC_IfVarGEDo = (AKC_CommandMask | 0x0095),
210 AKC_EndOfIfDo = (AKC_CommandMask | 0x009F),
211
212 AKC_StartActorTalkie = (AKC_CommandMask | 0x00A0),
213 AKC_IfTalkingGoTo = (AKC_CommandMask | 0x00A1),
214 AKC_IfNotTalkingGoTo = (AKC_CommandMask | 0x00A2),
215 AKC_StartTalkieInVar = (AKC_CommandMask | 0x00A3),
216 AKC_IfAnyTalkingGoTo = (AKC_CommandMask | 0x00A4),
217 AKC_IfNotAnyTalkingGoTo = (AKC_CommandMask | 0x00A5),
218 AKC_IfTalkingPickGoTo = (AKC_CommandMask | 0x00A6),
219 AKC_IfNotTalkingPickGoTo = (AKC_CommandMask | 0x00A7),
220
221 AKC_EndSeq = (AKC_CommandMask | 0x00FF)
222};
223
224enum AkosQueuedCommands {
225 AKQC_PutActorInTheVoid = 1,
226 AKQC_StartSound = 3,
227 AKQC_StartAnimation = 4,
228 AKQC_SetZClipping = 5,
229 AKQC_SetXYOffset = 6,
230 AKQC_DisplayAuxFrame = 7,
231 AKQC_StartTalkie = 8,
232 AKQC_SoftStartSound = 9,
233
234 // For V7-8
235 AKQC_SetSoundVolume = 7,
236 AKQC_SetSoundPan = 8,
237 AKQC_SetSoundPriority = 9
238};
239
240enum AkosAnimTypes {
241 AKAT_Empty = 0x00,
242 AKAT_KillLayer = 0x01,
243 AKAT_LoopLayer = 0x02,
244 AKAT_RunLayer = 0x03,
245 AKAT_LayerInvisible = 0x04,
246 AKAT_LayerVisible = 0x05,
247 AKAT_AlwaysRun = 0x06,
248 AKAT_UserConstant = 0x07,
249 AKAT_DeltaAnim = 0x08
250};
251
252#define GW(o) ((int16)READ_LE_UINT16(aksq + curState + (o)))
253#define GUW(o) READ_LE_UINT16(aksq + curState + (o))
254#define GB(o) aksq[curState + (o)]
255
256} // End of namespace Scumm
257
258#endif
Definition: actor.h:100
Definition: akos.h:44
Definition: akos.h:65
Definition: base-costume.h:49
Definition: base-costume.h:68
Definition: scumm.h:536
Definition: actor.h:30
Definition: rect.h:536
Definition: base-costume.h:114