From 862308166645a5f7b5422473b434f0a8ec86d7b2 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Tue, 7 Jul 2009 14:22:23 +0000 Subject: Add generic functionallity to draw FM-Towns ROM. (To be used by KYRA and SCI) svn-id: r42221 --- graphics/sjis.h | 108 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 108 insertions(+) create mode 100644 graphics/sjis.h (limited to 'graphics/sjis.h') diff --git a/graphics/sjis.h b/graphics/sjis.h new file mode 100644 index 0000000000..f6277b62a4 --- /dev/null +++ b/graphics/sjis.h @@ -0,0 +1,108 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * $URL$ + * $Id$ + */ + +#ifndef GRAPHICS_SJIS_H +#define GRAPHICS_SJIS_H + +#include "common/scummsys.h" +#include "common/stream.h" + +#include "graphics/surface.h" + +namespace Graphics { + +/** + * A font that is able to draw SJIS encoded characters. + * + * The font is always monospaced. + */ +class FontSJIS { +public: + virtual ~FontSJIS() {} + + /** + * Returns the height of the font. + */ + virtual uint getFontHeight() const = 0; + + /** + * Returns the width of the font. + */ + virtual uint getFontWidth() const = 0; + + /** + * Draws a SJIS encoded character on the given surface. + */ + void drawChar(Graphics::Surface &dst, uint16 ch, int x, int y, uint32 c1) const { + drawChar(dst.getBasePtr(x, y), ch, c1, dst.pitch, dst.bytesPerPixel); + } + + /** + * Draws a SJIS char on the given raw buffer. + * + * @param dst pointer to the destination + * @param ch character to draw + * @param pitch pitch of the destination buffer (size in *bytes*) + * @param bpp bytes per pixel of the destination buffer + * @param c1 forground color + */ + virtual void drawChar(void *dst, uint16 ch, int pitch, int bpp, uint32 c1) const = 0; +}; + +/** + * FM-Towns ROM based SJIS compatible font. + * + * This is used in KYRA and SCI. + */ +class FontTowns : public FontSJIS { +public: + /** + * Loads the ROM data from the given read stream. + */ + bool loadFromStream(Common::ReadStream &stream); + + uint getFontHeight() const { return 16; } + uint getFontWidth() const { return 16; } + + void drawChar(void *dst, uint16 ch, int pitch, int bpp, uint32 c1) const; + +private: + template + void drawCharIntern(const uint16 *glyph, uint8 *dst, int pitch, Color c1) const; + + enum { + kFontRomSize = 262144 + }; + + uint16 _fontData[kFontRomSize / 2]; + + static uint sjisToChunk(uint8 low, uint8 high); +}; + +// TODO: Consider adding support for PC98 ROM + +} // end of namespace Graphics + +#endif + -- cgit v1.2.3 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.h | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) (limited to 'graphics/sjis.h') diff --git a/graphics/sjis.h b/graphics/sjis.h index f6277b62a4..63013dccf1 100644 --- a/graphics/sjis.h +++ b/graphics/sjis.h @@ -41,6 +41,14 @@ class FontSJIS { public: virtual ~FontSJIS() {} + /** + * Enable shadow drawing. + * + * After changing shadow state, getFontHeight and getFontWidth might return + * different values! + */ + virtual void enableShadow(bool enable) {} + /** * Returns the height of the font. */ @@ -54,8 +62,8 @@ public: /** * Draws a SJIS encoded character on the given surface. */ - void drawChar(Graphics::Surface &dst, uint16 ch, int x, int y, uint32 c1) const { - drawChar(dst.getBasePtr(x, y), ch, c1, dst.pitch, dst.bytesPerPixel); + void drawChar(Graphics::Surface &dst, uint16 ch, int x, int y, uint32 c1, uint32 c2) const { + drawChar(dst.getBasePtr(x, y), ch, c1, c2, dst.pitch, dst.bytesPerPixel); } /** @@ -66,8 +74,9 @@ public: * @param pitch pitch of the destination buffer (size in *bytes*) * @param bpp bytes per pixel of the destination buffer * @param c1 forground color + * @param c2 shadow/outline color */ - virtual void drawChar(void *dst, uint16 ch, int pitch, int bpp, uint32 c1) const = 0; + virtual void drawChar(void *dst, uint16 ch, int pitch, int bpp, uint32 c1, uint32 c2) const = 0; }; /** @@ -82,12 +91,17 @@ public: */ bool loadFromStream(Common::ReadStream &stream); - uint getFontHeight() const { return 16; } - uint getFontWidth() const { return 16; } + void enableShadow(bool enable) { _shadowEnabled = enable; } - void drawChar(void *dst, uint16 ch, int pitch, int bpp, uint32 c1) const; + uint getFontHeight() const { return _shadowEnabled ? 18 : 16; } + uint getFontWidth() const { return _shadowEnabled ? 18 : 16; } + + void drawChar(void *dst, uint16 ch, int pitch, int bpp, uint32 c1, uint32 c2) const; private: + template + void drawCharInternShadow(const uint16 *glyph, uint8 *dst, int pitch, Color c1, Color c2) const; + template void drawCharIntern(const uint16 *glyph, uint8 *dst, int pitch, Color c1) const; @@ -95,6 +109,7 @@ private: kFontRomSize = 262144 }; + bool _shadowEnabled; uint16 _fontData[kFontRomSize / 2]; static uint sjisToChunk(uint8 low, uint8 high); -- cgit v1.2.3 From 8c65d4d4a94f5a0330b1c86f6378ffada20dd1be Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Tue, 7 Jul 2009 18:17:30 +0000 Subject: - Rename FontSJIS::enableShadow to enableOutline. - Initialize outline to false by default in FontTowns. svn-id: r42231 --- graphics/sjis.h | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'graphics/sjis.h') diff --git a/graphics/sjis.h b/graphics/sjis.h index 63013dccf1..9a20670bf3 100644 --- a/graphics/sjis.h +++ b/graphics/sjis.h @@ -42,12 +42,12 @@ public: virtual ~FontSJIS() {} /** - * Enable shadow drawing. + * Enable outline drawing. * - * After changing shadow state, getFontHeight and getFontWidth might return + * After changing outline state, getFontHeight and getFontWidth might return * different values! */ - virtual void enableShadow(bool enable) {} + virtual void enableOutline(bool enable) {} /** * Returns the height of the font. @@ -74,7 +74,7 @@ public: * @param pitch pitch of the destination buffer (size in *bytes*) * @param bpp bytes per pixel of the destination buffer * @param c1 forground color - * @param c2 shadow/outline color + * @param c2 outline color */ virtual void drawChar(void *dst, uint16 ch, int pitch, int bpp, uint32 c1, uint32 c2) const = 0; }; @@ -86,21 +86,23 @@ public: */ class FontTowns : public FontSJIS { public: + FontTowns() : _outlineEnabled(false) {} + /** * Loads the ROM data from the given read stream. */ bool loadFromStream(Common::ReadStream &stream); - void enableShadow(bool enable) { _shadowEnabled = enable; } + void enableOutline(bool enable) { _outlineEnabled = enable; } - uint getFontHeight() const { return _shadowEnabled ? 18 : 16; } - uint getFontWidth() const { return _shadowEnabled ? 18 : 16; } + uint getFontHeight() const { return _outlineEnabled ? 18 : 16; } + uint getFontWidth() const { return _outlineEnabled ? 18 : 16; } void drawChar(void *dst, uint16 ch, int pitch, int bpp, uint32 c1, uint32 c2) const; private: template - void drawCharInternShadow(const uint16 *glyph, uint8 *dst, int pitch, Color c1, Color c2) const; + void drawCharInternOutline(const uint16 *glyph, uint8 *dst, int pitch, Color c1, Color c2) const; template void drawCharIntern(const uint16 *glyph, uint8 *dst, int pitch, Color c1) const; @@ -109,7 +111,7 @@ private: kFontRomSize = 262144 }; - bool _shadowEnabled; + bool _outlineEnabled; uint16 _fontData[kFontRomSize / 2]; static uint sjisToChunk(uint8 low, uint8 high); -- cgit v1.2.3 From e35dd4df1c1f84e29210a4ce263d4b85ea4caf53 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Tue, 7 Jul 2009 19:00:39 +0000 Subject: Change "FM-Towns" to "FM-TOWNS" for consistency. svn-id: r42232 --- graphics/sjis.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'graphics/sjis.h') diff --git a/graphics/sjis.h b/graphics/sjis.h index 9a20670bf3..c7eeeed9f6 100644 --- a/graphics/sjis.h +++ b/graphics/sjis.h @@ -80,7 +80,7 @@ public: }; /** - * FM-Towns ROM based SJIS compatible font. + * FM-TOWNS ROM based SJIS compatible font. * * This is used in KYRA and SCI. */ -- cgit v1.2.3 From 2a117d9a90df395a388919d2734024d19f24b8f3 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Tue, 7 Jul 2009 19:00:51 +0000 Subject: Add guards to only include SJIS font code, when KYRA or SCI is enabled. svn-id: r42233 --- graphics/sjis.h | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'graphics/sjis.h') diff --git a/graphics/sjis.h b/graphics/sjis.h index c7eeeed9f6..ca5fc95004 100644 --- a/graphics/sjis.h +++ b/graphics/sjis.h @@ -22,6 +22,12 @@ * $Id$ */ +// The code in this files is currently only used in KYRA and SCI. +// So if no of those is enabled, we will not compile it. +// If you plan to use this code in another engine, you will have +// to add the proper defined check here and in sjis.cpp +#if defined(ENABLE_KYRA) || defined(ENABLE_SCI) + #ifndef GRAPHICS_SJIS_H #define GRAPHICS_SJIS_H @@ -123,3 +129,5 @@ private: #endif +#endif // defined(ENABLE_KYRA) || defined(ENABLE_SCI) + -- cgit v1.2.3 From 832540f64f6f0c9a77029fce17d4f06516c688ef Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Tue, 7 Jul 2009 19:18:32 +0000 Subject: Simply compile guard of SJIS code and fix comment. svn-id: r42234 --- graphics/sjis.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'graphics/sjis.h') diff --git a/graphics/sjis.h b/graphics/sjis.h index ca5fc95004..f7321742af 100644 --- a/graphics/sjis.h +++ b/graphics/sjis.h @@ -22,10 +22,12 @@ * $Id$ */ -// The code in this files is currently only used in KYRA and SCI. -// So if no of those is enabled, we will not compile it. +// The code in this file is currently only used in KYRA and SCI. +// So if neither of those is enabled, we will skip compiling it. // If you plan to use this code in another engine, you will have -// to add the proper defined check here and in sjis.cpp +// to add the proper define check here. +// Also please add the define check at the comment after the +// matching #endif further down this file. #if defined(ENABLE_KYRA) || defined(ENABLE_SCI) #ifndef GRAPHICS_SJIS_H -- cgit v1.2.3