From ab255ae90db1e0bd972accea3bfcd8d3d2a9871c Mon Sep 17 00:00:00 2001 From: Marijn van der Werf Date: Thu, 5 May 2016 17:42:50 +0200 Subject: [PATCH 01/16] Decompile fence drawing --- src/localisation/string_ids.h | 1 + src/paint/map_element/fence.c | 504 +++++++++++++++++++++++++++++++++- src/paint/paint.h | 4 +- 3 files changed, 501 insertions(+), 8 deletions(-) diff --git a/src/localisation/string_ids.h b/src/localisation/string_ids.h index a2057fc175..c1fe6695a9 100644 --- a/src/localisation/string_ids.h +++ b/src/localisation/string_ids.h @@ -742,6 +742,7 @@ enum { STR_OFF = 1775, STR_ON = 1776, STR_RIDE_MUSIC = 1777, + STR_SCROLLING_SIGN_TEXT = 1778, STR_UNIFORM_COLOUR_TIP = 1790, STR_UNIFORM_COLOUR = 1791, diff --git a/src/paint/map_element/fence.c b/src/paint/map_element/fence.c index 9944bb1f47..ff606927d8 100644 --- a/src/paint/map_element/fence.c +++ b/src/paint/map_element/fence.c @@ -14,14 +14,506 @@ *****************************************************************************/ #pragma endregion -#include "map_element.h" +#include "../../common.h" #include "../../addresses.h" #include "../../world/map.h" +#include "../../drawing/drawing.h" +#include "../../world/scenery.h" +#include "../../game.h" +#include "../../ride/track.h" +#include "../../config.h" +#include "../../localisation/localisation.h" +#include "../../interface/colour.h" +#include "../../interface/viewport.h" +#include "../paint.h" -extern bool TempForScrollText; +uint32 dword_993CC4[] = { + COLOUR_DARK_GREEN << 19 | COLOUR_GREY << 24 | 0x20000000, + COLOUR_YELLOW << 19 | COLOUR_GREY << 24 | 0x40000000 +}; -void fence_paint(uint8 direction, int height, rct_map_element* mapElement) { - TempForScrollText = true; - RCT2_CALLPROC_X(0x6E44B0, 0, 0, direction, height, (int)mapElement, 0, 0); - TempForScrollText = false; +const uint8 byte_9A406C[] = { + 2, 2, 22, 26, 30, 34, 34, 34, 34, 34, 30, 26, 22, 2, 6, 2, + 2, 2, 6, 10, 14, 18, 18, 18, 18, 18, 14, 10, 6, 2, 22, 2 +}; + +const uint8 byte_9A408C[] = { + 0, 0, 4, 8, 12, 16, 16, 16, 16, 16, 12, 8, 4, 0, 20, 0, + 0, 0, 20, 24, 28, 32, 32, 32, 32, 32, 28, 24, 20, 0, 4, 0 +}; + +const uint8 byte_9A40AC[] = { + 2, 2, 6, 10, 14, 18, 18, 18, 18, 18, 14, 10, 6, 2, 22, 2, + 2, 2, 22, 26, 30, 34, 34, 34, 34, 34, 30, 26, 22, 2, 6, 2 +}; +const uint8 byte_9A40CC[] = { + 0, 0, 20, 24, 28, 32, 32, 32, 32, 32, 28, 24, 20, 0, 4, 0, + 0, 0, 4, 8, 12, 16, 16, 16, 16, 16, 12, 8, 4, 0, 20, 0 +}; + +void fence_paint(uint8 direction, int height, rct_map_element * map_element) +{ + //RCT2_CALLPROC_X(0x6E44B0, 0, 0, direction, height, (int) map_element, 0, 0); + + rct_drawpixelinfo * dpi = RCT2_GLOBAL(0x140E9A8, rct_drawpixelinfo *); + RCT2_GLOBAL(RCT2_ADDRESS_PAINT_SETUP_CURRENT_TYPE, uint8) = VIEWPORT_INTERACTION_ITEM_WALL; + + rct_scenery_entry * dword_141F70C = g_wallSceneryEntries[map_element->properties.fence.type]; + uint32 dword_141F708 = 0; + + if (dword_141F70C->wall.flags2 & WALL_SCENERY_FLAG5) { + // animation? + dword_141F708 = (gCurrentTicks & 7) * 2; + } + + + uint32 dword_141F714 = (map_element->properties.fence.item[1] & 0b11111) << 19 | 0x20000000; + uint32 dword_141F718 = dword_141F714 + 0x23800006; + + if (dword_141F70C->wall.flags & WALL_SCENERY_HAS_SECONDARY_COLOUR) { + uint8 secondaryColour = (map_element->properties.fence.item[1] >> 5) | ((map_element->flags & 0x60) >> 2); + dword_141F714 |= secondaryColour << 24 | 0x80000000; + } + + uint32 dword_141F71C = 0; + if (dword_141F70C->wall.flags & WALL_SCENERY_HAS_TERNARY_COLOUR) { + dword_141F71C = map_element->properties.fence.item[0]; + dword_141F714 &= 0x0DFFFFFFF; + } + + int clearanceHeight = ceil2(map_element->clearance_height * 8 + 15, 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; + } + + uint32 dword_141F710 = 0; + if (RCT2_GLOBAL(0x9DEA6F, uint8) & 1) { + if (!track_save_contains_map_element(map_element)) { + dword_141F710 = 0x21700000; + } + } + + if (map_element->flags & MAP_ELEMENT_FLAG_GHOST) { + RCT2_GLOBAL(RCT2_ADDRESS_PAINT_SETUP_CURRENT_TYPE, uint8) = VIEWPORT_INTERACTION_ITEM_NONE; + dword_141F710 = dword_993CC4[gConfigGeneral.construction_marker_colour]; + } + + // save map_element + + uint8 ah = dword_141F70C->wall.height * 8 - 2; + + if (dword_141F70C->wall.flags & WALL_SCENERY_FLAG5) { + uint32 ebx = (map_element->properties.fence.item[2] >> 3) & 0x1F; + + switch (direction) { + case 0: + ebx = dword_141F70C->image + byte_9A406C[ebx]; + if (dword_141F70C->wall.flags & WALL_SCENERY_FLAG1) { + ebx |= dword_141F714; + } + + if (dword_141F710 != 0) { + ebx = (ebx & 0x7FFFF) | dword_141F710; + } + + if (dword_141F70C->wall.flags & WALL_SCENERY_FLAG4) { + paint_struct * ps; + + ps = sub_98197C(ebx, 0, 0, 1, 3, ah - 5, height, 1, 1, height + 1, get_current_rotation()); + if (ps != NULL) { + ps->tertiary_colour = dword_141F71C; + } + + ps = sub_98197C(ebx + 1, 0, 0, 1, 28, 3, height, 1, 1, height + ah - 5 - 4, get_current_rotation()); + if (ps != NULL) { + ps->tertiary_colour = dword_141F71C; + } + } else { + paint_struct * ps; + + ps = sub_98197C(ebx, 0, 0, 1, 28, ah, height, 1, 1, height + 1, get_current_rotation()); + if (ps != NULL) { + ps->tertiary_colour = dword_141F71C; + } + + ps = sub_98199C(ebx + 1, 0, 0, 1, 28, ah, height, 1, 1, height + 1, get_current_rotation()); + if (ps != NULL) { + ps->tertiary_colour = dword_141F71C; + } + } + break; + + case 1: + ebx = dword_141F70C->image + byte_9A408C[ebx]; + if (dword_141F70C->wall.flags & WALL_SCENERY_FLAG1) { + ebx |= dword_141F714; + } + + if (dword_141F710 != 0) { + ebx = (ebx & 0x7FFFF) | dword_141F710; + } + + if (dword_141F70C->wall.flags & WALL_SCENERY_FLAG4) { + paint_struct * ps; + + ps = sub_98197C(ebx, 1, 31, 3, 3, ah - 5, height, 1, 30, height + 1, get_current_rotation()); + if (ps != NULL) { + ps->tertiary_colour = dword_141F71C; + } + + ps = sub_98197C(ebx + 1, 1, 31, 29, 3, 2, height, 1, 30, height + ah - 8, get_current_rotation()); + if (ps != NULL) { + ps->tertiary_colour = dword_141F71C; + } + } else { + paint_struct * ps; + + ps = sub_98197C(ebx, 1, 31, 29, 1, ah, height, 2, 30, height + 1, get_current_rotation()); + if (ps != NULL) { + ps->tertiary_colour = dword_141F71C; + } + + ps = sub_98199C(ebx + 1, 1, 31, 29, 1, ah, height, 2, 30, height + 1, get_current_rotation()); + if (ps != NULL) { + ps->tertiary_colour = dword_141F71C; + } + } + break; + + case 2: + ebx = dword_141F70C->image + byte_9A40AC[ebx]; + if (dword_141F70C->wall.flags & WALL_SCENERY_FLAG1) { + ebx |= dword_141F714; + } + + if (dword_141F710 != 0) { + ebx = (ebx & 0x7FFFF) | dword_141F710; + } + + if (dword_141F70C->wall.flags & WALL_SCENERY_FLAG4) { + paint_struct * ps; + + ps = sub_98197C(ebx, 31, 0, 3, 3, ah - 5, height, 1, 30, height + 1, get_current_rotation()); + if (ps != NULL) { + ps->tertiary_colour = dword_141F71C; + } + + ps = sub_98197C(ebx + 1, 31, 0, 3, 29, 2, height, 1, 30, height + ah - 8, get_current_rotation()); + if (ps != NULL) { + ps->tertiary_colour = dword_141F71C; + } + } else { + paint_struct * ps; + + ps = sub_98197C(ebx, 31, 0, 1, 29, ah, height, 30, 2, height + 1, get_current_rotation()); + if (ps != NULL) { + ps->tertiary_colour = dword_141F71C; + } + + ps = sub_98199C(ebx + 1, 31, 0, 1, 29, ah, height, 30, 2, height + 1, get_current_rotation()); + if (ps != NULL) { + ps->tertiary_colour = dword_141F71C; + } + } + break; + + case 3: + ebx = dword_141F70C->image + byte_9A40CC[ebx]; + if (dword_141F70C->wall.flags & WALL_SCENERY_FLAG1) { + ebx |= dword_141F714; + } + + if (dword_141F710 != 0) { + ebx = (ebx & 0x7FFFF) | dword_141F710; + } + + if (dword_141F70C->wall.flags & WALL_SCENERY_FLAG4) { + paint_struct * ps; + + ps = sub_98197C(ebx, 2, 1, 3, 1, ah - 5, height, 1, 1, height + 1, get_current_rotation()); + if (ps != NULL) { + ps->tertiary_colour = dword_141F71C; + } + + ps = sub_98197C(ebx + 1, 2, 1, 28, 1, 3, height, 1, 1, height + ah - 5 - 4, get_current_rotation()); + if (ps != NULL) { + ps->tertiary_colour = dword_141F71C; + } + } else { + paint_struct * ps; + + ps = sub_98197C(ebx, 2, 1, 28, 1, ah, height, 1, 1, height + 1, get_current_rotation()); + if (ps != NULL) { + ps->tertiary_colour = dword_141F71C; + } + + ps = sub_98199C(ebx + 1, 2, 1, 28, 1, ah, height, 1, 1, height + 1, get_current_rotation()); + if (ps != NULL) { + ps->tertiary_colour = dword_141F71C; + } + } + break; + } + + return; + } + + + uint8 al = map_element->type; + + switch (direction) { + case 0: { + uint32 offset; + if (al & 0x80) { + offset = 3; + } else if (al & 0x40) { + offset = 5; + } else { + offset = 1; + } + + uint32 baseImageId = offset + dword_141F70C->image + dword_141F708; + + uint32 imageId = baseImageId; + if (dword_141F70C->wall.flags & WALL_SCENERY_FLAG2) { + if (dword_141F70C->wall.flags & WALL_SCENERY_FLAG1) { + imageId |= dword_141F714; + } + + if (dword_141F710 != 0) { + imageId = (imageId & 0x7FFFF) | dword_141F710; + } + + sub_98197C(imageId, 0, 0, 1, 28, ah, height, 1, 1, height + 1, get_current_rotation()); + if (dword_141F710 == 0) { + imageId = baseImageId + dword_141F718; + sub_98199C(imageId, 0, 0, 1, 28, ah, height, 1, 1, height + 1, get_current_rotation()); + } + } else { + if (dword_141F70C->wall.flags & WALL_SCENERY_FLAG1) { + imageId |= dword_141F714; + } + + if (dword_141F710 != 0) { + imageId = (imageId & 0x7FFFF) | dword_141F710; + } + + paint_struct * paint = sub_98197C(imageId, 0, 0, 1, 28, ah, height, 1, 1, height + 1, get_current_rotation()); + if (paint != NULL) { + paint->tertiary_colour = dword_141F71C; + } + } + + break; + } + + case 1: { + uint32 offset; + if (al & 0x80) { + offset = 2; + } else if (al & 0x40) { + offset = 4; + } else { + offset = 0; + } + + if (dword_141F70C->wall.flags & WALL_SCENERY_FLAG2) { + if (dword_141F70C->wall.flags & WALL_SCENERY_FLAG4) { + offset += 12; + } + + uint32 baseImageId = offset + dword_141F70C->image; + uint32 imageId = baseImageId; + + if (dword_141F70C->wall.flags & WALL_SCENERY_FLAG1) { + imageId |= dword_141F714; + } + + if (dword_141F710 != 0) { + imageId = (imageId & 0x7FFFF) | dword_141F710; + } + + sub_98197C(imageId, 1, 31, 29, 1, ah, height, 2, 30, height + 1, get_current_rotation()); + if (dword_141F710 == 0) { + imageId = baseImageId + dword_141F718; + sub_98199C(imageId, 1, 31, 29, 1, ah, height, 2, 30, height + 1, get_current_rotation()); + } + } else { + if (dword_141F70C->wall.flags & WALL_SCENERY_FLAG4) { + offset += 6; + } + + uint32 imageId = offset + dword_141F70C->image + dword_141F708; + + if (dword_141F70C->wall.flags & WALL_SCENERY_FLAG1) { + imageId |= dword_141F714; + } + + if (dword_141F710 != 0) { + imageId = (imageId & 0x7FFFF) | dword_141F710; + } + + paint_struct * paint = sub_98197C(imageId, 1, 31, 29, 1, ah, height, 2, 30, height + 1, get_current_rotation()); + if (paint != NULL) { + paint->tertiary_colour = dword_141F71C; + } + } + + break; + } + + case 2: { + uint32 offset; + if (al & 0x80) { + offset = 5; + } else if (al & 0x40) { + offset = 3; + } else { + offset = 1; + } + + if (dword_141F70C->wall.flags & WALL_SCENERY_FLAG4) { + offset += 6; + } + + uint32 baseImageId = offset + dword_141F70C->image; + uint32 imageId = baseImageId; + + if (dword_141F70C->wall.flags & WALL_SCENERY_FLAG2) { + if (dword_141F70C->wall.flags & WALL_SCENERY_FLAG1) { + imageId |= dword_141F714; + } + + if (dword_141F710 != 0) { + imageId = (imageId & 0x7FFFF) | dword_141F710; + } + + sub_98197C(imageId, 31, 0, 1, 29, ah, height, 30, 2, height + 1, get_current_rotation()); + if (dword_141F710 == 0) { + imageId = baseImageId + dword_141F718; + sub_98199C(imageId, 31, 0, 1, 29, ah, height, 30, 2, height + 1, get_current_rotation()); + } + } else { + uint32 imageId = imageId + dword_141F708; + + if (dword_141F70C->wall.flags & WALL_SCENERY_FLAG1) { + imageId |= dword_141F714; + } + + if (dword_141F710 != 0) { + imageId = (imageId & 0x7FFFF) | dword_141F710; + } + + paint_struct * paint = sub_98197C(imageId, 31, 0, 1, 29, ah, height, 30, 2, height + 1, get_current_rotation()); + if (paint != NULL) { + paint->tertiary_colour = dword_141F71C; + } + } + + break; + } + + case 3: { + uint32 offset; + if (al & 0x80) { + offset = 4; + } else if (al & 0x40) { + offset = 2; + } else { + offset = 0; + } + + uint32 baseImageId = offset + dword_141F70C->image + dword_141F708; + uint32 imageId = baseImageId; + + if (dword_141F70C->wall.flags & WALL_SCENERY_FLAG2) { + if (dword_141F70C->wall.flags & WALL_SCENERY_FLAG1) { + imageId |= dword_141F714; + } + + if (dword_141F710 != 0) { + imageId = (imageId & 0x7FFFF) | dword_141F710; + } + + sub_98197C(imageId, 2, 1, 28, 1, ah, height, 1, 1, height + 1, get_current_rotation()); + if (dword_141F710 == 0) { + imageId = baseImageId + dword_141F718; + sub_98199C(imageId, 2, 1, 28, 1, ah, height, 1, 1, height + 1, get_current_rotation()); + } + } else { + if (dword_141F70C->wall.flags & WALL_SCENERY_FLAG1) { + imageId |= dword_141F714; + } + + if (dword_141F710 != 0) { + imageId = (imageId & 0x7FFFF) | dword_141F710; + } + + paint_struct * paint = sub_98197C(imageId, 2, 1, 28, 1, ah, height, 1, 1, height + 1, get_current_rotation()); + if (paint != NULL) { + paint->tertiary_colour = dword_141F71C; + } + } + + break; + } + } + + if (dword_141F70C->wall.var_0D == 0xFF) { + return; + } + + if (direction != 0 && direction != 3) { + return; + } + + if (dword_141F70C->wall.flags & WALL_SCENERY_FLAG1) { + return; + } + + RCT2_GLOBAL(RCT2_ADDRESS_COMMON_FORMAT_ARGS, uint32) = 0; + RCT2_GLOBAL(RCT2_ADDRESS_COMMON_FORMAT_ARGS + 4, uint32) = 0; + + uint8 al_2 = map_element->properties.fence.item[1] >> 5 | (map_element->flags & 0x60) >> 2; + + if (dword_141F710 != 0) { + al_2 = COLOUR_GREY; + } + + if (get_current_rotation() == 0) { + al_2 |= 0x80; + } + + RCT2_GLOBAL(RCT2_ADDRESS_COMMON_FORMAT_ARGS + 7, uint8) = al_2; + + uint16 scrollingMode = dword_141F70C->wall.var_0D + (get_current_rotation() + 1) & 0x3; + + uint8 bannerIndex = map_element->properties.fence.item[0]; + rct_banner * banner = &gBanners[bannerIndex]; + RCT2_GLOBAL(RCT2_ADDRESS_COMMON_FORMAT_ARGS, rct_string_id) = banner->string_idx; + if (banner->flags & 0x04) { + rct_ride * ride = get_ride(banner->colour); + RCT2_GLOBAL(RCT2_ADDRESS_COMMON_FORMAT_ARGS, rct_string_id) = ride->name; + RCT2_GLOBAL(RCT2_ADDRESS_COMMON_FORMAT_ARGS + 2, uint32) = ride->name_arguments; + } + + sub_98199C(0, 0, 0, 1, 1, 13, height + 8, 0, 0, 0, get_current_rotation()); + + + utf8 signString[MAX_PATH]; + rct_string_id stringId = STR_SCROLLING_SIGN_TEXT; + if (gConfigGeneral.upper_case_banners) { + format_string_to_upper(signString, stringId, RCT2_ADDRESS(RCT2_ADDRESS_COMMON_FORMAT_ARGS, void)); + } else { + format_string(signString, stringId, RCT2_ADDRESS(RCT2_ADDRESS_COMMON_FORMAT_ARGS, void)); + } + + gCurrentFontSpriteBase = FONT_SPRITE_BASE_TINY; + + uint16 string_width = gfx_get_string_width(signString); + uint16 scroll = (gCurrentTicks / 2) % string_width; + + sub_98199C(scrolling_text_setup(stringId, scroll, scrollingMode), 0, 0, 1, 1, 13, height + 8, 1, 1, height + 1, get_current_rotation()); } + diff --git a/src/paint/paint.h b/src/paint/paint.h index 8e5bff4fcf..b527dee06c 100644 --- a/src/paint/paint.h +++ b/src/paint/paint.h @@ -43,9 +43,9 @@ typedef struct paint_struct paint_struct; struct paint_struct { uint32 image_id; // 0x00 union { - uint32 tertiary_colour; + uint32 tertiary_colour; // 0x04 // If masked image_id is masked_id - uint32 colour_image_id; + uint32 colour_image_id; // 0x04 }; uint16 bound_box_x; // 0x08 uint16 bound_box_y; // 0x0A From 78b63b2c6e0f942860b4844aed8e3575c14a3373 Mon Sep 17 00:00:00 2001 From: Marijn van der Werf Date: Thu, 5 May 2016 20:04:53 +0200 Subject: [PATCH 02/16] Refactor one paint function --- src/paint/map_element/fence.c | 204 ++++++++++++++-------------------- 1 file changed, 84 insertions(+), 120 deletions(-) diff --git a/src/paint/map_element/fence.c b/src/paint/map_element/fence.c index ff606927d8..ae4d43b90a 100644 --- a/src/paint/map_element/fence.c +++ b/src/paint/map_element/fence.c @@ -51,10 +51,57 @@ const uint8 byte_9A40CC[] = { 0, 0, 4, 8, 12, 16, 16, 16, 16, 16, 12, 8, 4, 0, 20, 0 }; +void do_part_1(uint32 imageId, + rct_scenery_entry * dword_141F70C, + uint32 dword_141F714, uint32 dword_141F71C, uint32 dword_141F710, + rct_xyz16 offset, + rct_xyz16 boundsR1, rct_xyz16 boundsR1_, + rct_xyz16 boundsR2, rct_xyz16 boundsR2_, + rct_xyz16 boundsL1, rct_xyz16 boundsL1_) +{ + if (dword_141F70C->wall.flags & WALL_SCENERY_FLAG1) { + imageId |= dword_141F714; + } + + if (dword_141F710 != 0) { + imageId = (imageId & 0x7FFFF) | dword_141F710; + } + + if (dword_141F70C->wall.flags & WALL_SCENERY_FLAG4) { + paint_struct * ps; + + ps = sub_98197C(imageId, offset.x, offset.y, boundsR1.x, boundsR1.y, boundsR1.z, offset.z, boundsR1_.x, boundsR1_.y, boundsR1_.z, get_current_rotation()); + if (ps != NULL) { + ps->tertiary_colour = dword_141F71C; + } + + ps = sub_98197C(imageId + 1, offset.x, offset.y, boundsR2.x, boundsR2.y, boundsR2.z, offset.z, boundsR2_.x, boundsR2_.y, boundsR2_.z, get_current_rotation()); + if (ps != NULL) { + ps->tertiary_colour = dword_141F71C; + } + } else { + paint_struct * ps; + + ps = sub_98197C(imageId, offset.x, offset.y, boundsL1.x, boundsL1.y, boundsL1.z, offset.z, boundsL1_.x, boundsL1_.y, boundsL1_.z, get_current_rotation()); + if (ps != NULL) { + ps->tertiary_colour = dword_141F71C; + } + + ps = sub_98199C(imageId + 1, offset.x, offset.y, boundsL1.x, boundsL1.y, boundsL1.z, offset.z, boundsL1_.x, boundsL1_.y, boundsL1_.z, get_current_rotation()); + if (ps != NULL) { + ps->tertiary_colour = dword_141F71C; + } + } +} + +/** + * rct2: 0x006E44B0 + * @param direction (cl) + * @param height (dx) + * @param map_element (esi) + */ void fence_paint(uint8 direction, int height, rct_map_element * map_element) { - //RCT2_CALLPROC_X(0x6E44B0, 0, 0, direction, height, (int) map_element, 0, 0); - rct_drawpixelinfo * dpi = RCT2_GLOBAL(0x140E9A8, rct_drawpixelinfo *); RCT2_GLOBAL(RCT2_ADDRESS_PAINT_SETUP_CURRENT_TYPE, uint8) = VIEWPORT_INTERACTION_ITEM_WALL; @@ -103,156 +150,73 @@ void fence_paint(uint8 direction, int height, rct_map_element * map_element) uint8 ah = dword_141F70C->wall.height * 8 - 2; + rct_xyz16 offset, boundsR1, boundsR1_, boundsR2, boundsR2_, boundsL1, boundsL1_; + if (dword_141F70C->wall.flags & WALL_SCENERY_FLAG5) { uint32 ebx = (map_element->properties.fence.item[2] >> 3) & 0x1F; - switch (direction) { case 0: ebx = dword_141F70C->image + byte_9A406C[ebx]; - if (dword_141F70C->wall.flags & WALL_SCENERY_FLAG1) { - ebx |= dword_141F714; - } - if (dword_141F710 != 0) { - ebx = (ebx & 0x7FFFF) | dword_141F710; - } + boundsR1 = (rct_xyz16) {1, 3, ah - 5}; + boundsR1_ = (rct_xyz16) {1, 1, height + 1}; + boundsR2 = (rct_xyz16) {1, 28, 3}; + boundsR2_ = (rct_xyz16) {1, 1, height + ah - 9}; - if (dword_141F70C->wall.flags & WALL_SCENERY_FLAG4) { - paint_struct * ps; + boundsL1 = (rct_xyz16) {1, 28, ah}; + boundsL1_ = (rct_xyz16) {1, 1, height + 1}; - ps = sub_98197C(ebx, 0, 0, 1, 3, ah - 5, height, 1, 1, height + 1, get_current_rotation()); - if (ps != NULL) { - ps->tertiary_colour = dword_141F71C; - } + offset = (rct_xyz16) {0, 0, height}; - ps = sub_98197C(ebx + 1, 0, 0, 1, 28, 3, height, 1, 1, height + ah - 5 - 4, get_current_rotation()); - if (ps != NULL) { - ps->tertiary_colour = dword_141F71C; - } - } else { - paint_struct * ps; - - ps = sub_98197C(ebx, 0, 0, 1, 28, ah, height, 1, 1, height + 1, get_current_rotation()); - if (ps != NULL) { - ps->tertiary_colour = dword_141F71C; - } - - ps = sub_98199C(ebx + 1, 0, 0, 1, 28, ah, height, 1, 1, height + 1, get_current_rotation()); - if (ps != NULL) { - ps->tertiary_colour = dword_141F71C; - } - } + do_part_1(ebx, dword_141F70C, dword_141F714, dword_141F71C, dword_141F710, offset, boundsR1, boundsR1_, boundsR2, boundsR2_, boundsL1, boundsL1_); break; case 1: ebx = dword_141F70C->image + byte_9A408C[ebx]; - if (dword_141F70C->wall.flags & WALL_SCENERY_FLAG1) { - ebx |= dword_141F714; - } - if (dword_141F710 != 0) { - ebx = (ebx & 0x7FFFF) | dword_141F710; - } + boundsR1 = (rct_xyz16) {3, 3, ah - 5}; + boundsR1_ = (rct_xyz16) {1, 30, height + 1}; + boundsR2 = (rct_xyz16) {29, 3, 2}; + boundsR2_ = (rct_xyz16) {1, 30, height + ah - 8}; - if (dword_141F70C->wall.flags & WALL_SCENERY_FLAG4) { - paint_struct * ps; + boundsL1 = (rct_xyz16) {29, 1, ah}; + boundsL1_ = (rct_xyz16) {2, 30, height + 1}; - ps = sub_98197C(ebx, 1, 31, 3, 3, ah - 5, height, 1, 30, height + 1, get_current_rotation()); - if (ps != NULL) { - ps->tertiary_colour = dword_141F71C; - } + offset = (rct_xyz16) {1, 31, height}; - ps = sub_98197C(ebx + 1, 1, 31, 29, 3, 2, height, 1, 30, height + ah - 8, get_current_rotation()); - if (ps != NULL) { - ps->tertiary_colour = dword_141F71C; - } - } else { - paint_struct * ps; - - ps = sub_98197C(ebx, 1, 31, 29, 1, ah, height, 2, 30, height + 1, get_current_rotation()); - if (ps != NULL) { - ps->tertiary_colour = dword_141F71C; - } - - ps = sub_98199C(ebx + 1, 1, 31, 29, 1, ah, height, 2, 30, height + 1, get_current_rotation()); - if (ps != NULL) { - ps->tertiary_colour = dword_141F71C; - } - } + do_part_1(ebx, dword_141F70C, dword_141F714, dword_141F71C, dword_141F710, offset, boundsR1, boundsR1_, boundsR2, boundsR2_, boundsL1, boundsL1_); break; case 2: ebx = dword_141F70C->image + byte_9A40AC[ebx]; - if (dword_141F70C->wall.flags & WALL_SCENERY_FLAG1) { - ebx |= dword_141F714; - } - if (dword_141F710 != 0) { - ebx = (ebx & 0x7FFFF) | dword_141F710; - } + boundsR1 = (rct_xyz16) {3, 3, ah - 5}; + boundsR1_ = (rct_xyz16) {30, 1, height + 1}; + boundsR2 = (rct_xyz16) {3, 29, 2}; + boundsR2_ = (rct_xyz16) {30, 1, height + ah - 8}; - if (dword_141F70C->wall.flags & WALL_SCENERY_FLAG4) { - paint_struct * ps; + boundsL1 = (rct_xyz16) {1, 29, ah}; + boundsL1_ = (rct_xyz16) {30, 2, height + 1}; - ps = sub_98197C(ebx, 31, 0, 3, 3, ah - 5, height, 1, 30, height + 1, get_current_rotation()); - if (ps != NULL) { - ps->tertiary_colour = dword_141F71C; - } + offset = (rct_xyz16) {31, 0, height}; - ps = sub_98197C(ebx + 1, 31, 0, 3, 29, 2, height, 1, 30, height + ah - 8, get_current_rotation()); - if (ps != NULL) { - ps->tertiary_colour = dword_141F71C; - } - } else { - paint_struct * ps; - - ps = sub_98197C(ebx, 31, 0, 1, 29, ah, height, 30, 2, height + 1, get_current_rotation()); - if (ps != NULL) { - ps->tertiary_colour = dword_141F71C; - } - - ps = sub_98199C(ebx + 1, 31, 0, 1, 29, ah, height, 30, 2, height + 1, get_current_rotation()); - if (ps != NULL) { - ps->tertiary_colour = dword_141F71C; - } - } + do_part_1(ebx, dword_141F70C, dword_141F714, dword_141F71C, dword_141F710, offset, boundsR1, boundsR1_, boundsR2, boundsR2_, boundsL1, boundsL1_); break; case 3: ebx = dword_141F70C->image + byte_9A40CC[ebx]; - if (dword_141F70C->wall.flags & WALL_SCENERY_FLAG1) { - ebx |= dword_141F714; - } - if (dword_141F710 != 0) { - ebx = (ebx & 0x7FFFF) | dword_141F710; - } + boundsR1 = (rct_xyz16) {3, 1, ah - 5}; + boundsR1_ = (rct_xyz16) {1, 1, height + 1}; + boundsR2 = (rct_xyz16) {28, 1, 3}; + boundsR2_ = (rct_xyz16) {1, 1, height + ah - 9}; - if (dword_141F70C->wall.flags & WALL_SCENERY_FLAG4) { - paint_struct * ps; + boundsL1 = (rct_xyz16) {28, 1, ah}; + boundsL1_ = (rct_xyz16) {1, 1, height + 1}; - ps = sub_98197C(ebx, 2, 1, 3, 1, ah - 5, height, 1, 1, height + 1, get_current_rotation()); - if (ps != NULL) { - ps->tertiary_colour = dword_141F71C; - } + offset = (rct_xyz16) {2, 1, height}; - ps = sub_98197C(ebx + 1, 2, 1, 28, 1, 3, height, 1, 1, height + ah - 5 - 4, get_current_rotation()); - if (ps != NULL) { - ps->tertiary_colour = dword_141F71C; - } - } else { - paint_struct * ps; - - ps = sub_98197C(ebx, 2, 1, 28, 1, ah, height, 1, 1, height + 1, get_current_rotation()); - if (ps != NULL) { - ps->tertiary_colour = dword_141F71C; - } - - ps = sub_98199C(ebx + 1, 2, 1, 28, 1, ah, height, 1, 1, height + 1, get_current_rotation()); - if (ps != NULL) { - ps->tertiary_colour = dword_141F71C; - } - } + do_part_1(ebx, dword_141F70C, dword_141F714, dword_141F71C, dword_141F710, offset, boundsR1, boundsR1_, boundsR2, boundsR2_, boundsL1, boundsL1_); break; } @@ -395,7 +359,7 @@ void fence_paint(uint8 direction, int height, rct_map_element * map_element) sub_98199C(imageId, 31, 0, 1, 29, ah, height, 30, 2, height + 1, get_current_rotation()); } } else { - uint32 imageId = imageId + dword_141F708; + uint32 imageId = baseImageId + dword_141F708; if (dword_141F70C->wall.flags & WALL_SCENERY_FLAG1) { imageId |= dword_141F714; From 564d6b2e1290e3307b4a04a5fbe24e99c252b8e6 Mon Sep 17 00:00:00 2001 From: Marijn van der Werf Date: Fri, 6 May 2016 13:42:14 +0200 Subject: [PATCH 03/16] Refactor other fence function --- src/paint/map_element/fence.c | 232 +++++++++++----------------------- 1 file changed, 73 insertions(+), 159 deletions(-) diff --git a/src/paint/map_element/fence.c b/src/paint/map_element/fence.c index ae4d43b90a..5799c1665a 100644 --- a/src/paint/map_element/fence.c +++ b/src/paint/map_element/fence.c @@ -94,6 +94,41 @@ void do_part_1(uint32 imageId, } } +void do_part_2(uint32 dword_141F708, const rct_scenery_entry * dword_141F70C, uint32 dword_141F710, uint32 dword_141F714, uint32 dword_141F718, uint32 dword_141F71C, uint32 imageOffset, rct_xyz16 offset, rct_xyz16 bounds, rct_xyz16 boundsOffset) +{ + uint32 baseImageId = dword_141F70C->image + imageOffset + dword_141F708; + uint32 imageId = baseImageId; + + + if (dword_141F70C->wall.flags & WALL_SCENERY_FLAG2) { + if (dword_141F70C->wall.flags & WALL_SCENERY_FLAG1) { + imageId |= dword_141F714; + } + + if (dword_141F710 != 0) { + imageId = (imageId & 0x7FFFF) | dword_141F710; + } + + sub_98197C(imageId, offset.x, offset.y, bounds.x, bounds.y, bounds.z, offset.z, boundsOffset.x, boundsOffset.y, boundsOffset.z, get_current_rotation()); + if (dword_141F710 == 0) { + imageId = baseImageId + dword_141F718; + sub_98199C(imageId, offset.x, offset.y, bounds.x, bounds.y, bounds.z, offset.z, boundsOffset.x, boundsOffset.y, boundsOffset.z, get_current_rotation()); + } + } else { + if (dword_141F70C->wall.flags & WALL_SCENERY_FLAG1) { + imageId |= dword_141F714; + } + + if (dword_141F710 != 0) { + imageId = (imageId & 0x7FFFF) | dword_141F710; + } + + paint_struct * paint = sub_98197C(imageId, offset.x, offset.y, bounds.x, bounds.y, bounds.z, offset.z, boundsOffset.x, boundsOffset.y, boundsOffset.z, get_current_rotation()); + if (paint != NULL) { + paint->tertiary_colour = dword_141F71C; + } + } +} /** * rct2: 0x006E44B0 * @param direction (cl) @@ -150,9 +185,9 @@ void fence_paint(uint8 direction, int height, rct_map_element * map_element) uint8 ah = dword_141F70C->wall.height * 8 - 2; - rct_xyz16 offset, boundsR1, boundsR1_, boundsR2, boundsR2_, boundsL1, boundsL1_; if (dword_141F70C->wall.flags & WALL_SCENERY_FLAG5) { + rct_xyz16 offset, boundsR1, boundsR1_, boundsR2, boundsR2_, boundsL1, boundsL1_; uint32 ebx = (map_element->properties.fence.item[2] >> 3) & 0x1F; switch (direction) { case 0: @@ -225,205 +260,84 @@ void fence_paint(uint8 direction, int height, rct_map_element * map_element) uint8 al = map_element->type; + uint32 imageOffset; + rct_xyz16 offset, bounds, boundsOffset; switch (direction) { - case 0: { - uint32 offset; + case 0: if (al & 0x80) { - offset = 3; + imageOffset = 3; } else if (al & 0x40) { - offset = 5; + imageOffset = 5; } else { - offset = 1; + imageOffset = 1; } - uint32 baseImageId = offset + dword_141F70C->image + dword_141F708; + offset = (rct_xyz16){1, 31, height}; + bounds = (rct_xyz16){29, 1, ah}; + boundsOffset = (rct_xyz16){2, 30, height + 1}; + break; - uint32 imageId = baseImageId; - if (dword_141F70C->wall.flags & WALL_SCENERY_FLAG2) { - if (dword_141F70C->wall.flags & WALL_SCENERY_FLAG1) { - imageId |= dword_141F714; - } - - if (dword_141F710 != 0) { - imageId = (imageId & 0x7FFFF) | dword_141F710; - } - - sub_98197C(imageId, 0, 0, 1, 28, ah, height, 1, 1, height + 1, get_current_rotation()); - if (dword_141F710 == 0) { - imageId = baseImageId + dword_141F718; - sub_98199C(imageId, 0, 0, 1, 28, ah, height, 1, 1, height + 1, get_current_rotation()); - } - } else { - if (dword_141F70C->wall.flags & WALL_SCENERY_FLAG1) { - imageId |= dword_141F714; - } - - if (dword_141F710 != 0) { - imageId = (imageId & 0x7FFFF) | dword_141F710; - } - - paint_struct * paint = sub_98197C(imageId, 0, 0, 1, 28, ah, height, 1, 1, height + 1, get_current_rotation()); - if (paint != NULL) { - paint->tertiary_colour = dword_141F71C; - } - } - - break; - } - - case 1: { - uint32 offset; + case 1: if (al & 0x80) { - offset = 2; + imageOffset = 2; } else if (al & 0x40) { - offset = 4; + imageOffset = 4; } else { - offset = 0; + imageOffset = 0; } if (dword_141F70C->wall.flags & WALL_SCENERY_FLAG2) { if (dword_141F70C->wall.flags & WALL_SCENERY_FLAG4) { - offset += 12; - } - - uint32 baseImageId = offset + dword_141F70C->image; - uint32 imageId = baseImageId; - - if (dword_141F70C->wall.flags & WALL_SCENERY_FLAG1) { - imageId |= dword_141F714; - } - - if (dword_141F710 != 0) { - imageId = (imageId & 0x7FFFF) | dword_141F710; - } - - sub_98197C(imageId, 1, 31, 29, 1, ah, height, 2, 30, height + 1, get_current_rotation()); - if (dword_141F710 == 0) { - imageId = baseImageId + dword_141F718; - sub_98199C(imageId, 1, 31, 29, 1, ah, height, 2, 30, height + 1, get_current_rotation()); + imageOffset += 12; } } else { if (dword_141F70C->wall.flags & WALL_SCENERY_FLAG4) { - offset += 6; - } - - uint32 imageId = offset + dword_141F70C->image + dword_141F708; - - if (dword_141F70C->wall.flags & WALL_SCENERY_FLAG1) { - imageId |= dword_141F714; - } - - if (dword_141F710 != 0) { - imageId = (imageId & 0x7FFFF) | dword_141F710; - } - - paint_struct * paint = sub_98197C(imageId, 1, 31, 29, 1, ah, height, 2, 30, height + 1, get_current_rotation()); - if (paint != NULL) { - paint->tertiary_colour = dword_141F71C; + imageOffset += 6; } } + offset = (rct_xyz16){1, 31, height}; + bounds = (rct_xyz16){29, 1, ah}; + boundsOffset = (rct_xyz16){2, 30, height + 1}; break; - } - case 2: { - uint32 offset; + case 2: if (al & 0x80) { - offset = 5; + imageOffset = 5; } else if (al & 0x40) { - offset = 3; + imageOffset = 3; } else { - offset = 1; + imageOffset = 1; } if (dword_141F70C->wall.flags & WALL_SCENERY_FLAG4) { - offset += 6; - } - - uint32 baseImageId = offset + dword_141F70C->image; - uint32 imageId = baseImageId; - - if (dword_141F70C->wall.flags & WALL_SCENERY_FLAG2) { - if (dword_141F70C->wall.flags & WALL_SCENERY_FLAG1) { - imageId |= dword_141F714; - } - - if (dword_141F710 != 0) { - imageId = (imageId & 0x7FFFF) | dword_141F710; - } - - sub_98197C(imageId, 31, 0, 1, 29, ah, height, 30, 2, height + 1, get_current_rotation()); - if (dword_141F710 == 0) { - imageId = baseImageId + dword_141F718; - sub_98199C(imageId, 31, 0, 1, 29, ah, height, 30, 2, height + 1, get_current_rotation()); - } - } else { - uint32 imageId = baseImageId + dword_141F708; - - if (dword_141F70C->wall.flags & WALL_SCENERY_FLAG1) { - imageId |= dword_141F714; - } - - if (dword_141F710 != 0) { - imageId = (imageId & 0x7FFFF) | dword_141F710; - } - - paint_struct * paint = sub_98197C(imageId, 31, 0, 1, 29, ah, height, 30, 2, height + 1, get_current_rotation()); - if (paint != NULL) { - paint->tertiary_colour = dword_141F71C; - } + imageOffset += 6; } + offset = (rct_xyz16){30, 0, height}; + bounds = (rct_xyz16){1, 29, ah}; + boundsOffset = (rct_xyz16){30, 2, height + 1}; break; - } - case 3: { - uint32 offset; + case 3: if (al & 0x80) { - offset = 4; + imageOffset = 4; } else if (al & 0x40) { - offset = 2; + imageOffset = 2; } else { - offset = 0; - } - - uint32 baseImageId = offset + dword_141F70C->image + dword_141F708; - uint32 imageId = baseImageId; - - if (dword_141F70C->wall.flags & WALL_SCENERY_FLAG2) { - if (dword_141F70C->wall.flags & WALL_SCENERY_FLAG1) { - imageId |= dword_141F714; - } - - if (dword_141F710 != 0) { - imageId = (imageId & 0x7FFFF) | dword_141F710; - } - - sub_98197C(imageId, 2, 1, 28, 1, ah, height, 1, 1, height + 1, get_current_rotation()); - if (dword_141F710 == 0) { - imageId = baseImageId + dword_141F718; - sub_98199C(imageId, 2, 1, 28, 1, ah, height, 1, 1, height + 1, get_current_rotation()); - } - } else { - if (dword_141F70C->wall.flags & WALL_SCENERY_FLAG1) { - imageId |= dword_141F714; - } - - if (dword_141F710 != 0) { - imageId = (imageId & 0x7FFFF) | dword_141F710; - } - - paint_struct * paint = sub_98197C(imageId, 2, 1, 28, 1, ah, height, 1, 1, height + 1, get_current_rotation()); - if (paint != NULL) { - paint->tertiary_colour = dword_141F71C; - } + imageOffset = 0; } + offset = (rct_xyz16){2, 1, height}; + bounds = (rct_xyz16){28, 1, ah}; + boundsOffset = (rct_xyz16){1, 1, height + 1}; break; - } } + do_part_2(dword_141F708, dword_141F70C, dword_141F710, dword_141F714, dword_141F718, dword_141F71C, imageOffset, offset, bounds, boundsOffset); + + if (dword_141F70C->wall.var_0D == 0xFF) { return; } From fda7dd6eea2145b2289d9467e9c40fa98d175487 Mon Sep 17 00:00:00 2001 From: Marijn van der Werf Date: Fri, 6 May 2016 13:52:41 +0200 Subject: [PATCH 04/16] Fix fences in direction 0 --- src/paint/map_element/fence.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/paint/map_element/fence.c b/src/paint/map_element/fence.c index 5799c1665a..d435f36f39 100644 --- a/src/paint/map_element/fence.c +++ b/src/paint/map_element/fence.c @@ -273,9 +273,9 @@ void fence_paint(uint8 direction, int height, rct_map_element * map_element) imageOffset = 1; } - offset = (rct_xyz16){1, 31, height}; - bounds = (rct_xyz16){29, 1, ah}; - boundsOffset = (rct_xyz16){2, 30, height + 1}; + offset = (rct_xyz16){0, 0, height}; + bounds = (rct_xyz16){1, 28, ah}; + boundsOffset = (rct_xyz16){1, 1, height + 1}; break; case 1: From 748ed9ccb041bcadb2f58680561dce05770568e2 Mon Sep 17 00:00:00 2001 From: Marijn van der Werf Date: Thu, 12 May 2016 20:44:05 +0100 Subject: [PATCH 05/16] Update code to use proper function names --- src/paint/map_element/fence.c | 2 +- src/ride/track_design.h | 1 + src/ride/track_design_save.c | 3 +-- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/paint/map_element/fence.c b/src/paint/map_element/fence.c index d435f36f39..83bd79c8be 100644 --- a/src/paint/map_element/fence.c +++ b/src/paint/map_element/fence.c @@ -171,7 +171,7 @@ void fence_paint(uint8 direction, int height, rct_map_element * map_element) uint32 dword_141F710 = 0; if (RCT2_GLOBAL(0x9DEA6F, uint8) & 1) { - if (!track_save_contains_map_element(map_element)) { + if (!track_design_save_contains_map_element(map_element)) { dword_141F710 = 0x21700000; } } diff --git a/src/ride/track_design.h b/src/ride/track_design.h index e35b751266..a6b28a67a6 100644 --- a/src/ride/track_design.h +++ b/src/ride/track_design.h @@ -209,6 +209,7 @@ void track_design_draw_preview(rct_track_td6 *td6, uint8 *pixels); /////////////////////////////////////////////////////////////////////////////// void track_design_save_init(); void track_design_save_reset_scenery(); +bool track_design_save_contains_map_element(rct_map_element *mapElement); void track_design_save_select_nearby_scenery(int rideIndex); void track_design_save_toggle_map_element(int interactionType, int x, int y, rct_map_element *mapElement); bool track_design_save(uint8 rideIndex); diff --git a/src/ride/track_design_save.c b/src/ride/track_design_save.c index ac64ba6152..d9f728dd51 100644 --- a/src/ride/track_design_save.c +++ b/src/ride/track_design_save.c @@ -44,7 +44,6 @@ static uint8 _trackSaveDirection; static bool track_design_save_should_select_scenery_around(int rideIndex, rct_map_element *mapElement); static void track_design_save_select_nearby_scenery_for_tile(int rideIndex, int cx, int cy); -static bool track_design_save_contains_map_element(rct_map_element *mapElement); static bool track_design_save_add_map_element(int interactionType, int x, int y, rct_map_element *mapElement); static void track_design_save_remove_map_element(int interactionType, int x, int y, rct_map_element *mapElement); static bool track_design_save_copy_scenery_to_td6(rct_track_td6 *td6); @@ -210,7 +209,7 @@ bool track_design_save(uint8 rideIndex) return true; } -static bool track_design_save_contains_map_element(rct_map_element *mapElement) +bool track_design_save_contains_map_element(rct_map_element *mapElement) { for (size_t i = 0; i < _trackSavedMapElementsCount; i++) { if (_trackSavedMapElements[i] == mapElement) { From a71c239b436d2fb7bb72b37e6dd068eb18cbad7f Mon Sep 17 00:00:00 2001 From: Marijn van der Werf Date: Thu, 12 May 2016 21:42:39 +0100 Subject: [PATCH 06/16] Rename dword_141F70C to sceneryEntry --- src/paint/map_element/fence.c | 60 +++++++++++++++++------------------ 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/src/paint/map_element/fence.c b/src/paint/map_element/fence.c index 83bd79c8be..1d004c2e7f 100644 --- a/src/paint/map_element/fence.c +++ b/src/paint/map_element/fence.c @@ -52,14 +52,14 @@ const uint8 byte_9A40CC[] = { }; void do_part_1(uint32 imageId, - rct_scenery_entry * dword_141F70C, + rct_scenery_entry * sceneryEntry, uint32 dword_141F714, uint32 dword_141F71C, uint32 dword_141F710, rct_xyz16 offset, rct_xyz16 boundsR1, rct_xyz16 boundsR1_, rct_xyz16 boundsR2, rct_xyz16 boundsR2_, rct_xyz16 boundsL1, rct_xyz16 boundsL1_) { - if (dword_141F70C->wall.flags & WALL_SCENERY_FLAG1) { + if (sceneryEntry->wall.flags & WALL_SCENERY_FLAG1) { imageId |= dword_141F714; } @@ -67,7 +67,7 @@ void do_part_1(uint32 imageId, imageId = (imageId & 0x7FFFF) | dword_141F710; } - if (dword_141F70C->wall.flags & WALL_SCENERY_FLAG4) { + if (sceneryEntry->wall.flags & WALL_SCENERY_FLAG4) { paint_struct * ps; ps = sub_98197C(imageId, offset.x, offset.y, boundsR1.x, boundsR1.y, boundsR1.z, offset.z, boundsR1_.x, boundsR1_.y, boundsR1_.z, get_current_rotation()); @@ -94,14 +94,14 @@ void do_part_1(uint32 imageId, } } -void do_part_2(uint32 dword_141F708, const rct_scenery_entry * dword_141F70C, uint32 dword_141F710, uint32 dword_141F714, uint32 dword_141F718, uint32 dword_141F71C, uint32 imageOffset, rct_xyz16 offset, rct_xyz16 bounds, rct_xyz16 boundsOffset) +void do_part_2(uint32 dword_141F708, const rct_scenery_entry * sceneryEntry, uint32 dword_141F710, uint32 dword_141F714, uint32 dword_141F718, uint32 dword_141F71C, uint32 imageOffset, rct_xyz16 offset, rct_xyz16 bounds, rct_xyz16 boundsOffset) { - uint32 baseImageId = dword_141F70C->image + imageOffset + dword_141F708; + uint32 baseImageId = sceneryEntry->image + imageOffset + dword_141F708; uint32 imageId = baseImageId; - if (dword_141F70C->wall.flags & WALL_SCENERY_FLAG2) { - if (dword_141F70C->wall.flags & WALL_SCENERY_FLAG1) { + if (sceneryEntry->wall.flags & WALL_SCENERY_FLAG2) { + if (sceneryEntry->wall.flags & WALL_SCENERY_FLAG1) { imageId |= dword_141F714; } @@ -115,7 +115,7 @@ void do_part_2(uint32 dword_141F708, const rct_scenery_entry * dword_141F70C, ui sub_98199C(imageId, offset.x, offset.y, bounds.x, bounds.y, bounds.z, offset.z, boundsOffset.x, boundsOffset.y, boundsOffset.z, get_current_rotation()); } } else { - if (dword_141F70C->wall.flags & WALL_SCENERY_FLAG1) { + if (sceneryEntry->wall.flags & WALL_SCENERY_FLAG1) { imageId |= dword_141F714; } @@ -140,10 +140,10 @@ void fence_paint(uint8 direction, int height, rct_map_element * map_element) rct_drawpixelinfo * dpi = RCT2_GLOBAL(0x140E9A8, rct_drawpixelinfo *); RCT2_GLOBAL(RCT2_ADDRESS_PAINT_SETUP_CURRENT_TYPE, uint8) = VIEWPORT_INTERACTION_ITEM_WALL; - rct_scenery_entry * dword_141F70C = g_wallSceneryEntries[map_element->properties.fence.type]; + rct_scenery_entry * sceneryEntry = g_wallSceneryEntries[map_element->properties.fence.type]; uint32 dword_141F708 = 0; - if (dword_141F70C->wall.flags2 & WALL_SCENERY_FLAG5) { + if (sceneryEntry->wall.flags2 & WALL_SCENERY_FLAG5) { // animation? dword_141F708 = (gCurrentTicks & 7) * 2; } @@ -152,13 +152,13 @@ void fence_paint(uint8 direction, int height, rct_map_element * map_element) uint32 dword_141F714 = (map_element->properties.fence.item[1] & 0b11111) << 19 | 0x20000000; uint32 dword_141F718 = dword_141F714 + 0x23800006; - if (dword_141F70C->wall.flags & WALL_SCENERY_HAS_SECONDARY_COLOUR) { + if (sceneryEntry->wall.flags & WALL_SCENERY_HAS_SECONDARY_COLOUR) { uint8 secondaryColour = (map_element->properties.fence.item[1] >> 5) | ((map_element->flags & 0x60) >> 2); dword_141F714 |= secondaryColour << 24 | 0x80000000; } uint32 dword_141F71C = 0; - if (dword_141F70C->wall.flags & WALL_SCENERY_HAS_TERNARY_COLOUR) { + if (sceneryEntry->wall.flags & WALL_SCENERY_HAS_TERNARY_COLOUR) { dword_141F71C = map_element->properties.fence.item[0]; dword_141F714 &= 0x0DFFFFFFF; } @@ -183,15 +183,15 @@ void fence_paint(uint8 direction, int height, rct_map_element * map_element) // save map_element - uint8 ah = dword_141F70C->wall.height * 8 - 2; + uint8 ah = sceneryEntry->wall.height * 8 - 2; - if (dword_141F70C->wall.flags & WALL_SCENERY_FLAG5) { + if (sceneryEntry->wall.flags & WALL_SCENERY_FLAG5) { rct_xyz16 offset, boundsR1, boundsR1_, boundsR2, boundsR2_, boundsL1, boundsL1_; uint32 ebx = (map_element->properties.fence.item[2] >> 3) & 0x1F; switch (direction) { case 0: - ebx = dword_141F70C->image + byte_9A406C[ebx]; + ebx = sceneryEntry->image + byte_9A406C[ebx]; boundsR1 = (rct_xyz16) {1, 3, ah - 5}; boundsR1_ = (rct_xyz16) {1, 1, height + 1}; @@ -203,11 +203,11 @@ void fence_paint(uint8 direction, int height, rct_map_element * map_element) offset = (rct_xyz16) {0, 0, height}; - do_part_1(ebx, dword_141F70C, dword_141F714, dword_141F71C, dword_141F710, offset, boundsR1, boundsR1_, boundsR2, boundsR2_, boundsL1, boundsL1_); + do_part_1(ebx, sceneryEntry, dword_141F714, dword_141F71C, dword_141F710, offset, boundsR1, boundsR1_, boundsR2, boundsR2_, boundsL1, boundsL1_); break; case 1: - ebx = dword_141F70C->image + byte_9A408C[ebx]; + ebx = sceneryEntry->image + byte_9A408C[ebx]; boundsR1 = (rct_xyz16) {3, 3, ah - 5}; boundsR1_ = (rct_xyz16) {1, 30, height + 1}; @@ -219,11 +219,11 @@ void fence_paint(uint8 direction, int height, rct_map_element * map_element) offset = (rct_xyz16) {1, 31, height}; - do_part_1(ebx, dword_141F70C, dword_141F714, dword_141F71C, dword_141F710, offset, boundsR1, boundsR1_, boundsR2, boundsR2_, boundsL1, boundsL1_); + do_part_1(ebx, sceneryEntry, dword_141F714, dword_141F71C, dword_141F710, offset, boundsR1, boundsR1_, boundsR2, boundsR2_, boundsL1, boundsL1_); break; case 2: - ebx = dword_141F70C->image + byte_9A40AC[ebx]; + ebx = sceneryEntry->image + byte_9A40AC[ebx]; boundsR1 = (rct_xyz16) {3, 3, ah - 5}; boundsR1_ = (rct_xyz16) {30, 1, height + 1}; @@ -235,11 +235,11 @@ void fence_paint(uint8 direction, int height, rct_map_element * map_element) offset = (rct_xyz16) {31, 0, height}; - do_part_1(ebx, dword_141F70C, dword_141F714, dword_141F71C, dword_141F710, offset, boundsR1, boundsR1_, boundsR2, boundsR2_, boundsL1, boundsL1_); + do_part_1(ebx, sceneryEntry, dword_141F714, dword_141F71C, dword_141F710, offset, boundsR1, boundsR1_, boundsR2, boundsR2_, boundsL1, boundsL1_); break; case 3: - ebx = dword_141F70C->image + byte_9A40CC[ebx]; + ebx = sceneryEntry->image + byte_9A40CC[ebx]; boundsR1 = (rct_xyz16) {3, 1, ah - 5}; boundsR1_ = (rct_xyz16) {1, 1, height + 1}; @@ -251,7 +251,7 @@ void fence_paint(uint8 direction, int height, rct_map_element * map_element) offset = (rct_xyz16) {2, 1, height}; - do_part_1(ebx, dword_141F70C, dword_141F714, dword_141F71C, dword_141F710, offset, boundsR1, boundsR1_, boundsR2, boundsR2_, boundsL1, boundsL1_); + do_part_1(ebx, sceneryEntry, dword_141F714, dword_141F71C, dword_141F710, offset, boundsR1, boundsR1_, boundsR2, boundsR2_, boundsL1, boundsL1_); break; } @@ -287,12 +287,12 @@ void fence_paint(uint8 direction, int height, rct_map_element * map_element) imageOffset = 0; } - if (dword_141F70C->wall.flags & WALL_SCENERY_FLAG2) { - if (dword_141F70C->wall.flags & WALL_SCENERY_FLAG4) { + if (sceneryEntry->wall.flags & WALL_SCENERY_FLAG2) { + if (sceneryEntry->wall.flags & WALL_SCENERY_FLAG4) { imageOffset += 12; } } else { - if (dword_141F70C->wall.flags & WALL_SCENERY_FLAG4) { + if (sceneryEntry->wall.flags & WALL_SCENERY_FLAG4) { imageOffset += 6; } } @@ -311,7 +311,7 @@ void fence_paint(uint8 direction, int height, rct_map_element * map_element) imageOffset = 1; } - if (dword_141F70C->wall.flags & WALL_SCENERY_FLAG4) { + if (sceneryEntry->wall.flags & WALL_SCENERY_FLAG4) { imageOffset += 6; } @@ -335,10 +335,10 @@ void fence_paint(uint8 direction, int height, rct_map_element * map_element) break; } - do_part_2(dword_141F708, dword_141F70C, dword_141F710, dword_141F714, dword_141F718, dword_141F71C, imageOffset, offset, bounds, boundsOffset); + do_part_2(dword_141F708, sceneryEntry, dword_141F710, dword_141F714, dword_141F718, dword_141F71C, imageOffset, offset, bounds, boundsOffset); - if (dword_141F70C->wall.var_0D == 0xFF) { + if (sceneryEntry->wall.var_0D == 0xFF) { return; } @@ -346,7 +346,7 @@ void fence_paint(uint8 direction, int height, rct_map_element * map_element) return; } - if (dword_141F70C->wall.flags & WALL_SCENERY_FLAG1) { + if (sceneryEntry->wall.flags & WALL_SCENERY_FLAG1) { return; } @@ -365,7 +365,7 @@ void fence_paint(uint8 direction, int height, rct_map_element * map_element) RCT2_GLOBAL(RCT2_ADDRESS_COMMON_FORMAT_ARGS + 7, uint8) = al_2; - uint16 scrollingMode = dword_141F70C->wall.var_0D + (get_current_rotation() + 1) & 0x3; + uint16 scrollingMode = sceneryEntry->wall.var_0D + (get_current_rotation() + 1) & 0x3; uint8 bannerIndex = map_element->properties.fence.item[0]; rct_banner * banner = &gBanners[bannerIndex]; From 000f9cc9b457969524fb27c83b245283523e5c39 Mon Sep 17 00:00:00 2001 From: Marijn van der Werf Date: Thu, 12 May 2016 22:23:56 +0100 Subject: [PATCH 07/16] Rename dword_141F708 to frameNum --- src/paint/map_element/fence.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/paint/map_element/fence.c b/src/paint/map_element/fence.c index 1d004c2e7f..3047e46354 100644 --- a/src/paint/map_element/fence.c +++ b/src/paint/map_element/fence.c @@ -94,9 +94,9 @@ void do_part_1(uint32 imageId, } } -void do_part_2(uint32 dword_141F708, const rct_scenery_entry * sceneryEntry, uint32 dword_141F710, uint32 dword_141F714, uint32 dword_141F718, uint32 dword_141F71C, uint32 imageOffset, rct_xyz16 offset, rct_xyz16 bounds, rct_xyz16 boundsOffset) +void do_part_2(uint32 frameNum, const rct_scenery_entry * sceneryEntry, uint32 dword_141F710, uint32 dword_141F714, uint32 dword_141F718, uint32 dword_141F71C, uint32 imageOffset, rct_xyz16 offset, rct_xyz16 bounds, rct_xyz16 boundsOffset) { - uint32 baseImageId = sceneryEntry->image + imageOffset + dword_141F708; + uint32 baseImageId = sceneryEntry->image + imageOffset + frameNum; uint32 imageId = baseImageId; @@ -141,11 +141,11 @@ void fence_paint(uint8 direction, int height, rct_map_element * map_element) RCT2_GLOBAL(RCT2_ADDRESS_PAINT_SETUP_CURRENT_TYPE, uint8) = VIEWPORT_INTERACTION_ITEM_WALL; rct_scenery_entry * sceneryEntry = g_wallSceneryEntries[map_element->properties.fence.type]; - uint32 dword_141F708 = 0; + uint32 frameNum = 0; if (sceneryEntry->wall.flags2 & WALL_SCENERY_FLAG5) { // animation? - dword_141F708 = (gCurrentTicks & 7) * 2; + frameNum = (gCurrentTicks & 7) * 2; } @@ -335,7 +335,7 @@ void fence_paint(uint8 direction, int height, rct_map_element * map_element) break; } - do_part_2(dword_141F708, sceneryEntry, dword_141F710, dword_141F714, dword_141F718, dword_141F71C, imageOffset, offset, bounds, boundsOffset); + do_part_2(frameNum, sceneryEntry, dword_141F710, dword_141F714, dword_141F718, dword_141F71C, imageOffset, offset, bounds, boundsOffset); if (sceneryEntry->wall.var_0D == 0xFF) { From 00d16e71866630f05229d83664368f248f03da42 Mon Sep 17 00:00:00 2001 From: Marijn van der Werf Date: Thu, 12 May 2016 22:24:16 +0100 Subject: [PATCH 08/16] tertiaryColour --- src/paint/map_element/fence.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/paint/map_element/fence.c b/src/paint/map_element/fence.c index 3047e46354..6cb3edfee4 100644 --- a/src/paint/map_element/fence.c +++ b/src/paint/map_element/fence.c @@ -53,7 +53,7 @@ const uint8 byte_9A40CC[] = { void do_part_1(uint32 imageId, rct_scenery_entry * sceneryEntry, - uint32 dword_141F714, uint32 dword_141F71C, uint32 dword_141F710, + uint32 dword_141F714, uint32 tertiaryColour, uint32 dword_141F710, rct_xyz16 offset, rct_xyz16 boundsR1, rct_xyz16 boundsR1_, rct_xyz16 boundsR2, rct_xyz16 boundsR2_, @@ -72,29 +72,29 @@ void do_part_1(uint32 imageId, ps = sub_98197C(imageId, offset.x, offset.y, boundsR1.x, boundsR1.y, boundsR1.z, offset.z, boundsR1_.x, boundsR1_.y, boundsR1_.z, get_current_rotation()); if (ps != NULL) { - ps->tertiary_colour = dword_141F71C; + ps->tertiary_colour = tertiaryColour; } ps = sub_98197C(imageId + 1, offset.x, offset.y, boundsR2.x, boundsR2.y, boundsR2.z, offset.z, boundsR2_.x, boundsR2_.y, boundsR2_.z, get_current_rotation()); if (ps != NULL) { - ps->tertiary_colour = dword_141F71C; + ps->tertiary_colour = tertiaryColour; } } else { paint_struct * ps; ps = sub_98197C(imageId, offset.x, offset.y, boundsL1.x, boundsL1.y, boundsL1.z, offset.z, boundsL1_.x, boundsL1_.y, boundsL1_.z, get_current_rotation()); if (ps != NULL) { - ps->tertiary_colour = dword_141F71C; + ps->tertiary_colour = tertiaryColour; } ps = sub_98199C(imageId + 1, offset.x, offset.y, boundsL1.x, boundsL1.y, boundsL1.z, offset.z, boundsL1_.x, boundsL1_.y, boundsL1_.z, get_current_rotation()); if (ps != NULL) { - ps->tertiary_colour = dword_141F71C; + ps->tertiary_colour = tertiaryColour; } } } -void do_part_2(uint32 frameNum, const rct_scenery_entry * sceneryEntry, uint32 dword_141F710, uint32 dword_141F714, uint32 dword_141F718, uint32 dword_141F71C, uint32 imageOffset, rct_xyz16 offset, rct_xyz16 bounds, rct_xyz16 boundsOffset) +void do_part_2(uint32 frameNum, const rct_scenery_entry * sceneryEntry, uint32 dword_141F710, uint32 dword_141F714, uint32 dword_141F718, uint32 tertiaryColour, uint32 imageOffset, rct_xyz16 offset, rct_xyz16 bounds, rct_xyz16 boundsOffset) { uint32 baseImageId = sceneryEntry->image + imageOffset + frameNum; uint32 imageId = baseImageId; @@ -125,7 +125,7 @@ void do_part_2(uint32 frameNum, const rct_scenery_entry * sceneryEntry, uint32 d paint_struct * paint = sub_98197C(imageId, offset.x, offset.y, bounds.x, bounds.y, bounds.z, offset.z, boundsOffset.x, boundsOffset.y, boundsOffset.z, get_current_rotation()); if (paint != NULL) { - paint->tertiary_colour = dword_141F71C; + paint->tertiary_colour = tertiaryColour; } } } @@ -157,9 +157,9 @@ void fence_paint(uint8 direction, int height, rct_map_element * map_element) dword_141F714 |= secondaryColour << 24 | 0x80000000; } - uint32 dword_141F71C = 0; + uint32 tertiaryColour = 0; if (sceneryEntry->wall.flags & WALL_SCENERY_HAS_TERNARY_COLOUR) { - dword_141F71C = map_element->properties.fence.item[0]; + tertiaryColour = map_element->properties.fence.item[0]; dword_141F714 &= 0x0DFFFFFFF; } @@ -203,7 +203,7 @@ void fence_paint(uint8 direction, int height, rct_map_element * map_element) offset = (rct_xyz16) {0, 0, height}; - do_part_1(ebx, sceneryEntry, dword_141F714, dword_141F71C, dword_141F710, offset, boundsR1, boundsR1_, boundsR2, boundsR2_, boundsL1, boundsL1_); + do_part_1(ebx, sceneryEntry, dword_141F714, tertiaryColour, dword_141F710, offset, boundsR1, boundsR1_, boundsR2, boundsR2_, boundsL1, boundsL1_); break; case 1: @@ -219,7 +219,7 @@ void fence_paint(uint8 direction, int height, rct_map_element * map_element) offset = (rct_xyz16) {1, 31, height}; - do_part_1(ebx, sceneryEntry, dword_141F714, dword_141F71C, dword_141F710, offset, boundsR1, boundsR1_, boundsR2, boundsR2_, boundsL1, boundsL1_); + do_part_1(ebx, sceneryEntry, dword_141F714, tertiaryColour, dword_141F710, offset, boundsR1, boundsR1_, boundsR2, boundsR2_, boundsL1, boundsL1_); break; case 2: @@ -235,7 +235,7 @@ void fence_paint(uint8 direction, int height, rct_map_element * map_element) offset = (rct_xyz16) {31, 0, height}; - do_part_1(ebx, sceneryEntry, dword_141F714, dword_141F71C, dword_141F710, offset, boundsR1, boundsR1_, boundsR2, boundsR2_, boundsL1, boundsL1_); + do_part_1(ebx, sceneryEntry, dword_141F714, tertiaryColour, dword_141F710, offset, boundsR1, boundsR1_, boundsR2, boundsR2_, boundsL1, boundsL1_); break; case 3: @@ -251,7 +251,7 @@ void fence_paint(uint8 direction, int height, rct_map_element * map_element) offset = (rct_xyz16) {2, 1, height}; - do_part_1(ebx, sceneryEntry, dword_141F714, dword_141F71C, dword_141F710, offset, boundsR1, boundsR1_, boundsR2, boundsR2_, boundsL1, boundsL1_); + do_part_1(ebx, sceneryEntry, dword_141F714, tertiaryColour, dword_141F710, offset, boundsR1, boundsR1_, boundsR2, boundsR2_, boundsL1, boundsL1_); break; } @@ -335,7 +335,7 @@ void fence_paint(uint8 direction, int height, rct_map_element * map_element) break; } - do_part_2(frameNum, sceneryEntry, dword_141F710, dword_141F714, dword_141F718, dword_141F71C, imageOffset, offset, bounds, boundsOffset); + do_part_2(frameNum, sceneryEntry, dword_141F710, dword_141F714, dword_141F718, tertiaryColour, imageOffset, offset, bounds, boundsOffset); if (sceneryEntry->wall.var_0D == 0xFF) { From 44021fdb0a710bb73a480bfb748b9ed34453adca Mon Sep 17 00:00:00 2001 From: Marijn van der Werf Date: Fri, 13 May 2016 12:20:36 +0100 Subject: [PATCH 09/16] Rename flag --- src/object.c | 2 +- src/paint/map_element/fence.c | 4 ++-- src/windows/scenery.c | 2 +- src/world/map.c | 2 +- src/world/scenery.h | 6 +++++- 5 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/object.c b/src/object.c index 5303610926..05c1b6084f 100644 --- a/src/object.c +++ b/src/object.c @@ -1116,7 +1116,7 @@ static void object_type_wall_paint(void *objectEntry, rct_drawpixelinfo *dpi, si if (sceneryEntry->wall.flags & WALL_SCENERY_FLAG2){ imageId = sceneryEntry->image + 0x44500006; gfx_draw_sprite(&clipDPI, imageId, x, y, 0); - } else if (sceneryEntry->wall.flags & WALL_SCENERY_FLAG5){ + } else if (sceneryEntry->wall.flags & WALL_SCENERY_IS_DOOR){ imageId++; gfx_draw_sprite(&clipDPI, imageId, x, y, 0); } diff --git a/src/paint/map_element/fence.c b/src/paint/map_element/fence.c index 6cb3edfee4..20248f458f 100644 --- a/src/paint/map_element/fence.c +++ b/src/paint/map_element/fence.c @@ -143,7 +143,7 @@ void fence_paint(uint8 direction, int height, rct_map_element * map_element) rct_scenery_entry * sceneryEntry = g_wallSceneryEntries[map_element->properties.fence.type]; uint32 frameNum = 0; - if (sceneryEntry->wall.flags2 & WALL_SCENERY_FLAG5) { + if (sceneryEntry->wall.flags2 & WALL_SCENERY_2_FLAG_5) { // animation? frameNum = (gCurrentTicks & 7) * 2; } @@ -186,7 +186,7 @@ void fence_paint(uint8 direction, int height, rct_map_element * map_element) uint8 ah = sceneryEntry->wall.height * 8 - 2; - if (sceneryEntry->wall.flags & WALL_SCENERY_FLAG5) { + if (sceneryEntry->wall.flags & WALL_SCENERY_IS_DOOR) { rct_xyz16 offset, boundsR1, boundsR1_, boundsR2, boundsR2_, boundsL1, boundsL1_; uint32 ebx = (map_element->properties.fence.item[2] >> 3) & 0x1F; switch (direction) { diff --git a/src/windows/scenery.c b/src/windows/scenery.c index a92ae6215d..dcc3b93c81 100644 --- a/src/windows/scenery.c +++ b/src/windows/scenery.c @@ -1169,7 +1169,7 @@ void window_scenery_scrollpaint(rct_window *w, rct_drawpixelinfo *dpi, int scrol gfx_draw_sprite(&clipdpi, imageId, 0x2F, (sceneryEntry->wall.height * 2) + 0x32, tertiaryColour); - if (sceneryEntry->wall.flags & WALL_SCENERY_FLAG5){ + if (sceneryEntry->wall.flags & WALL_SCENERY_IS_DOOR){ gfx_draw_sprite(&clipdpi, imageId + 1, 0x2F, (sceneryEntry->wall.height * 2) + 0x32, tertiaryColour); } diff --git a/src/world/map.c b/src/world/map.c index 965ca56c71..0ffad0af77 100644 --- a/src/world/map.c +++ b/src/world/map.c @@ -3130,7 +3130,7 @@ static bool map_place_fence_check_obstruction_with_track(rct_scenery_entry *wall } } - if (!(wall->wall.flags & WALL_SCENERY_FLAG5)) { + if (!(wall->wall.flags & WALL_SCENERY_IS_DOOR)) { return false; } diff --git a/src/world/scenery.h b/src/world/scenery.h index 5a51b86347..06b750ba0a 100644 --- a/src/world/scenery.h +++ b/src/world/scenery.h @@ -97,12 +97,16 @@ typedef enum { WALL_SCENERY_FLAG2 = (1 << 1), // 0x2 WALL_SCENERY_FLAG3 = (1 << 2), // 0x4 WALL_SCENERY_FLAG4 = (1 << 3), // 0x8 // Probably indicates translucency - WALL_SCENERY_FLAG5 = (1 << 4), // 0x10 + WALL_SCENERY_IS_DOOR = (1 << 4), // 0x10 WALL_SCENERY_FLAG6 = (1 << 5), // 0x20 WALL_SCENERY_HAS_SECONDARY_COLOUR = (1 << 6), // 0x40 WALL_SCENERY_HAS_TERNARY_COLOUR = (1 << 7), // 0x80 } WALL_SCENERY_FLAGS; +typedef enum { + WALL_SCENERY_2_FLAG_5 = (1 << 4), // 0x10 +} WALL_SCENERY_2_FLAGS; + typedef struct rct_path_bit_scenery_entry { uint16 var_06; uint8 pad_08; From 201a01f126251b62e3498f22fb96d7c38024f45e Mon Sep 17 00:00:00 2001 From: Marijn van der Werf Date: Fri, 13 May 2016 12:21:01 +0100 Subject: [PATCH 10/16] Split up image ids --- src/paint/map_element/fence.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/paint/map_element/fence.c b/src/paint/map_element/fence.c index 20248f458f..55de5fc3b6 100644 --- a/src/paint/map_element/fence.c +++ b/src/paint/map_element/fence.c @@ -149,7 +149,8 @@ void fence_paint(uint8 direction, int height, rct_map_element * map_element) } - uint32 dword_141F714 = (map_element->properties.fence.item[1] & 0b11111) << 19 | 0x20000000; + int primaryColour = map_element->properties.fence.item[1] & 0x1F; + uint32 dword_141F714 = primaryColour << 19 | 0x20000000; uint32 dword_141F718 = dword_141F714 + 0x23800006; if (sceneryEntry->wall.flags & WALL_SCENERY_HAS_SECONDARY_COLOUR) { @@ -188,10 +189,11 @@ void fence_paint(uint8 direction, int height, rct_map_element * map_element) if (sceneryEntry->wall.flags & WALL_SCENERY_IS_DOOR) { rct_xyz16 offset, boundsR1, boundsR1_, boundsR2, boundsR2_, boundsL1, boundsL1_; - uint32 ebx = (map_element->properties.fence.item[2] >> 3) & 0x1F; + uint animationFrame = (map_element->properties.fence.item[2] >> 3) & 0x1F; + uint32 imageId; switch (direction) { case 0: - ebx = sceneryEntry->image + byte_9A406C[ebx]; + imageId = sceneryEntry->image + byte_9A406C[animationFrame]; boundsR1 = (rct_xyz16) {1, 3, ah - 5}; boundsR1_ = (rct_xyz16) {1, 1, height + 1}; @@ -203,11 +205,11 @@ void fence_paint(uint8 direction, int height, rct_map_element * map_element) offset = (rct_xyz16) {0, 0, height}; - do_part_1(ebx, sceneryEntry, dword_141F714, tertiaryColour, dword_141F710, offset, boundsR1, boundsR1_, boundsR2, boundsR2_, boundsL1, boundsL1_); + do_part_1(imageId, sceneryEntry, dword_141F714, tertiaryColour, dword_141F710, offset, boundsR1, boundsR1_, boundsR2, boundsR2_, boundsL1, boundsL1_); break; case 1: - ebx = sceneryEntry->image + byte_9A408C[ebx]; + imageId = sceneryEntry->image + byte_9A408C[animationFrame]; boundsR1 = (rct_xyz16) {3, 3, ah - 5}; boundsR1_ = (rct_xyz16) {1, 30, height + 1}; @@ -219,11 +221,11 @@ void fence_paint(uint8 direction, int height, rct_map_element * map_element) offset = (rct_xyz16) {1, 31, height}; - do_part_1(ebx, sceneryEntry, dword_141F714, tertiaryColour, dword_141F710, offset, boundsR1, boundsR1_, boundsR2, boundsR2_, boundsL1, boundsL1_); + do_part_1(imageId, sceneryEntry, dword_141F714, tertiaryColour, dword_141F710, offset, boundsR1, boundsR1_, boundsR2, boundsR2_, boundsL1, boundsL1_); break; case 2: - ebx = sceneryEntry->image + byte_9A40AC[ebx]; + imageId = sceneryEntry->image + byte_9A40AC[animationFrame]; boundsR1 = (rct_xyz16) {3, 3, ah - 5}; boundsR1_ = (rct_xyz16) {30, 1, height + 1}; @@ -235,11 +237,11 @@ void fence_paint(uint8 direction, int height, rct_map_element * map_element) offset = (rct_xyz16) {31, 0, height}; - do_part_1(ebx, sceneryEntry, dword_141F714, tertiaryColour, dword_141F710, offset, boundsR1, boundsR1_, boundsR2, boundsR2_, boundsL1, boundsL1_); + do_part_1(imageId, sceneryEntry, dword_141F714, tertiaryColour, dword_141F710, offset, boundsR1, boundsR1_, boundsR2, boundsR2_, boundsL1, boundsL1_); break; case 3: - ebx = sceneryEntry->image + byte_9A40CC[ebx]; + imageId = sceneryEntry->image + byte_9A40CC[animationFrame]; boundsR1 = (rct_xyz16) {3, 1, ah - 5}; boundsR1_ = (rct_xyz16) {1, 1, height + 1}; @@ -251,7 +253,7 @@ void fence_paint(uint8 direction, int height, rct_map_element * map_element) offset = (rct_xyz16) {2, 1, height}; - do_part_1(ebx, sceneryEntry, dword_141F714, tertiaryColour, dword_141F710, offset, boundsR1, boundsR1_, boundsR2, boundsR2_, boundsL1, boundsL1_); + do_part_1(imageId, sceneryEntry, dword_141F714, tertiaryColour, dword_141F710, offset, boundsR1, boundsR1_, boundsR2, boundsR2_, boundsL1, boundsL1_); break; } From bfaa2acf3f909a78acb6a37ebae36418c85bc1f4 Mon Sep 17 00:00:00 2001 From: Marijn van der Werf Date: Mon, 16 May 2016 20:58:49 +0200 Subject: [PATCH 11/16] Update with changes in develop --- src/paint/map_element/fence.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/paint/map_element/fence.c b/src/paint/map_element/fence.c index 55de5fc3b6..c8881b9706 100644 --- a/src/paint/map_element/fence.c +++ b/src/paint/map_element/fence.c @@ -140,11 +140,10 @@ void fence_paint(uint8 direction, int height, rct_map_element * map_element) rct_drawpixelinfo * dpi = RCT2_GLOBAL(0x140E9A8, rct_drawpixelinfo *); RCT2_GLOBAL(RCT2_ADDRESS_PAINT_SETUP_CURRENT_TYPE, uint8) = VIEWPORT_INTERACTION_ITEM_WALL; - rct_scenery_entry * sceneryEntry = g_wallSceneryEntries[map_element->properties.fence.type]; + rct_scenery_entry * sceneryEntry = gWallSceneryEntries[map_element->properties.fence.type]; uint32 frameNum = 0; if (sceneryEntry->wall.flags2 & WALL_SCENERY_2_FLAG_5) { - // animation? frameNum = (gCurrentTicks & 7) * 2; } @@ -352,8 +351,8 @@ void fence_paint(uint8 direction, int height, rct_map_element * map_element) return; } - RCT2_GLOBAL(RCT2_ADDRESS_COMMON_FORMAT_ARGS, uint32) = 0; - RCT2_GLOBAL(RCT2_ADDRESS_COMMON_FORMAT_ARGS + 4, uint32) = 0; + set_format_arg(0, uint32, 0); + set_format_arg(4, uint32, 0); uint8 al_2 = map_element->properties.fence.item[1] >> 5 | (map_element->flags & 0x60) >> 2; @@ -365,17 +364,18 @@ void fence_paint(uint8 direction, int height, rct_map_element * map_element) al_2 |= 0x80; } - RCT2_GLOBAL(RCT2_ADDRESS_COMMON_FORMAT_ARGS + 7, uint8) = al_2; + set_format_arg(7, uint8, al_2); uint16 scrollingMode = sceneryEntry->wall.var_0D + (get_current_rotation() + 1) & 0x3; uint8 bannerIndex = map_element->properties.fence.item[0]; rct_banner * banner = &gBanners[bannerIndex]; - RCT2_GLOBAL(RCT2_ADDRESS_COMMON_FORMAT_ARGS, rct_string_id) = banner->string_idx; + + set_format_arg(0, rct_string_id, banner->string_idx); if (banner->flags & 0x04) { rct_ride * ride = get_ride(banner->colour); - RCT2_GLOBAL(RCT2_ADDRESS_COMMON_FORMAT_ARGS, rct_string_id) = ride->name; - RCT2_GLOBAL(RCT2_ADDRESS_COMMON_FORMAT_ARGS + 2, uint32) = ride->name_arguments; + set_format_arg(0, rct_string_id, ride->name); + set_format_arg(2, uint32, ride->name_arguments); } sub_98199C(0, 0, 0, 1, 1, 13, height + 8, 0, 0, 0, get_current_rotation()); @@ -384,9 +384,9 @@ void fence_paint(uint8 direction, int height, rct_map_element * map_element) utf8 signString[MAX_PATH]; rct_string_id stringId = STR_SCROLLING_SIGN_TEXT; if (gConfigGeneral.upper_case_banners) { - format_string_to_upper(signString, stringId, RCT2_ADDRESS(RCT2_ADDRESS_COMMON_FORMAT_ARGS, void)); + format_string_to_upper(signString, stringId, gCommonFormatArgs); } else { - format_string(signString, stringId, RCT2_ADDRESS(RCT2_ADDRESS_COMMON_FORMAT_ARGS, void)); + format_string(signString, stringId, gCommonFormatArgs); } gCurrentFontSpriteBase = FONT_SPRITE_BASE_TINY; From aee8607f7a554011eba1f0b3049362cd4d5fa98e Mon Sep 17 00:00:00 2001 From: Marijn van der Werf Date: Tue, 17 May 2016 09:30:41 +0200 Subject: [PATCH 12/16] Fix offset for left bottom walls --- src/paint/map_element/fence.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/paint/map_element/fence.c b/src/paint/map_element/fence.c index c8881b9706..4b2767a6da 100644 --- a/src/paint/map_element/fence.c +++ b/src/paint/map_element/fence.c @@ -316,7 +316,7 @@ void fence_paint(uint8 direction, int height, rct_map_element * map_element) imageOffset += 6; } - offset = (rct_xyz16){30, 0, height}; + offset = (rct_xyz16){31, 0, height}; bounds = (rct_xyz16){1, 29, ah}; boundsOffset = (rct_xyz16){30, 2, height + 1}; break; From 679db5e05506a5de4ad4acc82d13e5e694f4b895 Mon Sep 17 00:00:00 2001 From: Marijn van der Werf Date: Tue, 17 May 2016 10:33:36 +0200 Subject: [PATCH 13/16] Use decompiled construction markers --- src/paint/map_element/banner.c | 2 +- src/paint/map_element/entrance.c | 4 ++-- src/paint/map_element/fence.c | 7 +------ src/paint/paint.h | 8 ++++++++ src/ride/track_paint.c | 2 +- 5 files changed, 13 insertions(+), 10 deletions(-) diff --git a/src/paint/map_element/banner.c b/src/paint/map_element/banner.c index 7cded1eaed..d2d66c7eeb 100644 --- a/src/paint/map_element/banner.c +++ b/src/paint/map_element/banner.c @@ -53,7 +53,7 @@ void banner_paint(uint8 direction, int height, rct_map_element* map_element) if (map_element->flags & MAP_ELEMENT_FLAG_GHOST)//if being placed { RCT2_GLOBAL(RCT2_ADDRESS_PAINT_SETUP_CURRENT_TYPE, uint8_t) = VIEWPORT_INTERACTION_ITEM_NONE; - image_id |= RCT2_ADDRESS(0x993CC4, uint32_t)[gConfigGeneral.construction_marker_colour]; + image_id |= construction_markers[gConfigGeneral.construction_marker_colour]; } else{ image_id |= diff --git a/src/paint/map_element/entrance.c b/src/paint/map_element/entrance.c index d3d39bc9c7..9316e7784b 100644 --- a/src/paint/map_element/entrance.c +++ b/src/paint/map_element/entrance.c @@ -60,7 +60,7 @@ void ride_entrance_exit_paint(uint8 direction, int height, rct_map_element* map_ if (map_element->flags & MAP_ELEMENT_FLAG_GHOST){ RCT2_GLOBAL(RCT2_ADDRESS_PAINT_SETUP_CURRENT_TYPE, uint8) = VIEWPORT_INTERACTION_ITEM_NONE; - image_id = RCT2_ADDRESS(0x993CC4, uint32_t)[gConfigGeneral.construction_marker_colour]; + image_id = construction_markers[gConfigGeneral.construction_marker_colour]; RCT2_GLOBAL(0x009E32BC, uint32) = image_id; if (transparant_image_id) transparant_image_id = image_id; @@ -168,7 +168,7 @@ void park_entrance_paint(uint8 direction, int height, rct_map_element* map_eleme uint32 image_id, ghost_id = 0; if (map_element->flags & MAP_ELEMENT_FLAG_GHOST){ RCT2_GLOBAL(RCT2_ADDRESS_PAINT_SETUP_CURRENT_TYPE, uint8) = VIEWPORT_INTERACTION_ITEM_NONE; - ghost_id = RCT2_ADDRESS(0x993CC4, uint32)[gConfigGeneral.construction_marker_colour]; + ghost_id = construction_markers[gConfigGeneral.construction_marker_colour]; RCT2_GLOBAL(0x009E32BC, uint32) = ghost_id; } diff --git a/src/paint/map_element/fence.c b/src/paint/map_element/fence.c index 4b2767a6da..1c0c16b5b2 100644 --- a/src/paint/map_element/fence.c +++ b/src/paint/map_element/fence.c @@ -27,11 +27,6 @@ #include "../../interface/viewport.h" #include "../paint.h" -uint32 dword_993CC4[] = { - COLOUR_DARK_GREEN << 19 | COLOUR_GREY << 24 | 0x20000000, - COLOUR_YELLOW << 19 | COLOUR_GREY << 24 | 0x40000000 -}; - const uint8 byte_9A406C[] = { 2, 2, 22, 26, 30, 34, 34, 34, 34, 34, 30, 26, 22, 2, 6, 2, 2, 2, 6, 10, 14, 18, 18, 18, 18, 18, 14, 10, 6, 2, 22, 2 @@ -178,7 +173,7 @@ void fence_paint(uint8 direction, int 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; - dword_141F710 = dword_993CC4[gConfigGeneral.construction_marker_colour]; + dword_141F710 = construction_markers[gConfigGeneral.construction_marker_colour]; } // save map_element diff --git a/src/paint/paint.h b/src/paint/paint.h index b527dee06c..067e467a04 100644 --- a/src/paint/paint.h +++ b/src/paint/paint.h @@ -19,6 +19,8 @@ #include "../common.h" #include "../world/map.h" +#include "../interface/colour.h" +#include "../drawing/drawing.h" typedef struct attached_paint_struct attached_paint_struct; @@ -85,6 +87,12 @@ enum PAINT_STRUCT_FLAGS { PAINT_STRUCT_FLAG_IS_MASKED = (1 << 0) }; +/** rct2: 0x00993CC4 */ +const uint32 construction_markers[] = { + COLOUR_DARK_GREEN << 19 | COLOUR_GREY << 24 | IMAGE_TYPE_USE_PALETTE << 28, // White + 2 << 19 | 0b110000 << 19 | IMAGE_TYPE_MIX_BACKGROUND << 28, // Translucent +}; + void painter_setup(); paint_struct * sub_98196C(uint32 image_id, sint8 x_offset, sint8 y_offset, sint16 bound_box_length_x, sint16 bound_box_length_y, sint8 bound_box_length_z, sint16 z_offset, uint32 rotation); diff --git a/src/ride/track_paint.c b/src/ride/track_paint.c index 09ef4ab715..80fe203076 100644 --- a/src/ride/track_paint.c +++ b/src/ride/track_paint.c @@ -238,7 +238,7 @@ void track_paint(uint8 direction, int height, rct_map_element *mapElement) RCT2_GLOBAL(0x00F441A4, uint32) = 0x21600000; } if (mapElement->flags & MAP_ELEMENT_FLAG_GHOST) { - uint32 ghost_id = RCT2_ADDRESS(0x00993CC4, uint32)[gConfigGeneral.construction_marker_colour]; + uint32 ghost_id = construction_markers[gConfigGeneral.construction_marker_colour]; RCT2_GLOBAL(RCT2_ADDRESS_PAINT_SETUP_CURRENT_TYPE, uint8) = 0; RCT2_GLOBAL(0x00F44198, uint32) = ghost_id; RCT2_GLOBAL(0x00F4419C, uint32) = ghost_id; From 0a15ccc3550fc0016671846d445cbe37a40273ca Mon Sep 17 00:00:00 2001 From: Marijn van der Werf Date: Tue, 17 May 2016 10:51:37 +0200 Subject: [PATCH 14/16] Make construction_markers extern --- src/paint/paint.c | 5 +++++ src/paint/paint.h | 5 +---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/paint/paint.c b/src/paint/paint.c index 1fdb6a2058..e8208d061d 100644 --- a/src/paint/paint.c +++ b/src/paint/paint.c @@ -23,6 +23,11 @@ #include "sprite/sprite.h" #include "../addresses.h" +const uint32 construction_markers[] = { + COLOUR_DARK_GREEN << 19 | COLOUR_GREY << 24 | IMAGE_TYPE_USE_PALETTE << 28, // White + 2 << 19 | 0b110000 << 19 | IMAGE_TYPE_MIX_BACKGROUND << 28, // Translucent +}; + /** * * rct2: 0x0068615B diff --git a/src/paint/paint.h b/src/paint/paint.h index 067e467a04..be0cd713a7 100644 --- a/src/paint/paint.h +++ b/src/paint/paint.h @@ -88,10 +88,7 @@ enum PAINT_STRUCT_FLAGS { }; /** rct2: 0x00993CC4 */ -const uint32 construction_markers[] = { - COLOUR_DARK_GREEN << 19 | COLOUR_GREY << 24 | IMAGE_TYPE_USE_PALETTE << 28, // White - 2 << 19 | 0b110000 << 19 | IMAGE_TYPE_MIX_BACKGROUND << 28, // Translucent -}; +extern const uint32 construction_markers[]; void painter_setup(); From c84e23b9ea41e4bfb6b112f9eb109563c833111b Mon Sep 17 00:00:00 2001 From: Marijn van der Werf Date: Tue, 17 May 2016 11:02:54 +0200 Subject: [PATCH 15/16] Clean up code and fix banner drawing --- src/paint/map_element/fence.c | 72 ++++++++++++++++------------------- 1 file changed, 32 insertions(+), 40 deletions(-) diff --git a/src/paint/map_element/fence.c b/src/paint/map_element/fence.c index 1c0c16b5b2..e8d754aa42 100644 --- a/src/paint/map_element/fence.c +++ b/src/paint/map_element/fence.c @@ -46,16 +46,16 @@ const uint8 byte_9A40CC[] = { 0, 0, 4, 8, 12, 16, 16, 16, 16, 16, 12, 8, 4, 0, 20, 0 }; -void do_part_1(uint32 imageId, - rct_scenery_entry * sceneryEntry, - uint32 dword_141F714, uint32 tertiaryColour, uint32 dword_141F710, - rct_xyz16 offset, - rct_xyz16 boundsR1, rct_xyz16 boundsR1_, - rct_xyz16 boundsR2, rct_xyz16 boundsR2_, - rct_xyz16 boundsL1, rct_xyz16 boundsL1_) +void fence_paint_door(uint32 imageId, + rct_scenery_entry * sceneryEntry, + uint32 imageColourFlags, uint32 tertiaryColour, uint32 dword_141F710, + rct_xyz16 offset, + rct_xyz16 boundsR1, rct_xyz16 boundsR1_, + rct_xyz16 boundsR2, rct_xyz16 boundsR2_, + rct_xyz16 boundsL1, rct_xyz16 boundsL1_) { if (sceneryEntry->wall.flags & WALL_SCENERY_FLAG1) { - imageId |= dword_141F714; + imageId |= imageColourFlags; } if (dword_141F710 != 0) { @@ -89,7 +89,7 @@ void do_part_1(uint32 imageId, } } -void do_part_2(uint32 frameNum, const rct_scenery_entry * sceneryEntry, uint32 dword_141F710, uint32 dword_141F714, uint32 dword_141F718, uint32 tertiaryColour, uint32 imageOffset, rct_xyz16 offset, rct_xyz16 bounds, rct_xyz16 boundsOffset) +void fence_paint_wall(uint32 frameNum, const rct_scenery_entry * sceneryEntry, uint32 dword_141F710, uint32 imageColourFlags, uint32 dword_141F718, uint32 tertiaryColour, uint32 imageOffset, rct_xyz16 offset, rct_xyz16 bounds, rct_xyz16 boundsOffset) { uint32 baseImageId = sceneryEntry->image + imageOffset + frameNum; uint32 imageId = baseImageId; @@ -97,7 +97,7 @@ void do_part_2(uint32 frameNum, const rct_scenery_entry * sceneryEntry, uint32 d if (sceneryEntry->wall.flags & WALL_SCENERY_FLAG2) { if (sceneryEntry->wall.flags & WALL_SCENERY_FLAG1) { - imageId |= dword_141F714; + imageId |= imageColourFlags; } if (dword_141F710 != 0) { @@ -111,7 +111,7 @@ void do_part_2(uint32 frameNum, const rct_scenery_entry * sceneryEntry, uint32 d } } else { if (sceneryEntry->wall.flags & WALL_SCENERY_FLAG1) { - imageId |= dword_141F714; + imageId |= imageColourFlags; } if (dword_141F710 != 0) { @@ -144,18 +144,18 @@ void fence_paint(uint8 direction, int height, rct_map_element * map_element) int primaryColour = map_element->properties.fence.item[1] & 0x1F; - uint32 dword_141F714 = primaryColour << 19 | 0x20000000; - uint32 dword_141F718 = dword_141F714 + 0x23800006; + uint32 imageColourFlags = primaryColour << 19 | 0x20000000; + uint32 dword_141F718 = imageColourFlags + 0x23800006; if (sceneryEntry->wall.flags & WALL_SCENERY_HAS_SECONDARY_COLOUR) { uint8 secondaryColour = (map_element->properties.fence.item[1] >> 5) | ((map_element->flags & 0x60) >> 2); - dword_141F714 |= secondaryColour << 24 | 0x80000000; + imageColourFlags |= secondaryColour << 24 | 0x80000000; } uint32 tertiaryColour = 0; if (sceneryEntry->wall.flags & WALL_SCENERY_HAS_TERNARY_COLOUR) { tertiaryColour = map_element->properties.fence.item[0]; - dword_141F714 &= 0x0DFFFFFFF; + imageColourFlags &= 0x0DFFFFFFF; } int clearanceHeight = ceil2(map_element->clearance_height * 8 + 15, 16); @@ -199,7 +199,7 @@ void fence_paint(uint8 direction, int height, rct_map_element * map_element) offset = (rct_xyz16) {0, 0, height}; - do_part_1(imageId, sceneryEntry, dword_141F714, tertiaryColour, dword_141F710, offset, boundsR1, boundsR1_, boundsR2, boundsR2_, boundsL1, boundsL1_); + fence_paint_door(imageId, sceneryEntry, imageColourFlags, tertiaryColour, dword_141F710, offset, boundsR1, boundsR1_, boundsR2, boundsR2_, boundsL1, boundsL1_); break; case 1: @@ -215,7 +215,7 @@ void fence_paint(uint8 direction, int height, rct_map_element * map_element) offset = (rct_xyz16) {1, 31, height}; - do_part_1(imageId, sceneryEntry, dword_141F714, tertiaryColour, dword_141F710, offset, boundsR1, boundsR1_, boundsR2, boundsR2_, boundsL1, boundsL1_); + fence_paint_door(imageId, sceneryEntry, imageColourFlags, tertiaryColour, dword_141F710, offset, boundsR1, boundsR1_, boundsR2, boundsR2_, boundsL1, boundsL1_); break; case 2: @@ -231,7 +231,7 @@ void fence_paint(uint8 direction, int height, rct_map_element * map_element) offset = (rct_xyz16) {31, 0, height}; - do_part_1(imageId, sceneryEntry, dword_141F714, tertiaryColour, dword_141F710, offset, boundsR1, boundsR1_, boundsR2, boundsR2_, boundsL1, boundsL1_); + fence_paint_door(imageId, sceneryEntry, imageColourFlags, tertiaryColour, dword_141F710, offset, boundsR1, boundsR1_, boundsR2, boundsR2_, boundsL1, boundsL1_); break; case 3: @@ -247,7 +247,7 @@ void fence_paint(uint8 direction, int height, rct_map_element * map_element) offset = (rct_xyz16) {2, 1, height}; - do_part_1(imageId, sceneryEntry, dword_141F714, tertiaryColour, dword_141F710, offset, boundsR1, boundsR1_, boundsR2, boundsR2_, boundsL1, boundsL1_); + fence_paint_door(imageId, sceneryEntry, imageColourFlags, tertiaryColour, dword_141F710, offset, boundsR1, boundsR1_, boundsR2, boundsR2_, boundsL1, boundsL1_); break; } @@ -255,15 +255,14 @@ void fence_paint(uint8 direction, int height, rct_map_element * map_element) } - uint8 al = map_element->type; uint32 imageOffset; rct_xyz16 offset, bounds, boundsOffset; switch (direction) { case 0: - if (al & 0x80) { + if (map_element->type & 0x80) { imageOffset = 3; - } else if (al & 0x40) { + } else if (map_element->type & 0x40) { imageOffset = 5; } else { imageOffset = 1; @@ -275,9 +274,9 @@ void fence_paint(uint8 direction, int height, rct_map_element * map_element) break; case 1: - if (al & 0x80) { + if (map_element->type & 0x80) { imageOffset = 2; - } else if (al & 0x40) { + } else if (map_element->type & 0x40) { imageOffset = 4; } else { imageOffset = 0; @@ -299,9 +298,9 @@ void fence_paint(uint8 direction, int height, rct_map_element * map_element) break; case 2: - if (al & 0x80) { + if (map_element->type & 0x80) { imageOffset = 5; - } else if (al & 0x40) { + } else if (map_element->type & 0x40) { imageOffset = 3; } else { imageOffset = 1; @@ -317,9 +316,9 @@ void fence_paint(uint8 direction, int height, rct_map_element * map_element) break; case 3: - if (al & 0x80) { + if (map_element->type & 0x80) { imageOffset = 4; - } else if (al & 0x40) { + } else if (map_element->type & 0x40) { imageOffset = 2; } else { imageOffset = 0; @@ -331,7 +330,7 @@ void fence_paint(uint8 direction, int height, rct_map_element * map_element) break; } - do_part_2(frameNum, sceneryEntry, dword_141F710, dword_141F714, dword_141F718, tertiaryColour, imageOffset, offset, bounds, boundsOffset); + fence_paint_wall(frameNum, sceneryEntry, dword_141F710, imageColourFlags, dword_141F718, tertiaryColour, imageOffset, offset, bounds, boundsOffset); if (sceneryEntry->wall.var_0D == 0xFF) { @@ -342,10 +341,6 @@ void fence_paint(uint8 direction, int height, rct_map_element * map_element) return; } - if (sceneryEntry->wall.flags & WALL_SCENERY_FLAG1) { - return; - } - set_format_arg(0, uint32, 0); set_format_arg(4, uint32, 0); @@ -355,27 +350,24 @@ void fence_paint(uint8 direction, int height, rct_map_element * map_element) al_2 = COLOUR_GREY; } - if (get_current_rotation() == 0) { + if (direction == 0) { al_2 |= 0x80; } set_format_arg(7, uint8, al_2); - uint16 scrollingMode = sceneryEntry->wall.var_0D + (get_current_rotation() + 1) & 0x3; + uint16 scrollingMode = sceneryEntry->wall.var_0D + ((direction + 1) & 0x3); uint8 bannerIndex = map_element->properties.fence.item[0]; rct_banner * banner = &gBanners[bannerIndex]; set_format_arg(0, rct_string_id, banner->string_idx); - if (banner->flags & 0x04) { + if (banner->flags & BANNER_FLAG_2) { rct_ride * ride = get_ride(banner->colour); set_format_arg(0, rct_string_id, ride->name); set_format_arg(2, uint32, ride->name_arguments); } - sub_98199C(0, 0, 0, 1, 1, 13, height + 8, 0, 0, 0, get_current_rotation()); - - utf8 signString[MAX_PATH]; rct_string_id stringId = STR_SCROLLING_SIGN_TEXT; if (gConfigGeneral.upper_case_banners) { @@ -389,6 +381,6 @@ void fence_paint(uint8 direction, int height, rct_map_element * map_element) uint16 string_width = gfx_get_string_width(signString); uint16 scroll = (gCurrentTicks / 2) % string_width; - sub_98199C(scrolling_text_setup(stringId, scroll, scrollingMode), 0, 0, 1, 1, 13, height + 8, 1, 1, height + 1, get_current_rotation()); + sub_98199C(scrolling_text_setup(stringId, scroll, scrollingMode), 0, 0, 1, 1, 13, height + 8, boundsOffset.x, boundsOffset.y, boundsOffset.z, get_current_rotation()); } From ffa826976c6e0f1c31d38a9a7849d99089bebd05 Mon Sep 17 00:00:00 2001 From: Marijn van der Werf Date: Wed, 18 May 2016 22:50:44 +0200 Subject: [PATCH 16/16] Fix warnings --- src/paint/map_element/fence.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/src/paint/map_element/fence.c b/src/paint/map_element/fence.c index e8d754aa42..c38bdfefaa 100644 --- a/src/paint/map_element/fence.c +++ b/src/paint/map_element/fence.c @@ -49,7 +49,7 @@ const uint8 byte_9A40CC[] = { void fence_paint_door(uint32 imageId, rct_scenery_entry * sceneryEntry, uint32 imageColourFlags, uint32 tertiaryColour, uint32 dword_141F710, - rct_xyz16 offset, + rct_xyz8 offset, rct_xyz16 boundsR1, rct_xyz16 boundsR1_, rct_xyz16 boundsR2, rct_xyz16 boundsR2_, rct_xyz16 boundsL1, rct_xyz16 boundsL1_) @@ -65,24 +65,24 @@ void fence_paint_door(uint32 imageId, if (sceneryEntry->wall.flags & WALL_SCENERY_FLAG4) { paint_struct * ps; - ps = sub_98197C(imageId, offset.x, offset.y, boundsR1.x, boundsR1.y, boundsR1.z, offset.z, boundsR1_.x, boundsR1_.y, boundsR1_.z, get_current_rotation()); + ps = sub_98197C(imageId, offset.x, offset.y, boundsR1.x, boundsR1.y, (sint8) boundsR1.z, offset.z, boundsR1_.x, boundsR1_.y, boundsR1_.z, get_current_rotation()); if (ps != NULL) { ps->tertiary_colour = tertiaryColour; } - ps = sub_98197C(imageId + 1, offset.x, offset.y, boundsR2.x, boundsR2.y, boundsR2.z, offset.z, boundsR2_.x, boundsR2_.y, boundsR2_.z, get_current_rotation()); + ps = sub_98197C(imageId + 1, offset.x, offset.y, boundsR2.x, boundsR2.y, (sint8) boundsR2.z, offset.z, boundsR2_.x, boundsR2_.y, boundsR2_.z, get_current_rotation()); if (ps != NULL) { ps->tertiary_colour = tertiaryColour; } } else { paint_struct * ps; - ps = sub_98197C(imageId, offset.x, offset.y, boundsL1.x, boundsL1.y, boundsL1.z, offset.z, boundsL1_.x, boundsL1_.y, boundsL1_.z, get_current_rotation()); + ps = sub_98197C(imageId, offset.x, offset.y, boundsL1.x, boundsL1.y, (sint8) boundsL1.z, offset.z, boundsL1_.x, boundsL1_.y, boundsL1_.z, get_current_rotation()); if (ps != NULL) { ps->tertiary_colour = tertiaryColour; } - ps = sub_98199C(imageId + 1, offset.x, offset.y, boundsL1.x, boundsL1.y, boundsL1.z, offset.z, boundsL1_.x, boundsL1_.y, boundsL1_.z, get_current_rotation()); + ps = sub_98199C(imageId + 1, offset.x, offset.y, boundsL1.x, boundsL1.y, (sint8) boundsL1.z, offset.z, boundsL1_.x, boundsL1_.y, boundsL1_.z, get_current_rotation()); if (ps != NULL) { ps->tertiary_colour = tertiaryColour; } @@ -182,8 +182,9 @@ void fence_paint(uint8 direction, int height, rct_map_element * map_element) if (sceneryEntry->wall.flags & WALL_SCENERY_IS_DOOR) { - rct_xyz16 offset, boundsR1, boundsR1_, boundsR2, boundsR2_, boundsL1, boundsL1_; - uint animationFrame = (map_element->properties.fence.item[2] >> 3) & 0x1F; + rct_xyz8 offset; + rct_xyz16 boundsR1, boundsR1_, boundsR2, boundsR2_, boundsL1, boundsL1_; + uint8 animationFrame = (map_element->properties.fence.item[2] >> 3) & 0x1F; uint32 imageId; switch (direction) { case 0: @@ -197,7 +198,7 @@ void fence_paint(uint8 direction, int height, rct_map_element * map_element) boundsL1 = (rct_xyz16) {1, 28, ah}; boundsL1_ = (rct_xyz16) {1, 1, height + 1}; - offset = (rct_xyz16) {0, 0, height}; + offset = (rct_xyz8) {0, 0, height}; fence_paint_door(imageId, sceneryEntry, imageColourFlags, tertiaryColour, dword_141F710, offset, boundsR1, boundsR1_, boundsR2, boundsR2_, boundsL1, boundsL1_); break; @@ -213,7 +214,7 @@ void fence_paint(uint8 direction, int height, rct_map_element * map_element) boundsL1 = (rct_xyz16) {29, 1, ah}; boundsL1_ = (rct_xyz16) {2, 30, height + 1}; - offset = (rct_xyz16) {1, 31, height}; + offset = (rct_xyz8) {1, 31, height}; fence_paint_door(imageId, sceneryEntry, imageColourFlags, tertiaryColour, dword_141F710, offset, boundsR1, boundsR1_, boundsR2, boundsR2_, boundsL1, boundsL1_); break; @@ -229,7 +230,7 @@ void fence_paint(uint8 direction, int height, rct_map_element * map_element) boundsL1 = (rct_xyz16) {1, 29, ah}; boundsL1_ = (rct_xyz16) {30, 2, height + 1}; - offset = (rct_xyz16) {31, 0, height}; + offset = (rct_xyz8) {31, 0, height}; fence_paint_door(imageId, sceneryEntry, imageColourFlags, tertiaryColour, dword_141F710, offset, boundsR1, boundsR1_, boundsR2, boundsR2_, boundsL1, boundsL1_); break; @@ -245,7 +246,7 @@ void fence_paint(uint8 direction, int height, rct_map_element * map_element) boundsL1 = (rct_xyz16) {28, 1, ah}; boundsL1_ = (rct_xyz16) {1, 1, height + 1}; - offset = (rct_xyz16) {2, 1, height}; + offset = (rct_xyz8) {2, 1, height}; fence_paint_door(imageId, sceneryEntry, imageColourFlags, tertiaryColour, dword_141F710, offset, boundsR1, boundsR1_, boundsR2, boundsR2_, boundsL1, boundsL1_); break;