diff --git a/engines/ags/engine/ac/game.cpp b/engines/ags/engine/ac/game.cpp index 163efc2a06a..5fcbb48b17e 100644 --- a/engines/ags/engine/ac/game.cpp +++ b/engines/ags/engine/ac/game.cpp @@ -109,10 +109,6 @@ namespace AGS3 { using namespace AGS::Shared; using namespace AGS::Engine; -#if AGS_PLATFORM_OS_IOS || AGS_PLATFORM_OS_ANDROID -extern int _G(psp_gfx_renderer); -#endif - //============================================================================= // Audio //============================================================================= diff --git a/engines/ags/engine/ac/global_game.cpp b/engines/ags/engine/ac/global_game.cpp index 18604839074..93c34003082 100644 --- a/engines/ags/engine/ac/global_game.cpp +++ b/engines/ags/engine/ac/global_game.cpp @@ -77,10 +77,6 @@ using namespace AGS::Shared; extern int gui_disabled_style; -#if AGS_PLATFORM_OS_IOS || AGS_PLATFORM_OS_ANDROID -extern int _G(psp_gfx_renderer); -#endif - void GiveScore(int amnt) { guis_need_update = 1; _GP(play).score += amnt; diff --git a/engines/ags/engine/gfx/gfx_util.cpp b/engines/ags/engine/gfx/gfx_util.cpp index 298079fc2cf..c5b50c7a113 100644 --- a/engines/ags/engine/gfx/gfx_util.cpp +++ b/engines/ags/engine/gfx/gfx_util.cpp @@ -26,11 +26,6 @@ namespace AGS3 { -// CHECKME: is this hack still relevant? -#if AGS_PLATFORM_OS_IOS || AGS_PLATFORM_OS_ANDROID -extern int _G(psp_gfx_renderer); -#endif - namespace AGS { namespace Engine { diff --git a/engines/ags/engine/platform/base/agsplatformdriver.cpp b/engines/ags/engine/platform/base/agsplatformdriver.cpp index 97569bd0f40..e90ad0a82ce 100644 --- a/engines/ags/engine/platform/base/agsplatformdriver.cpp +++ b/engines/ags/engine/platform/base/agsplatformdriver.cpp @@ -190,10 +190,6 @@ void AGSPlatformDriver::PrintMessage(const Shared::DebugMessage &msg) { #if defined (AGS_HAS_CD_AUDIO) -// from ac_cdplayer -extern int _G(use_cdplayer); -extern int _G(need_to_stop_cd); - int numcddrives = 0; int cd_player_init() { diff --git a/engines/ags/engine/platform/windows/gfx/ali3dd3d.cpp b/engines/ags/engine/platform/windows/gfx/ali3dd3d.cpp index a53c0a328dd..0ce78f86634 100644 --- a/engines/ags/engine/platform/windows/gfx/ali3dd3d.cpp +++ b/engines/ags/engine/platform/windows/gfx/ali3dd3d.cpp @@ -49,9 +49,6 @@ namespace AGS3 { using namespace AGS::Shared; -// Necessary to update textures from 8-bit bitmaps -extern RGB palette[256]; - // // Following functions implement various matrix operations. Normally they are found in the auxiliary d3d9x.dll, // but we do not want AGS to be dependent on it. diff --git a/engines/ags/engine/platform/windows/win_ex_handling.cpp b/engines/ags/engine/platform/windows/win_ex_handling.cpp index c57f728ac33..f103d107f7c 100644 --- a/engines/ags/engine/platform/windows/win_ex_handling.cpp +++ b/engines/ags/engine/platform/windows/win_ex_handling.cpp @@ -41,9 +41,6 @@ namespace AGS3 { using namespace AGS::Shared; -extern int _G(our_eip); -extern int _G(eip_guinum); -extern int _G(eip_guiobj); extern int proper_exit; char tempmsg[100]; diff --git a/engines/ags/engine/script/cc_instance.cpp b/engines/ags/engine/script/cc_instance.cpp index 79bcf29e5e6..90375745ca2 100644 --- a/engines/ags/engine/script/cc_instance.cpp +++ b/engines/ags/engine/script/cc_instance.cpp @@ -50,14 +50,6 @@ namespace AGS3 { using namespace AGS::Shared; using namespace AGS::Shared::Memory; -extern ccInstance *loadedInstances[MAX_LOADED_INSTANCES]; // in script/script_runtime - - // in script/script -extern int maxWhileLoops; -extern new_line_hook_type new_line_hook; - - - enum ScriptOpArgIsReg { kScOpNoArgIsReg = 0, kScOpArg1IsReg = 0x0001, @@ -356,8 +348,8 @@ int ccInstance::CallScriptFunction(const char *funcname, int32_t numargs, const // object with ref count 0 that is in use _GP(pool).RunGarbageCollectionIfAppropriate(); - if (new_line_hook) - new_line_hook(nullptr, 0); + if (_G(new_line_hook)) + _G(new_line_hook)(nullptr, 0); if (reterr) return -6; @@ -525,8 +517,8 @@ int ccInstance::Run(int32_t curpc) { case SCMD_LINENUM: line_number = arg1.IValue; _G(currentline) = arg1.IValue; - if (new_line_hook) - new_line_hook(this, _G(currentline)); + if (_G(new_line_hook)) + _G(new_line_hook)(this, _G(currentline)); break; case SCMD_ADD: // If the the register is SREG_SP, we are allocating new variable on the stack @@ -760,13 +752,13 @@ int ccInstance::Run(int32_t curpc) { case SCMD_JMP: pc += arg1.IValue; - if ((arg1.IValue < 0) && (maxWhileLoops > 0) && (loopIterationCheckDisabled == 0)) { + if ((arg1.IValue < 0) && (_G(maxWhileLoops) > 0) && (loopIterationCheckDisabled == 0)) { // Make sure it's not stuck in a While loop loopIterations ++; if (flags & INSTF_RUNNING) { loopIterations = 0; flags &= ~INSTF_RUNNING; - } else if (loopIterations > maxWhileLoops) { + } else if (loopIterations > _G(maxWhileLoops)) { cc_error("!Script appears to be hung (a while loop ran %d times). The problem may be in a calling function; check the call stack.", loopIterations); return -1; } @@ -943,7 +935,7 @@ int ccInstance::Run(int32_t curpc) { // extract the instance ID int32_t instId = codeOp.Instruction.InstanceId; // determine the offset into the code of the instance we want - runningInst = loadedInstances[instId]; + runningInst = _G(loadedInstances)[instId]; intptr_t callAddr = reg1.Ptr - (char *)&runningInst->code[0]; if (callAddr % sizeof(intptr_t) != 0) { cc_error("call address not aligned"); @@ -1336,8 +1328,8 @@ bool ccInstance::_Create(PScript scri, ccInstance *joined) { // find a LoadedInstance slot for it for (i = 0; i < MAX_LOADED_INSTANCES; i++) { - if (loadedInstances[i] == nullptr) { - loadedInstances[i] = this; + if (_G(loadedInstances)[i] == nullptr) { + _G(loadedInstances)[i] = this; loadedInstanceId = i; break; } @@ -1413,8 +1405,8 @@ void ccInstance::Free() { } // remove from the Active Instances list - if (loadedInstances[loadedInstanceId] == this) - loadedInstances[loadedInstanceId] = nullptr; + if (_G(loadedInstances)[loadedInstanceId] == this) + _G(loadedInstances)[loadedInstanceId] = nullptr; if ((flags & INSTF_SHAREDATA) == 0) { nullfree(globaldata); diff --git a/engines/ags/engine/script/script_runtime.cpp b/engines/ags/engine/script/script_runtime.cpp index 4d6c62f4f63..26b2a28da83 100644 --- a/engines/ags/engine/script/script_runtime.cpp +++ b/engines/ags/engine/script/script_runtime.cpp @@ -83,11 +83,6 @@ void ccRemoveAllSymbols() { _GP(simp).clear(); } -ccInstance *loadedInstances[MAX_LOADED_INSTANCES] = { nullptr, - nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, - nullptr, nullptr, nullptr, nullptr, nullptr, nullptr -}; - void nullfree(void *data) { if (data != nullptr) free(data); @@ -119,16 +114,11 @@ void *ccGetSymbolAddressForPlugin(const String &name) { return nullptr; } -new_line_hook_type new_line_hook = nullptr; - -char ccRunnerCopyright[] = "ScriptExecuter32 v" SCOM_VERSIONSTR " (c) 2001 Chris Jones"; -int maxWhileLoops = 0; - // If a while loop does this many iterations without the // NofityScriptAlive function getting called, the script // aborts. Set to 0 to disable. void ccSetScriptAliveTimer(int numloop) { - maxWhileLoops = numloop; + _G(maxWhileLoops) = numloop; } void ccNotifyScriptStillAlive() { @@ -137,7 +127,7 @@ void ccNotifyScriptStillAlive() { } void ccSetDebugHook(new_line_hook_type jibble) { - new_line_hook = jibble; + _G(new_line_hook) = jibble; } int call_function(intptr_t addr, const RuntimeScriptValue *object, int numparm, const RuntimeScriptValue *parms) { diff --git a/engines/ags/globals.cpp b/engines/ags/globals.cpp index 4d0d9d2c182..f19f6350c10 100644 --- a/engines/ags/globals.cpp +++ b/engines/ags/globals.cpp @@ -282,6 +282,10 @@ Globals::Globals() { _objectScriptObjNames = new String[MAX_ROOM_OBJECTS]; _guiScriptObjNames = new std::vector(); + // script_runtime.cpp globals + Common::fill(_loadedInstances, _loadedInstances + MAX_LOADED_INSTANCES, + (ccInstance *)nullptr); + // systemimports.cpp globals _simp = new SystemImports(); _simp_for_plugin = new SystemImports(); diff --git a/engines/ags/globals.h b/engines/ags/globals.h index 075057d9dfc..1a01cae5d53 100644 --- a/engines/ags/globals.h +++ b/engines/ags/globals.h @@ -33,6 +33,7 @@ #include "ags/engine/main/engine.h" #include "ags/engine/media/audio/audiodefines.h" #include "ags/engine/script/script.h" +#include "ags/engine/script/script_runtime.h" #include "ags/lib/std/array.h" #include "ags/lib/std/set.h" #include "ags/lib/allegro/color.h" @@ -1039,7 +1040,18 @@ public: /**@}*/ /** - * \defgroup script globals + * \defgroup script_runtime globals + * @{ + */ + + new_line_hook_type _new_line_hook = nullptr; + int _maxWhileLoops = 0; + ccInstance *_loadedInstances[MAX_LOADED_INSTANCES]; + + /**@}*/ + + /** + * \defgroup systemimports globals * @{ */