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 | } |
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 | } |
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 | } |