2007-05-30 21:56:52 +00:00
|
|
|
/* 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.
|
2002-12-25 21:04:47 +00:00
|
|
|
*
|
|
|
|
* 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
|
2005-10-18 01:30:26 +00:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2002-12-25 21:04:47 +00:00
|
|
|
*/
|
|
|
|
|
2007-02-19 17:48:19 +00:00
|
|
|
#ifndef SCUMM_CHARSET_H
|
|
|
|
#define SCUMM_CHARSET_H
|
2002-12-25 21:04:47 +00:00
|
|
|
|
|
|
|
#include "common/scummsys.h"
|
2005-01-11 08:06:19 +00:00
|
|
|
#include "common/rect.h"
|
2010-10-15 19:10:18 +00:00
|
|
|
#include "graphics/sjis.h"
|
2011-07-09 21:57:25 +00:00
|
|
|
#include "scumm/scumm.h"
|
2004-04-08 23:41:10 +00:00
|
|
|
#include "scumm/gfx.h"
|
2007-05-28 08:02:10 +00:00
|
|
|
#include "scumm/saveload.h"
|
2002-12-25 21:04:47 +00:00
|
|
|
|
2003-10-03 18:33:57 +00:00
|
|
|
namespace Scumm {
|
|
|
|
|
2003-10-02 22:42:03 +00:00
|
|
|
class ScummEngine;
|
2002-12-26 01:47:40 +00:00
|
|
|
class NutRenderer;
|
2002-12-25 21:04:47 +00:00
|
|
|
struct VirtScreen;
|
|
|
|
|
2004-10-23 23:08:53 +00:00
|
|
|
static inline bool checkSJISCode(byte c) {
|
2010-10-17 13:08:00 +00:00
|
|
|
if ((c >= 0x80 && c <= 0x9f) || (c >= 0xe0 && c <= 0xfd))
|
|
|
|
return true;
|
|
|
|
return false;
|
2004-10-23 23:08:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-12-25 21:04:47 +00:00
|
|
|
class CharsetRenderer {
|
|
|
|
public:
|
2005-07-30 21:11:48 +00:00
|
|
|
|
2003-10-02 17:43:02 +00:00
|
|
|
Common::Rect _str;
|
2002-12-25 21:04:47 +00:00
|
|
|
|
|
|
|
int _top;
|
|
|
|
int _left, _startLeft;
|
|
|
|
int _right;
|
2002-12-25 21:14:26 +00:00
|
|
|
|
2003-04-27 18:49:27 +00:00
|
|
|
protected:
|
2002-12-25 21:04:47 +00:00
|
|
|
byte _color;
|
2002-12-25 21:14:26 +00:00
|
|
|
|
2003-04-27 18:49:27 +00:00
|
|
|
public:
|
2002-12-25 21:14:26 +00:00
|
|
|
bool _center;
|
2004-04-08 23:41:10 +00:00
|
|
|
|
|
|
|
bool _hasMask; // True if "removable" text is visible somewhere (should be called _hasText or so)
|
|
|
|
VirtScreenNumber _textScreenID; // ID of the virtual screen on which the text is visible.
|
|
|
|
|
2002-12-25 21:04:47 +00:00
|
|
|
bool _blitAlso;
|
|
|
|
bool _firstChar;
|
|
|
|
bool _disableOffsX;
|
|
|
|
|
|
|
|
protected:
|
2003-10-02 22:42:03 +00:00
|
|
|
ScummEngine *_vm;
|
2008-08-02 22:51:53 +00:00
|
|
|
int32 _curId;
|
2002-12-25 21:04:47 +00:00
|
|
|
|
|
|
|
public:
|
2003-10-02 22:42:03 +00:00
|
|
|
CharsetRenderer(ScummEngine *vm);
|
2005-03-25 01:52:20 +00:00
|
|
|
virtual ~CharsetRenderer();
|
2002-12-25 21:04:47 +00:00
|
|
|
|
2006-01-10 00:28:10 +00:00
|
|
|
virtual void printChar(int chr, bool ignoreCharsetMask) = 0;
|
2010-11-05 00:36:23 +00:00
|
|
|
virtual void drawChar(int chr, Graphics::Surface &s, int x, int y) {}
|
2002-12-25 21:57:01 +00:00
|
|
|
|
2003-05-21 16:28:02 +00:00
|
|
|
int getStringWidth(int a, const byte *str);
|
2002-12-25 21:04:47 +00:00
|
|
|
void addLinebreaks(int a, byte *str, int pos, int maxwidth);
|
2005-02-20 00:17:22 +00:00
|
|
|
void translateColor();
|
2010-10-05 19:04:52 +00:00
|
|
|
|
2008-08-02 22:51:53 +00:00
|
|
|
virtual void setCurID(int32 id) = 0;
|
2002-12-26 01:47:40 +00:00
|
|
|
int getCurID() { return _curId; }
|
2005-07-30 21:11:48 +00:00
|
|
|
|
2002-12-26 00:21:19 +00:00
|
|
|
virtual int getFontHeight() = 0;
|
2005-05-26 12:26:03 +00:00
|
|
|
virtual int getCharHeight(byte chr) { return getFontHeight(); }
|
2010-10-12 22:17:00 +00:00
|
|
|
virtual int getCharWidth(uint16 chr) = 0;
|
2005-07-30 21:11:48 +00:00
|
|
|
|
2005-02-20 00:17:22 +00:00
|
|
|
virtual void setColor(byte color) { _color = color; translateColor(); }
|
2007-05-28 08:02:10 +00:00
|
|
|
|
|
|
|
void saveLoadWithSerializer(Serializer *ser);
|
2002-12-26 00:21:19 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class CharsetRendererCommon : public CharsetRenderer {
|
|
|
|
protected:
|
2006-10-15 02:15:38 +00:00
|
|
|
const byte *_fontPtr;
|
2009-09-25 09:13:33 +00:00
|
|
|
int _bytesPerPixel;
|
2005-05-26 16:38:02 +00:00
|
|
|
int _fontHeight;
|
2005-11-06 08:56:50 +00:00
|
|
|
int _numChars;
|
2002-12-26 00:21:19 +00:00
|
|
|
|
2005-06-04 16:10:39 +00:00
|
|
|
byte _shadowColor;
|
2011-07-07 14:33:14 +00:00
|
|
|
bool _shadowMode;
|
2010-10-17 13:08:00 +00:00
|
|
|
|
2002-12-26 00:21:19 +00:00
|
|
|
public:
|
2005-06-04 16:10:39 +00:00
|
|
|
CharsetRendererCommon(ScummEngine *vm);
|
2002-12-26 00:21:19 +00:00
|
|
|
|
2008-08-02 22:51:53 +00:00
|
|
|
void setCurID(int32 id);
|
2005-07-30 21:11:48 +00:00
|
|
|
|
2011-07-07 14:33:14 +00:00
|
|
|
virtual int getFontHeight();
|
2002-12-25 21:04:47 +00:00
|
|
|
};
|
|
|
|
|
2002-12-26 00:21:19 +00:00
|
|
|
class CharsetRendererClassic : public CharsetRendererCommon {
|
2002-12-25 21:57:01 +00:00
|
|
|
protected:
|
2011-07-07 14:33:14 +00:00
|
|
|
virtual void drawBitsN(const Graphics::Surface &s, byte *dst, const byte *src, byte bpp, int drawTop, int width, int height);
|
|
|
|
void printCharIntern(bool is2byte, const byte *charPtr, int origWidth, int origHeight, int width, int height, VirtScreen *vs, bool ignoreCharsetMask);
|
2011-07-13 22:50:14 +00:00
|
|
|
virtual bool prepareDraw(uint16 chr);
|
2002-12-25 21:57:01 +00:00
|
|
|
|
2011-07-07 14:33:14 +00:00
|
|
|
int _width, _height, _origWidth, _origHeight;
|
|
|
|
int _offsX, _offsY;
|
|
|
|
const byte *_charPtr;
|
2007-01-28 20:11:31 +00:00
|
|
|
|
2011-08-26 03:51:08 +00:00
|
|
|
// On which virtual screen will be drawn right now
|
|
|
|
VirtScreenNumber _drawScreen;
|
|
|
|
|
2002-12-25 21:57:01 +00:00
|
|
|
public:
|
2003-10-02 22:42:03 +00:00
|
|
|
CharsetRendererClassic(ScummEngine *vm) : CharsetRendererCommon(vm) {}
|
2005-07-30 21:11:48 +00:00
|
|
|
|
2006-01-10 00:28:10 +00:00
|
|
|
void printChar(int chr, bool ignoreCharsetMask);
|
2010-11-05 00:36:23 +00:00
|
|
|
void drawChar(int chr, Graphics::Surface &s, int x, int y);
|
2004-08-23 08:37:55 +00:00
|
|
|
|
2010-10-12 22:17:00 +00:00
|
|
|
int getCharWidth(uint16 chr);
|
2011-07-07 14:33:14 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#ifdef USE_RGB_COLOR
|
|
|
|
#ifndef DISABLE_TOWNS_DUAL_LAYER_MODE
|
|
|
|
class CharsetRendererTownsClassic : public CharsetRendererClassic {
|
|
|
|
public:
|
|
|
|
CharsetRendererTownsClassic(ScummEngine *vm);
|
|
|
|
|
|
|
|
int getCharWidth(uint16 chr);
|
|
|
|
int getFontHeight();
|
|
|
|
|
|
|
|
private:
|
|
|
|
void drawBitsN(const Graphics::Surface &s, byte *dst, const byte *src, byte bpp, int drawTop, int width, int height);
|
2011-07-13 22:50:14 +00:00
|
|
|
bool prepareDraw(uint16 chr);
|
2011-07-07 14:33:14 +00:00
|
|
|
void setupShadowMode();
|
|
|
|
bool useFontRomCharacter(uint16 chr);
|
|
|
|
void processCharsetColors();
|
2010-10-17 13:08:00 +00:00
|
|
|
|
2011-07-07 14:33:14 +00:00
|
|
|
uint16 _sjisCurChar;
|
2002-12-25 21:57:01 +00:00
|
|
|
};
|
2011-07-07 14:33:14 +00:00
|
|
|
#endif
|
|
|
|
#endif
|
2002-12-25 21:57:01 +00:00
|
|
|
|
2005-03-16 03:20:32 +00:00
|
|
|
class CharsetRendererNES : public CharsetRendererCommon {
|
|
|
|
protected:
|
|
|
|
byte *_trTable;
|
|
|
|
|
2011-09-14 17:19:40 +00:00
|
|
|
void drawBits1(Graphics::Surface &dest, int x, int y, const byte *src, int drawTop, int width, int height);
|
2005-03-16 03:20:32 +00:00
|
|
|
|
|
|
|
public:
|
2005-05-20 22:49:09 +00:00
|
|
|
CharsetRendererNES(ScummEngine *vm) : CharsetRendererCommon(vm) {}
|
2005-07-30 21:11:48 +00:00
|
|
|
|
2008-08-02 22:51:53 +00:00
|
|
|
void setCurID(int32 id) {}
|
2006-01-10 00:28:10 +00:00
|
|
|
void printChar(int chr, bool ignoreCharsetMask);
|
2010-11-05 00:36:23 +00:00
|
|
|
void drawChar(int chr, Graphics::Surface &s, int x, int y);
|
2005-03-16 03:20:32 +00:00
|
|
|
|
|
|
|
int getFontHeight() { return 8; }
|
2010-10-12 22:17:00 +00:00
|
|
|
int getCharWidth(uint16 chr) { return 8; }
|
2005-03-16 03:20:32 +00:00
|
|
|
};
|
|
|
|
|
2003-05-08 22:44:46 +00:00
|
|
|
class CharsetRendererV3 : public CharsetRendererCommon {
|
2002-12-25 21:57:01 +00:00
|
|
|
protected:
|
2011-07-07 14:33:14 +00:00
|
|
|
virtual void enableShadow(bool enable);
|
2011-09-14 17:19:40 +00:00
|
|
|
virtual void drawBits1(Graphics::Surface &dest, int x, int y, const byte *src, int drawTop, int width, int height);
|
2011-07-07 14:33:14 +00:00
|
|
|
virtual int getDrawWidthIntern(uint16 chr);
|
|
|
|
virtual int getDrawHeightIntern(uint16 chr);
|
|
|
|
virtual void setDrawCharIntern(uint16 chr) {}
|
|
|
|
|
2006-10-15 02:15:38 +00:00
|
|
|
const byte *_widthTable;
|
2003-05-08 22:44:46 +00:00
|
|
|
|
2002-12-25 21:57:01 +00:00
|
|
|
public:
|
2003-10-02 22:42:03 +00:00
|
|
|
CharsetRendererV3(ScummEngine *vm) : CharsetRendererCommon(vm) {}
|
2005-07-30 21:11:48 +00:00
|
|
|
|
2006-01-10 00:28:10 +00:00
|
|
|
void printChar(int chr, bool ignoreCharsetMask);
|
2010-11-05 00:36:23 +00:00
|
|
|
void drawChar(int chr, Graphics::Surface &s, int x, int y);
|
2008-08-02 22:51:53 +00:00
|
|
|
void setCurID(int32 id);
|
2003-04-27 18:49:27 +00:00
|
|
|
void setColor(byte color);
|
2011-07-07 14:33:14 +00:00
|
|
|
virtual int getCharWidth(uint16 chr);
|
|
|
|
};
|
|
|
|
|
|
|
|
class CharsetRendererTownsV3 : public CharsetRendererV3 {
|
|
|
|
public:
|
|
|
|
CharsetRendererTownsV3(ScummEngine *vm);
|
|
|
|
|
2010-10-12 22:17:00 +00:00
|
|
|
int getCharWidth(uint16 chr);
|
2011-07-07 14:33:14 +00:00
|
|
|
int getFontHeight();
|
|
|
|
|
|
|
|
private:
|
|
|
|
void enableShadow(bool enable);
|
2011-09-14 17:19:40 +00:00
|
|
|
void drawBits1(Graphics::Surface &dest, int x, int y, const byte *src, int drawTop, int width, int height);
|
2011-07-07 14:33:14 +00:00
|
|
|
#ifndef DISABLE_TOWNS_DUAL_LAYER_MODE
|
|
|
|
int getDrawWidthIntern(uint16 chr);
|
|
|
|
int getDrawHeightIntern(uint16 chr);
|
|
|
|
void setDrawCharIntern(uint16 chr);
|
|
|
|
#endif
|
|
|
|
uint16 _sjisCurChar;
|
2002-12-25 21:57:01 +00:00
|
|
|
};
|
|
|
|
|
2009-11-22 11:43:12 +00:00
|
|
|
#ifdef USE_RGB_COLOR
|
2009-11-22 08:20:20 +00:00
|
|
|
class CharsetRendererPCE : public CharsetRendererV3 {
|
2011-07-09 18:06:18 +00:00
|
|
|
private:
|
2011-09-14 17:19:40 +00:00
|
|
|
void drawBits1(Graphics::Surface &dest, int x, int y, const byte *src, int drawTop, int width, int height);
|
2011-07-07 14:33:14 +00:00
|
|
|
|
|
|
|
int getDrawWidthIntern(uint16 chr);
|
|
|
|
int getDrawHeightIntern(uint16 chr);
|
2011-07-09 18:06:18 +00:00
|
|
|
void setDrawCharIntern(uint16 chr);
|
|
|
|
|
|
|
|
uint16 _sjisCurChar;
|
2009-11-22 08:20:20 +00:00
|
|
|
|
|
|
|
public:
|
2011-07-09 18:06:18 +00:00
|
|
|
CharsetRendererPCE(ScummEngine *vm) : CharsetRendererV3(vm), _sjisCurChar(0) {}
|
2009-11-22 08:36:14 +00:00
|
|
|
|
|
|
|
void setColor(byte color);
|
2009-11-22 08:20:20 +00:00
|
|
|
};
|
2009-11-22 11:43:12 +00:00
|
|
|
#endif
|
2009-11-22 08:20:20 +00:00
|
|
|
|
2003-05-08 22:44:46 +00:00
|
|
|
class CharsetRendererV2 : public CharsetRendererV3 {
|
2008-11-14 14:03:08 +00:00
|
|
|
protected:
|
|
|
|
bool _deleteFontPtr;
|
|
|
|
|
2003-05-08 22:44:46 +00:00
|
|
|
public:
|
2004-01-08 17:41:11 +00:00
|
|
|
CharsetRendererV2(ScummEngine *vm, Common::Language language);
|
2008-11-14 14:03:08 +00:00
|
|
|
~CharsetRendererV2();
|
2005-07-30 21:11:48 +00:00
|
|
|
|
2008-08-02 22:51:53 +00:00
|
|
|
void setCurID(int32 id) {}
|
2010-10-12 22:17:00 +00:00
|
|
|
int getCharWidth(uint16 chr) { return 8; }
|
2003-05-08 22:44:46 +00:00
|
|
|
};
|
|
|
|
|
2008-05-06 03:00:26 +00:00
|
|
|
#ifdef ENABLE_SCUMM_7_8
|
2002-12-26 01:47:40 +00:00
|
|
|
class CharsetRendererNut : public CharsetRenderer {
|
2002-12-26 00:21:19 +00:00
|
|
|
protected:
|
2002-12-31 21:41:24 +00:00
|
|
|
NutRenderer *_fr[5];
|
2002-12-26 01:47:40 +00:00
|
|
|
NutRenderer *_current;
|
2002-12-26 00:21:19 +00:00
|
|
|
|
|
|
|
public:
|
2003-10-02 22:42:03 +00:00
|
|
|
CharsetRendererNut(ScummEngine *vm);
|
2002-12-26 01:47:40 +00:00
|
|
|
~CharsetRendererNut();
|
2005-07-30 21:11:48 +00:00
|
|
|
|
2006-01-10 00:28:10 +00:00
|
|
|
void printChar(int chr, bool ignoreCharsetMask);
|
2002-12-26 00:21:19 +00:00
|
|
|
|
2008-08-02 22:51:53 +00:00
|
|
|
void setCurID(int32 id);
|
2005-07-30 21:11:48 +00:00
|
|
|
|
2002-12-26 01:47:40 +00:00
|
|
|
int getFontHeight();
|
2005-05-26 12:26:03 +00:00
|
|
|
int getCharHeight(byte chr);
|
2010-10-12 22:17:00 +00:00
|
|
|
int getCharWidth(uint16 chr);
|
2002-12-26 00:21:19 +00:00
|
|
|
};
|
2005-06-18 15:44:40 +00:00
|
|
|
#endif
|
2002-12-25 21:57:01 +00:00
|
|
|
|
2003-10-03 18:33:57 +00:00
|
|
|
} // End of namespace Scumm
|
|
|
|
|
|
|
|
|
2002-12-25 21:04:47 +00:00
|
|
|
#endif
|