diff options
-rw-r--r-- | engines/sci/gui/gui_font.cpp | 25 | ||||
-rw-r--r-- | engines/sci/gui/gui_font.h | 9 | ||||
-rw-r--r-- | engines/sci/gui/gui_gfx.cpp | 67 |
3 files changed, 63 insertions, 38 deletions
diff --git a/engines/sci/gui/gui_font.cpp b/engines/sci/gui/gui_font.cpp index 5725d1ec2a..8165db1fd0 100644 --- a/engines/sci/gui/gui_font.cpp +++ b/engines/sci/gui/gui_font.cpp @@ -31,21 +31,11 @@ namespace Sci { -SciGUIfont::SciGUIfont(EngineState *state, SciGUIscreen *screen, GUIResourceId resourceId) - : _s(state), _screen(screen), _resourceId(resourceId) { +SciGUIfont::SciGUIfont(ResourceManager *resMan, GUIResourceId resourceId) + : _resourceId(resourceId) { assert(resourceId != -1); - if (_s->_gameName == "lsl1sci") { - // we remove upper bits for lsl1, because it wants to load font 2107 which is not available - _resourceId &= 0x7ff; - } - initData(_resourceId); -} - -SciGUIfont::~SciGUIfont() { -} -void SciGUIfont::initData(GUIResourceId resourceId) { - Resource *fontResource = _s->resMan->findResource(ResourceId(kResourceTypeFont, resourceId), false); + Resource *fontResource = resMan->findResource(ResourceId(kResourceTypeFont, resourceId), false); if (!fontResource) { error("font resource %d not found", resourceId); } @@ -62,6 +52,9 @@ void SciGUIfont::initData(GUIResourceId resourceId) { } } +SciGUIfont::~SciGUIfont() { +} + GUIResourceId SciGUIfont::getResourceId() { return _resourceId; } @@ -79,8 +72,8 @@ byte *SciGUIfont::getCharData(byte chr) { return chr < mCharMax ? _resourceData + mChars[chr].offset + 2 : 0; } -void SciGUIfont::draw(int16 chr, int16 top, int16 left, byte color, byte textface) { - int charWidth = MIN<int>(getCharWidth(chr), _screen->_width - left); +void SciGUIfont::draw(SciGUIscreen *screen, int16 chr, int16 top, int16 left, byte color, byte textface) { + int charWidth = MIN<int>(getCharWidth(chr), screen->_width - left); int charHeight = MIN<int>(getCharHeight(chr), 200 - top); byte b = 0, mask = 0xFF; int y = top; @@ -93,7 +86,7 @@ void SciGUIfont::draw(int16 chr, int16 top, int16 left, byte color, byte textfac if ((done & 7) == 0) // fetching next data byte b = *(pIn++) & mask; if (b & 0x80) // if MSB is set - paint it - _screen->Put_Pixel(left + done, y, 1, color, 0, 0); + screen->Put_Pixel(left + done, y, 1, color, 0, 0); b = b << 1; } } diff --git a/engines/sci/gui/gui_font.h b/engines/sci/gui/gui_font.h index f9a6d41dd1..c6f457b541 100644 --- a/engines/sci/gui/gui_font.h +++ b/engines/sci/gui/gui_font.h @@ -30,7 +30,7 @@ namespace Sci { class SciGUIfont { public: - SciGUIfont(EngineState *state, SciGUIscreen *screen, GUIResourceId resourceId); + SciGUIfont(ResourceManager *resMan, GUIResourceId resourceId); ~SciGUIfont(); GUIResourceId getResourceId(); @@ -38,14 +38,9 @@ public: byte getCharWidth(byte chr); byte getCharHeight(byte chr); byte *getCharData(byte chr); - void draw(int16 chr, int16 top, int16 left, byte color, byte textface); + void draw(SciGUIscreen *screen, int16 chr, int16 top, int16 left, byte color, byte textface); private: - void initData(GUIResourceId resourceId); - - EngineState *_s; - SciGUIscreen *_screen; - GUIResourceId _resourceId; byte *_resourceData; diff --git a/engines/sci/gui/gui_gfx.cpp b/engines/sci/gui/gui_gfx.cpp index 3fe0eb0867..0745da943e 100644 --- a/engines/sci/gui/gui_gfx.cpp +++ b/engines/sci/gui/gui_gfx.cpp @@ -336,16 +336,30 @@ GUIResourceId SciGUIgfx::GetFontId() { } SciGUIfont *SciGUIgfx::GetFont() { - if ((_font == NULL) || (_font->getResourceId() != _curPort->fontId)) { - _font = new SciGUIfont(_s, _screen, _curPort->fontId); - } + GUIResourceId fontId = _curPort->fontId; + + // Workaround: lsl1sci mixes its own internal fonts with the global + // SCI ones, so we translate them here, by removing their extra bits + if (_s->_gameName == "lsl1sci") + fontId &= 0x7ff; + + if ((_font == NULL) || (_font->getResourceId() != _curPort->fontId)) + _font = new SciGUIfont(_s->resMan, fontId); + return _font; } void SciGUIgfx::SetFont(GUIResourceId fontId) { - if ((_font == NULL) || (_font->getResourceId() != fontId)) { - _font = new SciGUIfont(_s, _screen, fontId); - } + GUIResourceId actualFontId = fontId; + + // Workaround: lsl1sci mixes its own internal fonts with the global + // SCI ones, so we translate them here, by removing their extra bits + if (_s->_gameName == "lsl1sci") + actualFontId &= 0x7ff; + + if ((_font == NULL) || (_font->getResourceId() != fontId)) + _font = new SciGUIfont(_s->resMan, actualFontId); + _curPort->fontId = fontId; _curPort->fontHeight = _font->getHeight(); } @@ -747,7 +761,7 @@ void SciGUIgfx::DrawText(const char *text, int16 from, int16 len, GUIResourceId EraseRect(rect); } // CharStd - _font->draw(curChar, _curPort->top + _curPort->curTop, _curPort->left + _curPort->curLeft, _curPort->penClr, _curPort->textFace); + _font->draw(_screen, curChar, _curPort->top + _curPort->curTop, _curPort->left + _curPort->curLeft, _curPort->penClr, _curPort->textFace); _curPort->curLeft += charWidth; } } @@ -942,6 +956,21 @@ const byte pattern_Circles[8][15] = { { 0x18, 0x3C, 0x7E, 0x7E, 0x7E, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7E, 0x7E, 0x7E, 0x3C, 0x18 } }; +// TODO: perhaps this is a better way to set the pattern_Textures array below? +#if 0 +const byte patternTextures[32 * 2] = { + 0x04, 0x29, 0x40, 0x24, 0x09, 0x41, 0x25, 0x45, + 0x41, 0x90, 0x50, 0x44, 0x48, 0x08, 0x42, 0x28, + 0x89, 0x52, 0x89, 0x88, 0x10, 0x48, 0xA4, 0x08, + 0x44, 0x15, 0x28, 0x24, 0x00, 0x0A, 0x24, 0x20, + // Now the table is actually duplicated, so we won't need to wrap around + 0x04, 0x29, 0x40, 0x24, 0x09, 0x41, 0x25, 0x45, + 0x41, 0x90, 0x50, 0x44, 0x48, 0x08, 0x42, 0x28, + 0x89, 0x52, 0x89, 0x88, 0x10, 0x48, 0xA4, 0x08, + 0x44, 0x15, 0x28, 0x24, 0x00, 0x0A, 0x24, 0x20, +}; +#endif + const bool pattern_Textures[32 * 8 * 2] = { false, false, false, false, false, true, false, false, // 0x20 false, false, true, false, true, false, false, true, // 0x94 @@ -1012,14 +1041,22 @@ const bool pattern_Textures[32 * 8 * 2] = { // Bit offsets into pattern_textures const byte pattern_TextureOffset[128] = { - 0x00, 0x18, 0x30, 0xc4, 0xdc, 0x65, 0xeb, 0x48, 0x60, 0xbd, 0x89, 0x05, 0x0a, 0xf4, 0x7d, 0x7d, - 0x85, 0xb0, 0x8e, 0x95, 0x1f, 0x22, 0x0d, 0xdf, 0x2a, 0x78, 0xd5, 0x73, 0x1c, 0xb4, 0x40, 0xa1, - 0xb9, 0x3c, 0xca, 0x58, 0x92, 0x34, 0xcc, 0xce, 0xd7, 0x42, 0x90, 0x0f, 0x8b, 0x7f, 0x32, 0xed, - 0x5c, 0x9d, 0xc8, 0x99, 0xad, 0x4e, 0x56, 0xa6, 0xf7, 0x68, 0xb7, 0x25, 0x82, 0x37, 0x3a, 0x51, - 0x69, 0x26, 0x38, 0x52, 0x9e, 0x9a, 0x4f, 0xa7, 0x43, 0x10, 0x80, 0xee, 0x3d, 0x59, 0x35, 0xcf, - 0x79, 0x74, 0xb5, 0xa2, 0xb1, 0x96, 0x23, 0xe0, 0xbe, 0x05, 0xf5, 0x6e, 0x19, 0xc5, 0x66, 0x49, - 0xf0, 0xd1, 0x54, 0xa9, 0x70, 0x4b, 0xa4, 0xe2, 0xe6, 0xe5, 0xab, 0xe4, 0xd2, 0xaa, 0x4c, 0xe3, - 0x06, 0x6f, 0xc6, 0x4a, 0xa4, 0x75, 0x97, 0xe1 }; + 0x00, 0x18, 0x30, 0xc4, 0xdc, 0x65, 0xeb, 0x48, + 0x60, 0xbd, 0x89, 0x05, 0x0a, 0xf4, 0x7d, 0x7d, + 0x85, 0xb0, 0x8e, 0x95, 0x1f, 0x22, 0x0d, 0xdf, + 0x2a, 0x78, 0xd5, 0x73, 0x1c, 0xb4, 0x40, 0xa1, + 0xb9, 0x3c, 0xca, 0x58, 0x92, 0x34, 0xcc, 0xce, + 0xd7, 0x42, 0x90, 0x0f, 0x8b, 0x7f, 0x32, 0xed, + 0x5c, 0x9d, 0xc8, 0x99, 0xad, 0x4e, 0x56, 0xa6, + 0xf7, 0x68, 0xb7, 0x25, 0x82, 0x37, 0x3a, 0x51, + 0x69, 0x26, 0x38, 0x52, 0x9e, 0x9a, 0x4f, 0xa7, + 0x43, 0x10, 0x80, 0xee, 0x3d, 0x59, 0x35, 0xcf, + 0x79, 0x74, 0xb5, 0xa2, 0xb1, 0x96, 0x23, 0xe0, + 0xbe, 0x05, 0xf5, 0x6e, 0x19, 0xc5, 0x66, 0x49, + 0xf0, 0xd1, 0x54, 0xa9, 0x70, 0x4b, 0xa4, 0xe2, + 0xe6, 0xe5, 0xab, 0xe4, 0xd2, 0xaa, 0x4c, 0xe3, + 0x06, 0x6f, 0xc6, 0x4a, 0xa4, 0x75, 0x97, 0xe1 +}; void SciGUIgfx::Draw_Box(Common::Rect box, byte color, byte prio, byte control) { byte flag = _screen->GetDrawingMask(color, prio, control); |