[Scummvm-git-logs] scummvm master -> 8a901688198200d31b835e61508efac3e4224208
dreammaster
dreammaster at scummvm.org
Sun Mar 7 16:52:59 UTC 2021
This automated email contains information about 4 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
3a3f31cd56 AGS: Move Allegro color.cpp globals to Globals
0a98eb1fc1 AGS: Moving more Allegro globals to Globals
ab84798f9a AGS: Removing unneeded Allegro driver classes
8a90168819 AGS: Move remainder of Allegro globals to Globals
Commit: 3a3f31cd56bbc9a335d3ad9b5841136cc48ac8f3
https://github.com/scummvm/scummvm/commit/3a3f31cd56bbc9a335d3ad9b5841136cc48ac8f3
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2021-03-07T08:52:15-08:00
Commit Message:
AGS: Move Allegro color.cpp globals to Globals
Changed paths:
engines/ags/engine/ac/draw.cpp
engines/ags/engine/ac/draw.h
engines/ags/engine/ac/global_debug.cpp
engines/ags/engine/ac/region.cpp
engines/ags/engine/ac/room.cpp
engines/ags/engine/gfx/gfxdriverbase.cpp
engines/ags/engine/main/engine_setup.cpp
engines/ags/globals.h
engines/ags/lib/aastr-0.1.1/aautil.cpp
engines/ags/lib/allegro/color.cpp
engines/ags/lib/allegro/color.h
engines/ags/lib/allegro/gfx.cpp
engines/ags/lib/allegro/graphics.cpp
engines/ags/lib/allegro/surface.cpp
diff --git a/engines/ags/engine/ac/draw.cpp b/engines/ags/engine/ac/draw.cpp
index cf6d7b3c61..6219bfdcc7 100644
--- a/engines/ags/engine/ac/draw.cpp
+++ b/engines/ags/engine/ac/draw.cpp
@@ -183,9 +183,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) << _rgb_r_shift_16) |
- ((ds >> _places_g) << _rgb_g_shift_16) |
- ((b >> _places_b) << _rgb_b_shift_16));
+ 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)));
}
}
diff --git a/engines/ags/engine/ac/draw.h b/engines/ags/engine/ac/draw.h
index 5549737664..f16e202373 100644
--- a/engines/ags/engine/ac/draw.h
+++ b/engines/ags/engine/ac/draw.h
@@ -50,11 +50,11 @@ using namespace AGS; // FIXME later
// were included, because they override few Allegro function names;
// otherwise Allegro headers should not be included at all to the same
// code unit which uses these defines.
-#define getr32(xx) ((xx >> _rgb_r_shift_32) & 0xFF)
-#define getg32(xx) ((xx >> _rgb_g_shift_32) & 0xFF)
-#define getb32(xx) ((xx >> _rgb_b_shift_32) & 0xFF)
-#define geta32(xx) ((xx >> _rgb_a_shift_32) & 0xFF)
-#define makeacol32(r,g,b,a) ((r << _rgb_r_shift_32) | (g << _rgb_g_shift_32) | (b << _rgb_b_shift_32) | (a << _rgb_a_shift_32))
+#define getr32(xx) ((xx >> _G(_rgb_r_shift_32)) & 0xFF)
+#define getg32(xx) ((xx >> _G(_rgb_g_shift_32)) & 0xFF)
+#define getb32(xx) ((xx >> _G(_rgb_b_shift_32)) & 0xFF)
+#define geta32(xx) ((xx >> _G(_rgb_a_shift_32)) & 0xFF)
+#define makeacol32(r,g,b,a) ((r << _G(_rgb_r_shift_32)) | (g << _G(_rgb_g_shift_32)) | (b << _G(_rgb_b_shift_32)) | (a << _G(_rgb_a_shift_32)))
struct CachedActSpsData {
diff --git a/engines/ags/engine/ac/global_debug.cpp b/engines/ags/engine/ac/global_debug.cpp
index 7e3dd4e6d0..c72607a30c 100644
--- a/engines/ags/engine/ac/global_debug.cpp
+++ b/engines/ags/engine/ac/global_debug.cpp
@@ -98,7 +98,7 @@ void script_debug(int cmdd, int dataa) {
} else if (cmdd == 1) {
String toDisplay = GetRuntimeInfo();
Display(toDisplay.GetCStr());
- // Display("shftR: %d shftG: %d shftB: %d", _rgb_r_shift_16, _rgb_g_shift_16, _rgb_b_shift_16);
+ // Display("shftR: %d shftG: %d shftB: %d", _G(_rgb_r_shift_16), _G(_rgb_g_shift_16), _G(_rgb_b_shift_16));
// Display("Remaining memory: %d kb",_go32_dpmi_remaining_virtual_memory()/1024);
//Display("Play char bcd: %d",->GetColorDepth(_GP(spriteset)[_G(views)[playerchar->view].frames[playerchar->loop][playerchar->frame].pic]));
} else if (cmdd == 2) {
diff --git a/engines/ags/engine/ac/region.cpp b/engines/ags/engine/ac/region.cpp
index dd89680e11..6e84ca1cfd 100644
--- a/engines/ags/engine/ac/region.cpp
+++ b/engines/ags/engine/ac/region.cpp
@@ -123,9 +123,9 @@ void Region_RunInteraction(ScriptRegion *ssr, int mood) {
//=============================================================================
void generate_light_table() {
- if (_GP(game).color_depth == 1 && color_map == nullptr) {
+ if (_GP(game).color_depth == 1 && _G(color_map) == nullptr) {
create_light_table(&maincoltable, palette, 0, 0, 0, nullptr);
- color_map = &maincoltable;
+ _G(color_map) = &maincoltable;
}
}
diff --git a/engines/ags/engine/ac/room.cpp b/engines/ags/engine/ac/room.cpp
index 218ec4333f..c07e8afe1f 100644
--- a/engines/ags/engine/ac/room.cpp
+++ b/engines/ags/engine/ac/room.cpp
@@ -682,7 +682,7 @@ void load_new_room(int newnum, CharacterInfo *forchar) {
palette[ff].b = 63;
}
create_rgb_table(&rgb_table, palette, nullptr);
- rgb_map = &rgb_table;
+ _G(rgb_map) = &rgb_table;
}
our_eip = 211;
if (forchar != nullptr) {
@@ -860,7 +860,7 @@ void load_new_room(int newnum, CharacterInfo *forchar) {
else forchar->view = _GP(thisroom).Options.PlayerView - 1;
forchar->frame = 0; // make him standing
}
- color_map = nullptr;
+ _G(color_map) = nullptr;
our_eip = 209;
update_polled_stuff_if_runtime();
diff --git a/engines/ags/engine/gfx/gfxdriverbase.cpp b/engines/ags/engine/gfx/gfxdriverbase.cpp
index ae3a13a5ad..11b2b85efc 100644
--- a/engines/ags/engine/gfx/gfxdriverbase.cpp
+++ b/engines/ags/engine/gfx/gfxdriverbase.cpp
@@ -27,6 +27,7 @@
#include "ags/engine/gfx/gfxdriverbase.h"
#include "ags/engine/gfx/gfx_util.h"
#include "ags/engine/ac/draw.h"
+#include "ags/globals.h"
namespace AGS3 {
diff --git a/engines/ags/engine/main/engine_setup.cpp b/engines/ags/engine/main/engine_setup.cpp
index a89ef86665..f4cd318877 100644
--- a/engines/ags/engine/main/engine_setup.cpp
+++ b/engines/ags/engine/main/engine_setup.cpp
@@ -179,21 +179,21 @@ void engine_pre_gfxsystem_screen_destroy() {
// Setup color conversion parameters
void engine_setup_color_conversions(int coldepth) {
// default shifts for how we store the sprite data1
- _rgb_r_shift_32 = 16;
- _rgb_g_shift_32 = 8;
- _rgb_b_shift_32 = 0;
- _rgb_r_shift_16 = 11;
- _rgb_g_shift_16 = 5;
- _rgb_b_shift_16 = 0;
- _rgb_r_shift_15 = 10;
- _rgb_g_shift_15 = 5;
- _rgb_b_shift_15 = 0;
+ _G(_rgb_r_shift_32) = 16;
+ _G(_rgb_g_shift_32) = 8;
+ _G(_rgb_b_shift_32) = 0;
+ _G(_rgb_r_shift_16) = 11;
+ _G(_rgb_g_shift_16) = 5;
+ _G(_rgb_b_shift_16) = 0;
+ _G(_rgb_r_shift_15) = 10;
+ _G(_rgb_g_shift_15) = 5;
+ _G(_rgb_b_shift_15) = 0;
// Most cards do 5-6-5 RGB, which is the format the files are saved in
// Some do 5-6-5 BGR, or 6-5-5 RGB, in which case convert the gfx
- if ((coldepth == 16) && ((_rgb_b_shift_16 != 0) || (_rgb_r_shift_16 != 11))) {
+ if ((coldepth == 16) && ((_G(_rgb_b_shift_16) != 0) || (_G(_rgb_r_shift_16) != 11))) {
convert_16bit_bgr = 1;
- if (_rgb_r_shift_16 == 10) {
+ 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;
@@ -205,43 +205,43 @@ void engine_setup_color_conversions(int coldepth) {
// the wrong way round - so fix that
#if AGS_PLATFORM_OS_IOS || AGS_PLATFORM_OS_ANDROID
- _rgb_b_shift_16 = 0;
- _rgb_g_shift_16 = 5;
- _rgb_r_shift_16 = 11;
+ _G(_rgb_b_shift_16) = 0;
+ _G(_rgb_g_shift_16) = 5;
+ _G(_rgb_r_shift_16) = 11;
- _rgb_b_shift_15 = 0;
- _rgb_g_shift_15 = 5;
- _rgb_r_shift_15 = 10;
+ _G(_rgb_b_shift_15) = 0;
+ _G(_rgb_g_shift_15) = 5;
+ _G(_rgb_r_shift_15) = 10;
- _rgb_r_shift_32 = 0;
- _rgb_g_shift_32 = 8;
- _rgb_b_shift_32 = 16;
+ _G(_rgb_r_shift_32) = 0;
+ _G(_rgb_g_shift_32) = 8;
+ _G(_rgb_b_shift_32) = 16;
#else
- _rgb_r_shift_16 = 11;
- _rgb_g_shift_16 = 5;
- _rgb_b_shift_16 = 0;
+ _G(_rgb_r_shift_16) = 11;
+ _G(_rgb_g_shift_16) = 5;
+ _G(_rgb_b_shift_16) = 0;
#endif
} else if (coldepth == 16) {
// ensure that any 32-bit graphics displayed are converted
// properly to the current depth
- _rgb_r_shift_32 = 16;
- _rgb_g_shift_32 = 8;
- _rgb_b_shift_32 = 0;
+ _G(_rgb_r_shift_32) = 16;
+ _G(_rgb_g_shift_32) = 8;
+ _G(_rgb_b_shift_32) = 0;
} else if (coldepth < 16) {
// ensure that any 32-bit graphics displayed are converted
// properly to the current depth
#if AGS_PLATFORM_OS_WINDOWS
- _rgb_r_shift_32 = 16;
- _rgb_g_shift_32 = 8;
- _rgb_b_shift_32 = 0;
+ _G(_rgb_r_shift_32) = 16;
+ _G(_rgb_g_shift_32) = 8;
+ _G(_rgb_b_shift_32) = 0;
#else
- _rgb_r_shift_32 = 0;
- _rgb_g_shift_32 = 8;
- _rgb_b_shift_32 = 16;
+ _G(_rgb_r_shift_32) = 0;
+ _G(_rgb_g_shift_32) = 8;
+ _G(_rgb_b_shift_32) = 16;
- _rgb_b_shift_15 = 0;
- _rgb_g_shift_15 = 5;
- _rgb_r_shift_15 = 10;
+ _G(_rgb_b_shift_15) = 0;
+ _G(_rgb_g_shift_15) = 5;
+ _G(_rgb_r_shift_15) = 10;
#endif
}
diff --git a/engines/ags/globals.h b/engines/ags/globals.h
index bb667a51c3..526f0bca8d 100644
--- a/engines/ags/globals.h
+++ b/engines/ags/globals.h
@@ -31,6 +31,7 @@
#include "ags/lib/std/array.h"
#include "ags/lib/std/set.h"
#include "ags/lib/allegro/fixed.h"
+#include "ags/lib/allegro/aintern.h"
namespace AGS3 {
@@ -87,6 +88,7 @@ struct CCInventory;
struct CCObject;
struct CCRegion;
struct CharacterCache;
+struct COLOR_MAP;
struct DirtyRects;
struct ExecutingScript;
struct GameFrameSetup;
@@ -99,6 +101,7 @@ struct MoveList;
struct NonBlockingScriptFunction;
struct ObjectCache;
struct ResourcePaths;
+struct RGB_MAP;
struct RoomCameraDrawData;
struct RoomStatus;
struct RuntimeScriptValue;
@@ -121,13 +124,31 @@ struct ViewStruct;
class Globals {
public:
/**
- * \defgroup Overall flags
+ * \defgroup Allegro globals
* @{
*/
- // Major overall flags
- bool _want_exit = false;
- bool _abort_engine = false;
+ int __rgb_r_shift_15 = DEFAULT_RGB_R_SHIFT_15; /* truecolor pixel format */
+ int __rgb_g_shift_15 = DEFAULT_RGB_G_SHIFT_15;
+ int __rgb_b_shift_15 = DEFAULT_RGB_B_SHIFT_15;
+ int __rgb_r_shift_16 = DEFAULT_RGB_R_SHIFT_16;
+ int __rgb_g_shift_16 = DEFAULT_RGB_G_SHIFT_16;
+ int __rgb_b_shift_16 = DEFAULT_RGB_B_SHIFT_16;
+ int __rgb_r_shift_24 = DEFAULT_RGB_R_SHIFT_24;
+ int __rgb_g_shift_24 = DEFAULT_RGB_G_SHIFT_24;
+ int __rgb_b_shift_24 = DEFAULT_RGB_B_SHIFT_24;
+ int __rgb_r_shift_32 = DEFAULT_RGB_R_SHIFT_32;
+ int __rgb_g_shift_32 = DEFAULT_RGB_G_SHIFT_32;
+ int __rgb_b_shift_32 = DEFAULT_RGB_B_SHIFT_32;
+ int __rgb_a_shift_32 = DEFAULT_RGB_A_SHIFT_32;
+
+ RGB_MAP *_rgb_map;
+ COLOR_MAP *_color_map;
+ int _trans_blend_alpha = 0;
+ int _trans_blend_red = 0;
+ int _trans_blend_green = 0;
+ int _trans_blend_blue = 0;
+ BlenderMode __blender_mode = kRgbToRgbBlender;
/**@}*/
@@ -339,6 +360,10 @@ public:
AGS::Shared::String _saveGameParent;
AGS::Shared::String _saveGameSuffix;
+ // Major overall flags
+ bool _want_exit = false;
+ bool _abort_engine = false;
+
/**@}*/
/**
diff --git a/engines/ags/lib/aastr-0.1.1/aautil.cpp b/engines/ags/lib/aastr-0.1.1/aautil.cpp
index d5a840e166..89ed12033d 100644
--- a/engines/ags/lib/aastr-0.1.1/aautil.cpp
+++ b/engines/ags/lib/aastr-0.1.1/aautil.cpp
@@ -36,6 +36,7 @@
*/
#include "ags/lib/aastr-0.1.1/aautil.h"
+#include "ags/globals.h"
namespace AGS3 {
@@ -56,9 +57,9 @@ static struct {
* Prepare offsets for direct access to 24bpp bitmap.
*/
void _aa_prepare_for_24bpp() {
- _aa.roffset24 = _rgb_r_shift_24 / 8;
- _aa.goffset24 = _rgb_g_shift_24 / 8;
- _aa.boffset24 = _rgb_b_shift_24 / 8;
+ _aa.roffset24 = _G(_rgb_r_shift_24) / 8;
+ _aa.goffset24 = _G(_rgb_g_shift_24) / 8;
+ _aa.boffset24 = _G(_rgb_b_shift_24) / 8;
}
/*
diff --git a/engines/ags/lib/allegro/color.cpp b/engines/ags/lib/allegro/color.cpp
index fc4bc7977d..60164c78f2 100644
--- a/engines/ags/lib/allegro/color.cpp
+++ b/engines/ags/lib/allegro/color.cpp
@@ -25,6 +25,7 @@
#include "ags/lib/allegro/aintern.h"
#include "ags/shared/core/types.h"
#include "ags/shared/util/stream.h"
+#include "ags/globals.h"
#include "common/textconsole.h"
#include "common/system.h"
#include "graphics/palette.h"
@@ -33,28 +34,6 @@ namespace AGS3 {
#define VGA_COLOR_TRANS(x) ((x) * 255 / 63)
-int _rgb_r_shift_15 = DEFAULT_RGB_R_SHIFT_15; /* truecolor pixel format */
-int _rgb_g_shift_15 = DEFAULT_RGB_G_SHIFT_15;
-int _rgb_b_shift_15 = DEFAULT_RGB_B_SHIFT_15;
-int _rgb_r_shift_16 = DEFAULT_RGB_R_SHIFT_16;
-int _rgb_g_shift_16 = DEFAULT_RGB_G_SHIFT_16;
-int _rgb_b_shift_16 = DEFAULT_RGB_B_SHIFT_16;
-int _rgb_r_shift_24 = DEFAULT_RGB_R_SHIFT_24;
-int _rgb_g_shift_24 = DEFAULT_RGB_G_SHIFT_24;
-int _rgb_b_shift_24 = DEFAULT_RGB_B_SHIFT_24;
-int _rgb_r_shift_32 = DEFAULT_RGB_R_SHIFT_32;
-int _rgb_g_shift_32 = DEFAULT_RGB_G_SHIFT_32;
-int _rgb_b_shift_32 = DEFAULT_RGB_B_SHIFT_32;
-int _rgb_a_shift_32 = DEFAULT_RGB_A_SHIFT_32;
-
-RGB_MAP *rgb_map;
-COLOR_MAP *color_map;
-int trans_blend_alpha = 0;
-int trans_blend_red = 0;
-int trans_blend_green = 0;
-int trans_blend_blue = 0;
-BlenderMode _blender_mode = kRgbToRgbBlender;
-
void color::readFromFile(AGS::Shared::Stream *file) {
r = file->ReadByte();
g = file->ReadByte();
@@ -86,34 +65,34 @@ void set_palette_range(const PALETTE p, int from, int to, int retracesync) {
}
int makecol15(int r, int g, int b) {
- return (((r >> 3) << _rgb_r_shift_15) |
- ((g >> 3) << _rgb_g_shift_15) |
- ((b >> 3) << _rgb_b_shift_15));
+ return (((r >> 3) << _G(_rgb_r_shift_15)) |
+ ((g >> 3) << _G(_rgb_g_shift_15)) |
+ ((b >> 3) << _G(_rgb_b_shift_15)));
}
int makecol16(int r, int g, int b) {
- return (((r >> 3) << _rgb_r_shift_16) |
- ((g >> 2) << _rgb_g_shift_16) |
- ((b >> 3) << _rgb_b_shift_16));
+ return (((r >> 3) << _G(_rgb_r_shift_16)) |
+ ((g >> 2) << _G(_rgb_g_shift_16)) |
+ ((b >> 3) << _G(_rgb_b_shift_16)));
}
int makecol24(int r, int g, int b) {
- return ((r << _rgb_r_shift_24) |
- (g << _rgb_g_shift_24) |
- (b << _rgb_b_shift_24));
+ return ((r << _G(_rgb_r_shift_24)) |
+ (g << _G(_rgb_g_shift_24)) |
+ (b << _G(_rgb_b_shift_24)));
}
int makecol32(int r, int g, int b) {
- return ((r << _rgb_r_shift_32) |
- (g << _rgb_g_shift_32) |
- (b << _rgb_b_shift_32));
+ return ((r << _G(_rgb_r_shift_32)) |
+ (g << _G(_rgb_g_shift_32)) |
+ (b << _G(_rgb_b_shift_32)));
}
int makeacol32(int r, int g, int b, int a) {
- return ((r << _rgb_r_shift_32) |
- (g << _rgb_g_shift_32) |
- (b << _rgb_b_shift_32) |
- (a << _rgb_a_shift_32));
+ return ((r << _G(_rgb_r_shift_32)) |
+ (g << _G(_rgb_g_shift_32)) |
+ (b << _G(_rgb_b_shift_32)) |
+ (a << _G(_rgb_a_shift_32)));
}
int getr8(int c) {
@@ -129,55 +108,55 @@ int getb8(int c) {
}
int getr15(int c) {
- return _rgb_scale_5[(c >> _rgb_r_shift_15) & 0x1F];
+ return _rgb_scale_5[(c >> _G(_rgb_r_shift_15)) & 0x1F];
}
int getg15(int c) {
- return _rgb_scale_5[(c >> _rgb_g_shift_15) & 0x1F];
+ return _rgb_scale_5[(c >> _G(_rgb_g_shift_15)) & 0x1F];
}
int getb15(int c) {
- return _rgb_scale_5[(c >> _rgb_b_shift_15) & 0x1F];
+ return _rgb_scale_5[(c >> _G(_rgb_b_shift_15)) & 0x1F];
}
int getr16(int c) {
- return _rgb_scale_5[(c >> _rgb_r_shift_16) & 0x1F];
+ return _rgb_scale_5[(c >> _G(_rgb_r_shift_16)) & 0x1F];
}
int getg16(int c) {
- return _rgb_scale_6[(c >> _rgb_g_shift_16) & 0x3F];
+ return _rgb_scale_6[(c >> _G(_rgb_g_shift_16)) & 0x3F];
}
int getb16(int c) {
- return _rgb_scale_5[(c >> _rgb_b_shift_16) & 0x1F];
+ return _rgb_scale_5[(c >> _G(_rgb_b_shift_16)) & 0x1F];
}
int getr24(int c) {
- return ((c >> _rgb_r_shift_24) & 0xFF);
+ return ((c >> _G(_rgb_r_shift_24)) & 0xFF);
}
int getg24(int c) {
- return ((c >> _rgb_g_shift_24) & 0xFF);
+ return ((c >> _G(_rgb_g_shift_24)) & 0xFF);
}
int getb24(int c) {
- return ((c >> _rgb_b_shift_24) & 0xFF);
+ return ((c >> _G(_rgb_b_shift_24)) & 0xFF);
}
int getr32(int c) {
- return ((c >> _rgb_r_shift_32) & 0xFF);
+ return ((c >> _G(_rgb_r_shift_32)) & 0xFF);
}
int getg32(int c) {
- return ((c >> _rgb_g_shift_32) & 0xFF);
+ return ((c >> _G(_rgb_g_shift_32)) & 0xFF);
}
int getb32(int c) {
- return ((c >> _rgb_b_shift_32) & 0xFF);
+ return ((c >> _G(_rgb_b_shift_32)) & 0xFF);
}
int geta32(int c) {
- return ((c >> _rgb_a_shift_32) & 0xFF);
+ return ((c >> _G(_rgb_a_shift_32)) & 0xFF);
}
int makecol(byte r, byte g, byte b) {
@@ -223,11 +202,11 @@ void unselect_palette(void) {
}
void set_blender_mode(BlenderMode m, int r, int g, int b, int a) {
- _blender_mode = m;
- trans_blend_alpha = a;
- trans_blend_red = r;
- trans_blend_green = g;
- trans_blend_blue = b;
+ _G(_blender_mode) = m;
+ _G(trans_blend_alpha) = a;
+ _G(trans_blend_red) = r;
+ _G(trans_blend_green) = g;
+ _G(trans_blend_blue) = b;
}
void set_alpha_blender(void) {
@@ -498,12 +477,12 @@ int bestfit_color(AL_CONST PALETTE pal, int r, int g, int b) {
/* makecol8:
* Converts R, G, and B values (ranging 0-255) to an 8 bit paletted color.
- * If the global rgb_map table is initialised, it uses that, otherwise
+ * If the global _G(rgb_map) table is initialised, it uses that, otherwise
* it searches through the current palette to find the best match.
*/
int makecol8(int r, int g, int b) {
- if (rgb_map)
- return rgb_map->data[r >> 3][g >> 3][b >> 3];
+ if (_G(rgb_map))
+ return _G(rgb_map)->data[r >> 3][g >> 3][b >> 3];
else
return bestfit_color(_current_palette, r >> 2, g >> 2, b >> 2);
}
@@ -840,7 +819,7 @@ void create_light_table(COLOR_MAP *table, AL_CONST PALETTE pal, int r, int g, in
assert(g >= 0 && g <= 63);
assert(b >= 0 && b <= 63);
- if (rgb_map) {
+ if (_G(rgb_map)) {
for (x = 0; x < PAL_SIZE - 1; x++) {
t1 = x * 0x010101;
t2 = 0xFFFFFF - t1;
@@ -854,7 +833,7 @@ void create_light_table(COLOR_MAP *table, AL_CONST PALETTE pal, int r, int g, in
g2 = (g1 + pal[y].g * t1) >> 25;
b2 = (b1 + pal[y].b * t1) >> 25;
- table->data[x][y] = rgb_map->data[r2][g2][b2];
+ table->data[x][y] = _G(rgb_map)->data[r2][g2][b2];
}
}
if (callback)
@@ -919,7 +898,7 @@ void create_trans_table(COLOR_MAP *table, AL_CONST PALETTE pal, int r, int g, in
if (b > 128)
b++;
- if (rgb_map)
+ if (_G(rgb_map))
add = 255;
else
add = 127;
@@ -938,12 +917,12 @@ void create_trans_table(COLOR_MAP *table, AL_CONST PALETTE pal, int r, int g, in
p = table->data[x];
q = tmp;
- if (rgb_map) {
+ if (_G(rgb_map)) {
for (y = 0; y < PAL_SIZE; y++) {
tr = (i + *(q++)) >> 9;
tg = (j + *(q++)) >> 9;
tb = (k + *(q++)) >> 9;
- p[y] = rgb_map->data[tr][tg][tb];
+ p[y] = _G(rgb_map)->data[tr][tg][tb];
}
} else {
for (y = 0; y < PAL_SIZE; y++) {
diff --git a/engines/ags/lib/allegro/color.h b/engines/ags/lib/allegro/color.h
index fbbaf23901..70e3be95d6 100644
--- a/engines/ags/lib/allegro/color.h
+++ b/engines/ags/lib/allegro/color.h
@@ -75,13 +75,6 @@ AL_VAR(PALETTE, black_palette);
AL_VAR(PALETTE, desktop_palette);
AL_VAR(PALETTE, default_palette);
-AL_VAR(RGB_MAP *, rgb_map);
-AL_VAR(COLOR_MAP *, color_map);
-extern int trans_blend_alpha;
-extern int trans_blend_red;
-extern int trans_blend_green;
-extern int trans_blend_blue;
-
enum BlenderMode {
kSourceAlphaBlender,
kArgbToArgbBlender,
@@ -95,26 +88,8 @@ enum BlenderMode {
kTintLightBlenderMode
};
-extern BlenderMode _blender_mode;
-
-AL_VAR(PALETTE, _current_palette);
-
-extern int _rgb_r_shift_15;
-extern int _rgb_g_shift_15;
-extern int _rgb_b_shift_15;
-extern int _rgb_r_shift_16;
-extern int _rgb_g_shift_16;
-extern int _rgb_b_shift_16;
-extern int _rgb_r_shift_24;
-extern int _rgb_g_shift_24;
-extern int _rgb_b_shift_24;
-extern int _rgb_r_shift_32;
-extern int _rgb_g_shift_32;
-extern int _rgb_b_shift_32;
-extern int _rgb_a_shift_32;
-
-AL_ARRAY(int, _rgb_scale_5);
-AL_ARRAY(int, _rgb_scale_6);
+AL_ARRAY(const int, _rgb_scale_5);
+AL_ARRAY(const int, _rgb_scale_6);
AL_FUNC(void, set_color, (int idx, AL_CONST RGB *p));
AL_FUNC(void, set_palette, (AL_CONST PALETTE p));
diff --git a/engines/ags/lib/allegro/gfx.cpp b/engines/ags/lib/allegro/gfx.cpp
index f61beb3159..26643528f9 100644
--- a/engines/ags/lib/allegro/gfx.cpp
+++ b/engines/ags/lib/allegro/gfx.cpp
@@ -24,6 +24,7 @@
#include "ags/lib/allegro/color.h"
#include "ags/lib/allegro/flood.h"
#include "ags/ags.h"
+#include "ags/globals.h"
#include "common/textconsole.h"
#include "graphics/screen.h"
@@ -146,13 +147,13 @@ void stretch_sprite(BITMAP *bmp, const BITMAP *sprite, int x, int y, int w, int
void draw_trans_sprite(BITMAP *bmp, const BITMAP *sprite, int x, int y) {
bmp->draw(sprite, Common::Rect(0, 0, sprite->w, sprite->h),
Common::Rect(x, y, x + sprite->w, y + sprite->h),
- false, false, true, trans_blend_alpha);
+ false, false, true, _G(trans_blend_alpha));
}
void draw_lit_sprite(BITMAP *bmp, const BITMAP *sprite, int x, int y, int color) {
bmp->draw(sprite, Common::Rect(0, 0, sprite->w, sprite->h),
Common::Rect(x, y, x + sprite->w, y + sprite->h),
- false, false, true, color, trans_blend_red, trans_blend_green, trans_blend_blue);
+ false, false, true, color, _G(trans_blend_red), _G(trans_blend_green), _G(trans_blend_blue));
}
void draw_sprite_h_flip(BITMAP *bmp, const BITMAP *sprite, int x, int y) {
diff --git a/engines/ags/lib/allegro/graphics.cpp b/engines/ags/lib/allegro/graphics.cpp
index 518c76a1f4..026204c323 100644
--- a/engines/ags/lib/allegro/graphics.cpp
+++ b/engines/ags/lib/allegro/graphics.cpp
@@ -28,7 +28,7 @@ namespace AGS3 {
int _color_depth;
/* lookup table for scaling 5 bit colors up to 8 bits */
-int _rgb_scale_5[32] = {
+const int _rgb_scale_5[32] = {
0, 8, 16, 24, 33, 41, 49, 57,
66, 74, 82, 90, 99, 107, 115, 123,
132, 140, 148, 156, 165, 173, 181, 189,
@@ -37,7 +37,7 @@ int _rgb_scale_5[32] = {
/* lookup table for scaling 6 bit colors up to 8 bits */
-int _rgb_scale_6[64] = {
+const int _rgb_scale_6[64] = {
0, 4, 8, 12, 16, 20, 24, 28,
32, 36, 40, 44, 48, 52, 56, 60,
65, 69, 73, 77, 81, 85, 89, 93,
diff --git a/engines/ags/lib/allegro/surface.cpp b/engines/ags/lib/allegro/surface.cpp
index 2888d5d76c..86388ba08a 100644
--- a/engines/ags/lib/allegro/surface.cpp
+++ b/engines/ags/lib/allegro/surface.cpp
@@ -24,6 +24,7 @@
#include "ags/lib/allegro/color.h"
#include "ags/lib/allegro/flood.h"
#include "ags/ags.h"
+#include "ags/globals.h"
#include "common/textconsole.h"
#include "graphics/screen.h"
@@ -215,7 +216,7 @@ void BITMAP::blendPixel(uint8 aSrc, uint8 rSrc, uint8 gSrc, uint8 bSrc, uint8 &a
bDest = bSrc;
return;
}
- switch(_blender_mode) {
+ switch(_G(_blender_mode)) {
case kSourceAlphaBlender:
blendSourceAlpha(aSrc, rSrc, gSrc, bSrc, aDest, rDest, gDest, bDest, alpha);
break;
Commit: 0a98eb1fc1e7ea46305bf98074225c35d6ee9d11
https://github.com/scummvm/scummvm/commit/0a98eb1fc1e7ea46305bf98074225c35d6ee9d11
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2021-03-07T08:52:15-08:00
Commit Message:
AGS: Moving more Allegro globals to Globals
Changed paths:
engines/ags/engine/ac/sys_events.cpp
engines/ags/engine/main/game_run.cpp
engines/ags/globals.h
engines/ags/lib/allegro/fixed.cpp
engines/ags/lib/allegro/fixed.h
engines/ags/lib/allegro/fmaths.h
engines/ags/lib/allegro/keyboard.cpp
engines/ags/lib/allegro/math.cpp
engines/ags/lib/allegro/mouse.cpp
engines/ags/lib/allegro/mouse.h
diff --git a/engines/ags/engine/ac/sys_events.cpp b/engines/ags/engine/ac/sys_events.cpp
index dba630c58a..fb6630561e 100644
--- a/engines/ags/engine/ac/sys_events.cpp
+++ b/engines/ags/engine/ac/sys_events.cpp
@@ -116,7 +116,7 @@ int ags_getch() {
/*if ((scancode >= KEY_0_PAD) && (scancode <= KEY_9_PAD)) {
// fix numeric pad keys if numlock is off (allegro 4.2 changed this behaviour)
- if ((key_shifts & KB_NUMLOCK_FLAG) == 0)
+ if ((_G(key_shifts) & KB_NUMLOCK_FLAG) == 0)
gott = (gott & 0xff00) | EXTENDED_KEY_CODE;
}*/
diff --git a/engines/ags/engine/main/game_run.cpp b/engines/ags/engine/main/game_run.cpp
index b83b433f84..c8fbee1ae3 100644
--- a/engines/ags/engine/main/game_run.cpp
+++ b/engines/ags/engine/main/game_run.cpp
@@ -272,10 +272,6 @@ static void check_mouse_controls() {
}
// Returns current key modifiers;
-// NOTE: annoyingly enough, on Windows (not sure about other platforms)
-// Allegro API's 'key_shifts' variable seem to be always one step behind real
-// situation: if first modifier gets pressed, 'key_shifts' will be zero,
-// when second modifier gets pressed it will only contain first one, and so on.
static int get_active_shifts() {
return ::AGS::g_events->getModifierFlags();
}
diff --git a/engines/ags/globals.h b/engines/ags/globals.h
index 526f0bca8d..97457a4b0a 100644
--- a/engines/ags/globals.h
+++ b/engines/ags/globals.h
@@ -32,6 +32,7 @@
#include "ags/lib/std/set.h"
#include "ags/lib/allegro/fixed.h"
#include "ags/lib/allegro/aintern.h"
+#include "common/events.h"
namespace AGS3 {
diff --git a/engines/ags/lib/allegro/fixed.cpp b/engines/ags/lib/allegro/fixed.cpp
index 29ac103c37..f05588c196 100644
--- a/engines/ags/lib/allegro/fixed.cpp
+++ b/engines/ags/lib/allegro/fixed.cpp
@@ -25,9 +25,6 @@
namespace AGS3 {
-fixed fixtorad_r;
-fixed radtofix_r;
-
fixed ftofix(double x) {
if (x > 32767.0) {
*allegro_errno = AL_ERANGE;
diff --git a/engines/ags/lib/allegro/fixed.h b/engines/ags/lib/allegro/fixed.h
index d658c6d817..fbd16d96e9 100644
--- a/engines/ags/lib/allegro/fixed.h
+++ b/engines/ags/lib/allegro/fixed.h
@@ -30,11 +30,9 @@ namespace AGS3 {
typedef int32_t fixed;
-extern fixed fixtorad_r;
-extern fixed radtofix_r;
-extern fixed _cos_tbl[];
-extern fixed _tan_tbl[];
-extern fixed _acos_tbl[];
+extern const fixed _cos_tbl[];
+extern const fixed _tan_tbl[];
+extern const fixed _acos_tbl[];
extern fixed ftofix(double x);
extern double fixtof(fixed x);
diff --git a/engines/ags/lib/allegro/fmaths.h b/engines/ags/lib/allegro/fmaths.h
index 0aad8c5a1c..ba119dfe62 100644
--- a/engines/ags/lib/allegro/fmaths.h
+++ b/engines/ags/lib/allegro/fmaths.h
@@ -32,9 +32,9 @@ AL_FUNC(fixed, fixhypot, (fixed x, fixed y));
AL_FUNC(fixed, fixatan, (fixed x));
AL_FUNC(fixed, fixatan2, (fixed y, fixed x));
-AL_ARRAY(fixed, _cos_tbl);
-AL_ARRAY(fixed, _tan_tbl);
-AL_ARRAY(fixed, _acos_tbl);
+AL_ARRAY(const fixed, _cos_tbl);
+AL_ARRAY(const fixed, _tan_tbl);
+AL_ARRAY(const fixed, _acos_tbl);
} // namespace AGS3
diff --git a/engines/ags/lib/allegro/keyboard.cpp b/engines/ags/lib/allegro/keyboard.cpp
index 869ca1655a..0ff4edc2b7 100644
--- a/engines/ags/lib/allegro/keyboard.cpp
+++ b/engines/ags/lib/allegro/keyboard.cpp
@@ -21,21 +21,17 @@
*/
#include "ags/lib/allegro/keyboard.h"
+#include "ags/events.h"
+#include "ags/globals.h"
#include "common/algorithm.h"
#include "common/textconsole.h"
#include "common/system.h"
#include "common/events.h"
#include "common/textconsole.h"
-#include "ags/events.h"
namespace AGS3 {
-bool key[Common::KEYCODE_LAST];
-uint key_shifts;
-
int install_keyboard() {
- Common::fill(&key[0], &key[Common::KEYCODE_LAST], false);
- key_shifts = 0;
return 0;
}
diff --git a/engines/ags/lib/allegro/math.cpp b/engines/ags/lib/allegro/math.cpp
index 64617e2b56..7c293b8c72 100644
--- a/engines/ags/lib/allegro/math.cpp
+++ b/engines/ags/lib/allegro/math.cpp
@@ -28,7 +28,7 @@
namespace AGS3 {
-fixed _cos_tbl[512] = {
+const fixed _cos_tbl[512] = {
/* precalculated fixed point (16.16) cosines for a full circle (0-255) */
65536L, 65531L, 65516L, 65492L, 65457L, 65413L, 65358L, 65294L,
@@ -97,7 +97,7 @@ fixed _cos_tbl[512] = {
65220L, 65294L, 65358L, 65413L, 65457L, 65492L, 65516L, 65531L
};
-fixed _tan_tbl[256] = {
+const fixed _tan_tbl[256] = {
/* precalculated fixed point (16.16) tangents for a half circle (0-127) */
0L, 804L, 1609L, 2414L, 3220L, 4026L, 4834L, 5644L,
@@ -134,7 +134,7 @@ fixed _tan_tbl[256] = {
-6455L, -5644L, -4834L, -4026L, -3220L, -2414L, -1609L, -804L
};
-fixed _acos_tbl[513] = {
+const fixed _acos_tbl[513] = {
/* precalculated fixed point (16.16) inverse cosines (-1 to 1) */
0x800000L, 0x7C65C7L, 0x7AE75AL, 0x79C19EL, 0x78C9BEL, 0x77EF25L, 0x772953L, 0x76733AL,
diff --git a/engines/ags/lib/allegro/mouse.cpp b/engines/ags/lib/allegro/mouse.cpp
index b5cc5ab7ee..fd0d34ff2e 100644
--- a/engines/ags/lib/allegro/mouse.cpp
+++ b/engines/ags/lib/allegro/mouse.cpp
@@ -26,8 +26,6 @@
namespace AGS3 {
-MOUSE_DRIVER mousedrv_none;
-MOUSE_DRIVER *mouse_driver;
_DRIVER_INFO _mouse_driver_list[] = {
{ 0, nullptr, 0 }
};
diff --git a/engines/ags/lib/allegro/mouse.h b/engines/ags/lib/allegro/mouse.h
index a063b7e7ea..b6b832c921 100644
--- a/engines/ags/lib/allegro/mouse.h
+++ b/engines/ags/lib/allegro/mouse.h
@@ -51,8 +51,6 @@ struct MOUSE_DRIVER {
AL_METHOD(int, select_system_cursor, (int cursor));
};
-AL_VAR(MOUSE_DRIVER, mousedrv_none);
-AL_VAR(MOUSE_DRIVER *, mouse_driver);
AL_ARRAY(_DRIVER_INFO, _mouse_driver_list);
AL_FUNC(int, install_mouse, (void));
Commit: ab84798f9aedec73a03660ca4b91b85a575820d1
https://github.com/scummvm/scummvm/commit/ab84798f9aedec73a03660ca4b91b85a575820d1
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2021-03-07T08:52:15-08:00
Commit Message:
AGS: Removing unneeded Allegro driver classes
Changed paths:
engines/ags/engine/main/engine.cpp
engines/ags/lib/allegro/base.h
engines/ags/lib/allegro/mouse.cpp
engines/ags/lib/allegro/mouse.h
engines/ags/lib/allegro/system.cpp
engines/ags/lib/allegro/system.h
diff --git a/engines/ags/engine/main/engine.cpp b/engines/ags/engine/main/engine.cpp
index 02f97d8c86..1067ce65c5 100644
--- a/engines/ags/engine/main/engine.cpp
+++ b/engines/ags/engine/main/engine.cpp
@@ -1125,17 +1125,6 @@ static void engine_print_info(const std::set<String> &keys, const String &exe_pa
platform->WriteStdOut("%s", full.GetCStr());
}
-// Custom resource search callback for Allegro's system driver.
-// It helps us direct Allegro to our game data location, because it won't know.
-static int al_find_resource(char *dest, const char *resource, int dest_size) {
- String path = Path::ConcatPaths(get_install_dir(), resource);
- if (File::TestReadFile(path)) {
- snprintf(dest, dest_size, "%s", path.GetCStr());
- return 0;
- }
- return -1;
-}
-
// TODO: this function is still a big mess, engine/system-related initialization
// is mixed with game-related data adjustments. Divide it in parts, move game
// data init into either InitGameState() or other game method as appropriate.
@@ -1192,9 +1181,6 @@ int initialize_engine(const ConfigTree &startup_opts) {
our_eip = -193;
- // Assign custom find resource callback for limited Allegro operations
- system_driver->find_resource = al_find_resource;
-
//-----------------------------------------------------
// Begin setting up systems
engine_setup_window();
diff --git a/engines/ags/lib/allegro/base.h b/engines/ags/lib/allegro/base.h
index 1be1a12797..e85f4f7bfe 100644
--- a/engines/ags/lib/allegro/base.h
+++ b/engines/ags/lib/allegro/base.h
@@ -44,15 +44,6 @@ namespace AGS3 {
#define AL_ID MKTAG
-/**
- * info about a hardware driver
- */
-struct _DRIVER_INFO {
- int id; /* integer ID */
- void *driver; /* the driver structure */
- int autodetect; /* set to allow autodetection */
-};
-
#define AL_FUNC(type, name, args) type name args
#define SCUMMVM_ID MKTAG('S', 'C', 'V', 'M')
diff --git a/engines/ags/lib/allegro/mouse.cpp b/engines/ags/lib/allegro/mouse.cpp
index fd0d34ff2e..9dcbf9df48 100644
--- a/engines/ags/lib/allegro/mouse.cpp
+++ b/engines/ags/lib/allegro/mouse.cpp
@@ -26,10 +26,6 @@
namespace AGS3 {
-_DRIVER_INFO _mouse_driver_list[] = {
- { 0, nullptr, 0 }
-};
-
BITMAP *mouse_sprite;
int mouse_x_focus;
int mouse_y_focus;
diff --git a/engines/ags/lib/allegro/mouse.h b/engines/ags/lib/allegro/mouse.h
index b6b832c921..7cfb082aa3 100644
--- a/engines/ags/lib/allegro/mouse.h
+++ b/engines/ags/lib/allegro/mouse.h
@@ -33,26 +33,6 @@ namespace AGS3 {
#define MOUSEDRV_AUTODETECT -1
#define MOUSEDRV_NONE 0
-struct MOUSE_DRIVER {
- int id;
- AL_CONST char *name;
- AL_CONST char *desc;
- AL_CONST char *ascii_name;
- AL_METHOD(int, init, (void));
- AL_METHOD(void, exit, (void));
- AL_METHOD(void, poll, (void));
- AL_METHOD(void, timer_poll, (void));
- AL_METHOD(void, position, (int x, int y));
- AL_METHOD(void, set_range, (int x1, int y_1, int x2, int y2));
- AL_METHOD(void, set_speed, (int xspeed, int yspeed));
- AL_METHOD(void, get_mickeys, (int *mickeyx, int *mickeyy));
- AL_METHOD(int, analyse_data, (AL_CONST char *buffer, int size));
- AL_METHOD(void, enable_hardware_cursor, (int mode));
- AL_METHOD(int, select_system_cursor, (int cursor));
-};
-
-AL_ARRAY(_DRIVER_INFO, _mouse_driver_list);
-
AL_FUNC(int, install_mouse, (void));
AL_FUNC(void, remove_mouse, (void));
diff --git a/engines/ags/lib/allegro/system.cpp b/engines/ags/lib/allegro/system.cpp
index d256e0f813..219734e4e7 100644
--- a/engines/ags/lib/allegro/system.cpp
+++ b/engines/ags/lib/allegro/system.cpp
@@ -26,59 +26,6 @@
namespace AGS3 {
-SYSTEM_DRIVER system_none;
-
-SYSTEM_DRIVER system_scummvm = {
- SYSTEM_SCUMMVM,
- nullptr,
- nullptr,
- "ScummVM Device",
- nullptr, // TODO: ios_sys_init,
- nullptr, // TODO: ios_sys_exit,
- nullptr, /* AL_METHOD(void, get_executable_name, (char *output, int size)); */
- nullptr, /* AL_METHOD(int, find_resource, (char *dest, AL_CONST char *resource, int size)); */
- nullptr, /* AL_METHOD(void, set_window_title, (AL_CONST char *name)); */
- nullptr, /* AL_METHOD(int, set_close_button_callback, (AL_METHOD(void, proc, (void)))); */
- nullptr, /* AL_METHOD(void, message, (AL_CONST char *msg)); */
- nullptr, /* AL_METHOD(void, assert, (AL_CONST char *msg)); */
- nullptr, /* AL_METHOD(void, save_console_state, (void)); */
- nullptr, /* AL_METHOD(void, restore_console_state, (void)); */
- nullptr, /* AL_METHOD(struct BITMAP *, create_bitmap, (int color_depth, int width, int height)); */
- nullptr, /* AL_METHOD(void, created_bitmap, (struct BITMAP *bmp)); */
- nullptr, /* AL_METHOD(struct BITMAP *, create_sub_bitmap, (struct BITMAP *parent, int x, int y, int width, int height)); */
- nullptr, /* AL_METHOD(void, created_sub_bitmap, (struct BITMAP *bmp, struct BITMAP *parent)); */
- nullptr, /* AL_METHOD(int, destroy_bitmap, (struct BITMAP *bitmap)); */
- nullptr, /* AL_METHOD(void, read_hardware_palette, (void)); */
- nullptr, /* AL_METHOD(void, set_palette_range, (AL_CONST struct RGB *p, int from, int to, int retracesync)); */
- nullptr, /* AL_METHOD(struct GFX_VTABLE *, get_vtable, (int color_depth)); */
- nullptr, /* AL_METHOD(int, set_display_switch_mode, (int mode)); */
- nullptr, /* AL_METHOD(void, display_switch_lock, (int lock, int foreground)); */
- nullptr, /* AL_METHOD(int, desktop_color_depth, (void)); */
- nullptr, /* AL_METHOD(int, get_desktop_resolution, (int *width, int *height)); */
- nullptr, // TODO: ios_get_gfx_safe_mode, /*AL_METHOD(void, get_gfx_safe_mode, (int *driver, struct GFX_MODE *mode));*/
- nullptr, /* AL_METHOD(void, yield_timeslice, (void)); */
- nullptr, // TODO: _ios_create_mutex, /* AL_METHOD(void *, create_mutex, (void)); */
- nullptr, // TODO: _ios_destroy_mutex, /* AL_METHOD(void, destroy_mutex, (void *handle)); */
- nullptr, // TODO: _ios_lock_mutex, /* AL_METHOD(void, lock_mutex, (void *handle)); */
- nullptr, // TODO: _ios_unlock_mutex, /* AL_METHOD(void, unlock_mutex, (void *handle)); */
- nullptr, /* AL_METHOD(_DRIVER_INFO *, gfx_drivers, (void)); */
- nullptr, /* AL_METHOD(_DRIVER_INFO *, digi_drivers, (void)); */
- nullptr, /* AL_METHOD(_DRIVER_INFO *, midi_drivers, (void)); */
- nullptr, /* AL_METHOD(_DRIVER_INFO *, keyboard_drivers, (void)); */
- nullptr, /* AL_METHOD(_DRIVER_INFO *, mouse_drivers, (void)); */
- nullptr, /* AL_METHOD(_DRIVER_INFO *, joystick_drivers, (void)); */
- nullptr /* AL_METHOD(_DRIVER_INFO *, timer_drivers, (void)); */
-};
-
-_DRIVER_INFO _system_driver_list[] = {
- { SYSTEM_SCUMMVM, &system_scummvm, true },
- { SYSTEM_NONE, &system_none, false },
- { 0, nullptr , 0 }
-};
-
-SYSTEM_DRIVER *system_driver = &system_scummvm;
-
-
GFX_MODE_LIST *get_gfx_mode_list(int card) {
GFX_MODE_LIST *list = new GFX_MODE_LIST();
list->num_modes = 1;
diff --git a/engines/ags/lib/allegro/system.h b/engines/ags/lib/allegro/system.h
index bea3b36752..50ff9e5981 100644
--- a/engines/ags/lib/allegro/system.h
+++ b/engines/ags/lib/allegro/system.h
@@ -92,13 +92,6 @@ struct SYSTEM_DRIVER {
AL_METHOD(void, destroy_mutex, (void *handle));
AL_METHOD(void, lock_mutex, (void *handle));
AL_METHOD(void, unlock_mutex, (void *handle));
- AL_METHOD(_DRIVER_INFO *, gfx_drivers, (void));
- AL_METHOD(_DRIVER_INFO *, digi_drivers, (void));
- AL_METHOD(_DRIVER_INFO *, midi_drivers, (void));
- AL_METHOD(_DRIVER_INFO *, keyboard_drivers, (void));
- AL_METHOD(_DRIVER_INFO *, mouse_drivers, (void));
- AL_METHOD(_DRIVER_INFO *, joystick_drivers, (void));
- AL_METHOD(_DRIVER_INFO *, timer_drivers, (void));
};
/* creates and manages the screen bitmap */
@@ -139,10 +132,6 @@ struct GFX_DRIVER {
int windowed; /* true if driver runs windowed */
};
-extern SYSTEM_DRIVER system_none;
-extern SYSTEM_DRIVER *system_driver;
-extern _DRIVER_INFO _system_driver_list[];
-
extern void set_color_depth(int depth);
extern int get_color_depth();
extern int get_desktop_resolution(int32_t *width, int32_t *height);
Commit: 8a901688198200d31b835e61508efac3e4224208
https://github.com/scummvm/scummvm/commit/8a901688198200d31b835e61508efac3e4224208
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2021-03-07T08:52:15-08:00
Commit Message:
AGS: Move remainder of Allegro globals to Globals
Changed paths:
engines/ags/engine/ac/room.cpp
engines/ags/engine/ac/sys_events.cpp
engines/ags/engine/device/mousew32.cpp
engines/ags/globals.h
engines/ags/lib/allegro/aintern.h
engines/ags/lib/allegro/color.cpp
engines/ags/lib/allegro/graphics.cpp
engines/ags/lib/allegro/mouse.cpp
engines/ags/lib/allegro/mouse.h
engines/ags/lib/allegro/system.cpp
engines/ags/lib/allegro/unicode.cpp
diff --git a/engines/ags/engine/ac/room.cpp b/engines/ags/engine/ac/room.cpp
index c07e8afe1f..d9e245cab4 100644
--- a/engines/ags/engine/ac/room.cpp
+++ b/engines/ags/engine/ac/room.cpp
@@ -969,7 +969,7 @@ int find_highest_room_entered() {
void first_room_initialization() {
starting_room = displayed_room;
set_loop_counter(0);
- mouse_z_was = mouse_z;
+ mouse_z_was = _G(mouse_z);
}
void check_new_room() {
diff --git a/engines/ags/engine/ac/sys_events.cpp b/engines/ags/engine/ac/sys_events.cpp
index fb6630561e..2ec07282ff 100644
--- a/engines/ags/engine/ac/sys_events.cpp
+++ b/engines/ags/engine/ac/sys_events.cpp
@@ -87,12 +87,12 @@ void ags_domouse(int what) {
int ags_check_mouse_wheel() {
int result = 0;
- if ((mouse_z != mouse_z_was) && (_GP(game).options[OPT_MOUSEWHEEL] != 0)) {
- if (mouse_z > mouse_z_was)
+ if ((_G(mouse_z) != mouse_z_was) && (_GP(game).options[OPT_MOUSEWHEEL] != 0)) {
+ if (_G(mouse_z) > mouse_z_was)
result = 1;
else
result = -1;
- mouse_z_was = mouse_z;
+ mouse_z_was = _G(mouse_z);
}
return result;
}
diff --git a/engines/ags/engine/device/mousew32.cpp b/engines/ags/engine/device/mousew32.cpp
index 8467bf5f0d..6c96f935f8 100644
--- a/engines/ags/engine/device/mousew32.cpp
+++ b/engines/ags/engine/device/mousew32.cpp
@@ -157,8 +157,8 @@ void mgetgraphpos() {
return;
} else {
// Save real cursor coordinates provided by system
- _G(real_mouse_x) = mouse_x;
- _G(real_mouse_y) = mouse_y;
+ _G(real_mouse_x) = _G(mouse_x);
+ _G(real_mouse_y) = _G(mouse_y);
}
// Set new in-game cursor position
@@ -237,7 +237,7 @@ int butwas = 0;
int mgetbutton() {
int toret = NONE;
poll_mouse();
- int butis = mouse_b;
+ int butis = _G(mouse_b);
if ((butis > 0) &(butwas > 0))
return NONE; // don't allow holding button down
@@ -262,7 +262,7 @@ int mgetbutton() {
const int MB_ARRAY[3] = { 1, 2, 4 };
int misbuttondown(int buno) {
poll_mouse();
- if (mouse_b & MB_ARRAY[buno])
+ if (_G(mouse_b) & MB_ARRAY[buno])
return TRUE;
return FALSE;
}
diff --git a/engines/ags/globals.h b/engines/ags/globals.h
index 97457a4b0a..96c430f48f 100644
--- a/engines/ags/globals.h
+++ b/engines/ags/globals.h
@@ -129,6 +129,7 @@ public:
* @{
*/
+ int __color_depth = 0;
int __rgb_r_shift_15 = DEFAULT_RGB_R_SHIFT_15; /* truecolor pixel format */
int __rgb_g_shift_15 = DEFAULT_RGB_G_SHIFT_15;
int __rgb_b_shift_15 = DEFAULT_RGB_B_SHIFT_15;
@@ -151,6 +152,14 @@ public:
int _trans_blend_blue = 0;
BlenderMode __blender_mode = kRgbToRgbBlender;
+ volatile int _mouse_x = 0; // X position
+ volatile int _mouse_y = 0; // Y position
+ volatile int _mouse_z = 0; // Mouse wheel vertical
+ volatile int _mouse_b = 0; // Mouse buttons bitflags
+ volatile int _mouse_pos = 0; // X position in upper 16 bits, Y in lower 16
+
+ volatile int freeze_mouse_flag;
+
/**@}*/
/**
diff --git a/engines/ags/lib/allegro/aintern.h b/engines/ags/lib/allegro/aintern.h
index c85f2beab2..e54488ccdb 100644
--- a/engines/ags/lib/allegro/aintern.h
+++ b/engines/ags/lib/allegro/aintern.h
@@ -43,8 +43,6 @@
namespace AGS3 {
-extern int _color_depth;
-
} // namespace AGS3
#endif
diff --git a/engines/ags/lib/allegro/color.cpp b/engines/ags/lib/allegro/color.cpp
index 60164c78f2..0dc2c0a013 100644
--- a/engines/ags/lib/allegro/color.cpp
+++ b/engines/ags/lib/allegro/color.cpp
@@ -373,7 +373,7 @@ int geta_depth(int color_depth, int c) {
* being used by the current video mode.
*/
int getr(int c) {
- return getr_depth(_color_depth, c);
+ return getr_depth(_G(_color_depth), c);
}
@@ -383,7 +383,7 @@ int getr(int c) {
* being used by the current video mode.
*/
int getg(int c) {
- return getg_depth(_color_depth, c);
+ return getg_depth(_G(_color_depth), c);
}
@@ -393,7 +393,7 @@ int getg(int c) {
* being used by the current video mode.
*/
int getb(int c) {
- return getb_depth(_color_depth, c);
+ return getb_depth(_G(_color_depth), c);
}
@@ -403,7 +403,7 @@ int getb(int c) {
* being used by the current video mode.
*/
int geta(int c) {
- return geta_depth(_color_depth, c);
+ return geta_depth(_G(_color_depth), c);
}
diff --git a/engines/ags/lib/allegro/graphics.cpp b/engines/ags/lib/allegro/graphics.cpp
index 026204c323..ed27d4fdcd 100644
--- a/engines/ags/lib/allegro/graphics.cpp
+++ b/engines/ags/lib/allegro/graphics.cpp
@@ -25,8 +25,6 @@
namespace AGS3 {
-int _color_depth;
-
/* lookup table for scaling 5 bit colors up to 8 bits */
const int _rgb_scale_5[32] = {
0, 8, 16, 24, 33, 41, 49, 57,
diff --git a/engines/ags/lib/allegro/mouse.cpp b/engines/ags/lib/allegro/mouse.cpp
index 9dcbf9df48..65a4f50db8 100644
--- a/engines/ags/lib/allegro/mouse.cpp
+++ b/engines/ags/lib/allegro/mouse.cpp
@@ -22,23 +22,11 @@
#include "ags/lib/allegro/mouse.h"
#include "ags/events.h"
+#include "ags/globals.h"
#include "common/textconsole.h"
namespace AGS3 {
-BITMAP *mouse_sprite;
-int mouse_x_focus;
-int mouse_y_focus;
-
-volatile int mouse_x; // X position
-volatile int mouse_y; // Y position
-volatile int mouse_z; // Mouse wheel vertical
-volatile int mouse_w; // Mouse wheel horizontal
-volatile int mouse_b; // Mouse buttons bitflags
-volatile int mouse_pos; // X position in upper 16 bits, Y in lower 16
-
-volatile int freeze_mouse_flag;
-
static bool isMouseButtonDown(Common::EventType type) {
return type == Common::EVENT_LBUTTONDOWN || type == Common::EVENT_MBUTTONDOWN ||
type == Common::EVENT_RBUTTONDOWN;
@@ -60,9 +48,9 @@ static bool isMouseEvent(Common::EventType type) {
int install_mouse() {
- mouse_x = mouse_y = mouse_z = 0;
- mouse_w = mouse_b = 0;
- mouse_pos = 0;
+ _G(mouse_x) = _G(mouse_y) = _G(mouse_z) = 0;
+ _G(mouse_b) = 0;
+ _G(mouse_pos) = 0;
return 0;
}
@@ -76,35 +64,35 @@ int poll_mouse() {
Common::Event e;
while ((e = ::AGS::g_events->readEvent()).type != Common::EVENT_INVALID) {
if (isMouseEvent(e.type)) {
- mouse_x = e.mouse.x;
- mouse_y = e.mouse.y;
- mouse_pos = (e.mouse.x << 16) | e.mouse.y;
+ _G(mouse_x) = e.mouse.x;
+ _G(mouse_y) = e.mouse.y;
+ _G(mouse_pos) = (e.mouse.x << 16) | e.mouse.y;
}
switch (e.type) {
case Common::EVENT_LBUTTONDOWN:
- mouse_b |= 1;
+ _G(mouse_b) |= 1;
break;
case Common::EVENT_LBUTTONUP:
- mouse_b &= ~1;
+ _G(mouse_b) &= ~1;
break;
case Common::EVENT_RBUTTONDOWN:
- mouse_b |= 2;
+ _G(mouse_b) |= 2;
break;
case Common::EVENT_RBUTTONUP:
- mouse_b &= ~2;
+ _G(mouse_b) &= ~2;
break;
case Common::EVENT_MBUTTONDOWN:
- mouse_b |= 4;
+ _G(mouse_b) |= 4;
break;
case Common::EVENT_MBUTTONUP:
- mouse_b &= ~4;
+ _G(mouse_b) &= ~4;
break;
case Common::EVENT_WHEELDOWN:
- ++mouse_z;
+ ++_G(mouse_z);
break;
case Common::EVENT_WHEELUP:
- --mouse_z;
+ --_G(mouse_z);
break;
default:
break;
@@ -139,18 +127,14 @@ void unscare_mouse() {
}
void position_mouse(int x, int y) {
- mouse_x = x;
- mouse_y = y;
- mouse_pos = (x << 16) | y;
+ _G(mouse_x) = x;
+ _G(mouse_y) = y;
+ _G(mouse_pos) = (x << 16) | y;
::AGS::g_events->warpMouse(Common::Point(x, y));
}
void position_mouse_z(int z) {
- mouse_z = z;
-}
-
-void position_mouse_w(int w) {
- mouse_w = w;
+ _G(mouse_z) = z;
}
void set_mouse_range(int x1, int y_1, int x2, int y2) {
diff --git a/engines/ags/lib/allegro/mouse.h b/engines/ags/lib/allegro/mouse.h
index 7cfb082aa3..e45b4b824f 100644
--- a/engines/ags/lib/allegro/mouse.h
+++ b/engines/ags/lib/allegro/mouse.h
@@ -51,19 +51,6 @@ AL_FUNC(void, disable_hardware_cursor, (void));
#define MOUSE_CURSOR_EDIT 5
#define AL_NUM_MOUSE_CURSORS 6
-AL_VAR(BITMAP *, mouse_sprite);
-AL_VAR(int, mouse_x_focus);
-AL_VAR(int, mouse_y_focus);
-
-AL_VAR(volatile int, mouse_x);
-AL_VAR(volatile int, mouse_y);
-AL_VAR(volatile int, mouse_z);
-AL_VAR(volatile int, mouse_w);
-AL_VAR(volatile int, mouse_b);
-AL_VAR(volatile int, mouse_pos);
-
-AL_VAR(volatile int, freeze_mouse_flag);
-
#define MOUSE_FLAG_MOVE 1
#define MOUSE_FLAG_LEFT_DOWN 2
#define MOUSE_FLAG_LEFT_UP 4
@@ -82,7 +69,6 @@ AL_FUNC(void, scare_mouse_area, (int x, int y, int w, int h));
AL_FUNC(void, unscare_mouse, (void));
AL_FUNC(void, position_mouse, (int x, int y));
AL_FUNC(void, position_mouse_z, (int z));
-AL_FUNC(void, position_mouse_w, (int w));
AL_FUNC(void, set_mouse_range, (int x1, int y_1, int x2, int y2));
AL_FUNC(void, set_mouse_speed, (int xspeed, int yspeed));
AL_FUNC(void, select_mouse_cursor, (int cursor));
diff --git a/engines/ags/lib/allegro/system.cpp b/engines/ags/lib/allegro/system.cpp
index 219734e4e7..b428f9dad4 100644
--- a/engines/ags/lib/allegro/system.cpp
+++ b/engines/ags/lib/allegro/system.cpp
@@ -22,6 +22,7 @@
#include "ags/lib/allegro/system.h"
#include "ags/lib/allegro/aintern.h"
+#include "ags/globals.h"
#include "common/system.h"
namespace AGS3 {
@@ -45,11 +46,11 @@ void destroy_gfx_mode_list(GFX_MODE_LIST *list) {
}
void set_color_depth(int depth) {
- _color_depth = depth;
+ _G(_color_depth) = depth;
}
int get_color_depth() {
- return _color_depth;
+ return _G(_color_depth);
}
int get_desktop_resolution(int32_t *width, int32_t *height) {
diff --git a/engines/ags/lib/allegro/unicode.cpp b/engines/ags/lib/allegro/unicode.cpp
index 4c70f2fc6e..1ddd069067 100644
--- a/engines/ags/lib/allegro/unicode.cpp
+++ b/engines/ags/lib/allegro/unicode.cpp
@@ -33,5 +33,4 @@ size_t ustrsize(const char *s) {
return strlen(s);
}
-
} // namespace AGS3
More information about the Scummvm-git-logs
mailing list