diff options
Diffstat (limited to 'engines/sci')
-rw-r--r-- | engines/sci/graphics/font.cpp | 211 | ||||
-rw-r--r-- | engines/sci/graphics/font.h | 7 | ||||
-rw-r--r-- | engines/sci/graphics/text32.cpp | 7 | ||||
-rw-r--r-- | engines/sci/graphics/text32.h | 8 |
4 files changed, 202 insertions, 31 deletions
diff --git a/engines/sci/graphics/font.cpp b/engines/sci/graphics/font.cpp index ff2f361d93..8dd6cbde5d 100644 --- a/engines/sci/graphics/font.cpp +++ b/engines/sci/graphics/font.cpp @@ -27,34 +27,206 @@ namespace Sci { -GfxFontFromResource::GfxFontFromResource(ResourceManager *resMan, GfxScreen *screen, GuiResourceId resourceId) +#ifdef ENABLE_SCI32 +static const byte sci32SystemFont[] = { + 0x00, 0x00, 0x80, 0x00, 0x08, 0x00, 0x06, 0x01, + 0x09, 0x01, 0x0c, 0x01, 0x0f, 0x01, 0x12, 0x01, + 0x15, 0x01, 0x18, 0x01, 0x1b, 0x01, 0x1e, 0x01, + 0x21, 0x01, 0x26, 0x01, 0x29, 0x01, 0x2c, 0x01, + 0x2f, 0x01, 0x32, 0x01, 0x35, 0x01, 0x38, 0x01, + 0x3b, 0x01, 0x3e, 0x01, 0x41, 0x01, 0x44, 0x01, + 0x47, 0x01, 0x4a, 0x01, 0x4d, 0x01, 0x50, 0x01, + 0x53, 0x01, 0x56, 0x01, 0x59, 0x01, 0x5c, 0x01, + 0x5f, 0x01, 0x62, 0x01, 0x65, 0x01, 0x68, 0x01, + 0x71, 0x01, 0x7a, 0x01, 0x83, 0x01, 0x8c, 0x01, + 0x95, 0x01, 0x9e, 0x01, 0xa7, 0x01, 0xb0, 0x01, + 0xb9, 0x01, 0xc2, 0x01, 0xc9, 0x01, 0xd3, 0x01, + 0xdc, 0x01, 0xe5, 0x01, 0xee, 0x01, 0xf7, 0x01, + 0x00, 0x02, 0x09, 0x02, 0x12, 0x02, 0x1b, 0x02, + 0x24, 0x02, 0x2d, 0x02, 0x36, 0x02, 0x3f, 0x02, + 0x48, 0x02, 0x51, 0x02, 0x5a, 0x02, 0x63, 0x02, + 0x6c, 0x02, 0x75, 0x02, 0x7e, 0x02, 0x87, 0x02, + 0x90, 0x02, 0x99, 0x02, 0xa2, 0x02, 0xab, 0x02, + 0xb4, 0x02, 0xbd, 0x02, 0xc6, 0x02, 0xcf, 0x02, + 0xd8, 0x02, 0xe1, 0x02, 0xea, 0x02, 0xf3, 0x02, + 0xfc, 0x02, 0x05, 0x03, 0x0e, 0x03, 0x17, 0x03, + 0x20, 0x03, 0x29, 0x03, 0x32, 0x03, 0x3b, 0x03, + 0x44, 0x03, 0x4d, 0x03, 0x56, 0x03, 0x5f, 0x03, + 0x68, 0x03, 0x71, 0x03, 0x7a, 0x03, 0x83, 0x03, + 0x8c, 0x03, 0x95, 0x03, 0x9e, 0x03, 0xa7, 0x03, + 0xb0, 0x03, 0xb9, 0x03, 0xc2, 0x03, 0xcb, 0x03, + 0xd4, 0x03, 0xdd, 0x03, 0xe6, 0x03, 0xef, 0x03, + 0xf8, 0x03, 0x01, 0x04, 0x0a, 0x04, 0x13, 0x04, + 0x1c, 0x04, 0x25, 0x04, 0x2e, 0x04, 0x37, 0x04, + 0x40, 0x04, 0x49, 0x04, 0x52, 0x04, 0x5b, 0x04, + 0x64, 0x04, 0x6d, 0x04, 0x76, 0x04, 0x7f, 0x04, + 0x88, 0x04, 0x91, 0x04, 0x9b, 0x04, 0xa4, 0x04, + 0xad, 0x04, 0xb6, 0x04, 0xbf, 0x04, 0x02, 0x01, + 0x00, 0x02, 0x01, 0x00, 0x02, 0x01, 0x40, 0x02, + 0x01, 0x40, 0x02, 0x01, 0x40, 0x02, 0x01, 0x40, + 0x02, 0x01, 0x40, 0x02, 0x01, 0x40, 0x02, 0x01, + 0x40, 0x13, 0x01, 0x00, 0x00, 0x00, 0x02, 0x01, + 0x40, 0x02, 0x01, 0x40, 0x02, 0x01, 0x40, 0x02, + 0x01, 0x40, 0x02, 0x01, 0x40, 0x02, 0x01, 0x40, + 0x02, 0x01, 0x40, 0x02, 0x01, 0x40, 0x02, 0x01, + 0x40, 0x02, 0x01, 0x40, 0x02, 0x01, 0x40, 0x02, + 0x01, 0x40, 0x02, 0x01, 0x40, 0x02, 0x01, 0x40, + 0x02, 0x01, 0x40, 0x02, 0x01, 0x40, 0x02, 0x01, + 0x40, 0x02, 0x01, 0x40, 0x02, 0x01, 0x40, 0x02, + 0x01, 0x40, 0x02, 0x01, 0x40, 0x02, 0x01, 0x40, + 0x04, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x02, 0x07, 0x40, 0x40, 0x40, 0x40, 0x00, + 0x40, 0x00, 0x05, 0x07, 0x50, 0x50, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x06, 0x07, 0x28, 0x7c, 0x28, + 0x28, 0x7c, 0x28, 0x00, 0x04, 0x07, 0x20, 0x30, + 0x40, 0x20, 0x10, 0x60, 0x20, 0x06, 0x07, 0x24, + 0x58, 0x34, 0x28, 0x40, 0x00, 0x00, 0x04, 0x07, + 0x20, 0x30, 0x40, 0x20, 0x40, 0x30, 0x20, 0x03, + 0x07, 0x20, 0x20, 0x40, 0x00, 0x00, 0x00, 0x00, + 0x04, 0x07, 0x10, 0x20, 0x40, 0x40, 0x40, 0x20, + 0x10, 0x04, 0x07, 0x40, 0x20, 0x10, 0x10, 0x10, + 0x20, 0x40, 0x06, 0x05, 0x10, 0x54, 0x38, 0x54, + 0x10, 0x04, 0x08, 0x00, 0x20, 0x20, 0x70, 0x20, + 0x20, 0x00, 0x00, 0x03, 0x07, 0x00, 0x00, 0x00, + 0x00, 0x20, 0x20, 0x40, 0x05, 0x07, 0x00, 0x00, + 0x00, 0x70, 0x00, 0x00, 0x00, 0x04, 0x07, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x60, 0x00, 0x05, 0x07, + 0x08, 0x10, 0x10, 0x20, 0x20, 0x40, 0x00, 0x05, + 0x07, 0x30, 0x48, 0x58, 0x68, 0x48, 0x30, 0x00, + 0x05, 0x07, 0x20, 0x60, 0x20, 0x20, 0x20, 0x70, + 0x00, 0x05, 0x07, 0x30, 0x48, 0x08, 0x30, 0x40, + 0x78, 0x00, 0x05, 0x07, 0x70, 0x08, 0x30, 0x08, + 0x08, 0x70, 0x00, 0x05, 0x07, 0x18, 0x28, 0x48, + 0x78, 0x08, 0x08, 0x00, 0x05, 0x07, 0x78, 0x40, + 0x70, 0x08, 0x08, 0x70, 0x00, 0x05, 0x07, 0x30, + 0x40, 0x70, 0x48, 0x48, 0x30, 0x00, 0x05, 0x07, + 0x78, 0x08, 0x10, 0x20, 0x20, 0x20, 0x00, 0x05, + 0x07, 0x30, 0x48, 0x30, 0x48, 0x48, 0x30, 0x00, + 0x05, 0x07, 0x30, 0x48, 0x48, 0x38, 0x08, 0x30, + 0x00, 0x02, 0x07, 0x00, 0x40, 0x00, 0x00, 0x40, + 0x00, 0x00, 0x03, 0x07, 0x00, 0x20, 0x00, 0x00, + 0x20, 0x20, 0x40, 0x04, 0x07, 0x00, 0x10, 0x20, + 0x40, 0x20, 0x10, 0x00, 0x04, 0x07, 0x00, 0x00, + 0x70, 0x00, 0x70, 0x00, 0x00, 0x04, 0x07, 0x00, + 0x40, 0x20, 0x10, 0x20, 0x40, 0x00, 0x04, 0x07, + 0x20, 0x50, 0x10, 0x20, 0x20, 0x00, 0x20, 0x08, + 0x07, 0x1c, 0x2a, 0x55, 0x55, 0x2e, 0x18, 0x00, + 0x05, 0x07, 0x30, 0x48, 0x48, 0x78, 0x48, 0x48, + 0x00, 0x05, 0x07, 0x70, 0x48, 0x70, 0x48, 0x48, + 0x70, 0x00, 0x05, 0x07, 0x30, 0x48, 0x40, 0x40, + 0x48, 0x30, 0x00, 0x05, 0x07, 0x70, 0x48, 0x48, + 0x48, 0x48, 0x70, 0x00, 0x05, 0x07, 0x78, 0x40, + 0x70, 0x40, 0x40, 0x78, 0x00, 0x05, 0x07, 0x78, + 0x40, 0x70, 0x40, 0x40, 0x40, 0x00, 0x05, 0x07, + 0x30, 0x48, 0x40, 0x58, 0x48, 0x30, 0x00, 0x05, + 0x07, 0x48, 0x48, 0x78, 0x48, 0x48, 0x48, 0x00, + 0x04, 0x07, 0x70, 0x20, 0x20, 0x20, 0x20, 0x70, + 0x00, 0x05, 0x07, 0x08, 0x08, 0x08, 0x08, 0x48, + 0x30, 0x00, 0x05, 0x07, 0x48, 0x50, 0x60, 0x50, + 0x48, 0x48, 0x00, 0x05, 0x07, 0x40, 0x40, 0x40, + 0x40, 0x40, 0x78, 0x00, 0x06, 0x07, 0x44, 0x6c, + 0x54, 0x44, 0x44, 0x44, 0x00, 0x06, 0x07, 0x44, + 0x64, 0x54, 0x4c, 0x44, 0x44, 0x00, 0x05, 0x07, + 0x30, 0x48, 0x48, 0x48, 0x48, 0x30, 0x00, 0x05, + 0x07, 0x70, 0x48, 0x48, 0x70, 0x40, 0x40, 0x00, + 0x06, 0x07, 0x30, 0x48, 0x48, 0x48, 0x48, 0x38, + 0x04, 0x05, 0x07, 0x70, 0x48, 0x48, 0x70, 0x48, + 0x48, 0x00, 0x05, 0x07, 0x30, 0x48, 0x20, 0x10, + 0x48, 0x30, 0x00, 0x06, 0x07, 0x7c, 0x10, 0x10, + 0x10, 0x10, 0x10, 0x00, 0x05, 0x07, 0x48, 0x48, + 0x48, 0x48, 0x48, 0x30, 0x00, 0x06, 0x07, 0x44, + 0x44, 0x44, 0x44, 0x28, 0x10, 0x00, 0x06, 0x07, + 0x44, 0x44, 0x44, 0x54, 0x54, 0x28, 0x00, 0x06, + 0x07, 0x44, 0x28, 0x10, 0x10, 0x28, 0x44, 0x00, + 0x06, 0x07, 0x44, 0x44, 0x28, 0x10, 0x10, 0x10, + 0x00, 0x05, 0x07, 0x78, 0x08, 0x10, 0x20, 0x40, + 0x78, 0x00, 0x03, 0x07, 0x60, 0x40, 0x40, 0x40, + 0x40, 0x40, 0x60, 0x05, 0x07, 0x40, 0x20, 0x20, + 0x10, 0x10, 0x08, 0x00, 0x03, 0x07, 0x60, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x60, 0x04, 0x07, 0x20, + 0x50, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x07, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0x03, + 0x07, 0x40, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x05, 0x07, 0x00, 0x30, 0x08, 0x38, 0x48, 0x38, + 0x00, 0x05, 0x07, 0x40, 0x40, 0x70, 0x48, 0x48, + 0x70, 0x00, 0x05, 0x07, 0x00, 0x30, 0x48, 0x40, + 0x48, 0x30, 0x00, 0x05, 0x07, 0x08, 0x08, 0x38, + 0x48, 0x48, 0x38, 0x00, 0x05, 0x07, 0x00, 0x30, + 0x48, 0x78, 0x40, 0x38, 0x00, 0x05, 0x07, 0x18, + 0x20, 0x70, 0x20, 0x20, 0x20, 0x00, 0x05, 0x07, + 0x00, 0x30, 0x48, 0x48, 0x38, 0x48, 0x30, 0x05, + 0x07, 0x40, 0x40, 0x50, 0x68, 0x48, 0x48, 0x00, + 0x02, 0x07, 0x40, 0x00, 0x40, 0x40, 0x40, 0x40, + 0x00, 0x04, 0x07, 0x10, 0x00, 0x10, 0x10, 0x10, + 0x10, 0x60, 0x04, 0x07, 0x40, 0x50, 0x50, 0x60, + 0x50, 0x50, 0x00, 0x02, 0x07, 0x40, 0x40, 0x40, + 0x40, 0x40, 0x40, 0x00, 0x06, 0x07, 0x00, 0x68, + 0x54, 0x54, 0x54, 0x54, 0x00, 0x05, 0x07, 0x00, + 0x50, 0x68, 0x48, 0x48, 0x48, 0x00, 0x05, 0x07, + 0x00, 0x30, 0x48, 0x48, 0x48, 0x30, 0x00, 0x05, + 0x07, 0x00, 0x70, 0x48, 0x48, 0x70, 0x40, 0x40, + 0x05, 0x07, 0x00, 0x30, 0x48, 0x48, 0x38, 0x08, + 0x08, 0x05, 0x07, 0x00, 0x58, 0x60, 0x40, 0x40, + 0x40, 0x00, 0x05, 0x07, 0x00, 0x38, 0x40, 0x30, + 0x08, 0x70, 0x00, 0x04, 0x07, 0x20, 0x70, 0x20, + 0x20, 0x20, 0x20, 0x00, 0x05, 0x07, 0x00, 0x48, + 0x48, 0x48, 0x48, 0x38, 0x00, 0x06, 0x07, 0x00, + 0x44, 0x44, 0x44, 0x28, 0x10, 0x00, 0x06, 0x07, + 0x00, 0x54, 0x54, 0x54, 0x54, 0x28, 0x00, 0x05, + 0x07, 0x00, 0x48, 0x48, 0x30, 0x48, 0x48, 0x00, + 0x05, 0x07, 0x00, 0x48, 0x48, 0x48, 0x38, 0x08, + 0x70, 0x05, 0x08, 0x00, 0x78, 0x08, 0x30, 0x40, + 0x78, 0x00, 0x00, 0x04, 0x07, 0x10, 0x20, 0x20, + 0x40, 0x20, 0x20, 0x10, 0x03, 0x07, 0x40, 0x40, + 0x40, 0x00, 0x40, 0x40, 0x40, 0x04, 0x07, 0x40, + 0x20, 0x20, 0x10, 0x20, 0x20, 0x40, 0x05, 0x07, + 0x28, 0x50, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, + 0x01, 0x40 +}; +#endif + + GfxFontFromResource::GfxFontFromResource(ResourceManager *resMan, GfxScreen *screen, GuiResourceId resourceId) : _resourceId(resourceId), _screen(screen), _resMan(resMan) { - assert(resourceId != -1); + if (getSciVersion() < SCI_VERSION_2) { + assert(resourceId != -1); + } - // Workaround: lsl1sci mixes its own internal fonts with the global - // SCI ones, so we translate them here, by removing their extra bits - if (!resMan->testResource(ResourceId(kResourceTypeFont, resourceId))) - resourceId = resourceId & 0x7ff; +#ifdef ENABLE_SCI32 + if (getSciVersion() >= SCI_VERSION_2 && resourceId == kSci32SystemFont) { + _resource = nullptr; + _resourceData = SciSpan<const byte>(sci32SystemFont, sizeof(sci32SystemFont), "system font"); + } else { +#endif + // Workaround: lsl1sci mixes its own internal fonts with the global + // SCI ones, so we translate them here, by removing their extra bits + if (!resMan->testResource(ResourceId(kResourceTypeFont, resourceId))) + resourceId = resourceId & 0x7ff; - _resource = resMan->findResource(ResourceId(kResourceTypeFont, resourceId), true); - if (!_resource) { - error("font resource %d not found", resourceId); + _resource = resMan->findResource(ResourceId(kResourceTypeFont, resourceId), true); + if (!_resource) { + error("font resource %d not found", resourceId); + } + _resourceData = *_resource; +#ifdef ENABLE_SCI32 } +#endif - _numChars = _resource->getUint16SE32At(2); - _fontHeight = _resource->getUint16SE32At(4); + _numChars = _resourceData.getUint16SE32At(2); + _fontHeight = _resourceData.getUint16SE32At(4); _chars = new Charinfo[_numChars]; // filling info for every char for (int16 i = 0; i < _numChars; i++) { - _chars[i].offset = _resource->getUint16SE32At(6 + i * 2); - _chars[i].width = _resource->getUint8At(_chars[i].offset); - _chars[i].height = _resource->getUint8At(_chars[i].offset + 1); + _chars[i].offset = _resourceData.getUint16SE32At(6 + i * 2); + _chars[i].width = _resourceData.getUint8At(_chars[i].offset); + _chars[i].height = _resourceData.getUint8At(_chars[i].offset + 1); } } GfxFontFromResource::~GfxFontFromResource() { delete[] _chars; - _resMan->unlockResource(_resource); + if (_resource) { + _resMan->unlockResource(_resource); + } } GuiResourceId GfxFontFromResource::getResourceId() { @@ -64,19 +236,22 @@ GuiResourceId GfxFontFromResource::getResourceId() { uint8 GfxFontFromResource::getHeight() { return _fontHeight; } + uint8 GfxFontFromResource::getCharWidth(uint16 chr) { return chr < _numChars ? _chars[chr].width : 0; } + uint8 GfxFontFromResource::getCharHeight(uint16 chr) { return chr < _numChars ? _chars[chr].height : 0; } + SciSpan<const byte> GfxFontFromResource::getCharData(uint16 chr) { if (chr >= _numChars) { return SciSpan<const byte>(); } - const uint32 size = (chr + 1 >= _numChars ? _resource->size() : _chars[chr + 1].offset) - _chars[chr].offset - 2; - return _resource->subspan(_chars[chr].offset + 2, size); + const uint32 size = (chr + 1 >= _numChars ? _resourceData.size() : _chars[chr + 1].offset) - _chars[chr].offset - 2; + return _resourceData.subspan(_chars[chr].offset + 2, size); } void GfxFontFromResource::draw(uint16 chr, int16 top, int16 left, byte color, bool greyedOutput) { @@ -114,7 +289,6 @@ void GfxFontFromResource::draw(uint16 chr, int16 top, int16 left, byte color, bo } #ifdef ENABLE_SCI32 - void GfxFontFromResource::drawToBuffer(uint16 chr, int16 top, int16 left, byte color, bool greyedOutput, byte *buffer, int16 bufWidth, int16 bufHeight) { if (chr >= _numChars) { // SSCI silently ignores attempts to draw characters that do not exist @@ -145,7 +319,6 @@ void GfxFontFromResource::drawToBuffer(uint16 chr, int16 top, int16 left, byte c } } } - #endif } // End of namespace Sci diff --git a/engines/sci/graphics/font.h b/engines/sci/graphics/font.h index 4e26510804..05008de9ee 100644 --- a/engines/sci/graphics/font.h +++ b/engines/sci/graphics/font.h @@ -28,6 +28,12 @@ namespace Sci { +#ifdef ENABLE_SCI32 +enum { + kSci32SystemFont = -1 +}; +#endif + class GfxFont { public: GfxFont() {} @@ -68,6 +74,7 @@ private: GfxScreen *_screen; Resource *_resource; + SciSpan<const byte> _resourceData; GuiResourceId _resourceId; struct Charinfo { diff --git a/engines/sci/graphics/text32.cpp b/engines/sci/graphics/text32.cpp index 181dabc9a8..c6360010d3 100644 --- a/engines/sci/graphics/text32.cpp +++ b/engines/sci/graphics/text32.cpp @@ -38,7 +38,6 @@ namespace Sci { -int16 GfxText32::_defaultFontId = 0; int16 GfxText32::_xResolution = 0; int16 GfxText32::_yResolution = 0; @@ -49,8 +48,8 @@ GfxText32::GfxText32(SegManager *segMan, GfxCache *fonts) : _width(0), _text(""), _bitmap(NULL_REG) { - _fontId = _defaultFontId; - _font = _cache->getFont(_defaultFontId); + _fontId = kSci32SystemFont; + _font = _cache->getFont(kSci32SystemFont); if (_xResolution == 0) { // initialize the statics @@ -170,7 +169,7 @@ void GfxText32::setFont(const GuiResourceId fontId) { // table is built on the FontMgr directly; instead, because we already have // font resources, this code just grabs a font out of GfxCache. if (fontId != _fontId) { - _fontId = fontId == -1 ? _defaultFontId : fontId; + _fontId = fontId; _font = _cache->getFont(_fontId); } } diff --git a/engines/sci/graphics/text32.h b/engines/sci/graphics/text32.h index c4521a4f56..722af34339 100644 --- a/engines/sci/graphics/text32.h +++ b/engines/sci/graphics/text32.h @@ -57,14 +57,6 @@ private: GfxCache *_cache; /** - * The resource ID of the default font used by the game. - * - * @todo Check all SCI32 games to learn what their - * default font is. - */ - static int16 _defaultFontId; - - /** * The width and height of the currently active text * bitmap, in text-system coordinates. * |