2002-12-25 21:04:47 +00:00
|
|
|
/* ScummVM - Scumm Interpreter
|
2005-01-01 16:09:25 +00:00
|
|
|
* Copyright (C) 2001-2005 The ScummVM project
|
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
|
|
|
*
|
|
|
|
* $Header$
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef CHARSET_H
|
|
|
|
#define CHARSET_H
|
|
|
|
|
|
|
|
#include "common/scummsys.h"
|
2005-01-11 08:06:19 +00:00
|
|
|
#include "common/rect.h"
|
2004-04-08 23:41:10 +00:00
|
|
|
#include "scumm/gfx.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) {
|
|
|
|
if ((c > 0x84 && c < 0x88) || (c > 0x9f && c < 0xe0) || (c > 0xea /* && c <= 0xff */))
|
|
|
|
return false;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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 _nextLeft, _nextTop;
|
|
|
|
|
|
|
|
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:14:26 +00:00
|
|
|
bool _ignoreCharsetMask;
|
2002-12-25 21:04:47 +00:00
|
|
|
bool _blitAlso;
|
|
|
|
bool _firstChar;
|
|
|
|
bool _disableOffsX;
|
|
|
|
|
2005-03-25 01:27:28 +00:00
|
|
|
/**
|
|
|
|
* All text is normally rendered into this overlay surface. Then later
|
|
|
|
* drawStripToScreen() composits it over the game graphics.
|
|
|
|
*/
|
|
|
|
Graphics::Surface _textSurface;
|
|
|
|
|
2002-12-25 21:04:47 +00:00
|
|
|
protected:
|
2003-10-02 22:42:03 +00:00
|
|
|
ScummEngine *_vm;
|
2002-12-26 01:47:40 +00:00
|
|
|
byte _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
|
|
|
|
2004-01-08 21:21:40 +00:00
|
|
|
void restoreCharsetBg();
|
|
|
|
void clearCharsetMask();
|
2005-04-05 07:53:46 +00:00
|
|
|
void clearTextSurface();
|
2004-01-08 21:21:40 +00:00
|
|
|
|
2002-12-25 21:57:01 +00:00
|
|
|
virtual void printChar(int chr) = 0;
|
2004-08-23 08:37:55 +00:00
|
|
|
virtual void drawChar(int chr, const 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();
|
2005-07-30 21:11:48 +00:00
|
|
|
|
2002-12-26 00:21:19 +00:00
|
|
|
virtual void setCurID(byte 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(); }
|
2004-08-23 08:37:55 +00:00
|
|
|
virtual int getCharWidth(byte 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(); }
|
2002-12-26 00:21:19 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class CharsetRendererCommon : public CharsetRenderer {
|
|
|
|
protected:
|
|
|
|
byte *_fontPtr;
|
2005-05-26 16:38:02 +00:00
|
|
|
int _numChars;
|
|
|
|
int _fontHeight;
|
2002-12-26 00:21:19 +00:00
|
|
|
|
2005-06-04 16:10:39 +00:00
|
|
|
enum ShadowMode {
|
|
|
|
kNoShadowMode,
|
|
|
|
kFMTOWNSShadowMode,
|
|
|
|
kNormalShadowMode
|
|
|
|
};
|
|
|
|
byte _shadowColor;
|
|
|
|
ShadowMode _shadowMode;
|
|
|
|
|
|
|
|
void enableShadow(bool enable);
|
2004-08-23 08:37:55 +00:00
|
|
|
void drawBits1(const Graphics::Surface &s, byte *dst, const byte *src, int drawTop, int width, int height);
|
2003-06-04 14:37:43 +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
|
|
|
|
2002-12-25 21:04:47 +00:00
|
|
|
void setCurID(byte id);
|
2005-07-30 21:11:48 +00:00
|
|
|
|
2004-10-23 23:08:53 +00:00
|
|
|
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:
|
2004-08-23 08:37:55 +00:00
|
|
|
void drawBitsN(const Graphics::Surface &s, byte *dst, const byte *src, byte bpp, int drawTop, int width, int height);
|
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
|
|
|
|
2002-12-25 21:57:01 +00:00
|
|
|
void printChar(int chr);
|
2004-08-23 08:37:55 +00:00
|
|
|
void drawChar(int chr, const Graphics::Surface &s, int x, int y);
|
|
|
|
|
|
|
|
int getCharWidth(byte chr);
|
2002-12-25 21:57:01 +00:00
|
|
|
};
|
|
|
|
|
2005-03-16 03:20:32 +00:00
|
|
|
class CharsetRendererNES : public CharsetRendererCommon {
|
|
|
|
protected:
|
|
|
|
byte *_trTable;
|
|
|
|
|
|
|
|
void drawBits1(const Graphics::Surface &s, byte *dst, const byte *src, int drawTop, int width, int height);
|
|
|
|
|
|
|
|
public:
|
2005-05-20 22:49:09 +00:00
|
|
|
CharsetRendererNES(ScummEngine *vm) : CharsetRendererCommon(vm) {}
|
2005-07-30 21:11:48 +00:00
|
|
|
|
2005-03-16 03:20:32 +00:00
|
|
|
void setCurID(byte id) {}
|
|
|
|
void printChar(int chr);
|
|
|
|
void drawChar(int chr, const Graphics::Surface &s, int x, int y);
|
|
|
|
|
|
|
|
int getFontHeight() { return 8; }
|
|
|
|
int getCharWidth(byte chr) { return 8; }
|
|
|
|
};
|
|
|
|
|
2003-05-08 22:44:46 +00:00
|
|
|
class CharsetRendererV3 : public CharsetRendererCommon {
|
2002-12-25 21:57:01 +00:00
|
|
|
protected:
|
2003-05-08 22:44:46 +00:00
|
|
|
byte *_widthTable;
|
|
|
|
|
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
|
|
|
|
2002-12-25 21:57:01 +00:00
|
|
|
void printChar(int chr);
|
2004-08-23 08:37:55 +00:00
|
|
|
void drawChar(int chr, const Graphics::Surface &s, int x, int y);
|
2003-05-08 22:44:46 +00:00
|
|
|
void setCurID(byte id);
|
2003-04-27 18:49:27 +00:00
|
|
|
void setColor(byte color);
|
2004-10-23 23:08:53 +00:00
|
|
|
int getFontHeight();
|
2004-08-23 08:37:55 +00:00
|
|
|
int getCharWidth(byte chr);
|
2002-12-25 21:57:01 +00:00
|
|
|
};
|
|
|
|
|
2003-05-08 22:44:46 +00:00
|
|
|
class CharsetRendererV2 : public CharsetRendererV3 {
|
|
|
|
public:
|
2004-01-08 17:41:11 +00:00
|
|
|
CharsetRendererV2(ScummEngine *vm, Common::Language language);
|
2005-07-30 21:11:48 +00:00
|
|
|
|
2004-01-08 17:41:11 +00:00
|
|
|
void setCurID(byte id) {}
|
2004-08-23 08:37:55 +00:00
|
|
|
int getCharWidth(byte chr) { return 8; }
|
2003-05-08 22:44:46 +00:00
|
|
|
};
|
|
|
|
|
2005-06-18 15:44:40 +00:00
|
|
|
#ifndef DISABLE_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
|
|
|
|
2002-12-26 00:21:19 +00:00
|
|
|
void printChar(int chr);
|
|
|
|
|
|
|
|
void setCurID(byte 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);
|
2004-08-23 08:37:55 +00:00
|
|
|
int getCharWidth(byte 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
|