ScummVM API documentation
sjis.h
1/* ScummVM - Graphic Adventure Engine
2 *
3 * ScummVM is the legal property of its developers, whose names
4 * are too numerous to list here. Please refer to the COPYRIGHT
5 * file distributed with this source distribution.
6 *
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 *
20 */
21
22// The code in this file is currently used in BCB, KYRA, SCI, SCUMM,
23// SAGA, and AGOS. If none of those are enabled, we will skip compiling it.
24// We also enable this code for ScummVM builds including support
25// for dynamic engine plugins.
26// If you plan to use this code in another engine, you will have
27// to add the proper define check here.
28#if !(defined(ENABLE_BCB) || defined(ENABLE_KYRA) || defined(ENABLE_SCI) || defined(ENABLE_SCUMM) || defined(ENABLE_SAGA) || defined(ENABLE_AGOS) || defined(DYNAMIC_MODULES))
29
30// If neither of the above mentioned is enabled, do not include the SJIS code.
31
32#else
33
34#ifndef GRAPHICS_SJIS_H
35#define GRAPHICS_SJIS_H
36
37#ifdef __DS__
38/* This disables the flipped mode which is used in FM-Towns versions
39 * of Monkey Island 1 (and maybe other SCUMM 5 games). These are not supported
40 * on the DS, so it makes sense to have a corresponding setting here.
41 */
42#define DISABLE_FLIPPED_MODE
43#endif
44
45#include "common/scummsys.h"
46#include "common/platform.h"
47
48namespace Graphics {
49
59struct Surface;
60
64class FontSJIS {
65public:
66 virtual ~FontSJIS() {}
67
79 static FontSJIS *createFont(const Common::Platform platform = Common::kPlatformUnknown);
80
84 virtual bool loadData() = 0;
85
92 enum DrawingMode {
93 kDefaultMode,
94 kOutlineMode,
95 kShadowRightMode,
96 kShadowLeftMode,
97 kFMTownsShadowMode
98 };
99
100 virtual void setDrawingMode(DrawingMode mode) {}
101
105 virtual void toggleFatPrint(bool enable) {}
106
110 virtual void toggleFlippedMode(bool enable) {}
111
115 virtual void setCharSpacing(int spacing) {}
116 virtual void setLineSpacing(int spacing) {}
117
121 virtual uint getFontHeight() const = 0;
122
126 virtual uint getMaxFontWidth() const = 0;
127
131 virtual uint getCharWidth(uint16 ch) const = 0;
132
136 void drawChar(Graphics::Surface &dst, uint16 ch, int x, int y, uint32 c1, uint32 c2) const;
137
150 virtual void drawChar(void *dst, uint16 ch, int pitch, int bpp, uint32 c1, uint32 c2, int maxW, int maxH) const = 0;
151};
152
156class FontSJISBase : public FontSJIS {
157public:
158 FontSJISBase();
159
160 void setDrawingMode(DrawingMode mode) override;
161
162 void toggleFlippedMode(bool enable) override;
163
164 void toggleFatPrint(bool enable) override;
165
166 uint getFontHeight() const override;
167
168 uint getMaxFontWidth() const override;
169
170 uint getCharWidth(uint16 ch) const override;
171
172 void drawChar(void *dst, uint16 ch, int pitch, int bpp, uint32 c1, uint32 c2, int maxW, int maxH) const override;
173private:
174 template<typename Color>
175 void blitCharacter(const uint8 *glyph, const int w, const int h, uint8 *dst, int pitch, Color c) const;
176 void createOutline(uint8 *outline, const uint8 *glyph, const int w, const int h) const;
177
178#ifndef DISABLE_FLIPPED_MODE
179 // This is used in the FM-Towns version of Monkey Island 1
180 // when Guybrush gets shot out of the cannon in the circus tent.
181 const uint8 *flipCharacter(const uint8 *glyph, const int w) const;
182 mutable uint8 _tempGlyph[32];
183#endif
184 const uint8 *makeFatCharacter(const uint8 *glyph, const int w) const;
185 mutable uint8 _tempGlyph2[32];
186protected:
187 DrawingMode _drawMode;
188 bool _flippedMode, _fatPrint;
189 int _fontWidth, _fontHeight;
190 uint8 _bitPosNewLineMask;
191
192 bool isASCII(uint16 ch) const;
193
194 virtual const uint8 *getCharData(uint16 c) const = 0;
195
196 enum DrawingFeature {
197 kFeatDefault = 1 << 0,
198 kFeatOutline = 1 << 1,
199 kFeatShadow = 1 << 2,
200 kFeatFMTownsShadow = 1 << 3,
201 kFeatFlipped = 1 << 4,
202 kFeatFatPrint = 1 << 5
203 };
204
205 virtual bool hasFeature(int feat) const = 0;
206};
207
213class FontTowns : public FontSJISBase {
214public:
218 bool loadData() override;
219
220 static int getCharFMTChunk(uint16 ch);
221
222private:
223 enum {
224 kFont16x16Chars = 7808,
225 kFont8x16Chars = 256
226 };
227
228 uint8 _fontData16x16[kFont16x16Chars * 32];
229 uint8 _fontData8x16[kFont8x16Chars * 32];
230
231 const uint8 *getCharData(uint16 c) const override;
232
233 bool hasFeature(int feat) const override;
234};
235
241class FontPC98 : public FontSJISBase {
242public:
246 bool loadData() override;
247
251 bool loadBMPData();
252
253protected:
254 const uint8 *getCharData(uint16 c) const override;
255
256private:
257 enum {
258 kFont16x16Chars = 8831,
259 kFont8x16Chars = 256
260 };
261
262 uint8 _fontData16x16[kFont16x16Chars * 32];
263 uint8 _fontData8x16[kFont8x16Chars * 16];
264
265 bool hasFeature(int feat) const override;
266};
267
273class FontPCEngine : public FontSJISBase {
274public:
278 bool loadData() override;
279private:
280 enum {
281 kFont12x12Chars = 3418
282 };
283
284 uint8 _fontData12x12[kFont12x12Chars * 18];
285
286 const uint8 *getCharData(uint16 c) const override;
287
288 bool hasFeature(int feat) const override;
289};
290
294class FontSjisSVM : public FontSJISBase {
295public:
296 FontSjisSVM(const Common::Platform platform);
297 ~FontSjisSVM();
298
302 bool loadData() override;
303private:
304 uint8 *_fontData16x16;
305 uint _fontData16x16Size;
306
307 uint8 *_fontData8x16;
308 uint _fontData8x16Size;
309
310 uint8 *_fontData12x12;
311 uint _fontData12x12Size;
312
313 const uint8 *getCharData(uint16 c) const override;
314
315 bool hasFeature(int feat) const override;
316
317 const uint8 *getCharDataPCE(uint16 c) const;
318 const uint8 *getCharDataDefault(uint16 c) const;
319
320 void mapKANJIChar(const uint8 fB, const uint8 sB, int &base, int &index) const;
321
322 enum {
323 kSjisFontVersion = 3
324 };
325};
326
327// TODO: Consider adding support for PC98 ROM
329} // End of namespace Graphics
330
331#endif
332
333#endif // engine and dynamic plugins guard
Platform
Definition: platform.h:93
Definition: formatinfo.h:28
Definition: surface.h:67