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"
|
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
|
|
|
|
|
|
|
#ifndef DISABLE_TOWNS_DUAL_LAYER_MODE
|
SCUMM/FM-TOWNS: fix palette and other graphics issues
This commit should fix at least the following bugs/feature requests: #1032859, #1252088, #1055391, #1315968, #1315938, #1742106, #812891.
The FM-Towns version of Scumm games use a mixed graphics mode with 2 layers (one with 32767 colors and one with 16 colors). Among other things I have added a screen output class which emulates this dual layer approach which allows specific hardware effects like enabling and disabling layers (e.g. in the voodoo priestess scene in MI1).
Old savegames (saved before this update) will load, but you’ll encounter palette glitches in the verb/inventory screen, since the 16 color palette for layer 2 is not contained in your savegame. This will be true at least for version 5 games. Certain scene change actions (which require the verb/inventory part to be redrawn) might correct this (e.g. try looking at the treasure map in MI1 and closing it). Version 3 games should be okay, since they use a static text palette which is never changed and which will be reset after loading a savegame.
This update requires a USE_RGB_COLORS setting for proper operation. 8 bit users will get a warning that they’ll have to expect palette glitches . Apart from that the engine in 8 bit mode should not only still work okay, but also benefit from some of the other (non palette related) improvements (e.g. bug #1032859 should be fixed even in 8 bit mode).
Japanese font drawing hasn’t been improved much yet. This will be a separate task.
svn-id: r52966
2010-10-01 19:24:52 +00:00
|
|
|
void processTownsCharsetColors(uint8 bytesPerPixel);
|
2010-10-05 19:04:52 +00:00
|
|
|
#endif
|
2005-07-30 21:11:48 +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
|
|
|
enum ShadowMode {
|
|
|
|
kNoShadowMode,
|
|
|
|
kFMTOWNSShadowMode,
|
|
|
|
kNormalShadowMode
|
|
|
|
};
|
|
|
|
byte _shadowColor;
|
|
|
|
ShadowMode _shadowMode;
|
|
|
|
|
|
|
|
void enableShadow(bool enable);
|
2010-10-15 19:10:18 +00:00
|
|
|
virtual void drawBits1(const Graphics::Surface &s, byte *dst, const byte *src, int drawTop, int width, int height, uint8 bitDepth, bool scale2x = false);
|
2003-06-04 14:37:43 +00:00
|
|
|
|
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
|
|
|
|
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:
|
2010-10-15 21:26:05 +00:00
|
|
|
void drawBitsN(const Graphics::Surface &s, byte *dst, const byte *src, byte bpp, int drawTop, int width, int height, bool scale2x = false);
|
2002-12-25 21:57:01 +00:00
|
|
|
|
2007-01-28 20:11:31 +00:00
|
|
|
void printCharIntern(bool is2byte, const byte *charPtr, int origWidth, int origHeight, int width, int height, VirtScreen *vs, bool ignoreCharsetMask);
|
|
|
|
|
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);
|
2010-10-17 13:08:00 +00:00
|
|
|
|
|
|
|
// Some SCUMM 5 games contain hard coded logic to determine whether to use
|
|
|
|
// the SCUMM fonts or the FM-Towns font rom to draw a character. For the other
|
|
|
|
// games we will simply check for a character greater 127.
|
|
|
|
bool useTownsFontRomCharacter(uint16 chr);
|
2002-12-25 21:57:01 +00:00
|
|
|
};
|
|
|
|
|
2005-03-16 03:20:32 +00:00
|
|
|
class CharsetRendererNES : public CharsetRendererCommon {
|
|
|
|
protected:
|
|
|
|
byte *_trTable;
|
|
|
|
|
2010-10-15 19:10:18 +00:00
|
|
|
void drawBits1(const Graphics::Surface &s, byte *dst, const byte *src, int drawTop, int width, int height, uint8 bitDepth, bool scale2x = false);
|
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:
|
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);
|
2010-10-12 22:17:00 +00:00
|
|
|
int getCharWidth(uint16 chr);
|
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 {
|
|
|
|
protected:
|
2010-10-15 19:10:18 +00:00
|
|
|
void drawBits1(const Graphics::Surface &s, byte *dst, const byte *src, int drawTop, int width, int height, uint8 bitDepth, bool scale2x = false);
|
2009-11-22 08:20:20 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
CharsetRendererPCE(ScummEngine *vm) : CharsetRendererV3(vm) {}
|
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
|