diff --git a/projects/openrct2.vcxproj.filters b/projects/openrct2.vcxproj.filters index ea66dda408..9063f53269 100644 --- a/projects/openrct2.vcxproj.filters +++ b/projects/openrct2.vcxproj.filters @@ -162,16 +162,10 @@ Header Files - - Header Files - - - Header Files - Header Files - + Header Files @@ -392,6 +386,9 @@ Source Files + + Windows + Source Files @@ -401,18 +398,6 @@ Windows - - Source Files - - - Source Files - - - Source Files - - - Source Files - diff --git a/src/audio.c b/src/audio.c index b53b563d29..f9be13d26e 100644 --- a/src/audio.c +++ b/src/audio.c @@ -577,7 +577,7 @@ MMRESULT mmio_open(const char* filename, HMMIO* hmmio, HGLOBAL* hmem, LPMMCKINFO //strcpy(audio_info.var_0, "\x01"); hmem = 0; label11: - hmemold2 = GlobalAlloc(0, (SIZE_T)hmem + 18); + hmemold2 = GlobalAlloc(0, (SIZE_T)(hmem + 18)); *hmemold = hmemold2; if (!hmemold2) { result = 57344; @@ -1179,19 +1179,19 @@ int sound_play_panned(int sound_id, int ebx, sint16 x, sint16 y, sint16 z) sint16 v11; sint16 v12; switch (RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32)) { - case MAP_ELEMENT_DIRECTION_WEST: + case 0: v11 = y - x; v12 = ((y + x) / 2) - z; break; - case MAP_ELEMENT_DIRECTION_NORTH: + case 1: v11 = -x - y; v12 = ((y - x) / 2) - z; break; - case MAP_ELEMENT_DIRECTION_EAST: + case 2: v11 = x - y; v12 = ((-y - x) / 2) - z; break; - case MAP_ELEMENT_DIRECTION_SOUTH: + case 3: v11 = y + x; v12 = ((x - y) / 2) - z; break; diff --git a/src/audio.h b/src/audio.h index 278f6bd317..10ac0864d1 100644 --- a/src/audio.h +++ b/src/audio.h @@ -113,7 +113,7 @@ typedef struct { sint16 var_4; uint16 frequency; // 0x6 sint16 var_8; - uint16 next; // 0xA + uint16 var_A; // 0xA } rct_sound_unknown; typedef struct { diff --git a/src/ride.h b/src/ride.h index 34b040a707..1116903b04 100644 --- a/src/ride.h +++ b/src/ride.h @@ -89,7 +89,9 @@ typedef struct { uint16 overall_view; // 0x050 00XX = X, XX00 = Y (* 32 + 16) uint16 station_starts[4]; // 0x052 uint8 station_heights[4]; // 0x05A - uint8 pad_05E[0xC]; + uint8 pad_05E[0x4]; + uint8 var_062[4]; + uint8 pad_066[0x4]; uint16 entrances[4]; // 0x06A uint16 exits[4]; // 0x072 uint8 pad_07A[0x0C]; @@ -122,7 +124,8 @@ typedef struct { uint8 drops; // 0x115 (??XX XXXX) uint8 pad_116; uint8 highest_drop_height; // 0x117 - uint8 pad_118[0x0C]; + uint32 var_118; + uint8 pad_11C[0x08]; sint16 var_124; sint16 var_126; sint16 var_128; @@ -179,7 +182,7 @@ typedef struct { uint8 track_colour_supports[4]; // 0x1C4 uint8 music; // 0x1C8 uint8 entrance_style; // 0x1C9 - uint8 pad_1CA[0x02]; + uint16 var_1CA; uint8 num_block_brakes; // 0x1CC uint8 lift_hill_speed; // 0x1CD uint16 guests_favourite; // 0x1CE diff --git a/src/vehicle.c b/src/vehicle.c index 4575d61547..bf2e89f5f4 100644 --- a/src/vehicle.c +++ b/src/vehicle.c @@ -56,7 +56,7 @@ void sub_6BB9FF(rct_vehicle* vehicle) if (t8 >= RCT2_GLOBAL(0x009AF5A0, rct_widthheight).width && t9 >= RCT2_GLOBAL(0x009AF5A0, rct_widthheight).height) { uint16 v9 = sub_6BC2F3(vehicle); rct_sound_unknown* i; - for (i = RCT2_ADDRESS(0x00F438B4, rct_sound_unknown); i < RCT2_GLOBAL(0x00F438B0, rct_sound_unknown*) && v9 <= i->next; i++); + for (i = RCT2_ADDRESS(0x00F438B4, rct_sound_unknown); i < RCT2_GLOBAL(0x00F438B0, rct_sound_unknown*) && v9 <= i->var_A; i++); if (i < RCT2_ADDRESS(0x00F43908, rct_sound_unknown)) { // 0x00F43908 is end of rct_sound_unknown list, which has 7 elements, not to be confused with variable at 0x00F43908 if (RCT2_GLOBAL(0x00F438B0, rct_sound_unknown*) < RCT2_ADDRESS(0x00F43908, rct_sound_unknown)) { RCT2_GLOBAL(0x00F438B0, rct_sound_unknown*)++; @@ -66,7 +66,7 @@ void sub_6BB9FF(rct_vehicle* vehicle) j--; *(j + 1) = *j; } - i->next = v9; + i->var_A = v9; rct_widthheight v12; v12.height = vehicle->var_16.height; v12.width = ((uint16)RCT2_GLOBAL(0x009AF5A0, rct_widthheight).width / 2) + ((uint16)RCT2_GLOBAL(0x009AF5A4, rct_widthheight).width / 2) - RCT2_GLOBAL(0x00F438A4, rct_viewport*)->view_x; @@ -211,8 +211,11 @@ void vehicle_sounds_update() 1; } - for (rct_sound_unknown* sound_unknown = &RCT2_GLOBAL(0x00F438B4, rct_sound_unknown); sound_unknown != RCT2_GLOBAL(0x00F438B0, rct_sound_unknown*); sound_unknown++) { - label28: + for (rct_sound_unknown* sound_unknown = &RCT2_GLOBAL(0x00F438B4, rct_sound_unknown); ; sound_unknown++) { + label28: + if (sound_unknown >= RCT2_GLOBAL(0x00F438B0, rct_sound_unknown*)) { + return; + } result = (uint16)-1; sint16 v = sound_unknown->var_4; if (v < 0) { @@ -269,13 +272,13 @@ void vehicle_sounds_update() while (sound_unknown->id != vehicle_sound->id) { vehicle_sound++; if (vehicle_sound >= &RCT2_GLOBAL(0x009AF42C, rct_vehicle_sound)) { - vehicle_sound = &RCT2_GLOBAL(RCT2_ADDRESS_VEHICLE_SOUND_LIST, rct_vehicle_sound); + vehicle_sound = &RCT2_GLOBAL(RCT2_ADDRESS_VEHICLE_SOUND_LIST, rct_vehicle_sound); int i = 0; while (vehicle_sound->id != (uint16)-1) { vehicle_sound++; i++; - if (i >= RCT2_GLOBAL(0x009AAC75, sint8)) { - sound_unknown = (rct_sound_unknown*)((int)sound_unknown + sound_unknown->next); + if (i >= RCT2_GLOBAL(0x009AAC75, uint8)) { + sound_unknown = (rct_sound_unknown*)((int)sound_unknown + 10); goto label28; } } diff --git a/src/window.c b/src/window.c index 3b574fea36..41553254cc 100644 --- a/src/window.c +++ b/src/window.c @@ -39,6 +39,28 @@ rct_window* g_window_list = RCT2_ADDRESS(RCT2_ADDRESS_WINDOW_LIST, rct_window); +// converted from uint16 values at 0x009A41EC - 0x009A4230 +// these are percentage coordinates of the viewport to center to, if a window is obscuring a location, the next is tried +float window_scroll_locations[][2] = { + 0.5f, 0.5f, + 0.75f, 0.5f, + 0.25f, 0.5f, + 0.5f, 0.75f, + 0.5f, 0.25f, + 0.75f, 0.75f, + 0.75f, 0.25f, + 0.25f, 0.75f, + 0.25f, 0.25f, + 0.125f, 0.5f, + 0.875f, 0.5f, + 0.5f, 0.125f, + 0.5f, 0.875f, + 0.875f, 0.125f, + 0.875f, 0.875f, + 0.125f, 0.875f, + 0.125f, 0.125f, +}; + static void window_all_wheel_input(); static int window_draw_split(rct_window *w, int left, int top, int right, int bottom); @@ -953,12 +975,87 @@ void window_scroll_to_viewport(rct_window *w) } /** - * - * rct2: 0x006E7C9C - */ +* +* rct2: 0x006E7C9C +* @param w (esi) +* @param x (eax) +* @param y (ecx) +* @param z (edx) +*/ void window_scroll_to_location(rct_window *w, int x, int y, int z) { - RCT2_CALLPROC_X(0x006E7C9C, x, 0, y, z, (int)w, 0, 0); + if (w->viewport) { + sint16 height = map_element_height(x, y); + if (z < height - 16) { + if (!(w->viewport->flags & 1 << 0)) { + w->viewport->flags |= 1 << 0; + window_invalidate(w); + } + } else { + if (w->viewport->flags & 1 << 0) { + w->viewport->flags &= ~(1 << 0); + window_invalidate(w); + } + } + sint16 sx; + sint16 sy; + switch (RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint8)) { + case 0: + sx = y - x; + sy = ((x + y) / 2) - z; + break; + case 1: + sx = -y - x; + sy = ((-x + y) / 2) - z; + break; + case 2: + sx = -y + x; + sy = ((-x - y) / 2) - z; + break; + case 3: + sx = y + x; + sy = ((x - y) / 2) - z; + break; + } + int i = 0; + if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & SCREEN_FLAGS_TITLE_DEMO)) { + int found = 0; + while (!found) { + sint16 x2 = w->viewport->x + (sint16)(w->viewport->width * window_scroll_locations[i][0]); + sint16 y2 = w->viewport->y + (sint16)(w->viewport->height * window_scroll_locations[i][1]); + rct_window* w2 = w; + while (1) { + w2++; + if (w2 >= RCT2_GLOBAL(RCT2_ADDRESS_NEW_WINDOW_PTR, rct_window*)) { + found = 1; + break; + } + sint16 x1 = w2->x - 10; + sint16 y1 = w2->y - 10; + if (x2 >= x1 && x2 <= w2->width + x1 + 20) { + if (y2 >= y1 && y2 <= w2->height + y1 + 20) { + // window is covering this area, try the next one + i++; + found = 0; + break; + } + } + } + if (i >= countof(window_scroll_locations)) { + i = 0; + found = 1; + } + } + } + // rct2: 0x006E7C76 + if (w->viewport_target_sprite == -1) { + if (!(w->flags & WF_2)) { + w->saved_view_x = sx - (sint16)(w->viewport->view_width * window_scroll_locations[i][0]); + w->saved_view_y = sy - (sint16)(w->viewport->view_height * window_scroll_locations[i][1]); + w->flags |= WF_SCROLLING_TO_LOCATION; + } + } + } } /**