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

Introduce more constants for text rendering

This commit is contained in:
Marijn van der Werf
2017-07-22 22:06:50 +02:00
parent fd459f0791
commit c01bcea391
3 changed files with 24 additions and 19 deletions

View File

@@ -32,7 +32,7 @@ typedef struct rct_draw_scroll_text {
uint16 position; // 0x0A
uint16 mode; // 0x0C
uint32 id; // 0x0E
uint8 bitmap[64 * 8 * 5]; // 0x12
uint8 bitmap[64 * 40]; // 0x12
} rct_draw_scroll_text;
assert_struct_size(rct_draw_scroll_text, 0xA12);
#pragma pack(pop)
@@ -40,7 +40,7 @@ assert_struct_size(rct_draw_scroll_text, 0xA12);
#define MAX_SCROLLING_TEXT_ENTRIES 32
static rct_draw_scroll_text _drawScrollTextList[MAX_SCROLLING_TEXT_ENTRIES];
static uint8 _characterBitmaps[224 * 8];
static uint8 _characterBitmaps[FONT_SPRITE_GLYPH_COUNT][8];
static uint32 _drawSCrollNextIndex = 0;
void scrolling_text_set_bitmap_for_sprite(utf8 *text, sint32 scroll, uint8 *bitmap, const sint16 *scrollPositionOffsets);
@@ -60,7 +60,7 @@ void scrolling_text_initialise_bitmaps()
};
for (sint32 i = 0; i < 224; i++) {
for (sint32 i = 0; i < FONT_SPRITE_GLYPH_COUNT; i++) {
memset(drawingSurface, 0, sizeof(drawingSurface));
gfx_draw_sprite_software(&dpi, SPR_CHAR_START + FONT_SPRITE_BASE_TINY + i, -1, 0, 0);
@@ -73,7 +73,7 @@ void scrolling_text_initialise_bitmaps()
val |= 0x80;
}
}
_characterBitmaps[i * 8 + x] = val;
_characterBitmaps[i][x] = val;
}
}
@@ -93,7 +93,7 @@ void scrolling_text_initialise_bitmaps()
static uint8 *font_sprite_get_codepoint_bitmap(sint32 codepoint)
{
return &_characterBitmaps[font_sprite_get_codepoint_offset(codepoint) * 8];
return _characterBitmaps[font_sprite_get_codepoint_offset(codepoint)];
}

View File

@@ -565,36 +565,36 @@ sint32 string_get_height_raw(char *buffer)
char c = *ch++;
switch (c) {
case FORMAT_NEWLINE:
if (fontBase <= 224) {
if (fontBase == FONT_SPRITE_BASE_SMALL || fontBase == FONT_SPRITE_BASE_MEDIUM) {
height += 10;
break;
} else if (fontBase == 448) {
} else if (fontBase == FONT_SPRITE_BASE_TINY) {
height += 6;
break;
}
height += 18;
break;
case FORMAT_NEWLINE_SMALLER:
if (fontBase <= 224) {
if (fontBase == FONT_SPRITE_BASE_SMALL || fontBase == FONT_SPRITE_BASE_MEDIUM) {
height += 5;
break;
} else if (fontBase == 448) {
} else if (fontBase == FONT_SPRITE_BASE_TINY) {
height += 3;
break;
}
height += 9;
break;
case FORMAT_TINYFONT:
fontBase = 448;
fontBase = FONT_SPRITE_BASE_TINY;
break;
case FORMAT_BIGFONT:
fontBase = 672;
fontBase = FONT_SPRITE_BASE_BIG;
break;
case FORMAT_MEDIUMFONT:
fontBase = 224;
fontBase = FONT_SPRITE_BASE_MEDIUM;
break;
case FORMAT_SMALLFONT:
fontBase = 0;
fontBase = FONT_SPRITE_BASE_SMALL;
break;
default:
if (c >= 32) continue;
@@ -851,8 +851,8 @@ static const utf8 *ttf_process_format_code(rct_drawpixelinfo *dpi, const utf8 *t
memcpy(info->palette + 5, &(g1Element->offset[250]), 2);
break;
}
case 3:
case 4:
case FORMAT_3:
case FORMAT_4:
nextCh++;
break;
case FORMAT_NEWLINE:
@@ -864,13 +864,13 @@ static const utf8 *ttf_process_format_code(rct_drawpixelinfo *dpi, const utf8 *t
info->y += font_get_line_height_small(info->font_sprite_base);
break;
case FORMAT_TINYFONT:
info->font_sprite_base = 448;
info->font_sprite_base = FONT_SPRITE_BASE_TINY;
break;
case FORMAT_SMALLFONT:
info->font_sprite_base = 0;
info->font_sprite_base = FONT_SPRITE_BASE_SMALL;
break;
case FORMAT_MEDIUMFONT:
info->font_sprite_base = 224;
info->font_sprite_base = FONT_SPRITE_BASE_MEDIUM;
break;
case FORMAT_BIGFONT:
info->font_sprite_base = 672;
@@ -899,7 +899,7 @@ static const utf8 *ttf_process_format_code(rct_drawpixelinfo *dpi, const utf8 *t
colour_char_window(gCurrentWindowColours[2], &flags, info->palette);
break;
}
case 0x10:
case FORMAT_16:
break;
case FORMAT_INLINE_SPRITE:
{

View File

@@ -36,6 +36,9 @@ enum {
// The next byte specifies the palette
FORMAT_ADJUST_PALETTE,
FORMAT_3,
FORMAT_4,
// Moves to the next line
FORMAT_NEWLINE = 5,
// Moves less than NEWLINE
@@ -54,6 +57,8 @@ enum {
FORMAT_WINDOW_COLOUR_2,
FORMAT_WINDOW_COLOUR_3,
FORMAT_16,
// The next 2 bytes specify the X and Y coordinates
FORMAT_NEWLINE_X_Y = 17,