ResidualVM logo ResidualVM website - Forums - Contact us BuildBot - Doxygen - Wiki curved edge

sjis.h

Go to the documentation of this file.
00001 /* ScummVM - Graphic Adventure Engine
00002  *
00003  * ScummVM is the legal property of its developers, whose names
00004  * are too numerous to list here. Please refer to the COPYRIGHT
00005  * file distributed with this source distribution.
00006  *
00007  * This program is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU General Public License
00009  * as published by the Free Software Foundation; either version 2
00010  * of the License, or (at your option) any later version.
00011  *
00012  * This program is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU General Public License
00018  * along with this program; if not, write to the Free Software
00019  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00020  *
00021  */
00022 
00023 // The code in this file is currently only used in KYRA and SCI.
00024 // So if neither of those is enabled, we will skip compiling it.
00025 // We also enable this code for ScummVM builds including support
00026 // for dynamic engine plugins.
00027 // If you plan to use this code in another engine, you will have
00028 // to add the proper define check here.
00029 #if !(defined(ENABLE_KYRA) || defined(ENABLE_SCI) || defined(ENABLE_SCUMM) || defined(DYNAMIC_MODULES))
00030 
00031 // If neither of the above mentioned is enabled, do not include the SJIS code.
00032 
00033 #else
00034 
00035 #ifndef GRAPHICS_SJIS_H
00036 #define GRAPHICS_SJIS_H
00037 
00038 #ifdef __DS__
00039 /* This disables the flipped mode which is used in FM-Towns versions
00040  * of Monkey Island 1 (and maybe other SCUMM 5 games). These are not supported
00041  * on the DS, so it makes sense to have a corresponding setting here.
00042  */
00043 #define DISABLE_FLIPPED_MODE
00044 #endif
00045 
00046 #include "common/scummsys.h"
00047 #include "common/platform.h"
00048 
00049 namespace Graphics {
00050 
00051 struct Surface;
00052 
00056 class FontSJIS {
00057 public:
00058     virtual ~FontSJIS() {}
00059 
00071     static FontSJIS *createFont(const Common::Platform platform = Common::kPlatformUnknown);
00072 
00076     virtual bool loadData() = 0;
00077 
00084     enum DrawingMode {
00085         kDefaultMode,
00086         kOutlineMode,
00087         kShadowMode,
00088         kFMTownsShadowMode
00089     };
00090 
00091     virtual void setDrawingMode(DrawingMode mode) {}
00092 
00096     virtual void toggleFatPrint(bool enable) {}
00097 
00101     virtual void toggleFlippedMode(bool enable) {}
00102 
00106     virtual void setCharSpacing(int spacing) {}
00107     virtual void setLineSpacing(int spacing) {}
00108 
00112     virtual uint getFontHeight() const = 0;
00113 
00117     virtual uint getMaxFontWidth() const = 0;
00118 
00122     virtual uint getCharWidth(uint16 ch) const = 0;
00123 
00127     void drawChar(Graphics::Surface &dst, uint16 ch, int x, int y, uint32 c1, uint32 c2) const;
00128 
00141     virtual void drawChar(void *dst, uint16 ch, int pitch, int bpp, uint32 c1, uint32 c2, int maxW, int maxH) const = 0;
00142 };
00143 
00147 class FontSJISBase : public FontSJIS {
00148 public:
00149     FontSJISBase();
00150 
00151     virtual void setDrawingMode(DrawingMode mode);
00152 
00153     virtual void toggleFlippedMode(bool enable);
00154 
00155     virtual void toggleFatPrint(bool enable);
00156 
00157     virtual uint getFontHeight() const;
00158 
00159     virtual uint getMaxFontWidth() const;
00160 
00161     virtual uint getCharWidth(uint16 ch) const;
00162 
00163     virtual void drawChar(void *dst, uint16 ch, int pitch, int bpp, uint32 c1, uint32 c2, int maxW, int maxH) const;
00164 private:
00165     template<typename Color>
00166     void blitCharacter(const uint8 *glyph, const int w, const int h, uint8 *dst, int pitch, Color c) const;
00167     void createOutline(uint8 *outline, const uint8 *glyph, const int w, const int h) const;
00168 
00169 #ifndef DISABLE_FLIPPED_MODE
00170     // This is used in the FM-Towns version of Monkey Island 1
00171     // when Guybrush gets shot out of the cannon in the circus tent.
00172     const uint8 *flipCharacter(const uint8 *glyph, const int w) const;
00173     mutable uint8 _tempGlyph[32];
00174 #endif
00175     const uint8 *makeFatCharacter(const uint8 *glyph, const int w) const;
00176     mutable uint8 _tempGlyph2[32];
00177 protected:
00178     DrawingMode _drawMode;
00179     bool _flippedMode, _fatPrint;
00180     int _fontWidth, _fontHeight;
00181     uint8 _bitPosNewLineMask;
00182 
00183     bool isASCII(uint16 ch) const;
00184 
00185     virtual const uint8 *getCharData(uint16 c) const = 0;
00186 
00187     enum DrawingFeature {
00188         kFeatDefault        = 1 << 0,
00189         kFeatOutline        = 1 << 1,
00190         kFeatShadow         = 1 << 2,
00191         kFeatFMTownsShadow  = 1 << 3,
00192         kFeatFlipped        = 1 << 4,
00193         kFeatFatPrint       = 1 << 5
00194     };
00195 
00196     virtual bool hasFeature(int feat) const = 0;
00197 };
00198 
00204 class FontTowns : public FontSJISBase {
00205 public:
00209     bool loadData();
00210 private:
00211     enum {
00212         kFont16x16Chars = 7808,
00213         kFont8x16Chars = 256
00214     };
00215 
00216     uint8 _fontData16x16[kFont16x16Chars * 32];
00217     uint8 _fontData8x16[kFont8x16Chars * 32];
00218 
00219     virtual const uint8 *getCharData(uint16 c) const;
00220 
00221     bool hasFeature(int feat) const;
00222 };
00223 
00229 class FontPCEngine : public FontSJISBase {
00230 public:
00234     bool loadData();
00235 private:
00236     enum {
00237         kFont12x12Chars = 3418
00238     };
00239 
00240     uint8 _fontData12x12[kFont12x12Chars * 18];
00241 
00242     virtual const uint8 *getCharData(uint16 c) const;
00243 
00244     bool hasFeature(int feat) const;
00245 };
00246 
00250 class FontSjisSVM : public FontSJISBase {
00251 public:
00252     FontSjisSVM(const Common::Platform platform);
00253     ~FontSjisSVM();
00254 
00258     bool loadData();
00259 private:
00260     uint8 *_fontData16x16;
00261     uint _fontData16x16Size;
00262 
00263     uint8 *_fontData8x16;
00264     uint _fontData8x16Size;
00265 
00266     uint8 *_fontData12x12;
00267     uint _fontData12x12Size;
00268 
00269     virtual const uint8 *getCharData(uint16 c) const;
00270 
00271     bool hasFeature(int feat) const;
00272 
00273     const uint8 *getCharDataPCE(uint16 c) const;
00274     const uint8 *getCharDataDefault(uint16 c) const;
00275 
00276     void mapKANJIChar(const uint8 fB, const uint8 sB, int &base, int &index) const;
00277 
00278     enum {
00279         kSjisFontVersion = 3
00280     };
00281 };
00282 
00283 // TODO: Consider adding support for PC98 ROM
00284 
00285 } // End of namespace Graphics
00286 
00287 #endif
00288 
00289 #endif // engine and dynamic plugins guard


Generated on Sat Nov 16 2019 05:00:45 for ResidualVM by doxygen 1.7.1
curved edge   curved edge