mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-06 06:32:56 +01:00
Move input functions and add an address
This commit is contained in:
@@ -169,8 +169,10 @@
|
||||
#define RCT2_ADDRESS_DSOUND_DEVICES_COUNTER 0x009E2BAC
|
||||
|
||||
#define RCT2_ADDRESS_CMDLINE 0x009E2D98
|
||||
#define RCT2_ADDRESS_MOUSE_READ_INDEX 0x009E2DE8
|
||||
#define RCT2_ADDRESS_MOUSE_WRITE_INDEX 0x009E2DE4
|
||||
|
||||
#define RCT2_ADDRESS_MOUSE_READ_INDEX 0x009E2DE8
|
||||
#define RCT2_ADDRESS_MOUSE_WRITE_INDEX 0x009E2DE4
|
||||
|
||||
#define RCT2_ADDRESS_LAND_RAISE_COST 0x009E2E1C
|
||||
#define RCT2_ADDRESS_LAND_LOWER_COST 0x009E2E20
|
||||
#define RCT2_ADDRESS_SELECTED_TERRAIN_EDGE 0x009E2E24
|
||||
@@ -406,6 +408,8 @@
|
||||
#define RCT2_ADDRESS_SCREEN_CAP_BPP 0x01423C10
|
||||
#define RCT2_ADDRESS_SCREEN_CAP_RASTER_STRETCH 0x01423C14
|
||||
|
||||
#define RCT2_ADDRESS_INPUT_QUEUE 0x01424340
|
||||
|
||||
static void RCT2_CALLPROC_EBPSAFE(int address)
|
||||
{
|
||||
#ifdef _MSC_VER
|
||||
|
||||
47
src/input.c
47
src/input.c
@@ -36,6 +36,13 @@
|
||||
|
||||
POINT _dragPosition;
|
||||
|
||||
typedef struct {
|
||||
uint32 x, y;
|
||||
uint32 state; //1 = LeftDown 2 = LeftUp 3 = RightDown 4 = RightUp
|
||||
} rct_mouse_data;
|
||||
|
||||
rct_mouse_data* mouse_buffer = RCT2_ADDRESS(RCT2_ADDRESS_INPUT_QUEUE, rct_mouse_data);
|
||||
|
||||
static void game_get_next_input(int *x, int *y, int *state);
|
||||
static void input_mouseover(int x, int y, rct_window *w, int widgetIndex);
|
||||
static void input_mouseover_widget_check(rct_windowclass windowClass, rct_windownumber windowNumber, int widgetIndex);
|
||||
@@ -43,7 +50,7 @@ static void input_mouseover_widget_flatbutton_invalidate();
|
||||
void process_mouse_over(int x, int y);
|
||||
void sub_6ED801(int x, int y);
|
||||
void invalidate_scroll();
|
||||
static openrct2_mouse_data* get_mouse_input();
|
||||
static rct_mouse_data* get_mouse_input();
|
||||
|
||||
#pragma region Scroll bar input
|
||||
|
||||
@@ -1558,7 +1565,7 @@ void game_handle_input()
|
||||
*/
|
||||
static void game_get_next_input(int *x, int *y, int *state)
|
||||
{
|
||||
openrct2_mouse_data* eax = get_mouse_input();
|
||||
rct_mouse_data* eax = get_mouse_input();
|
||||
if (eax == NULL) {
|
||||
*x = gCursorState.x;
|
||||
*y = gCursorState.y;
|
||||
@@ -1764,16 +1771,38 @@ void invalidate_scroll()
|
||||
window_invalidate_by_id(RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DOWN_WINDOWCLASS, uint8), RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DOWN_WINDOWNUMBER, uint16));
|
||||
}
|
||||
|
||||
/**
|
||||
* rct2: 0x00406C96
|
||||
*/
|
||||
void store_mouse_input(int state)
|
||||
{
|
||||
uint32 write_index = RCT2_GLOBAL(RCT2_ADDRESS_MOUSE_WRITE_INDEX, uint32);
|
||||
uint32 next_write_index = (write_index + 1) % 64;
|
||||
|
||||
// check if the queue is full
|
||||
if (next_write_index == RCT2_GLOBAL(RCT2_ADDRESS_MOUSE_READ_INDEX, uint32))
|
||||
return;
|
||||
|
||||
rct_mouse_data* item = &mouse_buffer[write_index];
|
||||
item->x = RCT2_GLOBAL(0x01424318, uint32);
|
||||
item->y = RCT2_GLOBAL(0x0142431C, uint32);
|
||||
item->state = state;
|
||||
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_MOUSE_WRITE_INDEX, uint32) = next_write_index;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* rct2: 0x00407074
|
||||
*/
|
||||
static openrct2_mouse_data* get_mouse_input()
|
||||
static rct_mouse_data* get_mouse_input()
|
||||
{
|
||||
int read_index = RCT2_GLOBAL(RCT2_ADDRESS_MOUSE_READ_INDEX, uint32);
|
||||
if (read_index != RCT2_GLOBAL(RCT2_ADDRESS_MOUSE_WRITE_INDEX, uint32)) {
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_MOUSE_READ_INDEX, uint32) = (read_index + 1) & 0x3F;
|
||||
return &mouse_buffer[read_index];
|
||||
} else {
|
||||
uint32 read_index = RCT2_GLOBAL(RCT2_ADDRESS_MOUSE_READ_INDEX, uint32);
|
||||
|
||||
// check if that location has been written to yet
|
||||
if (read_index == RCT2_GLOBAL(RCT2_ADDRESS_MOUSE_WRITE_INDEX, uint32))
|
||||
return NULL;
|
||||
}
|
||||
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_MOUSE_READ_INDEX, uint32) = (read_index + 1) % 64;
|
||||
return &mouse_buffer[read_index];
|
||||
}
|
||||
|
||||
@@ -24,4 +24,6 @@
|
||||
void game_handle_input();
|
||||
void game_handle_keyboard_input();
|
||||
|
||||
void store_mouse_input(int state);
|
||||
|
||||
#endif
|
||||
@@ -28,6 +28,7 @@
|
||||
#include "addresses.h"
|
||||
#include "config.h"
|
||||
#include "gfx.h"
|
||||
#include "input.h"
|
||||
#include "osinterface.h"
|
||||
#include "screenshot.h"
|
||||
#include "window.h"
|
||||
@@ -40,12 +41,10 @@ openrct2_cursor gCursorState;
|
||||
const unsigned char *gKeysState;
|
||||
unsigned char *gKeysPressed;
|
||||
unsigned int gLastKeyPressed;
|
||||
openrct2_mouse_data* mouse_buffer = (openrct2_mouse_data*)0x1424340;
|
||||
|
||||
static void osinterface_create_window();
|
||||
static void osinterface_close_window();
|
||||
static void osinterface_resize(int width, int height);
|
||||
static void store_mouse_input(int state);
|
||||
|
||||
static SDL_Window *_window;
|
||||
static SDL_Surface *_surface;
|
||||
@@ -598,20 +597,4 @@ int osinterface_ensure_directory_exists(const char *path)
|
||||
char osinterface_get_path_separator()
|
||||
{
|
||||
return '\\';
|
||||
}
|
||||
|
||||
/**
|
||||
* rct2: 0x00406C96
|
||||
*/
|
||||
static void store_mouse_input(int state)
|
||||
{
|
||||
int write_index = RCT2_GLOBAL(RCT2_ADDRESS_MOUSE_WRITE_INDEX, uint32);
|
||||
int next_write_index = (write_index + 1) & 0x3F; //64 length buffer
|
||||
|
||||
if (next_write_index != RCT2_GLOBAL(RCT2_ADDRESS_MOUSE_READ_INDEX, uint32)) {
|
||||
mouse_buffer[write_index].x = RCT2_GLOBAL(0x01424318, uint32);
|
||||
mouse_buffer[write_index].y = RCT2_GLOBAL(0x0142431C, uint32);
|
||||
mouse_buffer[write_index].state = state;
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_MOUSE_WRITE_INDEX, uint32) = next_write_index;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -66,12 +66,6 @@ typedef struct {
|
||||
int old;
|
||||
} openrct2_cursor;
|
||||
|
||||
typedef struct {
|
||||
int x, y;
|
||||
int state; //0 = ? 1 = LeftDown 2 = LeftUp 3 = RightDown 4 = RightUp
|
||||
} openrct2_mouse_data;
|
||||
|
||||
extern openrct2_mouse_data* mouse_buffer;
|
||||
extern openrct2_cursor gCursorState;
|
||||
extern const unsigned char *gKeysState;
|
||||
extern unsigned char *gKeysPressed;
|
||||
|
||||
Reference in New Issue
Block a user