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 AGS_GLOBALS_H
23 #define AGS_GLOBALS_H
24 
25 #include "ags/shared/core/platform.h"
26 #define AGS_PLATFORM_DEFINES_PSP_VARS (AGS_PLATFORM_OS_IOS || AGS_PLATFORM_OS_ANDROID)
27 
28 #include "common/std/queue.h"
29 #include "ags/shared/ac/game_version.h"
30 #include "ags/shared/ac/keycode.h"
31 #include "ags/shared/util/stdio_compat.h"
32 #include "ags/shared/util/string.h"
33 #include "ags/shared/util/string_types.h"
34 #include "ags/shared/util/version.h"
35 #include "ags/shared/font/wfn_font.h"
36 #include "ags/shared/gui/gui_main.h"
37 #include "ags/shared/script/cc_script.h"
38 #include "ags/engine/ac/dynobj/script_game.h"
39 #include "ags/engine/ac/dynobj/script_user_object.h"
40 #include "ags/engine/ac/event.h"
41 #include "ags/engine/ac/file.h"
42 #include "ags/engine/ac/runtime_defines.h"
43 #include "ags/engine/ac/walk_behind.h"
44 #include "ags/engine/main/engine.h"
45 #include "ags/engine/main/graphics_mode.h"
46 #include "ags/engine/media/audio/audio_defines.h"
47 #include "ags/engine/script/script.h"
48 #include "ags/engine/script/script_runtime.h"
49 #include "common/std/array.h"
50 #include "common/std/chrono.h"
51 #include "common/std/memory.h"
52 #include "common/std/set.h"
53 #include "ags/lib/allegro/color.h"
54 #include "ags/lib/allegro/fixed.h"
55 #include "ags/lib/allegro/aintern.h"
56 #include "common/events.h"
57 
58 namespace Common {
59 class DumpFile;
60 }
61 
62 namespace AGS3 {
63 
64 #define MAXCURSORS 20
65 
66 using String = AGS::Shared::String;
67 using Version = AGS::Shared::Version;
68 
69 namespace AGS {
70 namespace Shared {
71 
72 class AssetManager;
73 class Bitmap;
74 class DebugManager;
75 struct Font;
76 class GUIButton;
77 class GUIInvWindow;
78 class GUILabel;
79 class GUIListBox;
80 class GUISlider;
81 class GUITextBox;
82 struct InteractionVariable;
83 struct PlaneScaling;
84 class RoomStruct;
85 class SpriteCache;
86 struct Translation;
87 
88 } // namespace Shared
89 
90 namespace Engine {
91 
92 class ConsoleOutputTarget;
93 struct GfxFilterInfo;
94 class IDriverDependantBitmap;
95 class IGfxDriverFactory;
96 class IGraphicsDriver;
97 class LogFile;
98 class MessageBuffer;
99 
100 } // namespace Engine
101 } // namespace AGS
102 
103 namespace Plugins {
104 namespace Core {
105 class EngineExports;
106 } // namespace Core
107 } // namespace Plugins
108 
109 class IRouteFinder;
110 class Navigation;
111 class SplitLines;
112 class TTFFontRenderer;
113 class WFNFontRenderer;
114 
115 struct AGSCCStaticObject;
116 struct AGSDeSerializer;
117 struct AGSPlatformDriver;
118 struct AmbientSound;
119 struct AnimatingGUIButton;
120 struct CachedActSpsData;
121 struct CCAudioChannel;
122 struct CCAudioClip;
123 struct CCCharacter;
124 struct CCDialog;
125 struct CCDynamicArray;
126 struct CCGUI;
127 struct CCGUIObject;
128 struct CCHotspot;
129 struct ccInstance;
130 struct CCInventory;
131 struct CCObject;
132 struct CCRegion;
133 struct CharacterCache;
134 struct CharacterExtras;
135 struct CharacterInfo;
136 struct color;
137 struct COLOR_MAP;
138 struct CSCIMessage;
139 struct DialogTopic;
140 struct DirtyRects;
141 struct EnginePlugin;
142 struct ExecutingScript;
143 struct EventHappened;
144 struct GameSetup;
145 struct GameSetupStruct;
146 struct GameState;
147 struct IAGSEditorDebugger;
148 struct ICCStringClass;
149 struct ManagedObjectPool;
150 struct Mouse;
151 struct MoveList;
152 struct NewControl;
153 struct NonBlockingScriptFunction;
154 struct ObjectCache;
155 struct OnScreenWindow;
156 struct PluginObjectReader;
157 struct Point;
158 struct ResourcePaths;
159 struct RGB_MAP;
160 struct RoomCameraDrawData;
161 struct RoomObject;
162 struct RoomStatus;
163 struct RuntimeScriptValue;
164 struct ScreenOverlay;
165 struct ScriptAudioChannel;
166 struct ScriptDialog;
167 struct ScriptDialogOptionsRendering;
168 struct ScriptDrawingSurface;
169 struct ScriptError;
170 struct ScriptGUI;
171 struct ScriptHotspot;
172 struct ScriptInvItem;
173 struct ScriptMouse;
174 struct ScriptObject;
175 struct ScriptPosition;
176 struct ScriptRegion;
177 struct ScriptString;
178 struct ScriptSystem;
179 struct SOUNDCLIP;
180 struct SpeechLipSyncLine;
181 struct SpriteListEntry;
182 struct StaticArray;
183 struct CCStaticArray;
184 struct StaticGame;
185 struct SystemImports;
186 struct TopBarSettings;
187 struct ViewStruct;
188 
189 class Globals {
190 public:
191  enum SimdFlags : uint {
192  SIMD_NONE = 0,
193  SIMD_NEON = (1 << 0),
194  SIMD_SSE2 = (1 << 1),
195  SIMD_AVX2 = (1 << 2),
196  };
197 
210  int _errnum = 0;
211  int *_allegro_errno = &_errnum;
212 
213  int __color_depth = 0;
214  int __rgb_r_shift_15 = DEFAULT_RGB_R_SHIFT_15; /* truecolor pixel format */
215  int __rgb_g_shift_15 = DEFAULT_RGB_G_SHIFT_15;
216  int __rgb_b_shift_15 = DEFAULT_RGB_B_SHIFT_15;
217  int __rgb_r_shift_16 = DEFAULT_RGB_R_SHIFT_16;
218  int __rgb_g_shift_16 = DEFAULT_RGB_G_SHIFT_16;
219  int __rgb_b_shift_16 = DEFAULT_RGB_B_SHIFT_16;
220  int __rgb_r_shift_24 = DEFAULT_RGB_R_SHIFT_24;
221  int __rgb_g_shift_24 = DEFAULT_RGB_G_SHIFT_24;
222  int __rgb_b_shift_24 = DEFAULT_RGB_B_SHIFT_24;
223  int __rgb_r_shift_32 = DEFAULT_RGB_R_SHIFT_32;
224  int __rgb_g_shift_32 = DEFAULT_RGB_G_SHIFT_32;
225  int __rgb_b_shift_32 = DEFAULT_RGB_B_SHIFT_32;
226  int __rgb_a_shift_32 = DEFAULT_RGB_A_SHIFT_32;
227 
228  RGB_MAP *_rgb_map = nullptr;
229  COLOR_MAP *_color_map = nullptr;
230  int _trans_blend_alpha = 0;
231  int _trans_blend_red = 0;
232  int _trans_blend_green = 0;
233  int _trans_blend_blue = 0;
234  BlenderMode __blender_mode = kRgbToRgbBlender;
235  uint _simd_flags = SIMD_NONE;
236  /* current format information and worker routines */
237  int _utype = U_UTF8;
238 
239  /* default palette structures */
240  PALETTE _black_palette;
241  PALETTE _current_palette;
242  PALETTE _prev_current_palette;
243 
244  volatile int _mouse_x = 0; // X position
245  volatile int _mouse_y = 0; // Y position
246  volatile int _mouse_z = 0; // Mouse wheel vertical
247  volatile int _mouse_b = 0; // Mouse buttons bitflags
248  volatile int _mouse_pos = 0; // X position in upper 16 bits, Y in lower 16
249 
250  // Accumulated absolute and relative mouse device motion.
251  // May be retrieved by calling *acquire_absxy and *acquire_relxy functions,
252  // after which these are reset, until next motion event is received.
253  volatile int _sys_mouse_x = 0; // mouse x position
254  volatile int _sys_mouse_y = 0; // mouse y position
255  volatile int _sys_mouse_z = 0; // mouse wheel position
256 
257  volatile int _freeze_mouse_flag = 0;
258 
259  // Relative x and y deltas
260  int _mouse_accum_relx = 0, _mouse_accum_rely = 0;
261 
262  int _mouse_button_state = 0;
263  int _mouse_accum_button_state = 0;
264  uint32 _mouse_clear_at_time = 0;
265  eAGSMouseButton _wasbutdown = kMouseNone;
266  int _wasongui = 0;
267 
277 
286  // We don't have many places where we delay longer than a frame, but where we
287  // do, we should give the audio layer a chance to update.
288  // 16 milliseconds is rough period for 60fps
289  const std::chrono::milliseconds _MaximumDelayBetweenPolling = std::chrono::milliseconds(16);
290 
299  AGS::Shared::Bitmap *_glVirtualScreenWrap;
300  std::vector<PluginObjectReader> *_pluginReaders;
301 
310  AGSCCStaticObject *_GlobalStaticManager;
311  CCScriptGame *_GameStaticManager;
312 
321  std::array<SOUNDCLIP *> *_audioChannels;
322  std::array<AmbientSound> *_ambient;
323 
324  ScriptAudioChannel *_scrAudioChannel;
325  int _reserved_channel_count = 0;
326 
327  // This is an indicator of a music played by an old audio system
328  // (to distinguish from the new system API)
329  int _current_music_type = 0;
330  // _G(crossFading) is >0 (channel number of new track), or -1 (old
331  // track fading out, no new track)
332  int _crossFading = 0, _crossFadeVolumePerStep = 0, _crossFadeStep = 0;
333  int _crossFadeVolumeAtStart = 0;
334  SOUNDCLIP *_cachedQueuedMusic = nullptr;
335 
336  // Music update is scheduled when the voice speech stops;
337  // we do a small delay before reverting any volume adjustments
338  bool _music_update_scheduled = false;
339  uint32 _music_update_at = 0;
340 
350 
359  CCDynamicArray *_globalDynamicArray;
360 
369  ICCStringClass *_stringClassImpl = nullptr;
370 
378  ScriptError *_ccError;
379 
388  // Instance thread stack holds a list of running or suspended script instances;
389  // In AGS currently only one thread is running, others are waiting in the queue.
390  // An example situation is repeatedly_execute_always callback running while
391  // another instance is waiting at the blocking action or Wait().
392  std::deque<ccInstance *> *_InstThreads;
393  // [IKM] 2012-10-21:
394  // NOTE: This is temporary solution (*sigh*, one of many) which allows certain
395  // exported functions return value as a RuntimeScriptValue object;
396  // Of 2012-12-20: now used only for plugin exports
397  RuntimeScriptValue *_GlobalReturnValue;
398  Common::DumpFile *_scriptDumpFile = nullptr;
399 
408  int _ccCompOptions;
409 
418  // currently executed line
419  int _currentline = 0;
420  // script file format signature
421  const char *_scfilesig = "SCOM";
422 
431  AGSDeSerializer *_ccUnserializer;
432 
441  int _use_cdplayer = 0;
442  bool _triedToUseCdAudioCommand = false;
443  int _need_to_stop_cd = 0;
444 
453  CharacterInfo *_playerchar = nullptr;
454  int32_t _sc_PlayerCharPtr = 0;
455  int _char_lowest_yp = 0;
456 
457  // Sierra-style speech settings
458  int _face_talking = -1, _facetalkview = 0, _facetalkwait = 0, _facetalkframe = 0;
459  int _facetalkloop = 0, _facetalkrepeat = 0, _facetalkAllowBlink = 1;
460  int _facetalkBlinkLoop = 0;
461  CharacterInfo *_facetalkchar = nullptr;
462  // Do override default portrait position during QFG4-style speech overlay update
463  bool _facetalk_qfg4_override_placement_x = false;
464  bool _facetalk_qfg4_override_placement_y = false;
465 
466  // lip-sync speech settings
467  int _loops_per_character = 0, _text_lips_offset = 0, _char_speaking = -1;
468  int _char_thinking = -1;
469  const char *_text_lips_text = nullptr;
470  std::vector<SpeechLipSyncLine> *_splipsync;
471  int _numLipLines = 0, _curLipLine = -1, _curLipLinePhoneme = 0;
472 
481  int _windowbackgroundcolor, _pushbuttondarkcolor;
482  int _pushbuttonlightcolor;
483  int _topwindowhandle = -1;
484  int _cbuttfont = 0;
485  int _acdialog_font = 0;
486  int _smcode = 0;
487  int _controlid = 0;
488  NewControl **_vobjs;
489  OnScreenWindow *_oswi;
490 
491  int _windowcount = 0, _curswas = 0;
492  int _win_x = 0, _win_y = 0, _win_width = 0, _win_height = 0;
493 
502  int _editor_debugging_enabled = 0;
503  int _editor_debugging_initialized = 0;
504  char _editor_debugger_instance_token[100];
505  IAGSEditorDebugger *_editor_debugger = nullptr;
506  int _break_on_next_script_step = 0;
507  volatile int _game_paused_in_debugger = 0;
508 
509  struct Breakpoint {
510  char scriptName[80] = { 0 };
511  int lineNumber = 0;
512  };
513 
514  std::vector<Breakpoint> _breakpoints;
515 
516  int _debug_flags = 0;
517 
518  int _display_fps;
521 
530  AGS::Shared::DebugManager *_DbgMgr;
531 
540  std::vector<DialogTopic> _dialog;
541  ScriptDialogOptionsRendering *_ccDialogOptionsRendering;
542  ScriptDrawingSurface *_dialogOptionsRenderingSurface = nullptr;
543 
544  // identifier (username) of the voice pak
545  String _VoicePakName;
546  // parent part to use when making voice asset names
547  String _VoiceAssetPath;
548  int _said_speech_line = 0; // used while in dialog to track whether screen needs updating
549  int _said_text = 0;
550  int _longestline = 0;
551  // Old dialog support
552  std::vector<std::vector<uint8_t>> _old_dialog_scripts;
553  std::vector<String> _old_speech_lines;
554 
563  int _display_message_aschar = 0;
564  int _source_text_length = -1;
565 
566  TopBarSettings *_topBar;
567  struct DisplayVars {
568  int lineheight = 0; // font's height of single line
569  int linespacing = 0; // font's line spacing
570  int fulltxtheight = 0; // total height of all the text
571  } _disp;
572 
581  std::vector<RoomCameraDrawData> *_CameraDrawData;
582  // Two lists of sprites to push into renderer during next render pass
583  // thingsToDrawList - is the main list, unsorted, drawn in the index order
584  std::vector<SpriteListEntry> *_thingsToDrawList;
586 
587  AGS::Engine::IGraphicsDriver *_gfxDriver = nullptr;
588  AGS::Engine::IDriverDependantBitmap *_blankImage = nullptr;
589  AGS::Engine::IDriverDependantBitmap *_blankSidebarImage = nullptr;
590 
591  // actsps is used for temporary storage of the bitamp and texture
592  // of the latest version of the sprite (room objects and characters);
593  // objects sprites begin with index 0, characters are after ACTSP_OBJSOFF
594  std::vector<ObjTexture> *_actsps;
595  // Walk-behind textures (3D renderers only)
596  std::vector<ObjTexture> *_walkbehindobj;
597  // GUI surfaces
598  std::vector<ObjTexture> *_guibg;
599  // GUI control surfaces
600  std::vector<ObjTexture> *_guiobjbg;
601  // first control texture index of each GUI
602  std::vector<int> *_guiobjddbref;
603  // Overlays textures
604  std::vector<ObjTexture> *_overtxs;
605  // For debugging room masks
606  ObjTexture *_debugRoomMaskObj;
607  ObjTexture *_debugMoveListObj;
608  RoomAreaMask _debugRoomMask = kRoomAreaNone;
609  int _debugMoveListChar = -1;
610  // For in-game "console" surface
611  AGS::Shared::Bitmap *_debugConsoleBuffer;
612  // Whether room bg was modified
613  bool _current_background_is_dirty = false;
614  // Room background sprite
615  AGS::Engine::IDriverDependantBitmap *_roomBackgroundBmp = nullptr;
616  // whether there are currently remnants of a DisplaySpeech
617  bool _screen_is_dirty = false;
618  std::unique_ptr<Shared::Bitmap> _raw_saved_screen;
619  std::unique_ptr<Shared::Bitmap> *_dynamicallyCreatedSurfaces;
620  color *_palette;
621  COLOR_MAP *_maincoltable;
622 
624  std::vector<Point> *_guiobjoff; // because surface may be larger than logical position
625 
626  DrawState _drawstate;
627  DrawFPS _gl_DrawFPS;
628 
637  // Dirty rects for the game screen background (black screen);
638  // these are used when the room viewport does not cover whole screen,
639  // so that we know when to paint black after mouse cursor and gui.
640  DirtyRects *_BlackRects;
641  Point *_GlobalOffs;
642  // Dirty rects object for the single room camera
643  std::vector<DirtyRects> *_RoomCamRects;
644  // Saved room camera offsets to know if we must invalidate whole surface.
645  // TODO: if we support rotation then we also need to compare full transform!
646  std::vector<std::pair<int, int> > *_RoomCamPositions;
647 
656  bool _check_dynamic_sprites_at_exit = true;
657 
666  ResourcePaths *_ResPaths;
667  t_engine_pre_init_callback _engine_pre_init_callback = nullptr;
668 
677  int _convert_16bit_bgr = 0;
678 
688  int _in_enters_screen = 0, _done_es_error = 0;
689  int _in_leaves_screen = -1;
690 
692 
693  int _inside_processevent = 0;
694  int _eventClaimed = 0;
695 
696  const char *_tsnames[kTS_Num] = { nullptr, REP_EXEC_NAME, "on_key_press", "on_mouse_click", "on_text_input" };
697 
706  // TODO: the asset path configuration should certainly be revamped at some
707  // point, with uniform method of configuring auxiliary paths and packages.
708  // Installation directory, may contain absolute or relative path
709  String _installDirectory;
710  // Installation directory, containing audio files
711  String _installAudioDirectory;
712  // Installation directory, containing voice-over files
713  String _installVoiceDirectory;
714 
715  ScriptFileHandle _valid_handles[MAX_OPEN_SCRIPT_FILES + 1];
716  // [IKM] NOTE: this is not precisely the number of files opened at this moment,
717  // but rather maximal number of handles that were used simultaneously during game run
718  int _num_open_script_files = 0;
719 
729  TTFFontRenderer *_ttfRenderer;
730  WFNFontRenderer *_wfnRenderer;
731  SplitLines *_Lines;
732  const WFNChar _emptyChar; // a dummy character to substitute bad symbols
733  Shared::Bitmap _wputblock_wrapper; // [IKM] argh! :[
734 
743  GameSetupStruct *_game;
744  GameState *_play;
745  AGS::Shared::SpriteCache *_spriteset;
746  AGS::Shared::RoomStruct *_thisroom;
747  RoomStatus *_troom; // used for non-saveable rooms, eg. intro
748 
750  CCGUIObject *_ccDynamicGUIObject;
751  CCCharacter *_ccDynamicCharacter;
752  CCHotspot *_ccDynamicHotspot;
753  CCRegion *_ccDynamicRegion;
754  CCInventory *_ccDynamicInv;
755  CCGUI *_ccDynamicGUI;
756  CCObject *_ccDynamicObject;
757  CCDialog *_ccDynamicDialog;
758  CCAudioClip *_ccDynamicAudioClip;
759  CCAudioChannel *_ccDynamicAudio;
760  ScriptObject *_scrObj;
761  std::vector<ScriptGUI> *_scrGui;
762  ScriptHotspot *_scrHotspot;
763  ScriptRegion *_scrRegion;
764  ScriptInvItem *_scrInv;
765  std::vector<ScriptDialog> *_scrDialog;
766 
767  std::vector<ViewStruct> *_views;
768 
769  // Draw cache: keep record of all kinds of things related to the previous drawing state
770  // Cached character and object states, used to determine
771  // whether these require texture update
772  std::vector<ObjectCache> *_charcache;
773  ObjectCache *_objcache;
774  std::vector<Point> *_overcache;
775  std::vector<CharacterExtras> *_charextra;
776  // MoveLists for characters and room objects; NOTE: 1-based array!
777  // object sprites begin with index 1, characters are after MAX_ROOM_OBJECTS + 1
778  std::vector<MoveList> *_mls;
779 
780  GameSetup *_usetup;
781  AGS::Shared::String _saveGameDirectory;
782  AGS::Shared::String _saveGameSuffix;
783  bool _want_exit = false;
784  bool _abort_engine = false;
785  AGSPlatformDriver *_platform = nullptr;
786 
787  RoomObject *_objs = nullptr;
788  RoomStatus *_croom = nullptr;
789 
790  volatile int _switching_away_from_game = 0;
791  volatile bool _switched_away = false;
792  int _frames_per_second = 40;
793  int _displayed_room = -10, _starting_room = -1;
794  int _in_new_room = 0, _new_room_was = 0; // 1 in new room, 2 first time in new room, 3 loading saved game
795  int _new_room_pos = 0;
796  int _new_room_x = SCR_NO_VALUE, _new_room_y = SCR_NO_VALUE;
797  int _new_room_loop = SCR_NO_VALUE;
798  bool _proper_exit = true;
799  int _our_eip = 0;
800 
801  int _oldmouse = 0;
802  // Data format version of the loaded game
803  GameDataVersion _loaded_game_file_version = kGameVersion_Undefined;
804  // The version of the engine the loaded game was compiled for (if available)
805  Version _game_compiled_version;
806  int _game_paused = 0;
807  unsigned int _load_new_game = 0;
808  int _load_new_game_restore = -1;
809  // TODO: refactor these global vars into function arguments
810  int _getloctype_index = 0, _getloctype_throughgui = 0;
811  char _gamefilenamebuf[200] = { 0 };
812  int _gameHasBeenRestored = 0;
813  int _oldeip = 0;
814  int _game_update_suspend = 0;
815  bool _new_room_placeonwalkable = false;
816 
825  CCStaticArray *_StaticCharacterArray;
826  CCStaticArray *_StaticObjectArray;
827  CCStaticArray *_StaticGUIArray;
828  CCStaticArray *_StaticHotspotArray;
829  CCStaticArray *_StaticRegionArray;
830  CCStaticArray *_StaticInventoryArray;
831  CCStaticArray *_StaticDialogArray;
832 
841  // Following struct instructs the engine to run game loops until
842  // certain condition is not fulfilled.
843  struct RestrictUntil {
844  int type = 0; // type of condition, UNTIL_* constant
845  int disabled_for = 0; // FOR_* constant
846  // pointer to the test variable
847  const void *data_ptr = nullptr;
848  // other values used for a test, depend on type
849  int data1 = 0;
850  int data2 = 0;
851  } _restrict_until;
852 
853  float _fps;
854  unsigned int _loopcounter = 0;
855  unsigned int _lastcounter = 0;
856  int _numEventsAtStartOfFunction = 0;
857  uint32 _t1 = 0; // timer for FPS
858  int _old_key_shifts = 0; // for saving shift modes
859 
868  const AGS::Engine::GfxFilterInfo *_aad3dFilterInfo;
869 
878  const AGS::Engine::GfxFilterInfo *_allegroFilterInfo;
879  AGS::Engine::GfxFilterInfo *_scummvmGfxFilter;
880 
889  const AGS::Engine::GfxFilterInfo *_hqxFilterInfo;
890 
899  const AGS::Engine::GfxFilterInfo *_d3dFilterInfo;
900 
909  ScriptPosition *_last_in_dialog_request_script_pos;
910 
919  ScriptPosition *_last_cutscene_script_pos;
920 
929  // Used for deciding whether a char or obj was closer
930  int _obj_lowest_yp = 0;
931 
940  AGS::Engine::IGfxDriverFactory *_GfxFactory = nullptr;
941 
942  // Last saved fullscreen and windowed configs; they are used when switching
943  // between between fullscreen and windowed modes at runtime.
944  // If particular mode is modified, e.g. by script command, related config should be overwritten.
945  ActiveDisplaySetting *_SavedFullscreenSetting;
946  ActiveDisplaySetting *_SavedWindowedSetting;
947  // Current frame scaling setup
948  FrameScaleDef _CurFrameSetup = kFrame_Undefined;
949  // The game-to-screen transformation
950  AGS::Shared::PlaneScaling *_GameScaling;
951 
960  int _ifacepopped = -1; // currently displayed pop-up GUI (-1 if none)
961  int _mouse_on_iface = -1; // mouse cursor is over this interface
962  int _mouse_ifacebut_xoffs = -1, _mouse_ifacebut_yoffs = -1;
963  int _eip_guinum = 0, _eip_guiobj = 0;
964 
974 
983  // TODO: store drawing surface inside old gui classes instead
984  int _windowPosX = 0, _windowPosY = 0, _windowPosWidth = 0, _windowPosHeight = 0;
985  AGS::Shared::Bitmap *_windowBuffer = nullptr;
986  AGS::Engine::IDriverDependantBitmap *_dialogDDB = nullptr;
987 
988 #define MAXSAVEGAMES_20 20
989  int _myscrnwid = 320, _myscrnhit = 200;
990  char *_lpTemp = nullptr, *_lpTemp2 = nullptr;
991  int _numsaves = 0, _toomanygames = 0;
992  int _filenumbers[MAXSAVEGAMES_20];
993  unsigned long _filedates[MAXSAVEGAMES_20];
994  char _bufTemp[260], _buffer2[260];
995  char _buff[200];
996  CSCIMessage *_smes;
997 
1007 
1017 
1027 
1036  int _guis_need_update = 1;
1037  AGS::Shared::GuiDisableStyle _all_buttons_disabled = AGS::Shared::kGuiDis_Undefined;
1038  int _gui_inv_pic = -1;
1039 
1049 
1059 
1068  AGS::Shared::InteractionVariable *_globalvars;
1069  int _numGlobalVars = 1;
1070 
1079  int _in_inv_screen = 0, _inv_screen_newroom = -1;
1080 
1089  uint8_t *_lzbuffer = nullptr;
1090  int *_node = nullptr;
1091  int _pos = 0;
1092  size_t _outbytes = 0;
1093 
1102  String _appPath;
1103  String _appDirectory; // Needed for library loading
1104  String _cmdGameDataPath;
1105 
1106  // Startup flags, set from parameters to engine
1107  int _override_start_room = 0;
1108  bool _justDisplayHelp = false;
1109  bool _justDisplayVersion = false;
1110  bool _justRunSetup = false;
1111  bool _justTellInfo = false;
1112  std::set<String> _tellInfoKeys;
1113  int _loadSaveGameOnStartup = -1;
1114 
1115  // ScummVM GUIO-controlled flags
1116  bool _saveThumbnail = true; // capture a screenshot when saving (used for saves thumbnails)
1117  bool _noScummAutosave = false; // disable ScummVM autosaves
1118  bool _noScummSaveLoad = false; // disable ScummVM GMM save/load
1119 
1120 #if 0
1121  int _psp_rotation = 0;
1123  int _psp_gfx_renderer = 0;
1124  int _psp_gfx_scaling = 1;
1125  int _psp_gfx_smoothing = 0;
1126  int _psp_gfx_super_sampling = 1;
1127  int _psp_gfx_smooth_sprites = 0;
1128 #endif
1129 
1130  // Current engine version
1131  Version _EngineVersion;
1132 
1141  ManagedObjectPool *_pool;
1142 
1151  int8 _currentcursor = 0;
1152  // virtual mouse cursor coordinates
1153  int _mousex = 0, _mousey = 0, _numcurso = -1, _hotx = 0, _hoty = 0;
1154  // real mouse coordinates and bounds (in window coords)
1155  int _real_mouse_x = 0, _real_mouse_y = 0;
1156  int _boundx1 = 0, _boundx2 = 99999, _boundy1 = 0, _boundy2 = 99999;
1157  int8 _ignore_bounds = 0;
1158  AGS::Shared::Bitmap *_mousecurs[MAXCURSORS];
1159 
1160  ScriptMouse *_scmouse;
1161  int _cur_mode = 0, _cur_cursor = 0;
1162  int _mouse_frame = 0, _mouse_delay = 0;
1163  int _lastmx = -1, _lastmy = -1;
1164  int8 _alpha_blend_cursor = 0;
1165  AGS::Shared::Bitmap *_dotted_mouse_cursor = nullptr;
1166  AGS::Engine::IDriverDependantBitmap *_mouseCursor = nullptr;
1167  AGS::Shared::Bitmap *_blank_mouse_cursor = nullptr;
1168 
1177  int _butwas = 0;
1178  int _hotxwas = 0, _hotywas = 0;
1179  Mouse *_mouse;
1180 
1189  std::vector<ScreenOverlay> *_screenover;
1190  std::queue<int32_t> *_over_free_ids;
1191  int _is_complete_overlay = 0;
1192 
1209  bool _handledErrorInEditor = false;
1210  char _return_to_roomedit[30] = { '\0' };
1211  char _return_to_room[150] = { '\0' };
1212  char _quit_message[256] = { '\0' };
1213 
1222  RGB_MAP *_rgb_table; // for 256-col antialiasing
1223  int _new_room_flags = 0;
1224  int _gs_to_newroom = -1;
1225  int _bg_just_changed = 0;
1226  std::unique_ptr<RoomStatus> _room_statuses[MAX_ROOMS];
1227 
1236  Point *_navpoints;
1237  Navigation *_nav;
1238  int _num_navpoints = 0;
1239  AGS::Shared::Bitmap *_wallscreen = nullptr;
1240  fixed _move_speed_x, _move_speed_y;
1241  int _lastcx = 0, _lastcy = 0;
1242  std::unique_ptr<IRouteFinder> *_route_finder_impl;
1243 
1252  // Screenshot made in the last room, used during some of the transition effects
1253  AGS::Shared::Bitmap *_saved_viewport_bitmap = nullptr;
1254  color *_old_palette;
1255 
1264  ExecutingScript *_scripts;
1265  ExecutingScript *_curscript = nullptr;
1266 
1267  PScript *_gamescript;
1268  PScript *_dialogScriptsScript;
1269  UInstance _gameinst;
1270  UInstance _roominst;
1271  UInstance _dialogScriptsInst;
1272  UInstance _gameinstFork;
1273  UInstance _roominstFork;
1274 
1275  int _num_scripts = 0;
1276  int _post_script_cleanup_stack = 0;
1277 
1278  int _inside_script = 0, _in_graph_script = 0;
1279  int _no_blocking_functions = 0; // set to 1 while in rep_Exec_always
1280 
1281  NonBlockingScriptFunction *_repExecAlways;
1282  NonBlockingScriptFunction *_lateRepExecAlways;
1283  NonBlockingScriptFunction *_getDialogOptionsDimensionsFunc;
1284  NonBlockingScriptFunction *_renderDialogOptionsFunc;
1285  NonBlockingScriptFunction *_getDialogOptionUnderCursorFunc;
1286  NonBlockingScriptFunction *_runDialogOptionMouseClickHandlerFunc;
1287  NonBlockingScriptFunction *_runDialogOptionKeyPressHandlerFunc;
1288  NonBlockingScriptFunction *_runDialogOptionTextInputHandlerFunc;
1289  NonBlockingScriptFunction *_runDialogOptionRepExecFunc;
1290  NonBlockingScriptFunction *_runDialogOptionCloseFunc;
1291 
1292  ScriptSystem *_scsystem;
1293 
1294  std::vector<PScript> *_scriptModules;
1295  std::vector<UInstance> *_moduleInst;
1296  std::vector<UInstance> *_moduleInstFork;
1297  std::vector<RuntimeScriptValue> *_moduleRepExecAddr;
1298  size_t _numScriptModules = 0;
1299 
1308  new_line_hook_type _new_line_hook = nullptr;
1309  // Minimal timeout: how much time may pass without any engine update
1310  // before we want to check on the situation and do system poll
1311  unsigned _timeoutCheckMs = 60u;
1312  // Critical timeout: how much time may pass without any engine update
1313  // before we abort or post a warning
1314  unsigned _timeoutAbortMs = 0u;
1315  // Maximal while loops without any engine update in between,
1316  // after which the interpreter will abort
1317  unsigned _maxWhileLoops = 0u;
1318  ccInstance *_loadedInstances[MAX_LOADED_INSTANCES];
1319  ScriptString *_myScriptStringImpl;
1320  ScriptUserObject _globalDynamicStruct;
1321 
1338  SystemImports *_simp;
1339  SystemImports *_simp_for_plugin;
1340 
1349  Plugins::Core::EngineExports *_engineExports;
1350  Common::Array<EnginePlugin> *_plugins;
1351  int _pluginsWantingDebugHooks = 0;
1352  long _pl_file_handle = -1;
1353  AGS::Shared::Stream *_pl_file_stream = nullptr;
1354 
1355  eAGSMouseButton _simulatedClick = kMouseNone;
1356  int _mouse_z_was = 0;
1357 
1366  std::chrono::microseconds _tick_duration = std::chrono::microseconds(1000000LL / 40);
1367  bool _framerate_maxed = false;
1368  int _framerate = 0;
1369 
1370  uint32 _last_tick_time = 0; // AGS_Clock::now();
1371  uint32 _next_frame_timestamp = 0; // AGS_Clock::now();
1372 
1381  AGS::Shared::Translation *_trans;
1382  AGS::Shared::StringMap *_transtree = nullptr;
1383  String _trans_name, _trans_filename;
1384  long _lang_offs_start = 0;
1385  char _transFileName[MAX_PATH_SZ] = { 0 };
1386  std::vector<uint16> _wcsbuf; // widechar buffer
1387  std::vector<char> _mbbuf; // utf8 buffer
1388 
1397  AGS::Shared::Bitmap *_walkareabackup = nullptr, *_walkable_areas_temp = nullptr;
1398 
1407  char *_walkBehindExists = nullptr; // whether a WB area is in this column
1408  int *_walkBehindStartY = nullptr, *_walkBehindEndY = nullptr;
1409  int8 _noWalkBehindsAtAll = 0;
1410  int _walkBehindLeft[MAX_WALK_BEHINDS], _walkBehindTop[MAX_WALK_BEHINDS];
1411  int _walkBehindRight[MAX_WALK_BEHINDS], _walkBehindBottom[MAX_WALK_BEHINDS];
1412  AGS::Engine::IDriverDependantBitmap *_walkBehindBitmap[MAX_WALK_BEHINDS];
1413  int _walkBehindsCachedForBgNum = -1;
1414  int _walk_behind_baselines_changed = 0;
1415  Rect _walkBehindAABB[MAX_WALK_BEHINDS]; // WB bounding box
1416  std::vector<WalkBehindColumn> _walkBehindCols; // precalculated WB positions
1417 
1426  const char *_passwencstring = "Avis Durgan";
1427 
1430 public:
1431  Globals();
1432  ~Globals();
1433 };
1434 
1435 extern Globals *g_globals;
1436 
1437 // Macro for accessing a globals member
1438 #define _G(FIELD) (::AGS3::g_globals->_##FIELD)
1439 // Macro for accessing a globals member that was an object in the original,
1440 // but is a pointer to the object in ScummVM, so that we don't need to
1441 // provide the full class/struct definition here in the header file
1442 #define _GP(FIELD) (*::AGS3::g_globals->_##FIELD)
1443 
1444 } // namespace AGS3
1445 
1446 #endif
Definition: achievements_tables.h:27
Definition: vector.h:39
Definition: script_system.h:37
Definition: cc_hotspot.h:29
Definition: cc_dynamic_array.h:33
Definition: globals.h:189
Definition: cc_common.h:46
Definition: gui_dialog_defines.h:115
Definition: cc_ags_dynamic_object.h:108
Definition: managed_object_pool.h:50
Definition: debug_manager.h:109
Definition: allegro_bitmap.h:44
Definition: draw.h:76
Definition: cc_dialog.h:29
Definition: geometry.h:87
Definition: array.h:52
Definition: script_dialog_options_rendering.h:29
Definition: script_string.h:29
Definition: display_client.h:58
Definition: graphics_mode.h:119
Definition: sprite_cache.h:80
Definition: runtime_script_value.h:63
Definition: draw.h:105
Definition: cc_instance.h:98
Definition: cc_audio_channel.h:29
Definition: cc_static_array.h:60
Definition: script_drawing_surface.h:32
Definition: script_game.h:35
Definition: room_status.h:65
Definition: file.h:145
Definition: queue.h:42
Definition: ptr.h:572
Definition: cc_gui_object.h:29
Definition: cc_region.h:29
Definition: gfxfilter.h:41
Definition: sound_clip.h:53
Definition: room_object.h:58
Definition: script_object.h:30
Definition: new_control.h:31
Definition: draw_software.h:63
Definition: cc_inventory.h:29
Definition: color.h:65
Definition: script_inv_item.h:27
Definition: cc_object.h:29
Definition: file.h:61
Definition: globals.h:509
Definition: game_setup_struct.h:60
Definition: ags_platform_driver.h:70
Definition: draw.h:139
Definition: tra_file.h:64
Definition: wfn_font.h:66
Definition: algorithm.h:29
Definition: graphics_driver.h:98
Definition: set.h:42
Definition: draw.h:155
Definition: cc_gui.h:29
Definition: version.h:39
Definition: interactions.h:185
Definition: queue.h:75
Definition: gui_dialog_defines.h:121
Definition: script_mouse.h:34
Definition: scaling.h:108
Definition: engine.h:59
Definition: geometry.h:219
Definition: color.h:49
Definition: character_info.h:117
Definition: ttf_font_renderer.h:33
Definition: fonts.h:154
Definition: cc_audio_clip.h:29
Definition: string.h:62
Definition: game_setup.h:61
Definition: executing_script.h:61
Definition: room_struct.h:269
Definition: wfn_font_renderer.h:33
Definition: game_state.h:80
Definition: ags_editor_debugger.h:27
Definition: globals.h:843
Definition: script_hotspot.h:27
Definition: route_finder_jps.h:40
Definition: top_bar_settings.h:27
Definition: cc_serializer.h:29
Definition: color.h:69
Definition: ptr.h:159
Definition: globals.h:567
Definition: mouse_w32.h:37
Definition: array.h:39
Definition: stream.h:52
Definition: gfx_driver_factory.h:51
Definition: script_audio_channel.h:27
Definition: script_user_object.h:36
Definition: cc_instance.h:114
Definition: engine.h:144
Definition: ags.h:40
Definition: system_imports.h:44
Definition: cc_character.h:36
Definition: script_region.h:27
Definition: non_blocking_script_function.h:31