From 70debab0fadbaf654e02a2b46afa7419ace20cdf Mon Sep 17 00:00:00 2001 From: Marijn van der Werf Date: Tue, 26 Apr 2016 19:36:54 +0200 Subject: [PATCH] Continue work on tunnels --- src/interface/paint_surface.c | 200 ++++++++++------------------------ 1 file changed, 60 insertions(+), 140 deletions(-) diff --git a/src/interface/paint_surface.c b/src/interface/paint_surface.c index 73a56c4da2..0885a6932f 100644 --- a/src/interface/paint_surface.c +++ b/src/interface/paint_surface.c @@ -176,6 +176,7 @@ const sint16 word_97B590[] = { -16, }; +// tunnel offset const uint8 byte_97B5B0[] = { 0, 0, 0, 3, 3, 3, 6, 6, 6, 6, 10, 11, 12, 13, 14, 14 @@ -505,86 +506,15 @@ void viewport_surface_smoothen_edge(enum edge edge, struct tile_descriptor self, } } -void viewport_surface_draw_land_side_top_right(enum edge edge, uint16 height) -{ - if (edge != EDGE_TOPLEFT) { - return; - } - - rct_map_element * esi = _dword_9E3240; - - registers regs; - regs.dl = height / 16; - regs.ax = _dword_9E327C; - regs.cx = _dword_9E3284; - - // save ecx - if (esi == NULL) { - regs.ah = 1; - regs.ch = 1; - } - - // al + cl probably are self tile corners, while ah/ch are neighbour tile corners - if (regs.al <= regs.ah && regs.cl <= regs.ch) { - return; - } - - if (!(RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_VIEWPORT_FLAGS, uint16) & VIEWPORT_FLAG_UNDERGROUND_INSIDE)) { - uint incline = (regs.cl - regs.al) + 1; - - uint32 image_id = RCT2_GLOBAL(0x009E32A8, uint32) + incline; // var_c; - - uint8 y = -((regs.al - regs.dl) * 16); - log_info("y: %d", y); - - sub_68818E(image_id, 0, y, NULL); - return; - } - - uint32 base_image_id = RCT2_GLOBAL(0x009E32A0, uint32); // var_04 - - uint8 cur_height = regs.ch; - if (regs.ch != regs.ah) { - // neightbour tile corners aren't level - uint32 image_offset = 3; - if (regs.ch > regs.ah) { - cur_height = regs.ah; - image_offset = 4; - } - - if (cur_height != regs.al && cur_height != regs.cl) { - uint32 image_id = base_image_id + image_offset; - sub_98196C(image_id, -2, 0, 0, 30, 15, cur_height * 16, get_current_rotation()); - cur_height++; - } - } - - regs.ah = regs.cl; - - while (cur_height < regs.al && cur_height < regs.ah) { - sub_98196C(base_image_id, -2, 0, 0, 30, 15, cur_height * 16, get_current_rotation()); - cur_height++; - } - - uint32 image_offset = 1; - if (cur_height >= regs.al) { - image_offset = 2; - - if (cur_height >= regs.ah) { - return; - } - } - - uint32 image_id = base_image_id + image_offset; - sub_98196C(image_id, -2, 0, 0, 30, 15, cur_height * 16, get_current_rotation()); -} - +/** + * rct2: 0x0065F63B, 0x0065F77D + */ void viewport_surface_draw_land_side_top(enum edge edge, uint8 height, uint8 terrain, struct tile_descriptor self, struct tile_descriptor neighbour) { registers regs; - rct_xy8 offset; - rct_xy8 bounds; + rct_xy8 offset = {0, 0}; + rct_xy8 bounds = {0, 0}; switch (edge) { case EDGE_TOPLEFT: regs.al = self.corner_heights.top; @@ -607,6 +537,9 @@ void viewport_surface_draw_land_side_top(enum edge edge, uint8 height, uint8 ter offset.x = -2; bounds.y = 30; break; + + default: + return; } regs.al; @@ -626,13 +559,13 @@ void viewport_surface_draw_land_side_top(enum edge edge, uint8 height, uint8 ter if (!(RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_VIEWPORT_FLAGS, uint16) & VIEWPORT_FLAG_UNDERGROUND_INSIDE)) { uint8 incline = (regs.cl - regs.al) + 1; - uint32 image_id = stru_97B5C0[3][3] + (edge == EDGE_TOPLEFT ? 3 : 0) + incline; // var_c; + uint32 image_id = stru_97B5C0[terrain][3] + (edge == EDGE_TOPLEFT ? 3 : 0) + incline; // var_c; sint16 y = (regs.dl - regs.al) * 16; sub_68818E(image_id, 0, y, NULL); return; } - uint32 base_image_id = stru_97B5C0[3][1] + (edge == EDGE_TOPLEFT ? 5 : 0); // var_04 + uint32 base_image_id = stru_97B5C0[terrain][1] + (edge == EDGE_TOPLEFT ? 5 : 0); // var_04 uint8 cur_height = min(regs.ch, regs.ah); if (regs.ch != regs.ah) { @@ -669,48 +602,41 @@ void viewport_surface_draw_land_side_top(enum edge edge, uint8 height, uint8 ter sub_98196C(image_id, offset.x, offset.y, bounds.x, bounds.y, 15, cur_height * 16, get_current_rotation()); } -void viewport_surface_draw_land_side(enum edge edge, uint16 height, uint8 eax) +void viewport_surface_draw_land_side_bottom(enum edge edge, uint8 height, uint8 terrain, struct tile_descriptor self, struct tile_descriptor neighbour) { - viewport_surface_paint_struct_0 from = RCT2_GLOBAL(0x0097B5C0 + eax, viewport_surface_paint_struct_0); - - if (edge) - - RCT2_GLOBAL(0x009E329C, uint32) = from.var_00; - RCT2_GLOBAL(0x009E32A0, uint32) = from.var_04; - RCT2_GLOBAL(0x009E32A4, uint32) = from.var_08; - RCT2_GLOBAL(0x009E32A8, uint32) = from.var_0C; - RCT2_GLOBAL(0x009E32AC, uint32) = from.var_10; - return; + registers regs; + rct_xy8 offset = {0, 0}; + rct_xy8 bounds = {0, 0}; switch (edge) { case EDGE_BOTTOMLEFT: - //RCT2_CALLPROC_X(0x65EB7D, 0x99999999, 0xAAAAAAAA, 0xBBBBBBBB, height / 16, 0xDDDDDDDD, 0, 0); + regs.al = self.corner_heights.left; + regs.cl = self.corner_heights.bottom; + + regs.ah = neighbour.corner_heights.top; + regs.ch = neighbour.corner_heights.right; + + offset.x = 30; + bounds.y = 30; break; + case EDGE_BOTTOMRIGHT: - RCT2_CALLPROC_X(0x65F0D8, 0x99999999, 0xAAAAAAAA, 0xBBBBBBBB, height / 16, 0xDDDDDDDD, 0, 0); - break; - case EDGE_TOPLEFT: - //viewport_surface_draw_land_side_top(edge, height); - //RCT2_CALLPROC_X(0x65F63B, 0x99999999, 0xAAAAAAAA, 0xBBBBBBBB, height / 16, 0xDDDDDDDD, 0, 0); - break; - case EDGE_TOPRIGHT: - RCT2_CALLPROC_X(0x65F77D, 0x99999999, 0xAAAAAAAA, 0xBBBBBBBB, height / 16, 0xDDDDDDDD, 0, 0); + regs.al = self.corner_heights.top; + regs.cl = self.corner_heights.right; + + regs.ah = neighbour.corner_heights.left; + regs.ch = neighbour.corner_heights.bottom; + + offset.x = -2; + bounds.y = 30; break; + + default: + return; } - if (edge != EDGE_BOTTOMLEFT) { - return; - } - - rct_map_element * esi = _dword_9E3248; - - registers regs; - regs.ax = _dword_9E3280; - regs.cx = _dword_9E3288; - - if (esi == NULL) { - // ch / ah: neighbour tile corner heights; - regs.ch = 0; + if (neighbour.map_element == 0) { + regs.ch = 1; regs.ah = 1; } @@ -718,64 +644,57 @@ void viewport_surface_draw_land_side(enum edge edge, uint16 height, uint8 eax) return; } - regs.ebp = RCT2_GLOBAL(0x009E329C, uint32); // var_00 + uint32 base_image_id = stru_97B5C0[terrain][0]; if (RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_VIEWPORT_FLAGS, uint16) & VIEWPORT_FLAG_UNDERGROUND_INSIDE) { - regs.ebp = RCT2_GLOBAL(0x009E32A0, uint32); // var_04 + base_image_id = stru_97B5C0[terrain][1]; } - uint32 base_image_id = regs.ebp; - - regs.dh = regs.ch; - if (regs.dh != regs.ah) { + uint8 curHeight = min(regs.ah, regs.ch); + if (regs.ch != regs.ah) { // If bottom part of edge isn't straight, add a filler uint32 image_offset = 3; - if (regs.dh >= regs.ah) { - regs.dh = regs.ah; + if (regs.ch >= regs.ah) { image_offset = 4; } - if (regs.dh != regs.al - && regs.dh != regs.cl) { - - uint32 image_id = base_image_id + image_offset; - sub_98196C(image_id, 30, 0, 0, 30, 15, regs.dh * 16, get_current_rotation()); + if (curHeight != regs.al && curHeight != regs.cl) { + uint32 image_id = stru_97B5C0[3][0] + image_offset; + sub_98196C(image_id, offset.x, offset.y, bounds.x, bounds.y, 15, curHeight * 16, get_current_rotation()); + curHeight++; } } - regs.ah = regs.cl; - while (true) { - if (regs.dh >= regs.al || regs.dh >= regs.ah) { + if (curHeight >= regs.al || curHeight >= regs.cl) { // If top of edge isn't straight, add a filler uint32 image_offset = 1; - if (regs.dh >= regs.al) { + if (curHeight >= regs.al) { image_offset = 2; - if (regs.dh >= regs.ah) { + if (curHeight >= regs.cl) { return; } } uint32 image_id = base_image_id + image_offset; - sub_98196C(image_id, 30, 0, 0, 30, 15, regs.dh * 16, get_current_rotation()); + sub_98196C(image_id, offset.x, offset.y, bounds.x, bounds.y, 15, curHeight * 16, get_current_rotation()); return; } - if (regs.dh != RCT2_GLOBAL(0x9E3138, uint8)) { + if (curHeight != RCT2_GLOBAL(0x9E3138, uint8)) { // Normal walls - while (regs.dh > RCT2_GLOBAL(0x9E3138, uint8)) { + while (curHeight > RCT2_GLOBAL(0x9E3138, uint8)) { for (int offset = 0; offset <= 0x7E; offset += 4) { RCT2_GLOBAL(0x9E3138 + offset, uint32) = RCT2_GLOBAL(0x9E3138 + 2 + offset, uint32); } } - sub_98196C(base_image_id, 30, 0, 0, 30, 15, regs.dh * 16, get_current_rotation()); - - regs.dh++; + sub_98196C(base_image_id, offset.x, offset.y, bounds.x, bounds.y, 15, curHeight * 16, get_current_rotation()); + curHeight++; continue; } @@ -807,7 +726,7 @@ void viewport_surface_draw_land_side(enum edge edge, uint16 height, uint8 eax) } uint32 esi = RCT2_GLOBAL(0x009E32AC, uint32); // var_10 - uint32 image_id = RCT2_GLOBAL(esi + ebx * 4, uint32); + uint32 image_id = stru_97B640[terrain][ebx]; sub_98197C(image_id, 30, 0, 32, 1, regs.ah, imageHeight, 0, 0, boundOffsetZ, get_current_rotation()); // push edx @@ -820,13 +739,13 @@ void viewport_surface_draw_land_side(enum edge edge, uint16 height, uint8 eax) regs.ah -= 16; } - image_id = RCT2_GLOBAL(esi + ebx * 4, uint32) + 1; + image_id = stru_97B640[terrain][ebx] + 1; sub_98197C(image_id, 30, 0, 32, 1, regs.ah, regs.dh * 16, 0, 31, boundOffsetZ, get_current_rotation()); uint8 edi = RCT2_GLOBAL(0x9E3138 + 1, uint8); regs.edx = saved_edx; regs.eax = saved_eax; - regs.dh += stru_97B570[edi][0]; + curHeight += stru_97B570[edi][0]; for (int offset = 0; offset <= 0x7E; offset += 4) { RCT2_GLOBAL(0x9E3138 + offset, uint32) = RCT2_GLOBAL(0x9E3138 + 2 + offset, uint32); @@ -901,6 +820,7 @@ void viewport_surface_paint_setup(uint8 direction, uint16 height, rct_map_elemen rct_xy16 offset = viewport_surface_paint_data[i][get_current_rotation()]; rct_xy16 position = {.x = base.x + offset.x, .y = base.y + offset.y}; + tileDescriptors[i + 1].map_element = NULL; if (position.x > 0x2000 || position.y > 0x2000) { continue; } @@ -1239,8 +1159,8 @@ void viewport_surface_paint_setup(uint8 direction, uint16 height, rct_map_elemen viewport_surface_draw_land_side_top(EDGE_TOPLEFT, height / 16, eax / 32, tileDescriptors[0], tileDescriptors[3]); viewport_surface_draw_land_side_top(EDGE_TOPRIGHT, height / 16, eax / 32, tileDescriptors[0], tileDescriptors[4]); - //viewport_surface_draw_land_side(EDGE_BOTTOMLEFT, height, eax / 32); - //viewport_surface_draw_land_side(EDGE_BOTTOMRIGHT, height, eax / 32); + viewport_surface_draw_land_side_bottom(EDGE_BOTTOMLEFT, height / 16, eax / 32, tileDescriptors[0], tileDescriptors[1]); + //viewport_surface_draw_land_side_bottom(EDGE_BOTTOMRIGHT, height, eax / 32); } RCT2_GLOBAL(0x009E3298, uint16) = 0;