AGS: Move remainder of Allegro globals to Globals

This commit is contained in:
Paul Gilbert 2021-03-07 08:45:00 -08:00
parent ab84798f9a
commit 8a90168819
11 changed files with 43 additions and 68 deletions

View File

@ -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() {

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
/**@}*/
/**

View File

@ -43,8 +43,6 @@
namespace AGS3 {
extern int _color_depth;
} // namespace AGS3
#endif

View File

@ -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);
}

View File

@ -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,

View File

@ -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) {

View File

@ -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));

View File

@ -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) {

View File

@ -33,5 +33,4 @@ size_t ustrsize(const char *s) {
return strlen(s);
}
} // namespace AGS3