mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-15 11:03:00 +01:00
Remove code duplication in character bitmap init
This commit is contained in:
committed by
GitHub
parent
4d88cf1aee
commit
21e88a8a33
@@ -47,7 +47,7 @@ static void scrolling_text_set_bitmap_for_sprite(
|
||||
static void scrolling_text_set_bitmap_for_ttf(
|
||||
std::string_view text, int32_t scroll, uint8_t* bitmap, const int16_t* scrollPositionOffsets, colour_t colour);
|
||||
|
||||
void scrolling_text_initialise_bitmaps()
|
||||
static void ScrollingTextInitialiseCharacterBitmaps(uint32_t glyphStart, uint16_t offset, uint16_t count, bool isAntiAliased)
|
||||
{
|
||||
uint8_t drawingSurface[64];
|
||||
rct_drawpixelinfo dpi;
|
||||
@@ -55,11 +55,10 @@ void scrolling_text_initialise_bitmaps()
|
||||
dpi.width = 8;
|
||||
dpi.height = 8;
|
||||
|
||||
for (int32_t i = 0; i < FONT_SPRITE_GLYPH_COUNT; i++)
|
||||
for (int32_t i = 0; i < count; i++)
|
||||
{
|
||||
std::fill_n(drawingSurface, sizeof(drawingSurface), 0x00);
|
||||
gfx_draw_sprite_software(
|
||||
&dpi, ImageId(SPR_CHAR_START + (EnumValue(FontStyle::Tiny) * FONT_SPRITE_GLYPH_COUNT) + i), { -1, 0 });
|
||||
gfx_draw_sprite_software(&dpi, ImageId(glyphStart + (EnumValue(FontStyle::Tiny) * count) + i), { -1, 0 });
|
||||
|
||||
for (int32_t x = 0; x < 8; x++)
|
||||
{
|
||||
@@ -68,37 +67,18 @@ void scrolling_text_initialise_bitmaps()
|
||||
{
|
||||
val >>= 1;
|
||||
uint8_t pixel = dpi.bits[x + y * 8];
|
||||
if (pixel == 1 || (gTinyFontAntiAliased && pixel == 2))
|
||||
if (pixel == 1 || (isAntiAliased && pixel == 2))
|
||||
{
|
||||
val |= 0x80;
|
||||
}
|
||||
}
|
||||
_characterBitmaps[i][x] = val;
|
||||
}
|
||||
}
|
||||
|
||||
for (int32_t i = 0; i < SPR_G2_GLYPH_COUNT; i++)
|
||||
{
|
||||
std::fill_n(drawingSurface, sizeof(drawingSurface), 0x00);
|
||||
gfx_draw_sprite_software(
|
||||
&dpi, ImageId(SPR_G2_CHAR_BEGIN + (EnumValue(FontStyle::Tiny) * SPR_G2_GLYPH_COUNT) + i), { -1, 0 });
|
||||
|
||||
for (int32_t x = 0; x < 8; x++)
|
||||
{
|
||||
uint8_t val = 0;
|
||||
for (int32_t y = 0; y < 8; y++)
|
||||
{
|
||||
val >>= 1;
|
||||
uint8_t pixel = dpi.bits[x + y * 8];
|
||||
if (pixel == 1 || (gTinyFontAntiAliased && pixel == 2))
|
||||
{
|
||||
val |= 0x80;
|
||||
}
|
||||
}
|
||||
_characterBitmaps[FONT_SPRITE_GLYPH_COUNT + i][x] = val;
|
||||
_characterBitmaps[offset + i][x] = val;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
static void ScrollingTextInitialiseScrollingText()
|
||||
{
|
||||
for (int32_t i = 0; i < OpenRCT2::MaxScrollingTextEntries; i++)
|
||||
{
|
||||
const int32_t imageId = SPR_SCROLLING_TEXT_START + i;
|
||||
@@ -122,6 +102,13 @@ void scrolling_text_initialise_bitmaps()
|
||||
}
|
||||
}
|
||||
|
||||
void scrolling_text_initialise_bitmaps()
|
||||
{
|
||||
ScrollingTextInitialiseCharacterBitmaps(SPR_CHAR_START, 0, FONT_SPRITE_GLYPH_COUNT, gTinyFontAntiAliased);
|
||||
ScrollingTextInitialiseCharacterBitmaps(SPR_G2_CHAR_BEGIN, FONT_SPRITE_GLYPH_COUNT, SPR_G2_GLYPH_COUNT, false);
|
||||
ScrollingTextInitialiseScrollingText();
|
||||
}
|
||||
|
||||
static uint8_t* font_sprite_get_codepoint_bitmap(int32_t codepoint)
|
||||
{
|
||||
auto offset = font_sprite_get_codepoint_offset(codepoint);
|
||||
|
||||
Reference in New Issue
Block a user