SCUMM: Simplified Mac font rendering
Instead of trying to keep track of the real Mac screen coordinates in the _charset data type, use the original 320x200 coordinates and only scale up at the time of rendering. Either way, the output is not pixel perfect, and this is much less error prone. Now if only text removal worked correctly...
This commit is contained in:
parent
5b70ddd802
commit
27420f78d4
4 changed files with 20 additions and 48 deletions
|
@ -1562,79 +1562,64 @@ CharsetRendererMac::CharsetRendererMac(ScummEngine *vm, const Common::String &fo
|
|||
}
|
||||
|
||||
int CharsetRendererMac::getFontHeight() {
|
||||
return _macFont.getFontHeight();
|
||||
return _macFont.getFontHeight() / 2;
|
||||
}
|
||||
|
||||
int CharsetRendererMac::getCharWidth(uint16 chr) {
|
||||
return _macFont.getCharWidth(chr);
|
||||
}
|
||||
|
||||
int CharsetRendererMac::evenDown(int x) {
|
||||
if (x & 1)
|
||||
x--;
|
||||
return x;
|
||||
}
|
||||
|
||||
int CharsetRendererMac::evenUp(int x) {
|
||||
if (x & 1)
|
||||
x++;
|
||||
return x;
|
||||
return _macFont.getCharWidth(chr) / 2;
|
||||
}
|
||||
|
||||
void CharsetRendererMac::printChar(int chr, bool ignoreCharsetMask) {
|
||||
// Mark the virtual screen as dirty, using downscaled coordinates.
|
||||
|
||||
VirtScreen *vs;
|
||||
int top = evenDown(_top) / 2;
|
||||
|
||||
if ((vs = _vm->findVirtScreen(top)) == NULL) {
|
||||
warning("findVirtScreen(%d) failed, therefore printChar cannot print '%c'", top, chr);
|
||||
if ((vs = _vm->findVirtScreen(_top)) == NULL) {
|
||||
warning("findVirtScreen(%d) failed, therefore printChar cannot print '%c'", _top, chr);
|
||||
return;
|
||||
}
|
||||
|
||||
if (chr == '@')
|
||||
return;
|
||||
|
||||
int macLeft = 2 * _left;
|
||||
int macTop = 2 * _top;
|
||||
|
||||
if (_enableShadow) {
|
||||
_macFont.drawChar(&_vm->_textSurface, chr, _left + 1, _top - 1, _shadowColor);
|
||||
_macFont.drawChar(&_vm->_textSurface, chr, _left - 1, _top + 1, _shadowColor);
|
||||
_macFont.drawChar(&_vm->_textSurface, chr, _left + 2, _top + 2, _shadowColor);
|
||||
_macFont.drawChar(&_vm->_textSurface, chr, macLeft + 1, macTop - 1, _shadowColor);
|
||||
_macFont.drawChar(&_vm->_textSurface, chr, macLeft - 1, macTop + 1, _shadowColor);
|
||||
_macFont.drawChar(&_vm->_textSurface, chr, macLeft + 2, macTop + 2, _shadowColor);
|
||||
}
|
||||
_macFont.drawChar(&_vm->_textSurface, chr, _left, _top, _color);
|
||||
int width = _macFont.getCharWidth(chr);
|
||||
_macFont.drawChar(&_vm->_textSurface, chr, macLeft, macTop, _color);
|
||||
int width = getCharWidth(chr);
|
||||
|
||||
int left = _left;
|
||||
int right = _left + width;
|
||||
int top = _top;
|
||||
int bottom = _top + _macFont.getFontHeight();
|
||||
|
||||
if (_enableShadow) {
|
||||
left--;
|
||||
right += 2;
|
||||
right++;
|
||||
top--;
|
||||
bottom++;
|
||||
}
|
||||
|
||||
int vsLeft = evenDown(left) / 2;
|
||||
int vsRight = evenUp(right) / 2;
|
||||
int vsTop = evenDown(top) / 2;
|
||||
int vsBottom = evenUp(bottom) / 2;
|
||||
|
||||
if (_firstChar) {
|
||||
_str.left = _left;
|
||||
_str.top = _top;
|
||||
_str.right = _right;
|
||||
_str.bottom = _top;
|
||||
_str.left = left;
|
||||
_str.top = top;
|
||||
_str.right = right;
|
||||
_str.bottom = top;
|
||||
_firstChar = false;
|
||||
}
|
||||
|
||||
_vm->markRectAsDirty(vs->number, vsLeft, vsRight, vsTop - vs->topline, vsBottom - vs->topline);
|
||||
_vm->markRectAsDirty(vs->number, left, right, top - vs->topline, bottom - vs->topline);
|
||||
|
||||
if (!ignoreCharsetMask) {
|
||||
_hasMask = true;
|
||||
_textScreenID = vs->number;
|
||||
}
|
||||
|
||||
// Adjust the position, using real screen coordinates
|
||||
_left += width;
|
||||
}
|
||||
|
||||
|
|
|
@ -279,8 +279,6 @@ class CharsetRendererMac : public CharsetRendererCommon {
|
|||
protected:
|
||||
Graphics::MacFONTFont _macFont;
|
||||
|
||||
int evenDown(int x);
|
||||
int evenUp(int x);
|
||||
public:
|
||||
CharsetRendererMac(ScummEngine *vm, const Common::String &fontFile);
|
||||
|
||||
|
|
|
@ -827,6 +827,7 @@ void ScummEngine::mac_restoreCharsetBg() {
|
|||
_charset->_left = -1;
|
||||
|
||||
_textSurface.fillRect(Common::Rect(_textSurface.w, _textSurface.h), 0);
|
||||
|
||||
VirtScreen *vs = &_virtscr[_charset->_textScreenID];
|
||||
if (!vs->h)
|
||||
return;
|
||||
|
|
|
@ -652,12 +652,6 @@ void ScummEngine::CHARSET_1() {
|
|||
_charset->_center = _string[0].center;
|
||||
_charset->setColor(_charsetColor);
|
||||
|
||||
if (_macScreen) {
|
||||
_charset->_top *= 2;
|
||||
_charset->_startLeft *= 2;
|
||||
_charset->_left *= 2;
|
||||
}
|
||||
|
||||
if (a && a->_charset)
|
||||
_charset->setCurID(a->_charset);
|
||||
else
|
||||
|
@ -1028,12 +1022,6 @@ void ScummEngine::drawString(int a, const byte *msg) {
|
|||
_charset->_disableOffsX = _charset->_firstChar = true;
|
||||
_charset->setCurID(_string[a].charset);
|
||||
|
||||
if (_macScreen) {
|
||||
_charset->_top *= 2;
|
||||
_charset->_startLeft *= 2;
|
||||
_charset->_left *= 2;
|
||||
}
|
||||
|
||||
// HACK: Correct positions of text in books in Indy3 Mac.
|
||||
// See also bug #8759.
|
||||
if (_game.id == GID_INDY3 && _game.platform == Common::kPlatformMacintosh && a == 1) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue