mirror of
https://github.com/libretro/scummvm.git
synced 2024-12-15 14:18:37 +00:00
AGS: Move script_runtime.cpp globals to Globals
This commit is contained in:
parent
bf3c05128d
commit
2f094655f1
@ -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
|
||||
//=============================================================================
|
||||
|
@ -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;
|
||||
|
@ -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 {
|
||||
|
||||
|
@ -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() {
|
||||
|
@ -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.
|
||||
|
@ -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];
|
||||
|
@ -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);
|
||||
|
@ -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) {
|
||||
|
@ -282,6 +282,10 @@ Globals::Globals() {
|
||||
_objectScriptObjNames = new String[MAX_ROOM_OBJECTS];
|
||||
_guiScriptObjNames = new std::vector<String>();
|
||||
|
||||
// script_runtime.cpp globals
|
||||
Common::fill(_loadedInstances, _loadedInstances + MAX_LOADED_INSTANCES,
|
||||
(ccInstance *)nullptr);
|
||||
|
||||
// systemimports.cpp globals
|
||||
_simp = new SystemImports();
|
||||
_simp_for_plugin = new SystemImports();
|
||||
|
@ -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
|
||||
* @{
|
||||
*/
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user