From cbb617c56f783b5536af4475a26ef893747becc2 Mon Sep 17 00:00:00 2001 From: Jackson Davis Date: Mon, 25 Aug 2014 12:09:44 +0700 Subject: [PATCH] First pass at 0x00406C96 --- src/osinterface.c | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/src/osinterface.c b/src/osinterface.c index cde7d3b082..2bcfa2dd1b 100644 --- a/src/osinterface.c +++ b/src/osinterface.c @@ -44,7 +44,7 @@ unsigned int gLastKeyPressed; static void osinterface_create_window(); static void osinterface_close_window(); static void osinterface_resize(int width, int height); - +static void sub_406C96(int actionType); static SDL_Window *_window; static SDL_Surface *_surface; @@ -350,7 +350,7 @@ void osinterface_process_messages() RCT2_GLOBAL(0x0142431C, int) = e.button.y; switch (e.button.button) { case SDL_BUTTON_LEFT: - RCT2_CALLPROC_1(0x00406C96, int, 1); + sub_406C96(1); //RCT2_CALLPROC_1(0x00406C96, int, 1); gCursorState.left = CURSOR_PRESSED; gCursorState.old = 1; break; @@ -358,7 +358,7 @@ void osinterface_process_messages() gCursorState.middle = CURSOR_PRESSED; break; case SDL_BUTTON_RIGHT: - RCT2_CALLPROC_1(0x00406C96, int, 3); + sub_406C96(3); //RCT2_CALLPROC_1(0x00406C96, int, 3); gCursorState.right = CURSOR_PRESSED; gCursorState.old = 2; break; @@ -369,7 +369,7 @@ void osinterface_process_messages() RCT2_GLOBAL(0x0142431C, int) = e.button.y; switch (e.button.button) { case SDL_BUTTON_LEFT: - RCT2_CALLPROC_1(0x00406C96, int, 2); + sub_406C96(2); //RCT2_CALLPROC_1(0x00406C96, int, 2); gCursorState.left = CURSOR_RELEASED; gCursorState.old = 3; break; @@ -377,7 +377,7 @@ void osinterface_process_messages() gCursorState.middle = CURSOR_RELEASED; break; case SDL_BUTTON_RIGHT: - RCT2_CALLPROC_1(0x00406C96, int, 4); + sub_406C96(4); //RCT2_CALLPROC_1(0x00406C96, int, 4); gCursorState.right = CURSOR_RELEASED; gCursorState.old = 4; break; @@ -596,3 +596,23 @@ char osinterface_get_path_separator() { return '\\'; } + +void sub_406C96(int actionType) +{ + int eax = RCT2_GLOBAL(0x009E2DE4, uint32); + int ecx = eax + 1; + ecx &= 0x3F; //Array of 64 point structs, loop around buffer? + if (ecx != RCT2_GLOBAL(0x009E2DE8, uint32)) { + int edx = RCT2_GLOBAL(0x01424318, uint32); // X + //eax is a struct index here. Mutliplied by then and then 4 for the struct with 3 4 byte fields + //Struct is {int x, int y, int actionType} + eax = eax + eax*2; + eax = 0x01424340 + eax * 4; //get base of struct, address is base of array + *((uint32*)eax) = edx; + edx = RCT2_GLOBAL(0x0142431C, uint32); // Y + *((uint32*)eax + 1) = edx; + edx = actionType; + *((uint32*)eax + 2) = edx; + RCT2_GLOBAL(0x009E2DE4, uint32) = ecx; + } +}