ScummVM API documentation
detail.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 CHEWY_DETAIL_H
23 #define CHEWY_DETAIL_H
24 
25 #include "common/path.h"
26 #include "common/scummsys.h"
27 #include "common/stream.h"
28 #include "chewy/ngstypes.h"
29 
30 namespace Chewy {
31 
32 #define SAVE_ROOM 0
33 #define RESTORE_ROOM 1
34 #define MAX_SOUNDS 3
35 
36 #define MAX_AUTO_MOV 20
37 
38 struct RoomInfo {
39  uint8 _roomNr;
40  uint8 _imageNr;
41  uint8 _autoMovNr;
42  uint8 _tafLoad;
43  char _tafName[14];
44  uint8 _zoomFactor;
45  uint8 _dummy;
46 
47  bool load(Common::SeekableReadStream *src);
48  static constexpr int SIZE() {
49  return 4 * 1 + 14 + 1 + 1;
50  }
51 };
52 
53 struct RoomAutoMov {
54  int16 _x;
55  int16 _y;
56  uint8 _sprNr;
57  uint8 _dummy;
58 
59  bool load(Common::SeekableReadStream *src);
60  static constexpr int SIZE() {
61  return 2 + 2 + 1 + 1;
62  }
63 };
64 
65 #define MAXDETAILS 32
66 #define MAX_M_ITEMS 50
67 
68 struct SprInfo {
69  byte *_image = nullptr;
70  int16 _zLevel = 0;
71  int16 _x = 0;
72  int16 _y = 0;
73  int16 X1 = 0;
74  int16 Y1 = 0;
75 };
76 
77 struct SoundDefBlk {
78  // 2 * MAX_SOUNDS sound_enable flags
79  int16 sound_index[MAX_SOUNDS];
80  int16 sound_start[MAX_SOUNDS];
81  int16 channel[MAX_SOUNDS];
82  int16 volume[MAX_SOUNDS];
83  int16 repeats[MAX_SOUNDS];
84  int16 stereo[MAX_SOUNDS];
85 
86  bool load(Common::SeekableReadStream *src);
87  static constexpr int SIZE() {
88  return 7 * 2 * MAX_SOUNDS;
89  }
90 };
91 
92 struct AniDetailInfo {
93  int16 x;
94  int16 y;
95  uint8 start_flag;
96  uint8 repeat;
97  int16 start_ani;
98  int16 end_ani;
99  int16 ani_count;
100  int16 delay;
101  int16 delay_count;
102  int16 reverse;
103  int16 timer_start;
104  int16 z_ebene;
105  uint8 load_flag;
106  uint8 zoom;
107  SoundDefBlk sfx;
108  int16 show_1_phase;
109  int16 phase_nr;
110 
111  bool load(Common::SeekableReadStream *src);
112  static constexpr int SIZE() {
113  return 2 + 2 + 1 + 1 + 2 * 8 + 1 + 1 +
114  SoundDefBlk::SIZE() + 2 + 2;
115  }
116 };
117 
119  int16 x;
120  int16 y;
121  int16 SprNr;
122  int16 z_ebene;
123  bool hide;
124  uint8 Dummy;
125 
126  bool load(Common::SeekableReadStream *src);
127  static constexpr int SIZE() {
128  return 2 + 2 + 2 + 2 + 1 + 1;
129  }
130 };
131 
133  int16 _staticDetailNr = 0;
134  int16 _aniDetailNr = 0;
135  TafInfo *dptr = nullptr;
136  AniDetailInfo Ainfo[MAXDETAILS];
137  StaticDetailInfo staticSprite[MAXDETAILS];
138  int16 mvect[MAX_M_ITEMS * 4] = { 0 };
139  int16 mtxt[MAX_M_ITEMS] = { 0 };
140  RoomInfo Ri;
141  RoomAutoMov autoMove[MAX_AUTO_MOV];
142  int16 detailSfxIndex[MAXDETAILS * MAX_SOUNDS] = { 0 };
143 
144  bool load(Common::SeekableReadStream *src);
145  static constexpr int SIZE() {
146  return 2 + 2 + 4 +
147  (AniDetailInfo::SIZE() * MAXDETAILS) +
148  (StaticDetailInfo::SIZE() * MAXDETAILS) +
149  (2 * MAX_M_ITEMS * 4) +
150  (2 * MAX_M_ITEMS) +
151  RoomInfo::SIZE() +
152  (RoomAutoMov::SIZE() * MAX_AUTO_MOV) +
153  (2 * MAXDETAILS * MAX_SOUNDS) +
154  (4 * MAXDETAILS * MAX_SOUNDS);
155  }
156 };
157 
159  char _id[4];
160  int16 _nr;
161 
162  bool load(Common::SeekableReadStream *src);
163 };
164 
165 class Detail {
166 public:
167  Detail();
168  ~Detail();
169 
170  void load_rdi(const char *fname, int16 room_nr);
171 
172  void load_rdi_taf(const char *fname, int16 load_flag);
173 
174  void setStaticPos(int16 detNr, int16 x, int16 y, bool hideFl, bool correctionFlag);
175  void setDetailPos(int16 detNr, int16 x, int16 y);
176  void hideStaticSpr(int16 detNr);
177  void showStaticSpr(int16 detNr);
178  void freezeAni();
179  void unfreezeAni();
180  void getAniValues(int16 aniNr, int16 *start, int16 *end);
181  AniDetailInfo *getAniDetail(int16 aniNr);
182  void init_taf(TafInfo *dptr);
183  TafInfo *get_taf_info();
184  RoomDetailInfo *getRoomDetailInfo();
185 
186  void set_static_ani(int16 ani_nr, int16 static_nr);
187 
188  void del_static_ani(int16 ani_nr);
189  void startDetail(int16 nr, int16 rep, int16 reverse);
190  void stopDetail(int16 nr);
191  void playSound(int16 nr, int16 slot);
192  void stopSound(int16 slot);
193  void plot_ani_details(int16 scrx, int16 scry, int16 start, int16 end,
194  int16 zoomx, int16 zoomy);
195  void plot_static_details(int16 scrx, int16 scry, int16 start, int16 end);
196  int16 maus_vector(int16 x, int16 y);
197  int16 get_ani_status(int16 det_nr);
198 
199  SprInfo plot_detail_sprite(int16 scrx, int16 scry, int16 det_nr,
200  int16 spr_nr, int16 mode);
201 
202  void set_global_delay(int16 delay);
203 
204  TafInfo *init_taf_tbl(const char *fname);
205 
206  void del_taf_tbl(TafInfo *Tt);
207 
208  void del_taf_tbl(int16 start, int16 nr, TafInfo *Tt);
209 
210  void load_taf_seq(int16 sprNr, int16 sprCount, TafInfo *Tt);
211  void load_taf_tbl(TafInfo *fti);
212 
213  void del_dptr();
214 
215  void calc_zoom_kor(int16 *kx, int16 *ky, int16 xzoom,
216  int16 yzoom);
217 
218  int16 mouse_on_detail(int16 mouse_x, int16 mouse_y,
219  int16 scrx, int16 scry);
220 
221  void set_taf_ani_mem(byte *load_area);
222 
223 private:
224  void load_taf_ani_sprite(int16 nr);
225 
226  RoomDetailInfo _rdi;
227  RdiDataHeader _rdiDataHeader;
228  SprInfo _sprInfo;
229 
230  int16 _globalDelay = 0;
231  bool _aniFreezeflag = false;
232  bool _fullTaf = false;
233  Common::Path _tafName;
234  byte *_tafLoadBuffer = nullptr;
235  int16 _directTafAni = 0;
236 };
237 
238 } // namespace Chewy
239 
240 #endif
Definition: detail.h:77
Definition: detail.h:68
Definition: detail.h:53
Definition: detail.h:132
Definition: ngstypes.h:29
Definition: path.h:52
Definition: stream.h:745
Definition: detail.h:92
Definition: detail.h:38
Definition: detail.h:158
Definition: detail.h:165
Definition: ani_dat.h:25
Definition: detail.h:118