diff options
Diffstat (limited to 'engines/sherlock/fonts.cpp')
-rw-r--r-- | engines/sherlock/fonts.cpp | 83 |
1 files changed, 75 insertions, 8 deletions
diff --git a/engines/sherlock/fonts.cpp b/engines/sherlock/fonts.cpp index 482e795b6d..dc7ecd521e 100644 --- a/engines/sherlock/fonts.cpp +++ b/engines/sherlock/fonts.cpp @@ -43,7 +43,7 @@ void Fonts::setVm(SherlockEngine *vm) { _charCount = 0; } -void Fonts::free() { +void Fonts::freeFont() { delete _font; } @@ -53,6 +53,15 @@ void Fonts::setFont(int fontNum) { // Discard previous font delete _font; + if (IS_SERRATED_SCALPEL) { + // Scalpel + if ((_vm->isDemo()) && (!_vm->_interactiveFl)) { + // Do not set up any font for the non-interactive demo of scalpel + // The non-interactive demo does not contain any font at all + return; + } + } + Common::String fontFilename; if (_vm->getPlatform() != Common::kPlatform3DO) { @@ -62,6 +71,43 @@ void Fonts::setFont(int fontNum) { // load font data _font = new ImageFile(fontFilename); + + if (IS_SERRATED_SCALPEL) { + if (_vm->getLanguage() == Common::ES_ESP) { + if (_fontNumber == 1) { + // Create a new character - inverted exclamation mark (0x88) + // Seems this wasn't included originally, but some text has it + // This was obviously not done in the original game interpreter + ImageFrame &frameExclamationMark = (*_font)[0]; // get actual exclamation mark + ImageFrame frameRevExclamationMark; + + frameRevExclamationMark._width = frameExclamationMark._width; + frameRevExclamationMark._height = frameExclamationMark._height; + frameRevExclamationMark._paletteBase = frameExclamationMark._paletteBase; + frameRevExclamationMark._rleEncoded = frameExclamationMark._rleEncoded; + frameRevExclamationMark._size = frameExclamationMark._size; + frameRevExclamationMark._frame.create(frameExclamationMark._width, frameExclamationMark._height, Graphics::PixelFormat::createFormatCLUT8()); + + byte *frameExclMarkPixels = (byte *)frameExclamationMark._frame.getPixels(); + byte *frameRevExclMarkPixels = (byte *)frameRevExclamationMark._frame.getPixels(); + + uint16 revExclMarkY = frameExclamationMark._height - 1; + frameRevExclMarkPixels += frameExclamationMark._width * (frameExclamationMark._height - 1); + for (uint16 exclMarkY = 0; exclMarkY < frameExclamationMark._height; exclMarkY++) { + memcpy(frameRevExclMarkPixels, frameExclMarkPixels, frameExclamationMark._width); + revExclMarkY--; + frameRevExclMarkPixels -= frameExclamationMark._width; + frameExclMarkPixels += frameExclamationMark._width; + } + + frameRevExclamationMark._offset.x = frameExclamationMark._offset.x; + frameRevExclamationMark._offset.y = frameExclamationMark._offset.y + 1; + + _font->push_back(frameRevExclamationMark); + } + } + } + } else { // 3DO switch (fontNum) { @@ -81,10 +127,10 @@ void Fonts::setFont(int fontNum) { } _charCount = _font->size(); - + // Iterate through the frames to find the widest and tallest font characters _fontHeight = _widestChar = 0; - for (uint idx = 0; idx < _charCount; ++idx) { + for (uint idx = 0; idx < MIN<uint>(_charCount, 128 - 32); ++idx) { _fontHeight = MAX((uint16)_fontHeight, (*_font)[idx]._frame.h); _widestChar = MAX((uint16)_widestChar, (*_font)[idx]._frame.w); } @@ -118,6 +164,24 @@ inline byte Fonts::translateChar(byte c) { return 135; // and this for SH1 default: if (IS_SERRATED_SCALPEL) { + if (_vm->getLanguage() == Common::ES_ESP) { + if (_fontNumber == 1) { + // Special workarounds for translated game text, which was skipped because of effectively a bug + // This was not done in the original interpreter + // It seems at least the inverted exclamation mark was skipped by the original interpreter / + // wasn't shown at all. + // This character is used for example in the alley room, when talking with the inspector after + // searching the corpse. "[0xAD]Claro! Mi experiencia profesional revela que esta mujer fue asesinada..." + // The same text gets put inside Watson's journal as well and should be on page 10 right after + // talking with the inspector. For further study see bug #6931 + // Inverted question mark was also skipped, but at least that character is inside the font already. + if (c == 0xAD) { + // inverted exclamation mark + return 0x88; // our own font character, created during setFont() + } + // Inverted question mask is 0x86 (mapped from 0x88) + } + } if (c >= 0x80) { // German SH1 version did this, but not German SH2 c--; } @@ -131,7 +195,7 @@ inline byte Fonts::translateChar(byte c) { } } -void Fonts::writeString(Surface *surface, const Common::String &str, +void Fonts::writeString(BaseSurface *surface, const Common::String &str, const Common::Point &pt, int overrideColor) { Common::Point charPos = pt; @@ -147,10 +211,13 @@ void Fonts::writeString(Surface *surface, const Common::String &str, } curChar = translateChar(curChar); - assert(curChar < _charCount); - ImageFrame &frame = (*_font)[curChar]; - surface->transBlitFrom(frame, Common::Point(charPos.x, charPos.y + _yOffsets[curChar]), false, overrideColor); - charPos.x += frame._frame.w + 1; + if (curChar < _charCount) { + ImageFrame &frame = (*_font)[curChar]; + surface->SHtransBlitFrom(frame, Common::Point(charPos.x, charPos.y + _yOffsets[curChar]), false, overrideColor); + charPos.x += frame._frame.w + 1; + } else { + warning("Invalid character encountered - %d", (int)curChar); + } } } |