diff options
author | Colin Snover | 2017-02-07 15:27:15 -0600 |
---|---|---|
committer | Colin Snover | 2017-04-22 19:25:20 -0500 |
commit | ede7976ede9121d52932b4b0780e6adc68f6e35d (patch) | |
tree | 09a5239e8bfc772544df05b8ea6d524c7195355f | |
parent | c6cf7215f0f620dc4a155ca79510a44db13370fc (diff) | |
download | scummvm-rg350-ede7976ede9121d52932b4b0780e6adc68f6e35d.tar.gz scummvm-rg350-ede7976ede9121d52932b4b0780e6adc68f6e35d.tar.bz2 scummvm-rg350-ede7976ede9121d52932b4b0780e6adc68f6e35d.zip |
SCI32: Fix bad kPointSize implementation
Fixes text scaling gone mad in Phant2.
-rw-r--r-- | engines/sci/engine/kernel.h | 2 | ||||
-rw-r--r-- | engines/sci/engine/kernel_tables.h | 8 | ||||
-rw-r--r-- | engines/sci/engine/kgraphics32.cpp | 8 | ||||
-rw-r--r-- | engines/sci/graphics/text32.cpp | 5 | ||||
-rw-r--r-- | engines/sci/graphics/text32.h | 5 |
5 files changed, 17 insertions, 11 deletions
diff --git a/engines/sci/engine/kernel.h b/engines/sci/engine/kernel.h index 2b61a9e0d9..c648cd0323 100644 --- a/engines/sci/engine/kernel.h +++ b/engines/sci/engine/kernel.h @@ -651,7 +651,7 @@ reg_t kCelInfoGetPixel(EngineState *s, int argc, reg_t *argv); reg_t kSetLanguage(EngineState *s, int argc, reg_t *argv); reg_t kScrollWindow(EngineState *s, int argc, reg_t *argv); -reg_t kSetFontHeight(EngineState *s, int argc, reg_t *argv); +reg_t kPointSize(EngineState *s, int argc, reg_t *argv); reg_t kSetFontRes(EngineState *s, int argc, reg_t *argv); reg_t kFont(EngineState *s, int argc, reg_t *argv); reg_t kAddLine(EngineState *s, int argc, reg_t *argv); diff --git a/engines/sci/engine/kernel_tables.h b/engines/sci/engine/kernel_tables.h index 77f1aa134c..fd3f4bdb2d 100644 --- a/engines/sci/engine/kernel_tables.h +++ b/engines/sci/engine/kernel_tables.h @@ -369,7 +369,7 @@ static const SciKernelMapSubEntry kSave_subops[] = { // version, subId, function-mapping, signature, workarounds static const SciKernelMapSubEntry kFont_subops[] = { - { SIG_SINCE_SCI21MID, 0, MAP_CALL(SetFontHeight), "i", NULL }, + { SIG_SINCE_SCI21MID, 0, MAP_CALL(PointSize), "i", NULL }, { SIG_SINCE_SCI21MID, 1, MAP_CALL(SetFontRes), "ii", NULL }, SCI_SUBOPENTRY_TERMINATOR }; @@ -937,7 +937,7 @@ static SciKernelMapEntry s_kernelMap[] = { { MAP_DUMMY(InvertRect), SIG_THRU_SCI21EARLY, SIGFOR_ALL, "(.*)", NULL, NULL }, { MAP_DUMMY(InputText), SIG_EVERYWHERE, "(.*)", NULL, NULL }, { MAP_CALL(TextWidth), SIG_THRU_SCI21EARLY, SIGFOR_ALL, "ri", NULL, NULL }, - { MAP_DUMMY(PointSize), SIG_EVERYWHERE, "(.*)", NULL, NULL }, + { MAP_CALL(PointSize), SIG_THRU_SCI21EARLY, SIGFOR_ALL, "i", NULL, NULL }, // SCI2.1 Kernel Functions { "CheckCDisc", kCheckCD, SIG_SCI21EARLY, SIGFOR_ALL, "(i)", NULL, NULL }, @@ -1314,8 +1314,8 @@ static const char *const sci2_default_knames[] = { /*0x86*/ "CheckIntegrity", // for debugging /*0x87*/ "ObjectIntersect", /*0x88*/ "MarkMemory", // for debugging - /*0x89*/ "TextWidth", // for debugging(?), only in SCI2, not used in any SCI2 game - /*0x8a*/ "PointSize", // for debugging(?), only in SCI2, not used in any SCI2 game + /*0x89*/ "TextWidth", + /*0x8a*/ "PointSize", /*0x8b*/ "AddLine", /*0x8c*/ "DeleteLine", diff --git a/engines/sci/engine/kgraphics32.cpp b/engines/sci/engine/kgraphics32.cpp index ae84e6b8a5..f332e17b29 100644 --- a/engines/sci/engine/kgraphics32.cpp +++ b/engines/sci/engine/kgraphics32.cpp @@ -608,13 +608,9 @@ reg_t kFont(EngineState *s, int argc, reg_t *argv) { error("not supposed to call this"); } -reg_t kSetFontHeight(EngineState *s, int argc, reg_t *argv) { - // TODO: Setting font may have just been for side effect - // of setting the fontHeight on the font manager, in - // which case we could just get the font directly ourselves. +reg_t kPointSize(EngineState *s, int argc, reg_t *argv) { g_sci->_gfxText32->setFont(argv[0].toUint16()); - g_sci->_gfxText32->_yResolution = (g_sci->_gfxText32->_font->getHeight() * g_sci->_gfxFrameout->getCurrentBuffer().scriptHeight + g_sci->_gfxText32->_yResolution - 1) / g_sci->_gfxText32->_yResolution; - return make_reg(0, g_sci->_gfxText32->_yResolution); + return make_reg(0, g_sci->_gfxText32->getScaledFontHeight()); } reg_t kSetFontRes(EngineState *s, int argc, reg_t *argv) { diff --git a/engines/sci/graphics/text32.cpp b/engines/sci/graphics/text32.cpp index a017a2fcc5..7399fe0268 100644 --- a/engines/sci/graphics/text32.cpp +++ b/engines/sci/graphics/text32.cpp @@ -216,6 +216,11 @@ void GfxText32::drawChar(const char charIndex) { _drawPosition.x += _font->getCharWidth((unsigned char)charIndex); } +int16 GfxText32::getScaledFontHeight() const { + const int16 scriptHeight = g_sci->_gfxFrameout->getCurrentBuffer().scriptHeight; + return (_font->getHeight() * scriptHeight + _yResolution - 1) / _yResolution; +} + uint16 GfxText32::getCharWidth(const char charIndex, const bool doScaling) const { uint16 width = _font->getCharWidth((unsigned char)charIndex); if (doScaling) { diff --git a/engines/sci/graphics/text32.h b/engines/sci/graphics/text32.h index bfd5ebc606..c8fafb287f 100644 --- a/engines/sci/graphics/text32.h +++ b/engines/sci/graphics/text32.h @@ -236,6 +236,11 @@ public: void setFont(const GuiResourceId fontId); /** + * Gets the pixel height of the currently loaded font. + */ + int16 getScaledFontHeight() const; + + /** * Gets the width of a character. */ uint16 getCharWidth(const char charIndex, const bool doScaling) const; |