ScummVM API documentation
globals.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_GLOBALS_H
23 #define CHEWY_GLOBALS_H
24 
25 #include "common/array.h"
26 #include "common/rect.h"
27 #include "chewy/chewy.h"
28 #include "chewy/types.h"
29 #include "chewy/atds.h"
30 #include "chewy/room.h"
31 #include "chewy/movclass.h"
32 #include "chewy/timer.h"
33 #include "chewy/barriers.h"
34 #include "chewy/text.h"
35 #include "chewy/object.h"
36 #include "chewy/effect.h"
37 
38 namespace Chewy {
39 
40 #define MAX_ZOBJ 60
41 #define MAX_RAND_NO_USE 6
42 #define R45_MAX_PERSON 9
43 
44 extern const uint8 RAND_NO_USE[MAX_RAND_NO_USE];
45 
46 class ChewyFont;
47 class Cursor;
48 class FontMgr;
49 class McgaGraphics;
50 class Memory;
51 
52 class Globals {
53  class CurrentScreen : public Graphics::Surface {
54  public:
55  CurrentScreen() {
56  w = pitch = SCREEN_WIDTH;
57  h = SCREEN_HEIGHT;
59  }
60  CurrentScreen &operator=(byte *p) {
61  setPixels(p);
62  return *this;
63  }
64  byte *getPixels() { return (byte *)Graphics::Surface::getPixels(); }
65  };
66 
67  struct ZObjSort {
68  uint8 ObjArt;
69  uint8 ObjNr;
70  int16 ObjZ;
71  };
72 public:
73  Globals();
74  ~Globals();
75 public:
76  int16 _ani_invent_anf[3] = { 38, 39, 21 };
77  int16 _ani_invent_delay[3][2] = {
78  { 12, 12 }, { 10, 10 }, { 11, 11 }
79  };
80  int16 _ani_count[3] = { 38, 39, 21 };
81  int16 _timer_nr[MAX_TIMER_OBJ] = { 0 };
82 public:
83  CurrentScreen _currentScreen;
84  GameState _gameState;
85 
86  int16 _pfeil_ani = 0;
87  int16 _pfeil_delay = 0;
88  int16 _auto_p_nr = 0;
89 
90  int16 _zoom_horizont = 0;
91  int16 _zoom_mov_fak = 0;
92 
93  int16 _auto_obj = 0;
94 
95  int16 _mouseLeftClick = 0;
96  Common::String _calc_inv_text_str1, _calc_inv_text_str2;
97  bool _stopAutoMove[3] = { false };
98  bool _e_streifen = false;
99  int16 _r45_delay = 0;
100  int16 _r56koch_flug = 0;
101  int16 _r62Delay = 0;
102  int16 _r62TalkAni = 0;
103  int16 _r64TalkAni = 0;
104  int16 _r63ChewyAni = 0;
105  int16 _r63Schalter = 0;
106  int16 _r63RunDia = 0;
107  int16 _r65tmp_scrollx = 0;
108  int16 _r65tmp_scrolly = 0;
109  int16 _r65tmp_ch_x = 0;
110  int16 _r65tmp_ch_y = 0;
111  int16 _r65tmp_ho_x = 0;
112  int16 _r65tmp_ho_y = 0;
113  int16 _r68HohesC = 0;
114 
115  // global.cpp
116  const uint8 *_chewy_ph_nr;
117  const uint8 *_chewy_ph;
118  byte *_pal = nullptr;
119  int16 _scr_width = 0;
120  BlendMode _fx_blend = BLEND_NONE;
121  void (*_SetUpScreenFunc)() = nullptr;
122 
123  int16 _FrameSpeed = 0;
124  int16 _FrameSpeedTmp = 0;
125 
126  byte **_ablage = nullptr;
127  byte *_workpage = nullptr;
128  byte *_workptr = nullptr;
129  byte *_spblende = nullptr;
130  char **_dialogCloseupItemPtr = nullptr;
131 
132  int16 _ads_dia_nr = 0;
133  int16 _ads_item_nr = 0;
134  int16 _ads_blk_nr = 0;
135  int16 _ads_push = 0;
136 
137  int16 _ads_tmp_dsp = 0;
138  int8 _menu_display = 0;
139  int16 _menu_lauflicht = 0;
140  int16 _menu_item = 0;
141  int16 _menu_item_vorwahl = 0;
142  int16 _maus_old_x = 0;
143  int16 _maus_old_y = 0;
144  int16 _inventoryNr = 0;
145  int16 _invent_cur_mode = 0;
146  byte *_inv_spr[MAX_MOV_OBJ] = { nullptr };
147  int16 _person_tmp_hide[MAX_PERSON] = { 0 };
148  int16 _person_tmp_room[MAX_PERSON] = { 0 };
149 
150  int16 _talk_start_ani = -1;
151  int16 _talk_hide_static = -1;
152  bool _savegameFlag = false;
153  int _timer_action_ctr = 0;
154 
155  AutoMov _auto_mov[MAX_AUTO_MOV];
156  int16 _HowardMov = 0;
157 
158  TafSeqInfo *_spz_tinfo = nullptr;
159  int16 _SpzDelay = 0;
160  int16 _spz_spr_nr[MAX_SPZ_PHASEN] = { 0 };
161  int16 _spz_start = 0;
162  int16 _spz_akt_id = 0;
163 
164  int16 _spz_p_nr = 0;
165  int16 _spz_delay[MAX_PERSON] = { 0 };
166  int16 _spz_count = 0;
167  int16 _spz_ani[MAX_PERSON] = { 0 };
168 
169  int16 _AkChewyTaf = 0;
170  int16 _PersonAni[MAX_PERSON] = { 0 };
171  TafSeqInfo *_PersonTaf[MAX_PERSON] = { nullptr };
172  uint8 _PersonSpr[MAX_PERSON][8] = {{ 0 }};
173 
174  RoomDetailInfo *_Rdi = nullptr;
175  StaticDetailInfo *_Sdi = nullptr;
176  AniDetailInfo *_Adi = nullptr;
177  TafInfo *_menutaf = nullptr;
178  TafSeqInfo *_howard_taf = nullptr;
179  TafInfo *_chewy = nullptr;
180  Barriers *_barriers = nullptr;
181  Text *_txt = nullptr;
182  Room *_room = nullptr;
183  Object *_obj = nullptr;
184  Timer *_uhr = nullptr;
185  Detail *_det = nullptr;
186  Effect *_fx = nullptr;
187  Atdsys *_atds = nullptr;
188  MovClass *_mov = nullptr;
189 
190  ObjMov _moveState[MAX_PERSON];
191  SprInfo _spr_info[MAX_PROG_ANI];
192  MovInfo _spieler_mi[MAX_PERSON];
193  ObjMov _auto_mov_vector[MAX_OBJ_MOV];
194  MovInfo _auto_mov_obj[MAX_OBJ_MOV];
195  MovPhasen _mov_phasen[MAX_OBJ_MOV];
196  MovLine _mov_line[MAX_OBJ_MOV][5];
197  TimerBlk _ani_timer[MAX_TIMER_OBJ];
198  int16 _person_end_phase[MAX_PERSON] = { 0 };
199  int16 _ani_stand_count[MAX_PERSON] = { 0 };
200  bool _ani_stand_flag[MAX_PERSON] = { false };
201 
202  MouseInfo _minfo;
203  RaumBlk _room_blk;
204  Flags _flags = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
205  0, 0, 0, 0, 0, 0, 0, 0 };
206  byte *_tempArea = nullptr;
207  GotoPkt _gpkt;
208  bool _disableScreen = false;
209 
210  int16 _r45_pinfo[R45_MAX_PERSON][4] = {
211  { 0, 4, 1490, 1500 },
212  { 0, 1, 180, 190 },
213  { 0, 1, 40, 60 },
214  { 0, 1, 40, 150 },
215  { 0, 1, 40, 230 },
216  { 0, 1, 40, 340 },
217  { 0, 1, 49, 50 },
218  { 0, 1, 5, 90 },
219  { 0, 1, 7, 190 }
220  };
221 
222  // main.cpp
223  bool _inv_disp_ok = 0;
224  int16 _txt_aus_click = 0;
225  int16 _txt_nummer = 0;
226  int16 _tmp_menu_item = 0;
227  int16 _cur_ausgang_flag = 0;
228  int16 _room_start_nr = 0;
229  int16 _TmpFrameSpeed = 0;
230  Memory *_mem = nullptr;
231  McgaGraphics *_out = nullptr;
232  Cursor *_cur = nullptr;
233  ChewyFont *_font6 = nullptr;
234  ChewyFont *_font8 = nullptr;
235  FontMgr *_fontMgr = nullptr;
236  int16 _scroll_delay = 0;
237 
238  // mcga.cpp
239  int _spriteWidth = 0;
240 
241  // mcga_graphics.cpp
242  int16 _gcurx = 0, _gcury = 0;
243 
244  // menus.cpp
245  int8 _m_flip = 0;
246  int16 _tmp_menu = 0;
247  int16 _show_invent_menu = 0;
248 
249  // sprite.cpp
250  int16 _z_count = 0;
251  ZObjSort _z_obj_sort[MAX_ZOBJ];
252  char _new_vector = false;
253 
254  // timer.cpp
255  bool _timer_int = false;
256  int _timer_count = 0;
257  bool _timer_suspend = false;
258 
259  // Hotspot rect arrays
260  const Common::Rect _cinematicsHotspots[4] = {
261  { 10, 80, 32, 105 },
262  { 10, 150, 32, 175 },
263  { 36, 64, 310, 188 },
264  { -1, -1, -1, -1 }
265  };
266  const Common::Rect _fileHotspots[9] = {
267  { 14, 73, 32, 94 },
268  { 14, 96, 32, 118 },
269  { 36, 64, 310, 128 },
270  { 16, 143, 76, 193 },
271  { 78, 143, 130, 193 },
272  { 132, 143, 178, 193 },
273  { 180, 143, 228, 193 },
274  { 232, 143, 310, 193 },
275  { -1, -1, -1, -1 }
276  };
277  const Common::Rect _inventoryHotspots[9] = {
278  { 21, 25, 51, 39 },
279  { 53, 25, 83, 39 },
280  { -2, -2, -2, -2 },
281  { 213, 25, 243, 39 },
282  { 253, 25, 283, 39 },
283  { 21, 45, 283, 135 },
284  { 257, 151, 307, 165 },
285  { 257, 171, 307, 185 },
286  { -1, -1, -1, -1 }
287  };
288  const Common::Rect _optionHotspots[10] = {
289  { 18, 61, 40, 76 },
290  { 112, 61, 130, 76 },
291  { 82, 104, 144, 139 },
292  { 164, 93, 194, 115 },
293  { 198, 80, 206, 115 },
294  { 210, 55, 302, 138 },
295  { 126, 146, 210, 198 },
296  { 22, 92, 44, 136 },
297  { 50, 92, 72, 136 },
298  { -1, -1, -1, -1 }
299  };
300 };
301 
302 extern Globals *g_globals;
303 
304 #define _G(FIELD) g_globals->_##FIELD
305 
306 void cursorChoice(int16 nr);
307 
308 void hideCur();
309 
310 void showCur();
311 
312 void alloc_buffers();
313 
314 bool mainLoop(int16 mode);
315 
316 void setupScreen(SetupScreenMode mode);
317 
318 void kb_mov(int16 mode);
319 
320 void kb_cur_action(int16 key, int16 mode);
321 void mouseAction();
322 
323 void evaluateObj(int16 objectId, int16 txt_nr);
324 
325 void swap_if_l(int16 *x1, int16 *x2);
326 
327 void printShadowed(int16 x, int16 y, int16 fgCol, int16 bgCol, int16 shadowFgCol,
328  int16 scrWidth, const char *txtPtr);
329 
330 bool autoMove(int16 movNr, int16 playerNum);
331 void get_user_key(int16 mode);
332 void clear_prog_ani();
333 
334 void set_ani_screen();
335 
336 void delInventory(int16 nr);
337 
338 bool isCurInventory(int16 nr);
339 
340 void setShadowPalette(int16 palIdx, bool setPartialPalette);
341 
342 void get_scroll_off(int16 x, int16 y, int16 pic_x, int16 pic_y,
343  int16 *sc_x, int16 *sc_y);
344 
345 void calc_scroll(int16 x, int16 y, int16 pic_x, int16 pic_y,
346  int16 *sc_x, int16 *sc_y);
347 
348 void auto_scroll(int16 scrx, int16 scry);
349 
350 int16 calc_mouse_mov_obj(int16 *auto_nr);
351 
352 void check_mouse_ausgang(int16 x, int16 y);
353 
354 void calcExit(int16 x, int16 y);
355 
356 void goAutoXy(int16 x, int16 y, int16 personNum, int16 mode);
357 
358 void calc_auto_go();
359 
360 void disable_timer();
361 
362 void enable_timer();
363 
364 int16 is_mouse_person(int16 x, int16 y);
365 
366 void calc_mouse_person(int16 x, int16 y);
367 
368 void hide_person();
369 
370 void show_person();
371 
372 void save_person_rnr();
373 
374 void set_person_rnr();
375 
376 bool is_chewy_busy();
377 
378 void standard_init();
379 
380 void tidy();
381 
382 void init_load();
383 
384 void var_init();
385 
386 void new_game();
387 void show_intro();
388 void register_cutscene(int cutsceneNum);
389 void getCutscenes(Common::Array<int> &cutscenes);
390 
391 void init_room();
392 
393 void buildMenu(int16 x, int16 y, int16 xNr, int16 yNr, int16 col, int16 mode);
394 
395 void autoMenu(int16 *x, int16 *y, int16 lineNr, int16 zeilen_hoehe,
396  char *txt, int16 mode);
397 
398 void cur_2_inventory();
399 
400 void inventory_2_cur(int16 nr);
401 
402 void new_invent_2_cur(int16 inv_nr);
403 
404 void invent_2_slot(int16 nr);
405 
406 int16 del_invent_slot(int16 nr);
407 
408 void remove_inventory(int16 nr);
409 
410 void getDisplayCoord(int16 *x, int16 *y, int16 nr);
411 void calcTxtXy(int16 *x, int16 *y, char *txtAdr, int16 txtNr);
412 void calcTxtXy(int16 *x, int16 *y, Common::StringArray &desc);
413 void handleDialogCloseupMenu();
414 
415 void stopDialogCloseupDialog();
416 
417 void play_scene_ani(int16 nr, int16 direction);
418 
419 void timer_action(int16 t_nr);
420 
421 void check_ged_action(int16 index);
422 
423 void enter_room(int16 eib_nr);
424 
425 void exit_room(int16 eib_nr);
426 
427 void flic_cut(int16 nr);
428 
429 int16 sib_event_no_inv(int16 sib_nr);
430 
431 void sib_event_inv(int16 sib_nr);
432 
433 uint16 exit_flip_flop(int16 ani_nr, int16 eib_nr1, int16 eib_nr2,
434  int16 ats_nr1, int16 ats_nr2, int16 sib_nr,
435  int16 spr_nr1, int16 spr_nr2, int16 flag);
436 
437 void loadDialogCloseup(int16 diaNr);
438 
439 void setSsiPos();
440 
441 int16 atsAction(int16 txtNr, int16 txtMode, int16 MODE);
442 
443 void selectDialogOption(int16 diaNr, int16 blkNr, int16 strEndNr);
444 
445 void endDialogCloseup(int16 diaNr, int16 blkNr, int16 strEndNr);
446 
447 void atdsStringStart(int16 diaNr, int16 strNr, int16 personNr,
448  int16 mode);
449 void useItemWithInvItem(int16 itemId);
450 bool calc_inv_no_use(int16 test_nr, int16 mode);
451 int16 calc_person_txt(int16 p_nr);
452 int16 calc_person_click(int16 p_nr);
453 void calc_person_dia(int16 p_nr);
454 void spriteEngine();
455 
456 void calc_z_ebene();
457 
458 void startAniBlock(int16 nr, const AniBlock *ab);
459 
460 void startSetAILWait(int16 aniNr, int16 rep, int16 mode);
461 
462 void startDetailFrame(int16 aniNr, int16 rep, int16 mode,
463  int16 frame);
464 
465 void waitDetail(int16 detNr);
466 
467 void waitShowScreen(int16 frames);
468 
469 void zoom_mov_anpass(ObjMov *om, MovInfo *mi);
470 
471 void calc_zoom(int16 y, int16 zoomFactorX, int16 zoomFactorY,
472  ObjMov *om);
473 
474 bool startAtsWait(int16 txtNr, int16 txtMode, int16 col, int16 mode);
475 void startAadWait(int16 diaNr);
476 
477 void start_aad(int16 diaNr);
478 void aadWait(int16 strNr);
479 void startDialogCloseupWait(int16 diaNr);
480 void start_aad(int16 diaNr, int16 ssiNr, bool continueWhenSpeechEnds = false);
481 void wait_auto_obj(int16 nr);
482 
483 void stop_auto_obj(int16 nr);
484 
485 void continue_auto_obj(int16 nr, int16 repeat);
486 
487 void new_auto_line(int16 nr);
488 void init_auto_obj(int16 auto_nr, const int16 *phasen, int16 lines,
489  const MovLine *pkt);
490 
491 int16 mouse_auto_obj(int16 nr, int16 xoff, int16 yoff);
492 
493 int16 auto_obj_status(int16 nr);
494 
495 int16 mouse_on_prog_ani();
496 
497 void set_spz_delay(int16 delay);
498 
499 void start_spz_wait(int16 ani_id, int16 count, bool reverse, int16 p_nr);
500 
501 bool start_spz(int16 ani_id, int16 count, bool reverse, int16 p_nr);
502 
503 void stop_spz();
504 
505 void calc_person_spz_ani(ObjMov *om);
506 
507 void setPersonPos(int16 x, int16 y, int16 personNr, int16 direction);
508 
509 void setPersonSpr(int16 nr, int16 personNr);
510 
511 void stopPerson(int16 personNr);
512 
513 void mov_objekt(ObjMov *om, MovInfo *mi);
514 
515 void calc_person_end_ani(ObjMov *om, int16 p_nr);
516 
517 void get_phase(ObjMov *om, MovInfo *mi);
518 
519 void get_lr_phase(ObjMov *om, int16 obj_mode);
520 
521 void load_person_ani(int16 ani_id, int16 p_nr);
522 
523 void calc_person_ani();
524 
525 } // namespace Chewy
526 
527 #endif
Definition: types.h:543
Definition: cursor.h:35
Definition: str.h:59
Definition: detail.h:68
Definition: text.h:73
Definition: atds.h:209
Definition: surface.h:67
Definition: object.h:37
Definition: effect.h:37
Definition: timer.h:36
Definition: movclass.h:107
Definition: detail.h:132
Definition: movclass.h:71
Definition: ngstypes.h:29
Definition: rect.h:144
Definition: room.h:74
Definition: types.h:516
Definition: movclass.h:53
Definition: timer.h:48
Definition: types.h:378
Definition: memory.h:29
Definition: ngstypes.h:42
Definition: detail.h:92
Definition: room.h:50
Definition: types.h:527
Definition: types.h:533
Definition: atari-cursor.h:38
Definition: types.h:511
Definition: mcga_graphics.h:29
Definition: globals.h:52
Definition: font.h:30
Definition: movclass.h:38
Definition: detail.h:165
Definition: ani_dat.h:25
Definition: ngstypes.h:36
Definition: detail.h:118
Definition: barriers.h:27
static PixelFormat createFormatCLUT8()
Definition: pixelformat.h:184
Definition: font.h:53
const void * getPixels() const
Definition: surface.h:108