Start text

This commit is contained in:
Miloslav Ciz 2024-12-17 00:56:51 +01:00
parent 30c9a55cb5
commit 6d31c3c492
4 changed files with 125 additions and 0 deletions

View file

@ -31,6 +31,8 @@
#define LCR_RENDERER_MODEL_COUNT 10
#define LCR_RENDERER_CAR_SCALE (LCR_RENDERER_UNIT / 4)
#define LCR_RENDERER_FONT_SEGMENT_SIZE 4
/** For some reason the map model is a bit misaligned with physics world, this
kinda hotfixes it -- later try to discover source of this bug. TODO */
#define _LCR_MAP_MODEL_SCALE 1034
@ -112,6 +114,58 @@ void LCR_rendererSetCarTransform(LCR_GameUnit position[3],
S3L_F) / LCR_GAME_UNIT,S3L_F);
}
void _LCR_rendererDrawFontPixel(int x, int y, uint16_t color)
{
#if LCR_FONT_PIXEL_SIZE == 1
LCR_drawPixelXYSafe(x,y,color);
#else
if ((x >= 0) && (y >= 0) &&
(x < LCR_EFFECTIVE_RESOLUTION_X - LCR_FONT_PIXEL_SIZE) &&
(y < LCR_EFFECTIVE_RESOLUTION_Y - LCR_FONT_PIXEL_SIZE))
for (int i = x; i < x + LCR_FONT_PIXEL_SIZE; ++i)
for (int j = y; j < y + LCR_FONT_PIXEL_SIZE; ++j)
LCR_drawPixelXYSafe(i,j,color);
#endif
}
void LCR_rendererDrawText(const char *text, int x, int y, uint16_t color,
int size)
{
size *= LCR_RENDERER_FONT_SEGMENT_SIZE;
while (*text)
{
uint16_t c = LCR_getFontChar(*text);
for (int b = 0; b < 3; ++b) // horizontal and vertical segments
for (int a = 0; a < 2; ++a)
{
if (c & 0x01)
for (int i = 0; i < size; ++i)
_LCR_rendererDrawFontPixel(x + a * size + i,y + b * size,color);
if (c & 0x02)
for (int i = 0; i < size; ++i)
_LCR_rendererDrawFontPixel(x + b * size,y + a * size + i,color);
c >>= 2;
}
for (int b = 0; b < 2; ++b) // diagonal segments
for (int a = 0; a < 2; ++a)
{
if (c & 0x01)
for (int i = 0; i < size; ++i)
_LCR_rendererDrawFontPixel(x + a * size + i,y + b * size + i,color);
c >>= 1;
}
x += 2 * size + 3 * size / 4;
text++;
}
}
void _LCR_pixelFunc3D(S3L_PixelInfo *pixel)
{
// once we get a new triangle, we precompute things for it: