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 "ags/lib/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/event.h"
39 #include "ags/engine/ac/runtime_defines.h"
40 #include "ags/engine/ac/walk_behind.h"
41 #include "ags/engine/main/engine.h"
42 #include "ags/engine/main/graphics_mode.h"
43 #include "ags/engine/media/audio/audio_defines.h"
44 #include "ags/engine/script/script.h"
45 #include "ags/engine/script/script_runtime.h"
46 #include "ags/lib/std/array.h"
47 #include "ags/lib/std/chrono.h"
48 #include "ags/lib/std/memory.h"
49 #include "ags/lib/std/set.h"
50 #include "ags/lib/allegro/color.h"
51 #include "ags/lib/allegro/fixed.h"
52 #include "ags/lib/allegro/aintern.h"
53 #include "common/events.h"
54 
55 namespace Common {
56 class DumpFile;
57 }
58 
59 namespace AGS3 {
60 
61 #define MAXCURSORS 20
62 
63 using String = AGS::Shared::String;
64 using Version = AGS::Shared::Version;
65 
66 namespace AGS {
67 namespace Shared {
68 
69 class AssetManager;
70 class Bitmap;
71 class DebugManager;
72 struct Font;
73 class GUIButton;
74 class GUIInvWindow;
75 class GUILabel;
76 class GUIListBox;
77 class GUISlider;
78 class GUITextBox;
79 struct InteractionVariable;
80 struct PlaneScaling;
81 class RoomStruct;
82 class SpriteCache;
83 struct Translation;
84 
85 } // namespace Shared
86 
87 namespace Engine {
88 
89 class ConsoleOutputTarget;
90 struct GfxFilterInfo;
91 class IDriverDependantBitmap;
92 class IGfxDriverFactory;
93 class IGraphicsDriver;
94 class LogFile;
95 class MessageBuffer;
96 
97 } // namespace Engine
98 } // namespace AGS
99 
100 namespace Plugins {
101 namespace Core {
102 class EngineExports;
103 } // namespace Core
104 } // namespace Plugins
105 
106 class IRouteFinder;
107 class Navigation;
108 class SplitLines;
109 class TTFFontRenderer;
110 class WFNFontRenderer;
111 
112 struct AGSDeSerializer;
113 struct AGSPlatformDriver;
114 struct AGSStaticObject;
115 struct AmbientSound;
116 struct AnimatingGUIButton;
117 struct CachedActSpsData;
118 struct CCAudioChannel;
119 struct CCAudioClip;
120 struct CCCharacter;
121 struct CCDialog;
122 struct CCDynamicArray;
123 struct CCGUI;
124 struct CCGUIObject;
125 struct CCHotspot;
126 struct ccInstance;
127 struct CCInventory;
128 struct CCObject;
129 struct CCRegion;
130 struct CharacterCache;
131 struct CharacterExtras;
132 struct CharacterInfo;
133 struct color;
134 struct COLOR_MAP;
135 struct CSCIMessage;
136 struct DialogTopic;
137 struct DirtyRects;
138 struct EnginePlugin;
139 struct ExecutingScript;
140 struct EventHappened;
141 struct GameSetup;
142 struct GameSetupStruct;
143 struct GameState;
144 struct IAGSEditorDebugger;
145 struct ICCStringClass;
146 struct ManagedObjectPool;
147 struct Mouse;
148 struct MoveList;
149 struct NewControl;
150 struct NonBlockingScriptFunction;
151 struct ObjectCache;
152 struct OnScreenWindow;
153 struct PluginObjectReader;
154 struct Point;
155 struct ResourcePaths;
156 struct RGB_MAP;
157 struct RoomCameraDrawData;
158 struct RoomObject;
159 struct RoomStatus;
160 struct RuntimeScriptValue;
161 struct ScreenOverlay;
162 struct ScriptAudioChannel;
163 struct ScriptDialog;
164 struct ScriptDialogOptionsRendering;
165 struct ScriptDrawingSurface;
166 struct ScriptError;
167 struct ScriptGUI;
168 struct ScriptHotspot;
169 struct ScriptInvItem;
170 struct ScriptMouse;
171 struct ScriptObject;
172 struct ScriptPosition;
173 struct ScriptRegion;
174 struct ScriptString;
175 struct ScriptSystem;
176 struct SOUNDCLIP;
177 struct SpeechLipSyncLine;
178 struct SpriteListEntry;
179 struct StaticArray;
180 struct StaticGame;
181 struct SystemImports;
182 struct TopBarSettings;
183 struct ViewStruct;
184 
185 class Globals {
186 public:
187  enum SimdFlags : uint {
188  SIMD_NONE = 0,
189  SIMD_NEON = (1 << 0),
190  SIMD_SSE2 = (1 << 1),
191  SIMD_AVX2 = (1 << 2),
192  };
193 
206  int _errnum = 0;
207  int *_allegro_errno = &_errnum;
208 
209  int __color_depth = 0;
210  int __rgb_r_shift_15 = DEFAULT_RGB_R_SHIFT_15; /* truecolor pixel format */
211  int __rgb_g_shift_15 = DEFAULT_RGB_G_SHIFT_15;
212  int __rgb_b_shift_15 = DEFAULT_RGB_B_SHIFT_15;
213  int __rgb_r_shift_16 = DEFAULT_RGB_R_SHIFT_16;
214  int __rgb_g_shift_16 = DEFAULT_RGB_G_SHIFT_16;
215  int __rgb_b_shift_16 = DEFAULT_RGB_B_SHIFT_16;
216  int __rgb_r_shift_24 = DEFAULT_RGB_R_SHIFT_24;
217  int __rgb_g_shift_24 = DEFAULT_RGB_G_SHIFT_24;
218  int __rgb_b_shift_24 = DEFAULT_RGB_B_SHIFT_24;
219  int __rgb_r_shift_32 = DEFAULT_RGB_R_SHIFT_32;
220  int __rgb_g_shift_32 = DEFAULT_RGB_G_SHIFT_32;
221  int __rgb_b_shift_32 = DEFAULT_RGB_B_SHIFT_32;
222  int __rgb_a_shift_32 = DEFAULT_RGB_A_SHIFT_32;
223 
224  RGB_MAP *_rgb_map = nullptr;
225  COLOR_MAP *_color_map = nullptr;
226  int _trans_blend_alpha = 0;
227  int _trans_blend_red = 0;
228  int _trans_blend_green = 0;
229  int _trans_blend_blue = 0;
230  BlenderMode __blender_mode = kRgbToRgbBlender;
231  uint _simd_flags = SIMD_NONE;
232  /* current format information and worker routines */
233  int _utype = U_UTF8;
234 
235  /* default palette structures */
236  PALETTE _black_palette;
237  PALETTE _current_palette;
238  PALETTE _prev_current_palette;
239 
240  volatile int _mouse_x = 0; // X position
241  volatile int _mouse_y = 0; // Y position
242  volatile int _mouse_z = 0; // Mouse wheel vertical
243  volatile int _mouse_b = 0; // Mouse buttons bitflags
244  volatile int _mouse_pos = 0; // X position in upper 16 bits, Y in lower 16
245 
246  // Accumulated absolute and relative mouse device motion.
247  // May be retrieved by calling *acquire_absxy and *acquire_relxy functions,
248  // after which these are reset, until next motion event is received.
249  volatile int _sys_mouse_x = 0; // mouse x position
250  volatile int _sys_mouse_y = 0; // mouse y position
251  volatile int _sys_mouse_z = 0; // mouse wheel position
252 
253  volatile int _freeze_mouse_flag = 0;
254 
255  // Relative x and y deltas
256  int _mouse_accum_relx = 0, _mouse_accum_rely = 0;
257 
258  int _mouse_button_state = 0;
259  int _mouse_accum_button_state = 0;
260  uint32 _mouse_clear_at_time = 0;
261  eAGSMouseButton _wasbutdown = kMouseNone;
262  int _wasongui = 0;
263 
273 
282  // We don't have many places where we delay longer than a frame, but where we
283  // do, we should give the audio layer a chance to update.
284  // 16 milliseconds is rough period for 60fps
285  const std::chrono::milliseconds _MaximumDelayBetweenPolling = std::chrono::milliseconds(16);
286 
295  AGS::Shared::Bitmap *_glVirtualScreenWrap;
296 
305  AGSStaticObject *_GlobalStaticManager;
306  StaticGame *_GameStaticManager;
307 
316  std::array<SOUNDCLIP *> *_audioChannels;
317  std::array<AmbientSound> *_ambient;
318 
319  ScriptAudioChannel *_scrAudioChannel;
320  int _reserved_channel_count = 0;
321 
322  // This is an indicator of a music played by an old audio system
323  // (to distinguish from the new system API)
324  int _current_music_type = 0;
325  // _G(crossFading) is >0 (channel number of new track), or -1 (old
326  // track fading out, no new track)
327  int _crossFading = 0, _crossFadeVolumePerStep = 0, _crossFadeStep = 0;
328  int _crossFadeVolumeAtStart = 0;
329  SOUNDCLIP *_cachedQueuedMusic = nullptr;
330 
331  // Music update is scheduled when the voice speech stops;
332  // we do a small delay before reverting any volume adjustments
333  bool _music_update_scheduled = false;
334  uint32 _music_update_at = 0;
335 
345 
354  CCDynamicArray *_globalDynamicArray;
355 
364  ICCStringClass *_stringClassImpl = nullptr;
365 
373  ScriptError *_ccError;
374 
383  // Instance thread stack holds a list of running or suspended script instances;
384  // In AGS currently only one thread is running, others are waiting in the queue.
385  // An example situation is repeatedly_execute_always callback running while
386  // another instance is waiting at the blocking action or Wait().
387  std::deque<ccInstance *> *_InstThreads;
388  // [IKM] 2012-10-21:
389  // NOTE: This is temporary solution (*sigh*, one of many) which allows certain
390  // exported functions return value as a RuntimeScriptValue object;
391  // Of 2012-12-20: now used only for plugin exports
392  RuntimeScriptValue *_GlobalReturnValue;
393  Common::DumpFile *_scriptDumpFile = nullptr;
394 
403  int _ccCompOptions;
404 
413  // currently executed line
414  int _currentline = 0;
415  // script file format signature
416  const char *_scfilesig = "SCOM";
417 
426  AGSDeSerializer *_ccUnserializer;
427 
436  int _use_cdplayer = 0;
437  bool _triedToUseCdAudioCommand = false;
438  int _need_to_stop_cd = 0;
439 
448  CharacterInfo *_playerchar = nullptr;
449  int32_t _sc_PlayerCharPtr = 0;
450  int _char_lowest_yp = 0;
451 
452  // Sierra-style speech settings
453  int _face_talking = -1, _facetalkview = 0, _facetalkwait = 0, _facetalkframe = 0;
454  int _facetalkloop = 0, _facetalkrepeat = 0, _facetalkAllowBlink = 1;
455  int _facetalkBlinkLoop = 0;
456  CharacterInfo *_facetalkchar = nullptr;
457  // Do override default portrait position during QFG4-style speech overlay update
458  bool _facetalk_qfg4_override_placement_x = false;
459  bool _facetalk_qfg4_override_placement_y = false;
460 
461  // lip-sync speech settings
462  int _loops_per_character = 0, _text_lips_offset = 0, _char_speaking = -1;
463  int _char_thinking = -1;
464  const char *_text_lips_text = nullptr;
465  SpeechLipSyncLine *_splipsync = nullptr;
466  int _numLipLines = 0, _curLipLine = -1, _curLipLinePhoneme = 0;
467 
476  int _windowbackgroundcolor, _pushbuttondarkcolor;
477  int _pushbuttonlightcolor;
478  int _topwindowhandle = -1;
479  int _cbuttfont = 0;
480  int _acdialog_font = 0;
481  int _smcode = 0;
482  int _controlid = 0;
483  NewControl **_vobjs;
484  OnScreenWindow *_oswi;
485 
486  int _windowcount = 0, _curswas = 0;
487  int _win_x = 0, _win_y = 0, _win_width = 0, _win_height = 0;
488 
497  int _editor_debugging_enabled = 0;
498  int _editor_debugging_initialized = 0;
499  char _editor_debugger_instance_token[100];
500  IAGSEditorDebugger *_editor_debugger = nullptr;
501  int _break_on_next_script_step = 0;
502  volatile int _game_paused_in_debugger = 0;
503 
504  struct Breakpoint {
505  char scriptName[80] = { 0 };
506  int lineNumber = 0;
507  };
508 
509  std::vector<Breakpoint> _breakpoints;
510 
511  int _debug_flags = 0;
512 
513  String *_debug_line;
514  int _first_debug_line = 0, _last_debug_line = 0, _display_console = 0;
515 
516  float _fps;
517  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  AGS::Engine::IDriverDependantBitmap *_debugConsole = nullptr;
591 
592  // actsps is used for temporary storage of the bitamp and texture
593  // of the latest version of the sprite (room objects and characters);
594  // objects sprites begin with index 0, characters are after ACTSP_OBJSOFF
595  std::vector<ObjTexture> *_actsps;
596  // Walk-behind textures (3D renderers only)
597  std::vector<ObjTexture> *_walkbehindobj;
598  // GUI surfaces
599  std::vector<ObjTexture> *_guibg;
600  // GUI control surfaces
601  std::vector<ObjTexture> *_guiobjbg;
602  // first control texture index of each GUI
603  std::vector<int> *_guiobjddbref;
604  // Overlay's cached transformed bitmap, for software mode
606  // For debugging room masks
607  ObjTexture *_debugRoomMaskObj;
608  ObjTexture *_debugMoveListObj;
609  RoomAreaMask _debugRoomMask = kRoomAreaNone;
610  int _debugMoveListChar = -1;
611 
612  bool _current_background_is_dirty = false;
613  // Room background sprite
614  AGS::Engine::IDriverDependantBitmap *_roomBackgroundBmp = nullptr;
615  AGS::Shared::Bitmap *_debugConsoleBuffer = nullptr;
616  // whether there are currently remnants of a DisplaySpeech
617  bool _screen_is_dirty = false;
618  AGS::Shared::Bitmap *_raw_saved_screen = nullptr;
619  AGS::Shared::Bitmap **_dynamicallyCreatedSurfaces = nullptr;
620  int _places_r = 3, _places_g = 2, _places_b = 3;
621  color *_palette;
622  COLOR_MAP *_maincoltable;
623 
625  std::vector<Point> *_guiobjoff; // because surface may be larger than logical position
626 
635  // Dirty rects for the game screen background (black screen);
636  // these are used when the room viewport does not cover whole screen,
637  // so that we know when to paint black after mouse cursor and gui.
638  DirtyRects *_BlackRects;
639  Point *_GlobalOffs;
640  // Dirty rects object for the single room camera
641  std::vector<DirtyRects> *_RoomCamRects;
642  // Saved room camera offsets to know if we must invalidate whole surface.
643  // TODO: if we support rotation then we also need to compare full transform!
644  std::vector<std::pair<int, int> > *_RoomCamPositions;
645 
654  bool _check_dynamic_sprites_at_exit = true;
655 
664  ResourcePaths *_ResPaths;
665  t_engine_pre_init_callback _engine_pre_init_callback = nullptr;
666 
675  int _convert_16bit_bgr = 0;
676 
686  int _in_enters_screen = 0, _done_es_error = 0;
687  int _in_leaves_screen = -1;
688 
690 
691  const char *_evblockbasename = nullptr;
692  int _evblocknum = 0;
693 
694  int _inside_processevent = 0;
695  int _eventClaimed = 0;
696 
697  const char *_tsnames[TS_NUM] = { nullptr, REP_EXEC_NAME, "on_key_press", "on_mouse_click", "on_text_input" };
698 
707  // TODO: the asset path configuration should certainly be revamped at some
708  // point, with uniform method of configuring auxiliary paths and packages.
709  // Installation directory, may contain absolute or relative path
710  String _installDirectory;
711  // Installation directory, containing audio files
712  String _installAudioDirectory;
713  // Installation directory, containing voice-over files
714  String _installVoiceDirectory;
715 
725  TTFFontRenderer *_ttfRenderer;
726  WFNFontRenderer *_wfnRenderer;
727  SplitLines *_Lines;
728  const WFNChar _emptyChar; // a dummy character to substitute bad symbols
729  Shared::Bitmap _wputblock_wrapper; // [IKM] argh! :[
730 
739  GameSetupStruct *_game;
740  GameState *_play;
741  AGS::Shared::SpriteCache *_spriteset;
742  AGS::Shared::RoomStruct *_thisroom;
743  RoomStatus *_troom; // used for non-saveable rooms, eg. intro
744 
746  CCGUIObject *_ccDynamicGUIObject;
747  CCCharacter *_ccDynamicCharacter;
748  CCHotspot *_ccDynamicHotspot;
749  CCRegion *_ccDynamicRegion;
750  CCInventory *_ccDynamicInv;
751  CCGUI *_ccDynamicGUI;
752  CCObject *_ccDynamicObject;
753  CCDialog *_ccDynamicDialog;
754  CCAudioClip *_ccDynamicAudioClip;
755  CCAudioChannel *_ccDynamicAudio;
756  ScriptString *_myScriptStringImpl;
757 
758  // TODO: IMPORTANT!!
759  // we cannot simply replace these arrays with vectors, or other C++ containers,
760  // until we implement safe management of such containers in script exports
761  // system. Noteably we would need an alternate to StaticArray class to track
762  // access to their elements.
763  ScriptObject *_scrObj;
764  ScriptGUI *_scrGui = nullptr;
765  ScriptHotspot *_scrHotspot;
766  ScriptRegion *_scrRegion;
767  ScriptInvItem *_scrInv;
768  ScriptDialog *_scrDialog = nullptr;
769  std::vector<ViewStruct> *_views;
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> *_screenovercache;
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  StaticArray *_StaticCharacterArray;
826  StaticArray *_StaticObjectArray;
827  StaticArray *_StaticGUIArray;
828  StaticArray *_StaticHotspotArray;
829  StaticArray *_StaticRegionArray;
830  StaticArray *_StaticInventoryArray;
831  StaticArray *_StaticDialogArray;
832 
841  // Following struct instructs the engine to run game loops until
842  // certain condition is not fullfilled.
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  unsigned int _loopcounter = 0;
854  unsigned int _lastcounter = 0;
855  int _numEventsAtStartOfFunction = 0;
856  uint32 _t1 = 0; // timer for FPS
857  int _old_key_shifts = 0; // for saving shift modes
858 
867  const AGS::Engine::GfxFilterInfo *_aad3dFilterInfo;
868 
877  const AGS::Engine::GfxFilterInfo *_allegroFilterInfo;
878  AGS::Engine::GfxFilterInfo *_scummvmGfxFilter;
879 
888  const AGS::Engine::GfxFilterInfo *_hqxFilterInfo;
889 
898  const AGS::Engine::GfxFilterInfo *_d3dFilterInfo;
899 
908  ScriptPosition *_last_in_dialog_request_script_pos;
909 
918  ScriptPosition *_last_cutscene_script_pos;
919 
928  // Used for deciding whether a char or obj was closer
929  int _obj_lowest_yp = 0;
930 
939  AGS::Engine::IGfxDriverFactory *_GfxFactory = nullptr;
940 
941  // Last saved fullscreen and windowed configs; they are used when switching
942  // between between fullscreen and windowed modes at runtime.
943  // If particular mode is modified, e.g. by script command, related config should be overwritten.
944  ActiveDisplaySetting *_SavedFullscreenSetting;
945  ActiveDisplaySetting *_SavedWindowedSetting;
946  // Current frame scaling setup
947  FrameScaleDef _CurFrameSetup = kFrame_Undefined;
948  // The game-to-screen transformation
949  AGS::Shared::PlaneScaling *_GameScaling;
950 
959  int _ifacepopped = -1; // currently displayed pop-up GUI (-1 if none)
960  int _mouse_on_iface = -1; // mouse cursor is over this interface
961  int _mouse_ifacebut_xoffs = -1, _mouse_ifacebut_yoffs = -1;
962  int _eip_guinum = 0, _eip_guiobj = 0;
963 
973 
982  // TODO: store drawing surface inside old gui classes instead
983  int _windowPosX = 0, _windowPosY = 0, _windowPosWidth = 0, _windowPosHeight = 0;
984  AGS::Shared::Bitmap *_windowBuffer = nullptr;
985  AGS::Engine::IDriverDependantBitmap *_dialogDDB = nullptr;
986 
987 #define MAXSAVEGAMES_20 20
988  int _myscrnwid = 320, _myscrnhit = 200;
989  char *_lpTemp = nullptr, *_lpTemp2 = nullptr;
990  int _numsaves = 0, _toomanygames = 0;
991  int _filenumbers[MAXSAVEGAMES_20];
992  unsigned long _filedates[MAXSAVEGAMES_20];
993  char _bufTemp[260], _buffer2[260];
994  char _buff[200];
995  CSCIMessage *_smes;
996 
1006 
1016 
1026 
1035  int _guis_need_update = 1;
1036  AGS::Shared::GuiDisableStyle _all_buttons_disabled = AGS::Shared::kGuiDis_Undefined;
1037  int _gui_inv_pic = -1;
1038 
1048 
1058 
1067  AGS::Shared::InteractionVariable *_globalvars;
1068  int _numGlobalVars = 1;
1069 
1078  int _in_inv_screen = 0, _inv_screen_newroom = -1;
1079 
1088  uint8_t *_lzbuffer = nullptr;
1089  int *_node = nullptr;
1090  int _pos = 0;
1091  size_t _outbytes = 0;
1092 
1101  String _appPath;
1102  String _appDirectory; // Needed for library loading
1103  String _cmdGameDataPath;
1104 
1105  // Startup flags, set from parameters to engine
1106  int _override_start_room = 0;
1107  bool _justDisplayHelp = false;
1108  bool _justDisplayVersion = false;
1109  bool _justRunSetup = false;
1110  bool _justTellInfo = false;
1111  std::set<String> _tellInfoKeys;
1112  int _loadSaveGameOnStartup = -1;
1113 
1114  // ScummVM GUIO-controlled flags
1115  bool _saveThumbnail = true; // capture a screenshot when saving (used for saves thumbnails)
1116  bool _noScummAutosave = false; // disable ScummVM autosaves
1117  bool _noScummSaveLoad = false; // disable ScummVM GMM save/load
1118 
1119 #if 0
1120  int _psp_rotation = 0;
1122  int _psp_gfx_renderer = 0;
1123  int _psp_gfx_scaling = 1;
1124  int _psp_gfx_smoothing = 0;
1125  int _psp_gfx_super_sampling = 1;
1126  int _psp_gfx_smooth_sprites = 0;
1127 #endif
1128 
1129  // Current engine version
1130  Version _EngineVersion;
1131 
1140  ManagedObjectPool *_pool;
1141 
1150  int8 _currentcursor = 0;
1151  // virtual mouse cursor coordinates
1152  int _mousex = 0, _mousey = 0, _numcurso = -1, _hotx = 0, _hoty = 0;
1153  // real mouse coordinates and bounds (in window coords)
1154  int _real_mouse_x = 0, _real_mouse_y = 0;
1155  int _boundx1 = 0, _boundx2 = 99999, _boundy1 = 0, _boundy2 = 99999;
1156  int8 _ignore_bounds = 0;
1157  AGS::Shared::Bitmap *_mousecurs[MAXCURSORS];
1158 
1159  ScriptMouse *_scmouse;
1160  int _cur_mode = 0, _cur_cursor = 0;
1161  int _mouse_frame = 0, _mouse_delay = 0;
1162  int _lastmx = -1, _lastmy = -1;
1163  int8 _alpha_blend_cursor = 0;
1164  AGS::Shared::Bitmap *_dotted_mouse_cursor = nullptr;
1165  AGS::Engine::IDriverDependantBitmap *_mouseCursor = nullptr;
1166  AGS::Shared::Bitmap *_blank_mouse_cursor = nullptr;
1167 
1176  int _butwas = 0;
1177  int _hotxwas = 0, _hotywas = 0;
1178  Mouse *_mouse;
1179 
1188  std::vector<ScreenOverlay> *_screenover;
1189  int _is_complete_overlay = 0;
1190 
1199  PluginObjectReader *_pluginReaders;
1200  int _numPluginReaders = 0;
1201 
1210  bool _handledErrorInEditor = false;
1211  char _return_to_roomedit[30] = { '\0' };
1212  char _return_to_room[150] = { '\0' };
1213  char _quit_message[256] = { '\0' };
1214 
1223  RGB_MAP *_rgb_table; // for 256-col antialiasing
1224  int _new_room_flags = 0;
1225  int _gs_to_newroom = -1;
1226  int _bg_just_changed = 0;
1227 
1236  int32_t *_navpoints;
1237  Navigation *_nav;
1238  int _num_navpoints = 0;
1239  AGS::Shared::Bitmap *_wallscreen = nullptr;
1240  int _lastcx = 0, _lastcy = 0;
1241  std::unique_ptr<IRouteFinder> *_route_finder_impl;
1242 
1251  // Screenshot made in the last room, used during some of the transition effects
1252  AGS::Shared::Bitmap *_saved_viewport_bitmap = nullptr;
1253  color *_old_palette;
1254 
1263  ExecutingScript *_scripts;
1264  ExecutingScript *_curscript = nullptr;
1265 
1266  PScript *_gamescript;
1267  PScript *_dialogScriptsScript;
1268  ccInstance *_gameinst = nullptr, *_roominst = nullptr;
1269  ccInstance *_dialogScriptsInst = nullptr;
1270  ccInstance *_gameinstFork = nullptr, *_roominstFork = nullptr;
1271 
1272  int _num_scripts = 0;
1273  int _post_script_cleanup_stack = 0;
1274 
1275  int _inside_script = 0, _in_graph_script = 0;
1276  int _no_blocking_functions = 0; // set to 1 while in rep_Exec_always
1277 
1278  NonBlockingScriptFunction *_repExecAlways;
1279  NonBlockingScriptFunction *_lateRepExecAlways;
1280  NonBlockingScriptFunction *_getDialogOptionsDimensionsFunc;
1281  NonBlockingScriptFunction *_renderDialogOptionsFunc;
1282  NonBlockingScriptFunction *_getDialogOptionUnderCursorFunc;
1283  NonBlockingScriptFunction *_runDialogOptionMouseClickHandlerFunc;
1284  NonBlockingScriptFunction *_runDialogOptionKeyPressHandlerFunc;
1285  NonBlockingScriptFunction *_runDialogOptionTextInputHandlerFunc;
1286  NonBlockingScriptFunction *_runDialogOptionRepExecFunc;
1287  NonBlockingScriptFunction *_runDialogOptionCloseFunc;
1288 
1289  ScriptSystem *_scsystem;
1290 
1291  std::vector<PScript> *_scriptModules;
1292  std::vector<ccInstance *> *_moduleInst;
1293  std::vector<ccInstance *> *_moduleInstFork;
1294  std::vector<RuntimeScriptValue> *_moduleRepExecAddr;
1295  size_t _numScriptModules = 0;
1296 
1305  new_line_hook_type _new_line_hook = nullptr;
1306  // Minimal timeout: how much time may pass without any engine update
1307  // before we want to check on the situation and do system poll
1308  unsigned _timeoutCheckMs = 60u;
1309  // Critical timeout: how much time may pass without any engine update
1310  // before we abort or post a warning
1311  unsigned _timeoutAbortMs = 0u;
1312  // Maximal while loops without any engine update in between,
1313  // after which the interpreter will abort
1314  unsigned _maxWhileLoops = 0u;
1315  ccInstance *_loadedInstances[MAX_LOADED_INSTANCES];
1316 
1325  int _MAXSTRLEN = MAX_MAXSTRLEN;
1326 
1335  SystemImports *_simp;
1336  SystemImports *_simp_for_plugin;
1337 
1346  Plugins::Core::EngineExports *_engineExports;
1347  Common::Array<EnginePlugin> *_plugins;
1348  int _pluginsWantingDebugHooks = 0;
1349  long _pl_file_handle = -1;
1350  AGS::Shared::Stream *_pl_file_stream = nullptr;
1351 
1352  eAGSMouseButton _pluginSimulatedClick = kMouseNone;
1353  int _mouse_z_was = 0;
1354 
1363  std::chrono::microseconds _tick_duration = std::chrono::microseconds(1000000LL / 40);
1364  bool _framerate_maxed = false;
1365  int _framerate = 0;
1366 
1367  uint32 _last_tick_time = 0; // AGS_Clock::now();
1368  uint32 _next_frame_timestamp = 0; // AGS_Clock::now();
1369 
1378  AGS::Shared::Translation *_trans;
1379  AGS::Shared::StringMap *_transtree = nullptr;
1380  String _trans_name, _trans_filename;
1381  long _lang_offs_start = 0;
1382  char _transFileName[MAX_PATH_SZ] = { 0 };
1383  std::vector<uint16> _wcsbuf; // widechar buffer
1384  std::vector<char> _mbbuf; // utf8 buffer
1385 
1394  AGS::Shared::Bitmap *_walkareabackup = nullptr, *_walkable_areas_temp = nullptr;
1395 
1404  char *_walkBehindExists = nullptr; // whether a WB area is in this column
1405  int *_walkBehindStartY = nullptr, *_walkBehindEndY = nullptr;
1406  int8 _noWalkBehindsAtAll = 0;
1407  int _walkBehindLeft[MAX_WALK_BEHINDS], _walkBehindTop[MAX_WALK_BEHINDS];
1408  int _walkBehindRight[MAX_WALK_BEHINDS], _walkBehindBottom[MAX_WALK_BEHINDS];
1409  AGS::Engine::IDriverDependantBitmap *_walkBehindBitmap[MAX_WALK_BEHINDS];
1410  int _walkBehindsCachedForBgNum = 0;
1411  WalkBehindMethodEnum _walkBehindMethod = DrawOverCharSprite;
1412  int _walk_behind_baselines_changed = 0;
1413  Rect _walkBehindAABB[MAX_WALK_BEHINDS]; // WB bounding box
1414  std::vector<WalkBehindColumn> _walkBehindCols; // precalculated WB positions
1415 
1424  const char *_passwencstring = "Avis Durgan";
1425 
1428 public:
1429  Globals();
1430  ~Globals();
1431 };
1432 
1433 extern Globals *g_globals;
1434 
1435 // Macro for accessing a globals member
1436 #define _G(FIELD) (::AGS3::g_globals->_##FIELD)
1437 // Macro for accessing a globals member that was an object in the original,
1438 // but is a pointer to the object in ScummVM, so that we don't need to
1439 // provide the full class/struct definition here in the header file
1440 #define _GP(FIELD) (*::AGS3::g_globals->_##FIELD)
1441 
1442 } // namespace AGS3
1443 
1444 #endif
Definition: achievements_tables.h:27
Definition: script_system.h:35
Definition: cc_hotspot.h:29
Definition: cc_dynamic_array.h:33
Definition: globals.h:185
Definition: cc_common.h:46
Definition: gui_dialog_defines.h:106
Definition: managed_object_pool.h:50
Definition: debug_manager.h:109
Definition: allegro_bitmap.h:44
Definition: vector.h:45
Definition: cc_dialog.h:29
Definition: geometry.h:87
Definition: array.h:52
Definition: plugin_object_reader.h:29
Definition: script_gui.h:28
Definition: script_dialog_options_rendering.h:29
Definition: script_string.h:29
Definition: display_client.h:58
Definition: graphics_mode.h:119
Definition: queue.h:67
Definition: sprite_cache.h:86
Definition: runtime_script_value.h:65
Definition: draw.h:65
Definition: cc_instance.h:84
Definition: cc_audio_channel.h:29
Definition: script_drawing_surface.h:36
Definition: room_status.h:61
Definition: file.h:145
Definition: ptr.h:572
Definition: cc_gui_object.h:29
Definition: cc_region.h:29
Definition: chrono.h:65
Definition: gfxfilter.h:41
Definition: ags_static_object.h:29
Definition: sound_clip.h:53
Definition: room_object.h:48
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: lip_sync.h:27
Definition: globals.h:504
Definition: game_setup_struct.h:53
Definition: cc_dynamic_object.h:103
Definition: ags_platform_driver.h:70
Definition: draw.h:91
Definition: tra_file.h:64
Definition: wfn_font.h:66
Definition: algorithm.h:29
Definition: graphics_driver.h:98
Definition: cc_gui.h:29
Definition: version.h:39
Definition: static_array.h:31
Definition: set.h:34
Definition: interactions.h:185
Definition: gui_dialog_defines.h:112
Definition: script_mouse.h:28
Definition: scaling.h:108
Definition: engine.h:59
Definition: geometry.h:215
Definition: color.h:49
Definition: character_info.h:74
Definition: ttf_font_renderer.h:33
Definition: fonts.h:150
Definition: cc_audio_clip.h:29
Definition: string.h:62
Definition: game_setup.h:61
Definition: executing_script.h:61
Definition: room_struct.h:270
Definition: wfn_font_renderer.h:32
Definition: game_state.h:74
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: stream.h:52
Definition: gfx_driver_factory.h:51
Definition: script_dialog.h:27
Definition: ags_static_object.h:47
Definition: script_audio_channel.h:27
Definition: cc_instance.h:99
Definition: engine.h:143
Definition: ags.h:40
Definition: array.h:31
Definition: chrono.h:55
Definition: system_imports.h:45
Definition: cc_character.h:29
Definition: script_region.h:27
Definition: non_blocking_script_function.h:31