Ticket #8109: dig-corruption2.diff

File dig-corruption2.diff, 9.4 KB (added by eriktorbjorn, 21 years ago)

Patch against an October 28 CVS snapshot

  • scummvm/scumm/akos.h

    diff -ur ScummVM-cvs20021028/scummvm/scumm/akos.h ScummVM-cvs20021028+hack/scummvm/scumm/akos.h
    old new  
    127127        AkosRenderer(Scumm *scumm) {
    128128                memset(this, 0, sizeof(AkosRenderer));
    129129                _vm = scumm;
    130                 _numStrips = _vm->gdi._numStrips;
     130                _numStrips = _vm->_scrWidth / 8;
    131131        }
    132132        bool drawCostume();
    133133        void setPalette(byte *palette);
  • scummvm/scumm/costume.h

    diff -ur ScummVM-cvs20021028/scummvm/scumm/costume.h ScummVM-cvs20021028+hack/scummvm/scumm/costume.h
    old new  
    108108        void setCostume(int costume);
    109109
    110110public:
    111         CostumeRenderer(Scumm *vm) : _vm(vm), _numStrips(vm->gdi._numStrips), _loaded(vm) {}
     111        CostumeRenderer(Scumm *vm) : _vm(vm), _numStrips(vm->_scrWidth / 8), _loaded(vm) {}
    112112};
    113113
    114114#endif
  • scummvm/scumm/gfx.cpp

    diff -ur ScummVM-cvs20021028/scummvm/scumm/gfx.cpp ScummVM-cvs20021028+hack/scummvm/scumm/gfx.cpp
    old new  
    378378{
    379379        byte *ptr;
    380380        int size, itemsize, i;
     381        int mask_pitch = _scrWidth / 8;
    381382        byte *room;
    382383
    383384        if (_features & GF_AFTER_V7) {
     
    422423        assert(gdi._numZBuffer >= 1 && gdi._numZBuffer <= 5);
    423424
    424425        if (_features & GF_AFTER_V7)
    425                 itemsize = (virtscr[0].height + 4) * gdi._numStrips;
     426                itemsize = (virtscr[0].height + 4) * mask_pitch;
    426427        else
    427                 itemsize = (_scrHeight + 4) * gdi._numStrips;
    428 
     428                itemsize = (_scrHeight + 4) * mask_pitch;
    429429
    430430        size = itemsize * gdi._numZBuffer;
     431        debug(1, "Allocating %dx%d strips for mask buffer (%d bytes)", gdi._numZBuffer, _scrWidth / 8, size);
     432
    431433        createResource(rtBuffer, 9, size);
    432434
    433435        for (i = 0; i < 4; i++)
     
    840842        int sx;
    841843        bool lightsOn;
    842844
     845        int mask_pitch = _vm->_scrWidth / 8;
     846
    843847        // Check whether lights are turned on or not
    844848        lightsOn = (_vm->_features & GF_AFTER_V6) || (vs->number != 0) || (_vm->_vars[_vm->VAR_CURRENT_LIGHTS] & LIGHTMODE_screen);
    845849
     
    920924                else
    921925                        _bgbak_ptr = _backbuff_ptr;
    922926
    923                 _mask_ptr = _vm->getResourceAddress(rtBuffer, 9) + (y * _numStrips + x);
     927                _mask_ptr = _vm->getResourceAddress(rtBuffer, 9) + (y * mask_pitch + x);
    924928
    925929                where_draw_ptr = _bgbak_ptr;
    926930                decompressBitmap();
     
    962966                if (flag & dbDrawMaskOnAll) {
    963967                        _z_plane_ptr = zplane_list[1] + READ_LE_UINT16(zplane_list[1] + stripnr * 2 + 8);
    964968                        for (i = 0; i < numzbuf; i++) {
    965                                 _mask_ptr_dest = _vm->getResourceAddress(rtBuffer, 9) + y * _numStrips + x + _imgBufOffs[i];
     969                                _mask_ptr_dest = _vm->getResourceAddress(rtBuffer, 9) + y * mask_pitch + x + _imgBufOffs[i];
    966970                                if (_useOrDecompress && flag & dbAllowMaskOr)
    967971                                        decompressMaskImgOr();
    968972                                else
     
    983987                                } else
    984988                                        offs = READ_LE_UINT16(zplane_list[i] + stripnr * 2 + 8);
    985989
    986                                 _mask_ptr_dest = _vm->getResourceAddress(rtBuffer, 9) + y * _numStrips + x + _imgBufOffs[i];
     990                                _mask_ptr_dest = _vm->getResourceAddress(rtBuffer, 9) + y * mask_pitch + x + _imgBufOffs[i];
    987991
    988992                                if (offs) {
    989993                                        _z_plane_ptr = zplane_list[i] + offs;
     
    995999                                } else {
    9961000                                        if (!(_useOrDecompress && flag & dbAllowMaskOr))
    9971001                                                for (int height = 0; height < _numLinesToProcess; height++)
    998                                                         _mask_ptr_dest[height * _numStrips] = 0;
     1002                                                        _mask_ptr_dest[height * mask_pitch] = 0;
    9991003                                        /* needs better abstraction, FIXME */
    10001004                                }
    10011005                        }
     
    11481152void Gdi::draw8ColWithMasking()
    11491153{
    11501154        int height = _numLinesToProcess;
     1155        int mask_pitch = _vm->_scrWidth / 8;
    11511156        byte *mask = _mask_ptr;
    11521157        byte *dst = _backbuff_ptr;
    11531158        byte *src = _bgbak_ptr;
     
    11781183                }
    11791184                src += _vm->_realWidth;
    11801185                dst += _vm->_realWidth;
    1181                 mask += _numStrips;
     1186                mask += mask_pitch;
    11821187        } while (--height);
    11831188}
    11841189
    11851190void Gdi::clear8ColWithMasking()
    11861191{
    11871192        int height = _numLinesToProcess;
     1193        int mask_pitch = _vm->_scrWidth / 8;
    11881194        byte *mask = _mask_ptr;
    11891195        byte *dst = _backbuff_ptr;
    11901196        byte maskbits;
     
    12131219                        ((uint32 *)dst)[1] = 0;
    12141220                }
    12151221                dst += _vm->_realWidth;
    1216                 mask += _numStrips;
     1222                mask += mask_pitch;
    12171223        } while (--height);
    12181224}
    12191225
     
    12341240        byte *src = _z_plane_ptr;
    12351241        byte *dst = _mask_ptr_dest;
    12361242        int height = _numLinesToProcess;
     1243        int mask_pitch = _vm->_scrWidth / 8;
    12371244        byte b, c;
    12381245       
    1239         if ((_vm->_gameId == GID_DIG) && (_vm->_currentRoom == 23))
    1240                 height--;
    1241                                 // FIXME: This seems to fix The Dig nexus wrapping corrupting memory..
    1242                                 //        and doesn't break any other games.. but is it correct? If so,
    1243                                 //        do we need to mirror this change anywhere else?
    12441246        while (1) {
    12451247                b = *src++;
    12461248
     
    12501252
    12511253                        do {
    12521254                                *dst = c;
    1253                                 dst += _numStrips;
     1255                                dst += mask_pitch;
    12541256                                if (!--height)
    12551257                                        return;
    12561258                        } while (--b);
    12571259                } else {
    12581260                        do {
    12591261                                *dst = *src++;
    1260                                 dst += _numStrips;
     1262                                dst += mask_pitch;
    12611263                                if (!--height)
    12621264                                        return;
    12631265                        } while (--b);
     
    12701272        byte *src = _z_plane_ptr;
    12711273        byte *dst = _mask_ptr_dest;
    12721274        int height = _numLinesToProcess;
     1275        int mask_pitch = _vm->_scrWidth / 8;
    12731276        byte b, c;
    12741277
    12751278        while (1) {
     
    12801283
    12811284                        do {
    12821285                                *dst |= c;
    1283                                 dst += _numStrips;
     1286                                dst += mask_pitch;
    12841287                                if (!--height)
    12851288                                        return;
    12861289                        } while (--b);
    12871290                } else {
    12881291                        do {
    12891292                                *dst |= *src++;
    1290                                 dst += _numStrips;
     1293                                dst += mask_pitch;
    12911294                                if (!--height)
    12921295                                        return;
    12931296                        } while (--b);
     
    17771780{
    17781781        VirtScreen *vs;
    17791782        int topline, height, width, widthmod;
     1783        int mask_pitch = _scrWidth / 8;
    17801784        byte *backbuff, *bgbak, *mask;
    17811785
    17821786        if (left == right || top == bottom)
     
    18121816
    18131817        backbuff = vs->screenPtr + height;
    18141818        bgbak = getResourceAddress(rtBuffer, vs->number + 5) + height;
    1815         mask = getResourceAddress(rtBuffer, 9) + top * gdi._numStrips + (left >> 3) + _screenStartStrip;
     1819        mask = getResourceAddress(rtBuffer, 9) + top * mask_pitch + (left >> 3) + _screenStartStrip;
    18161820        if (vs->number == 0) {
    18171821                // FIXME: hardcoded value
    18181822                mask += vs->topline * 216;
     
    18271831                if (vs->number == 0 && charset._hasMask && height) {
    18281832                        do {
    18291833                                memset(mask, 0, widthmod);
    1830                                 mask += gdi._numStrips;
     1834                                mask += mask_pitch;
    18311835                        } while (--height);
    18321836                }
    18331837        } else {
     
    26982702void Gdi::resetBackground(int top, int bottom, int strip)
    26992703{
    27002704        VirtScreen *vs = &_vm->virtscr[0];
     2705        int mask_pitch = _vm->_scrWidth / 8;
    27012706        int offs;
    27022707
    27032708        if (top < vs->tdirty[strip])
     
    27072712                vs->bdirty[strip] = bottom;
    27082713
    27092714        offs = (top * _numStrips + _vm->_screenStartStrip + strip);
    2710         _mask_ptr = _vm->getResourceAddress(rtBuffer, 9) + offs;
     2715        _mask_ptr = _vm->getResourceAddress(rtBuffer, 9) + top * mask_pitch + _vm->_screenStartStrip + strip;
    27112716        _bgbak_ptr = _vm->getResourceAddress(rtBuffer, 5) + (offs << 3);
    27122717        _backbuff_ptr = vs->screenPtr + (offs << 3);
    27132718
     
    27402745
    27412746byte Scumm::isMaskActiveAt(int l, int t, int r, int b, byte *mem)
    27422747{
     2748        int mask_pitch = _scrWidth / 8;
    27432749        int w, h, i;
    27442750
    27452751        l >>= 3;
     
    27492755                t = 0;
    27502756
    27512757        r >>= 3;
    2752         if (r > gdi._numStrips - 1)
    2753                 r = gdi._numStrips - 1;
     2758        if (r > mask_pitch - 1)
     2759                r = mask_pitch - 1;
    27542760
    2755         mem += l + t * gdi._numStrips;
     2761        mem += l + t * mask_pitch;
    27562762
    27572763        w = r - l;
    27582764        h = b - t + 1;
     
    27622768                        if (mem[i]) {
    27632769                                return true;
    27642770                        }
    2765                 mem += gdi._numStrips;
     2771                mem += mask_pitch;
    27662772        } while (--h);
    27672773
    27682774        return false;
     
    31753181
    31763182void Scumm::drawBomp(BompDrawData *bd, int param1, byte *dataPtr, int param2, int param3)
    31773183{
     3184        int mask_pitch = _scrWidth / 8;
    31783185        byte *scale_rows = NULL;
    31793186        byte *scale_cols = NULL;
    31803187        byte *dest = bd->out + bd->y * bd->outwidth, *src;
     
    32613268                                for (i = 0; i < num; i++) {
    32623269                                        if (bd->scale_x == 255 || scale_cols[src_x]) {
    32633270                                                if (dst_x >= 0 && dst_x < bd->outwidth) {
    3264                                                         if (!(*(mask + dst_y * gdi._numStrips + (dst_x >> 3)) & revBitMask[dst_x & 7]))
     3271                                                        if (!(*(mask + dst_y * mask_pitch + (dst_x >> 3)) & revBitMask[dst_x & 7]))
    32653272                                                       
    32663273                                                                *d = blend(_currentPalette, color, *d);
    32673274                                                }
     
    32743281                                for (i = 0; i < num; i++) {
    32753282                                        if (bd->scale_x == 255 || scale_cols[src_x]) {
    32763283                                                if (dst_x >= 0 && dst_x < bd->outwidth)
    3277                                                         if (!(*(mask + dst_y * gdi._numStrips + (dst_x >> 3)) & revBitMask[dst_x & 7]))
     3284                                                        if (!(*(mask + dst_y * mask_pitch + (dst_x >> 3)) & revBitMask[dst_x & 7]))
    32783285                                                                *d = blend(_currentPalette, src[i], *d);
    32793286                                                d++;
    32803287                                                dst_x++;
  • scummvm/scumm/string.cpp

    diff -ur ScummVM-cvs20021028/scummvm/scumm/string.cpp ScummVM-cvs20021028+hack/scummvm/scumm/string.cpp
    old new  
    941941
    942942void CharsetRenderer::printChar(int chr)
    943943{
     944        int mask_pitch = _vm->_scrWidth / 8;
    944945        int d, right;
    945946        VirtScreen *vs;
    946947
     
    10401041        }
    10411042
    10421043        _mask_ptr = _vm->getResourceAddress(rtBuffer, 9)
    1043                 + _drawTop * _vm->gdi._numStrips + _left / 8 + _vm->_screenStartStrip;
     1044                + _drawTop * mask_pitch + _left / 8 + _vm->_screenStartStrip;
    10441045
    10451046        _virtScreenHeight = vs->height;
    10461047        _charPtr += 4;
     
    10621063
    10631064void CharsetRenderer::drawBits()
    10641065{
     1066        int mask_pitch = _vm->_scrWidth / 8;
    10651067        bool usemask;
    10661068        byte *dst, *mask, maskmask;
    10671069        int y, x;
     
    11021104                        }
    11031105                }
    11041106                dst = (_dest_ptr += _vm->_realWidth);
    1105                 mask += 40;
     1107                mask += mask_pitch;
    11061108                y++;
    11071109        }
    11081110}