[Scummvm-cvs-logs] SF.net SVN: scummvm:[42812] scummvm/trunk/graphics
lordhoto at users.sourceforge.net
lordhoto at users.sourceforge.net
Sun Jul 26 16:16:51 CEST 2009
Revision: 42812
http://scummvm.svn.sourceforge.net/scummvm/?rev=42812&view=rev
Author: lordhoto
Date: 2009-07-26 14:16:51 +0000 (Sun, 26 Jul 2009)
Log Message:
-----------
Create base class FontSJIS16x16 for our own SJIS font.
Modified Paths:
--------------
scummvm/trunk/graphics/sjis.cpp
scummvm/trunk/graphics/sjis.h
Modified: scummvm/trunk/graphics/sjis.cpp
===================================================================
--- scummvm/trunk/graphics/sjis.cpp 2009-07-26 14:15:58 UTC (rev 42811)
+++ scummvm/trunk/graphics/sjis.cpp 2009-07-26 14:16:51 UTC (rev 42812)
@@ -30,14 +30,8 @@
namespace Graphics {
-bool FontTowns::loadFromStream(Common::ReadStream &stream) {
- for (uint i = 0; i < (kFontRomSize / 2); ++i)
- _fontData[i] = stream.readUint16BE();
- return !stream.err();
-}
-
template<typename Color>
-void FontTowns::drawCharInternOutline(const uint16 *glyph, uint8 *dst, int pitch, Color c1, Color c2) const {
+void FontSJIS16x16::drawCharInternOutline(const uint16 *glyph, uint8 *dst, int pitch, Color c1, Color c2) const {
uint32 outlineGlyph[18];
memset(outlineGlyph, 0, sizeof(outlineGlyph));
@@ -72,7 +66,7 @@
}
template<typename Color>
-void FontTowns::drawCharIntern(const uint16 *glyph, uint8 *dst, int pitch, Color c1) const {
+void FontSJIS16x16::drawCharIntern(const uint16 *glyph, uint8 *dst, int pitch, Color c1) const {
for (int y = 0; y < 16; ++y) {
Color *lineBuf = (Color *)dst;
uint16 line = *glyph++;
@@ -88,8 +82,8 @@
}
}
-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;
+void FontSJIS16x16::drawChar(void *dst, uint16 ch, int pitch, int bpp, uint32 c1, uint32 c2) const {
+ const uint16 *glyphSource = getCharData(ch);
if (bpp == 1) {
if (!_outlineEnabled)
@@ -106,7 +100,16 @@
}
}
-uint FontTowns::sjisToChunk(uint8 f, uint8 s) {
+bool FontTowns::loadFromStream(Common::ReadStream &stream) {
+ for (uint i = 0; i < (kFontRomSize / 2); ++i)
+ _fontData[i] = stream.readUint16BE();
+ return !stream.err();
+}
+
+const uint16 *FontTowns::getCharData(uint16 ch) const {
+ uint8 f = ch & 0xFF;
+ uint8 s = ch >> 8;
+
// copied from scumm\charset.cpp
enum {
KANA = 0,
@@ -188,7 +191,7 @@
}
debug(6, "Kanji: %c%c f 0x%x s 0x%x base 0x%x c %d p %d chunk %d cr %d index %d", f, s, f, s, base, c, p, chunk, cr, ((chunk_f + chunk) * 32 + (s - base)) + cr);
- return ((chunk_f + chunk) * 32 + (s - base)) + cr;
+ return _fontData + (((chunk_f + chunk) * 32 + (s - base)) + cr) * 16;
}
} // end of namespace Graphics
Modified: scummvm/trunk/graphics/sjis.h
===================================================================
--- scummvm/trunk/graphics/sjis.h 2009-07-26 14:15:58 UTC (rev 42811)
+++ scummvm/trunk/graphics/sjis.h 2009-07-26 14:16:51 UTC (rev 42812)
@@ -87,20 +87,10 @@
virtual void drawChar(void *dst, uint16 ch, int pitch, int bpp, uint32 c1, uint32 c2) const = 0;
};
-/**
- * FM-TOWNS ROM based SJIS compatible font.
- *
- * This is used in KYRA and SCI.
- */
-class FontTowns : public FontSJIS {
+class FontSJIS16x16 : public FontSJIS {
public:
- FontTowns() : _outlineEnabled(false) {}
+ FontSJIS16x16() : _outlineEnabled(false) {}
- /**
- * Loads the ROM data from the given read stream.
- */
- bool loadFromStream(Common::ReadStream &stream);
-
void enableOutline(bool enable) { _outlineEnabled = enable; }
uint getFontHeight() const { return _outlineEnabled ? 18 : 16; }
@@ -115,14 +105,32 @@
template<typename Color>
void drawCharIntern(const uint16 *glyph, uint8 *dst, int pitch, Color c1) const;
+ bool _outlineEnabled;
+protected:
+
+ virtual const uint16 *getCharData(uint16 c) const = 0;
+};
+
+/**
+ * FM-TOWNS ROM based SJIS compatible font.
+ *
+ * This is used in KYRA and SCI.
+ */
+class FontTowns : public FontSJIS16x16 {
+public:
+ /**
+ * Loads the ROM data from the given read stream.
+ */
+ bool loadFromStream(Common::ReadStream &stream);
+
+private:
enum {
kFontRomSize = 262144
};
- bool _outlineEnabled;
uint16 _fontData[kFontRomSize / 2];
- static uint sjisToChunk(uint8 low, uint8 high);
+ const uint16 *getCharData(uint16 c) const;
};
// TODO: Consider adding support for PC98 ROM
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list