Ticket #8109: dig-corruption3.diff

File dig-corruption3.diff, 9.9 KB (added by eriktorbjorn, 21 years ago)

Patch against an October 31 CVS snapshot

  • scummvm/scumm/akos.h

    diff -ur ScummVM-cvs20021031/scummvm/scumm/akos.h ScummVM-cvs20021031+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-cvs20021031/scummvm/scumm/costume.h ScummVM-cvs20021031+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-cvs20021031/scummvm/scumm/gfx.cpp ScummVM-cvs20021031+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);
     
    17761779void Scumm::restoreBG(int left, int top, int right, int bottom)
    17771780{
    17781781        VirtScreen *vs;
    1779         int topline, height, width, widthmod;
    1780         byte *backbuff, *bgbak, *mask;
     1782        int topline, height, width;
     1783        byte *backbuff, *bgbak;
    17811784
    17821785        if (left == right || top == bottom)
    17831786                return;
     
    18121815
    18131816        backbuff = vs->screenPtr + height;
    18141817        bgbak = getResourceAddress(rtBuffer, vs->number + 5) + height;
    1815         mask = getResourceAddress(rtBuffer, 9) + top * gdi._numStrips + (left >> 3) + _screenStartStrip;
    1816         if (vs->number == 0) {
    1817                 // FIXME: hardcoded value
    1818                 mask += vs->topline * 216;
    1819         }
    18201818
    18211819        height = bottom - top;
    18221820        width = right - left;
    1823         widthmod = (width >> 2) + 2;
    18241821
    18251822        if (vs->alloctwobuffers && _currentRoom != 0 /*&& _vars[VAR_V5_DRAWFLAGS]&2 */ ) {
    18261823                blit(backbuff, bgbak, width, height);
    18271824                if (vs->number == 0 && charset._hasMask && height) {
     1825                        byte *mask;
     1826                        int mask_pitch = _scrWidth / 8;
     1827                        int mask_width = (width >> 3);
     1828
     1829                        if (width & 0x07)
     1830                                mask_width++;
     1831
     1832                        mask = getResourceAddress(rtBuffer, 9) + top * mask_pitch + (left >> 3) + _screenStartStrip;
     1833                        if (vs->number == 0)
     1834                                mask += vs->topline * mask_pitch;
     1835
    18281836                        do {
    1829                                 memset(mask, 0, widthmod);
    1830                                 mask += gdi._numStrips;
     1837                                memset(mask, 0, mask_width);
     1838                                mask += mask_pitch;
    18311839                        } while (--height);
    18321840                }
    18331841        } else {
     
    26982706void Gdi::resetBackground(int top, int bottom, int strip)
    26992707{
    27002708        VirtScreen *vs = &_vm->virtscr[0];
     2709        int mask_pitch = _vm->_scrWidth / 8;
    27012710        int offs;
    27022711
    27032712        if (top < vs->tdirty[strip])
     
    27072716                vs->bdirty[strip] = bottom;
    27082717
    27092718        offs = (top * _numStrips + _vm->_screenStartStrip + strip);
    2710         _mask_ptr = _vm->getResourceAddress(rtBuffer, 9) + offs;
     2719        _mask_ptr = _vm->getResourceAddress(rtBuffer, 9) + top * mask_pitch + _vm->_screenStartStrip + strip;
    27112720        _bgbak_ptr = _vm->getResourceAddress(rtBuffer, 5) + (offs << 3);
    27122721        _backbuff_ptr = vs->screenPtr + (offs << 3);
    27132722
     
    27402749
    27412750byte Scumm::isMaskActiveAt(int l, int t, int r, int b, byte *mem)
    27422751{
     2752        int mask_pitch = _scrWidth / 8;
    27432753        int w, h, i;
    27442754
    27452755        l >>= 3;
     
    27492759                t = 0;
    27502760
    27512761        r >>= 3;
    2752         if (r > gdi._numStrips - 1)
    2753                 r = gdi._numStrips - 1;
     2762        if (r > mask_pitch - 1)
     2763                r = mask_pitch - 1;
    27542764
    2755         mem += l + t * gdi._numStrips;
     2765        mem += l + t * mask_pitch;
    27562766
    27572767        w = r - l;
    27582768        h = b - t + 1;
     
    27622772                        if (mem[i]) {
    27632773                                return true;
    27642774                        }
    2765                 mem += gdi._numStrips;
     2775                mem += mask_pitch;
    27662776        } while (--h);
    27672777
    27682778        return false;
     
    31753185
    31763186void Scumm::drawBomp(BompDrawData *bd, int param1, byte *dataPtr, int param2, int param3)
    31773187{
     3188        int mask_pitch = _scrWidth / 8;
    31783189        byte *scale_rows = NULL;
    31793190        byte *scale_cols = NULL;
    31803191        byte *dest = bd->out + bd->y * bd->outwidth, *src;
     
    32613272                                for (i = 0; i < num; i++) {
    32623273                                        if (bd->scale_x == 255 || scale_cols[src_x]) {
    32633274                                                if (dst_x >= 0 && dst_x < bd->outwidth) {
    3264                                                         if (!(*(mask + dst_y * gdi._numStrips + (dst_x >> 3)) & revBitMask[dst_x & 7]))
     3275                                                        if (!(*(mask + dst_y * mask_pitch + (dst_x >> 3)) & revBitMask[dst_x & 7]))
    32653276                                                       
    32663277                                                                *d = blend(_currentPalette, color, *d);
    32673278                                                }
     
    32743285                                for (i = 0; i < num; i++) {
    32753286                                        if (bd->scale_x == 255 || scale_cols[src_x]) {
    32763287                                                if (dst_x >= 0 && dst_x < bd->outwidth)
    3277                                                         if (!(*(mask + dst_y * gdi._numStrips + (dst_x >> 3)) & revBitMask[dst_x & 7]))
     3288                                                        if (!(*(mask + dst_y * mask_pitch + (dst_x >> 3)) & revBitMask[dst_x & 7]))
    32783289                                                                *d = blend(_currentPalette, src[i], *d);
    32793290                                                d++;
    32803291                                                dst_x++;
  • scummvm/scumm/string.cpp

    diff -ur ScummVM-cvs20021031/scummvm/scumm/string.cpp ScummVM-cvs20021031+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}