diff -ur ScummVM-cvs20021031/scummvm/scumm/akos.h ScummVM-cvs20021031+hack/scummvm/scumm/akos.h
old
|
new
|
|
127 | 127 | AkosRenderer(Scumm *scumm) { |
128 | 128 | memset(this, 0, sizeof(AkosRenderer)); |
129 | 129 | _vm = scumm; |
130 | | _numStrips = _vm->gdi._numStrips; |
| 130 | _numStrips = _vm->_scrWidth / 8; |
131 | 131 | } |
132 | 132 | bool drawCostume(); |
133 | 133 | void setPalette(byte *palette); |
diff -ur ScummVM-cvs20021031/scummvm/scumm/costume.h ScummVM-cvs20021031+hack/scummvm/scumm/costume.h
old
|
new
|
|
108 | 108 | void setCostume(int costume); |
109 | 109 | |
110 | 110 | public: |
111 | | CostumeRenderer(Scumm *vm) : _vm(vm), _numStrips(vm->gdi._numStrips), _loaded(vm) {} |
| 111 | CostumeRenderer(Scumm *vm) : _vm(vm), _numStrips(vm->_scrWidth / 8), _loaded(vm) {} |
112 | 112 | }; |
113 | 113 | |
114 | 114 | #endif |
diff -ur ScummVM-cvs20021031/scummvm/scumm/gfx.cpp ScummVM-cvs20021031+hack/scummvm/scumm/gfx.cpp
old
|
new
|
|
378 | 378 | { |
379 | 379 | byte *ptr; |
380 | 380 | int size, itemsize, i; |
| 381 | int mask_pitch = _scrWidth / 8; |
381 | 382 | byte *room; |
382 | 383 | |
383 | 384 | if (_features & GF_AFTER_V7) { |
… |
… |
|
422 | 423 | assert(gdi._numZBuffer >= 1 && gdi._numZBuffer <= 5); |
423 | 424 | |
424 | 425 | if (_features & GF_AFTER_V7) |
425 | | itemsize = (virtscr[0].height + 4) * gdi._numStrips; |
| 426 | itemsize = (virtscr[0].height + 4) * mask_pitch; |
426 | 427 | else |
427 | | itemsize = (_scrHeight + 4) * gdi._numStrips; |
428 | | |
| 428 | itemsize = (_scrHeight + 4) * mask_pitch; |
429 | 429 | |
430 | 430 | size = itemsize * gdi._numZBuffer; |
| 431 | debug(1, "Allocating %dx%d strips for mask buffer (%d bytes)", gdi._numZBuffer, _scrWidth / 8, size); |
| 432 | |
431 | 433 | createResource(rtBuffer, 9, size); |
432 | 434 | |
433 | 435 | for (i = 0; i < 4; i++) |
… |
… |
|
840 | 842 | int sx; |
841 | 843 | bool lightsOn; |
842 | 844 | |
| 845 | int mask_pitch = _vm->_scrWidth / 8; |
| 846 | |
843 | 847 | // Check whether lights are turned on or not |
844 | 848 | lightsOn = (_vm->_features & GF_AFTER_V6) || (vs->number != 0) || (_vm->_vars[_vm->VAR_CURRENT_LIGHTS] & LIGHTMODE_screen); |
845 | 849 | |
… |
… |
|
920 | 924 | else |
921 | 925 | _bgbak_ptr = _backbuff_ptr; |
922 | 926 | |
923 | | _mask_ptr = _vm->getResourceAddress(rtBuffer, 9) + (y * _numStrips + x); |
| 927 | _mask_ptr = _vm->getResourceAddress(rtBuffer, 9) + (y * mask_pitch + x); |
924 | 928 | |
925 | 929 | where_draw_ptr = _bgbak_ptr; |
926 | 930 | decompressBitmap(); |
… |
… |
|
962 | 966 | if (flag & dbDrawMaskOnAll) { |
963 | 967 | _z_plane_ptr = zplane_list[1] + READ_LE_UINT16(zplane_list[1] + stripnr * 2 + 8); |
964 | 968 | 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]; |
966 | 970 | if (_useOrDecompress && flag & dbAllowMaskOr) |
967 | 971 | decompressMaskImgOr(); |
968 | 972 | else |
… |
… |
|
983 | 987 | } else |
984 | 988 | offs = READ_LE_UINT16(zplane_list[i] + stripnr * 2 + 8); |
985 | 989 | |
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]; |
987 | 991 | |
988 | 992 | if (offs) { |
989 | 993 | _z_plane_ptr = zplane_list[i] + offs; |
… |
… |
|
995 | 999 | } else { |
996 | 1000 | if (!(_useOrDecompress && flag & dbAllowMaskOr)) |
997 | 1001 | for (int height = 0; height < _numLinesToProcess; height++) |
998 | | _mask_ptr_dest[height * _numStrips] = 0; |
| 1002 | _mask_ptr_dest[height * mask_pitch] = 0; |
999 | 1003 | /* needs better abstraction, FIXME */ |
1000 | 1004 | } |
1001 | 1005 | } |
… |
… |
|
1148 | 1152 | void Gdi::draw8ColWithMasking() |
1149 | 1153 | { |
1150 | 1154 | int height = _numLinesToProcess; |
| 1155 | int mask_pitch = _vm->_scrWidth / 8; |
1151 | 1156 | byte *mask = _mask_ptr; |
1152 | 1157 | byte *dst = _backbuff_ptr; |
1153 | 1158 | byte *src = _bgbak_ptr; |
… |
… |
|
1178 | 1183 | } |
1179 | 1184 | src += _vm->_realWidth; |
1180 | 1185 | dst += _vm->_realWidth; |
1181 | | mask += _numStrips; |
| 1186 | mask += mask_pitch; |
1182 | 1187 | } while (--height); |
1183 | 1188 | } |
1184 | 1189 | |
1185 | 1190 | void Gdi::clear8ColWithMasking() |
1186 | 1191 | { |
1187 | 1192 | int height = _numLinesToProcess; |
| 1193 | int mask_pitch = _vm->_scrWidth / 8; |
1188 | 1194 | byte *mask = _mask_ptr; |
1189 | 1195 | byte *dst = _backbuff_ptr; |
1190 | 1196 | byte maskbits; |
… |
… |
|
1213 | 1219 | ((uint32 *)dst)[1] = 0; |
1214 | 1220 | } |
1215 | 1221 | dst += _vm->_realWidth; |
1216 | | mask += _numStrips; |
| 1222 | mask += mask_pitch; |
1217 | 1223 | } while (--height); |
1218 | 1224 | } |
1219 | 1225 | |
… |
… |
|
1234 | 1240 | byte *src = _z_plane_ptr; |
1235 | 1241 | byte *dst = _mask_ptr_dest; |
1236 | 1242 | int height = _numLinesToProcess; |
| 1243 | int mask_pitch = _vm->_scrWidth / 8; |
1237 | 1244 | byte b, c; |
1238 | 1245 | |
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? |
1244 | 1246 | while (1) { |
1245 | 1247 | b = *src++; |
1246 | 1248 | |
… |
… |
|
1250 | 1252 | |
1251 | 1253 | do { |
1252 | 1254 | *dst = c; |
1253 | | dst += _numStrips; |
| 1255 | dst += mask_pitch; |
1254 | 1256 | if (!--height) |
1255 | 1257 | return; |
1256 | 1258 | } while (--b); |
1257 | 1259 | } else { |
1258 | 1260 | do { |
1259 | 1261 | *dst = *src++; |
1260 | | dst += _numStrips; |
| 1262 | dst += mask_pitch; |
1261 | 1263 | if (!--height) |
1262 | 1264 | return; |
1263 | 1265 | } while (--b); |
… |
… |
|
1270 | 1272 | byte *src = _z_plane_ptr; |
1271 | 1273 | byte *dst = _mask_ptr_dest; |
1272 | 1274 | int height = _numLinesToProcess; |
| 1275 | int mask_pitch = _vm->_scrWidth / 8; |
1273 | 1276 | byte b, c; |
1274 | 1277 | |
1275 | 1278 | while (1) { |
… |
… |
|
1280 | 1283 | |
1281 | 1284 | do { |
1282 | 1285 | *dst |= c; |
1283 | | dst += _numStrips; |
| 1286 | dst += mask_pitch; |
1284 | 1287 | if (!--height) |
1285 | 1288 | return; |
1286 | 1289 | } while (--b); |
1287 | 1290 | } else { |
1288 | 1291 | do { |
1289 | 1292 | *dst |= *src++; |
1290 | | dst += _numStrips; |
| 1293 | dst += mask_pitch; |
1291 | 1294 | if (!--height) |
1292 | 1295 | return; |
1293 | 1296 | } while (--b); |
… |
… |
|
1776 | 1779 | void Scumm::restoreBG(int left, int top, int right, int bottom) |
1777 | 1780 | { |
1778 | 1781 | VirtScreen *vs; |
1779 | | int topline, height, width, widthmod; |
1780 | | byte *backbuff, *bgbak, *mask; |
| 1782 | int topline, height, width; |
| 1783 | byte *backbuff, *bgbak; |
1781 | 1784 | |
1782 | 1785 | if (left == right || top == bottom) |
1783 | 1786 | return; |
… |
… |
|
1812 | 1815 | |
1813 | 1816 | backbuff = vs->screenPtr + height; |
1814 | 1817 | 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 | | } |
1820 | 1818 | |
1821 | 1819 | height = bottom - top; |
1822 | 1820 | width = right - left; |
1823 | | widthmod = (width >> 2) + 2; |
1824 | 1821 | |
1825 | 1822 | if (vs->alloctwobuffers && _currentRoom != 0 /*&& _vars[VAR_V5_DRAWFLAGS]&2 */ ) { |
1826 | 1823 | blit(backbuff, bgbak, width, height); |
1827 | 1824 | 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 | |
1828 | 1836 | do { |
1829 | | memset(mask, 0, widthmod); |
1830 | | mask += gdi._numStrips; |
| 1837 | memset(mask, 0, mask_width); |
| 1838 | mask += mask_pitch; |
1831 | 1839 | } while (--height); |
1832 | 1840 | } |
1833 | 1841 | } else { |
… |
… |
|
2698 | 2706 | void Gdi::resetBackground(int top, int bottom, int strip) |
2699 | 2707 | { |
2700 | 2708 | VirtScreen *vs = &_vm->virtscr[0]; |
| 2709 | int mask_pitch = _vm->_scrWidth / 8; |
2701 | 2710 | int offs; |
2702 | 2711 | |
2703 | 2712 | if (top < vs->tdirty[strip]) |
… |
… |
|
2707 | 2716 | vs->bdirty[strip] = bottom; |
2708 | 2717 | |
2709 | 2718 | 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; |
2711 | 2720 | _bgbak_ptr = _vm->getResourceAddress(rtBuffer, 5) + (offs << 3); |
2712 | 2721 | _backbuff_ptr = vs->screenPtr + (offs << 3); |
2713 | 2722 | |
… |
… |
|
2740 | 2749 | |
2741 | 2750 | byte Scumm::isMaskActiveAt(int l, int t, int r, int b, byte *mem) |
2742 | 2751 | { |
| 2752 | int mask_pitch = _scrWidth / 8; |
2743 | 2753 | int w, h, i; |
2744 | 2754 | |
2745 | 2755 | l >>= 3; |
… |
… |
|
2749 | 2759 | t = 0; |
2750 | 2760 | |
2751 | 2761 | r >>= 3; |
2752 | | if (r > gdi._numStrips - 1) |
2753 | | r = gdi._numStrips - 1; |
| 2762 | if (r > mask_pitch - 1) |
| 2763 | r = mask_pitch - 1; |
2754 | 2764 | |
2755 | | mem += l + t * gdi._numStrips; |
| 2765 | mem += l + t * mask_pitch; |
2756 | 2766 | |
2757 | 2767 | w = r - l; |
2758 | 2768 | h = b - t + 1; |
… |
… |
|
2762 | 2772 | if (mem[i]) { |
2763 | 2773 | return true; |
2764 | 2774 | } |
2765 | | mem += gdi._numStrips; |
| 2775 | mem += mask_pitch; |
2766 | 2776 | } while (--h); |
2767 | 2777 | |
2768 | 2778 | return false; |
… |
… |
|
3175 | 3185 | |
3176 | 3186 | void Scumm::drawBomp(BompDrawData *bd, int param1, byte *dataPtr, int param2, int param3) |
3177 | 3187 | { |
| 3188 | int mask_pitch = _scrWidth / 8; |
3178 | 3189 | byte *scale_rows = NULL; |
3179 | 3190 | byte *scale_cols = NULL; |
3180 | 3191 | byte *dest = bd->out + bd->y * bd->outwidth, *src; |
… |
… |
|
3261 | 3272 | for (i = 0; i < num; i++) { |
3262 | 3273 | if (bd->scale_x == 255 || scale_cols[src_x]) { |
3263 | 3274 | 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])) |
3265 | 3276 | |
3266 | 3277 | *d = blend(_currentPalette, color, *d); |
3267 | 3278 | } |
… |
… |
|
3274 | 3285 | for (i = 0; i < num; i++) { |
3275 | 3286 | if (bd->scale_x == 255 || scale_cols[src_x]) { |
3276 | 3287 | 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])) |
3278 | 3289 | *d = blend(_currentPalette, src[i], *d); |
3279 | 3290 | d++; |
3280 | 3291 | dst_x++; |
diff -ur ScummVM-cvs20021031/scummvm/scumm/string.cpp ScummVM-cvs20021031+hack/scummvm/scumm/string.cpp
old
|
new
|
|
941 | 941 | |
942 | 942 | void CharsetRenderer::printChar(int chr) |
943 | 943 | { |
| 944 | int mask_pitch = _vm->_scrWidth / 8; |
944 | 945 | int d, right; |
945 | 946 | VirtScreen *vs; |
946 | 947 | |
… |
… |
|
1040 | 1041 | } |
1041 | 1042 | |
1042 | 1043 | _mask_ptr = _vm->getResourceAddress(rtBuffer, 9) |
1043 | | + _drawTop * _vm->gdi._numStrips + _left / 8 + _vm->_screenStartStrip; |
| 1044 | + _drawTop * mask_pitch + _left / 8 + _vm->_screenStartStrip; |
1044 | 1045 | |
1045 | 1046 | _virtScreenHeight = vs->height; |
1046 | 1047 | _charPtr += 4; |
… |
… |
|
1062 | 1063 | |
1063 | 1064 | void CharsetRenderer::drawBits() |
1064 | 1065 | { |
| 1066 | int mask_pitch = _vm->_scrWidth / 8; |
1065 | 1067 | bool usemask; |
1066 | 1068 | byte *dst, *mask, maskmask; |
1067 | 1069 | int y, x; |
… |
… |
|
1102 | 1104 | } |
1103 | 1105 | } |
1104 | 1106 | dst = (_dest_ptr += _vm->_realWidth); |
1105 | | mask += 40; |
| 1107 | mask += mask_pitch; |
1106 | 1108 | y++; |
1107 | 1109 | } |
1108 | 1110 | } |