[Scummvm-cvs-logs] CVS: scummvm/scumm akos.cpp,1.137,1.138 base-costume.h,1.21,1.22 bomp.cpp,2.20,2.21 charset.cpp,2.93,2.94 charset.h,2.27,2.28 costume.cpp,1.134,1.135 gfx.cpp,2.281,2.282 gfx.h,1.63,1.64 nut_renderer.cpp,1.49,1.50 nut_renderer.h,1.19,1.20 scumm.cpp,1.115,1.116 verbs.cpp,1.101,1.102
Max Horn
fingolfin at users.sourceforge.net
Sun Aug 8 15:10:03 CEST 2004
Update of /cvsroot/scummvm/scummvm/scumm
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31471
Modified Files:
akos.cpp base-costume.h bomp.cpp charset.cpp charset.h
costume.cpp gfx.cpp gfx.h nut_renderer.cpp nut_renderer.h
scumm.cpp verbs.cpp
Log Message:
Patch #1003866 (SCUMM: New text rendering code (fixes various bugs))
Index: akos.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/akos.cpp,v
retrieving revision 1.137
retrieving revision 1.138
diff -u -d -r1.137 -r1.138
--- akos.cpp 31 Jul 2004 23:20:37 -0000 1.137
+++ akos.cpp 8 Aug 2004 22:09:49 -0000 1.138
@@ -385,7 +385,7 @@
return;
}
} else {
- masked = (y < 0 || y >= _outheight) || (v1.mask_ptr && ((mask[0] | mask[v1.imgbufoffs]) & maskbit));
+ masked = (y < 0 || y >= _outheight) || (v1.mask_ptr && (*mask & maskbit));
if (color && !masked && !skip_column) {
pcolor = palette[color];
@@ -781,8 +781,7 @@
v1.destptr = _outptr + v1.y * _outwidth + v1.x;
- v1.mask_ptr = _vm->getMaskBuffer(0, v1.y, 0);
- v1.imgbufoffs = _vm->gdi._imgBufOffs[_zbuf];
+ v1.mask_ptr = _vm->getMaskBuffer(0, v1.y, _zbuf);
codec1_genericDecode();
@@ -847,9 +846,7 @@
}
bdd.y = _actorY + ymoveCur;
- if (_zbuf != 0) {
- bdd.maskPtr = _vm->getMaskBuffer(0, 0, _zbuf);
- }
+ bdd.maskPtr = _vm->getMaskBuffer(0, 0, _zbuf);
_vm->drawBomp(bdd, !_mirror);
_vm->_bompActorPalettePtr = NULL;
@@ -930,7 +927,7 @@
int32 numskip_before, int32 numskip_after, byte transparency, int maskLeft, int maskTop, int zBuf) {
byte *tmp_buf = akos16.buffer;
int maskpitch;
- byte *maskptr = 0, *charsetMask = 0;
+ byte *maskptr;
const byte maskbit = revBitMask[maskLeft & 7];
if (dir < 0) {
@@ -946,19 +943,13 @@
maskpitch = _numStrips;
- charsetMask = _vm->getMaskBuffer(maskLeft, maskTop, 0);
- if (zBuf != 0)
- maskptr = _vm->getMaskBuffer(maskLeft, maskTop, zBuf);
+ maskptr = _vm->getMaskBuffer(maskLeft, maskTop, zBuf);
assert(t_height > 0);
assert(t_width > 0);
while (t_height--) {
akos16DecodeLine(tmp_buf, t_width, dir);
- bompApplyMask(akos16.buffer, charsetMask, maskbit, t_width, transparency);
- if (maskptr) {
- bompApplyMask(akos16.buffer, maskptr, maskbit, t_width, transparency);
- maskptr += maskpitch;
- }
+ bompApplyMask(akos16.buffer, maskptr, maskbit, t_width, transparency);
bool HE7Check = (_vm->_heversion == 70);
bompApplyShadow(_shadow_mode, _shadow_table, akos16.buffer, dest, t_width, transparency, HE7Check);
@@ -966,7 +957,7 @@
akos16SkipData(numskip_after);
}
dest += pitch;
- charsetMask += maskpitch;
+ maskptr += maskpitch;
}
}
Index: base-costume.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/base-costume.h,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -d -r1.21 -r1.22
--- base-costume.h 29 Jun 2004 11:02:15 -0000 1.21
+++ base-costume.h 8 Aug 2004 22:09:49 -0000 1.22
@@ -97,7 +97,6 @@
int skip_width;
byte *destptr;
const byte *mask_ptr;
- int imgbufoffs;
} v1;
public:
Index: bomp.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/bomp.cpp,v
retrieving revision 2.20
retrieving revision 2.21
diff -u -d -r2.20 -r2.21
--- bomp.cpp 27 Jun 2004 23:54:53 -0000 2.20
+++ bomp.cpp 8 Aug 2004 22:09:49 -0000 2.21
@@ -199,7 +199,6 @@
const byte *src;
byte *dst;
byte *mask = 0;
- byte *charset_mask;
Common::Rect clip;
byte *scalingYPtr = bd.scalingYPtr;
byte skip_y_bits = 0x80;
@@ -234,10 +233,7 @@
const byte maskbit = revBitMask[(bd.x + clip.left) & 7];
- // Always mask against the charset mask
- charset_mask = getMaskBuffer(bd.x + clip.left, bd.y, 0);
-
- // Also mask against any additionally imposed mask
+ // Mask against any additionally imposed mask
if (bd.maskPtr) {
mask = bd.maskPtr + (bd.y * gdi._numStrips) + ((bd.x + clip.left) / 8);
}
@@ -310,7 +306,6 @@
// Replace the parts of the line which are masked with the transparency color
if (bd.maskPtr)
bompApplyMask(line_ptr, mask, maskbit, width, 255);
- bompApplyMask(line_ptr, charset_mask, maskbit, width, 255);
// Apply custom color map, if available
if (_bompActorPalettePtr)
@@ -324,7 +319,6 @@
// Advance to the next line
pos_y++;
mask += gdi._numStrips;
- charset_mask += gdi._numStrips;
dst += bd.outwidth;
}
}
Index: charset.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/charset.cpp,v
retrieving revision 2.93
retrieving revision 2.94
diff -u -d -r2.93 -r2.94
--- charset.cpp 27 Jun 2004 21:52:23 -0000 2.93
+++ charset.cpp 8 Aug 2004 22:09:49 -0000 2.94
@@ -944,7 +944,7 @@
void CharsetRendererV3::printChar(int chr) {
// Indy3 / Zak256 / Loom
VirtScreen *vs;
- byte *char_ptr, *dest_ptr, *mask_ptr;
+ byte *char_ptr, *dest_ptr;
int width, height;
int drawTop;
@@ -972,8 +972,6 @@
drawTop = _top - vs->topline;
char_ptr = _fontPtr + chr * 8;
- dest_ptr = vs->screenPtr + vs->xstart + drawTop * vs->width + _left;
- mask_ptr = _vm->getMaskBuffer(_left, drawTop, 0);
_vm->markRectAsDirty(vs->number, _left, _left + width, drawTop, drawTop + height);
@@ -981,8 +979,13 @@
_hasMask = true;
_textScreenID = vs->number;
}
+ if (_ignoreCharsetMask || !vs->hasTwoBuffers) {
+ dest_ptr = vs->screenPtr + vs->xstart + drawTop * vs->width + _left;
+ } else {
+ dest_ptr = (byte *)_vm->gdi._textSurface.pixels + drawTop * _vm->gdi._textSurface.pitch + _left;
+ }
- drawBits1(vs, dest_ptr, char_ptr, mask_ptr, drawTop, 8, 8);
+ drawBits1(vs, dest_ptr, char_ptr, drawTop, 8, 8);
if (_str.left > _left)
_str.left = _left;
@@ -1085,24 +1088,29 @@
_vm->markRectAsDirty(vs->number, _left, _left + width, drawTop, drawTop + height + offsY);
+ byte *dst;
+ byte *back;
+
if (!_ignoreCharsetMask) {
_hasMask = true;
_textScreenID = vs->number;
}
+ if (_ignoreCharsetMask || !vs->hasTwoBuffers) {
+ dst = vs->screenPtr + vs->xstart + drawTop * vs->width + _left;
+ } else {
+ dst = (byte *)_vm->gdi._textSurface.pixels + drawTop * _vm->gdi._textSurface.pitch + _left;
+ }
- byte *mask = _vm->getMaskBuffer(_left, drawTop, 0);
- byte *dst = vs->screenPtr + vs->xstart + drawTop * vs->width + _left;
-
- byte *back = dst;
+ back = dst;
if (_blitAlso && vs->hasTwoBuffers) {
dst = vs->backBuf + vs->xstart + drawTop * vs->width + _left;
}
if (is2byte) {
- drawBits1(vs, dst, charPtr, mask, drawTop, origWidth, origHeight);
+ drawBits1(vs, dst, charPtr, drawTop, origWidth, origHeight);
} else {
byte bpp = *_fontPtr;
- drawBitsN(vs, dst, charPtr, mask, bpp, drawTop, origWidth, origHeight);
+ drawBitsN(vs, dst, charPtr, bpp, drawTop, origWidth, origHeight);
}
if (_blitAlso && vs->hasTwoBuffers) {
@@ -1128,30 +1136,21 @@
_top -= offsY;
}
-void CharsetRendererClassic::drawBitsN(VirtScreen *vs, byte *dst, const byte *src, byte *mask, byte bpp, int drawTop, int width, int height) {
- byte maskmask;
+void CharsetRendererClassic::drawBitsN(VirtScreen *vs, byte *dst, const byte *src, byte bpp, int drawTop, int width, int height) {
int y, x;
- int maskpos;
int color;
byte numbits, bits;
- bool useMask = (vs->number == kMainVirtScreen && !_ignoreCharsetMask);
assert(bpp == 1 || bpp == 2 || bpp == 4 || bpp == 8);
bits = *src++;
numbits = 8;
for (y = 0; y < height && y + drawTop < vs->height; y++) {
- maskmask = revBitMask[_left & 7];
- maskpos = 0;
-
for (x = 0; x < width; x++) {
color = (bits >> (8 - bpp)) & 0xFF;
if (color && y + drawTop >= 0) {
*dst = _vm->_charsetColorMap[color];
- if (useMask) {
- mask[maskpos] |= maskmask;
- }
}
dst++;
bits <<= bpp;
@@ -1160,28 +1159,16 @@
bits = *src++;
numbits = 8;
}
- maskmask >>= 1;
- if (maskmask == 0) {
- maskmask = 0x80;
- maskpos++;
- }
}
dst += vs->width - width;
- mask += _vm->gdi._numStrips;
}
}
-void CharsetRendererCommon::drawBits1(VirtScreen *vs, byte *dst, const byte *src, byte *mask, int drawTop, int width, int height) {
- byte maskmask;
+void CharsetRendererCommon::drawBits1(VirtScreen *vs, byte *dst, const byte *src, int drawTop, int width, int height) {
int y, x;
- int maskpos;
byte bits = 0;
- bool useMask = (vs->number == kMainVirtScreen && !_ignoreCharsetMask);
for (y = 0; y < height && y + drawTop < vs->height; y++) {
- maskmask = revBitMask[_left & 7];
- maskpos = 0;
-
for (x = 0; x < width; x++) {
if ((x % 8) == 0)
bits = *src++;
@@ -1192,30 +1179,11 @@
*(dst + vs->width + 1) = _shadowColor;
}
*dst = _color;
- if (useMask) {
- mask[maskpos] |= maskmask;
- if (_dropShadow) {
- mask[maskpos + _vm->gdi._numStrips] |= maskmask;
- if (maskmask == 1) {
- mask[maskpos + 1] |= 0x80;
- mask[maskpos + _vm->gdi._numStrips + 1] |= 0x80;
- } else {
- mask[maskpos] |= (maskmask >> 1);
- mask[maskpos + _vm->gdi._numStrips] |= (maskmask >> 1);
- }
- }
- }
}
dst++;
- maskmask >>= 1;
- if (maskmask == 0) {
- maskmask = 0x80;
- maskpos++;
- }
}
dst += vs->width - width;
- mask += _vm->gdi._numStrips;
}
}
@@ -1293,12 +1261,23 @@
shadow.right = _left + width + 2;
shadow.bottom = _top + height + 2;
+ Graphics::Surface s;
if (!_ignoreCharsetMask) {
_hasMask = true;
_textScreenID = kMainVirtScreen;
}
+ if (_ignoreCharsetMask) {
+ VirtScreen *vs = &_vm->virtscr[kMainVirtScreen];
+ s.pixels = vs->screenPtr + vs->xstart + _vm->_screenTop * vs->width;
+ s.w = vs->width;
+ s.h = vs->height;
+ s.pitch = vs->width;
+ s.bytesPerPixel = 1;
+ } else {
+ s = _vm->gdi._textSurface;
+ }
- _current->drawShadowChar(chr, _left, _top, _color, !_ignoreCharsetMask, _curId != 3);
+ _current->drawShadowChar(s, chr, _left, _top, _color, _curId != 3);
_vm->markRectAsDirty(kMainVirtScreen, shadow);
if (_str.left > _left)
Index: charset.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/charset.h,v
retrieving revision 2.27
retrieving revision 2.28
diff -u -d -r2.27 -r2.28
--- charset.h 8 Apr 2004 23:41:10 -0000 2.27
+++ charset.h 8 Aug 2004 22:09:49 -0000 2.28
@@ -69,7 +69,6 @@
void restoreCharsetBg();
void clearCharsetMask();
- bool hasCharsetMask(int left, int top, int right, int bottom);
virtual void printChar(int chr) = 0;
@@ -88,7 +87,7 @@
protected:
byte *_fontPtr;
- void drawBits1(VirtScreen *vs, byte *dst, const byte *src, byte *mask, int drawTop, int width, int height);
+ void drawBits1(VirtScreen *vs, byte *dst, const byte *src, int drawTop, int width, int height);
public:
CharsetRendererCommon(ScummEngine *vm) : CharsetRenderer(vm) {}
@@ -102,7 +101,7 @@
protected:
int getCharWidth(byte chr);
- void drawBitsN(VirtScreen *vs, byte *dst, const byte *src, byte *mask, byte bpp, int drawTop, int width, int height);
+ void drawBitsN(VirtScreen *vs, byte *dst, const byte *src, byte bpp, int drawTop, int width, int height);
public:
CharsetRendererClassic(ScummEngine *vm) : CharsetRendererCommon(vm) {}
Index: costume.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/costume.cpp,v
retrieving revision 1.134
retrieving revision 1.135
diff -u -d -r1.134 -r1.135
--- costume.cpp 26 Jul 2004 13:53:24 -0000 1.134
+++ costume.cpp 8 Aug 2004 22:09:49 -0000 1.135
@@ -284,8 +284,7 @@
v1.destptr = _outptr + v1.y * _outwidth + v1.x;
- v1.mask_ptr = _vm->getMaskBuffer(0, v1.y, 0);
- v1.imgbufoffs = _vm->gdi._imgBufOffs[_zbuf];
+ v1.mask_ptr = _vm->getMaskBuffer(0, v1.y, _zbuf);
CHECK_HEAP
@@ -350,7 +349,7 @@
};
#define MASK_AT(xoff) \
- (mask && (mask[((v1.x + xoff) / 8) + v1.imgbufoffs] & revBitMask[(v1.x + xoff) & 7]))
+ (mask && (mask[((v1.x + xoff) / 8)] & revBitMask[(v1.x + xoff) & 7]))
#define LINE(c,p) \
pcolor = (color >> c) & 3; \
if (pcolor) { \
@@ -467,7 +466,7 @@
do {
if (_scaleY == 255 || *scaleytab++ < _scaleY) {
- masked = (y < 0 || y >= _outheight) || (v1.mask_ptr && ((mask[0] | mask[v1.imgbufoffs]) & maskbit));
+ masked = (y < 0 || y >= _outheight) || (v1.mask_ptr && (mask[0] & maskbit));
if (color && !masked) {
// FIXME: Fully implement _shadow_mode.in Sam & Max
@@ -536,7 +535,7 @@
len = *src++;
do {
if (_scaleY == 255 || cost_scaleTable[_scaleIndexY] < _scaleY) {
- masked = (y < 0 || y >= _outheight) || (v1.mask_ptr && ((mask[0] | mask[v1.imgbufoffs]) & maskbit));
+ masked = (y < 0 || y >= _outheight) || (v1.mask_ptr && (mask[0] & maskbit));
if (color && v1.x >= 0 && v1.x < _outwidth && !masked) {
*dst = _palette[color];
Index: gfx.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/gfx.cpp,v
retrieving revision 2.281
retrieving revision 2.282
diff -u -d -r2.281 -r2.282
--- gfx.cpp 8 Aug 2004 13:24:41 -0000 2.281
+++ gfx.cpp 8 Aug 2004 22:09:49 -0000 2.282
@@ -156,49 +156,12 @@
};
#endif
-static inline void copy8PixelsWithMasking(byte *dst, const byte *src, byte maskbits) {
- if (!(maskbits & 0x80))
- dst[0] = src[0];
- if (!(maskbits & 0x40))
- dst[1] = src[1];
- if (!(maskbits & 0x20))
- dst[2] = src[2];
- if (!(maskbits & 0x10))
- dst[3] = src[3];
- if (!(maskbits & 0x08))
- dst[4] = src[4];
- if (!(maskbits & 0x04))
- dst[5] = src[5];
- if (!(maskbits & 0x02))
- dst[6] = src[6];
- if (!(maskbits & 0x01))
- dst[7] = src[7];
-}
-
-static inline void clear8PixelsWithMasking(byte *dst, const byte color, byte maskbits) {
- if (!(maskbits & 0x80))
- dst[0] = color;
- if (!(maskbits & 0x40))
- dst[1] = color;
- if (!(maskbits & 0x20))
- dst[2] = color;
- if (!(maskbits & 0x10))
- dst[3] = color;
- if (!(maskbits & 0x08))
- dst[4] = color;
- if (!(maskbits & 0x04))
- dst[5] = color;
- if (!(maskbits & 0x02))
- dst[6] = color;
- if (!(maskbits & 0x01))
- dst[7] = color;
-}
-
#pragma mark -
#pragma mark --- Virtual Screens ---
#pragma mark -
+#define CHARSET_MASK_TRANSPARENCY 254
Gdi::Gdi(ScummEngine *vm) {
memset(this, 0, sizeof(*this));
@@ -206,6 +169,9 @@
_roomPalette = vm->_roomPalette;
if ((vm->_features & GF_AMIGA) && (vm->_version >= 4))
_roomPalette += 16;
+
+ _compositeBuf = 0;
+ _textSurface.pixels = 0;
}
void ScummEngine::initScreens(int b, int h) {
@@ -235,8 +201,26 @@
_screenB = b;
_screenH = h;
+
+ gdi.init();
+}
+
+void Gdi::init() {
+ const int size = _vm->_screenWidth * _vm->_screenHeight;
+ free(_compositeBuf);
+ free(_textSurface.pixels);
+ _compositeBuf = (byte *)malloc(size);
+ _textSurface.pixels = malloc(size);
+ memset(_compositeBuf, CHARSET_MASK_TRANSPARENCY, size);
+ memset(_textSurface.pixels, CHARSET_MASK_TRANSPARENCY, size);
+
+ _textSurface.w = _vm->_screenWidth;
+ _textSurface.h = _vm->_screenHeight;
+ _textSurface.pitch = _vm->_screenWidth;
+ _textSurface.bytesPerPixel = 1;
}
+
void ScummEngine::initVirtScreen(VirtScreenNumber slot, int number, int top, int width, int height, bool twobufs,
bool scrollable) {
VirtScreen *vs = &virtscr[slot];
@@ -246,7 +230,7 @@
assert(slot >= 0 && slot < 4);
if (_version >= 7) {
- if (slot == 0 && (_roomHeight != 0))
+ if (slot == kMainVirtScreen && (_roomHeight != 0))
height = _roomHeight;
}
@@ -431,8 +415,7 @@
* specified by top/bottom coordinate in the virtual screen.
*/
void Gdi::drawStripToScreen(VirtScreen *vs, int x, int width, int top, int bottom) {
- byte *ptr;
- int height;
+ const int height = bottom - top;
if (bottom <= top)
return;
@@ -442,11 +425,33 @@
assert(top >= 0 && bottom <= vs->height); // Paranoia checks
- height = bottom - top;
// We don't clip height and width here, rather we rely on the backend to
// perform any needed clipping.
- ptr = vs->screenPtr + (x + vs->xstart) + top * vs->width;
- _vm->_system->copyRectToScreen(ptr, vs->width, x, vs->topline + top - _vm->_screenTop, width, height);
+ const int y = vs->topline + top - _vm->_screenTop;
+ const byte *src = vs->screenPtr + (x + vs->xstart) + top * vs->width;
+
+ assert(_textSurface.pixels);
+ assert(_compositeBuf);
+ Common::Rect r(x, y, x+width, y+height);
+ r.clip(Common::Rect(_textSurface.w, _textSurface.h));
+ // TODO: is this enough clipping?
+
+ byte *dst = _compositeBuf + x + y * _vm->_screenWidth;
+ const byte *text = (byte *)_textSurface.pixels + x + y * _textSurface.pitch;
+
+ for (int h = 0; h < r.height(); ++h) {
+ for (int w = 0; w < r.width(); ++w) {
+ if (text[w] == CHARSET_MASK_TRANSPARENCY)
+ dst[w] = src[w];
+ else
+ dst[w] = text[w];
+ }
+ src += vs->width;
+ dst += _vm->_screenWidth;
+ text += _textSurface.pitch;
+ }
+
+ _vm->_system->copyRectToScreen(_compositeBuf + x + y * _vm->_screenWidth, _vm->_screenWidth, x, y, width, height);
}
#pragma mark -
@@ -633,14 +638,12 @@
// be optimized to (rect.right - rect.left) / 8 and
// thus to width / 8, but that's not the case since
// we are dealing with integer math here.
- const int mask_width = ((rect.right + 7) / 8) - (rect.left / 8);
-
- byte *mask = getMaskBuffer(rect.left, rect.top, 0);
-
- do {
- memset(mask, 0, mask_width);
- mask += gdi._numStrips;
- } while (--height);
+ const int mask_width = rect.width();
+ byte *mask = (byte *)gdi._textSurface.pixels + gdi._textSurface.pitch * rect.top + rect.left;
+ while (height--) {
+ memset(mask, CHARSET_MASK_TRANSPARENCY, mask_width);
+ mask += gdi._textSurface.pitch;
+ }
}
} else {
while (height--) {
@@ -663,9 +666,7 @@
// restoreBG(), but was changed to only restore those parts which are
// currently covered by the charset mask.
- // Loop over first three virtual screens
VirtScreen *vs = &_vm->virtscr[_textScreenID];
-
if (!vs->height)
return;
@@ -677,27 +678,8 @@
const byte *backBuf = vs->backBuf + vs->xstart;
if (vs->number == kMainVirtScreen) {
- // Restore from back buffer, but only those parts which are
- // currently covered by the charset mask. In addition, we
- // clean out the charset mask
-
- const int mask_width = _vm->gdi._numStrips;
- byte *mask = _vm->getMaskBuffer(0, 0, 0);
- assert(vs->width == 8 * _vm->gdi._numStrips);
-
- int height = vs->height;
- while (height--) {
- for (int w = 0; w < mask_width; ++w) {
- const byte maskbits = mask[w];
- if (maskbits) {
- copy8PixelsWithMasking(screenBuf + w*8, backBuf + w*8, ~maskbits);
- mask[w] = 0;
- }
- }
- screenBuf += vs->width;
- backBuf += vs->width;
- mask += _vm->gdi._numStrips;
- }
+ // Clean out the charset mask
+ memset(_vm->gdi._textSurface.pixels, CHARSET_MASK_TRANSPARENCY, _vm->gdi._textSurface.pitch * _vm->gdi._textSurface.h);
} else {
// Restore from back buffer
_vm->blit(screenBuf, backBuf, vs->width, vs->height);
@@ -713,10 +695,6 @@
memset(_vm->getResourceAddress(rtBuffer, 9), 0, _vm->gdi._imgBufOffs[1]);
}
-bool CharsetRenderer::hasCharsetMask(int left, int top, int right, int bottom) {
- return _hasMask;
-}
-
byte *ScummEngine::getMaskBuffer(int x, int y, int z) {
return gdi.getMaskBuffer(x / 8, y, z) + _screenStartStrip;
}
@@ -1170,21 +1148,12 @@
}
}
- mask_ptr = getMaskBuffer(x, y);
-
CHECK_HEAP;
if (vs->hasTwoBuffers) {
- if (_vm->_charset->hasCharsetMask(sx * 8, y, (sx + 1) * 8, bottom)) {
- if (flag & dbClear || !lightsOn)
- clear8ColWithMasking(backbuff_ptr, height, mask_ptr);
- else
- draw8ColWithMasking(backbuff_ptr, bgbak_ptr, height, mask_ptr);
- } else {
- if (flag & dbClear || !lightsOn)
- clear8Col(backbuff_ptr, height);
- else
- draw8Col(backbuff_ptr, bgbak_ptr, height);
- }
+ if (flag & dbClear || !lightsOn)
+ clear8Col(backbuff_ptr, height);
+ else
+ draw8Col(backbuff_ptr, bgbak_ptr, height);
}
CHECK_HEAP;
@@ -1304,17 +1273,13 @@
vs->bdirty[strip] = bottom;
offs = top * vs->width + vs->xstart + strip * 8;
- byte *mask_ptr = _vm->getMaskBuffer(strip * 8, top, 0);
bgbak_ptr = vs->backBuf + offs;
backbuff_ptr = vs->screenPtr + offs;
numLinesToProcess = bottom - top;
if (numLinesToProcess) {
if (_vm->isLightOn()) {
- if (_vm->_charset->hasCharsetMask(strip * 8, top, (strip + 1) * 8, bottom))
- draw8ColWithMasking(backbuff_ptr, bgbak_ptr, numLinesToProcess, mask_ptr);
- else
- draw8Col(backbuff_ptr, bgbak_ptr, numLinesToProcess);
+ draw8Col(backbuff_ptr, bgbak_ptr, numLinesToProcess);
} else {
clear8Col(backbuff_ptr, numLinesToProcess);
}
@@ -1654,47 +1619,6 @@
return useOrDecompress;
}
-void Gdi::draw8ColWithMasking(byte *dst, const byte *src, int height, byte *mask) {
- byte maskbits;
-
- do {
- maskbits = *mask;
- if (maskbits) {
- copy8PixelsWithMasking(dst, src, maskbits);
- } else {
-#if defined(SCUMM_NEED_ALIGNMENT)
- memcpy(dst, src, 8);
-#else
- ((uint32 *)dst)[0] = ((const uint32 *)src)[0];
- ((uint32 *)dst)[1] = ((const uint32 *)src)[1];
-#endif
- }
- src += _vm->_screenWidth;
- dst += _vm->_screenWidth;
- mask += _numStrips;
- } while (--height);
-}
-
-void Gdi::clear8ColWithMasking(byte *dst, int height, byte *mask) {
- byte maskbits;
-
- do {
- maskbits = *mask;
- if (maskbits) {
- clear8PixelsWithMasking(dst, 0, maskbits);
- } else {
-#if defined(SCUMM_NEED_ALIGNMENT)
- memset(dst, 0, 8);
-#else
- ((uint32 *)dst)[0] = 0;
- ((uint32 *)dst)[1] = 0;
-#endif
- }
- dst += _vm->_screenWidth;
- mask += _numStrips;
- } while (--height);
-}
-
void Gdi::draw8Col(byte *dst, const byte *src, int height) {
do {
#if defined(SCUMM_NEED_ALIGNMENT)
Index: gfx.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/gfx.h,v
retrieving revision 1.63
retrieving revision 1.64
diff -u -d -r1.63 -r1.64
--- gfx.h 8 Aug 2004 13:24:41 -0000 1.63
+++ gfx.h 8 Aug 2004 22:09:50 -0000 1.64
@@ -24,6 +24,7 @@
#define GFX_H
#include "common/rect.h"
+#include "graphics/surface.h"
namespace Scumm {
@@ -217,7 +218,11 @@
Gdi(ScummEngine *vm);
+ Graphics::Surface _textSurface;
+
protected:
+ byte *_compositeBuf;
+
byte *_roomPalette;
byte _decomp_shr, _decomp_mask;
byte _transparentColor;
@@ -251,9 +256,7 @@
void decodeStrip3DO(byte *dst, const byte *src, int height, byte transpCheck);
void decodeStripHE(byte *dst, const byte *src, int height, byte transpCheck);
- void draw8ColWithMasking(byte *dst, const byte *src, int height, byte *mask);
void draw8Col(byte *dst, const byte *src, int height);
- void clear8ColWithMasking(byte *dst, int height, byte *mask);
void clear8Col(byte *dst, int height);
void decompressMaskImgOr(byte *dst, const byte *src, int height);
void decompressMaskImg(byte *dst, const byte *src, int height);
@@ -261,9 +264,11 @@
void drawStripToScreen(VirtScreen *vs, int x, int w, int t, int b);
void updateDirtyScreen(VirtScreen *vs);
- byte *getMaskBuffer(int x, int y, int z = 0);
+ byte *getMaskBuffer(int x, int y, int z);
public:
+ void init();
+
void drawBitmap(const byte *ptr, VirtScreen *vs, int x, int y, const int width, const int height,
int stripnr, int numstrip, byte flag, StripTable *table = 0);
void drawBitmapV2Helper(const byte *ptr, VirtScreen *vs, int x, int y, const int width, const int height,
Index: nut_renderer.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/nut_renderer.cpp,v
retrieving revision 1.49
retrieving revision 1.50
diff -u -d -r1.49 -r1.50
--- nut_renderer.cpp 26 Jul 2004 23:14:56 -0000 1.49
+++ nut_renderer.cpp 8 Aug 2004 22:09:50 -0000 1.50
@@ -239,16 +239,13 @@
return _chars[c].height;
}
-void NutRenderer::drawShadowChar(int c, int x, int y, byte color, bool useMask, bool showShadow) {
- debug(8, "NutRenderer::drawShadowChar('%c', %d, %d, %d, %d, %d) called", c, x, y, (int)color, useMask, showShadow);
+void NutRenderer::drawShadowChar(const Graphics::Surface &s, int c, int x, int y, byte color, bool showShadow) {
+ debug(8, "NutRenderer::drawShadowChar('%c', %d, %d, %d, %d) called", c, x, y, (int)color, showShadow);
if (!_loaded) {
warning("NutRenderer::drawShadowChar() Font is not loaded");
return;
}
- VirtScreen *vs = &_vm->virtscr[kMainVirtScreen];
- byte *dst, *mask = NULL;
-
// HACK: we draw the character a total of 7 times: 6 times shifted
// and in black for the shadow, and once in the right color and position.
// This way we achieve the exact look as the original CMI had. However,
@@ -268,18 +265,10 @@
y += offsetY[i];
color = cTable[i];
- if (y >= vs->height || x >= vs->width) {
- continue;
- }
-
- dst = vs->screenPtr + y * vs->width + x + vs->xstart;
- if (useMask)
- mask = _vm->getMaskBuffer(x, y, 0);
-
if (c >= 256 && _vm->_CJKMode)
- draw2byte(dst, mask, c, x, y - _vm->_screenTop, color);
+ draw2byte(s, c, x, y, color);
else
- drawChar(dst, mask, (byte)c, x, y - _vm->_screenTop, color);
+ drawChar(s, (byte)c, x, y, color);
x -= offsetX[i];
y -= offsetY[i];
@@ -318,15 +307,13 @@
}
}
-void NutRenderer::drawChar(byte *dst, byte *mask, byte c, int x, int y, byte color) {
- const int width = MIN(_chars[c].width, _vm->_screenWidth - x);
- const int height = MIN(_chars[c].height, _vm->_screenHeight - y);
+void NutRenderer::drawChar(const Graphics::Surface &s, byte c, int x, int y, byte color) {
+ byte *dst = (byte *)s.pixels + y * s.pitch + x;
+ const int width = MIN(_chars[c].width, s.w - x);
+ const int height = MIN(_chars[c].height, s.h - y);
const byte *src = _chars[c].src;
const int srcPitch = _chars[c].width;
- byte maskmask;
- int maskpos;
-
const int minX = x < 0 ? -x : 0;
const int minY = y < 0 ? -y : 0;
@@ -336,75 +323,47 @@
if (minY) {
src += minY * srcPitch;
- dst += minY * _vm->_screenWidth;
- if (mask)
- mask += minY * _vm->gdi._numStrips;
+ dst += minY * s.pitch;
}
for (int ty = minY; ty < height; ty++) {
- maskmask = revBitMask[(x + minX) & 7];
- maskpos = (x%8 + minX) / 8;
for (int tx = minX; tx < width; tx++) {
if (src[tx] != 0) {
dst[tx] = color;
- if (mask)
- mask[maskpos] |= maskmask;
- }
- maskmask >>= 1;
- if (maskmask == 0) {
- maskmask = 0x80;
- maskpos++;
}
}
src += srcPitch;
- dst += _vm->_screenWidth;
- if (mask)
- mask += _vm->gdi._numStrips;
+ dst += s.pitch;
}
}
-void NutRenderer::draw2byte(byte *dst, byte *mask, int c, int x, int y, byte color) {
+void NutRenderer::draw2byte(const Graphics::Surface &s, int c, int x, int y, byte color) {
if (!_loaded) {
debug(2, "NutRenderer::draw2byte() Font is not loaded");
return;
}
+ byte *dst = (byte *)s.pixels + y * s.pitch + x;
const int width = _vm->_2byteWidth;
- const int height = MIN(_vm->_2byteHeight, _vm->_screenHeight - y);
+ const int height = MIN(_vm->_2byteHeight, s.h - y);
byte *src = _vm->get2byteCharPtr(c);
byte bits = 0;
- byte maskmask;
- int maskpos;
-
if (height <= 0 || width <= 0) {
return;
}
for (int ty = 0; ty < height; ty++) {
- maskmask = revBitMask[x & 7];
- maskpos = 0;
for (int tx = 0; tx < width; tx++) {
if ((tx & 7) == 0)
bits = *src++;
- if (x + tx < 0 || x + tx >= _vm->_screenWidth || y + ty < 0)
+ if (x + tx < 0 || x + tx >= s.w || y + ty < 0)
continue;
if (bits & revBitMask[tx & 7]) {
dst[tx] = color;
- if (mask) {
- mask[maskpos] |= maskmask;
- }
- }
-
- maskmask >>= 1;
- if (maskmask == 0) {
- maskmask = 0x80;
- maskpos++;
}
}
- dst += _vm->_screenWidth;
- if (mask)
- mask += _vm->gdi._numStrips;
+ dst += s.pitch;
}
}
Index: nut_renderer.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/nut_renderer.h,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -d -r1.19 -r1.20
--- nut_renderer.h 27 Jun 2004 21:52:23 -0000 1.19
+++ nut_renderer.h 8 Aug 2004 22:09:50 -0000 1.20
@@ -22,6 +22,7 @@
#define NUT_RENDERER_H
#include "common/file.h"
+#include "graphics/surface.h"
namespace Scumm {
@@ -43,8 +44,8 @@
int32 decodeCodec44(byte *dst, const byte *src, uint32 length);
- void drawChar(byte *dst, byte *mask, byte c, int x, int y, byte color);
- void draw2byte(byte *dst, byte *mask, int c, int x, int y, byte color);
+ void drawChar(const Graphics::Surface &s, byte c, int x, int y, byte color);
+ void draw2byte(const Graphics::Surface &s, int c, int x, int y, byte color);
public:
NutRenderer(ScummEngine *vm);
@@ -54,7 +55,7 @@
bool loadFont(const char *filename);
void drawFrame(byte *dst, int c, int x, int y);
- void drawShadowChar(int c, int x, int y, byte color, bool useMask, bool showShadow);
+ void drawShadowChar(const Graphics::Surface &s, int c, int x, int y, byte color, bool showShadow);
int getCharWidth(byte c);
int getCharHeight(byte c);
Index: scumm.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/scumm.cpp,v
retrieving revision 1.115
retrieving revision 1.116
diff -u -d -r1.115 -r1.116
--- scumm.cpp 6 Aug 2004 06:19:14 -0000 1.115
+++ scumm.cpp 8 Aug 2004 22:09:50 -0000 1.116
@@ -2652,13 +2652,13 @@
// Transparent color
if (_features & GF_OLD_BUNDLE)
- gdi._transparentColor = 255; // TODO - FIXME
+ gdi._transparentColor = 255;
else {
ptr = findResourceData(MKID('TRNS'), roomptr);
if (ptr)
gdi._transparentColor = ptr[0];
else if (_version == 8)
- gdi._transparentColor = 5; // FIXME
+ gdi._transparentColor = 5;
else
gdi._transparentColor = 255;
}
Index: verbs.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/verbs.cpp,v
retrieving revision 1.101
retrieving revision 1.102
diff -u -d -r1.101 -r1.102
--- verbs.cpp 6 Aug 2004 06:19:14 -0000 1.101
+++ verbs.cpp 8 Aug 2004 22:09:50 -0000 1.102
@@ -419,8 +419,6 @@
}
void ScummEngine::restoreVerbBG(int verb) {
- if (_version >= 7)
- return;
VerbSlot *vs;
More information about the Scummvm-git-logs
mailing list