diff --git a/src/addresses.h b/src/addresses.h index e8618000c2..b288384800 100644 --- a/src/addresses.h +++ b/src/addresses.h @@ -126,6 +126,8 @@ #define RCT2_ADDRESS_RUN_INTRO_TICK_PART 0x009AC319 +#define RCT2_ADDRESS_WINDOW_MAP_FLASHING_FLAGS 0x009AC861 + #define RCT2_ADDRESS_RIDE_ENTRIES 0x009ACFA4 #define RCT2_ADDRESS_INSTALLED_OBJECT_LIST 0x009ADAE8 diff --git a/src/game.c b/src/game.c index 9d21b3bb08..47ce26f2ed 100644 --- a/src/game.c +++ b/src/game.c @@ -201,7 +201,7 @@ void update_palette_effects() void game_update() { - int i, numUpdates, tmp; + int i, numUpdates; // Handles picked-up peep and rain redraw redraw_peep_and_rain(); @@ -250,17 +250,24 @@ void game_update() RCT2_GLOBAL(0x009A8C28, uint8) = 0; RCT2_GLOBAL(RCT2_ADDRESS_INPUT_FLAGS, uint32) &= ~INPUT_FLAG_VIEWPORT_SCROLLING; - RCT2_GLOBAL(0x009AC861, uint16) ^= (1 << 15); - RCT2_GLOBAL(0x009AC861, uint16) &= ~(1 << 1); - tmp = RCT2_GLOBAL(0x009AC861, uint16) & (1 << 0); - RCT2_GLOBAL(0x009AC861, uint16) &= ~(1 << 0); - if (!tmp) - RCT2_GLOBAL(0x009AC861, uint16) |= (1 << 1); - RCT2_GLOBAL(0x009AC861, uint16) &= ~(1 << 3); - tmp = RCT2_GLOBAL(0x009AC861, uint16) & (1 << 2); - RCT2_GLOBAL(0x009AC861, uint16) &= ~(1 << 2); - if (!tmp) - RCT2_GLOBAL(0x009AC861, uint16) |= (1 << 2); + + // the flickering frequency is reduced by 4, compared to the original + // it was done due to inability to reproduce original frequency + // and decision that the original one looks too fast + if (RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_TICKS, sint32) % 4 == 0) + RCT2_GLOBAL(RCT2_ADDRESS_WINDOW_MAP_FLASHING_FLAGS, uint16) ^= (1 << 15); + + // Handle guest map flashing + RCT2_GLOBAL(RCT2_ADDRESS_WINDOW_MAP_FLASHING_FLAGS, uint16) &= ~(1 << 1); + if (RCT2_GLOBAL(RCT2_ADDRESS_WINDOW_MAP_FLASHING_FLAGS, uint16) & (1 << 0)) + RCT2_GLOBAL(RCT2_ADDRESS_WINDOW_MAP_FLASHING_FLAGS, uint16) |= (1 << 1); + RCT2_GLOBAL(RCT2_ADDRESS_WINDOW_MAP_FLASHING_FLAGS, uint16) &= ~(1 << 0); + + // Handle staff map flashing + RCT2_GLOBAL(RCT2_ADDRESS_WINDOW_MAP_FLASHING_FLAGS, uint16) &= ~(1 << 3); + if (RCT2_GLOBAL(RCT2_ADDRESS_WINDOW_MAP_FLASHING_FLAGS, uint16) & (1 << 2)) + RCT2_GLOBAL(RCT2_ADDRESS_WINDOW_MAP_FLASHING_FLAGS, uint16) |= (1 << 3); + RCT2_GLOBAL(RCT2_ADDRESS_WINDOW_MAP_FLASHING_FLAGS, uint16) &= ~(1 << 2); window_map_tooltip_update_visibility(); window_update_all(); diff --git a/src/title.c b/src/title.c index 87380c673b..4adfd8c253 100644 --- a/src/title.c +++ b/src/title.c @@ -277,17 +277,6 @@ void title_update() } RCT2_GLOBAL(RCT2_ADDRESS_INPUT_FLAGS, uint32) &= ~0x80; - RCT2_GLOBAL(0x009AC861, uint16) &= ~0x8000; - RCT2_GLOBAL(0x009AC861, uint16) &= ~0x02; - tmp = RCT2_GLOBAL(0x009AC861, uint16) & 0x01; - RCT2_GLOBAL(0x009AC861, uint16) &= ~0x01; - if (!tmp) - RCT2_GLOBAL(0x009AC861, uint16) |= 0x02; - RCT2_GLOBAL(0x009AC861, uint16) &= ~0x08; - tmp = RCT2_GLOBAL(0x009AC861, uint16) & 0x04; - RCT2_GLOBAL(0x009AC861, uint16) &= ~0x04; - if (!tmp) - RCT2_GLOBAL(0x009AC861, uint16) |= 0x04; window_map_tooltip_update_visibility(); window_update_all(); diff --git a/src/windows/guest_list.c b/src/windows/guest_list.c index cef844f839..7e4229bea5 100644 --- a/src/windows/guest_list.c +++ b/src/windows/guest_list.c @@ -598,7 +598,7 @@ static void window_guest_list_scrollpaint() if (_window_guest_list_selected_filter != -1) { if (window_guest_list_is_peep_in_filter(peep)) continue; - RCT2_GLOBAL(0x009AC861, uint16) |= 1; + RCT2_GLOBAL(RCT2_ADDRESS_WINDOW_MAP_FLASHING_FLAGS, uint16) |= (1 << 0); peep->var_0C |= 0x200; } diff --git a/src/windows/map.c b/src/windows/map.c index d25f11b4ce..1dca570427 100644 --- a/src/windows/map.c +++ b/src/windows/map.c @@ -601,6 +601,174 @@ static void window_map_tooltip() RCT2_GLOBAL(RCT2_ADDRESS_COMMON_FORMAT_ARGS, short) = 0xC55; } +/** +* +* part of window_map_paint_peep_overlay and window_map_paint_train_overlay +*/ +static void window_map_transform_to_map_coords(sint16 *left, sint16 *top) +{ + sint16 x = *left, y = *top; + sint16 temp; + + switch (RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32)) { + case 3: + temp = x; + x = y; + y = temp; + x = 0x1FFF - x; + break; + case 2: + x = 0x1FFF - x; + y = 0x1FFF - y; + break; + case 1: + temp = x; + x = y; + y = temp; + y = 0x1FFF - y; + break; + case 0: + break; + } + x >>= 5; + y >>= 5; + + *left = -x + y + 0xF8; + *top = x + y - 8; +} + +/** +* +* rct2: 0x0068DADA +*/ +static void window_map_paint_peep_overlay(rct_drawpixelinfo *dpi) +{ + //RCT2_CALLPROC_X(0x68DADA, 0, 0, 0, 0, (int)w, (int)dpi, 0); //draws dots representing guests + //return; + + rct_peep *peep; + uint16 spriteIndex; + + sint16 left, right, bottom, top; + sint16 color; + + FOR_ALL_PEEPS(spriteIndex, peep) { + left = peep->x; + top = peep->y; + + if (left == SPRITE_LOCATION_NULL) + continue; + + window_map_transform_to_map_coords(&left, &top); + + right = left; + bottom = top; + + color = 0x14; + + if ((peep->var_0C & 0x200) != 0) { + if (peep->type == PEEP_TYPE_STAFF) { + if ((RCT2_GLOBAL(RCT2_ADDRESS_WINDOW_MAP_FLASHING_FLAGS, uint16) & (1 << 3)) != 0) { + color = 0x8A; + left--; + if ((RCT2_GLOBAL(RCT2_ADDRESS_WINDOW_MAP_FLASHING_FLAGS, uint16) & (1 << 15)) == 0) + color = 0xA; + } + } else { + if ((RCT2_GLOBAL(RCT2_ADDRESS_WINDOW_MAP_FLASHING_FLAGS, uint16) & (1 << 1)) != 0) { + color = 0xAC; + left--; + if ((RCT2_GLOBAL(RCT2_ADDRESS_WINDOW_MAP_FLASHING_FLAGS, uint16) & (1 << 15)) == 0) + color = 0x15; + } + } + } + gfx_fill_rect(dpi, left, top, right, bottom, color); + } +} + +/** +* +* rct2: 0x0068DBC1 +*/ +static void window_map_paint_train_overlay(rct_drawpixelinfo *dpi) +{ + //RCT2_CALLPROC_X(0x68DBC1, 0, 0, 0, 0, (int)w, (int)dpi, 0); //draws dots representing trains + //return; + + rct_vehicle *train, *vehicle; + uint16 train_index, vehicle_index; + + sint16 left, top, right, bottom; + + for (train_index = RCT2_GLOBAL(RCT2_ADDRESS_SPRITES_START_VEHICLE, uint16); train_index != SPRITE_INDEX_NULL; train_index = train->next) { + train = GET_VEHICLE(train_index); + for (vehicle_index = train_index; vehicle_index != SPRITE_INDEX_NULL; vehicle_index = vehicle->next_vehicle_on_train) { + vehicle = GET_VEHICLE(vehicle_index); + + left = vehicle->x; + top = vehicle->y; + + if (left == SPRITE_LOCATION_NULL) + continue; + + window_map_transform_to_map_coords(&left, &top); + + right = left; + bottom = top; + + gfx_fill_rect(dpi, left, top, right, bottom, 0xAB); + } + } +} + +/** +* The call to gfx_fill_rect was originally wrapped in sub_68DABD which made sure that arguments were ordered correctly, +* but it doesn't look like it's ever necessary here so the call was removed. +* +* rct2: 0x0068D8CE +*/ +static void window_map_paint_hud_rectangle(rct_drawpixelinfo *dpi) +{ + //RCT2_CALLPROC_X(0x68D8CE, 0, 0, 0, 0, 0, (int)dpi, 0); + //return; + + static const sint16 offsets_x[4] = { 0xF8, 0x1F8, 0xF8, 0xFFF8 }; + static const sint16 offsets_y[4] = { 0, 0x100, 0x200, 0x100 }; + + rct_window *main_window = window_get_main(); + if (main_window == NULL) + return; + rct_viewport *viewport = main_window->viewport; + if (viewport == NULL) + return; + + int rotation = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32); + sint16 offset_x = offsets_x[rotation]; + sint16 offset_y = offsets_y[rotation]; + + sint16 left = (viewport->view_x >> 5) + offset_x; + sint16 right = ((viewport->view_x + viewport->view_width) >> 5) + offset_x; + sint16 top = (viewport->view_y >> 4) + offset_y; + sint16 bottom = ((viewport->view_y + viewport->view_height) >> 4) + offset_y; + + // top horizontal lines + gfx_fill_rect(dpi, left, top, left + 3, top, 0x38); + gfx_fill_rect(dpi, right - 3, top, right, top, 0x38); + + // left vertical lines + gfx_fill_rect(dpi, left, top, left, top + 3, 0x38); + gfx_fill_rect(dpi, left, bottom - 3, left, bottom, 0x38); + + // bottom horizontal lines + gfx_fill_rect(dpi, left, bottom, left + 3, bottom, 0x38); + gfx_fill_rect(dpi, right - 3, bottom, right, bottom, 0x38); + + // right vertical lines + gfx_fill_rect(dpi, right, top, right, top + 3, 0x38); + gfx_fill_rect(dpi, right, bottom - 3, right, bottom, 0x38); +} + /** * * rct2: 0x0068CF23 @@ -632,11 +800,11 @@ static void window_map_scrollpaint() *g1_element = pushed_g1_element; if (w->selected_tab == 0) - RCT2_CALLPROC_X(0x68DADA, 0, 0, 0, 0, (int)w, (int)dpi, 0); //draws dots representing guests + window_map_paint_peep_overlay(dpi); else - RCT2_CALLPROC_X(0x68DBC1, 0, 0, 0, 0, (int)w, (int)dpi, 0); //draws dots representing trains + window_map_paint_train_overlay(dpi); - RCT2_CALLPROC_X(0x68D8CE, 0, 0, 0, 0, (int)w, (int)dpi, 0); //draws the HUD rectangle on the map + window_map_paint_hud_rectangle(dpi); } /** diff --git a/src/windows/staff_list.c b/src/windows/staff_list.c index b3dc14a47c..f7197f25ca 100644 --- a/src/windows/staff_list.c +++ b/src/windows/staff_list.c @@ -315,13 +315,13 @@ void window_staff_list_update(rct_window *w) w->list_information_type = 0; } else { widget_invalidate(w, WIDX_STAFF_LIST_HANDYMEN_TAB + RCT2_GLOBAL(RCT2_ADDRESS_WINDOW_STAFF_LIST_SELECTED_TAB, uint8)); - RCT2_GLOBAL(0x009AC861, uint16) |= 2; + RCT2_GLOBAL(RCT2_ADDRESS_WINDOW_MAP_FLASHING_FLAGS, uint16) |= (1 << 2); FOR_ALL_PEEPS(spriteIndex, peep) { if (peep->type == PEEP_TYPE_STAFF) { - peep->var_0C &= 0xFDFF; + peep->var_0C &= ~0x200; if (peep->staff_type == RCT2_GLOBAL(RCT2_ADDRESS_WINDOW_STAFF_LIST_SELECTED_TAB, uint8)) { - peep->var_0C &= 0x200; + peep->var_0C |= 0x200; } } }