SCUMM: Implement correct behavior for old style text overflow

This commit is contained in:
Andrea Boscarino 2022-03-27 19:37:14 +02:00 committed by athrxx
parent d3f756eedc
commit 47270487b6
2 changed files with 32 additions and 16 deletions

View file

@ -1986,16 +1986,44 @@ int CharsetRendererV7::draw2byte(byte *buffer, Common::Rect &clipRect, int x, in
} }
int CharsetRendererV7::drawChar(byte *buffer, Common::Rect &clipRect, int x, int y, int pitch, int16 col, TextStyleFlags flags, byte chr) { int CharsetRendererV7::drawChar(byte *buffer, Common::Rect &clipRect, int x, int y, int pitch, int16 col, TextStyleFlags flags, byte chr) {
// I am aware of not doing anything with the clipRect here, but I currently see no need to upgrade the old rendering with that.
if (!prepareDraw(chr)) if (!prepareDraw(chr))
return 0; return 0;
_width = getCharWidth(chr); _width = getCharWidth(chr);
if (_direction < 0) if (_direction < 0)
x -= _width; x -= _width;
int width = MIN(_origWidth, clipRect.right - x);
int height = MIN(_origHeight, clipRect.bottom - y);
_vm->_charsetColorMap[1] = col; _vm->_charsetColorMap[1] = col;
VirtScreen &vs = _vm->_virtscr[kMainVirtScreen]; byte *cmap = _vm->_charsetColorMap;
drawBitsN(vs, buffer + (y + _offsY) * vs.pitch + x, _charPtr, *_fontPtr, y, _origWidth, _origHeight); const byte *src = _charPtr;
return _direction * _width; byte *dst = buffer + (y + _offsY) * pitch + x;
uint8 bpp = *_fontPtr;
byte bits = *src++;
byte numbits = 8;
pitch -= _origWidth;
while (height--) {
for (int dx = x; dx < x + _origWidth; ++dx) {
byte color = (bits >> (8 - bpp)) & 0xFF;
if (color && dx >= 0 && dx < x + width && y >= 0)
*dst = cmap[color];
dst++;
bits <<= bpp;
numbits -= bpp;
if (numbits == 0) {
bits = *src++;
numbits = 8;
}
}
dst += pitch;
++y;
}
return _direction * width;
} }

View file

@ -217,18 +217,6 @@ void TextRenderer_v7::drawString(const char *str, byte *buffer, Common::Rect &cl
// with kStyleAlignLeft flag). // with kStyleAlignLeft flag).
xpos = x - _direction * width; xpos = x - _direction * width;
if (!_newStyle) {
int amax = _screenWidth - width;
int amin = (_direction == 1) ? clipRect.left : clipRect.left + width;
// Full Throttle has several lines which can fail the amin <= amax assertion in our CLIP()
// function; this is because said lines have a width higher than _screenWidth.
// Doing this restores the correct and accurate behaviour for those lines.
if (amin > amax) {
amax = amin;
}
xpos = CLIP<int>(xpos, amin, amax);
}
drawSubstring(str + lineStart, len, buffer, clipRect, xpos, y, pitch, col, flags); drawSubstring(str + lineStart, len, buffer, clipRect, xpos, y, pitch, col, flags);
y += height; y += height;
} }