diff options
Diffstat (limited to 'engines/sci/graphics/text16.cpp')
-rw-r--r-- | engines/sci/graphics/text16.cpp | 79 |
1 files changed, 73 insertions, 6 deletions
diff --git a/engines/sci/graphics/text16.cpp b/engines/sci/graphics/text16.cpp index f5eb268863..3fba3006c7 100644 --- a/engines/sci/graphics/text16.cpp +++ b/engines/sci/graphics/text16.cpp @@ -30,6 +30,7 @@ #include "sci/sci.h" #include "sci/engine/state.h" #include "sci/graphics/cache.h" +#include "sci/graphics/coordadjuster.h" #include "sci/graphics/ports.h" #include "sci/graphics/paint16.h" #include "sci/graphics/font.h" @@ -88,7 +89,7 @@ void GfxText16::ClearChar(int16 chr) { // will process the encountered code and set new font/set color. We only support // one-digit codes currently, don't know if multi-digit codes are possible. // Returns textcode character count. -int16 GfxText16::CodeProcessing(const char *&text, GuiResourceId orgFontId, int16 orgPenColor) { +int16 GfxText16::CodeProcessing(const char *&text, GuiResourceId orgFontId, int16 orgPenColor, bool doingDrawing) { const char *textCode = text; int16 textCodeSize = 0; char curCode; @@ -126,8 +127,20 @@ int16 GfxText16::CodeProcessing(const char *&text, GuiResourceId orgFontId, int1 } } break; - case 'r': // reference?! - // Used in Pepper, no idea how this works out + case 'r': // reference (used in pepper) + if (doingDrawing) { + if (_codeRefTempRect.top == -1) { + // Starting point + _codeRefTempRect.top = _ports->_curPort->curTop; + _codeRefTempRect.left = _ports->_curPort->curLeft; + } else { + // End point reached + _codeRefTempRect.bottom = _ports->_curPort->curTop + _ports->_curPort->fontHeight; + _codeRefTempRect.right = _ports->_curPort->curLeft; + _codeRefRects.push_back(_codeRefTempRect); + _codeRefTempRect.left = _codeRefTempRect.top = -1; + } + } break; } return textCodeSize; @@ -162,7 +175,7 @@ int16 GfxText16::GetLongest(const char *text, int16 maxWidth, GuiResourceId orgF case 0x7C: if (getSciVersion() >= SCI_VERSION_1_1) { curCharCount++; - curCharCount += CodeProcessing(text, orgFontId, previousPenColor); + curCharCount += CodeProcessing(text, orgFontId, previousPenColor, false); continue; } break; @@ -258,7 +271,7 @@ void GfxText16::Width(const char *text, int16 from, int16 len, GuiResourceId org break; case 0x7C: if (getSciVersion() >= SCI_VERSION_1_1) { - len -= CodeProcessing(text, orgFontId, 0); + len -= CodeProcessing(text, orgFontId, 0, false); break; } default: @@ -359,7 +372,7 @@ void GfxText16::Draw(const char *text, int16 from, int16 len, GuiResourceId orgF break; case 0x7C: if (getSciVersion() >= SCI_VERSION_1_1) { - len -= CodeProcessing(text, orgFontId, orgPenColor); + len -= CodeProcessing(text, orgFontId, orgPenColor, true); break; } default: @@ -408,6 +421,10 @@ void GfxText16::Box(const char *text, int16 bshow, const Common::Rect &rect, Tex doubleByteMode = true; } + // Reset reference code rects + _codeRefRects.clear(); + _codeRefTempRect.left = _codeRefTempRect.top = -1; + maxTextWidth = 0; while (*text) { charCount = GetLongest(text, rect.width(), fontId); @@ -474,6 +491,32 @@ void GfxText16::Draw_String(const char *text) { _ports->penColor(previousPenColor); } +// we need to have a separate status drawing code +// In KQ4 the IV char is actually 0xA, which would otherwise get considered as linebreak and not printed +void GfxText16::Draw_Status(const char *text) { + uint16 curChar, charWidth; + uint16 textLen = strlen(text); + Common::Rect rect; + + GetFont(); + if (!_font) + return; + + rect.top = _ports->_curPort->curTop; + rect.bottom = rect.top + _ports->_curPort->fontHeight; + while (textLen--) { + curChar = (*(const byte *)text++); + switch (curChar) { + case 0: + break; + default: + charWidth = _font->getCharWidth(curChar); + _font->draw(curChar, _ports->_curPort->top + _ports->_curPort->curTop, _ports->_curPort->left + _ports->_curPort->curLeft, _ports->_curPort->penClr, _ports->_curPort->greyedOutput); + _ports->_curPort->curLeft += charWidth; + } + } +} + // Sierra did this in their PC98 interpreter only, they identify a text as being // sjis and then switch to font 900 bool GfxText16::SwitchToFont900OnSjis(const char *text) { @@ -485,6 +528,30 @@ bool GfxText16::SwitchToFont900OnSjis(const char *text) { return false; } +reg_t GfxText16::allocAndFillReferenceRectArray() { + uint rectCount = _codeRefRects.size(); + if (rectCount) { + reg_t rectArray; + byte *rectArrayPtr = g_sci->getEngineState()->_segMan->allocDynmem(4 * 2 * (rectCount + 1), "text code reference rects", &rectArray); + GfxCoordAdjuster *coordAdjuster = g_sci->_gfxCoordAdjuster; + for (uint curRect = 0; curRect < rectCount; curRect++) { + coordAdjuster->kernelLocalToGlobal(_codeRefRects[curRect].left, _codeRefRects[curRect].top); + coordAdjuster->kernelLocalToGlobal(_codeRefRects[curRect].right, _codeRefRects[curRect].bottom); + WRITE_LE_UINT16(rectArrayPtr + 0, _codeRefRects[curRect].left); + WRITE_LE_UINT16(rectArrayPtr + 2, _codeRefRects[curRect].top); + WRITE_LE_UINT16(rectArrayPtr + 4, _codeRefRects[curRect].right); + WRITE_LE_UINT16(rectArrayPtr + 6, _codeRefRects[curRect].bottom); + rectArrayPtr += 8; + } + WRITE_LE_UINT16(rectArrayPtr + 0, 0x7777); + WRITE_LE_UINT16(rectArrayPtr + 2, 0x7777); + WRITE_LE_UINT16(rectArrayPtr + 4, 0x7777); + WRITE_LE_UINT16(rectArrayPtr + 6, 0x7777); + return rectArray; + } + return NULL_REG; +} + void GfxText16::kernelTextSize(const char *text, int16 font, int16 maxWidth, int16 *textWidth, int16 *textHeight) { Common::Rect rect(0, 0, 0, 0); Size(rect, text, font, maxWidth); |