aboutsummaryrefslogtreecommitdiff
path: root/engines/scumm/charset.cpp
diff options
context:
space:
mode:
authorFlorian Kagerer2010-11-05 00:36:23 +0000
committerFlorian Kagerer2010-11-05 00:36:23 +0000
commit206971d16b56ff37a6a81ff85a1b488fdc60c627 (patch)
tree297c170bace8de89f30a5065f2a3654998ec59a2 /engines/scumm/charset.cpp
parent8c997e26088481340927a779d16d2eb482c14293 (diff)
downloadscummvm-rg350-206971d16b56ff37a6a81ff85a1b488fdc60c627.tar.gz
scummvm-rg350-206971d16b56ff37a6a81ff85a1b488fdc60c627.tar.bz2
scummvm-rg350-206971d16b56ff37a6a81ff85a1b488fdc60c627.zip
SCUMM/FM-TOWNS JAPANESE: fix out of bounds text drawing
(could cause invalid memory access in MI1) svn-id: r54079
Diffstat (limited to 'engines/scumm/charset.cpp')
-rw-r--r--engines/scumm/charset.cpp26
1 files changed, 10 insertions, 16 deletions
diff --git a/engines/scumm/charset.cpp b/engines/scumm/charset.cpp
index e75a45212e..8d7f9c9e9f 100644
--- a/engines/scumm/charset.cpp
+++ b/engines/scumm/charset.cpp
@@ -773,13 +773,13 @@ void CharsetRendererV3::printChar(int chr, bool ignoreCharsetMask) {
if (charPtr)
drawBits1(*vs, dst, charPtr, drawTop, origWidth, origHeight, vs->bytesPerPixel);
else if (_vm->_cjkFont)
- _vm->_cjkFont->drawChar(dst, chr, vs->pitch, vs->bytesPerPixel, _color, _shadowColor);
+ _vm->_cjkFont->drawChar(vs, chr, _left, drawTop, _color, _shadowColor);
} else {
dst = (byte *)_vm->_textSurface.getBasePtr(_left * _vm->_textSurfaceMultiplier, _top * _vm->_textSurfaceMultiplier);
if (charPtr)
drawBits1(_vm->_textSurface, dst, charPtr, drawTop, origWidth, origHeight, _vm->_textSurface.bytesPerPixel, (_vm->_textSurfaceMultiplier == 2 && !is2byte));
else if (_vm->_cjkFont)
- _vm->_cjkFont->drawChar(dst, chr, _vm->_textSurface.pitch, vs->bytesPerPixel, _color, _shadowColor);
+ _vm->_cjkFont->drawChar(_vm->_textSurface, chr, _left * _vm->_textSurfaceMultiplier, _top * _vm->_textSurfaceMultiplier, _color, _shadowColor);
if (is2byte)
origWidth /= _vm->_textSurfaceMultiplier;
}
@@ -799,17 +799,14 @@ void CharsetRendererV3::printChar(int chr, bool ignoreCharsetMask) {
_str.bottom = _top + height / _vm->_textSurfaceMultiplier;
}
-void CharsetRendererV3::drawChar(int chr, const Graphics::Surface &s, int x, int y) {
+void CharsetRendererV3::drawChar(int chr, Graphics::Surface &s, int x, int y) {
const byte *charPtr;
byte *dst;
int width, height;
int is2byte = (chr >= 0x80 && _vm->_useCJKMode) ? 1 : 0;
if (is2byte) {
if (_vm->_game.platform == Common::kPlatformFMTowns) {
- width = _vm->_cjkFont->getCharWidth(chr);
- height = _vm->_cjkFont->getFontHeight();
- dst = (byte *)s.pixels + y * s.pitch + x;
- _vm->_cjkFont->drawChar(dst, chr, s.pitch, s.bytesPerPixel, _color, _shadowColor);
+ _vm->_cjkFont->drawChar(s, chr, x * _vm->_textSurfaceMultiplier, y * _vm->_textSurfaceMultiplier, _color, _shadowColor);
return;
} else {
charPtr = _vm->get2byteCharPtr(chr);
@@ -1079,9 +1076,9 @@ void CharsetRendererClassic::printCharIntern(bool is2byte, const byte *charPtr,
drawTop = _top - _vm->_screenTop;
}
- if (!charPtr && _vm->_cjkFont)
- _vm->_cjkFont->drawChar(dstPtr, _vm->_cjkChar, dstSurface.pitch, dstSurface.bytesPerPixel, _vm->_townsCharsetColorMap[1], _shadowColor);
- else if (is2byte) {
+ if (!charPtr && _vm->_cjkFont) {
+ _vm->_cjkFont->drawChar(dstSurface, _vm->_cjkChar, _left * _vm->_textSurfaceMultiplier, (_top - _vm->_screenTop) * _vm->_textSurfaceMultiplier, _vm->_townsCharsetColorMap[1], _shadowColor);
+ } else if (is2byte) {
drawBits1(dstSurface, dstPtr, charPtr, drawTop, origWidth, origHeight, dstSurface.bytesPerPixel);
} else {
drawBitsN(dstSurface, dstPtr, charPtr, *_fontPtr, drawTop, origWidth, origHeight, _vm->_textSurfaceMultiplier == 2);
@@ -1124,7 +1121,7 @@ void CharsetRendererClassic::printCharIntern(bool is2byte, const byte *charPtr,
}
}
-void CharsetRendererClassic::drawChar(int chr, const Graphics::Surface &s, int x, int y) {
+void CharsetRendererClassic::drawChar(int chr, Graphics::Surface &s, int x, int y) {
const byte *charPtr;
byte *dst;
int width, height;
@@ -1133,10 +1130,7 @@ void CharsetRendererClassic::drawChar(int chr, const Graphics::Surface &s, int x
if (is2byte) {
enableShadow(true);
if (_vm->_game.platform == Common::kPlatformFMTowns) {
- width = _vm->_cjkFont->getCharWidth(chr);
- height = _vm->_cjkFont->getFontHeight();
- dst = (byte *)s.pixels + y * s.pitch + x;
- _vm->_cjkFont->drawChar(dst, chr, s.pitch, s.bytesPerPixel, _color, _shadowColor);
+ _vm->_cjkFont->drawChar(s, chr, x * _vm->_textSurfaceMultiplier, y * _vm->_textSurfaceMultiplier, _color, _shadowColor);
return;
} else {
charPtr = _vm->get2byteCharPtr(chr);
@@ -1525,7 +1519,7 @@ void CharsetRendererNES::printChar(int chr, bool ignoreCharsetMask) {
_str.bottom = _top + height;
}
-void CharsetRendererNES::drawChar(int chr, const Graphics::Surface &s, int x, int y) {
+void CharsetRendererNES::drawChar(int chr, Graphics::Surface &s, int x, int y) {
byte *charPtr, *dst;
int width, height;