SCUMM FM-TOWNS: fix regression and cleanup

(LOOM mouse cursor was broken in b1cb88ddc25da64772bbba253bd2210678189ace)
This commit is contained in:
athrxx 2011-09-14 19:19:40 +02:00
parent 867f2887e8
commit 0d1d974e14
2 changed files with 50 additions and 65 deletions

View File

@ -511,14 +511,15 @@ void CharsetRendererV3::enableShadow(bool enable) {
_shadowMode = enable;
}
void CharsetRendererV3::drawBits1(const Graphics::Surface &s, byte *dst, const byte *src, int drawTop, int width, int height, uint8 bitDepth) {
int y, x;
void CharsetRendererV3::drawBits1(Graphics::Surface &dest, int x, int y, const byte *src, int drawTop, int width, int height) {
byte *dst = (byte *)dest.getBasePtr(x, y);
byte bits = 0;
uint8 col = _color;
int pitch = s.pitch - width * bitDepth;
byte *dst2 = dst + s.pitch;
int pitch = dest.pitch - width * dest.format.bytesPerPixel;
byte *dst2 = dst + dest.pitch;
for (y = 0; y < height && y + drawTop < s.h; y++) {
for (y = 0; y < height && y + drawTop < dest.h; y++) {
for (x = 0; x < width; x++) {
if ((x % 8) == 0)
bits = *src++;
@ -527,8 +528,8 @@ void CharsetRendererV3::drawBits1(const Graphics::Surface &s, byte *dst, const b
dst[1] = dst2[0] = dst2[1] = _shadowColor;
dst[0] = col;
}
dst += bitDepth;
dst2 += bitDepth;
dst += dest.format.bytesPerPixel;
dst2 += dest.format.bytesPerPixel;
}
dst += pitch;
@ -591,7 +592,6 @@ void CharsetRendererV3::printChar(int chr, bool ignoreCharsetMask) {
int width, height, origWidth = 0, origHeight;
VirtScreen *vs;
const byte *charPtr;
byte *dst;
int is2byte = (chr >= 256 && _vm->_useCJKMode) ? 1 : 0;
assertRange(0, _curId, _vm->_numCharsets - 1, "charset");
@ -636,13 +636,10 @@ void CharsetRendererV3::printChar(int chr, bool ignoreCharsetMask) {
_textScreenID = vs->number;
}
if ((ignoreCharsetMask || !vs->hasTwoBuffers)) {
dst = vs->getPixels(_left, drawTop);
drawBits1(*vs, dst, charPtr, drawTop, origWidth, origHeight, vs->format.bytesPerPixel);
} else {
dst = (byte *)_vm->_textSurface.getBasePtr(_left * _vm->_textSurfaceMultiplier, _top * _vm->_textSurfaceMultiplier);
drawBits1(_vm->_textSurface, dst, charPtr, drawTop, origWidth, origHeight, _vm->_textSurface.format.bytesPerPixel);
}
if ((ignoreCharsetMask || !vs->hasTwoBuffers) && (_vm->_game.platform != Common::kPlatformFMTowns))
drawBits1(*vs, _left + vs->xstart, drawTop, charPtr, drawTop, origWidth, origHeight);
else
drawBits1(_vm->_textSurface, _left * _vm->_textSurfaceMultiplier, _top * _vm->_textSurfaceMultiplier, charPtr, drawTop, origWidth, origHeight);
if (is2byte) {
origWidth /= _vm->_textSurfaceMultiplier;
@ -669,9 +666,7 @@ void CharsetRendererV3::drawChar(int chr, Graphics::Surface &s, int x, int y) {
int width = getDrawWidthIntern(chr);
int height = getDrawHeightIntern(chr);
setDrawCharIntern(chr);
byte *dst = (byte *)s.pixels + y * s.pitch + x;
drawBits1(s, dst, charPtr, y, width, height, s.format.bytesPerPixel);
drawBits1(s, x, y, charPtr, y, width, height);
}
void CharsetRenderer::translateColor() {
@ -993,50 +988,43 @@ void CharsetRendererTownsV3::enableShadow(bool enable) {
#endif
}
void CharsetRendererTownsV3::drawBits1(const Graphics::Surface &s, byte *dst, const byte *src, int drawTop, int width, int height, uint8 bitDepth) {
void CharsetRendererTownsV3::drawBits1(Graphics::Surface &dest, int x, int y, const byte *src, int drawTop, int width, int height) {
#ifndef DISABLE_TOWNS_DUAL_LAYER_MODE
#ifdef USE_RGB_COLOR
if (_sjisCurChar) {
assert(_vm->_cjkFont);
_vm->_cjkFont->drawChar(_vm->_textSurface, _sjisCurChar, _left * _vm->_textSurfaceMultiplier, _top * _vm->_textSurfaceMultiplier, _color, _shadowColor);
_vm->_cjkFont->drawChar(dest, _sjisCurChar, x, y, _color, _shadowColor);
return;
}
#endif
dst = (byte *)_vm->_textSurface.getBasePtr(_left * _vm->_textSurfaceMultiplier, _top * _vm->_textSurfaceMultiplier);
int sfPitch = _vm->_textSurface.pitch;
int sfHeight = _vm->_textSurface.h;
bool scale2x = (_vm->_textSurfaceMultiplier == 2 && !(_sjisCurChar >= 256 && _vm->_useCJKMode));
#else
int sfPitch = s.pitch;
int sfHeight = s.h;
byte *dst = (byte *)dest.getBasePtr(x, y);
bool scale2x = ((&dest == &_vm->_textSurface) && (_vm->_textSurfaceMultiplier == 2) && !(_sjisCurChar >= 256 && _vm->_useCJKMode));
#endif
int y, x;
byte bits = 0;
uint8 col = _color;
int pitch = sfPitch - width * bitDepth;
byte *dst2 = dst + sfPitch;
int pitch = dest.pitch - width * dest.format.bytesPerPixel;
byte *dst2 = dst + dest.pitch;
#ifndef DISABLE_TOWNS_DUAL_LAYER_MODE
byte *dst3 = dst2;
byte *dst4 = dst2;
if (scale2x) {
dst3 = dst2 + sfPitch;
dst4 = dst3 + sfPitch;
dst3 = dst2 + dest.pitch;
dst4 = dst3 + dest.pitch;
pitch <<= 1;
}
#endif
for (y = 0; y < height && y + drawTop < sfHeight; y++) {
for (y = 0; y < height && y + drawTop < dest.h; y++) {
for (x = 0; x < width; x++) {
if ((x % 8) == 0)
bits = *src++;
if ((bits & revBitMask(x % 8)) && y + drawTop >= 0) {
if (bitDepth == 2) {
if (dest.format.bytesPerPixel == 2) {
if (_shadowMode) {
WRITE_UINT16(dst + 2, _vm->_16BitPalette[_shadowColor]);
WRITE_UINT16(dst + sfPitch, _vm->_16BitPalette[_shadowColor]);
WRITE_UINT16(dst + dest.pitch, _vm->_16BitPalette[_shadowColor]);
}
WRITE_UINT16(dst, _vm->_16BitPalette[_color]);
} else {
@ -1059,8 +1047,8 @@ void CharsetRendererTownsV3::drawBits1(const Graphics::Surface &s, byte *dst, co
#endif
}
}
dst += bitDepth;
dst2 += bitDepth;
dst += dest.format.bytesPerPixel;
dst2 += dest.format.bytesPerPixel;
#ifndef DISABLE_TOWNS_DUAL_LAYER_MODE
if (scale2x) {
dst++;
@ -1106,45 +1094,45 @@ void CharsetRendererTownsV3::setDrawCharIntern(uint16 chr) {
#endif
#ifdef USE_RGB_COLOR
void CharsetRendererPCE::drawBits1(const Graphics::Surface &s, byte *dst, const byte *src, int drawTop, int width, int height, uint8 bitDepth) {
void CharsetRendererPCE::drawBits1(Graphics::Surface &dest, int x, int y, const byte *src, int drawTop, int width, int height) {
byte *dst = (byte *)dest.getBasePtr(x, y);
if (_sjisCurChar) {
assert(_vm->_cjkFont);
uint16 col1 = _color;
uint16 col2 = _shadowColor;
if (s.format.bytesPerPixel == 2) {
if (dest.format.bytesPerPixel == 2) {
col1 = _vm->_16BitPalette[col1];
col2 = _vm->_16BitPalette[col2];
}
_vm->_cjkFont->drawChar(dst, _sjisCurChar, s.pitch, s.format.bytesPerPixel, col1, col2, -1, -1);
_vm->_cjkFont->drawChar(dst, _sjisCurChar, dest.pitch, dest.format.bytesPerPixel, col1, col2, -1, -1);
return;
}
int y, x;
byte bits = 0;
for (y = 0; y < height && y + drawTop < s.h; y++) {
for (y = 0; y < height && y + drawTop < dest.h; y++) {
int bitCount = 0;
for (x = 0; x < width; x++) {
if ((bitCount % 8) == 0)
bits = *src++;
if ((bits & revBitMask(bitCount % 8)) && y + drawTop >= 0) {
if (bitDepth == 2) {
if (dest.format.bytesPerPixel == 2) {
if (_shadowMode)
WRITE_UINT16(dst + s.pitch + 2, _vm->_16BitPalette[_shadowColor]);
WRITE_UINT16(dst + dest.pitch + 2, _vm->_16BitPalette[_shadowColor]);
WRITE_UINT16(dst, _vm->_16BitPalette[_color]);
} else {
if (_shadowMode)
*(dst + s.pitch + 1) = _shadowColor;
*(dst + dest.pitch + 1) = _shadowColor;
*dst = _color;
}
}
dst += bitDepth;
dst += dest.format.bytesPerPixel;
bitCount++;
}
dst += s.pitch - width * bitDepth;
dst += dest.pitch - width * dest.format.bytesPerPixel;
}
}
@ -1282,7 +1270,7 @@ void CharsetRendererNut::printChar(int chr, bool ignoreCharsetMask) {
void CharsetRendererNES::printChar(int chr, bool ignoreCharsetMask) {
int width, height, origWidth, origHeight;
VirtScreen *vs;
byte *charPtr, *dst;
byte *charPtr;
// Init it here each time since it is cheap and fixes bug with
// charset after game load
@ -1322,13 +1310,10 @@ void CharsetRendererNES::printChar(int chr, bool ignoreCharsetMask) {
_textScreenID = vs->number;
}
if (ignoreCharsetMask || !vs->hasTwoBuffers) {
dst = vs->getPixels(_left, drawTop);
drawBits1(*vs, dst, charPtr, drawTop, origWidth, origHeight, vs->format.bytesPerPixel);
} else {
dst = (byte *)_vm->_textSurface.pixels + _top * _vm->_textSurface.pitch + _left;
drawBits1(_vm->_textSurface, dst, charPtr, drawTop, origWidth, origHeight, _vm->_textSurface.format.bytesPerPixel);
}
if (ignoreCharsetMask || !vs->hasTwoBuffers)
drawBits1(*vs, _left + vs->xstart, drawTop, charPtr, drawTop, origWidth, origHeight);
else
drawBits1(_vm->_textSurface, _left, _top, charPtr, drawTop, origWidth, origHeight);
if (_str.left > _left)
_str.left = _left;
@ -1346,7 +1331,7 @@ void CharsetRendererNES::printChar(int chr, bool ignoreCharsetMask) {
}
void CharsetRendererNES::drawChar(int chr, Graphics::Surface &s, int x, int y) {
byte *charPtr, *dst;
byte *charPtr;
int width, height;
if (!_trTable)
@ -1356,8 +1341,7 @@ void CharsetRendererNES::drawChar(int chr, Graphics::Surface &s, int x, int y) {
width = getCharWidth(chr);
height = 8;
dst = (byte *)s.pixels + y * s.pitch + x;
drawBits1(s, dst, charPtr, y, width, height, s.format.bytesPerPixel);
drawBits1(s, x, y, charPtr, y, width, height);
}
#ifdef USE_RGB_COLOR
@ -1557,14 +1541,15 @@ void CharsetRendererTownsClassic::processCharsetColors() {
#endif
#endif
void CharsetRendererNES::drawBits1(const Graphics::Surface &s, byte *dst, const byte *src, int drawTop, int width, int height, uint8 bitDepth) {
void CharsetRendererNES::drawBits1(Graphics::Surface &dest, int x, int y, const byte *src, int drawTop, int width, int height) {
byte *dst = (byte *)dest.getBasePtr(x, y);
for (int i = 0; i < 8; i++) {
byte c0 = src[i];
byte c1 = src[i + 8];
for (int j = 0; j < 8; j++)
dst[j] = _vm->_NESPalette[0][((c0 >> (7 - j)) & 1) | (((c1 >> (7 - j)) & 1) << 1) |
(_color ? 12 : 8)];
dst += s.pitch;
dst += dest.pitch;
}
}

View File

@ -156,7 +156,7 @@ class CharsetRendererNES : public CharsetRendererCommon {
protected:
byte *_trTable;
void drawBits1(const Graphics::Surface &s, byte *dst, const byte *src, int drawTop, int width, int height, uint8 bitDepth);
void drawBits1(Graphics::Surface &dest, int x, int y, const byte *src, int drawTop, int width, int height);
public:
CharsetRendererNES(ScummEngine *vm) : CharsetRendererCommon(vm) {}
@ -172,7 +172,7 @@ public:
class CharsetRendererV3 : public CharsetRendererCommon {
protected:
virtual void enableShadow(bool enable);
virtual void drawBits1(const Graphics::Surface &s, byte *dst, const byte *src, int drawTop, int width, int height, uint8 bitDepth);
virtual void drawBits1(Graphics::Surface &dest, int x, int y, const byte *src, int drawTop, int width, int height);
virtual int getDrawWidthIntern(uint16 chr);
virtual int getDrawHeightIntern(uint16 chr);
virtual void setDrawCharIntern(uint16 chr) {}
@ -198,7 +198,7 @@ public:
private:
void enableShadow(bool enable);
void drawBits1(const Graphics::Surface &s, byte *dst, const byte *src, int drawTop, int width, int height, uint8 bitDepth);
void drawBits1(Graphics::Surface &dest, int x, int y, const byte *src, int drawTop, int width, int height);
#ifndef DISABLE_TOWNS_DUAL_LAYER_MODE
int getDrawWidthIntern(uint16 chr);
int getDrawHeightIntern(uint16 chr);
@ -210,7 +210,7 @@ private:
#ifdef USE_RGB_COLOR
class CharsetRendererPCE : public CharsetRendererV3 {
private:
void drawBits1(const Graphics::Surface &s, byte *dst, const byte *src, int drawTop, int width, int height, uint8 bitDepth);
void drawBits1(Graphics::Surface &dest, int x, int y, const byte *src, int drawTop, int width, int height);
int getDrawWidthIntern(uint16 chr);
int getDrawHeightIntern(uint16 chr);