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         kShadowRightMode,
00088         kShadowLeftMode,
00089         kFMTownsShadowMode
00090     };
00091 
00092     virtual void setDrawingMode(DrawingMode mode) {}
00093 
00097     virtual void toggleFatPrint(bool enable) {}
00098 
00102     virtual void toggleFlippedMode(bool enable) {}
00103 
00107     virtual void setCharSpacing(int spacing) {}
00108     virtual void setLineSpacing(int spacing) {}
00109 
00113     virtual uint getFontHeight() const = 0;
00114 
00118     virtual uint getMaxFontWidth() const = 0;
00119 
00123     virtual uint getCharWidth(uint16 ch) const = 0;
00124 
00128     void drawChar(Graphics::Surface &dst, uint16 ch, int x, int y, uint32 c1, uint32 c2) const;
00129 
00142     virtual void drawChar(void *dst, uint16 ch, int pitch, int bpp, uint32 c1, uint32 c2, int maxW, int maxH) const = 0;
00143 };
00144 
00148 class FontSJISBase : public FontSJIS {
00149 public:
00150     FontSJISBase();
00151 
00152     virtual void setDrawingMode(DrawingMode mode);
00153 
00154     virtual void toggleFlippedMode(bool enable);
00155 
00156     virtual void toggleFatPrint(bool enable);
00157 
00158     virtual uint getFontHeight() const;
00159 
00160     virtual uint getMaxFontWidth() const;
00161 
00162     virtual uint getCharWidth(uint16 ch) const;
00163 
00164     virtual void drawChar(void *dst, uint16 ch, int pitch, int bpp, uint32 c1, uint32 c2, int maxW, int maxH) const;
00165 private:
00166     template<typename Color>
00167     void blitCharacter(const uint8 *glyph, const int w, const int h, uint8 *dst, int pitch, Color c) const;
00168     void createOutline(uint8 *outline, const uint8 *glyph, const int w, const int h) const;
00169 
00170 #ifndef DISABLE_FLIPPED_MODE
00171     // This is used in the FM-Towns version of Monkey Island 1
00172     // when Guybrush gets shot out of the cannon in the circus tent.
00173     const uint8 *flipCharacter(const uint8 *glyph, const int w) const;
00174     mutable uint8 _tempGlyph[32];
00175 #endif
00176     const uint8 *makeFatCharacter(const uint8 *glyph, const int w) const;
00177     mutable uint8 _tempGlyph2[32];
00178 protected:
00179     DrawingMode _drawMode;
00180     bool _flippedMode, _fatPrint;
00181     int _fontWidth, _fontHeight;
00182     uint8 _bitPosNewLineMask;
00183 
00184     bool isASCII(uint16 ch) const;
00185 
00186     virtual const uint8 *getCharData(uint16 c) const = 0;
00187 
00188     enum DrawingFeature {
00189         kFeatDefault        = 1 << 0,
00190         kFeatOutline        = 1 << 1,
00191         kFeatShadow         = 1 << 2,
00192         kFeatFMTownsShadow  = 1 << 3,
00193         kFeatFlipped        = 1 << 4,
00194         kFeatFatPrint       = 1 << 5
00195     };
00196 
00197     virtual bool hasFeature(int feat) const = 0;
00198 };
00199 
00205 class FontTowns : public FontSJISBase {
00206 public:
00210     bool loadData();
00211 private:
00212     enum {
00213         kFont16x16Chars = 7808,
00214         kFont8x16Chars = 256
00215     };
00216 
00217     uint8 _fontData16x16[kFont16x16Chars * 32];
00218     uint8 _fontData8x16[kFont8x16Chars * 32];
00219 
00220     virtual const uint8 *getCharData(uint16 c) const;
00221 
00222     bool hasFeature(int feat) const;
00223 };
00224 
00230 class FontPCEngine : public FontSJISBase {
00231 public:
00235     bool loadData();
00236 private:
00237     enum {
00238         kFont12x12Chars = 3418
00239     };
00240 
00241     uint8 _fontData12x12[kFont12x12Chars * 18];
00242 
00243     virtual const uint8 *getCharData(uint16 c) const;
00244 
00245     bool hasFeature(int feat) const;
00246 };
00247 
00251 class FontSjisSVM : public FontSJISBase {
00252 public:
00253     FontSjisSVM(const Common::Platform platform);
00254     ~FontSjisSVM();
00255 
00259     bool loadData();
00260 private:
00261     uint8 *_fontData16x16;
00262     uint _fontData16x16Size;
00263 
00264     uint8 *_fontData8x16;
00265     uint _fontData8x16Size;
00266 
00267     uint8 *_fontData12x12;
00268     uint _fontData12x12Size;
00269 
00270     virtual const uint8 *getCharData(uint16 c) const;
00271 
00272     bool hasFeature(int feat) const;
00273 
00274     const uint8 *getCharDataPCE(uint16 c) const;
00275     const uint8 *getCharDataDefault(uint16 c) const;
00276 
00277     void mapKANJIChar(const uint8 fB, const uint8 sB, int &base, int &index) const;
00278 
00279     enum {
00280         kSjisFontVersion = 3
00281     };
00282 };
00283 
00284 // TODO: Consider adding support for PC98 ROM
00285 
00286 } // End of namespace Graphics
00287 
00288 #endif
00289 
00290 #endif // engine and dynamic plugins guard


Generated on Sat May 30 2020 05:01:02 for ResidualVM by doxygen 1.7.1
curved edge   curved edge