Clean up magic numbers in footpath corner drawing

This commit is contained in:
Gymnasiast 2019-01-20 17:29:27 +01:00
parent d000457fb5
commit cd8227c756
2 changed files with 27 additions and 20 deletions

View File

@ -484,13 +484,12 @@ static void sub_6A4101(
return;
}
// save ecx, ebp, esi
uint32_t drawnEdges = connectedEdges;
uint32_t drawnCorners = 0;
// If the path is not drawn over the supports, then no corner sprites will be drawn (making double-width paths
// look like connected series of intersections).
if (!tile_element->AsPath()->ShouldDrawPathOverSupports())
if (tile_element->AsPath()->ShouldDrawPathOverSupports())
{
drawnEdges &= FOOTPATH_PROPERTIES_EDGES_EDGES_MASK;
drawnCorners = (connectedEdges & FOOTPATH_PROPERTIES_EDGES_CORNERS_MASK) >> 4;
}
if (tile_element->AsPath()->IsSloped())
@ -558,7 +557,7 @@ static void sub_6A4101(
sub_98197C(
session, 77 + base_image_id, 28, 0, 1, 28, 7, height, 28, 4,
height + 2); // bound_box_offset_y seems to be a bug
if (!(drawnEdges & 0x10))
if (!(drawnCorners & FOOTPATH_CORNER_0))
{
sub_98197C(session, 84 + base_image_id, 0, 0, 4, 4, 7, height, 0, 28, height + 2);
}
@ -566,7 +565,7 @@ static void sub_6A4101(
case 6:
sub_98197C(session, 77 + base_image_id, 4, 0, 1, 28, 7, height, 4, 0, height + 2);
sub_98197C(session, 78 + base_image_id, 0, 4, 28, 1, 7, height, 0, 4, height + 2);
if (!(drawnEdges & 0x20))
if (!(drawnCorners & FOOTPATH_CORNER_1))
{
sub_98197C(session, 85 + base_image_id, 0, 0, 4, 4, 7, height, 28, 28, height + 2);
}
@ -574,7 +573,7 @@ static void sub_6A4101(
case 9:
sub_98197C(session, 75 + base_image_id, 28, 0, 1, 28, 7, height, 28, 0, height + 2);
sub_98197C(session, 76 + base_image_id, 0, 28, 28, 1, 7, height, 0, 28, height + 2);
if (!(drawnEdges & 0x80))
if (!(drawnCorners & FOOTPATH_CORNER_3))
{
sub_98197C(session, 83 + base_image_id, 0, 0, 4, 4, 7, height, 0, 0, height + 2);
}
@ -584,7 +583,7 @@ static void sub_6A4101(
sub_98197C(
session, 78 + base_image_id, 0, 28, 28, 1, 7, height, 4, 28,
height + 2); // bound_box_offset_x seems to be a bug
if (!(drawnEdges & 0x40))
if (!(drawnCorners & FOOTPATH_CORNER_2))
{
sub_98197C(session, 86 + base_image_id, 0, 0, 4, 4, 7, height, 28, 0, height + 2);
}
@ -592,63 +591,63 @@ static void sub_6A4101(
case 7:
sub_98197C(session, 74 + base_image_id, 0, 4, 32, 1, 7, height, 0, 4, height + 2);
if (!(drawnEdges & 0x10))
if (!(drawnCorners & FOOTPATH_CORNER_0))
{
sub_98197C(session, 84 + base_image_id, 0, 0, 4, 4, 7, height, 0, 28, height + 2);
}
if (!(drawnEdges & 0x20))
if (!(drawnCorners & FOOTPATH_CORNER_1))
{
sub_98197C(session, 85 + base_image_id, 0, 0, 4, 4, 7, height, 28, 28, height + 2);
}
break;
case 13:
sub_98197C(session, 74 + base_image_id, 0, 28, 32, 1, 7, height, 0, 28, height + 2);
if (!(drawnEdges & 0x40))
if (!(drawnCorners & FOOTPATH_CORNER_2))
{
sub_98197C(session, 86 + base_image_id, 0, 0, 4, 4, 7, height, 28, 0, height + 2);
}
if (!(drawnEdges & 0x80))
if (!(drawnCorners & FOOTPATH_CORNER_3))
{
sub_98197C(session, 83 + base_image_id, 0, 0, 4, 4, 7, height, 0, 0, height + 2);
}
break;
case 14:
sub_98197C(session, 73 + base_image_id, 4, 0, 1, 32, 7, height, 4, 0, height + 2);
if (!(drawnEdges & 0x20))
if (!(drawnCorners & FOOTPATH_CORNER_1))
{
sub_98197C(session, 85 + base_image_id, 0, 0, 4, 4, 7, height, 28, 28, height + 2);
}
if (!(drawnEdges & 0x40))
if (!(drawnCorners & FOOTPATH_CORNER_2))
{
sub_98197C(session, 86 + base_image_id, 0, 0, 4, 4, 7, height, 28, 0, height + 2);
}
break;
case 11:
sub_98197C(session, 73 + base_image_id, 28, 0, 1, 32, 7, height, 28, 0, height + 2);
if (!(drawnEdges & 0x10))
if (!(drawnCorners & FOOTPATH_CORNER_0))
{
sub_98197C(session, 84 + base_image_id, 0, 0, 4, 4, 7, height, 0, 28, height + 2);
}
if (!(drawnEdges & 0x80))
if (!(drawnCorners & FOOTPATH_CORNER_3))
{
sub_98197C(session, 83 + base_image_id, 0, 0, 4, 4, 7, height, 0, 0, height + 2);
}
break;
case 15:
if (!(drawnEdges & 0x10))
if (!(drawnCorners & FOOTPATH_CORNER_0))
{
sub_98197C(session, 84 + base_image_id, 0, 0, 4, 4, 7, height, 0, 28, height + 2);
}
if (!(drawnEdges & 0x20))
if (!(drawnCorners & FOOTPATH_CORNER_1))
{
sub_98197C(session, 85 + base_image_id, 0, 0, 4, 4, 7, height, 28, 28, height + 2);
}
if (!(drawnEdges & 0x40))
if (!(drawnCorners & FOOTPATH_CORNER_2))
{
sub_98197C(session, 86 + base_image_id, 0, 0, 4, 4, 7, height, 28, 0, height + 2);
}
if (!(drawnEdges & 0x80))
if (!(drawnCorners & FOOTPATH_CORNER_3))
{
sub_98197C(session, 83 + base_image_id, 0, 0, 4, 4, 7, height, 0, 0, height + 2);
}

View File

@ -111,6 +111,14 @@ enum
RAISE_FOOTPATH_FLAG = (1 << 4)
};
enum
{
FOOTPATH_CORNER_0 = (1 << 0),
FOOTPATH_CORNER_1 = (1 << 1),
FOOTPATH_CORNER_2 = (1 << 2),
FOOTPATH_CORNER_3 = (1 << 3),
};
extern uint8_t gFootpathProvisionalFlags;
extern LocationXYZ16 gFootpathProvisionalPosition;
extern uint8_t gFootpathProvisionalType;