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