KYRA: implement SJIS features required for EOB II FM-Towns

- low res font drawing for intro and outro texts
- fat print mode for ingame texts
This commit is contained in:
athrxx 2015-11-14 19:52:26 +01:00
parent 35126dba8a
commit e4e5e68f0d
4 changed files with 82 additions and 20 deletions

View file

@ -141,7 +141,7 @@ bool Screen::init() {
if (!font)
error("Could not load any SJIS font, neither the original nor ScummVM's 'SJIS.FNT'");
_fonts[FID_SJIS_FNT] = new SJISFont(font, _sjisInvisibleColor, _use16ColorMode, !_use16ColorMode && _vm->game() != GI_LOL, !_use16ColorMode && _vm->game() == GI_LOL ? 1 : 0);
_fonts[FID_SJIS_FNT] = new SJISFont(font, _sjisInvisibleColor, _use16ColorMode, !_use16ColorMode && _vm->game() != GI_LOL && _vm->game() != GI_EOB2, _vm->game() == GI_EOB2 && _vm->gameFlags().platform == Common::kPlatformFMTowns, !_use16ColorMode && _vm->game() == GI_LOL ? 1 : 0);
}
}
@ -3583,12 +3583,11 @@ void AMIGAFont::unload() {
memset(_chars, 0, sizeof(_chars));
}
SJISFont::SJISFont(Graphics::FontSJIS *font, const uint8 invisColor, bool is16Color, bool drawOutline, int extraSpacing)
: _colorMap(0), _font(font), _invisColor(invisColor), _is16Color(is16Color), _drawOutline(drawOutline), _sjisWidthOffset(extraSpacing) {
SJISFont::SJISFont(Graphics::FontSJIS *font, const uint8 invisColor, bool is16Color, bool drawOutline, bool fatPrint, int extraSpacing)
: _colorMap(0), _font(font), _invisColor(invisColor), _is16Color(is16Color), _drawOutline(drawOutline), _sjisWidthOffset(extraSpacing) {
assert(_font);
_font->setDrawingMode(_drawOutline ? Graphics::FontSJIS::kOutlineMode : Graphics::FontSJIS::kDefaultMode);
_font->toggleFatPrint(fatPrint);
_sjisWidth = _font->getMaxFontWidth() >> 1;
_fontHeight = _font->getFontHeight() >> 1;
_asciiWidth = _font->getCharWidth('a') >> 1;
@ -3641,6 +3640,16 @@ void SJISFont::drawChar(uint16 c, byte *dst, int pitch) const {
_font->drawChar(dst, c, 640, 1, color1, color2, 640, 400);
}
SJISFontLarge::SJISFontLarge(Graphics::FontSJIS *font) : SJISFont(font, 0, false, false, false, 0) {
_sjisWidth = _font->getMaxFontWidth();
_fontHeight = _font->getFontHeight();
_asciiWidth = _font->getCharWidth('a');
}
void SJISFontLarge::drawChar(uint16 c, byte *dst, int pitch) const {
_font->drawChar(dst, c, 320, 1, _colorMap[1], _colorMap[0], 320, 200);
}
#pragma mark -
Palette::Palette(const int numColors) : _palData(0), _numColors(numColors) {

View file

@ -211,34 +211,47 @@ private:
*/
class SJISFont : public Font {
public:
SJISFont(Graphics::FontSJIS *font, const uint8 invisColor, bool is16Color, bool drawOutline, int extraSpacing);
~SJISFont() { unload(); }
SJISFont(Graphics::FontSJIS *font, const uint8 invisColor, bool is16Color, bool drawOutline, bool fatPrint, int extraSpacing);
virtual ~SJISFont() { unload(); }
bool usesOverlay() const { return true; }
virtual bool usesOverlay() const { return true; }
bool load(Common::SeekableReadStream &) { return true; }
int getHeight() const;
int getWidth() const;
int getCharWidth(uint16 c) const;
void setColorMap(const uint8 *src);
void drawChar(uint16 c, byte *dst, int pitch) const;
private:
virtual void drawChar(uint16 c, byte *dst, int pitch) const;
protected:
void unload();
const uint8 *_colorMap;
Graphics::FontSJIS *_font;
int _sjisWidth, _asciiWidth;
int _fontHeight;
const bool _drawOutline;
Graphics::FontSJIS *_font;
private:
const uint8 _invisColor;
const bool _is16Color;
const bool _drawOutline;
// We use this for cases where the font width returned by getWidth() or getCharWidth() does not match the original.
// The original Japanese game versions use hard coded sjis font widths of 8 or 9. However, this does not necessarily
// depend on whether an outline is used or not (neither LOL/PC-9801 nor LOL/FM-TOWNS use an outline, but the first
// version uses a font width of 8 where the latter uses a font width of 9).
const int _sjisWidthOffset;
};
int _sjisWidth, _asciiWidth;
int _fontHeight;
/**
* SJISFont variant used in the intro and outro of EOB II FM-Towns. It appears twice as large, since it is not rendered on the hires overlay pages
*/
class SJISFontLarge : public SJISFont {
public:
SJISFontLarge(Graphics::FontSJIS *font);
virtual ~SJISFontLarge() { unload(); }
virtual bool usesOverlay() const { return false; }
virtual void drawChar(uint16 c, byte *dst, int pitch) const;
};
/**
@ -400,6 +413,7 @@ public:
FID_GOLDFONT_FNT,
FID_INTRO_FNT,
FID_SJIS_FNT,
FID_SJIS_LARGE_FNT,
FID_NUM
};

View file

@ -71,7 +71,7 @@ void FontSJIS::drawChar(Graphics::Surface &dst, uint16 ch, int x, int y, uint32
}
FontSJISBase::FontSJISBase()
: _drawMode(kDefaultMode), _flippedMode(false), _fontWidth(16), _fontHeight(16), _bitPosNewLineMask(0) {
: _drawMode(kDefaultMode), _flippedMode(false), _fatPrint(false), _fontWidth(16), _fontHeight(16), _bitPosNewLineMask(0) {
}
void FontSJISBase::setDrawingMode(DrawingMode mode) {
@ -88,6 +88,13 @@ void FontSJISBase::toggleFlippedMode(bool enable) {
warning("Flipped mode unsupported by this font");
}
void FontSJISBase::toggleFatPrint(bool enable) {
if (hasFeature(kFeatFatPrint))
_fatPrint = enable;
else
warning("Fat print unsupported by this font");
}
uint FontSJISBase::getFontHeight() const {
switch (_drawMode) {
case kOutlineMode:
@ -207,6 +214,25 @@ const uint8 *FontSJISBase::flipCharacter(const uint8 *glyph, const int w) const
}
#endif
const uint8 *FontSJISBase::makeFatCharacter(const uint8 *glyph, const int w) const {
// This is the EOB II FM-Towns implementation.
// The last bit to the right of each line is cut off so that the fat
// character actually has the same width as it would normally have.
if (w == 8) {
for (int i = 0; i < 16; ++i) {
_tempGlyph2[i] = *glyph | (*glyph >> 1);
glyph++;
}
} else {
for (int i = 0; i < 16; ++i) {
uint16 l = READ_BE_UINT16(glyph);
WRITE_BE_UINT16(&_tempGlyph2[i << 1], l | (l >> 1));
glyph += 2;
}
}
return _tempGlyph2;
}
void FontSJISBase::drawChar(void *dst, uint16 ch, int pitch, int bpp, uint32 c1, uint32 c2, int maxW, int maxH) const {
const uint8 *glyphSource = 0;
int width = 0, height = 0;
@ -243,11 +269,14 @@ void FontSJISBase::drawChar(void *dst, uint16 ch, int pitch, int bpp, uint32 c1,
return;
}
if (_fatPrint)
glyphSource = makeFatCharacter(glyphSource, width);
#ifndef DISABLE_FLIPPED_MODE
if (_flippedMode)
glyphSource = flipCharacter(glyphSource, width);
#endif
uint8 outline[18 * 18];
if (_drawMode == kOutlineMode) {
memset(outline, 0, sizeof(outline));
@ -409,7 +438,7 @@ const uint8 *FontTowns::getCharData(uint16 ch) const {
}
bool FontTowns::hasFeature(int feat) const {
static const int features = kFeatDefault | kFeatOutline | kFeatShadow | kFeatFMTownsShadow | kFeatFlipped;
static const int features = kFeatDefault | kFeatOutline | kFeatShadow | kFeatFMTownsShadow | kFeatFlipped | kFeatFatPrint;
return (features & feat) ? true : false;
}
@ -577,7 +606,7 @@ bool FontSjisSVM::hasFeature(int feat) const {
// Flipped mode is not supported since the hard coded table (taken from SCUMM 5 FM-TOWNS)
// is set up for font sizes of 8/16. This mode is also not required at the moment, since
// there aren't any SCUMM 5 PC-Engine games.
static const int features16 = kFeatDefault | kFeatOutline | kFeatShadow | kFeatFMTownsShadow | kFeatFlipped;
static const int features16 = kFeatDefault | kFeatOutline | kFeatShadow | kFeatFMTownsShadow | kFeatFlipped | kFeatFatPrint;
static const int features12 = kFeatDefault | kFeatOutline | kFeatShadow | kFeatFMTownsShadow;
return (((_fontWidth == 12) ? features12 : features16) & feat) ? true : false;
}

View file

@ -90,6 +90,11 @@ public:
virtual void setDrawingMode(DrawingMode mode) {}
/**
* Enable fat character drawing if supported by the Font (used in EOB II FM-Towns).
*/
virtual void toggleFatPrint(bool enable) {}
/**
* Enable flipped character drawing if supported by the Font (e.g. in the MI1 circus scene after Guybrush gets shot out of the cannon).
*/
@ -147,6 +152,8 @@ public:
virtual void toggleFlippedMode(bool enable);
virtual void toggleFatPrint(bool enable);
virtual uint getFontHeight() const;
virtual uint getMaxFontWidth() const;
@ -165,9 +172,11 @@ private:
const uint8 *flipCharacter(const uint8 *glyph, const int w) const;
mutable uint8 _tempGlyph[32];
#endif
const uint8 *makeFatCharacter(const uint8 *glyph, const int w) const;
mutable uint8 _tempGlyph2[32];
protected:
DrawingMode _drawMode;
bool _flippedMode;
bool _flippedMode, _fatPrint;
int _fontWidth, _fontHeight;
uint8 _bitPosNewLineMask;
@ -180,7 +189,8 @@ protected:
kFeatOutline = 1 << 1,
kFeatShadow = 1 << 2,
kFeatFMTownsShadow = 1 << 3,
kFeatFlipped = 1 << 4
kFeatFlipped = 1 << 4,
kFeatFatPrint = 1 << 5
};
virtual bool hasFeature(int feat) const = 0;