[Scummvm-git-logs] scummvm master -> bf3c05128d15680fc93b5c46d64cb901b6ac39fc
dreammaster
dreammaster at scummvm.org
Sat Mar 13 04:44:37 UTC 2021
This automated email contains information about 8 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
f8eb923d25 AGS: Moved cdaudio.cpp globals to Globals
7462386f66 AGS: Remove unused test globals
1735868c31 AGS: Move draw.cpp globals to Globals
f3cf990c7c AGS: Move cc_instance.cpp globals to Globals
94212de9c8 AGS: Move game.cpp globals to Globals
b807c94441 AGS: Move pluginobjectreader.cpp globals to Globals
d88d97d69d AGS: Move draw.cpp globals to Globals
bf3c05128d AGS: Move screen.cpp globals to Globals
Commit: f8eb923d254d208461329fb9ab1555509ecdc805
https://github.com/scummvm/scummvm/commit/f8eb923d254d208461329fb9ab1555509ecdc805
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2021-03-12T19:41:09-08:00
Commit Message:
AGS: Moved cdaudio.cpp globals to Globals
Changed paths:
engines/ags/engine/ac/cdaudio.cpp
engines/ags/engine/main/quit.cpp
engines/ags/engine/platform/base/agsplatformdriver.cpp
engines/ags/globals.h
diff --git a/engines/ags/engine/ac/cdaudio.cpp b/engines/ags/engine/ac/cdaudio.cpp
index 6941d0cb11..f4c541c8fd 100644
--- a/engines/ags/engine/ac/cdaudio.cpp
+++ b/engines/ags/engine/ac/cdaudio.cpp
@@ -26,22 +26,18 @@
namespace AGS3 {
-int use_cdplayer = 0;
-bool triedToUseCdAudioCommand = false;
-int need_to_stop_cd = 0;
-
int init_cd_player() {
- use_cdplayer = 0;
+ _G(use_cdplayer) = 0;
return _G(platform)->InitializeCDPlayer();
}
int cd_manager(int cmdd, int datt) {
- if (!triedToUseCdAudioCommand) {
- triedToUseCdAudioCommand = true;
+ if (!_G(triedToUseCdAudioCommand)) {
+ _G(triedToUseCdAudioCommand) = true;
init_cd_player();
}
- if (cmdd == 0) return use_cdplayer;
- if (use_cdplayer == 0) return 0; // ignore other commands
+ if (cmdd == 0) return _G(use_cdplayer);
+ if (_G(use_cdplayer) == 0) return 0; // ignore other commands
return _G(platform)->CDPlayerCommand(cmdd, datt);
}
diff --git a/engines/ags/engine/main/quit.cpp b/engines/ags/engine/main/quit.cpp
index 8cdea78859..190d771066 100644
--- a/engines/ags/engine/main/quit.cpp
+++ b/engines/ags/engine/main/quit.cpp
@@ -54,9 +54,6 @@ namespace AGS3 {
using namespace AGS::Shared;
using namespace AGS::Engine;
-extern int need_to_stop_cd;
-extern int use_cdplayer;
-
// TODO: move to test unit
extern Bitmap *test_allegro_bitmap;
extern IDriverDependantBitmap *test_allegro_ddb;
@@ -71,7 +68,7 @@ void quit_tell_editor_debugger(const String &qmsg, QuitReason qreason) {
}
void quit_stop_cd() {
- if (need_to_stop_cd)
+ if (_G(need_to_stop_cd))
cd_manager(3, 0);
}
@@ -104,7 +101,7 @@ void quit_shutdown_platform(QuitReason qreason) {
_G(platform)->FinishedUsingGraphicsMode();
- if (use_cdplayer)
+ if (_G(use_cdplayer))
_G(platform)->ShutdownCDPlayer();
}
diff --git a/engines/ags/engine/platform/base/agsplatformdriver.cpp b/engines/ags/engine/platform/base/agsplatformdriver.cpp
index 9f0eaa759b..97569bd0f4 100644
--- a/engines/ags/engine/platform/base/agsplatformdriver.cpp
+++ b/engines/ags/engine/platform/base/agsplatformdriver.cpp
@@ -191,8 +191,8 @@ void AGSPlatformDriver::PrintMessage(const Shared::DebugMessage &msg) {
#if defined (AGS_HAS_CD_AUDIO)
// from ac_cdplayer
-extern int use_cdplayer;
-extern int need_to_stop_cd;
+extern int _G(use_cdplayer);
+extern int _G(need_to_stop_cd);
int numcddrives = 0;
@@ -200,7 +200,7 @@ int cd_player_init() {
int erro = cd_init();
if (erro) return -1;
numcddrives = 1;
- use_cdplayer = 1;
+ _G(use_cdplayer) = 1;
return 0;
}
@@ -211,7 +211,7 @@ int cd_player_control(int cmdd, int datt) {
return 0;
} else if (cmdd == 2) {
cd_play_from(datt);
- need_to_stop_cd = 1;
+ _G(need_to_stop_cd) = 1;
} else if (cmdd == 3)
cd_pause();
else if (cmdd == 4)
diff --git a/engines/ags/globals.h b/engines/ags/globals.h
index 707b05fd08..77299836fe 100644
--- a/engines/ags/globals.h
+++ b/engines/ags/globals.h
@@ -296,6 +296,17 @@ public:
/**@}*/
+ /**
+ * \defgroup character globals
+ * @{
+ */
+
+ int _use_cdplayer = 0;
+ bool _triedToUseCdAudioCommand = false;
+ int _need_to_stop_cd = 0;
+
+ /**@}*/
+
/**
* \defgroup character globals
* @{
Commit: 7462386f6630e20bb05bf38212ddd82b089ba18d
https://github.com/scummvm/scummvm/commit/7462386f6630e20bb05bf38212ddd82b089ba18d
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2021-03-12T19:41:09-08:00
Commit Message:
AGS: Remove unused test globals
Changed paths:
engines/ags/engine/main/engine.cpp
engines/ags/engine/main/quit.cpp
diff --git a/engines/ags/engine/main/engine.cpp b/engines/ags/engine/main/engine.cpp
index babe4c2932..12f77dd230 100644
--- a/engines/ags/engine/main/engine.cpp
+++ b/engines/ags/engine/main/engine.cpp
@@ -883,15 +883,6 @@ void engine_prepare_to_start_game() {
#endif
}
-// TODO: move to test unit
-Bitmap *test_allegro_bitmap;
-IDriverDependantBitmap *test_allegro_ddb;
-void allegro_bitmap_test_init() {
- test_allegro_bitmap = nullptr;
- // Switched the test off for now
- //test_allegro_bitmap = AllegroBitmap::CreateBitmap(320,200,32);
-}
-
// Only allow searching around for game data on desktop systems;
// otherwise use explicit argument either from program wrapper, command-line
// or read from default config.
@@ -1234,8 +1225,6 @@ int initialize_engine(const ConfigTree &startup_opts) {
engine_prepare_to_start_game();
- allegro_bitmap_test_init();
-
initialize_start_and_play_game(_G(override_start_room), _G(loadSaveGameOnStartup));
return EXIT_NORMAL;
diff --git a/engines/ags/engine/main/quit.cpp b/engines/ags/engine/main/quit.cpp
index 190d771066..fff8e9d754 100644
--- a/engines/ags/engine/main/quit.cpp
+++ b/engines/ags/engine/main/quit.cpp
@@ -54,10 +54,6 @@ namespace AGS3 {
using namespace AGS::Shared;
using namespace AGS::Engine;
-// TODO: move to test unit
-extern Bitmap *test_allegro_bitmap;
-extern IDriverDependantBitmap *test_allegro_ddb;
-
void quit_tell_editor_debugger(const String &qmsg, QuitReason qreason) {
if (_G(editor_debugging_initialized)) {
if (qreason & kQuitKind_GameException)
@@ -188,13 +184,6 @@ void quit_delete_temp_files() {
#endif
}
-// TODO: move to test unit
-void allegro_bitmap_test_release() {
- delete test_allegro_bitmap;
- if (test_allegro_ddb)
- _G(gfxDriver)->DestroyDDB(test_allegro_ddb);
-}
-
// quit - exits the engine, shutting down everything gracefully
// The parameter is the message to print. If this message begins with
// an '!' character, then it is printed as a "contact game author" error.
@@ -221,8 +210,6 @@ void quit_free() {
if (qreason & kQuitKind_NormalExit)
save_config_file();
- allegro_bitmap_test_release();
-
_G(handledErrorInEditor) = false;
quit_tell_editor_debugger(_G(quit_message), qreason);
Commit: 1735868c31a4e34763f5b12a545aa4742ac200a0
https://github.com/scummvm/scummvm/commit/1735868c31a4e34763f5b12a545aa4742ac200a0
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2021-03-12T19:41:10-08:00
Commit Message:
AGS: Move draw.cpp globals to Globals
Changed paths:
engines/ags/engine/ac/draw.cpp
engines/ags/engine/main/engine_setup.cpp
engines/ags/globals.h
diff --git a/engines/ags/engine/ac/draw.cpp b/engines/ags/engine/ac/draw.cpp
index 9d88440b23..1c8be290e2 100644
--- a/engines/ags/engine/ac/draw.cpp
+++ b/engines/ags/engine/ac/draw.cpp
@@ -107,8 +107,6 @@ void setpal() {
set_palette_range(palette, 0, 255, 0);
}
-int _places_r = 3, _places_g = 2, _places_b = 3;
-
// convert RGB to BGR for strange graphics cards
Bitmap *convert_16_to_16bgr(Bitmap *tempbl) {
@@ -125,9 +123,9 @@ Bitmap *convert_16_to_16bgr(Bitmap *tempbl) {
ds = _rgb_scale_6[(c >> 5) & 0x3F];
r = _rgb_scale_5[(c >> 11) & 0x1F];
// allegro assumes 5-6-5 for 16-bit
- p16[x] = (((r >> _places_r) << _G(_rgb_r_shift_16)) |
- ((ds >> _places_g) << _G(_rgb_g_shift_16)) |
- ((b >> _places_b) << _G(_rgb_b_shift_16)));
+ p16[x] = (((r >> _G(places_r)) << _G(_rgb_r_shift_16)) |
+ ((ds >> _G(places_g)) << _G(_rgb_g_shift_16)) |
+ ((b >> _G(places_b)) << _G(_rgb_b_shift_16)));
}
}
diff --git a/engines/ags/engine/main/engine_setup.cpp b/engines/ags/engine/main/engine_setup.cpp
index 71ad6d6409..d0ee5c3966 100644
--- a/engines/ags/engine/main/engine_setup.cpp
+++ b/engines/ags/engine/main/engine_setup.cpp
@@ -50,8 +50,6 @@ namespace AGS3 {
using namespace AGS::Shared;
using namespace AGS::Engine;
-extern int _places_r, _places_g, _places_b;
-
// Convert guis position and size to proper game resolution.
// Necessary for pre 3.1.0 games only to sync with modern engine.
void convert_gui_to_game_resolution(GameDataVersion filever) {
@@ -191,8 +189,8 @@ void engine_setup_color_conversions(int coldepth) {
if (_G(_rgb_r_shift_16) == 10) {
// some very old graphics cards lie about being 16-bit when they
// are in fact 15-bit ... get around this
- _places_r = 3;
- _places_g = 3;
+ _G(places_r) = 3;
+ _G(places_g) = 3;
}
}
if (coldepth > 16) {
diff --git a/engines/ags/globals.h b/engines/ags/globals.h
index 77299836fe..afc951b089 100644
--- a/engines/ags/globals.h
+++ b/engines/ags/globals.h
@@ -464,6 +464,7 @@ public:
bool _screen_is_dirty = false;
AGS::Shared::Bitmap *_raw_saved_screen = nullptr;
AGS::Shared::Bitmap **_dynamicallyCreatedSurfaces = nullptr;
+ int _places_r = 3, _places_g = 2, _places_b = 3;
/**@}*/
Commit: f3cf990c7c15d07d5a08bce72ce9f4a8fe88ce1e
https://github.com/scummvm/scummvm/commit/f3cf990c7c15d07d5a08bce72ce9f4a8fe88ce1e
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2021-03-12T19:51:14-08:00
Commit Message:
AGS: Move cc_instance.cpp globals to Globals
Changed paths:
engines/ags/engine/script/cc_instance.cpp
engines/ags/engine/script/script_runtime.cpp
engines/ags/globals.cpp
engines/ags/globals.h
engines/ags/plugins/agsplugin.cpp
diff --git a/engines/ags/engine/script/cc_instance.cpp b/engines/ags/engine/script/cc_instance.cpp
index 47f4fb780f..90fef8e59b 100644
--- a/engines/ags/engine/script/cc_instance.cpp
+++ b/engines/ags/engine/script/cc_instance.cpp
@@ -165,13 +165,6 @@ const char *regnames[] = { "null", "sp", "mar", "ax", "bx", "cx", "op", "dx" };
const char *fixupnames[] = { "null", "fix_gldata", "fix_func", "fix_string", "fix_import", "fix_datadata", "fix_stack" };
-ccInstance *current_instance;
-// [IKM] 2012-10-21:
-// NOTE: This is temporary solution (*sigh*, one of many) which allows certain
-// exported functions return value as a RuntimeScriptValue object;
-// Of 2012-12-20: now used only for plugin exports
-RuntimeScriptValue GlobalReturnValue;
-
// Function call stack is used to temporarily store
// values before passing them to script function
#define MAX_FUNC_PARAMS 20
@@ -196,7 +189,7 @@ struct FunctionCallStack {
ccInstance *ccInstance::GetCurrentInstance() {
- return current_instance;
+ return _G(current_instance);
}
ccInstance *ccInstance::CreateFromScript(PScript scri) {
@@ -337,7 +330,7 @@ int ccInstance::CallScriptFunction(const char *funcname, int32_t numargs, const
// object pointer needs to start zeroed
registers[SREG_OP].SetDynamicObject(nullptr, nullptr);
- ccInstance *currentInstanceWas = current_instance;
+ ccInstance *currentInstanceWas = _G(current_instance);
registers[SREG_SP].SetStackPtr(&stack[0]);
stackdata_ptr = stackdata;
// NOTE: Pushing parameters to stack in reverse order
@@ -355,7 +348,7 @@ int ccInstance::CallScriptFunction(const char *funcname, int32_t numargs, const
ASSERT_STACK_SIZE(numargs);
PopValuesFromStack(numargs);
pc = 0;
- current_instance = currentInstanceWas;
+ _G(current_instance) = currentInstanceWas;
// NOTE that if proper multithreading is added this will need
// to be reconsidered, since the GC could be run in the middle
@@ -423,7 +416,7 @@ int ccInstance::Run(int32_t curpc) {
int loopIterationCheckDisabled = 0;
thisbase[0] = 0;
funcstart[0] = pc;
- current_instance = this;
+ _G(current_instance) = this;
ccInstance *codeInst = runningInst;
int write_debug_dump = ccGetOption(SCOPT_DEBUGRUN);
ScriptOperation codeOp;
@@ -612,7 +605,7 @@ int ccInstance::Run(int32_t curpc) {
returnValue = registers[SREG_AX].IValue;
return 0;
}
- current_instance = this;
+ _G(current_instance) = this;
POP_CALL_STACK;
continue; // continue so that the PC doesn't get overwritten
}
@@ -995,7 +988,7 @@ int ccInstance::Run(int32_t curpc) {
RuntimeScriptValue return_value;
if (reg1.Type == kScValPluginFunction) {
- GlobalReturnValue.Invalidate();
+ _GP(GlobalReturnValue).Invalidate();
int32_t int_ret_val;
if (next_call_needs_object) {
RuntimeScriptValue obj_rval = registers[SREG_OP];
@@ -1005,8 +998,8 @@ int ccInstance::Run(int32_t curpc) {
int_ret_val = call_function((intptr_t)reg1.Ptr, nullptr, num_args_to_func, func_callstack.GetHead() + 1);
}
- if (GlobalReturnValue.IsValid()) {
- return_value = GlobalReturnValue;
+ if (_GP(GlobalReturnValue).IsValid()) {
+ return_value = _GP(GlobalReturnValue);
} else {
return_value.SetPluginArgument(int_ret_val);
}
@@ -1033,7 +1026,7 @@ int ccInstance::Run(int32_t curpc) {
}
registers[SREG_AX] = return_value;
- current_instance = this;
+ _G(current_instance) = this;
next_call_needs_object = 0;
num_args_to_func = -1;
break;
diff --git a/engines/ags/engine/script/script_runtime.cpp b/engines/ags/engine/script/script_runtime.cpp
index 2433292907..4d6c62f4f6 100644
--- a/engines/ags/engine/script/script_runtime.cpp
+++ b/engines/ags/engine/script/script_runtime.cpp
@@ -47,8 +47,6 @@
namespace AGS3 {
-extern ccInstance *current_instance; // in script/cc_instance
-
bool ccAddExternalStaticFunction(const String &name, ScriptAPIFunction *pfn) {
return _GP(simp).add(name, RuntimeScriptValue().SetStaticFunction(pfn), nullptr) == 0;
}
@@ -134,8 +132,8 @@ void ccSetScriptAliveTimer(int numloop) {
}
void ccNotifyScriptStillAlive() {
- if (current_instance != nullptr)
- current_instance->flags |= INSTF_RUNNING;
+ if (_G(current_instance) != nullptr)
+ _G(current_instance)->flags |= INSTF_RUNNING;
}
void ccSetDebugHook(new_line_hook_type jibble) {
diff --git a/engines/ags/globals.cpp b/engines/ags/globals.cpp
index e7202d9193..599d0dfaf7 100644
--- a/engines/ags/globals.cpp
+++ b/engines/ags/globals.cpp
@@ -108,6 +108,9 @@ Globals::Globals() {
// button.cpp globals
_animbuts = new AnimatingGUIButton[MAX_ANIMATING_BUTTONS];
+ // cc_instance.cpp globals
+ _GlobalReturnValue = new RuntimeScriptValue();
+
// cc_options.cpp globals
_ccCompOptions = SCOPT_LEFTTORIGHT;
@@ -294,6 +297,9 @@ Globals::~Globals() {
// button.cpp globals
delete[] _animbuts;
+ // cc_instance.cpp globals
+ delete _GlobalReturnValue;
+
// cc_serializer.cpp globals
delete _ccUnserializer;
diff --git a/engines/ags/globals.h b/engines/ags/globals.h
index afc951b089..aa144ba4db 100644
--- a/engines/ags/globals.h
+++ b/engines/ags/globals.h
@@ -266,6 +266,20 @@ public:
/**@}*/
+ /**
+ * \defgroup cc_instance globals
+ * @{
+ */
+
+ ccInstance *_current_instance = nullptr;
+ // [IKM] 2012-10-21:
+ // NOTE: This is temporary solution (*sigh*, one of many) which allows certain
+ // exported functions return value as a RuntimeScriptValue object;
+ // Of 2012-12-20: now used only for plugin exports
+ RuntimeScriptValue *_GlobalReturnValue;
+
+ /**@}*/
+
/**
* \defgroup cc_options globals
* @{
diff --git a/engines/ags/plugins/agsplugin.cpp b/engines/ags/plugins/agsplugin.cpp
index 1d5c22bf8d..4b41e7f702 100644
--- a/engines/ags/plugins/agsplugin.cpp
+++ b/engines/ags/plugins/agsplugin.cpp
@@ -87,7 +87,6 @@ using namespace AGS::Engine;
extern color palette[256];
extern PluginObjectReader pluginReaders[MAX_PLUGIN_OBJECT_READERS];
extern int numPluginReaders;
-extern RuntimeScriptValue GlobalReturnValue;
void PluginSimulateMouseClick(int pluginButtonID) {
_G(pluginSimulatedClick) = pluginButtonID - 1;
@@ -718,7 +717,7 @@ void IAGSEngine::QueueGameScriptFunction(const char *name, int32 globalScript, i
int IAGSEngine::RegisterManagedObject(const void *object, IAGSScriptManagedObject *callback) {
// TODO: handle loss of const better
- GlobalReturnValue.SetPluginObject(const_cast<void *>(object), (ICCDynamicObject *)callback);
+ _GP(GlobalReturnValue).SetPluginObject(const_cast<void *>(object), (ICCDynamicObject *)callback);
return ccRegisterManagedObject(object, (ICCDynamicObject *)callback, true);
}
@@ -741,7 +740,7 @@ void IAGSEngine::AddManagedObjectReader(const char *typeName, IAGSManagedObjectR
void IAGSEngine::RegisterUnserializedObject(int key_, const void *object, IAGSScriptManagedObject *callback) {
// TODO: handle loss of const better
- GlobalReturnValue.SetPluginObject(const_cast<void *>(object), (ICCDynamicObject *)callback);
+ _GP(GlobalReturnValue).SetPluginObject(const_cast<void *>(object), (ICCDynamicObject *)callback);
ccRegisterUnserializedObject(key_, object, (ICCDynamicObject *)callback, true);
}
@@ -754,9 +753,9 @@ void *IAGSEngine::GetManagedObjectAddressByKey(int key_) {
ICCDynamicObject *manager;
ScriptValueType obj_type = ccGetObjectAddressAndManagerFromHandle(key_, object, manager);
if (obj_type == kScValPluginObject) {
- GlobalReturnValue.SetPluginObject(object, manager);
+ _GP(GlobalReturnValue).SetPluginObject(object, manager);
} else {
- GlobalReturnValue.SetDynamicObject(object, manager);
+ _GP(GlobalReturnValue).SetDynamicObject(object, manager);
}
return object;
}
@@ -765,7 +764,7 @@ const char *IAGSEngine::CreateScriptString(const char *fromText) {
const char *string = CreateNewScriptString(fromText);
// Should be still standard dynamic object, because not managed by plugin
// TODO: handle loss of const better
- GlobalReturnValue.SetDynamicObject(const_cast<char *>(string), &_GP(myScriptStringImpl));
+ _GP(GlobalReturnValue).SetDynamicObject(const_cast<char *>(string), &_GP(myScriptStringImpl));
return string;
}
Commit: 94212de9c85ca7bc5c235bf24049ed02d8b764af
https://github.com/scummvm/scummvm/commit/94212de9c85ca7bc5c235bf24049ed02d8b764af
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2021-03-12T19:51:21-08:00
Commit Message:
AGS: Move game.cpp globals to Globals
Changed paths:
engines/ags/engine/ac/game.cpp
engines/ags/engine/ac/global_game.cpp
engines/ags/engine/script/cc_instance.cpp
engines/ags/engine/script/script.cpp
engines/ags/globals.h
diff --git a/engines/ags/engine/ac/game.cpp b/engines/ags/engine/ac/game.cpp
index d36b0a1782..16e0f2328c 100644
--- a/engines/ags/engine/ac/game.cpp
+++ b/engines/ags/engine/ac/game.cpp
@@ -229,6 +229,7 @@ void setup_for_dialog() {
_G(oldmouse) = _G(cur_cursor);
set_mouse_cursor(CURS_ARROW);
}
+
void restore_after_dialog() {
set_mouse_cursor(_G(oldmouse));
if (!_GP(play).mouse_cursor_hidden)
@@ -237,7 +238,6 @@ void restore_after_dialog() {
}
-
String get_save_game_directory() {
return _G(saveGameDirectory);
}
@@ -528,9 +528,6 @@ const char *Game_GetGlobalStrings(int index) {
return CreateNewScriptString(_GP(play).globalstrings[index]);
}
-
-char gamefilenamebuf[200];
-
// ** GetGameParameter replacement functions
int Game_GetInventoryItemCount() {
@@ -1416,9 +1413,6 @@ HSaveError restore_game_data(Stream *in, SavegameVersion svg_version, const Pres
return HSaveError::None();
}
-int gameHasBeenRestored = 0;
-int oldeip;
-
bool read_savedgame_description(const String &savedgame, String &description) {
SavegameDescription desc;
if (OpenSavegame(savedgame, desc, kSvgDesc_UserText)) {
@@ -1449,9 +1443,9 @@ bool read_savedgame_screenshot(const String &savedgame, int &want_shot) {
HSaveError load_game(int slotNumber, bool &data_overwritten) {
data_overwritten = false;
- gameHasBeenRestored++;
+ _G(gameHasBeenRestored)++;
- oldeip = _G(our_eip);
+ _G(oldeip) = _G(our_eip);
_G(our_eip) = 2050;
HSaveError err;
@@ -1473,8 +1467,8 @@ HSaveError load_game(int slotNumber, bool &data_overwritten) {
// [IKM] 2012-11-26: this is a workaround, indeed.
// Try to find wanted game's executable; if it does not exist,
// continue loading savedgame in current game, and pray for the best
- get_install_dir_path(gamefilenamebuf, desc.MainDataFilename);
- if (Shared::File::TestReadFile(gamefilenamebuf)) {
+ get_install_dir_path(_G(gamefilenamebuf), desc.MainDataFilename);
+ if (Shared::File::TestReadFile(_G(gamefilenamebuf))) {
RunAGSGame(desc.MainDataFilename, 0, 0);
_G(load_new_game_restore) = slotNumber;
return HSaveError::None();
@@ -1489,7 +1483,7 @@ HSaveError load_game(int slotNumber, bool &data_overwritten) {
if (!err)
return err;
src.InputStream.reset();
- _G(our_eip) = oldeip;
+ _G(our_eip) = _G(oldeip);
// ensure keyboard buffer is clean
ags_clear_input_buffer();
diff --git a/engines/ags/engine/ac/global_game.cpp b/engines/ags/engine/ac/global_game.cpp
index 8c98b5fce2..2b1cc6586a 100644
--- a/engines/ags/engine/ac/global_game.cpp
+++ b/engines/ags/engine/ac/global_game.cpp
@@ -75,8 +75,6 @@ using namespace AGS::Shared;
#define ALLEGRO_KEYBOARD_HANDLER
-
-extern char gamefilenamebuf[200];
extern int gui_disabled_style;
extern color palette[256];
@@ -237,9 +235,9 @@ int RunAGSGame(const char *newgame, unsigned int mode, int data) {
if ((mode & RAGMODE_LOADNOW) == 0) {
// need to copy, since the script gets destroyed
- get_install_dir_path(gamefilenamebuf, newgame);
- _GP(ResPaths).GamePak.Path = gamefilenamebuf;
- _GP(ResPaths).GamePak.Name = Shared::Path::get_filename(gamefilenamebuf);
+ get_install_dir_path(_G(gamefilenamebuf), newgame);
+ _GP(ResPaths).GamePak.Path = _G(gamefilenamebuf);
+ _GP(ResPaths).GamePak.Name = Shared::Path::get_filename(_G(gamefilenamebuf));
_GP(play).takeover_data = data;
_G(load_new_game_restore) = -1;
diff --git a/engines/ags/engine/script/cc_instance.cpp b/engines/ags/engine/script/cc_instance.cpp
index 90fef8e59b..79bcf29e5e 100644
--- a/engines/ags/engine/script/cc_instance.cpp
+++ b/engines/ags/engine/script/cc_instance.cpp
@@ -51,7 +51,7 @@ using namespace AGS::Shared;
using namespace AGS::Shared::Memory;
extern ccInstance *loadedInstances[MAX_LOADED_INSTANCES]; // in script/script_runtime
-extern int gameHasBeenRestored; // in ac/game
+
// in script/script
extern int maxWhileLoops;
extern new_line_hook_type new_line_hook;
diff --git a/engines/ags/engine/script/script.cpp b/engines/ags/engine/script/script.cpp
index 152e814991..1106a80d8f 100644
--- a/engines/ags/engine/script/script.cpp
+++ b/engines/ags/engine/script/script.cpp
@@ -54,8 +54,6 @@
namespace AGS3 {
-extern int gameHasBeenRestored;
-
int run_dialog_request(int parmtr) {
_GP(play).stop_dialog_at_end = DIALOG_RUNNING;
RunTextScriptIParam(_G(gameinst), "dialog_request", RuntimeScriptValue().SetInt32(parmtr));
@@ -334,7 +332,7 @@ int PrepareTextScript(ccInstance *sci, const char **tsname) {
}
int RunScriptFunctionIfExists(ccInstance *sci, const char *tsname, int numParam, const RuntimeScriptValue *params) {
- int oldRestoreCount = gameHasBeenRestored;
+ int oldRestoreCount = _G(gameHasBeenRestored);
// First, save the current _G(ccError) state
// This is necessary because we might be attempting
// to run Script B, while Script A is still running in the
@@ -376,7 +374,7 @@ int RunScriptFunctionIfExists(ccInstance *sci, const char *tsname, int numParam,
_G(ccError) = cachedCcError;
// if the game has been restored, ensure that any further scripts are not run
- if ((oldRestoreCount != gameHasBeenRestored) && (_G(eventClaimed) == EVENT_INPROGRESS))
+ if ((oldRestoreCount != _G(gameHasBeenRestored)) && (_G(eventClaimed) == EVENT_INPROGRESS))
_G(eventClaimed) = EVENT_CLAIMED;
return toret;
@@ -388,14 +386,14 @@ int RunTextScript(ccInstance *sci, const char *tsname) {
// FIXME: in theory the function may be already called for _GP(moduleInst)[i],
// in which case this should not be executed; need to rearrange the code somehow
int room_changes_was = _GP(play).room_changes;
- int restore_game_count_was = gameHasBeenRestored;
+ int restore_game_count_was = _G(gameHasBeenRestored);
for (int kk = 0; kk < _G(numScriptModules); kk++) {
if (!_GP(moduleRepExecAddr)[kk].IsNull())
RunScriptFunctionIfExists(_GP(moduleInst)[kk], tsname, 0, nullptr);
if ((room_changes_was != _GP(play).room_changes) ||
- (restore_game_count_was != gameHasBeenRestored))
+ (restore_game_count_was != _G(gameHasBeenRestored)))
return 0;
}
}
diff --git a/engines/ags/globals.h b/engines/ags/globals.h
index aa144ba4db..427cf152da 100644
--- a/engines/ags/globals.h
+++ b/engines/ags/globals.h
@@ -645,6 +645,9 @@ public:
int _load_new_game_restore = -1;
// TODO: refactor these global vars into function arguments
int _getloctype_index = 0, _getloctype_throughgui = 0;
+ char _gamefilenamebuf[200] = { 0 };
+ int _gameHasBeenRestored = 0;
+ int _oldeip = 0;
/**@}*/
Commit: b807c94441ef351f1485159168acd3e94a7e73a2
https://github.com/scummvm/scummvm/commit/b807c94441ef351f1485159168acd3e94a7e73a2
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2021-03-12T20:28:30-08:00
Commit Message:
AGS: Move pluginobjectreader.cpp globals to Globals
Changed paths:
R engines/ags/plugins/pluginobjectreader.cpp
engines/ags/engine/ac/dynobj/cc_serializer.cpp
engines/ags/globals.cpp
engines/ags/globals.h
engines/ags/module.mk
engines/ags/plugins/agsplugin.cpp
diff --git a/engines/ags/engine/ac/dynobj/cc_serializer.cpp b/engines/ags/engine/ac/dynobj/cc_serializer.cpp
index 535fb9b33f..dc6149505f 100644
--- a/engines/ags/engine/ac/dynobj/cc_serializer.cpp
+++ b/engines/ags/engine/ac/dynobj/cc_serializer.cpp
@@ -36,9 +36,6 @@
namespace AGS3 {
-extern PluginObjectReader pluginReaders[MAX_PLUGIN_OBJECT_READERS];
-extern int numPluginReaders;
-
// *** De-serialization of script objects
void AGSDeSerializer::Unserialize(int index, const char *objectType, const char *serializedData, int dataSize) {
@@ -100,9 +97,9 @@ void AGSDeSerializer::Unserialize(int index, const char *objectType, const char
suo->Unserialize(index, serializedData, dataSize);
} else if (!unserialize_audio_script_object(index, objectType, serializedData, dataSize)) {
// check if the type is read by a plugin
- for (int ii = 0; ii < numPluginReaders; ii++) {
- if (strcmp(objectType, pluginReaders[ii].type) == 0) {
- pluginReaders[ii].reader->Unserialize(index, serializedData, dataSize);
+ for (int ii = 0; ii < _G(numPluginReaders); ii++) {
+ if (strcmp(objectType, _G(pluginReaders)[ii].type) == 0) {
+ _G(pluginReaders)[ii].reader->Unserialize(index, serializedData, dataSize);
return;
}
}
diff --git a/engines/ags/globals.cpp b/engines/ags/globals.cpp
index 599d0dfaf7..08c0a41755 100644
--- a/engines/ags/globals.cpp
+++ b/engines/ags/globals.cpp
@@ -89,6 +89,7 @@
#include "ags/engine/script/script.h"
#include "ags/engine/script/systemimports.h"
#include "ags/lib/std/limits.h"
+#include "ags/plugins/pluginobjectreader.h"
namespace AGS3 {
@@ -245,6 +246,9 @@ Globals::Globals() {
// overlay.cpp globals
_screenover = new std::vector<ScreenOverlay>();
+ // pluginobjectreader.cpp globals
+ _pluginReaders = new PluginObjectReader[MAX_PLUGIN_OBJECT_READERS];
+
// room.cpp globals
_rgb_table = new RGB_MAP();
@@ -420,6 +424,9 @@ Globals::~Globals() {
// overlay.cpp globals
delete _screenover;
+ // pluginobjectreader.cpp globals
+ delete[] _pluginReaders;
+
// room.cpp globals
delete _rgb_table;
diff --git a/engines/ags/globals.h b/engines/ags/globals.h
index 427cf152da..16215b5fb6 100644
--- a/engines/ags/globals.h
+++ b/engines/ags/globals.h
@@ -121,6 +121,7 @@ struct NewControl;
struct NonBlockingScriptFunction;
struct ObjectCache;
struct OnScreenWindow;
+struct PluginObjectReader;
struct ResourcePaths;
struct RGB_MAP;
struct RoomCameraDrawData;
@@ -931,6 +932,16 @@ public:
/**@}*/
+ /**
+ * \defgroup quit globals
+ * @{
+ */
+
+ PluginObjectReader *_pluginReaders;
+ int _numPluginReaders = 0;
+
+ /**@}*/
+
/**
* \defgroup quit globals
* @{
diff --git a/engines/ags/module.mk b/engines/ags/module.mk
index 51a7aae292..d7e7bb26b6 100644
--- a/engines/ags/module.mk
+++ b/engines/ags/module.mk
@@ -286,7 +286,6 @@ MODULE_OBJS = \
engine/script/systemimports.o \
plugins/agsplugin.o \
plugins/plugin_base.o \
- plugins/pluginobjectreader.o \
plugins/ags_blend/ags_blend.o \
plugins/ags_creditz/ags_creditz.o \
plugins/ags_creditz/ags_creditz1.o \
diff --git a/engines/ags/plugins/agsplugin.cpp b/engines/ags/plugins/agsplugin.cpp
index 4b41e7f702..7d89279eb1 100644
--- a/engines/ags/plugins/agsplugin.cpp
+++ b/engines/ags/plugins/agsplugin.cpp
@@ -85,8 +85,6 @@ using namespace AGS::Shared::Memory;
using namespace AGS::Engine;
extern color palette[256];
-extern PluginObjectReader pluginReaders[MAX_PLUGIN_OBJECT_READERS];
-extern int numPluginReaders;
void PluginSimulateMouseClick(int pluginButtonID) {
_G(pluginSimulatedClick) = pluginButtonID - 1;
@@ -722,20 +720,20 @@ int IAGSEngine::RegisterManagedObject(const void *object, IAGSScriptManagedObjec
}
void IAGSEngine::AddManagedObjectReader(const char *typeName, IAGSManagedObjectReader *reader) {
- if (numPluginReaders >= MAX_PLUGIN_OBJECT_READERS)
+ if (_G(numPluginReaders) >= MAX_PLUGIN_OBJECT_READERS)
quit("Plugin error: IAGSEngine::AddObjectReader: Too many object readers added");
if ((typeName == nullptr) || (typeName[0] == 0))
quit("Plugin error: IAGSEngine::AddObjectReader: invalid name for type");
- for (int ii = 0; ii < numPluginReaders; ii++) {
- if (strcmp(pluginReaders[ii].type, typeName) == 0)
+ for (int ii = 0; ii < _G(numPluginReaders); ii++) {
+ if (strcmp(_G(pluginReaders)[ii].type, typeName) == 0)
quitprintf("Plugin error: IAGSEngine::AddObjectReader: type '%s' has been registered already", typeName);
}
- pluginReaders[numPluginReaders].reader = reader;
- pluginReaders[numPluginReaders].type = typeName;
- numPluginReaders++;
+ _G(pluginReaders)[_G(numPluginReaders)].reader = reader;
+ _G(pluginReaders)[_G(numPluginReaders)].type = typeName;
+ _G(numPluginReaders)++;
}
void IAGSEngine::RegisterUnserializedObject(int key_, const void *object, IAGSScriptManagedObject *callback) {
diff --git a/engines/ags/plugins/pluginobjectreader.cpp b/engines/ags/plugins/pluginobjectreader.cpp
deleted file mode 100644
index dd510ca1c0..0000000000
--- a/engines/ags/plugins/pluginobjectreader.cpp
+++ /dev/null
@@ -1,31 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-#include "ags/plugins/pluginobjectreader.h"
-#include "ags/engine/ac/runtime_defines.h"
-
-namespace AGS3 {
-
-PluginObjectReader pluginReaders[MAX_PLUGIN_OBJECT_READERS];
-int numPluginReaders = 0;
-
-} // namespace AGS3
Commit: d88d97d69deb56017b011dc8f10076772568b212
https://github.com/scummvm/scummvm/commit/d88d97d69deb56017b011dc8f10076772568b212
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2021-03-12T20:38:46-08:00
Commit Message:
AGS: Move draw.cpp globals to Globals
Changed paths:
engines/ags/engine/ac/draw.cpp
engines/ags/engine/ac/dynamicsprite.cpp
engines/ags/engine/ac/event.cpp
engines/ags/engine/ac/game.cpp
engines/ags/engine/ac/global_game.cpp
engines/ags/engine/ac/global_palette.cpp
engines/ags/engine/ac/global_screen.cpp
engines/ags/engine/ac/region.cpp
engines/ags/engine/ac/room.cpp
engines/ags/engine/ac/sprite.cpp
engines/ags/engine/device/mousew32.cpp
engines/ags/engine/game/savegame_components.cpp
engines/ags/engine/main/engine.cpp
engines/ags/globals.cpp
engines/ags/globals.h
engines/ags/plugins/agsplugin.cpp
diff --git a/engines/ags/engine/ac/draw.cpp b/engines/ags/engine/ac/draw.cpp
index 1c8be290e2..8637d24320 100644
--- a/engines/ags/engine/ac/draw.cpp
+++ b/engines/ags/engine/ac/draw.cpp
@@ -90,11 +90,6 @@ extern "C" void ios_render();
extern int bg_just_changed;
-color palette[256];
-
-COLOR_MAP maincoltable;
-
-
SpriteListEntry::SpriteListEntry()
: bmp(nullptr)
, pic(nullptr)
@@ -104,7 +99,7 @@ SpriteListEntry::SpriteListEntry()
}
void setpal() {
- set_palette_range(palette, 0, 255, 0);
+ set_palette_range(_G(palette), 0, 255, 0);
}
// convert RGB to BGR for strange graphics cards
@@ -226,7 +221,7 @@ Bitmap *ReplaceBitmapWithSupportedFormat(Bitmap *bitmap) {
Bitmap *PrepareSpriteForUse(Bitmap *bitmap, bool has_alpha) {
bool must_switch_palette = bitmap->GetColorDepth() == 8 && _GP(game).GetColorDepth() > 8;
if (must_switch_palette)
- select_palette(palette);
+ select_palette(_G(palette));
Bitmap *new_bitmap = AdjustBitmapForUseWithDisplayMode(bitmap, has_alpha);
if (new_bitmap != bitmap)
@@ -241,7 +236,7 @@ Bitmap *PrepareSpriteForUse(Bitmap *bitmap, bool has_alpha) {
PBitmap PrepareSpriteForUse(PBitmap bitmap, bool has_alpha) {
bool must_switch_palette = bitmap->GetColorDepth() == 8 && System_GetColorDepth() > 8;
if (must_switch_palette)
- select_palette(palette);
+ select_palette(_G(palette));
Bitmap *new_bitmap = AdjustBitmapForUseWithDisplayMode(bitmap.get(), has_alpha);
new_bitmap = ReplaceBitmapWithSupportedFormat(new_bitmap);
@@ -1164,7 +1159,7 @@ int scale_and_flip_sprite(int useindx, int coldept, int zoom_level,
// Ensure that anti-aliasing routines have a palette to
// use for mapping while faded out
if (_G(in_new_room))
- select_palette(palette);
+ select_palette(_G(palette));
if (isMirrored) {
diff --git a/engines/ags/engine/ac/dynamicsprite.cpp b/engines/ags/engine/ac/dynamicsprite.cpp
index 0cad3ffe47..79e12bbf45 100644
--- a/engines/ags/engine/ac/dynamicsprite.cpp
+++ b/engines/ags/engine/ac/dynamicsprite.cpp
@@ -49,8 +49,6 @@ namespace AGS3 {
using namespace Shared;
using namespace Engine;
-extern color palette[256];
-
// ** SCRIPT DYNAMIC SPRITE
void DynamicSprite_Delete(ScriptDynamicSprite *sds) {
@@ -270,7 +268,7 @@ int DynamicSprite_SaveToFile(ScriptDynamicSprite *sds, const char *namm) {
ResolvedPath rp;
if (!ResolveWritePathAndCreateDirs(filename, rp))
return 0;
- return _GP(spriteset)[sds->slot]->SaveToFile(rp.FullPath, palette) ? 1 : 0;
+ return _GP(spriteset)[sds->slot]->SaveToFile(rp.FullPath, _G(palette)) ? 1 : 0;
}
ScriptDynamicSprite *DynamicSprite_CreateFromSaveGame(int sgslot, int width, int height) {
diff --git a/engines/ags/engine/ac/event.cpp b/engines/ags/engine/ac/event.cpp
index 433447d141..8af64804b9 100644
--- a/engines/ags/engine/ac/event.cpp
+++ b/engines/ags/engine/ac/event.cpp
@@ -48,7 +48,6 @@ namespace AGS3 {
using namespace AGS::Shared;
using namespace AGS::Engine;
-extern color palette[256];
extern color old_palette[256];
int run_claimable_event(const char *tsname, bool includeRoom, int numParams, const RuntimeScriptValue *params, bool *eventWasClaimed) {
@@ -221,9 +220,9 @@ void process_event(EventHappened *evp) {
const Rect &viewport = _GP(play).GetMainViewport();
if ((theTransition == FADE_INSTANT) || ignore_transition)
- set_palette_range(palette, 0, 255, 0);
+ set_palette_range(_G(palette), 0, 255, 0);
else if (theTransition == FADE_NORMAL) {
- my_fade_in(palette, 5);
+ my_fade_in(_G(palette), 5);
} else if (theTransition == FADE_BOXOUT) {
if (!_G(gfxDriver)->UsesMemoryBackBuffer()) {
_G(gfxDriver)->BoxOutEffect(false, get_fixed_pixel_size(16), 1000 / GetGameSpeed());
@@ -231,7 +230,7 @@ void process_event(EventHappened *evp) {
// First of all we render the game once again and save backbuffer from further editing.
// We put temporary bitmap as a new backbuffer for the transition period, and
// will be drawing saved image of the game over to that backbuffer, simulating "box-out".
- set_palette_range(palette, 0, 255, 0);
+ set_palette_range(_G(palette), 0, 255, 0);
construct_game_scene(true);
construct_game_screen_overlay(false);
_G(gfxDriver)->RenderToBackBuffer();
@@ -289,7 +288,7 @@ void process_event(EventHappened *evp) {
delete saved_viewport_bitmap;
saved_viewport_bitmap = nullptr;
- set_palette_range(palette, 0, 255, 0);
+ set_palette_range(_G(palette), 0, 255, 0);
_G(gfxDriver)->DestroyDDB(ddb);
} else if (theTransition == FADE_DISSOLVE) {
int pattern[16] = { 0, 4, 14, 9, 5, 11, 2, 8, 10, 3, 12, 7, 15, 6, 13, 1 };
@@ -300,7 +299,7 @@ void process_event(EventHappened *evp) {
for (aa = 0; aa < 16; aa++) {
// merge the palette while dithering
if (_GP(game).color_depth == 1) {
- fade_interpolate(old_palette, palette, interpal, aa * 4, 0, 255);
+ fade_interpolate(old_palette, _G(palette), interpal, aa * 4, 0, 255);
set_palette_range(interpal, 0, 255, 0);
}
// do the dissolving
@@ -321,7 +320,7 @@ void process_event(EventHappened *evp) {
delete saved_viewport_bitmap;
saved_viewport_bitmap = nullptr;
- set_palette_range(palette, 0, 255, 0);
+ set_palette_range(_G(palette), 0, 255, 0);
_G(gfxDriver)->DestroyDDB(ddb);
}
diff --git a/engines/ags/engine/ac/game.cpp b/engines/ags/engine/ac/game.cpp
index 16e0f2328c..163efc2a06 100644
--- a/engines/ags/engine/ac/game.cpp
+++ b/engines/ags/engine/ac/game.cpp
@@ -113,8 +113,6 @@ using namespace AGS::Engine;
extern int _G(psp_gfx_renderer);
#endif
-extern color palette[256];
-
//=============================================================================
// Audio
//=============================================================================
@@ -881,7 +879,7 @@ void skip_serialized_bitmap(Stream *in) {
long write_screen_shot_for_vista(Stream *out, Bitmap *screenshot) {
// Save the screenshot to a memory stream so we can access the raw data
Common::MemoryWriteStreamDynamic bitmap(DisposeAfterUse::YES);
- screenshot->SaveToFile(bitmap, palette);
+ screenshot->SaveToFile(bitmap, _G(palette));
update_polled_stuff_if_runtime();
@@ -1108,7 +1106,7 @@ void ReadCharacterExtras_Aligned(Stream *in) {
}
void restore_game_palette(Stream *in) {
- in->SafeReadArray(&palette[0], PALETTE_COUNT);
+ in->SafeReadArray(&_G(palette)[0], PALETTE_COUNT);
}
void restore_game_dialogs(Stream *in) {
@@ -2199,7 +2197,7 @@ void RegisterStaticObjects() {
ccAddExternalStaticObject("game", &_GP(play), &GameStaticManager);
ccAddExternalStaticObject("gs_globals", &_GP(play).globalvars[0], &GlobalStaticManager);
ccAddExternalStaticObject("mouse", &_GP(scmouse), &GlobalStaticManager);
- ccAddExternalStaticObject("palette", &palette[0], &GlobalStaticManager);
+ ccAddExternalStaticObject("palette", &_G(palette)[0], &GlobalStaticManager);
ccAddExternalStaticObject("system", &_GP(scsystem), &GlobalStaticManager);
ccAddExternalStaticObject("savegameindex", &_GP(play).filenumbers[0], &GlobalStaticManager);
}
diff --git a/engines/ags/engine/ac/global_game.cpp b/engines/ags/engine/ac/global_game.cpp
index 2b1cc6586a..1860483907 100644
--- a/engines/ags/engine/ac/global_game.cpp
+++ b/engines/ags/engine/ac/global_game.cpp
@@ -76,7 +76,6 @@ using namespace AGS::Shared;
#define ALLEGRO_KEYBOARD_HANDLER
extern int gui_disabled_style;
-extern color palette[256];
#if AGS_PLATFORM_OS_IOS || AGS_PLATFORM_OS_ANDROID
extern int _G(psp_gfx_renderer);
@@ -835,7 +834,7 @@ int SaveScreenShot(const char *namm) {
fileName.Format("%s%s", svg_dir.GetCStr(), namm);
Bitmap *buffer = CopyScreenIntoBitmap(_GP(play).GetMainViewport().GetWidth(), _GP(play).GetMainViewport().GetHeight());
- if (!buffer->SaveToFile(fileName, palette)) {
+ if (!buffer->SaveToFile(fileName, _G(palette))) {
delete buffer;
return 0;
}
diff --git a/engines/ags/engine/ac/global_palette.cpp b/engines/ags/engine/ac/global_palette.cpp
index 313e09f40c..5ad19da5de 100644
--- a/engines/ags/engine/ac/global_palette.cpp
+++ b/engines/ags/engine/ac/global_palette.cpp
@@ -29,9 +29,6 @@
namespace AGS3 {
-
-extern color palette[256];
-
void CyclePalette(int strt, int eend) {
// hi-color game must invalidate screen since the palette changes
// the effect of the drawing operations
@@ -43,12 +40,12 @@ void CyclePalette(int strt, int eend) {
if (eend > strt) {
// forwards
- wcolrotate(strt, eend, 0, palette);
- set_palette_range(palette, strt, eend, 0);
+ wcolrotate(strt, eend, 0, _G(palette));
+ set_palette_range(_G(palette), strt, eend, 0);
} else {
// backwards
- wcolrotate(eend, strt, 1, palette);
- set_palette_range(palette, eend, strt, 0);
+ wcolrotate(eend, strt, 1, _G(palette));
+ set_palette_range(_G(palette), eend, strt, 0);
}
}
@@ -56,8 +53,8 @@ void SetPalRGB(int inndx, int rr, int gg, int bb) {
if (_GP(game).color_depth > 1)
invalidate_screen();
- wsetrgb(inndx, rr, gg, bb, palette);
- set_palette_range(palette, inndx, inndx, 0);
+ wsetrgb(inndx, rr, gg, bb, _G(palette));
+ set_palette_range(_G(palette), inndx, inndx, 0);
}
/*void scSetPal(color*pptr) {
wsetpalette(0,255,pptr);
diff --git a/engines/ags/engine/ac/global_screen.cpp b/engines/ags/engine/ac/global_screen.cpp
index ddbe845cc0..3e38b1697d 100644
--- a/engines/ags/engine/ac/global_screen.cpp
+++ b/engines/ags/engine/ac/global_screen.cpp
@@ -41,8 +41,6 @@ namespace AGS3 {
using namespace AGS::Shared;
using namespace AGS::Engine;
-extern color palette[256];
-
void FlipScreen(int amount) {
if ((amount < 0) | (amount > 3)) quit("!FlipScreen: invalid argument (0-3)");
_GP(play).screen_flipped = amount;
@@ -174,7 +172,7 @@ void FadeIn(int sppd) {
if (_GP(play).fast_forward)
return;
- my_fade_in(palette, sppd);
+ my_fade_in(_G(palette), sppd);
}
} // namespace AGS3
diff --git a/engines/ags/engine/ac/region.cpp b/engines/ags/engine/ac/region.cpp
index 0c7db276b4..e4a8db4eb2 100644
--- a/engines/ags/engine/ac/region.cpp
+++ b/engines/ags/engine/ac/region.cpp
@@ -40,9 +40,6 @@ namespace AGS3 {
using namespace AGS::Shared;
-extern COLOR_MAP maincoltable;
-extern color palette[256];
-
ScriptRegion *GetRegionAtRoom(int xx, int yy) {
return &_G(scrRegion)[GetRegionIDAtRoom(xx, yy)];
}
@@ -123,8 +120,8 @@ void Region_RunInteraction(ScriptRegion *ssr, int mood) {
void generate_light_table() {
if (_GP(game).color_depth == 1 && _G(color_map) == nullptr) {
- create_light_table(&maincoltable, palette, 0, 0, 0, nullptr);
- _G(color_map) = &maincoltable;
+ create_light_table(&_GP(maincoltable), _G(palette), 0, 0, 0, nullptr);
+ _G(color_map) = &_GP(maincoltable);
}
}
diff --git a/engines/ags/engine/ac/room.cpp b/engines/ags/engine/ac/room.cpp
index 372dcef22b..0d5e0aa873 100644
--- a/engines/ags/engine/ac/room.cpp
+++ b/engines/ags/engine/ac/room.cpp
@@ -85,8 +85,6 @@ namespace AGS3 {
using namespace AGS::Shared;
using namespace AGS::Engine;
-extern color palette[256];
-
ScriptDrawingSurface *Room_GetDrawingSurfaceForBackground(int backgroundNumber) {
if (_G(displayed_room) < 0)
quit("!Room.GetDrawingSurfaceForBackground: no room is currently loaded");
@@ -455,11 +453,11 @@ void load_new_room(int newnum, CharacterInfo *forchar) {
// do the palette
for (cc = 0; cc < 256; cc++) {
if (_GP(game).paluses[cc] == PAL_BACKGROUND)
- palette[cc] = _GP(thisroom).Palette[cc];
+ _G(palette)[cc] = _GP(thisroom).Palette[cc];
else {
// copy the gamewide colours into the room palette
for (size_t i = 0; i < _GP(thisroom).BgFrameCount; ++i)
- _GP(thisroom).BgFrames[i].Palette[cc] = palette[cc];
+ _GP(thisroom).BgFrames[i].Palette[cc] = _G(palette)[cc];
}
}
@@ -639,14 +637,14 @@ void load_new_room(int newnum, CharacterInfo *forchar) {
// the create_rgb_table call
// so, fix them
for (int ff = 0; ff < 256; ff++) {
- if (palette[ff].r > 63)
- palette[ff].r = 63;
- if (palette[ff].g > 63)
- palette[ff].g = 63;
- if (palette[ff].b > 63)
- palette[ff].b = 63;
+ if (_G(palette)[ff].r > 63)
+ _G(palette)[ff].r = 63;
+ if (_G(palette)[ff].g > 63)
+ _G(palette)[ff].g = 63;
+ if (_G(palette)[ff].b > 63)
+ _G(palette)[ff].b = 63;
}
- create_rgb_table(&_GP(rgb_table), palette, nullptr);
+ create_rgb_table(&_GP(rgb_table), _G(palette), nullptr);
_G(rgb_map) = &_GP(rgb_table);
}
_G(our_eip) = 211;
@@ -984,7 +982,7 @@ void on_background_frame_change() {
invalidate_cached_walkbehinds();
// get the new frame's palette
- memcpy(palette, _GP(thisroom).BgFrames[_GP(play).bg_frame].Palette, sizeof(color) * 256);
+ memcpy(_G(palette), _GP(thisroom).BgFrames[_GP(play).bg_frame].Palette, sizeof(color) * 256);
// hi-colour, update the palette. It won't have an immediate effect
// but will be drawn properly when the screen fades in
diff --git a/engines/ags/engine/ac/sprite.cpp b/engines/ags/engine/ac/sprite.cpp
index 91265daaf0..1594203d2a 100644
--- a/engines/ags/engine/ac/sprite.cpp
+++ b/engines/ags/engine/ac/sprite.cpp
@@ -38,8 +38,6 @@ namespace AGS3 {
using namespace AGS::Shared;
using namespace AGS::Engine;
-extern color palette[256];
-
void get_new_size_for_sprite(int ee, int ww, int hh, int &newwid, int &newhit) {
newwid = ww;
newhit = hh;
diff --git a/engines/ags/engine/device/mousew32.cpp b/engines/ags/engine/device/mousew32.cpp
index 68d898a8e0..0144478480 100644
--- a/engines/ags/engine/device/mousew32.cpp
+++ b/engines/ags/engine/device/mousew32.cpp
@@ -71,7 +71,6 @@ enum {
};
extern char lib_file_name[13];
-extern color palette[256];
static const int MB_ARRAY[3] = { 1, 2, 4 };
diff --git a/engines/ags/engine/game/savegame_components.cpp b/engines/ags/engine/game/savegame_components.cpp
index 7106be6744..798d223ab2 100644
--- a/engines/ags/engine/game/savegame_components.cpp
+++ b/engines/ags/engine/game/savegame_components.cpp
@@ -63,8 +63,6 @@ namespace AGS3 {
using namespace Shared;
-extern color palette[256];
-
namespace AGS {
namespace Engine {
@@ -195,7 +193,7 @@ HSaveError WriteGameState(PStream out) {
// Game base
_GP(game).WriteForSavegame(out);
// Game palette
- out->SafeWriteArray(palette, PALETTE_COUNT);
+ out->SafeWriteArray(_G(palette), PALETTE_COUNT);
if (_G(loaded_game_file_version) <= kGameVersion_272) {
// Global variables
@@ -284,7 +282,7 @@ HSaveError ReadGameState(PStream in, int32_t cmp_ver, const PreservedParams &pp,
// Game base
_GP(game).ReadFromSavegame(in);
// Game palette
- in->SafeReadArray(palette, PALETTE_COUNT);
+ in->SafeReadArray(_G(palette), PALETTE_COUNT);
if (_G(loaded_game_file_version) <= kGameVersion_272) {
// Legacy interaction global variables
diff --git a/engines/ags/engine/main/engine.cpp b/engines/ags/engine/main/engine.cpp
index 12f77dd230..c7474d54bb 100644
--- a/engines/ags/engine/main/engine.cpp
+++ b/engines/ags/engine/main/engine.cpp
@@ -83,8 +83,6 @@ namespace AGS3 {
using namespace AGS::Shared;
using namespace AGS::Engine;
-extern color palette[256];
-
#define ALLEGRO_KEYBOARD_HANDLER
bool engine_init_allegro() {
@@ -615,7 +613,7 @@ void engine_init_game_settings() {
for (ee = 0; ee < 256; ee++) {
if (_GP(game).paluses[ee] != PAL_BACKGROUND)
- palette[ee] = _GP(game).defpal[ee];
+ _G(palette)[ee] = _GP(game).defpal[ee];
}
for (ee = 0; ee < _GP(game).numcursors; ee++) {
diff --git a/engines/ags/globals.cpp b/engines/ags/globals.cpp
index 08c0a41755..4e1d1d756a 100644
--- a/engines/ags/globals.cpp
+++ b/engines/ags/globals.cpp
@@ -150,6 +150,8 @@ Globals::Globals() {
_dynamicallyCreatedSurfaces = new AGS::Shared::Bitmap *[MAX_DYNAMIC_SURFACES];
Common::fill(_dynamicallyCreatedSurfaces, _dynamicallyCreatedSurfaces +
MAX_DYNAMIC_SURFACES, (AGS::Shared::Bitmap *)nullptr);
+ _palette = new color[256];
+ _maincoltable = new COLOR_MAP();
// draw_software.cpp globals
_BlackRects = new DirtyRects();
@@ -331,6 +333,8 @@ Globals::~Globals() {
delete _sprlist;
delete _thingsToDrawList;
delete[] _dynamicallyCreatedSurfaces;
+ delete[] _palette;
+ delete[] _maincoltable;
// draw_software.cpp globals
delete _BlackRects;
diff --git a/engines/ags/globals.h b/engines/ags/globals.h
index 16215b5fb6..181cbcce78 100644
--- a/engines/ags/globals.h
+++ b/engines/ags/globals.h
@@ -103,6 +103,7 @@ struct CCRegion;
struct CharacterCache;
struct CharacterExtras;
struct CharacterInfo;
+struct color;
struct COLOR_MAP;
struct DialogTopic;
struct DirtyRects;
@@ -480,6 +481,8 @@ public:
AGS::Shared::Bitmap *_raw_saved_screen = nullptr;
AGS::Shared::Bitmap **_dynamicallyCreatedSurfaces = nullptr;
int _places_r = 3, _places_g = 2, _places_b = 3;
+ color *_palette;
+ COLOR_MAP *_maincoltable;
/**@}*/
diff --git a/engines/ags/plugins/agsplugin.cpp b/engines/ags/plugins/agsplugin.cpp
index 7d89279eb1..4e7d9d0abd 100644
--- a/engines/ags/plugins/agsplugin.cpp
+++ b/engines/ags/plugins/agsplugin.cpp
@@ -84,8 +84,6 @@ using namespace AGS::Shared;
using namespace AGS::Shared::Memory;
using namespace AGS::Engine;
-extern color palette[256];
-
void PluginSimulateMouseClick(int pluginButtonID) {
_G(pluginSimulatedClick) = pluginButtonID - 1;
}
@@ -417,7 +415,7 @@ AGSGameOptions *IAGSEngine::GetGameOptions() {
return (AGSGameOptions *)&_GP(play);
}
AGSColor *IAGSEngine::GetPalette() {
- return (AGSColor *)&palette[0];
+ return (AGSColor *)&_G(palette)[0];
}
void IAGSEngine::SetPalette(int32 start, int32 finish, AGSColor *cpl) {
set_palette_range((color *)cpl, start, finish, 0);
Commit: bf3c05128d15680fc93b5c46d64cb901b6ac39fc
https://github.com/scummvm/scummvm/commit/bf3c05128d15680fc93b5c46d64cb901b6ac39fc
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2021-03-12T20:44:13-08:00
Commit Message:
AGS: Move screen.cpp globals to Globals
Changed paths:
engines/ags/engine/ac/event.cpp
engines/ags/engine/ac/screen.cpp
engines/ags/engine/ac/screen.h
engines/ags/globals.cpp
engines/ags/globals.h
diff --git a/engines/ags/engine/ac/event.cpp b/engines/ags/engine/ac/event.cpp
index 8af64804b9..8277f49d41 100644
--- a/engines/ags/engine/ac/event.cpp
+++ b/engines/ags/engine/ac/event.cpp
@@ -48,8 +48,6 @@ namespace AGS3 {
using namespace AGS::Shared;
using namespace AGS::Engine;
-extern color old_palette[256];
-
int run_claimable_event(const char *tsname, bool includeRoom, int numParams, const RuntimeScriptValue *params, bool *eventWasClaimed) {
*eventWasClaimed = true;
// Run the room script function, and if it is not claimed,
@@ -207,7 +205,7 @@ void process_event(EventHappened *evp) {
const bool ignore_transition = (_GP(play).screen_tint > 0);
if (((theTransition == FADE_CROSSFADE) || (theTransition == FADE_DISSOLVE)) &&
- (saved_viewport_bitmap == nullptr) && !ignore_transition) {
+ (_G(saved_viewport_bitmap) == nullptr) && !ignore_transition) {
// transition type was not crossfade/dissolve when the screen faded out,
// but it is now when the screen fades in (Eg. a save game was restored
// with a different setting). Therefore just fade normally.
@@ -284,10 +282,10 @@ void process_event(EventHappened *evp) {
WaitForNextFrame();
transparency -= 16;
}
- saved_viewport_bitmap->Release();
+ _G(saved_viewport_bitmap)->Release();
- delete saved_viewport_bitmap;
- saved_viewport_bitmap = nullptr;
+ delete _G(saved_viewport_bitmap);
+ _G(saved_viewport_bitmap) = nullptr;
set_palette_range(_G(palette), 0, 255, 0);
_G(gfxDriver)->DestroyDDB(ddb);
} else if (theTransition == FADE_DISSOLVE) {
@@ -299,17 +297,17 @@ void process_event(EventHappened *evp) {
for (aa = 0; aa < 16; aa++) {
// merge the palette while dithering
if (_GP(game).color_depth == 1) {
- fade_interpolate(old_palette, _G(palette), interpal, aa * 4, 0, 255);
+ fade_interpolate(_G(old_palette), _G(palette), interpal, aa * 4, 0, 255);
set_palette_range(interpal, 0, 255, 0);
}
// do the dissolving
- int maskCol = saved_viewport_bitmap->GetMaskColor();
+ int maskCol = _G(saved_viewport_bitmap)->GetMaskColor();
for (bb = 0; bb < viewport.GetWidth(); bb += 4) {
for (cc = 0; cc < viewport.GetHeight(); cc += 4) {
- saved_viewport_bitmap->PutPixel(bb + pattern[aa] / 4, cc + pattern[aa] % 4, maskCol);
+ _G(saved_viewport_bitmap)->PutPixel(bb + pattern[aa] / 4, cc + pattern[aa] % 4, maskCol);
}
}
- _G(gfxDriver)->UpdateDDBFromBitmap(ddb, saved_viewport_bitmap, false);
+ _G(gfxDriver)->UpdateDDBFromBitmap(ddb, _G(saved_viewport_bitmap), false);
construct_game_scene(true);
construct_game_screen_overlay(false);
_G(gfxDriver)->DrawSprite(0, 0, ddb);
@@ -318,8 +316,8 @@ void process_event(EventHappened *evp) {
WaitForNextFrame();
}
- delete saved_viewport_bitmap;
- saved_viewport_bitmap = nullptr;
+ delete _G(saved_viewport_bitmap);
+ _G(saved_viewport_bitmap) = nullptr;
set_palette_range(_G(palette), 0, 255, 0);
_G(gfxDriver)->DestroyDDB(ddb);
}
diff --git a/engines/ags/engine/ac/screen.cpp b/engines/ags/engine/ac/screen.cpp
index 555ff8137b..2373d37a26 100644
--- a/engines/ags/engine/ac/screen.cpp
+++ b/engines/ags/engine/ac/screen.cpp
@@ -56,8 +56,6 @@ void my_fade_in(PALETTE p, int speed) {
_G(gfxDriver)->FadeIn(speed, p, _GP(play).fade_to_red, _GP(play).fade_to_green, _GP(play).fade_to_blue);
}
-Bitmap *saved_viewport_bitmap = nullptr;
-color old_palette[256];
void current_fade_out_effect() {
if (pl_run_plugin_hooks(AGSE_TRANSITIONOUT, 0))
return;
@@ -78,30 +76,30 @@ void current_fade_out_effect() {
_G(gfxDriver)->BoxOutEffect(true, get_fixed_pixel_size(16), 1000 / GetGameSpeed());
_GP(play).screen_is_faded_out = 1;
} else {
- get_palette(old_palette);
+ get_palette(_G(old_palette));
const Rect &viewport = _GP(play).GetMainViewport();
- saved_viewport_bitmap = CopyScreenIntoBitmap(viewport.GetWidth(), viewport.GetHeight());
+ _G(saved_viewport_bitmap) = CopyScreenIntoBitmap(viewport.GetWidth(), viewport.GetHeight());
}
}
IDriverDependantBitmap *prepare_screen_for_transition_in() {
- if (saved_viewport_bitmap == nullptr)
+ if (_G(saved_viewport_bitmap) == nullptr)
quit("Crossfade: buffer is null attempting transition");
- saved_viewport_bitmap = ReplaceBitmapWithSupportedFormat(saved_viewport_bitmap);
+ _G(saved_viewport_bitmap) = ReplaceBitmapWithSupportedFormat(_G(saved_viewport_bitmap));
const Rect &viewport = _GP(play).GetMainViewport();
- if (saved_viewport_bitmap->GetHeight() < viewport.GetHeight()) {
- Bitmap *enlargedBuffer = BitmapHelper::CreateBitmap(saved_viewport_bitmap->GetWidth(), viewport.GetHeight(), saved_viewport_bitmap->GetColorDepth());
- enlargedBuffer->Blit(saved_viewport_bitmap, 0, 0, 0, (viewport.GetHeight() - saved_viewport_bitmap->GetHeight()) / 2, saved_viewport_bitmap->GetWidth(), saved_viewport_bitmap->GetHeight());
- delete saved_viewport_bitmap;
- saved_viewport_bitmap = enlargedBuffer;
- } else if (saved_viewport_bitmap->GetHeight() > viewport.GetHeight()) {
- Bitmap *clippedBuffer = BitmapHelper::CreateBitmap(saved_viewport_bitmap->GetWidth(), viewport.GetHeight(), saved_viewport_bitmap->GetColorDepth());
- clippedBuffer->Blit(saved_viewport_bitmap, 0, (saved_viewport_bitmap->GetHeight() - viewport.GetHeight()) / 2, 0, 0, saved_viewport_bitmap->GetWidth(), saved_viewport_bitmap->GetHeight());
- delete saved_viewport_bitmap;
- saved_viewport_bitmap = clippedBuffer;
+ if (_G(saved_viewport_bitmap)->GetHeight() < viewport.GetHeight()) {
+ Bitmap *enlargedBuffer = BitmapHelper::CreateBitmap(_G(saved_viewport_bitmap)->GetWidth(), viewport.GetHeight(), _G(saved_viewport_bitmap)->GetColorDepth());
+ enlargedBuffer->Blit(_G(saved_viewport_bitmap), 0, 0, 0, (viewport.GetHeight() - _G(saved_viewport_bitmap)->GetHeight()) / 2, _G(saved_viewport_bitmap)->GetWidth(), _G(saved_viewport_bitmap)->GetHeight());
+ delete _G(saved_viewport_bitmap);
+ _G(saved_viewport_bitmap) = enlargedBuffer;
+ } else if (_G(saved_viewport_bitmap)->GetHeight() > viewport.GetHeight()) {
+ Bitmap *clippedBuffer = BitmapHelper::CreateBitmap(_G(saved_viewport_bitmap)->GetWidth(), viewport.GetHeight(), _G(saved_viewport_bitmap)->GetColorDepth());
+ clippedBuffer->Blit(_G(saved_viewport_bitmap), 0, (_G(saved_viewport_bitmap)->GetHeight() - viewport.GetHeight()) / 2, 0, 0, _G(saved_viewport_bitmap)->GetWidth(), _G(saved_viewport_bitmap)->GetHeight());
+ delete _G(saved_viewport_bitmap);
+ _G(saved_viewport_bitmap) = clippedBuffer;
}
- IDriverDependantBitmap *ddb = _G(gfxDriver)->CreateDDBFromBitmap(saved_viewport_bitmap, false);
+ IDriverDependantBitmap *ddb = _G(gfxDriver)->CreateDDBFromBitmap(_G(saved_viewport_bitmap), false);
return ddb;
}
diff --git a/engines/ags/engine/ac/screen.h b/engines/ags/engine/ac/screen.h
index ef1ecba60c..11b8175702 100644
--- a/engines/ags/engine/ac/screen.h
+++ b/engines/ags/engine/ac/screen.h
@@ -41,9 +41,6 @@ void my_fade_in(PALETTE p, int speed);
void current_fade_out_effect();
AGS::Engine::IDriverDependantBitmap *prepare_screen_for_transition_in();
-// Screenshot made in the last room, used during some of the transition effects
-extern AGS::Shared::Bitmap *saved_viewport_bitmap;
-
} // namespace AGS3
#endif
diff --git a/engines/ags/globals.cpp b/engines/ags/globals.cpp
index 4e1d1d756a..4d0d9d2c18 100644
--- a/engines/ags/globals.cpp
+++ b/engines/ags/globals.cpp
@@ -258,6 +258,9 @@ Globals::Globals() {
_navpoints = new int32_t[MAXNEEDSTAGES];
_nav = new Navigation();
+ // screen.cpp globals
+ _old_palette = new color[256];
+
// script.cpp globals
_scripts = new ExecutingScript[MAX_SCRIPT_AT_ONCE];
_gamescript = new PScript();
@@ -438,6 +441,9 @@ Globals::~Globals() {
delete _navpoints;
delete _nav;
+ // screen.cpp globals
+ delete[] _old_palette;
+
// script.cpp globals
delete[] _scripts;
delete _gamescript;
diff --git a/engines/ags/globals.h b/engines/ags/globals.h
index 181cbcce78..075057d9df 100644
--- a/engines/ags/globals.h
+++ b/engines/ags/globals.h
@@ -982,6 +982,17 @@ public:
/**@}*/
+ /**
+ * \defgroup screen globals
+ * @{
+ */
+
+ // Screenshot made in the last room, used during some of the transition effects
+ AGS::Shared::Bitmap *_saved_viewport_bitmap = nullptr;
+ color *_old_palette;
+
+ /**@}*/
+
/**
* \defgroup script globals
* @{
More information about the Scummvm-git-logs
mailing list