From 62eebc3e17f952defaa779ed1dc770570dac309d Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Tue, 7 Jul 2009 18:10:35 +0000 Subject: - Added support for outlined FM-Towns ROM drawing - Adapted KYRA to use that svn-id: r42230 --- graphics/sjis.cpp | 56 ++++++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 49 insertions(+), 7 deletions(-) (limited to 'graphics/sjis.cpp') diff --git a/graphics/sjis.cpp b/graphics/sjis.cpp index 4421a86eef..1478c1c286 100644 --- a/graphics/sjis.cpp +++ b/graphics/sjis.cpp @@ -34,9 +34,44 @@ bool FontTowns::loadFromStream(Common::ReadStream &stream) { return !stream.err(); } +template +void FontTowns::drawCharInternShadow(const uint16 *glyph, uint8 *dst, int pitch, Color c1, Color c2) const { + uint32 outlineGlyph[18]; + memset(outlineGlyph, 0, sizeof(outlineGlyph)); + + // Create an outline map including the original character + const uint16 *src = glyph; + for (int i = 0; i < 16; ++i) { + uint32 line = *src++; + line = (line << 2) | (line << 1) | (line << 0); + + outlineGlyph[i + 0] |= line; + outlineGlyph[i + 1] |= line; + outlineGlyph[i + 2] |= line; + } + + uint8 *dstLine = dst; + for (int y = 0; y < 18; ++y) { + Color *lineBuf = (Color *)dstLine; + uint32 line = outlineGlyph[y]; + + for (int x = 0; x < 18; ++x) { + if (line & 0x20000) + *lineBuf = c2; + line <<= 1; + ++lineBuf; + } + + dstLine += pitch; + } + + // draw the original char + drawCharIntern(glyph, dst + pitch + 1, pitch, c1); +} + template void FontTowns::drawCharIntern(const uint16 *glyph, uint8 *dst, int pitch, Color c1) const { - for (int y = getFontHeight(); y > 0; --y) { + for (int y = 0; y < 16; ++y) { Color *lineBuf = (Color *)dst; uint16 line = *glyph++; @@ -51,15 +86,22 @@ void FontTowns::drawCharIntern(const uint16 *glyph, uint8 *dst, int pitch, Color } } -void FontTowns::drawChar(void *dst, uint16 ch, int pitch, int bpp, uint32 c1) const { +void FontTowns::drawChar(void *dst, uint16 ch, int pitch, int bpp, uint32 c1, uint32 c2) const { const uint16 *glyphSource = _fontData + sjisToChunk(ch & 0xFF, ch >> 8) * 16; - if (bpp == 1) - drawCharIntern(glyphSource, (uint8 *)dst, pitch, c1); - else if (bpp == 2) - drawCharIntern(glyphSource, (uint8 *)dst, pitch, c1); - else + if (bpp == 1) { + if (!_shadowEnabled) + drawCharIntern(glyphSource, (uint8 *)dst, pitch, c1); + else + drawCharInternShadow(glyphSource, (uint8 *)dst, pitch, c1, c2); + } else if (bpp == 2) { + if (!_shadowEnabled) + drawCharIntern(glyphSource, (uint8 *)dst, pitch, c1); + else + drawCharInternShadow(glyphSource, (uint8 *)dst, pitch, c1, c2); + } else { error("FontTowns::drawChar: unsupported bpp: %d", bpp); + } } uint FontTowns::sjisToChunk(uint8 f, uint8 s) { -- cgit v1.2.3