1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-18 12:33:17 +01:00

Partially integrate side tunnels

This commit is contained in:
Marijn van der Werf
2016-09-07 13:26:53 +02:00
parent 933d13ecde
commit 8f3c43fcf1
3 changed files with 56 additions and 44 deletions

View File

@@ -33,6 +33,13 @@
#include "../../game.h"
#include "../supports.h"
#ifdef NO_RCT2
tunnel_entry gLeftTunnels[65];
uint8 gLeftTunnelCount;
tunnel_entry gRightTunnels[65];
uint8 gRightTunnelCount;
#endif
static void blank_tiles_paint(int x, int y);
static void sub_68B3FB(int x, int y);
@@ -134,9 +141,11 @@ static void sub_68B3FB(int x, int y)
{
rct_drawpixelinfo *dpi = unk_140E9A8;
RCT2_GLOBAL(0x141F56A, uint16_t) = 0;
RCT2_GLOBAL(0x9E3138, uint8_t) = 0xFF;
RCT2_GLOBAL(0x9E30B6, uint8_t) = 0xFF;
gLeftTunnelCount = 0;
gRightTunnelCount = 0;
gLeftTunnels[0] = (tunnel_entry){0xFF, 0xFF};
gRightTunnels[0] = (tunnel_entry){0xFF, 0xFF};
RCT2_GLOBAL(0x9E323C, uint8_t) = 0xFF;
RCT2_GLOBAL(0x9DE56A, uint16_t) = x;
RCT2_GLOBAL(0x9DE56E, uint16_t) = y;
@@ -302,16 +311,16 @@ static void sub_68B3FB(int x, int y)
void paint_util_push_tunnel_left(uint16 height, uint8 type)
{
uint32 eax = 0xFFFF0000 | ((height / 16) & 0xFF) | type << 8;
RCT2_ADDRESS(0x009E3138, uint32)[RCT2_GLOBAL(0x141F56A, uint8) / 2] = eax;
RCT2_GLOBAL(0x141F56A, uint8)++;
gLeftTunnels[gLeftTunnelCount] = (tunnel_entry){.height = (height / 16), .type = type};
gLeftTunnels[gLeftTunnelCount + 1] = (tunnel_entry){0xFF, 0xFF};
gLeftTunnelCount++;
}
void paint_util_push_tunnel_right(uint16 height, uint8 type)
{
uint32 eax = 0xFFFF0000 | ((height / 16) & 0xFF) | type << 8;
RCT2_ADDRESS(0x009E30B6, uint32)[RCT2_GLOBAL(0x141F56B, uint8) / 2] = eax;
RCT2_GLOBAL(0x141F56B, uint8)++;
gRightTunnels[gRightTunnelCount] = (tunnel_entry){.height = (height / 16), .type = type};
gRightTunnels[gRightTunnelCount + 1] = (tunnel_entry){0xFF, 0xFF};
gRightTunnelCount++;
}
void paint_util_set_general_support_height(sint16 height, uint8 slope)

View File

@@ -62,6 +62,23 @@ enum
TUNNEL_14 = 0x0E
};
typedef struct tunnel_entry {
uint8 height;
uint8 type;
} tunnel_entry;
#ifdef NO_RCT2
extern tunnel_entry gLeftTunnels[65];
extern uint8 gLeftTunnelCount;
extern tunnel_entry gRightTunnels[65];
extern uint8 gRightTunnelCount;
#else
#define gLeftTunnels RCT2_ADDRESS(0x009E3138, tunnel_entry)
#define gLeftTunnelCount RCT2_GLOBAL(0x0141F56A, uint8)
#define gRightTunnels RCT2_ADDRESS(0x009E30B6, tunnel_entry)
#define gRightTunnelCount RCT2_GLOBAL(0x0141F56B, uint8)
#endif
extern bool gShowSupportSegmentHeights;
void paint_util_push_tunnel_left(uint16 height, uint8 type);

View File

