ScummVM API documentation
atds.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_ATDS_H
23 #define CHEWY_ATDS_H
24 
25 #include "common/str.h"
26 #include "common/str-array.h"
27 #include "chewy/resource.h"
28 #include "chewy/text.h"
29 
30 namespace Chewy {
31 
32 #define ATDS_VOC_OFFSET 20
33 
34 #define AAD_MAX_PERSON 10
35 
36 #define AAD_STR_START 0
37 #define AAD_STR_END 1
38 #define AAD_DATA 0
39 #define ATS_DATA 1
40 #define DIALOG_CLOSEUP_DATA 2 // ADS_DATA
41 #define INV_USE_DATA 4
42 #define INV_ATS_DATA 6
43 
44 #define MAX_HANDLE 8
45 #define AAD_HANDLE 0
46 #define ADS_HANDLE 2
47 
48 #define MAX_STR_SPLIT 10
49 
50 #define SPLIT_CENTER 1
51 #define SPLIT_LEFT 2
52 
53 #define ATDS_END_LINE 0
54 #define ATDS_END_BLOCK 0x0b
55 #define ATDS_END_ENTRY 0x0c
56 #define ATDS_END_TEXT 0x0d
57 #define ATDS_END 0x0e
58 #define BLOCKENDE 0x0f
59 
60 #define MAX_ATS_ROOM 100
61 
62 #define ATS_ACTIVE_BIT 1
63 #define ATS_COUNT_BIT 2
64 #define ATS_RESET_BIT 4
65 #define ATS_ACTION_BIT 8
66 
67 #define MAX_ATS_STATUS 3
68 
69 #define TXT_MARK_NAME 0
70 #define TXT_MARK_LOOK 1
71 #define TXT_MARK_USE 2
72 #define TXT_MARK_WALK 3
73 #define TXT_MARK_TALK 4
74 
75 #define CONTROL_BYTE 0xff
76 
77 #define DIALOG_CLOSEUP_MAX 6
78 #define DIALOG_CLOSEUP_STACK_SIZE 50
79 
80 #define ADS_EXIT_BIT 1
81 #define ADS_SHOW_BIT 2
82 #define ADS_RESTART_BIT 4
83 
84 struct KbdMouseInfo;
85 class Text;
86 
87 struct AtdsVar {
88  int16 _silent = 0;
89  int16 _delay = 1;
90  int16 _diaNr = 0;
91 
92  bool _eventsEnabled = false;
93  int16 _vocNr = 0;
94 
95  void (*aad_str)(int16 diaNr, int16 strNr, int16 personNr, int16 mode) = nullptr;
96 };
97 
98 #define IUID_IIB 0
99 #define IUID_SIB 1
100 #define IUID_REC 2
101 #define IUID_AUTO 3
102 #define IUID_DET 4
103 #define IUID_PLAYER 5
104 #define INV_USE_DEF 16
105 
106 struct AadInfo {
107  int16 _x;
108  int16 _y;
109  int16 _color;
110 
111  AadInfo() : _x(0), _y(0), _color(0) {}
112  void load(Common::SeekableReadStream *src);
113  static constexpr int SIZE() { return 6; }
114 };
115 
116 class AadInfoArray : public Common::Array<AadInfo> {
117 public:
118  void load(const void *data, size_t count);
119 };
120 
121 struct AadStrHeader {
122  int16 _akPerson;
123  int16 _vocNr;
124 };
125 
126 // ADS (dialog closeup) header
128  int16 _diaNr;
129  int16 _perNr;
130  int16 _aMov;
131  int16 _curNr;
132 
133  bool load(const void *src);
134  static constexpr int SIZE() { return 8; }
135 };
136 
138  int16 _dialog;
139  int16 _autoDia;
140  DialogCloseupTxtHeader _txtHeader;
141  AadInfoArray _person;
142  char *_ptr;
143  char *_blockPtr;
144  int16 _strNr;
145  int16 _delayCount;
146  int16 _silentCount;
147 };
148 
150  int16 _blkNr;
151  int16 _endNr;
152 };
153 
154 struct AadVar {
155  int16 _dialog;
156 
157  DialogCloseupTxtHeader *_txtHeader;
158  AadStrHeader *_strHeader;
159  AadInfoArray _person;
160  char *_ptr;
161  int16 _strNr;
162  int16 _delayCount;
163  int16 _silentCount;
164 };
165 
166 struct AtsTxtHeader {
167  uint16 _txtNr = 0;
168  int16 _aMov = 0;
169  int16 _curNr = 0;
170 
171  bool load(Common::SeekableReadStream *src);
172  static constexpr int SIZE() { return 8; }
173 };
174 
175 struct AtsVar {
176  AtsTxtHeader _txtHeader;
177  uint16 vocNum;
178  Common::String text;
179  int16 _delayCount;
180  int16 _silentCount;
181  int16 _color;
182  int16 _txtMode;
183  bool shown;
184 };
185 
187  char **_strPtr;
188  int16 *_x;
189  int16 _y;
190  short _nr;
191  int16 _next;
192 
193  SplitStringRet() {
194  _strPtr = nullptr;
195  _x = nullptr;
196  _y = 0;
197  _nr = 0;
198  _next = 0;
199  }
200 };
201 
203  char *_str;
204 
205  int16 _x;
206  int16 _y;
207 };
208 
209 class Atdsys {
210 public:
211  Atdsys();
212  ~Atdsys();
213 
214  void set_delay(int16 *delay, int16 silent);
215  void set_split_win(int16 nr, int16 x, int16 y);
216  void split_string(SplitStringInit *ssi, SplitStringRet *ret);
217  void calc_txt_win(SplitStringInit *ssi);
218  void str_null2leer(char *strStart, char *strEnd);
219  void load_atds(int16 chunkNr, int16 mode);
220 
221  void set_handle(int16 mode, int16 chunkStart, int16 chunkNr);
222  bool start_ats(int16 txtNr, int16 txtMode, int16 color, int16 mode, int16 *vocNr);
223  void stop_ats();
224  bool atsShown() { return _atsv.shown; }
225  void print_ats(int16 x, int16 y, int16 scrX, int16 scrY);
226  int16 getControlBit(int16 txtNr, int16 bitIdx);
227  void setControlBit(int16 txtNr, int16 bitIdx);
228  void delControlBit(int16 txtNr, int16 bitIdx);
229  void set_ats_str(int16 txtNr, int16 txtMode, int16 strNr, int16 mode);
230  void set_ats_str(int16 txtNr, int16 strNr, int16 mode);
231  int16 start_aad(int16 diaNr, bool continueWhenSpeechEnds = false);
232  void stopAad();
233  void print_aad(int16 scrX, int16 scrY);
234  int16 aadGetStatus();
235  void set_string_end_func(void (*strFunc)(int16 diaNr, int16 strNr, int16 personNr, int16 mode));
236  void aad_search_dia(int16 diaNr, char **ptr);
237  int16 aadGetTxtLen(char *str);
238 
239  bool startDialogCloseup(int16 diaNr);
240  void stopDialogCloseup();
241  char **dialogCloseupItemPtr(uint16 dialogNum, int16 blockNr, int16 *retNr);
242  DialogCloseupNextBlock *dialogCloseupItemChoice(uint16 dialogNum, int16 blockNr, int16 itemNr);
243  DialogCloseupNextBlock *calcNextDialogCloseupBlock(uint16 dialogNum, int16 blockNr, int16 itemNr);
244  int16 getDialogCloseupStatus();
245  void hideDialogCloseupItem(int16 diaNr, int16 blockNr, int16 itemNr);
246  void showDialogCloseupItem(int16 diaNr, int16 blockNr, int16 itemNr);
247  int16 getDialogCloseupBlock(uint16 dialogNum);
248  void dialogCloseupSearchBlock(int16 blockNr, char **ptr);
249  void dialogCloseupSearchItem(int16 itemNr, char **blkAdr);
250  int16 startAutoDialogCloseup(char *itemAdr);
251 
252  int16 calc_inv_no_use(int16 curInv, int16 testNr);
253  int8 getStereoPos(int16 x);
254  void enableEvents(bool nr) {
255  _atdsv._eventsEnabled = nr;
256  }
257 
258  void saveAtdsStream(Common::WriteStream *stream);
259  void loadAtdsStream(Common::SeekableReadStream *stream);
260  uint32 getAtdsStreamSize() const;
261 
262  Common::StringArray getTextArray(uint dialogNum, uint entryNum, int type, int subEntry = -1);
263  Common::String getTextEntry(uint dialogNum, uint entryNum, int type, int subEntry = -1);
264  int16 getLastSpeechId();
265 
266 private:
267  void init();
268  int16 get_delay(int16 txt_len);
269  void initItemUseWith();
270 
271  char *_atdsMem[MAX_HANDLE] = { nullptr };
272  int16 _atdsPoolOff[MAX_HANDLE] = { 0 };
273  AadVar _aadv;
274  AtsVar _atsv;
275  DialogCloseupVariables _dialogCloseup;
276  AtdsVar _atdsv;
277  char *_ePtr[DIALOG_CLOSEUP_MAX] = { nullptr };
278  int16 _eNr[DIALOG_CLOSEUP_MAX] = { 0 };
279  DialogCloseupNextBlock _dialogCloseupNextBlock;
280  uint8 _dialogCloseupStack[DIALOG_CLOSEUP_STACK_SIZE] = { 0 };
281  int16 _dialogCloseupStackPtr;
282  bool _continueWhenSpeechEnds = false;
283 
284  SplitStringInit _ssi[AAD_MAX_PERSON] = {
285  { 0, 100, 0 },
286  { 0, 100, 0 },
287  { 0, 100, 0 },
288  { 0, 100, 0 },
289  { 0, 100, 0 },
290  { 0, 100, 0 },
291  { 0, 100, 0 },
292  { 0, 100, 0 },
293  { 0, 100, 0 },
294  { 0, 100, 0 },
295  };
296 
297  char *_splitPtr[MAX_STR_SPLIT] = { nullptr };
298  int16 _splitX[MAX_STR_SPLIT] = { 0 };
299  int16 _invBlockNr;
300  int16 _mousePush = 0;
301  int _printDelayCount1 = 0;
302  DialogResource *_dialogResource;
303  Text *_text;
304 
305  Common::HashMap<uint32, uint16> _itemUseWithDesc;
306 };
307 
308 } // namespace Chewy
309 
310 #endif
Definition: atds.h:166
Definition: str.h:59
Definition: text.h:73
Definition: atds.h:209
Definition: stream.h:77
Definition: array.h:52
Definition: atds.h:175
Definition: stream.h:745
Definition: atds.h:116
Definition: resource.h:204
Definition: atds.h:202
Definition: atds.h:121
Definition: atds.h:154
Definition: atds.h:87
Definition: ani_dat.h:25
Definition: atds.h:137
Definition: atds.h:149
Definition: atds.h:106
Definition: atds.h:186
Definition: atds.h:127