sync text.c

This commit is contained in:
cawtds
2025-02-14 18:44:25 +01:00
parent 1618bfd135
commit ba946852d0
4 changed files with 539 additions and 365 deletions

View File

@@ -59,14 +59,15 @@ enum
FONTATTR_COLOR_SHADOW
};
struct GlyphInfo
struct TextGlyph
{
u8 pixels[0x80];
u32 gfxBufferTop[16];
u32 gfxBufferBottom[16];
u8 width;
u8 height;
};
extern struct GlyphInfo gGlyphInfo;
extern struct TextGlyph gCurGlyph;
struct TextPrinterSubStruct
{
@@ -160,7 +161,7 @@ u32 RenderFont(struct TextPrinter *textPrinter);
void GenerateFontHalfRowLookupTable(u8 fgColor, u8 bgColor, u8 shadowColor);
void SaveTextColors(u8 *fgColor, u8 *bgColor, u8 *shadowColor);
void RestoreTextColors(u8 *fgColor, u8 *bgColor, u8 *shadowColor);
void DecompressGlyphTile(const u16 *src, u16 *dest);
void DecompressGlyphTile(const void *src_, void *dest_);
u8 GetLastTextColor(u8 colorType);
void CopyGlyphToWindow(struct TextPrinter *x);
void ClearTextSpan(struct TextPrinter *textPrinter, u32 width);

View File

@@ -7,6 +7,7 @@
// This file handles the braille font.
// For printing braille messages, see ScrCmd_braillemessage
ALIGNED(4)
static const u8 sScrollDistances[] = {
[OPTIONS_TEXT_SPEED_SLOW] = 1,
[OPTIONS_TEXT_SPEED_MID] = 2,
@@ -135,7 +136,7 @@ u16 FontFunc_Braille(struct TextPrinter *textPrinter)
}
DecompressGlyph_Braille(char_);
CopyGlyphToWindow(textPrinter);
textPrinter->printerTemplate.currentX += gGlyphInfo.width + textPrinter->printerTemplate.letterSpacing;
textPrinter->printerTemplate.currentX += gCurGlyph.width + textPrinter->printerTemplate.letterSpacing;
return RENDER_PRINT;
case RENDER_STATE_WAIT:
if (TextPrinterWait(textPrinter))
@@ -198,12 +199,12 @@ static void DecompressGlyph_Braille(u16 glyph)
const u16 *glyphs;
glyphs = sBrailleGlyphs + 0x100 * (glyph / 8) + 0x10 * (glyph % 8);
DecompressGlyphTile(glyphs, (u16 *)gGlyphInfo.pixels);
DecompressGlyphTile(glyphs + 0x8, (u16 *)(gGlyphInfo.pixels + 0x20));
DecompressGlyphTile(glyphs + 0x80, (u16 *)(gGlyphInfo.pixels + 0x40));
DecompressGlyphTile(glyphs + 0x88, (u16 *)(gGlyphInfo.pixels + 0x60));
gGlyphInfo.width = 16;
gGlyphInfo.height = 16;
DecompressGlyphTile(glyphs, gCurGlyph.gfxBufferTop);
DecompressGlyphTile(glyphs + 0x8, gCurGlyph.gfxBufferTop + 8);
DecompressGlyphTile(glyphs + 0x80, gCurGlyph.gfxBufferBottom);
DecompressGlyphTile(glyphs + 0x88, gCurGlyph.gfxBufferBottom + 8);
gCurGlyph.width = 16;
gCurGlyph.height = 16;
}
u32 GetGlyphWidth_Braille(u16 font_type, bool32 isJapanese)

View File

@@ -402,7 +402,7 @@ void HelpSystemRenderText(u8 fontId, u8 * dest, const u8 * src, u8 x, u8 y, u8 w
return;
case CHAR_NEWLINE:
x = orig_x;
y += gGlyphInfo.height + 1;
y += gCurGlyph.height + 1;
break;
case PLACEHOLDER_BEGIN:
curChar = *src;
@@ -419,11 +419,11 @@ void HelpSystemRenderText(u8 fontId, u8 * dest, const u8 * src, u8 x, u8 y, u8 w
// This is required to match a dummy [sp+#0x24] read here
if (fontId == FONT_SMALL)
{
x += gGlyphInfo.width;
x += gCurGlyph.width;
}
else
{
x += gGlyphInfo.width + ZERO;
x += gCurGlyph.width + ZERO;
}
}
}
@@ -449,11 +449,11 @@ void HelpSystemRenderText(u8 fontId, u8 * dest, const u8 * src, u8 x, u8 y, u8 w
}
if (fontId == FONT_SMALL)
{
x += gGlyphInfo.width;
x += gCurGlyph.width;
}
else
{
x += gGlyphInfo.width + ZERO;
x += gCurGlyph.width + ZERO;
}
}
}
@@ -461,7 +461,7 @@ void HelpSystemRenderText(u8 fontId, u8 * dest, const u8 * src, u8 x, u8 y, u8 w
case CHAR_PROMPT_SCROLL:
case CHAR_PROMPT_CLEAR:
x = orig_x;
y += gGlyphInfo.height + 1;
y += gCurGlyph.height + 1;
break;
case EXT_CTRL_CODE_BEGIN:
curChar = *src;
@@ -550,11 +550,11 @@ void HelpSystemRenderText(u8 fontId, u8 * dest, const u8 * src, u8 x, u8 y, u8 w
DecompressAndRenderGlyph(fontId, curChar, &srcBlit, &destBlit, dest, x, y, width, height);
if (fontId == FONT_SMALL)
{
x += gGlyphInfo.width;
x += gCurGlyph.width;
}
else
{
x += gGlyphInfo.width + ZERO;
x += gCurGlyph.width + ZERO;
}
}
break;
@@ -570,13 +570,13 @@ void DecompressAndRenderGlyph(u8 fontId, u16 glyph, struct Bitmap *srcBlit, stru
DecompressGlyph_Female(glyph, FALSE);
else
DecompressGlyph_Normal(glyph, FALSE);
srcBlit->pixels = gGlyphInfo.pixels;
srcBlit->pixels = (u8*) gCurGlyph.gfxBufferTop;
srcBlit->width = 16;
srcBlit->height = 16;
destBlit->pixels = destBuffer;
destBlit->width = width * 8;
destBlit->height = height * 8;
BlitBitmapRect4Bit(srcBlit, destBlit, 0, 0, x, y, gGlyphInfo.width, gGlyphInfo.height, 0);
BlitBitmapRect4Bit(srcBlit, destBlit, 0, 0, x, y, gCurGlyph.width, gCurGlyph.height, 0);
}
void HelpSystem_PrintTextInTopLeftCorner(const u8 * str)

File diff suppressed because it is too large Load Diff