From 425ab513a4c91e78b87ae3cfdd5ebb8990755ac4 Mon Sep 17 00:00:00 2001 From: Duncan Frost Date: Sun, 27 Jul 2014 16:29:07 +0100 Subject: [PATCH] Started cleanup of process mouse over --- src/addresses.h | 1 + src/game.c | 187 ++++++++++++++++++++++++---------------------- src/osinterface.h | 54 ++++++------- 3 files changed, 127 insertions(+), 115 deletions(-) diff --git a/src/addresses.h b/src/addresses.h index e3ee5d9fbe..990278eadc 100644 --- a/src/addresses.h +++ b/src/addresses.h @@ -101,6 +101,7 @@ #define RCT2_ADDRESS_INSTALLED_OBJECT_LIST 0x009ADAE8 +#define RCT2_ADDRESS_CURENT_CURSOR 0x009DE51C #define RCT2_ADDRESS_INPUT_STATE 0x009DE51D #define RCT2_ADDRESS_CURSOR_DOWN_WINDOWCLASS 0x009DE51F #define RCT2_ADDRESS_CURSOR_DOWN_WINDOWNUMBER 0x009DE520 diff --git a/src/game.c b/src/game.c index 5b7b6ff49d..024e360d63 100644 --- a/src/game.c +++ b/src/game.c @@ -77,11 +77,27 @@ void sub_0x6ED801(int x, int y){ tool_cancel(); } else{ - RCT2_CALLPROC_X(w->event_handlers[WE_TOOL_UPDATE], x, y, 0, RCT2_GLOBAL(0x9DE546, uint16), w, 0, 0); + RCT2_CALLPROC_X(w->event_handlers[WE_TOOL_UPDATE], x, y, 0, RCT2_GLOBAL(0x9DE546, uint16), (int)w, 0, 0); } } } +void sub_0x6ED990(char cursor_id){ + if (RCT2_GLOBAL(RCT2_ADDRESS_INPUT_STATE, uint8) == INPUT_STATE_RESIZING) + { + cursor_id = CURSOR_DIAGONAL_ARROWS; //resize icon + } + + if (cursor_id == RCT2_GLOBAL(RCT2_ADDRESS_CURENT_CURSOR, uint8)) + { + return; + } + RCT2_GLOBAL(RCT2_ADDRESS_CURENT_CURSOR, uint8) = cursor_id; + RCT2_GLOBAL(0x14241BC, uint32) = 2; + osinterface_set_cursor(cursor_id); + RCT2_GLOBAL(0x14241BC, uint32) = 0; +} + /** * * rct2: 0x006ED833 @@ -91,9 +107,6 @@ void process_mouse_over(int x, int y) rct_window* window; rct_window* subWindow; - uint32* abc; - static int def; - int widgetId; int cursorId; int eax, ebx, ecx, edx, esi, edi, ebp; @@ -104,21 +117,33 @@ void process_mouse_over(int x, int y) RCT2_GLOBAL(0x9A9808, sint16) = -1; //RCT2_CALLFUNC_X(0x6EA845, &eax, &ebx, &ecx, &edx, &esi, &edi, &ebp); window = window_find_from_point(x, y); + esi = window; push(eax); push(ebx); - if (esi == NULL) + if (window == NULL) { - goto loc_6ED983; + pop(); + pop(); + RCT2_CALLPROC_X(0x6EDE88, x, y, ecx, edx, esi, edi, ebp); + sub_0x6ED990((char)edx); + return; } push(edx); widgetId = window_find_widget_from_point(window, x, y); + edx = widgetId; RCT2_GLOBAL(0x1420046, sint16) = (edx & 0xFFFF); - if (((sint16)(edx & 0xFFFF)) == -1) + if (widgetId == -1) { - edx = pop(); - goto loc_6ED983; + edx = 0; + pop(); + pop(); + pop(); + RCT2_CALLPROC_X(0x6EDE88, x, y, ecx, edx, esi, edi, ebp); + sub_0x6ED990((char)edx); + return; } - edx = pop(); + edx = 0; + pop(); if (window->widgets[widgetId].type != WWT_VIEWPORT) { goto loc_6ED8EE; @@ -132,7 +157,11 @@ void process_mouse_over(int x, int y) ebp = (int)subWindow; if (subWindow == NULL) { - goto loc_6ED983; + pop(); + pop(); + RCT2_CALLPROC_X(0x6EDE88, x, y, ecx, edx, esi, edi, ebp); + sub_0x6ED990((char)edx); + return; } ebx = ebx & 0xFFFFFF00; edi = edx; @@ -142,34 +171,49 @@ void process_mouse_over(int x, int y) edx = edi; if ((ebx & 0xFF) == 0) { - goto loc_6ED983; + pop(); + pop(); + RCT2_CALLPROC_X(0x6EDE88, x, y, ecx, edx, esi, edi, ebp); + sub_0x6ED990((char)edx); + return; } else { - ebx = pop(); - eax = pop(); - goto loc_6ED990; + ebx = y; + eax = x; + pop(); + pop(); + sub_0x6ED990(edx); + return; } loc_6ED8C8: { push(edx); RCT2_CALLFUNC_X(0X6ED9D0, &eax, &ebx, &ecx, &edx, &esi, &edi, &ebp); - edx = pop(); + edx = 0; + pop(); if ((ebx & 0xFF) == 2 || (ebx & 0xFF) == 8) { goto loc_6ED8E2; } if ((ebx & 0xFF) != 3) { - goto loc_6ED983; + pop(); + pop(); + RCT2_CALLPROC_X(0x6EDE88, x, y, ecx, edx, esi, edi, ebp); + sub_0x6ED990((char)edx); + return; } } loc_6ED8E2: { - edx = 4; - ebx = pop(); - eax = pop(); - goto loc_6ED990; + edx = CURSOR_HAND_POINT; + ebx = y; + eax = x; + pop(); + pop(); + sub_0x6ED990(edx); + return; } loc_6ED8EE: if (window->widgets[widgetId].type == WWT_RESIZE) @@ -184,7 +228,11 @@ loc_6ED8EE: loc_6ED8F8: if (window->flags & 0x100) { - goto loc_6ED983; + pop(); + pop(); + RCT2_CALLPROC_X(0x6EDE88, x, y, ecx, edx, esi, edi, ebp); + sub_0x6ED990((char)edx); + return; } if (window->min_width != window->max_width) { @@ -195,95 +243,62 @@ loc_6ED8F8: goto loc_6ED93D; } loc_6ED914: - if (x < window->x + window->width - 0x13) + if (x < window->x + window->width - 19) { goto loc_6ED93D; } - if (y < window->y + window->height - 0x13) + if (y < window->y + window->height - 19) { goto loc_6ED93D; } - edx = 6; - goto loc_6ED983; + edx = CURSOR_DIAGONAL_ARROWS; + RCT2_CALLPROC_X(0x6EDE88, x, y, ecx, edx, esi, edi, ebp); + sub_0x6ED990((char)edx); + return; loc_6ED93D: RCT2_GLOBAL(0x9DE558, uint16) = x; RCT2_GLOBAL(0x9DE55A, uint16) = y; - push(eax); - push(ebx); - push(edx); - if (window->widgets[widgetId].type != WWT_SCROLL) - { - goto loc_6ED95C; - } + int push_eax = eax; + int push_ebx = ebx; + int push_edx = edx; + + if (window->widgets[widgetId].type == WWT_SCROLL) { int output_x, output_y, output_cx, output_dx; - widget_scroll_get_part(window, window->widgets, eax, ebx, &output_x, &output_y, &output_cx, &output_dx); + widget_scroll_get_part(window, window->widgets, x, y, &output_x, &output_y, &output_cx, &output_dx); edx = output_dx; if (output_cx != 0) { - goto loc_6ED980; + edx = push_edx; + ebx = y; + eax = x; + pop(); + pop(); + RCT2_CALLPROC_X(0x6EDE88, x, y, ecx, edx, esi, edi, ebp); + sub_0x6ED990((char)edx); + return; } } loc_6ED95C: { - ecx = eax; - edx = ebx; - eax = RCT2_GLOBAL(0x1420046, uint16); - ebx = 0xFFFFFFFF; + ecx = x; + edx = y; + eax = widgetId; + //eax = RCT2_GLOBAL(0x1420046, uint16); + ebx = -1; push(edi); RCT2_CALLFUNC_X(window->event_handlers[WE_UNKNOWN_17], &eax, &ebx, &ecx, &edx, &esi, &edi, &ebp); edi = pop(); - if (ebx == 0xFFFFFFFF) - { - goto loc_6ED980; + if (ebx != -1){ + edx = ebx; } - edx = ebx; - ebx = pop(); - ebx = pop(); - eax = pop(); - goto loc_6ED983; - } -loc_6ED980: - edx = pop(); - ebx = pop(); - eax = pop(); - -loc_6ED983: - { - ebx = pop(); - eax = pop(); - push(eax); - push(ebx); - push(edx); - RCT2_CALLFUNC_X(0x6EDE88, &eax, &ebx, &ecx, &edx, &esi, &edi, &ebp); + RCT2_CALLPROC_X(0x6EDE88, x, y, ecx, edx, esi, edi, ebp); //itemUnderCursor(&eax, &ebx, &ecx, &edx); - edx = pop(); - ebx = pop(); - eax = pop(); } -loc_6ED990: - if (RCT2_GLOBAL(RCT2_ADDRESS_INPUT_STATE, uint8) != INPUT_STATE_RESIZING) - { - goto loc_6ED99E; - } - edx = 6; //resize icon -loc_6ED99E: - if ((edx & 0xFF) == RCT2_GLOBAL(0x9DE51C, uint8)) - { - return; - } - RCT2_GLOBAL(0x9DE51C, uint8) = (edx & 0xFF); - RCT2_GLOBAL(0x14241BC, uint32) = 2; - abc = (uint32 *)(0x1423598); - //edx = 6; - char debug_out[250]; - sprintf(debug_out, "%d %d\n", edx, abc[edx]); - OutputDebugString(debug_out); - osinterface_set_cursor(edx); - RCT2_GLOBAL(0x14241BC, uint32) = 0; + sub_0x6ED990((char)edx); } /** @@ -641,10 +656,6 @@ static void game_get_next_input(int *x, int *y, int *state) *y = RCT2_GLOBAL(eax + 4, sint32); *state = RCT2_GLOBAL(eax + 8, sint32); - edx = RCT2_GLOBAL(0x9DE51C, uint8); - RCT2_GLOBAL(0x14241BC, uint32) = 2; - osinterface_set_cursor(edx); - RCT2_GLOBAL(0x14241BC, uint32) = 0; //int eax, ebx, ecx, edx, esi, edi, ebp; //RCT2_CALLFUNC_X(0x006E83C7, &eax, &ebx, &ecx, &edx, &esi, &edi, &ebp); //*x = eax & 0xFFFF; diff --git a/src/osinterface.h b/src/osinterface.h index 7a4b5e1bef..ea91c79a85 100644 --- a/src/osinterface.h +++ b/src/osinterface.h @@ -30,33 +30,33 @@ enum { }; enum{ - CURSOR_ARROW, - CURSOR_BLANK, - CURSOR_UP_ARROW, - CURSOR_UP_DOWN_ARROW, - CURSOR_HAND_POINT, - CURSOR_ZZZ, - CURSOR_DIAGONAL_ARROWS, - CURSOR_PICKER, - CURSOR_TREE_DOWN, - CURSOR_FOUNTAIN_DOWN, - CURSOR_STATUE_DOWN, - CURSOR_BENCH_DOWN, - CURSOR_CROSS_HAIR, - CURSOR_BIN_DOWN, - CURSOR_LAMPPOST_DOWN, - CURSOR_FENCE_DOWN, - CURSOR_FLOWER_DOWN, - CURSOR_PATH_DOWN, - CURSOR_DIG_DOWN, - CURSOR_WATER_DOWN, - CURSOR_HOUSE_DOWN, - CURSOR_VOLCANO_DOWN, - CURSOR_WALK_DOWN, - CURSOR_PAINT_DOWN, - CURSOR_ENTRANCE_DOWN, - CURSOR_HAND_OPEN, - CURSOR_HAND_CLOSED + CURSOR_ARROW = 0, + CURSOR_BLANK = 1, + CURSOR_UP_ARROW = 2, + CURSOR_UP_DOWN_ARROW = 3, + CURSOR_HAND_POINT = 4, + CURSOR_ZZZ = 5, + CURSOR_DIAGONAL_ARROWS = 6, + CURSOR_PICKER = 7, + CURSOR_TREE_DOWN = 8, + CURSOR_FOUNTAIN_DOWN = 9, + CURSOR_STATUE_DOWN = 10, + CURSOR_BENCH_DOWN = 11, + CURSOR_CROSS_HAIR = 12, + CURSOR_BIN_DOWN = 13, + CURSOR_LAMPPOST_DOWN = 14, + CURSOR_FENCE_DOWN = 15, + CURSOR_FLOWER_DOWN = 16, + CURSOR_PATH_DOWN = 17, + CURSOR_DIG_DOWN = 18, + CURSOR_WATER_DOWN = 19, + CURSOR_HOUSE_DOWN = 20, + CURSOR_VOLCANO_DOWN = 21, + CURSOR_WALK_DOWN = 22, + CURSOR_PAINT_DOWN = 23, + CURSOR_ENTRANCE_DOWN = 24, + CURSOR_HAND_OPEN = 25, + CURSOR_HAND_CLOSED = 26 }; typedef struct {