aboutsummaryrefslogtreecommitdiff
path: root/graphics
diff options
context:
space:
mode:
authorJohannes Schickel2009-07-26 14:16:51 +0000
committerJohannes Schickel2009-07-26 14:16:51 +0000
commit712e0c80eaef79870a302749ae3e91c637088f81 (patch)
tree0305d5046b14e4abbcdf8ec0cd8fcbda130494f5 /graphics
parent997f7b9a3b261b263c70f36e262849058b65d54f (diff)
downloadscummvm-rg350-712e0c80eaef79870a302749ae3e91c637088f81.tar.gz
scummvm-rg350-712e0c80eaef79870a302749ae3e91c637088f81.tar.bz2
scummvm-rg350-712e0c80eaef79870a302749ae3e91c637088f81.zip
Create base class FontSJIS16x16 for our own SJIS font.
svn-id: r42812
Diffstat (limited to 'graphics')
-rw-r--r--graphics/sjis.cpp27
-rw-r--r--graphics/sjis.h36
2 files changed, 37 insertions, 26 deletions
diff --git a/graphics/sjis.cpp b/graphics/sjis.cpp
index 5392a1c9a4..6f8979bc6e 100644
--- a/graphics/sjis.cpp
+++ b/graphics/sjis.cpp
@@ -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 @@ void FontTowns::drawCharInternOutline(const uint16 *glyph, uint8 *dst, int pitch
}
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::drawCharIntern(const uint16 *glyph, uint8 *dst, int pitch, Color
}
}
-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 @@ void FontTowns::drawChar(void *dst, uint16 ch, int pitch, int bpp, uint32 c1, ui
}
}
-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 @@ uint FontTowns::sjisToChunk(uint8 f, uint8 s) {
}
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
diff --git a/graphics/sjis.h b/graphics/sjis.h
index f7321742af..954f673f54 100644
--- a/graphics/sjis.h
+++ b/graphics/sjis.h
@@ -87,19 +87,9 @@ public:
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) {}
-
- /**
- * Loads the ROM data from the given read stream.
- */
- bool loadFromStream(Common::ReadStream &stream);
+ FontSJIS16x16() : _outlineEnabled(false) {}
void enableOutline(bool enable) { _outlineEnabled = enable; }
@@ -115,14 +105,32 @@ private:
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