aboutsummaryrefslogtreecommitdiff
path: root/graphics/sjis.h
diff options
context:
space:
mode:
authorWillem Jan Palenstijn2013-04-18 23:34:29 +0200
committerWillem Jan Palenstijn2013-05-08 20:39:44 +0200
commit01f3f3a8dd0ad2891939d03b0ce47cbf36ea9bc6 (patch)
tree544b07f3aa41abe7907bcd2040cdad11ebc324bb /graphics/sjis.h
parent9cf2c83e5e5a35816ab153bf8443dac691829ea8 (diff)
parenta41d72a44a660c72fdadbc3a8ef580e5e03cb890 (diff)
downloadscummvm-rg350-01f3f3a8dd0ad2891939d03b0ce47cbf36ea9bc6.tar.gz
scummvm-rg350-01f3f3a8dd0ad2891939d03b0ce47cbf36ea9bc6.tar.bz2
scummvm-rg350-01f3f3a8dd0ad2891939d03b0ce47cbf36ea9bc6.zip
Merge branch 'master'
Diffstat (limited to 'graphics/sjis.h')
-rw-r--r--graphics/sjis.h101
1 files changed, 77 insertions, 24 deletions
diff --git a/graphics/sjis.h b/graphics/sjis.h
index 0c3b057cc4..f96eef6ad1 100644
--- a/graphics/sjis.h
+++ b/graphics/sjis.h
@@ -75,7 +75,7 @@ public:
virtual bool loadData() = 0;
/**
- * Enable drawing with outline or shadow.
+ * Enable drawing with outline or shadow if supported by the Font.
*
* After changing outline state, getFontHeight and getMaxFontWidth / getCharWidth might return
* different values!
@@ -90,11 +90,17 @@ public:
virtual void setDrawingMode(DrawingMode mode) {}
/**
- * Enable flipped character drawing (e.g. in the MI1 circus scene after Guybrush gets shot out of the cannon).
+ * Enable flipped character drawing if supported by the Font (e.g. in the MI1 circus scene after Guybrush gets shot out of the cannon).
*/
virtual void toggleFlippedMode(bool enable) {}
/**
+ * Set spacing between characters and lines. This affects font height / char width
+ */
+ virtual void setCharSpacing(int spacing) {}
+ virtual void setLineSpacing(int spacing) {}
+
+ /**
* Returns the height of the font.
*/
virtual uint getFontHeight() const = 0;
@@ -123,30 +129,30 @@ public:
* @param bpp bytes per pixel of the destination buffer
* @param c1 forground color
* @param c2 outline color
- * @param maxW max draw width (to ensure that character drawing takes place within surface boundaries)
- * @param maxH max draw height (to ensure that character drawing takes place within surface boundaries)
+ * @param maxW max draw width (to ensure that character drawing takes place within surface boundaries), -1 = no check
+ * @param maxH max draw height (to ensure that character drawing takes place within surface boundaries), -1 = no check
*/
- virtual void drawChar(void *dst, uint16 ch, int pitch, int bpp, uint32 c1, uint32 c2, int maxW = -1, int maxH = -1) const = 0;
+ virtual void drawChar(void *dst, uint16 ch, int pitch, int bpp, uint32 c1, uint32 c2, int maxW, int maxH) const = 0;
};
/**
- * A base class to render 16x16 (2 byte chars), 8x16 (1 byte chars) monochrome SJIS fonts.
+ * A base class to render monochrome SJIS fonts.
*/
class FontSJISBase : public FontSJIS {
public:
- FontSJISBase() : _drawMode(kDefaultMode), _flippedMode(false) {}
+ FontSJISBase();
- void setDrawingMode(DrawingMode mode) { _drawMode = mode; }
+ virtual void setDrawingMode(DrawingMode mode);
- void toggleFlippedMode(bool enable) { _flippedMode = enable; }
+ virtual void toggleFlippedMode(bool enable);
- uint getFontHeight() const { return (_drawMode == kOutlineMode) ? 18 : (_drawMode == kDefaultMode ? 16 : 17); }
+ virtual uint getFontHeight() const;
- uint getMaxFontWidth() const { return (_drawMode == kOutlineMode) ? 18 : (_drawMode == kDefaultMode ? 16 : 17); }
+ virtual uint getMaxFontWidth() const;
- uint getCharWidth(uint16 ch) const;
+ virtual uint getCharWidth(uint16 ch) const;
- void drawChar(void *dst, uint16 ch, int pitch, int bpp, uint32 c1, uint32 c2, int maxW = -1, int maxH = -1) const;
+ virtual void drawChar(void *dst, uint16 ch, int pitch, int bpp, uint32 c1, uint32 c2, int maxW, int maxH) const;
private:
template<typename Color>
void blitCharacter(const uint8 *glyph, const int w, const int h, uint8 *dst, int pitch, Color c) const;
@@ -161,17 +167,28 @@ private:
protected:
DrawingMode _drawMode;
bool _flippedMode;
-
- bool is8x16(uint16 ch) const;
+ int _fontWidth, _fontHeight;
+ uint8 _bitPosNewLineMask;
+
+ bool isASCII(uint16 ch) const;
virtual const uint8 *getCharData(uint16 c) const = 0;
- virtual const uint8 *getCharData8x16(uint16 c) const = 0;
+
+ enum DrawingFeature {
+ kFeatDefault = 1 << 0,
+ kFeatOutline = 1 << 1,
+ kFeatShadow = 1 << 2,
+ kFeatFMTownsShadow = 1 << 3,
+ kFeatFlipped = 1 << 4
+ };
+
+ virtual bool hasFeature(int feat) const = 0;
};
/**
* FM-TOWNS ROM based SJIS compatible font.
*
- * This is used in KYRA and SCI.
+ * This is used in KYRA, SCUMM and SCI.
*/
class FontTowns : public FontSJISBase {
public:
@@ -188,8 +205,32 @@ private:
uint8 _fontData16x16[kFont16x16Chars * 32];
uint8 _fontData8x16[kFont8x16Chars * 32];
- const uint8 *getCharData(uint16 c) const;
- const uint8 *getCharData8x16(uint16 c) const;
+ virtual const uint8 *getCharData(uint16 c) const;
+
+ bool hasFeature(int feat) const;
+};
+
+/**
+ * PC-Engine System Card based SJIS compatible font.
+ *
+ * This is used in LOOM.
+ */
+class FontPCEngine : public FontSJISBase {
+public:
+ /**
+ * Loads the ROM data from "pce.cdbios".
+ */
+ bool loadData();
+private:
+ enum {
+ kFont12x12Chars = 3418
+ };
+
+ uint8 _fontData12x12[kFont12x12Chars * 18];
+
+ virtual const uint8 *getCharData(uint16 c) const;
+
+ bool hasFeature(int feat) const;
};
/**
@@ -197,8 +238,8 @@ private:
*/
class FontSjisSVM : public FontSJISBase {
public:
- FontSjisSVM() : _fontData16x16(0), _fontData16x16Size(0), _fontData8x16(0), _fontData8x16Size(0) {}
- ~FontSjisSVM() { delete[] _fontData16x16; delete[] _fontData8x16; }
+ FontSjisSVM(const Common::Platform platform);
+ ~FontSjisSVM();
/**
* Load the font data from "SJIS.FNT".
@@ -211,8 +252,21 @@ private:
uint8 *_fontData8x16;
uint _fontData8x16Size;
- const uint8 *getCharData(uint16 c) const;
- const uint8 *getCharData8x16(uint16 c) const;
+ uint8 *_fontData12x12;
+ uint _fontData12x12Size;
+
+ virtual const uint8 *getCharData(uint16 c) const;
+
+ bool hasFeature(int feat) const;
+
+ const uint8 *getCharDataPCE(uint16 c) const;
+ const uint8 *getCharDataDefault(uint16 c) const;
+
+ void mapKANJIChar(const uint8 fB, const uint8 sB, int &base, int &index) const;
+
+ enum {
+ kSjisFontVersion = 3
+ };
};
// TODO: Consider adding support for PC98 ROM
@@ -222,4 +276,3 @@ private:
#endif
#endif // engine and dynamic plugins guard
-