diff options
Diffstat (limited to 'engines/kyra/graphics')
-rw-r--r-- | engines/kyra/graphics/screen.cpp | 51 | ||||
-rw-r--r-- | engines/kyra/graphics/screen.h | 16 | ||||
-rw-r--r-- | engines/kyra/graphics/screen_eob.cpp | 12 | ||||
-rw-r--r-- | engines/kyra/graphics/screen_eob.h | 4 |
4 files changed, 45 insertions, 38 deletions
diff --git a/engines/kyra/graphics/screen.cpp b/engines/kyra/graphics/screen.cpp index 3bcbf3967e..e21344948f 100644 --- a/engines/kyra/graphics/screen.cpp +++ b/engines/kyra/graphics/screen.cpp @@ -65,6 +65,7 @@ Screen::Screen(KyraEngine_v1 *vm, OSystem *system, const ScreenDim *dimTable, co _4bitPixelPacking = false; _currentFont = FID_8_FNT; + _currentFontType = FTYPE_ASCII; _paletteChanged = true; _curDim = 0; } @@ -160,12 +161,21 @@ bool Screen::init() { } if (_useSJIS) { - Graphics::FontSJIS *font = Graphics::FontSJIS::createFont(_vm->gameFlags().platform); + Common::SharedPtr<Graphics::FontSJIS> font(Graphics::FontSJIS::createFont(_vm->gameFlags().platform)); - if (!font) + if (!font.get()) 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 && _vm->game() != GI_EOB2, _vm->game() == GI_EOB2 && _vm->gameFlags().platform == Common::kPlatformFMTowns, !_use16ColorMode && _vm->game() == GI_LOL ? 1 : 0); + if (_use16ColorMode) { + _fonts[FID_SJIS_TEXTMODE_FNT] = new SJISFont(font, _sjisInvisibleColor, true, false, _vm->game() == GI_EOB2 && _vm->gameFlags().platform == Common::kPlatformFMTowns, 0); + if (_vm->game() == GI_EOB1) + _fonts[FID_SJIS_FNT] = new SJISFont(font, _sjisInvisibleColor, false, false, _vm->game() == GI_EOB2 && _vm->gameFlags().platform == Common::kPlatformFMTowns, 0); + } else { + _fonts[FID_SJIS_FNT] = new SJISFont(font, _sjisInvisibleColor, false, _vm->game() != GI_LOL && _vm->game() != GI_EOB2, _vm->game() == GI_EOB2 && _vm->gameFlags().platform == Common::kPlatformFMTowns, _vm->game() == GI_LOL ? 1 : 0); + } + + if (_vm->game() == GI_EOB2 && _vm->gameFlags().platform == Common::kPlatformFMTowns) + _fonts[FID_SJIS_LARGE_FNT] = new SJISFontLarge(font); } } @@ -1397,6 +1407,7 @@ bool Screen::loadFont(FontId fontId, const char *filename) { Screen::FontId Screen::setFont(FontId fontId) { FontId prev = _currentFont; _currentFont = fontId; + _currentFontType = _currentFont >= FID_SJIS_FNT ? FTYPE_SJIS : FTYPE_ASCII; assert(_fonts[_currentFont]); return prev; @@ -1420,9 +1431,10 @@ int Screen::getTextWidth(const char *str) { int maxLineLen = 0; FontId curFont = _currentFont; + FontType curType = _currentFontType; while (1) { - if (_sjisMixedFontMode && curFont != FID_SJIS_FNT && curFont != FID_SJIS_LARGE_FNT && curFont != FID_SJIS_SMALL_FNT) + if (_sjisMixedFontMode && curType == FTYPE_ASCII) setFont((*str & 0x80) ? ((_vm->game() == GI_EOB2 && curFont == FID_6_FNT) ? FID_SJIS_SMALL_FNT : FID_SJIS_FNT) : curFont); uint c = fetchChar(str); @@ -1456,6 +1468,7 @@ void Screen::printText(const char *str, int x, int y, uint8 color1, uint8 color2 setTextColor(cmap8, 0, 1); FontId curFont = _currentFont; + FontType curType = _currentFontType; if (x < 0) x = 0; @@ -1469,7 +1482,7 @@ void Screen::printText(const char *str, int x, int y, uint8 color1, uint8 color2 return; while (1) { - if (_sjisMixedFontMode && curFont != FID_SJIS_FNT && curFont != FID_SJIS_LARGE_FNT && curFont != FID_SJIS_SMALL_FNT) + if (_sjisMixedFontMode && curType == FTYPE_ASCII) setFont((*str & 0x80) ? ((_vm->game() == GI_EOB2 && curFont == FID_6_FNT) ? FID_SJIS_SMALL_FNT : FID_SJIS_FNT) : curFont); uint8 charHeightFnt = getFontHeight(); @@ -1497,7 +1510,7 @@ void Screen::printText(const char *str, int x, int y, uint8 color1, uint8 color2 } uint16 Screen::fetchChar(const char *&s) const { - if (_currentFont != FID_SJIS_FNT && _currentFont != FID_SJIS_LARGE_FNT && _currentFont != FID_SJIS_SMALL_FNT) + if (_currentFontType == FTYPE_ASCII) return (uint8)*s++; uint16 ch = (uint8)*s++; @@ -1529,7 +1542,7 @@ void Screen::drawChar(uint16 c, int x, int y) { return; } - int bpp = (_currentFont == Screen::FID_SJIS_FNT || _currentFont == Screen::FID_SJIS_SMALL_FNT) ? 1 : 2; + int bpp = (_currentFont == Screen::FID_SJIS_LARGE_FNT) ? 2 : 1; destPage += (y * 2) * 640 * bpp + (x * 2 * bpp); fnt->drawChar(c, destPage, 640, bpp); @@ -3770,21 +3783,14 @@ void AMIGAFont::unload() { memset(_chars, 0, sizeof(_chars)); } -SJISFont::SJISFont(Graphics::FontSJIS *font, const uint8 invisColor, bool is16Color, bool drawOutline, bool fatPrint, int extraSpacing) - : _colorMap(0), _font(font), _invisColor(invisColor), _isTextMode(is16Color), _drawOutline(drawOutline), _sjisWidthOffset(extraSpacing) { +SJISFont::SJISFont(Common::SharedPtr<Graphics::FontSJIS> &font, const uint8 invisColor, bool is16Color, bool drawOutline, bool fatPrint, int extraSpacing) + : _colorMap(0), _font(font), _invisColor(invisColor), _isTextMode(is16Color), _drawOutline(drawOutline), _fatPrint(fatPrint), _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; } -void SJISFont::unload() { - delete _font; - _font = 0; -} - int SJISFont::getHeight() const { return _fontHeight; } @@ -3802,13 +3808,6 @@ int SJISFont::getCharWidth(uint16 c) const { void SJISFont::setColorMap(const uint8 *src) { _colorMap = src; - - if (!_isTextMode) { - if (_colorMap[0] == _invisColor) - _font->setDrawingMode(Graphics::FontSJIS::kDefaultMode); - else - _font->setDrawingMode(_drawOutline ? Graphics::FontSJIS::kOutlineMode : Graphics::FontSJIS::kDefaultMode); - } } void SJISFont::drawChar(uint16 c, byte *dst, int pitch, int) const { @@ -3824,6 +3823,12 @@ void SJISFont::drawChar(uint16 c, byte *dst, int pitch, int) const { color2 = _colorMap[0]; } + if (!_isTextMode && _colorMap[0] == _invisColor) + _font->setDrawingMode(Graphics::FontSJIS::kDefaultMode); + else + _font->setDrawingMode(_drawOutline ? Graphics::FontSJIS::kOutlineMode : Graphics::FontSJIS::kDefaultMode); + + _font->toggleFatPrint(_fatPrint); _font->drawChar(dst, c, 640, 1, color1, color2, 640, 400); } diff --git a/engines/kyra/graphics/screen.h b/engines/kyra/graphics/screen.h index c1a1cfefa5..d9d2831726 100644 --- a/engines/kyra/graphics/screen.h +++ b/engines/kyra/graphics/screen.h @@ -290,8 +290,8 @@ private: */ class SJISFont : public Font { public: - SJISFont(Graphics::FontSJIS *font, const uint8 invisColor, bool is16Color, bool drawOutline, bool fatPrint, int extraSpacing); - virtual ~SJISFont() { unload(); } + SJISFont(Common::SharedPtr<Graphics::FontSJIS> &font, const uint8 invisColor, bool is16Color, bool drawOutline, bool fatPrint, int extraSpacing); + virtual ~SJISFont() {} virtual bool usesOverlay() const { return true; } @@ -303,13 +303,12 @@ public: virtual void drawChar(uint16 c, byte *dst, int pitch, int) const; protected: - void unload(); - const uint8 *_colorMap; - Graphics::FontSJIS *_font; + Common::SharedPtr<Graphics::FontSJIS> _font; int _sjisWidth, _asciiWidth; int _fontHeight; const bool _drawOutline; + const bool _fatPrint; private: const uint8 _invisColor; @@ -485,11 +484,17 @@ public: FID_GOLDFONT_FNT, FID_INTRO_FNT, FID_SJIS_FNT, + FID_SJIS_TEXTMODE_FNT, FID_SJIS_LARGE_FNT, FID_SJIS_SMALL_FNT, FID_NUM }; + enum FontType { + FTYPE_ASCII = 0, + FTYPE_SJIS + }; + Screen(KyraEngine_v1 *vm, OSystem *system, const ScreenDim *dimTable, const int dimTableSize); virtual ~Screen(); @@ -629,6 +634,7 @@ public: uint8 *_shapePages[2]; int _maskMinY, _maskMaxY; FontId _currentFont; + FontType _currentFontType; // decoding functions static void decodeFrame1(const uint8 *src, uint8 *dst, uint32 size); diff --git a/engines/kyra/graphics/screen_eob.cpp b/engines/kyra/graphics/screen_eob.cpp index ad967fe5ed..e25ad3860c 100644 --- a/engines/kyra/graphics/screen_eob.cpp +++ b/engines/kyra/graphics/screen_eob.cpp @@ -92,13 +92,7 @@ bool Screen_EoB::init() { if (_vm->gameFlags().platform == Common::kPlatformFMTowns) { _shpBuffer = new uint8[SCREEN_H * SCREEN_W]; _convertHiColorBuffer = new uint8[SCREEN_H * SCREEN_W]; - enableHiColorMode(true); - - Graphics::FontSJIS *font = Graphics::FontSJIS::createFont(Common::kPlatformFMTowns); - if (!font) - error("Could not load any SJIS font, neither the original nor ScummVM's 'SJIS.FNT'"); - _fonts[FID_SJIS_LARGE_FNT] = new SJISFontLarge(font); - + enableHiColorMode(true); loadFont(FID_SJIS_SMALL_FNT, "FONT.DMP"); } @@ -2519,13 +2513,15 @@ void AmigaDOSFont::selectMode(int mode) { _last = _content[mode].data->lastChar; } -SJISFontLarge::SJISFontLarge(Graphics::FontSJIS *font) : SJISFont(font, 0, false, false, false, 0) { +SJISFontLarge::SJISFontLarge(Common::SharedPtr<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, int) const { + _font->setDrawingMode(Graphics::FontSJIS::kDefaultMode); + _font->toggleFatPrint(false); _font->drawChar(dst, c, 320, 1, _colorMap[1], _colorMap[0], 320, 200); } diff --git a/engines/kyra/graphics/screen_eob.h b/engines/kyra/graphics/screen_eob.h index b457ba2c83..4f9161af92 100644 --- a/engines/kyra/graphics/screen_eob.h +++ b/engines/kyra/graphics/screen_eob.h @@ -162,8 +162,8 @@ private: */ class SJISFontLarge : public SJISFont { public: - SJISFontLarge(Graphics::FontSJIS *font); - virtual ~SJISFontLarge() { unload(); } + SJISFontLarge(Common::SharedPtr<Graphics::FontSJIS> &font); + virtual ~SJISFontLarge() {} virtual bool usesOverlay() const { return false; } virtual void drawChar(uint16 c, byte *dst, int pitch, int) const; |