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  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 
97 public:
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 
119 protected:
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 
135 private:
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 markAsDirty(const Common::Rect &rect, ByleRLEData &compData, bool &decode) override;
140 };
141 
142 enum AkosSequenceCodes {
143  // Auxiliary uSweat tokens:
144  AKC_ExtendBit = 0x80,
145  AKC_ExtendWordBit = 0x8000,
146  AKC_CelMask = 0x0FFF,
147 
148  // Opcode uSweat tokens:
149  AKC_CommandMask = 0xC000,
150 
151  AKC_EmptyCel = (AKC_CommandMask | 0x0001),
152 
153  AKC_SetVar = (AKC_CommandMask | 0x0010),
154  AKC_StartSound = (AKC_CommandMask | 0x0015),
155  AKC_IfSoundInVarRunningGoTo = (AKC_CommandMask | 0x0016),
156  AKC_IfNotSoundInVarRunningGoTo = (AKC_CommandMask | 0x0017),
157  AKC_IfSoundRunningGoTo = (AKC_CommandMask | 0x0018),
158  AKC_IfNotSoundRunningGoTo = (AKC_CommandMask | 0x0019),
159 
160  AKC_DrawMany = (AKC_CommandMask | 0x0020),
161  AKC_CondDrawMany = (AKC_CommandMask | 0x0021),
162  AKC_CondRelativeOffsetDrawMany = (AKC_CommandMask | 0x0022),
163  AKC_RelativeOffsetDrawMany = (AKC_CommandMask | 0x0025),
164 
165  AKC_GoToState = (AKC_CommandMask | 0x0030),
166  AKC_IfVarGoTo = (AKC_CommandMask | 0x0031),
167 
168  AKC_AddVar = (AKC_CommandMask | 0x0040),
169  AKC_SoftSound = (AKC_CommandMask | 0x0042),
170  AKC_SoftVarSound = (AKC_CommandMask | 0x0044),
171  AKC_SetUserCondition = (AKC_CommandMask | 0x0045),
172  AKC_SetVarToUserCondition = (AKC_CommandMask | 0x0046),
173  AKC_SetTalkCondition = (AKC_CommandMask | 0x0047),
174  AKC_SetVarToTalkCondition = (AKC_CommandMask | 0x0048),
175  AKC_StartScript = (AKC_CommandMask | 0x0050),
176 
177  AKC_IncVar = (AKC_CommandMask | 0x0060),
178  AKC_StartSound_SpecialCase = (AKC_CommandMask | 0x0061),
179 
180  AKC_IfVarEQJump = (AKC_CommandMask | 0x0070),
181  AKC_IfVarNEJump = (AKC_CommandMask | 0x0071),
182  AKC_IfVarLTJump = (AKC_CommandMask | 0x0072),
183  AKC_IfVarLEJump = (AKC_CommandMask | 0x0073),
184  AKC_IfVarGTJump = (AKC_CommandMask | 0x0074),
185  AKC_IfVarGEJump = (AKC_CommandMask | 0x0075),
186 
187  AKC_StartAnim = (AKC_CommandMask | 0x0080),
188  AKC_StartVarAnim = (AKC_CommandMask | 0x0081),
189  AKC_SetVarRandom = (AKC_CommandMask | 0x0082),
190  AKC_SetActorZClipping = (AKC_CommandMask | 0x0083),
191  AKC_StartActorAnim = (AKC_CommandMask | 0x0084),
192  AKC_SetActorVar = (AKC_CommandMask | 0x0085),
193  AKC_HideActor = (AKC_CommandMask | 0x0086),
194  AKC_SetDrawOffs = (AKC_CommandMask | 0x0087),
195  AKC_JumpToOffsetInVar = (AKC_CommandMask | 0x0088),
196  AKC_SoundStuff = (AKC_CommandMask | 0x0089),
197  AKC_Flip = (AKC_CommandMask | 0x008A),
198  AKC_StartActionOn = (AKC_CommandMask | 0x008B),
199  AKC_StartScriptVar = (AKC_CommandMask | 0x008C),
200  AKC_StartSoundVar = (AKC_CommandMask | 0x008D),
201  AKC_DisplayAuxFrame = (AKC_CommandMask | 0x008E),
202 
203  AKC_IfVarEQDo = (AKC_CommandMask | 0x0090),
204  AKC_IfVarNEDo = (AKC_CommandMask | 0x0091),
205  AKC_IfVarLTDo = (AKC_CommandMask | 0x0092),
206  AKC_IfVarLEDo = (AKC_CommandMask | 0x0093),
207  AKC_IfVarGTDo = (AKC_CommandMask | 0x0094),
208  AKC_IfVarGEDo = (AKC_CommandMask | 0x0095),
209  AKC_EndOfIfDo = (AKC_CommandMask | 0x009F),
210 
211  AKC_StartActorTalkie = (AKC_CommandMask | 0x00A0),
212  AKC_IfTalkingGoTo = (AKC_CommandMask | 0x00A1),
213  AKC_IfNotTalkingGoTo = (AKC_CommandMask | 0x00A2),
214  AKC_StartTalkieInVar = (AKC_CommandMask | 0x00A3),
215  AKC_IfAnyTalkingGoTo = (AKC_CommandMask | 0x00A4),
216  AKC_IfNotAnyTalkingGoTo = (AKC_CommandMask | 0x00A5),
217  AKC_IfTalkingPickGoTo = (AKC_CommandMask | 0x00A6),
218  AKC_IfNotTalkingPickGoTo = (AKC_CommandMask | 0x00A7),
219 
220  AKC_EndSeq = (AKC_CommandMask | 0x00FF)
221 };
222 
223 enum AkosQueuedCommands {
224  AKQC_PutActorInTheVoid = 1,
225  AKQC_StartSound = 3,
226  AKQC_StartAnimation = 4,
227  AKQC_SetZClipping = 5,
228  AKQC_SetXYOffset = 6,
229  AKQC_DisplayAuxFrame = 7,
230  AKQC_StartTalkie = 8,
231  AKQC_SoftStartSound = 9,
232 
233  // For V7-8
234  AKQC_SetSoundVolume = 7,
235  AKQC_SetSoundPan = 8,
236  AKQC_SetSoundPriority = 9
237 };
238 
239 enum AkosAnimTypes {
240  AKAT_Empty = 0x00,
241  AKAT_KillLayer = 0x01,
242  AKAT_LoopLayer = 0x02,
243  AKAT_RunLayer = 0x03,
244  AKAT_LayerInvisible = 0x04,
245  AKAT_LayerVisible = 0x05,
246  AKAT_AlwaysRun = 0x06,
247  AKAT_UserConstant = 0x07,
248  AKAT_DeltaAnim = 0x08
249 };
250 
251 #define GW(o) ((int16)READ_LE_UINT16(aksq + curState + (o)))
252 #define GUW(o) READ_LE_UINT16(aksq + curState + (o))
253 #define GB(o) aksq[curState + (o)]
254 
255 } // End of namespace Scumm
256 
257 #endif
Definition: base-costume.h:114
Definition: rect.h:524
Definition: scumm.h:511
Definition: akos.h:65
Definition: actor.h:100
Definition: base-costume.h:68
Definition: akos.h:44
Definition: base-costume.h:49
Definition: actor.h:30