From 78845ca16553b6bbe28450a314a326fafa7728e1 Mon Sep 17 00:00:00 2001 From: Duncan Date: Mon, 23 Jun 2014 12:37:12 +0100 Subject: [PATCH 1/6] is_peep_in_filter updated to use decompiled func Has not been tested. Considering redoing all of these functions removing hard to understand variables. --- src/window_guest_list.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/window_guest_list.c b/src/window_guest_list.c index 8142acd81e..08638a1c77 100644 --- a/src/window_guest_list.c +++ b/src/window_guest_list.c @@ -802,15 +802,13 @@ static void window_guest_list_scrollpaint() */ static int window_guest_list_is_peep_in_filter(rct_peep* peep) { - int eax, ebx, ecx, edx, esi, edi, ebp; + int eax, ebx; char temp; temp = _window_guest_list_selected_view; _window_guest_list_selected_view = _window_guest_list_selected_filter; - esi = (int)peep; - RCT2_CALLFUNC_X(0x0069B7EA, &eax, &ebx, &ecx, &edx, &esi, &edi, &ebp); - ebx &= 0xFFFF; + ebx = sub_69B7EA(peep, &eax); _window_guest_list_selected_view = temp; eax = (RCT2_GLOBAL(0x013CE952, uint16) << 16) | ebx; From e32293f6b0943b01040e0678658ea19c1ab5c941 Mon Sep 17 00:00:00 2001 From: Duncan Frost Date: Mon, 23 Jun 2014 16:51:21 +0100 Subject: [PATCH 2/6] Fixed compile error --- src/window_guest_list.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/window_guest_list.c b/src/window_guest_list.c index 08638a1c77..b62bfc7507 100644 --- a/src/window_guest_list.c +++ b/src/window_guest_list.c @@ -132,6 +132,7 @@ static int window_guest_list_is_peep_in_filter(rct_peep* peep); static void window_guest_list_find_groups(); static int get_guest_face_sprite_small(rct_peep *peep); static int get_guest_face_sprite_large(rct_peep *peep); +static int sub_69B7EA(rct_peep *peep, int *outEAX); /** * From 044a0b72e83aa6e0c7a43f6e64009fed0694af0f Mon Sep 17 00:00:00 2001 From: Duncan Date: Tue, 24 Jun 2014 12:21:43 +0100 Subject: [PATCH 3/6] Re-factor of 0x69B7EA into get_arguments_from_peep Has not been tested. This should remove a few global variables 0x13CE952 and 0x13CE954. (Note these globals are also used for drawing strings so will still be relevant elsewhere.) --- src/window_guest_list.c | 68 ++++++++++++++++++++--------------------- 1 file changed, 34 insertions(+), 34 deletions(-) diff --git a/src/window_guest_list.c b/src/window_guest_list.c index b62bfc7507..ed5b55975f 100644 --- a/src/window_guest_list.c +++ b/src/window_guest_list.c @@ -132,7 +132,7 @@ static int window_guest_list_is_peep_in_filter(rct_peep* peep); static void window_guest_list_find_groups(); static int get_guest_face_sprite_small(rct_peep *peep); static int get_guest_face_sprite_large(rct_peep *peep); -static int sub_69B7EA(rct_peep *peep, int *outEAX); +static void get_arguments_from_peep(rct_peep *peep, uint32 *argument_1, uint32* argument_2); /** * @@ -797,33 +797,37 @@ static void window_guest_list_scrollpaint() } } + /** - * + * returns 0 for in filter and 1 for not in filter * rct2: 0x0069B865 */ static int window_guest_list_is_peep_in_filter(rct_peep* peep) { - int eax, ebx; char temp; temp = _window_guest_list_selected_view; _window_guest_list_selected_view = _window_guest_list_selected_filter; - - ebx = sub_69B7EA(peep, &eax); + int argument1, argument2; + get_arguments_from_peep(peep, &argument1, &argument2); _window_guest_list_selected_view = temp; - eax = (RCT2_GLOBAL(0x013CE952, uint16) << 16) | ebx; if (((RCT2_GLOBAL(0x00F1EDF6, uint32) >> 16) & 0xFFFF) == 0xFFFF && _window_guest_list_selected_filter == 1) - eax |= 0xFFFF; + argument1 |= 0xFFFF; - if (eax == RCT2_GLOBAL(0x00F1EDF6, uint32) && RCT2_GLOBAL(0x013CE954, uint32) == RCT2_GLOBAL(0x00F1EDFA, uint32)) + if (argument1 == RCT2_GLOBAL(0x00F1EDF6, uint32) && argument2 == RCT2_GLOBAL(0x00F1EDFA, uint32)) return 0; return 1; } -/* Calculates a hash value for comparing peep actions/thoughts*/ -static int sub_69B7EA(rct_peep *peep, int *outEAX) +/** + * rct2:0x0069B7EA + * Calculates a hash value (arguments) for comparing peep actions/thoughts + * argument_1 (0x013CE952) + * argument_2 (0x013CE954) + */ +static void get_arguments_from_peep(rct_peep *peep, uint32 *argument_1, uint32* argument_2) { int eax, ebx, ecx, edx, esi, edi, ebp; @@ -831,33 +835,29 @@ static int sub_69B7EA(rct_peep *peep, int *outEAX) case VIEW_ACTIONS: eax = peep->sprite_index; RCT2_CALLFUNC_X(0x00698B0D, &eax, &ebx, &ecx, &edx, &esi, &edi, &ebp); - RCT2_GLOBAL(0x013CE952, uint16) = ecx & 0xFFFF; - RCT2_GLOBAL(0x013CE952 + 2, uint32) = edx; - - *outEAX = eax; - return ebx & 0xFFFF; + *argument_1 = (ecx & 0xFFFF << 16) | (ebx & 0xFFFF); + *argument_2 = edx; + return; case VIEW_THOUGHTS: if (peep->thoughts[0].var_2 <= 5) { eax = peep->thoughts[0].item; ebx = peep->thoughts[0].type; if (peep->thoughts[0].type != PEEP_THOUGHT_TYPE_NONE) { RCT2_CALLFUNC_X(0x00698342, &eax, &ebx, &ecx, &edx, &esi, &edi, &ebp); - RCT2_GLOBAL(0x013CE952, uint16) = *((uint16*)esi); - RCT2_GLOBAL(0x013CE952 + 2, uint32) = *((uint32*)(esi + 2)); - - *outEAX = eax; - return ebx & 0xFFFF; + *argument_1 = (*((uint16*)esi)<< 16) | (ebx & 0xFFFF); + *argument_2 = *((uint32*)(esi + 2); + return; } } - RCT2_GLOBAL(0x013CE952, uint16) = 0; - RCT2_GLOBAL(0x013CE952 + 2, uint32) = 0; - - *outEAX = 0; - return 0; + *argument_1 = 0; + *argument_2 = 0; + return; } - return 0; + *argument_1 = 0; + *argument_2 = 0; + return; } /** @@ -898,12 +898,11 @@ static void window_guest_list_find_groups() _window_guest_list_num_groups++; _window_guest_list_groups_num_guests[groupIndex] = 1; peep->var_0C &= ~(1 << 8); - int bx = sub_69B7EA(peep, &eax); - eax = (RCT2_GLOBAL(0x013CE952, uint16) << 16) | bx; - RCT2_GLOBAL(0x00F1EDF6, uint32) = eax; - _window_guest_list_groups_argument_1[groupIndex] = eax; - RCT2_GLOBAL(0x00F1EDFA, uint32) = RCT2_GLOBAL(0x013CE952 + 2, uint32); - _window_guest_list_groups_argument_2[groupIndex] = RCT2_GLOBAL(0x013CE952 + 2, uint32); + + get_arguments_from_peep( peep, &_window_guest_list_groups_argument_1[groupIndex], &_window_guest_list_groups_argument_2[groupIndex]); + RCT2_GLOBAL(0x00F1EDF6, uint32) = _window_guest_list_groups_argument_1[groupIndex]; + RCT2_GLOBAL(0x00F1EDFA, uint32) = _window_guest_list_groups_argument_2[groupIndex]; + RCT2_ADDRESS(0x00F1AF26, uint8)[groupIndex] = groupIndex; faceIndex = groupIndex * 56; _window_guest_list_groups_guest_faces[faceIndex++] = get_guest_face_sprite_small(peep) - 5486; @@ -913,9 +912,10 @@ static void window_guest_list_find_groups() if (peep2->var_2A != 0 || !(peep2->var_0C & (1 << 8))) continue; + int argument1, argument2; // Get and check if in same group - bx = sub_69B7EA(peep2, &eax); - if ((bx != (0xFFFF&_window_guest_list_groups_argument_1[groupIndex]) || (RCT2_GLOBAL(0x00F1EDF8, uint16) != RCT2_GLOBAL(0x013CE952, uint16)) || _window_guest_list_groups_argument_2[groupIndex] != RCT2_GLOBAL(0x013CE952 + 2, uint32))) + get_arguments_from_peep(peep2, &argument1, &argument2); + if (argument1 != _window_guest_list_groups_argument_1[groupIndex] || argument2 != _window_guest_list_groups_argument_2[groupIndex] )) continue; // Assign guest From 54e46c044aca664b51dd2dda74dfbfe1b765d9d6 Mon Sep 17 00:00:00 2001 From: Duncan Frost Date: Tue, 24 Jun 2014 18:02:36 +0100 Subject: [PATCH 4/6] Fix small ) mistake --- src/window_guest_list.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/window_guest_list.c b/src/window_guest_list.c index ed5b55975f..d9b91b71e9 100644 --- a/src/window_guest_list.c +++ b/src/window_guest_list.c @@ -824,6 +824,7 @@ static int window_guest_list_is_peep_in_filter(rct_peep* peep) /** * rct2:0x0069B7EA * Calculates a hash value (arguments) for comparing peep actions/thoughts + * peep (esi) * argument_1 (0x013CE952) * argument_2 (0x013CE954) */ @@ -845,14 +846,10 @@ static void get_arguments_from_peep(rct_peep *peep, uint32 *argument_1, uint32* if (peep->thoughts[0].type != PEEP_THOUGHT_TYPE_NONE) { RCT2_CALLFUNC_X(0x00698342, &eax, &ebx, &ecx, &edx, &esi, &edi, &ebp); *argument_1 = (*((uint16*)esi)<< 16) | (ebx & 0xFFFF); - *argument_2 = *((uint32*)(esi + 2); + *argument_2 = *((uint32*)(esi + 2)); return; } } - - *argument_1 = 0; - *argument_2 = 0; - return; } *argument_1 = 0; @@ -915,7 +912,7 @@ static void window_guest_list_find_groups() int argument1, argument2; // Get and check if in same group get_arguments_from_peep(peep2, &argument1, &argument2); - if (argument1 != _window_guest_list_groups_argument_1[groupIndex] || argument2 != _window_guest_list_groups_argument_2[groupIndex] )) + if (argument1 != _window_guest_list_groups_argument_1[groupIndex] || argument2 != _window_guest_list_groups_argument_2[groupIndex] ) continue; // Assign guest From 97894a648e0d873a6d2ab2cd1b8c99893130e6ea Mon Sep 17 00:00:00 2001 From: Duncan Frost Date: Tue, 24 Jun 2014 18:45:17 +0100 Subject: [PATCH 5/6] Added get_argument_from_thought --- src/window_guest_list.c | 58 +++++++++++++++++++++++++++++++++-------- 1 file changed, 47 insertions(+), 11 deletions(-) diff --git a/src/window_guest_list.c b/src/window_guest_list.c index d9b91b71e9..822109ac3c 100644 --- a/src/window_guest_list.c +++ b/src/window_guest_list.c @@ -19,6 +19,7 @@ *****************************************************************************/ #include +#include #include "addresses.h" #include "game.h" #include "peep.h" @@ -821,6 +822,45 @@ static int window_guest_list_is_peep_in_filter(rct_peep* peep) return 1; } +/** + * rct2: 0x00698342 + * thought.item (eax) + * thought.type (ebx) + * argument_1 (esi & ebx) + * argument_2 (esi+2) + */ +void get_argument_from_thought(rct_peep_thought thought, uint32* argument_1, uint32* argument_2){ + int esi = 0x9AC86C; + + if ((RCT2_ADDRESS(0x981DB1, uint16)[thought.type] & 0xFF) == 1){ + uint32 item = thought.item; + item *= 0x260; + esi = 0x1362942 + item; + } + else if ((RCT2_ADDRESS(0x981DB1, uint16)[thought.type] & 0xFF) == 2){ + if (thought.item < 0x20){ + RCT2_GLOBAL(0x9AC86C, uint16) = thought.item + 0x7C4; + } + else{ + RCT2_GLOBAL(0x9AC86C, uint16) = thought.item + 0x82A; + } + } + else if ((RCT2_ADDRESS(0x981DB1, uint16)[thought.type] & 0xFF) == 4){ + if (thought.item < 0x20){ + RCT2_GLOBAL(0x9AC86C, uint16) = thought.item + 0x7FC; + } + else + { + RCT2_GLOBAL(0x9AC86C, uint16) = thought.item + 0x856; + } + } + else{ + esi = 0x9AC864; + } + *argument_1 = ((thought.type + 0x5C8) & 0xFFFF) | (*((uint16*)esi) << 16); + *argument_2 = *((uint32*)(esi+2)); +} + /** * rct2:0x0069B7EA * Calculates a hash value (arguments) for comparing peep actions/thoughts @@ -836,24 +876,20 @@ static void get_arguments_from_peep(rct_peep *peep, uint32 *argument_1, uint32* case VIEW_ACTIONS: eax = peep->sprite_index; RCT2_CALLFUNC_X(0x00698B0D, &eax, &ebx, &ecx, &edx, &esi, &edi, &ebp); - *argument_1 = (ecx & 0xFFFF << 16) | (ebx & 0xFFFF); + *argument_1 = (ecx << 16) | (ebx & 0xFFFF); *argument_2 = edx; - return; + break; case VIEW_THOUGHTS: if (peep->thoughts[0].var_2 <= 5) { - eax = peep->thoughts[0].item; - ebx = peep->thoughts[0].type; if (peep->thoughts[0].type != PEEP_THOUGHT_TYPE_NONE) { - RCT2_CALLFUNC_X(0x00698342, &eax, &ebx, &ecx, &edx, &esi, &edi, &ebp); - *argument_1 = (*((uint16*)esi)<< 16) | (ebx & 0xFFFF); - *argument_2 = *((uint32*)(esi + 2)); - return; + get_argument_from_thought(peep->thoughts[0], argument_1, argument_2); + break; } } + default: + *argument_1 = 0; + *argument_2 = 0; } - - *argument_1 = 0; - *argument_2 = 0; return; } From 96abc93c79471293ce25eb773c118fbada6367ad Mon Sep 17 00:00:00 2001 From: Duncan Frost Date: Tue, 24 Jun 2014 20:11:25 +0100 Subject: [PATCH 6/6] Added get_arguments_from_action --- src/window_guest_list.c | 141 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 135 insertions(+), 6 deletions(-) diff --git a/src/window_guest_list.c b/src/window_guest_list.c index 822109ac3c..42d2b0924d 100644 --- a/src/window_guest_list.c +++ b/src/window_guest_list.c @@ -26,6 +26,7 @@ #include "string_ids.h" #include "sprite.h" #include "sprites.h" +#include "ride.h" #include "widget.h" #include "window.h" #include "window_dropdown.h" @@ -861,6 +862,139 @@ void get_argument_from_thought(rct_peep_thought thought, uint32* argument_1, uin *argument_2 = *((uint32*)(esi+2)); } +/** +* rct2: 0x00698B0D +* peep.sprite_index (eax) +* thought.type (ebx) +* argument_1 (ecx & ebx) +* argument_2 (edx) +*/ +void get_arguments_from_action(rct_peep* peep, uint32 *argument_1, uint32* argument_2){ + rct_ride ride; + + switch (peep->state){ + case 0: + *argument_1 = peep->var_71 == 0xB ? 0x59A : 0x597; + *argument_2 = 0; + break; + case 1: + *argument_1 = 0x597; + *argument_2 = 0; + break; + case 3: + case 4: + case 7: + *argument_1 = 0x59B; + ride = RCT2_ADDRESS(RCT2_ADDRESS_RIDE_LIST, rct_ride)[peep->current_ride]; + if (RCT2_GLOBAL(RCT2_ADDRESS_RIDE_FLAGS + ride.type*8, uint32)& 0x400000){ + (*argument_1)++; + } + *argument_1 |= (ride.var_04A << 16); + *argument_2 = ride.var_04C; + break; + case 0x11: + ride = RCT2_ADDRESS(RCT2_ADDRESS_RIDE_LIST, rct_ride)[peep->current_ride]; + *argument_1 = 0x59D | (ride.var_04A << 16); + *argument_2 = ride.var_04C; + break; + case 5: + case 0x14: + if (peep->var_C5 != 0xFF){ + ride = RCT2_ADDRESS(RCT2_ADDRESS_RIDE_LIST, rct_ride)[peep->var_C5]; + *argument_1 = 0x598 | (ride.var_04A << 16); + *argument_2 = ride.var_04C; + } + else{ + *argument_1 = peep->flags & 1 ? 0x5A7 : 0x597; + *argument_2 = 0; + } + break; + case 2: + case 6: + ride = RCT2_ADDRESS(RCT2_ADDRESS_RIDE_LIST, rct_ride)[peep->current_ride]; + *argument_1 = 0x599 | (ride.var_04A << 16); + *argument_2 = ride.var_04C; + break; + case 8: + *argument_1 = 0x59E; + *argument_2 = 0; + break; + case 0x12: + if (peep->current_ride != 0xFF){ + ride = RCT2_ADDRESS(RCT2_ADDRESS_RIDE_LIST, rct_ride)[peep->current_ride]; + *argument_1 = 0x5A4 | (ride.var_04A << 16); + *argument_2 = ride.var_04C; + if (peep->current_seat & 0x1) + *argument_1 = 0x5A5 | (ride.var_04A << 16); + else + *argument_1 = 0x5A4 | (ride.var_04A << 16); + } + else{ + *argument_1 = peep->current_seat & 0x1 ? 0x5A8 : 0x5A6; + *argument_2 = 0; + } + break; + case 9: + *argument_1 = 0x59F; + *argument_2 = 0; + break; + case 0xA: + case 0xD: + case 0xE: + *argument_1 = 0x597; + *argument_2 = 0; + break; + case 0xB: + *argument_1 = 0x5A0; + *argument_2 = 0; + break; + case 0xC: + *argument_1 = 0x5A1; + *argument_2 = 0; + break; + case 0x15: + *argument_1 = 0x5A3; + *argument_2 = 0; + break; + case 0x13: + *argument_1 = 0x5A2; + *argument_2 = 0; + break; + case 0xF: + if (peep->pad_2C == 0){ + *argument_1 = 0x597; + *argument_2 = 0; + } + else if (peep->pad_2C == 1){ + *argument_1 = 0x703; + *argument_2 = 0; + } + else{ + ride = RCT2_ADDRESS(RCT2_ADDRESS_RIDE_LIST, rct_ride)[peep->current_ride]; + *argument_1 = 0x700 | (ride.var_04A << 16); + *argument_2 = ride.var_04C; + } + break; + case 0x10: + ride = RCT2_ADDRESS(RCT2_ADDRESS_RIDE_LIST, rct_ride)[peep->current_ride]; + *argument_1 = 0x702 | (ride.var_04A << 16); + *argument_2 = ride.var_04C; + break; + case 0x16: + ride = RCT2_ADDRESS(RCT2_ADDRESS_RIDE_LIST, rct_ride)[peep->current_ride]; + *argument_1 = 0x701 | (ride.var_04A << 16); + *argument_2 = ride.var_04C; + break; + case 0x17: + ride = RCT2_ADDRESS(RCT2_ADDRESS_RIDE_LIST, rct_ride)[peep->current_ride]; + *argument_1 = 0x75E | (ride.var_04A << 16); + *argument_2 = ride.var_04C; + break; + } + +} + + /** * rct2:0x0069B7EA * Calculates a hash value (arguments) for comparing peep actions/thoughts @@ -870,14 +1004,9 @@ void get_argument_from_thought(rct_peep_thought thought, uint32* argument_1, uin */ static void get_arguments_from_peep(rct_peep *peep, uint32 *argument_1, uint32* argument_2) { - int eax, ebx, ecx, edx, esi, edi, ebp; - switch (_window_guest_list_selected_view) { case VIEW_ACTIONS: - eax = peep->sprite_index; - RCT2_CALLFUNC_X(0x00698B0D, &eax, &ebx, &ecx, &edx, &esi, &edi, &ebp); - *argument_1 = (ecx << 16) | (ebx & 0xFFFF); - *argument_2 = edx; + get_arguments_from_action(peep, argument_1, argument_2); break; case VIEW_THOUGHTS: if (peep->thoughts[0].var_2 <= 5) {