Ticket #8157: comi-usagebits.diff
File comi-usagebits.diff, 16.2 KB (added by , 21 years ago) |
---|
-
scummvm/scumm/actor.cpp
diff -urN ScummVM-cvs20030113/scummvm/scumm/actor.cpp ScummVM-cvs20030113+usagebits/scummvm/scumm/actor.cpp
old new 28 28 #include "costume.h" 29 29 #include "resource.h" 30 30 #include "sound.h" 31 #include "usage_bits.h" 31 32 32 33 #include <math.h> 33 34 … … 1100 1101 void Scumm::setActorRedrawFlags(bool fg, bool bg) 1101 1102 { 1102 1103 int i, j; 1103 uint32 bits;1104 1104 1105 1105 if (_fullRedraw) { 1106 1106 for (j = 0; j < NUM_ACTORS; j++) { … … 1112 1112 } 1113 1113 } else { 1114 1114 for (i = 0; i < gdi._numStrips; i++) { 1115 bits = gfxUsageBits[_screenStartStrip + i];1116 if ( bits & 0x3FFFFFFF) {1115 int strip = _screenStartStrip + i; 1116 if (testGfxAnyUsageBits(strip)) { 1117 1117 for (j = 0; j < NUM_ACTORS; j++) { 1118 if ( (bits & (1 << j)) && bits != (uint32)(1 <<j)) {1118 if (testGfxUsageBit(strip, j) && testGfxOtherUsageBits(strip, j)) { 1119 1119 Actor *a = derefActor(j); 1120 1120 if (fg) 1121 1121 a->needRedraw = true; … … 1130 1130 1131 1131 int Scumm::getActorFromPos(int x, int y) 1132 1132 { 1133 uint32 drawbits;1134 1133 int i; 1135 1134 1136 drawbits = gfxUsageBits[x >> 3]; 1137 if (!(drawbits & 0x3FFFFFFF)) 1135 if (!testGfxAnyUsageBits(x >> 3)) 1138 1136 return 0; 1139 1137 for (i = 1; i < NUM_ACTORS; i++) { 1140 1138 Actor *a = derefActor(i); 1141 if ( drawbits & (1 <<i) && !getClass(i, 32) && y >= a->top && y <= a->bottom) {1139 if (testGfxUsageBit(x >> 3, i) && !getClass(i, 32) && y >= a->top && y <= a->bottom) { 1142 1140 return i; 1143 1141 } 1144 1142 } … … 1541 1539 void Scumm::resetActorBgs() 1542 1540 { 1543 1541 Actor *a; 1544 int i; 1545 uint32 onlyActorFlags, bitpos; 1542 int i, j; 1546 1543 1547 1544 for (i = 0; i < gdi._numStrips; i++) { 1548 onlyActorFlags = (gfxUsageBits[_screenStartStrip + i] &= 0x3FFFFFFF);1545 int strip = _screenStartStrip + i; 1549 1546 a = getFirstActor(); 1550 bitpos = 1; 1551 1552 while (onlyActorFlags) { 1553 if (onlyActorFlags & 1 && a->top != 0xFF && a->needBgReset) { 1554 gfxUsageBits[_screenStartStrip + i] ^= bitpos; 1555 1547 for (j = 0; j < NUM_ACTORS; j++) { 1548 if (testGfxUsageBit(strip, j) && a->top != 0xFF && a->needBgReset) { 1549 clearGfxUsageBit(strip, j); 1556 1550 if ((a->bottom - a->top) >= 0) 1557 1551 gdi.resetBackground(a->top, a->bottom, i); 1558 1552 } 1559 bitpos <<= 1;1560 onlyActorFlags >>= 1;1561 1553 a++; 1562 1554 } 1563 1555 } -
scummvm/scumm/akos.cpp
diff -urN ScummVM-cvs20030113/scummvm/scumm/akos.cpp ScummVM-cvs20030113+usagebits/scummvm/scumm/akos.cpp
old new 829 829 if (v1.skip_width <= 0 || _height <= 0) 830 830 return; 831 831 832 _vm->updateDirtyRect(0, x_left, x_right, y_top, y_bottom, 1 <<_dirty_id);832 _vm->updateDirtyRect(0, x_left, x_right, y_top, y_bottom, _dirty_id); 833 833 834 834 y_clipping = ((uint) y_bottom > outheight || y_top < 0); 835 835 … … 949 949 if ((clip_right <= clip_left) || (clip_top >= clip_bottom)) 950 950 return; 951 951 952 _vm->updateDirtyRect(0, clip_left, clip_right + 1, clip_top, clip_bottom + 1, 1 <<_dirty_id);952 _vm->updateDirtyRect(0, clip_left, clip_right + 1, clip_top, clip_bottom + 1, _dirty_id); 953 953 954 954 if (_draw_top > clip_top) 955 955 _draw_top = clip_top; … … 1280 1280 if ((clip_left >= clip_right) || (clip_top >= clip_bottom)) 1281 1281 return; 1282 1282 1283 _vm->updateDirtyRect(0, clip_left, clip_right + 1, clip_top, clip_bottom + 1, 1 <<_dirty_id);1283 _vm->updateDirtyRect(0, clip_left, clip_right + 1, clip_top, clip_bottom + 1, _dirty_id); 1284 1284 1285 1285 if (_draw_top > clip_top) 1286 1286 _draw_top = clip_top; -
scummvm/scumm/costume.cpp
diff -urN ScummVM-cvs20030113/scummvm/scumm/costume.cpp ScummVM-cvs20030113+usagebits/scummvm/scumm/costume.cpp
old new 213 213 _scaleIndexXStep = 1; 214 214 _ypostop = _ypos; 215 215 216 _vm->updateDirtyRect(0, _left, _right + 1, _top, _bottom, 1 <<_dirty_id);216 _vm->updateDirtyRect(0, _left, _right + 1, _top, _bottom, _dirty_id); 217 217 218 218 if (_top >= (int)_outheight || _bottom <= 0) 219 219 return 0; -
scummvm/scumm/gfx.cpp
diff -urN ScummVM-cvs20030113/scummvm/scumm/gfx.cpp ScummVM-cvs20030113+usagebits/scummvm/scumm/gfx.cpp
old new 24 24 #include "actor.h" 25 25 #include "charset.h" 26 26 #include "resource.h" 27 #include "usage_bits.h" 27 28 #include "util.h" 28 29 29 30 … … 295 296 return NULL; 296 297 } 297 298 298 void Scumm::updateDirtyRect(int virt, int left, int right, int top, int bottom, uint32 dirtybits)299 void Scumm::updateDirtyRect(int virt, int left, int right, int top, int bottom, int dirtybit) 299 300 { 300 301 VirtScreen *vs = &virtscr[virt]; 301 302 int lp, rp; 302 uint32 *sp;303 int num;304 303 305 304 if (top > vs->height || left > vs->width || right < 0 || bottom < 0) 306 305 return; … … 314 313 if (right > vs->width) 315 314 right = vs->width; 316 315 317 if (virt == 0 && dirtybit s) {316 if (virt == 0 && dirtybit) { 318 317 lp = (left >> 3) + _screenStartStrip; 319 318 if (lp < 0) 320 319 lp = 0; … … 331 330 if (rp >= 200) 332 331 rp = 200; 333 332 } 334 if (lp <= rp) { 335 num = rp - lp + 1; 336 sp = &gfxUsageBits[lp]; 337 do { 338 *sp++ |= dirtybits; 339 } while (--num); 340 } 333 for (; lp <= rp; lp++) 334 setGfxUsageBit(lp, dirtybit); 341 335 } 342 336 343 337 setVirtscreenDirty(vs, left, top, right, bottom); … … 632 626 633 627 // Redraw any actors "under" the flashlight 634 628 for (i = _flashlight.x/8; i < (_flashlight.x+_flashlight.w)/8; i++) { 635 gfxUsageBits[_screenStartStrip + i] |= 0x80000000;629 setGfxUsageBit(_screenStartStrip + i, USAGE_BIT_DIRTY); 636 630 virtscr[0].tdirty[i] = 0; 637 631 virtscr[0].bdirty[i] = virtscr[0].height; 638 632 } … … 682 676 // Redraw parts of the background which are marked as dirty. 683 677 if (!_fullRedraw && _BgNeedsRedraw) { 684 678 for (i = 0; i != gdi._numStrips; i++) { 685 if ( gfxUsageBits[_screenStartStrip + i] & 0x80000000) {679 if (testGfxUsageBit(_screenStartStrip + i, USAGE_BIT_DIRTY)) { 686 680 redrawBGStrip(i, 1); 687 681 } 688 682 } … … 723 717 { 724 718 int s = _screenStartStrip + start; 725 719 726 assert(s >= 0 && (size_t) s < sizeof(gfxUsageBits) / sizeof(gfxUsageBits[0]));720 assert(s >= 0 && (size_t) s < sizeof(gfxUsageBits) / (3 * sizeof(gfxUsageBits[0]))); 727 721 728 722 for (int i = 0; i < num; i++) 729 gfxUsageBits[s + i] |= 0x80000000;723 setGfxUsageBit(s + i, USAGE_BIT_DIRTY); 730 724 731 725 gdi.drawBitmap(getResourceAddress(rtRoom, _roomResource) + _IM00_offs, 732 726 &virtscr[0], s, 0, virtscr[0].height, s, num, 0); … … 775 769 if (bottom >= height) 776 770 bottom = height; 777 771 778 updateDirtyRect(vs->number, left, right, top - topline, bottom - topline, 0x40000000);772 updateDirtyRect(vs->number, left, right, top - topline, bottom - topline, USAGE_BIT_RESTORED); 779 773 780 774 int offset = (top - topline) * _realWidth + vs->xstart + left; 781 775 backbuff = vs->screenPtr + offset; -
scummvm/scumm/module.mk
diff -urN ScummVM-cvs20030113/scummvm/scumm/module.mk ScummVM-cvs20030113+usagebits/scummvm/scumm/module.mk
old new 27 27 scumm/scummvm.o \ 28 28 scumm/sound.o \ 29 29 scumm/string.o \ 30 scumm/usage_bits.o \ 30 31 scumm/vars.o \ 31 32 scumm/verbs.o 32 33 -
scummvm/scumm/object.cpp
diff -urN ScummVM-cvs20030113/scummvm/scumm/object.cpp ScummVM-cvs20030113+usagebits/scummvm/scumm/object.cpp
old new 25 25 #include "actor.h" 26 26 #include "object.h" 27 27 #include "resource.h" 28 #include "usage_bits.h" 28 29 29 30 bool Scumm::getClass(int obj, int cls) 30 31 { … … 393 394 continue; 394 395 if (tmp < _screenStartStrip || tmp > _screenEndStrip) 395 396 continue; 396 gfxUsageBits[tmp] |= 0x80000000;397 setGfxUsageBit(tmp, USAGE_BIT_DIRTY); 397 398 if (tmp < x) 398 399 x = tmp; 399 400 numstrip++; … … 762 763 763 764 void Scumm::removeObjectFromRoom(int obj) 764 765 { 765 int i, cnt; 766 uint32 *ptr; 766 int i, j; 767 767 768 768 for (i = 1; i < _numLocalObjects; i++) { 769 769 if (_objs[i].obj_nr == (uint16)obj) { 770 770 if (_objs[i].width != 0) { 771 ptr = &gfxUsageBits[_objs[i].x_pos >> 3]; 772 cnt = _objs[i].width >> 3; 773 do { 774 *ptr++ |= 0x80000000; 775 } while (--cnt); 771 for (j = 0; j < _objs[i].width; j++) 772 setGfxUsageBit((_objs[i].x_pos >> 3) + j, USAGE_BIT_DIRTY); 776 773 } 777 774 _BgNeedsRedraw = true; 778 775 return; … … 1619 1616 for (i = left_strip; i <= right_strip; i++) 1620 1617 gdi.resetBackground(top, bottom, i); 1621 1618 1622 updateDirtyRect(0, left, right, top, bottom, 0x40000000);1619 updateDirtyRect(0, left, right, top, bottom, USAGE_BIT_RESTORED); 1623 1620 } 1624 1621 1625 1622 int Scumm::findLocalObjectSlot() -
scummvm/scumm/saveload.cpp
diff -urN ScummVM-cvs20030113/scummvm/scumm/saveload.cpp ScummVM-cvs20030113+usagebits/scummvm/scumm/saveload.cpp
old new 424 424 MKLINE(Scumm, _palManipEnd, sleByte, VER_V10), 425 425 MKLINE(Scumm, _palManipCounter, sleUint16, VER_V10), 426 426 427 // gfxUsageBits grew from 200 to 410 entries :427 // gfxUsageBits grew from 200 to 410 entries. Then 3 * 410 entries: 428 428 MKARRAY_OLD(Scumm, gfxUsageBits[0], sleUint32, 200, VER_V8, VER_V9), 429 MKARRAY(Scumm, gfxUsageBits[0], sleUint32, 410, VER_V10), 429 MKARRAY_OLD(Scumm, gfxUsageBits[0], sleUint32, 410, VER_V10, VER_V13), 430 MKARRAY(Scumm, gfxUsageBits[0], sleUint32, 3 * 410, VER_V14), 430 431 431 432 MKLINE(Scumm, gdi._transparentColor, sleByte, VER_V8), 432 433 MKARRAY(Scumm, _currentPalette[0], sleByte, 768, VER_V8), … … 557 558 } 558 559 } 559 560 561 // Because old savegames won't fill the entire gfxUsageBits[] array, 562 // clear it here just to be sure it won't hold any unforseen garbage. 563 memset(gfxUsageBits, 0, sizeof(gfxUsageBits)); 564 560 565 s->saveLoadEntries(this, mainEntries); 561 566 567 if (!s->isSaving() && savegameVersion < VER_V14) 568 upgradeGfxUsageBits(); 569 562 570 s->saveLoadArrayOf(_actors, NUM_ACTORS, sizeof(_actors[0]), actorEntries); 563 571 564 572 if (savegameVersion < VER_V9) -
scummvm/scumm/saveload.h
diff -urN ScummVM-cvs20030113/scummvm/scumm/saveload.h ScummVM-cvs20030113+usagebits/scummvm/scumm/saveload.h
old new 32 32 VER_V10, 33 33 VER_V11, 34 34 VER_V12, 35 VER_V13 35 VER_V13, 36 VER_V14 36 37 }; 37 38 38 #define CURRENT_VER VER_V1 339 #define CURRENT_VER VER_V14 39 40 40 41 41 42 // To work around a warning in GCC 3.2 (and 3.1 ?) regarding non-POD types, -
scummvm/scumm/scumm.h
diff -urN ScummVM-cvs20030113/scummvm/scumm/scumm.h ScummVM-cvs20030113+usagebits/scummvm/scumm/scumm.h
old new 748 748 void useBompCursor(byte *im, int w, int h); 749 749 750 750 751 void updateDirtyRect(int virt, int left, int right, int top, int bottom, uint32 dirtybits);751 void updateDirtyRect(int virt, int left, int right, int top, int bottom, int dirtybit); 752 752 void setDirtyRange(int slot, int a, int height); 753 753 void drawDirtyScreenParts(); 754 754 void updateDirtyScreen(int slot); … … 810 810 byte *_palManipPalette; 811 811 byte *_palManipIntermediatePal; 812 812 813 /* For each screen strip, gfxUsageBits contains a bitmask. 814 * The lower 30 bits each correspond to one actor and signify if any part 815 * of that actor is currently contained in that strip. 816 * If the left most bit is set, the strip (background) is dirty needs to be redrawn. 813 /* For each of the 410 screen strips, gfxUsageBits contains a 814 * bitmask. The lower 80 bits each correspond to one actor and 815 * signify if any part of that actor is currently contained in 816 * that strip. 817 * 818 * If the leftmost bit is set, the strip (background) is dirty 819 * needs to be redrawn. 820 * 821 * The second leftmost bit is set by removeBlastObject() and 822 * restoreBG(), but I'm not yet sure why. 817 823 */ 818 uint32 gfxUsageBits[410 ];824 uint32 gfxUsageBits[410 * 3]; 819 825 820 826 byte *_shadowPalette; 821 827 int _shadowPaletteSize; … … 924 930 uint32 fileReadDword() { return _fileHandle.readUint32BE(); } 925 931 #endif 926 932 933 void upgradeGfxUsageBits(); 934 void setGfxUsageBit(int strip, int bit); 935 void clearGfxUsageBit(int strip, int bit); 936 bool testGfxUsageBit(int strip, int bit); 937 bool testGfxAnyUsageBits(int strip); 938 bool testGfxOtherUsageBits(int strip, int bit); 939 927 940 /* Scumm Vars */ 928 941 byte VAR_KEYPRESS; 929 942 byte VAR_EGO; -
scummvm/scumm/usage_bits.cpp
diff -urN ScummVM-cvs20030113/scummvm/scumm/usage_bits.cpp ScummVM-cvs20030113+usagebits/scummvm/scumm/usage_bits.cpp
old new 1 /* ScummVM - Scumm Interpreter 2 * Copyright (C) 2001 Ludvig Strigeus 3 * Copyright (C) 2001-2003 The ScummVM project 4 * 5 * This program is free software; you can redistribute it and/or 6 * modify it under the terms of the GNU General Public License 7 * as published by the Free Software Foundation; either version 2 8 * of the License, or (at your option) any later version. 9 10 * This program is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU General Public License for more details. 14 15 * You should have received a copy of the GNU General Public License 16 * along with this program; if not, write to the Free Software 17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 */ 19 20 #include "stdafx.h" 21 #include "scumm.h" 22 #include "usage_bits.h" 23 24 void Scumm::upgradeGfxUsageBits() 25 { 26 int i; 27 28 for (i = 409; i >= 0; i--) { 29 bool dirty_bit = gfxUsageBits[i] & 0x80000000; 30 bool restored_bit = gfxUsageBits[i] & 0x40000000; 31 32 gfxUsageBits[3 * i] = gfxUsageBits[i] & 0x3FFFFFFF; 33 if (dirty_bit) 34 setGfxUsageBit(i, USAGE_BIT_DIRTY); 35 if (restored_bit) 36 setGfxUsageBit(i, USAGE_BIT_RESTORED); 37 } 38 } 39 40 void Scumm::setGfxUsageBit(int strip, int bit) 41 { 42 gfxUsageBits[3 * strip + bit / 32] |= (1 << (bit - 1)); 43 } 44 45 void Scumm::clearGfxUsageBit(int strip, int bit) 46 { 47 gfxUsageBits[3 * strip + bit / 32] &= ~(1 << (bit - 1)); 48 } 49 50 bool Scumm::testGfxUsageBit(int strip, int bit) 51 { 52 return (gfxUsageBits[3 * strip + bit / 32] & (1 << (bit - 1))) != 0; 53 } 54 55 bool Scumm::testGfxAnyUsageBits(int strip) 56 { 57 // Exclude the DIRTY and RESTORED bits from the test 58 uint32 bitmask[3] = { 0x3FFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF }; 59 int i; 60 61 for (i = 0; i < 3; i++) 62 if (gfxUsageBits[3 * strip + i] & bitmask[i]) 63 return true; 64 65 return false; 66 } 67 68 bool Scumm::testGfxOtherUsageBits(int strip, int bit) 69 { 70 // Don't exclude the DIRTY and RESTORED bits from the test 71 uint32 bitmask[3] = { 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF }; 72 int i; 73 74 bitmask[bit / 32] &= ~(1 << (bit - 1)); 75 76 for (i = 0; i < 3; i++) 77 if (gfxUsageBits[3 * strip + i] & bitmask[i]) 78 return true; 79 80 return false; 81 } -
scummvm/scumm/usage_bits.h
diff -urN ScummVM-cvs20030113/scummvm/scumm/usage_bits.h ScummVM-cvs20030113+usagebits/scummvm/scumm/usage_bits.h
old new 1 /* ScummVM - Scumm Interpreter 2 * Copyright (C) 2001 Ludvig Strigeus 3 * Copyright (C) 2001-2003 The ScummVM project 4 * 5 * This program is free software; you can redistribute it and/or 6 * modify it under the terms of the GNU General Public License 7 * as published by the Free Software Foundation; either version 2 8 * of the License, or (at your option) any later version. 9 10 * This program is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU General Public License for more details. 14 15 * You should have received a copy of the GNU General Public License 16 * along with this program; if not, write to the Free Software 17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 */ 19 20 #ifndef USAGE_BITS_H 21 #define USAGE_BITS_H 22 23 enum { 24 USAGE_BIT_DIRTY = 96, 25 USAGE_BIT_RESTORED = 95 26 }; 27 28 #endif