1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-15 11:03:00 +01:00

Fix RCTC g1.dat rendering issues

This commit is contained in:
LRFLEW
2017-09-30 19:18:31 -05:00
committed by GitHub
parent 58b980d6ba
commit 11cdcea72b
5 changed files with 66 additions and 6 deletions

View File

@@ -36,10 +36,35 @@
using namespace OpenRCT2;
using namespace OpenRCT2::Ui;
constexpr struct
{
int start;
sint32 x_offset;
sint32 y_offset;
}
sprite_peep_pickup_starts[15] =
{
{SPR_PEEP_PICKUP_GUEST_START, 0, 15},
{SPR_PEEP_PICKUP_HANDYMAN_START, 1, 18},
{SPR_PEEP_PICKUP_MECHANIC_START, 3, 22},
{SPR_PEEP_PICKUP_GUARD_START, 3, 15},
{SPR_PEEP_PICKUP_PANDA_START, -1, 19},
{SPR_PEEP_PICKUP_TIGER_START, -1, 17},
{SPR_PEEP_PICKUP_ELEPHANT_START, -1, 17},
{SPR_PEEP_PICKUP_GORILLA_START, 0, 17},
{SPR_PEEP_PICKUP_SNOWMAN_START, -1, 16},
{SPR_PEEP_PICKUP_KNIGHT_START, -2, 17},
{SPR_PEEP_PICKUP_BANDIT_START, 0, 16},
{SPR_PEEP_PICKUP_PIRATE_START, 0, 16},
{SPR_PEEP_PICKUP_SHERIFF_START, 0, 16},
{SPR_PEEP_PICKUP_ASTRONAUT_START, 0, 16},
{SPR_PEEP_PICKUP_ROMAN_START, -1, 17},
};
static inline uint32 rctc_to_rct2_index(uint32 image)
{
if ( image < 1575) return image;
else if (image >= 1607 && image < 4983) return image - 32;
if ( image < 1542) return image;
else if (image >= 1574 && image < 4983) return image - 32;
else if (image >= 4986 && image < 17189) return image - 35;
else if (image >= 17191 && image < 18121) return image - 37;
else if (image >= 18123 && image < 23800) return image - 39;
@@ -63,7 +88,7 @@ static void read_and_convert_gxdat(IStream * stream, size_t count, bool is_rctc,
// statement skips over the elements we don't want.
switch (i)
{
case 1575:
case 1542:
rctc += 32; break;
case 23761:
case 24627:
@@ -98,6 +123,18 @@ static void read_and_convert_gxdat(IStream * stream, size_t count, bool is_rctc,
++rctc;
}
// The pincer graphic for picking up peeps is different in
// RCTC, and the sprites have different offsets to accommodate
// the change. This reverts the offsets to their RCT2 values.
for (const auto &animation : sprite_peep_pickup_starts)
{
for (int i=0; i < SPR_PEEP_PICKUP_COUNT; ++i)
{
elements[animation.start + i].x_offset -= animation.x_offset;
elements[animation.start + i].y_offset -= animation.y_offset;
}
}
}
else
{
@@ -131,6 +168,7 @@ extern "C"
#else
rct_g1_element * g1Elements = RCT2_ADDRESS(RCT2_ADDRESS_G1_ELEMENTS, rct_g1_element);
#endif
bool gTinyFontAntiAliased = false;
/**
*
@@ -156,7 +194,9 @@ extern "C"
#ifdef NO_RCT2
g1Elements = Memory::AllocateArray<rct_g1_element>(324206);
#endif
read_and_convert_gxdat(&fs, header.num_entries, header.num_entries == SPR_RCTC_G1_END, g1Elements);
bool is_rctc = header.num_entries == SPR_RCTC_G1_END;
read_and_convert_gxdat(&fs, header.num_entries, is_rctc, g1Elements);
gTinyFontAntiAliased = is_rctc;
// Read element data
_g1Buffer = fs.ReadArray<uint8>(header.total_size);

View File

@@ -281,6 +281,7 @@ extern sint32 gPickupPeepX;
extern sint32 gPickupPeepY;
extern rct_g1_element *g1Elements;
extern bool gTinyFontAntiAliased;
extern rct_drawpixelinfo gScreenDPI;
extern rct_drawpixelinfo gWindowDPI;

View File

@@ -45,7 +45,8 @@ void font_sprite_initialise_characters()
for (uint8 glyphIndex = 0; glyphIndex < FONT_SPRITE_GLYPH_COUNT; glyphIndex++) {
rct_g1_element g1 = g1Elements[glyphIndex + SPR_CHAR_START + glyphOffset];
sint32 width = fontSize == FONT_SIZE_BIG ? g1.width + 1 : g1.width - 1;
sint32 width = g1.width + 2 * g1.x_offset;
width += fontSize == FONT_SIZE_BIG ? 1 : -1;
if (glyphIndex >= (FORMAT_ARGUMENT_CODE_START - 32) && glyphIndex < (FORMAT_COLOUR_CODE_END - 32)) {
width = 0;
}

View File

@@ -68,7 +68,8 @@ void scrolling_text_initialise_bitmaps()
uint8 val = 0;
for (sint32 y = 0; y < 8; y++) {
val >>= 1;
if (dpi.bits[x + y * 8] == 1) {
uint8 pixel = dpi.bits[x + y * 8];
if (pixel == 1 || (gTinyFontAntiAliased && pixel == 2)) {
val |= 0x80;
}
}

View File

@@ -533,6 +533,23 @@ enum {
SPR_6410 = 6410,
SPR_PEEP_PICKUP_COUNT = 12,
SPR_PEEP_PICKUP_GUEST_START = 6813,
SPR_PEEP_PICKUP_HANDYMAN_START = 11289,
SPR_PEEP_PICKUP_MECHANIC_START = 11469,
SPR_PEEP_PICKUP_GUARD_START = 11909,
SPR_PEEP_PICKUP_PANDA_START = 12001,
SPR_PEEP_PICKUP_TIGER_START = 12157,
SPR_PEEP_PICKUP_ELEPHANT_START = 12353,
SPR_PEEP_PICKUP_GORILLA_START = 12665,
SPR_PEEP_PICKUP_SNOWMAN_START = 12881,
SPR_PEEP_PICKUP_KNIGHT_START = 12981,
SPR_PEEP_PICKUP_BANDIT_START = 13197,
SPR_PEEP_PICKUP_PIRATE_START = 13469,
SPR_PEEP_PICKUP_SHERIFF_START = 13701,
SPR_PEEP_PICKUP_ASTRONAUT_START = 13845,
SPR_PEEP_PICKUP_ROMAN_START = 13925,
SPR_RIDE_DESIGN_PREVIEW_SPIRAL_ROLLER_COASTER_TRACK = 14222,
SPR_RIDE_DESIGN_PREVIEW_SPIRAL_ROLLER_COASTER_SUPPORTS = 14223,
SPR_RIDE_DESIGN_PREVIEW_STAND_UP_ROLLER_COASTER_TRACK = 14224,