Ticket #8352: text-render.patch

File text-render.patch, 26.9 KB (added by fingolfin, 20 years ago)
  • akos.cpp

    RCS file: /cvsroot/scummvm/scummvm/scumm/akos.cpp,v
    retrieving revision 1.137
    diff -u -d -r1.137 akos.cpp
     
    385385                                                return;
    386386                                        }
    387387                                } else {
    388                                         masked = (y < 0 || y >= _outheight) || (v1.mask_ptr && ((mask[0] | mask[v1.imgbufoffs]) & maskbit));
     388                                        masked = (y < 0 || y >= _outheight) || (v1.mask_ptr && (*mask & maskbit));
    389389
    390390                                        if (color && !masked && !skip_column) {
    391391                                                pcolor = palette[color];
     
    781781
    782782        v1.destptr = _outptr + v1.y * _outwidth + v1.x;
    783783
    784         v1.mask_ptr = _vm->getMaskBuffer(0, v1.y, 0);
    785         v1.imgbufoffs = _vm->gdi._imgBufOffs[_zbuf];
     784        v1.mask_ptr = _vm->getMaskBuffer(0, v1.y, _zbuf);
    786785
    787786        codec1_genericDecode();
    788787       
     
    847846        }
    848847        bdd.y = _actorY + ymoveCur;
    849848
    850         if (_zbuf != 0) {
    851                 bdd.maskPtr = _vm->getMaskBuffer(0, 0, _zbuf);
    852         }
     849        bdd.maskPtr = _vm->getMaskBuffer(0, 0, _zbuf);
    853850        _vm->drawBomp(bdd, !_mirror);
    854851
    855852        _vm->_bompActorPalettePtr = NULL;
     
    930927                int32 numskip_before, int32 numskip_after, byte transparency, int maskLeft, int maskTop, int zBuf) {
    931928        byte *tmp_buf = akos16.buffer;
    932929        int maskpitch;
    933         byte *maskptr = 0, *charsetMask = 0;
     930        byte *maskptr;
    934931        const byte maskbit = revBitMask[maskLeft & 7];
    935932
    936933        if (dir < 0) {
     
    946943
    947944        maskpitch = _numStrips;
    948945       
    949         charsetMask = _vm->getMaskBuffer(maskLeft, maskTop, 0);
    950         if (zBuf != 0)
    951                 maskptr = _vm->getMaskBuffer(maskLeft, maskTop, zBuf);
     946        maskptr = _vm->getMaskBuffer(maskLeft, maskTop, zBuf);
    952947
    953948        assert(t_height > 0);
    954949        assert(t_width > 0);
    955950        while (t_height--) {
    956951                akos16DecodeLine(tmp_buf, t_width, dir);
    957                 bompApplyMask(akos16.buffer, charsetMask, maskbit, t_width, transparency);
    958                 if (maskptr) {
    959                         bompApplyMask(akos16.buffer, maskptr, maskbit, t_width, transparency);
    960                         maskptr += maskpitch;
    961                 }
     952                bompApplyMask(akos16.buffer, maskptr, maskbit, t_width, transparency);
    962953                bool HE7Check = (_vm->_heversion == 70);
    963954                bompApplyShadow(_shadow_mode, _shadow_table, akos16.buffer, dest, t_width, transparency, HE7Check);
    964955
     
    966957                        akos16SkipData(numskip_after);
    967958                }
    968959                dest += pitch;
    969                 charsetMask += maskpitch;
     960                maskptr += maskpitch;
    970961        }
    971962}
    972963
  • base-costume.h

    RCS file: /cvsroot/scummvm/scummvm/scumm/base-costume.h,v
    retrieving revision 1.21
    diff -u -d -r1.21 base-costume.h
     
    9797                int skip_width;
    9898                byte *destptr;
    9999                const byte *mask_ptr;
    100                 int imgbufoffs;
    101100        } v1;
    102101
    103102public:
  • bomp.cpp

    RCS file: /cvsroot/scummvm/scummvm/scumm/bomp.cpp,v
    retrieving revision 2.20
    diff -u -d -r2.20 bomp.cpp
     
    199199        const byte *src;
    200200        byte *dst;
    201201        byte *mask = 0;
    202         byte *charset_mask;
    203202        Common::Rect clip;
    204203        byte *scalingYPtr = bd.scalingYPtr;
    205204        byte skip_y_bits = 0x80;
     
    234233
    235234        const byte maskbit = revBitMask[(bd.x + clip.left) & 7];
    236235
    237         // Always mask against the charset mask
    238         charset_mask = getMaskBuffer(bd.x + clip.left, bd.y, 0);
    239 
    240         // Also mask against any additionally imposed mask
     236        // Mask against any additionally imposed mask
    241237        if (bd.maskPtr) {
    242238                mask = bd.maskPtr + (bd.y * gdi._numStrips) + ((bd.x + clip.left) / 8);
    243239        }
     
    310306                        // Replace the parts of the line which are masked with the transparency color
    311307                        if (bd.maskPtr)
    312308                                bompApplyMask(line_ptr, mask, maskbit, width, 255);
    313                         bompApplyMask(line_ptr, charset_mask, maskbit, width, 255);
    314309       
    315310                        // Apply custom color map, if available
    316311                        if (_bompActorPalettePtr)
     
    324319                // Advance to the next line
    325320                pos_y++;
    326321                mask += gdi._numStrips;
    327                 charset_mask += gdi._numStrips;
    328322                dst += bd.outwidth;
    329323        }
    330324}
  • charset.cpp

    RCS file: /cvsroot/scummvm/scummvm/scumm/charset.cpp,v
    retrieving revision 2.93
    diff -u -d -r2.93 charset.cpp
     
    944944void CharsetRendererV3::printChar(int chr) {
    945945        // Indy3 / Zak256 / Loom
    946946        VirtScreen *vs;
    947         byte *char_ptr, *dest_ptr, *mask_ptr;
     947        byte *char_ptr, *dest_ptr;
    948948        int width, height;
    949949        int drawTop;
    950950
     
    972972
    973973        drawTop = _top - vs->topline;
    974974        char_ptr = _fontPtr + chr * 8;
    975         dest_ptr = vs->screenPtr + vs->xstart + drawTop * vs->width + _left;
    976         mask_ptr = _vm->getMaskBuffer(_left, drawTop, 0);
    977975
    978976        _vm->markRectAsDirty(vs->number, _left, _left + width, drawTop, drawTop + height);
    979977       
     
    981979                _hasMask = true;
    982980                _textScreenID = vs->number;
    983981        }
     982        if (_ignoreCharsetMask || !vs->hasTwoBuffers) {
     983                dest_ptr = vs->screenPtr + vs->xstart + drawTop * vs->width + _left;
     984        } else {
     985                dest_ptr = (byte *)_vm->gdi._textSurface.pixels + drawTop * _vm->gdi._textSurface.pitch + _left;
     986        }
    984987
    985         drawBits1(vs, dest_ptr, char_ptr, mask_ptr, drawTop, 8, 8);
     988        drawBits1(vs, dest_ptr, char_ptr, drawTop, 8, 8);
    986989
    987990        if (_str.left > _left)
    988991                _str.left = _left;
     
    10851088
    10861089        _vm->markRectAsDirty(vs->number, _left, _left + width, drawTop, drawTop + height + offsY);
    10871090
     1091        byte *dst;
     1092        byte *back;
     1093
    10881094        if (!_ignoreCharsetMask) {
    10891095                _hasMask = true;
    10901096                _textScreenID = vs->number;
    10911097        }
     1098        if (_ignoreCharsetMask || !vs->hasTwoBuffers) {
     1099                dst = vs->screenPtr + vs->xstart + drawTop * vs->width + _left;
     1100        } else {
     1101                dst = (byte *)_vm->gdi._textSurface.pixels + drawTop * _vm->gdi._textSurface.pitch + _left;
     1102        }
    10921103
    1093         byte *mask = _vm->getMaskBuffer(_left, drawTop, 0);
    1094         byte *dst = vs->screenPtr + vs->xstart + drawTop * vs->width + _left;
    1095 
    1096         byte *back = dst;
     1104        back = dst;
    10971105        if (_blitAlso && vs->hasTwoBuffers) {
    10981106                dst = vs->backBuf + vs->xstart + drawTop * vs->width + _left;
    10991107        }
    11001108
    11011109        if (is2byte) {
    1102                 drawBits1(vs, dst, charPtr, mask, drawTop, origWidth, origHeight);
     1110                drawBits1(vs, dst, charPtr, drawTop, origWidth, origHeight);
    11031111        } else {
    11041112                byte bpp = *_fontPtr;
    1105                 drawBitsN(vs, dst, charPtr, mask, bpp, drawTop, origWidth, origHeight);
     1113                drawBitsN(vs, dst, charPtr, bpp, drawTop, origWidth, origHeight);
    11061114        }
    11071115
    11081116        if (_blitAlso && vs->hasTwoBuffers) {
     
    11281136        _top -= offsY;
    11291137}
    11301138
    1131 void CharsetRendererClassic::drawBitsN(VirtScreen *vs, byte *dst, const byte *src, byte *mask, byte bpp, int drawTop, int width, int height) {
    1132         byte maskmask;
     1139void CharsetRendererClassic::drawBitsN(VirtScreen *vs, byte *dst, const byte *src, byte bpp, int drawTop, int width, int height) {
    11331140        int y, x;
    1134         int maskpos;
    11351141        int color;
    11361142        byte numbits, bits;
    1137         bool useMask = (vs->number == kMainVirtScreen && !_ignoreCharsetMask);
    11381143
    11391144        assert(bpp == 1 || bpp == 2 || bpp == 4 || bpp == 8);
    11401145        bits = *src++;
    11411146        numbits = 8;
    11421147
    11431148        for (y = 0; y < height && y + drawTop < vs->height; y++) {
    1144                 maskmask = revBitMask[_left & 7];
    1145                 maskpos = 0;
    1146 
    11471149                for (x = 0; x < width; x++) {
    11481150                        color = (bits >> (8 - bpp)) & 0xFF;
    11491151                       
    11501152                        if (color && y + drawTop >= 0) {
    11511153                                *dst = _vm->_charsetColorMap[color];
    1152                                 if (useMask) {
    1153                                         mask[maskpos] |= maskmask;
    1154                                 }
    11551154                        }
    11561155                        dst++;
    11571156                        bits <<= bpp;
     
    11601159                                bits = *src++;
    11611160                                numbits = 8;
    11621161                        }
    1163                         maskmask >>= 1;
    1164                         if (maskmask == 0) {
    1165                                 maskmask = 0x80;
    1166                                 maskpos++;
    1167                         }
    11681162                }
    11691163                dst += vs->width - width;
    1170                 mask += _vm->gdi._numStrips;
    11711164        }
    11721165}
    11731166
    1174 void CharsetRendererCommon::drawBits1(VirtScreen *vs, byte *dst, const byte *src, byte *mask, int drawTop, int width, int height) {
    1175         byte maskmask;
     1167void CharsetRendererCommon::drawBits1(VirtScreen *vs, byte *dst, const byte *src, int drawTop, int width, int height) {
    11761168        int y, x;
    1177         int maskpos;
    11781169        byte bits = 0;
    1179         bool useMask = (vs->number == kMainVirtScreen && !_ignoreCharsetMask);
    11801170
    11811171        for (y = 0; y < height && y + drawTop < vs->height; y++) {
    1182                 maskmask = revBitMask[_left & 7];
    1183                 maskpos = 0;
    1184 
    11851172                for (x = 0; x < width; x++) {
    11861173                        if ((x % 8) == 0)
    11871174                                bits = *src++;
     
    11921179                                        *(dst + vs->width + 1) = _shadowColor;
    11931180                                }                                       
    11941181                                *dst = _color;
    1195                                 if (useMask) {
    1196                                         mask[maskpos] |= maskmask;
    1197                                         if (_dropShadow) {
    1198                                                 mask[maskpos + _vm->gdi._numStrips] |= maskmask;
    1199                                                 if (maskmask == 1) {
    1200                                                         mask[maskpos + 1] |= 0x80;
    1201                                                         mask[maskpos + _vm->gdi._numStrips + 1] |= 0x80;
    1202                                                 } else {
    1203                                                         mask[maskpos] |= (maskmask >> 1);
    1204                                                         mask[maskpos + _vm->gdi._numStrips] |= (maskmask >> 1);
    1205                                                 }
    1206                                         }
    1207                                 }
    12081182                        }
    12091183                        dst++;
    1210                         maskmask >>= 1;
    1211                         if (maskmask == 0) {
    1212                                 maskmask = 0x80;
    1213                                 maskpos++;
    1214                         }
    12151184                }
    12161185
    12171186                dst += vs->width - width;
    1218                 mask += _vm->gdi._numStrips;
    12191187        }
    12201188}
    12211189
     
    12931261        shadow.right = _left + width + 2;
    12941262        shadow.bottom = _top + height + 2;
    12951263
     1264        Graphics::Surface s;
    12961265        if (!_ignoreCharsetMask) {
    12971266                _hasMask = true;
    12981267                _textScreenID = kMainVirtScreen;
    12991268        }
     1269        if (_ignoreCharsetMask) {
     1270                VirtScreen *vs = &_vm->virtscr[kMainVirtScreen];
     1271                s.pixels = vs->screenPtr + vs->xstart + _vm->_screenTop * vs->width;
     1272                s.w = vs->width;
     1273                s.h = vs->height;
     1274                s.pitch = vs->width;
     1275                s.bytesPerPixel = 1;
     1276        } else {
     1277                s = _vm->gdi._textSurface;
     1278        }
    13001279
    1301         _current->drawShadowChar(chr, _left, _top, _color, !_ignoreCharsetMask, _curId != 3);
     1280        _current->drawShadowChar(s, chr, _left, _top, _color, _curId != 3);
    13021281        _vm->markRectAsDirty(kMainVirtScreen, shadow);
    13031282
    13041283        if (_str.left > _left)
  • charset.h

    RCS file: /cvsroot/scummvm/scummvm/scumm/charset.h,v
    retrieving revision 2.27
    diff -u -d -r2.27 charset.h
     
    6969
    7070        void restoreCharsetBg();
    7171        void clearCharsetMask();
    72         bool hasCharsetMask(int left, int top, int right, int bottom);
    7372
    7473        virtual void printChar(int chr) = 0;
    7574
     
    8887protected:
    8988        byte *_fontPtr;
    9089
    91         void drawBits1(VirtScreen *vs, byte *dst, const byte *src, byte *mask, int drawTop, int width, int height);
     90        void drawBits1(VirtScreen *vs, byte *dst, const byte *src, int drawTop, int width, int height);
    9291
    9392public:
    9493        CharsetRendererCommon(ScummEngine *vm) : CharsetRenderer(vm) {}
     
    102101protected:
    103102        int getCharWidth(byte chr);
    104103
    105         void drawBitsN(VirtScreen *vs, byte *dst, const byte *src, byte *mask, byte bpp, int drawTop, int width, int height);
     104        void drawBitsN(VirtScreen *vs, byte *dst, const byte *src, byte bpp, int drawTop, int width, int height);
    106105
    107106public:
    108107        CharsetRendererClassic(ScummEngine *vm) : CharsetRendererCommon(vm) {}
  • costume.cpp

    RCS file: /cvsroot/scummvm/scummvm/scumm/costume.cpp,v
    retrieving revision 1.134
    diff -u -d -r1.134 costume.cpp
     
    284284
    285285        v1.destptr = _outptr + v1.y * _outwidth + v1.x;
    286286
    287         v1.mask_ptr = _vm->getMaskBuffer(0, v1.y, 0);
    288         v1.imgbufoffs = _vm->gdi._imgBufOffs[_zbuf];
     287        v1.mask_ptr = _vm->getMaskBuffer(0, v1.y, _zbuf);
    289288
    290289        CHECK_HEAP
    291290
     
    350349};
    351350
    352351#define MASK_AT(xoff) \
    353         (mask && (mask[((v1.x + xoff) / 8) + v1.imgbufoffs] & revBitMask[(v1.x + xoff) & 7]))
     352        (mask && (mask[((v1.x + xoff) / 8)] & revBitMask[(v1.x + xoff) & 7]))
    354353#define LINE(c,p) \
    355354        pcolor = (color >> c) & 3; \
    356355        if (pcolor) { \
     
    467466
    468467                do {
    469468                        if (_scaleY == 255 || *scaleytab++ < _scaleY) {
    470                                 masked = (y < 0 || y >= _outheight) || (v1.mask_ptr && ((mask[0] | mask[v1.imgbufoffs]) & maskbit));
     469                                masked = (y < 0 || y >= _outheight) || (v1.mask_ptr && (mask[0] & maskbit));
    471470                               
    472471                                if (color && !masked) {
    473472                                        // FIXME: Fully implement _shadow_mode.in Sam & Max
     
    536535                        len = *src++;
    537536                do {
    538537                        if (_scaleY == 255 || cost_scaleTable[_scaleIndexY] < _scaleY) {
    539                                 masked = (y < 0 || y >= _outheight) || (v1.mask_ptr && ((mask[0] | mask[v1.imgbufoffs]) & maskbit));
     538                                masked = (y < 0 || y >= _outheight) || (v1.mask_ptr && (mask[0] & maskbit));
    540539                               
    541540                                if (color && v1.x >= 0 && v1.x < _outwidth && !masked) {
    542541                                        *dst = _palette[color];
  • gfx.cpp

    RCS file: /cvsroot/scummvm/scummvm/scumm/gfx.cpp,v
    retrieving revision 2.279
    diff -u -d -r2.279 gfx.cpp
     
    199199#pragma mark -
    200200
    201201
     202#define CHARSET_MASK_TRANSPARENCY       254
    202203
    203204Gdi::Gdi(ScummEngine *vm) {
    204205        memset(this, 0, sizeof(*this));
     
    206207        _roomPalette = vm->_roomPalette;
    207208        if ((vm->_features & GF_AMIGA) && (vm->_version >= 4))
    208209                _roomPalette += 16;
     210       
     211        _compositeBuf = 0;
     212        _textSurface.pixels = 0;
    209213}
    210214
    211215void ScummEngine::initScreens(int b, int h) {
     
    235239
    236240        _screenB = b;
    237241        _screenH = h;
     242       
     243        gdi.init();
     244}
     245
     246void Gdi::init() {
     247        const int size = _vm->_screenWidth * _vm->_screenHeight;
     248        free(_compositeBuf);
     249        free(_textSurface.pixels);
     250        _compositeBuf = (byte *)malloc(size);
     251        _textSurface.pixels = malloc(size);
     252        memset(_compositeBuf, CHARSET_MASK_TRANSPARENCY, size);
     253        memset(_textSurface.pixels, CHARSET_MASK_TRANSPARENCY, size);
     254
     255        _textSurface.w = _vm->_screenWidth;
     256        _textSurface.h = _vm->_screenHeight;
     257        _textSurface.pitch = _vm->_screenWidth;
     258        _textSurface.bytesPerPixel = 1;
    238259}
    239260
     261
    240262void ScummEngine::initVirtScreen(VirtScreenNumber slot, int number, int top, int width, int height, bool twobufs,
    241263                                                                                                         bool scrollable) {
    242264        VirtScreen *vs = &virtscr[slot];
     
    246268        assert(slot >= 0 && slot < 4);
    247269
    248270        if (_version >= 7) {
    249                 if (slot == 0 && (_roomHeight != 0))
     271                if (slot == kMainVirtScreen && (_roomHeight != 0))
    250272                        height = _roomHeight;
    251273        }
    252274
     
    431453 * specified by top/bottom coordinate in the virtual screen.
    432454 */
    433455void Gdi::drawStripToScreen(VirtScreen *vs, int x, int width, int top, int bottom) {
    434         byte *ptr;
    435         int height;
     456        const int height = bottom - top;
    436457
    437458        if (bottom <= top)
    438459                return;
     
    442463
    443464        assert(top >= 0 && bottom <= vs->height);       // Paranoia checks
    444465
    445         height = bottom - top;
    446466        // We don't clip height and width here, rather we rely on the backend to
    447467        // perform any needed clipping.
    448         ptr = vs->screenPtr + (x + vs->xstart) + top * vs->width;
    449         _vm->_system->copyRectToScreen(ptr, vs->width, x, vs->topline + top - _vm->_screenTop, width, height);
     468        const int y = vs->topline + top - _vm->_screenTop;
     469        const byte *src = vs->screenPtr + (x + vs->xstart) + top * vs->width;
     470
     471        assert(_textSurface.pixels);
     472        assert(_compositeBuf);
     473        Common::Rect r(x, y, x+width, y+height);
     474        r.clip(Common::Rect(_textSurface.w, _textSurface.h));
     475        // TODO: is this enough clipping?
     476
     477        byte *dst = _compositeBuf + x + y * _vm->_screenWidth;
     478        const byte *text = (byte *)_textSurface.pixels + x + y * _textSurface.pitch;
     479
     480        for (int h = 0; h < r.height(); ++h) {
     481                for (int w = 0; w < r.width(); ++w) {
     482                        if (text[w] == CHARSET_MASK_TRANSPARENCY)
     483                                dst[w] = src[w];
     484                        else
     485                                dst[w] = text[w];
     486                }
     487                src += vs->width;
     488                dst += _vm->_screenWidth;
     489                text += _textSurface.pitch;
     490        }
     491       
     492        _vm->_system->copyRectToScreen(_compositeBuf + x + y * _vm->_screenWidth, _vm->_screenWidth, x, y, width, height);
    450493}
    451494
    452495#pragma mark -
     
    633676                        // be optimized to (rect.right - rect.left) / 8 and
    634677                        // thus to width / 8, but that's not the case since
    635678                        // we are dealing with integer math here.
    636                         const int mask_width = ((rect.right + 7) / 8) - (rect.left / 8);
    637 
    638                         byte *mask = getMaskBuffer(rect.left, rect.top, 0);
    639 
    640                         do {
    641                                 memset(mask, 0, mask_width);
    642                                 mask += gdi._numStrips;
    643                         } while (--height);
     679                        const int mask_width = rect.width();
     680                        byte *mask = (byte *)gdi._textSurface.pixels + gdi._textSurface.pitch * rect.top + rect.left;
     681                        while (height--) {
     682                                memset(mask, CHARSET_MASK_TRANSPARENCY, mask_width);
     683                                mask += gdi._textSurface.pitch;
     684                        }
    644685                }
    645686        } else {
    646687                while (height--) {
     
    663704                // restoreBG(), but was changed to only restore those parts which are
    664705                // currently covered by the charset mask.
    665706
    666                 // Loop over first three virtual screens
    667707                VirtScreen *vs = &_vm->virtscr[_textScreenID];
    668                
    669708                if (!vs->height)
    670709                        return;
    671710
     
    677716                        const byte *backBuf = vs->backBuf + vs->xstart;
    678717
    679718                        if (vs->number == kMainVirtScreen) {
    680                                 // Restore from back buffer, but only those parts which are
    681                                 // currently covered by the charset mask. In addition, we
    682                                 // clean out the charset mask
    683 
    684                                 const int mask_width = _vm->gdi._numStrips;
    685                                 byte *mask = _vm->getMaskBuffer(0, 0, 0);
    686                                 assert(vs->width == 8 * _vm->gdi._numStrips);
    687                                
    688                                 int height = vs->height;
    689                                 while (height--) {
    690                                         for (int w = 0; w < mask_width; ++w) {
    691                                                 const byte maskbits = mask[w];
    692                                                 if (maskbits) {
    693                                                         copy8PixelsWithMasking(screenBuf + w*8, backBuf + w*8, ~maskbits);
    694                                                         mask[w] = 0;
    695                                                 }
    696                                         }
    697                                         screenBuf += vs->width;
    698                                         backBuf += vs->width;
    699                                         mask += _vm->gdi._numStrips;
    700                                 }
     719                                // Clean out the charset mask
     720                                memset(_vm->gdi._textSurface.pixels, CHARSET_MASK_TRANSPARENCY, _vm->gdi._textSurface.pitch * _vm->gdi._textSurface.h);
    701721                        } else {
    702722                                // Restore from back buffer
    703723                                _vm->blit(screenBuf, backBuf, vs->width, vs->height);
     
    713733        memset(_vm->getResourceAddress(rtBuffer, 9), 0, _vm->gdi._imgBufOffs[1]);
    714734}
    715735
    716 bool CharsetRenderer::hasCharsetMask(int left, int top, int right, int bottom) {
    717         return _hasMask;
    718 }
    719 
    720736byte *ScummEngine::getMaskBuffer(int x, int y, int z) {
    721737        return gdi.getMaskBuffer(x / 8, y, z) + _screenStartStrip;
    722738}
     
    11641180                        }
    11651181                }
    11661182
    1167                 mask_ptr = getMaskBuffer(x, y);
    1168 
    11691183                CHECK_HEAP;
    11701184                if (vs->hasTwoBuffers) {
    1171                         if (_vm->_charset->hasCharsetMask(sx * 8, y, (sx + 1) * 8, bottom)) {
    1172                                 if (flag & dbClear || !lightsOn)
    1173                                         clear8ColWithMasking(backbuff_ptr, height, mask_ptr);
    1174                                 else
    1175                                         draw8ColWithMasking(backbuff_ptr, bgbak_ptr, height, mask_ptr);
    1176                         } else {
    1177                                 if (flag & dbClear || !lightsOn)
    1178                                         clear8Col(backbuff_ptr, height);
    1179                                 else
    1180                                         draw8Col(backbuff_ptr, bgbak_ptr, height);
    1181                         }
     1185                        if (flag & dbClear || !lightsOn)
     1186                                clear8Col(backbuff_ptr, height);
     1187                        else
     1188                                draw8Col(backbuff_ptr, bgbak_ptr, height);
    11821189                }
    11831190                CHECK_HEAP;
    11841191
     
    12981305                vs->bdirty[strip] = bottom;
    12991306
    13001307        offs = top * vs->width + vs->xstart + strip * 8;
    1301         byte *mask_ptr = _vm->getMaskBuffer(strip * 8, top, 0);
    13021308        bgbak_ptr = vs->backBuf + offs;
    13031309        backbuff_ptr = vs->screenPtr + offs;
    13041310
    13051311        numLinesToProcess = bottom - top;
    13061312        if (numLinesToProcess) {
    13071313                if (_vm->isLightOn()) {
    1308                         if (_vm->_charset->hasCharsetMask(strip * 8, top, (strip + 1) * 8, bottom))
    1309                                 draw8ColWithMasking(backbuff_ptr, bgbak_ptr, numLinesToProcess, mask_ptr);
    1310                         else
    1311                                 draw8Col(backbuff_ptr, bgbak_ptr, numLinesToProcess);
     1314                        draw8Col(backbuff_ptr, bgbak_ptr, numLinesToProcess);
    13121315                } else {
    13131316                        clear8Col(backbuff_ptr, numLinesToProcess);
    13141317                }
     
    16741677        return useOrDecompress;
    16751678}
    16761679
    1677 void Gdi::draw8ColWithMasking(byte *dst, const byte *src, int height, byte *mask) {
    1678         byte maskbits;
    1679 
    1680         do {
    1681                 maskbits = *mask;
    1682                 if (maskbits) {
    1683                         copy8PixelsWithMasking(dst, src, maskbits);
    1684                 } else {
    1685 #if defined(SCUMM_NEED_ALIGNMENT)
    1686                         memcpy(dst, src, 8);
    1687 #else
    1688                         ((uint32 *)dst)[0] = ((const uint32 *)src)[0];
    1689                         ((uint32 *)dst)[1] = ((const uint32 *)src)[1];
    1690 #endif
    1691                 }
    1692                 src += _vm->_screenWidth;
    1693                 dst += _vm->_screenWidth;
    1694                 mask += _numStrips;
    1695         } while (--height);
    1696 }
    1697 
    1698 void Gdi::clear8ColWithMasking(byte *dst, int height, byte *mask) {
    1699         byte maskbits;
    1700 
    1701         do {
    1702                 maskbits = *mask;
    1703                 if (maskbits) {
    1704                         clear8PixelsWithMasking(dst, 0, maskbits);
    1705                 } else {
    1706 #if defined(SCUMM_NEED_ALIGNMENT)
    1707                         memset(dst, 0, 8);
    1708 #else
    1709                         ((uint32 *)dst)[0] = 0;
    1710                         ((uint32 *)dst)[1] = 0;
    1711 #endif
    1712                 }
    1713                 dst += _vm->_screenWidth;
    1714                 mask += _numStrips;
    1715         } while (--height);
    1716 }
    1717 
    17181680void Gdi::draw8Col(byte *dst, const byte *src, int height) {
    17191681        do {
    17201682#if defined(SCUMM_NEED_ALIGNMENT)
  • gfx.h

    RCS file: /cvsroot/scummvm/scummvm/scumm/gfx.h,v
    retrieving revision 1.62
    diff -u -d -r1.62 gfx.h
     
    2424#define GFX_H
    2525
    2626#include "common/rect.h"
     27#include "graphics/surface.h"
    2728
    2829namespace Scumm {
    2930
     
    217218       
    218219        Gdi(ScummEngine *vm);
    219220
     221        Graphics::Surface _textSurface;
     222
    220223protected:
     224        byte *_compositeBuf;
     225
    221226        byte *_roomPalette;
    222227        byte _decomp_shr, _decomp_mask;
    223228        byte _transparentColor;
     
    251256        void decodeStrip3DO(byte *dst, const byte *src, int height, byte transpCheck);
    252257        void decodeStripHE(byte *dst, const byte *src, int height, byte transpCheck);
    253258
    254         void draw8ColWithMasking(byte *dst, const byte *src, int height, byte *mask);
    255259        void draw8Col(byte *dst, const byte *src, int height);
    256         void clear8ColWithMasking(byte *dst, int height, byte *mask);
    257260        void clear8Col(byte *dst, int height);
    258261        void decompressMaskImgOr(byte *dst, const byte *src, int height);
    259262        void decompressMaskImg(byte *dst, const byte *src, int height);
     
    261264        void drawStripToScreen(VirtScreen *vs, int x, int w, int t, int b);
    262265        void updateDirtyScreen(VirtScreen *vs);
    263266       
    264         byte *getMaskBuffer(int x, int y, int z = 0);
     267        byte *getMaskBuffer(int x, int y, int z);
    265268
    266269public:
     270        void init();
     271
    267272        void drawBitmap(const byte *ptr, VirtScreen *vs, int x, int y, const int width, const int height,
    268273                        int stripnr, int numstrip, byte flag, StripTable *table = 0);
    269274        StripTable *generateStripTable(const byte *src, int width, int height, StripTable *table);
  • nut_renderer.cpp

    RCS file: /cvsroot/scummvm/scummvm/scumm/nut_renderer.cpp,v
    retrieving revision 1.49
    diff -u -d -r1.49 nut_renderer.cpp
     
    239239        return _chars[c].height;
    240240}
    241241
    242 void NutRenderer::drawShadowChar(int c, int x, int y, byte color, bool useMask, bool showShadow) {
    243         debug(8, "NutRenderer::drawShadowChar('%c', %d, %d, %d, %d, %d) called", c, x, y, (int)color, useMask, showShadow);
     242void NutRenderer::drawShadowChar(const Graphics::Surface &s, int c, int x, int y, byte color, bool showShadow) {
     243        debug(8, "NutRenderer::drawShadowChar('%c', %d, %d, %d, %d) called", c, x, y, (int)color, showShadow);
    244244        if (!_loaded) {
    245245                warning("NutRenderer::drawShadowChar() Font is not loaded");
    246246                return;
    247247        }
    248248
    249         VirtScreen *vs = &_vm->virtscr[kMainVirtScreen];
    250         byte *dst, *mask = NULL;
    251 
    252249        // HACK: we draw the character a total of 7 times: 6 times shifted
    253250        // and in black for the shadow, and once in the right color and position.
    254251        // This way we achieve the exact look as the original CMI had. However,
     
    268265                y += offsetY[i];
    269266                color = cTable[i];
    270267               
    271                 if (y >= vs->height || x >= vs->width) {
    272                         continue;
    273                 }
    274                
    275                 dst = vs->screenPtr + y * vs->width + x + vs->xstart;
    276                 if (useMask)
    277                         mask = _vm->getMaskBuffer(x, y, 0);
    278                
    279268                if (c >= 256 && _vm->_CJKMode)
    280                         draw2byte(dst, mask, c, x, y - _vm->_screenTop, color);
     269                        draw2byte(s, c, x, y, color);
    281270                else
    282                         drawChar(dst, mask, (byte)c, x, y - _vm->_screenTop, color);
     271                        drawChar(s, (byte)c, x, y, color);
    283272               
    284273                x -= offsetX[i];
    285274                y -= offsetY[i];
     
    318307        }
    319308}
    320309
    321 void NutRenderer::drawChar(byte *dst, byte *mask, byte c, int x, int y, byte color) {
    322         const int width = MIN(_chars[c].width, _vm->_screenWidth - x);
    323         const int height = MIN(_chars[c].height, _vm->_screenHeight - y);
     310void NutRenderer::drawChar(const Graphics::Surface &s, byte c, int x, int y, byte color) {
     311        byte *dst = (byte *)s.pixels + y * s.pitch + x;
     312        const int width = MIN(_chars[c].width, s.w - x);
     313        const int height = MIN(_chars[c].height, s.h - y);
    324314        const byte *src = _chars[c].src;
    325315        const int srcPitch = _chars[c].width;
    326316
    327         byte maskmask;
    328         int maskpos;
    329 
    330317        const int minX = x < 0 ? -x : 0;
    331318        const int minY = y < 0 ? -y : 0;
    332319
     
    336323
    337324        if (minY) {
    338325                src += minY * srcPitch;
    339                 dst += minY * _vm->_screenWidth;
    340                 if (mask)
    341                         mask += minY * _vm->gdi._numStrips;
     326                dst += minY * s.pitch;
    342327        }
    343328
    344329        for (int ty = minY; ty < height; ty++) {
    345                 maskmask = revBitMask[(x + minX) & 7];
    346                 maskpos = (x%8 + minX) / 8;
    347330                for (int tx = minX; tx < width; tx++) {
    348331                        if (src[tx] != 0) {
    349332                                dst[tx] = color;
    350                                 if (mask)
    351                                         mask[maskpos] |= maskmask;
    352                         }
    353                         maskmask >>= 1;
    354                         if (maskmask == 0) {
    355                                 maskmask = 0x80;
    356                                 maskpos++;
    357333                        }
    358334                }
    359335                src += srcPitch;
    360                 dst += _vm->_screenWidth;
    361                 if (mask)
    362                         mask += _vm->gdi._numStrips;
     336                dst += s.pitch;
    363337        }
    364338}
    365339
    366 void NutRenderer::draw2byte(byte *dst, byte *mask, int c, int x, int y, byte color) {
     340void NutRenderer::draw2byte(const Graphics::Surface &s, int c, int x, int y, byte color) {
    367341        if (!_loaded) {
    368342                debug(2, "NutRenderer::draw2byte() Font is not loaded");
    369343                return;
    370344        }
    371345
     346        byte *dst = (byte *)s.pixels + y * s.pitch + x;
    372347        const int width = _vm->_2byteWidth;
    373         const int height = MIN(_vm->_2byteHeight, _vm->_screenHeight - y);
     348        const int height = MIN(_vm->_2byteHeight, s.h - y);
    374349        byte *src = _vm->get2byteCharPtr(c);
    375350        byte bits = 0;
    376351
    377         byte maskmask;
    378         int maskpos;
    379 
    380352        if (height <= 0 || width <= 0) {
    381353                return;
    382354        }
    383355
    384356        for (int ty = 0; ty < height; ty++) {
    385                 maskmask = revBitMask[x & 7];
    386                 maskpos = 0;
    387357                for (int tx = 0; tx < width; tx++) {
    388358                        if ((tx & 7) == 0)
    389359                                bits = *src++;
    390                         if (x + tx < 0 || x + tx >= _vm->_screenWidth || y + ty < 0)
     360                        if (x + tx < 0 || x + tx >= s.w || y + ty < 0)
    391361                                continue;
    392362                        if (bits & revBitMask[tx & 7]) {
    393363                                dst[tx] = color;
    394                                 if (mask) {
    395                                         mask[maskpos] |= maskmask;
    396                                 }
    397                         }
    398 
    399                         maskmask >>= 1;
    400                         if (maskmask == 0) {
    401                                 maskmask = 0x80;
    402                                 maskpos++;
    403364                        }
    404365                }
    405                 dst += _vm->_screenWidth;
    406                 if (mask)
    407                         mask += _vm->gdi._numStrips;
     366                dst += s.pitch;
    408367        }
    409368}
    410369
  • nut_renderer.h

    RCS file: /cvsroot/scummvm/scummvm/scumm/nut_renderer.h,v
    retrieving revision 1.19
    diff -u -d -r1.19 nut_renderer.h
     
    2222#define NUT_RENDERER_H
    2323
    2424#include "common/file.h"
     25#include "graphics/surface.h"
    2526
    2627namespace Scumm {
    2728
     
    4344
    4445        int32 decodeCodec44(byte *dst, const byte *src, uint32 length);
    4546
    46         void drawChar(byte *dst, byte *mask, byte c, int x, int y, byte color);
    47         void draw2byte(byte *dst, byte *mask, int c, int x, int y, byte color);
     47        void drawChar(const Graphics::Surface &s, byte c, int x, int y, byte color);
     48        void draw2byte(const Graphics::Surface &s, int c, int x, int y, byte color);
    4849
    4950public:
    5051        NutRenderer(ScummEngine *vm);
     
    5455        bool loadFont(const char *filename);
    5556
    5657        void drawFrame(byte *dst, int c, int x, int y);
    57         void drawShadowChar(int c, int x, int y, byte color, bool useMask, bool showShadow);
     58        void drawShadowChar(const Graphics::Surface &s, int c, int x, int y, byte color, bool showShadow);
    5859
    5960        int getCharWidth(byte c);
    6061        int getCharHeight(byte c);