From 8d339d00df356b37a8cb6286632857d20c554851 Mon Sep 17 00:00:00 2001 From: athrxx Date: Fri, 11 Mar 2022 15:57:58 +0100 Subject: [PATCH] KYRA: (EOB II/PC98) - font/layout fixes --- engines/kyra/engine/chargen.cpp | 6 +++--- engines/kyra/engine/eobcommon.cpp | 12 ++++++++---- engines/kyra/engine/eobcommon.h | 2 ++ engines/kyra/graphics/screen_eob.cpp | 18 +++++++++++------- engines/kyra/graphics/screen_eob.h | 6 +++++- engines/kyra/graphics/screen_eob_pc98.cpp | 2 +- engines/kyra/gui/gui_eob.cpp | 16 +++++++++------- engines/kyra/gui/gui_eob.h | 2 ++ engines/kyra/resource/staticres_eob.cpp | 8 ++++++++ 9 files changed, 49 insertions(+), 23 deletions(-) diff --git a/engines/kyra/engine/chargen.cpp b/engines/kyra/engine/chargen.cpp index 8d9acc57664..704e032ba24 100644 --- a/engines/kyra/engine/chargen.cpp +++ b/engines/kyra/engine/chargen.cpp @@ -2086,7 +2086,7 @@ bool TransferPartyWiz::selectAndLoadTransferFile() { int TransferPartyWiz::selectCharactersMenu() { _screen->setCurPage(2); - _screen->setFont(Screen::FID_6_FNT); + Screen::FontId of = _screen->setFont(Screen::FID_6_FNT); _screen->clearCurPage(); _vm->gui_drawBox(0, 0, 320, 163, _vm->guiSettings()->colors.frame1, _vm->guiSettings()->colors.frame2, _vm->guiSettings()->colors.fill); @@ -2166,7 +2166,7 @@ int TransferPartyWiz::selectCharactersMenu() { _screen->updateScreen(); if (highlight == 6 || _vm->shouldQuit()) { - _screen->setFont(Screen::FID_8_FNT); + _screen->setFont(of); return 0; } @@ -2184,7 +2184,7 @@ int TransferPartyWiz::selectCharactersMenu() { _screen->updateScreen(); } - _screen->setFont(Screen::FID_8_FNT); + _screen->setFont(of); if (_vm->shouldQuit()) return 0; else diff --git a/engines/kyra/engine/eobcommon.cpp b/engines/kyra/engine/eobcommon.cpp index 496ce020d6e..cc1f78ddb01 100644 --- a/engines/kyra/engine/eobcommon.cpp +++ b/engines/kyra/engine/eobcommon.cpp @@ -197,7 +197,7 @@ EoBCoreEngine::EoBCoreEngine(OSystem *system, const GameFlags &flags) : KyraRpgE _buttonList3Size = _buttonList4Size = _buttonList5Size = _buttonList6Size = 0; _buttonList7Size = _buttonList8Size = 0; _inventorySlotsY = _mnDef = 0; - _invFont1 = _invFont2 = _conFont = Screen::FID_6_FNT; + _invFont1 = _invFont2 = _invFont4 = _conFont = _bookFont = Screen::FID_6_FNT; _invFont3 = Screen::FID_8_FNT; _transferStringsScummVM = 0; _buttonDefs = 0; @@ -578,6 +578,7 @@ void EoBCoreEngine::loadFonts() { } else if (_flags.gameID == GI_EOB2 && _flags.platform == Common::kPlatformPC98) { _screen->loadFont(Screen::FID_6_FNT, "FONT6B.FNT"); _screen->loadFont(Screen::FID_8_FNT, "FONT8B.FNT"); + _screen->loadFont(Screen::FID_SJIS_SMALL_FNT, "FONT1206.FNT"); } else if (_flags.platform != Common::kPlatformSegaCD) { _screen->loadFont(Screen::FID_6_FNT, "FONT6.FNT"); _screen->loadFont(Screen::FID_8_FNT, "FONT8.FNT"); @@ -586,13 +587,16 @@ void EoBCoreEngine::loadFonts() { if (_flags.platform == Common::kPlatformFMTowns) { _screen->loadFont(Screen::FID_SJIS_SMALL_FNT, "FONT.DMP"); } else if (_flags.platform == Common::kPlatformPC98) { - _screen->loadFont(Screen::FID_SJIS_SMALL_FNT, _flags.gameID == GI_EOB1 ? "FONT12.FNT" : "FONT1206.FNT"); - _invFont1 = Screen::FID_SJIS_SMALL_FNT; + if (_flags.gameID == GI_EOB1) { + _screen->loadFont(Screen::FID_SJIS_SMALL_FNT, "FONT12.FNT"); + _invFont1 = _bookFont = Screen::FID_SJIS_SMALL_FNT; + _invFont4 = Screen::FID_SJIS_FNT; + } _conFont = _invFont3 = Screen::FID_SJIS_FNT; } else if (_flags.platform == Common::kPlatformSegaCD) { _screen->loadFont(Screen::FID_8_FNT, "FONTK12"); _screen->setFontStyles(Screen::FID_8_FNT, Font::kStyleNone); - _invFont1 = _invFont2 = _conFont = Screen::FID_8_FNT; + _invFont1 = _invFont2 = _invFont4 = _conFont = Screen::FID_8_FNT; } if (_flags.lang == Common::ZH_TWN) { diff --git a/engines/kyra/engine/eobcommon.h b/engines/kyra/engine/eobcommon.h index df416df4feb..123c024eb1d 100644 --- a/engines/kyra/engine/eobcommon.h +++ b/engines/kyra/engine/eobcommon.h @@ -834,7 +834,9 @@ protected: Screen::FontId _invFont1; Screen::FontId _invFont2; Screen::FontId _invFont3; + Screen::FontId _invFont4; Screen::FontId _conFont; + Screen::FontId _bookFont; const uint8 **_compassShapes; uint8 _charExchangeSwap; uint8 *_swapShape; diff --git a/engines/kyra/graphics/screen_eob.cpp b/engines/kyra/graphics/screen_eob.cpp index 39bdb50c0ea..beaec3772b6 100644 --- a/engines/kyra/graphics/screen_eob.cpp +++ b/engines/kyra/graphics/screen_eob.cpp @@ -1708,12 +1708,16 @@ bool Screen_EoB::loadFont(FontId fontId, const char *filename) { fnt = nullptr; } - if (fontId == FID_SJIS_SMALL_FNT) { + if (_vm->gameFlags().platform == Common::kPlatformPC98 && _vm->game() == GI_EOB2) { + // We use normal VGA rendering in EOB II, since we do the complete EGA dithering in updateScreen(). + fnt = new OldDOSFont(_useHiResEGADithering ? Common::kRenderVGA : _renderMode, 12, 256, fontId == FID_SJIS_SMALL_FNT); + } else if (fontId == FID_SJIS_SMALL_FNT) { if (_vm->gameFlags().platform == Common::kPlatformFMTowns) fnt = new SJISFont12x12(_vm->staticres()->loadRawDataBe16(kEoB2FontDmpSearchTbl, temp)); - else if (_vm->gameFlags().platform == Common::kPlatformPC98) + else if (_vm->gameFlags().platform == Common::kPlatformPC98) { fnt = new Font12x12PC98(12, _vm->staticres()->loadRawDataBe16(kEoB1Ascii2SjisTable1, temp), _vm->staticres()->loadRawDataBe16(kEoB1Ascii2SjisTable2, temp), _vm->staticres()->loadRawData(kEoB1FontLookupTable, temp)); + } } else if (_isAmiga) { fnt = new AmigaDOSFont(_vm->resource(), _vm->game() == GI_EOB2 && _vm->gameFlags().lang == Common::DE_DEU); } else if (_isSegaCD) { @@ -1728,7 +1732,7 @@ bool Screen_EoB::loadFont(FontId fontId, const char *filename) { return true; } else { // We use normal VGA rendering in EOB II, since we do the complete EGA dithering in updateScreen(). - fnt = new OldDOSFont(_useHiResEGADithering ? Common::kRenderVGA : _renderMode, 12); + fnt = new OldDOSFont(_useHiResEGADithering ? Common::kRenderVGA : _renderMode, 12, 128); } assert(fnt); @@ -1977,7 +1981,7 @@ const uint8 Screen_EoB::_egaMatchTable[] = { uint16 *OldDOSFont::_cgaDitheringTable = 0; int OldDOSFont::_numRef = 0; -OldDOSFont::OldDOSFont(Common::RenderMode mode, uint8 shadowColor) : _renderMode(mode), _shadowColor(shadowColor), _colorMap8bit(0), _colorMap16bit(0) { +OldDOSFont::OldDOSFont(Common::RenderMode mode, uint8 shadowColor, uint16 numGlyphMax, bool useOverlay) : _renderMode(mode), _shadowColor(shadowColor), _numGlyphMax(numGlyphMax), _useOverlay(useOverlay), _colorMap8bit(0), _colorMap16bit(0) { _data = 0; _width = _height = _numGlyphs = 0; _bitmapOffsets = 0; @@ -2045,11 +2049,11 @@ bool OldDOSFont::load(Common::SeekableReadStream &file) { if (file.size() - 2 != READ_LE_UINT16(_data)) return false; - _width = _data[0x103]; - _height = _data[0x102]; + _width = _data[_numGlyphMax * 2 + 3]; + _height = _data[_numGlyphMax * 2 + 2]; _numGlyphs = (READ_LE_UINT16(_data + 2) / 2) - 2; - _bitmapOffsets = (uint16 *)(_data + 2); + _bitmapOffsets = (uint16*)(_data + 2); for (int i = 0; i < _numGlyphs; ++i) _bitmapOffsets[i] = READ_LE_UINT16(&_bitmapOffsets[i]); diff --git a/engines/kyra/graphics/screen_eob.h b/engines/kyra/graphics/screen_eob.h index 00c618e8527..4f7fc8efcf5 100644 --- a/engines/kyra/graphics/screen_eob.h +++ b/engines/kyra/graphics/screen_eob.h @@ -262,7 +262,7 @@ private: */ class OldDOSFont : public Font { public: - OldDOSFont(Common::RenderMode mode, uint8 shadowColor); + OldDOSFont(Common::RenderMode mode, uint8 shadowColor, uint16 _numGlyphMax, bool _useOverlay = false); ~OldDOSFont() override; bool load(Common::SeekableReadStream &file) override; @@ -270,6 +270,7 @@ public: Type getType() const override { return kASCII; } int getHeight() const override { return _height; } int getWidth() const override { return _width; } + bool usesOverlay() const override { return _useOverlay; } int getCharWidth(uint16 c) const override; void setColorMap(const uint8 *src) override; void set16bitColorMap(const uint16 *src) override { _colorMap16bit = src; } @@ -293,6 +294,9 @@ private: Common::RenderMode _renderMode; const uint16 *_colorMap16bit; + const uint16 _numGlyphMax; + const bool _useOverlay; + static uint16 *_cgaDitheringTable; static int _numRef; }; diff --git a/engines/kyra/graphics/screen_eob_pc98.cpp b/engines/kyra/graphics/screen_eob_pc98.cpp index 179ad900199..9d4f441b1dc 100644 --- a/engines/kyra/graphics/screen_eob_pc98.cpp +++ b/engines/kyra/graphics/screen_eob_pc98.cpp @@ -209,7 +209,7 @@ uint16 SJISFontEoB1PC98::convert(uint16 c) const { return c; } -Font12x12PC98::Font12x12PC98(uint8 shadowColor, const uint16 *convTable1, const uint16 *convTable2, const uint8 *lookupTable) : OldDOSFont(Common::kRenderDefault, 12), +Font12x12PC98::Font12x12PC98(uint8 shadowColor, const uint16 *convTable1, const uint16 *convTable2, const uint8 *lookupTable) : OldDOSFont(Common::kRenderDefault, 12, 0), _convTable1(convTable1), _convTable2(convTable2) { assert(convTable1); assert(convTable2); diff --git a/engines/kyra/gui/gui_eob.cpp b/engines/kyra/gui/gui_eob.cpp index 06b637b00a6..8b504b79ed2 100644 --- a/engines/kyra/gui/gui_eob.cpp +++ b/engines/kyra/gui/gui_eob.cpp @@ -218,8 +218,9 @@ void EoBCoreEngine::gui_drawCharPortraitWithStats(int index, bool screenUpdt) { _screen->updateScreen(); } else { - _screen->setFont(cf); + _screen->setFont(_invFont4); gui_drawCharacterStatsPage(); + _screen->setFont(cf); } _screen->_curPage = 0; @@ -650,7 +651,7 @@ void EoBCoreEngine::gui_drawSpellbook() { int numTab = (_flags.gameID == GI_EOB1) ? 5 : 6; _screen->copyRegion(64, 121, 64, 121, 112, 56, 0, 2, Screen::CR_NO_P_CHECK); - Screen::FontId of = (_flags.gameID == GI_EOB1 && _flags.platform == Common::kPlatformPC98) ? _screen->setFont(Screen::FID_SJIS_SMALL_FNT) : _screen->_currentFont; + Screen::FontId of = _screen->setFont(_bookFont); for (int i = 0; i < numTab; i++) { int col1 = 0; @@ -1512,9 +1513,10 @@ void EoBCoreEngine::gui_processInventorySlotClick(int slot) { } } -GUI_EoB::GUI_EoB(EoBCoreEngine *vm) : GUI(vm), _vm(vm), _screen(vm->_screen), _numSlotsVisible(vm->gameFlags().platform == Common::kPlatformSegaCD ? 5 : 6) { - _menuStringsPrefsTemp = new char*[4](); +GUI_EoB::GUI_EoB(EoBCoreEngine *vm) : GUI(vm), _vm(vm), _screen(vm->_screen), _numSlotsVisible(vm->gameFlags().platform == Common::kPlatformSegaCD ? 5 : 6), + _menuFont(_vm->gameFlags().platform == Common::kPlatformPC98 ? Screen::FID_SJIS_FNT : (_vm->_flags.lang == Common::Language::ZH_TWN ? Screen::FID_CHINESE_FNT : Screen::FID_8_FNT)) { + _menuStringsPrefsTemp = new char*[4](); _saveSlotStringsTemp = new char*[6]; for (int i = 0; i < 6; i++) { _saveSlotStringsTemp[i] = new char[52](); @@ -2303,7 +2305,7 @@ void GUI_EoB::simpleMenu_flashSelection(const char *str, int x, int y, int color } void GUI_EoB::runCampMenu() { - Screen::FontId of = _screen->setFont(_vm->_flags.lang == Common::Language::ZH_TWN ? Screen::FID_CHINESE_FNT : _vm->_flags.use16ColorMode ? Screen::FID_SJIS_FNT : Screen::FID_8_FNT); + Screen::FontId of = _screen->setFont(_menuFont); Button *highlightButton = 0; Button *prevHighlightButton = 0; @@ -2633,7 +2635,7 @@ bool GUI_EoB::runLoadMenu(int x, int y, bool fromMainMenu) { bool GUI_EoB::confirmDialogue2(int dim, int id, int deflt) { int od = _screen->curDimIndex(); - Screen::FontId of = _screen->setFont(_vm->_flags.lang == Common::Language::ZH_TWN ? Screen::FontId::FID_CHINESE_FNT : _vm->_flags.use16ColorMode ? Screen::FID_SJIS_FNT : Screen::FID_8_FNT); + Screen::FontId of = _screen->setFont(_menuFont); _screen->setScreenDim(dim); drawTextBox(dim, id); @@ -2702,7 +2704,7 @@ bool GUI_EoB::confirmDialogue2(int dim, int id, int deflt) { void GUI_EoB::messageDialogue(int dim, int id, int buttonTextCol) { int od = _screen->curDimIndex(); _screen->setScreenDim(dim); - Screen::FontId of = _screen->setFont(_vm->_flags.lang == Common::Language::ZH_TWN ? Screen::FontId::FID_CHINESE_FNT : _vm->_flags.use16ColorMode ? Screen::FID_SJIS_FNT : Screen::FID_8_FNT); + Screen::FontId of = _screen->setFont(_menuFont); drawTextBox(dim, id); const ScreenDim *dm = _screen->getScreenDim(dim); diff --git a/engines/kyra/gui/gui_eob.h b/engines/kyra/gui/gui_eob.h index b9cce3bbee6..8f42fce5d50 100644 --- a/engines/kyra/gui/gui_eob.h +++ b/engines/kyra/gui/gui_eob.h @@ -174,6 +174,8 @@ private: const uint8 *_highLightColorTable; uint32 _highLightBoxTimer; + const Screen::FontId _menuFont; + const EoBRect16 *_highlightFrames; static const EoBRect16 _highlightFramesDefault[]; static const uint8 _highlightColorTableVGA[]; diff --git a/engines/kyra/resource/staticres_eob.cpp b/engines/kyra/resource/staticres_eob.cpp index 3ef199dd230..63d8de46380 100644 --- a/engines/kyra/resource/staticres_eob.cpp +++ b/engines/kyra/resource/staticres_eob.cpp @@ -1876,6 +1876,13 @@ void DarkMoonEngine::initStaticResource() { "Escoge Fichero", "\r\r Un momento\r por favor..." }, + { + "\x82""d""\x82""n""\x82""a""\x82""h""\x82\xcc\x83""f""\x81""[""\x83""^""\x81""iEOBDATA.SAV""\x81""j""\x82\xaa\x8c\xa9\x82\xc2\x82\xa9\x82\xe8\x82\xdc\x82\xb9\x82\xf1\x81""B""\x83""J""\x83\x8c\x83\x93\x83""g""\x83""f""\x83""B""\x83\x8c\x83""N""\x83""g""\x83\x8a\x82\xc9\x93""]""\x91\x97\x82\xb5\x82\xc4\x82\xa9\x82\xe7\x8e\xc0\x8d""s""\x82\xb5\x82\xc4\x89\xba\x82\xb3\x82\xa2\x81""B", + "\x83\x51\x81\x5B\x83\x80\x82\x68\x82\x63", + "\x82""d""\x82""n""\x82""a""\x82""h""\x82\xcc\x83""f""\x81""[""\x83""^""\x81""iEOBDATA.SAV""\x81""j""\x82\xaa\x8c\xa9\x82\xc2\x82\xa9\x82\xe8\x82\xdc\x82\xb9\x82\xf1\x81""B""\x83""J""\x83\x8c\x83\x93\x83""g""\x83""f""\x83""B""\x83\x8c\x83""N""\x83""g""\x83\x8a\x82\xc9\x93""]""\x91\x97\x82\xb5\x82\xc4\x82\xa9\x82\xe7\x8e\xc0\x8d""s""\x82\xb5\x82\xc4\x89\xba\x82\xb3\x82\xa2\x81""B", + "\x83\x51\x81\x5B\x83\x80\x82\xf0\x91\x49\x82\xf1\x82\xc5\x89\xba\x82\xb3\x82\xa2\x81\x42", + "\r\r \x82\xa8\x91\xd2\x82\xbF\x89\xba\x82\xb3\x82\xa2\x81""E""\x81""E""\x81""E" + } }; switch(_flags.lang) { @@ -1892,6 +1899,7 @@ void DarkMoonEngine::initStaticResource() { _errorSlotNoNameString = errorSlotNoNameString[2]; _transferStringsScummVM = transferStringsScummVM[2]; break; + case Common::JA_JPN: case Common::ZH_TWN: _errorSlotNoNameString = errorSlotNoNameString[3]; _transferStringsScummVM = transferStringsScummVM[0];