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
58namespace Common {
59class DumpFile;
60}
61
62namespace AGS3 {
63
64#define MAXCURSORS 20
65
66using String = AGS::Shared::String;
67using Version = AGS::Shared::Version;
68
69namespace AGS {
70namespace Shared {
71
72class AssetManager;
73class Bitmap;
74class DebugManager;
75struct Font;
76class GUIButton;
77class GUIInvWindow;
78class GUILabel;
79class GUIListBox;
80class GUISlider;
81class GUITextBox;
82struct InteractionVariable;
83struct PlaneScaling;
84class RoomStruct;
85class SpriteCache;
86struct Translation;
87
88} // namespace Shared
89
90namespace Engine {
91
92class ConsoleOutputTarget;
93struct GfxFilterInfo;
94class IDriverDependantBitmap;
95class IGfxDriverFactory;
96class IGraphicsDriver;
97class LogFile;
98class MessageBuffer;
99
100} // namespace Engine
101} // namespace AGS
102
103namespace Plugins {
104namespace Core {
105class EngineExports;
106} // namespace Core
107} // namespace Plugins
108
109class IRouteFinder;
110class Navigation;
111class SplitLines;
112class TTFFontRenderer;
113class WFNFontRenderer;
114
115struct AGSCCStaticObject;
116struct AGSDeSerializer;
117struct AGSPlatformDriver;
118struct AmbientSound;
119struct AnimatingGUIButton;
120struct CachedActSpsData;
121struct CCAudioChannel;
122struct CCAudioClip;
123struct CCCharacter;
124struct CCDialog;
125struct CCDynamicArray;
126struct CCGUI;
127struct CCGUIObject;
128struct CCHotspot;
129struct ccInstance;
130struct CCInventory;
131struct CCObject;
132struct CCRegion;
133struct CharacterCache;
134struct CharacterExtras;
135struct CharacterInfo;
136struct color;
137struct COLOR_MAP;
138struct CSCIMessage;
139struct DialogTopic;
140struct DirtyRects;
141struct EnginePlugin;
142struct ExecutingScript;
143struct EventHappened;
144struct GameSetup;
145struct GameSetupStruct;
146struct GameState;
147struct IAGSEditorDebugger;
148struct ICCStringClass;
149struct ManagedObjectPool;
150struct Mouse;
151struct MoveList;
152struct NewControl;
153struct NonBlockingScriptFunction;
154struct ObjectCache;
155struct OnScreenWindow;
156struct PluginObjectReader;
157struct Point;
158struct ResourcePaths;
159struct RGB_MAP;
160struct RoomCameraDrawData;
161struct RoomObject;
162struct RoomStatus;
163struct RuntimeScriptValue;
164struct ScreenOverlay;
165struct ScriptAudioChannel;
166struct ScriptDialog;
167struct ScriptDialogOptionsRendering;
168struct ScriptDrawingSurface;
169struct ScriptError;
170struct ScriptGUI;
171struct ScriptHotspot;
172struct ScriptInvItem;
173struct ScriptMouse;
174struct ScriptObject;
175struct ScriptPosition;
176struct ScriptRegion;
177struct ScriptString;
178struct ScriptSystem;
179struct SOUNDCLIP;
180struct SpeechLipSyncLine;
181struct SpriteListEntry;
182struct StaticArray;
183struct CCStaticArray;
184struct StaticGame;
185struct SystemImports;
186struct TopBarSettings;
187struct ViewStruct;
188
189class Globals {
190public:
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;
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
531
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
595 // Walk-behind textures (3D renderers only)
596 std::vector<ObjTexture> *_walkbehindobj;
597 // GUI surfaces
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
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;
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
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.
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
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
1122 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 // 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 int _ignore_bounds = 0; // FIXME: this currently works as a counter, not bool?
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 std::queue<int32_t> *_over_free_ids;
1190 int _is_complete_overlay = 0;
1191
1208 bool _handledErrorInEditor = false;
1209 char _return_to_roomedit[30] = { '\0' };
1210 char _return_to_room[150] = { '\0' };
1211 char _quit_message[256] = { '\0' };
1212
1221 RGB_MAP *_rgb_table; // for 256-col antialiasing
1222 int _new_room_flags = 0;
1223 int _gs_to_newroom = -1;
1224 int _bg_just_changed = 0;
1225 std::unique_ptr<RoomStatus> _room_statuses[MAX_ROOMS];
1226
1235 Point *_navpoints;
1236 Navigation *_nav;
1237 int _num_navpoints = 0;
1238 AGS::Shared::Bitmap *_wallscreen = nullptr;
1239 fixed _move_speed_x, _move_speed_y;
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 UInstance _gameinst;
1269 UInstance _roominst;
1270 UInstance _dialogScriptsInst;
1271 UInstance _gameinstFork;
1272 UInstance _roominstFork;
1273
1274 int _num_scripts = 0;
1275 int _post_script_cleanup_stack = 0;
1276
1277 int _inside_script = 0, _in_graph_script = 0;
1278 int _no_blocking_functions = 0; // set to 1 while in rep_Exec_always
1279
1280 NonBlockingScriptFunction *_repExecAlways;
1281 NonBlockingScriptFunction *_lateRepExecAlways;
1282 NonBlockingScriptFunction *_getDialogOptionsDimensionsFunc;
1283 NonBlockingScriptFunction *_renderDialogOptionsFunc;
1284 NonBlockingScriptFunction *_getDialogOptionUnderCursorFunc;
1285 NonBlockingScriptFunction *_runDialogOptionMouseClickHandlerFunc;
1286 NonBlockingScriptFunction *_runDialogOptionKeyPressHandlerFunc;
1287 NonBlockingScriptFunction *_runDialogOptionTextInputHandlerFunc;
1288 NonBlockingScriptFunction *_runDialogOptionRepExecFunc;
1289 NonBlockingScriptFunction *_runDialogOptionCloseFunc;
1290
1291 ScriptSystem *_scsystem;
1292
1293 std::vector<PScript> *_scriptModules;
1294 std::vector<UInstance> *_moduleInst;
1295 std::vector<UInstance> *_moduleInstFork;
1296 std::vector<RuntimeScriptValue> *_moduleRepExecAddr;
1297 size_t _numScriptModules = 0;
1298
1307 new_line_hook_type _new_line_hook = nullptr;
1308 // Minimal timeout: how much time may pass without any engine update
1309 // before we want to check on the situation and do system poll
1310 unsigned _timeoutCheckMs = 60u;
1311 // Critical timeout: how much time may pass without any engine update
1312 // before we abort or post a warning
1313 unsigned _timeoutAbortMs = 0u;
1314 // Maximal while loops without any engine update in between,
1315 // after which the interpreter will abort
1316 unsigned _maxWhileLoops = 0u;
1317 ccInstance *_loadedInstances[MAX_LOADED_INSTANCES];
1318 ScriptString *_myScriptStringImpl;
1319 ScriptUserObject _globalDynamicStruct;
1320
1337 SystemImports *_simp;
1338 SystemImports *_simp_for_plugin;
1339
1348 Plugins::Core::EngineExports *_engineExports;
1350 int _pluginsWantingDebugHooks = 0;
1351 long _pl_file_handle = -1;
1352 AGS::Shared::Stream *_pl_file_stream = nullptr;
1353
1354 eAGSMouseButton _simulatedClick = kMouseNone;
1355 int _mouse_z_was = 0;
1356
1365 std::chrono::microseconds _tick_duration = std::chrono::microseconds(1000000LL / 40);
1366 bool _framerate_maxed = false;
1367 int _framerate = 0;
1368
1369 uint32 _last_tick_time = 0; // AGS_Clock::now();
1370 uint32 _next_frame_timestamp = 0; // AGS_Clock::now();
1371
1380 AGS::Shared::Translation *_trans;
1381 AGS::Shared::StringMap *_transtree = nullptr;
1382 String _trans_name, _trans_filename;
1383 long _lang_offs_start = 0;
1384 char _transFileName[MAX_PATH_SZ] = { 0 };
1385 std::vector<uint16> _wcsbuf; // widechar buffer
1386 std::vector<char> _mbbuf; // utf8 buffer
1387
1396 AGS::Shared::Bitmap *_walkareabackup = nullptr, *_walkable_areas_temp = nullptr;
1397
1406 char *_walkBehindExists = nullptr; // whether a WB area is in this column
1407 int *_walkBehindStartY = nullptr, *_walkBehindEndY = nullptr;
1408 int8 _noWalkBehindsAtAll = 0;
1409 int _walkBehindLeft[MAX_WALK_BEHINDS], _walkBehindTop[MAX_WALK_BEHINDS];
1410 int _walkBehindRight[MAX_WALK_BEHINDS], _walkBehindBottom[MAX_WALK_BEHINDS];
1411 AGS::Engine::IDriverDependantBitmap *_walkBehindBitmap[MAX_WALK_BEHINDS];
1412 int _walkBehindsCachedForBgNum = -1;
1413 int _walk_behind_baselines_changed = 0;
1414 Rect _walkBehindAABB[MAX_WALK_BEHINDS]; // WB bounding box
1415 std::vector<WalkBehindColumn> _walkBehindCols; // precalculated WB positions
1416
1425 const char *_passwencstring = "Avis Durgan";
1426
1429public:
1430 Globals();
1431 ~Globals();
1432};
1433
1434extern Globals *g_globals;
1435
1436// Macro for accessing a globals member
1437#define _G(FIELD) (::AGS3::g_globals->_##FIELD)
1438// Macro for accessing a globals member that was an object in the original,
1439// but is a pointer to the object in ScummVM, so that we don't need to
1440// provide the full class/struct definition here in the header file
1441#define _GP(FIELD) (*::AGS3::g_globals->_##FIELD)
1442
1443} // namespace AGS3
1444
1445#endif
Definition: gfx_driver_factory.h:51
Definition: graphics_driver.h:98
Definition: allegro_bitmap.h:44
Definition: debug_manager.h:109
Definition: room_struct.h:269
Definition: sprite_cache.h:80
Definition: string.h:60
Definition: globals.h:189
Definition: fonts.h:157
Definition: ttf_font_renderer.h:33
Definition: wfn_font_renderer.h:33
Definition: array.h:52
Definition: file.h:145
Definition: queue.h:42
Definition: ptr.h:572
Definition: engine.h:149
Definition: array.h:39
Definition: queue.h:75
Definition: set.h:42
Definition: vector.h:39
Definition: algorithm.h:29
Definition: gfxfilter.h:41
Definition: interactions.h:185
Definition: scaling.h:108
Definition: version.h:39
Definition: cc_ags_dynamic_object.h:108
Definition: cc_serializer.h:29
Definition: ags_platform_driver.h:72
Definition: graphics_mode.h:119
Definition: cc_audio_channel.h:29
Definition: cc_audio_clip.h:29
Definition: cc_character.h:36
Definition: cc_dialog.h:29
Definition: cc_dynamic_array.h:33
Definition: cc_gui.h:29
Definition: cc_gui_object.h:29
Definition: cc_hotspot.h:29
Definition: cc_inventory.h:29
Definition: cc_object.h:29
Definition: cc_region.h:29
Definition: script_game.h:35
Definition: color.h:69
Definition: gui_dialog_defines.h:115
Definition: character_info.h:117
Definition: draw_software.h:63
Definition: draw.h:155
Definition: draw.h:76
Definition: game_setup.h:61
Definition: game_setup_struct.h:60
Definition: game_state.h:80
Definition: globals.h:509
Definition: globals.h:567
Definition: globals.h:843
Definition: ags_editor_debugger.h:27
Definition: managed_object_pool.h:50
Definition: mouse_w32.h:37
Definition: new_control.h:31
Definition: draw.h:105
Definition: draw.h:139
Definition: gui_dialog_defines.h:121
Definition: geometry.h:87
Definition: color.h:65
Definition: engine.h:59
Definition: room_object.h:58
Definition: room_status.h:65
Definition: runtime_script_value.h:63
Definition: sound_clip.h:53
Definition: script_audio_channel.h:27
Definition: script_dialog_options_rendering.h:29
Definition: script_drawing_surface.h:32
Definition: cc_common.h:46
Definition: file.h:61
Definition: script_hotspot.h:27
Definition: script_inv_item.h:27
Definition: script_mouse.h:34
Definition: script_object.h:30
Definition: cc_instance.h:98
Definition: script_region.h:27
Definition: top_bar_settings.h:27
Definition: wfn_font.h:66
Definition: color.h:49
Definition: display_client.h:58