From f639fd6054f8fab7a53d64697025ece050e98a8e Mon Sep 17 00:00:00 2001 From: IntelOrca Date: Wed, 3 Sep 2014 23:17:31 +0100 Subject: [PATCH 1/7] refactor ride structure --- src/peep.c | 42 +++++++++++++++++++-------------------- src/ride.c | 12 +++++------ src/ride.h | 11 ++++++---- src/window_finances.c | 4 ++-- src/window_new_campaign.c | 10 +++++----- src/window_ride_list.c | 10 +++++----- 6 files changed, 46 insertions(+), 43 deletions(-) diff --git a/src/peep.c b/src/peep.c index 447b7c08d1..da7c594544 100644 --- a/src/peep.c +++ b/src/peep.c @@ -437,20 +437,20 @@ void get_arguments_from_action(rct_peep* peep, uint32 *argument_1, uint32* argum if (RCT2_GLOBAL(RCT2_ADDRESS_RIDE_FLAGS + ride.type * 8, uint32) & 0x400000){ *argument_1 = STR_IN_RIDE; } - *argument_1 |= (ride.var_04A << 16); - *argument_2 = ride.var_04C; + *argument_1 |= (ride.name << 16); + *argument_2 = ride.name_arguments; break; case PEEP_STATE_BUYING: ride = g_ride_list[peep->current_ride]; - *argument_1 = STR_AT_RIDE | (ride.var_04A << 16); - *argument_2 = ride.var_04C; + *argument_1 = STR_AT_RIDE | (ride.name << 16); + *argument_2 = ride.name_arguments; break; case PEEP_STATE_WALKING: case 0x14: if (peep->var_C5 != 0xFF){ ride = g_ride_list[peep->var_C5]; - *argument_1 = STR_HEADING_FOR | (ride.var_04A << 16); - *argument_2 = ride.var_04C; + *argument_1 = STR_HEADING_FOR | (ride.name << 16); + *argument_2 = ride.name_arguments; } else{ *argument_1 = peep->flags & PEEP_FLAGS_LEAVING_PARK ? STR_LEAVING_PARK : STR_WALKING; @@ -460,8 +460,8 @@ void get_arguments_from_action(rct_peep* peep, uint32 *argument_1, uint32* argum case PEEP_STATE_QUEUING_FRONT: case PEEP_STATE_QUEUING: ride = g_ride_list[peep->current_ride]; - *argument_1 = STR_QUEUING_FOR | (ride.var_04A << 16); - *argument_2 = ride.var_04C; + *argument_1 = STR_QUEUING_FOR | (ride.name << 16); + *argument_2 = ride.name_arguments; break; case PEEP_STATE_SITTING: *argument_1 = STR_SITTING; @@ -470,12 +470,12 @@ void get_arguments_from_action(rct_peep* peep, uint32 *argument_1, uint32* argum case PEEP_STATE_WATCHING: if (peep->current_ride != 0xFF){ ride = g_ride_list[peep->current_ride]; - *argument_1 = STR_WATCHING_RIDE | (ride.var_04A << 16); - *argument_2 = ride.var_04C; + *argument_1 = STR_WATCHING_RIDE | (ride.name << 16); + *argument_2 = ride.name_arguments; if (peep->current_seat & 0x1) - *argument_1 = STR_WATCHING_CONSTRUCTION_OF | (ride.var_04A << 16); + *argument_1 = STR_WATCHING_CONSTRUCTION_OF | (ride.name << 16); else - *argument_1 = STR_WATCHING_RIDE | (ride.var_04A << 16); + *argument_1 = STR_WATCHING_RIDE | (ride.name << 16); } else{ *argument_1 = peep->current_seat & 0x1 ? STR_WATCHING_NEW_RIDE_BEING_CONSTRUCTED : STR_LOOKING_AT_SCENERY; @@ -519,24 +519,24 @@ void get_arguments_from_action(rct_peep* peep, uint32 *argument_1, uint32* argum } else{ ride = g_ride_list[peep->current_ride]; - *argument_1 = STR_RESPONDING_TO_RIDE_BREAKDOWN_CALL | (ride.var_04A << 16); - *argument_2 = ride.var_04C; + *argument_1 = STR_RESPONDING_TO_RIDE_BREAKDOWN_CALL | (ride.name << 16); + *argument_2 = ride.name_arguments; } break; case PEEP_STATE_FIXING: ride = g_ride_list[peep->current_ride]; - *argument_1 = STR_FIXING_RIDE | (ride.var_04A << 16); - *argument_2 = ride.var_04C; + *argument_1 = STR_FIXING_RIDE | (ride.name << 16); + *argument_2 = ride.name_arguments; break; case PEEP_STATE_HEADING_TO_INSPECTION: ride = g_ride_list[peep->current_ride]; - *argument_1 = STR_HEADING_TO_RIDE_FOR_INSPECTION | (ride.var_04A << 16); - *argument_2 = ride.var_04C; + *argument_1 = STR_HEADING_TO_RIDE_FOR_INSPECTION | (ride.name << 16); + *argument_2 = ride.name_arguments; break; case PEEP_STATE_INSPECTING: ride = g_ride_list[peep->current_ride]; - *argument_1 = STR_INSPECTING_RIDE | (ride.var_04A << 16); - *argument_2 = ride.var_04C; + *argument_1 = STR_INSPECTING_RIDE | (ride.name << 16); + *argument_2 = ride.name_arguments; break; } @@ -554,7 +554,7 @@ void get_arguments_from_thought(rct_peep_thought thought, uint32* argument_1, ui if ((RCT2_ADDRESS(0x981DB1, uint16)[thought.type] & 0xFF) & 1){ rct_ride* ride = &g_ride_list[thought.item]; - esi = (int)(&(ride->var_04A)); + esi = (int)(&(ride->name)); } else if ((RCT2_ADDRESS(0x981DB1, uint16)[thought.type] & 0xFF) & 2){ if (thought.item < 0x20){ diff --git a/src/ride.c b/src/ride.c index 43798a15db..af8530288b 100644 --- a/src/ride.c +++ b/src/ride.c @@ -242,16 +242,16 @@ void ride_entrance_exit_connected(rct_ride* ride, int ride_idx) continue; if (entrance != -1 && !ride_entrance_exit_is_reachable(entrance, ride, i)) { // name of ride is parameter of the format string - RCT2_GLOBAL(0x013CE952, uint16) = ride->var_04A; - RCT2_GLOBAL(0x013CE954, uint32) = ride->var_04C; + RCT2_GLOBAL(0x013CE952, uint16) = ride->name; + RCT2_GLOBAL(0x013CE954, uint32) = ride->name_arguments; news_item_add_to_queue(1, STR_ENTRANCE_NOT_CONNECTED, ride_idx); ride->connected_message_throttle = 3; } if (exit != -1 && !ride_entrance_exit_is_reachable(exit, ride, i)) { // name of ride is parameter of the format string - RCT2_GLOBAL(0x013CE952, uint16) = ride->var_04A; - RCT2_GLOBAL(0x013CE954, uint32) = ride->var_04C; + RCT2_GLOBAL(0x013CE952, uint16) = ride->name; + RCT2_GLOBAL(0x013CE954, uint32) = ride->name_arguments; news_item_add_to_queue(1, STR_EXIT_NOT_CONNECTED, ride_idx); ride->connected_message_throttle = 3; } @@ -315,8 +315,8 @@ void ride_shop_connected(rct_ride* ride, int ride_idx) } // name of ride is parameter of the format string - RCT2_GLOBAL(0x013CE952, uint16) = ride->var_04A; - RCT2_GLOBAL(0x013CE954, uint32) = ride->var_04C; + RCT2_GLOBAL(0x013CE952, uint16) = ride->name; + RCT2_GLOBAL(0x013CE954, uint32) = ride->name_arguments; news_item_add_to_queue(1, STR_ENTRANCE_NOT_CONNECTED, ride_idx); ride->connected_message_throttle = 3; diff --git a/src/ride.h b/src/ride.h index 0c452f956d..d454020c92 100644 --- a/src/ride.h +++ b/src/ride.h @@ -49,7 +49,9 @@ typedef struct { uint32 var_008; uint8 var_00C; uint8 var_00D; - uint8 pad_00E[0x1A4]; + uint8 pad_00E[0x5]; + uint8 var_013; + uint8 pad_014[0x19E]; sint8 excitement_multipler; // 0x1B2 sint8 intensity_multipler; // 0x1B3 sint8 nausea_multipler; // 0x1B4 @@ -74,8 +76,8 @@ typedef struct { uint8 pad_046[0x03]; // 0 = closed, 1 = open, 2 = test uint8 status; // 0x049 - uint16 var_04A; - uint32 var_04C; + rct_string_id name; // 0x04A + uint32 name_arguments; // 0x04C probably just for when a ride hasn't been named (e.g. Crooked House 1) uint16 overall_view; // 0x050 00XX = X, XX00 = Y (* 32 + 16) uint16 station_starts[4]; // 0x052 uint8 station_heights[4]; // 0x05A @@ -149,7 +151,8 @@ typedef struct { uint8 var_1CD; uint16 guests_favourite; // 0x1CE uint32 lifecycle_flags; // 0x1D0 - uint8 pad_1D4[0x20]; + uint8 var_1D4; + uint8 pad_1D5[0x1F]; // Example value for wild mouse ride is d5 (before it's been constructed) // I tried searching the IDA file for "1F4" but couldn't find places where // this is written to. diff --git a/src/window_finances.c b/src/window_finances.c index e8500fc84b..56f7072898 100644 --- a/src/window_finances.c +++ b/src/window_finances.c @@ -1250,8 +1250,8 @@ static void window_finances_marketing_paint() case ADVERTISING_CAMPAIGN_RIDE_FREE: case ADVERTISING_CAMPAIGN_RIDE: ride = GET_RIDE(campaignRideIndex[i]); - RCT2_GLOBAL(0x013CE952, uint16) = ride->var_04A; - RCT2_GLOBAL(0x013CE952 + 2, uint32) = ride->var_04C; + RCT2_GLOBAL(0x013CE952, uint16) = ride->name; + RCT2_GLOBAL(0x013CE952 + 2, uint32) = ride->name_arguments; break; case ADVERTISING_CAMPAIGN_FOOD_OR_DRINK_FREE: shopString = campaignRideIndex[i] + 2016; // STR_BALLOONS+ diff --git a/src/window_new_campaign.c b/src/window_new_campaign.c index efe6ad5afd..39ad693d98 100644 --- a/src/window_new_campaign.c +++ b/src/window_new_campaign.c @@ -118,8 +118,8 @@ int ride_name_compare(const void *a, const void *b) rideA = GET_RIDE(*((uint8*)a)); rideB = GET_RIDE(*((uint8*)b)); - format_string(rideAName, rideA->var_04A, &rideA->var_04C); - format_string(rideBName, rideB->var_04A, &rideB->var_04C); + format_string(rideAName, rideA->name, &rideA->name_arguments); + format_string(rideBName, rideB->name, &rideB->name_arguments); return _strcmpi(rideAName, rideBName); } @@ -288,7 +288,7 @@ static void window_new_campaign_mousedown(int widgetIndex, rct_window *w, rct_wi rct_ride *ride = GET_RIDE(window_new_campaign_rides[i]); gDropdownItemsFormat[i] = 1142; - gDropdownItemsArgs[i] = (ride->var_04C << 16) | ride->var_04A; + gDropdownItemsArgs[i] = (ride->name_arguments << 16) | ride->name; numItems++; } @@ -364,8 +364,8 @@ static void window_new_campaign_invalidate() window_new_campaign_widgets[WIDX_RIDE_LABEL].image = STR_MARKETING_RIDE; if (w->campaign.ride_id != SELECTED_RIDE_UNDEFINED) { rct_ride *ride = GET_RIDE(w->campaign.ride_id); - window_new_campaign_widgets[WIDX_RIDE_DROPDOWN].image = ride->var_04A; - RCT2_GLOBAL(0x013CE952, uint32) = ride->var_04C; + window_new_campaign_widgets[WIDX_RIDE_DROPDOWN].image = ride->name; + RCT2_GLOBAL(0x013CE952, uint32) = ride->name_arguments; } break; case ADVERTISING_CAMPAIGN_FOOD_OR_DRINK_FREE: diff --git a/src/window_ride_list.c b/src/window_ride_list.c index 1a876b8457..0298a93c9e 100644 --- a/src/window_ride_list.c +++ b/src/window_ride_list.c @@ -507,7 +507,7 @@ static void window_ride_list_scrollpaint() ride = &g_ride_list[w->list_item_positions[i]]; // Ride name - gfx_draw_string_left_clipped(dpi, format, &ride->var_04A, 0, 0, y - 1, 159); + gfx_draw_string_left_clipped(dpi, format, &ride->name, 0, 0, y - 1, 159); // Ride information formatSecondary = 0; @@ -648,12 +648,12 @@ static void window_ride_list_refresh_list(rct_window *w) int current_list_position = list_index; switch (w->list_information_type) { case INFORMATION_TYPE_STATUS: - RCT2_GLOBAL(0x013CE952, uint32) = ride->var_04C; - RCT2_CALLPROC_X(0x006C2538, ride->var_04A, 0, 0x013CE952, 0, 0, RCT2_ADDRESS_COMMON_STRING_FORMAT_BUFFER, 0); + RCT2_GLOBAL(0x013CE952, uint32) = ride->name_arguments; + RCT2_CALLPROC_X(0x006C2538, ride->name, 0, 0x013CE952, 0, 0, RCT2_ADDRESS_COMMON_STRING_FORMAT_BUFFER, 0); while (--current_list_position >= 0) { otherRide = &g_ride_list[w->list_item_positions[current_list_position]]; - RCT2_GLOBAL(0x013CE952, uint32) = otherRide->var_04C; - RCT2_CALLPROC_X(0x006C2538, otherRide->var_04A, 0, 0x013CE952, 0, 0, 0x0141EF68, 0); + RCT2_GLOBAL(0x013CE952, uint32) = otherRide->name_arguments; + RCT2_CALLPROC_X(0x006C2538, otherRide->name, 0, 0x013CE952, 0, 0, 0x0141EF68, 0); if (strcmp((char*)RCT2_ADDRESS_COMMON_STRING_FORMAT_BUFFER, (char*)0x0141EF68) >= 0) break; From 10ab0030ae19005708dd3cf6503f1ea0325cbb89 Mon Sep 17 00:00:00 2001 From: Tom van der Kleij Date: Thu, 4 Sep 2014 22:10:53 +0200 Subject: [PATCH 2/7] Decompiled peep_create (0x0069EC6B) --- src/peep.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++ src/peep.h | 1 + src/staff.c | 11 +++++------ 3 files changed, 53 insertions(+), 6 deletions(-) diff --git a/src/peep.c b/src/peep.c index ea85a117e4..56fa5dd5e9 100644 --- a/src/peep.c +++ b/src/peep.c @@ -410,6 +410,53 @@ rct_peep *peep_generate(int x, int y, int z) return (rct_peep*)esi; } +/* +* rct2: 69EC6B +* bl: unclear what this does +*/ +rct_peep *peep_create(uint8 bl) +{ + rct_peep *peep = NULL; + + int ecx = 0xA; + + if ((bl & 2 != 0)) + { + // 69EC96; + uint16 cx = 0x12C - RCT2_GLOBAL(0x13573CE, uint16); + if (cx >= RCT2_GLOBAL(0x13573C8, uint16)) + { + return NULL; + } + + ecx = 6; + } + else if (RCT2_GLOBAL(0x13573C8, uint16) <= 0) + { + return NULL; + } + + peep = &g_sprite_list[RCT2_GLOBAL(RCT2_ADDRESS_SPRITES_NEXT_INDEX, uint16)]; + + RCT2_CALLPROC_X(0x0069ED0B, 0, 0, ecx, 0, (int)peep, 0, 0); + + peep->x = SPRITE_LOCATION_NULL; + peep->y = SPRITE_LOCATION_NULL; + peep->z = 0; + peep->name_string_idx = 0; + peep->var_14 = 0x10; + peep->var_09 = 0x14; + peep->var_15 = 0x8; + peep->var_0C = 0x0; + peep->var_16 = SPRITE_LOCATION_NULL; + + uint16 oldGlobal = RCT2_GLOBAL(0xF3EF60, uint16); + RCT2_GLOBAL(0xF3EF60, uint16) = peep->sprite_index; + peep->var_02 = oldGlobal; + + return peep; +} + /** * rct2: 0x00698B0D * peep.sprite_index (eax) diff --git a/src/peep.h b/src/peep.h index 3f18e5d587..306ff82551 100644 --- a/src/peep.h +++ b/src/peep.h @@ -443,6 +443,7 @@ void peep_problem_warnings_update(); void peep_update_crowd_noise(); void peep_applause(); rct_peep *peep_generate(int x, int y, int z); +rct_peep *peep_create(uint8 bl); void get_arguments_from_action(rct_peep* peep, uint32 *argument_1, uint32* argument_2); void get_arguments_from_thought(rct_peep_thought thought, uint32* argument_1, uint32* argument_2); diff --git a/src/staff.c b/src/staff.c index 1e0bc041cb..7ec082a5c1 100644 --- a/src/staff.c +++ b/src/staff.c @@ -111,14 +111,13 @@ void game_command_hire_new_staff_member(int* eax, int* ebx, int* ecx, int* edx, int newStaffId = i; - int _eax, _ebx, _ecx = _cx, _edx, _esi, _edi, _ebp; - _esi = 0; + int _eax, _ebx, _ecx = _cx, _edx, _edi, _ebp; + int _esi; _ebx = _bl; - RCT2_CALLFUNC_X(0x0069EC6B, &_eax, &_ebx, &_ecx, &_edx, &_esi, &_edi, &_ebp); - rct_peep* newPeep = (rct_peep*)_esi; - //if ((newPeep = create_peep_sprite(_bl)) == NULL) - if (_esi == 0) + rct_peep* newPeep = peep_create(_bl); + + if (newPeep == 0) { *ebx = 0x80000000; RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_TEXT, uint16) = STR_TOO_MANY_PEOPLE_IN_GAME; From 657621db20a139d8f75d8a3394efcb964f2a01c8 Mon Sep 17 00:00:00 2001 From: adrian17 Date: Thu, 4 Sep 2014 21:09:54 +0200 Subject: [PATCH 3/7] Decompile window_rotate_camera, change sub_689174 to use z parameter --- src/map.c | 4 +++- src/viewport.c | 10 ++++++---- src/viewport.h | 3 +++ src/window.c | 46 +++++++++++++++++++++++++++++++++++++++++++++- 4 files changed, 57 insertions(+), 6 deletions(-) diff --git a/src/map.c b/src/map.c index ac086487e4..f654935c4a 100644 --- a/src/map.c +++ b/src/map.c @@ -138,7 +138,9 @@ void map_update_tile_pointers() /** * Return the absolute height of an element, given its (x,y) coordinates - * + * ax: x + * cx: y + * dx: return * rct2: 0x00662783 */ int map_element_height(int x, int y) diff --git a/src/viewport.c b/src/viewport.c index e47bc4f653..4266f27c8e 100644 --- a/src/viewport.c +++ b/src/viewport.c @@ -221,8 +221,8 @@ void viewport_update_pointers() *vp = NULL; } -void sub_689174(sint16* x, sint16* y, uint8 curr_rotation){ - //RCT2_CALLFUNC_X(0x00689174, (int*)&x, (int*)&y, &ecx, &curr_rotation, (int*)&window, (int*)&viewport, &ebp); +void sub_689174(sint16* x, sint16* y, sint16 *z, uint8 curr_rotation){ + //RCT2_CALLFUNC_X(0x00689174, (int*)&x, (int*)&y, (int*)&z, &curr_rotation, (int*)&window, (int*)&viewport, &ebp); sint16 start_x = *x; sint16 start_y = *y; @@ -262,6 +262,7 @@ void sub_689174(sint16* x, sint16* y, uint8 curr_rotation){ } break; } + *z = height; } /** @@ -296,11 +297,12 @@ void viewport_update_position(rct_window *window) sint16 x = viewport->view_width / 2 + window->saved_view_x; sint16 y = viewport->view_height / 2 + window->saved_view_y; + sint16 z; int curr_rotation = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32); - sub_689174(&x, &y, curr_rotation); + sub_689174(&x, &y, &z, curr_rotation); - RCT2_CALLPROC_X(0x006E7A15, x, y, 0, 0, (int)window, (int)viewport, 0); + RCT2_CALLPROC_X(0x006E7A15, x, y, z, 0, (int)window, (int)viewport, 0); //Clamp to the map minimum value int at_map_edge = 0; diff --git a/src/viewport.h b/src/viewport.h index 9b709f8d03..dfbcfb8c5c 100644 --- a/src/viewport.h +++ b/src/viewport.h @@ -47,11 +47,14 @@ enum { extern rct_viewport* g_viewport_list; void viewport_init_all(); +void center_2d_coordinates(int x, int y, int z, int* out_x, int* out_y, rct_viewport* viewport); void viewport_create(rct_window *w, int x, int y, int width, int height, int zoom, int center_x, int center_y, int center_z, char flags, sint16 sprite); void viewport_update_pointers(); void viewport_update_position(rct_window *window); void viewport_render(rct_drawpixelinfo *dpi, rct_viewport *viewport, int left, int top, int right, int bottom); +void sub_689174(sint16* x, sint16* y, sint16 *z, uint8 curr_rotation); + void screen_pos_to_map_pos(short *x, short *y); void show_gridlines(); diff --git a/src/window.c b/src/window.c index 4351d90d1a..af22ebfc4a 100644 --- a/src/window.c +++ b/src/window.c @@ -21,7 +21,9 @@ #include #include "addresses.h" #include "audio.h" +#include "game.h" #include "gfx.h" +#include "map.h" #include "osinterface.h" #include "rct2.h" #include "widget.h" @@ -963,7 +965,49 @@ void window_scroll_to_location(rct_window *w, int x, int y, int z) */ void window_rotate_camera(rct_window *w) { - RCT2_CALLPROC_X(0x0068881A, 0, 0, 0, 0, (int)w, 0, 0); + //RCT2_CALLPROC_X(0x0068881A, 0, 0, 0, 0, (int)w, 0, 0); + + rct_viewport *viewport = w->viewport; + if (viewport == NULL) + return; + + sint16 x = (viewport->width >> 1) + viewport->x; + sint16 y = (viewport->height >> 1) + viewport->y; + sint16 z; + + uint8 rot = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint8); + + int ecx, edx, esi, edi = (int)viewport, ebp; + //has something to do with checking if middle of the viewport is obstructed + RCT2_CALLFUNC_X(0x00688972, (int*)&x, (int*)&y, &ecx, &edx, &esi, &edi, &ebp); + rct_viewport *other = (rct_viewport*)edi; + + // other != viewport probably triggers on viewports in ride or guest window? + // x is 0x8000 if middle of viewport is obstructed by another window? + if (x == (sint16)SPRITE_LOCATION_NULL || other != viewport){ + x = (viewport->view_width >> 1) + viewport->view_x; + y = (viewport->view_height >> 1) + viewport->view_y; + + sub_689174(&x, &y, &z, rot); + } else { + z = map_element_height(x, y); + } + + RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32) = (rot + 1) % 4; + + int new_x, new_y; + center_2d_coordinates(x, y, z, &new_x, &new_y, viewport); + + w->saved_view_x = new_x; + w->saved_view_y = new_y; + viewport->view_x = new_x; + viewport->view_y = new_y; + + window_invalidate(w); + + RCT2_CALLPROC_EBPSAFE(0x00688956); + + sub_0x0069E9A7(); } /** From 7359134fc549518bdc80cc6f532ececcf7be616e Mon Sep 17 00:00:00 2001 From: adrian17 Date: Thu, 4 Sep 2014 21:10:49 +0200 Subject: [PATCH 4/7] Fix off-by-one error in center_2d_coordinates --- src/viewport.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/viewport.c b/src/viewport.c index 4266f27c8e..d39bf92a8d 100644 --- a/src/viewport.c +++ b/src/viewport.c @@ -113,19 +113,19 @@ void center_2d_coordinates(int x, int y, int z, int* out_x, int* out_y, rct_view switch (RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32)){ case 0: x = y - x; - y = y / 2 + start_x / 2 - z; + y = (y + start_x) / 2 - z; break; case 1: x = -y - x; - y = y / 2 - start_x / 2 - z; + y = (y - start_x) / 2 - z; break; case 2: x = -y + x; - y = -y / 2 - start_x / 2 - z; + y = (-y - start_x) / 2 - z; break; case 3: x = y + x; - y = -y / 2 + start_x / 2 - z; + y = (-y + start_x) / 2 - z; break; } From c9f081e5d2bfd41bf471e1ed03bf9f8dd86cc48d Mon Sep 17 00:00:00 2001 From: Tom van der Kleij Date: Thu, 4 Sep 2014 23:21:17 +0200 Subject: [PATCH 5/7] Renamed peep_create --> create_sprite + minor changes from feedback --- src/peep.c | 47 ----------------------------------------------- src/peep.h | 1 - src/sprite.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ src/sprite.h | 8 ++++++-- src/staff.c | 5 ++--- 5 files changed, 52 insertions(+), 53 deletions(-) diff --git a/src/peep.c b/src/peep.c index 56fa5dd5e9..ea85a117e4 100644 --- a/src/peep.c +++ b/src/peep.c @@ -410,53 +410,6 @@ rct_peep *peep_generate(int x, int y, int z) return (rct_peep*)esi; } -/* -* rct2: 69EC6B -* bl: unclear what this does -*/ -rct_peep *peep_create(uint8 bl) -{ - rct_peep *peep = NULL; - - int ecx = 0xA; - - if ((bl & 2 != 0)) - { - // 69EC96; - uint16 cx = 0x12C - RCT2_GLOBAL(0x13573CE, uint16); - if (cx >= RCT2_GLOBAL(0x13573C8, uint16)) - { - return NULL; - } - - ecx = 6; - } - else if (RCT2_GLOBAL(0x13573C8, uint16) <= 0) - { - return NULL; - } - - peep = &g_sprite_list[RCT2_GLOBAL(RCT2_ADDRESS_SPRITES_NEXT_INDEX, uint16)]; - - RCT2_CALLPROC_X(0x0069ED0B, 0, 0, ecx, 0, (int)peep, 0, 0); - - peep->x = SPRITE_LOCATION_NULL; - peep->y = SPRITE_LOCATION_NULL; - peep->z = 0; - peep->name_string_idx = 0; - peep->var_14 = 0x10; - peep->var_09 = 0x14; - peep->var_15 = 0x8; - peep->var_0C = 0x0; - peep->var_16 = SPRITE_LOCATION_NULL; - - uint16 oldGlobal = RCT2_GLOBAL(0xF3EF60, uint16); - RCT2_GLOBAL(0xF3EF60, uint16) = peep->sprite_index; - peep->var_02 = oldGlobal; - - return peep; -} - /** * rct2: 0x00698B0D * peep.sprite_index (eax) diff --git a/src/peep.h b/src/peep.h index 306ff82551..3f18e5d587 100644 --- a/src/peep.h +++ b/src/peep.h @@ -443,7 +443,6 @@ void peep_problem_warnings_update(); void peep_update_crowd_noise(); void peep_applause(); rct_peep *peep_generate(int x, int y, int z); -rct_peep *peep_create(uint8 bl); void get_arguments_from_action(rct_peep* peep, uint32 *argument_1, uint32* argument_2); void get_arguments_from_thought(rct_peep_thought thought, uint32* argument_1, uint32* argument_2); diff --git a/src/sprite.c b/src/sprite.c index c2c80cb5dd..96dbdc4596 100644 --- a/src/sprite.c +++ b/src/sprite.c @@ -104,4 +104,48 @@ void reset_0x69EBE4(){ spr->unknown.var_02 = ax; } } +} + +/* +* rct2: 0x0069EC6B +* bl: unclear what this does +*/ +rct_sprite *create_sprite(uint8 bl) +{ + int ecx = 0xA; + + if ((bl & 2 != 0)) + { + // 69EC96; + uint16 cx = 0x12C - RCT2_GLOBAL(0x13573CE, uint16); + if (cx >= RCT2_GLOBAL(0x13573C8, uint16)) + { + return NULL; + } + + ecx = 6; + } + else if (RCT2_GLOBAL(0x13573C8, uint16) <= 0) + { + return NULL; + } + + rct_unk_sprite *sprite = &g_sprite_list[RCT2_GLOBAL(RCT2_ADDRESS_SPRITES_NEXT_INDEX, uint16)]; + + RCT2_CALLPROC_X(0x0069ED0B, 0, 0, ecx, 0, (int)sprite, 0, 0); + + sprite->x = SPRITE_LOCATION_NULL; + sprite->y = SPRITE_LOCATION_NULL; + sprite->z = 0; + sprite->name_string_idx = 0; + sprite->var_14 = 0x10; + sprite->pad_09 = 0x14; + sprite->var_15 = 0x8; + sprite->pad_0C[0] = 0x0; + sprite->var_16 = SPRITE_LOCATION_NULL; + + sprite->var_02 = RCT2_GLOBAL(0xF3EF60, uint16); + RCT2_GLOBAL(0xF3EF60, uint16) = sprite->sprite_index; + + return sprite; } \ No newline at end of file diff --git a/src/sprite.h b/src/sprite.h index 701d448cbc..81f6955956 100644 --- a/src/sprite.h +++ b/src/sprite.h @@ -49,12 +49,15 @@ typedef struct { sint16 x; // 0x0E sint16 y; // 0x10 sint16 z; // 0x12 - uint16 pad_14; + uint8 var_14; // 0x14 + uint8 var_15; // 0x15 sint16 var_16; //x related sint16 var_18; //y related sint16 var_1A; //x related sint16 var_1C; //y related - uint8 sprite_direction; //direction of sprite? + uint8 sprite_direction; //direction of sprite? 0x1e + uint8 pad_1F[3]; // 0x1f + uint16 name_string_idx; // 0x22 } rct_unk_sprite; typedef struct { @@ -86,6 +89,7 @@ typedef union { extern rct_sprite* g_sprite_list; void create_balloon(int x, int y, int z, int colour); +rct_sprite *create_sprite(uint8 bl); void reset_sprite_list(); void reset_0x69EBE4(); diff --git a/src/staff.c b/src/staff.c index 7ec082a5c1..4fe6e6eb68 100644 --- a/src/staff.c +++ b/src/staff.c @@ -112,12 +112,11 @@ void game_command_hire_new_staff_member(int* eax, int* ebx, int* ecx, int* edx, int newStaffId = i; int _eax, _ebx, _ecx = _cx, _edx, _edi, _ebp; - int _esi; _ebx = _bl; - rct_peep* newPeep = peep_create(_bl); + rct_peep* newPeep = create_sprite(_bl); - if (newPeep == 0) + if (newPeep == NULL) { *ebx = 0x80000000; RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_TEXT, uint16) = STR_TOO_MANY_PEOPLE_IN_GAME; From 2bb4274f057f1c6ed4d5f16309a3583b3b38da0f Mon Sep 17 00:00:00 2001 From: IntelOrca Date: Thu, 4 Sep 2014 23:27:16 +0100 Subject: [PATCH 6/7] fix warnings --- src/ride.c | 1 - src/sprite.c | 6 +++--- src/staff.c | 4 ++-- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/ride.c b/src/ride.c index af8530288b..7637de70fb 100644 --- a/src/ride.c +++ b/src/ride.c @@ -448,7 +448,6 @@ void ride_construct_new(int list_item) //Looks like edi became the ride index after the command. eax = edi; rct_window *w; - short widgetIndex; //TODO: replace with window_ride_main_open(eax) // window_ride_main_open(eax); diff --git a/src/sprite.c b/src/sprite.c index 96dbdc4596..ec511dfaeb 100644 --- a/src/sprite.c +++ b/src/sprite.c @@ -114,7 +114,7 @@ rct_sprite *create_sprite(uint8 bl) { int ecx = 0xA; - if ((bl & 2 != 0)) + if ((bl & 2) != 0) { // 69EC96; uint16 cx = 0x12C - RCT2_GLOBAL(0x13573CE, uint16); @@ -130,7 +130,7 @@ rct_sprite *create_sprite(uint8 bl) return NULL; } - rct_unk_sprite *sprite = &g_sprite_list[RCT2_GLOBAL(RCT2_ADDRESS_SPRITES_NEXT_INDEX, uint16)]; + rct_unk_sprite *sprite = &(g_sprite_list[RCT2_GLOBAL(RCT2_ADDRESS_SPRITES_NEXT_INDEX, uint16)]).unknown; RCT2_CALLPROC_X(0x0069ED0B, 0, 0, ecx, 0, (int)sprite, 0, 0); @@ -147,5 +147,5 @@ rct_sprite *create_sprite(uint8 bl) sprite->var_02 = RCT2_GLOBAL(0xF3EF60, uint16); RCT2_GLOBAL(0xF3EF60, uint16) = sprite->sprite_index; - return sprite; + return (rct_sprite*)sprite; } \ No newline at end of file diff --git a/src/staff.c b/src/staff.c index 4fe6e6eb68..cead4581e3 100644 --- a/src/staff.c +++ b/src/staff.c @@ -111,10 +111,10 @@ void game_command_hire_new_staff_member(int* eax, int* ebx, int* ecx, int* edx, int newStaffId = i; - int _eax, _ebx, _ecx = _cx, _edx, _edi, _ebp; + int _eax, _ebx, _ecx = _cx, _edx; _ebx = _bl; - rct_peep* newPeep = create_sprite(_bl); + rct_peep* newPeep = &(create_sprite(_bl)->peep); if (newPeep == NULL) { From 6b3c39655fea8e3a5880eea737d22207333cc8f0 Mon Sep 17 00:00:00 2001 From: IntelOrca Date: Fri, 5 Sep 2014 23:46:35 +0100 Subject: [PATCH 7/7] fixes #279, WWT_24 no longer shows a checkbox --- src/widget.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/widget.c b/src/widget.c index 22226cd78f..003e86597a 100644 --- a/src/widget.c +++ b/src/widget.c @@ -736,13 +736,15 @@ static void widget_checkbox_draw(rct_drawpixelinfo *dpi, rct_window *w, int widg // Get the colour colour = w->colours[widget->colour]; - // checkbox - gfx_fill_rect_inset(dpi, l, t, l + 9, b - 1, colour, 0x60); + if (widget->type != WWT_24) { + // checkbox + gfx_fill_rect_inset(dpi, l, t, l + 9, b - 1, colour, 0x60); - // fill it when checkbox is pressed - if (widget_is_pressed(w, widgetIndex)) { - RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_FONT_SPRITE_BASE, uint16) = 224; - gfx_draw_string(dpi, (char*)0x009DED72, colour & 0x7F, l, t); + // fill it when checkbox is pressed + if (widget_is_pressed(w, widgetIndex)) { + RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_FONT_SPRITE_BASE, uint16) = 224; + gfx_draw_string(dpi, (char*)0x009DED72, colour & 0x7F, l, t); + } } // draw the text