25#include "ags/shared/core/platform.h"
26#define AGS_PLATFORM_DEFINES_PSP_VARS (AGS_PLATFORM_OS_IOS || AGS_PLATFORM_OS_ANDROID)
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"
66using String = AGS::Shared::String;
67using Version = AGS::Shared::Version;
82struct InteractionVariable;
92class ConsoleOutputTarget;
94class IDriverDependantBitmap;
95class IGfxDriverFactory;
112class TTFFontRenderer;
113class WFNFontRenderer;
115struct AGSCCStaticObject;
116struct AGSDeSerializer;
117struct AGSPlatformDriver;
119struct AnimatingGUIButton;
120struct CachedActSpsData;
121struct CCAudioChannel;
125struct CCDynamicArray;
133struct CharacterCache;
134struct CharacterExtras;
142struct ExecutingScript;
145struct GameSetupStruct;
147struct IAGSEditorDebugger;
148struct ICCStringClass;
149struct ManagedObjectPool;
153struct NonBlockingScriptFunction;
155struct OnScreenWindow;
156struct PluginObjectReader;
160struct RoomCameraDrawData;
163struct RuntimeScriptValue;
165struct ScriptAudioChannel;
167struct ScriptDialogOptionsRendering;
168struct ScriptDrawingSurface;
175struct ScriptPosition;
180struct SpeechLipSyncLine;
181struct SpriteListEntry;
186struct TopBarSettings;
191 enum SimdFlags : uint {
193 SIMD_NEON = (1 << 0),
194 SIMD_SSE2 = (1 << 1),
195 SIMD_AVX2 = (1 << 2),
211 int *_allegro_errno = &_errnum;
213 int __color_depth = 0;
214 int __rgb_r_shift_15 = DEFAULT_RGB_R_SHIFT_15;
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;
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;
240 PALETTE _black_palette;
241 PALETTE _current_palette;
242 PALETTE _prev_current_palette;
244 volatile int _mouse_x = 0;
245 volatile int _mouse_y = 0;
246 volatile int _mouse_z = 0;
247 volatile int _mouse_b = 0;
248 volatile int _mouse_pos = 0;
253 volatile int _sys_mouse_x = 0;
254 volatile int _sys_mouse_y = 0;
255 volatile int _sys_mouse_z = 0;
257 volatile int _freeze_mouse_flag = 0;
260 int _mouse_accum_relx = 0, _mouse_accum_rely = 0;
262 int _mouse_button_state = 0;
263 int _mouse_accum_button_state = 0;
264 uint32 _mouse_clear_at_time = 0;
265 eAGSMouseButton _wasbutdown = kMouseNone;
289 const std::chrono::milliseconds _MaximumDelayBetweenPolling = std::chrono::milliseconds(16);
325 int _reserved_channel_count = 0;
329 int _current_music_type = 0;
332 int _crossFading = 0, _crossFadeVolumePerStep = 0, _crossFadeStep = 0;
333 int _crossFadeVolumeAtStart = 0;
338 bool _music_update_scheduled =
false;
339 uint32 _music_update_at = 0;
369 ICCStringClass *_stringClassImpl =
nullptr;
419 int _currentline = 0;
421 const char *_scfilesig =
"SCOM";
441 int _use_cdplayer = 0;
442 bool _triedToUseCdAudioCommand =
false;
443 int _need_to_stop_cd = 0;
454 int32_t _sc_PlayerCharPtr = 0;
455 int _char_lowest_yp = 0;
458 int _face_talking = -1, _facetalkview = 0, _facetalkwait = 0, _facetalkframe = 0;
459 int _facetalkloop = 0, _facetalkrepeat = 0, _facetalkAllowBlink = 1;
460 int _facetalkBlinkLoop = 0;
463 bool _facetalk_qfg4_override_placement_x =
false;
464 bool _facetalk_qfg4_override_placement_y =
false;
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;
481 int _windowbackgroundcolor, _pushbuttondarkcolor;
482 int _pushbuttonlightcolor;
483 int _topwindowhandle = -1;
485 int _acdialog_font = 0;
491 int _windowcount = 0, _curswas = 0;
492 int _win_x = 0, _win_y = 0, _win_width = 0, _win_height = 0;
502 int _editor_debugging_enabled = 0;
503 int _editor_debugging_initialized = 0;
504 char _editor_debugger_instance_token[100];
506 int _break_on_next_script_step = 0;
507 volatile int _game_paused_in_debugger = 0;
510 char scriptName[80] = { 0 };
516 int _debug_flags = 0;
548 int _said_speech_line = 0;
550 int _longestline = 0;
563 int _display_message_aschar = 0;
564 int _source_text_length = -1;
570 int fulltxtheight = 0;
608 RoomAreaMask _debugRoomMask = kRoomAreaNone;
609 int _debugMoveListChar = -1;
613 bool _current_background_is_dirty =
false;
617 bool _screen_is_dirty =
false;
656 bool _check_dynamic_sprites_at_exit =
true;
667 t_engine_pre_init_callback _engine_pre_init_callback =
nullptr;
677 int _convert_16bit_bgr = 0;
688 int _in_enters_screen = 0, _done_es_error = 0;
689 int _in_leaves_screen = -1;
693 int _inside_processevent = 0;
694 int _eventClaimed = 0;
696 const char *_tsnames[kTS_Num] = {
nullptr, REP_EXEC_NAME,
"on_key_press",
"on_mouse_click",
"on_text_input" };
711 String _installAudioDirectory;
713 String _installVoiceDirectory;
718 int _num_open_script_files = 0;
755 CCGUI *_ccDynamicGUI;
783 bool _want_exit =
false;
784 bool _abort_engine =
false;
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;
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;
803 GameDataVersion _loaded_game_file_version = kGameVersion_Undefined;
805 Version _game_compiled_version;
806 int _game_paused = 0;
807 unsigned int _load_new_game = 0;
808 int _load_new_game_restore = -1;
810 int _getloctype_index = 0, _getloctype_throughgui = 0;
811 char _gamefilenamebuf[200] = { 0 };
812 int _gameHasBeenRestored = 0;
814 int _game_update_suspend = 0;
815 bool _new_room_placeonwalkable =
false;
825 CCStaticArray *_StaticCharacterArray;
826 CCStaticArray *_StaticObjectArray;
827 CCStaticArray *_StaticGUIArray;
828 CCStaticArray *_StaticHotspotArray;
829 CCStaticArray *_StaticRegionArray;
830 CCStaticArray *_StaticInventoryArray;
831 CCStaticArray *_StaticDialogArray;
845 int disabled_for = 0;
847 const void *data_ptr =
nullptr;
854 unsigned int _loopcounter = 0;
855 unsigned int _lastcounter = 0;
856 int _numEventsAtStartOfFunction = 0;
858 int _old_key_shifts = 0;
930 int _obj_lowest_yp = 0;
948 FrameScaleDef _CurFrameSetup = kFrame_Undefined;
960 int _ifacepopped = -1;
961 int _mouse_on_iface = -1;
962 int _mouse_ifacebut_xoffs = -1, _mouse_ifacebut_yoffs = -1;
963 int _eip_guinum = 0, _eip_guiobj = 0;
984 int _windowPosX = 0, _windowPosY = 0, _windowPosWidth = 0, _windowPosHeight = 0;
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];
1036 int _guis_need_update = 1;
1037 AGS::Shared::GuiDisableStyle _all_buttons_disabled = AGS::Shared::kGuiDis_Undefined;
1038 int _gui_inv_pic = -1;
1069 int _numGlobalVars = 1;
1079 int _in_inv_screen = 0, _inv_screen_newroom = -1;
1089 uint8_t *_lzbuffer =
nullptr;
1090 int *_node =
nullptr;
1092 size_t _outbytes = 0;
1107 int _override_start_room = 0;
1108 bool _justDisplayHelp =
false;
1109 bool _justDisplayVersion =
false;
1110 bool _justRunSetup =
false;
1111 bool _justTellInfo =
false;
1113 int _loadSaveGameOnStartup = -1;
1116 bool _saveThumbnail =
true;
1117 bool _noScummAutosave =
false;
1118 bool _noScummSaveLoad =
false;
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;
1152 int _mousex = 0, _mousey = 0, _numcurso = -1, _hotx = 0, _hoty = 0;
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;
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;
1177 int _hotxwas = 0, _hotywas = 0;
1190 int _is_complete_overlay = 0;
1208 bool _handledErrorInEditor =
false;
1209 char _return_to_roomedit[30] = {
'\0' };
1210 char _return_to_room[150] = {
'\0' };
1211 char _quit_message[256] = {
'\0' };
1221 RGB_MAP *_rgb_table;
1222 int _new_room_flags = 0;
1223 int _gs_to_newroom = -1;
1224 int _bg_just_changed = 0;
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;
1252 AGS::Shared::Bitmap *_saved_viewport_bitmap =
nullptr;
1253 color *_old_palette;
1263 ExecutingScript *_scripts;
1264 ExecutingScript *_curscript =
nullptr;
1266 PScript *_gamescript;
1267 PScript *_dialogScriptsScript;
1268 UInstance _gameinst;
1269 UInstance _roominst;
1270 UInstance _dialogScriptsInst;
1271 UInstance _gameinstFork;
1272 UInstance _roominstFork;
1274 int _num_scripts = 0;
1275 int _post_script_cleanup_stack = 0;
1277 int _inside_script = 0, _in_graph_script = 0;
1278 int _no_blocking_functions = 0;
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;
1291 ScriptSystem *_scsystem;
1297 size_t _numScriptModules = 0;
1307 new_line_hook_type _new_line_hook =
nullptr;
1310 unsigned _timeoutCheckMs = 60u;
1313 unsigned _timeoutAbortMs = 0u;
1316 unsigned _maxWhileLoops = 0u;
1317 ccInstance *_loadedInstances[MAX_LOADED_INSTANCES];
1318 ScriptString *_myScriptStringImpl;
1319 ScriptUserObject _globalDynamicStruct;
1337 SystemImports *_simp;
1338 SystemImports *_simp_for_plugin;
1348 Plugins::Core::EngineExports *_engineExports;
1350 int _pluginsWantingDebugHooks = 0;
1351 long _pl_file_handle = -1;
1352 AGS::Shared::Stream *_pl_file_stream =
nullptr;
1354 eAGSMouseButton _simulatedClick = kMouseNone;
1355 int _mouse_z_was = 0;
1365 std::chrono::microseconds _tick_duration = std::chrono::microseconds(1000000LL / 40);
1366 bool _framerate_maxed =
false;
1369 uint32 _last_tick_time = 0;
1370 uint32 _next_frame_timestamp = 0;
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 };
1396 AGS::Shared::Bitmap *_walkareabackup =
nullptr, *_walkable_areas_temp =
nullptr;
1406 char *_walkBehindExists =
nullptr;
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];
1425 const char *_passwencstring =
"Avis Durgan";
1434extern Globals *g_globals;
1437#define _G(FIELD) (::AGS3::g_globals->_##FIELD)
1441#define _GP(FIELD) (*::AGS3::g_globals->_##FIELD)
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: globals.h:189
Definition: ttf_font_renderer.h:33
Definition: wfn_font_renderer.h:33
Definition: algorithm.h:29
Definition: gfxfilter.h:41
Definition: interactions.h:185
Definition: scaling.h:108
Definition: cc_ags_dynamic_object.h:108
Definition: cc_serializer.h:29
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_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: gui_dialog_defines.h:115
Definition: character_info.h:117
Definition: draw_software.h:63
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: gui_dialog_defines.h:121
Definition: geometry.h:87
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: 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: display_client.h:58