Ticket #8079: akos-codec5.diff

File akos-codec5.diff, 4.3 KB (added by eriktorbjorn, 22 years ago)

Patch against an October 3 CVS snapshot

  • scummvm/scumm/akos.cpp

    diff -ur ScummVM-cvs20021003/scummvm/scumm/akos.cpp ScummVM-cvs20021003+hack/scummvm/scumm/akos.cpp
    old new  
    860860void AkosRenderer::codec5()
    861861{
    862862        VirtScreen *vs;
    863         BompDrawData bdd;
    864863
    865         int moveX;
    866         int moveY;
    867         int left;
    868         int var_20;
    869         int max_width;
    870 
    871         int right;
    872         int top;
    873         int bottom;
     864        int left, right, top, bottom;
    874865
     866        byte *src, *dest;
     867        int src_x, src_y;
     868        uint dst_x, dst_y;
     869
     870        bool masking;
     871        byte maskbit;
     872        const byte *mask = NULL;
     873
     874        // I don't know if this is complete. It used to simply call drawBomp()
     875        // to draw an unscaled image, but I don't know if that was because it
     876        // will never have to scale, or if it's because until quite recently
     877        // drawBomp() didn't know how to scale images.
     878        //
     879        // What I do know is that drawBomp() doesn't care about masking and
     880        // shadows, and these are both needed for Full Throttle.
     881       
    875882        vs = &_vm->virtscr[0];
    876         //setBlastObjectMode(shadow_mode); // not implemented yet
    877         moveX = move_x_cur;
    878         moveY = move_y_cur;
    879883
    880884        if (!mirror) {
    881                 left = (x - moveX - width) + 1;
     885                left = (x - move_x_cur - width) + 1;
    882886        } else {
    883                 left = x + moveX - 1;
     887                left = x + move_x_cur - 1;
    884888        }
    885889
    886         var_20 = 0;
    887         max_width = outwidth;
    888 
    889         right = left + width - 1;
    890         top = y + moveY;
    891         bottom = top + height;
     890        right = left + width;
     891        top = y + move_y_cur;
     892        bottom = top + height + 1;
    892893
    893894        if (left < 0)
    894895                left = 0;
    895         if (left > max_width)
    896                 left -= left - max_width;
     896        if (left > (int) outwidth)
     897                left -= left - outwidth;
    897898
    898         // Yazoo: this is not correct, but fix a lots of bugs for the momment
     899        if (top < draw_top)
     900                draw_top = top;
     901        if (bottom > draw_bottom)
     902                draw_bottom = bottom;
     903
     904        _vm->updateDirtyRect(0, left, right, top, bottom, 1 << dirty_id);
     905
     906        masking = false;
     907        if (clipping) {
     908                masking = _vm->isMaskActiveAt(left, top, right, bottom,
     909                        _vm->getResourceAddress(rtBuffer, 9) +
     910                        _vm->gdi._imgBufOffs[clipping] +
     911                        _vm->_screenStartStrip) != 0;
     912        }
    899913
    900         draw_top = 0;
    901         draw_bottom = vs->height;
     914        v1.mask_ptr = NULL;
    902915
    903         _vm->updateDirtyRect(0, left, right + 1, top, bottom + 1, 1 << dirty_id);
    904 
    905         bdd.dataptr = srcptr;
    906         bdd.out = outptr;
    907         bdd.outheight = outheight;
    908         bdd.outwidth = outwidth;
    909         bdd.scale_x = 0xFF;
    910         bdd.scale_y = 0xFF;
    911         bdd.srcheight = height;
    912         bdd.srcwidth = width;
    913         bdd.x = left + 1;
    914         bdd.y = top;
     916        if (masking || charsetmask || shadow_mode) {
     917                v1.mask_ptr = _vm->getResourceAddress(rtBuffer, 9) +
     918                        top * 40 + _vm->_screenStartStrip;
     919                v1.imgbufoffs = _vm->gdi._imgBufOffs[clipping];
     920                if (!charsetmask && masking) {
     921                        v1.mask_ptr += v1.imgbufoffs;
     922                        v1.imgbufoffs = 0;
     923                }
     924        }
    915925
    916         _vm->drawBomp(&bdd, 0, bdd.dataptr, 0, 0);
     926        src = srcptr;
     927        dest = outptr + top * outwidth + left + 1;
     928
     929        for (src_y = 0, dst_y = top; src_y < height; src_y++) {
     930                byte code, color;
     931                uint len, num, i;
     932                byte *d = dest;
     933
     934                if (dst_y < 0 || dst_y >= outheight) {
     935                        src += READ_LE_UINT16(src) + 2;
     936                        mask += 40;
     937                        continue;
     938                }
     939
     940                len = width;
     941                src_x = 0;
     942                dst_x = left + 1;
     943                src += 2;
     944
     945                while (src_x <width) {
     946                        code = *src++;
     947                        num = (code >> 1) + 1;
     948                        if (num > len)
     949                                num = len;
     950                        len -= num;
     951                        if (code & 1) {
     952                                color = *src++;
     953                                for (i = 0; i < num; i++) {
     954                                        if (dst_x >= 0 && dst_x < outwidth) {
     955                                                if (color != 255) {
     956                                                        if (v1.mask_ptr)
     957                                                                mask = v1.mask_ptr + (dst_x >> 3);
     958                                                        maskbit = revBitMask[dst_x & 7];
     959                                                        if (shadow_mode && color == 13)
     960                                                                color = shadow_table[*d];
     961                                                        if (!mask || !((mask[0] | mask[v1.imgbufoffs]) & maskbit))
     962                                                                *d = color;
     963                                                }
     964                                        }
     965                                        d++;
     966                                        dst_x++;
     967                                        src_x++;
     968                                }
     969                        } else {
     970                                for (i = 0; i < num; i++) {
     971                                        color = src[i];
     972                                        if (dst_x >= 0 && dst_x < outwidth) {
     973                                                if (color != 255) {
     974                                                        if (v1.mask_ptr)
     975                                                                mask = v1.mask_ptr + (dst_x >> 3);
     976                                                        maskbit = revBitMask[dst_x & 7];
     977                                                        if (shadow_mode && color == 13)
     978                                                                color = shadow_table[*d];
     979                                                        if (!mask || !((mask[0] | mask[v1.imgbufoffs]) & maskbit))
     980                                                                *d = color;
     981                                                }
     982                                        }
     983                                        d++;
     984                                        dst_x++;
     985                                        src_x++;
     986                                }
     987                                src += num;
     988                        }
     989                }
     990                dest += outwidth;
     991                dst_y++;
     992        }
    917993}
    918994
    919995void AkosRenderer::codec16()