@@ -539,7 +539,7 @@ static void viewport_surface_draw_land_side_bottom(enum edge edge, uint8 height,
rct_xy16 tunnelBounds = {1, 1};
rct_xy16 tunnelTopBoundBoxOffset = {0, 0};
uint32 tunnelArray;
tunnel_entry * tunnelArray;
switch (edge) {
case EDGE_BOTTOMLEFT:
regs.al = self.corner_heights.left;
@@ -553,7 +553,7 @@ static void viewport_surface_draw_land_side_bottom(enum edge edge, uint8 height,
tunnelBounds.x = 32;
tunnelTopBoundBoxOffset.y = 31;
tunnelArray = 0x9E3138;
tunnelArray = gLeftTunnels;
break;
case EDGE_BOTTOMRIGHT:
@@ -568,7 +568,7 @@ static void viewport_surface_draw_land_side_bottom(enum edge edge, uint8 height,
tunnelBounds.y = 32;
tunnelTopBoundBoxOffset.x = 31;
tunnelArray = 0x009E30B6;
tunnelArray = gRightTunnels;
break;
default:
@@ -629,15 +629,14 @@ static void viewport_surface_draw_land_side_bottom(enum edge edge, uint8 height,
return;
}
if (curHeight != RCT2_GLOBAL(tunnelArray, uint8)) {
if (curHeight != tunnelArray[0].height) {
// Normal walls
while (curHeight > RCT2_GLOBAL(tunnelArray, uint8)) {
for (int offset = 0; offset <= 0x7E; offset += 4) {
RCT2_GLOBAL(tunnelArray + offset, uint32) = RCT2_GLOBAL(tunnelArray + 2 + offset, uint32);
}
while (curHeight > tunnelArray[0].height) {
// TODO: Should probably be done by just keeping track of the current index
memcpy(&tunnelArray[0], &tunnelArray[1], sizeof(tunnel_entry) * 64);
}
if (curHeight != RCT2_GLOBAL(tunnelArray, uint8)) {
if (curHeight != tunnelArray[0].height) {
sub_98196C(base_image_id, offset.x, offset.y, bounds.x, bounds.y, 15, curHeight * 16, rotation);
curHeight++;
@@ -646,7 +645,7 @@ static void viewport_surface_draw_land_side_bottom(enum edge edge, uint8 height,
}
// Tunnels
uint8 tunnelType = RCT2_GLOBAL(tunnelArray + 1, uint8);
uint8 tunnelType = tunnelArray[0].type;
uint8 tunnelHeight = stru_97B570[tunnelType][0];
sint16 zOffset = curHeight;
@@ -681,9 +680,8 @@ static void viewport_surface_draw_land_side_bottom(enum edge edge, uint8 height,
curHeight += stru_97B570[tunnelType][0];
for (int offset = 0; offset <= 0x7E; offset += 4) {
RCT2_GLOBAL(tunnelArray + offset, uint32) = RCT2_GLOBAL(tunnelArray + 2 + offset, uint32);
}
// TODO: Should probably be done by just keeping track of the current index
memcpy(&tunnelArray[0], &tunnelArray[1], sizeof(tunnel_entry) * 64);
}
}
@@ -801,7 +799,7 @@ static void viewport_surface_draw_water_side_bottom(enum edge edge, uint8 height
rct_xy16 tunnelBounds = {1, 1};
rct_xy16 tunnelTopBoundBoxOffset = {0, 0};
uint32 tunnelArray;
tunnel_entry * tunnelArray;
switch (edge) {
case EDGE_BOTTOMLEFT:
regs.al = self.corner_heights.left;
@@ -815,7 +813,7 @@ static void viewport_surface_draw_water_side_bottom(enum edge edge, uint8 height
tunnelBounds.x = 32;
tunnelTopBoundBoxOffset.y = 31;
tunnelArray = 0x9E3138;
tunnelArray = gLeftTunnels;
break;
case EDGE_BOTTOMRIGHT:
@@ -830,7 +828,7 @@ static void viewport_surface_draw_water_side_bottom(enum edge edge, uint8 height
tunnelBounds.y = 32;
tunnelTopBoundBoxOffset.x = 31;
tunnelArray = 0x009E30B6;
tunnelArray = gRightTunnels;
break;
default:
@@ -901,12 +899,11 @@ static void viewport_surface_draw_water_side_bottom(enum edge edge, uint8 height
return;
}
if (curHeight != RCT2_GLOBAL(tunnelArray, uint8)) {
if (curHeight != tunnelArray[0].height) {
// Normal walls
while (curHeight > RCT2_GLOBAL(tunnelArray, uint8)) {
for (int offset = 0; offset <= 0x7E; offset += 4) {
RCT2_GLOBAL(tunnelArray + offset, uint32) = RCT2_GLOBAL(tunnelArray + 2 + offset, uint32);
}
while (curHeight > tunnelArray[0].height) {
// TODO: Should probably be done by just keeping track of the current index
memcpy(&tunnelArray[0], &tunnelArray[1], sizeof(tunnel_entry) * 64);
}
sub_98196C(base_image_id, offset.x, offset.y, bounds.x, bounds.y, 15, curHeight * 16, rotation);
@@ -916,7 +913,7 @@ static void viewport_surface_draw_water_side_bottom(enum edge edge, uint8 height
}
// Tunnels
uint8 tunnelType = RCT2_GLOBAL(tunnelArray + 1, uint8);
uint8 tunnelType = tunnelArray[0].type;
uint8 tunnelHeight = stru_97B570[tunnelType][0];
sint16 zOffset = curHeight;
@@ -951,9 +948,8 @@ static void viewport_surface_draw_water_side_bottom(enum edge edge, uint8 height
curHeight += stru_97B570[tunnelType][0];
for (int offset = 0; offset <= 0x7E; offset += 4) {
RCT2_GLOBAL(tunnelArray + offset, uint32) = RCT2_GLOBAL(tunnelArray + 2 + offset, uint32);
}
// TODO: Should probably be done by just keeping track of the current index
memcpy(&tunnelArray[0], &tunnelArray[1], sizeof(tunnel_entry) * 64);
}
}
@@ -1322,11 +1318,6 @@ void surface_paint(uint8 direction, uint16 height, rct_map_element * mapElement)
log_verbose("eax: %d", eax);
}
for (int i = 0; i <= 0x7C; i += 4) {
RCT2_GLOBAL(0x009E2F30 + i, uint32) = RCT2_GLOBAL(0x009E3138 + i, uint32);
RCT2_GLOBAL(0x009E2EAE + i, uint32) = RCT2_GLOBAL(0x009E30B6 + i, uint32);
}
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_bottom(EDGE_BOTTOMLEFT, height / 16, eax / 32, tileDescriptors[0], tileDescriptors[1]);
@@ -1356,11 +1347,6 @@ void surface_paint(uint8 direction, uint16 height, rct_map_element * mapElement)
paint_attach_to_previous_ps(SPR_WATER_OVERLAY + image_offset, 0, 0);
for (int i = 0; i <= 0x7C; i += 4) {
RCT2_GLOBAL(0x009E3138 + i, uint32) = RCT2_GLOBAL(0x009E2F30 + i, uint32);
RCT2_GLOBAL(0x009E30B6 + i, uint32) = RCT2_GLOBAL(0x009E2EAE + i, uint32);
}
// This wasn't in the original, but the code depended on globals that were only set in a different conditional
uint8 al_edgeStyle = mapElement->properties.surface.slope & 0xE0;
uint8 di_type = mapElement->type & 0x80;