Ticket #8352: text-render.patch
File text-render.patch, 26.9 KB (added by , 20 years ago) |
---|
-
akos.cpp
RCS file: /cvsroot/scummvm/scummvm/scumm/akos.cpp,v retrieving revision 1.137 diff -u -d -r1.137 akos.cpp
385 385 return; 386 386 } 387 387 } else { 388 masked = (y < 0 || y >= _outheight) || (v1.mask_ptr && ( (mask[0] | mask[v1.imgbufoffs])& maskbit));388 masked = (y < 0 || y >= _outheight) || (v1.mask_ptr && (*mask & maskbit)); 389 389 390 390 if (color && !masked && !skip_column) { 391 391 pcolor = palette[color]; … … 781 781 782 782 v1.destptr = _outptr + v1.y * _outwidth + v1.x; 783 783 784 v1.mask_ptr = _vm->getMaskBuffer(0, v1.y, 0); 785 v1.imgbufoffs = _vm->gdi._imgBufOffs[_zbuf]; 784 v1.mask_ptr = _vm->getMaskBuffer(0, v1.y, _zbuf); 786 785 787 786 codec1_genericDecode(); 788 787 … … 847 846 } 848 847 bdd.y = _actorY + ymoveCur; 849 848 850 if (_zbuf != 0) { 851 bdd.maskPtr = _vm->getMaskBuffer(0, 0, _zbuf); 852 } 849 bdd.maskPtr = _vm->getMaskBuffer(0, 0, _zbuf); 853 850 _vm->drawBomp(bdd, !_mirror); 854 851 855 852 _vm->_bompActorPalettePtr = NULL; … … 930 927 int32 numskip_before, int32 numskip_after, byte transparency, int maskLeft, int maskTop, int zBuf) { 931 928 byte *tmp_buf = akos16.buffer; 932 929 int maskpitch; 933 byte *maskptr = 0, *charsetMask = 0;930 byte *maskptr; 934 931 const byte maskbit = revBitMask[maskLeft & 7]; 935 932 936 933 if (dir < 0) { … … 946 943 947 944 maskpitch = _numStrips; 948 945 949 charsetMask = _vm->getMaskBuffer(maskLeft, maskTop, 0); 950 if (zBuf != 0) 951 maskptr = _vm->getMaskBuffer(maskLeft, maskTop, zBuf); 946 maskptr = _vm->getMaskBuffer(maskLeft, maskTop, zBuf); 952 947 953 948 assert(t_height > 0); 954 949 assert(t_width > 0); 955 950 while (t_height--) { 956 951 akos16DecodeLine(tmp_buf, t_width, dir); 957 bompApplyMask(akos16.buffer, charsetMask, maskbit, t_width, transparency); 958 if (maskptr) { 959 bompApplyMask(akos16.buffer, maskptr, maskbit, t_width, transparency); 960 maskptr += maskpitch; 961 } 952 bompApplyMask(akos16.buffer, maskptr, maskbit, t_width, transparency); 962 953 bool HE7Check = (_vm->_heversion == 70); 963 954 bompApplyShadow(_shadow_mode, _shadow_table, akos16.buffer, dest, t_width, transparency, HE7Check); 964 955 … … 966 957 akos16SkipData(numskip_after); 967 958 } 968 959 dest += pitch; 969 charsetMask+= maskpitch;960 maskptr += maskpitch; 970 961 } 971 962 } 972 963 -
base-costume.h
RCS file: /cvsroot/scummvm/scummvm/scumm/base-costume.h,v retrieving revision 1.21 diff -u -d -r1.21 base-costume.h
97 97 int skip_width; 98 98 byte *destptr; 99 99 const byte *mask_ptr; 100 int imgbufoffs;101 100 } v1; 102 101 103 102 public: -
bomp.cpp
RCS file: /cvsroot/scummvm/scummvm/scumm/bomp.cpp,v retrieving revision 2.20 diff -u -d -r2.20 bomp.cpp
199 199 const byte *src; 200 200 byte *dst; 201 201 byte *mask = 0; 202 byte *charset_mask;203 202 Common::Rect clip; 204 203 byte *scalingYPtr = bd.scalingYPtr; 205 204 byte skip_y_bits = 0x80; … … 234 233 235 234 const byte maskbit = revBitMask[(bd.x + clip.left) & 7]; 236 235 237 // Always mask against the charset mask 238 charset_mask = getMaskBuffer(bd.x + clip.left, bd.y, 0); 239 240 // Also mask against any additionally imposed mask 236 // Mask against any additionally imposed mask 241 237 if (bd.maskPtr) { 242 238 mask = bd.maskPtr + (bd.y * gdi._numStrips) + ((bd.x + clip.left) / 8); 243 239 } … … 310 306 // Replace the parts of the line which are masked with the transparency color 311 307 if (bd.maskPtr) 312 308 bompApplyMask(line_ptr, mask, maskbit, width, 255); 313 bompApplyMask(line_ptr, charset_mask, maskbit, width, 255);314 309 315 310 // Apply custom color map, if available 316 311 if (_bompActorPalettePtr) … … 324 319 // Advance to the next line 325 320 pos_y++; 326 321 mask += gdi._numStrips; 327 charset_mask += gdi._numStrips;328 322 dst += bd.outwidth; 329 323 } 330 324 } -
charset.cpp
RCS file: /cvsroot/scummvm/scummvm/scumm/charset.cpp,v retrieving revision 2.93 diff -u -d -r2.93 charset.cpp
944 944 void CharsetRendererV3::printChar(int chr) { 945 945 // Indy3 / Zak256 / Loom 946 946 VirtScreen *vs; 947 byte *char_ptr, *dest_ptr , *mask_ptr;947 byte *char_ptr, *dest_ptr; 948 948 int width, height; 949 949 int drawTop; 950 950 … … 972 972 973 973 drawTop = _top - vs->topline; 974 974 char_ptr = _fontPtr + chr * 8; 975 dest_ptr = vs->screenPtr + vs->xstart + drawTop * vs->width + _left;976 mask_ptr = _vm->getMaskBuffer(_left, drawTop, 0);977 975 978 976 _vm->markRectAsDirty(vs->number, _left, _left + width, drawTop, drawTop + height); 979 977 … … 981 979 _hasMask = true; 982 980 _textScreenID = vs->number; 983 981 } 982 if (_ignoreCharsetMask || !vs->hasTwoBuffers) { 983 dest_ptr = vs->screenPtr + vs->xstart + drawTop * vs->width + _left; 984 } else { 985 dest_ptr = (byte *)_vm->gdi._textSurface.pixels + drawTop * _vm->gdi._textSurface.pitch + _left; 986 } 984 987 985 drawBits1(vs, dest_ptr, char_ptr, mask_ptr,drawTop, 8, 8);988 drawBits1(vs, dest_ptr, char_ptr, drawTop, 8, 8); 986 989 987 990 if (_str.left > _left) 988 991 _str.left = _left; … … 1085 1088 1086 1089 _vm->markRectAsDirty(vs->number, _left, _left + width, drawTop, drawTop + height + offsY); 1087 1090 1091 byte *dst; 1092 byte *back; 1093 1088 1094 if (!_ignoreCharsetMask) { 1089 1095 _hasMask = true; 1090 1096 _textScreenID = vs->number; 1091 1097 } 1098 if (_ignoreCharsetMask || !vs->hasTwoBuffers) { 1099 dst = vs->screenPtr + vs->xstart + drawTop * vs->width + _left; 1100 } else { 1101 dst = (byte *)_vm->gdi._textSurface.pixels + drawTop * _vm->gdi._textSurface.pitch + _left; 1102 } 1092 1103 1093 byte *mask = _vm->getMaskBuffer(_left, drawTop, 0); 1094 byte *dst = vs->screenPtr + vs->xstart + drawTop * vs->width + _left; 1095 1096 byte *back = dst; 1104 back = dst; 1097 1105 if (_blitAlso && vs->hasTwoBuffers) { 1098 1106 dst = vs->backBuf + vs->xstart + drawTop * vs->width + _left; 1099 1107 } 1100 1108 1101 1109 if (is2byte) { 1102 drawBits1(vs, dst, charPtr, mask,drawTop, origWidth, origHeight);1110 drawBits1(vs, dst, charPtr, drawTop, origWidth, origHeight); 1103 1111 } else { 1104 1112 byte bpp = *_fontPtr; 1105 drawBitsN(vs, dst, charPtr, mask,bpp, drawTop, origWidth, origHeight);1113 drawBitsN(vs, dst, charPtr, bpp, drawTop, origWidth, origHeight); 1106 1114 } 1107 1115 1108 1116 if (_blitAlso && vs->hasTwoBuffers) { … … 1128 1136 _top -= offsY; 1129 1137 } 1130 1138 1131 void CharsetRendererClassic::drawBitsN(VirtScreen *vs, byte *dst, const byte *src, byte *mask, byte bpp, int drawTop, int width, int height) { 1132 byte maskmask; 1139 void CharsetRendererClassic::drawBitsN(VirtScreen *vs, byte *dst, const byte *src, byte bpp, int drawTop, int width, int height) { 1133 1140 int y, x; 1134 int maskpos;1135 1141 int color; 1136 1142 byte numbits, bits; 1137 bool useMask = (vs->number == kMainVirtScreen && !_ignoreCharsetMask);1138 1143 1139 1144 assert(bpp == 1 || bpp == 2 || bpp == 4 || bpp == 8); 1140 1145 bits = *src++; 1141 1146 numbits = 8; 1142 1147 1143 1148 for (y = 0; y < height && y + drawTop < vs->height; y++) { 1144 maskmask = revBitMask[_left & 7];1145 maskpos = 0;1146 1147 1149 for (x = 0; x < width; x++) { 1148 1150 color = (bits >> (8 - bpp)) & 0xFF; 1149 1151 1150 1152 if (color && y + drawTop >= 0) { 1151 1153 *dst = _vm->_charsetColorMap[color]; 1152 if (useMask) {1153 mask[maskpos] |= maskmask;1154 }1155 1154 } 1156 1155 dst++; 1157 1156 bits <<= bpp; … … 1160 1159 bits = *src++; 1161 1160 numbits = 8; 1162 1161 } 1163 maskmask >>= 1;1164 if (maskmask == 0) {1165 maskmask = 0x80;1166 maskpos++;1167 }1168 1162 } 1169 1163 dst += vs->width - width; 1170 mask += _vm->gdi._numStrips;1171 1164 } 1172 1165 } 1173 1166 1174 void CharsetRendererCommon::drawBits1(VirtScreen *vs, byte *dst, const byte *src, byte *mask, int drawTop, int width, int height) { 1175 byte maskmask; 1167 void CharsetRendererCommon::drawBits1(VirtScreen *vs, byte *dst, const byte *src, int drawTop, int width, int height) { 1176 1168 int y, x; 1177 int maskpos;1178 1169 byte bits = 0; 1179 bool useMask = (vs->number == kMainVirtScreen && !_ignoreCharsetMask);1180 1170 1181 1171 for (y = 0; y < height && y + drawTop < vs->height; y++) { 1182 maskmask = revBitMask[_left & 7];1183 maskpos = 0;1184 1185 1172 for (x = 0; x < width; x++) { 1186 1173 if ((x % 8) == 0) 1187 1174 bits = *src++; … … 1192 1179 *(dst + vs->width + 1) = _shadowColor; 1193 1180 } 1194 1181 *dst = _color; 1195 if (useMask) {1196 mask[maskpos] |= maskmask;1197 if (_dropShadow) {1198 mask[maskpos + _vm->gdi._numStrips] |= maskmask;1199 if (maskmask == 1) {1200 mask[maskpos + 1] |= 0x80;1201 mask[maskpos + _vm->gdi._numStrips + 1] |= 0x80;1202 } else {1203 mask[maskpos] |= (maskmask >> 1);1204 mask[maskpos + _vm->gdi._numStrips] |= (maskmask >> 1);1205 }1206 }1207 }1208 1182 } 1209 1183 dst++; 1210 maskmask >>= 1;1211 if (maskmask == 0) {1212 maskmask = 0x80;1213 maskpos++;1214 }1215 1184 } 1216 1185 1217 1186 dst += vs->width - width; 1218 mask += _vm->gdi._numStrips;1219 1187 } 1220 1188 } 1221 1189 … … 1293 1261 shadow.right = _left + width + 2; 1294 1262 shadow.bottom = _top + height + 2; 1295 1263 1264 Graphics::Surface s; 1296 1265 if (!_ignoreCharsetMask) { 1297 1266 _hasMask = true; 1298 1267 _textScreenID = kMainVirtScreen; 1299 1268 } 1269 if (_ignoreCharsetMask) { 1270 VirtScreen *vs = &_vm->virtscr[kMainVirtScreen]; 1271 s.pixels = vs->screenPtr + vs->xstart + _vm->_screenTop * vs->width; 1272 s.w = vs->width; 1273 s.h = vs->height; 1274 s.pitch = vs->width; 1275 s.bytesPerPixel = 1; 1276 } else { 1277 s = _vm->gdi._textSurface; 1278 } 1300 1279 1301 _current->drawShadowChar( chr, _left, _top, _color, !_ignoreCharsetMask, _curId != 3);1280 _current->drawShadowChar(s, chr, _left, _top, _color, _curId != 3); 1302 1281 _vm->markRectAsDirty(kMainVirtScreen, shadow); 1303 1282 1304 1283 if (_str.left > _left) -
charset.h
RCS file: /cvsroot/scummvm/scummvm/scumm/charset.h,v retrieving revision 2.27 diff -u -d -r2.27 charset.h
69 69 70 70 void restoreCharsetBg(); 71 71 void clearCharsetMask(); 72 bool hasCharsetMask(int left, int top, int right, int bottom);73 72 74 73 virtual void printChar(int chr) = 0; 75 74 … … 88 87 protected: 89 88 byte *_fontPtr; 90 89 91 void drawBits1(VirtScreen *vs, byte *dst, const byte *src, byte *mask,int drawTop, int width, int height);90 void drawBits1(VirtScreen *vs, byte *dst, const byte *src, int drawTop, int width, int height); 92 91 93 92 public: 94 93 CharsetRendererCommon(ScummEngine *vm) : CharsetRenderer(vm) {} … … 102 101 protected: 103 102 int getCharWidth(byte chr); 104 103 105 void drawBitsN(VirtScreen *vs, byte *dst, const byte *src, byte *mask, bytebpp, int drawTop, int width, int height);104 void drawBitsN(VirtScreen *vs, byte *dst, const byte *src, byte bpp, int drawTop, int width, int height); 106 105 107 106 public: 108 107 CharsetRendererClassic(ScummEngine *vm) : CharsetRendererCommon(vm) {} -
costume.cpp
RCS file: /cvsroot/scummvm/scummvm/scumm/costume.cpp,v retrieving revision 1.134 diff -u -d -r1.134 costume.cpp
284 284 285 285 v1.destptr = _outptr + v1.y * _outwidth + v1.x; 286 286 287 v1.mask_ptr = _vm->getMaskBuffer(0, v1.y, 0); 288 v1.imgbufoffs = _vm->gdi._imgBufOffs[_zbuf]; 287 v1.mask_ptr = _vm->getMaskBuffer(0, v1.y, _zbuf); 289 288 290 289 CHECK_HEAP 291 290 … … 350 349 }; 351 350 352 351 #define MASK_AT(xoff) \ 353 (mask && (mask[((v1.x + xoff) / 8) + v1.imgbufoffs] & revBitMask[(v1.x + xoff) & 7]))352 (mask && (mask[((v1.x + xoff) / 8)] & revBitMask[(v1.x + xoff) & 7])) 354 353 #define LINE(c,p) \ 355 354 pcolor = (color >> c) & 3; \ 356 355 if (pcolor) { \ … … 467 466 468 467 do { 469 468 if (_scaleY == 255 || *scaleytab++ < _scaleY) { 470 masked = (y < 0 || y >= _outheight) || (v1.mask_ptr && ( (mask[0] | mask[v1.imgbufoffs])& maskbit));469 masked = (y < 0 || y >= _outheight) || (v1.mask_ptr && (mask[0] & maskbit)); 471 470 472 471 if (color && !masked) { 473 472 // FIXME: Fully implement _shadow_mode.in Sam & Max … … 536 535 len = *src++; 537 536 do { 538 537 if (_scaleY == 255 || cost_scaleTable[_scaleIndexY] < _scaleY) { 539 masked = (y < 0 || y >= _outheight) || (v1.mask_ptr && ( (mask[0] | mask[v1.imgbufoffs])& maskbit));538 masked = (y < 0 || y >= _outheight) || (v1.mask_ptr && (mask[0] & maskbit)); 540 539 541 540 if (color && v1.x >= 0 && v1.x < _outwidth && !masked) { 542 541 *dst = _palette[color]; -
gfx.cpp
RCS file: /cvsroot/scummvm/scummvm/scumm/gfx.cpp,v retrieving revision 2.279 diff -u -d -r2.279 gfx.cpp
199 199 #pragma mark - 200 200 201 201 202 #define CHARSET_MASK_TRANSPARENCY 254 202 203 203 204 Gdi::Gdi(ScummEngine *vm) { 204 205 memset(this, 0, sizeof(*this)); … … 206 207 _roomPalette = vm->_roomPalette; 207 208 if ((vm->_features & GF_AMIGA) && (vm->_version >= 4)) 208 209 _roomPalette += 16; 210 211 _compositeBuf = 0; 212 _textSurface.pixels = 0; 209 213 } 210 214 211 215 void ScummEngine::initScreens(int b, int h) { … … 235 239 236 240 _screenB = b; 237 241 _screenH = h; 242 243 gdi.init(); 244 } 245 246 void Gdi::init() { 247 const int size = _vm->_screenWidth * _vm->_screenHeight; 248 free(_compositeBuf); 249 free(_textSurface.pixels); 250 _compositeBuf = (byte *)malloc(size); 251 _textSurface.pixels = malloc(size); 252 memset(_compositeBuf, CHARSET_MASK_TRANSPARENCY, size); 253 memset(_textSurface.pixels, CHARSET_MASK_TRANSPARENCY, size); 254 255 _textSurface.w = _vm->_screenWidth; 256 _textSurface.h = _vm->_screenHeight; 257 _textSurface.pitch = _vm->_screenWidth; 258 _textSurface.bytesPerPixel = 1; 238 259 } 239 260 261 240 262 void ScummEngine::initVirtScreen(VirtScreenNumber slot, int number, int top, int width, int height, bool twobufs, 241 263 bool scrollable) { 242 264 VirtScreen *vs = &virtscr[slot]; … … 246 268 assert(slot >= 0 && slot < 4); 247 269 248 270 if (_version >= 7) { 249 if (slot == 0&& (_roomHeight != 0))271 if (slot == kMainVirtScreen && (_roomHeight != 0)) 250 272 height = _roomHeight; 251 273 } 252 274 … … 431 453 * specified by top/bottom coordinate in the virtual screen. 432 454 */ 433 455 void Gdi::drawStripToScreen(VirtScreen *vs, int x, int width, int top, int bottom) { 434 byte *ptr; 435 int height; 456 const int height = bottom - top; 436 457 437 458 if (bottom <= top) 438 459 return; … … 442 463 443 464 assert(top >= 0 && bottom <= vs->height); // Paranoia checks 444 465 445 height = bottom - top;446 466 // We don't clip height and width here, rather we rely on the backend to 447 467 // perform any needed clipping. 448 ptr = vs->screenPtr + (x + vs->xstart) + top * vs->width; 449 _vm->_system->copyRectToScreen(ptr, vs->width, x, vs->topline + top - _vm->_screenTop, width, height); 468 const int y = vs->topline + top - _vm->_screenTop; 469 const byte *src = vs->screenPtr + (x + vs->xstart) + top * vs->width; 470 471 assert(_textSurface.pixels); 472 assert(_compositeBuf); 473 Common::Rect r(x, y, x+width, y+height); 474 r.clip(Common::Rect(_textSurface.w, _textSurface.h)); 475 // TODO: is this enough clipping? 476 477 byte *dst = _compositeBuf + x + y * _vm->_screenWidth; 478 const byte *text = (byte *)_textSurface.pixels + x + y * _textSurface.pitch; 479 480 for (int h = 0; h < r.height(); ++h) { 481 for (int w = 0; w < r.width(); ++w) { 482 if (text[w] == CHARSET_MASK_TRANSPARENCY) 483 dst[w] = src[w]; 484 else 485 dst[w] = text[w]; 486 } 487 src += vs->width; 488 dst += _vm->_screenWidth; 489 text += _textSurface.pitch; 490 } 491 492 _vm->_system->copyRectToScreen(_compositeBuf + x + y * _vm->_screenWidth, _vm->_screenWidth, x, y, width, height); 450 493 } 451 494 452 495 #pragma mark - … … 633 676 // be optimized to (rect.right - rect.left) / 8 and 634 677 // thus to width / 8, but that's not the case since 635 678 // we are dealing with integer math here. 636 const int mask_width = ((rect.right + 7) / 8) - (rect.left / 8); 637 638 byte *mask = getMaskBuffer(rect.left, rect.top, 0); 639 640 do { 641 memset(mask, 0, mask_width); 642 mask += gdi._numStrips; 643 } while (--height); 679 const int mask_width = rect.width(); 680 byte *mask = (byte *)gdi._textSurface.pixels + gdi._textSurface.pitch * rect.top + rect.left; 681 while (height--) { 682 memset(mask, CHARSET_MASK_TRANSPARENCY, mask_width); 683 mask += gdi._textSurface.pitch; 684 } 644 685 } 645 686 } else { 646 687 while (height--) { … … 663 704 // restoreBG(), but was changed to only restore those parts which are 664 705 // currently covered by the charset mask. 665 706 666 // Loop over first three virtual screens667 707 VirtScreen *vs = &_vm->virtscr[_textScreenID]; 668 669 708 if (!vs->height) 670 709 return; 671 710 … … 677 716 const byte *backBuf = vs->backBuf + vs->xstart; 678 717 679 718 if (vs->number == kMainVirtScreen) { 680 // Restore from back buffer, but only those parts which are 681 // currently covered by the charset mask. In addition, we 682 // clean out the charset mask 683 684 const int mask_width = _vm->gdi._numStrips; 685 byte *mask = _vm->getMaskBuffer(0, 0, 0); 686 assert(vs->width == 8 * _vm->gdi._numStrips); 687 688 int height = vs->height; 689 while (height--) { 690 for (int w = 0; w < mask_width; ++w) { 691 const byte maskbits = mask[w]; 692 if (maskbits) { 693 copy8PixelsWithMasking(screenBuf + w*8, backBuf + w*8, ~maskbits); 694 mask[w] = 0; 695 } 696 } 697 screenBuf += vs->width; 698 backBuf += vs->width; 699 mask += _vm->gdi._numStrips; 700 } 719 // Clean out the charset mask 720 memset(_vm->gdi._textSurface.pixels, CHARSET_MASK_TRANSPARENCY, _vm->gdi._textSurface.pitch * _vm->gdi._textSurface.h); 701 721 } else { 702 722 // Restore from back buffer 703 723 _vm->blit(screenBuf, backBuf, vs->width, vs->height); … … 713 733 memset(_vm->getResourceAddress(rtBuffer, 9), 0, _vm->gdi._imgBufOffs[1]); 714 734 } 715 735 716 bool CharsetRenderer::hasCharsetMask(int left, int top, int right, int bottom) {717 return _hasMask;718 }719 720 736 byte *ScummEngine::getMaskBuffer(int x, int y, int z) { 721 737 return gdi.getMaskBuffer(x / 8, y, z) + _screenStartStrip; 722 738 } … … 1164 1180 } 1165 1181 } 1166 1182 1167 mask_ptr = getMaskBuffer(x, y);1168 1169 1183 CHECK_HEAP; 1170 1184 if (vs->hasTwoBuffers) { 1171 if (_vm->_charset->hasCharsetMask(sx * 8, y, (sx + 1) * 8, bottom)) { 1172 if (flag & dbClear || !lightsOn) 1173 clear8ColWithMasking(backbuff_ptr, height, mask_ptr); 1174 else 1175 draw8ColWithMasking(backbuff_ptr, bgbak_ptr, height, mask_ptr); 1176 } else { 1177 if (flag & dbClear || !lightsOn) 1178 clear8Col(backbuff_ptr, height); 1179 else 1180 draw8Col(backbuff_ptr, bgbak_ptr, height); 1181 } 1185 if (flag & dbClear || !lightsOn) 1186 clear8Col(backbuff_ptr, height); 1187 else 1188 draw8Col(backbuff_ptr, bgbak_ptr, height); 1182 1189 } 1183 1190 CHECK_HEAP; 1184 1191 … … 1298 1305 vs->bdirty[strip] = bottom; 1299 1306 1300 1307 offs = top * vs->width + vs->xstart + strip * 8; 1301 byte *mask_ptr = _vm->getMaskBuffer(strip * 8, top, 0);1302 1308 bgbak_ptr = vs->backBuf + offs; 1303 1309 backbuff_ptr = vs->screenPtr + offs; 1304 1310 1305 1311 numLinesToProcess = bottom - top; 1306 1312 if (numLinesToProcess) { 1307 1313 if (_vm->isLightOn()) { 1308 if (_vm->_charset->hasCharsetMask(strip * 8, top, (strip + 1) * 8, bottom)) 1309 draw8ColWithMasking(backbuff_ptr, bgbak_ptr, numLinesToProcess, mask_ptr); 1310 else 1311 draw8Col(backbuff_ptr, bgbak_ptr, numLinesToProcess); 1314 draw8Col(backbuff_ptr, bgbak_ptr, numLinesToProcess); 1312 1315 } else { 1313 1316 clear8Col(backbuff_ptr, numLinesToProcess); 1314 1317 } … … 1674 1677 return useOrDecompress; 1675 1678 } 1676 1679 1677 void Gdi::draw8ColWithMasking(byte *dst, const byte *src, int height, byte *mask) {1678 byte maskbits;1679 1680 do {1681 maskbits = *mask;1682 if (maskbits) {1683 copy8PixelsWithMasking(dst, src, maskbits);1684 } else {1685 #if defined(SCUMM_NEED_ALIGNMENT)1686 memcpy(dst, src, 8);1687 #else1688 ((uint32 *)dst)[0] = ((const uint32 *)src)[0];1689 ((uint32 *)dst)[1] = ((const uint32 *)src)[1];1690 #endif1691 }1692 src += _vm->_screenWidth;1693 dst += _vm->_screenWidth;1694 mask += _numStrips;1695 } while (--height);1696 }1697 1698 void Gdi::clear8ColWithMasking(byte *dst, int height, byte *mask) {1699 byte maskbits;1700 1701 do {1702 maskbits = *mask;1703 if (maskbits) {1704 clear8PixelsWithMasking(dst, 0, maskbits);1705 } else {1706 #if defined(SCUMM_NEED_ALIGNMENT)1707 memset(dst, 0, 8);1708 #else1709 ((uint32 *)dst)[0] = 0;1710 ((uint32 *)dst)[1] = 0;1711 #endif1712 }1713 dst += _vm->_screenWidth;1714 mask += _numStrips;1715 } while (--height);1716 }1717 1718 1680 void Gdi::draw8Col(byte *dst, const byte *src, int height) { 1719 1681 do { 1720 1682 #if defined(SCUMM_NEED_ALIGNMENT) -
gfx.h
RCS file: /cvsroot/scummvm/scummvm/scumm/gfx.h,v retrieving revision 1.62 diff -u -d -r1.62 gfx.h
24 24 #define GFX_H 25 25 26 26 #include "common/rect.h" 27 #include "graphics/surface.h" 27 28 28 29 namespace Scumm { 29 30 … … 217 218 218 219 Gdi(ScummEngine *vm); 219 220 221 Graphics::Surface _textSurface; 222 220 223 protected: 224 byte *_compositeBuf; 225 221 226 byte *_roomPalette; 222 227 byte _decomp_shr, _decomp_mask; 223 228 byte _transparentColor; … … 251 256 void decodeStrip3DO(byte *dst, const byte *src, int height, byte transpCheck); 252 257 void decodeStripHE(byte *dst, const byte *src, int height, byte transpCheck); 253 258 254 void draw8ColWithMasking(byte *dst, const byte *src, int height, byte *mask);255 259 void draw8Col(byte *dst, const byte *src, int height); 256 void clear8ColWithMasking(byte *dst, int height, byte *mask);257 260 void clear8Col(byte *dst, int height); 258 261 void decompressMaskImgOr(byte *dst, const byte *src, int height); 259 262 void decompressMaskImg(byte *dst, const byte *src, int height); … … 261 264 void drawStripToScreen(VirtScreen *vs, int x, int w, int t, int b); 262 265 void updateDirtyScreen(VirtScreen *vs); 263 266 264 byte *getMaskBuffer(int x, int y, int z = 0);267 byte *getMaskBuffer(int x, int y, int z); 265 268 266 269 public: 270 void init(); 271 267 272 void drawBitmap(const byte *ptr, VirtScreen *vs, int x, int y, const int width, const int height, 268 273 int stripnr, int numstrip, byte flag, StripTable *table = 0); 269 274 StripTable *generateStripTable(const byte *src, int width, int height, StripTable *table); -
nut_renderer.cpp
RCS file: /cvsroot/scummvm/scummvm/scumm/nut_renderer.cpp,v retrieving revision 1.49 diff -u -d -r1.49 nut_renderer.cpp
239 239 return _chars[c].height; 240 240 } 241 241 242 void NutRenderer::drawShadowChar( int c, int x, int y, byte color, bool useMask, bool showShadow) {243 debug(8, "NutRenderer::drawShadowChar('%c', %d, %d, %d, %d , %d) called", c, x, y, (int)color, useMask, showShadow);242 void NutRenderer::drawShadowChar(const Graphics::Surface &s, int c, int x, int y, byte color, bool showShadow) { 243 debug(8, "NutRenderer::drawShadowChar('%c', %d, %d, %d, %d) called", c, x, y, (int)color, showShadow); 244 244 if (!_loaded) { 245 245 warning("NutRenderer::drawShadowChar() Font is not loaded"); 246 246 return; 247 247 } 248 248 249 VirtScreen *vs = &_vm->virtscr[kMainVirtScreen];250 byte *dst, *mask = NULL;251 252 249 // HACK: we draw the character a total of 7 times: 6 times shifted 253 250 // and in black for the shadow, and once in the right color and position. 254 251 // This way we achieve the exact look as the original CMI had. However, … … 268 265 y += offsetY[i]; 269 266 color = cTable[i]; 270 267 271 if (y >= vs->height || x >= vs->width) {272 continue;273 }274 275 dst = vs->screenPtr + y * vs->width + x + vs->xstart;276 if (useMask)277 mask = _vm->getMaskBuffer(x, y, 0);278 279 268 if (c >= 256 && _vm->_CJKMode) 280 draw2byte( dst, mask, c, x, y - _vm->_screenTop, color);269 draw2byte(s, c, x, y, color); 281 270 else 282 drawChar( dst, mask, (byte)c, x, y - _vm->_screenTop, color);271 drawChar(s, (byte)c, x, y, color); 283 272 284 273 x -= offsetX[i]; 285 274 y -= offsetY[i]; … … 318 307 } 319 308 } 320 309 321 void NutRenderer::drawChar(byte *dst, byte *mask, byte c, int x, int y, byte color) { 322 const int width = MIN(_chars[c].width, _vm->_screenWidth - x); 323 const int height = MIN(_chars[c].height, _vm->_screenHeight - y); 310 void NutRenderer::drawChar(const Graphics::Surface &s, byte c, int x, int y, byte color) { 311 byte *dst = (byte *)s.pixels + y * s.pitch + x; 312 const int width = MIN(_chars[c].width, s.w - x); 313 const int height = MIN(_chars[c].height, s.h - y); 324 314 const byte *src = _chars[c].src; 325 315 const int srcPitch = _chars[c].width; 326 316 327 byte maskmask;328 int maskpos;329 330 317 const int minX = x < 0 ? -x : 0; 331 318 const int minY = y < 0 ? -y : 0; 332 319 … … 336 323 337 324 if (minY) { 338 325 src += minY * srcPitch; 339 dst += minY * _vm->_screenWidth; 340 if (mask) 341 mask += minY * _vm->gdi._numStrips; 326 dst += minY * s.pitch; 342 327 } 343 328 344 329 for (int ty = minY; ty < height; ty++) { 345 maskmask = revBitMask[(x + minX) & 7];346 maskpos = (x%8 + minX) / 8;347 330 for (int tx = minX; tx < width; tx++) { 348 331 if (src[tx] != 0) { 349 332 dst[tx] = color; 350 if (mask)351 mask[maskpos] |= maskmask;352 }353 maskmask >>= 1;354 if (maskmask == 0) {355 maskmask = 0x80;356 maskpos++;357 333 } 358 334 } 359 335 src += srcPitch; 360 dst += _vm->_screenWidth; 361 if (mask) 362 mask += _vm->gdi._numStrips; 336 dst += s.pitch; 363 337 } 364 338 } 365 339 366 void NutRenderer::draw2byte( byte *dst, byte *mask, int c, int x, int y, byte color) {340 void NutRenderer::draw2byte(const Graphics::Surface &s, int c, int x, int y, byte color) { 367 341 if (!_loaded) { 368 342 debug(2, "NutRenderer::draw2byte() Font is not loaded"); 369 343 return; 370 344 } 371 345 346 byte *dst = (byte *)s.pixels + y * s.pitch + x; 372 347 const int width = _vm->_2byteWidth; 373 const int height = MIN(_vm->_2byteHeight, _vm->_screenHeight- y);348 const int height = MIN(_vm->_2byteHeight, s.h - y); 374 349 byte *src = _vm->get2byteCharPtr(c); 375 350 byte bits = 0; 376 351 377 byte maskmask;378 int maskpos;379 380 352 if (height <= 0 || width <= 0) { 381 353 return; 382 354 } 383 355 384 356 for (int ty = 0; ty < height; ty++) { 385 maskmask = revBitMask[x & 7];386 maskpos = 0;387 357 for (int tx = 0; tx < width; tx++) { 388 358 if ((tx & 7) == 0) 389 359 bits = *src++; 390 if (x + tx < 0 || x + tx >= _vm->_screenWidth|| y + ty < 0)360 if (x + tx < 0 || x + tx >= s.w || y + ty < 0) 391 361 continue; 392 362 if (bits & revBitMask[tx & 7]) { 393 363 dst[tx] = color; 394 if (mask) {395 mask[maskpos] |= maskmask;396 }397 }398 399 maskmask >>= 1;400 if (maskmask == 0) {401 maskmask = 0x80;402 maskpos++;403 364 } 404 365 } 405 dst += _vm->_screenWidth; 406 if (mask) 407 mask += _vm->gdi._numStrips; 366 dst += s.pitch; 408 367 } 409 368 } 410 369 -
nut_renderer.h
RCS file: /cvsroot/scummvm/scummvm/scumm/nut_renderer.h,v retrieving revision 1.19 diff -u -d -r1.19 nut_renderer.h
22 22 #define NUT_RENDERER_H 23 23 24 24 #include "common/file.h" 25 #include "graphics/surface.h" 25 26 26 27 namespace Scumm { 27 28 … … 43 44 44 45 int32 decodeCodec44(byte *dst, const byte *src, uint32 length); 45 46 46 void drawChar( byte *dst, byte *mask, byte c, int x, int y, byte color);47 void draw2byte( byte *dst, byte *mask, int c, int x, int y, byte color);47 void drawChar(const Graphics::Surface &s, byte c, int x, int y, byte color); 48 void draw2byte(const Graphics::Surface &s, int c, int x, int y, byte color); 48 49 49 50 public: 50 51 NutRenderer(ScummEngine *vm); … … 54 55 bool loadFont(const char *filename); 55 56 56 57 void drawFrame(byte *dst, int c, int x, int y); 57 void drawShadowChar( int c, int x, int y, byte color, bool useMask, bool showShadow);58 void drawShadowChar(const Graphics::Surface &s, int c, int x, int y, byte color, bool showShadow); 58 59 59 60 int getCharWidth(byte c); 60 61 int getCharHeight(byte c);