From 9de7492121100a5509b3fff8e1690a6096d80b4e Mon Sep 17 00:00:00 2001 From: Marijn van der Werf Date: Sat, 30 Apr 2016 22:09:53 +0200 Subject: [PATCH 01/15] Start decompilation of 0x6A3590 --- src/paint/map_element/path.c | 781 ++++++++++++++++++++++++++++++++++- src/world/map.h | 2 +- 2 files changed, 779 insertions(+), 4 deletions(-) diff --git a/src/paint/map_element/path.c b/src/paint/map_element/path.c index ce9b3b83e4..9195640a9c 100644 --- a/src/paint/map_element/path.c +++ b/src/paint/map_element/path.c @@ -16,15 +16,790 @@ #include "map_element.h" #include "../../addresses.h" -#include "../../world/map.h" +#include "../../interface/viewport.h" +#include "../../ride/track.h" +#include "../../world/footpath.h" +#include "../../config.h" +#include "../paint.h" +#include "surface.h" +#include "../../ride/track_paint.h" // #3628: Until path_paint is implemented, this variable is used by scrolling_text_setup // to use the old string arguments array. Remove when scrolling_text_setup is no // longer hooked. bool TempForScrollText = false; -void path_paint(uint8 direction, uint16 height, rct_map_element *mapElement) { +const uint8 byte_98D800[] = { + 12, 9, 3, 6 +}; + +const uint8 byte_98D6E0[] = { + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, + 0, 1, 2, 20, 4, 5, 6, 22, 8, 9, 10, 26, 12, 13, 14, 36, + 0, 1, 2, 3, 4, 5, 21, 23, 8, 9, 10, 11, 12, 13, 33, 37, + 0, 1, 2, 3, 4, 5, 6, 24, 8, 9, 10, 11, 12, 13, 14, 38, + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 29, 30, 34, 39, + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 40, + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 35, 41, + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 42, + 0, 1, 2, 3, 4, 5, 6, 7, 8, 25, 10, 27, 12, 31, 14, 43, + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 28, 12, 13, 14, 44, + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 45, + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 46, + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 32, 14, 47, + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 48, + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 49, + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 50 +}; + +const sint16 stru_98D804[][4] = { + {3, 3, 26, 26}, + {0, 3, 29, 26}, + {3, 3, 26, 29}, + {0, 3, 29, 29}, + {3, 3, 29, 26}, + {0, 3, 32, 26}, + {3, 3, 29, 29}, + {0, 3, 32, 29}, + {3, 0, 26, 29}, + {0, 0, 29, 29}, + {3, 0, 26, 32}, + {0, 0, 29, 32}, + {3, 0, 29, 29}, + {0, 0, 32, 29}, + {3, 0, 29, 32}, + {0, 0, 32, 32}, +}; + +const uint8 byte_98D8A4[] = { + 0, 0, 1, 0, 0, 0, 1, 0, 1, 1, 1, 1, 0, 0, 1, 0 +}; + +typedef struct +{ + uint8 var_0, var_1, var_2, var_3, var_4, var_5, var_6, var_7; +} unk_supports_desc_bound_box; + +const unk_supports_desc_bound_box stru_98D8D4[] = { + {0, 0, 0, 1, 1, 4, 0, 1}, + {0, 0, 0, 1, 1, 4, 0, 1}, + {0, 0, 0, 1, 1, 4, 0, 1}, + {0, 0, 0, 1, 1, 4, 0, 1} +}; + + +void loc_6A37C9(rct_map_element * map_element, int height, rct_footpath_entry * dword_F3EF6C, bool word_F3F038, uint32 dword_F3EF70, uint32 dword_F3EF74); + +void loc_6A3B57(); + +bool is_map_element_saved(rct_map_element * map_element) +{ +// rct_map_element ** savedMapElement = gTrackSavedMapElements; +// while (*gTrackSavedMapElements != (rct_map_element *) 0xFFFFFFFF) { +// if (*gTrackSavedMapElements == map_element) { +// return true; +// } +// +// savedMapElement++; +// } + + return false; +} + +void loc_6A3FED() +{ + +} + +bool do_sub_6A2ECC(int supportType, int special, int height, uint32 imageColourFlags, rct_footpath_entry * dword_F3EF6C, bool * underground) +{ + if (underground != NULL) { + *underground = false; + } + + int eax = special, edx = height, _edi = supportType, ebp = imageColourFlags; + + if (gCurrentViewportFlags & VIEWPORT_FLAG_INVISIBLE_SUPPORTS) { + return false; + } + + if (!(RCT2_GLOBAL(0x0141E9DB, uint8) & 1)) { + return false; + } + + int z = floor2(RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_PAINT_TILE_MAX_HEIGHT, sint16) + 15, 16); + height -= z; + if (height < 0) { + if (underground != NULL) { + *underground = true; + } + return false; + } + height /= 16; + + bool hasSupports = false; + + // Draw base support (usually shaped to the slope) + int slope = RCT2_GLOBAL(0x0141E9DA, uint8); + if (slope & 0x20) { + uint32 image_id = (dword_F3EF6C->bridge_image + 48) | imageColourFlags; + sub_98196C(image_id, 0, 0, 32, 32, 0, z - 2, get_current_rotation()); + hasSupports = true; + } else { + + } + + while (height != 0) { + if ((z & 16) == 0 && height >= 2 && z + 16 != RCT2_GLOBAL(0x00141E9DC, uint16)) { + // Full support + int imageId = (dword_F3EF6C->bridge_image + 22 + supportType * 24) | imageColourFlags; + uint8 ah = height == 2 ? 23 : 28; // weird + sub_98196C(imageId, 0, 0, 32, 32, ah, z, get_current_rotation()); + hasSupports = true; + z += 32; + height -= 2; + } else { + // Half support + int imageId = (dword_F3EF6C->bridge_image + 23 + supportType * 24) | imageColourFlags; + uint8 ah = special == 1 ? 7 : 12; + sub_98196C(imageId, 0, 0, 32, 32, ah, z, get_current_rotation()); + hasSupports = true; + z += 16; + height -= 1; + } + } + + if (special == 0) { + return hasSupports; + } + + special = (special - 1) & 0xFFFF; + + uint32 imageId = (dword_F3EF6C->bridge_image + 55 + special) | imageColourFlags; + + + unk_supports_desc_bound_box stru = stru_98D8D4[special]; + // var_6 is always zero. + + sub_98197C(imageId, 0, 0, stru.var_3, stru.var_4, stru.var_5, z, stru.var_0, stru.var_1, z + stru.var_3, get_current_rotation()); + hasSupports = true; + + return hasSupports; +} + +/** + * rct2: 0x006A4101 + * @param map_element (esi) + * @param (ecx) + * @param ebp (ebp) + * @param base_image_id (0x00F3EF78) + */ +void sub_6A4101(rct_map_element * map_element, uint16 height, uint32 ebp, bool word_F3F038, rct_footpath_entry * dword_F3EF6C, uint32 base_image_id) +{ + if (map_element->type & 1) { + uint8 local_ebp = ebp & 0x0F; + if (map_element->properties.path.type & 0x04) { + switch ((map_element->properties.path.type + get_current_rotation()) & 0x03) { + case 0: + sub_98197C(95 + base_image_id, 0, 4, 32, 1, 23, height, 0, 4, height + 2, get_current_rotation()); + sub_98197C(95 + base_image_id, 0, 28, 32, 1, 23, height, 0, 28, height + 2, get_current_rotation()); + break; + case 1: + sub_98197C(94 + base_image_id, 4, 0, 1, 32, 23, height, 4, 0, height + 2, get_current_rotation()); + sub_98197C(94 + base_image_id, 28, 0, 1, 32, 23, height, 28, 0, height + 2, get_current_rotation()); + break; + case 2: + sub_98197C(96 + base_image_id, 0, 4, 32, 1, 23, height, 0, 4, height + 2, get_current_rotation()); + sub_98197C(96 + base_image_id, 0, 28, 32, 1, 23, height, 0, 28, height + 2, get_current_rotation()); + break; + case 3: + sub_98197C(93 + base_image_id, 4, 0, 1, 32, 23, height, 4, 0, height + 2, get_current_rotation()); + sub_98197C(93 + base_image_id, 28, 0, 1, 32, 23, height, 28, 0, height + 2, get_current_rotation()); + break; + } + } else { + switch (local_ebp) { + case 1: + sub_98197C(90 + base_image_id, 0, 4, 28, 1, 7, height, 0, 4, height + 2, get_current_rotation()); + sub_98197C(90 + base_image_id, 0, 28, 28, 1, 7, height, 0, 28, height + 2, get_current_rotation()); + break; + case 2: + sub_98197C(91 + base_image_id, 4, 0, 1, 28, 7, height, 4, 0, height + 2, get_current_rotation()); + sub_98197C(91 + base_image_id, 28, 0, 1, 28, 7, height, 28, 0, height + 2, get_current_rotation()); + break; + case 3: + sub_98197C(90 + base_image_id, 0, 4, 28, 1, 7, height, 0, 4, height + 2, get_current_rotation()); + sub_98197C(91 + base_image_id, 28, 0, 1, 28, 7, height, 28, 4, height + 2, get_current_rotation()); // bound_box_offset_y seems to be a bug + sub_98197C(98 + base_image_id, 0, 0, 4, 4, 7, height, 0, 28, height + 2, get_current_rotation()); + break; + case 4: + sub_98197C(92 + base_image_id, 0, 4, 28, 1, 7, height, 0, 4, height + 2, get_current_rotation()); + sub_98197C(92 + base_image_id, 0, 28, 28, 1, 7, height, 0, 28, height + 2, get_current_rotation()); + break; + case 5: + sub_98197C(88 + base_image_id, 0, 4, 32, 1, 7, height, 0, 4, height + 2, get_current_rotation()); + sub_98197C(88 + base_image_id, 0, 28, 32, 1, 7, height, 0, 28, height + 2, get_current_rotation()); + break; + case 6: + sub_98197C(91 + base_image_id, 4, 0, 1, 28, 7, height, 4, 0, height + 2, get_current_rotation()); + sub_98197C(92 + base_image_id, 0, 4, 28, 1, 7, height, 0, 4, height + 2, get_current_rotation()); + sub_98197C(99 + base_image_id, 0, 0, 4, 4, 7, height, 28, 28, height + 2, get_current_rotation()); + break; + case 8: + sub_98197C(89 + base_image_id, 4, 0, 1, 28, 7, height, 4, 0, height + 2, get_current_rotation()); + sub_98197C(89 + base_image_id, 28, 0, 1, 28, 7, height, 28, 0, height + 2, get_current_rotation()); + break; + case 9: + sub_98197C(89 + base_image_id, 28, 0, 1, 28, 7, height, 28, 0, height + 2, get_current_rotation()); + sub_98197C(90 + base_image_id, 0, 28, 28, 1, 7, height, 0, 28, height + 2, get_current_rotation()); + sub_98197C(97 + base_image_id, 0, 0, 4, 4, 7, height, 0, 0, height + 2, get_current_rotation()); + break; + case 10: + sub_98197C(87 + base_image_id, 4, 0, 1, 32, 7, height, 4, 0, height + 2, get_current_rotation()); + sub_98197C(87 + base_image_id, 28, 0, 1, 32, 7, height, 28, 0, height + 2, get_current_rotation()); + break; + case 12: + sub_98197C(89 + base_image_id, 4, 0, 1, 28, 7, height, 4, 0, height + 2, get_current_rotation()); + sub_98197C(92 + base_image_id, 0, 28, 28, 1, 7, height, 4, 28, height + 2, get_current_rotation()); // bound_box_offset_x seems to be a bug + sub_98197C(100 + base_image_id, 0, 0, 4, 4, 7, height, 28, 0, height + 2, get_current_rotation()); + break; + default: + // purposely left empty + break; + } + } + + if (!(map_element->properties.path.type & 0x08)) { + return; + } + + // Draw ride sign + RCT2_CALLPROC_X(0x006A4A71, 0, 0, get_current_rotation(), height, (int) map_element, 0, ebp); + return; + } + + + // save ecx, ebp, esi + rct_footpath_entry * ebx = dword_F3EF6C; + uint32 dword_F3EF80 = ebp; + if (!(ebx->flags & 2)) { + dword_F3EF80 &= 0x0F; + } + + if (map_element->properties.path.type & 0x04) { + switch ((map_element->properties.path.type + get_current_rotation()) & 0x03) { + case 0: + sub_98197C(81 + base_image_id, 0, 4, 32, 1, 23, height, 0, 4, height + 2, get_current_rotation()); + sub_98197C(81 + base_image_id, 0, 28, 32, 1, 23, height, 0, 28, height + 2, get_current_rotation()); + break; + case 1: + sub_98197C(80 + base_image_id, 4, 0, 1, 32, 23, height, 4, 0, height + 2, get_current_rotation()); + sub_98197C(80 + base_image_id, 28, 0, 1, 32, 23, height, 28, 0, height + 2, get_current_rotation()); + break; + case 2: + sub_98197C(82 + base_image_id, 0, 4, 32, 1, 23, height, 0, 4, height + 2, get_current_rotation()); + sub_98197C(82 + base_image_id, 0, 28, 32, 1, 23, height, 0, 28, height + 2, get_current_rotation()); + break; + case 3: + sub_98197C(79 + base_image_id, 4, 0, 1, 32, 23, height, 4, 0, height + 2, get_current_rotation()); + sub_98197C(79 + base_image_id, 28, 0, 1, 32, 23, height, 28, 0, height + 2, get_current_rotation()); + break; + } + } else { + if (!word_F3F038) { + return; + } + + uint8 local_ebp = ebp & 0x0F; + switch (local_ebp) { + case 0: + // purposely left empty + break; + case 1: + sub_98197C(76 + base_image_id, 0, 4, 28, 1, 7, height, 0, 4, height + 2, get_current_rotation()); + sub_98197C(76 + base_image_id, 0, 28, 28, 1, 7, height, 0, 28, height + 2, get_current_rotation()); + break; + case 2: + sub_98197C(77 + base_image_id, 4, 0, 1, 28, 7, height, 4, 0, height + 2, get_current_rotation()); + sub_98197C(77 + base_image_id, 28, 0, 1, 28, 7, height, 28, 0, height + 2, get_current_rotation()); + break; + case 4: + sub_98197C(78 + base_image_id, 0, 4, 28, 1, 7, height, 0, 4, height + 2, get_current_rotation()); + sub_98197C(78 + base_image_id, 0, 28, 28, 1, 7, height, 0, 28, height + 2, get_current_rotation()); + break; + case 5: + sub_98197C(74 + base_image_id, 0, 4, 32, 1, 7, height, 0, 4, height + 2, get_current_rotation()); + sub_98197C(74 + base_image_id, 0, 28, 32, 1, 7, height, 0, 28, height + 2, get_current_rotation()); + break; + case 8: + sub_98197C(75 + base_image_id, 4, 0, 1, 28, 7, height, 4, 0, height + 2, get_current_rotation()); + sub_98197C(75 + base_image_id, 28, 0, 1, 28, 7, height, 28, 0, height + 2, get_current_rotation()); + break; + case 10: + sub_98197C(73 + base_image_id, 4, 0, 1, 32, 7, height, 4, 0, height + 2, get_current_rotation()); + sub_98197C(74 + base_image_id, 28, 0, 1, 32, 7, height, 28, 0, height + 2, get_current_rotation()); + break; + + case 3: + sub_98197C(76 + base_image_id, 0, 4, 28, 1, 7, height, 0, 4, height + 2, get_current_rotation()); + sub_98197C(77 + base_image_id, 28, 0, 1, 28, 7, height, 28, 4, height + 2, get_current_rotation()); // bound_box_offset_y seems to be a bug + if (!(dword_F3EF80 & 0x10)) { + sub_98197C(84 + base_image_id, 0, 0, 4, 4, 7, height, 0, 28, height + 2, get_current_rotation()); + } + break; + case 6: + sub_98197C(77 + base_image_id, 4, 0, 1, 28, 7, height, 4, 0, height + 2, get_current_rotation()); + sub_98197C(78 + base_image_id, 0, 4, 28, 1, 7, height, 0, 4, height + 2, get_current_rotation()); + if (!(dword_F3EF80 & 0x20)) { + sub_98197C(85 + base_image_id, 0, 0, 4, 4, 7, height, 28, 28, height + 2, get_current_rotation()); + } + break; + case 9: + sub_98197C(75 + base_image_id, 28, 0, 1, 28, 7, height, 28, 0, height + 2, get_current_rotation()); + sub_98197C(76 + base_image_id, 0, 28, 28, 1, 7, height, 0, 28, height + 2, get_current_rotation()); + if (!(dword_F3EF80 & 0x80)) { + sub_98197C(83 + base_image_id, 0, 0, 4, 4, 7, height, 0, 0, height + 2, get_current_rotation()); + } + break; + case 12: + sub_98197C(75 + base_image_id, 4, 0, 1, 28, 7, height, 4, 0, height + 2, get_current_rotation()); + sub_98197C(78 + base_image_id, 0, 28, 28, 1, 7, height, 4, 28, height + 2, get_current_rotation()); // bound_box_offset_x seems to be a bug + if (!(dword_F3EF80 & 0x40)) { + sub_98197C(86 + base_image_id, 0, 0, 4, 4, 7, height, 28, 0, height + 2, get_current_rotation()); + } + break; + + case 7: + sub_98197C(74 + base_image_id, 0, 4, 32, 1, 7, height, 0, 4, height + 2, get_current_rotation()); + if (!(dword_F3EF80 & 0x10)) { + sub_98197C(84 + base_image_id, 0, 0, 4, 4, 7, height, 0, 28, height + 2, get_current_rotation()); + } + if (!(dword_F3EF80 & 0x20)) { + sub_98197C(85 + base_image_id, 0, 0, 4, 4, 7, height, 28, 28, height + 2, get_current_rotation()); + } + break; + case 13: + sub_98197C(74 + base_image_id, 0, 28, 32, 1, 7, height, 0, 28, height + 2, get_current_rotation()); + if (!(dword_F3EF80 & 0x40)) { + sub_98197C(86 + base_image_id, 0, 0, 4, 4, 7, height, 28, 0, height + 2, get_current_rotation()); + } + if (!(dword_F3EF80 & 0x80)) { + sub_98197C(83 + base_image_id, 0, 0, 4, 4, 7, height, 0, 0, height + 2, get_current_rotation()); + } + break; + case 14: + sub_98197C(73 + base_image_id, 4, 0, 1, 32, 7, height, 4, 0, height + 2, get_current_rotation()); + if (!(dword_F3EF80 & 0x20)) { + sub_98197C(85 + base_image_id, 0, 0, 4, 4, 7, height, 28, 28, height + 2, get_current_rotation()); + } + if (!(dword_F3EF80 & 0x40)) { + sub_98197C(86 + base_image_id, 0, 0, 4, 4, 7, height, 28, 0, height + 2, get_current_rotation()); + } + break; + case 11: + sub_98197C(73 + base_image_id, 28, 0, 1, 32, 7, height, 28, 0, height + 2, get_current_rotation()); + if (!(dword_F3EF80 & 0x10)) { + sub_98197C(84 + base_image_id, 0, 0, 4, 4, 7, height, 0, 28, height + 2, get_current_rotation()); + } + if (!(dword_F3EF80 & 0x80)) { + sub_98197C(83 + base_image_id, 0, 0, 4, 4, 7, height, 0, 0, height + 2, get_current_rotation()); + } + break; + + case 15: + if (!(dword_F3EF80 & 0x10)) { + sub_98197C(84 + base_image_id, 0, 0, 4, 4, 7, height, 0, 28, height + 2, get_current_rotation()); + } + if (!(dword_F3EF80 & 0x20)) { + sub_98197C(85 + base_image_id, 0, 0, 4, 4, 7, height, 28, 28, height + 2, get_current_rotation()); + } + if (!(dword_F3EF80 & 0x40)) { + sub_98197C(86 + base_image_id, 0, 0, 4, 4, 7, height, 28, 0, height + 2, get_current_rotation()); + } + if (!(dword_F3EF80 & 0x80)) { + sub_98197C(83 + base_image_id, 0, 0, 4, 4, 7, height, 0, 0, height + 2, get_current_rotation()); + } + break; + + + } + } + +} + +/** + * rct2: 0x006A3F61 + * @param map_element (esp[0]) + * @param bp (bp) + * @param height (dx) + * @param dword_F3EF6C (0x00F3EF6C) + * @param dword_F3EF70 (0x00F3EF70) + * @param dword_F3EF74 (0x00F3EF74) + */ +void sub_6A3F61(rct_map_element * map_element, uint16 bp, uint16 height, rct_footpath_entry * dword_F3EF6C, uint32 dword_F3EF70, uint32 dword_F3EF74, bool word_F3F038) +{ + // eax -- + // ebx -- + // ecx + // edx + // esi -- + // edi -- + // ebp + // esp: [ esi, ???, 000] + + // Probably drawing benches etc. + + rct_drawpixelinfo * dpi = RCT2_GLOBAL(0x140E9A8, rct_drawpixelinfo*); + + if (dpi->zoom_level <= 1) { + if (!(RCT2_GLOBAL(0x9DEA6F, uint8) & 1)) { + uint8 additions = map_element->properties.path.additions & 0xF; + if (additions != 0) { + RCT2_GLOBAL(RCT2_ADDRESS_PAINT_SETUP_CURRENT_TYPE, uint8) = VIEWPORT_INTERACTION_ITEM_FOOTPATH_ITEM; + if (dword_F3EF74 != 0) { + RCT2_GLOBAL(RCT2_ADDRESS_PAINT_SETUP_CURRENT_TYPE, uint8) = VIEWPORT_INTERACTION_ITEM_NONE; + } + + // loc_6A3F9A: No idea how what is happening here + + RCT2_GLOBAL(RCT2_ADDRESS_PAINT_SETUP_CURRENT_TYPE, uint8) = VIEWPORT_INTERACTION_ITEM_FOOTPATH; + + if (dword_F3EF74 != 0) { + RCT2_GLOBAL(RCT2_ADDRESS_PAINT_SETUP_CURRENT_TYPE, uint8) = VIEWPORT_INTERACTION_ITEM_NONE; + } + } + } + + // Redundant zoom-level check removed + RCT2_GLOBAL(0xF3EF78, uint32) = dword_F3EF6C->image | dword_F3EF70; + //RCT2_CALLPROC_X(0x6A4101, 0, 0, 0, 0, (int) map_element, 0, 0); + sub_6A4101(map_element, height, bp, word_F3F038, dword_F3EF6C, dword_F3EF6C->image | dword_F3EF70); + } + + // This is about tunnel drawing + uint8 direction = (map_element->properties.path.type + get_current_rotation()) & 0x03; + uint8 diagonal = map_element->properties.path.type & 0x04; + uint8 bl = direction | diagonal; + + if (bp & 2) { + // Bottom right of tile is a tunnel + registers regs = {0}; + regs.eax = 0xFFFFFFFF; + if (bl == 5) { + regs.ax = (height + 16) / 16; + regs.ah = 0x0A; + } else if (bp & 1) { + regs.ax = height / 16; + regs.ah = 0x0B; + } else { + regs.ax = height / 16; + regs.ah = 0x0A; + + } + RCT2_ADDRESS(0x009E30B6, uint32)[RCT2_GLOBAL(0x141F56B, uint8) / 2] = regs.eax; + RCT2_GLOBAL(0x141F56B, uint8)++; + } + + if (!(bp & 4)) { + return; + } + + // Bottom left of the tile is a tunnel + registers regs = {0}; + regs.eax = 0xFFFFFFFF; + if (bl == 6) { + regs.ax = (height + 16) / 16; + regs.ah = 0x0A; + } else if (bp & 8) { + regs.ax = height / 16; + regs.ah = 0x0B; + } else { + regs.ax = height / 16; + regs.ah = 0x0A; + + } + RCT2_ADDRESS(0x009E3138, uint32)[RCT2_GLOBAL(0x141F56A, uint8) / 2] = regs.eax; + RCT2_GLOBAL(0x141F56A, uint8)++; +} + +/** + * rct2: 0x0006A3590 + */ +void path_paint(uint8 direction, uint16 height, rct_map_element * map_element) +{ + if (gUseOriginalRidePaint) { + TempForScrollText = true; + RCT2_CALLPROC_X(0x6A3590, 0, 0, direction, height, (int) map_element, 0, 0); + TempForScrollText = false; + return; + } + + + RCT2_GLOBAL(RCT2_ADDRESS_PAINT_SETUP_CURRENT_TYPE, uint8) = VIEWPORT_INTERACTION_ITEM_FOOTPATH; + + uint32 ecx = get_current_rotation(); + bool word_F3F038 = false; + + uint32 dword_F3EF74 = 0; + uint32 dword_F3EF70 = 0; + + if (RCT2_GLOBAL(0x9DEA6F, uint8) & 1) { + if (map_element->type & 1) { + if (map_element->properties.path.ride_index != RCT2_GLOBAL(0x00F64DE8, uint8)) { + return; + } + } + + if (!is_map_element_saved(map_element)) { + dword_F3EF70 = 0x21700000; + } + } + + if (footpath_element_path_scenery_is_ghost(map_element)) { + dword_F3EF74 = RCT2_ADDRESS(0x993CC4, uint32_t)[gConfigGeneral.construction_marker_colour]; + } + + if (map_element->flags & MAP_ELEMENT_FLAG_GHOST) { + RCT2_GLOBAL(RCT2_ADDRESS_PAINT_SETUP_CURRENT_TYPE, uint8) = VIEWPORT_INTERACTION_ITEM_NONE; + dword_F3EF70 = RCT2_ADDRESS(0x993CC4, uint32_t)[gConfigGeneral.construction_marker_colour]; + } + + sint16 x = RCT2_GLOBAL(0x009DE56A, sint16), y = RCT2_GLOBAL(0x009DE56E, sint16); + + rct_map_element * surface = map_get_surface_element_at(x / 32, y / 32); + + uint16 bl = height / 8; + if (surface == NULL) { + word_F3F038 = true; + } else if (surface->base_height != bl) { + word_F3F038 = true; + } else { + if (map_element->properties.path.type & 0x04) { + // Diagonal path + + if ((surface->properties.surface.slope & 0x1F) != byte_98D800[map_element->properties.path.type & 0x03]) { + word_F3F038 = true; + } + } else { + if (surface->properties.surface.slope & 0x1F) { + word_F3F038 = true; + } + } + } + + if (RCT2_GLOBAL(0x009DEA50, sint16) != -1) { + sint32 staffIndex = RCT2_GLOBAL(0x009DEA50, sint16); + uint8 staffType = staffIndex & 0x7FFF; + sint16 x = RCT2_GLOBAL(0x009DE56A, sint16), y = RCT2_GLOBAL(0x009DE56E, sint16); + + uint8 patrolColour = COLOUR_LIGHT_BLUE; + + x = (x & 0x1F80) >> 7; + y = (y & 0x1F80) >> 1; + int offset = (x | y) >> 5; + int bitIndex = (x | y) & 0x1F; + + bool do_it = false; + + if (staffIndex >= 0) { + rct_peep * staff = GET_PEEP(staffIndex); + if (RCT2_ADDRESS(RCT2_ADDRESS_STAFF_PATROL_AREAS + (staff->staff_id * 512), uint32)[offset] & (1 << bitIndex)) { + do_it = true; + } else { + patrolColour = COLOUR_GREY; + staffType = (staff->staff_type + 200) * 512; + if (RCT2_ADDRESS(RCT2_ADDRESS_STAFF_PATROL_AREAS + staffType, uint32)[offset] & (1 << bitIndex)) { + do_it = true; + } + } + } else { + staffType = (staffType + 200) * 512; + if (RCT2_ADDRESS(RCT2_ADDRESS_STAFF_PATROL_AREAS + staffType, uint32)[offset] & (1 << bitIndex)) { + do_it = true; + } + } + + if (do_it) { + uint32 imageId = 2618; + int height = map_element->base_height * 8; + if (map_element->properties.path.type & 0x04) { + imageId = 2619 + ((map_element->properties.path.type + get_current_rotation()) & 3); + height += 16; + } + + sub_98196C(imageId | patrolColour << 19 | 0x20000000, 16, 16, 1, 1, 0, height + 2, get_current_rotation()); + } + } + + + if (gCurrentViewportFlags & VIEWPORT_FLAG_PATH_HEIGHTS) { + uint16 height = 3 + map_element->base_height * 8; + if (map_element->properties.path.type & 0x04) { + height += 8; + } + uint32 imageId = (SPR_HEIGHT_MARKER_BASE + height / 16) | COLOUR_GREY << 19 | 0x20000000; + imageId += RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_HEIGHT_MARKERS, uint16); + imageId -= RCT2_GLOBAL(0x01359208, uint16); + sub_98196C(imageId, 16, 16, 1, 1, 0, height, get_current_rotation()); + } + + uint8 pathType = (map_element->properties.path.type & 0xF0) >> 4; + rct_footpath_entry * dword_F3EF6C = gFootpathEntries[pathType]; + TempForScrollText = true; - RCT2_CALLPROC_X(0x6A3590, 0, 0, direction, height, (int)mapElement, 0, 0); + if (dword_F3EF6C->var_0A == 0) { + loc_6A37C9(map_element, height, dword_F3EF6C, word_F3F038, dword_F3EF70, dword_F3EF74); + } else { + loc_6A3B57(); + RCT2_GLOBAL(0x00F3EF6C, uint32) = (uint32) dword_F3EF6C; + RCT2_GLOBAL(0x00F3F038, uint16) = word_F3F038; + RCT2_GLOBAL(0x00F3EF70, uint16) = dword_F3EF70; + RCT2_GLOBAL(0x00F3EF74, uint16) = dword_F3EF74; + RCT2_CALLPROC_X(0x6A3B57, 0, 0, get_current_rotation(), height, (int) map_element, 0, 0); + } TempForScrollText = false; } + +void loc_6A37C9(rct_map_element * map_element, int height, rct_footpath_entry * dword_F3EF6C, bool word_F3F038, uint32 dword_F3EF70, uint32 dword_F3EF74) +{ + // esi: mapElement + // ecx: get_current_rotation(); + registers regs = {0}; + regs.al = map_element->properties.path.edges; + regs.ah = regs.al << 4; + + uint8 edi_index = rol16(regs.ax, get_current_rotation()) & 0xF; + // stru_98D804[edi_index]; +// mov eax, dword ptr ds:stru_98D804.anonymous_0[edi*8] +// mov ebx, dword ptr ds:stru_98D804.anonymous_1[edi*8] +// mov dword ptr _boundbox_offset_x, eax +// mov dword ptr word_F3EFC8, ebx + rct_xy16 boundBoxOffset = {.x =stru_98D804[edi_index][0], .y = stru_98D804[edi_index][1]}; + rct_xy16 boundBoxSize = {.x =stru_98D804[edi_index][2], .y = stru_98D804[edi_index][3]}; + + regs.al = map_element->properties.path.edges; + regs.ah = regs.al >> 4; + regs.ax = (rol16(regs.ax, get_current_rotation()) >> 4) & 0xF0; + + uint16 edi = edi_index | regs.ax; + + uint32 ebx; + if (map_element->properties.path.type & 0x04) { + ebx = ((map_element->properties.path.type + get_current_rotation()) & 3) + 16; + } else { + ebx = byte_98D6E0[edi]; + } + + // save edi + + ebx += dword_F3EF6C->image; + if (map_element_get_direction(map_element) & 1) { + ebx += 51; + } + + if (!RCT2_GLOBAL(0x9DE57C, bool)) { + boundBoxOffset.x = 3; + boundBoxOffset.y = 3; + boundBoxSize.x = 26; + boundBoxSize.y = 26; + } + + if (!word_F3F038 || !RCT2_GLOBAL(0x9DE57C, bool)) { + sub_98197C(ebx | dword_F3EF70, 0, 0, boundBoxSize.x, boundBoxSize.y, 0, height, boundBoxOffset.x, boundBoxOffset.y, height + 1, get_current_rotation()); + } else { + uint32 image_id; + if (map_element->properties.path.type & 0x04) { + image_id = ((map_element->properties.path.type + get_current_rotation()) & 3) + dword_F3EF6C->bridge_image + 51; + } else { + image_id = byte_98D8A4[edi_index] + dword_F3EF6C->bridge_image + 49; + } + + sub_98197C(image_id | dword_F3EF70, 0, 0, boundBoxSize.x, boundBoxSize.y, 0, height, boundBoxOffset.x, boundBoxOffset.y, height + 1, get_current_rotation()); + + if (!(map_element->type & 1) && !(dword_F3EF6C->flags & 2)) { + // don't draw + } else { + sub_98199C(ebx | dword_F3EF70, 0, 0, boundBoxSize.x, boundBoxSize.y, 0, height, boundBoxOffset.x, boundBoxOffset.y, height + 1, get_current_rotation()); + } + } + + + sub_6A3F61(map_element, edi, height, dword_F3EF6C, dword_F3EF70, dword_F3EF74, word_F3F038); // TODO: arguments + + uint16 ax = 0; + if (map_element->properties.path.type & 0x04) { + ax = ((map_element->properties.path.type + get_current_rotation()) & 0x3) + 1; + } + + uint32 ebp = edi; + ebx = ebp & 0xF; + + if (byte_98D8A4[ebx] == 0) { + do_sub_6A2ECC(0, ax, height, dword_F3EF70, dword_F3EF6C, NULL); + } else { + do_sub_6A2ECC(1, ax, height, dword_F3EF70, dword_F3EF6C, NULL); + } + + + sint16 x = RCT2_GLOBAL(0x009DE56A, sint16), y = RCT2_GLOBAL(0x009DE56E, sint16); + + height += 32; + if (map_element->properties.path.type & 0x04) { + height += 16; + } + + if (RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_PAINT_TILE_MAX_HEIGHT, sint16) < height) { + RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_PAINT_TILE_MAX_HEIGHT, sint16) = height; + RCT2_GLOBAL(0x141E9DA, uint8) = 0x20; + } + + if (map_element->type & 1 + || (map_element->properties.path.edges != 0xFF && word_F3F038) + ) { + RCT2_GLOBAL(0x141E9C4, uint16) = 0xFFFF; + RCT2_GLOBAL(0x141E9C8, uint16) = 0xFFFF; + RCT2_GLOBAL(0x141E9CC, uint16) = 0xFFFF; + RCT2_GLOBAL(0x141E9D0, uint16) = 0xFFFF; + RCT2_GLOBAL(0x141E9D4, uint16) = 0xFFFF; + RCT2_GLOBAL(0x141E9B4, uint16) = 0xFFFF; + RCT2_GLOBAL(0x141E9C0, uint16) = 0xFFFF; + RCT2_GLOBAL(0x141E9B8, uint16) = 0xFFFF; + RCT2_GLOBAL(0x141E9BC, uint16) = 0xFFFF; + return; + } + + if (map_element->properties.path.edges == 0xFF) { + RCT2_GLOBAL(0x141E9C8, uint16) = 0xFFFF; + RCT2_GLOBAL(0x141E9CC, uint16) = 0xFFFF; + RCT2_GLOBAL(0x141E9D0, uint16) = 0xFFFF; + RCT2_GLOBAL(0x141E9D4, uint16) = 0xFFFF; + return; + } + + RCT2_GLOBAL(0x141E9C4, uint16) = 0xFFFF; + + // no idea whre bp comes from + uint16 bp = 0; + + if (bp & 1) { + RCT2_GLOBAL(0x141E9CC, uint16) = 0xFFFF; + } + + if (bp & 2) { + RCT2_GLOBAL(0x141E9D4, uint16) = 0xFFFF; + } + + if (bp & 4) { + RCT2_GLOBAL(0x141E9D0, uint16) = 0xFFFF; + } + + if (bp & 8) { + RCT2_GLOBAL(0x141E9C8, uint16) = 0xFFFF; + } + +} + +void loc_6A3B57() +{ + +} \ No newline at end of file diff --git a/src/world/map.h b/src/world/map.h index 9d9e5a8329..03deaebbf3 100644 --- a/src/world/map.h +++ b/src/world/map.h @@ -29,7 +29,7 @@ typedef struct rct_map_element_surface_properties { assert_struct_size(rct_map_element_surface_properties, 4); typedef struct rct_map_element_path_properties { - uint8 type; //4 0xF0 Path type, 0x08 Unknown/Unused, 0x04 Set when path is diagonal, 0x03 Rotation + uint8 type; //4 0xF0 Path type, 0x08 Ride sign, 0x04 Set when path is diagonal, 0x03 Rotation uint8 additions; //5 uint8 edges; //6 union { From a37d5e7382771014d4ed0e18a91811b88afc412c Mon Sep 17 00:00:00 2001 From: duncanspumpkin Date: Sun, 5 Jun 2016 18:35:02 +0100 Subject: [PATCH 02/15] Finish var_0A paths --- src/paint/map_element/path.c | 86 ++++++++++++++++++++++++++---------- src/world/footpath.h | 1 + 2 files changed, 64 insertions(+), 23 deletions(-) diff --git a/src/paint/map_element/path.c b/src/paint/map_element/path.c index 9195640a9c..1225a6312a 100644 --- a/src/paint/map_element/path.c +++ b/src/paint/map_element/path.c @@ -23,6 +23,8 @@ #include "../paint.h" #include "surface.h" #include "../../ride/track_paint.h" +#include "../../localisation/localisation.h" +#include "../../game.h" // #3628: Until path_paint is implemented, this variable is used by scrolling_text_setup // to use the old string arguments array. Remove when scrolling_text_setup is no @@ -92,25 +94,6 @@ void loc_6A37C9(rct_map_element * map_element, int height, rct_footpath_entry * void loc_6A3B57(); -bool is_map_element_saved(rct_map_element * map_element) -{ -// rct_map_element ** savedMapElement = gTrackSavedMapElements; -// while (*gTrackSavedMapElements != (rct_map_element *) 0xFFFFFFFF) { -// if (*gTrackSavedMapElements == map_element) { -// return true; -// } -// -// savedMapElement++; -// } - - return false; -} - -void loc_6A3FED() -{ - -} - bool do_sub_6A2ECC(int supportType, int special, int height, uint32 imageColourFlags, rct_footpath_entry * dword_F3EF6C, bool * underground) { if (underground != NULL) { @@ -194,7 +177,7 @@ bool do_sub_6A2ECC(int supportType, int special, int height, uint32 imageColourF * @param ebp (ebp) * @param base_image_id (0x00F3EF78) */ -void sub_6A4101(rct_map_element * map_element, uint16 height, uint32 ebp, bool word_F3F038, rct_footpath_entry * dword_F3EF6C, uint32 base_image_id) +void sub_6A4101(rct_map_element * map_element, uint16 height, uint32 ebp, bool word_F3F038, rct_footpath_entry * dword_F3EF6C, uint32 base_image_id, uint32 dword_F3EF70) { if (map_element->type & 1) { uint8 local_ebp = ebp & 0x0F; @@ -273,8 +256,65 @@ void sub_6A4101(rct_map_element * map_element, uint16 height, uint32 ebp, bool w return; } + uint8 direction = ((map_element->type & 0xC0) >> 6); // Draw ride sign - RCT2_CALLPROC_X(0x006A4A71, 0, 0, get_current_rotation(), height, (int) map_element, 0, ebp); + RCT2_GLOBAL(RCT2_ADDRESS_PAINT_SETUP_CURRENT_TYPE, uint8) = VIEWPORT_INTERACTION_ITEM_RIDE; + if (footpath_element_is_sloped(map_element)) { + if (footpath_element_get_slope_direction(map_element) == direction) + height += 16; + } + direction += get_current_rotation(); + direction &= 3; + + rct_xyz16 boundBoxOffsets = { + .x = RCT2_ADDRESS(0x0098D884, sint16)[direction * 4], + .y = RCT2_ADDRESS(0x0098D884 + 2, sint16)[direction * 4], + .z = height + 2 + }; + + uint32 imageId = (direction << 1) + base_image_id + 101; + + sub_98197C(imageId, 0, 0, 1, 1, 21, height, boundBoxOffsets.x, boundBoxOffsets.y, boundBoxOffsets.z, get_current_rotation()); + + boundBoxOffsets.x = RCT2_ADDRESS(0x98D888, sint16)[direction * 4]; + boundBoxOffsets.y = RCT2_ADDRESS(0x98D888 + 2, sint16)[direction * 4]; + imageId++; + sub_98197C(imageId, 0, 0, 1, 1, 21, height, boundBoxOffsets.x, boundBoxOffsets.y, boundBoxOffsets.z, get_current_rotation()); + + direction--; + // If text shown + if (direction < 2 && map_element->properties.path.ride_index != 255 && dword_F3EF70 == 0) { + uint16 scrollingMode = dword_F3EF6C->scrolling_mode; + scrollingMode += direction; + + set_format_arg(0, uint32, 0); + set_format_arg(4, uint32, 0); + + rct_ride* ride = get_ride(map_element->properties.path.ride_index); + rct_string_id string_id = STR_RIDE_ENTRANCE_CLOSED; + if (ride->status == RIDE_STATUS_OPEN && !(ride->lifecycle_flags & RIDE_LIFECYCLE_BROKEN_DOWN)){ + set_format_arg(0, uint16, ride->name); + set_format_arg(2, uint32, ride->name_arguments); + string_id = STR_RIDE_ENTRANCE_NAME; + } + if (gConfigGeneral.upper_case_banners) { + format_string_to_upper(RCT2_ADDRESS(RCT2_ADDRESS_COMMON_STRING_FORMAT_BUFFER, char), string_id, gCommonFormatArgs); + } else { + format_string(RCT2_ADDRESS(RCT2_ADDRESS_COMMON_STRING_FORMAT_BUFFER, char), string_id, gCommonFormatArgs); + } + + gCurrentFontSpriteBase = FONT_SPRITE_BASE_TINY; + + uint16 string_width = gfx_get_string_width(RCT2_ADDRESS(RCT2_ADDRESS_COMMON_STRING_FORMAT_BUFFER, char)); + uint16 scroll = (gCurrentTicks / 2) % string_width; + + sub_98199C(scrolling_text_setup(string_id, scroll, scrollingMode), 0, 0, 1, 1, 21, height + 7, boundBoxOffsets.x, boundBoxOffsets.y, boundBoxOffsets.z, get_current_rotation()); + } + + RCT2_GLOBAL(RCT2_ADDRESS_PAINT_SETUP_CURRENT_TYPE, uint8) = VIEWPORT_INTERACTION_ITEM_FOOTPATH; + if (dword_F3EF70 != 0) { + RCT2_GLOBAL(RCT2_ADDRESS_PAINT_SETUP_CURRENT_TYPE, uint8) = VIEWPORT_INTERACTION_ITEM_NONE; + } return; } @@ -473,7 +513,7 @@ void sub_6A3F61(rct_map_element * map_element, uint16 bp, uint16 height, rct_foo // Redundant zoom-level check removed RCT2_GLOBAL(0xF3EF78, uint32) = dword_F3EF6C->image | dword_F3EF70; //RCT2_CALLPROC_X(0x6A4101, 0, 0, 0, 0, (int) map_element, 0, 0); - sub_6A4101(map_element, height, bp, word_F3F038, dword_F3EF6C, dword_F3EF6C->image | dword_F3EF70); + sub_6A4101(map_element, height, bp, word_F3F038, dword_F3EF6C, dword_F3EF6C->image | dword_F3EF70, dword_F3EF70); } // This is about tunnel drawing @@ -550,7 +590,7 @@ void path_paint(uint8 direction, uint16 height, rct_map_element * map_element) } } - if (!is_map_element_saved(map_element)) { + if (!track_design_save_contains_map_element(map_element)) { dword_F3EF70 = 0x21700000; } } diff --git a/src/world/footpath.h b/src/world/footpath.h index 394f8b8ff7..d45c76d947 100644 --- a/src/world/footpath.h +++ b/src/world/footpath.h @@ -34,6 +34,7 @@ typedef struct rct_footpath_entry { uint32 bridge_image; // 0x06 uint8 var_0A; uint8 flags; // 0x0B + uint8 scrolling_mode; // 0x0C } rct_footpath_entry; assert_struct_size(rct_footpath_entry, 12); #pragma pack(pop) From 980e6ca30a6d833aec7d690caeacbffd22911269 Mon Sep 17 00:00:00 2001 From: duncanspumpkin Date: Sun, 5 Jun 2016 19:56:57 +0100 Subject: [PATCH 03/15] Start last part --- src/paint/map_element/path.c | 134 ++++++++++++++++++++++++++++++++++- src/paint/supports.c | 2 +- src/paint/supports.h | 1 + 3 files changed, 133 insertions(+), 4 deletions(-) diff --git a/src/paint/map_element/path.c b/src/paint/map_element/path.c index 1225a6312a..b149cbd65b 100644 --- a/src/paint/map_element/path.c +++ b/src/paint/map_element/path.c @@ -25,6 +25,7 @@ #include "../../ride/track_paint.h" #include "../../localisation/localisation.h" #include "../../game.h" +#include "../supports.h" // #3628: Until path_paint is implemented, this variable is used by scrolling_text_setup // to use the old string arguments array. Remove when scrolling_text_setup is no @@ -690,12 +691,12 @@ void path_paint(uint8 direction, uint16 height, rct_map_element * map_element) if (dword_F3EF6C->var_0A == 0) { loc_6A37C9(map_element, height, dword_F3EF6C, word_F3F038, dword_F3EF70, dword_F3EF74); } else { - loc_6A3B57(); + loc_6A3B57(map_element, height, dword_F3EF6C, word_F3F038, dword_F3EF70, dword_F3EF74); RCT2_GLOBAL(0x00F3EF6C, uint32) = (uint32) dword_F3EF6C; RCT2_GLOBAL(0x00F3F038, uint16) = word_F3F038; RCT2_GLOBAL(0x00F3EF70, uint16) = dword_F3EF70; RCT2_GLOBAL(0x00F3EF74, uint16) = dword_F3EF74; - RCT2_CALLPROC_X(0x6A3B57, 0, 0, get_current_rotation(), height, (int) map_element, 0, 0); + //RCT2_CALLPROC_X(0x6A3B57, 0, 0, get_current_rotation(), height, (int) map_element, 0, 0); } TempForScrollText = false; } @@ -839,7 +840,134 @@ void loc_6A37C9(rct_map_element * map_element, int height, rct_footpath_entry * } -void loc_6A3B57() +void loc_6A3B57(rct_map_element* mapElement, sint16 height, rct_footpath_entry* footpathEntry, bool hasFences, uint32 imageFlags, uint32 sceneryImageFlags) { + uint8 type = footpath_element_get_type(mapElement); + // Rol edges around rotation + uint8 edges = ((mapElement->properties.path.edges << get_current_rotation()) & 0xF) | + ((mapElement->properties.path.edges << get_current_rotation()) >> 4); + + rct_xy16 boundBoxOffset = { + .x = stru_98D804[edges][0], + .y = stru_98D804[edges][1] + }; + + rct_xy16 boundBoxSize = { + .x = stru_98D804[edges][2], + .y = stru_98D804[edges][3] + }; + + uint8 corners = (((mapElement->properties.path.edges >> 4) << get_current_rotation()) & 0xF) | + (((mapElement->properties.path.edges >> 4) << get_current_rotation()) >> 4); + + uint16 edi = edges | (corners << 4); + + uint32 imageId; + if (footpath_element_is_sloped(mapElement)) { + imageId = ((mapElement->properties.path.type + get_current_rotation()) & 3) + 16; + } + else { + imageId = byte_98D6E0[edi]; + } + + + imageId += footpathEntry->image; + if (mapElement->type & 1) { + imageId += 51; + } + + // Below Surface + if (!RCT2_GLOBAL(0x9DE57C, bool)) { + boundBoxOffset.x = 3; + boundBoxOffset.y = 3; + boundBoxSize.x = 26; + boundBoxSize.y = 26; + } + + if (!hasFences || !RCT2_GLOBAL(0x9DE57C, bool)) { + sub_98197C(imageId | imageFlags, 0, 0, boundBoxSize.x, boundBoxSize.y, 0, height, boundBoxOffset.x, boundBoxOffset.y, height + 1, get_current_rotation()); + } + else { + uint32 bridgeImage; + if (footpath_element_is_sloped(mapElement)) { + bridgeImage = ((mapElement->properties.path.type + get_current_rotation()) & 3) + footpathEntry->bridge_image + 16; + } + else { + bridgeImage = edges + footpathEntry->bridge_image; + bridgeImage |= imageFlags; + } + + sub_98197C(bridgeImage | imageFlags, 0, 0, boundBoxSize.x, boundBoxSize.y, 0, height, boundBoxOffset.x, boundBoxOffset.y, height + 1, get_current_rotation()); + + if ((mapElement->type & 1) || (footpathEntry->flags & 2)) { + sub_98199C(imageId | imageFlags, 0, 0, boundBoxSize.x, boundBoxSize.y, 0, height, boundBoxOffset.x, boundBoxOffset.y, height + 1, get_current_rotation()); + } + } + + sub_6A3F61(mapElement, edi, height, footpathEntry, imageFlags, sceneryImageFlags, hasFences); // TODO: arguments + + uint16 ax = 0; + if (footpath_element_is_sloped(mapElement)) { + ax = 8; + } + + uint8 supports[] = { + 6, + 8, + 7, + 5 + }; + + for (sint8 i = 3; i > -1; --i) { + if (!(edges & (1 << i))) { + path_wooden_a_supports_paint_setup(supports[i], ax, height, imageFlags); + } + } + + sint16 x = RCT2_GLOBAL(0x009DE56A, sint16), y = RCT2_GLOBAL(0x009DE56E, sint16); + + height += 32; + if (footpath_element_is_sloped(mapElement)) { + height += 16; + } + + paint_util_set_general_support_height(height, 0x20); + + if ((mapElement->type & 1) + || (mapElement->properties.path.edges != 0xFF && hasFences) + ) { + + paint_util_set_segment_support_height(SEGMENTS_ALL, 0xFFFF, 0); + return; + } + + //if (map_element->properties.path.edges == 0xFF) { + // RCT2_GLOBAL(0x141E9C8, uint16) = 0xFFFF; + // RCT2_GLOBAL(0x141E9CC, uint16) = 0xFFFF; + // RCT2_GLOBAL(0x141E9D0, uint16) = 0xFFFF; + // RCT2_GLOBAL(0x141E9D4, uint16) = 0xFFFF; + // return; + //} + + //RCT2_GLOBAL(0x141E9C4, uint16) = 0xFFFF; + + //// no idea whre bp comes from + //uint16 bp = 0; + + //if (bp & 1) { + // RCT2_GLOBAL(0x141E9CC, uint16) = 0xFFFF; + //} + + //if (bp & 2) { + // RCT2_GLOBAL(0x141E9D4, uint16) = 0xFFFF; + //} + + //if (bp & 4) { + // RCT2_GLOBAL(0x141E9D0, uint16) = 0xFFFF; + //} + + //if (bp & 8) { + // RCT2_GLOBAL(0x141E9C8, uint16) = 0xFFFF; + //} } \ No newline at end of file diff --git a/src/paint/supports.c b/src/paint/supports.c index cbc676416f..6ffb43f0f8 100644 --- a/src/paint/supports.c +++ b/src/paint/supports.c @@ -533,7 +533,7 @@ bool sub_6A2ECC(int supportType, int special, int height, uint32 imageColourFlag */ bool path_wooden_a_supports_paint_setup(int supportType, int special, int height, uint32 imageColourFlags) { - int eax = special, ebx = 0, ecx = 0, edx = height, esi = 0, _edi = supportType, ebp = imageColourFlags; + int eax = special, ebx = supportType, ecx = 0, edx = height, esi = 0, _edi = 0, ebp = imageColourFlags; RCT2_CALLFUNC_X(0x006A326B, &eax, &ebx, &ecx, &edx, &esi, &_edi, &ebp); return eax & 0xFF; } diff --git a/src/paint/supports.h b/src/paint/supports.h index eefde8536f..9ae37dd22d 100644 --- a/src/paint/supports.h +++ b/src/paint/supports.h @@ -23,5 +23,6 @@ bool wooden_a_supports_paint_setup(int supportType, int special, int height, uin bool wooden_b_supports_paint_setup(int supportType, int special, int height, uint32 imageColourFlags); bool metal_a_supports_paint_setup(int supportType, int segment, int special, int height, uint32 imageColourFlags); bool metal_b_supports_paint_setup(int supportType, uint8 segment, int special, int height, uint32 imageColourFlags); +bool path_wooden_a_supports_paint_setup(int supportType, int special, int height, uint32 imageColourFlags); #endif From fc296428fd8b4a84116257bdcd8b0c72d4b6ac1c Mon Sep 17 00:00:00 2001 From: duncanspumpkin Date: Mon, 6 Jun 2016 17:21:54 +0100 Subject: [PATCH 04/15] Finish function. Readd path additions. Fix scrolling text --- src/paint/map_element/path.c | 53 +++++++++++++++--------------------- 1 file changed, 22 insertions(+), 31 deletions(-) diff --git a/src/paint/map_element/path.c b/src/paint/map_element/path.c index b149cbd65b..f7bba20ee6 100644 --- a/src/paint/map_element/path.c +++ b/src/paint/map_element/path.c @@ -21,6 +21,7 @@ #include "../../world/footpath.h" #include "../../config.h" #include "../paint.h" +#include "../../world/scenery.h" #include "surface.h" #include "../../ride/track_paint.h" #include "../../localisation/localisation.h" @@ -501,7 +502,9 @@ void sub_6A3F61(rct_map_element * map_element, uint16 bp, uint16 height, rct_foo RCT2_GLOBAL(RCT2_ADDRESS_PAINT_SETUP_CURRENT_TYPE, uint8) = VIEWPORT_INTERACTION_ITEM_NONE; } - // loc_6A3F9A: No idea how what is happening here + // Draw additional path bits (i.e. bins) + rct_scenery_entry* sceneryEntry = get_footpath_item_entry(footpath_element_get_path_scenery_index(map_element)); + RCT2_CALLPROC_X(RCT2_ADDRESS(0x0098D8FC, uint32)[sceneryEntry->path_bit.var_08], 0, (int)sceneryEntry, get_current_rotation(), height, (int)map_element, 0, bp); RCT2_GLOBAL(RCT2_ADDRESS_PAINT_SETUP_CURRENT_TYPE, uint8) = VIEWPORT_INTERACTION_ITEM_FOOTPATH; @@ -687,18 +690,11 @@ void path_paint(uint8 direction, uint16 height, rct_map_element * map_element) uint8 pathType = (map_element->properties.path.type & 0xF0) >> 4; rct_footpath_entry * dword_F3EF6C = gFootpathEntries[pathType]; - TempForScrollText = true; if (dword_F3EF6C->var_0A == 0) { loc_6A37C9(map_element, height, dword_F3EF6C, word_F3F038, dword_F3EF70, dword_F3EF74); } else { loc_6A3B57(map_element, height, dword_F3EF6C, word_F3F038, dword_F3EF70, dword_F3EF74); - RCT2_GLOBAL(0x00F3EF6C, uint32) = (uint32) dword_F3EF6C; - RCT2_GLOBAL(0x00F3F038, uint16) = word_F3F038; - RCT2_GLOBAL(0x00F3EF70, uint16) = dword_F3EF70; - RCT2_GLOBAL(0x00F3EF74, uint16) = dword_F3EF74; - //RCT2_CALLPROC_X(0x6A3B57, 0, 0, get_current_rotation(), height, (int) map_element, 0, 0); } - TempForScrollText = false; } void loc_6A37C9(rct_map_element * map_element, int height, rct_footpath_entry * dword_F3EF6C, bool word_F3F038, uint32 dword_F3EF70, uint32 dword_F3EF74) @@ -918,6 +914,7 @@ void loc_6A3B57(rct_map_element* mapElement, sint16 height, rct_footpath_entry* 5 }; + RCT2_GLOBAL(0x00F3EF6C, rct_footpath_entry*) = footpathEntry; for (sint8 i = 3; i > -1; --i) { if (!(edges & (1 << i))) { path_wooden_a_supports_paint_setup(supports[i], ax, height, imageFlags); @@ -941,33 +938,27 @@ void loc_6A3B57(rct_map_element* mapElement, sint16 height, rct_footpath_entry* return; } - //if (map_element->properties.path.edges == 0xFF) { - // RCT2_GLOBAL(0x141E9C8, uint16) = 0xFFFF; - // RCT2_GLOBAL(0x141E9CC, uint16) = 0xFFFF; - // RCT2_GLOBAL(0x141E9D0, uint16) = 0xFFFF; - // RCT2_GLOBAL(0x141E9D4, uint16) = 0xFFFF; - // return; - //} + if (mapElement->properties.path.edges == 0xFF) { + paint_util_set_segment_support_height(SEGMENT_C8 | SEGMENT_CC | SEGMENT_D0 | SEGMENT_D4, 0xFFFF, 0); + return; + } - //RCT2_GLOBAL(0x141E9C4, uint16) = 0xFFFF; + paint_util_set_segment_support_height(SEGMENT_C4, 0xFFFF, 0); - //// no idea whre bp comes from - //uint16 bp = 0; + if (edges & 1) { + paint_util_set_segment_support_height(SEGMENT_CC, 0xFFFF, 0); + } - //if (bp & 1) { - // RCT2_GLOBAL(0x141E9CC, uint16) = 0xFFFF; - //} + if (edges & 2) { + paint_util_set_segment_support_height(SEGMENT_D4, 0xFFFF, 0); + } - //if (bp & 2) { - // RCT2_GLOBAL(0x141E9D4, uint16) = 0xFFFF; - //} + if (edges & 4) { + paint_util_set_segment_support_height(SEGMENT_D0, 0xFFFF, 0); + } - //if (bp & 4) { - // RCT2_GLOBAL(0x141E9D0, uint16) = 0xFFFF; - //} - - //if (bp & 8) { - // RCT2_GLOBAL(0x141E9C8, uint16) = 0xFFFF; - //} + if (edges & 8) { + paint_util_set_segment_support_height(SEGMENT_C8, 0xFFFF, 0); + } } \ No newline at end of file From 1099a17686d455f6512514f3009fcfa253177781 Mon Sep 17 00:00:00 2001 From: duncanspumpkin Date: Mon, 6 Jun 2016 17:26:42 +0100 Subject: [PATCH 05/15] Fix minor issue with declaration --- src/paint/map_element/path.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/paint/map_element/path.c b/src/paint/map_element/path.c index f7bba20ee6..06141ec4a0 100644 --- a/src/paint/map_element/path.c +++ b/src/paint/map_element/path.c @@ -94,7 +94,7 @@ const unk_supports_desc_bound_box stru_98D8D4[] = { void loc_6A37C9(rct_map_element * map_element, int height, rct_footpath_entry * dword_F3EF6C, bool word_F3F038, uint32 dword_F3EF70, uint32 dword_F3EF74); -void loc_6A3B57(); +void loc_6A3B57(rct_map_element* mapElement, sint16 height, rct_footpath_entry* footpathEntry, bool hasFences, uint32 imageFlags, uint32 sceneryImageFlags); bool do_sub_6A2ECC(int supportType, int special, int height, uint32 imageColourFlags, rct_footpath_entry * dword_F3EF6C, bool * underground) { @@ -502,7 +502,7 @@ void sub_6A3F61(rct_map_element * map_element, uint16 bp, uint16 height, rct_foo RCT2_GLOBAL(RCT2_ADDRESS_PAINT_SETUP_CURRENT_TYPE, uint8) = VIEWPORT_INTERACTION_ITEM_NONE; } - // Draw additional path bits (i.e. bins) + // Draw additional path bits (bins, benchs, lamps, queue screens) rct_scenery_entry* sceneryEntry = get_footpath_item_entry(footpath_element_get_path_scenery_index(map_element)); RCT2_CALLPROC_X(RCT2_ADDRESS(0x0098D8FC, uint32)[sceneryEntry->path_bit.var_08], 0, (int)sceneryEntry, get_current_rotation(), height, (int)map_element, 0, bp); From 9f467739616956e3e365b89e483cbbb0dfe4954d Mon Sep 17 00:00:00 2001 From: duncanspumpkin Date: Wed, 8 Jun 2016 19:53:55 +0100 Subject: [PATCH 06/15] Start adding path bits paints --- src/paint/map_element/path.c | 151 ++++++++++++++++++++++++++++++++++- 1 file changed, 149 insertions(+), 2 deletions(-) diff --git a/src/paint/map_element/path.c b/src/paint/map_element/path.c index 06141ec4a0..10879b4902 100644 --- a/src/paint/map_element/path.c +++ b/src/paint/map_element/path.c @@ -96,6 +96,140 @@ void loc_6A37C9(rct_map_element * map_element, int height, rct_footpath_entry * void loc_6A3B57(rct_map_element* mapElement, sint16 height, rct_footpath_entry* footpathEntry, bool hasFences, uint32 imageFlags, uint32 sceneryImageFlags); +/* rct2: 0x006A5AE5 */ +void path_bit_lights_paint(rct_scenery_entry* pathBitEntry, rct_map_element* mapElement, int height, uint8 edges, uint32 pathBitImageFlags) { + if (footpath_element_is_sloped(mapElement)) + height += 8; + + uint32 imageId; + + if (!(edges & (1 << 0))) { + imageId = pathBitEntry->image + 1; + + if (mapElement->flags & MAP_ELEMENT_FLAG_BROKEN) + imageId += 4; + + imageId |= pathBitImageFlags; + + sub_98197C(imageId, 2, 16, 1, 1, 23, height, 3, 16, height + 2, get_current_rotation()); + } + if (!(edges & (1 << 1))) { + imageId = pathBitEntry->image + 2; + + if (mapElement->flags & MAP_ELEMENT_FLAG_BROKEN) + imageId += 4; + + imageId |= pathBitImageFlags; + + sub_98197C(imageId, 16, 30, 1, 0, 23, height, 16, 29, height + 2, get_current_rotation()); + } + + if (!(edges & (1 << 2))) { + imageId = pathBitEntry->image + 3; + + if (mapElement->flags & MAP_ELEMENT_FLAG_BROKEN) + imageId += 4; + + imageId |= pathBitImageFlags; + + sub_98197C(imageId, 30, 16, 0, 1, 23, height, 29, 16, height + 2, get_current_rotation()); + } + + if (!(edges & (1 << 3))) { + imageId = pathBitEntry->image + 4; + + if (mapElement->flags & MAP_ELEMENT_FLAG_BROKEN) + imageId += 4; + + imageId |= pathBitImageFlags; + + sub_98197C(imageId, 16, 2, 1, 1, 23, height, 16, 3, height + 2, get_current_rotation()); + } +} + +/* rct2: 0x006A5C94 */ +void path_bit_bins_paint(rct_scenery_entry* pathBitEntry, rct_map_element* mapElement, int height, uint8 edges, uint32 pathBitImageFlags) { + if (footpath_element_is_sloped(mapElement)) + height += 8; + + uint32 imageId; + + if (!(edges & (1 << 0))) { + imageId = pathBitEntry->image + 5; + + imageId |= pathBitImageFlags; + + if (!(mapElement->flags & MAP_ELEMENT_FLAG_BROKEN)) { + imageId -= 4; + + if (!(mapElement->properties.path.addition_status & (0x3 << get_current_rotation()))) + imageId += 8; + } + + + sub_98197C(imageId, 7, 16, 1, 1, 7, height, 7, 16, height + 2, get_current_rotation()); + } + if (!(edges & (1 << 1))) { + imageId = pathBitEntry->image + 6; + + imageId |= pathBitImageFlags; + + if (!(mapElement->flags & MAP_ELEMENT_FLAG_BROKEN)) { + imageId -= 4; + + if (!(mapElement->properties.path.addition_status & rol8(0xC, get_current_rotation()))) + imageId += 8; + } + + + sub_98197C(imageId, 16, 25, 1, 1, 7, height, 16, 25, height + 2, get_current_rotation()); + } + + if (!(edges & (1 << 2))) { + imageId = pathBitEntry->image + 7; + + imageId |= pathBitImageFlags; + + if (!(mapElement->flags & MAP_ELEMENT_FLAG_BROKEN)) { + imageId -= 4; + + if (!(mapElement->properties.path.addition_status & rol8(0x30, get_current_rotation()))) + imageId += 8; + } + + + sub_98197C(imageId, 25, 16, 1, 1, 7, height, 25, 16, height + 2, get_current_rotation()); + } + + if (!(edges & (1 << 3))) { + imageId = pathBitEntry->image + 8; + + imageId |= pathBitImageFlags; + + if (!(mapElement->flags & MAP_ELEMENT_FLAG_BROKEN)) { + imageId -= 4; + + if (!(mapElement->properties.path.addition_status & rol8(0xC0, get_current_rotation()))) + imageId += 8; + } + + + sub_98197C(imageId, 16, 7, 1, 1, 7, height, 16, 7, height + 2, get_current_rotation()); + } +} + +/* rct2: 0x006A5E81 */ +void path_bit_benches_paint(rct_scenery_entry* pathBitEntry, rct_map_element* mapElement, int height, uint8 edges, uint32 pathBitImageFlags) { + RCT2_GLOBAL(0x00F3EF74, uint32) = pathBitImageFlags; + RCT2_CALLPROC_X(0x006A5E81, 0, (int)pathBitEntry, get_current_rotation(), height, (int)mapElement, 0, edges); +} + +/* rct2: 0x006A6008 */ +void path_bit_queue_screens_paint(rct_scenery_entry* pathBitEntry, rct_map_element* mapElement, int height, uint8 edges, uint32 pathBitImageFlags) { + RCT2_GLOBAL(0x00F3EF74, uint32) = pathBitImageFlags; + RCT2_CALLPROC_X(0x006A6008, 0, (int)pathBitEntry, get_current_rotation(), height, (int)mapElement, 0, edges); +} + bool do_sub_6A2ECC(int supportType, int special, int height, uint32 imageColourFlags, rct_footpath_entry * dword_F3EF6C, bool * underground) { if (underground != NULL) { @@ -504,8 +638,21 @@ void sub_6A3F61(rct_map_element * map_element, uint16 bp, uint16 height, rct_foo // Draw additional path bits (bins, benchs, lamps, queue screens) rct_scenery_entry* sceneryEntry = get_footpath_item_entry(footpath_element_get_path_scenery_index(map_element)); - RCT2_CALLPROC_X(RCT2_ADDRESS(0x0098D8FC, uint32)[sceneryEntry->path_bit.var_08], 0, (int)sceneryEntry, get_current_rotation(), height, (int)map_element, 0, bp); - + switch (sceneryEntry->path_bit.var_08) { + case 0: + path_bit_lights_paint(sceneryEntry, map_element, height, (uint8)bp, dword_F3EF74); + break; + case 1: + path_bit_bins_paint(sceneryEntry, map_element, height, (uint8)bp, dword_F3EF74); + break; + case 2: + path_bit_benches_paint(sceneryEntry, map_element, height, (uint8)bp, dword_F3EF74); + break; + case 3: + path_bit_queue_screens_paint(sceneryEntry, map_element, height, (uint8)bp, dword_F3EF74); + break; + } + RCT2_GLOBAL(RCT2_ADDRESS_PAINT_SETUP_CURRENT_TYPE, uint8) = VIEWPORT_INTERACTION_ITEM_FOOTPATH; if (dword_F3EF74 != 0) { From 27eab3b0ec05d1d6c5dffb104a560f42cdfbd9eb Mon Sep 17 00:00:00 2001 From: duncanspumpkin Date: Thu, 9 Jun 2016 19:47:36 +0100 Subject: [PATCH 07/15] Finish implementing path bit drawings --- src/paint/map_element/path.c | 62 ++++++++++++++++++++++++++++++++---- 1 file changed, 56 insertions(+), 6 deletions(-) diff --git a/src/paint/map_element/path.c b/src/paint/map_element/path.c index 10879b4902..217b3f6509 100644 --- a/src/paint/map_element/path.c +++ b/src/paint/map_element/path.c @@ -220,14 +220,64 @@ void path_bit_bins_paint(rct_scenery_entry* pathBitEntry, rct_map_element* mapEl /* rct2: 0x006A5E81 */ void path_bit_benches_paint(rct_scenery_entry* pathBitEntry, rct_map_element* mapElement, int height, uint8 edges, uint32 pathBitImageFlags) { - RCT2_GLOBAL(0x00F3EF74, uint32) = pathBitImageFlags; - RCT2_CALLPROC_X(0x006A5E81, 0, (int)pathBitEntry, get_current_rotation(), height, (int)mapElement, 0, edges); + uint32 imageId; + + if (!(edges & (1 << 0))) { + imageId = pathBitEntry->image + 1; + + if (mapElement->flags & MAP_ELEMENT_FLAG_BROKEN) + imageId += 4; + + imageId |= pathBitImageFlags; + + sub_98197C(imageId, 7, 16, 0, 16, 7, height, 6, 8, height + 2, get_current_rotation()); + } + if (!(edges & (1 << 1))) { + imageId = pathBitEntry->image + 2; + + if (mapElement->flags & MAP_ELEMENT_FLAG_BROKEN) + imageId += 4; + + imageId |= pathBitImageFlags; + + sub_98197C(imageId, 16, 25, 16, 0, 7, height, 8, 23, height + 2, get_current_rotation()); + } + + if (!(edges & (1 << 2))) { + imageId = pathBitEntry->image + 3; + + if (mapElement->flags & MAP_ELEMENT_FLAG_BROKEN) + imageId += 4; + + imageId |= pathBitImageFlags; + + sub_98197C(imageId, 25, 16, 0, 16, 7, height, 23, 8, height + 2, get_current_rotation()); + } + + if (!(edges & (1 << 3))) { + imageId = pathBitEntry->image + 4; + + if (mapElement->flags & MAP_ELEMENT_FLAG_BROKEN) + imageId += 4; + + imageId |= pathBitImageFlags; + + sub_98197C(imageId, 16, 7, 16, 0, 7, height, 8, 6, height + 2, get_current_rotation()); + } } /* rct2: 0x006A6008 */ -void path_bit_queue_screens_paint(rct_scenery_entry* pathBitEntry, rct_map_element* mapElement, int height, uint8 edges, uint32 pathBitImageFlags) { - RCT2_GLOBAL(0x00F3EF74, uint32) = pathBitImageFlags; - RCT2_CALLPROC_X(0x006A6008, 0, (int)pathBitEntry, get_current_rotation(), height, (int)mapElement, 0, edges); +void path_bit_jumping_fountains_paint(rct_scenery_entry* pathBitEntry, rct_map_element* mapElement, int height, uint8 edges, uint32 pathBitImageFlags, rct_drawpixelinfo* dpi) { + if (dpi->zoom_level != 0) + return; + + uint32 imageId = pathBitEntry->image; + imageId |= pathBitImageFlags; + + sub_98197C(imageId + 1, 0, 0, 1, 1, 2, height, 3, 3, height + 2, get_current_rotation()); + sub_98197C(imageId + 2, 0, 0, 1, 1, 2, height, 3, 29, height + 2, get_current_rotation()); + sub_98197C(imageId + 3, 0, 0, 1, 1, 2, height, 29, 29, height + 2, get_current_rotation()); + sub_98197C(imageId + 4, 0, 0, 1, 1, 2, height, 29, 3, height + 2, get_current_rotation()); } bool do_sub_6A2ECC(int supportType, int special, int height, uint32 imageColourFlags, rct_footpath_entry * dword_F3EF6C, bool * underground) @@ -649,7 +699,7 @@ void sub_6A3F61(rct_map_element * map_element, uint16 bp, uint16 height, rct_foo path_bit_benches_paint(sceneryEntry, map_element, height, (uint8)bp, dword_F3EF74); break; case 3: - path_bit_queue_screens_paint(sceneryEntry, map_element, height, (uint8)bp, dword_F3EF74); + path_bit_jumping_fountains_paint(sceneryEntry, map_element, height, (uint8)bp, dword_F3EF74, dpi); break; } From 63f42c6d474d561ae0653bbe2bb1f6cb4e2013be Mon Sep 17 00:00:00 2001 From: duncanspumpkin Date: Thu, 9 Jun 2016 19:49:44 +0100 Subject: [PATCH 08/15] Fix support issue --- src/paint/map_element/path.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/paint/map_element/path.c b/src/paint/map_element/path.c index 217b3f6509..f0c985fd6d 100644 --- a/src/paint/map_element/path.c +++ b/src/paint/map_element/path.c @@ -1013,7 +1013,7 @@ void loc_6A37C9(rct_map_element * map_element, int height, rct_footpath_entry * RCT2_GLOBAL(0x141E9C4, uint16) = 0xFFFF; // no idea whre bp comes from - uint16 bp = 0; + uint16 bp = edi; if (bp & 1) { RCT2_GLOBAL(0x141E9CC, uint16) = 0xFFFF; From a36a6c3ef9e903680511c03dbde9d1c7f12b4a75 Mon Sep 17 00:00:00 2001 From: duncanspumpkin Date: Thu, 9 Jun 2016 20:10:50 +0100 Subject: [PATCH 09/15] Small refactor --- src/cheats.c | 2 +- src/paint/map_element/path.c | 10 +++++----- src/peep/peep.c | 14 +++++++------- src/world/footpath.c | 7 +++---- src/world/footpath.h | 2 +- src/world/scenery.h | 15 +++++++++++---- 6 files changed, 28 insertions(+), 22 deletions(-) diff --git a/src/cheats.c b/src/cheats.c index dd2655576a..231c5f88ac 100644 --- a/src/cheats.c +++ b/src/cheats.c @@ -127,7 +127,7 @@ static void cheat_remove_litter() continue; sceneryEntry = get_footpath_item_entry(footpath_element_get_path_scenery_index(it.element)); - if(sceneryEntry->path_bit.flags & PATH_BIT_FLAG_BIN) + if (sceneryEntry->path_bit.flags & PATH_BIT_FLAG_IS_BIN) it.element->properties.path.addition_status = 0xFF; } while (map_element_iterator_next(&it)); diff --git a/src/paint/map_element/path.c b/src/paint/map_element/path.c index f0c985fd6d..a03990994e 100644 --- a/src/paint/map_element/path.c +++ b/src/paint/map_element/path.c @@ -688,17 +688,17 @@ void sub_6A3F61(rct_map_element * map_element, uint16 bp, uint16 height, rct_foo // Draw additional path bits (bins, benchs, lamps, queue screens) rct_scenery_entry* sceneryEntry = get_footpath_item_entry(footpath_element_get_path_scenery_index(map_element)); - switch (sceneryEntry->path_bit.var_08) { - case 0: + switch (sceneryEntry->path_bit.draw_type) { + case PATH_BIT_DRAW_TYPE_LIGHTS: path_bit_lights_paint(sceneryEntry, map_element, height, (uint8)bp, dword_F3EF74); break; - case 1: + case PATH_BIT_DRAW_TYPE_BINS: path_bit_bins_paint(sceneryEntry, map_element, height, (uint8)bp, dword_F3EF74); break; - case 2: + case PATH_BIT_DRAW_TYPE_BENCHES: path_bit_benches_paint(sceneryEntry, map_element, height, (uint8)bp, dword_F3EF74); break; - case 3: + case PATH_BIT_DRAW_TYPE_JUMPING_FOUNTAINS: path_bit_jumping_fountains_paint(sceneryEntry, map_element, height, (uint8)bp, dword_F3EF74, dpi); break; } diff --git a/src/peep/peep.c b/src/peep/peep.c index ca40a45b4a..2e03469daf 100644 --- a/src/peep/peep.c +++ b/src/peep/peep.c @@ -626,7 +626,7 @@ static void sub_68F41A(rct_peep *peep, int index) if (footpath_element_has_path_scenery(mapElement) && footpath_element_path_scenery_is_ghost(mapElement)){ uint8 pathSceneryIndex = footpath_element_get_path_scenery_index(mapElement); rct_scenery_entry *sceneryEntry = get_footpath_item_entry(pathSceneryIndex); - if (sceneryEntry->path_bit.flags & PATH_BIT_FLAG_QUEUE_MONITOR) { + if (sceneryEntry->path_bit.flags & PAHT_BIT_FLAG_IS_QUEUE_SCREEN){ found = 1; } } @@ -4272,7 +4272,7 @@ static void peep_update_emptying_bin(rct_peep* peep){ rct_scenery_entry* scenery_entry = get_footpath_item_entry(footpath_element_get_path_scenery_index(map_element)); if ( - !(scenery_entry->path_bit.flags & PATH_BIT_FLAG_BIN) + !(scenery_entry->path_bit.flags & PATH_BIT_FLAG_IS_BIN) || map_element->flags & (1 << 5) || footpath_element_path_scenery_is_ghost(map_element) ) { @@ -4532,7 +4532,7 @@ static int peep_update_walking_find_bench(rct_peep* peep){ if (!footpath_element_has_path_scenery(map_element)) return 0; rct_scenery_entry* sceneryEntry = get_footpath_item_entry(footpath_element_get_path_scenery_index(map_element)); - if (!(sceneryEntry->path_bit.flags & PATH_BIT_FLAG_BENCH))return 0; + if (!(sceneryEntry->path_bit.flags & PATH_BIT_FLAG_IS_BENCH))return 0; if (map_element->flags & MAP_ELEMENT_FLAG_BROKEN)return 0; @@ -4607,7 +4607,7 @@ static int peep_update_walking_find_bin(rct_peep* peep){ if (!footpath_element_has_path_scenery(map_element)) return 0; rct_scenery_entry* sceneryEntry = get_footpath_item_entry(footpath_element_get_path_scenery_index(map_element)); - if (!(sceneryEntry->path_bit.flags & PATH_BIT_FLAG_BIN))return 0; + if (!(sceneryEntry->path_bit.flags & PATH_BIT_FLAG_IS_BIN))return 0; if (map_element->flags & MAP_ELEMENT_FLAG_BROKEN)return 0; @@ -4859,7 +4859,7 @@ static void peep_update_using_bin(rct_peep* peep){ } rct_scenery_entry* sceneryEntry = get_footpath_item_entry(footpath_element_get_path_scenery_index(map_element)); - if (!(sceneryEntry->path_bit.flags & PATH_BIT_FLAG_BIN)){ + if (!(sceneryEntry->path_bit.flags & PATH_BIT_FLAG_IS_BIN)){ peep_state_reset(peep); return; } @@ -5256,7 +5256,7 @@ static int peep_update_patrolling_find_bin(rct_peep* peep){ if (!footpath_element_has_path_scenery(map_element)) return 0; rct_scenery_entry* sceneryEntry = get_footpath_item_entry(footpath_element_get_path_scenery_index(map_element)); - if (!(sceneryEntry->path_bit.flags & PATH_BIT_FLAG_BIN)) + if (!(sceneryEntry->path_bit.flags & PATH_BIT_FLAG_IS_BIN)) return 0; if (map_element->flags & MAP_ELEMENT_FLAG_BROKEN) @@ -5560,7 +5560,7 @@ static void peep_update_walking(rct_peep* peep){ if (!footpath_element_path_scenery_is_ghost(map_element)) { rct_scenery_entry* sceneryEntry = get_footpath_item_entry(footpath_element_get_path_scenery_index(map_element)); - if (!(sceneryEntry->path_bit.flags & PATH_BIT_FLAG_BENCH)) ebp = 9; + if (!(sceneryEntry->path_bit.flags & PATH_BIT_FLAG_IS_BENCH)) ebp = 9; } } diff --git a/src/world/footpath.c b/src/world/footpath.c index 349f30466c..79f5da12e0 100644 --- a/src/world/footpath.c +++ b/src/world/footpath.c @@ -238,13 +238,12 @@ static money32 footpath_element_update(int x, int y, rct_map_element *mapElement return MONEY32_UNDEFINED; } - uint16 jfMask = PATH_BIT_FLAG_JUMPING_FOUNTAIN_WATER | PATH_BIT_FLAG_JUMPING_FOUNTAIN_SNOW; - if (!(unk6 & jfMask) && (mapElement->properties.path.edges & 0x0F) == 0x0F) { + if (!(unk6 & (PATH_BIT_FLAG_JUMPING_FOUNTAIN_WATER | PATH_BIT_FLAG_JUMPING_FOUNTAIN_SNOW)) && (mapElement->properties.path.edges & 0x0F) == 0x0F) { gGameCommandErrorText = STR_NONE; return MONEY32_UNDEFINED; } - if ((unk6 & PATH_BIT_FLAG_QUEUE_MONITOR) && !footpath_element_is_queue(mapElement)) { + if ((unk6 & PAHT_BIT_FLAG_IS_QUEUE_SCREEN) && !footpath_element_is_queue(mapElement)) { gGameCommandErrorText = STR_CAN_ONLY_PLACE_THESE_ON_QUEUE_AREA; return MONEY32_UNDEFINED; } @@ -282,7 +281,7 @@ static money32 footpath_element_update(int x, int y, rct_map_element *mapElement mapElement->flags &= ~MAP_ELEMENT_FLAG_BROKEN; if (pathItemType != 0) { rct_scenery_entry* scenery_entry = get_footpath_item_entry(pathItemType - 1); - if (scenery_entry->path_bit.flags & PATH_BIT_FLAG_BIN) { + if (scenery_entry->path_bit.flags & PATH_BIT_FLAG_IS_BIN) { mapElement->properties.path.addition_status = 255; } } diff --git a/src/world/footpath.h b/src/world/footpath.h index d45c76d947..bc9270abb1 100644 --- a/src/world/footpath.h +++ b/src/world/footpath.h @@ -36,7 +36,7 @@ typedef struct rct_footpath_entry { uint8 flags; // 0x0B uint8 scrolling_mode; // 0x0C } rct_footpath_entry; -assert_struct_size(rct_footpath_entry, 12); +assert_struct_size(rct_footpath_entry, 13); #pragma pack(pop) enum { diff --git a/src/world/scenery.h b/src/world/scenery.h index 145761db2a..741e5d758d 100644 --- a/src/world/scenery.h +++ b/src/world/scenery.h @@ -136,7 +136,7 @@ typedef enum { typedef struct rct_path_bit_scenery_entry { uint16 flags; // 0x06 - uint8 pad_08; + uint8 draw_type; // 0x08 uint8 tool_id; // 0x09 sint16 price; // 0x0A uint8 scenery_tab_id; // 0x0C @@ -180,15 +180,22 @@ assert_struct_size(rct_scenery_set_entry, 14 + 2 * 0x80); #pragma pack(pop) enum { - PATH_BIT_FLAG_BIN = 1 << 0, - PATH_BIT_FLAG_BENCH = 1 << 1, + PATH_BIT_FLAG_IS_BIN = 1 << 0, + PATH_BIT_FLAG_IS_BENCH = 1 << 1, PATH_BIT_FLAG_BREAKABLE = 1 << 2, PATH_BIT_FLAG_LAMP = 1 << 3, PATH_BIT_FLAG_JUMPING_FOUNTAIN_WATER = 1 << 4, PATH_BIT_FLAG_JUMPING_FOUNTAIN_SNOW = 1 << 5, PATH_BIT_FLAG_DONT_ALLOW_ON_QUEUE = 1 << 6, PATH_BIT_FLAG_DONT_ALLOW_ON_SLOPE = 1 << 7, - PATH_BIT_FLAG_QUEUE_MONITOR = 1 << 8, + PAHT_BIT_FLAG_IS_QUEUE_SCREEN = 1 << 8 +}; + +enum { + PATH_BIT_DRAW_TYPE_LIGHTS, + PATH_BIT_DRAW_TYPE_BINS, + PATH_BIT_DRAW_TYPE_BENCHES, + PATH_BIT_DRAW_TYPE_JUMPING_FOUNTAINS }; enum { From 413139684477ab634b4f7a439d878167e1758fb8 Mon Sep 17 00:00:00 2001 From: duncanspumpkin Date: Fri, 10 Jun 2016 18:33:43 +0100 Subject: [PATCH 10/15] Fix bugs --- src/paint/map_element/path.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/paint/map_element/path.c b/src/paint/map_element/path.c index a03990994e..ec921ed1d2 100644 --- a/src/paint/map_element/path.c +++ b/src/paint/map_element/path.c @@ -563,7 +563,7 @@ void sub_6A4101(rct_map_element * map_element, uint16 height, uint32 ebp, bool w break; case 10: sub_98197C(73 + base_image_id, 4, 0, 1, 32, 7, height, 4, 0, height + 2, get_current_rotation()); - sub_98197C(74 + base_image_id, 28, 0, 1, 32, 7, height, 28, 0, height + 2, get_current_rotation()); + sub_98197C(73 + base_image_id, 28, 0, 1, 32, 7, height, 28, 0, height + 2, get_current_rotation()); break; case 3: @@ -1038,7 +1038,7 @@ void loc_6A3B57(rct_map_element* mapElement, sint16 height, rct_footpath_entry* uint8 type = footpath_element_get_type(mapElement); // Rol edges around rotation uint8 edges = ((mapElement->properties.path.edges << get_current_rotation()) & 0xF) | - ((mapElement->properties.path.edges << get_current_rotation()) >> 4); + (((mapElement->properties.path.edges & 0xF) << get_current_rotation()) >> 4); rct_xy16 boundBoxOffset = { .x = stru_98D804[edges][0], From 8e962c91573aae960a42ac187411fdb166f122dd Mon Sep 17 00:00:00 2001 From: Marijn van der Werf Date: Sat, 11 Jun 2016 11:35:18 +0200 Subject: [PATCH 11/15] Restore original path support drawing --- src/paint/map_element/path.c | 95 ++---------------------------------- src/paint/supports.c | 6 +-- src/paint/supports.h | 4 +- 3 files changed, 9 insertions(+), 96 deletions(-) diff --git a/src/paint/map_element/path.c b/src/paint/map_element/path.c index ec921ed1d2..d03b770b7a 100644 --- a/src/paint/map_element/path.c +++ b/src/paint/map_element/path.c @@ -79,19 +79,6 @@ const uint8 byte_98D8A4[] = { 0, 0, 1, 0, 0, 0, 1, 0, 1, 1, 1, 1, 0, 0, 1, 0 }; -typedef struct -{ - uint8 var_0, var_1, var_2, var_3, var_4, var_5, var_6, var_7; -} unk_supports_desc_bound_box; - -const unk_supports_desc_bound_box stru_98D8D4[] = { - {0, 0, 0, 1, 1, 4, 0, 1}, - {0, 0, 0, 1, 1, 4, 0, 1}, - {0, 0, 0, 1, 1, 4, 0, 1}, - {0, 0, 0, 1, 1, 4, 0, 1} -}; - - void loc_6A37C9(rct_map_element * map_element, int height, rct_footpath_entry * dword_F3EF6C, bool word_F3F038, uint32 dword_F3EF70, uint32 dword_F3EF74); void loc_6A3B57(rct_map_element* mapElement, sint16 height, rct_footpath_entry* footpathEntry, bool hasFences, uint32 imageFlags, uint32 sceneryImageFlags); @@ -280,82 +267,6 @@ void path_bit_jumping_fountains_paint(rct_scenery_entry* pathBitEntry, rct_map_e sub_98197C(imageId + 4, 0, 0, 1, 1, 2, height, 29, 3, height + 2, get_current_rotation()); } -bool do_sub_6A2ECC(int supportType, int special, int height, uint32 imageColourFlags, rct_footpath_entry * dword_F3EF6C, bool * underground) -{ - if (underground != NULL) { - *underground = false; - } - - int eax = special, edx = height, _edi = supportType, ebp = imageColourFlags; - - if (gCurrentViewportFlags & VIEWPORT_FLAG_INVISIBLE_SUPPORTS) { - return false; - } - - if (!(RCT2_GLOBAL(0x0141E9DB, uint8) & 1)) { - return false; - } - - int z = floor2(RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_PAINT_TILE_MAX_HEIGHT, sint16) + 15, 16); - height -= z; - if (height < 0) { - if (underground != NULL) { - *underground = true; - } - return false; - } - height /= 16; - - bool hasSupports = false; - - // Draw base support (usually shaped to the slope) - int slope = RCT2_GLOBAL(0x0141E9DA, uint8); - if (slope & 0x20) { - uint32 image_id = (dword_F3EF6C->bridge_image + 48) | imageColourFlags; - sub_98196C(image_id, 0, 0, 32, 32, 0, z - 2, get_current_rotation()); - hasSupports = true; - } else { - - } - - while (height != 0) { - if ((z & 16) == 0 && height >= 2 && z + 16 != RCT2_GLOBAL(0x00141E9DC, uint16)) { - // Full support - int imageId = (dword_F3EF6C->bridge_image + 22 + supportType * 24) | imageColourFlags; - uint8 ah = height == 2 ? 23 : 28; // weird - sub_98196C(imageId, 0, 0, 32, 32, ah, z, get_current_rotation()); - hasSupports = true; - z += 32; - height -= 2; - } else { - // Half support - int imageId = (dword_F3EF6C->bridge_image + 23 + supportType * 24) | imageColourFlags; - uint8 ah = special == 1 ? 7 : 12; - sub_98196C(imageId, 0, 0, 32, 32, ah, z, get_current_rotation()); - hasSupports = true; - z += 16; - height -= 1; - } - } - - if (special == 0) { - return hasSupports; - } - - special = (special - 1) & 0xFFFF; - - uint32 imageId = (dword_F3EF6C->bridge_image + 55 + special) | imageColourFlags; - - - unk_supports_desc_bound_box stru = stru_98D8D4[special]; - // var_6 is always zero. - - sub_98197C(imageId, 0, 0, stru.var_3, stru.var_4, stru.var_5, z, stru.var_0, stru.var_1, z + stru.var_3, get_current_rotation()); - hasSupports = true; - - return hasSupports; -} - /** * rct2: 0x006A4101 * @param map_element (esi) @@ -969,9 +880,9 @@ void loc_6A37C9(rct_map_element * map_element, int height, rct_footpath_entry * ebx = ebp & 0xF; if (byte_98D8A4[ebx] == 0) { - do_sub_6A2ECC(0, ax, height, dword_F3EF70, dword_F3EF6C, NULL); + path_a_supports_paint_setup(0, ax, height, dword_F3EF70, dword_F3EF6C, NULL); } else { - do_sub_6A2ECC(1, ax, height, dword_F3EF70, dword_F3EF6C, NULL); + path_a_supports_paint_setup(1, ax, height, dword_F3EF70, dword_F3EF6C, NULL); } @@ -1114,7 +1025,7 @@ void loc_6A3B57(rct_map_element* mapElement, sint16 height, rct_footpath_entry* RCT2_GLOBAL(0x00F3EF6C, rct_footpath_entry*) = footpathEntry; for (sint8 i = 3; i > -1; --i) { if (!(edges & (1 << i))) { - path_wooden_a_supports_paint_setup(supports[i], ax, height, imageFlags); + path_b_supports_paint_setup(supports[i], ax, height, imageFlags); } } diff --git a/src/paint/supports.c b/src/paint/supports.c index 6ffb43f0f8..9abccdacbb 100644 --- a/src/paint/supports.c +++ b/src/paint/supports.c @@ -517,11 +517,11 @@ bool metal_b_supports_paint_setup(int supportType, uint8 segment, int special, i } /** - * Some kind of supports * rct2: 0x006A2ECC */ -bool sub_6A2ECC(int supportType, int special, int height, uint32 imageColourFlags) +bool path_a_supports_paint_setup(int supportType, int special, int height, uint32 imageColourFlags, rct_footpath_entry * pathEntry, bool * underground) { + RCT2_GLOBAL(0xF3EF6C, rct_footpath_entry *) = pathEntry; int eax = special, ebx = 0, ecx = 0, edx = height, esi = 0, _edi = supportType, ebp = imageColourFlags; RCT2_CALLFUNC_X(0x006A2ECC, &eax, &ebx, &ecx, &edx, &esi, &_edi, &ebp); return eax & 0xFF; @@ -531,7 +531,7 @@ bool sub_6A2ECC(int supportType, int special, int height, uint32 imageColourFlag * * rct2: 0x006A326B */ -bool path_wooden_a_supports_paint_setup(int supportType, int special, int height, uint32 imageColourFlags) +bool path_b_supports_paint_setup(int supportType, int special, int height, uint32 imageColourFlags) { int eax = special, ebx = supportType, ecx = 0, edx = height, esi = 0, _edi = 0, ebp = imageColourFlags; RCT2_CALLFUNC_X(0x006A326B, &eax, &ebx, &ecx, &edx, &esi, &_edi, &ebp); diff --git a/src/paint/supports.h b/src/paint/supports.h index 9ae37dd22d..2acd39bdc1 100644 --- a/src/paint/supports.h +++ b/src/paint/supports.h @@ -18,11 +18,13 @@ #define _DRAWING_SUPPORTS_H_ #include "../common.h" +#include "../world/footpath.h" bool wooden_a_supports_paint_setup(int supportType, int special, int height, uint32 imageColourFlags, bool* underground); bool wooden_b_supports_paint_setup(int supportType, int special, int height, uint32 imageColourFlags); bool metal_a_supports_paint_setup(int supportType, int segment, int special, int height, uint32 imageColourFlags); bool metal_b_supports_paint_setup(int supportType, uint8 segment, int special, int height, uint32 imageColourFlags); -bool path_wooden_a_supports_paint_setup(int supportType, int special, int height, uint32 imageColourFlags); +bool path_a_supports_paint_setup(int supportType, int special, int height, uint32 imageColourFlags, rct_footpath_entry * pathEntry, bool * underground); +bool path_b_supports_paint_setup(int supportType, int special, int height, uint32 imageColourFlags); #endif From 3edcadcbec50d0de48cd33021ae46a448667a905 Mon Sep 17 00:00:00 2001 From: Marijn van der Werf Date: Sat, 11 Jun 2016 11:47:44 +0200 Subject: [PATCH 12/15] Clean up function to use less globals --- src/paint/map_element/map_element.h | 1 + src/paint/map_element/path.c | 94 ++++++++++------------------- 2 files changed, 33 insertions(+), 62 deletions(-) diff --git a/src/paint/map_element/map_element.h b/src/paint/map_element/map_element.h index 3eece1e121..58f53fae26 100644 --- a/src/paint/map_element/map_element.h +++ b/src/paint/map_element/map_element.h @@ -57,6 +57,7 @@ enum TUNNEL_7 = 7, TUNNEL_8 = 8, TUNNEL_10 = 0x0A, + TUNNEL_11 = 0x0B, TUNNEL_12 = 0x0C, TUNNEL_14 = 0x0E }; diff --git a/src/paint/map_element/path.c b/src/paint/map_element/path.c index d03b770b7a..c85bb1ffa5 100644 --- a/src/paint/map_element/path.c +++ b/src/paint/map_element/path.c @@ -27,6 +27,7 @@ #include "../../localisation/localisation.h" #include "../../game.h" #include "../supports.h" +#include "../../peep/staff.h" // #3628: Until path_paint is implemented, this variable is used by scrolling_text_setup // to use the old string arguments array. Remove when scrolling_text_setup is no @@ -355,7 +356,7 @@ void sub_6A4101(rct_map_element * map_element, uint16 height, uint32 ebp, bool w uint8 direction = ((map_element->type & 0xC0) >> 6); // Draw ride sign - RCT2_GLOBAL(RCT2_ADDRESS_PAINT_SETUP_CURRENT_TYPE, uint8) = VIEWPORT_INTERACTION_ITEM_RIDE; + gPaintInteractionType = VIEWPORT_INTERACTION_ITEM_RIDE; if (footpath_element_is_sloped(map_element)) { if (footpath_element_get_slope_direction(map_element) == direction) height += 16; @@ -408,9 +409,9 @@ void sub_6A4101(rct_map_element * map_element, uint16 height, uint32 ebp, bool w sub_98199C(scrolling_text_setup(string_id, scroll, scrollingMode), 0, 0, 1, 1, 21, height + 7, boundBoxOffsets.x, boundBoxOffsets.y, boundBoxOffsets.z, get_current_rotation()); } - RCT2_GLOBAL(RCT2_ADDRESS_PAINT_SETUP_CURRENT_TYPE, uint8) = VIEWPORT_INTERACTION_ITEM_FOOTPATH; + gPaintInteractionType = VIEWPORT_INTERACTION_ITEM_FOOTPATH; if (dword_F3EF70 != 0) { - RCT2_GLOBAL(RCT2_ADDRESS_PAINT_SETUP_CURRENT_TYPE, uint8) = VIEWPORT_INTERACTION_ITEM_NONE; + gPaintInteractionType = VIEWPORT_INTERACTION_ITEM_NONE; } return; } @@ -592,9 +593,9 @@ void sub_6A3F61(rct_map_element * map_element, uint16 bp, uint16 height, rct_foo if (!(RCT2_GLOBAL(0x9DEA6F, uint8) & 1)) { uint8 additions = map_element->properties.path.additions & 0xF; if (additions != 0) { - RCT2_GLOBAL(RCT2_ADDRESS_PAINT_SETUP_CURRENT_TYPE, uint8) = VIEWPORT_INTERACTION_ITEM_FOOTPATH_ITEM; + gPaintInteractionType = VIEWPORT_INTERACTION_ITEM_FOOTPATH_ITEM; if (dword_F3EF74 != 0) { - RCT2_GLOBAL(RCT2_ADDRESS_PAINT_SETUP_CURRENT_TYPE, uint8) = VIEWPORT_INTERACTION_ITEM_NONE; + gPaintInteractionType = VIEWPORT_INTERACTION_ITEM_NONE; } // Draw additional path bits (bins, benchs, lamps, queue screens) @@ -614,10 +615,10 @@ void sub_6A3F61(rct_map_element * map_element, uint16 bp, uint16 height, rct_foo break; } - RCT2_GLOBAL(RCT2_ADDRESS_PAINT_SETUP_CURRENT_TYPE, uint8) = VIEWPORT_INTERACTION_ITEM_FOOTPATH; + gPaintInteractionType = VIEWPORT_INTERACTION_ITEM_FOOTPATH; if (dword_F3EF74 != 0) { - RCT2_GLOBAL(RCT2_ADDRESS_PAINT_SETUP_CURRENT_TYPE, uint8) = VIEWPORT_INTERACTION_ITEM_NONE; + gPaintInteractionType = VIEWPORT_INTERACTION_ITEM_NONE; } } } @@ -635,21 +636,13 @@ void sub_6A3F61(rct_map_element * map_element, uint16 bp, uint16 height, rct_foo if (bp & 2) { // Bottom right of tile is a tunnel - registers regs = {0}; - regs.eax = 0xFFFFFFFF; if (bl == 5) { - regs.ax = (height + 16) / 16; - regs.ah = 0x0A; + paint_util_push_tunnel_right(height + 16, TUNNEL_10); } else if (bp & 1) { - regs.ax = height / 16; - regs.ah = 0x0B; + paint_util_push_tunnel_right(height, TUNNEL_11); } else { - regs.ax = height / 16; - regs.ah = 0x0A; - + paint_util_push_tunnel_right(height, TUNNEL_10); } - RCT2_ADDRESS(0x009E30B6, uint32)[RCT2_GLOBAL(0x141F56B, uint8) / 2] = regs.eax; - RCT2_GLOBAL(0x141F56B, uint8)++; } if (!(bp & 4)) { @@ -657,21 +650,13 @@ void sub_6A3F61(rct_map_element * map_element, uint16 bp, uint16 height, rct_foo } // Bottom left of the tile is a tunnel - registers regs = {0}; - regs.eax = 0xFFFFFFFF; if (bl == 6) { - regs.ax = (height + 16) / 16; - regs.ah = 0x0A; + paint_util_push_tunnel_left(height + 16, TUNNEL_10); } else if (bp & 8) { - regs.ax = height / 16; - regs.ah = 0x0B; + paint_util_push_tunnel_left(height , TUNNEL_11); } else { - regs.ax = height / 16; - regs.ah = 0x0A; - + paint_util_push_tunnel_left(height , TUNNEL_10); } - RCT2_ADDRESS(0x009E3138, uint32)[RCT2_GLOBAL(0x141F56A, uint8) / 2] = regs.eax; - RCT2_GLOBAL(0x141F56A, uint8)++; } /** @@ -687,7 +672,7 @@ void path_paint(uint8 direction, uint16 height, rct_map_element * map_element) } - RCT2_GLOBAL(RCT2_ADDRESS_PAINT_SETUP_CURRENT_TYPE, uint8) = VIEWPORT_INTERACTION_ITEM_FOOTPATH; + gPaintInteractionType = VIEWPORT_INTERACTION_ITEM_FOOTPATH; uint32 ecx = get_current_rotation(); bool word_F3F038 = false; @@ -712,7 +697,7 @@ void path_paint(uint8 direction, uint16 height, rct_map_element * map_element) } if (map_element->flags & MAP_ELEMENT_FLAG_GHOST) { - RCT2_GLOBAL(RCT2_ADDRESS_PAINT_SETUP_CURRENT_TYPE, uint8) = VIEWPORT_INTERACTION_ITEM_NONE; + gPaintInteractionType = VIEWPORT_INTERACTION_ITEM_NONE; dword_F3EF70 = RCT2_ADDRESS(0x993CC4, uint32_t)[gConfigGeneral.construction_marker_colour]; } @@ -739,8 +724,8 @@ void path_paint(uint8 direction, uint16 height, rct_map_element * map_element) } } - if (RCT2_GLOBAL(0x009DEA50, sint16) != -1) { - sint32 staffIndex = RCT2_GLOBAL(0x009DEA50, sint16); + if (gStaffDrawPatrolAreas != 0xFFFF) { + sint32 staffIndex = gStaffDrawPatrolAreas; uint8 staffType = staffIndex & 0x7FFF; sint16 x = RCT2_GLOBAL(0x009DE56A, sint16), y = RCT2_GLOBAL(0x009DE56E, sint16); @@ -790,7 +775,7 @@ void path_paint(uint8 direction, uint16 height, rct_map_element * map_element) height += 8; } uint32 imageId = (SPR_HEIGHT_MARKER_BASE + height / 16) | COLOUR_GREY << 19 | 0x20000000; - imageId += RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_HEIGHT_MARKERS, uint16); + imageId += get_height_marker_offset(); imageId -= RCT2_GLOBAL(0x01359208, uint16); sub_98196C(imageId, 16, 16, 1, 1, 0, height, get_current_rotation()); } @@ -893,55 +878,40 @@ void loc_6A37C9(rct_map_element * map_element, int height, rct_footpath_entry * height += 16; } - if (RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_PAINT_TILE_MAX_HEIGHT, sint16) < height) { - RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_PAINT_TILE_MAX_HEIGHT, sint16) = height; - RCT2_GLOBAL(0x141E9DA, uint8) = 0x20; - } + paint_util_set_general_support_height(height, 0x20); if (map_element->type & 1 || (map_element->properties.path.edges != 0xFF && word_F3F038) ) { - RCT2_GLOBAL(0x141E9C4, uint16) = 0xFFFF; - RCT2_GLOBAL(0x141E9C8, uint16) = 0xFFFF; - RCT2_GLOBAL(0x141E9CC, uint16) = 0xFFFF; - RCT2_GLOBAL(0x141E9D0, uint16) = 0xFFFF; - RCT2_GLOBAL(0x141E9D4, uint16) = 0xFFFF; - RCT2_GLOBAL(0x141E9B4, uint16) = 0xFFFF; - RCT2_GLOBAL(0x141E9C0, uint16) = 0xFFFF; - RCT2_GLOBAL(0x141E9B8, uint16) = 0xFFFF; - RCT2_GLOBAL(0x141E9BC, uint16) = 0xFFFF; + paint_util_set_segment_support_height(SEGMENTS_ALL, 0xFFFF, 0); return; } if (map_element->properties.path.edges == 0xFF) { - RCT2_GLOBAL(0x141E9C8, uint16) = 0xFFFF; - RCT2_GLOBAL(0x141E9CC, uint16) = 0xFFFF; - RCT2_GLOBAL(0x141E9D0, uint16) = 0xFFFF; - RCT2_GLOBAL(0x141E9D4, uint16) = 0xFFFF; + paint_util_set_segment_support_height(SEGMENT_C8 | SEGMENT_CC | SEGMENT_D0 | SEGMENT_D4, 0xFFFF, 0); return; } - RCT2_GLOBAL(0x141E9C4, uint16) = 0xFFFF; + paint_util_set_segment_support_height(SEGMENT_C4, 0xFFFF, 0); // no idea whre bp comes from - uint16 bp = edi; + uint16 edges = edi; - if (bp & 1) { - RCT2_GLOBAL(0x141E9CC, uint16) = 0xFFFF; + if (edges & 1) { + paint_util_set_segment_support_height(SEGMENT_CC, 0xFFFF, 0); } - if (bp & 2) { - RCT2_GLOBAL(0x141E9D4, uint16) = 0xFFFF; + if (edges & 2) { + paint_util_set_segment_support_height(SEGMENT_D4, 0xFFFF, 0); } - if (bp & 4) { - RCT2_GLOBAL(0x141E9D0, uint16) = 0xFFFF; + if (edges & 4) { + paint_util_set_segment_support_height(SEGMENT_D0, 0xFFFF, 0); } - if (bp & 8) { - RCT2_GLOBAL(0x141E9C8, uint16) = 0xFFFF; + if (edges & 8) { + paint_util_set_segment_support_height(SEGMENT_C8, 0xFFFF, 0); } - } void loc_6A3B57(rct_map_element* mapElement, sint16 height, rct_footpath_entry* footpathEntry, bool hasFences, uint32 imageFlags, uint32 sceneryImageFlags) From b0d08d6e42d5f545b1e51bf641ad0fd1aa3edf04 Mon Sep 17 00:00:00 2001 From: Marijn van der Werf Date: Sun, 12 Jun 2016 19:00:30 +0200 Subject: [PATCH 13/15] Make two branches match better --- src/paint/map_element/path.c | 42 ++++++++++++++++++------------------ 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/src/paint/map_element/path.c b/src/paint/map_element/path.c index c85bb1ffa5..ac3212fc4d 100644 --- a/src/paint/map_element/path.c +++ b/src/paint/map_element/path.c @@ -80,7 +80,7 @@ const uint8 byte_98D8A4[] = { 0, 0, 1, 0, 0, 0, 1, 0, 1, 1, 1, 1, 0, 0, 1, 0 }; -void loc_6A37C9(rct_map_element * map_element, int height, rct_footpath_entry * dword_F3EF6C, bool word_F3F038, uint32 dword_F3EF70, uint32 dword_F3EF74); +void loc_6A37C9(rct_map_element * mapElement, int height, rct_footpath_entry * dword_F3EF6C, bool hasFences, uint32 dword_F3EF70, uint32 dword_F3EF74); void loc_6A3B57(rct_map_element* mapElement, sint16 height, rct_footpath_entry* footpathEntry, bool hasFences, uint32 imageFlags, uint32 sceneryImageFlags); @@ -790,12 +790,12 @@ void path_paint(uint8 direction, uint16 height, rct_map_element * map_element) } } -void loc_6A37C9(rct_map_element * map_element, int height, rct_footpath_entry * dword_F3EF6C, bool word_F3F038, uint32 dword_F3EF70, uint32 dword_F3EF74) +void loc_6A37C9(rct_map_element * mapElement, int height, rct_footpath_entry * dword_F3EF6C, bool hasFences, uint32 dword_F3EF70, uint32 dword_F3EF74) { // esi: mapElement // ecx: get_current_rotation(); registers regs = {0}; - regs.al = map_element->properties.path.edges; + regs.al = mapElement->properties.path.edges; regs.ah = regs.al << 4; uint8 edi_index = rol16(regs.ax, get_current_rotation()) & 0xF; @@ -807,15 +807,15 @@ void loc_6A37C9(rct_map_element * map_element, int height, rct_footpath_entry * rct_xy16 boundBoxOffset = {.x =stru_98D804[edi_index][0], .y = stru_98D804[edi_index][1]}; rct_xy16 boundBoxSize = {.x =stru_98D804[edi_index][2], .y = stru_98D804[edi_index][3]}; - regs.al = map_element->properties.path.edges; + regs.al = mapElement->properties.path.edges; regs.ah = regs.al >> 4; regs.ax = (rol16(regs.ax, get_current_rotation()) >> 4) & 0xF0; uint16 edi = edi_index | regs.ax; uint32 ebx; - if (map_element->properties.path.type & 0x04) { - ebx = ((map_element->properties.path.type + get_current_rotation()) & 3) + 16; + if (mapElement->properties.path.type & 0x04) { + ebx = ((mapElement->properties.path.type + get_current_rotation()) & 3) + 16; } else { ebx = byte_98D6E0[edi]; } @@ -823,7 +823,7 @@ void loc_6A37C9(rct_map_element * map_element, int height, rct_footpath_entry * // save edi ebx += dword_F3EF6C->image; - if (map_element_get_direction(map_element) & 1) { + if (map_element_get_direction(mapElement) & 1) { ebx += 51; } @@ -834,19 +834,19 @@ void loc_6A37C9(rct_map_element * map_element, int height, rct_footpath_entry * boundBoxSize.y = 26; } - if (!word_F3F038 || !RCT2_GLOBAL(0x9DE57C, bool)) { + if (!hasFences || !RCT2_GLOBAL(0x9DE57C, bool)) { sub_98197C(ebx | dword_F3EF70, 0, 0, boundBoxSize.x, boundBoxSize.y, 0, height, boundBoxOffset.x, boundBoxOffset.y, height + 1, get_current_rotation()); } else { uint32 image_id; - if (map_element->properties.path.type & 0x04) { - image_id = ((map_element->properties.path.type + get_current_rotation()) & 3) + dword_F3EF6C->bridge_image + 51; + if (mapElement->properties.path.type & 0x04) { + image_id = ((mapElement->properties.path.type + get_current_rotation()) & 3) + dword_F3EF6C->bridge_image + 51; } else { image_id = byte_98D8A4[edi_index] + dword_F3EF6C->bridge_image + 49; } sub_98197C(image_id | dword_F3EF70, 0, 0, boundBoxSize.x, boundBoxSize.y, 0, height, boundBoxOffset.x, boundBoxOffset.y, height + 1, get_current_rotation()); - if (!(map_element->type & 1) && !(dword_F3EF6C->flags & 2)) { + if (!(mapElement->type & 1) && !(dword_F3EF6C->flags & 2)) { // don't draw } else { sub_98199C(ebx | dword_F3EF70, 0, 0, boundBoxSize.x, boundBoxSize.y, 0, height, boundBoxOffset.x, boundBoxOffset.y, height + 1, get_current_rotation()); @@ -854,11 +854,11 @@ void loc_6A37C9(rct_map_element * map_element, int height, rct_footpath_entry * } - sub_6A3F61(map_element, edi, height, dword_F3EF6C, dword_F3EF70, dword_F3EF74, word_F3F038); // TODO: arguments + sub_6A3F61(mapElement, edi, height, dword_F3EF6C, dword_F3EF70, dword_F3EF74, hasFences); // TODO: arguments uint16 ax = 0; - if (map_element->properties.path.type & 0x04) { - ax = ((map_element->properties.path.type + get_current_rotation()) & 0x3) + 1; + if (mapElement->properties.path.type & 0x04) { + ax = ((mapElement->properties.path.type + get_current_rotation()) & 0x3) + 1; } uint32 ebp = edi; @@ -871,32 +871,32 @@ void loc_6A37C9(rct_map_element * map_element, int height, rct_footpath_entry * } + + // no idea whre bp comes from + uint16 edges = edi; sint16 x = RCT2_GLOBAL(0x009DE56A, sint16), y = RCT2_GLOBAL(0x009DE56E, sint16); height += 32; - if (map_element->properties.path.type & 0x04) { + if (footpath_element_is_sloped(mapElement)) { height += 16; } paint_util_set_general_support_height(height, 0x20); - if (map_element->type & 1 - || (map_element->properties.path.edges != 0xFF && word_F3F038) + if ((mapElement->type & 1) + || (mapElement->properties.path.edges != 0xFF && hasFences) ) { paint_util_set_segment_support_height(SEGMENTS_ALL, 0xFFFF, 0); return; } - if (map_element->properties.path.edges == 0xFF) { + if (mapElement->properties.path.edges == 0xFF) { paint_util_set_segment_support_height(SEGMENT_C8 | SEGMENT_CC | SEGMENT_D0 | SEGMENT_D4, 0xFFFF, 0); return; } paint_util_set_segment_support_height(SEGMENT_C4, 0xFFFF, 0); - // no idea whre bp comes from - uint16 edges = edi; - if (edges & 1) { paint_util_set_segment_support_height(SEGMENT_CC, 0xFFFF, 0); } From b13f499d5b22030c4bc402b723fe77c225b0962f Mon Sep 17 00:00:00 2001 From: Marijn van der Werf Date: Sun, 12 Jun 2016 19:01:16 +0200 Subject: [PATCH 14/15] Fix typo in enum value --- src/peep/peep.c | 2 +- src/world/footpath.c | 2 +- src/world/scenery.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/peep/peep.c b/src/peep/peep.c index 2e03469daf..0af4b4eade 100644 --- a/src/peep/peep.c +++ b/src/peep/peep.c @@ -626,7 +626,7 @@ static void sub_68F41A(rct_peep *peep, int index) if (footpath_element_has_path_scenery(mapElement) && footpath_element_path_scenery_is_ghost(mapElement)){ uint8 pathSceneryIndex = footpath_element_get_path_scenery_index(mapElement); rct_scenery_entry *sceneryEntry = get_footpath_item_entry(pathSceneryIndex); - if (sceneryEntry->path_bit.flags & PAHT_BIT_FLAG_IS_QUEUE_SCREEN){ + if (sceneryEntry->path_bit.flags & PATH_BIT_FLAG_IS_QUEUE_SCREEN){ found = 1; } } diff --git a/src/world/footpath.c b/src/world/footpath.c index 79f5da12e0..a16b140d62 100644 --- a/src/world/footpath.c +++ b/src/world/footpath.c @@ -243,7 +243,7 @@ static money32 footpath_element_update(int x, int y, rct_map_element *mapElement return MONEY32_UNDEFINED; } - if ((unk6 & PAHT_BIT_FLAG_IS_QUEUE_SCREEN) && !footpath_element_is_queue(mapElement)) { + if ((unk6 & PATH_BIT_FLAG_IS_QUEUE_SCREEN) && !footpath_element_is_queue(mapElement)) { gGameCommandErrorText = STR_CAN_ONLY_PLACE_THESE_ON_QUEUE_AREA; return MONEY32_UNDEFINED; } diff --git a/src/world/scenery.h b/src/world/scenery.h index 741e5d758d..9a2f5e990b 100644 --- a/src/world/scenery.h +++ b/src/world/scenery.h @@ -188,7 +188,7 @@ enum { PATH_BIT_FLAG_JUMPING_FOUNTAIN_SNOW = 1 << 5, PATH_BIT_FLAG_DONT_ALLOW_ON_QUEUE = 1 << 6, PATH_BIT_FLAG_DONT_ALLOW_ON_SLOPE = 1 << 7, - PAHT_BIT_FLAG_IS_QUEUE_SCREEN = 1 << 8 + PATH_BIT_FLAG_IS_QUEUE_SCREEN = 1 << 8 }; enum { From 0bdff0af63192ab26db3409b62d76cc351da668b Mon Sep 17 00:00:00 2001 From: duncanspumpkin Date: Tue, 14 Jun 2016 20:33:56 +0100 Subject: [PATCH 15/15] Refactor --- src/paint/map_element/path.c | 173 +++++++++++++++-------------------- 1 file changed, 72 insertions(+), 101 deletions(-) diff --git a/src/paint/map_element/path.c b/src/paint/map_element/path.c index ac3212fc4d..a0430a9212 100644 --- a/src/paint/map_element/path.c +++ b/src/paint/map_element/path.c @@ -80,7 +80,7 @@ const uint8 byte_98D8A4[] = { 0, 0, 1, 0, 0, 0, 1, 0, 1, 1, 1, 1, 0, 0, 1, 0 }; -void loc_6A37C9(rct_map_element * mapElement, int height, rct_footpath_entry * dword_F3EF6C, bool hasFences, uint32 dword_F3EF70, uint32 dword_F3EF74); +void loc_6A37C9(rct_map_element * mapElement, int height, rct_footpath_entry * footpathEntry, bool hasFences, uint32 imageFlags, uint32 sceneryImageFlags); void loc_6A3B57(rct_map_element* mapElement, sint16 height, rct_footpath_entry* footpathEntry, bool hasFences, uint32 imageFlags, uint32 sceneryImageFlags); @@ -275,11 +275,11 @@ void path_bit_jumping_fountains_paint(rct_scenery_entry* pathBitEntry, rct_map_e * @param ebp (ebp) * @param base_image_id (0x00F3EF78) */ -void sub_6A4101(rct_map_element * map_element, uint16 height, uint32 ebp, bool word_F3F038, rct_footpath_entry * dword_F3EF6C, uint32 base_image_id, uint32 dword_F3EF70) +void sub_6A4101(rct_map_element * map_element, uint16 height, uint32 ebp, bool word_F3F038, rct_footpath_entry * footpathEntry, uint32 base_image_id, uint32 imageFlags) { if (map_element->type & 1) { uint8 local_ebp = ebp & 0x0F; - if (map_element->properties.path.type & 0x04) { + if (footpath_element_is_sloped(map_element)) { switch ((map_element->properties.path.type + get_current_rotation()) & 0x03) { case 0: sub_98197C(95 + base_image_id, 0, 4, 32, 1, 23, height, 0, 4, height + 2, get_current_rotation()); @@ -381,8 +381,8 @@ void sub_6A4101(rct_map_element * map_element, uint16 height, uint32 ebp, bool w direction--; // If text shown - if (direction < 2 && map_element->properties.path.ride_index != 255 && dword_F3EF70 == 0) { - uint16 scrollingMode = dword_F3EF6C->scrolling_mode; + if (direction < 2 && map_element->properties.path.ride_index != 255 && imageFlags == 0) { + uint16 scrollingMode = footpathEntry->scrolling_mode; scrollingMode += direction; set_format_arg(0, uint32, 0); @@ -410,7 +410,7 @@ void sub_6A4101(rct_map_element * map_element, uint16 height, uint32 ebp, bool w } gPaintInteractionType = VIEWPORT_INTERACTION_ITEM_FOOTPATH; - if (dword_F3EF70 != 0) { + if (imageFlags != 0) { gPaintInteractionType = VIEWPORT_INTERACTION_ITEM_NONE; } return; @@ -418,13 +418,12 @@ void sub_6A4101(rct_map_element * map_element, uint16 height, uint32 ebp, bool w // save ecx, ebp, esi - rct_footpath_entry * ebx = dword_F3EF6C; uint32 dword_F3EF80 = ebp; - if (!(ebx->flags & 2)) { + if (!(footpathEntry->flags & 2)) { dword_F3EF80 &= 0x0F; } - if (map_element->properties.path.type & 0x04) { + if (footpath_element_is_sloped(map_element)) { switch ((map_element->properties.path.type + get_current_rotation()) & 0x03) { case 0: sub_98197C(81 + base_image_id, 0, 4, 32, 1, 23, height, 0, 4, height + 2, get_current_rotation()); @@ -570,11 +569,11 @@ void sub_6A4101(rct_map_element * map_element, uint16 height, uint32 ebp, bool w * @param map_element (esp[0]) * @param bp (bp) * @param height (dx) - * @param dword_F3EF6C (0x00F3EF6C) - * @param dword_F3EF70 (0x00F3EF70) - * @param dword_F3EF74 (0x00F3EF74) + * @param footpathEntry (0x00F3EF6C) + * @param imageFlags (0x00F3EF70) + * @param sceneryImageFlags (0x00F3EF74) */ -void sub_6A3F61(rct_map_element * map_element, uint16 bp, uint16 height, rct_footpath_entry * dword_F3EF6C, uint32 dword_F3EF70, uint32 dword_F3EF74, bool word_F3F038) +void sub_6A3F61(rct_map_element * map_element, uint16 bp, uint16 height, rct_footpath_entry * footpathEntry, uint32 imageFlags, uint32 sceneryImageFlags, bool word_F3F038) { // eax -- // ebx -- @@ -594,7 +593,7 @@ void sub_6A3F61(rct_map_element * map_element, uint16 bp, uint16 height, rct_foo uint8 additions = map_element->properties.path.additions & 0xF; if (additions != 0) { gPaintInteractionType = VIEWPORT_INTERACTION_ITEM_FOOTPATH_ITEM; - if (dword_F3EF74 != 0) { + if (sceneryImageFlags != 0) { gPaintInteractionType = VIEWPORT_INTERACTION_ITEM_NONE; } @@ -602,31 +601,31 @@ void sub_6A3F61(rct_map_element * map_element, uint16 bp, uint16 height, rct_foo rct_scenery_entry* sceneryEntry = get_footpath_item_entry(footpath_element_get_path_scenery_index(map_element)); switch (sceneryEntry->path_bit.draw_type) { case PATH_BIT_DRAW_TYPE_LIGHTS: - path_bit_lights_paint(sceneryEntry, map_element, height, (uint8)bp, dword_F3EF74); + path_bit_lights_paint(sceneryEntry, map_element, height, (uint8)bp, sceneryImageFlags); break; case PATH_BIT_DRAW_TYPE_BINS: - path_bit_bins_paint(sceneryEntry, map_element, height, (uint8)bp, dword_F3EF74); + path_bit_bins_paint(sceneryEntry, map_element, height, (uint8)bp, sceneryImageFlags); break; case PATH_BIT_DRAW_TYPE_BENCHES: - path_bit_benches_paint(sceneryEntry, map_element, height, (uint8)bp, dword_F3EF74); + path_bit_benches_paint(sceneryEntry, map_element, height, (uint8)bp, sceneryImageFlags); break; case PATH_BIT_DRAW_TYPE_JUMPING_FOUNTAINS: - path_bit_jumping_fountains_paint(sceneryEntry, map_element, height, (uint8)bp, dword_F3EF74, dpi); + path_bit_jumping_fountains_paint(sceneryEntry, map_element, height, (uint8)bp, sceneryImageFlags, dpi); break; } gPaintInteractionType = VIEWPORT_INTERACTION_ITEM_FOOTPATH; - if (dword_F3EF74 != 0) { + if (sceneryImageFlags != 0) { gPaintInteractionType = VIEWPORT_INTERACTION_ITEM_NONE; } } } // Redundant zoom-level check removed - RCT2_GLOBAL(0xF3EF78, uint32) = dword_F3EF6C->image | dword_F3EF70; + RCT2_GLOBAL(0xF3EF78, uint32) = footpathEntry->image | imageFlags; //RCT2_CALLPROC_X(0x6A4101, 0, 0, 0, 0, (int) map_element, 0, 0); - sub_6A4101(map_element, height, bp, word_F3F038, dword_F3EF6C, dword_F3EF6C->image | dword_F3EF70, dword_F3EF70); + sub_6A4101(map_element, height, bp, word_F3F038, footpathEntry, footpathEntry->image | imageFlags, imageFlags); } // This is about tunnel drawing @@ -677,8 +676,8 @@ void path_paint(uint8 direction, uint16 height, rct_map_element * map_element) uint32 ecx = get_current_rotation(); bool word_F3F038 = false; - uint32 dword_F3EF74 = 0; - uint32 dword_F3EF70 = 0; + uint32 sceneryImageFlags = 0; + uint32 imageFlags = 0; if (RCT2_GLOBAL(0x9DEA6F, uint8) & 1) { if (map_element->type & 1) { @@ -688,17 +687,17 @@ void path_paint(uint8 direction, uint16 height, rct_map_element * map_element) } if (!track_design_save_contains_map_element(map_element)) { - dword_F3EF70 = 0x21700000; + imageFlags = 0x21700000; } } if (footpath_element_path_scenery_is_ghost(map_element)) { - dword_F3EF74 = RCT2_ADDRESS(0x993CC4, uint32_t)[gConfigGeneral.construction_marker_colour]; + sceneryImageFlags = RCT2_ADDRESS(0x993CC4, uint32_t)[gConfigGeneral.construction_marker_colour]; } if (map_element->flags & MAP_ELEMENT_FLAG_GHOST) { gPaintInteractionType = VIEWPORT_INTERACTION_ITEM_NONE; - dword_F3EF70 = RCT2_ADDRESS(0x993CC4, uint32_t)[gConfigGeneral.construction_marker_colour]; + imageFlags = RCT2_ADDRESS(0x993CC4, uint32_t)[gConfigGeneral.construction_marker_colour]; } sint16 x = RCT2_GLOBAL(0x009DE56A, sint16), y = RCT2_GLOBAL(0x009DE56E, sint16); @@ -711,7 +710,7 @@ void path_paint(uint8 direction, uint16 height, rct_map_element * map_element) } else if (surface->base_height != bl) { word_F3F038 = true; } else { - if (map_element->properties.path.type & 0x04) { + if (footpath_element_is_sloped(map_element)) { // Diagonal path if ((surface->properties.surface.slope & 0x1F) != byte_98D800[map_element->properties.path.type & 0x03]) { @@ -727,39 +726,28 @@ void path_paint(uint8 direction, uint16 height, rct_map_element * map_element) if (gStaffDrawPatrolAreas != 0xFFFF) { sint32 staffIndex = gStaffDrawPatrolAreas; uint8 staffType = staffIndex & 0x7FFF; + bool is_staff_list = staffIndex & 0x8000; sint16 x = RCT2_GLOBAL(0x009DE56A, sint16), y = RCT2_GLOBAL(0x009DE56E, sint16); uint8 patrolColour = COLOUR_LIGHT_BLUE; + if (!is_staff_list) { + rct_peep * staff = GET_PEEP(staffIndex); + if (!staff_is_patrol_area_set(staff->staff_id, x, y)) { + patrolColour = COLOUR_GREY; + } + staffType = staff->staff_type; + } + x = (x & 0x1F80) >> 7; y = (y & 0x1F80) >> 1; int offset = (x | y) >> 5; int bitIndex = (x | y) & 0x1F; - - bool do_it = false; - - if (staffIndex >= 0) { - rct_peep * staff = GET_PEEP(staffIndex); - if (RCT2_ADDRESS(RCT2_ADDRESS_STAFF_PATROL_AREAS + (staff->staff_id * 512), uint32)[offset] & (1 << bitIndex)) { - do_it = true; - } else { - patrolColour = COLOUR_GREY; - staffType = (staff->staff_type + 200) * 512; - if (RCT2_ADDRESS(RCT2_ADDRESS_STAFF_PATROL_AREAS + staffType, uint32)[offset] & (1 << bitIndex)) { - do_it = true; - } - } - } else { - staffType = (staffType + 200) * 512; - if (RCT2_ADDRESS(RCT2_ADDRESS_STAFF_PATROL_AREAS + staffType, uint32)[offset] & (1 << bitIndex)) { - do_it = true; - } - } - - if (do_it) { + int ebx = (staffType + 200) * 512; + if (RCT2_ADDRESS(RCT2_ADDRESS_STAFF_PATROL_AREAS + ebx, uint32)[offset] & (1 << bitIndex)) { uint32 imageId = 2618; int height = map_element->base_height * 8; - if (map_element->properties.path.type & 0x04) { + if (footpath_element_is_sloped(map_element)) { imageId = 2619 + ((map_element->properties.path.type + get_current_rotation()) & 3); height += 16; } @@ -771,7 +759,7 @@ void path_paint(uint8 direction, uint16 height, rct_map_element * map_element) if (gCurrentViewportFlags & VIEWPORT_FLAG_PATH_HEIGHTS) { uint16 height = 3 + map_element->base_height * 8; - if (map_element->properties.path.type & 0x04) { + if (footpath_element_is_sloped(map_element)) { height += 8; } uint32 imageId = (SPR_HEIGHT_MARKER_BASE + height / 16) | COLOUR_GREY << 19 | 0x20000000; @@ -781,50 +769,40 @@ void path_paint(uint8 direction, uint16 height, rct_map_element * map_element) } uint8 pathType = (map_element->properties.path.type & 0xF0) >> 4; - rct_footpath_entry * dword_F3EF6C = gFootpathEntries[pathType]; + rct_footpath_entry * footpathEntry = gFootpathEntries[pathType]; - if (dword_F3EF6C->var_0A == 0) { - loc_6A37C9(map_element, height, dword_F3EF6C, word_F3F038, dword_F3EF70, dword_F3EF74); + if (footpathEntry->var_0A == 0) { + loc_6A37C9(map_element, height, footpathEntry, word_F3F038, imageFlags, sceneryImageFlags); } else { - loc_6A3B57(map_element, height, dword_F3EF6C, word_F3F038, dword_F3EF70, dword_F3EF74); + loc_6A3B57(map_element, height, footpathEntry, word_F3F038, imageFlags, sceneryImageFlags); } } -void loc_6A37C9(rct_map_element * mapElement, int height, rct_footpath_entry * dword_F3EF6C, bool hasFences, uint32 dword_F3EF70, uint32 dword_F3EF74) +void loc_6A37C9(rct_map_element * mapElement, int height, rct_footpath_entry * footpathEntry, bool hasFences, uint32 imageFlags, uint32 sceneryImageFlags) { - // esi: mapElement - // ecx: get_current_rotation(); - registers regs = {0}; - regs.al = mapElement->properties.path.edges; - regs.ah = regs.al << 4; + // Rol edges around rotation + uint8 edges = ((mapElement->properties.path.edges << get_current_rotation()) & 0xF) | + (((mapElement->properties.path.edges & 0xF) << get_current_rotation()) >> 4); - uint8 edi_index = rol16(regs.ax, get_current_rotation()) & 0xF; - // stru_98D804[edi_index]; -// mov eax, dword ptr ds:stru_98D804.anonymous_0[edi*8] -// mov ebx, dword ptr ds:stru_98D804.anonymous_1[edi*8] -// mov dword ptr _boundbox_offset_x, eax -// mov dword ptr word_F3EFC8, ebx - rct_xy16 boundBoxOffset = {.x =stru_98D804[edi_index][0], .y = stru_98D804[edi_index][1]}; - rct_xy16 boundBoxSize = {.x =stru_98D804[edi_index][2], .y = stru_98D804[edi_index][3]}; + uint8 corners = (((mapElement->properties.path.edges >> 4) << get_current_rotation()) & 0xF) | + (((mapElement->properties.path.edges >> 4) << get_current_rotation()) >> 4); - regs.al = mapElement->properties.path.edges; - regs.ah = regs.al >> 4; - regs.ax = (rol16(regs.ax, get_current_rotation()) >> 4) & 0xF0; - uint16 edi = edi_index | regs.ax; + rct_xy16 boundBoxOffset = {.x =stru_98D804[edges][0], .y = stru_98D804[edges][1]}; + rct_xy16 boundBoxSize = {.x =stru_98D804[edges][2], .y = stru_98D804[edges][3]}; - uint32 ebx; - if (mapElement->properties.path.type & 0x04) { - ebx = ((mapElement->properties.path.type + get_current_rotation()) & 3) + 16; + uint16 edi = edges | (corners << 4); + + uint32 imageId; + if (footpath_element_is_sloped(mapElement)) { + imageId = ((mapElement->properties.path.type + get_current_rotation()) & 3) + 16; } else { - ebx = byte_98D6E0[edi]; + imageId = byte_98D6E0[edi]; } - // save edi - - ebx += dword_F3EF6C->image; - if (map_element_get_direction(mapElement) & 1) { - ebx += 51; + imageId += footpathEntry->image; + if (mapElement->type & 1) { + imageId += 51; } if (!RCT2_GLOBAL(0x9DE57C, bool)) { @@ -835,45 +813,38 @@ void loc_6A37C9(rct_map_element * mapElement, int height, rct_footpath_entry * d } if (!hasFences || !RCT2_GLOBAL(0x9DE57C, bool)) { - sub_98197C(ebx | dword_F3EF70, 0, 0, boundBoxSize.x, boundBoxSize.y, 0, height, boundBoxOffset.x, boundBoxOffset.y, height + 1, get_current_rotation()); + sub_98197C(imageId | imageFlags, 0, 0, boundBoxSize.x, boundBoxSize.y, 0, height, boundBoxOffset.x, boundBoxOffset.y, height + 1, get_current_rotation()); } else { uint32 image_id; - if (mapElement->properties.path.type & 0x04) { - image_id = ((mapElement->properties.path.type + get_current_rotation()) & 3) + dword_F3EF6C->bridge_image + 51; + if (footpath_element_is_sloped(mapElement)) { + image_id = ((mapElement->properties.path.type + get_current_rotation()) & 3) + footpathEntry->bridge_image + 51; } else { - image_id = byte_98D8A4[edi_index] + dword_F3EF6C->bridge_image + 49; + image_id = byte_98D8A4[edges] + footpathEntry->bridge_image + 49; } - sub_98197C(image_id | dword_F3EF70, 0, 0, boundBoxSize.x, boundBoxSize.y, 0, height, boundBoxOffset.x, boundBoxOffset.y, height + 1, get_current_rotation()); + sub_98197C(image_id | imageFlags, 0, 0, boundBoxSize.x, boundBoxSize.y, 0, height, boundBoxOffset.x, boundBoxOffset.y, height + 1, get_current_rotation()); - if (!(mapElement->type & 1) && !(dword_F3EF6C->flags & 2)) { + if (!(mapElement->type & 1) && !(footpathEntry->flags & 2)) { // don't draw } else { - sub_98199C(ebx | dword_F3EF70, 0, 0, boundBoxSize.x, boundBoxSize.y, 0, height, boundBoxOffset.x, boundBoxOffset.y, height + 1, get_current_rotation()); + sub_98199C(imageId | imageFlags, 0, 0, boundBoxSize.x, boundBoxSize.y, 0, height, boundBoxOffset.x, boundBoxOffset.y, height + 1, get_current_rotation()); } } - sub_6A3F61(mapElement, edi, height, dword_F3EF6C, dword_F3EF70, dword_F3EF74, hasFences); // TODO: arguments + sub_6A3F61(mapElement, edi, height, footpathEntry, imageFlags, sceneryImageFlags, hasFences); uint16 ax = 0; - if (mapElement->properties.path.type & 0x04) { + if (footpath_element_is_sloped(mapElement)) { ax = ((mapElement->properties.path.type + get_current_rotation()) & 0x3) + 1; } - uint32 ebp = edi; - ebx = ebp & 0xF; - - if (byte_98D8A4[ebx] == 0) { - path_a_supports_paint_setup(0, ax, height, dword_F3EF70, dword_F3EF6C, NULL); + if (byte_98D8A4[edges] == 0) { + path_a_supports_paint_setup(0, ax, height, imageFlags, footpathEntry, NULL); } else { - path_a_supports_paint_setup(1, ax, height, dword_F3EF70, dword_F3EF6C, NULL); + path_a_supports_paint_setup(1, ax, height, imageFlags, footpathEntry, NULL); } - - - // no idea whre bp comes from - uint16 edges = edi; sint16 x = RCT2_GLOBAL(0x009DE56A, sint16), y = RCT2_GLOBAL(0x009DE56E, sint16); height += 32;